GrADS crashes on multiple loops

Lifeng Luo luo at ENVSCI.RUTGERS.EDU
Fri Apr 1 15:06:30 EST 2005


Hi, GrADS users,

I am using GrADS to extract time series from a grib file to ASCII format
for a selected region. I have the following 5 loop index: y, x, year,
leadtime, file. The script is quite simple, nothing fancy. But GrADS
always crashes at certain step, for example,
y=8,x=10,year=10,leadtime=3,file=10. It seems to be a memory problem
because if I change the range of y from 1-10 to 2-11, it will crash at
y=9,x=10,year=10,leadtime=3,file=10, instead of y=8.  Any ideas?  The
script is as below...

Thanks!

-Lifeng

***************************************************

'reinit'
'open file1.ctl'
'open file2.ctl'
...
...
'open file17.ctl'

*loop through all selected grids
*Here defines the region
xmn=144
xmx=152
ymn=59
ymx=68

fmt = '%-10.4f'
fmt2 = '%-6.3f'

y=ymn
while(y<=ymx)
'set y 'y
x=xmn
while(x<=xmx)
'set x 'x

'q dims'
ret=sublin(result,2)
res=subwrd(ret,6)
lon=math_format(fmt2,res)
ret=sublin(result,3)
res=subwrd(ret,6)
lat=math_format(fmt2,res)

filename=prate_01_%lat%_%lon
*say filename

*loop through all years
yr=0
while(yr<23)
year=1981+yr

t=1
while(t<=9)

ttt=t+yr*12
'set t 'ttt
record=year%" 01 "%t
f=1
while(f<=17)
'set dfile 'f
*display the variable
'd 86400*prate'
v=subwrd(result,4)
say x" "y" "yr" "t" "f" "v
mod= math_format(fmt,v)
record=record%"  "%mod
f=f+1
endwhile
res=write(filename, record)
t=t+1
endwhile
yr=yr+1
endwhile

res = close(filename)
status = sublin(res,1)
if(status != 0)
     say "close error #"status
     'quit'
endif

x=x+1
endwhile
y=y+1
endwhile

'quit'



More information about the gradsusr mailing list