# Re: Question on NCL reading binary file

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 29 May 2009 13:59:41 -0600

I think the following is what would be needed

NCL can only read a variable of one type.
So, maybe,

AI = fbinrecread (fili, 0, -1, "integer")
a = AI(0:4)
delete(AI)

nx = 100
ny = 399
nlat = 64
mlon = 128
nz = nlat*mlon

AF = fbinrecread (fili, 0, -1, "float")
nStrt = 5
nLast = nStrt+nx-1
x = AF(nStrt:nLast)

nStrt = nLast+1
nLast = nStrt+ny-1
y = AF(nStrt:nLast)

nStrt = nLast+1
nLast = nStrt+nz-1

z = onedtond(AF(nStrt:nLast), (/nlat,mlon/) )

delete(AF)

a = fbinrecread (fili, 0, 5, "integer")

guangshan chen wrote:
> Hi all,
>
> I have a question for fbinrecread:
> There is the example 1. It says that: if a binary file written in
> this way using fortran:
> integer a(5)
> real x(100), y(399), z(128,64)
>
> open (11,file="example01",form="unformatted")
>
> write (11) a ! 1st record [rec_num=0]
> write (11) x ! 2nd record [rec_num=1]
> write (11) y ! 3rd record [rec_num=2]
> write (11) z ! 4th record [rec_num=3]
>
> This binary file can be read by NCL in this way:
> fili = "example01" ; input file
> a = fbinrecread (fili, 0, 5, "integer") ; 1st record
> is zero
> x = fbinrecread (fili, 1, 100, "float") ;
> 2nd one
> y = fbinrecread (fili, 2, 399, "float") ; 3rd record
> is two
> z = fbinrecread (fili, 3, (/ 64,128 /), "float") ; 4th record
> is three
>
> My question is that If I write a binary file in this way:
> open (12,file="example02", form="unformatted")
> write (12) a,x,y,z
>
> then how to use NCL to read "example02" binary file?
>
> Thanks.
>
> Guangshan
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

```--
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
```
Received on Fri May 29 2009 - 13:59:41 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 01 2009 - 07:47:28 MDT