17 USE iso_c_binding,
ONLY: c_int
31#include "comin_global.inc"
34 INTEGER,
PARAMETER :: MAX_GRPNAMELEN = 256
36 INTEGER,
PARAMETER :: MAX_GROUPS = 64
39 INTEGER,
PARAMETER :: debug_level = 0
51 INTEGER,
INTENT(IN) :: comm
52 CHARACTER(LEN=MAX_GRPNAMELEN),
INTENT(IN) :: group_names(:)
53 CHARACTER(LEN=*),
INTENT(IN) :: component_name
55 INTEGER :: num_plugin_comms
56 CHARACTER(LEN=MAX_GRPNAMELEN),
ALLOCATABLE :: all_group_names(:)
57 INTEGER,
ALLOCATABLE :: all_comms(:)
59 num_plugin_comms = count(group_names /=
"")
60 ALLOCATE(all_group_names(num_plugin_comms+1))
61 IF(num_plugin_comms > 0) &
62 all_group_names(1:num_plugin_comms) = pack(group_names, group_names /=
"")
63 all_group_names(num_plugin_comms+1) =
"comin_host_"//component_name
65 ALLOCATE(all_comms(num_plugin_comms+1))
68 ALLOCATE(
state%parallel_info%component_name_bilateral(num_plugin_comms))
69 state%parallel_info%component_name_bilateral = all_group_names(1:num_plugin_comms)
70 state%parallel_info%mpi_comm_bilateral = all_comms(1:num_plugin_comms)
71 state%parallel_info%host_comm = all_comms(num_plugin_comms+1)
73 DEALLOCATE(all_group_names)
78 INTEGER :: i, ierr, nmpi_comm
80 IF (.NOT.
ALLOCATED(
state%parallel_info%mpi_comm_bilateral))
RETURN
81 nmpi_comm =
SIZE(
state%parallel_info%mpi_comm_bilateral)
83 CALL mpi_comm_free(
state%parallel_info%mpi_comm_bilateral(i), ierr)
85 state%parallel_info%mpi_comm_bilateral(i) = mpi_comm_null
87 DEALLOCATE(
state%parallel_info%mpi_comm_bilateral)
88 DEALLOCATE(
state%parallel_info%component_name_bilateral)
95 mpi_comm =
state%parallel_info%host_comm
99 INTEGER(KIND=C_INT) FUNCTION comin_parallel_get_host_mpi_comm_c() &
100 result(mpi_comm)
BIND(C, name="comin_parallel_get_host_mpi_comm")
102 END FUNCTION comin_parallel_get_host_mpi_comm_c
110 mpi_comm = comin_parallel_find_mpi_comm(
state%parallel_info,
state%current_plugin%comm)
111 IF(mpi_comm == mpi_comm_null)
THEN
113 &
"Error: To use the plugin_comm, 'comm' must be set in the plugin namelist")
118 INTEGER(KIND=C_INT) FUNCTION comin_parallel_get_plugin_mpi_comm_c() &
119 result(mpi_comm)
BIND(C, name="comin_parallel_get_plugin_mpi_comm")
121 END FUNCTION comin_parallel_get_plugin_mpi_comm_c
128 INTEGER :: mpi_comm, ierr, rank_f
130 CALL mpi_comm_rank(mpi_comm, rank_f, ierr)
138 INTEGER FUNCTION comin_parallel_find_mpi_comm(parallel_info, component_name)
140 CHARACTER(LEN=*),
INTENT(IN) :: component_name
142 INTEGER :: i, nmpi_comm
144 comin_parallel_find_mpi_comm = mpi_comm_null
145 IF (.NOT.
ALLOCATED(parallel_info%mpi_comm_bilateral))
RETURN
146 nmpi_comm =
SIZE(parallel_info%mpi_comm_bilateral)
147 loop :
DO i=1,nmpi_comm
148 IF (trim(parallel_info%component_name_bilateral(i)) == component_name)
THEN
149 comin_parallel_find_mpi_comm = parallel_info%mpi_comm_bilateral(i)
153 END FUNCTION comin_parallel_find_mpi_comm
157 INTEGER,
INTENT(IN) :: errcode
159 IF (errcode .NE. mpi_success)
THEN
160 WRITE (0,*)
"Error in MPI program. Terminating."
161 CALL mpi_abort(mpi_comm_world, errcode, ierr)
integer function, public comin_parallel_get_host_mpi_comm()
Returns the communicator with all ICON processes.
subroutine, public mpi_handshake(comm, group_names, group_comms)
Procedure for the communicator splitting ("MPI handshake") that has been harmonized with the respecti...
subroutine, public comin_parallel_mpi_handshake(comm, group_names, component_name)
Procedure for the communicator splitting ("MPI handshake") that has been harmonized with the respecti...
subroutine, public comin_plugin_finish(routine, text)
Wrapper function for callback to ICON's "finish" routine.
integer function, public comin_parallel_get_plugin_mpi_comm()
Called within a plugin's callback function: get MPI communicator which contains all MPI tasks of the ...
integer(kind=c_int) function, public comin_parallel_get_host_mpi_rank()
Called within a plugin's callback function: get MPI rank with respect to the "host" MPI communicator.
subroutine, public comin_parallel_handle_mpi_errcode(errcode)
Utility function.
subroutine, public comin_parallel_free_mpi_comms()
type(t_comin_state), pointer, public state