Again, fwrite problem

Mark Wang gemark at GEORGE2.AS.NTU.EDU.TW
Mon Mar 28 12:10:03 EST 2005


Hi all
I am trying to deal with the MM5v3 output data through GrADSv1.8SL11.
The MM5v3 programs are on Linux, and GrADS and Fortran77 are on DEC.
First, I can correctly use fwrite to convert MM5v3 data to GrADS output.
(Compare with MM5toGrADS and self-writing GrADS ctl files.)
But when I try to write a Fortran77 program to read the GrADS output,
I met a problem.

The xdef of self-writing ctl is:
xdef  41 linear 121.989  0.2027
ydef  32 linear  24.9028 0.2027

After execute GrADS, and open that ctl file.
The result of q dims is:
X is varying   Lon = 121.989 to 130.097   X = 1.00003 to 41.0001
Y is varying   Lat = 24.9028 to 31.1865   Y = 1.00001 to 32

Then I write a gs file,to fwrite variables without set any x or y dimension.
'open model_all.ctl'
'set fwrite model_all.bin'
tt=1
while(tt<=25)
 'set gxout fwrite';'set t 'tt
 level=1
 while(level<=20)
  'd h(z='level')'
 level=level+1
 endwhile
tt=tt+1
endwhile
'disable fwrite'

The message of fwrite is:
Wrote 1312 elements to grads.fwrite as Stream Little_Endian

The Fortran77 program is:
open(21,file='grads.fwrite',status='old',form='unformatted',recl=41*32)
do t=1,tt
 do k=1,L
  inum=k+(t-1)*L
  read(21,rec=inum) ((data(i,j,k),i=1,41),j=1,32)
 enddo
enddo

The program of Fortran77 is correct.
But when I execute the program, some kinds of errors happen:
forrtl: Not a typewriter
forrtl: severe(39): error during read, unit 21, file grads.fwrite

If the variables, times of fwrite data increase, the error become:
forrtl: Bad file number
forrtl: severe(39): error during read, unit 21, file grads.fwrite

All of these errors happen at the end of grads.fwrite file.
Could anyone help me solving this problem?
Thank you very much!

Mark



More information about the gradsusr mailing list