fields in GrADS

Charles Seman Charles.Seman at NOAA.GOV
Wed Feb 23 11:37:49 EST 2005


Kristian,

One possibility is to try:

a.count=subwrd(result,3)

this will generate a subscripted array "a" with ten values, for your
example.  Here is some documentation from
http://grads.iges.org/grads/gadoc/script.html#variables

------------------------------------------------------------------------------------------------------------------------------------------------

Compound string variables

Compound variables are used to construct arrays in scripts. A compound
variable has a variable name with segments separated by periods. For
example:

      varname.i.j

In this case, when the variable contents are accessed, i and j will be
looked up to see if they are also variables (non-compound). If they are,
the i and j will be replaced by the string values of i and j. For example:

      i = 10
      j = 3
      varname.i.j = 343

In the above example, the assignment is equivalent to:

      varname.10.3 = 343

Note that the string values of i and j may be anything, but the variable
name specification in the script must follow the rules for variable
names: letters or numbers, with a leading letter. The variable name
after substitution may be any string:

      i = 'a#$xx'
      varname.i = 343

The above is valid. However, we cannot refer to this variable name
directly:

      varname.a#$xx = 343

would be invalid.

Variable names may not be longer than 16 characters, either before or
after substitution.

Note that the GrADS scripting language is not particularly efficient in
handling large numbers of variables. Thus compound variables should not
be used to create large arrays:

      i = 1
      while (i < 10000)
         var.i = i
         i = i + 1
      endwhile

The above loop will create 10000 distinct variable names. Such a large
number of variables in the variable chain will slow the script down a lot.

------------------------------------------------------------------------------------------------------------------------------------------------

I hope this helps,
Chuck


Kristian Horvath wrote:

> Dear GrADS people,
>
> I would like to write a while loop and every time when passing the
> loop remember the value of a variable for manipulation after the loop.
>
> Something like:
>
> count=1
> while ( count <= 10 )
> 'd pslv/100'
>  'q pos'
>  a=subwrd(result,3)
> count=count+1
> endwhile
>
> where I would like to have values of a(1), a(2)...a(10) after in the
> script.
>
> I would appreciate any suggestions,
> Cheers,
> Kristian
>
> _________________________________________
>
> Kristian Horvath
> research fellow
> Croatian Meteorological and Hydrological Service
>


--

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08542                 http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20050223/d3357d54/attachment.html 


More information about the gradsusr mailing list