[ncl-talk] Creating variables automatically
Rick Brownrigg
brownrig at ucar.edu
Mon Oct 8 15:17:27 MDT 2018
One can't create variables in that way. However, you can create attributes,
so using your example, something like:
res = True ; arbitrary value
*do i = 1, 5*
* varname = "cases_"+sprinti("%i",i)+"days"*
* res@$varname$ = new( (/ nlat, nlon /), "float" )*
* res@$varname$ = dim_avg_n( slp( idxCases, :, : ), 0 )*
*end do*
*Hope that helps...*
*Rick*
On Mon, Oct 8, 2018 at 3:08 PM Mateus da Silva Teixeira <
mateusstex at gmail.com> wrote:
> Hi,
>
> Can I use string reference to create different variables in NCL?
>
> I'm trying it
>
> *do i = 1, 5*
> * varname = "cases_"+sprinti("%i",i)+"days"*
> * $varname$ = new( (/ nlat, nlon /), "float" )*
>
> * $varname$ = dim_avg_n( slp( idxCases, :, : ), 0 )*
> *end do*
>
> But NCL is giving syntax error. It seems that I can't use string
> references that way. So, would there be a way to do this?
>
> Thanks.
>
> Mateus
>
> _______________________________________________
> 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/20181008/870706cb/attachment.html>
More information about the ncl-talk
mailing list