convert_csr_to_dbcsr Subroutine

public subroutine convert_csr_to_dbcsr(dbcsr_mat, csr_mat)

convert a CSR matrix to a DBCSR matrix

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_type), intent(inout) :: dbcsr_mat

correctly allocated DBCSR matrix

type(csr_type), intent(inout) :: csr_mat

CSR matrix to convert


Contents

Source Code


Source Code

   SUBROUTINE convert_csr_to_dbcsr(dbcsr_mat, csr_mat)
      !! convert a CSR matrix to a DBCSR matrix

      TYPE(dbcsr_type), INTENT(INOUT)                    :: dbcsr_mat
         !! correctly allocated DBCSR matrix
      TYPE(csr_type), INTENT(INOUT)                      :: csr_mat
         !! CSR matrix to convert

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

      INTEGER                                            :: handle
      TYPE(dbcsr_type)                                   :: dbcsr_mat_nosym

      CALL timeset(routineN, handle)

      IF (.NOT. dbcsr_valid_index(dbcsr_mat)) &
         DBCSR_ABORT("Invalid DBCSR matrix")

      IF (dbcsr_get_data_type(dbcsr_mat) /= csr_mat%nzval_local%data_type) &
         DBCSR_ABORT("DBCSR and CSR matrix must have same type")

      IF (.NOT. csr_mat%has_mapping) &
         DBCSR_ABORT("CSR_mat must contain mapping to DBCSR format")

      ! Desymmetrize to assert that DBCSR matrix has sparsity pattern consistent with CSR matrix
      IF (dbcsr_has_symmetry(dbcsr_mat)) THEN
         CALL dbcsr_desymmetrize_deep(dbcsr_mat, dbcsr_mat_nosym, untransposed_data=.TRUE.)
      ELSE
         dbcsr_mat_nosym = dbcsr_mat
      END IF

      CALL csr_assert_consistency_with_dbcsr(csr_mat, dbcsr_mat_nosym)

      IF (dbcsr_has_symmetry(dbcsr_mat)) CALL dbcsr_release(dbcsr_mat_nosym)

      ! 1) CSR -> BRD
      CALL convert_csr_to_brd(csr_mat%dbcsr_mapping%brd_mat, csr_mat)

      ! 2) BRD -> DBCSR
      CALL dbcsr_complete_redistribute(csr_mat%dbcsr_mapping%brd_mat, dbcsr_mat)

      CALL timestop(handle)
   END SUBROUTINE convert_csr_to_dbcsr