[gradsusr] how to convert netcdf file to grads data file

Jeff Duda jeffduda319 at gmail.com
Tue Jul 24 15:30:18 EDT 2012


If by .dat you mean the gridded binary that is standard for grid files,
then yes you need to convert.  Some netCDF files need full descriptor files
to read, while some can be read using the sdfopen business.  So they
probably are not the same.  To convert, you'll have to extract the values
from the netcdf file, then use Fortran to write out the values to the
binary file.  I have recently begun doing something similar myself, so it's
fresh in my mind.  You need to open the file using these parameters:

OPEN(17,file=file_name,STATUS="unknown",form="unformatted",access="direct",recl=4*I_size*J_size)
   WRITE(17,rec=1) ((field(i,j), j = row_min, row_max), i = col_min,
col_max)

Where I_size and J_size in this example are the number of x and y points in
your array that you want to write.  The WRITE statement writes the values
to the file, but you have to be specific about the rec= part.  I think you
use successive record numbers for each vertical level, time level, and
ensemble member (if you are using those dimensions).  Otherwise each
horizontal cross section works as just one record.  Also, as far as I know,
this example only writes one array to a file.  To write additional arrays I
think you'd have to increase the recl value and increment the rec number in
the WRITE statement.

Jeff

On Tue, Jul 24, 2012 at 1:07 PM, Kishore Babu <kishoreragi at gmail.com> wrote:

> Dear Jeff,
>
>    Yes, we can open .nc file with sdfopen in GrADS.  But, I need .dat file
> in other applications. Do you think .nc file and .dat files are same?
> netcdf file is self-described and .dat file needs descriptor file. Is it?
>
> Kishore
>
> On Tue, Jul 24, 2012 at 11:26 PM, Jeff Duda <jeffduda319 at gmail.com> wrote:
>
>> You don't need to convert.  You can use SDFOPEN or write a control file
>> to open the netcdf file directly.  See this page for more information and
>> instructions: http://www.iges.org/grads/gadoc/SDFdescriptorfile.html
>>
>> Jeff Duda
>>
>> On Tue, Jul 24, 2012 at 12:40 PM, Kishore Babu <kishoreragi at gmail.com>wrote:
>>
>>> Dear GrADS user,
>>>
>>>   I am quit new in data handling. I have netcdf files and I need to
>>> convert to .dat files. Could anyone please provide me  a command to convert
>>> .nc to .dat files?
>>>
>>> Thank you in advance,
>>>
>>> yours sincerely,
>>>
>>> Kishore
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>>
>>>
>>
>>
>> --
>> Jeff Duda
>> Graduate research assistant
>> University of Oklahoma School of Meteorology
>> Center for Analysis and Prediction of Storms
>>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Graduate research assistant
University of Oklahoma School of Meteorology
Center for Analysis and Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20120724/4f9d0197/attachment-0003.html 


More information about the gradsusr mailing list