[Thread Prev][Thread Next][Index]

Re: Several variables in one unformatted file

On Dec 4, 12:59pm, beland@cerca.umontreal.ca wrote:
> Subject: Several variables in one unformatted file
> Hello,
> Using a Fortran program, I wrote an unformatted file containing four
> two-dimensional fields.
> The file was written like this:
>    real A(64,32),B(64,32),C(64,32),D(64,32)
>    open(10,file='tempmoy.dat',form='UNFORMATTED')
>    write(10) A,B,C,D
>    close(10)

The problem is how the data was written out. There may be a way to read this
format into ferret, but far easier is to change the method you are using to
write the data in the ForTran program. What's currently happening is you are
getting one long record with all the variables. Instead, try the following:

      real A(64,32),B(64,32),C(64,32),D(64,32)

      do j=1,32
         do i=1,64
            write(10) A(i,j),B(i,j),C(i,j),D(i,j)

Even thought the resulting file is 33% larger, this should be no problem with
arrays this small.

> I try to read it with ferret using
> ! Definition of gaussian grid 64x32
> file /var=lats/columns=1 lats.gauss.32
> define axis/x=0:354.375:5.625/unit=degrees x64
> define axis/y/from_data/name=y32/unit=degrees lats
> define grid/x=x64/y=y32 g64x32
> file/var="T650,T1000,Tdiff,r"/grid=g64x32/format=UNFORMATTED/COLUMNS=`64*32*4`

Now, you read it in ferret as follows (only need to change the file line):

file/var="T650,T1000,Tdiff,r"/grid=g64x32/format=UNFORMATTED tempmoy.dat

This should work fine.



	      Mark Verschell (verschell@coaps.fsu.edu)
	      Center for Ocean and Atmospheric Prediction Studies
	      Florida State University
              2035 E. Paul Dirac Drive
              R.M. Johnson Bldg. - Suite 200
	      Tallahassee, FL  32310
	      (904) 644-6532              (904) 644-4841 (fax)

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / ERL / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement