eplf/src/mpi.irp.f

89 lines
1.5 KiB
Fortran

subroutine start_mpi
implicit none
integer :: ierr
integer, save :: started = 0
IRP_IF MPI
include 'mpif.h'
if (started == 0) then
call MPI_INIT(ierr)
if (ierr /= MPI_SUCCESS) then
call abrt(irp_here,"Unable to initialize MPI")
endif
endif
started = 1
IRP_ENDIF
end
BEGIN_PROVIDER [ integer, mpi_rank ]
implicit none
BEGIN_DOC
! Number of the processor
END_DOC
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call start_mpi
call MPI_COMM_RANK(MPI_COMM_WORLD, mpi_rank, ierr)
if (ierr /= MPI_SUCCESS) then
call abrt(irp_here,"Unable to get MPI")
endif
IRP_ELSE
mpi_rank = 0
IRP_ENDIF
END_PROVIDER
BEGIN_PROVIDER [ integer, mpi_size ]
implicit none
BEGIN_DOC
! Number of processors
END_DOC
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call start_mpi
call MPI_COMM_SIZE(MPI_COMM_WORLD, mpi_size, ierr)
if (ierr /= MPI_SUCCESS) then
call abrt(irp_here,"Unable to get MPI size")
endif
IRP_ELSE
mpi_size = 1
IRP_ENDIF
call iinfo(irp_here,'mpi_size',mpi_size)
END_PROVIDER
BEGIN_PROVIDER [ logical, mpi_master ]
implicit none
BEGIN_DOC
! mpi_master : True if the current processor is the master
END_DOC
mpi_master = (mpi_rank == 0)
END_PROVIDER
subroutine barrier()
IRP_IF MPI
include 'mpif.h'
integer :: ierr
call MPI_BARRIER(MPI_COMM_WORLD,ierr)
if (ierr /= MPI_SUCCESS) then
call abrt(irp_here,'Unable to realize MPI barrier')
endif
IRP_ENDIF
end