compute_gather_debug Subroutine

private subroutine compute_gather_debug(flow, context, state, debug_T_diff, debug_Y_diff)

Arguments

Type IntentOptional Attributes Name
type(flow_mpi_t), intent(in) :: flow
type(radiation_context_t), intent(in) :: context
type(radiation_state_t), intent(in) :: state
real(kind=rk), intent(out) :: debug_T_diff
real(kind=rk), intent(out) :: debug_Y_diff

Source Code

   subroutine compute_gather_debug(flow, context, state, debug_T_diff, debug_Y_diff)
      type(flow_mpi_t), intent(in) :: flow
      type(radiation_context_t), intent(in) :: context
      type(radiation_state_t), intent(in) :: state
      real(rk), intent(out) :: debug_T_diff, debug_Y_diff
      real(rk) :: owned_sum, global_owned_sum, gathered_sum, diff, maxdiff
      integer :: ierr, c, s

      debug_T_diff = zero
      debug_Y_diff = zero
      if (.not. context%debug) return

      owned_sum = zero
      do c = flow%first_cell, flow%last_cell
         owned_sum = owned_sum + state%temperature(c)
      end do
      call MPI_Allreduce(owned_sum, global_owned_sum, 1, MPI_DOUBLE_PRECISION, MPI_SUM, flow%comm, ierr)
      if (ierr /= MPI_SUCCESS) call fatal_error('radiation', 'MPI failure reducing T checksum')
      gathered_sum = sum(state%temperature)
      diff = abs(gathered_sum - global_owned_sum)
      call MPI_Allreduce(diff, debug_T_diff, 1, MPI_DOUBLE_PRECISION, MPI_MAX, flow%comm, ierr)
      if (ierr /= MPI_SUCCESS) call fatal_error('radiation', 'MPI failure reducing T checksum diff')

      maxdiff = zero
      if (allocated(state%Y)) then
         do s = 1, state%n_species
            owned_sum = zero
            do c = flow%first_cell, flow%last_cell
               owned_sum = owned_sum + state%Y(s, c)
            end do
            call MPI_Allreduce(owned_sum, global_owned_sum, 1, MPI_DOUBLE_PRECISION, MPI_SUM, flow%comm, ierr)
            if (ierr /= MPI_SUCCESS) call fatal_error('radiation', 'MPI failure reducing Y checksum')
            gathered_sum = sum(state%Y(s, :))
            maxdiff = max(maxdiff, abs(gathered_sum - global_owned_sum))
         end do
      end if
      call MPI_Allreduce(maxdiff, debug_Y_diff, 1, MPI_DOUBLE_PRECISION, MPI_MAX, flow%comm, ierr)
      if (ierr /= MPI_SUCCESS) call fatal_error('radiation', 'MPI failure reducing Y checksum diff')
   end subroutine compute_gather_debug