10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-09-27 03:51:01 +02:00

Fixed options

This commit is contained in:
Anthony Scemama 2019-01-14 19:52:41 +01:00
parent 316fb508d5
commit cd7d0280d7
18 changed files with 429 additions and 232 deletions

View File

@ -15,12 +15,12 @@ Usage
.. code:: bash .. code:: bash
qp_convert_output_to_ezfio <file.out> [-o EZFIO_DIR] qp_convert_output_to_ezfio [-o EZFIO_DIR] FILE
.. option:: -o, --output=EZFIO_DIR .. option:: -o, --output=EZFIO_DIR
Renames the |EZFIO| directory. If this option is not present, the default Renames the |EZFIO| directory. If this option is not present, the default
name fill be :file:`<FILE.out>.ezfio` name fill be :file:`FILE.ezfio`
.. note:: .. note::
All the parameters of the wave functgion need to be presente in the output All the parameters of the wave functgion need to be presente in the output

View File

@ -13,14 +13,9 @@ Usage
.. code:: bash .. code:: bash
qp_create_ezfio_from_xyz [FLAGS] (<xyz_file> | <zmt_file>) qp_create_ezfio_from_xyz [-a] -b <string> [-c <int>] [-d <float>]
[-h] [-m <int>] [-o EZFIO_DIR] [-p <string>] [-x] [--] FILE
Flags :
[-a|--au] [-b string|--basis=string]
[-c int|--charge=int] [-d float|--dummy=float] [-h|--help]
[-m int|--multiplicity=int] [-o file|--output=file]
[-p string|--pseudo=string] [-x|--cartesian]
.. option:: -a, --au .. option:: -a, --au
@ -37,6 +32,10 @@ Usage
-b "cc-pvtz | 1,H:sto-3g | 3,H:6-31g" -b "cc-pvtz | 1,H:sto-3g | 3,H:6-31g"
By default, the basis set is obtained from the local database of the |qp|. By default, the basis set is obtained from the local database of the |qp|.
This option is mandatory.
If ``<string>`` is set to ``show``, the list of all available basis sets is
displayed.
.. option:: -c, --charge=<int> .. option:: -c, --charge=<int>

View File

@ -27,8 +27,7 @@ Usage
.. code:: bash .. code:: bash
qp_edit [-c|--check] [-h|--help] [-n <int>|--ndet=<int>] qp_edit [-c] [-h] [-n <int>] [-s <range>] [--] EZFIO_DIR
[-s <range>|--state=<range>] [--] EZFIO_DIR
.. option:: -c, --check .. option:: -c, --check

View File

@ -24,7 +24,7 @@ Usage
Prints the help message Prints the help message
.. note:: .. note::
There can be conflicts due to the version of Glibc. The machine on which |QP| is There can be conflicts due to the version of glibc. The machine on which |QP| is
compiled should be the oldest one. compiled should be the oldest one.

View File

@ -15,11 +15,11 @@ Usage
.. code:: bash .. code:: bash
qp_plugins list [ -i, --installed | -u, --uninstalled | -q, --repositories ] qp_plugins list [-i] [-u] [-q]
qp_plugins download <url> qp_plugins download <url>
qp_plugins install <name>... qp_plugins install <name>...
qp_plugins uninstall <name> qp_plugins uninstall <name>
qp_plugins create -n <name> [-r, --repository=<repo>] [<needed_modules>...] qp_plugins create -n <name> [-r <repo>] [<needed_modules>...]
.. option:: list .. option:: list
@ -37,7 +37,7 @@ Usage
List all the downloaded repositories. List all the downloaded repositories.
.. option:: download URL .. option:: download <url>
Download an external repository. The URL points to a tar.gz file or a Download an external repository. The URL points to a tar.gz file or a
git repository, for example: git repository, for example:

View File

@ -15,8 +15,7 @@ Usage
.. code:: bash .. code:: bash
qp_run [-h|--help] [-p <string>|--prefix=<string>] [-s|--slave] [--] qp_run [-h] [-p <string>] [-s] [--] PROGRAM EZFIO_DIR
PROGRAM EZFIO_DIR
``PROGRAM`` is the name of the |QP| program to be run, and ``EZFIO_DIR`` is ``PROGRAM`` is the name of the |QP| program to be run, and ``EZFIO_DIR`` is
the name of the |EZFIO| directory containing the data. the name of the |EZFIO| directory containing the data.

View File

@ -21,7 +21,7 @@ Usage
.. code:: bash .. code:: bash
qp_set_frozen_core [-q] <EZFIO_DIRECTORY> qp_set_frozen_core [-q] EZFIO_DIR
.. option:: -q .. option:: -q

View File

@ -38,38 +38,32 @@ Usage
.. code:: bash .. code:: bash
qp_set_mo_class [FLAGS] <EZFIO_DIRECTORY> qp_set_mo_class [-a <range>] [-c <range>] [-d <range>] [-h] [-i <range>]
Flags: [-q] [-v <range>] [--] EZFIO_DIR
[-act range] [-core range] [-del range]
[-inact range] [-q] [-virt range]
[-help]
.. option:: -a, --act=<range>
.. option:: -act <range>
Range of active orbitals Range of active orbitals
.. option:: -core <range> .. option:: -c, --core=<range>
Range of core orbitals Range of core orbitals
.. option:: -del <range> .. option:: -d, --del=<range>
Range of deleted orbitals Range of deleted orbitals
.. option:: -inact <range> .. option:: -i, --inact=<range>
Range of inactive orbitals Range of inactive orbitals
.. option:: -q .. option:: -q, --query
Query: print the current masks Print the |MO| classes
.. option:: -virt <range> .. option:: -v, --virt=<range>
Range of virtual orbitals Range of virtual orbitals
.. option:: -help, -?

View File

