[Thread Prev][Thread Next][Index]
Re: Fortran Binary File Read
On Sep 5, 1:18pm, David Oxilia wrote:
> I'd like to read a set of fortran binary files into ferret. I've tried it
> a couple of different ways according to the documentation (User guide v4.4
> p24) but ferret quits with a core dump.
The problem is your file format. Ferret is pretty forgiving with file structure
but what you are trying to do is not something that ferret can EASILY read. It
could be done but there are easier ways. In your style you would have to do all
sorts of playing around with the file command to get it to work correctly - NOT
AN EASY TASK. It's easier to write the data out differently, such as the
following 2 examples:
1) 11 separate files (1 each for eta, ub, ...)
Write them in the following manner:
2D (nx,ny):
do j=1,ny
write(10) (eta(i,j),i=1,nx)
enddo
3D (nx,ny,nz):
do k=1,nz
do j=1,ny
write(11) (q(i,j,k),i=1,nx)
enddo
enddo
Read them into ferret (with a more appropriate grid definition):
yes? define axis/x=1:nx:1 myx
yes? define axis/y=1:ny:1 myy
yes? define axis/z=1:nz:1 myz
yes? define grid/x=myx/y=myy grid2
yes? define grid/like=grid2/z=myz grid3
yes? file/form=unfor/grid=grid2/var=eta eta.dat
yes? file/form=unfor/grid=grid3/var=q q.dat
You might also need to add column info to the file command (I can't recall)
i.e.:
yes? file/form=unfor/grid=grid2/col=nx/var=eta eta.dat
yes? file/form=unfor/grid=grid3/col=nx/var=q q.dat
--------------------------------------------------------------------------
2) Split them into 2 files (1 for 2D and 1 for 3D)
In Fortran:
do j=1,ny
do i=1,nx
write(10) eta(i,j),ub(i,j),vb(i,j),up(i,j),us(i,j),vs(i,j)
enddo
enddo
do k=1,nz
do j=1,ny
do i=1,nx
write(11) dp(i,j,k),q(i,j,k),qx(i,j,k),qy(i,j,k)
enddo
enddo
enddo
In Ferret:
yes? define axis/y=1:ny:1 myy
yes? define axis/z=1:nz:1 myz
yes? define grid/x=myx/y=myy grid2
yes? define grid/like=grid2/z=myz grid3
yes? file/form=unfor/grid=grid2/var="eta,ub,vb,up,us,vs" d2.dat
yes? file/form=unfor/grid=grid3/var="dp,q,qx,qy" d3.dat
Good Luck!
--
Mark Verschell NASA/Goddard Space Flight Center
verschell@neptune.gsfc.nasa.gov Code 970/Lab. for Hydrospheric Proc.
301-286-2027 Fax: 301-286-1761 Greenbelt, MD 20771
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement