Re: Dynamic variable names

From: Brandon Fisel <bjfisel_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 04 2010 - 10:18:59 MST

Ekin,

In the past, I have created an array containing all or some of the variables
in a file and created a loop, which would process them individually.

vars = (/x1,x2,x3,x4/)
nvars = dimsizes(vars) - 1

do n=0, nvars
  var = f->$vars(n)$

; process variable
  .
  .
  .
delete(var)
end do

-------------------------------------------------------------
Brandon Fisel

On Thu, Mar 4, 2010 at 10:09, Mary Haley <haley@ucar.edu> wrote:

> Ekin,
>
> Unfortunately, there's no way to do what you are requesting. We've had
> other users request this as well,
> and it's on our list of things to add to NCL.
>
> There may be ways to rewrite your code so that you can get the
> functionality that you want.
>
> What do you need to do with all of these variables once you read them in?
> Is it possible that you
> can read the values from one variable to a dummy variable, do the
> processing you need, and then delete that
> dummy variable before the next time through the loop?
>
> --Mary
>
> On Mar 4, 2010, at 7:32 AM, Ekin Akoglu wrote:
>
> Dear Users,
>
> I am reading data from netcdf file and there are many variables in it. I
> would like to read all variables into NCL with the same name or appending a
> prefix
> to the variable names in the netcdf file. Below is my code:
>
> blacksea = addfile("blacksea.nc","r") ; load netcdf file
>
> names = getfilevarnames(blacksea) ; get variable namelist from file
>
> do i=0, dimsizes(names)-1
> $names(1)$ = blacksea->$names(1)$ ; for all the variables
> use the same name to import them into NCL
> end do
>
> but as you will guess it does not work. Could you help me to overcome this
> problem?
>
> Regards,
>
> --
> Ekin Akoglu
>
> Institute of Marine Sciences
> Middle East Technical University
> P.O. Box 28, 33731
> Erdemli, Mersin
> Turkey
>
> Web: www.ims.metu.edu.tr
> Email: ekin@ims.metu.edu.tr
> Phone: +90 324 521 34 34
> GSM: +90 506 554 03 90
> _______________________________________________
> 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 Thu Mar 4 10:19:20 2010

This archive was generated by hypermail 2.1.8 : Thu Mar 04 2010 - 15:07:06 MST