@ -1,161 +1,199 @@
type argument = With_arg | Without_arg | With_opt_arg type short_opt = char
type long_opt = string
type optional = Mandatory | Optional
type documentation = string
type argument = With_arg of string | Without_arg | With_opt_arg of string
let anon_args = ref [] type description = {
short: short_opt ;
long : long_opt ;
opt : optional ;
doc : documentation ;
arg : argument ;
}
let anon_args = ref []
and header_doc = ref "" and header_doc = ref ""
and description_doc = ref ""
and footer_doc = ref "" and footer_doc = ref ""
and specs = ref [] and specs = ref []
let set_header_doc s = header_doc := s let set_header_doc s = header_doc := s
let set_description_doc s = description_doc := s
let set_footer_doc s = footer_doc := s let set_footer_doc s = footer_doc := s
let dict = (* Hash table containing all the options *)
let d = Hashtbl.create 67 in let dict = Hashtbl.create 67
d
let get_bool x = Hashtbl.mem dict x
let show_help () = get_bool "help"
let get x = let get x =
try Some (Hashtbl.find dict x) try Some (Hashtbl.find dict x)
with Not_found -> None with Not_found -> None
let get_bool x = let anonymous name opt doc =
Hashtbl.mem dict x { short=' ' ; long=name; opt; doc; arg=Without_arg; }
let show_help () = let output_text t =
get_bool "help" Format.printf "@[<v 0>";
begin
match Str.split (Str.regexp "\n") t with
| x :: [] -> Format.printf "@[<hov 0>";
Str.split (Str.regexp " ") x
|> List.iter (fun y -> Format.printf "@[%s@]@ " y) ;
Format.printf "@]"
| t -> List.iter (fun x ->
Format.printf "@[<hov 0>";
Str.split (Str.regexp " ") x
|> List.iter (fun y -> Format.printf "@[%s@]@ " y) ;
Format.printf "@]@;") t
end;
Format.printf "@]"
;;
let output_short x =
match x.short, x.opt, x.arg with
| ' ', Mandatory, _ -> Format.printf "@[%s@]" x.long
| ' ', Optional , _ -> Format.printf "@[[%s]@]" x.long
| _ , Mandatory, Without_arg -> Format.printf "@[-%c@]" x.short
| _ , Optional , Without_arg -> Format.printf "@[[-%c]@]" x.short
| _ , Mandatory, With_arg arg -> Format.printf "@[-%c %s@]" x.short arg
| _ , Optional , With_arg arg -> Format.printf "@[[-%c %s]@]" x.short arg
| _ , Mandatory, With_opt_arg arg -> Format.printf "@[-%c [%s]@]" x.short arg
| _ , Optional , With_opt_arg arg -> Format.printf "@[[-%c [%s]]@]" x.short arg
let output_long max_width x =
let arg =
match x.short, x.arg with
| ' ' , _ -> x.long
| _ , Without_arg -> x.long
| _ , With_arg arg -> Printf.sprintf "%s=%s" x.long arg
| _ , With_opt_arg arg -> Printf.sprintf "%s[=%s]" x.long arg
in
let long =
let l = String.length arg in
arg^(String.make (max_width-l) ' ')
in
Format.printf "@[<v 0>";
begin
match x.short with
| ' ' -> Format.printf "@[%s @]" long
| short -> Format.printf "@[-%c --%s @]" short long
end;
Format.printf "@]";
output_text x.doc
let anonymous ?(optional=false) name doc =
( ' ', name, doc,
if optional then With_opt_arg else Without_arg
)
let help () = let help () =
Format.printf "@[%s@]@.@." !header_doc; (* Print the header *)
let get_param_from_doc doc = output_text !header_doc;
match Str.split (Str.regexp "[ \n\r\x0c\t]+") doc with Format.printf "@.@.";
| param :: doc -> param, (String.concat " " doc)
| _ -> failwith "Bad format for documentation"
in
let anon = (* Find the anonymous arguments *)
List.filter (fun (x,_,_,_) -> x = ' ') !specs let anon =
|> List.map (fun x -> List.filter (fun x -> x.short = ' ') !specs
match x with in
| (_,name,doc,Without_arg) -> (name,doc,false)
| (_,name,doc,_) -> (name,doc,true)
)
in
let options = (* Find the options *)
List.filter (fun (x,_,_,_) -> x <> ' ') !specs let options =
|> List.sort (fun (x,_,_,_) (y,_,_,_) -> Char.compare x y) List.filter (fun x -> x.short <> ' ') !specs
|> List.map (fun x -> |> List.sort (fun x y -> Char.compare x.short y.short)
match x with in
| (short,long,doc,With_arg) -> (* with arg *)
let param, doc = get_param_from_doc doc in
(Printf.sprintf "-%c %s" short param,
Printf.sprintf "--%s=%s" long param,
doc)
| (short,long,doc,Without_arg) -> (* without arg *)
(Printf.sprintf "-%c" short,
Printf.sprintf "--%s" long,
doc)
| (short,long,doc,With_opt_arg) -> (* with or without arg *)
let param, doc = get_param_from_doc doc in
(Printf.sprintf "-%c [%s]" short param,
Printf.sprintf "--%s[=%s]" long param,
doc)
)
in
let max_short = (* Find column lengths *)
List.map (fun (x,_,_) -> String.length x) options let max_width =
|> List.fold_left max 0 List.map (fun x ->
in ( match x.arg with
| Without_arg -> String.length x.long
let max_long = | With_arg arg -> String.length x.long + String.length arg
List.map (fun (_,x,_) -> String.length x) options | With_opt_arg arg -> String.length x.long + String.length arg + 2
|> List.fold_left max 0 )
in + ( if x.opt = Optional then 2 else 0)
) !specs
let fmt_opt max_w o = |> List.fold_left max 0
let l = String.length o in in
o^(String.make (max_w-l) ' ')
in
let output_option ?(fixed_width=false) (short, long, doc) = (* Print usage *)
if fixed_width then Format.printf "@[<v>@[<v 2>Usage:@,@,@[<hov 4>@[%s@]" Sys.argv.(0);
Format.printf "@[%s %s@]" List.iter (fun x -> Format.printf "@ "; output_short x) options;
(fmt_opt max_short short) (fmt_opt max_long long) Format.printf "@ @[[--]@]";
else List.iter (fun x -> Format.printf "@ "; output_short x;) anon;
Format.printf "@[%s|%s@]" short long Format.printf "@]@,@]@,";
in
let output_anon ?(fixed_width=false) (name, doc, optional) =
if optional then
Format.printf "@[[%s]@]" name
else
Format.printf "@[%s@]" name
in
Format.printf "@[<v>@[<v 2>Usage:@,@,@[<hov 4>@[%s@]" Sys.argv.(0); (* Print arguments and doc *)
List.iter (fun x -> Format.printf "@[<v 2>Arguments:@,";
Format.printf "@ @[["; Format.printf "@[<v 0>" ;
output_option ~fixed_width:false x; List.iter (fun x -> Format.printf "@ "; output_long max_width x) anon;
Format.printf "]@]" Format.printf "@]@,@]@,";
) options;
Format.printf "@ @[[--]@]";
List.iter (fun x ->
Format.printf "@ @[";
output_anon ~fixed_width:false x;
Format.printf "@]"
) anon;
Format.printf "@]@]@,@,";
Format.printf "@[<v>Arguments:@,";
Format.printf "@[<v 2>@," ; (* Print options and doc *)
List.iter (fun (name,doc,optional) -> Format.printf "@[<v 2>Options:@,";
Format.printf "@[<h>";
output_anon ~fixed_width:true (name,doc,optional);
Format.printf "@ @[<v 0>%s@]@]@," doc
) anon;
Format.printf "@]@;";
Format.printf "@[<v>Options:@,"; Format.printf "@[<v 0>" ;
List.iter (fun x -> Format.printf "@ "; output_long max_width x) options;
Format.printf "@]@,@]@,";
(* Print footer *)
if !description_doc <> "" then
begin
Format.printf "@[<v 2>Description:@,@,";
output_text !description_doc;
Format.printf "@,"
end;
(* Print footer *)
output_text !footer_doc;
Format.printf "@."
Format.printf "@[<v 2>@," ;
List.iter (fun (short,long,doc) ->
Format.printf "@[<h>";
output_option ~fixed_width:true (short,long,doc);
Format.printf "@ @[<v 0>%s@]@]@," doc
) options;
Format.printf "@]@;";
Format.printf "@[%s@]@." !footer_doc
let set_specs specs_in = let set_specs specs_in =
specs := ( 'h', "help", "Prints the help message", Without_arg) :: specs_in; specs := { short='h' ;
long ="help" ;
doc ="Prints the help message." ;
arg =Without_arg ;
opt =Optional ;
} :: specs_in;
let specs = let cmd_specs =
List.filter (fun (x,_,_,_) -> x != ' ') !specs List.filter (fun x -> x.short != ' ') !specs
|> List.map (fun x -> |> List.map (fun { short ; long ; opt ; doc ; arg } ->
match x with match arg with
| (short, long, doc, With_arg) -> | With_arg _ ->
(short, long, None, Some (fun x -> Hashtbl.replace dict long x) ) (short, long, None, Some (fun x -> Hashtbl.replace dict long x) )
| (short, long, doc, Without_arg) -> | Without_arg ->
(short, long, Some (fun () -> Hashtbl.replace dict long ""), None) (short, long, Some (fun () -> Hashtbl.replace dict long ""), None)
| (short, long, doc, With_opt_arg) -> | With_opt_arg _ ->
(short, long, Some (fun () -> Hashtbl.replace dict long ""), (short, long, Some (fun () -> Hashtbl.replace dict long ""),
Some (fun x -> Hashtbl.replace dict long x) ) Some (fun x -> Hashtbl.replace dict long x) )
) )
in in
Getopt.parse_cmdline specs (fun x -> anon_args := !anon_args @ [x]); Getopt.parse_cmdline cmd_specs (fun x -> anon_args := !anon_args @ [x]);
if show_help () then
(help () ; exit 0);
(* Check that all mandatory arguments are set *)
List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs
|> List.iter (fun x ->
match get x.long with
| Some _ -> ()
| None -> failwith ("Error: --"^x.long^" option is missing.")
)
;;
if show_help () then
(help () ; exit 0)
let anon_args () = !anon_args let anon_args () = !anon_args

