sorttruncate_da_label Subroutine

public subroutine sorttruncate_da_label(me)

fixing the dynamic array

truncate the array after the last valid entry and hence cut off the empty trailing empty entries store the array in the sorted order according to the sorted( ) array

Arguments

Type IntentOptional Attributes Name
type(dyn_labelarray_type) :: me

Source Code

  subroutine sorttruncate_da_label(me)
    !------------------------------------------------------------------------
    type(dyn_labelarray_type) :: me !< array to sorttruncate
    !------------------------------------------------------------------------
    type(dyn_labelarray_type) :: tarray !< temporary array
    integer :: ival
    integer :: dpos
    !------------------------------------------------------------------------
    ! allocate the temporary array
    call init( me = tarray, length = me%nvals )
    ! copy the entries in a sorted fashion into the temporary array
    do ival = 1, me%nvals
      call append( me = tarray, val = me%val( me%sorted( ival )), &
           &       pos = dpos)
    enddo
    call destroy( me = me )

    me = tarray
    call destroy( me = tarray )

  end subroutine sorttruncate_da_label