[ncl-talk] how to define a alterable dimension for the variables in a self-defined functions?

Dennis Shea shea at ucar.edu
Sat Oct 17 11:04:04 MDT 2015


It is simple but a bit cumbersome. Something like:

undef("foox")
function foox (x:numeric)
local dimx, rankx
begin
    dimx  = dimsizes(x)
    rankx = dimsizes(dimx)

    if (rankx.eq.1) then
        ...
        result = ...
    end if

    if (rankx.eq.2) then
        ...
        result =
    end if

    return(result)

end

function fooxy (x:numeric, y:numeric)
local dimx, rankx, dimy, ranky
begin
    dimx  = dimsizes(x)
    rankx = dimsizes(dimx)
    dimy  = dimsizes(y)
    ranky = dimsizes(dimy)

    if (rankx.eq.1) then
        if (ranky.eq.1) then
             ...
        end if
        if (ranky.eq.2) then
             ...
        end if
       ...
    end if

    if (rankx.eq.2) then
        if (ranky.eq.1) then
             ...
        end if
        if (ranky.eq.2) then
             ...
        end if
        ...

    end if

     return(...)
end

Under "Support", click "Manuals",

https://www.ncl.ucar.edu/Document/Manuals/

Click: Mini-Language Manual, See 5.7



On Sat, Oct 17, 2015 at 10:10 AM, xianglin72 <xianglin72 at icloud.com> wrote:
> Hi, all
>
>
>       In many ncl functions, the variables can be in any dimension,  but how
> to define a variables of which the dimension can be alterable when I define
> a personal function ?    For example, when I write the following :
>
>
>         undef("partialcorr")
>
>         function partialcorr(x[*][*][*],y[*],z[*])
>
>
> the x input must be 3d,  how could the x can be input as a 1d array without
> writing another function ?
>
>
> Besides, Anyone can show me some tutorial for writing personal function and
> procedure?
>
>
> Thanks!
>
>
>
> Lin
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list