126
ocaml/Command_line.mli Normal file
View File

@ -0,0 +1,126 @@
(** Handles command-line arguments, using getopt.
Example:
let () =
(* Command-line specs *)
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - quantum_package command");
[ { short='c'; long="check"; opt=Optional;
doc="Checks the input data";
arg=Without_arg; };
{ short='n'; long="ndet"; opt=Optional;
doc="Truncate the wavefunction to the target number of determinants";
arg=With_arg "<int>"; };
{ short='s'; long="state"; opt=Optional;
doc="Extract selected states, for example \"[1,3-5]\"";
arg=With_arg "<range>"; };
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
]
|> set_specs ;
set_description_doc
"Opens a text editor to edit the parameters of a EZFIO directory.";
end;
(* Handle options *)
let ndet =
match Command_line.get "ndet" with
| None -> None
| Some s -> (try Some (int_of_string s)
with _ -> failwith "[-n|--ndet] expects an integer")
in
let state =
match Command_line.get "state" with
| None -> None
| Some s -> (try Some (Range.of_string s)
with _ -> failwith "[-s|--state] expects a range")
in
let c = Command_line.get_bool "check" in
let filename =
match Command_line.anon_args () with
| [x] -> x
| _ -> (Command_line.help () ; failwith "EZFIO_DIR is missing")
in
(* Run the program *)
run c ?ndet ?state filename
*)
type short_opt = char
type long_opt = string
type optional = Mandatory
| Optional
type documentation = string
type argument = With_arg of string
| Without_arg
| With_opt_arg of string
type description =
{
short : short_opt;
long : long_opt;
opt : optional;
doc : documentation;
arg : argument;
}
(** Sets the header of the help message. *)
val set_header_doc : string -> unit
(** Sets the description of the help message. *)
val set_description_doc : string -> unit
(** Sets the footer of the help message. *)
val set_footer_doc : string -> unit
(** Gets the value of an option. If the option is not set, returns [None]. If
the option is set, returns Some <string>. *)
val get : string -> string option
(** Gets the value of an option with no argument. If the option is set, returns [true]. *)
val get_bool : string -> bool
(** True if the '-h' or "--help" option was found. *)
val show_help : unit -> bool
(** Creates a specification of an anonymous argument. *)
val anonymous : long_opt -> optional -> documentation -> description
(** Prints the help message *)
val help : unit -> unit
(** Sets the specification list as a list of tuples:
( short option, long option, documentation, argument ) *)
val set_specs : description list -> unit
(** Returns the list of anonymous arguments *)
val anon_args : unit -> string list

