Hi Guangshan,
There's no way to do this the way you are indicating below, but you can do this a kludgy way using attributes.
If you treat the three variables as attributes of another variable, then you can use the special "$" syntax.
For example, let's say you have a variable called "ccsm_var". It doesn't really matter what type it is. You can make it logical.
Further assume this variable has three attributes attached to it, each an array of 10 elements:
ccsm_var@ccsm_var_EAS = (/...array of 10 elements.../)
ccsm_var@ccsm_var_SAS = (/...array of 10 elements.../)
ccsm_var@ccsm_var_NAU = (/...array of 10 elements.../)
You can now do this:
reg_nm = (/"EAS","SAS","NAU"/)
do i=0,2
var_str = "ccsm_var_" + reg_nm(i)
ccsm_var_3reg(i,:) = ccsm_var@$var_str$
end do
We have it our list to be able to use the "$..$" type of syntax directly. Right now, you can only use this syntax when referencing metadata of another variable.
--Mary
On Sep 13, 2010, at 1:18 PM, Guangshan Chen wrote:
> Dear there,
>
> Let's say that I have the following variables for three regions:
> ccsm_var_EAS(10),
> ccsm_var_SAS(10),
> ccsm_var_NAU(10)
>
> Now I want to create a new array to hold these three varaibles:
> ccsm_var_3reg = new((/3,10/),float)
>
> if I create a string array to hold the region name:
> reg_nm = (/"EAS","SAS","NAU"/)
>
> How could I use do loop to put the three variables to ccsm_var_3reg?
>
> some thing like this:
>
> do i=0,2
> ccsm_var_3reg(i,:) = ccsm_var_"reg_nm(i)"
> end do
>
> Guangshan
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 14 09:35:35 2010
This archive was generated by hypermail 2.1.8 : Thu Sep 16 2010 - 11:05:24 MDT