[Thread Prev][Thread Next][Index]

Re: [ferret_users] reading FORTRAN sequential access data - simplequestion



Just to establish the more elementary piece that may be useful to other users: Ferret easily and straightforwardly reads fortran binary writes if the file is NOT 'sequential access'.

In the fortran code:

parameter (nx=154, ny=35) ! 141E-66W, 34S-0 by 1 deg

real uav(nx,ny),vav(nx,ny) ! input data
real curl(nx,ny),psi(nx,ny) ! output
.....
open(30,file='ir4.dat',status='new',form='unformatted')
.....
write(30) ((psi(i,j),curl(i,j),uav(i,j),vav (i,j),i=1,nx),j=1,ny) ! write 4 grids on one record

In Ferret:

define axis/x=141e:66w:1/unit=lon xpsi
define axis/y=34s:0:1/unit=lat ypsi
define grid/x=xpsi/y=ypsi gpsi
file/format=unf/var="psi,curl,uav,vav"/g=gpsi/col=`4*154*35` ir4.dat ! read 4x(154,35) grids on one record
save/file=ir4.cdf psi,curl,uav,vav ! Ferret converts the fortran binary to netcdf

The main reason to do this is that Ferret is such a good netcdf converter. I could write a subroutine to write the output of my fortran code in netcdf directly. But it is much easier to write the above 5 lines of extremely transparent Ferret code to accomplish the same thing. Then I would delete the fortran output ir4.dat.

Thus, without the complication of sequential access, there is no issue of counting record information or anything else. It is very easy. This is also very well tested as I have done this sequence (fortran=>binary output=>Ferret conversion to netcdf) many, many times over a decade.

Billy K



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement