convert_dbcsr_to_csr Subroutine

public subroutine convert_dbcsr_to_csr(dbcsr_mat, csr_mat)

Convert a DBCSR matrix to a CSR matrix.

Arguments

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

DBCSR matrix to convert

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

correctly allocated CSR matrix


Source Code

   SUBROUTINE convert_dbcsr_to_csr(dbcsr_mat, csr_mat)
      !! Convert a DBCSR matrix to a CSR matrix.

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

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

      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")

      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)

      ! 1) DBCSR -> BRD
      CALL dbcsr_complete_redistribute(dbcsr_mat_nosym, csr_mat%dbcsr_mapping%brd_mat)
      ! 2) BRD -> CSR
      CALL convert_brd_to_csr(csr_mat%dbcsr_mapping%brd_mat, csr_mat)

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

      CALL timestop(handle)
   END SUBROUTINE convert_dbcsr_to_csr