Output txt specific format

Stegert stegert at IFM.UNI-HAMBURG.DE
Tue Feb 12 08:30:45 EST 2008


Dear Ranyere,
folloing your ctl:
- ixmax would be 61 and
- iymax would be 76 and
- itmax would be 365

These are to be transferred into world coordinates
in the center loop:
_ilonmin equals -90.000 (at x = 1)
_dlon equals the increment of 1.
i.e. at x = 12 your ilon = _ilonmin + 12*_dlon

I included a full script as attachment, where I also
corrected a bug in doing the loop.

Three additions were made there, too:
1) Values can be read from the ctl-file using function getlevs
    (if you want to store only a part of the data you
     have to set boundaries manually)
2) undefined values can be left out (using "if...")
3) your current ctl will return 61*76*365 lines output - quite much.
    You can also store values of each day into a new file

Whether you need these or not you can check for yourself.
In any way: Looking at various skripts and see what they do
is, I think, the easiest way to learn how they work and
how to write your own.
So, good luck, and for any open question:
Fell free to ask...

Yours

*--- your ctl ---
dset ^20080104.ll
title SA Daily Precipitation from 20020101 to 20021231
options big_endian
options template
options sequential
undef 9999.
xdef   61 linear  -90.000  1.
ydef   76 linear  -60.000  1.
zdef    1 linear    1 1
tdef  365 linear 01jan2003 1dy
vars 1
p   0 0 daily precip  (mm/day)
ENDVARS

*--- loop for txt-output (---
* ix = 1 (BUG1: NOT HERE)
* iy = 1 (BUG1: NOT HERE)
it = 1
*or wherever you like to start

while (it <= itmax)
* where i*max has to be declared above
   'set t 'it
* BUG1: re-initiate iy here:
   iy = 1
   while (iy <= iymax)
     'set y 'iy
*   re-initiate ix here
     ix = 1
     while (ix <= ixmax)
       'set x 'ix
       ilon = _ilonmin + ix*_dlon
*      ilat = _ilatmin + ix*_dlat (it has to be iy of course)
       ilat = _ilatmin + iy*_dlat
*     _ilonmin and _dlon (and corresponding lats)
*     are those declared in your CTL
       'd var'
*     where var is your valiable
       var2 = subwrd(result,4)
       output = ilat'  'ilon'  'it'  'var2
       res = write('output.txt',output,append)
       ix = ix + 1
     endwhile
     iy = iy + 1
   endwhile
   it = it + 1
endwhile
st1 = close('output.txt')


Ranyére Nóbrega schrieb:
> Thanks Stegert.
> I'm having a problem with script.
> I do not have much knowledge with scripts in Grads, because of this Iask
> more its help again.
> What would be the variable dlon and dlat that you defined?
> Once again, thanks.

--
Christoph Stegert:  Ecological Modelling group
Institut für Meereskunde - Universität Hamburg, Germany
Zentrum f. Marine u. Atmosphärische Wissenschaften ZMAW
Bundesstr.53, 20146 Hamburg - Phone: +49-40/ 42838-7486
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: get_txt.gs
Url: http://gradsusr.org/pipermail/gradsusr/attachments/20080212/b8d6a4a0/attachment.pl 


More information about the gradsusr mailing list