[ncl-talk] Loop
Dennis Shea
shea at ucar.edu
Thu Mar 10 18:03:08 MST 2016
I don't know!
==
Try
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
tStrt = 11
tLast = 2492
pltType = "pdf"
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 := tofloat(str_get_field(data(tStrt:tLast:), 1," ")) ;Time[min:sec]
Geo := tofloat(str_get_field(data(tStrt:tLast:), 2," "))
;P[hPa]
T := tofloat(str_get_field(data(tStrt:tLast:), 3," ")) ;T[C]
U := tofloat(str_get_field(data(tStrt:tLast:), 4," ")) ;U[%]
; wks = gsn_open_wks(pltType,"perfil_110215") ; Open an ps
workstation.
wks = gsn_open_wks(pltType,"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, fname /])
end
On Thu, Mar 10, 2016 at 11:46 AM, Theomar Trindade <
theomar_trindade at hotmail.com> wrote:
> Dear NCL users fellows,
>
> I'm trying to play a loop in my scipt:
>
>
> ----------------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"begindo
> 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,
> <theomar.neves at cptec.inpe.br>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160310/7ff0b14d/attachment.html
More information about the ncl-talk
mailing list