dbcsr_create_template Subroutine

private subroutine dbcsr_create_template(matrix, name, template, dist, matrix_type, row_blk_size, col_blk_size, nze, data_type, reuse_arrays, mutable_work, replication_type)

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix
character(len=*), intent(in), optional :: name
type(dbcsr_type), intent(in) :: template
type(dbcsr_distribution_type), intent(in), optional :: dist
character(len=1), intent(in), optional :: matrix_type
integer, intent(inout), optional, DIMENSION(:), POINTER :: row_blk_size
integer, intent(inout), optional, DIMENSION(:), POINTER :: col_blk_size
integer, intent(in), optional :: nze
integer, intent(in), optional :: data_type
logical, intent(in), optional :: reuse_arrays
logical, intent(in), optional :: mutable_work
character(len=1), intent(in), optional :: replication_type

Source Code

   SUBROUTINE dbcsr_create_template(matrix, name, template, &
                                    dist, matrix_type, &
                                    row_blk_size, col_blk_size, nze, data_type, &
                                    reuse_arrays, mutable_work, replication_type)
      TYPE(dbcsr_type), INTENT(INOUT)                    :: matrix
      CHARACTER(len=*), INTENT(IN), OPTIONAL             :: name
      TYPE(dbcsr_type), INTENT(IN)                       :: template
      TYPE(dbcsr_distribution_type), INTENT(IN), &
         OPTIONAL                                        :: dist
      CHARACTER, INTENT(IN), OPTIONAL                    :: matrix_type
      INTEGER, DIMENSION(:), INTENT(INOUT), OPTIONAL, &
         POINTER                                         :: row_blk_size, col_blk_size
      INTEGER, INTENT(IN), OPTIONAL                      :: nze, data_type
      LOGICAL, INTENT(IN), OPTIONAL                      :: reuse_arrays, mutable_work
      CHARACTER, INTENT(IN), OPTIONAL                    :: replication_type

      INTEGER, DIMENSION(:), POINTER, CONTIGUOUS         :: cont_row_blk_size, cont_col_blk_size

      IF (PRESENT(row_blk_size) .NEQV. PRESENT(col_blk_size)) THEN
         DBCSR_ABORT("Both row_blk_size and col_blk_size must be provided!")
      END IF

      ! Make the array contiguous, avoid to change API
      IF (PRESENT(row_blk_size)) THEN
         ! Avoid to change API
         ALLOCATE (cont_row_blk_size(SIZE(row_blk_size)), cont_col_blk_size(SIZE(col_blk_size)))
         cont_row_blk_size(:) = row_blk_size(:)
         cont_col_blk_size(:) = col_blk_size(:)
         IF (PRESENT(reuse_arrays)) THEN
            IF (reuse_arrays) THEN
               DEALLOCATE (row_blk_size, col_blk_size)
               NULLIFY (row_blk_size, col_blk_size)
            END IF
         END IF
      END IF

      IF (PRESENT(dist)) THEN
         IF (PRESENT(row_blk_size)) THEN
            CALL dbcsr_create_prv(matrix%prv, template%prv, name, &
                                  dist%prv, matrix_type, &
                                  row_blk_size=cont_row_blk_size, col_blk_size=cont_col_blk_size, &
                                  nze=nze, data_type=data_type, &
                                  reuse_arrays=.TRUE., mutable_work=mutable_work, &
                                  replication_type=replication_type)
         ELSE
            CALL dbcsr_create_prv(matrix%prv, template%prv, name, &
                                  dist%prv, matrix_type, &
                                  nze=nze, data_type=data_type, &
                                  reuse_arrays=reuse_arrays, mutable_work=mutable_work, &
                                  replication_type=replication_type)
         END IF
      ELSE
         IF (PRESENT(row_blk_size)) THEN
            CALL dbcsr_create_prv(matrix%prv, template%prv, name, &
                                  matrix_type=matrix_type, &
                                  row_blk_size=cont_row_blk_size, col_blk_size=cont_col_blk_size, &
                                  nze=nze, data_type=data_type, &
                                  reuse_arrays=.TRUE., mutable_work=mutable_work, &
                                  replication_type=replication_type)
         ELSE
            CALL dbcsr_create_prv(matrix%prv, template%prv, name, &
                                  matrix_type=matrix_type, &
                                  nze=nze, data_type=data_type, &
                                  reuse_arrays=reuse_arrays, mutable_work=mutable_work, &
                                  replication_type=replication_type)
         END IF
      END IF
   END SUBROUTINE dbcsr_create_template