SURFEX v8.1
General documentation of Surfex
mpl_stats_mod.F90
Go to the documentation of this file.
2 
3 PRIVATE
5 
6 CONTAINS
7 
8 SUBROUTINE mpl_statsinit
9 
10 !**** MPL_STATSINIT - Initialise collection of mpl statistics
11 
12 ! Purpose.
13 ! --------
14 ! Initialises the mpl_stats package
15 
16 !** Interface.
17 ! ----------
18 ! CALL MPL_STATSINIT
19 
20 ! Input required arguments :
21 ! -------------------------
22 ! none
23 
24 ! Input optional arguments :
25 ! -------------------------
26 ! none
27 
28 ! Output required arguments :
29 ! -------------------------
30 ! none
31 
32 ! Output optional arguments :
33 ! -------------------------
34 ! none
35 
36 ! Author.
37 ! -------
38 ! P.Towers ECMWF
39 
40 ! Modifications.
41 ! --------------
42 ! Original: 2011-04-06
43 ! F. Vana 05-Mar-2015 Support for single precision
44 
45 ! ------------------------------------------------------------------
46 
47 USE parkind1 ,ONLY : jpim
48 
49 USE yommplstats
50 
51 IMPLICIT NONE
52 
53 INTEGER(KIND=JPIM) :: ITHR,OMP_GET_MAX_THREADS
54 
55 lmplstats=.true.
56 
57 ithr = 1
58 !$ ITHR = OMP_GET_MAX_THREADS()
59 ithr = ithr-1
60 
61 ALLOCATE(mplsendbytes(0:ithr))
62 ALLOCATE(mplrecvbytes(0:ithr))
63 ALLOCATE(mplsendnum(0:ithr))
64 ALLOCATE(mplrecvnum(0:ithr))
65 
66 mplsendbytes(:) = 0
67 mplrecvbytes(:) = 0
68 mplsendnum(:) = 0
69 mplrecvnum(:) = 0
70 
71 RETURN
72 END SUBROUTINE mpl_statsinit
73 
74 SUBROUTINE mpl_statson(SENDNUM,SENDBYTES,RECVNUM,RECVBYTES)
75 
76 !**** MPL_STATSON - Reset mpl statistics counters
77 
78 ! Purpose.
79 ! --------
80 ! Returns the mpl statistics counter values
81 ! and sets them back to zero
82 ! non zero returned values correspond to messages that have
83 ! been sent/received outside of a GSTATS MPL region
84 
85 !** Interface.
86 ! ----------
87 ! CALL MPL_STATSON(SENDNUM,SENDBYTES,RECVNUM,RECVBYTES)
88 
89 ! Input required arguments :
90 ! -------------------------
91 ! none
92 
93 ! Input optional arguments :
94 ! -------------------------
95 ! none
96 
97 ! Output required arguments :
98 ! -------------------------
99 ! SENDNUM - number of unknown messages sent
100 ! SENDBYTES - number of unknown bytes sent
101 ! RECVNUM - number of unknown messages received
102 ! RECVBYTES - number of unknown bytes received
103 
104 ! Output optional arguments :
105 ! -------------------------
106 ! none
107 
108 ! Author.
109 ! -------
110 ! P.Towers ECMWF
111 
112 ! Modifications.
113 ! --------------
114 ! Original: 2011-04-06
115 
116 ! ------------------------------------------------------------------
117 
118 USE parkind1 ,ONLY : jprd, jpim
119 
120 USE yommplstats
121 
122 IMPLICIT NONE
123 
124 REAL(KIND=JPRD), INTENT(OUT) :: SENDBYTES,RECVBYTES
125 INTEGER(KIND=JPIM), INTENT(OUT) :: SENDNUM,RECVNUM
126 
127 
128  sendbytes = sum(mplsendbytes(:))
129  recvbytes = sum(mplrecvbytes(:))
130  sendnum = sum(mplsendnum(:))
131  recvnum = sum(mplrecvnum(:))
132 
133  mplsendbytes(:)=0.0_jprd
134  mplrecvbytes(:)=0.0_jprd
135  mplsendnum(:)=0
136  mplrecvnum(:)=0
137 
138 RETURN
139 END SUBROUTINE mpl_statson
140 
141 SUBROUTINE mpl_statsread(SENDNUM,SENDBYTES,RECVNUM,RECVBYTES)
143 !**** MPL_STATSREAD - read mpl statistics counters
144 
145 ! Purpose.
146 ! --------
147 ! returns the mpl statistics counter values
148 ! before setting them back to zero
149 
150 !** Interface.
151 ! ----------
152 ! CALL MPL_STATSREAD(SENDNUM,SENDBYTES,RECVNUM,RECVBYTES)
153 
154 ! Input required arguments :
155 ! -------------------------
156 ! none
157 
158 ! Input optional arguments :
159 ! -------------------------
160 ! none
161 
162 ! Output required arguments :
163 ! -------------------------
164 ! SENDNUM - number of messages sent
165 ! SENDBYTES - number of bytes sent
166 ! RECVNUM - number of messages received
167 ! RECVBYTES - number of bytes received
168 
169 ! Output optional arguments :
170 ! -------------------------
171 ! none
172 
173 ! Author.
174 ! -------
175 ! P.Towers ECMWF
176 
177 ! Modifications.
178 ! --------------
179 ! Original: 2011-04-06
180 
181 ! ------------------------------------------------------------------
182 
183 USE parkind1 ,ONLY : jprd, jpim
184 
185 USE yommplstats
186 
187 IMPLICIT NONE
188 
189 REAL(KIND=JPRD), INTENT(OUT) :: SENDBYTES,RECVBYTES
190 INTEGER(KIND=JPIM), INTENT(OUT) :: SENDNUM,RECVNUM
191 
192  sendnum=sum(mplsendnum(:))
193  recvnum=sum(mplrecvnum(:))
194  sendbytes=sum(mplsendbytes(:))
195  recvbytes=sum(mplrecvbytes(:))
196 
197  mplsendnum(:)=0
198  mplrecvnum(:)=0
199  mplsendbytes(:)=0.0_jprd
200  mplrecvbytes(:)=0.0_jprd
201 
202 RETURN
203 END SUBROUTINE mpl_statsread
204 
205 SUBROUTINE mpl_sendstats(ICOUNT,ITYPE)
207 !**** MPL_SENDSTATS - collect mpl send statistics
208 
209 ! Purpose.
210 ! --------
211 ! counts the number of messages and volume sent
212 
213 !** Interface.
214 ! ----------
215 ! CALL MPL_SENDSTATS(ICOUNT,ITYPE)
216 
217 ! Input required arguments :
218 ! -------------------------
219 ! ICOUNT - The number of elements sent
220 ! ITYPE - The type of an element
221 
222 ! Input optional arguments :
223 ! -------------------------
224 ! none
225 
226 ! Output required arguments :
227 ! -------------------------
228 ! none
229 
230 ! Output optional arguments :
231 ! -------------------------
232 ! none
233 
234 ! Author.
235 ! -------
236 ! P.Towers ECMWF
237 
238 ! Modifications.
239 ! --------------
240 ! Original: 2011-04-06
241 
242 ! ------------------------------------------------------------------
243 
244 USE parkind1 ,ONLY : jpim
245 
246 USE mpl_data_module
247 USE mpl_message_mod
248 USE yommplstats
249 
250 IMPLICIT NONE
251 
252 INTEGER(KIND=JPIM),INTENT(IN) :: ICOUNT
253 INTEGER(KIND=JPIM),INTENT(IN) :: ITYPE
254 
255 INTEGER(KIND=JPIM) ISIZE,IERR,ITH,OMP_GET_THREAD_NUM
256 
257 ith = 0
258 !$ ITH = OMP_GET_THREAD_NUM()
259 
260 mplsendnum(ith) = mplsendnum(ith) + 1
261 
262 CALL mpi_type_size(itype,isize,ierr)
263 
264 mplsendbytes(ith)=mplsendbytes(ith) + float(isize * icount)
265 
266 
267 RETURN
268 END SUBROUTINE mpl_sendstats
269 
270 SUBROUTINE mpl_recvstats(ICOUNT,ITYPE)
272 !**** MPL_RECVSTATS - collect mpl recv statistics
273 
274 ! Purpose.
275 ! --------
276 ! counts the number of messages and volume received
277 
278 !** Interface.
279 ! ----------
280 ! CALL MPL_RECVSTATS(ICOUNT,ITYPE)
281 
282 ! Input required arguments :
283 ! -------------------------
284 ! ICOUNT - The number of elements received
285 ! ITYPE - The type of an element
286 
287 ! Input optional arguments :
288 ! -------------------------
289 ! none
290 
291 ! Output required arguments :
292 ! -------------------------
293 ! none
294 
295 ! Output optional arguments :
296 ! -------------------------
297 ! none
298 
299 ! Author.
300 ! -------
301 ! P.Towers ECMWF
302 
303 ! Modifications.
304 ! --------------
305 ! Original: 2011-04-06
306 
307 ! ------------------------------------------------------------------
308 
309 USE parkind1 ,ONLY : jpim
310 
311 USE mpl_data_module
312 USE mpl_message_mod
313 USE yommplstats
314 
315 IMPLICIT NONE
316 
317 INTEGER(KIND=JPIM),INTENT(IN) :: ICOUNT
318 INTEGER(KIND=JPIM),INTENT(IN) :: ITYPE
319 
320 INTEGER(KIND=JPIM) ISIZE,IERR,ITH,OMP_GET_THREAD_NUM
321 
322 ith = 0
323 !$ ITH = OMP_GET_THREAD_NUM()
324 
325 mplrecvnum(ith) = mplrecvnum(ith) + 1
326 
327 CALL mpi_type_size(itype,isize,ierr)
328 
329 mplrecvbytes(ith)=mplrecvbytes(ith) + float(isize * icount)
330 
331 RETURN
332 END SUBROUTINE mpl_recvstats
333 
334 END MODULE mpl_stats_mod
integer, parameter jpim
Definition: parkind1.F90:13
integer, parameter jprd
Definition: parkind1.F90:39
subroutine, public mpl_recvstats(ICOUNT, ITYPE)
logical lmplstats
Definition: yommplstats.F90:17
real(kind=jprd), dimension(:), allocatable mplsendbytes
Definition: yommplstats.F90:18
real(kind=jprd), dimension(:), allocatable mplrecvbytes
Definition: yommplstats.F90:18
subroutine, public mpl_statson(SENDNUM, SENDBYTES, RECVNUM, RECVBYTES)
subroutine, public mpl_sendstats(ICOUNT, ITYPE)
intent(out) overrides sub arrays one Sort by the least significant key first sum(iindex(1:n))
integer(kind=jpim), dimension(:), allocatable mplrecvnum
Definition: yommplstats.F90:19
integer(kind=jpim), dimension(:), allocatable mplsendnum
Definition: yommplstats.F90:19
subroutine, public mpl_statsinit
subroutine, public mpl_statsread(SENDNUM, SENDBYTES, RECVNUM, RECVBYTES)