Hi Dennis,
The file (flat binary, little endian) is written as follows
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
Based on your reply I would read the file as follows,
P = new ((/365,8,nlat,nlon/), "float")
do i=0,364
do j=0,7
P(i,j,:,:) = fbindirread(file.bin, (i*8+j), (/nlat,nlon/),"float"
end do
end do
Thanks,
Noel
Noel Aloysius
On Wed, Oct 24, 2012 at 5:20 PM, Dennis Shea <shea@ucar.edu> wrote:
> 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<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 16:10:46 2012
This archive was generated by hypermail 2.1.8 : Wed Oct 31 2012 - 09:14:12 MDT