Re: varible name

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 08 2010 - 12:57:50 MST

function createVar()
begin
   x = new ((/10, 64, 128/), double)
   x!0 = "time"
   x!1 = "lat"
   x!2 = "lon"
   return( x)
end

   xNEWi_temp = createVar()
   xNEWi_pcp = createVar()
   xNEWi_dlw = createVar()
   xNEWi_dsw = createVar()

   printVarSummary(xNEWi_temp)
==========================================
?better?

function createVar(longName[1]:string, units[1]:string)
begin
   x = new ((/10, 64, 128/), double)
   x!0 = "time"
   x!1 = "lat"
   x!2 = "lon"
   x@long_name = long_name
   x@units = units
   return( x)
end

   xNEWi_temp = createVar("temperature", "K")
   xNEWi_pcp = createVar(...)
   xNEWi_dlw = createVar(...)
   xNEWi_dsw = createVar(...)

   printVarSummary(xNEWi_temp)

===========================================

If you are creating your own library of NCL functions
(say, "MyLib.ncl"), then place the function in it

load "MyLib.ncl"

   xNEWi_temp = createVar("temperature", "K")
   xNEWi_pcp = createVar(...)
   xNEWi_dlw = createVar(...)
   xNEWi_dsw = createVar(...)

   printVarSummary(xNEWi_temp)

David Brown wrote:
> Hi Sanjiv,
> Currently string references only work for variables in files. We have
> it on our to-do list to make it possible to reference regular
> variables in the same way.
> -dave
>
> On Jan 8, 2010, at 11:57 AM, Sanjiv Kumar wrote:
>
>> Hello,
>>
>> I want to use follwing expression
>>
>> var = (/"xNEWi_temp", "xNEWi_pcp", "xNEWi_dlw", "xNEWi_dsw"/)
>>
>> do i = 0, 3
>> $var(i)$ = new ((/10, 64, 128/), double)
>> $var(i)$!0 = "time"
>> $var(i)$!1 = "lat"
>> $var(i)$!2 = "lon"
>> end do
>>
>> but some how it is not working. Can you please see it
>>
>> Main question is:
>>
>> If there is a string array contaning a list of varibles. How there
>> varibles can be called during the program.
>>
>>
>> thanks
>> sanjiv
>>
>>
>>
>>
>>
>> _______________________________________________
>> 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
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 8 12:59:22 2010

This archive was generated by hypermail 2.1.8 : Tue Jan 12 2010 - 15:38:20 MST