[ncl-talk] help loop

Vanúcia Schumacher vanucia-schumacher at hotmail.com
Tue Jan 16 06:11:09 MST 2018


Hi NCLs


I would like to create an array of 36 x 12 (time x months), but I can only generate one file at a time. Also calculate a file (36 x 12) for each lat and lon values from another file (91 values).
I tried the script below, but I am not able to generate a loop for what I want to get, if anyone can give a help I appreciate.


 lats  = asciiread("lat.txt",(/91,3/),"float")
 lons = asciiread("lon..txt",(/91,3/),"float")
 lat    = lats(:,1)
 lon    = lons(:,2)


 f = systemfunc("ls /cru.*.nc")  ; are 12 files separated by months

 N = dimsizes( f )

 do i = 0,N-1
a = addfiles(f(i), "r")
var = a[:]->pr(:,{lat},{lon})
 asciiwrite ("prec.cru."+i+".txt", sprintf("%9.2f", var))
 end do



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180116/90dbd8b5/attachment.html>


More information about the ncl-talk mailing list