csr_assert_consistency_with_dbcsr Subroutine

private subroutine csr_assert_consistency_with_dbcsr(csr_mat, dbcsr_mat)

Helper function to assert that a given CSR matrix and a given DBCSR matrix are consistent before doing the conversion

Arguments

Type IntentOptional Attributes Name
type(csr_type), intent(in) :: csr_mat
type(dbcsr_type), intent(in) :: dbcsr_mat

Source Code

   SUBROUTINE csr_assert_consistency_with_dbcsr(csr_mat, dbcsr_mat)
      !! Helper function to assert that a given CSR matrix and a given DBCSR
      !! matrix are consistent before doing the conversion

      TYPE(csr_type), INTENT(IN)                         :: csr_mat
      TYPE(dbcsr_type), INTENT(IN)                       :: dbcsr_mat

      CHARACTER(LEN=*), PARAMETER :: routineN = 'csr_assert_consistency_with_dbcsr'

      INTEGER                                            :: handle
      TYPE(csr_mapping_data)                             :: map

      CALL timeset(routineN, handle)
      map = csr_mat%dbcsr_mapping
      IF (map%has_dbcsr_block_data) THEN
         IF (map%dbcsr_nblkcols_total .NE. dbcsr_nblkcols_total(dbcsr_mat)) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field nblkcols_total of DBCSR matrix not consistent with CSR matrix")
         IF (map%dbcsr_nblkrows_total .NE. dbcsr_nblkrows_total(dbcsr_mat)) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field nblkrows_total of DBCSR matrix not consistent with CSR matrix")
         IF (map%dbcsr_nblks_local .NE. dbcsr_mat%nblks) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field nblks of DBCSR matrix not consistent with CSR matrix")
         IF (ANY(map%dbcsr_row_p .NE. dbcsr_mat%row_p)) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field row_p of DBCSR matrix not consistent with CSR matrix")
         IF (ANY(map%dbcsr_col_i .NE. dbcsr_mat%col_i)) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field dbcsr_col_i of DBCSR matrix not consistent with CSR matrix")
         IF (ANY(map%dbcsr_row_blk_size .NE. dbcsr_row_block_sizes(dbcsr_mat))) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field row_blk_size of DBCSR matrix not consistent with CSR matrix")
         IF (ANY(map%dbcsr_col_blk_size .NE. dbcsr_col_block_sizes(dbcsr_mat))) &
            CALL dbcsr_abort(__LOCATION__, &
                             "field col_blk_size of DBCSR matrix not consistent with CSR matrix")
      ELSE
         CALL dbcsr_warn(__LOCATION__, "Can not assert consistency of the matrices "// &
                         "as no block data stored in CSR matrix.")
      END IF
      CALL timestop(handle)
   END SUBROUTINE csr_assert_consistency_with_dbcsr