Hi,
There was a better solution than what I told you before. I'm jet-lagged and not thinking clearly. :-)
Instead of printing "dados" to the screen, you can save each line to a "dados" string array, and then write the string array to a file using asciiwrite.
So, before the "do" loop, you would have something like this:
max_lines = 100000 ; change this as needed
dados = new(max_lines,string)
nlines = 0
Inside of the do loop, instead of:
dados = ( sprintf("%6.2f",vd) + sprintf("%7.2f",tcd) + sprintf("%7.2f",prpd) + \
sprintf("%8.2f",sinid) + sprintf("%8.2f",linid) + sprintf("%8.2f",urd) )
print("" + dados)
do this:
dados(nlines) = ( sprintf("%6.2f",vd) + sprintf("%7.2f",tcd) + sprintf("%7.2f",prpd) + \
sprintf("%8.2f",sinid) + sprintf("%8.2f",linid) + sprintf("%8.2f",urd) )
nlines = nlines+1
When the do loop is done, do this:
asciiwrite("fileout.txt",dados(0:nlines-1))
--Mary
On Oct 8, 2012, at 10:14 AM, Guilherme Martins wrote:
> Hi Mary,
>
> I want to save the result in file txt without the "ncl -Q -n media_diaris.ncl > fileout.txt". The file that I'm using is in attach. The script it's ok.
>
> Thanks,
>
> Guilherme.
>
> 2012/10/8 Mary Haley <haley@ucar.edu>
> Hi Guilherme,
>
> You didn't say exactly what the problem is. The script looks okay, but I can't execute it without the ASCII file, so I'm not sure what it's doing.
>
> To run your script, you should use:
>
> ncl -Q -n media_diaris.ncl > fileout.txt
>
> The "-Q" turns off the header stuff that gets echoed by NCL (like the version number, the copyright, etc), and the "-n" turns off those "(0)" characters at the beginning of each lilne.
>
> Given that you are formatting each string differently, using "sprintf" is the correct way to go. "asciiwrite" only writes one line per row.
>
> In NCL Version 6.1.0, you will be able to use "print_table":
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/print_table.shtml
>
> --Mary
>
> On Oct 8, 2012, at 5:35 AM, Guilherme Martins wrote:
>
> > Hi users,
> >
> > I want to write to txt file, but I don't get. I tried the asciiwrite, but it don't work. See the file in attach.
> >
> > Thanks,
> >
> > Guilherme.
> >
> > --
> > Guilherme Martins
> > http://guilhermemartins.hd1.com.br/
> >
> >
> >
> > <media_diaris.ncl>_______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Guilherme Martins
> http://guilhermemartins.hd1.com.br/
>
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 8 15:47:31 2012
This archive was generated by hypermail 2.1.8 : Mon Oct 08 2012 - 15:54:16 MDT