dbcsr_set_d Subroutine

private subroutine dbcsr_set_d(matrix, alpha)

Interface for dbcsr_set

Arguments

Type IntentOptional Attributes Name
type(dbcsr_type), intent(inout) :: matrix
real(kind=real_8), intent(in) :: alpha

Source Code

      SUBROUTINE dbcsr_set_d (matrix, alpha)
      !! Interface for dbcsr_set
         TYPE(dbcsr_type), INTENT(INOUT)           :: matrix
         REAL(kind=real_8), INTENT(IN)                      :: alpha

         CHARACTER(len=*), PARAMETER :: routineN = 'dbcsr_set'

         INTEGER                                            :: col, handle, row
         TYPE(dbcsr_iterator)                               :: iter
         REAL(kind=real_8), DIMENSION(:, :), POINTER                   :: block
         LOGICAL                                            :: tr

         CALL timeset(routineN, handle)

         IF (alpha == 0.0_real_8) THEN
            CALL dbcsr_zero(matrix)
         ELSE
            IF (dbcsr_get_data_type(matrix) /= dbcsr_type_real_8) &
               DBCSR_ABORT("Incompatible data types")

            !TODO: could be speedup by direct assignment to data_area, similar to dbcsr_zero()
            CALL dbcsr_iterator_start(iter, matrix)
            DO WHILE (dbcsr_iterator_blocks_left(iter))
               CALL dbcsr_iterator_next_block(iter, row, col, block, tr)
               block(:, :) = alpha
            END DO
            CALL dbcsr_iterator_stop(iter)
         END IF

         CALL timestop(handle)
      END SUBROUTINE dbcsr_set_d