SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
sum_on_all_procs_ol.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE sum_on_all_procs_ol(HGRID,KSIZE,KIN,KOUT,HNAME)
7 ! #######################################################
8 !
9 !
10 !!**** *SUM_ON_ALL_PROCS_OL* - sums the values of the integers provided on each processor
11 !!
12 !! PURPOSE
13 !! -------
14 !!
15 !!** METHOD
16 !! ------
17 !!
18 !! EXTERNAL
19 !! --------
20 !!
21 !!
22 !! IMPLICIT ARGUMENTS
23 !! ------------------
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !!
29 !! AUTHOR
30 !! ------
31 !! V. Masson *Meteo France*
32 !!
33 !! MODIFICATIONS
34 !! -------------
35 !! Original 07/2011
36 !-------------------------------------------------------------------------------
37 !
38 !* 0. DECLARATIONS
39 ! ------------
40 !
41 USE modd_surfex_mpi, ONLY : nindex, nrank, npio, ncomm, nproc
42 !
43 USE modd_surfex_omp, ONLY : nwork0
44 !
46 !
47 USE yomhook ,ONLY : lhook, dr_hook
48 USE parkind1 ,ONLY : jprb
49 !
50 IMPLICIT NONE
51 !
52 #ifdef SFX_MPI
53 include "mpif.h"
54 #endif
55 !
56 !* 0.1 Declarations of arguments
57 ! -------------------------
58 !
59  CHARACTER(LEN=10), INTENT(IN) :: hgrid ! grid type
60 INTEGER, INTENT(IN) :: ksize ! size of integer array
61 INTEGER, DIMENSION(KSIZE), INTENT(IN) :: kin ! integer array to sum
62 INTEGER, INTENT(INOUT) :: kout ! sum of all integers
63  CHARACTER(LEN=3), INTENT(IN) :: hname ! name of type of field
64 !
65 !* 0.2 Declarations of local variables
66 ! -------------------------------
67 !
68 INTEGER, DIMENSION(SIZE(NINDEX)) :: iin
69 INTEGER :: infompi
70 REAL(KIND=JPRB) :: zhook_handle
71 !-------------------------------------------------------------------------------
72 !
73 IF (lhook) CALL dr_hook('SUM_ON_ALL_PROCS_OL',0,zhook_handle)
74 !
75 !* sum of field
76 !
77  CALL gather_and_write_mpi(kin,iin)
78 IF (nrank==npio) THEN
79 !$OMP SINGLE
80  nwork0 = sum(iin)
81 !$OMP END SINGLE
82 ENDIF
83 !
84 IF (nproc>1) THEN
85 !$OMP SINGLE
86 #ifdef SFX_MPI
87  CALL mpi_bcast(nwork0,kind(nwork0)/4,mpi_integer,npio,ncomm,infompi)
88 #endif
89 !$OMP END SINGLE
90 ENDIF
91 !
92 kout = nwork0
93 !
94 IF (lhook) CALL dr_hook('SUM_ON_ALL_PROCS_OL',1,zhook_handle)
95 !
96 !-------------------------------------------------------------------------------
97 !
98 END SUBROUTINE sum_on_all_procs_ol
subroutine sum_on_all_procs_ol(HGRID, KSIZE, KIN, KOUT, HNAME)