FMS 2025.01-dev
Flexible Modeling System
Loading...
Searching...
No Matches
mpp_sum.inc
1! -*-f90-*-
2
3!***********************************************************************
4!* GNU Lesser General Public License
5!*
6!* This file is part of the GFDL Flexible Modeling System (FMS).
7!*
8!* FMS is free software: you can redistribute it and/or modify it under
9!* the terms of the GNU Lesser General Public License as published by
10!* the Free Software Foundation, either version 3 of the License, or (at
11!* your option) any later version.
12!*
13!* FMS is distributed in the hope that it will be useful, but WITHOUT
14!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15!* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16!* for more details.
17!*
18!* You should have received a copy of the GNU Lesser General Public
19!* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
20!***********************************************************************
21
22!> @file
23!> @brief Summation routines for @ref mpp_mod
24
25!> @addtogroup mpp_mod
26!> @{
27!#######################################################################
28
29 !> Sums array a when only first element is passed: this routine just converts to a call to MPP_SUM_
30 subroutine mpp_sum_scalar_( a, pelist )
31 mpp_type_, intent(inout) :: a
32 integer, intent(in), optional :: pelist(:)
33 mpp_type_ :: b(1)
34
35 b(1) = a
36 if( debug )call mpp_error( note, 'MPP_SUM_SCALAR_: calling MPP_SUM_ ...' )
37 call mpp_sum_( b, 1, pelist )
38 a = b(1)
39 return
40 end subroutine mpp_sum_scalar_
41
42!#######################################################################
43 !> Sums 2d array across pes
44 subroutine mpp_sum_2d_( a, length, pelist )
45 mpp_type_, intent(inout) :: a(:,:) !< 2d array to sum
46 integer, intent(in) :: length !< amount of indices in given 2d array
47 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
48 mpp_type_ :: a1d(length)
49
50 pointer( ptr, a1d )
51 ptr = loc(a)
52 call mpp_sum( a1d, length, pelist )
53
54 return
55 end subroutine mpp_sum_2d_
56
57!#######################################################################
58 !> Sums 3d array across pes
59 subroutine mpp_sum_3d_( a, length, pelist )
60 mpp_type_, intent(inout) :: a(:,:,:) !< 3d array to sum
61 integer, intent(in) :: length !< amount of indices in given 3d array
62 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
63 mpp_type_ :: a1d(length)
64
65 pointer( ptr, a1d )
66 ptr = loc(a)
67 call mpp_sum( a1d, length, pelist )
68
69 return
70 end subroutine mpp_sum_3d_
71
72!#######################################################################
73 !> Sums 4d array across pes
74 subroutine mpp_sum_4d_( a, length, pelist )
75 mpp_type_, intent(inout) :: a(:,:,:,:) !< 4d array to sum
76 integer, intent(in) :: length !< amount of indices in given 4d array
77 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
78 mpp_type_ :: a1d(length)
79
80 pointer( ptr, a1d )
81 ptr = loc(a)
82 call mpp_sum( a1d, length, pelist )
83
84 return
85 end subroutine mpp_sum_4d_
86
87!#######################################################################
88 !> Sums 5d array across pes
89 subroutine mpp_sum_5d_( a, length, pelist )
90 mpp_type_, intent(inout) :: a(:,:,:,:,:) !< 5d array to sum
91 integer, intent(in) :: length !< amount of indices in given 5d array
92 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
93 mpp_type_ :: a1d(length)
94
95 pointer( ptr, a1d )
96 ptr = loc(a)
97 call mpp_sum( a1d, length, pelist )
98
99 return
100 end subroutine mpp_sum_5d_
101!> @}
subroutine mpp_sum_2d_(a, length, pelist)
Sums 2d array across pes.
Definition mpp_sum.inc:45
subroutine mpp_sum_3d_(a, length, pelist)
Sums 3d array across pes.
Definition mpp_sum.inc:60
subroutine mpp_sum_scalar_(a, pelist)
Sums array a when only first element is passed: this routine just converts to a call to MPP_SUM_.
Definition mpp_sum.inc:31
subroutine mpp_sum_4d_(a, length, pelist)
Sums 4d array across pes.
Definition mpp_sum.inc:75
subroutine mpp_sum_5d_(a, length, pelist)
Sums 5d array across pes.
Definition mpp_sum.inc:90