NCL Website header
NCL Home > Documentation > Language

Array pre-allocation

In general, array pre-allocation is required before a do loop, or when using a procedure. Pre-allocation is achieved using new.
    x = new( (/34,56,78/), double)   ; create array
    do i = 0, nobs-1
        x(i,:,:) = calculation_that_returns_2d_varb()
    end do
    
    y = new( (/25,67/), float)
    procedure (arg1,y)