fortran/c interface problems?

Patrick ptripp at UCSD.EDU
Mon Oct 16 20:42:31 EDT 2006


Hi Barry,

Fortran does write binary data differently than C. Fortran writes data as
records, with an appropriate record header for each. C simply writes the
data in a stream with no header.
Grads works perfectly well with Fortran binary data, I'm unsure about how
well it works with C binary data.

Depending on how you write the array data in Fortran, the records will be
interpreted and written differently. For example: if you write each array
element separately in a loop, each array element will have a record header.
If you write all elements of an array dimension using a ':' then that array
dimension will be written as a single record.

Also, there may be a problem with the index or .ctl file. It's really
difficult to say what the problem is without those. Grads shouldn't be
adding a zero, it could be the array dimensions are off by 1 if it is only a
single data point that is causing problems. Fortran array dimensions begin
at 1, C begins at 0.

Hope this has provided some insight.

- Patrick

----- Original Message -----
From: "Barry" <Barry.E.Schwartz at NOAA.GOV>
To: <GRADSUSR at LIST.CINECA.IT>
Sent: Monday, October 16, 2006 10:49 AM
Subject: fortran/c interface problems?


> Hi all
>
> I am new so excuse me if someone has already asked this question;
> I have not gone through the index yet.
>
> I have written code to create my own binary data set in FORTRAN.
> When grads reads it to display the data, I get a zero value ADDED
> to my data so when I contour my field, it has a bullseye in it
> trying to draw for the zero. The zero is absolutely NOT on my
> data that I am writing out- I have double and triple checked this!
> When I plot a 3_D array, the zero moves around in a predictable manner.
>
> My feeling is that fortran writes binary files differently than C with
> an extra few bytes (header)- that grads, probably written in c,
> reads and interprets differently. Is there a  way around this that
> I failed to read about in the documentation?
>
> If anyone can help, it would be greatly appreciated.
> I like grads alot but I need to fix this to make it useful.
>
> Thanks,
>
> Barry



More information about the gradsusr mailing list