10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-11-09 07:33:39 +01:00
qmcchem/ocaml/Qmcchem_debug.ml
Anthony Scemama c56c3ea851 Smaller time step errors
- Implemented SRMC and DMC
- Using (E_new+E_old)/2 in DMC weight reduces time step errors
- Branching weight is present in E_loc accumulation
- Introduces Error in Message.ml
2016-01-18 20:17:37 +01:00

85 lines
1.9 KiB
OCaml

open Core.Std
let run ~t ezfio_filename=
Qputils.set_ezfio_filename ezfio_filename;
if (not (Ezfio.has_simulation_http_server ())) then
failwith "QMC=Chem is not running"
;
let zmq_context =
ZMQ.Context.create ()
in
Printf.printf "Debugging %s\n%!" ezfio_filename;
let socket =
ZMQ.Socket.create zmq_context ZMQ.Socket.sub
in
let address =
match (Ezfio.get_simulation_http_server ()
|> String.rsplit2 ~on:':' )
with
| Some (a,p) -> a^":"^( (Int.of_string p)+4 |> Int.to_string )
| None -> failwith "Badly formed address"
in
ZMQ.Socket.connect socket address;
ZMQ.Socket.subscribe socket "";
if t then
begin
let re_split =
Str.regexp " *: *"
in
let tot_size =
ref (Byte_units.create `Bytes 0.)
in
while true
do
let msg =
ZMQ.Socket.recv socket
in
let (socket, bytes) =
match Str.split re_split msg with
| socket :: bytes :: _ ->
(socket, Byte_units.create `Bytes (Float.of_string bytes))
| _ -> (print_endline msg ; ("", Byte_units.create `Bytes 0.))
in
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_float 1.)
done
end
else
begin
while true
do
let msg =
ZMQ.Socket.recv socket
in
Printf.printf "%s\n%!" msg;
done
end
let spec =
let open Command.Spec in
empty
+> flag "t" no_arg
~doc:"Measure the throughput"
+> anon ("ezfio_file" %: string)
let command =
Command.basic
~summary: "Debug ZeroMQ communications"
~readme:(fun () -> "Gets debug information from the ZMQ debug sockets.")
spec
(fun t ezfio_file () -> run t ezfio_file)