Skip to main content

Expand

Expand method expands a vector (if necessary) and add an element to it.

Reference

Calling example

CALL Expand(vec, n=0, chunk_size)
CALL Expand(vec, n, chunk_size, finished=.TRUE.)

Interface

  MODULE PURE SUBROUTINE Expand(vec, n, chunk_size, val, finished)
INTEGER(Int8| Int16 | Int32 | Int64) | REAL(Real32| Real64), ALLOCATABLE, INTENT(INOUT) :: vec(:)
INTEGER(I4B), INTENT(INOUT) :: n
!! counter for last element added to `vec`.
!! must be initialized to `size(vec)`
!! (or 0 if not allocated) before first call
INTEGER(I4B), INTENT(IN) :: chunk_size
!! allocate `vec` in blocks of this size (>0)
INTEGER(Int8| Int16 | Int32 | Int64) | REAL(Real32| Real64), OPTIONAL, INTENT(IN) :: val
!! the value to add to `vec`
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: finished
!! set to true to return `vec`
!! as its correct size (`n`)
END SUBROUTINE Expand