Branch data Line data Source code
1 : : !{\src2tex{textfont=tt}}
2 : : !!****f* ABINIT/xmpi_min_intv
3 : : !! NAME
4 : : !! xmpi_min_intv
5 : : !!
6 : : !! FUNCTION
7 : : !! This module contains functions that calls MPI routine,
8 : : !! if we compile the code using the MPI CPP flags.
9 : : !! xmpi_min is the generic function.
10 : : !!
11 : : !! COPYRIGHT
12 : : !! Copyright (C) 2001-2026 ABINIT group (AR,XG,MB)
13 : : !! This file is distributed under the terms of the
14 : : !! GNU General Public License, see ~ABINIT/COPYING
15 : : !! or http://www.gnu.org/copyleft/gpl.txt .
16 : : !!
17 : : !! SOURCE
18 : :
19 : 3454 : subroutine xmpi_min_intv(xval,xmin,comm,ier)
20 : :
21 : : !Arguments-------------------------
22 : : integer ,intent(in) :: xval
23 : : integer ,intent(out) :: xmin
24 : : integer ,intent(in) :: comm
25 : : integer ,intent(out) :: ier
26 : :
27 : : !Local variables-------------------
28 : : #if defined HAVE_MPI
29 : : integer :: arr_xval(1),arr_xmin(1)
30 : : #endif
31 : :
32 : : ! *************************************************************************
33 : :
34 : 3454 : ier=0
35 : : #if defined HAVE_MPI
36 [ + + ]: 3454 : if (comm /= MPI_COMM_SELF .and. comm /= MPI_COMM_NULL) then
37 : 3419 : arr_xval(1) = xval
38 : 3419 : call MPI_ALLREDUCE(arr_xval,arr_xmin,1,MPI_INTEGER,MPI_MIN,comm,ier)
39 : 3419 : xmin = arr_xmin(1)
40 : : else
41 : : #endif
42 : 35 : xmin=xval
43 : : #if defined HAVE_MPI
44 : : end if
45 : : #endif
46 : :
47 : 3454 : end subroutine xmpi_min_intv
48 : : !!***
49 : :
50 : : !!****f* ABINIT/xmpi_min_dpv
51 : : !! NAME
52 : : !! xmpi_min_dpv
53 : : !!
54 : : !! FUNCTION
55 : : !! Combines values from all processes and distribute
56 : : !! the result back to all processes.
57 : : !! Target: scalar double precisions.
58 : : !!
59 : : !! INPUTS
60 : : !! comm= MPI communicator
61 : : !!
62 : : !! OUTPUT
63 : : !! ier= exit status, a non-zero value meaning there is an error
64 : : !!
65 : : !! SIDE EFFECTS
66 : : !! xval= buffer array
67 : : !! xmin= number of elements in send buffer
68 : : !!
69 : : !! SOURCE
70 : :
71 : 23689 : subroutine xmpi_min_dpv(xval,xmin,comm,ier)
72 : :
73 : : !Arguments-------------------------
74 : : real(dp),intent(in) :: xval
75 : : real(dp),intent(out) :: xmin
76 : : integer ,intent(in) :: comm
77 : : integer ,intent(out) :: ier
78 : :
79 : : !Local variables-------------------
80 : : #if defined HAVE_MPI
81 : : real(dp) :: arr_xval(1),arr_xmin(1)
82 : : #endif
83 : :
84 : : ! *************************************************************************
85 : :
86 : 23689 : ier=0
87 : : #if defined HAVE_MPI
88 [ + + ]: 23689 : if (comm /= MPI_COMM_SELF .and. comm /= MPI_COMM_NULL) then
89 : 19471 : arr_xval(1) = xval
90 : 19471 : call MPI_ALLREDUCE(arr_xval,arr_xmin,1,MPI_DOUBLE_PRECISION,MPI_MIN,comm,ier)
91 : 19471 : xmin = arr_xmin(1)
92 : : else
93 : : #endif
94 : 4218 : xmin=xval
95 : : #if defined HAVE_MPI
96 : : end if
97 : : #endif
98 : :
99 : 23689 : end subroutine xmpi_min_dpv
100 : : !!***
101 : :
102 : : !----------------------------------------------------------------------
103 : :
104 : : !!****f* ABINIT/xmpi_min_int1d
105 : : !! NAME
106 : : !! xmpi_min_int1d
107 : : !!
108 : : !! FUNCTION
109 : : !! Combines values from all processes and distribute the result back to all processes.
110 : : !! Target: 1d int array, in-place version
111 : : !!
112 : : !! INPUTS
113 : : !! comm= MPI communicator
114 : : !!
115 : : !! OUTPUT
116 : : !! ier= exit status, a non-zero value meaning there is an error
117 : : !!
118 : : !! SIDE EFFECTS
119 : : !! xval= buffer array
120 : : !!
121 : : !! SOURCE
122 : :
123 [ # # ]: 0 : subroutine xmpi_min_int1d(xval, comm, ier)
124 : :
125 : : !Arguments-------------------------
126 : : integer,intent(inout) :: xval(:)
127 : : integer,intent(in) :: comm
128 : : integer,intent(out) :: ier
129 : :
130 : : !Local variables-------------------
131 : : #if defined HAVE_MPI
132 : 0 : integer :: arr_xmin(size(xval))
133 : : #endif
134 : :
135 : : ! *************************************************************************
136 : :
137 : 0 : ier=0
138 : : #if defined HAVE_MPI
139 [ # # ]: 0 : if (comm /= MPI_COMM_SELF .and. comm /= MPI_COMM_NULL) then
140 [ # # ]: 0 : call MPI_ALLREDUCE(xval, arr_xmin, size(xval), MPI_INTEGER, MPI_MIN, comm, ier)
141 [ # # ]: 0 : xval = arr_xmin
142 : : end if
143 : : #endif
144 : :
145 : 0 : end subroutine xmpi_min_int1d
146 : : !!***
147 : :
148 : : !----------------------------------------------------------------------
149 : :
150 : : !!****f* ABINIT/xmpi_min_dp
151 : : !! NAME
152 : : !! xmpi_min_dp
153 : : !!
154 : : !! FUNCTION
155 : : !! Combines values from all processes and distribute the result back to all processes.
156 : : !! Target: scalar double precisions, in-place version
157 : : !!
158 : : !! INPUTS
159 : : !! comm= MPI communicator
160 : : !!
161 : : !! OUTPUT
162 : : !! ier= exit status, a non-zero value meaning there is an error
163 : : !!
164 : : !! SIDE EFFECTS
165 : : !! xval= buffer array
166 : : !!
167 : : !! SOURCE
168 : :
169 : 14 : subroutine xmpi_min_dp(xval, comm, ier)
170 : :
171 : : !Arguments-------------------------
172 : : real(dp),intent(inout) :: xval
173 : : integer ,intent(in) :: comm
174 : : integer ,intent(out) :: ier
175 : :
176 : : !Local variables-------------------
177 : : #if defined HAVE_MPI
178 : : real(dp) :: arr_xval(1), arr_xmin(1)
179 : : #endif
180 : :
181 : : ! *************************************************************************
182 : :
183 : 14 : ier=0
184 : : #if defined HAVE_MPI
185 [ + - ]: 14 : if (comm /= MPI_COMM_SELF .and. comm /= MPI_COMM_NULL) then
186 : 14 : arr_xval(1) = xval
187 : 14 : call MPI_ALLREDUCE(arr_xval,arr_xmin,1,MPI_DOUBLE_PRECISION,MPI_MIN,comm,ier)
188 : 14 : xval = arr_xmin(1)
189 : : end if
190 : : #endif
191 : :
192 : 14 : end subroutine xmpi_min_dp
193 : : !!***
|