[ncl-talk] Loop
Theomar Trindade
theomar_trindade at hotmail.com
Thu Mar 10 11:46:13 MST 2016
Dear NCL users fellows,
I'm trying to play a loop in my scipt:
----------------------------------------------------------------------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
do a=1,6
fname = "/home/theomar/Documents/Theomar/GobleATTO15/2015110"+a+"1100.txt"
data = asciiread(fname,-1,"string")
nfields = str_fields_count(data(11)," ")
print("number of fields = " + nfields)
time = stringtofloat(str_get_field(data(11:2492:), 1," ")) ;Time[min:sec]
Geo = stringtofloat(str_get_field(data(11:2492:), 2," ")) ;P[hPa]
T = stringtofloat(str_get_field(data(11:2492:), 3," ")) ;T[C]
U = stringtofloat(str_get_field(data(11:2492:), 4," ")) ;U[%]
; wks = gsn_open_wks("pdf","perfil_110215") ; Open an ps workstation.
wks = gsn_open_wks("pdf","perfil_110"+a+"15") ; Open an ps workstation.
a1 = gsn_xy(wks,T(:1100),Geo(:1100),False) ; Draw an XY plot with 1 curve.
a2 = gsn_xy(wks,U(:1100),Geo(:1100),False) ; Draw an XY plot with 1 curve.
plot=(/a1,a2/)
dims=(/1,2/)
gsn_panel(wks,plot,dims,False)
end do
delete(data)
delete(fname)
end
----------------------------------------------------------------------------------------------------------------------------
As answer it gives to me the file perfil_110"+a+"15 with a=1 and the follow error:
fatal:Dimension sizes of left hand side and right hand side of assignment do not match
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 12 in file perfil_v2.ncl
What am I doing wrong? If I write 2 instead a it runs normally.
Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160310/7803c911/attachment.html
More information about the ncl-talk
mailing list