Error in reading binary file written by fortran

From: Qi Tang <tangq_at_nyahnyahspammersnyahnyah>
Date: Thu, 28 Aug 2008 16:17:23 -0700

Hi,

I am trying to read a binary file created by the following fortran code:

       integer IYEAR,IDAY, JYEAR,JDAY,JMON,JDATE,
      & IM,JM,LM,NTM, IPAR,JPAR,LPAR,NPAR
       character*80 RTITLE
       real*8, dimension(IPAR,JPAR,LPAR) :: AIR
       real*8, dimension(IPAR,JPAR,LPAR,NPAR) :: STT
       real*4, dimension(IPAR,JPAR,LPAR,NPAR) :: SUT,SVT,SWT, SUU,SVV,
      & SWW, SUV,SUW,SVW

       open(11,file=FN_CON,form='UNFORMATTED',status='new',err=11)

       write(11) RTITLE

       write(11) IYEAR,IDAY, JYEAR,JDAY,JMON,JDATE,
      & IM,JM,LM,NTM, IPAR,JPAR,LPAR,NPAR,
      & AIR,STT,SUT,SVT,SWT,SUU,SVV,SWW,SUV,SUW,SVW

       close(11)

And I wrote the following NCL script to read the AIR array. But it gives
me crazy values.

load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"

begin

   dirOld = "restrt00213_Old"
   dirNew = "restrt00213_New"

   number = fbinnumrec(dirOld)
   print(number)
   a = fbinrecread (dirOld, 0, 80, "character")
   tmp = fbinrecread (dirOld, 1, 14, "integer")
   print(tmp)
   air = fbinrecread (dirOld, 1, (/37,64,128/), "double")
   print(air(0,0,0))
end

The output is:
Variable: number
Type: integer
Total Size: 4 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 2
warning:fbinrecread: size specified is less than record size, some data
will not be read

Variable: tmp
Type: integer
Total Size: 56 bytes
             14 values
Number of Dimensions: 1
Dimensions and sizes: [14]
Coordinates:
(0) 2003
(1) 213
(2) 2003
(3) 213
(4) 8
(5) 1
(6) 128
(7) 64
(8) 37
(9) 28
(10) 128
(11) 64
(12) 37
(13) 28
warning:fbinrecread: size specified is less than record size, some data
will not be read

Variable: air (subsection)
Type: double
Total Size: 8 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 4.519851044652165e-312

Thanks!
Qi
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 28 2008 - 17:17:23 MDT

This archive was generated by hypermail 2.2.0 : Fri Aug 29 2008 - 07:39:21 MDT