dbcsr_distribution_new Subroutine

public subroutine dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, reuse_arrays)

Creates new distribution from blockr distributions

Arguments

Type IntentOptional Attributes Name
type(dbcsr_distribution_type), intent(out) :: dist

distribution

type(dbcsr_distribution_type), intent(in), optional :: template
integer, intent(in), optional :: group
integer, optional, DIMENSION(:, :), POINTER :: pgrid
integer, intent(inout), DIMENSION(:), POINTER :: row_dist
integer, intent(inout), DIMENSION(:), POINTER :: col_dist
logical, intent(in), optional :: reuse_arrays

Source Code

   SUBROUTINE dbcsr_distribution_new(dist, template, group, pgrid, row_dist, col_dist, &
                                     reuse_arrays)
      !! Creates new distribution from blockr distributions

      TYPE(dbcsr_distribution_type), INTENT(OUT)         :: dist
      !! distribution
      TYPE(dbcsr_distribution_type), INTENT(IN), &
         OPTIONAL                                        :: template
      INTEGER, INTENT(IN), OPTIONAL                      :: group
      INTEGER, DIMENSION(:, :), OPTIONAL, POINTER        :: pgrid
      INTEGER, DIMENSION(:), INTENT(INOUT), POINTER      :: row_dist, col_dist
      LOGICAL, INTENT(IN), OPTIONAL                      :: reuse_arrays

      INTEGER, DIMENSION(:), POINTER, CONTIGUOUS         :: cont_row_dist, cont_col_dist

      TYPE(mp_comm_type)                                 :: my_mp_group

      ! Make the arrays contiguous, avoid change in the API
      ALLOCATE (cont_row_dist(SIZE(row_dist)), cont_col_dist(SIZE(col_dist)))
      cont_row_dist(:) = row_dist(:)
      cont_col_dist(:) = col_dist(:)

      IF (PRESENT(reuse_arrays)) THEN
         IF (reuse_arrays) THEN
            DEALLOCATE (row_dist, col_dist)
            NULLIFY (row_dist, col_dist)
         END IF
      END IF

      IF (PRESENT(group)) THEN
         CALL my_mp_group%set_handle(group)
         IF (PRESENT(template)) THEN
            call dbcsr_distribution_new_prv(dist%prv, template%prv, my_mp_group, pgrid, cont_row_dist, cont_col_dist, &
                                            reuse_arrays=.TRUE.)
         ELSE
            call dbcsr_distribution_new_prv(dist%prv, group=my_mp_group, pgrid=pgrid, &
                                            row_dist=cont_row_dist, col_dist=cont_col_dist, &
                                            reuse_arrays=.TRUE.)
         END IF
      ELSE
         IF (PRESENT(template)) THEN
            call dbcsr_distribution_new_prv(dist%prv, template%prv, pgrid=pgrid, row_dist=cont_row_dist, col_dist=cont_col_dist, &
                                            reuse_arrays=.TRUE.)
         ELSE
            call dbcsr_distribution_new_prv(dist%prv, pgrid=pgrid, &
                                            row_dist=cont_row_dist, col_dist=cont_col_dist, &
                                            reuse_arrays=.TRUE.)
         END IF
      END IF
   END SUBROUTINE dbcsr_distribution_new