FEDEM Solver  R8.0
Source code of the dynamics solver
Data Types | Functions/Subroutines | Variables
allocationmodule Module Reference

Module with subroutines for dynamic allocation of arrays. More...

Data Types

interface  reallocate
 Allocates, reallocates or deallocates a generic array. More...
 
interface  logallocmem
 Prints the accumulated memory usage to log file. More...
 

Functions/Subroutines

subroutine reallocateint (label, array, nw, ierr, preserveContent)
 Allocate, reallocate or deallocate a one-dimensional integer array. More...
 
subroutine reallocateint8 (label, array, nw, ierr, preserveContent)
 Allocate, reallocate or deallocate a one-dimensional integer array. More...
 
subroutine reallocatefloat1d (label, array, nw, ierr)
 Allocate, reallocate or deallocate a one-dimensional real array. More...
 
subroutine reallocatefloat2d (label, array, n1, n2, ierr)
 Allocate, reallocate or deallocate a two-dimensional real array. More...
 
subroutine reallocatedouble1d (label, array, nw, ierr, preserveContent)
 Allocate, reallocate or deallocate a one-dimensional real array. More...
 
subroutine reallocatebigdouble1d (label, array, nw, ierr)
 Allocate, reallocate or deallocate a big one-dimensional real array. More...
 
subroutine reallocatedouble2d (label, array, n1, n2, ierr)
 Allocate, reallocate or deallocate a two-dimensional real array. More...
 
subroutine logallocmemi8 (label, oldSize, newSize, nBytes)
 Prints the current accumulated memory usage to the log file. More...
 
subroutine logallocmemi4 (label, oldSize, newSize, nBytes)
 Prints the current accumulated memory usage to the log file. More...
 
subroutine, public closememlogfile ()
 Closes the memory logging file. More...
 
subroutine, public writepeakmem (lpu)
 Writes the peak memory usage to file unit lpu. More...
 
subroutine, public writestorage (name, nwI, nwR, lpu)
 Writes storage requirement information for an item to unit lpu. More...
 
character(len=12) function, public strbytes (nBytes)
 Converts a number of bytes to a user-friendly string. More...
 

Variables

logical, save, public dologmem = .false.
 Toggle for print of memory usage. More...
 
integer, save logfile = 0
 File unit number for memory logging. More...
 
integer(i8), save totmem = 0_i8
 Total number of bytes allocatedy. More...
 
integer(i8), save peakmem = 0_i8
 Maximum number of bytes allocated. More...
 

Detailed Description

Module with subroutines for dynamic allocation of arrays.

This module contains utility subroutines to facilitate allocation, reallocation, and deallocation of integer, real and double precision arrays, with optional log of accumulated memory usage. They work much in the similar way as the C-function realloc(). The allocation subroutines are accessed via the common interface allocationmodule::reallocate().

Author
Knut Morten Okstad
Date
25 Oct 2001

Function/Subroutine Documentation

◆ closememlogfile()

subroutine, public allocationmodule::closememlogfile

Closes the memory logging file.

◆ logallocmemi4()

subroutine allocationmodule::logallocmemi4 ( character(len=*), intent(in)  label,
integer, intent(in)  oldSize,
integer, intent(in)  newSize,
integer, intent(in)  nBytes 
)

Prints the current accumulated memory usage to the log file.

Parameters
[in]labelName of calling subroutine
[in]oldSizeNumber of words deallocated
[in]newSizeNumber of words allocated
[in]nBytesNumber of bytes per word

◆ logallocmemi8()

subroutine allocationmodule::logallocmemi8 ( character(len=*), intent(in)  label,
integer(i8), intent(in)  oldSize,
integer(i8), intent(in)  newSize,
integer, intent(in)  nBytes 
)

Prints the current accumulated memory usage to the log file.

Parameters
[in]labelName of calling subroutine
[in]oldSizeNumber of words deallocated
[in]newSizeNumber of words allocated
[in]nBytesNumber of bytes per word

◆ reallocatebigdouble1d()

subroutine allocationmodule::reallocatebigdouble1d ( character(len=*), intent(in)  label,
real(dp), dimension(:), pointer  array,
integer(i8), intent(in)  nw,
integer, intent(inout)  ierr 
)

Allocate, reallocate or deallocate a big one-dimensional real array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe double precision real array to (re)allocate
[in]nwNumber of words in array after reallocation
[out]ierrError flag

This subroutine is used for arrays that may contain more than 2^31 words, which is the largest number that can be represented by normal 4-byte integer variables.

Author
Knut Morten Okstad
Date
12 May 2017

◆ reallocatedouble1d()

