stringtool_obj_ContainsTime Function

private pure function stringtool_obj_ContainsTime(str) result(val)

Looks for a time token in the ES12.4 format in the input string

Type Bound

stringtool_obj

Arguments

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

Input string

Return Value logical

Logical switch; true if string has time


Called by

proc~~stringtool_obj_containstime~~CalledByGraph proc~stringtool_obj_containstime stringtool_obj%stringtool_obj_ContainsTime proc~marker_set_writehdf5 marker_set%marker_set_WriteHDF5 proc~marker_set_writehdf5->proc~stringtool_obj_containstime proc~particle_set_writehdf5 particle_set%particle_set_WriteHDF5 proc~particle_set_writehdf5->proc~stringtool_obj_containstime proc~respart_set_writehdf5 ResPart_set%ResPart_set_WriteHDF5 proc~respart_set_writehdf5->proc~marker_set_writehdf5 proc~solid_set_writehdf5 solid_set%solid_set_WriteHDF5 proc~solid_set_writehdf5->proc~marker_set_writehdf5

Source Code

    pure function stringtool_obj_ContainsTime(str) result(val)
      !> Looks for a time token in the ES12.4 format in the input string
      character(len=*), intent(in)  :: str                                     !! Input string
      logical                       :: val                                     !! Logical switch; true if string has time
      ! Work variables
      integer :: i, n
        
      val = .false.
      n = len(str)

      ! An ES12.4 string is 12 characters long.
      ! Example: 1.0000E+01
      ! We look for the 'E' and check if the surrounding 12 chars fit the mold.
      do i = 1, n - 11
        ! Check for decimal at index i+1 and 'E' at index i+6
        if (str(i+1:i+1) == '.' .and. (str(i+6:i+6) == 'E' .or. str(i+6:i+6) == 'e')) then
          ! Basic check for the sign after E
          if (str(i+7:i+7) == '+' .or. str(i+7:i+7) == '-') then
            val = .true.
            return
          end if
        end if
      end do

      return
    end function stringtool_obj_ContainsTime