# [gradsusr] Help with do loops

Alan Robock robock at envsci.rutgers.edu
Mon Jun 3 19:17:24 EDT 2019

```Hi,

I haven't used grads for several years and am a little rusty.  I was
there when it was invented by Brian Doty at the Univ. of Maryland, but
my students have had the pleasure for years and now have moved onto NCL
and python.  However, I would still like to use grads for some simple tasks.

I am analyzing the NCAR Large Ensemble with 40 ensemble members and want
to average some values over the ensemble.  For example, I want to
calculate the mean of the five-year periods of DJF values, for each
ensemble and for the average over all ensembles, and then calculate the
anomaly with respect to that mean  I have tried writing a script, but am
confused as to where the ' go.  Can somebody help me?  For example, if I
just do this from the command line or in an exec for one ensemble
member, it works:

fiymne1 = (ave(ta.1, time = 1dec1986,time=1feb1987)+ ave(ta.1, time =
1dec1987,time=1feb1988)+ ave(ta.1, time = 1dec1988,time=1feb1989) +
ave(ta.1, time = 1dec1989,time=1feb1990)+ ave(ta.1, time =
1dec1990,time=1feb1991))/5
*
djf19911992e1 = ave (ta.1, time = 1dec1991,time=1feb1992)
*
d (djf19911992e1 - fiymne1)

I even know there is probably a more efficient way to even do the first
expression.

I can open all 40 files with the variables.  Is there a way to produce
an indexed value for the five-year mean for all ta.1, ta.2, ... ta.40,
and then use it is a "do loop"?

I know I am showing my age using grads and Fortran notation, but if I
don't have to learn another language, that would make my life easier.
Thanks.

--
Alan
_________________________________________________________________________
Alan Robock, Distinguished Professor
Associate Editor, Reviews of Geophysics
Department of Environmental Sciences             Phone: +1-848-932-5751
Rutgers University                    E-mail: robock at envsci.rutgers.edu