[gradsusr] writing out data in fortran

Daniele Gandini daniele.gandini at arpa.piemonte.it
Fri Aug 26 10:37:20 EDT 2011


FORM must be "unformatted".
Normally I write without "REC=k".

Bye

Dan

----- Messaggio originale -----
Da: "Meg Sutton" <mcs2214 at columbia.edu>
A: gradsusr at gradsusr.org
Inviato: Venerdì, 26 agosto 2011 16:23:20
Oggetto: [gradsusr] writing out data in fortran

Hi gradusers,
I am trying to write out my .tsv file to a format grads can read. The program is:

PROGRAM y
 INTEGER, PARAMETER  :: m1=21 ! - number of longitudes -
 INTEGER, PARAMETER  :: m2=31 ! - number of latitudes -
 INTEGER, PARAMETER  :: n=3  ! - number of years -
 REAL :: x(m1,m2,n)
 OPEN (UNIT=31,FILE='file1.txt',FORM='formatted')
 READ (UNIT=31,FMT=*)
 READ (UNIT=31,FMT=*)
 DO k=1,n
    READ (UNIT=31,FMT=*)
    READ (UNIT=31,FMT=*)
    READ (UNIT=31,FMT=*) ((x(j,i,k),j=1,m1),i=1,m2)
 END DO
 CLOSE (UNIT=31)
 OPEN (UNIT=31,FILE='file2',ACCESS='direct',RECL=m1*m2*4,FORM='unformatted')
 DO k=1,n
    WRITE (UNIT=31,REC=k) ((x(j,i,k),j=1,m1),i=1,m2)
 END DO
 CLOSE (UNIT=31)
END PROGRAM y


when I run it and try to write it out it gives me the following error on line 12
"fortran runtime error: Bad real number in item 1 of list input" 

Does anyone have any ideas?

Best, 
Meg




_______________________________________________
gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr




More information about the gradsusr mailing list