dbcsr_destroy Subroutine

private recursive subroutine dbcsr_destroy(matrix, force)

Deallocates and destroys a matrix.

Arguments

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

matrix

logical, intent(in), optional :: force

force deallocation


Contents

Source Code


Source Code

   RECURSIVE SUBROUTINE dbcsr_destroy(matrix, force)
      !! Deallocates and destroys a matrix.

      TYPE(dbcsr_type), INTENT(INOUT)                    :: matrix
         !! matrix
      LOGICAL, INTENT(IN), OPTIONAL                      :: force
         !! force deallocation

      CHARACTER(len=*), PARAMETER :: routineN = 'dbcsr_destroy'
      INTEGER                                            :: error_handle
      LOGICAL                                            :: force_all

!   ---------------------------------------------------------------------------

      CALL timeset(routineN, error_handle)
      force_all = .FALSE.
      IF (PRESENT(force)) force_all = force
      IF (.NOT. force_all .AND. matrix%refcount .NE. 0) &
         DBCSR_WARN("You should not destroy referenced matrix.")
      IF (force_all .AND. matrix%refcount .GT. 1) &
         DBCSR_WARN("You should not destroy referenced matrix.")
      IF (force_all .OR. matrix%refcount .EQ. 0) THEN
         IF (ASSOCIATED(matrix%wms)) &
            DBCSR_WARN("Destroying unfinalized matrix")
         IF (ASSOCIATED(matrix%index)) THEN
            CALL memory_deallocate(matrix%index, matrix%index_memory_type)
         END IF
         CALL dbcsr_data_release(matrix%data_area)
         CALL array_release(matrix%row_blk_size)
         CALL array_release(matrix%col_blk_size)
         CALL array_release(matrix%row_blk_offset)
         CALL array_release(matrix%col_blk_offset)
         CALL dbcsr_distribution_release(matrix%dist)
         CALL dbcsr_release_locals(matrix)
         matrix%valid = .FALSE.
         matrix%refcount = 0
      END IF
      CALL timestop(error_handle)
   END SUBROUTINE dbcsr_destroy