NCL Website header
NCL Home > Documentation > Language

Manual Array Creation

The NCL syntax (/.../) is used to manually create an array by specifying the array's values:

    aInt = (/1,2,3/)
    aStr= (/"a","b","c"/)
    
One can also pre-allocate array memory without initially specifying any array values by using the new function:

    X = new(size_of_array,type_of_array)
    A = new(3,float)
    B = new((/2,64,128/),float)
    C = new(10,float,1.e20)
    D = new(dimsizes(x),typeof(x))
    
"B" example:, values within (/../) are dimensions, not array values. B is 3D, not 1D with three elements.

"C" example: there are three arguments to the new funtion. The third is an assignment of a _FillValue. If it is not explicitly provided, NCL will use a default value.

The new function and the (/.../) syntax can appear anywhere in the code.