Create grads-compatible (fortran-unformatted) binary files with perl

Jennifer Adams jma at COLA.IGES.ORG
Thu May 21 20:21:40 EDT 2009


On May 21, 2009, at 7:58 PM, P.R. wrote:

> Im trying to setup a perl script to create a grads binary file.
>
> Based on the documentation, the grads binary files are in sequential
> (unformatted) fortran binary format.
>
> So, they should contain a record header, record, & record trailer.
Grads will handle binary data in sequential or stream format. The
stream format has no header or trailer. It is easier to just write out
stream and skip the headers and trailers -- why make your file
unnecessarily large?

>
>
> Example for a record containing a 32bit single-precision float
> ('REAL*4' in
> fortan).
> 4byte/32bit header:
> Value='4'
>
> 4byte/32bit record:
> Value='3.23343'
>
> 4byte/32bit trailer:
> Value='4'
>
> I have a few questions on how GrADS reads (fortran unformatted) binary
> files:
>
> 1) how many bytes should the record header&trailer be?
> Is this platform-specific, or does GrADS expect a specific size?
The header and trailer for sequential format are always 4 bytes.
>
>
> 2) grads expects each record to contain a REAL (float) value, correct?
yes
>
>
> 3) if question #2 is correct, does grads expect "REAL" values in the
> binary
> file to be 4 bytes or 8?
4 bytes per value

>
> So, if my data is a 'double' data-type, should it be forced to
> 'REAL*8',
> i.e. 64bit double-precision float?
> Or, does it need to be 'REAL*4', 32bit single precision float?
you have to convert your REAL*8 doubles to REAL*4 floats and then
write them out. Although internally GrADS converts everything to
double, we don't yet have an interface for reading (or writing out)
double precision binary data.

Jennifer

>
>
> Please help,
> Thanks,
> P.Romero

--
Jennifer M. Adams
IGES/COLA
4041 Powder Mill Road, Suite 302
Calverton, MD 20705
jma at cola.iges.org



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20090521/108b6d8d/attachment.html 


More information about the gradsusr mailing list