[Thread Prev][Thread Next][Index]

Re: how can i read all my data from files?



Hi Weiq,

In another message you mentioned that the read appears to work fine for
two, three, four, but it failed for five and more. That is a very strong
clue that the problem is the file not matching the description that you
are giving Ferret. Do some plots of the data itself to see if it looks
correct -- particularly the first and last values read from each time
step.

There is not strict standardization of FORTRAN binary record structure
between systems.  It is possible that the binary files created by Visual
Fortran  6.0 are not consistent with the system on which you are running
Ferret. I have seen MAC FORTRAN implementations, for example, that
insert a preceding byte count but lack a closing count. Also systems
where the count is in words instead of bytes.  Any of these would cause
the type of behavior you are seeing.

An alternative to FORTRAN unformatted is /FORMAT=stream where you read
*all* the bytes. The FORTRAN binary header then shows up as data and you
have to make sure to ignore it. Here is a schematic example -- the
"I=2:..." in the final step is in order to step over the FORTRAN record
length information.

     define axis/x=1:`180:360`:1 my_1dX
     define grid/x=my_1dX/T=my_T my_grid_XT
     file/format=stream/g=my_grid_XT/var=my_var my_file.dat

     define grid/x=my_X/y=my_Y/T=my_T my_grid_XYT
     let dummy = X[g=my_grid_XYT] + Y[g=my_grid_XYT] +
     T[g=my_grid_XYT]
     let v = RESHAPE(my_var[I=2:`3+360*180`],dummy)

If this helps to lead you to a solution

    - steve

weiq wrote:

> I read it by file/format=stream/grid=gridxy/columns=64800/var=xx
> c:\tmp\sh2.dat
> and this data file(sh2.dat) is writted by Visual Fortran  6.0. Pls see
>
> the below:
>
>      parameter(mi=360,mj=180,msea=12)
>       real map1(mi,mj)
>
> open(1,form='unformatted',file='sh2.dat',access='direct',recl=mi*mj)
>
>        do is=1,msea
>         write(1,rel=is)  map1
>       enddo
>
> thanks ur reply.
>
>        weiq

--
Steve Hankin
NOAA/PMEL, 7600 Sand Point Way NE, Seattle, WA 98115-0070
ph. (206) 526-6080 -- FAX (206) 526-6744




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement