diff --git a/sources/forcing.F90 b/sources/forcing.F90 index 73f6240..84e0841 100644 --- a/sources/forcing.F90 +++ b/sources/forcing.F90 @@ -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 ! diff --git a/sources/statistics.F90 b/sources/statistics.F90 index 50cbbbc..c3e9556 100644 --- a/sources/statistics.F90 +++ b/sources/statistics.F90 @@ -1199,13 +1199,6 @@ module statistics end if ! track conservation -! sum up the injected energy and injection rate -! - if (forcing_enabled) then - lint(29) = einj - lint(30) = rinj - end if - gint = gint + lint gavg = gavg + lavg gmin = min(gmin, lmin) @@ -1217,6 +1210,13 @@ module statistics work_in_use(nt) = .false. !$omp end parallel +! sum up the injected energy and injection rate +! + if (forcing_enabled) then + gint(29) = gint(29) + einj + gint(30) = gint(30) + rinj + end if + #ifdef MPI ! sum the integral array from all processes !