#!/bin/csh
#PBS -N postproc
#PBS -j oe
#PBS -o postproc.log
#PBS -W umask=027
#PBS -l application=home-grown
#PBS -l select=1:ncpus=1:mpiprocs=1
#PBS -l place=scatter:excl
#PBS -l walltime=00:30:00
#PBS -A ONRDC10855122
#PBS -q debug
#
set echo
# --- Get the vertical streamfunction in Z-coord for the Global and Atlantic Basin in Netcdf
# --- Get the Northward Heat/freshwater transport GLobal and Atlantic in Netcdf
# --- Get the Global Barotropic streamfunction in Netcdf
#

#
# --- D,y,d select the archive files.
setenv CDF_TITLE        "HYCOM GLBt0.72"
setenv CDF_INST         "Naval Research Laboratory"

#
# --- D,y,d select the archive files.
#

setenv IDM 500
setenv JDM 382
setenv KDM 41
#
setenv Y01 "011"
setenv G GLBt0.72/expt_06.0/data/
setenv P /p/home/abozec/hycom/POST_PROC/GLBt0.72/STAND-ALONE/
setenv D /p/work1/abozec/hycom/${G}/
setenv O ${D}/netcdf/
setenv E 060

cd ${D}/
ln -s ../regional* .

## regional mask for the Atlantic
touch regional.mask.a regional.mask.b
if (-z regional.mask.a) then
  /bin/rm regional.mask.a
  ln -s /p/work1/abozec/hycom/GLBt0.72/topo/regional.atlmask.strmf.a regional.mask.a
endif
if (-z regional.mask.b) then
  /bin/rm regional.mask.b
  ln -s /p/work1/abozec/hycom/GLBt0.72/topo/regional.atlmask.strmf.b regional.mask.b
endif

setenv YY `echo ${Y01} | awk '{printf("%04.0f", $1+1900)}'`
@ y=2000
while (${y} <= 2006)

   setenv CDF032  ${O}/${E}_archm.${y}_strmf_test.nc

   /bin/rm   $CDF032
/p/home/abozec/hycom/ALL4/archive/src_2.2.35_core/archv2strmf_nc << E-o-D
${D}/${E}_archm.${y}.a
NetCDF
 000    'iexpt ' = experiment number x10 (000=from archive file)
   3    'yrflag' = days in year flag (0=360J16,1=366J16,2=366J01,3-actual)
 ${IDM} 'idm   ' = longitudinal array size
 ${JDM} 'jdm   ' = latitudinal  array size
 ${KDM} 'kdm   ' = number of layers
    1   'iorign' = i-origin of sampled subregion
    1   'jorign' = j-origin of sampled subregion
    0   'idmp  ' = i-extent of sampled subregion (<=idm; 0 implies idm)
    0   'jdmp  ' = j-extent of sampled subregion (<=jdm; 0 implies jdm)
    0   'uvflx ' = use uvflx if present (1=T;0=F)
  115   'kz    ' = number of depths to sample
   0.00 'z     ' = sample depth    1
   5.00 'z     ' = sample depth    2
  10.00 'z     ' = sample depth    3
  15.00 'z     ' = sample depth    4
  20.00 'z     ' = sample depth    5
  25.00 'z     ' = sample depth    6
  30.00 'z     ' = sample depth    7
  35.00 'z     ' = sample depth    8
  40.00 'z     ' = sample depth    9
  45.00 'z     ' = sample depth   10
  50.00 'z     ' = sample depth   11
  55.00 'z     ' = sample depth   12
  60.00 'z     ' = sample depth   13
  65.00 'z     ' = sample depth   14
  70.00 'z     ' = sample depth   15
  75.00 'z     ' = sample depth   16
  80.00 'z     ' = sample depth   17
  85.00 'z     ' = sample depth   18
  90.00 'z     ' = sample depth   19
  95.00 'z     ' = sample depth   20
 100.00 'z     ' = sample depth   21
 115.00 'z     ' = sample depth   22
 130.00 'z     ' = sample depth   23
 145.00 'z     ' = sample depth   24
 160.00 'z     ' = sample depth   25
 175.00 'z     ' = sample depth   26
 190.00 'z     ' = sample depth   27
 205.00 'z     ' = sample depth   28
 220.00 'z     ' = sample depth   29
 235.00 'z     ' = sample depth   30
 250.00 'z     ' = sample depth   31
 265.00 'z     ' = sample depth   32
 280.00 'z     ' = sample depth   33
 295.00 'z     ' = sample depth   34
 310.00 'z     ' = sample depth   35
 325.00 'z     ' = sample depth   36
 340.00 'z     ' = sample depth   37
 355.00 'z     ' = sample depth   38
 370.00 'z     ' = sample depth   39
 385.00 'z     ' = sample depth   40
 400.00 'z     ' = sample depth   41
 430.00 'z     ' = sample depth   42
 460.00 'z     ' = sample depth   43
 490.00 'z     ' = sample depth   44
 520.00 'z     ' = sample depth   45
 550.00 'z     ' = sample depth   46
 580.00 'z     ' = sample depth   47
 610.00 'z     ' = sample depth   48
 640.00 'z     ' = sample depth   49
 670.00 'z     ' = sample depth   50
 700.00 'z     ' = sample depth   51
 730.00 'z     ' = sample depth   52
 760.00 'z     ' = sample depth   53
 790.00 'z     ' = sample depth   54
 820.00 'z     ' = sample depth   55
 850.00 'z     ' = sample depth   56
 880.00 'z     ' = sample depth   57
 910.00 'z     ' = sample depth   58
 940.00 'z     ' = sample depth   59
 970.00 'z     ' = sample depth   60
