Resizes entries array to add a new entry.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(parser_obj), | intent(inout) | :: | this |
Parser object |
||
| type(entry_obj), | intent(in) | :: | entry |
New entrysize |
pure subroutine parser_obj_AddEntry(this,entry) !> Resizes entries array to add a new entry. implicit none class(parser_obj), intent(inout) :: this !! Parser object type(entry_obj), intent(in) :: entry !! New entrysize ! Work variables type(entry_obj), & allocatable :: my_entries(:) integer :: size_old ! Resize array and add a new entry if (.not.allocated(this%entries)) then allocate(this%entries(1)) this%entries(1)=entry else ! Get old size size_old = size(this%entries) ! Allocate temporary array allocate(my_entries(size_old+1)) ! Copy values to temporary variable my_entries(1:size_old)=this%entries(1:size_old) ! Add new entry my_entries(size_old+1)=entry ! Move the allocation from the ! temporary array to the final one call move_alloc(my_entries,this%entries) end if return end subroutine parser_obj_AddEntry