[gradsusr] If else condition in GRADS

Mubashar Dogar mubashardogar at gmail.com
Mon Sep 24 12:05:04 EDT 2012


Dear GrADS users,

I have 30 years time series data in a file named "File.ctl". The name
of the variable in the file is "output" and it has different value for
each year.

I wanted to use if/else in GrADS. My condition is that if my output
value is greater than "0" then write a new variable as "alpha=0.4"
else "alpha=0".

Following are few lines that I tried but it is only saving one value
for each year
'open File.ctl'
'set gxout fwrite '
'set fwrite alpha.dat'
'set t 1 30'
if (output>0)
'define alpha=0.4'
else
'define alpha=0'
endif
'd alpha'
But it is giving only one value that is 0.4 for all years. what's wrong in this?

Thanks,

Mubashar



More information about the gradsusr mailing list