[gradsusr] problem in looping with sdfwrite to generate multiple netcdf files

pankaj kumar pankajqumar at yahoo.com
Thu Feb 13 06:12:39 EST 2014


Hi,

It's my deepest request to whosoever working to write 4-dimensional netcdf data using grads since sdfwrite is unable to generate 4-D netcdf data. My global netcdf data is in 4-D format with each yearly file has 12 time and 15 vertical points. I am trying to save errenous data from these files into netcdf format in 4-dimensions. I have tried many methods of looping in z and t scales. Although loops in z and t scales are running properly as grads displays sorted data for each time and each layer, the output file only saves data in netcdf format for final time and final layer which is 2-dimensional data. It is clear that the sdfwrite command does not allow one to write out more than one variable to a file (source: grads documentation on sdfwrite) so the sdfwrite generates output for one time and one layer only.


However, can someone tell me how to write a loop in grads to generate multiple netcdf files using sdfwrite command for each single time and each layer from my 4-D netcdf data? Once number of netcdf files are generated with data for different time and layers, I hope sdfwrite allows to concatenate all files for multiple layers first and then for long time series.

Here, I have tried a looping to produce multiple files for each layer and each time but it hasn't worked.
_____________________________________________________________________________________

'set lon 0 360'
'set lat -90 90'


'set sdfwrite -4d flt -nc4 data_'z'_'t'.nc'
'sdfwrite var'

t=1
 while(t<=12)
  'set t 't

   z=1
    while(z<=15)
     'set z 'z

#  rec=read(filename.nc)
# IO = sublin(rec,1)

# if (IO = 0) 

#a = subwrd(rec,2) 

# endif

# 'sdfopen 'a'' 

# say '' 

# say ' Filename: 'a'' 

# say ' File no: 'z'_'t''


            'define var = var'
            'd var'
         #'set sdfwrite -4d flt -nc4 data-sort_'z'_'t'.nc'
         #'sdfwrite var'

    z=z+1
   endwhile
 t=t+1
endwhile


Thank you for your help and support here.
Regards
Pankaj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140213/bb97e8c4/attachment.html 


More information about the gradsusr mailing list