set_query Function

public function set_query(lstring, lset)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: lstring
character(len=*), intent(in) :: lset

Return Value integer


Called by

proc~~set_query~~CalledByGraph proc~set_query set_query proc~calc_grid_rank calc_grid_rank proc~calc_grid_rank->proc~set_query proc~dist_rank dist_rank proc~dist_rank->proc~set_query proc~interpret_descriptor_string interpret_descriptor_string proc~interpret_descriptor_string->proc~set_query proc~memory_topology memory_topology proc~memory_topology->proc~set_query proc~parse_descriptor_string parse_descriptor_string proc~parse_descriptor_string->proc~interpret_descriptor_string proc~parse_descriptor_string->proc~memory_topology proc~read_testharness_specifier Read_TestHarness_Specifier proc~read_testharness_specifier->proc~parse_descriptor_string program~esmf_test_harness esmf_test_harness program~esmf_test_harness->proc~read_testharness_specifier

Source Code

    integer function set_query(lstring,lset)
    !---------------------------------------------------------------------------
    ! Scans a string for any character from a SET of characters. Returns zero
    ! if none of the elements of the set occur in the string or if the set or
    ! string is empty.
    !---------------------------------------------------------------------------

    ! arguments
    character(len=*), intent(in) :: lstring
    character(len=*), intent(in) :: lset

    ! local variables
    integer :: k, klast, ncount
    integer :: len_string, len_set

    ! initialize variables
    ncount = 0
    klast = 0
    len_string = len(lstring)
    len_set = len( trim(adjustL(lset) ))
    
    !---------------------------------------------------------------------------
    ! error check - conduct the scan only if the set and string are not empty
    !---------------------------------------------------------------------------
    if( (len_set > 0) .and. (len_string > 0) ) then
       !------------------------------------------------------------------------
       ! examine the string to find the find the FIRST instance of an 
       ! element in the set.
       !------------------------------------------------------------------------
       k = scan(lstring(klast+1:len_string), trim(adjustL(lset) ))
       do while( k > 0 )
          !---------------------------------------------------------------------
          ! if scan is nonzero, there is at least one match, increment
          ! through the string checking for additional matches. 
          !---------------------------------------------------------------------
          ncount = ncount + 1    ! count match
          klast = k + klast      ! slide forward in string looking for next match
          k = scan(lstring(klast+1:len_string), trim(adjustL(lset) ))
       enddo     ! while
    endif 
    
    set_query = ncount
    
    !---------------------------------------------------------------------------
    end function set_query