View File

@ -69,7 +69,6 @@ let list_basis () =
) )
in in
List.sort basis_list ~compare:String.ascending List.sort basis_list ~compare:String.ascending
|> String.concat ~sep:"\n"
(** Run the program *) (** Run the program *)
@ -648,36 +647,54 @@ let run ?o b au c d m p cart xyz_file =
let () = let () =
"=== Available basis sets ===
" ^ (list_basis ()) ^ " let open Command_line in
begin
"Creates an EZFIO directory from a standard xyz file or from a z-matrix file in Gaussian format. The basis set is defined as a single string if all the atoms are taken from the same basis set, otherwise specific elements can be defined as follows:
============================ -b \"cc-pcvdz | H:cc-pvdz | C:6-31g\"
-b \"cc-pvtz | 1,H:sto-3g | 3,H:6-31g\"
Creates an EZFIO directory from a standard xyz file or from a z-matrix file If a file with the same name as the basis set exists, this file will be read. Otherwise, the basis set is obtained from the database.
in Gaussian format. The basis set is defined as a single string if all the " |> set_description_doc ;
atoms are taken from the same basis set, otherwise specific elements can be set_header_doc (Sys.argv.(0) ^ " - Quantum Package command");
defined as follows:
-b \"cc-pcvdz | H:cc-pvdz | C:6-31g\" [ { opt=Optional ; short='o'; long="output";
-b \"cc-pvtz | 1,H:sto-3g | 3,H:6-31g\" arg=With_arg "EZFIO_DIR";
doc="Name of the created EZFIO directory."} ;
If a file with the same name as the basis set exists, this file will be read. { opt=Mandatory; short='b'; long="basis";
Otherwise, the basis set is obtained from the database. arg=With_arg "<string>";
doc="Name of basis set. If <string>=show, the list of all basis sets is displayed."} ;
" |> Command_line.set_header_doc ; { opt=Optional ; short='a'; long="au";
arg=Without_arg;
doc="Input geometry is in atomic units."} ;
[ ( 'o', "output", "<file> Name of the created EZFIO file.", Command_line.With_arg) ; { opt=Optional ; short='c'; long="charge";
( 'b', "basis", "<string> Name of basis set.", Command_line.With_arg) ; arg=With_arg "<int>";
( 'a', "au", "Input geometry is in atomic units.", Command_line.Without_arg) ; doc="Total charge of the molecule. Default is 0."} ;
( 'c', "charge", "<int> Total charge of the molecule. Default is 0.", Command_line.With_arg) ;
( 'd', "dummy", "<float> Add dummy atoms. x * (covalent radii of the atoms)", Command_line.With_arg); { opt=Optional ; short='d'; long="dummy";
( 'm', "multiplicity", "<int> Spin multiplicity (2S+1) of the molecule. Default is 1.", Command_line.With_arg); arg=With_arg "<float>";
( 'p', "pseudo", "<string> Name of the pseudopotential.", Command_line.With_arg); doc="Add dummy atoms. x * (covalent radii of the atoms)."} ;
( 'x', "cartesian", "Compute AOs in the Cartesian basis set (6d, 10f, ...)", Command_line.Without_arg);
Command_line.anonymous "(xyz_file|zmt_file)" "input file in xyz format or z-matrix." { opt=Optional ; short='m'; long="multiplicity";
] arg=With_arg "<int>";
|> Command_line.set_specs ; doc="Spin multiplicity (2S+1) of the molecule. Default is 1."} ;
{ opt=Optional ; short='p'; long="pseudo";
arg=With_arg "<string>";
doc="Name of the pseudopotential."} ;
{ opt=Optional ; short='x'; long="cartesian";
arg=Without_arg;
doc="Compute AOs in the Cartesian basis set (6d, 10f, ...)."} ;
anonymous "FILE" Mandatory "Input file in xyz format or z-matrix.";
]
|> set_specs
end;
(* Handle options *) (* Handle options *)
@ -687,7 +704,7 @@ Otherwise, the basis set is obtained from the database.
let basis = let basis =
match Command_line.get "basis" with match Command_line.get "basis" with
| None -> (Command_line.help () ; failwith "Error: [-b|--basis] option is missing.") | None -> assert false
| Some x -> x | Some x -> x
in in
@ -721,6 +738,13 @@ Otherwise, the basis set is obtained from the database.
Command_line.get_bool "cartesian" Command_line.get_bool "cartesian"
in in
if basis = "show" then
begin
list_basis ()
|> List.iter ~f:print_endline;
exit 0
end;
let xyz_filename = let xyz_filename =
match Command_line.anon_args () with match Command_line.anon_args () with
| [x] -> x | [x] -> x

