Problem with self-made binary files

Andrea Storto andrea.storto at TISCALI.IT
Tue Jan 25 03:54:02 EST 2005

It doesn't seem to be the problem:
GrADS still does not work, and I get the same message
(Was expecting 2 records, found 0)
Thank you anyway!


----- Original Message -----
From: Charles Seman
Sent: Monday, January 24, 2005 11:15 PM
Subject: Re: Problem with self-made binary files

Dear Andrea,

Could you try:

      WRITE (7,REC=1) U
      WRITE (7,REC=2) V

for unformatted output (number of elements are specified in your "open"
statement)?  This works for our codes... If you had an NDZ, then put the
write statements in a vertical loop, and assign data to 2D "U" and "V" for
each level (or modify the RECL and array dimensions).

I hope this helps,

Andrea Storto wrote:
Hi everybody,
I'm trying to create binary files for GrADS with Fortran:

      PARAMETER (NDY=16,NDX=116)
C  Reading from files:

      do 2 i=1,NDY
          read(3,*) (U(i,k),k=1,NDX)
          read(4,*) (V(i,k),k=1,NDX)
2     continue
C  Writing on standard output to test:

      WRITE (*,*) 'U variables:'
      WRITE (*,*) ((U(K,L),L=1,NDX),K=1,NDY)
      WRITE (*,*) '   '
      WRITE (*,*) 'V variables:'
      WRITE (*,*) ((V(K,L),L=1,NDX),K=1,NDY)

C  Writing binary files:

      OPEN (7,FILE='uv_uhiX1.dat' ,FORM='UNFORMATTED',
C For Linux pgf77 just change the last row in:

      WRITE (7,REC=1) ((U(K,L),L=1,NDX),K=1,NDY)
      WRITE (7,REC=2) ((V(K,L),L=1,NDX),K=1,NDY)

and ctl file songs like:

 dset   ^uv_uhiX1.dat
 title   Prova
 undef    1e+20
 xdef          16 linear   1.206897       2.413793
 ydef         116 linear   1.031250       2.062500
 zdef      1 levels 0
 tdef      1 linear 0Z2jan1987 1dy
 vars      2
    u 1 33,100 Eastward wind [m/s]
    v 1 34,100 Northward wind [m/s]

I compiled with Visual Fortran: OK
Built .exe: OK
Verified Standard output and file existence: OK
Tested the same command :
       OPEN (7,FILE='uv_uhiX1.dat' ,FORM='UNFORMATTED',
       WRITE (7,REC=1) ((U(K,L),L=1,NDX),K=1,NDY)
       WRITE (7,REC=2) ((V(K,L),L=1,NDX),K=1,NDY)
: OK for smaller matrices and manual initialization
for U and V(!!!)
Tested ctl structure: OK
But when I type "open uv_uhiX1.ctl" I get:

Scanning description file:    uv_uhiX1.ctl
Open Error: Unexpected EOF reading variables
Was expecting 2 records. Found 0.
  The data file was not opened.

I don't know why I get this messsage, since I used the same
fortran code (but initializing variables not from file but in Fortran
Moreover, I can see in standard output correct values for my variables
(even if some of them have exponential notation, others fixed notation)
Have you ever had my problem?
Thank you in advance

Andrea Storto


 Charles Seman                                Charles.Seman at
 Geophysical Fluid Dynamics Laboratory / NOAA
 Princeton University                          voice: (609) 452-6547
 P.O. Box 308                                    fax: (609) 987-5063
 Princeton, NJ  08542-0308  

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."

More information about the gradsusr mailing list