[ncl-talk] variable dimension specifier

Mark.Collier at csiro.au Mark.Collier at csiro.au
Sun Feb 15 20:08:09 MST 2015


Hi Jatin,
the problem is being at to specify a range of colons, e.g.

:,:,:

:,:

:

without having to use if else if statements…some languages have a function for this, it may not be easy to implement in NCL.

It would be a way of making certain code more compact and general.

Regards, Mark.

> On 16 Feb 2015, at 1:22 pm, Jatin Kala <jatin.kala.jk at gmail.com> wrote:
> 
> Hi Mark,
> Maybe use something like getfilevardimsizes:
> https://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevardimsizes.shtml
> That should tell you the number of dims
> 
> 
> 
> 
> On 16/02/15 12:41 PM, Mark.Collier at csiro.au wrote:
>> Hi,
>> is it possible to reference an input variable dimension list with a variable, for example
>> 
>> data=fh->pr(colons)
>> 
>> where the variable pr is defined in the data file pointed to be the file handle fh.
>> 
>> where colons is a list that could vary in length, e.g. “:,:,:” or “:,:” depending on whether it was a 3,2 or n dimensioned quantity?
>> 
>> The reason for this, is sometimes it is necessary to specify the colon list without knowing the variables dimension, and without having to result to if, else if control flow for each dimension case…
>> 
>> Ideally colons could be a function taking an integer argument to specify the list
>> 
>> e.g. colons(3) would reflect “:,:,:”
>> 
>> I’ve tried to do this but I guess the : are a unique quantity not able to be defined by a simple string argument…
>> 
>> Thanks,
>> Mark.
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> 



More information about the ncl-talk mailing list