parse_model_section Module Subroutine

module subroutine parse_model_section(unit, config, error)

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_model_section~~CallsGraph proc~parse_model_section parse_model_section proc~error_set error_t%error_set proc~parse_model_section->proc~error_set proc~parse_method_string parse_method_string proc~parse_model_section->proc~parse_method_string proc~strip_comment strip_comment proc~parse_model_section->proc~strip_comment proc~method_type_from_string method_type_from_string proc~parse_method_string->proc~method_type_from_string

Called by

proc~~parse_model_section~~CalledByGraph proc~parse_model_section parse_model_section interface~parse_model_section parse_model_section interface~parse_model_section->proc~parse_model_section proc~read_mqc_file read_mqc_file proc~read_mqc_file->interface~parse_model_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_model_section(unit, config, error)
      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 %model 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 ('method')
            ! Parse method string (e.g., "XTB-GFN1" -> "gfn1")
            config%method = parse_method_string(trim(value))
            if (config%method == METHOD_TYPE_UNKNOWN) then
               call error%set(ERROR_PARSE, "Invalid method: "//trim(value))
               return
            end if
         case ('basis')
            config%basis = trim(value)
         case ('aux_basis')
            config%aux_basis = trim(value)
         case default
            call error%set(ERROR_PARSE, "Unknown key in %model section: "//trim(key))
            return
         end select
      end do

   end subroutine parse_model_section