#! /bin/csh

set ydir = `cat list-tmp`
set nydir = `cat list-tmp | wc -l`

set count = 1
#while ($count <= 1)
while ($count <= $nydir)

cat > CVR$ydir[$count].ctl << EOF
***output grads ctl file for imt_pb***
dset ^CVR$ydir[$count].grd
title p-plane result
undef -9999.0
xdef  250 linear  291.443    0.019
ydef  100 levels
  17.307  17.326  17.344  17.362  17.380  17.398  17.416  17.434  17.452  17.470
  17.488  17.506  17.524  17.542  17.560  17.578  17.596  17.614  17.633  17.651
  17.669  17.687  17.705  17.723  17.741  17.759  17.777  17.795  17.813  17.831
  17.849  17.867  17.885  17.903  17.921  17.939  17.957  17.975  17.993  18.011
  18.029  18.047  18.065  18.083  18.101  18.119  18.137  18.155  18.173  18.191
  18.209  18.227  18.245  18.263  18.281  18.299  18.317  18.335  18.353  18.371
  18.389  18.407  18.425  18.443  18.461  18.479  18.497  18.514  18.532  18.550
  18.568  18.586  18.604  18.622  18.640  18.658  18.676  18.694  18.712  18.730
  18.748  18.766  18.784  18.801  18.819  18.837  18.855  18.873  18.891  18.909
  18.927  18.945  18.963  18.981  18.999  19.016  19.034  19.052  19.070  19.088
zdef   16 levels  1000.00  975.00  950.00  925.00  900.00  850.00  800.00  700.00  600.00  500.00  400.00  300.00  250.00  200.00  150.00  100.00
tdef 12 linear 00z01JAN$ydir[$count]   1mo
vars    1
CVR     16 99 CVR
endvars
***end of ctl file***
EOF

cdo -f nc import_binary CVR$ydir[$count].ctl cvrnhm$ydir[$count].nc
@ count = $count + 1
end