1000.00 'z     ' = sample depth   61
1050.00 'z     ' = sample depth   62
1100.00 'z     ' = sample depth   63
1150.00 'z     ' = sample depth   64
1200.00 'z     ' = sample depth   65
1250.00 'z     ' = sample depth   66
1300.00 'z     ' = sample depth   67
1350.00 'z     ' = sample depth   68
1400.00 'z     ' = sample depth   69
1450.00 'z     ' = sample depth   70
1500.00 'z     ' = sample depth   71
1550.00 'z     ' = sample depth   72
1600.00 'z     ' = sample depth   73
1650.00 'z     ' = sample depth   74
1700.00 'z     ' = sample depth   75
1800.00 'z     ' = sample depth   76
1900.00 'z     ' = sample depth   77
2000.00 'z     ' = sample depth   78
2100.00 'z     ' = sample depth   79
2200.00 'z     ' = sample depth   80
2300.00 'z     ' = sample depth   81
2400.00 'z     ' = sample depth   82
2500.00 'z     ' = sample depth   83
2600.00 'z     ' = sample depth   84
2700.00 'z     ' = sample depth   85
2800.00 'z     ' = sample depth   86
2900.00 'z     ' = sample depth   87
3000.00 'z     ' = sample depth   88
3100.00 'z     ' = sample depth   89
3200.00 'z     ' = sample depth   90
3300.00 'z     ' = sample depth   91
3400.00 'z     ' = sample depth   92
3500.00 'z     ' = sample depth   93
3600.00 'z     ' = sample depth   94
3700.00 'z     ' = sample depth   95
3800.00 'z     ' = sample depth   96
3900.00 'z     ' = sample depth   97
4000.00 'z     ' = sample depth   98
4100.00 'z     ' = sample depth   99
4200.00 'z     ' = sample depth  100
4300.00 'z     ' = sample depth  101
4550.00 'z     ' = sample depth  102
4800.00 'z     ' = sample depth  103
5050.00 'z     ' = sample depth  104
5300.00 'z     ' = sample depth  105
5550.00 'z     ' = sample depth  106
5800.00 'z     ' = sample depth  107
6050.00 'z     ' = sample depth  108
6300.00 'z     ' = sample depth  109
6550.00 'z     ' = sample depth  110
6800.00 'z     ' = sample depth  111
7000.00 'z     ' = sample depth  112
7500.00 'z     ' = sample depth  113
8000.00 'z     ' = sample depth  114
8500.00 'z     ' = sample depth  115
   0    'uvfio ' = u-flux/vflux I/O unit (0 no I/O)
   0    'uvlio ' = u-transport  I/O unit (0 no I/O)
  32    'vvlio ' = Vert. Streamfunction  I/O unit (0 no I/O)
   0    'bsfio ' = barotropic strmfn.  I/O unit (0 no I/O)
   0    'vbtio ' = V-Barot. transport  I/O unit (0 no I/O)
   0    'httio ' = heat transport      I/O unit (0 no I/O)
   0    'sltio ' = salt transport      I/O unit (0 no I/O)
E-o-D
@ y++
    end

end

