[[mesh.templates]] の読み込み数に応じてテンプレート配列容量を拡張する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(inout) | :: | cfg |
容量拡張対象のアプリ設定。 |
||
| integer, | intent(in) | :: | required_size |
必要最小要素数。 |
subroutine ensure_template_capacity(cfg, required_size) type(app_config), intent(inout) :: cfg integer, intent(in) :: required_size type(template_spec), allocatable :: grown(:) integer :: old_capacity, new_capacity if (required_size <= 0) return if (allocated(cfg%templates)) then old_capacity = size(cfg%templates) else old_capacity = 0 end if if (old_capacity >= required_size) return new_capacity = max(required_size, max(max_templates, max(1, 2*old_capacity))) allocate (grown(new_capacity)) if (old_capacity > 0) grown(1:old_capacity) = cfg%templates(1:old_capacity) call move_alloc(grown, cfg%templates) end subroutine ensure_template_capacity