98 integer :: iigrid, igrid, level, ratio
99 integer :: ix1, k, klo, khi, kk, k_apex, k_cutoff_left, k_cutoff_right
100 integer :: k_left, k_right
101 double precision :: x_cell, rho_cell, running_sum
102 double precision :: cm_value
105 if (.not. arrays_allocated)
call escape_prob_setup_arrays()
106 if (n_aux == 0)
return
118 do ix1 = ixmlo1, ixmhi1
119 x_cell = ps(igrid)%x(ix1, 1)
120 rho_cell = ps(igrid)%w(ix1,
iw_rho)
123 k = floor((x_cell - xprobmin1) / dx_aux) + 1
124 k = max(1, min(k, n_aux))
128 rho_dx_local(k) = rho_dx_local(k) + rho_cell * dx_aux
132 klo = k - ratio/2 + 1
133 khi = klo + ratio - 1
135 khi = min(n_aux, khi)
137 rho_dx_local(kk) = rho_dx_local(kk) + rho_cell * dx_aux
144 call mpi_allreduce(rho_dx_local, rho_dx_global, n_aux, &
153 if (rho_dx_global(k) == 0.0d0)
then
157 if (rho_dx_global(kk) /= 0.0d0)
then
165 if (rho_dx_global(kk) /= 0.0d0)
then
171 if (k_left > 0 .and. k_right > 0)
then
172 rho_dx_global(k) = half * (rho_dx_global(k_left) &
173 + rho_dx_global(k_right))
174 else if (k_left > 0)
then
175 rho_dx_global(k) = rho_dx_global(k_left)
176 else if (k_right > 0)
then
177 rho_dx_global(k) = rho_dx_global(k_right)
186 if (escape_height_ > 0.0d0)
then
187 k_cutoff_left = floor(escape_height_ / dx_aux) + 1
188 k_cutoff_left = min(k_cutoff_left, n_aux)
189 if (escape_sym_)
then
190 k_cutoff_right = n_aux - k_cutoff_left + 1
191 k_cutoff_right = max(1, k_cutoff_right)
192 do k = k_cutoff_left + 1, k_cutoff_right - 1
193 rho_dx_global(k) = 0.0d0
196 do k = k_cutoff_left + 1, n_aux
197 rho_dx_global(k) = 0.0d0
206 running_sum = running_sum + rho_dx_global(k)
207 colmass_left(k) = running_sum
213 running_sum = running_sum + rho_dx_global(k)
214 colmass_right(k) = running_sum
218 if (escape_sym_)
then
232 do ix1 = ixglo1, ixghi1
233 x_cell = ps(igrid)%x(ix1, 1)
234 k = floor((x_cell - xprobmin1) / dx_aux) + 1
235 k = max(1, min(k, n_aux))
237 if (escape_sym_)
then
242 if (k <= k_apex)
then
244 cm_value = colmass_left(k_apex) - colmass_left(k)
247 cm_value = colmass_right(k_apex + 1) - colmass_right(k)
251 cm_value = colmass_right(k)
254 ps(igrid)%wextra(ix1, iw_colmass_) = max(cm_value, 0.0d0)