posofval_label Function

public function posofval_label(me, val, nextifnotfound, lower, upper) result(pos)

the actual position of a given value in the dynamic array

most likely this is what you need in codes, using this data structure, it first does the binary search on the sorted values with sortposofval_label and then returns the looked up position in the original unsorted array, which corresponds to the position returned by the append routine.

Arguments

Type IntentOptional Attributes Name
type(dyn_labelarray_type), intent(in) :: me
character(len=*), intent(in) :: val
logical, intent(in), optional :: nextifnotfound

flag to indicate, if the position of the next entry in the sorted list should be returned instead, if val is not found.

integer, intent(in), optional :: lower
integer, intent(in), optional :: upper

Return Value integer


Calls

proc~~posofval_label~~CallsGraph proc~posofval_label posofval_label interface~sortedposofval~5 sortedposofval proc~posofval_label->interface~sortedposofval~5 proc~sortposofval_label sortposofval_label interface~sortedposofval~5->proc~sortposofval_label

Called by

proc~~posofval_label~~CalledByGraph proc~posofval_label posofval_label interface~positionofval~5 positionofval interface~positionofval~5->proc~posofval_label proc~tem_varsys_append_dervar~2 tem_varSys_append_derVar proc~tem_varsys_append_dervar~2->interface~positionofval~5 proc~tem_comm_createbuffer tem_comm_createBuffer proc~tem_comm_createbuffer->interface~positionofval~5 proc~identify_additionalneigh identify_additionalNeigh proc~identify_additionalneigh->interface~positionofval~5 proc~tem_varsys_append_dervar tem_varSys_append_derVar proc~tem_varsys_append_dervar->interface~positionofval~5 proc~identify_local_element identify_local_element proc~identify_local_element->interface~positionofval~5 proc~tem_build_facesendbuffers tem_build_faceSendBuffers proc~tem_build_facesendbuffers->interface~positionofval~5 proc~check_opvar_prerequisites check_opVar_prerequisites proc~check_opvar_prerequisites->interface~positionofval~5 proc~tem_etypeofid tem_eTypeOfId proc~tem_etypeofid->interface~positionofval~5 proc~add_ghostfromfiner add_ghostFromFiner proc~add_ghostfromfiner->interface~positionofval~5 proc~tem_build_treehorizontaldep tem_build_treeHorizontalDep proc~tem_build_treehorizontaldep->interface~positionofval~5 proc~tem_timer_dumplabeled tem_timer_dumplabeled proc~tem_timer_dumplabeled->interface~positionofval~5 proc~tem_adddep_up tem_addDep_up proc~tem_adddep_up->interface~positionofval~5 proc~setup_indices_spacetime setup_indices_spacetime proc~setup_indices_spacetime->interface~positionofval~5 proc~identify_halo identify_halo proc~identify_halo->interface~positionofval~5 proc~tem_debug_horizontaldependencies tem_debug_HorizontalDependencies proc~tem_debug_horizontaldependencies->interface~positionofval~5 proc~tem_varsys_append_luavar tem_varSys_append_luaVar proc~tem_varsys_append_luavar->interface~positionofval~5 proc~tem_adapt_dump_newmesh tem_adapt_dump_newMesh proc~tem_adapt_dump_newmesh->interface~positionofval~5 proc~tem_adddep_down tem_addDep_down proc~tem_adddep_down->interface~positionofval~5 proc~request_remotehalos request_remoteHalos proc~request_remotehalos->interface~positionofval~5 proc~tem_build_facerecvbuffers tem_build_faceRecvBuffers proc~tem_build_facerecvbuffers->interface~positionofval~5 proc~tem_create_varmap tem_create_varMap proc~tem_create_varmap->interface~positionofval~5 proc~add_all_virtual_children add_all_virtual_children proc~add_all_virtual_children->interface~positionofval~5 proc~tem_appendface_prp tem_appendFace_prp proc~tem_appendface_prp->interface~positionofval~5

Contents

Source Code


Source Code

  function posofval_label(me, val, nextifnotfound, lower, upper) result(pos)
    !------------------------------------------------------------------------
    type(dyn_labelarray_type), intent(in) :: me !< dynamic array
    character(len=*), intent(in) :: val !< value to search for
    !> flag to indicate, if the position of the next entry in the sorted
    !! list should be returned instead, if val is not found.
    logical, intent(in), optional :: nextifnotfound
    integer, intent(in), optional :: lower !< lower search limit
    integer, intent(in), optional :: upper !< upper search limit
    integer :: pos !< position in the array of the searche value, 0 if not found
    !------------------------------------------------------------------------
    integer :: sortpos
    integer :: lb, ub
    !------------------------------------------------------------------------

    lb = 1
    ub = me%nvals

    if( present( lower ) ) lb = lower
    if( present( upper ) ) ub = upper

    sortpos = sortedposofval(me, val, nextifnotfound, lb, ub)

    ! if result (sorted pos)
    if ((sortpos <= me%nvals) .and. (sortpos > 0)) then
      pos = me%sorted(sortpos)
    else
      pos = sortpos
    end if
  end function posofval_label