Is a matrix automatically deallocated at the end?

Viewed 50

If I define the following subroutine in Fortran

SUBROUTINE (A)
REAL :: A(:,:)
REAL :: B(SIZE(A,1),SIZE(A,2))
...

The matrix B is automatically deallocated at the end of the subroutine?

In that sense, is better to write a subroutine as the last, or it is better to define something like the following?

SUBROUTINE (A)
REAL :: A(:,:)
REAL, ALLOCATABLE :: B(:,:)

ALLOCATE(B(SIZE(A,1),SIZE(A,2)))

...

DEALLOCATE(B)
...
0 Answers
Related