Compiling f77 program with gfortran but not successful

Muhammad Dogar muhammad.dogar@kaust.edu.sa
Mon Feb 20 15:40:00 GMT 2012


Dear Sir,

I am trying to read following text data using gfortran compiler with
the DEC FORTRAN script given at the very end, but it gives me errors
(although program/script is totally fine). Could you please try at
your side and suggest me what's going wrong. Else you can suggest me
how can I read following text data and write it in binary format as in
my script.


Year   Month  Stid    Lat    Lon    Rainfall
1980     1     QQQ    34.3  -85.5    123.3
1980     1     RRR    44.2  -84.5     87.1
1980     1     SSS    22.4  -83.5    412.8
1980     1     TTT    33.4  -82.5     23.3
1980     2     QQQ    34.3  -85.5    145.1
1980     2     RRR    44.2  -84.5    871.4
1980     2     SSS    22.4  -83.5    223.1
1980     2     TTT    33.4  -82.5     45.5

A sample DEC FORTRAN program to write this data set in GrADS format is
given below. Note that the OPEN statement is set to write a stream
data set. This option may not not available with every compiler.

       CHARACTER*8 STID
       OPEN (8,NAME='rain.ch')
       OPEN (10,NAME='rain.dat',FORM='UNFORMATTED',RECORDTYPE='STREAM')
       IFLAG = 0
C  Read and Write
10     READ (8,9000,END=90) IYEAR,IMONTH,STID,RLAT,RLON,RVAL
9000   FORMAT (I4,3X,I2,2X,A8,3F8.1)
       IF (IFLAG.EQ.0) THEN
          IFLAG = 1
          IYROLD = IYEAR
          IMNOLD = IMONTH
       ENDIF
C  If new time group, write time group terminator.
C  Assuming no empty time groups.
       IF (IYROLD.NE.IYEAR.OR.IMNOLD.NE.IMONTH) THEN
          NLEV = 0
          WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
          ENDIF
          IYROLD = IYEAR
          IMNOLD = IMONTH
C  Write this report
       TIM = 0.0
       NLEV = 1
       NFLAG = 1
       WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
       WRITE (10) RVAL
       GO TO 10
C  On end of file write last time group terminator.
90     CONTINUE
       NLEV = 0
       WRITE (10) STID,RLAT,RLON,TIM,NLEV,NFLAG
       STOP
       END



More information about the Fortran mailing list