help needed with ascii output
Jean Pierre Arabonis
arabonis at EGS.UCT.AC.ZA
Thu Sep 1 15:23:14 EDT 2005
Hi Matt
I work extensively with grads writing text and have found that the
following method, while not elegant is for me most effective, have a
look at my old positing below and apply to your problem. essentially
what I posted is an idiots' version of Jennifer's' script but is
probably easier to understand.
You will need to assign values to each variable then create the line
before writing the file.
Have a look at the script then give me some specifics and I'll give
you a hand.
Cheers
JP
Hi
fwrite will produce a binary file, you need to write a script,
somthing like the following for ascii, using the write command:
function main(args)
i = 1
while i <= 249
'set t ' i
'd htsgwsfc'
Val=subwrd(result,4)
write (Valuedir.txt,Val, append)
i = i + 1
endwhile
Good Luck
Jean Pierre
M P Borkow wrote:
>This listserv has been a life saver as I've been struggling with how to get
>grads output into a ascii text file for over a week, and now I feel like I'm
>making progress.
>
>After searching the archives I have tried (with success) using the following
>script posted by Jennifer Adams several years ago:
>
>function txtout()
>'open sst.master.ctl'
>'set gxout print'
>'set prnopts %12.8f'
>'d sst'
>ascii = result
>asciifile = 'test.txt'
>
>numbers = sublin(result,2)
>if (numbers != '')
> rc = write(asciifile,numbers)
>else
> say 'no ascii data to write'
>return
>endif
>
>i=3
>while(1)
> numbers = sublin(result,i)
> if (numbers!='')
> rc = write(asciifile,numbers,append)
> else
> break
> endif
> i = i+1
>endwhile
>close(asciifile)
>return 0
>
>However, I need to modify the script a bit and, no having much grads
>experience, don't know how to do so. What I'd essentially like to end up
>with is a text file with 3 columns per line...containing the variables
>latitude, longitude, and sst. Can explain to me how I need to go about
>modifying the script to do this? Right now the script just spits out the
>sst values with a couple spaces in between each value. Also, what exactly
>am I defining by doing 'prnopts %12.8f'?
>
>Thanks,
>Matt
>
>
>
--
Jean Pierre Arabonis
arabonis at egs.uct.ac.za
Tel 021 780 1021 cell 084 401 1365
This email is 100% Microsoft Free
More information about the gradsusr
mailing list