FORCING: Make injected energy update atomic.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2024-05-24 19:01:08 -03:00
parent 3013d57f9f
commit bca8681d96

View File

@ -1582,12 +1582,13 @@ module forcing
real(kind=8), dimension(nn):: zk, kz, snkz, cskz
#endif /* NDIMS == 3 */
real(kind=8), save :: deinj
real(kind=8), dimension(:,:,:,:), pointer, save :: acc
real(kind=8), dimension(:,:,:) , pointer, save :: den
integer, save :: nt
!$ integer :: omp_get_thread_num
!$omp threadprivate(first, nt, acc, den)
!$omp threadprivate(first, nt, acc, den, deinj)
character(len=*), parameter :: loc = 'FORCING:inject_fmodes_block()'
@ -1750,10 +1751,12 @@ module forcing
! calculate the injected energy
!
#if NDIMS == 3
einj = einj + sum(den(nb:ne,nb:ne,nb:ne)) * dvol
deinj = sum(den(nb:ne,nb:ne,nb:ne)) * dvol
#else /* NDIMS == 3 */
einj = einj + sum(den(nb:ne,nb:ne, 1 )) * dvol
deinj = sum(den(nb:ne,nb:ne, 1 )) * dvol
#endif /* NDIMS == 3 */
!$omp atomic update
einj = einj + deinj
! add the energy increment
!