[ncl-talk] define group of variables of different size and type with NCL

Dennis Shea shea at ucar.edu
Mon Jul 11 08:24:56 MDT 2016


NCL 'list' Variables

http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml

See Section: List variables

===

The syntax [/ ... /] can be used to create a list.

 i = (/ (/1,2,3/), (/4,5,6/), (/7,8,9/) /)   ; 2-dimensioal integer array
 x = 5.0                                     ; scalar of type float
 d = (/100000.d, 283457.23d/)                ; 1-dimensional double array
 s = "abcde"                                 ; string
 c = stringtochar("abcde")                   ; character
 var = *[/*i, x, d, c, s*/]*                     ; construct list via [/.../]

variables with list may have meta data attached to them.

  print(var)

  C = var[3]]                 ; explicitly extract a variable from the
list;
                                    ; not required but helps with clarity

   delete( var )              ; delete a list

Some 'list' functions

*ListAppend*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListAppend.shtml>,
*ListCount*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListCount.shtml>,
*ListGetType*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListGetType.shtml>,
*ListIndex*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListIndex.shtml>,
*ListIndexFromName*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListIndexFromName.shtml>,
*ListPop*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListPop.shtml>,
*ListPush*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ListPush.shtml>,
*ListSetType*, *NewList*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/NewList.shtml>
======
Vraiables of type list are sometimes used to returm multiple variables from
a function.

    function FOO(....)
    begin
        a = ...
        b = ...
        c = ...
        return( [/ a, b, c /] )
     end

Regards
D

On Mon, Jul 11, 2016 at 3:22 AM, franz <f.trotta at sincem.unibo.it> wrote:

> Dear ncl-team
>     I’m using the nil 6.3.0
>     In my NCL program, I define all file name of datasets that I use like
> in the follow way:
>
>     file_extrapdataOce_temp_less1 = new((/nnest/),string,"")
>     file_extrapdataOce_temp       = new((/nnest,ndays_max/),string,"")
>     file_extrapdataOce_temp_plus1 = new((/nnest/),string,"")
>     file_extrapdataOce_sal_less1  = new((/nnest/),string,"")
>     file_extrapdataOce_sal        = new((/nnest,ndays_max/),string,"")
>     file_extrapdataOce_sal_plus1  = new((/nnest/),string,"")
>     file_extrapdataOce_ssh_less1  = new((/nnest/),string,"")
>     file_extrapdataOce_ssh        = new((/nnest,ndays_max/),string,"")
>     file_extrapdataOce_ssh_plus1  = new((/nnest/),string,"")
>     file_extrapdataOce_curx_less1 = new((/nnest/),string,"")
>     file_extrapdataOce_curx       = new((/nnest,ndays_max/),string,"")
>     file_extrapdataOce_curx_plus1 = new((/nnest/),string,"")
>     file_extrapdataOce_cury_less1 = new((/nnest/),string,"")
>     file_extrapdataOce_cury       = new((/nnest,ndays_max/),string,"")
>     file_extrapdataOce_cury_plus1 = new((/nnest/),string,"")
>
>
>
> set_files_extrapdataOce(nnest,ndays,runMan_date_less1,runMan_date_plus1,runMan_date,
> \
>
>
> file_extrapdataOce_temp_less1,file_extrapdataOce_temp,file_extrapdataOce_temp_plus1,
> \
>
>
> file_extrapdataOce_sal_less1,file_extrapdataOce_sal,file_extrapdataOce_sal_plus1,
> \
>
>
> file_extrapdataOce_ssh_less1,file_extrapdataOce_ssh,file_extrapdataOce_ssh_plus1,
> \
>
>
> file_extrapdataOce_curx_less1,file_extrapdataOce_curx,file_extrapdataOce_curx_plus1,
> \
>
>
> file_extrapdataOce_cury_less1,file_extrapdataOce_cury,file_extrapdataOce_cury_plus1)
>
>     All these file name belong to subgroup ‘file_extrapdataOce’ and I
> would like to define something like ‘C language structures’
>     Is it possible to define in NCL groups of variables of different size
> and type?
>
> thanks
> Francesco T.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160711/1f93fe98/attachment.html 


More information about the ncl-talk mailing list