Validate the arguments of a field resize.
Rejects negative lengths and any request to preserve or fill more elements than the new array will hold.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | new_capacity |
Requested allocated length. |
||
| integer(kind=default_int), | intent(in) | :: | keep |
Number of leading elements to preserve. |
||
| integer(kind=default_int), | intent(in) | :: | fill_to |
Highest index to zero-fill above |
||
| type(error_t), | intent(inout) | :: | err |
Error state, |
subroutine soa_check_resize_args(new_capacity, keep, fill_to, err) !! Validate the arguments of a field resize. !! !! Rejects negative lengths and any request to preserve or fill more !! elements than the new array will hold. integer(default_int), intent(in) :: new_capacity !! Requested allocated length. integer(default_int), intent(in) :: keep !! Number of leading elements to preserve. integer(default_int), intent(in) :: fill_to !! Highest index to zero-fill above `keep`. type(error_t), intent(inout) :: err !! Error state, `ERROR_VALIDATION` on an inconsistent request. if (new_capacity < 0 .or. keep < 0 .or. fill_to < 0) then call err%set(ERROR_VALIDATION, "soa: negative length in resize request") return end if if (keep > new_capacity .or. fill_to > new_capacity) then call err%set(ERROR_VALIDATION, "soa: resize would keep or fill past the new capacity "// & to_char(int(new_capacity, int64))) end if end subroutine soa_check_resize_args