[gradsusr] If else condition in GRADS

M.Adnan Abid madnanabid at gmail.com
Mon Sep 24 12:24:33 EDT 2012


Hi Mubashar

Try maskout function

Adnan

On Mon, Sep 24, 2012 at 7:05 PM, Mubashar Dogar <mubashardogar at gmail.com> wrote:
> 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
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr



More information about the gradsusr mailing list