[ncl-talk] functions handling input of unknown dimension

Will Hobbs Will.Hobbs at utas.edu.au
Tue Jun 2 00:43:34 MDT 2015


Hi all

I wonder if anyone has any suggestions for a generic way of writing functions that deal with input/output arrays which may have different numbers of dimensions, e.g.

function generic_example(input:numeric)

begin
  output = some_subset_of_(input)

  return(output)
        end

where input/output might be 1, 2, 3, 4 or more dimensions, and so a different line is needed to do the subsetting step.

At the moment I just use nested 'if' statements based on the rank of the array (where rank is the number of dimensions, i.e. dimsizes(dim sizes(input)), and this works fine. But, it does not make for particularly 'clean' or efficient code, so I wonder if anyone has any nicer ways of doing this.

Many thanks

Will


University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150602/48e59126/attachment.html 


More information about the ncl-talk mailing list