problem in reading binary file

From: Ufuk Utku Turuncoglu <u.utku.turuncoglu_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 15 2010 - 07:35:08 MST

Hi All,

I try to read a binary file (Hadley Center, HadCM3 output in PP format).
The file simple contains header information in each slice of the
variable. The header file contains 1-45 integer values and 46-64 float
values (total 64 value). The actual field data comes after these header
values. Please see the following link Appendix 5 for more information.

http://precis.metoffice.com/docs/tech_man.pdf

My problem is i could not read header data correctly when i use the
following code,

     rec1 = fbinrecread("./aenwha.1.1.96.73.pit9410.ext.pp", 0, 45,
"integer")

     lblrec = rec1(14) ; length of data record in words
     lbrow = rec1(17) ; number of rows in field (latitude)
     lbnpt = rec1(18) ; number of grid points in each row (longitude)
     lbfc = rec1(22) ; field code
     lbvc = rec1(25) ; vertical coordinate type

     rec2 = fbinrecread("./aenwha.1.1.96.73.pit9410.ext.pp", 1, 19, "float")

     bval = rec2(0) ; b-value of vertical coordinate (if lbvc == 9)
     aval = rec2(1) ; a-value of vertical coordinate (if lbvc == 9)

but if i use following one,

     rec1 = fbinrecread("./aenwha.1.1.96.73.pit9410.ext.pp", 0, 45,
"integer")

     lblrec = rec1(14) ; length of data record in words
     lbrow = rec1(17) ; number of rows in field (latitude)
     lbnpt = rec1(18) ; number of grid points in each row (longitude)
     lbfc = rec1(22) ; field code
     lbvc = rec1(25) ; vertical coordinate type

     rec2 = fbinrecread("./aenwha.1.1.96.73.pit9410.ext.pp", 0, 64, "float")

     bval = rec2(45) ; b-value of vertical coordinate (if lbvc == 9)
     aval = rec2(46) ; a-value of vertical coordinate (if lbvc == 9)

i can read the correct value of bval and aval values. Why does the first
version read wrong data? How can i read defined subset of header file in
each fbinrecread call? I will use this script to read ak and bk values
of the each hybrid sigma layers but i this case it is not working.
Please let me know, if you need any further information.

Thanks,

--ufuk

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 15 07:35:27 2010

This archive was generated by hypermail 2.1.8 : Fri Jan 15 2010 - 13:51:45 MST