mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 04:13:33 +01:00
Improved GAMESS/US parser
This commit is contained in:
parent
a2859ad69c
commit
13fcc8e6fa
@ -22,7 +22,9 @@ let read_shell ic =
|
||||
|
||||
let shell, n =
|
||||
try
|
||||
Scanf.sscanf (input_line ic) " %c %d " (fun shell n -> shell, n)
|
||||
let line = input_line ic in
|
||||
if String.trim line = "$END" then raise End_of_file;
|
||||
Scanf.sscanf line "%c %d " (fun shell n -> shell, n)
|
||||
with
|
||||
| End_of_file -> raise No_shell
|
||||
| Scanf.Scan_failure m -> raise (Malformed_shell m)
|
||||
@ -32,7 +34,7 @@ let read_shell ic =
|
||||
| 0 -> []
|
||||
| i -> let contraction =
|
||||
let line = (input_line ic) in
|
||||
try Scanf.sscanf line " %_d %f %f "
|
||||
try Scanf.sscanf line "%_d %f %f "
|
||||
(fun exponent coefficient -> { exponent ; coefficient })
|
||||
with _ -> raise (Malformed_shell (Printf.sprintf
|
||||
"Expected %d %c contractions, error at contraction %d:\n%s"
|
||||
@ -63,19 +65,21 @@ let read_element ic =
|
||||
Some (element, Array.of_list (loop ()) )
|
||||
|
||||
with
|
||||
| Element.ElementError _ -> None
|
||||
| End_of_file -> None
|
||||
|
||||
|
||||
|
||||
let read filename =
|
||||
let ic = open_in filename in
|
||||
let rec loop () =
|
||||
match read_element ic with
|
||||
| Some e -> e :: loop ()
|
||||
| None -> []
|
||||
let rec loop accu =
|
||||
try
|
||||
match read_element ic with
|
||||
| Some e -> loop (e :: accu)
|
||||
| None -> accu
|
||||
with
|
||||
Element.ElementError _ -> loop accu
|
||||
in
|
||||
loop ()
|
||||
loop []
|
||||
|
||||
|
||||
let combine basis_list =
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user