FMS 2025.01-dev
Flexible Modeling System
Loading...
Searching...
No Matches
mpp_sum_ad.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!> @file
22!> @brief Adjoint summation routines for @ref mpp_mod
23
24!> @addtogroup mpp_mod
25!> @{
26
27!#######################################################################
28
29 !> Sums array a.
30 !! when only first element is passed: this routine just converts to a call to MPP_SUM_
31 subroutine mpp_sum_scalar_ad_( a, pelist )
32 mpp_type_, intent(inout) :: a !< scalar value to sum over pelist
33 integer, intent(in), optional :: pelist(:)
34 mpp_type_ :: b(1)
35
36 b(1) = a
37 if( debug )call mpp_error( note, 'MPP_SUM_SCALAR_: calling MPP_SUM_ ...' )
38 call mpp_sum_ad_( b, 1, pelist )
39 a = b(1)
40 return
41 end subroutine mpp_sum_scalar_ad_
42
43!#######################################################################
44 !> Sums 2d array across pes
45 subroutine mpp_sum_2d_ad_( a, length, pelist )
46 mpp_type_, intent(inout) :: a(:,:) !< 2d array to sum
47 integer, intent(in) :: length !< amount of indices in given 2d array
48 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
49 mpp_type_ :: a1d(length)
50
51 pointer( ptr, a1d )
52 ptr = loc(a)
53 call mpp_sum_ad( a1d, length, pelist )
54
55 return
56 end subroutine mpp_sum_2d_ad_
57
58!#######################################################################
59 !> Sums 3d array across pes
60 subroutine mpp_sum_3d_ad_( a, length, pelist )
61 mpp_type_, intent(inout) :: a(:,:,:) !< 3d array to sum
62 integer, intent(in) :: length !< amount of indices in given 3d array
63 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
64 mpp_type_ :: a1d(length)
65
66 pointer( ptr, a1d )
67 ptr = loc(a)
68 call mpp_sum_ad( a1d, length, pelist )
69
70 return
71 end subroutine mpp_sum_3d_ad_
72
73!#######################################################################
74 !> Sums 4d array across pes
75 subroutine mpp_sum_4d_ad_( a, length, pelist )
76 mpp_type_, intent(inout) :: a(:,:,:,:) !< 4d array to sum
77 integer, intent(in) :: length !< amount of indices in given 4d array
78 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
79 mpp_type_ :: a1d(length)
80
81 pointer( ptr, a1d )
82 ptr = loc(a)
83 call mpp_sum_ad( a1d, length, pelist )
84
85 return
86 end subroutine mpp_sum_4d_ad_
87
88!#######################################################################
89 !> Sums 5d array across pes
90 subroutine mpp_sum_5d_ad_( a, length, pelist )
91 mpp_type_, intent(inout) :: a(:,:,:,:,:) !< 5d array to sum
92 integer, intent(in) :: length !< amount of indices in given 5d array
93 integer, intent(in), optional :: pelist(:) !< pelist to calculate sum across
94 mpp_type_ :: a1d(length)
95
96 pointer( ptr, a1d )
97 ptr = loc(a)
98 call mpp_sum_ad( a1d, length, pelist )
99
100 return
101 end subroutine mpp_sum_5d_ad_
subroutine mpp_sum_5d_ad_(a, length, pelist)
Sums 5d array across pes.
subroutine mpp_sum_3d_ad_(a, length, pelist)
Sums 3d array across pes.
subroutine mpp_sum_2d_ad_(a, length, pelist)
Sums 2d array across pes.
subroutine mpp_sum_4d_ad_(a, length, pelist)
Sums 4d array across pes.
subroutine mpp_sum_scalar_ad_(a, pelist)
Sums array a. when only first element is passed: this routine just converts to a call to MPP_SUM_.