Convert method type string to integer constant
Performs case-insensitive comparison and returns appropriate constant. Returns METHOD_TYPE_UNKNOWN for unrecognized strings.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | method_str |
Input string (e.g., “gfn1”, “gfn2”, “hf”) |
Output integer constant
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| character(len=len_trim), | private | :: | lower_str |
pure function method_type_from_string(method_str) result(method_type) !! Convert method type string to integer constant !! !! Performs case-insensitive comparison and returns appropriate constant. !! Returns METHOD_TYPE_UNKNOWN for unrecognized strings. character(len=*), intent(in) :: method_str !! Input string (e.g., "gfn1", "gfn2", "hf") integer(int32) :: method_type !! Output integer constant character(len=len_trim(method_str)) :: lower_str integer :: i ! Convert to lowercase for case-insensitive comparison lower_str = trim(adjustl(method_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) ! Semi-empirical case ('gfn1', 'gfn1-xtb') method_type = METHOD_TYPE_GFN1 case ('gfn2', 'gfn2-xtb') method_type = METHOD_TYPE_GFN2 ! SCF methods case ('hf', 'rhf', 'uhf', 'hartree-fock') method_type = METHOD_TYPE_HF case ('dft', 'ks', 'kohn-sham') method_type = METHOD_TYPE_DFT ! Multi-reference case ('mcscf', 'casscf', 'casci') method_type = METHOD_TYPE_MCSCF ! Perturbation theory case ('mp2', 'ri-mp2', 'df-mp2', 'scs-mp2', 'sos-mp2') method_type = METHOD_TYPE_MP2 case ('mp2-f12', 'ri-mp2-f12', 'df-mp2-f12') method_type = METHOD_TYPE_MP2_F12 ! Coupled cluster case ('ccsd', 'ri-ccsd', 'df-ccsd') method_type = METHOD_TYPE_CCSD case ('ccsd(t)', 'ri-ccsd(t)', 'df-ccsd(t)') method_type = METHOD_TYPE_CCSD_T case ('ccsd-f12', 'ri-ccsd-f12') method_type = METHOD_TYPE_CCSD_F12 case ('ccsd(t)-f12', 'ri-ccsd(t)-f12') method_type = METHOD_TYPE_CCSD_T_F12 case default method_type = METHOD_TYPE_UNKNOWN end select end function method_type_from_string