184. Use MOVE_ALLOC to resize an array.#

topic: Allocation

Note

This tip is a draft1.

CALL MOVE_ALLOC(FROM,TO) copies FROM to TO and then deallocates FROM. It can be used to expand array x(:) with

n = size(x) allocate (y(n+size(new))) y(:n) = x y(n+1:) = new call move_alloc(from=y,to=x)

This may be faster than

x = [x,new]



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.