da_proc_sum_ints.inc
References to this file elsewhere.
1 subroutine da_proc_sum_ints (values)
2
3 !---------------------------------------------------------------------------
4 ! Purpose: Do MPI sum operation across processors to get the global sum of
5 ! an integer array. The sum is returned only on the root processor,
6 ! i.e., processor 0. (In this way, we do not have to do all-to-all
7 ! communication, unlike wrf_dm_sum_ints, which does)
8 !
9 ! The routine generates a MPI barrier
10 !---------------------------------------------------------------------------
11
12 implicit none
13
14 integer, intent(inout) :: values(:) ! Values
15
16 #ifdef DM_PARALLEL
17 integer, allocatable :: sums(:) ! Sum across processors.
18
19
20 ! Don't trace, as called within trace routines
21 ! if (trace_use_frequent) call da_trace_entry("da_proc_sum_ints")
22
23 allocate (sums(size(values)))
24 sums(:)=0
25 call mpi_reduce(values(:), sums(:), size(values), mpi_integer, mpi_sum, &
26 root, comm, ierr)
27
28 if (rootproc) values(:) = sums(:)
29 deallocate(sums)
30
31 ! if (trace_use_frequent) call da_trace_exit("da_proc_sum_ints")
32 #endif
33
34 end subroutine da_proc_sum_ints
35
36