SURFEX v8.1
General documentation of Surfex
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 !
42 !
44 !
45 USE yomhook ,ONLY : lhook, dr_hook
46 USE parkind1 ,ONLY : jprb
47 !
48 IMPLICIT NONE
49 !
50 #ifdef SFX_MPI
51 include "mpif.h"
52 #endif
53 !
54 !* 0.1 Declarations of arguments
55 ! -------------------------
56 !
57  CHARACTER(LEN=10), INTENT(IN) :: HGRID ! grid type
58 INTEGER, INTENT(IN) :: KSIZE ! size of integer array
59 INTEGER, DIMENSION(KSIZE), INTENT(IN) :: KIN ! integer array to sum
60 INTEGER, INTENT(INOUT) :: KOUT ! sum of all integers
61  CHARACTER(LEN=3), INTENT(IN) :: HNAME ! name of type of field
62 !
63 !* 0.2 Declarations of local variables
64 ! -------------------------------
65 !
66 INTEGER, DIMENSION(NDIM_FULL_INIT) :: IIN
67 INTEGER :: INFOMPI
68 REAL(KIND=JPRB) :: ZHOOK_HANDLE
69 !-------------------------------------------------------------------------------
70 !
71 IF (lhook) CALL dr_hook('SUM_ON_ALL_PROCS_OL',0,zhook_handle)
72 !
73 !* sum of field
74 !
75  CALL gather_and_write_mpi(kin,iin)
76 IF (nrank==npio) THEN
77  kout = sum(iin)
78 ENDIF
79 !
80 IF (nproc>1) THEN
81 #ifdef SFX_MPI
82  CALL mpi_bcast(kout,kind(kout)/4,mpi_integer,npio,ncomm,infompi)
83 #endif
84 ENDIF
85 !
86 IF (lhook) CALL dr_hook('SUM_ON_ALL_PROCS_OL',1,zhook_handle)
87 !
88 !-------------------------------------------------------------------------------
89 !
90 END SUBROUTINE sum_on_all_procs_ol
subroutine sum_on_all_procs_ol(HGRID, KSIZE, KIN, KOUT, HNAME)
integer, parameter jprb
Definition: parkind1.F90:32
intent(out) overrides sub arrays one Sort by the least significant key first sum(iindex(1:n))
logical lhook
Definition: yomhook.F90:15