Initializes the parallel environement.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parallel_obj), | intent(inout) | :: | this |
Parallel object |
impure subroutine parallel_obj_Init(this) !> Initializes the parallel environement. implicit none class(parallel_obj), intent(inout) :: this !! Parallel object ! Work variables logical :: ok integer :: ierr integer :: size_sp integer :: size_dp ! Initialize a first basic MPI environment call MPI_INITIALIZED(ok,ierr) if (.not.ok) call MPI_INIT(ierr) ! Total number of ranks call MPI_COMM_SIZE(MPI_COMM_WORLD,this%nproc,ierr) ! Store the MPI_COMM_WORLD this%comm%w = MPI_COMM_WORLD ! MPI types this%REAL_SP = MPI_REAL this%REAL_DP = MPI_DOUBLE_PRECISION this%COMPLEX_SP = MPI_COMPLEX this%COMPLEX_DP = MPI_DOUBLE_COMPLEX this%INTEGER = MPI_INTEGER this%INT8 = MPI_INTEGER8 this%LOGICAL = MPI_LOGICAL ! Working precision call MPI_TYPE_SIZE(MPI_REAL, size_sp,ierr) call MPI_TYPE_SIZE(MPI_DOUBLE_PRECISION,size_dp,ierr) if (wp .eq. size_sp) then this%REAL_WP = MPI_REAL else if (wp .eq. size_dp) then this%REAL_WP = MPI_DOUBLE_PRECISION else call this%Stop('Error in parallel_obj_init: no WP equivalent in MPI') end if call MPI_TYPE_SIZE(MPI_COMPLEX,size_sp,ierr) call MPI_TYPE_SIZE(MPI_DOUBLE_COMPLEX,size_dp,ierr) if (2*wp .eq. size_sp) then this%COMPLEX_WP = MPI_COMPLEX else if (2*wp .eq. size_dp) then this%COMPLEX_WP = MPI_DOUBLE_COMPLEX else call this%Stop('Error in parallel_obj_init: no complex WP equivalent in MPI') end if ! Topology call MPI_COMM_RANK(this%comm%w,this%rank%mine,ierr) this%rank%mine = this%rank%mine+1 ! Initialize grid communicator to be equal to ! world communicator this%comm%g = this%comm%w return end subroutine parallel_obj_Init