make_conformant_scalar_c Function

private function make_conformant_scalar_c(scalar, matrix) result(encapsulated)

Encapsulates a given scalar value and makes it conform with the type of the matrix.

Arguments

TypeIntentOptionalAttributesName
complex(kind=real_4), intent(in) :: scalar
type(dbcsr_type), intent(in) :: matrix

Return Value type(dbcsr_scalar_type)


Contents


Source Code

      FUNCTION make_conformant_scalar_c (scalar, matrix) RESULT(encapsulated)
      !! Encapsulates a given scalar value and makes it conform with the
      !! type of the matrix.

         COMPLEX(kind=real_4), INTENT(IN)                      :: scalar
         TYPE(dbcsr_type), INTENT(IN)             :: matrix

         TYPE(dbcsr_scalar_type)                  :: encapsulated
         INTEGER                                  :: data_type, scalar_data_type

         encapsulated = dbcsr_scalar(scalar)
         CALL dbcsr_scalar_fill_all(encapsulated)
         data_type = dbcsr_get_data_type(matrix)
         scalar_data_type = dbcsr_scalar_get_type(encapsulated)
         IF (scalar_data_type .EQ. dbcsr_type_complex_4 .OR. &
             scalar_data_type .EQ. dbcsr_type_complex_8) THEN
            IF (data_type .NE. dbcsr_type_complex_4 .AND. data_type .NE. dbcsr_type_complex_8) &
               DBCSR_ABORT("Can not conform a complex to a real number")
         END IF
         CALL dbcsr_scalar_set_type(encapsulated, data_type)
      END FUNCTION make_conformant_scalar_c