truncate the array after the last valid entry and hence cut off the empty trailing empty entries
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dyn_longarray_type) | :: | me |
subroutine truncate_da_long(me)
!------------------------------------------------------------------------
type(dyn_longarray_type) :: me !< array to sorttruncate
!------------------------------------------------------------------------
integer(kind=long_k), allocatable :: swpval(:)
integer, allocatable :: swpsort(:)
!------------------------------------------------------------------------
if (me%nvals < me%containersize) then
allocate(swpval(me%nvals))
allocate(swpsort(me%nvals))
swpval = me%val(:me%nvals)
swpsort = me%sorted(:me%nvals)
call move_alloc(swpval, me%val)
call move_alloc(swpsort, me%sorted)
me%containersize = me%nvals
end if
end subroutine truncate_da_long