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    allocate (sums(size(values)))
20    sums(:)=0
21    call mpi_reduce(values(:), sums(:), size(values), mpi_integer, mpi_sum, &
22       root, comm, ierr)
23 
24    if (rootproc) values(:) = sums(:)
25    deallocate(sums)
26 #endif
27 
28 end subroutine da_proc_sum_ints
29 
30