Best practice: Deallocating allocatable arrays explicitly vs implicitly

I would only remind you that you do not get the choice of implicit deallocation in procedures when compiling with gfortran using heap arrays (gfortran -fmax-stack-var-size=10 main.f90 -o). To me, this seems to be a bug in gfortran. Intel ifort compiler has no issues with it.

    call testAutoDealloc
    call testAutoDealloc
contains
    subroutine testAutoDealloc
        real, allocatable :: temp(:)
        allocate(temp(200))
        !deallocate(temp)
    end
end
1 Like