[ncl-talk] Asciwrite question
Tao Lu
hakufu.asano at gmail.com
Sun Feb 5 20:24:54 MST 2017
Hello Barry
1. If I did this, I will make station_name(i_sta) to ,station_name(i_sta,it)
Then I can use write_table to do pretty print.
2. Also, you can make a fortran subroutine to do this.
Above is my experiences. If 1. take time, 2. may be an efficient way.
Hope this help,
Tao
On Mon, Feb 6, 2017 at 5:20 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:
> 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 <(914)%20432-3108>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
******************************************************
盧 涛 (ル タオ) 修士課程2年
〒112-8551 東京都文京区春日1-13-27
中央大学理工学研究科都市環境学専攻
河川・水文研究室(山田正教授)
TEL: 03-3817-3406; Phone: 070-2188-7509
Email1: hakufu.asano at gmail.com <mail%3Amet.yamos at gmail.com>
Email2: lutao at civil.chuo-u.ac.jp <mail%3Ayamoto at civil.chuo-u.ac.jp>
*******************************************************
******************************************************
Tao Lu (M. Eng)
Laboratory of River Engineering and Hydrology,
Dept. of Civil and Environmental Engineering,
Graduate School of Science and Engineering,
Chuo University
1-13-27,Kasuga,Bunkyo-ku,Tokyo
112-8551, Japan
TEL: 03-3817-1805; Phone: 070-2188-7509
Email1: hakufu.asano at gmail.com <mail%3Amet.yamos at gmail.com>
Email2: lutao at civil.chuo-u.ac.jp <mail%3Ayamoto at civil.chuo-u.ac.jp>
*****************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170206/01d8ae64/attachment.html
More information about the ncl-talk
mailing list