View File

@ -141,34 +141,32 @@ let run slave ?prefix exe ezfio_file =
let () = let () =
(* Command-line specs *) (* Command-line specs *)
"Executes a Quantum Package binary file among these:\n\n" let open Command_line in
^ (Lazy.force Qpackage.executables begin
|> List.map (fun (x,_) -> Printf.sprintf " * %s" x ) set_header_doc (Sys.argv.(0) ^ " - Quantum Package command");
|> String.concat "\n" "Executes a Quantum Package binary file among these:\n\n"
) |> Command_line.set_header_doc; ^ (Lazy.force Qpackage.executables
|> List.map (fun (x,_) -> Printf.sprintf " * %s" x )
|> String.concat "\n")
|> set_description_doc;
[ ( 's', "slave", "Required to run slave tasks in distributed environments", [ { short='s'; long="slave"; opt=Optional;
Command_line.Without_arg); doc="Required to run slave tasks in distributed environments.";
( 'p', "prefix", "<string> Prefix before running the program, like gdb or valgrind", arg=Without_arg; };
Command_line.With_arg );
Command_line.anonymous "PROGRAM" "Name of the QP program to be run"; { short='p'; long="prefix"; opt=Optional;
Command_line.anonymous "EZFIO_DIR" "EZFIO directory"; doc="Prefix before running the program, like gdb or valgrind.";
arg=With_arg "<string>"; };
anonymous "PROGRAM" Mandatory "Name of the QP program to be run";
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
] ]
|> Command_line.set_specs ; |> set_specs ;
end;
(* Handle options *) (* Handle options *)
if Command_line.show_help () then let slave = Command_line.get_bool "slave"
exit 0; and prefix = Command_line.get "prefix"
let slave =
match Command_line.get "slave" with
| None -> false
| _ -> true
in
let prefix =
Command_line.get "prefix"
in in
(* Run the program *) (* Run the program *)

