Skip to content

Commit

Permalink
MPI: use mpi module instead of Fortran include statement (#389)
Browse files Browse the repository at this point in the history
* Switch to mpi module, fix some wrong arguments

* Remove uneeded 'status' argument from MPI_SEND calls
  • Loading branch information
phil-blain authored and apcraig committed Dec 19, 2019
1 parent 73fb4d0 commit 1071c7b
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 100 deletions.
3 changes: 1 addition & 2 deletions cicecore/cicedynB/infrastructure/comm/mpi/ice_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module ice_boundary
! 2008-01-28: Elizabeth Hunke replaced old routines with new POP
! infrastructure

use mpi ! MPI Fortran module
use ice_kinds_mod
use ice_communicate, only: my_task, mpiR4, mpiR8, mpitagHalo
use ice_constants, only: field_type_scalar, &
Expand All @@ -37,8 +38,6 @@ module ice_boundary
implicit none
private

include 'mpif.h'

type, public :: ice_halo
integer (int_kind) :: &
communicator, &! communicator to use for update messages
Expand Down
35 changes: 1 addition & 34 deletions cicecore/cicedynB/infrastructure/comm/mpi/ice_broadcast.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module ice_broadcast
! author: Phil Jones, LANL
! Oct. 2004: Adapted from POP version by William H. Lipscomb, LANL

use mpi ! MPI Fortran module
use ice_kinds_mod
use ice_communicate, only: mpiR8, mpir4, MPI_COMM_ICE
use ice_exit, only: abort_ice
Expand Down Expand Up @@ -60,8 +61,6 @@ subroutine broadcast_scalar_dbl(scalar, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_scalar interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -94,8 +93,6 @@ subroutine broadcast_scalar_real(scalar, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_scalar interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -128,8 +125,6 @@ subroutine broadcast_scalar_int(scalar, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_scalar interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -162,8 +157,6 @@ subroutine broadcast_scalar_log(scalar, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_scalar interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -210,8 +203,6 @@ subroutine broadcast_scalar_char(scalar, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_scalar interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -248,8 +239,6 @@ subroutine broadcast_array_dbl_1d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -286,8 +275,6 @@ subroutine broadcast_array_real_1d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -324,8 +311,6 @@ subroutine broadcast_array_int_1d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -362,8 +347,6 @@ subroutine broadcast_array_log_1d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -420,8 +403,6 @@ subroutine broadcast_array_dbl_2d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -458,8 +439,6 @@ subroutine broadcast_array_real_2d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -496,8 +475,6 @@ subroutine broadcast_array_int_2d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -534,8 +511,6 @@ subroutine broadcast_array_log_2d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -592,8 +567,6 @@ subroutine broadcast_array_dbl_3d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -630,8 +603,6 @@ subroutine broadcast_array_real_3d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -668,8 +639,6 @@ subroutine broadcast_array_int_3d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down Expand Up @@ -706,8 +675,6 @@ subroutine broadcast_array_log_3d(array, root_pe)
! to all other processors. This is a specific instance of the generic
! broadcast\_array interface.

include 'mpif.h' ! MPI Fortran include file

integer (int_kind), intent(in) :: &
root_pe ! processor number to broadcast from

Expand Down
13 changes: 5 additions & 8 deletions cicecore/cicedynB/infrastructure/comm/mpi/ice_communicate.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module ice_communicate
! author: Phil Jones, LANL
! Oct. 2004: Adapted from POP version by William H. Lipscomb, LANL

use mpi ! MPI Fortran module
use ice_kinds_mod
use ice_exit, only: abort_ice
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
Expand Down Expand Up @@ -61,8 +62,6 @@ subroutine init_communicate(mpicom)
!
!-----------------------------------------------------------------------

include 'mpif.h' ! MPI Fortran include file

integer (kind=int_kind), optional, intent(in) :: mpicom ! specified communicator

integer (int_kind) :: ierr ! MPI error flag
Expand Down Expand Up @@ -166,8 +165,6 @@ subroutine create_communicator(new_comm, num_procs)
! this routine should be called from init_domain1 when the
! domain configuration (e.g. nprocs_btrop) has been determined

include 'mpif.h'

integer (int_kind), intent(in) :: &
num_procs ! num of procs in new distribution

Expand All @@ -187,7 +184,7 @@ subroutine create_communicator(new_comm, num_procs)
integer (int_kind) :: &
ierr ! error flag for MPI comms

integer (int_kind), dimension(3) :: &
integer (int_kind), dimension(3,1) :: &
range ! range of tasks assigned to new dist
! (assumed 0,num_procs-1)

Expand All @@ -201,9 +198,9 @@ subroutine create_communicator(new_comm, num_procs)

call MPI_COMM_GROUP (MPI_COMM_ICE, MPI_GROUP_ICE, ierr)

range(1) = 0
range(2) = num_procs-1
range(3) = 1
range(1,1) = 0
range(2,1) = num_procs-1
range(3,1) = 1

!-----------------------------------------------------------------------
!
Expand Down
9 changes: 6 additions & 3 deletions cicecore/cicedynB/infrastructure/comm/mpi/ice_exit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subroutine abort_ice(error_message, file, line)
use shr_sys_mod
#else
use ice_fileunits, only: nu_diag, ice_stderr, flush_fileunit
include 'mpif.h' ! MPI Fortran include file
use mpi ! MPI Fortran module
#endif

character (len=*), intent(in),optional :: error_message
Expand All @@ -39,7 +39,9 @@ subroutine abort_ice(error_message, file, line)
! local variables

#ifndef CESMCOUPLED
integer (int_kind) :: ierr ! MPI error flag
integer (int_kind) :: &
ierr, & ! MPI error flag
error_code ! return code
#endif
character(len=*), parameter :: subname='(abort_ice)'

Expand All @@ -62,7 +64,8 @@ subroutine abort_ice(error_message, file, line)
if (present(line)) write (ice_stderr,*) subname,' line number ',line
if (present(error_message)) write (ice_stderr,*) subname,' error = ',trim(error_message)
call flush_fileunit(ice_stderr)
call MPI_ABORT(MPI_COMM_WORLD, ierr)
error_code = 128
call MPI_ABORT(MPI_COMM_WORLD, error_code, ierr)
stop
#endif

Expand Down
Loading

0 comments on commit 1071c7b

Please sign in to comment.