is_decimal_real_token Function

public pure function is_decimal_real_token(token) result(valid)

List-directed control syntaxを除外した十進実数tokenだけを許可する。

Arguments

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

Return Value logical


Called by

proc~~is_decimal_real_token~~CalledByGraph proc~is_decimal_real_token is_decimal_real_token proc~read_matching_plane_query_csv read_matching_plane_query_csv proc~read_matching_plane_query_csv->proc~is_decimal_real_token proc~generate_matching_plane_zhao_atlas generate_matching_plane_zhao_atlas proc~generate_matching_plane_zhao_atlas->proc~read_matching_plane_query_csv proc~generate_matching_plane_zhao_response_table generate_matching_plane_zhao_response_table proc~generate_matching_plane_zhao_response_table->proc~read_matching_plane_query_csv program~zhao_atlas_main zhao_atlas_main program~zhao_atlas_main->proc~generate_matching_plane_zhao_atlas program~zhao_response_main zhao_response_main program~zhao_response_main->proc~generate_matching_plane_zhao_response_table

Source Code

  pure logical function is_decimal_real_token(token) result(valid)
    character(len=*), intent(in) :: token
    integer :: position, token_length
    logical :: has_mantissa_digit, has_exponent_digit

    valid = .false.
    token_length = len_trim(token)
    if (token_length <= 0) return
    position = 1
    if (token(position:position) == '+' .or. token(position:position) == '-') position = position + 1
    if (position > token_length) return

    has_mantissa_digit = .false.
    do while (position <= token_length)
      if (.not. is_decimal_digit(token(position:position))) exit
      has_mantissa_digit = .true.
      position = position + 1
    end do
    if (position <= token_length) then
      if (token(position:position) == '.') then
        position = position + 1
        do while (position <= token_length)
          if (.not. is_decimal_digit(token(position:position))) exit
          has_mantissa_digit = .true.
          position = position + 1
        end do
      end if
    end if
    if (.not. has_mantissa_digit) return

    if (position <= token_length) then
      if (index('eEdD', token(position:position)) > 0) then
        position = position + 1
        if (position <= token_length) then
          if (token(position:position) == '+' .or. token(position:position) == '-') position = position + 1
        end if
        has_exponent_digit = .false.
        do while (position <= token_length)
          if (.not. is_decimal_digit(token(position:position))) exit
          has_exponent_digit = .true.
          position = position + 1
        end do
        if (.not. has_exponent_digit) return
      end if
    end if
    valid = position > token_length
  end function is_decimal_real_token