[Thread Prev][Thread Next][Index]

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



Hi Ryo,

On Thu, 6 Jul 2006, Ryo Furue wrote:
Hi Jaison,

| 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.

I may be missing something, but what's the unit of "skip"?
Is it a 4-byte word?   Otherwise, I don't understand why
your Case_2 works.  But, if the unit of "skip" is a 4-byte
word, what would you do if you want to skip the first three
bytes of your binary file, for example?
      It is "words" i think. I don't know precisely, the
SKIP may be working according to the data type specified. So
in case of R4 it will remove the record information at the beginning
with 1 word length with respect to R4 type. In R8 case it should
remove 1 word corresponding to R8 type. Hence it seems that
you cannot remove first 3 bytes from a variable of type R4.

| 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.

I've never used "Format=UNFORMATTED", but it's very interesting.
If you write a sequential file as you do in Case_3, each
element (a real*4 number) of the array is surrounded by
a header and trailer in the file.  So, Ferret assumes this,
when given format=unformatted . . .  This is an odd thing
to do, because your file will be three times the size of the
real*4 array itself.

   in the first case with REAL*4, the filesize (in bytes) is
   (128*64*19 + 1 word at beginning + 1 word at end)*4 = 622600

   in second case, with REAL*4, there will be as many headers
   and trailers as the variable values with similar length of word.
   So we should multiply the grid points with 3, then the filesize is
   (128*64*19 * 3) * 4 = 1867776

   Let us check whether the filesizes match this estimates
   (seq_1array.bin corresponds to the 1st case and
   seq_looped.bin to 2nd case)

[jaison@mercury binary_data]$ ls -la *.bin
-rw-r--r--    1 jaison   users   622600 Jul  7 15:46 seq_1array.bin
-rw-r--r--    1 jaison   users  1867776 Jul  7 15:46 seq_looped.bin
[jaison@mercury binary_data]$

   Exactly matching. So we should stick to the first method to
   save some disk space (if you are so fond of SEQUENTIAL access
   files) !!!!

Regards,
Ryo

========= Quoting from Jaison's message =====================

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.


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement