Routine to ensure that enough storage is allocated for the configuration type. If not the new size will be twice as much as the current size. If no storage is allocated yet a minumum amount of starage is allocated.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(CFG_t), | intent(inout) | :: | cfg |
subroutine ensure_free_storage(cfg) type(CFG_t), intent(inout) :: cfg type(CFG_var_t), allocatable :: cfg_copy(:) integer, parameter :: min_dyn_size = 100 integer :: cur_size, new_size if (allocated(cfg%vars)) then cur_size = size(cfg%vars) if (cur_size < cfg%num_vars + 1) then new_size = 2 * cur_size allocate(cfg_copy(cur_size)) cfg_copy = cfg%vars deallocate(cfg%vars) allocate(cfg%vars(new_size)) cfg%vars(1:cur_size) = cfg_copy end if else allocate(cfg%vars(min_dyn_size)) end if end subroutine ensure_free_storage