Reallocate a list of dependencies
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(dependency_config_t), | intent(inout), | allocatable | :: | var(:) |
Instance of the array to be resized |
|
| integer, | intent(in), | optional | :: | n |
Dimension of the final array size |
subroutine resize_dependency_config(var, n) !> Instance of the array to be resized class(dependency_config_t), allocatable, intent(inout) :: var(:) !> Dimension of the final array size integer, intent(in), optional :: n class(dependency_config_t), allocatable :: tmp(:) integer :: this_size, new_size integer, parameter :: initial_size = 16 if (allocated(var)) then this_size = size(var, 1) call move_alloc(var, tmp) else this_size = initial_size end if if (present(n)) then new_size = n else new_size = this_size + this_size/2 + 1 end if allocate (var(new_size)) if (allocated(tmp)) then this_size = min(size(tmp, 1), size(var, 1)) select type (var) type is (dependency_config_t) var(:this_size) = tmp(:this_size) end select deallocate (tmp) end if end subroutine resize_dependency_config