View File

@ -314,30 +314,50 @@ let default range =
let () = let () =
"Set the orbital classes in an EZFIO directory. let open Command_line in
The range of MOs has the form : \"[36-53,72-107,126-131]\"." |> Command_line.set_header_doc ; begin
"Set the orbital classes in an EZFIO directory. The range of MOs has the form : \"[36-53,72-107,126-131]\"."
|> set_footer_doc ;
[ ( 'c', "core", "range Range of core MOs", Command_line.With_opt_arg); [ { opt=Optional ; short='c'; long="core";
( 'i', "inact", "range Range of inactive MOs", Command_line.With_opt_arg); arg=With_arg "<range>";
( 'a', "act", "range Range of active MOs", Command_line.With_opt_arg); doc="Range of core MOs." };
( 'v', "virt", "range Range of virtual MOs", Command_line.With_opt_arg);
( 'd', "del", "range Range of deleted MOs", Command_line.With_opt_arg); { opt=Optional ; short='i'; long="inact";
( 'q', "query", "Print the current MOs classes", Command_line.Without_arg); arg=With_arg "<range>";
Command_line.anonymous "<EZFIO_FILE>" "EZFIO directory"; doc="Range of inactive MOs." };
] |> Command_line.set_specs ;
{ opt=Optional ; short='a'; long="act";
arg=With_arg "<range>";
doc="Range of active MOs." };
{ opt=Optional ; short='v'; long="virt";
arg=With_arg "<range>";
doc="Range of virtual MOs." };
{ opt=Optional ; short='d'; long="del";
arg=With_arg "<range>";
doc="Range of deleted MOs." };
{ opt=Optional ; short='q'; long="query";
arg=Without_arg;
doc="Print the current MO classes." };
anonymous "EZFIO_DIR" Mandatory "EZFIO directory.";
] |> set_specs
end;
(* Handle options *) (* Handle options *)
if Command_line.show_help () then
exit 0;
let core = Command_line.get "core" let core = Command_line.get "core"
and inact = Command_line.get "inact" and inact = Command_line.get "inact"
and act = Command_line.get "act" and act = Command_line.get "act"
and virt = Command_line.get "virt" and virt = Command_line.get "virt"
and del = Command_line.get "del" and del = Command_line.get "del"
and q = Command_line.get_bool "q" and q = Command_line.get_bool "query"
in in
let ezfio_filename = let ezfio_filename =
match Command_line.anon_args () with match Command_line.anon_args () with
| [x] -> x | [x] -> x

