Give the container n live elements, discarding any it already had.
Equivalent to clear followed by resize(n), so calling it twice is
well defined: the second call simply replaces the contents. Every
element is set to the zero value of its field’s type. Capacity is
never lowered, so a smaller second call reuses the existing memory.
On failure the container is left empty rather than half filled.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(particle_soa_t), | intent(inout) | :: | this |
Container to (re)allocate. |
||
| integer(kind=default_int), | intent(in) | :: | n |
Number of live elements. Must not be negative. |
||
| type(error_t), | intent(inout) | :: | err |
Error state, |
subroutine particle_soa_allocate(this, n, err) !! Give the container `n` live elements, discarding any it already had. !! !! Equivalent to `clear` followed by `resize(n)`, so calling it twice is !! well defined: the second call simply replaces the contents. Every !! element is set to the zero value of its field's type. Capacity is !! never lowered, so a smaller second call reuses the existing memory. !! !! On failure the container is left empty rather than half filled. class(particle_soa_t), intent(inout) :: this !! Container to (re)allocate. integer(default_int), intent(in) :: n !! Number of live elements. Must not be negative. type(error_t), intent(inout) :: err !! Error state, `ERROR_VALIDATION` on a negative `n` and !! `ERROR_ALLOC` if the field arrays cannot be allocated. this%extent%used = 0 call this%resize(n, err) end subroutine particle_soa_allocate