"define" values are different. why?

Michael Fiorino Michael.Fiorino at NOAA.GOV
Tue Jun 19 13:56:29 EDT 2007


mary jo, the technical reason, is that the code that does "display" is
NOT the same as does "define"   there are some situations where i could
not define a variable resulting from a user defined function and had to
resort to 'fwrite' to put out and bring back in -- a clumsy process.  i
believe this difference is going away in grads2... /r mike

Mary Jo Nath wrote:
> Hi,
>
> I wasn't able to find anything on the board regarding this issue.
> Maybe someone can explain why do I get different values in the script
> (below) for the defined variable "a" & "b" ? ("b" and "c" are the same
> and correct.)  I would expect a = b = c regardless of how I access the
> values of those variables.
>
> Below is the full script and the results. The data file is attached if
> anyone would like to run the script on their machine . If you get
> different results, please let me know.
>
> (I'm using Config: v1.9b4 32-bit little-endian on a Linux workstation.
> I get the same results, though, using older versions 1.7beta9 and
> 1.8SL10.)
>
>  I think this is occurring because of this data's grid, where X=1 is
> longitude 1.25E instead of 0E. By default GrADS maps "set lon 0 360"
> into "X = 0.5 to 144.5", so however "define" works, GrADS returns  the
> proper value for "a" if "set x 30" is done first, but doesn't return
> the expected value if you do
> "d a(x=30)". Variables "b" and "c" work because I explicitly "set x 1
> 144" or "set lon 1.25 358.75" (which correspond to X=1 and X=144 ).
>
> When I ran a similar script using NCEP data which starts at Lon = 0.,
> I didn't have this problem.
>
> Thanks,
> Mary Jo
>
> SCRIPT:
>
> sdfopen model.slp.nc
> set lat 0
> q dims
> define a=slp
> set x 1 144
> q dims
> define b=slp
> set lon 1.25 358.75
> q dims
> define c=slp
> set x 30
> d a
> d b
> d c
> d a(x=30)
> d b(x=30)
> d c(x=30)
> d a-b
> d a(x=30)-b(x=30)
> d a-c
> d a(x=30)-c(x=30)
> d b-c
> d b(x=30)-c(x=30)
>
>
> RESULTS:
>
> *sdfopen /net2/mjn/model.slp.nc*
> Scanning self-describing file:  /net2/mjn/model.slp.nc
> SDF file /net2/mjn/model.slp.nc is open as file 1
> LON set to 0 360
> LAT set to -89.4944 89.4944
> LEV set to 0 0
> Time values set: 1870:1:16:12 1870:1:16:12
> *set lat 0*
> LAT set to 1.01124 1.01124
> *q dims*
> Default file number is: 1
> X is varying   Lon = 0 to 360   X = 0.5 to 144.5
> Y is fixed     Lat = 1.01124  Y = 46
> Z is fixed     Lev = 0  Z = 1
> T is fixed     Time = 12Z16JAN1870  T = 1
> *define a=slp*
> Define memory allocation size = 584 bytes
> *set x 1 144*
> LON set to 1.25 358.75
> *q dims*
> Default file number is: 1
> X is varying   Lon = 1.25 to 358.75   X = 1 to 144
> Y is fixed     Lat = 1.01124  Y = 46
> Z is fixed     Lev = 0  Z = 1
> T is fixed     Time = 12Z16JAN1870  T = 1
> *define b=slp*
> Define memory allocation size = 576 bytes
> *set lon 1.25 358.75*
> LON set to 1.25 358.75
> *q dims*
> Default file number is: 1
> X is varying   Lon = 1.25 to 358.75   X = 1 to 144
> Y is fixed     Lat = 1.01124  Y = 46
> Z is fixed     Lev = 0  Z = 1
> T is fixed     Time = 12Z16JAN1870  T = 1
> *define c=slp*
> Define memory allocation size = 576 bytes
> *set x 30*
> LON set to 73.75 73.75
> *d a*
> Result value = 1010.45
> *d b*
> Result value = 1010.45
> *d c*
> Result value = 1010.45
> *d a(x=30)*
> Result value = 1010.57   /<==== ????/
> *d b(x=30)*
> Result value = 1010.45
> *d c(x=30)*
> Result value = 1010.45
> *d a-b*
> Result value = 0
> *d a(x=30)-b(x=30)*
> Result value = 0.122498  /<==== a != b/
> *d a-c*
> *Result value = 0
> d a(x=30)-c(x=30)*
> Result value = 0.122498  /<=== a != c/
> *d b-c*
> Result value = 0
> *d b(x=30)-c(x=30*)
> Result value = 0
> EOF EXECuting test_script



More information about the gradsusr mailing list