10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-09-01 07:43:41 +02:00

Compare commits

..

No commits in common. "5e25738f53dde2e291324d2e000e3a08e3bbcd63" and "a13410d2776ee4cd21321d4ed54e1637c5157012" have entirely different histories.

14 changed files with 116 additions and 208 deletions

View File

@ -12,22 +12,12 @@ type description = {
arg : argument ;
}
(* Mutable variables *)
let anon_args = ref []
and header_doc = ref ""
and description_doc = ref ""
and footer_doc = ref ""
and specs = ref []
let reset () =
anon_args := [];
header_doc := "";
description_doc := "";
footer_doc := "";
specs := []
(* End mutable variables *)
let set_header_doc s = header_doc := s
let set_description_doc s = description_doc := s
let set_footer_doc s = footer_doc := s

View File

@ -124,6 +124,3 @@ val set_specs : description list -> unit
val anon_args : unit -> string list
(** Reset the internal state *)
val reset : unit -> unit

View File

@ -24,8 +24,6 @@ ALL_EXE=$(patsubst %.ml,%.native,$(wildcard qp_*.ml)) qmcchem.native
default: $(ALL_EXE)
mv qmcchem.native $(QMCCHEM_PATH)/bin/qmcchem
tests: $(ALL_TESTS)

View File

