mirror of
https://gitlab.com/scemama/qmcchem.git
synced 2024-08-29 22:33:41 +02:00
Removing core
This commit is contained in:
parent
a13410d277
commit
b14fe1dc34
@ -19,7 +19,7 @@ let run ~t ezfio_filename=
|
|||||||
match (Ezfio.get_simulation_http_server ()
|
match (Ezfio.get_simulation_http_server ()
|
||||||
|> String_ext.rsplit2 ~on:':' )
|
|> String_ext.rsplit2 ~on:':' )
|
||||||
with
|
with
|
||||||
| Some (a,p) -> a^":"^( (Int.of_string p)+4 |> Int.to_string )
|
| Some (a,p) -> a^":"^( (int_of_string p)+4 |> string_of_int )
|
||||||
| None -> failwith "Badly formed address"
|
| None -> failwith "Badly formed address"
|
||||||
in
|
in
|
||||||
Zmq.Socket.connect socket address;
|
Zmq.Socket.connect socket address;
|
||||||
@ -31,7 +31,7 @@ let run ~t ezfio_filename=
|
|||||||
Str.regexp " *: *"
|
Str.regexp " *: *"
|
||||||
in
|
in
|
||||||
let tot_size =
|
let tot_size =
|
||||||
ref (Byte_units.create `Bytes 0.)
|
ref 0.
|
||||||
in
|
in
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
@ -41,12 +41,12 @@ let run ~t ezfio_filename=
|
|||||||
let (socket, bytes) =
|
let (socket, bytes) =
|
||||||
match Str.split re_split msg with
|
match Str.split re_split msg with
|
||||||
| socket :: bytes :: _ ->
|
| socket :: bytes :: _ ->
|
||||||
(socket, Byte_units.create `Bytes (Float.of_string bytes))
|
(socket, float_of_string bytes)
|
||||||
| _ -> (print_endline msg ; ("", Byte_units.create `Bytes 0.))
|
| _ -> (print_endline msg ; ("", 0.))
|
||||||
in
|
in
|
||||||
tot_size := Byte_units.create `Bytes ((Byte_units.bytes !tot_size) +. (Byte_units.bytes bytes));
|
tot_size := !tot_size +. bytes;
|
||||||
Printf.printf "%s\n%!" (Byte_units.to_string !tot_size);
|
Printf.printf "%f\n%!" !tot_size;
|
||||||
Time.pause (Time.Span.of_sec 1.)
|
Unix.sleep 1
|
||||||
done
|
done
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -62,20 +62,29 @@ let run ~t ezfio_filename=
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
let spec =
|
let () =
|
||||||
let open Command.Spec in
|
let open Command_line in
|
||||||
empty
|
begin
|
||||||
+> flag "t" no_arg
|
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
|
||||||
~doc:"Measure the throughput"
|
set_description_doc "Debug ZeroMQ communications";
|
||||||
+> anon ("ezfio_file" %: string)
|
[ { 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 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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,22 +10,22 @@ let run ezfio_filename =
|
|||||||
[| qmcchem_info ; ezfio_filename |]
|
[| qmcchem_info ; ezfio_filename |]
|
||||||
in
|
in
|
||||||
ignore @@
|
ignore @@
|
||||||
Unix.exec prog argv
|
Unix.execv prog argv
|
||||||
|
|
||||||
|
let () =
|
||||||
|
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 spec =
|
let ezfio_file =
|
||||||
let open Command.Spec in
|
match Command_line.anon_args () with
|
||||||
empty
|
| ezfio_file :: [] -> ezfio_file
|
||||||
+> anon ("ezfio_file" %: string)
|
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
|
||||||
|
in
|
||||||
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
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ let run ?c ?d ~l ~update ezfio_filename =
|
|||||||
String.concat "/" [ ezfio_filename; "input"; old_key ]
|
String.concat "/" [ ezfio_filename; "input"; old_key ]
|
||||||
in
|
in
|
||||||
Printf.printf "Removing %s\n%!" old_name;
|
Printf.printf "Removing %s\n%!" old_name;
|
||||||
try Sys.unlink old_name with
|
try Sys.remove old_name with
|
||||||
| Sys_error _ -> ();
|
| Sys_error _ -> ();
|
||||||
end
|
end
|
||||||
in
|
in
|
||||||
@ -87,11 +87,10 @@ let run ?c ?d ~l ~update ezfio_filename =
|
|||||||
else
|
else
|
||||||
""
|
""
|
||||||
in
|
in
|
||||||
let date =
|
let date =
|
||||||
(Unix.stat filename).Unix.st_mtime
|
let open Unix in
|
||||||
in
|
localtime (stat filename).st_mtime
|
||||||
let date =
|
|> Time.string_of_date
|
||||||
Unix.strftime (Unix.localtime date) "%a, %d %b %Y %T %z"
|
|
||||||
in
|
in
|
||||||
Printf.printf "%s : %s %s\n" md5 date this)
|
Printf.printf "%s : %s %s\n" md5 date this)
|
||||||
in
|
in
|
||||||
@ -153,6 +152,12 @@ let () =
|
|||||||
let d = Command_line.get "diff" in
|
let d = Command_line.get "diff" in
|
||||||
let l = Command_line.get_bool "list" 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
|
run ?c ?d ~l ~update ezfio_file
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
open Core
|
|
||||||
|
|
||||||
let full_run ?(start_dataserver=true) ezfio_filename =
|
let full_run ?(start_dataserver=true) ezfio_filename =
|
||||||
(* Identify the job scheduler *)
|
(* Identify the job scheduler *)
|
||||||
@ -39,13 +38,13 @@ let full_run ?(start_dataserver=true) ezfio_filename =
|
|||||||
|
|
||||||
|
|
||||||
(* Start the data server *)
|
(* Start the data server *)
|
||||||
let prog, argv =
|
let prog, args =
|
||||||
qmcchem, [ qmcchem; "run" ; "-d" ; ezfio_filename]
|
qmcchem, [| qmcchem; "run" ; "-d" ; ezfio_filename |]
|
||||||
in
|
in
|
||||||
let pid_dataserver =
|
let pid_dataserver =
|
||||||
Watchdog.fork_exec ~prog ~argv ()
|
Watchdog.fork_exec ~prog ~args ()
|
||||||
in
|
in
|
||||||
Printf.printf "%7d : %s\n%!" (Pid.to_int pid_dataserver) (String.concat ~sep:" " argv)
|
Printf.printf "%7d : %s\n%!" pid_dataserver (String.concat " " (Array.to_list args))
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ let full_run ?(start_dataserver=true) ezfio_filename =
|
|||||||
| n ->
|
| n ->
|
||||||
if (not (test_open_rep_socket ())) then
|
if (not (test_open_rep_socket ())) then
|
||||||
begin
|
begin
|
||||||
Time.pause (Time.Span.of_sec 0.5);
|
Unix.sleepf 0.5;
|
||||||
count (n-1);
|
count (n-1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -96,32 +95,33 @@ let full_run ?(start_dataserver=true) ezfio_filename =
|
|||||||
if (not (count 300)) then
|
if (not (count 300)) then
|
||||||
Watchdog.kill ();
|
Watchdog.kill ();
|
||||||
*)
|
*)
|
||||||
Time.pause (Time.Span.of_sec 3.);
|
Unix.sleep 3;
|
||||||
|
|
||||||
|
|
||||||
(* Start the qmc processes *)
|
(* Start the qmc processes *)
|
||||||
let prog, argv =
|
let prog, args_list =
|
||||||
let launcher =
|
let launcher =
|
||||||
Launcher.(find () |> to_string)
|
Launcher.(find () |> to_string)
|
||||||
in
|
in
|
||||||
match launcher
|
match launcher
|
||||||
|> String.split ~on:' '
|
|> String.split_on_char ' '
|
||||||
|> List.map ~f:String.strip
|
|> List.map String.trim
|
||||||
|> List.filter ~f:(fun x -> x <> "")
|
|> List.filter (fun x -> x <> "")
|
||||||
with
|
with
|
||||||
| launcher_exe::launcher_flags ->
|
| launcher_exe::launcher_flags ->
|
||||||
launcher_exe, launcher_exe :: launcher_flags @ qmc @ [
|
launcher_exe, launcher_exe :: launcher_flags @ qmc @ [
|
||||||
Ezfio.get_simulation_http_server () ; ezfio_filename ]
|
Ezfio.get_simulation_http_server () ; ezfio_filename ]
|
||||||
| _ -> failwith "Error in launcher"
|
| _ -> failwith "Error in launcher"
|
||||||
in
|
in
|
||||||
|
let args = Array.of_list args_list in
|
||||||
let pid_qmc =
|
let pid_qmc =
|
||||||
try
|
try
|
||||||
Watchdog.fork_exec ~prog ~argv ()
|
Watchdog.fork_exec ~prog ~args ()
|
||||||
with
|
with
|
||||||
| Unix.Unix_error _ ->
|
| Unix.Unix_error _ ->
|
||||||
begin
|
begin
|
||||||
let command =
|
let command =
|
||||||
String.concat ~sep:" " argv
|
String.concat " " args_list
|
||||||
in
|
in
|
||||||
Printf.printf "
|
Printf.printf "
|
||||||
============================================================
|
============================================================
|
||||||
@ -132,7 +132,7 @@ Error: Unable to run the following command
|
|||||||
Watchdog.kill ()
|
Watchdog.kill ()
|
||||||
end
|
end
|
||||||
in
|
in
|
||||||
Printf.printf "%7d : %s\n%!" (Pid.to_int pid_qmc) (String.concat ~sep:" " argv);
|
Printf.printf "%7d : %s\n%!" pid_qmc (String.concat " " args_list);
|
||||||
|
|
||||||
(* Wait for processes to finish *)
|
(* Wait for processes to finish *)
|
||||||
Watchdog.join ()
|
Watchdog.join ()
|
||||||
@ -152,18 +152,19 @@ let run a d ?q ?s ezfio_filename =
|
|||||||
Qputils.set_ezfio_filename ezfio_filename;
|
Qputils.set_ezfio_filename ezfio_filename;
|
||||||
|
|
||||||
(* Signal handler to Kill properly all the processes *)
|
(* Signal handler to Kill properly all the processes *)
|
||||||
let handler s =
|
let handler s =
|
||||||
Printf.printf "QMC=Chem received the %s signal... killing\n%!" (Signal.to_string s);
|
Printf.printf "QMC=Chem received signal %d... killing\n%!" s;
|
||||||
Watchdog.kill ();
|
Watchdog.kill ();
|
||||||
in
|
in
|
||||||
List.iter [
|
List.iter (fun s -> ignore @@ Sys.signal s (Sys.Signal_handle handler))
|
||||||
Signal.int ;
|
[
|
||||||
Signal.term ;
|
Sys.sigint ;
|
||||||
Signal.quit ;
|
Sys.sigterm ;
|
||||||
|
Sys.sigquit ;
|
||||||
]
|
]
|
||||||
~f:(fun x -> Signal.Expert.handle x handler)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
(* Validate input *)
|
(* Validate input *)
|
||||||
Input.validate ();
|
Input.validate ();
|
||||||
(* Printf.printf "MD5 : %s\n" (Lazy.force Md5.hash) ; *)
|
(* Printf.printf "MD5 : %s\n" (Lazy.force Md5.hash) ; *)
|
||||||
@ -191,30 +192,45 @@ let run a d ?q ?s ezfio_filename =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
let spec =
|
let () =
|
||||||
let open Command.Spec in
|
let open Command_line in
|
||||||
empty
|
begin
|
||||||
+> flag "a" no_arg
|
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
|
||||||
~doc:(" Add more resources to a running calculation.")
|
set_description_doc "Run a calculation";
|
||||||
+> flag "d" no_arg
|
|
||||||
~doc:(" Start a dataserver process on the local host.")
|
[ { short='a' ; long="add" ; opt=Optional ;
|
||||||
+> flag "q" (optional string)
|
doc="Add more resources to a running calculation" ;
|
||||||
~doc:("<dataserver_addr> Start a qmc process on the local host.")
|
arg=Without_arg ; };
|
||||||
+> flag "s" (optional string)
|
|
||||||
~doc:("<host> Start a qmc process on <host>.")
|
{ short='d' ; long="data-server" ; opt=Optional ;
|
||||||
+> anon ("ezfio_file" %: string)
|
doc="Start a dataserver process on the local host" ;
|
||||||
|
arg=Without_arg ; };
|
||||||
|
|
||||||
|
{ short='q' ; long="local-qmc" ; opt=Optional ;
|
||||||
let command =
|
doc="Start a qmc process on the local host attached to the addres given as an argument" ;
|
||||||
Command.basic_spec
|
arg=With_arg "<string>" ; };
|
||||||
~summary: "Run a calculation"
|
|
||||||
~readme:(fun () ->
|
{ short='s' ; long="remote-qmc" ; opt=Optional ;
|
||||||
"
|
doc="Start a qmc process on the remote host as an argument" ;
|
||||||
Run QMC=Chem
|
arg=With_arg "<string>" ; };
|
||||||
")
|
|
||||||
spec
|
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
|
||||||
(fun a d q s ezfio_file () -> run a d ?q ?s ezfio_file )
|
]
|
||||||
|
|> 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,20 +3,21 @@ let run ezfio_filename =
|
|||||||
Qputils.set_ezfio_filename ezfio_filename;
|
Qputils.set_ezfio_filename ezfio_filename;
|
||||||
Status.write Status.Stopping
|
Status.write Status.Stopping
|
||||||
|
|
||||||
|
let () =
|
||||||
|
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 spec =
|
let ezfio_file =
|
||||||
let open Command.Spec in
|
match Command_line.anon_args () with
|
||||||
empty
|
| ezfio_file :: [] -> ezfio_file
|
||||||
+> anon ("ezfio_file" %: string)
|
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
|
||||||
|
in
|
||||||
|
|
||||||
let command =
|
run ezfio_file
|
||||||
Command.basic_spec
|
|
||||||
~summary: "Stop a running calculation"
|
|
||||||
~readme:(fun () ->
|
|
||||||
"
|
|
||||||
Stop a running calculation
|
|
||||||
")
|
|
||||||
spec
|
|
||||||
(fun ezfio_file () -> run ezfio_file )
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
open Sexplib.Std
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
| One_dimensional of float
|
| One_dimensional of float
|
||||||
| Multidimensional of (float array * int)
|
| Multidimensional of (float array * int)
|
||||||
[@ deriving sexp]
|
[@@deriving sexp]
|
||||||
|
|
||||||
let dimension = function
|
let dimension = function
|
||||||
| One_dimensional _ -> 1
|
| One_dimensional _ -> 1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
type t [@@ deriving sexp]
|
type t [@@deriving sexp]
|
||||||
val to_float : ?idx:int -> t -> float
|
val to_float : ?idx:int -> t -> float
|
||||||
val to_float_array : t -> float array
|
val to_float_array : t -> float array
|
||||||
val of_float : float -> t
|
val of_float : float -> t
|
||||||
|
@ -20,6 +20,30 @@ let string_of_t t =
|
|||||||
in
|
in
|
||||||
Printf.sprintf "%2d:%2d:%2d" hour min sec
|
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 =
|
let string_of_sec s =
|
||||||
of_sec s
|
of_sec s
|
||||||
|> string_of_t
|
|> string_of_t
|
||||||
|
@ -1,16 +1,39 @@
|
|||||||
open Core
|
let update_command_line () =
|
||||||
|
let last = Array.length Sys.argv - 1 in
|
||||||
|
for i=1 to last do
|
||||||
|
Sys.argv.(i) <- Sys.argv.(i+1)
|
||||||
|
done;
|
||||||
|
Sys.argv.(last) <- "--"
|
||||||
|
|
||||||
|
|
||||||
let command =
|
let () =
|
||||||
Command.group ~summary:"QMC=Chem command" [
|
let open Command_line in
|
||||||
"debug" , Qmcchem_debug.command ;
|
begin
|
||||||
"edit" , Qmcchem_edit.command ;
|
set_header_doc (Sys.argv.(0) ^ " - QMC=Chem command");
|
||||||
"info" , Qmcchem_info.command ;
|
set_description_doc "Driver for subcommands.";
|
||||||
"md5" , Qmcchem_md5.command ;
|
[
|
||||||
"result", Qmcchem_result.command ;
|
anonymous "COMMAND" Mandatory "[debug|edit|info|md5|result|run|stop]";
|
||||||
"run" , Qmcchem_run.command ;
|
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
|
||||||
"stop" , Qmcchem_stop.command ;
|
|
||||||
]
|
]
|
||||||
|
|> set_specs
|
||||||
|
end;
|
||||||
|
|
||||||
|
let command =
|
||||||
|
match Command_line.anon_args () with
|
||||||
|
| command :: ezfio_file :: [] -> command
|
||||||
|
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
|
||||||
|
in
|
||||||
|
|
||||||
|
update_command_line ();
|
||||||
|
|
||||||
|
match command with
|
||||||
|
| "debug" -> let open Qmcchem_debug in ()
|
||||||
|
| "edit" -> let open Qmcchem_edit in ()
|
||||||
|
| "info" -> let open Qmcchem_info in ()
|
||||||
|
| "md5" -> let open Qmcchem_md5 in ()
|
||||||
|
| "result" -> let open Qmcchem_result in ()
|
||||||
|
| "run" -> let open Qmcchem_run in ()
|
||||||
|
| "stop" -> let open Qmcchem_stop in ()
|
||||||
|
| _ -> (Command_line.help () ; failwith "Inconsistent command line")
|
||||||
|
|
||||||
|
|
||||||
let () =
|
|
||||||
Command.run command
|
|
||||||
|
Loading…
Reference in New Issue
Block a user