SOURCES: Use resize_workspace() in update_sources().

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2021-11-13 20:38:27 -03:00
parent 43e32a755f
commit 1b1e3ab034

View File

@ -331,7 +331,7 @@ module sources
use iso_fortran_env, only : error_unit
use operators , only : divergence, gradient, laplace, curl
use user_problem , only : update_user_sources
use workspace , only : work, nwork, work_in_use
use workspace , only : resize_workspace, work, work_in_use
implicit none
@ -368,28 +368,15 @@ module sources
#endif /* PROFILE */
if (first) then
status = 0
if (work_in_use) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace is already occupied!"
status = 1
go to 100
else
i = nn**NDIMS
j = 10 * i
i = nn**NDIMS
j = 10 * i
if (j > nwork) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace has too be increased!"
nwork = j
deallocate(work)
allocate(work(nwork), stat=status)
if (status /= 0) then
write(error_unit,"('[',a,']: ',a)") trim(loc), &
"Cannot increase the workspace's size!"
go to 100
end if
end if
call resize_workspace(j, status)
if (status /= 0) then
write(error_unit,"('[',a,']: ',a)") trim(loc), &
"Could not resize the workspace!"
go to 100
end if
#if NDIMS == 3
db(1:nn,1:nn,1:nn) => work( 1:i)
@ -398,7 +385,6 @@ module sources
db(1:nn,1:nn,1: 1) => work( 1:i)
tmp(1:3,1:3,1:nn,1:nn,1: 1) => work(i+1:j)
#endif /* NDIMS == 3 */
end if
first = .false.
end if
@ -473,7 +459,8 @@ module sources
if (work_in_use) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace is already occupied! Corruptions can occur!"
"Workspace is being used right now! " // &
"Corruptions can occur!"
end if
work_in_use = .true.
@ -614,7 +601,8 @@ module sources
if (work_in_use) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace is already occupied! Corruptions can occur!"
"Workspace is being used right now! " // &
"Corruptions can occur!"
end if
work_in_use = .true.