[gradsusr] Finding the maximum value of Ri in a single grid point

Lippo Nester liikkuvattaakse at gmail.com
Thu Nov 3 06:23:48 EDT 2011


Hi!

I've been trying to create my very first GrADS-script. The script should
compute values of the bulk Richardson number in a specific grid point
between predefined model levels and then find the minimum value of Ri and
probably the model level associated with it.

I tried to do this using while and if loops, but for some reason it's not
working as I expected. Maybe I can't understand handling variables in GrADS?

In this script the top and the bottom model layers are set to 40 and 50. Ri
is computed and I get a list of the Ri at different levels, and they seem
to be ok. However the variable "minri" gets always the value of ri at the
lowest model level (here: ri at level 50). Variable "minlevel" is always
the highest model level (here: level 40)!

When count is 40 at the first step of the while-loop, the value of ri
should be saved into variable minri and the model level at minlev. After
that, if ri < minri at lower levels (count > 40), values of minri and
minlev should be varied by the second if-loop...

Is there a more simple or more correct way to do this? I thought max()
can't make it...

Any help is much appreciated!

Best regards, Lippo

(version of GrADS 2.0.a1)

'set lat 50.00'
'set lon 10.00'
botlevel=50
toplevel=40

count=toplevel

while (count <= botlevel)

'set lev 'count
'define th1 = temp * (pow(100000 / press , (0.286)))'
'define u1 = u'
'define v1 = v'
'define z1 = geopot/9.81'

'set lev 'count - 1
'define th2 = temp * (pow(100000 / press , (0.286)))'
'define u2 = u'
'define v2 = v'
'define z2 = geopot/9.81'

'define
ri=9.81/(0.5*th1+th2)*(th2-th1)/(pow((u2-u1),2)+pow((v2-v1),2))*(z2-z1)'

'd 'ri
say result *THIS SEEMS TO WORK AS I GET 10 DIFFERENT VALUES OF RI

if (count = toplevel) *THESE IF-LOOPS AREN'T OKAY, BUT WHY?
minri = ri
minlevel = count
endif

if (ri < minri)
minri = ri
minlevel = count
endif

count = count+1
endwhile

'd 'minri
say "Min Ri " result *ALWAYS THE VALUE OF RI AT LEVEL 50 (AT THE BOTTOM
LEVEL)
'd 'minlevel
say "Model level " result *ALWAYS LEVEL 40 (TOP LEVEL)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111103/ed696597/attachment-0003.html 


More information about the gradsusr mailing list