[gradsusr] How to write data in a file

Nick Heath nkh09 at fsu.edu
Wed Sep 28 08:44:34 EDT 2011


Hey,

At the end of your script, after 'd avez' add this line..
average=subwrd(result,4)
write(test.txt,average)

When you display a variable with a single value, GrADS writes the value to the terminal in a format like this
Result value = xxxx
So, you just have to tell it to grab the xxxx part of the output.

Hope that helps!
-Nick

That should do it

----- Original Message -----
From: Arlindo da Silva <dasilva at alum.mit.edu>
Date: Wednesday, September 28, 2011 12:28 pm
Subject: Re: [gradsusr] How to write data in a file
To: GrADS Users Forum <gradsusr at gradsusr.org>

> On Wed, Sep 28, 2011 at 12:56 AM, sushant puranik
> <sushantpuranik at gmail.com>wrote:
> 
> > Hi
> > I am trying to make average of vorticity over four points as
> >
> > set lev 850
> > define zeta=hcurl(uwnd,vwnd.2)
> > set lat 12.5
> > set lon 100
> > define z1=zeta
> > clear
> > set lat 10
> > set lon 100
> > define z2=zeta
> > clear
> > set lat 12.5
> > set lon 97.5
> > define z3=zeta
> > clear
> > set lat 10
> > set lon 97.5
> > define z4=zeta
> > clear
> > define avez=(z1+z2+z3+z4)/4
> > d avez
> > write (testz.txt,te)
> >
> >
> > But the output file remains blank.
> >
> > whats wrong with the script?
> >
> >
> What kind of script is this? Exec? Recall that write() is a gs script
> function, not something you call from the "ga->" command line. Read 
> thesection of the User's Guide on scripts:
> 
>     http://grads.iges.org/grads/gadoc/script.html#intro
> 
> Make sure you define the variable "te" that you are writing to the 
> file, and
> that the file name is a string.
> 
> -- 
> Arlindo da Silva
> dasilva at alum.mit.edu
> 



More information about the gradsusr mailing list