EVOLUTION: Make the arrays allocatable in initialize_time_step().

Two arrays used in the initial time step estimation, sc and df, are
allocated only if the integration methods support the estimation of
error.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2021-11-11 18:09:30 -03:00
parent 8e7369388f
commit 2dc4d3ca17

View File

@ -1194,11 +1194,7 @@ module evolution
real(kind=8) :: dx_min, fnorm, h0, h1
real(kind=8), dimension(3) :: d
#if NDIMS == 3
real(kind=8), dimension(nf,nc,nc,nc) :: sc, df
#else /* NDIMS == 3 */
real(kind=8), dimension(nf,nc,nc, 1) :: sc, df
#endif /* NDIMS == 3 */
real(kind=8), dimension(:,:,:,:), allocatable :: sc, df
real(kind=8), parameter :: eps = tiny(cmax)
@ -1246,6 +1242,20 @@ module evolution
!
if (error_control) then
#if NDIMS == 3
allocate(sc(nf,nc,nc,nc),df(nf,nc,nc,nc), stat=status)
#else /* NDIMS == 3 */
allocate(sc(nf,nc,nc, 1),df(nf,nc,nc, 1), stat=status)
#endif /* NDIMS == 3 */
#ifdef MPI
call reduce_maximum(status)
#endif /* MPI */
if (status > 0) then
write(error_unit,"('[',a,']: ',a)") trim(loc), &
"Cannot allocate memory for the time step estimation!"
go to 100
end if
fnorm = 1.0d+00 / (get_nleafs() * nc**NDIMS)
d(:) = 0.0d+00
@ -1363,6 +1373,11 @@ module evolution
end if
if (allocated(sc)) deallocate(sc)
if (allocated(df)) deallocate(df)
100 continue
end if
#ifdef PROFILE