[ncl-talk] Asciwrite question

Barry Lynn barry.h.lynn at gmail.com
Sun Feb 5 13:20:54 MST 2017


Hello:

I would like to write variables with this format.

do i_sta = 0,n_stations-1
do it = 0,ntimes-1

write(station_name(i_sta),var1(i_sta,it),var2(i_sta,it),var3(i_sta,it),
a10,3(f6.2,1x))

end do
end do

I found this:

http://www.ncl.ucar.edu/Document/Functions/Built-in/asciiwrite.shtml

Example 2 in the new *write_table*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml>
function in NCL 6.1.0 is
one approach. Another approach: do your own line formatting.


     outfile = "out.txt"
     x = (/ (/ 4.35,   4.36,   9.73,   4.91 /), \
            (/ 4.39,   4.66,  -5.84,   4.59 /), \
            (/ 0.27,   3.77,   0.89,  -3.09 /)    /)


     dimx  = *dimsizes*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>
(x)
     nrows = dimx(0)                                  ; ncols = dimx(1)
     lines = *new*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/new.shtml>
(nrows, string)

     do i = 0, nrows-1
       lines(i) = *str_concat*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/str_concat.shtml>
(sprintf ("%7.2f,", x(i,:)))
     end do

     *asciiwrite* (outfile, lines)


The problem is that my variable need to write each station's data

for the time index before writing the next stations's data.


Thank you.


-- 
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170205/7a01fd01/attachment.html 


More information about the ncl-talk mailing list