[ncl-talk] do loop based on variable similar names

xyzheng at mail.ustc.edu.cn xyzheng at mail.ustc.edu.cn
Wed Nov 9 19:44:27 MST 2016


Hello,
I am looking for a way to call a series of variables through  their names (string) in NCL.These variables are of different sizes,so they can't be set as an array iz(k) of fixed size. And Idon't know how to do loop and some other operations based on these similar namessince ("iz"+i) can't be identified as a variable in the following script. Can anyone help?
.....................................................................................................................
 
fieldf(0,:) = asciiread(fi,-1,"float")
   iz1=ind(fieldf(0,:).ge.0.and.fieldf(0,:).lt.1.5) 
   iz2=ind(fieldf(0,:).ge.1.and.fieldf(0,:).lt.2.2) 
   iz3=ind(fieldf(0,:).ge.2.2.and.fieldf(0,:).lt.3)
   iz4=ind(fieldf(0,:).ge.3.and.fieldf(0,:).lt.4.2)
   iz5=ind(fieldf(0,:).ge.4.2.and.fieldf(0,:).lt.5.6)
   iz6=ind(fieldf(0,:).ge.5.6.and.fieldf(0,:).lt.6)
   iz7=ind(fieldf(0,:).ge.6.and.fieldf(0,:).lt.7)
   iz8=ind(fieldf(0,:).ge.7.and.fieldf(0,:).lt.8)
   iz9=ind(fieldf(0,:).ge.8.and.fieldf(0,:).lt.9.1)
   iz10=ind(fieldf(0,:).ge.9.1.and.fieldf(0,:).lt.10)
   iz11=ind(fieldf(0,:).ge.10.and.fieldf(0,:).lt.11)
   iz12=ind(fieldf(0,:).ge.11.and.fieldf(0,:).lt.12) 
   iz13=ind(fieldf(0,:).ge.12.and.fieldf(0,:).lt.13) 

   do i=1,13
         print(dimsizes("iz"+i))
  end do
....................................................................................................
 
Thanks very much,
 
Zoey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161110/e529b512/attachment.html 


More information about the ncl-talk mailing list