dbcsr_mempool_add Subroutine

public subroutine dbcsr_mempool_add(area)

Adds an unused (refcount==0) data_area to the pool.

Arguments

TypeIntentOptionalAttributesName
type(dbcsr_data_obj) :: area

Contents

Source Code


Source Code

   SUBROUTINE dbcsr_mempool_add(area)
      !! Adds an unused (refcount==0) data_area to the pool.
      TYPE(dbcsr_data_obj)                               :: area

      TYPE(dbcsr_mempool_entry_type), POINTER            :: new_entry
      TYPE(dbcsr_mempool_type), POINTER                  :: pool

      pool => area%d%memory_type%pool
      IF (.NOT. ASSOCIATED(pool)) DBCSR_ABORT("pool not allocated")
      IF (.NOT. dbcsr_data_exists(area)) DBCSR_ABORT("area not allocated")
      IF (area%d%refcount /= 0) DBCSR_ABORT("refcount /= 0")

      CALL mempool_collect_garbage(pool)

!$    CALL OMP_SET_LOCK(pool%lock)
      ALLOCATE (new_entry)
      new_entry%area = area
      new_entry%next => pool%root%next
      pool%root%next => new_entry
!$    CALL OMP_UNSET_LOCK(pool%lock)
   END SUBROUTINE dbcsr_mempool_add