Re: reading binary files

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 24 2012 - 15:20:23 MDT

Was it a sequential (fortran default) or direct (access=direct) write?

Was it written in one record

    write(10) P

Or, say,

     do n=1,365
       do m=1,8
          write(10) ((P(i,j,m,n),i=1,nlon),j=1,nlat)
       end do
     end do

Was it written on a big-endian machine and you are on
a little-endian machine? If so:

        setfileoption("bin","ReadByteOrder","BigEndian")

or vice versa

        setfileoption("bin","ReadByteOrder","LittleEndian")

*****************************************

If one record for whole array:

If written as sequential file

        P1 = fbinseqread( file.bin, 0, (/365,8,nlat,nlon/), "float")

If direct
        P1 = fbindirread( file.bin, 0, (/365,8,nlat,nlon/), "float")

===========

If multiple records

     P1 = new( (/365,8,nlat,nlon/), "float")

then loop appropriately, updating the record counter

On 10/24/12 3:01 PM, Noel Aloysius wrote:
> Hi NCL,
>
> The binary file written by a Fortran program has the following format,
>
> P (lon,lat,8,365) ; 8 three-hourly values for each day, 365 days in
> the year, lon = (0 to 360) and lat = (0 to 180)
>
> I want to know if reading this file into NCL as follows is correct or
> should I read this within a do-loop,
>
> P1 = fbindirread( file.bin, 0, (/365,8,nlat,nlon/), "float")
>
> Thanks,
> Noel
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 24 15:20:33 2012

This archive was generated by hypermail 2.1.8 : Wed Oct 31 2012 - 09:14:12 MDT