config_to_driver Subroutine

public subroutine config_to_driver(mqc_config, driver_config, molecule_index)

Convert mqc_config_t to minimal driver_config_t Extracts only the fields needed by the driver If molecule_index is provided, uses that molecule’s fragment count

Arguments

Type IntentOptional Attributes Name
type(mqc_config_t), intent(in) :: mqc_config
type(driver_config_t), intent(out) :: driver_config
integer, intent(in), optional :: molecule_index

Which molecule to use (for multi-molecule mode)


Calls

proc~~config_to_driver~~CallsGraph proc~config_to_driver config_to_driver proc~xtb_configure xtb_config_t%xtb_configure proc~config_to_driver->proc~xtb_configure

Called by

proc~~config_to_driver~~CalledByGraph proc~config_to_driver config_to_driver proc~run_multi_molecule_calculations run_multi_molecule_calculations proc~run_multi_molecule_calculations->proc~config_to_driver program~main main program~main->proc~config_to_driver program~main->proc~run_multi_molecule_calculations

Variables

Type Visibility Attributes Name Initial
integer, private :: nfrag_to_use

Source Code

   subroutine config_to_driver(mqc_config, driver_config, molecule_index)
      !! Convert mqc_config_t to minimal driver_config_t
      !! Extracts only the fields needed by the driver
      !! If molecule_index is provided, uses that molecule's fragment count
      type(mqc_config_t), intent(in) :: mqc_config
      type(driver_config_t), intent(out) :: driver_config
      integer, intent(in), optional :: molecule_index  !! Which molecule to use (for multi-molecule mode)

      integer :: nfrag_to_use

      ! Build method configuration
      driver_config%method_config%method_type = mqc_config%method
      driver_config%method_config%verbose = .false.  ! Controlled by logger level in do_fragment_work

      ! Configure XTB solvation settings
      call driver_config%method_config%xtb%configure( &
         use_cds=mqc_config%use_cds, &
         use_shift=mqc_config%use_shift, &
         dielectric=mqc_config%dielectric, &
         cpcm_nang=mqc_config%cpcm_nang, &
         cpcm_rscale=mqc_config%cpcm_rscale, &
         solvent=mqc_config%solvent, &
         solvation_model=mqc_config%solvation_model)

      ! Copy calc_type
      driver_config%calc_type = mqc_config%calc_type

      ! Determine fragment count
      if (present(molecule_index)) then
         ! Multi-molecule mode: use specific molecule's fragment count
         if (molecule_index < 1 .or. molecule_index > mqc_config%nmol) then
            nfrag_to_use = 0
         else
            nfrag_to_use = mqc_config%molecules(molecule_index)%nfrag
         end if
      else
         ! Single molecule mode (backward compatible)
         nfrag_to_use = mqc_config%nfrag
      end if

      ! Set fragmentation level
      ! For unfragmented calculations (nfrag=0), nlevel must be 0
      if (nfrag_to_use == 0) then
         driver_config%nlevel = 0
      else
         driver_config%nlevel = mqc_config%frag_level
      end if

      ! Set GMBE overlapping fragments flag
      driver_config%allow_overlapping_fragments = mqc_config%allow_overlapping_fragments

      ! Set GMBE maximum intersection level
      driver_config%max_intersection_level = mqc_config%max_intersection_level

      ! Copy fragment distance cutoffs if present
      if (allocated(mqc_config%fragment_cutoffs)) then
         allocate (driver_config%fragment_cutoffs(size(mqc_config%fragment_cutoffs)))
         driver_config%fragment_cutoffs = mqc_config%fragment_cutoffs
      end if

      ! Set calculation-specific keywords
      driver_config%hessian%displacement = mqc_config%hessian_displacement
      driver_config%hessian%temperature = mqc_config%hessian_temperature
      driver_config%hessian%pressure = mqc_config%hessian_pressure
      driver_config%aimd%dt = mqc_config%aimd_dt
      driver_config%aimd%nsteps = mqc_config%aimd_nsteps
      driver_config%aimd%initial_temperature = mqc_config%aimd_initial_temperature
      driver_config%aimd%output_frequency = mqc_config%aimd_output_frequency
      driver_config%scf%max_iterations = mqc_config%scf_maxiter
      driver_config%scf%convergence_threshold = mqc_config%scf_tolerance

      ! Output control
      driver_config%skip_json_output = mqc_config%skip_json_output

   end subroutine config_to_driver