[ncl-talk] convert string to variable name

Wei Huang whuang at univ-wea.com
Fri Aug 28 10:18:45 MDT 2015


Change:
b = $a + "a01"$
to:

b = a + "a01"


Wei Huang

From: ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of Zhifeng Yang
Sent: Friday, August 28, 2015 10:59 AM
To: Talk NCL
Subject: [ncl-talk] convert string to variable name

Hi
I wanted to change variable names through strings. Since I use the similar property while I read variable from .nc file. For instance,
a = "var"
b = addfile(filename + ".nc", "r")
c = b->$a$
In this case, I can change a to change the variable names.

Now I wanted to use the similar feature to modify variable names. For instance,
a is a string,
a = "var"
b is a variable. I want to modify b by using
b = $a + "a01"$
Unfortunately, I got the error below.

fatal:syntax error: line 1 before or near $
b = $
Do you know whether these is any way to change the variable name like what I want?
Thank you
Zhifeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150828/1c3bc676/attachment.html 


More information about the ncl-talk mailing list