[gradsusr] Printing out a single value from a grads script

Charles Seman Charles.Seman at noaa.gov
Fri Sep 24 16:28:45 EDT 2010


MK,

After "d steering", try adding:

say result
say sublin(result,2)

You can use a combination of "sublin()" and "subwrd()" (and even 
"substr()") commands to extract the desired information from "result"...

For example,

"d steering"
say result
line1 = sublin(result,1) ; word11 = subwrd(line1,1) ; word12 = 
subwrd(line1,2)
say line1 word11 word12
line2 = sublin(result,2) ; word21 = subwrd(line2,1) ; word22 = 
subwrd(line2,2)
say line2 word21 word22

Note, the number of "sublin" and "subwrd" values will depend on the 
"result" so this is why we issue the "say result" command (no quotes in 
script), to see what we've got...  I tried a test in a script I'm 
working on right now, and defined a "line3"  and tried printing it and 
also subwrd(line1,10) (both of which that didn't exist), and the script 
printed nothing but otherwise seemed OK...

For more information on this, please see 
http://grads.iges.org/grads/gadoc/script.html#intrinsic

Hope this helps,
Chuck

Michael Kevin Hernandez wrote:
> Dear Grads Users
>
> I am trying to do a simple command (see below):
>
>        "set gxout print"
>        "set prnopts %g"
>        say "Magnitude of steering at "level1" to "level2""
>        "d steering"
>
> The code doesn't print out steering, which is a single value real 
> ("aarea" of wind).  However in the command prompt i can type: d 
> steering; and the single value of steering shows up on the terminal.  
> However, doing this manually after my code for multiple levels will 
> take too much time.  So can someone help me?
>
> -- 
> MK Hernández
>
>  Pennsylvania State University                   
>     Department of Meteorology grad student 
>     http://met.psu.edu/~mkh182 <http://met.psu.edu/%7Emkh182>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>   

-- 

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 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  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect any
official or unofficial position of the United States Federal Government,
the United States Department of Commerce, or NOAA."




More information about the gradsusr mailing list