Fortran Wiki
move_alloc

Description

move_alloc(src, dest) moves the allocation from src to dest. src will become deallocated in the process.

Standard

Fortran 2003 and later

Class

Subroutine

Syntax

call move_alloc(src, dest)

Arguments

  • src - allocatable, intent(inout), may be of any type and kind.
  • dest - allocatable, intent(out), shall be of the same type, kind and rank as src.

Example

program test_move_alloc
    integer, allocatable :: a(:), b(:)

    allocate(a(3))
    a = [ 1, 2, 3 ]
    call move_alloc(a, b)
    print *, allocated(a), allocated(b)
    print *, b
end program test_move_alloc

See Also

allocated

category: intrinsics