[ncl-talk] Loop

Walter Kolczynski walter.kolczynski at noaa.gov
Thu Mar 10 18:08:06 MST 2016


Based on the error message, it looks like it is dying when time goes to 
be overwritten on the second loop, but it looks like it should still be 
the same size. Deleting the variables at the end of the loop would 
probably get it to run, but this might be indicating unexpected 
behavior. I would run a printVarSummary on time each loop to confirm it 
is giving the expected dimensions each loop.

- Walter

On 2016-03-10 20:03, Dennis Shea wrote:
> 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 <mailto: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"
>
>     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,
>
>     _______________________________________________
>     ncl-talk mailing list
>     ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>     List instructions, subscriber options, unsubscribe:
>     http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160310/464c0535/attachment.html 


More information about the ncl-talk mailing list