pub fn parse_input(path: &Path) -> Result<InputData, ParseError>Expand description
Parse an OpenMECP input file.
This function reads and parses a complete OpenMECP input file, extracting all configuration parameters, geometries, constraints, and additional keywords. It supports the custom section-based input format with support for external geometry files.
§Arguments
path- Path to the input file (e.g., “input.inp”)
§Returns
Returns Ok(InputData) on successful parsing, or Err(ParseError) if:
- The file cannot be read (I/O error)
- The file format is invalid
- Required sections are missing
- External geometry files cannot be read
§Examples
Basic usage:
use omecp::parser::parse_input;
use std::path::Path;
let input_path = Path::new("input.inp");
match parse_input(input_path) {
Ok(input_data) => {
println!("Parsed {} atoms", input_data.geometry.num_atoms);
println!("QM program: {:?}", input_data.config.program);
}
Err(e) => eprintln!("Parse error: {}", e),
}Parsing with external geometry file:
// input.inp
*GEOM
@molecule.xyz
*
program = gaussian
method = B3LYP/6-31G*
// ... other parameters ...use omecp::parser::parse_input;
use std::path::Path;
let input_data = parse_input(Path::new("input.inp"))?;
// Geometry will be read from molecule.xyz