Re: Is there a bug with fbinrecwrite or fbinrecread

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 30 2009 - 09:25:26 MDT

Guangshan,

I was also unable to reproduce this problem, and I ran it on 32-bit
and 64-bit systems (Mac, LINUX, AIX).

What version of NCL do you have? Did you try running the program more
than once to see if the problem was still there?

--Mary

On Oct 30, 2009, at 5:53 AM, Rick Brownrigg wrote:

> Hi Guangshan,
>
> Curiously, I get the following output, which appears to be correct:
>
> (0)
> (0) Monthly Longterm Mean of U-Wind: min=-37.2069 max=95.8738
> (0)
> (0) Monthly Longterm Mean of V-Wind: min=-33.7934 max=32.8907
> (0) u-wind Min and Max values read from ./wind.mon.ltm.bin
> (0)
> (0) min=-37.2069 max=95.8738
> (0) v-wind Min and Max values read from ./wind.mon.ltm.bin
> (0)
> (0) min=-33.7934 max=32.8907
> (0) u-wind Min and Max values read from ./uwind.mon.ltm.bin
> (0)
> (0) min=-37.2069 max=95.8738
>
> I hate to think there might be platform differences, but not sure what
> to suggest here.
> This was running NCL 5.1.1 under MacOS 10.5.8.
>
> Rick
>
> On Thu, 29 Oct 2009 21:19:20 -0500
> guangshan chen <gchen9@gmail.com> wrote:
>> Dear all:
>>
>> It seems there is bug in fbinrecwrite or fbinrecread.
>>
>> Here is the test main idea:
>> step 1: read netcdf file and get two variables data
>> step 2: printMinMax values of variables
>> step 3: using fbinrecwrite to write binary file
>> step 4: using fbinrecread to read binary file
>> step 5: printMinMax values of the new two variables
>>
>> But I compared the Min and Max values between the original data and
>>
>> new data read from binary file are different.
>>
>> Original Min and Max values:
>> Monthly Longterm Mean of U-Wind: min=-37.2069 max=95.8738
>> Monthly Longterm Mean of V-Wind: min=-33.7934 max=32.8907
>>
>> New Min and Max values read from binary file
>> u-wind Min and Max values read from ./wind.mon.ltm.bin are
>> min=-37.2069 max=81.1241
>> v-wind Min and Max values read from ./wind.mon.ltm.bin are
>> min=-36.9928 max=95.8738
>>
>> Also in my script I output only variable to binary file and read it,
>>
>> there is no problem.
>> u-wind Min and Max values read from ./uwind.mon.ltm.bin are
>> min=-37.2069 max=95.8738
>>
>> So Could anyone check what is going when outputting two variables?
>>
>> Thanks
>>
>> Guangshan
>>
>>
>> ;================================================;
>> 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"
>> ;================================================;
>> ;load external functions should be included path;
>> ;external function_name "./function_name.so"
>> ;================================================;
>> begin
>> ;================================================;
>> ;The binary file will be the same as a one open via fortran's open
>> statement:
>> ;
>> ; open(..., form="unformatted", [,access="sequential"] ) ;
>> sequential is default
>>
>> uwind_file = addfile("uwnd.mon.ltm.nc","r")
>> vwind_file = addfile("vwnd.mon.ltm.nc","r")
>>
>> ; data can be download from
>> ;http://www.esrl.noaa.gov/psd/cgi-bin/db_search/DBSearch.pl?
>> Variable=U-
>> ; Wind&Dataset=CDC+Derived+NCEP+Reanalysis+Products+Pressure+Level
>> ;
>> http://www.esrl.noaa.gov/psd/cgi-bin/db_search/DBSearch.pl?
>> Variable=V-
>> ; Wind&Dataset=CDC+Derived+NCEP+Reanalysis+Products+Pressure+Level
>>
>> lat = uwind_file->lat(::-1)
>> print(lat)
>> lon = uwind_file->lon
>> lev = uwind_file->level
>> time = uwind_file->time
>>
>> nlat = dimsizes(lat)
>> nlon = dimsizes(lon)
>> nlev = dimsizes(lev)
>> ntime = dimsizes(time)
>>
>> ; make sure lat from -90. 90.
>> uwind = uwind_file->uwnd(:,:,::-1,:)
>> vwind = vwind_file->vwnd(:,:,::-1,:)
>>
>> printMinMax(uwind,True)
>> printMinMax(vwind,True)
>>
>>
>> setfileoption("bin","WriteByteOrder","BigEndian")
>>
>> path = "./wind.mon.ltm.bin"
>>
>> do itime=0,ntime-1
>>
>> do ilev=0,nlev-1
>> fbinrecwrite(path,-1,(/uwind(itime,ilev,:,:)/))
>> end do
>>
>> do ilev=0,nlev-1
>> fbinrecwrite(path,-1,(/vwind(itime,ilev,:,:)/))
>> end do
>>
>> end do
>>
>> ;************************************************************
>> ; note the -1 indicates to just add on to the end of the file
>> ; the (/.../) syntax means output the values only with no meta
>> ; data
>> ;************************************************************
>>
>> path1 = "./uwind.mon.ltm.bin"
>>
>> do itime=0,ntime-1
>> do ilev=0,nlev-1
>> fbinrecwrite(path1,-1,(/uwind(itime,ilev,:,:)/))
>> end do
>> end do
>>
>> ; read uwind and vwind binary file
>>
>> setfileoption("bin","ReadByteOrder","BigEndian")
>>
>> rec_dims=(/nlat,nlon/)
>> rec_type="float"
>>
>> uwnd=new( (/ntime,nlev,nlat,nlon/), rec_type )
>> vwnd=new( (/ntime,nlev,nlat,nlon/), rec_type )
>> rec_num = 0
>> do it=0,ntime-1
>> do il=0,nlev-1
>> uwnd(it,il,:,:)=fbinrecread(path,rec_num,rec_dims,rec_type )
>> rec_num=rec_num+1
>> end do
>>
>> do il=0,nlev-1
>> vwnd(it,il,:,:)=fbinrecread(path,rec_num,rec_dims,rec_type )
>> rec_num=rec_num+1
>> end do
>>
>> end do
>>
>> print("u-wind Min and Max values read from "+ path)
>> printMinMax(uwnd,True)
>> print("v-wind Min and Max values read from "+ path)
>> printMinMax(vwnd,True)
>>
>> ; read uwind only binary file
>> uwnd_o=new( (/ntime,nlev,nlat,nlon/), rec_type )
>> rec_num = 0
>> do it=0,ntime-1
>>
>> do il=0,nlev-1
>> uwnd_o(it,il,:,:)=fbinrecread(path1,rec_num,rec_dims,rec_type
>> )
>> rec_num=rec_num+1
>> end do
>>
>> end do
>>
>> print("u-wind Min and Max values read from "+ path1)
>> printMinMax(uwnd_o,True)
>> ;================================================;
>> ;================================================;
>> end
>>
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 30 09:25:14 2009

This archive was generated by hypermail 2.1.8 : Mon Nov 02 2009 - 08:49:47 MST