SURFEX v8.1
General documentation of Surfex
mpl_barrier_mod.F90
Go to the documentation of this file.
2 
3 !**** MPL_BARRIER - Barrier synchronisation
4 
5 ! Purpose.
6 ! --------
7 ! Blocks the caller until all group members have called it.
8 
9 !** Interface.
10 ! ----------
11 ! CALL MPL_BARRIER
12 
13 ! Input required arguments :
14 ! -------------------------
15 ! none
16 
17 ! Input optional arguments :
18 ! -------------------------
19 ! KCOMM - Communicator number if different from MPI_COMM_WORLD
20 ! or from that established as the default
21 ! by an MPL communicator routine
22 ! CDSTRING - Character string for ABORT messages
23 ! used when KERROR is not provided
24 
25 ! Output required arguments :
26 ! -------------------------
27 ! none
28 
29 ! Output optional arguments :
30 ! -------------------------
31 ! KERROR - return error code. If not supplied,
32 ! MPL_BARRIER aborts when an error is detected.
33 ! Author.
34 ! -------
35 ! D.Dent, M.Hamrud ECMWF
36 
37 ! Modifications.
38 ! --------------
39 ! Original: 2000-09-01
40 ! Threadsafe: 2004-12-15, J.Hague
41 
42 ! ------------------------------------------------------------------
43 
44 USE parkind1 ,ONLY : jpim ,jprb
45 
48 
49 IMPLICIT NONE
50 
51 
52 PRIVATE
53 
54 LOGICAL :: llabort=.true.
55 
56 PUBLIC mpl_barrier
57 
58 CONTAINS
59 
60 SUBROUTINE mpl_barrier(KCOMM,CDSTRING,KERROR)
61 
62 
63 #ifdef USE_8_BYTE_WORDS
64  USE mpi4to8, ONLY : &
65  mpi_barrier => mpi_barrier8
66 #endif
67 
68 
69 INTEGER(KIND=JPIM),INTENT(IN),OPTIONAL :: KCOMM
70 INTEGER(KIND=JPIM),INTENT(OUT),OPTIONAL :: KERROR
71 CHARACTER*(*),INTENT(IN),OPTIONAL :: CDSTRING
72 INTEGER :: ICOMM,IERROR,ITID
73 ierror = 0
74 itid = oml_my_thread()
75 IF(mpl_numproc < 1) CALL mpl_message(cdstring=cdstring,&
76  & cdmessage='MPL_BARRIER: MPL NOT INITIALISED ',ldabort=llabort)
77 
78 IF(PRESENT(kcomm)) THEN
79  icomm=kcomm
80 ELSE
81  icomm=mpl_comm_oml(itid)
82 ENDIF
83 
84 #ifdef VPP
85  CALL vpp_barrier
86 #else
87  CALL mpi_barrier(icomm,ierror)
88 #endif
89 
90 IF(PRESENT(kerror)) THEN
91  kerror=ierror
92 ELSE
93  IF(ierror /= 0 ) CALL mpl_message(ierror,'MPL_BARRIER',cdstring,ldabort=llabort)
94 ENDIF
95 
96 RETURN
97 END SUBROUTINE mpl_barrier
98 
99 END MODULE mpl_barrier_mod
subroutine, public mpl_message(KERROR, CDMESSAGE, CDSTRING, LDABORT)
integer, parameter jpim
Definition: parkind1.F90:13
integer(kind=jpim) mpl_numproc
integer(kind=jpim), dimension(:), allocatable mpl_comm_oml
integer, parameter jprb
Definition: parkind1.F90:32
subroutine, public mpl_barrier(KCOMM, CDSTRING, KERROR)