View File

@ -39,10 +39,10 @@ do
done done
if [[ $? -ne 0 ]] ; then if [[ $? -ne 0 ]] ; then
echo "==================================================" 1>& 2 >&2 echo "=================================================="
echo "Unable to create temporary file $tmpfile" 1>& 2 >&2 echo "Unable to create temporary file $tmpfile"
echo "==================================================" 1>& 2 >&2 echo "=================================================="
echo "ERROR" >&2 echo "ERROR"
exit 1 exit 1
fi fi

View File

@ -3,11 +3,11 @@
convert output of GAMESS/GAU$$IAN to ezfio convert output of GAMESS/GAU$$IAN to ezfio
Usage: Usage:
qp_convert_output_to_ezfio [-o EZFIO_DIR|--output=EZFIO_DIR] <file.out> qp_convert_output_to_ezfio [-o EZFIO_DIR] FILE
Options: Options:
-o EZFIO_DIR --output=EZFIO_DIR Produced directory -o --output=EZFIO_DIR Produced directory
by default is file.out.ezfio by default is FILE.ezfio
""" """
@ -342,7 +342,7 @@ def get_full_path(file_path):
if __name__ == '__main__': if __name__ == '__main__':
ARGUMENTS = docopt(__doc__) ARGUMENTS = docopt(__doc__)
FILE = get_full_path(ARGUMENTS['<file.out>']) FILE = get_full_path(ARGUMENTS['FILE'])
if ARGUMENTS["--output"]: if ARGUMENTS["--output"]:
EZFIO_FILE = get_full_path(ARGUMENTS["--output"]) EZFIO_FILE = get_full_path(ARGUMENTS["--output"])

View File

@ -2,7 +2,7 @@
file=$1 file=$1
if [[ -z ${QP_ROOT} ]] ; then if [[ -z ${QP_ROOT} ]] ; then
2>& echo "please source quantum_package.rc" >&2 echo "please source quantum_package.rc"
exit 1 exit 1
fi fi
source ${QP_ROOT}/quantum_package.rc source ${QP_ROOT}/quantum_package.rc

View File

@ -13,7 +13,7 @@ zero.
Usage: Usage:
qp_set_frozen_core [-q|--query] <EZFIO_DIRECTORY> qp_set_frozen_core [-q|--query] EZFIO_DIR
Options: Options:
-q --query Prints in the standard output the number of frozen MOs -q --query Prints in the standard output the number of frozen MOs
@ -37,7 +37,7 @@ from ezfio import ezfio
def main(arguments): def main(arguments):
"""Main function""" """Main function"""
filename = arguments["<EZFIO_DIRECTORY>"] filename = arguments["EZFIO_DIR"]
ezfio.set_filename(filename) ezfio.set_filename(filename)
n_frozen = 0 n_frozen = 0

View File

@ -10,7 +10,7 @@
if [[ -n $1 ]] ; then if [[ -n $1 ]] ; then
exec sed --in-place 's| *$||' $1 exec sed --in-place 's| *$||' $1
else else
2>& echo "Usage: $0 FILE" >&2 echo "Usage: $0 FILE"
exit 1 exit 1
fi fi