Re: read fortran unformatted binary

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri Apr 13 2012 - 09:06:24 MDT

[1] As suggested, it is likely fbinrecread that should be used.
     Fortran's sequentail write (default) silently prepends and
     posrpend each record with a 4-byte delimeter.

[2] If that still does not solve the problem, then it is likely
     an 'endian' issue. You are trying to read a file created on
     a big-endian machine (eg: IBM, AIX) on a little-endian machine
     (most linux boxes).

http://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml
    setfileoption("bin","ReadByteOrder","LittleEndian")
orsetfileoption("bin","ReadByteOrder","BigEndian")

On 04/13/2012 03:01 AM, Ekin Akoglu wrote:
> Did you try fbinrecread? It seems it is more appropriate for you file
> because it is for sequential access files.
>
>
> On 04/13/2012 11:57 AM, Prince K XAVIER wrote:
>> Hi,
>>
>> I have a fortran f77 binary file written using a f77 code as:
>>
>> open(15,file=outfile, form='unformatted')
>>
>> do i = 1, ntime
>> ....
>> write(15) yyr,ymo,yda ! Integers
>> write(15) ((y(lon,lat),lon=1,145),lat=1,33) ! float
>> ....
>> end do
>>
>> How can I read it using NCL?
>>
>> I tried to read the first two records using:
>>
>> date = fbindirread (datadir+datafile, 0, (/3/), "integer")
>> data = fbindirread (datadir+datafile, 1, (/145,33/), "float")
>>
>> but it gives some strange values and I know there is something wrong
>> with the read statement. Could you suggest the correct way of reading
>> the data?
>>
>> Another option was to write a fortran subroutine to read it and
>> linking it using a shared object. This worked for some time but now
>> fails with "Memory fault" error. Not a very stable solution in my
>> opinion. Any better suggestions?
>>
>> Cheers
>> Prince
>>

> _______________________________________________
> 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 Fri Apr 13 09:06:35 2012

This archive was generated by hypermail 2.1.8 : Fri Apr 13 2012 - 13:37:52 MDT