subroutine allocationmodule::reallocatedouble1d ( character(len=*), intent(in)  label,
real(dp), dimension(:), pointer  array,
integer, intent(in), optional  nw,
integer, intent(inout), optional  ierr,
logical, intent(in), optional  preserveContent 
)

Allocate, reallocate or deallocate a one-dimensional real array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe double precision real array to (re)allocate
[in]nwNumber of words in array after reallocation
[out]ierrError flag
[in]preserveContentIf .true., the existing contents is preserved when the array is reallocated

◆ reallocatedouble2d()

subroutine allocationmodule::reallocatedouble2d ( character(len=*), intent(in)  label,
real(dp), dimension(:,:), pointer  array,
integer, intent(in), optional  n1,
integer, intent(in), optional  n2,
integer, intent(inout), optional  ierr 
)

Allocate, reallocate or deallocate a two-dimensional real array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe double precision real array to (re)allocate
[in]n1Number of rows in array after reallocation
[in]n2Number of columns in array after reallocation
[out]ierrError flag

◆ reallocatefloat1d()

subroutine allocationmodule::reallocatefloat1d ( character(len=*), intent(in)  label,
real(sp), dimension(:), pointer  array,
integer, intent(in), optional  nw,
integer, intent(inout), optional  ierr 
)

Allocate, reallocate or deallocate a one-dimensional real array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe single precision real array to (re)allocate
[in]nwNumber of words in array after reallocation
[out]ierrError flag
Author
Knut Morten Okstad
Date
30 Dec 2004

◆ reallocatefloat2d()

subroutine allocationmodule::reallocatefloat2d ( character(len=*), intent(in)  label,
real(sp), dimension(:,:), pointer  array,
integer, intent(in), optional  n1,
integer, intent(in), optional  n2,
integer, intent(inout), optional  ierr 
)

Allocate, reallocate or deallocate a two-dimensional real array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe single precision real array to (re)allocate
[in]n1Number of rows in array after reallocation
[in]n2Number of columns in array after reallocation
[out]ierrError flag

◆ reallocateint()

subroutine allocationmodule::reallocateint ( character(len=*), intent(in)  label,
integer, dimension(:), pointer  array,
integer, intent(in), optional  nw,
integer, intent(inout), optional  ierr,
logical, intent(in), optional  preserveContent 
)
private

Allocate, reallocate or deallocate a one-dimensional integer array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe integer array to (re)allocate
[in]nwNumber of words in array after reallocation
[out]ierrError flag
[in]preserveContentIf .true., the existing contents is preserved when the array is reallocated

◆ reallocateint8()

subroutine allocationmodule::reallocateint8 ( character(len=*), intent(in)  label,
integer(i8), dimension(:), pointer  array,
integer, intent(in), optional  nw,
integer, intent(inout), optional  ierr,
logical, intent(in), optional  preserveContent 
)

Allocate, reallocate or deallocate a one-dimensional integer array.

Parameters
[in]labelName of calling subroutine (for memory logging)
arrayThe integer*8 array to (re)allocate
[in]nwNumber of words in array after reallocation
[out]ierrError flag
[in]preserveContentIf .true., the existing contents is preserved when the array is reallocated

◆ strbytes()

character(len=12) function, public allocationmodule::strbytes ( integer(i8), intent(in)  nBytes)

Converts a number of bytes to a user-friendly string.

Parameters
[in]nBytesNumber of bytes
Returns
A string with the number of bytes with a user-friendly byte unit.
Author
Knut Morten Okstad
Date
6 Sep 2006

◆ writepeakmem()

subroutine, public allocationmodule::writepeakmem ( integer, intent(in)  lpu)

Writes the peak memory usage to file unit lpu.

◆ writestorage()

subroutine, public allocationmodule::writestorage ( character(len=*), intent(in)  name,
integer(i8), intent(in)  nwI,
integer(i8), intent(in)  nwR,
integer, intent(in)  lpu 
)

Writes storage requirement information for an item to unit lpu.

Parameters
[in]nameName of the item to write storage info for
[in]nwINumber of integer words
[in]nwRNumber of real words
[in]lpuFile unit number to write to
Author
Knut Morten Okstad
Date
7 Mar 2003

Variable Documentation

◆ dologmem

logical, save, public allocationmodule::dologmem = .false.

Toggle for print of memory usage.

◆ logfile

integer, save allocationmodule::logfile = 0
private

File unit number for memory logging.

◆ peakmem

integer(i8), save allocationmodule::peakmem = 0_i8
private

Maximum number of bytes allocated.

◆ totmem

integer(i8), save allocationmodule::totmem = 0_i8
private

Total number of bytes allocatedy.