Re: how to read complicated sequential data by fbinrecread?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 31 Jul 2009 10:38:57 -0600

An alternative to the following would be to write a
fortran subroutine to read the data. Then ,use WRAPIT
to make it accessible from NCL.

===
If you want to use NCL, the following *may *work.
It is not tested.

You state "nlev, nflag are of type 'string' " ... Do you mean type
"integer" ?

Each 8-character variable is 8-bytes; each integer/float has 4 bytes.
Hence,
xid(ista),xlat(ista),xlon(ista),tim,nlev,nflag,mrain2(ista,isea)
has
8, 4, 4, 4, 4, 4, 4 bytes

rec = -1
do isea=0,nsea-1
do ista=0,nsta-1

rec = rec+1
ch = fbinrecread(fili, rec, 32, "character") ; read rec as 32 characters
[bytes]
xid = ch(0:7)
print("rec="+rec+" xid="+xid)

xf = fbinrecread(fili, rec, 8, "float") ; read rec as 8 float [4*8=32]
xlat = xf(2)
xlon = xf(3)
tim = xf(4)
mrain = xf(7)
print("rec="+rec+" xlat="+xlat+" xlon="+xlon+" tim="+tim+" mrain="+mrain)

xi = fbinrecread(fili, rec, 8, "integer") ; read rec as 8 interger [4*8=32]
nlev = xi(5)
nflag = xi(6)
print("rec="+rec+" nlev="+nlev+" nflag="+nflag)

end do

rec = rec+1
ch2 = fbinrecread(fili, rec, 28, "character")
xid2 = ch2(0:7)
print("rec="+rec+" xid2="+xid2)

xf2 = fbinrecread(fili, rec, 7, "float")
xlat2 = xf2(2)
xlon2 = xf2(3)
tim2 = xf2(4)
print("rec="+rec+" xlat2="+xlat2+" xlon2="+xlon2+" tim2="+tim2)

xi2= fbinrecread(fili, rec, 7, "integer")
nlev 2 = xi2(5)
nflag 2 = xi2(6)
print("rec="+rec+" nlev2="+nlev2+" nflag2="+nflag2)

end do

Xuguang Sun wrote:
> Dear everyone,
>
> I've a sequential format binary data, which is written by the following fortran code,
>
> do isea= 1, nsea !1-4 climatological seasonal mean
> do ista = 1, nsta ! station loop
> tim = 0.0
> nlev = 1
> nflag = 1
> write(2)xid(ista),xlat(ista),xlon(ista),tim,nlev,nflag,mrain2(ista,isea)
> enddo
> nlev = 0
> write(2)xid(1),xlat(1),xlon(1),tim,nlev,nflag
> enddo
>
> where, xid(ista) is of type "string" with 8 characters, xlat(ista), xlon(ista),tim,mrain2(ista,isea) are of type "float", and nlev, nflag are of type "string".
>
> one record contains multiple types, then how to read these data in NCL?
>
> Thanks in advance.
>
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 31 2009 - 10:38:57 MDT

This archive was generated by hypermail 2.2.0 : Fri Jul 31 2009 - 14:51:03 MDT