dbcsr_mp_new_grid Subroutine

private subroutine dbcsr_mp_new_grid(mp_env, mp_group, pgrid, mynode, numnodes, myprow, mypcol, source)

Creates new process grid

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mp_obj), intent(out) :: mp_env

multiprocessor environment

type(mp_comm_type), intent(in) :: mp_group
integer, intent(in), DIMENSION(0:, 0:) :: pgrid

process grid

integer, intent(in) :: mynode

my processor number

integer, intent(in), optional :: numnodes

total number of processors (processes)

integer, intent(in), optional :: myprow

total number of processors (processes)

integer, intent(in), optional :: mypcol

total number of processors (processes)

integer, intent(in), optional :: source

total number of processors (processes)


Source Code

   SUBROUTINE dbcsr_mp_new_grid(mp_env, mp_group, pgrid, mynode, &
                                numnodes, myprow, mypcol, source)
      !! Creates new process grid

      TYPE(dbcsr_mp_obj), INTENT(OUT)                    :: mp_env
         !! multiprocessor environment
      TYPE(mp_comm_type), INTENT(IN)                     :: mp_group
      INTEGER, INTENT(IN)                                :: mynode
         !! my processor number
      INTEGER, DIMENSION(0:, 0:), INTENT(IN)             :: pgrid
         !! process grid
      INTEGER, INTENT(IN), OPTIONAL                      :: numnodes, myprow, mypcol, source
         !! total number of processors (processes)

      INTEGER                                            :: pcol, prow

!   ---------------------------------------------------------------------------

      ALLOCATE (mp_env%mp)
      mp_env%mp%refcount = 1
      ALLOCATE (mp_env%mp%pgrid(0:SIZE(pgrid, 1) - 1, 0:SIZE(pgrid, 2) - 1))
      mp_env%mp%pgrid(:, :) = pgrid(:, :)
      mp_env%mp%mynode = mynode
      mp_env%mp%mp_group = mp_group
      mp_env%mp%source = 0
      IF (PRESENT(source)) mp_env%mp%source = source
      IF (PRESENT(numnodes)) THEN
         mp_env%mp%numnodes = numnodes
      ELSE
         mp_env%mp%numnodes = SIZE(pgrid)
      END IF
      IF (PRESENT(myprow) .AND. PRESENT(mypcol)) THEN
         mp_env%mp%myprow = myprow
         mp_env%mp%mypcol = mypcol
      ELSE
         mp_env%mp%myprow = -33777
         mp_env%mp%mypcol = -33777
         column_loop: DO pcol = LBOUND(pgrid, 2), UBOUND(pgrid, 2)
            row_loop: DO prow = LBOUND(pgrid, 1), UBOUND(pgrid, 1)
               test_position: IF (pgrid(prow, pcol) .EQ. mynode) THEN
                  mp_env%mp%myprow = prow
                  mp_env%mp%mypcol = pcol
                  EXIT column_loop
               END IF test_position
            END DO row_loop
         END DO column_loop
      END IF
      mp_env%mp%subgroups_defined = .FALSE.
      !call dbcsr_mp_grid_setup(mp_env)
   END SUBROUTINE dbcsr_mp_new_grid