Scientific Programming / 2015 / Article / Lst 11

Research Article

High-Performance Design Patterns for Modern Fortran

Listing 11

subroutine mpi_begin
integer:: dims(), periods(), reorder
! prevent accidentally starting MPI
! if it has already been initiated
if (program_status .eq. 0) then
call MPI_INIT(ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, num_procs, ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, my_id, ierr)
! Create a 1D Cartesian partition
! with reordering and periodicity
 dims = num_procs
 reorder = .true.
 periods = .true.
call MPI_CART_CREATE(MPI_COMM_WORLD, 1, dims, periods, reorder, MPI_COMM_CART, ierr)
call MPI_COMM_RANK(MPI_COMM_CART, my_id, ierr)
call MPI_CART_SHIFT(MPI_COMM_CART, 0, 1, left_id, right_id, ierr)
 program_status = 1
end subroutine

We are committed to sharing findings related to COVID-19 as quickly as possible. We will be providing unlimited waivers of publication charges for accepted research articles as well as case reports and case series related to COVID-19. Review articles are excluded from this waiver policy. Sign up here as a reviewer to help fast-track new submissions.