mem_pool - Implement a straightforward memory pool
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
DATA TYPES AND ROUTINES
IMPLEMENTATION NOTES
COPYRIGHT
|
The mem_pool.f90 source file defines a set of subroutines that allow you to acquire and release memory of a particular derived type, thereby reducing the number of allocations and deallocations. Such a memory pool is useful for instance when you need temporary memory of fixed size.
The source code expects a data type, POOL_DATA, that contains an integer field "pool_index" for private use by the subroutines. All other fields can be used by the application itself:
module MYDATA_POOL type POOLDATA integer :: pool_index ! For private use by pool_acquire/pool_release real, dimension(100) :: work ! The actual work space end type include "mem_pool.f90" end module MYDATA_POOL |
The subroutines do not change the fields of the POOL_DATA structure (except for pool_index). This means that allocatable (pointer) components in this structure are not influenced. You could use this to store dynamically sized arrays in the memory pool. It is especially useful if all such arrays have the same size.
Copyright © 2006 Arjen Markus <arjenmarkus@sourceforge.net>