@ -19,7 +19,7 @@ let run ~t ezfio_filename=
match (Ezfio.get_simulation_http_server ()
|> String_ext.rsplit2 ~on:':' )
with
| Some (a,p) -> a^":"^( (int_of_string p)+4 |> string_of_int )
| Some (a,p) -> a^":"^( (Int.of_string p)+4 |> Int.to_string )
| None -> failwith "Badly formed address"
in
Zmq.Socket.connect socket address;
@ -31,7 +31,7 @@ let run ~t ezfio_filename=
Str.regexp " *: *"
in
let tot_size =
ref 0.
ref (Byte_units.create `Bytes 0.)
in
while true
do
@ -41,12 +41,12 @@ let run ~t ezfio_filename=
let (socket, bytes) =
match Str.split re_split msg with
| socket :: bytes :: _ ->
(socket, float_of_string bytes)
| _ -> (print_endline msg ; ("", 0.))
(socket, Byte_units.create `Bytes (Float.of_string bytes))
| _ -> (print_endline msg ; ("", Byte_units.create `Bytes 0.))
in
tot_size := !tot_size +. bytes;
Printf.printf "%f\n%!" !tot_size;
Unix.sleep 1
tot_size := Byte_units.create `Bytes ((Byte_units.bytes !tot_size) +. (Byte_units.bytes bytes));
Printf.printf "%s\n%!" (Byte_units.to_string !tot_size);
Time.pause (Time.Span.of_sec 1.)
done
end
else
@ -62,29 +62,20 @@ let run ~t ezfio_filename=
let command () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
set_description_doc "Debug ZeroMQ communications";
[ { short='t' ; long="traffic" ; opt=Optional ;
doc="Print traffic in bytes" ;
arg=Without_arg } ;
anonymous "EZFIO_DIR" Mandatory "EZFIO directory" ]
|> set_specs
end;
let t = Command_line.get_bool "traffic" in
let ezfio_file =
match Command_line.anon_args () with
| ezfio_file :: [] -> ezfio_file
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
in
run t ezfio_file
let spec =
let open Command.Spec in
empty
+> flag "t" no_arg
~doc:"Measure the throughput"
+> anon ("ezfio_file" %: string)
let command =
Command.basic_spec
~summary: "Debug ZeroMQ communications"
~readme:(fun () -> "Gets debug information from the Zmq debug sockets.")
spec
(fun t ezfio_file () -> run t ezfio_file)

View File

@ -274,7 +274,7 @@ let run ~c ?f ?t ?l ?m ?e ?et ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename =
write_input_in_ezfio ezfio_filename fields
let command () =
let () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");

View File

@ -10,22 +10,22 @@ let run ezfio_filename =
[| qmcchem_info ; ezfio_filename |]
in
ignore @@
Unix.execv prog argv
Unix.exec prog argv
let command () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
set_description_doc "Display info on an EZFIO database";
[ anonymous "EZFIO_DIR" Mandatory "EZFIO directory" ]
|> set_specs
end;
let ezfio_file =
match Command_line.anon_args () with
| ezfio_file :: [] -> ezfio_file
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
in
let spec =
let open Command.Spec in
empty
+> anon ("ezfio_file" %: string)
let command =
Command.basic_spec
~summary: "Display info on an EZFIO database"
~readme:(fun () ->
"
Display info on an EZFIO database
")
spec
(fun ezfio_file () -> run ezfio_file )
run ezfio_file

View File

@ -52,7 +52,7 @@ let run ?c ?d ~l ~update ezfio_filename =
String.concat "/" [ ezfio_filename; "input"; old_key ]
in
Printf.printf "Removing %s\n%!" old_name;
try Sys.remove old_name with
try Sys.unlink old_name with
| Sys_error _ -> ();
end
in
@ -87,10 +87,11 @@ let run ?c ?d ~l ~update ezfio_filename =
else
""
in
let date =
let open Unix in
localtime (stat filename).st_mtime
|> Time.string_of_date
let date =
(Unix.stat filename).Unix.st_mtime
in
let date =
Unix.strftime (Unix.localtime date) "%a, %d %b %Y %T %z"
in
Printf.printf "%s : %s %s\n" md5 date this)
in
@ -120,7 +121,7 @@ let run ?c ?d ~l ~update ezfio_filename =
| _ -> handle_options ()
let command () =
let () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
@ -152,12 +153,6 @@ let command () =
let d = Command_line.get "diff" in
let l = Command_line.get_bool "list" in
let ezfio_file =
match Command_line.anon_args () with
| ezfio_file :: [] -> ezfio_file
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
in
run ?c ?d ~l ~update ezfio_file

View File

@ -206,7 +206,7 @@ let run ?a ?c ?e ?h ?t ?p ?rmin ?rmax ezfio_file =
display_summary ~range
let command () =
let () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");

View File

@ -1,3 +1,4 @@
open Core
let full_run ?(start_dataserver=true) ezfio_filename =
(* Identify the job scheduler *)
@ -38,13 +39,13 @@ let full_run ?(start_dataserver=true) ezfio_filename =
(* Start the data server *)
let prog, args =
qmcchem, [| qmcchem; "run" ; "-d" ; ezfio_filename |]
let prog, argv =
qmcchem, [ qmcchem; "run" ; "-d" ; ezfio_filename]
in
let pid_dataserver =
Watchdog.fork_exec ~prog ~args ()
Watchdog.fork_exec ~prog ~argv ()
in
Printf.printf "%7d : %s\n%!" pid_dataserver (String.concat " " (Array.to_list args))
Printf.printf "%7d : %s\n%!" (Pid.to_int pid_dataserver) (String.concat ~sep:" " argv)
end;
@ -86,7 +87,7 @@ let full_run ?(start_dataserver=true) ezfio_filename =
| n ->
if (not (test_open_rep_socket ())) then
begin
Unix.sleepf 0.5;
Time.pause (Time.Span.of_sec 0.5);
count (n-1);
end
else
@ -95,33 +96,32 @@ let full_run ?(start_dataserver=true) ezfio_filename =
if (not (count 300)) then
Watchdog.kill ();
*)
Unix.sleep 3;
Time.pause (Time.Span.of_sec 3.);
(* Start the qmc processes *)
let prog, args_list =
let prog, argv =
let launcher =
Launcher.(find () |> to_string)
in
match launcher
|> String.split_on_char ' '
|> List.map String.trim
|> List.filter (fun x -> x <> "")
|> String.split ~on:' '
|> List.map ~f:String.strip
|> List.filter ~f:(fun x -> x <> "")
with
| launcher_exe::launcher_flags ->
launcher_exe, launcher_exe :: launcher_flags @ qmc @ [
Ezfio.get_simulation_http_server () ; ezfio_filename ]
| _ -> failwith "Error in launcher"
in
let args = Array.of_list args_list in
let pid_qmc =
try
Watchdog.fork_exec ~prog ~args ()
Watchdog.fork_exec ~prog ~argv ()
with
| Unix.Unix_error _ ->
begin
let command =
String.concat " " args_list
String.concat ~sep:" " argv
in
Printf.printf "
============================================================
@ -132,7 +132,7 @@ Error: Unable to run the following command
Watchdog.kill ()
end
in
Printf.printf "%7d : %s\n%!" pid_qmc (String.concat " " args_list);
Printf.printf "%7d : %s\n%!" (Pid.to_int pid_qmc) (String.concat ~sep:" " argv);
(* Wait for processes to finish *)
Watchdog.join ()
@ -152,19 +152,18 @@ let run a d ?q ?s ezfio_filename =
Qputils.set_ezfio_filename ezfio_filename;
(* Signal handler to Kill properly all the processes *)
let handler s =
Printf.printf "QMC=Chem received signal %d... killing\n%!" s;
let handler s =
Printf.printf "QMC=Chem received the %s signal... killing\n%!" (Signal.to_string s);
Watchdog.kill ();
in
List.iter (fun s -> ignore @@ Sys.signal s (Sys.Signal_handle handler))
[
Sys.sigint ;
Sys.sigterm ;
Sys.sigquit ;
List.iter [
Signal.int ;
Signal.term ;
Signal.quit ;
]
~f:(fun x -> Signal.Expert.handle x handler)
;
(* Validate input *)
Input.validate ();
(* Printf.printf "MD5 : %s\n" (Lazy.force Md5.hash) ; *)
@ -192,45 +191,30 @@ let run a d ?q ?s ezfio_filename =
let command () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
set_description_doc "Run a calculation";
[ { short='a' ; long="add" ; opt=Optional ;
doc="Add more resources to a running calculation" ;
arg=Without_arg ; };
{ short='d' ; long="data-server" ; opt=Optional ;
doc="Start a dataserver process on the local host" ;
arg=Without_arg ; };
{ short='q' ; long="local-qmc" ; opt=Optional ;
doc="Start a qmc process on the local host attached to the addres given as an argument" ;
arg=With_arg "<string>" ; };
{ short='s' ; long="remote-qmc" ; opt=Optional ;
doc="Start a qmc process on the remote host as an argument" ;
arg=With_arg "<string>" ; };
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
]
|> set_specs
end;
let a = Command_line.get_bool "add" in
let d = Command_line.get_bool "data-server" in
let q = Command_line.get "local-qmc" in
let s = Command_line.get "remote-qmc" in
let ezfio_file =
match Command_line.anon_args () with
| ezfio_file :: [] -> ezfio_file
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
in
run a d ?q ?s ezfio_file
let spec =
let open Command.Spec in
empty
+> flag "a" no_arg
~doc:(" Add more resources to a running calculation.")
+> flag "d" no_arg
~doc:(" Start a dataserver process on the local host.")
+> flag "q" (optional string)
~doc:("<dataserver_addr> Start a qmc process on the local host.")
+> flag "s" (optional string)
~doc:("<host> Start a qmc process on <host>.")
+> anon ("ezfio_file" %: string)
let command =
Command.basic_spec
~summary: "Run a calculation"
~readme:(fun () ->
"
Run QMC=Chem
")
spec
(fun a d q s ezfio_file () -> run a d ?q ?s ezfio_file )

View File

@ -3,21 +3,20 @@ let run ezfio_filename =
Qputils.set_ezfio_filename ezfio_filename;
Status.write Status.Stopping
let command () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
set_description_doc "Stop a running calculation";
[ anonymous "EZFIO_DIR" Mandatory "EZFIO directory" ]
|> set_specs
end;
let ezfio_file =
match Command_line.anon_args () with
| ezfio_file :: [] -> ezfio_file
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
in
let spec =
let open Command.Spec in
empty
+> anon ("ezfio_file" %: string)
run ezfio_file
let command =
Command.basic_spec
~summary: "Stop a running calculation"
~readme:(fun () ->
"
Stop a running calculation
")
spec
(fun ezfio_file () -> run ezfio_file )

View File

@ -1,9 +1,7 @@
open Sexplib.Std
type t =
| One_dimensional of float
| Multidimensional of (float array * int)
[@@deriving sexp]
[@ deriving sexp]
let dimension = function
| One_dimensional _ -> 1

View File

@ -1,4 +1,4 @@
type t [@@deriving sexp]
type t [@@ deriving sexp]
val to_float : ?idx:int -> t -> float
val to_float_array : t -> float array
val of_float : float -> t

View File

@ -20,30 +20,6 @@ let string_of_t t =
in
Printf.sprintf "%2d:%2d:%2d" hour min sec
let string_of_date t =
let year = 1900 + t.Unix.tm_year in
let mon = t.Unix.tm_mon in
let mday = t.Unix.tm_mday in
let sec = t.Unix.tm_sec
and min = t.Unix.tm_min
and hour = t.Unix.tm_hour
in
let month =
match mon with
| 0 -> "Jan" | 1 -> "Feb" | 2 -> "Mar" | 3 -> "Apr"
| 4 -> "May" | 5 -> "Jun" | 6 -> "Jul" | 7 -> "Aug"
| 8 -> "Sep" | 9 -> "Oct" | 10 -> "Nov" | 11 -> "Dec"
| _ -> assert false
in
Printf.sprintf "%2d %3s %4d - %2.2d:%2.2d:%2.2d" mday month year hour min sec
let string_of_now () =
Unix.time ()
|> Unix.localtime
|> string_of_date
let string_of_sec s =
of_sec s
|> string_of_t

View File

@ -1,36 +1,16 @@
let update_command_line () =
let last = (Array.length Sys.argv) - 2 in
Sys.argv.(0) <- Sys.argv.(0) ^ " " ^ Sys.argv.(1);
for i=1 to last do
Sys.argv.(i) <- Sys.argv.(i+1)
done;
Sys.argv.(last+1) <- "--"
open Core
let command =
Command.group ~summary:"QMC=Chem command" [
"debug" , Qmcchem_debug.command ;
"edit" , Qmcchem_edit.command ;
"info" , Qmcchem_info.command ;
"md5" , Qmcchem_md5.command ;
"result", Qmcchem_result.command ;
"run" , Qmcchem_run.command ;
"stop" , Qmcchem_stop.command ;
]
let () =
let open Command_line in
begin
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
set_description_doc "Driver for subcommands.";
set_specs []
end;
if Array.length Sys.argv < 2 then
(Command_line.help (); failwith "Inconsistent command line");
let command = Sys.argv.(1) in
update_command_line ();
Command_line.reset ();
match command with
| "debug" -> let open Qmcchem_debug in command ()
| "edit" -> let open Qmcchem_edit in command ()
| "info" -> let open Qmcchem_info in command ()
| "md5" -> let open Qmcchem_md5 in command ()
| "result" -> let open Qmcchem_result in command ()
| "run" -> let open Qmcchem_run in command ()
| "stop" -> let open Qmcchem_stop in command ()
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
let () =
Command.run command