SURFEX v8.1
General documentation of Surfex
mpl_waitany_mod.F90
Go to the documentation of this file.
2 
3 !**** MPL_WAITANY Waits for completion of any request
4 
5 ! Purpose.
6 ! --------
7 ! Returns control when any operation identified by the request
8 ! is completed.
9 ! Normally used in conjunction with non-blocking buffering type
10 
11 !** Interface.
12 ! ----------
13 ! CALL MPL_WAITANY
14 
15 ! Input required arguments :
16 ! -------------------------
17 ! KREQUEST - array or scalar containing
18 ! Communication request(s)
19 ! as provided by MPL_RECV or MPL_SEND
20 
21 ! Input optional arguments :
22 ! -------------------------
23 ! CDSTRING - Character string for ABORT messages
24 ! used when KERROR is not provided
25 
26 ! Output required arguments :
27 ! -------------------------
28 ! KINDEX - index of received request
29 
30 ! Output optional arguments :
31 ! -------------------------
32 ! KERROR - return error code. If not supplied,
33 ! MPL_WAITANY aborts when an error is detected.
34 ! Author.
35 ! -------
36 ! R. El Khatib *Meteo-France*
37 
38 ! Modifications.
39 ! --------------
40 ! Original: 02-Sep-2014
41 
42 ! ------------------------------------------------------------------
43 
44 USE parkind1 ,ONLY : jpim ,jprb ,jprm, jpib
45 
46 USE mpl_mpif
49 
50 IMPLICIT NONE
51 
52 PRIVATE
53 PUBLIC mpl_waitany
54 
55 CONTAINS
56 
57 SUBROUTINE mpl_waitany(KREQUEST,KINDEX,CDSTRING,KERROR)
58 
59 
60 #ifdef USE_8_BYTE_WORDS
61  USE mpi4to8, ONLY : &
62  mpi_waitany => mpi_waitany8
63 #endif
64 
65 INTEGER(KIND=JPIM),INTENT(IN) :: KREQUEST(:)
66 INTEGER(KIND=JPIM),INTENT(OUT) :: KINDEX
67 CHARACTER*(*) ,INTENT(IN), OPTIONAL :: CDSTRING
68 INTEGER(KIND=JPIM),INTENT(OUT),OPTIONAL :: KERROR
69 
70 INTEGER(KIND=JPIM) :: IWAITERR,IREQLEN
71 INTEGER(KIND=JPIM) :: IWAIT_STATUS(mpi_status_size)
72 LOGICAL :: LLABORT
73 llabort=.true.
74 iwaiterr=0
75 
76 IF(mpl_numproc < 1) CALL mpl_message( &
77  & cdmessage='MPL_WAITANY: MPL NOT INITIALISED ',ldabort=llabort)
78 
79 ireqlen=SIZE(krequest)
80 
81 #ifndef MPI1
82 CALL mpi_waitany(ireqlen,krequest,kindex,iwait_status,iwaiterr)
83 #else
84 
85 CALL abor1('MPI_WAITANY not built with MPI2')
86 
87 #endif
88 
89 
90 IF(PRESENT(kerror))THEN
91  kerror=iwaiterr
92 ELSE IF(iwaiterr /= 0) THEN
93  CALL mpl_message(iwaiterr,'MPL_WAITANY_WAITING',cdstring,ldabort=llabort)
94 ENDIF
95 
96 RETURN
97 END SUBROUTINE mpl_waitany
98 
99 
100 END MODULE mpl_waitany_mod
subroutine, public mpl_message(KERROR, CDMESSAGE, CDSTRING, LDABORT)
integer, parameter jpim
Definition: parkind1.F90:13
subroutine abor1(CDTEXT)
Definition: abor1.F90:2
integer(kind=jpim) mpl_numproc
subroutine, public mpl_waitany(KREQUEST, KINDEX, CDSTRING, KERROR)
integer, parameter jprb
Definition: parkind1.F90:32
integer, parameter jprm
Definition: parkind1.F90:30
integer, parameter jpib
Definition: parkind1.F90:14