parse_xtb_section Module Subroutine

module subroutine parse_xtb_section(unit, config, error)

Parse %xtb section for XTB-specific settings (solvation, etc.)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit
type(mqc_config_t), intent(inout) :: config
type(error_t), intent(out) :: error

Calls

proc~~parse_xtb_section~~CallsGraph proc~parse_xtb_section parse_xtb_section proc~error_set error_t%error_set proc~parse_xtb_section->proc~error_set proc~strip_comment strip_comment proc~parse_xtb_section->proc~strip_comment

Called by

proc~~parse_xtb_section~~CalledByGraph proc~parse_xtb_section parse_xtb_section interface~parse_xtb_section parse_xtb_section interface~parse_xtb_section->proc~parse_xtb_section proc~read_mqc_file read_mqc_file proc~read_mqc_file->interface~parse_xtb_section program~main main program~main->proc~read_mqc_file

Variables

Type Visibility Attributes Name Initial
integer, private :: eq_pos
integer, private :: io_stat
character(len=MAX_LINE_LEN), private :: key
character(len=MAX_LINE_LEN), private :: line
character(len=MAX_LINE_LEN), private :: value

Source Code

   module subroutine parse_xtb_section(unit, config, error)
      !! Parse %xtb section for XTB-specific settings (solvation, etc.)
      integer, intent(in) :: unit
      type(mqc_config_t), intent(inout) :: config
      type(error_t), intent(out) :: error

      character(len=MAX_LINE_LEN) :: line, key, value
      integer :: io_stat, eq_pos
      do
         read (unit, '(A)', iostat=io_stat) line
         if (io_stat /= 0) then
            call error%set(ERROR_IO, "Unexpected end of file in %xtb section")
            return
         end if

         line = adjustl(line)
         if (len_trim(line) == 0) cycle
         if (line(1:1) == '#' .or. line(1:1) == '!') cycle

         if (trim(strip_comment(line)) == 'end') exit

         eq_pos = index(line, '=')
         if (eq_pos == 0) cycle

         key = adjustl(line(1:eq_pos - 1))
         value = adjustl(line(eq_pos + 1:))

         select case (trim(key))
         case ('solvent')
            config%solvent = trim(value)
         case ('solvation_model')
            config%solvation_model = trim(value)
         case ('use_cds')
            config%use_cds = (trim(value) == 'true')
         case ('use_shift')
            config%use_shift = (trim(value) == 'true')
         case ('dielectric')
            read (value, *, iostat=io_stat) config%dielectric
            if (io_stat /= 0) then
               call error%set(ERROR_PARSE, "Invalid dielectric value: "//trim(value))
               return
            end if
         case ('cpcm_nang')
            read (value, *, iostat=io_stat) config%cpcm_nang
            if (io_stat /= 0) then
               call error%set(ERROR_PARSE, "Invalid cpcm_nang value: "//trim(value))
               return
            end if
         case ('cpcm_rscale')
            read (value, *, iostat=io_stat) config%cpcm_rscale
            if (io_stat /= 0) then
               call error%set(ERROR_PARSE, "Invalid cpcm_rscale value: "//trim(value))
               return
            end if
         case default
            call error%set(ERROR_PARSE, "Unknown key in %xtb section: "//trim(key))
            return
         end select
      end do

   end subroutine parse_xtb_section