Hi Jaison,
Thanks for checking this out. I had overlooked the "/type=r8"
qualifier. We will record your #2 discovery as a bug and schedule it
for repair. Indeed, the ability to read /FORMAT=unformatted dates back
to the very
earliest days of Ferret -- probably 1985 (well before netCDF). The
/FORMAT=STREAM and /TYPE= qualifiers were added years later.
By the way, regarding the /SKIP qualifier, here are words from the
on-line Users' Guide (click in Index under SET DATA - /SKIP)
For
FORTRAN-structured binary files the /SKIP argument refers to the number
of binary records to be skipped.
For
unstructured (stream) binary files (e.g., output of a C program) the
/SKIP argument refers to the number of words (4-byte quantities)
to skip before reading begins
- steve
=================================================
Jaison Kurian wrote:
Hi Bob, Steve, Billy, Ryo & Dan,
I made few experiments with
writing "sequential access" data in Fortran and reading it in
Ferret. Here is the summary.
1. Sequential access files with all the data written in a single
stretch (as Bob wanted) should be readed in Ferret as
"Format=STREAM" with /SKIP=1. (Don't be annoyed, it will
work !!!). SKIP=1 will remove the first record information
then the data is exactly same as that of "Direct Access".
You have to specify TYPE=R4 or R8 according to your Fortran
program.
see Case_1 and Case_2 below.
2. Sequential access files with data written inside the loop (as
in the example i suggested earlier) should be readed in
Ferret as "Format=UNFORMATTED". Ferret will support only
REAL*4 and not REAL*8 types.
see Case_3 and Case_4 below.
Hope this will answer Bob's questions.
Regards
Jaison
---------------------------------------------------------------
Common to all cases
-------------------
open(unit=10,access='sequential',form='unformatted',
# file='seq.bin')
case 1
------
Fortran
real*4 hrmean(nx,ny,nz)
..................
write(10) hrmean
Ferret
file/skip=1/format=stream/type=R4/var=hrmean/\
grid=mygrid seq.bin
case 2
------
Fortran
real*8 hrmean(nx,ny,nz)
..................
write(10) hrmean
Ferret
file/skip=1/format=stream/type=R8/var=hrmean/\
grid=mygrid seq.bin
case 3
------
Fortran
real*4 hrmean(nx,ny,nz)
...............
DO k =1,nz
Do j = 1,ny
Do i = 1,nx
write(10) hrmean(i,j,k)
ENDDO
ENDDO
ENDDO
Ferret
file/format=unformatted/type=R4/var=hrmean/\
grid=mygrid seq.bin
case 4
------
Fortran
real*8 hrmean(nx,ny,nz)
...............
DO k =1,nz
Do j = 1,ny
Do i = 1,nx
write(10) hrmean(i,j,k)
ENDDO
ENDDO
ENDDO
Ferret
Ferret is not able to handle this dataset.
--------------------------------------------------------------------
On Thu, 6 Jul 2006, Ryo Furue wrote:
Hi,
| FORTRAN unformatted output is not really a standard. It is system
| and compiler dependent how the concept of a "record" is implemented.
You are correct in principle. In practice, unformatted files are
very compatible, *if* these two items are taken care of:
1) Endianness: Compilers on little-endian machines usually
have an option to convert to the big endian format on I/O.
Ferret has one, too. (The "swap" keyword.)
2) For direct access files, recl may not be in terms of bytes.
On some compilers, recl can be in the units of 4 bytes.
But, such compilers usually have an option to make it one byte.
For sequential files, most compilers follow the de facto standard
for the representation of records. A direct-access file is almost
always represented as a uniform sequence of bytes, so there's no
record boundary or anything in the underlying data.
Cheers,
Ryo
--------------------------
On the three major OSes (Unix/Linux, Windows, & MacOS),
files aren't orgnized around "records". From the user's point
of view, files are simply uniform sequences of bytes. Fortran
direct-access files are almost always just that, on such OSes.
Fortran sequential files are a bit trickier because they do
have the notion of record. But, most compilers follow the
de facto standard format to represent records. To represent
floating-point numbers, the IEEE standard is the norm these
days, so, once the endianness is taken care of, the
floating-point number representation is almost always
compatible. Unless you are using an old IBM mainframe
or a Cray (what about VMS?), that is.
--
--
Steve Hankin, NOAA/PMEL -- Steven.C.Hankin@noaa.gov
7600 Sand Point Way NE, Seattle, WA 98115-0070
ph. (206) 526-6080, FAX (206) 526-6744
|