scalar_shared_memory_mpi.F90 Source File


Contents


Source Code

module scalar_shared_memory_mpi_int
  use Parallel_neci
  use constants
  use mpi, only: MPI_BYTE
  implicit none

! interface for the variadic allocation used when the shared memory option is disabled
  interface variadic_allocate
      module procedure variadic_allocate_1_int
      module procedure variadic_allocate_2_int
  end interface

    interface MPIBCast_inter_byte
        module procedure MPIBCast_inter_byte_int
    end interface

    interface variadic_allocate_1
        module procedure variadic_allocate_1_int
    end interface

    interface variadic_allocate_2
        module procedure variadic_allocate_2_int
    end interface

contains
    subroutine MPIBCast_inter_byte_int(p_shm,nbytes)
      integer(int32):: p_shm
      integer:: nbytes
      integer(MPIArg):: ierr

      !only task 0 of each shared memory task range does the MPI communication
      if (iProcIndex_intra.eq.0) then
         call mpi_bcast(p_shm,int(nbytes,MPIArg), &
              MPI_BYTE,0_MPIArg,mpi_comm_inter,ierr)
      end if

    end subroutine

    subroutine variadic_allocate_1_int(p_shm, dims)
      implicit none
      integer(int32), pointer :: p_shm(:)
      integer(int64) :: dims(1)
      allocate(p_shm(dims(1)))
    end subroutine

    subroutine variadic_allocate_2_int(p_shm, dims)
      implicit none
      integer(int32), pointer :: p_shm(:,:)
      integer(int64):: dims(2)
      allocate(p_shm(dims(1),dims(2)))
    end subroutine

end module


module scalar_shared_memory_mpi_int64
  use Parallel_neci
  use constants
  use mpi, only: MPI_BYTE
  implicit none

! interface for the variadic allocation used when the shared memory option is disabled
  interface variadic_allocate
      module procedure variadic_allocate_1_int64
      module procedure variadic_allocate_2_int64
  end interface

    interface MPIBCast_inter_byte
        module procedure MPIBCast_inter_byte_int64
    end interface

    interface variadic_allocate_1
        module procedure variadic_allocate_1_int64
    end interface

    interface variadic_allocate_2
        module procedure variadic_allocate_2_int64
    end interface

contains
    subroutine MPIBCast_inter_byte_int64(p_shm,nbytes)
      integer(int64):: p_shm
      integer:: nbytes
      integer(MPIArg):: ierr

      !only task 0 of each shared memory task range does the MPI communication
      if (iProcIndex_intra.eq.0) then
         call mpi_bcast(p_shm,int(nbytes,MPIArg), &
              MPI_BYTE,0_MPIArg,mpi_comm_inter,ierr)
      end if

    end subroutine

    subroutine variadic_allocate_1_int64(p_shm, dims)
      implicit none
      integer(int64), pointer :: p_shm(:)
      integer(int64) :: dims(1)
      allocate(p_shm(dims(1)))
    end subroutine

    subroutine variadic_allocate_2_int64(p_shm, dims)
      implicit none
      integer(int64), pointer :: p_shm(:,:)
      integer(int64):: dims(2)
      allocate(p_shm(dims(1),dims(2)))
    end subroutine

end module


module scalar_shared_memory_mpi_doub
  use Parallel_neci
  use constants
  use mpi, only: MPI_BYTE
  implicit none

! interface for the variadic allocation used when the shared memory option is disabled
  interface variadic_allocate
      module procedure variadic_allocate_1_doub
      module procedure variadic_allocate_2_doub
  end interface

    interface MPIBCast_inter_byte
        module procedure MPIBCast_inter_byte_doub
    end interface

    interface variadic_allocate_1
        module procedure variadic_allocate_1_doub
    end interface

    interface variadic_allocate_2
        module procedure variadic_allocate_2_doub
    end interface

contains
    subroutine MPIBCast_inter_byte_doub(p_shm,nbytes)
      real(dp):: p_shm
      integer:: nbytes
      integer(MPIArg):: ierr

      !only task 0 of each shared memory task range does the MPI communication
      if (iProcIndex_intra.eq.0) then
         call mpi_bcast(p_shm,int(nbytes,MPIArg), &
              MPI_BYTE,0_MPIArg,mpi_comm_inter,ierr)
      end if

    end subroutine

    subroutine variadic_allocate_1_doub(p_shm, dims)
      implicit none
      real(dp), pointer :: p_shm(:)
      integer(int64) :: dims(1)
      allocate(p_shm(dims(1)))
    end subroutine

    subroutine variadic_allocate_2_doub(p_shm, dims)
      implicit none
      real(dp), pointer :: p_shm(:,:)
      integer(int64):: dims(2)
      allocate(p_shm(dims(1),dims(2)))
    end subroutine

end module


module scalar_shared_memory_mpi_comp
  use Parallel_neci
  use constants
  use mpi, only: MPI_BYTE
  implicit none

! interface for the variadic allocation used when the shared memory option is disabled
  interface variadic_allocate
      module procedure variadic_allocate_1_comp
      module procedure variadic_allocate_2_comp
  end interface

    interface MPIBCast_inter_byte
        module procedure MPIBCast_inter_byte_comp
    end interface

    interface variadic_allocate_1
        module procedure variadic_allocate_1_comp
    end interface

    interface variadic_allocate_2
        module procedure variadic_allocate_2_comp
    end interface

contains
    subroutine MPIBCast_inter_byte_comp(p_shm,nbytes)
      complex(dp):: p_shm
      integer:: nbytes
      integer(MPIArg):: ierr

      !only task 0 of each shared memory task range does the MPI communication
      if (iProcIndex_intra.eq.0) then
         call mpi_bcast(p_shm,int(nbytes,MPIArg), &
              MPI_BYTE,0_MPIArg,mpi_comm_inter,ierr)
      end if

    end subroutine

    subroutine variadic_allocate_1_comp(p_shm, dims)
      implicit none
      complex(dp), pointer :: p_shm(:)
      integer(int64) :: dims(1)
      allocate(p_shm(dims(1)))
    end subroutine

    subroutine variadic_allocate_2_comp(p_shm, dims)
      implicit none
      complex(dp), pointer :: p_shm(:,:)
      integer(int64):: dims(2)
      allocate(p_shm(dims(1),dims(2)))
    end subroutine

end module


module scalar_shared_memory_mpi
    use scalar_shared_memory_mpi_int
    use scalar_shared_memory_mpi_int64
    use scalar_shared_memory_mpi_doub
    use scalar_shared_memory_mpi_comp
   implicit none
end module