Re: ascii writewrite

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 24 2011 - 08:17:59 MDT

You should take the "asciiwrite" out of the "do loop". Every time in the do loop you are overwriting it. The idea is to use the "do" loop
to fill up the "strs" array, and then when you're done, write everything to the ASCII file. "asciiwrite" doesn't allow you to append,
unfortunately.

do x =0,11
yy(x) = big(x,0)
hh(x) = big(x,1)
nn(x)= big(x,2)
mm(x) = big(x,3)
. . .
end do

asciiwrite("test.txt",strs)

On Oct 21, 2011, at 8:30 PM, cnl88 wrote:

> the script run one time it turns out 4 varibles that are constants
> I run 12 times and i want to write the 12 lines in one file
> each by each
> but it only write the last line the ncl runs and all previous results are missing!
>
> need for your help
> thank you
>
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "/usr/local/ncl/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> load "/usr/local/ncl/lib/ncarg/nclscripts/csm/contributed.ncl"
> ;************************************************
> begin
> big = asciiread("./nlcheng3-4chuance2.txt",(/6336,4/),"integer")
> line = 6336
> yy = new((/line/),integer)
> hh = new((/line/),integer)
> nn = new((/line/),integer)
> mm = new((/line/),integer)
> do x =0,11
> yy(x) = big(x,0)
> hh(x) = big(x,1)
> nn(x)= big(x,2)
> mm(x) = big(x,3)
>
> fn = "/home/nlcheng/huatu111111111/cmaq/chou/ln/METCRO2D_"+yy(x)+".nc"
> a = addfile(fn,"r")
> fon = "nlcheng-result.txt"
> t=hh(x)
> m=mm(x)
> n=nn(x)
> PBL = a->PBL(t,0,m,n)
> TEMP2= a->TEMP2(t,0,m,n)
>
> WSPD10 = a->WSPD10(t,0,m,n)
> WDIR10=a->WDIR10(t,0,m,n)
> print(PBL)
>
>
> nvals = 12
> fmtx = "%14.6f"
> title = " PBL(m) TEMP2(K) WSPD10(m/s) WDIR10(DEGREES)"
> vals = sprintf(fmtx,PBL) + " " + sprintf(fmtx,TEMP2) + " " + \
> sprintf(fmtx,WSPD10) + " " + sprintf(fmtx,WDIR10)
> strs = new(nvals+1,string)
> strs(0) = title
> strs(x+1:x+1) = vals
> asciiwrite("test.txt",strs)
> end do
> end
> <截图1.png>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 24 08:18:06 2011

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2011 - 09:29:35 MDT