Re: binary read

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 29 2010 - 09:51:20 MDT

Hi Michael,

We didn't make any changes to the binary read functions that I can think of. I don't really have enough information to know what the problem could be.

You might be running into one of two issues:

1. Big endian versus little endian - did you write this file on a little endian (or vice versa) system, and now are trying to it on a big endian (or vice versa) system? If so, you might need to call "setfileoption" before you read the file to set the appropriate endianness:

   setfileoption("bin","ReadByteOrder","LittleEndian")
or

   setfileoption("bin","ReadByteOrder","BigEndian")

2. The other possible issue that this might might have been written such that an 8-byte record was written at the beginning of the file.

This can happen if the file was written with a Fortran program that was compiled with an older version of g77 or gfortran that wrote 8-byte headers by default. This has changed with newer versions of gfortran.

--Mary

On Jul 28, 2010, at 3:34 PM, Michael Notaro wrote:

> On a previous version of NCL, I used this script and was able to read
> binary data fine. Now I am using NCL 5.2 and have recently rerun the
> script to find that all the values that are read in are now garbage.
> What do I need to change to read the binary files correctly?
>
> Thanks, Michael
>
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
>
> names=asciiread("filenames",(/600/),"string")
>
> a = fbindirread("/Users/notaro/ndvi/namer_albers.lat",0,(/1024,1280/),"short")
> lat2d=short2flt(a)
> lat2d=lat2d/100.
> b = fbindirread("/Users/notaro/ndvi/namer_albers.lon",0,(/1024,1280/),"short")
> lon2d=short2flt(b)
> lon2d=lon2d/100.
> lat2d!0="lat"
> lat2d!1="lon"
> lon2d!0="lat"
> lon2d!1="lon"
> lat2d@units="degrees_north"
> lon2d@units="degrees_east"
>
> sw=new((/600/),float)
>
> do i=0,599
>
> d = fbindirread("/Users/notaro/ndvi/namer_all/"+names(i),0,(/1024,1280/),"short")
> var=(/short2flt(d)/)
> var=var/10000.
>
> var!0="lat"
> var!1="lon"
> var@lat2d=lat2d
> var@lon2d=lon2d
>
> sw(i)=(/avg(var(692:694,597:599))/)
>
> end do
>
> ETC............
> _______________________________________________
> 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 Thu Jul 29 09:51:33 2010

This archive was generated by hypermail 2.1.8 : Fri Jul 30 2010 - 13:45:56 MDT