Problem with self-made binary files

Andrea Storto andrea.storto at TISCALI.IT
Mon Jan 24 16:07:09 EST 2005


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

...
      PARAMETER (NDY=16,NDX=116)
...
      REAL U(NDY,NDX)
      REAL V(NDY,NDX)
...
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',
     &ACCESS='DIRECT',RECL=NDY*NDX)
C For Linux pgf77 just change the last row in:
C   &ACCESS='DIRECT',RECL=NDY*NDX*4)

      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)
      CLOSE(7)
...

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]
 endvars

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',
     &ACCESS='DIRECT',RECL=NDY*NDX)
       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)
       CLOSE(7)
: 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 itself!!!).
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20050124/a59b8dc7/attachment.html 


More information about the gradsusr mailing list