ComIn 0.5.1
ICON Community Interface
Loading...
Searching...
No Matches
mo_mpi_handshake.F90
Go to the documentation of this file.
1!> @file mo_mpi_handshake.F90
2!! @brief Interfaces for MPI handshake routines (written in C).
3!
4! @authors 08/2021 :: ICON Community Interface <comin@icon-model.org>
5!
6! SPDX-License-Identifier: BSD-3-Clause
7!
8! Please see the file LICENSE in the root of the source tree for this code.
9! Where software is supplied by third parties, it is indicated in the
10! headers of the routines.
11!
13
15 INTEGER, PARAMETER :: max_groupname_len = 256
16
17CONTAINS
18
19 !> Procedure for the communicator splitting ("MPI handshake") that
20 !> has been harmonized with the respective algorithm of the YAC
21 !> coupler software
22 SUBROUTINE mpi_handshake ( comm, group_names, group_comms )
23 use, INTRINSIC :: iso_c_binding, only : c_ptr, c_char, c_null_char, c_loc
24
25 implicit none
26
27 interface
28 SUBROUTINE mpi_handshake_c2f (n, group_names, group_comms, comm) &
29 bind( c, name='mpi_handshake_c2f')
30 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
31 implicit none
32 INTEGER(KIND=c_int), INTENT(in), VALUE :: n
33 TYPE (c_ptr) , INTENT(in) :: group_names(n)
34 INTEGER(KIND=c_int), INTENT(out) :: group_comms(n)
35 INTEGER(KIND=c_int), INTENT(in), VALUE :: comm
36 end subroutine mpi_handshake_c2f
37 end interface
38
39 integer, intent(in) :: comm
40 character(len=MAX_GROUPNAME_LEN), intent(in) :: group_names(:)
41 integer, intent(inout) :: group_comms(size(group_names))
42
43 CHARACTER (kind=c_char, len=MAX_GROUPNAME_LEN), TARGET :: group_names_cpy(size(group_names))
44 type( c_ptr ) :: group_name_ptr(size(group_names))
45 integer :: i
46 DO i=1,SIZE(group_names)
47 group_names_cpy(i) = trim(group_names(i)) // c_null_char
48 group_name_ptr(i) = c_loc(group_names_cpy(i))
49 END DO
50
51 CALL mpi_handshake_c2f(SIZE(group_names), group_name_ptr, group_comms, comm)
52
53 END SUBROUTINE mpi_handshake
54
55 SUBROUTINE mpi_handshake_dummy(comm)
56 INTEGER, INTENT(IN) :: comm
57 INTEGER :: empty_int_array(0)
58 CHARACTER(LEN=MAX_GROUPNAME_LEN) :: empty_char_array(0)
59
60 CALL mpi_handshake(comm, empty_char_array, empty_int_array)
61 END SUBROUTINE mpi_handshake_dummy
62
63END MODULE mo_mpi_handshake
void mpi_handshake_c2f(int n, char const **group_names, MPI_Fint *group_comms, MPI_Fint comm)
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 mpi_handshake_dummy(comm)
integer, parameter, public max_groupname_len