SUBROUTINE setup_buffer_matrices(buffer_set, buff_nrows, buff_ncols, &
source_matrix, index_size, data_size)
TYPE(dbcsr_2d_array_type), INTENT(OUT) :: buffer_set
INTEGER, INTENT(IN) :: buff_nrows, buff_ncols
TYPE(dbcsr_type), INTENT(IN) :: source_matrix
INTEGER, INTENT(IN) :: index_size
INTEGER, INTENT(IN), OPTIONAL :: data_size
CHARACTER(len=*), PARAMETER :: routineN = 'setup_buffer_matrices'
INTEGER :: col_image, handle, row_image
! ---------------------------------------------------------------------------
CALL timeset(routineN, handle)
CALL dbcsr_image_dist_init(buffer_set%image_dist)
ALLOCATE (buffer_set%mats(buff_nrows, buff_ncols))
DO row_image = 1, buff_nrows
DO col_image = 1, buff_ncols
CALL setup_buffer_matrix(buffer_set%mats(row_image, col_image), &
source_matrix, index_size, data_size=data_size, &
data_memory_type=memtype_abpanel_2)
END DO
END DO
IF (source_matrix%local_indexing .AND. careful_mod) THEN
IF (.NOT. array_exists(source_matrix%local_rows)) &
DBCSR_ABORT("Local rows should exist.")
IF (.NOT. array_exists(source_matrix%global_rows)) &
DBCSR_ABORT("Global rows should exist.")
!
IF (.NOT. array_exists(source_matrix%local_cols)) &
DBCSR_ABORT("Local cols should exist.")
IF (.NOT. array_exists(source_matrix%global_cols)) &
DBCSR_ABORT("Global cols should exist.")
END IF
CALL timestop(handle)
END SUBROUTINE setup_buffer_matrices