function int

Tetsuo Nakazawa nakazawa at MRI-JMA.GO.JP
Thu Jun 4 02:41:41 EDT 2009


Dear GrADS users,

  I tried to use the function of int (truncate the real number to
integer),
but an error came when I used opengrads 2.0.a5.oga.5 for Mac OSX.

  The script and the anal_p.ctl are as follows

'open anal_p.ctl'
'set lon 30 180'
'set lat -40 40'
'i0=ugrdsfc*2.+1.'
'd i0'
'd int(i0)'

  It worked fine to "d i0", but when I did "d int(i0)", then
the following error message came.

Syntax Error:  Invalid Operand
   'int' not a variable or function name
   Error ocurred at column 1
DISPLAY error:  Invalid expression
   Expression = int(i0)


function int(i0)
   i=0
   while(i<12)
     i=i+1
     if(substr(i0,i,1)='.')
       i0=substr(i0,1,i-1)
       break
     endif
   endwhile
return(i0)


* content of anal_p.ctl

dset ^anal_p.%y4%m2%d2%h2
index ^anal_p.idx
undef 9.999E+20
title grib.anal_p
dtype grib 255
options yrev template
ydef  145  linear  -90.0  1.25
xdef  288  linear    0.0  1.25
tdef 124 linear 00Z01jan1979 6hr
zdef 23  levels
1000 925 850 700 600 500 400 300 250 200 150 100 70 50 30 20 10 7 5 3
2 1 0.4
vars 13
HGTprs   23 7,100,0   ** Geopotential height            [gpm]
TMPprs   23 11,100,0  ** Air temperature                  [K]
SPFHprs  23 51,100,0  ** Specific humidity            [kg/kg]
DEPRprs   8 18,100,0  ** Dew point depression             [K]
UGRDprs  23 33,100,0  ** Zonal wind                     [m/s]
VGRDprs  23 34,100,0  ** Meridional wind                [m/s]
CWATprs  12 76,100,0  ** Cloud water content         [kg/m^2]
PRMSLmsl  0 2,102,0   ** Pressure reduced to MSL         [Pa]
TMPsfc    0 11,105,2  ** Surface 2m air temperature       [K]
SPFHsfc   0 51,105,2  ** Surface 2m specific humidity [kg/kg]
DEPRsfc   0 18,105,2  ** Surface 2m dew point depression  [K]
UGRDsfc   0 33,105,10 ** Surface 10m zonal wind         [m/s]
VGRDsfc   0 34,105,10 ** Surface 10m meridional wind    [m/s]
ENDVARS



********************************************
Tetsuo Nakazawa
                       nakazawa at mri-jma.go.jp
Typhoon Research Department
Meteorological Research Institute
Tel:  029-853-8671 Fax: 029-853-8735
********************************************



More information about the gradsusr mailing list