mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-21 11:53:31 +01:00
Added Command_line module
This commit is contained in:
parent
ecf61058f9
commit
61c380f31e
2
_tags
2
_tags
@ -1,4 +1,4 @@
|
||||
true: package(str,unix,bigarray,lacaml,alcotest,zarith)
|
||||
true: package(str,unix,bigarray,lacaml,alcotest,zarith,getopt)
|
||||
<*.byte> : linkdep(Utils/math_functions.o), custom
|
||||
<*.native>: linkdep(Utils/math_functions.o)
|
||||
<odoc-ltxhtml>: not_hygienic
|
||||
|
@ -1,38 +1,50 @@
|
||||
let out_file : string option ref = ref None
|
||||
let basis_file : string option ref = ref None
|
||||
let nuclei_file : string option ref = ref None
|
||||
let charge : int ref = ref 0
|
||||
let multiplicity: int ref = ref 1
|
||||
let () =
|
||||
let open Command_line in
|
||||
begin
|
||||
set_header_doc (Sys.argv.(0) ^ " - QCaml command");
|
||||
set_description_doc "Runs a Hartree-Fock calculation";
|
||||
set_specs
|
||||
[ { short='b' ; long="basis" ; opt=Mandatory;
|
||||
arg=With_arg "<string>";
|
||||
doc="Name of the file containing the basis set"; } ;
|
||||
|
||||
{ short='x' ; long="xyz" ; opt=Mandatory;
|
||||
arg=With_arg "<string>";
|
||||
doc="Name of the file containing the nuclear coordinates in xyz format"; } ;
|
||||
|
||||
let speclist = [
|
||||
( "-b" , Arg.String (fun x -> basis_file := Some x),
|
||||
"File containing the atomic basis set") ;
|
||||
( "-c" , Arg.String (fun x -> nuclei_file := Some x),
|
||||
"File containing the nuclear coordinates") ;
|
||||
( "-o" , Arg.String (fun x -> out_file := Some x) ,
|
||||
"Output file") ;
|
||||
( "-charge" , Arg.Int (fun x -> charge := x),
|
||||
"Charge of the system") ;
|
||||
( "-mult" , Arg.Int (fun x -> multiplicity := x),
|
||||
"Spin multiplicity of the system") ;
|
||||
]
|
||||
{ short='m' ; long="multiplicity" ; opt=Optional;
|
||||
arg=With_arg "<int>";
|
||||
doc="Spin multiplicity (2S+1). Default is singlet"; } ;
|
||||
|
||||
let run ~out =
|
||||
(*
|
||||
let gc = Gc.get () in
|
||||
Gc.set { gc with minor_heap_size=(262144 / 16) };
|
||||
*)
|
||||
let basis_file =
|
||||
match !basis_file with
|
||||
| None -> raise (Invalid_argument "Basis set file should be specified with -b")
|
||||
{ short='c' ; long="charge" ; opt=Optional;
|
||||
arg=With_arg "<int>";
|
||||
doc="Total charge of the molecule. Default is 0"; } ;
|
||||
]
|
||||
end;
|
||||
|
||||
(* Handle options *)
|
||||
let basis_file =
|
||||
match Command_line.get "basis" with
|
||||
| Some x -> x
|
||||
and nuclei_file =
|
||||
match !nuclei_file with
|
||||
| None -> raise (Invalid_argument "Coordinate file should be specified with -c")
|
||||
| None -> assert false
|
||||
in
|
||||
|
||||
let nuclei_file =
|
||||
match Command_line.get "xyz" with
|
||||
| Some x -> x
|
||||
and charge = !charge
|
||||
and multiplicity = !multiplicity
|
||||
| None -> assert false
|
||||
in
|
||||
|
||||
let charge =
|
||||
match Command_line.get "charge" with
|
||||
| Some x -> int_of_string x
|
||||
| None -> 0
|
||||
in
|
||||
|
||||
let multiplicity =
|
||||
match Command_line.get "multiplicity" with
|
||||
| Some x -> int_of_string x
|
||||
| None -> 1
|
||||
in
|
||||
|
||||
let s =
|
||||
@ -44,8 +56,3 @@ let run ~out =
|
||||
|> print_endline
|
||||
|
||||
|
||||
let () =
|
||||
let usage_msg = "Available options:" in
|
||||
Arg.parse speclist (fun _ -> ()) usage_msg;
|
||||
run ~out:!out_file
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user