SURFEX v8.1
General documentation of Surfex
mpl_myrank_mod.F90
Go to the documentation of this file.
2 
3 !**** MPL_MYRANK - Find rank
4 
5 ! Purpose.
6 ! --------
7 ! Returns the rank of the calling process
8 ! in the currently active communicator
9 
10 !** Interface.
11 ! ----------
12 ! IRANK=MPL_MYRANK(KCOMM)
13 
14 ! Input optional arguments :
15 ! -------------------------
16 ! KCOMM - Communicator number if different from MPI_COMM_WORLD
17 
18 ! Input required arguments :
19 ! -------------------------
20 
21 ! Input optional arguments :
22 ! -------------------------
23 ! none
24 
25 ! Output required arguments :
26 ! -------------------------
27 ! none
28 
29 ! Output optional arguments :
30 ! -------------------------
31 ! none
32 ! Author.
33 ! -------
34 ! D.Dent, M.Hamrud ECMWF
35 
36 ! Modifications.
37 ! --------------
38 ! Original: 2000-09-01
39 
40 ! ------------------------------------------------------------------
41 
42 USE parkind1 ,ONLY : jpim ,jprb
43 
46 
47 IMPLICIT NONE
48 PRIVATE
49 PUBLIC mpl_myrank
50 
51 CONTAINS
52 
53 FUNCTION mpl_myrank(KCOMM)
54 
55 #ifdef USE_8_BYTE_WORDS
56  USE mpi4to8, ONLY : &
57  mpi_comm_rank => mpi_comm_rank8
58 #endif
59 
60 INTEGER(KIND=JPIM),INTENT(IN),OPTIONAL :: KCOMM
61 INTEGER(KIND=JPIM) :: MPL_MYRANK
62 
63 INTEGER(KIND=JPIM) IRANK,IERROR,ICOMM
64 LOGICAL :: LLABORT=.true.
65 
66 IF(mpl_numproc < 1) CALL mpl_message( &
67  & cdmessage='MPL_MYRANK: MPL NOT INITIALISED ',ldabort=llabort)
68 
69 IF(PRESENT(kcomm)) THEN
70  CALL mpi_comm_rank(kcomm, irank, ierror)
71  IF(ierror /= 0 ) CALL mpl_message(ierror,&
72  &'MPL_MYRANK: ERROR FROM MPI_COMM_RANK')
73  mpl_myrank=irank+1
74 ELSE
75  mpl_myrank=mpl_rank
76 ENDIF
77 
78 END FUNCTION mpl_myrank
79 
80 END MODULE mpl_myrank_mod
subroutine, public mpl_message(KERROR, CDMESSAGE, CDSTRING, LDABORT)
integer, parameter jpim
Definition: parkind1.F90:13
integer(kind=jpim) mpl_numproc
integer, parameter jprb
Definition: parkind1.F90:32
integer(kind=jpim) function, public mpl_myrank(KCOMM)
integer(kind=jpim) mpl_rank