@brief Re-sizeable array type that can be filled elementwise to build up a contiguous data chunk that can then be dumped to an allocatable
@details For multidimensional buffers only the last dimension can grow. (i.e. it is only possible to add columns.)
The buffer has to be initiliazed before first use.
After dumping (dump_reset) it is automatically resetted.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int64), | public, | dimension(:, :), allocatable | :: | buf | |||
| integer(kind=int64), | private | :: | pos | ||||
| real(kind=dp), | private | :: | grow_factor | = | 1.5_dp | ||
| integer(kind=int64), | private | :: | start_size | = | 100_int64 |
@brief Set up the re-sizeable array (buffer) with a given start size and grow_factor.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(inout) | :: | this | |||
| integer, | intent(in) | :: | rows |
Number of rows in the first dimension. |
||
| real, | intent(in), | optional | :: | grow_factor |
Factor about which to grow the buffer along the last dimension, |
|
| integer, | intent(in), | optional | :: | start_size |
Initial size of the buffer along the last dimension. |
@brief Deallocate the resource.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(inout) | :: | this |
@brief Reset an already initiliazed buffer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(inout) | :: | this |
@brief Returns the number of already stored elements in the buffer along the last dimension.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(in) | :: | this |
@brief Returns the capacity of the buffer along the last dimension.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(in) | :: | this |
@brief Append a value to the buffer, expanding the capacity if necessary.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(inout) | :: | this | |||
| integer(kind=int64), | intent(in), | dimension(:) | :: | val |
Value to be added |
@brief Dump the buffer to an allocatable array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(inout) | :: | this | |||
| integer(kind=int64), | intent(out), | dimension(:, :), allocatable | :: | tgt |
Allocatable array (reset upon entry), contains the stored elements of |
Dump the buffer to an allocatable array and reset the buffer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(buffer_int64_2D_t), | intent(inout) | :: | this | |||
| integer(kind=int64), | intent(out), | dimension(:, :), allocatable | :: | tgt |
Allocatable array (reset upon entry), contains the stored elements of |
type :: buffer_int64_2D_t private integer(int64), dimension(:, :), allocatable, public :: buf ! Internal position of the buffer integer(int64) :: pos real(dp) :: grow_factor = 1.5_dp integer(int64) :: start_size = 100_int64 contains procedure :: init => init_int64_2D procedure :: finalize => finalize_int64_2D procedure, private :: reset => reset_int64_2D procedure :: size => get_size_int64_2D procedure :: capacity => get_capacity_int64_2D procedure :: push_back => add_val_int64_2D procedure, private :: dump => dump_int64_2D procedure :: dump_reset => dump_reset_int64_2D end type buffer_int64_2D_t