dbcsr_mempool_clear Subroutine

public subroutine dbcsr_mempool_clear(pool)

Deallocates all data_areas contained in given mempool.

Arguments

Type IntentOptional Attributes Name
type(dbcsr_mempool_type), POINTER :: pool

Source Code

   SUBROUTINE dbcsr_mempool_clear(pool)
      !! Deallocates all data_areas contained in given mempool.
      TYPE(dbcsr_mempool_type), POINTER                  :: pool

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

      INTEGER                                            :: handle
      TYPE(dbcsr_mempool_entry_type), POINTER            :: cur, prev

      IF (.NOT. ASSOCIATED(pool)) DBCSR_ABORT("pool not allocated")

      CALL timeset(routineN, handle)

!$    CALL OMP_SET_LOCK(pool%lock)
      cur => pool%root%next
      DO WHILE (ASSOCIATED(cur))
         CALL internal_data_deallocate(cur%area%d)
         DEALLOCATE (cur%area%d)
         prev => cur
         cur => cur%next
         DEALLOCATE (prev)
      END DO
      NULLIFY (pool%root%next)
!$    CALL OMP_UNSET_LOCK(pool%lock)

      CALL timestop(handle)
   END SUBROUTINE dbcsr_mempool_clear