mqc_calc_types.f90 Source File

Calculation type constants for quantum chemistry calculations


Files dependent on this one

sourcefile~~mqc_calc_types.f90~~AfferentGraph sourcefile~mqc_calc_types.f90 mqc_calc_types.f90 sourcefile~mqc_calculation_interface.f90 mqc_calculation_interface.f90 sourcefile~mqc_calculation_interface.f90->sourcefile~mqc_calc_types.f90 sourcefile~mqc_config_parser.f90 mqc_config_parser.F90 sourcefile~mqc_calculation_interface.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_driver.f90 mqc_driver.f90 sourcefile~mqc_calculation_interface.f90->sourcefile~mqc_driver.f90 sourcefile~mqc_config_adapter.f90 mqc_config_adapter.f90 sourcefile~mqc_calculation_interface.f90->sourcefile~mqc_config_adapter.f90 sourcefile~mqc_config_parser.f90->sourcefile~mqc_calc_types.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_calc_types.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90 mqc_mbe_fragment_distribution_scheme.F90 sourcefile~mqc_driver.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_config_adapter.f90 sourcefile~mqc_many_body_expansion.f90 mqc_many_body_expansion.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_many_body_expansion.f90 sourcefile~mqc_mbe.f90 mqc_mbe.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_mbe.f90 sourcefile~mqc_frag_utils.f90 mqc_frag_utils.f90 sourcefile~mqc_driver.f90->sourcefile~mqc_frag_utils.f90 sourcefile~mqc_gmbe_fragment_distribution_scheme.f90 mqc_gmbe_fragment_distribution_scheme.f90 sourcefile~mqc_gmbe_fragment_distribution_scheme.f90->sourcefile~mqc_calc_types.f90 sourcefile~mqc_gmbe_fragment_distribution_scheme.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90->sourcefile~mqc_calc_types.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90->sourcefile~mqc_config_adapter.f90 sourcefile~mqc_mbe_fragment_distribution_scheme.f90->sourcefile~mqc_mbe.f90 sourcefile~main.f90 main.f90 sourcefile~main.f90->sourcefile~mqc_config_parser.f90 sourcefile~main.f90->sourcefile~mqc_driver.f90 sourcefile~main.f90->sourcefile~mqc_config_adapter.f90 sourcefile~mqc_config_adapter.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_config_parser_basic_sections.f90 mqc_config_parser_basic_sections.f90 sourcefile~mqc_config_parser_basic_sections.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_config_parser_calc_settings.f90 mqc_config_parser_calc_settings.f90 sourcefile~mqc_config_parser_calc_settings.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_config_parser_fragments.f90 mqc_config_parser_fragments.f90 sourcefile~mqc_config_parser_fragments.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_config_parser_molecules.f90 mqc_config_parser_molecules.f90 sourcefile~mqc_config_parser_molecules.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_config_parser_structure.f90 mqc_config_parser_structure.f90 sourcefile~mqc_config_parser_structure.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_many_body_expansion.f90->sourcefile~mqc_gmbe_fragment_distribution_scheme.f90 sourcefile~mqc_many_body_expansion.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_many_body_expansion.f90->sourcefile~mqc_config_adapter.f90 sourcefile~mqc_mbe.f90->sourcefile~mqc_config_parser.f90 sourcefile~mqc_mbe.f90->sourcefile~mqc_frag_utils.f90 sourcefile~mqc_mbe_fragment_distribution_scheme_hessian.f90 mqc_mbe_fragment_distribution_scheme_hessian.F90 sourcefile~mqc_mbe_fragment_distribution_scheme_hessian.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_mbe_mpi_fragment_distribution_scheme.f90 mqc_mbe_mpi_fragment_distribution_scheme.F90 sourcefile~mqc_mbe_mpi_fragment_distribution_scheme.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_serial_fragment_processor.f90 mqc_serial_fragment_processor.f90 sourcefile~mqc_serial_fragment_processor.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_unfragmented_workflow.f90 mqc_unfragmented_workflow.f90 sourcefile~mqc_unfragmented_workflow.f90->sourcefile~mqc_mbe_fragment_distribution_scheme.f90 sourcefile~mqc_frag_utils.f90->sourcefile~mqc_config_adapter.f90

Source Code

!! Calculation type constants for quantum chemistry calculations
module mqc_calc_types
   !! Defines integer constants for calculation types to avoid string comparisons
   !! throughout the codebase. Provides conversion utilities between string
   !! representations and integer constants.
   use pic_types, only: int32
   implicit none
   private

   ! Public constants
   public :: CALC_TYPE_ENERGY, CALC_TYPE_GRADIENT, CALC_TYPE_HESSIAN
   public :: CALC_TYPE_UNKNOWN

   ! Public functions
   public :: calc_type_from_string, calc_type_to_string

   ! Calculation type constants
   integer(int32), parameter :: CALC_TYPE_UNKNOWN = 0
   integer(int32), parameter :: CALC_TYPE_ENERGY = 1
   integer(int32), parameter :: CALC_TYPE_GRADIENT = 2
   integer(int32), parameter :: CALC_TYPE_HESSIAN = 3

contains

   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

   pure function calc_type_to_string(calc_type) result(calc_type_str)
      !! Convert calculation type integer constant to string
      !!
      !! Provides human-readable string representation of calculation type.
      integer(int32), intent(in) :: calc_type         !! Input integer constant
      character(len=:), allocatable :: calc_type_str  !! Output string representation

      select case (calc_type)
      case (CALC_TYPE_ENERGY)
         calc_type_str = "energy"
      case (CALC_TYPE_GRADIENT)
         calc_type_str = "gradient"
      case (CALC_TYPE_HESSIAN)
         calc_type_str = "hessian"
      case default
         calc_type_str = "unknown"
      end select

   end function calc_type_to_string

end module mqc_calc_types