Fwrite output (WINDOWS) in .txt or ASCII format (vs unreadable binary)

Henrique Barbosa hmjbarbosa at GMAIL.COM
Wed Nov 1 20:36:01 EST 2006


Jason,

Check the grads help files:

http://www.iges.org/grads/gadoc/script.html

Under the intrinsic functions section. You will see that
there is a write (not fwrite) command for writing ascii (text)
data into plain files that you will be able to open
with your favorite text editor.

How do you calculate your equations? I mean, is it from
an external function? or is it from a grads script?

Example: area average... Input: field, Output: single value.
If you do:

display aave(my_field,g)

You will see on the screen a line containing your result (one number).
If you want to write this result to a file, you will need to do some
thing like:

'display aave(my_field,g)'
val=subwrd(result,4)
rc=write(filename,val)

remember that you cannot type these into the grads prompt...
it must be inside a gs script called from grads. If you need
to write your 10 values in the same line, then:

line=val1' 'val2' 'val3' '....
rc=write(filename,line)

See ya,

Henrique


On 11/1/06, Jason E Patla <patla at hawaii.edu> wrote:
> Henrique,
> Thank you for your reply.  You answered a lot of my questions/concerns.
> One clarification, however....   You wrote "then use write command within a script."   Did you mean Fwrite or is there a way to display a bunch of variables on the GRADS input screen using a WRITE command?  D (display) doesn't seem to work.
> My situation is strange since my equations yield single numbers/components (vs a field), but I have about 10 of them at a time.  I hoped to make appear instead of requesting individually.
> Again, thank you very much for your help.
> Jason
>
> ----- Original Message -----
> From: Henrique Barbosa <hmjbarbosa at GMAIL.COM>
> Date: Wednesday, November 1, 2006 2:51 pm
> Subject: Re: Fwrite output (WINDOWS) in .txt or ASCII format (vs unreadable binary)
> To: GRADSUSR at LIST.CINECA.IT
>
> > Dear Jason,
> >
> > Fwrite will write output in binary format, i.e., a sequence of bytes
> > in a archive without formating... Therefore, you will not be able
> > to see the values if you open it with a text editor, for instance.
> >
> > If you want to write an ascii file, then use write command, within
> > a script. Look at the documentation:
> >
> > http://www.iges.org/grads/gadoc/gadocindex.html
> >
> > If you need a binary file thou, than fwrite is the way to go.
> > Remember that you have to:
> >
> > set gxout fwrite
> > set fwrite <options> <file name>
> >
> > To open or deal with these binary files you will need a
> > fortran or c program... well, matlab will also do it...
> > and of course, grads, if you write a ctl appropriate
> > for you binary output.
> >
> > {}'s
> > Henrique
> >
> > On 11/1/06, Jason E Patla <patla at hawaii.edu> wrote:
> > > GRAD User,
> > > Anyone know a way to FWRITE output that is able to be edited (or
> > even read) on a PC?
> > > I tried .txt.  I can't read .dat and tried a number of programs.
> >  Fwrite almost appears useless on my laptop (which is all I've
> > got).  :(
> > > Thanks for any help you can provide.
> > > Jason
> > >
> >
>



More information about the gradsusr mailing list