[ncl-talk] Dynamic Variable Names (with unique prefix/suffix)

Alan Rhoades alan.m.rhoades at gmail.com
Tue Oct 20 12:33:58 MDT 2015


Hello,

I'm currently trying to make dynamic variable names within NCL (i.e., with
unique prefix and/or suffix, but consistent patterns for each variable).
I've tried to track down a solution for my current problem via the NCL
archives, but can't seem to find it.  A post in 2010 said that this type of
NCL scripting wasn't yet possible, but I was curious if an update had
occurred.

I'm trying to do the following...

Assess several different mountain ranges
With four different variables (SNOWFALL, SNOWC, SWE, TSA)
Across four different elevation classes (500 m, 1000 m, 1500 m, 2000 m)

This is my current stab at making the dynamic variable names within NCL,
but of course, it isn't working (although the print statement is working,
the NCL functions just don't like the syntax used to name the dynamic
variable names).  Here is a snippet of the code...

;------------------------------------------------------
;  STAT DISPERSION
;------------------------------------------------------
 opt = True
 opt at PrintStat = True

 vars = (/"SNOWFALL","SNOWC","SWE","TSA"/)
 elev = (/"500","1000","1500","2000"/)
 nvars = dimsizes(vars)-1
 nelev = dimsizes(elev)-1

 do n=0,nvars
 do k=0,nelev
 print("VR-CESM28 - HISTORICAL - AVG DJF Sierra Nevada "+elev(k)+"
"+vars(n)+"")
 Sierra_STAT_VR_CESM_28_HIST_+vars(n)+elev(k)+ =
stat_dispersion(oned_+vars(n)+_VR_CESM_28_HIST_+elev(k)+,opt)

 end do
 end do

Do you have any advice on how to move forward on this?  I have heard that
it is possible to read in variable names via a shell script into NCL, but I
can't track down an example of how to do this either.

Thanks in advance,

AR

-- 

*Alan Rhoades*
*PhD Student, Atmospheric Science Graduate Group*
*Climate Change Water and Society (CCWAS) NSF IGERT Trainee*
*University of California, Davis*
*LinkedIn <https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a>*
*alan.m.rhoades at gmail.com <alan.m.rhoades at gmail.com> *
*amrhoades at ucdavis.edu <amrhoades at ucdavis.edu>*

*"It’s all really there. That’s what really gets you. But you gotta stop
and think about it to really get the pleasure about the complexity, the
inconceivable nature of nature."*
*Richard Feynman*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151020/58d4f4f2/attachment.html 


More information about the ncl-talk mailing list