calc_type_from_string Function

public pure function calc_type_from_string(calc_type_str) result(calc_type)

Convert calculation type string to integer constant

Performs case-insensitive comparison and returns appropriate constant. Returns CALC_TYPE_UNKNOWN for unrecognized strings.

Arguments

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

Input string (e.g., “energy”, “gradient”)

Return Value integer(kind=int32)

Output integer constant


Called by

proc~~calc_type_from_string~~CalledByGraph proc~calc_type_from_string calc_type_from_string proc~parse_driver_section parse_driver_section proc~parse_driver_section->proc~calc_type_from_string interface~parse_driver_section parse_driver_section interface~parse_driver_section->proc~parse_driver_section proc~read_mqc_file read_mqc_file proc~read_mqc_file->interface~parse_driver_section program~main main program~main->proc~read_mqc_file

Variables

Type Visibility Attributes Name Initial
integer, private :: i
character(len=len_trim), private :: lower_str

Source Code

   pure function calc_type_from_string(calc_type_str) result(calc_type)
      !! Convert calculation type string to integer constant
      !!
      !! Performs case-insensitive comparison and returns appropriate constant.
      !! Returns CALC_TYPE_UNKNOWN for unrecognized strings.
      character(len=*), intent(in) :: calc_type_str  !! Input string (e.g., "energy", "gradient")
      integer(int32) :: calc_type                     !! Output integer constant

      character(len=len_trim(calc_type_str)) :: lower_str
      integer :: i

      ! Convert to lowercase for case-insensitive comparison
      lower_str = trim(adjustl(calc_type_str))
      do i = 1, len(lower_str)
         if (lower_str(i:i) >= 'A' .and. lower_str(i:i) <= 'Z') then
            lower_str(i:i) = achar(iachar(lower_str(i:i)) + 32)
         end if
      end do

      ! Match against known types
      select case (lower_str)
      case ('energy')
         calc_type = CALC_TYPE_ENERGY
      case ('gradient')
         calc_type = CALC_TYPE_GRADIENT
      case ('hessian')
         calc_type = CALC_TYPE_HESSIAN
      case default
         calc_type = CALC_TYPE_UNKNOWN
      end select

   end function calc_type_from_string