Re: read binary data for integer and float types

From: Li, Yongzuo <yongzuo.li_at_nyahnyahspammersnyahnyah>
Date: Wed Jan 20 2010 - 09:54:49 MST

Dennis,

The problem is solved by modifying your script

two = new(2,"integer")
two = fbindirread("data.bin",0,2,"integer")
jj = two(0)
ii = two(1)
rf = new((/jj,ii/),"float")
rec = fbindirread("data.bin",0, ii*jj+2,"float")
rf = onedtond(rec(2:), (/jj,ii/) )

print("rf="+rf(0,0))
print("rf="+rf(0,899))

Yongzuo
________________________________________
From: shea@ucar.edu [shea@ucar.edu]
Sent: Tuesday, January 19, 2010 8:03 PM
To: Li, Yongzuo
Cc: ncl-talk@ucar.edu
Subject: Re: read binary data for integer and float types

This is not clear.

Are you sure the file was created with "direct" writing?

Or, was it created with a fortran sequential write

integer i1, i2
real x(ii,jj)

write(iunit) i1, i2, x

If the latter, then use fbinrecread

irec = fbinrecread("data.bin",0, ii*jj+2,"integer")
i1 = irec(0)
i2 = irec(1)

rec = fbinrecread("data.bin",0, ii*jj+2,"float")
data = onedtond( rec(2:), (/jj,ii/) )

> Hi,
>
> I have following script to read binary data in integer/float type.
>
> two = new(2,"integer")
> ;two = fbindirread("data.bin",0,2,"integer")
> jj = 67
> ii = 43
> rf = new((/jj,ii/),"float")
> rf = fbindirread("data.bin",0,(/jj,ii/),"float")
>
> Question (1),
>
> Can fbindirread work without "(/jj,ii/)"? I tried and failed without it.
>
> Question (2),
>
> How can jj and ii be read from data.bin and then used to define jj and ii
> for rf = new(xxx) ?
>
> Either
> two = fbindirread("data.bin",0,2,"integer")
> or
> rf = fbindirread("data.bin",0,(/jj,ii/),"float")
> works well separately.
>
> But they do not work together (change 0 to 1 in rf line when both
> applied).
>
> Thanks
>
> Yongzuo
>
>
> _______________________________________________
> 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 Jan 20 09:56:26 2010

This archive was generated by hypermail 2.1.8 : Thu Jan 21 2010 - 13:54:45 MST