Skip to content

Commit

Permalink
Make mpi_f08 opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick Stein authored and fstein93 committed Jan 10, 2023
1 parent 3c3bfb1 commit 81cb08f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ there are several freely available alternatives:

CP2K assumes that the MPI library implements MPI version 3. Older
versions of MPI (e.g., MPI 2.0) are not supported and the old flag `-D__MPI_VERSION` in
the arch file will be ignored. CP2K makes use of the mpi_f08 module by default. Should there
be any issues with the usage of this module, set the flag `-D__NO_MPI_F08`.
the arch file will be ignored. CP2K can make use of the mpi_f08 module. If its use is requested,
set the flag `-D__MPI_F08`.

### 2f. FFTW (optional, improved performance of FFTs)

Expand Down
4 changes: 2 additions & 2 deletions src/cp2k_info.F
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ FUNCTION cp2k_flags() RESULT(flags)
#if defined(__parallel)
flags = TRIM(flags)//" parallel"
#endif
#if defined(__NO_MPI_F08)
flags = TRIM(flags)//" no_mpi_f08"
#if defined(__MPI_F08)
flags = TRIM(flags)//" mpi_f08"
#endif
#if defined(__SCALAPACK)
flags = TRIM(flags)//" scalapack"
Expand Down
24 changes: 12 additions & 12 deletions src/mpiwrap/message_passing.F
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MODULE message_passing

! To simplify the transition between the old MPI module and the F08-style module, we introduce these constants to switch between the required handle types
! Unfortunately, Fortran does not offer something like typedef in C++
#if defined(__parallel) && !defined(__NO_MPI_F08)
#if defined(__parallel) && defined(__MPI_F08)
#define MPI_DATA_TYPE TYPE(MPI_Datatype)
#define MPI_COMM_TYPE TYPE(MPI_Comm)
#define MPI_REQUEST_TYPE TYPE(MPI_Request)
Expand All @@ -55,10 +55,10 @@ MODULE message_passing
#endif

#if defined(__parallel)
#if defined(__NO_MPI_F08)
USE mpi
#else
#if defined(__MPI_F08)
USE mpi_f08
#else
USE mpi
#endif
! subroutines: unfortunately, mpi implementations do not provide interfaces for all subroutines (problems with types and ranks explosion),
! we do not quite know what is in the module, so we can not include any....
Expand Down Expand Up @@ -825,7 +825,7 @@ ELEMENTAL SUBROUTINE mp_${type}$_type_set_handle(this, handle)
CLASS(mp_${type}$_type), INTENT(INOUT) :: this
INTEGER, INTENT(IN) :: handle

#if defined(__parallel) && !defined(__NO_MPI_F08)
#if defined(__parallel) && defined(__MPI_F08)
this%handle%mpi_val = handle
#else
this%handle = handle
Expand All @@ -836,7 +836,7 @@ ELEMENTAL FUNCTION mp_${type}$_type_get_handle(this) RESULT(handle)
CLASS(mp_${type}$_type), INTENT(IN) :: this
INTEGER :: handle

#if defined(__parallel) && !defined(__NO_MPI_F08)
#if defined(__parallel) && defined(__MPI_F08)
handle = this%handle%mpi_val
#else
handle = this%handle
Expand Down Expand Up @@ -1791,7 +1791,7 @@ SUBROUTINE mp_waitall_1(requests)
INTEGER :: handle, ierr
#if defined(__parallel)
INTEGER :: count
#if defined(__NO_MPI_F08)
#if !defined(__MPI_F08)
INTEGER, ALLOCATABLE, DIMENSION(:, :) :: status
#else
TYPE(MPI_Status), ALLOCATABLE, DIMENSION(:) :: status
Expand All @@ -1803,7 +1803,7 @@ SUBROUTINE mp_waitall_1(requests)

#if defined(__parallel)
count = SIZE(requests)
#if defined(__NO_MPI_F08)
#if !defined(__MPI_F08)
ALLOCATE (status(MPI_STATUS_SIZE, count))
#else
ALLOCATE (status(count))
Expand Down Expand Up @@ -1833,7 +1833,7 @@ SUBROUTINE mp_waitall_2(requests)
INTEGER :: handle, ierr
#if defined(__parallel)
INTEGER :: count
#if defined(__NO_MPI_F08)
#if !defined(__MPI_F08)
INTEGER, ALLOCATABLE, DIMENSION(:, :) :: status
#else
TYPE(MPI_Status), ALLOCATABLE, DIMENSION(:) :: status
Expand All @@ -1845,7 +1845,7 @@ SUBROUTINE mp_waitall_2(requests)

#if defined(__parallel)
count = SIZE(requests)
#if defined(__NO_MPI_F08)
#if !defined(__MPI_F08)
ALLOCATE (status(MPI_STATUS_SIZE, count))
#else
ALLOCATE (status(count))
Expand Down Expand Up @@ -1875,7 +1875,7 @@ END SUBROUTINE mp_waitall_2
SUBROUTINE mpi_waitall_internal(count, array_of_requests, array_of_statuses, ierr)
INTEGER, INTENT(in) :: count
TYPE(mp_request_type), DIMENSION(count), INTENT(inout) :: array_of_requests
#if defined(__NO_MPI_F08)
#if !defined(__MPI_F08)
INTEGER, DIMENSION(MPI_STATUS_SIZE, count), &
INTENT(out) :: array_of_statuses
#else
Expand Down Expand Up @@ -4033,7 +4033,7 @@ SUBROUTINE mp_file_type_free(type_descriptor)
IF (ierr /= 0) &
CPABORT("MPI_Type_free @ "//routineN)
#endif
#if defined(__parallel) && !defined(__NO_MPI_F08)
#if defined(__parallel) && defined(__MPI_F08)
type_descriptor%type_handle%mpi_val = -1
#else
type_descriptor%type_handle = -1
Expand Down

0 comments on commit 81cb08f

Please sign in to comment.