10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-11-07 06:33:38 +01:00

Update for OCaml 4.04

This commit is contained in:
Anthony Scemama 2017-10-10 09:39:58 +02:00
parent 9d186b3759
commit 8f978d95c2
26 changed files with 57 additions and 55 deletions

View File

@ -1,5 +1,5 @@
open Core.Std;; open Core
open Qptypes;; open Qptypes
type t = type t =
{ property : Property.t ; { property : Property.t ;

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
let simulation_nucl_fitcusp_factor = lazy( let simulation_nucl_fitcusp_factor = lazy(

View File

@ -1,4 +1,4 @@
open Core.Std open Core
open Qptypes open Qptypes
open Qputils open Qputils

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
type t = type t =
| Srun | Srun

View File

@ -1,4 +1,4 @@
open Core.Std open Core
(** Directory containing the list of input files. The directory is created is inexistant. *) (** Directory containing the list of input files. The directory is created is inexistant. *)
let input_directory = lazy ( let input_directory = lazy (

View File

@ -1,4 +1,4 @@
open Core.Std open Core
open Qptypes open Qptypes
type t = type t =

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
(** QMC=Chem installation directory *) (** QMC=Chem installation directory *)

View File

@ -1,4 +1,4 @@
open Core.Std open Core
open Qptypes open Qptypes
(** Data server of QMC=Chem. (** Data server of QMC=Chem.
@ -36,7 +36,7 @@ let run ?(daemon=true) ezfio_filename =
begin begin
Printf.printf "Generating initial walkers...\n%!"; Printf.printf "Generating initial walkers...\n%!";
Unix.fork_exec ~prog:(Lazy.force Qmcchem_config.qmc_create_walkers) Unix.fork_exec ~prog:(Lazy.force Qmcchem_config.qmc_create_walkers)
~args:["qmc_create_walkers" ; ezfio_filename] () ~argv:["qmc_create_walkers" ; ezfio_filename] ()
|> Unix.waitpid_exn ; |> Unix.waitpid_exn ;
Printf.printf "Initial walkers ready\n%!" Printf.printf "Initial walkers ready\n%!"
end ; end ;

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let run ~t ezfio_filename= let run ~t ezfio_filename=
@ -49,7 +49,7 @@ let run ~t ezfio_filename=
in in
tot_size := Byte_units.create `Bytes ((Byte_units.bytes !tot_size) +. (Byte_units.bytes bytes)); 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); Printf.printf "%s\n%!" (Byte_units.to_string !tot_size);
Time.pause (Time.Span.of_float 1.) Time.pause (Time.Span.of_sec 1.)
done done
end end
else else

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let file_header filename = Printf.sprintf let file_header filename = Printf.sprintf
" "

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
let bind_socket ~socket_type ~socket ~address = let bind_socket ~socket_type ~socket ~address =
let rec loop = function let rec loop = function
@ -11,7 +11,7 @@ let bind_socket ~socket_type ~socket ~address =
ZMQ.Socket.bind socket address; ZMQ.Socket.bind socket address;
loop (-1) loop (-1)
with with
| Unix.Unix_error _ -> (Time.pause @@ Time.Span.of_float 1. ; loop (i-1) ) | Unix.Unix_error _ -> (Time.pause @@ Time.Span.of_sec 1. ; loop (i-1) )
| other_exception -> raise other_exception | other_exception -> raise other_exception
in loop 10 in loop 10
@ -40,7 +40,7 @@ let run ezfio_filename dataserver =
in in
(* Build qmc executable command *) (* Build qmc executable command *)
let prog, args = let prog, argv =
qmc, qmc,
[ qmc ; ezfio_filename ; [ qmc ; ezfio_filename ;
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm port ]; Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm port ];
@ -57,7 +57,7 @@ let run ezfio_filename dataserver =
| Unix.Unix_error _ -> | Unix.Unix_error _ ->
begin begin
Unix.chdir tmpdir; Unix.chdir tmpdir;
Time.pause @@ Time.Span.of_float 0.1; Time.pause @@ Time.Span.of_sec 0.1;
match (Sys.file_exists "PID") with match (Sys.file_exists "PID") with
| `No | `No
| `Unknown -> () | `Unknown -> ()
@ -75,7 +75,7 @@ let run ezfio_filename dataserver =
begin begin
match Signal.send (Signal.of_system_int 0) (`Pid (Pid.of_int pid)) with match Signal.send (Signal.of_system_int 0) (`Pid (Pid.of_int pid)) with
| `No_such_process -> () | `No_such_process -> ()
| _ -> ignore @@ Unix.exec ~prog ~args () | _ -> ignore @@ Unix.exec ~prog ~argv ()
end end
end end
in in
@ -89,7 +89,7 @@ let run ezfio_filename dataserver =
(* Fork a qmc *) (* Fork a qmc *)
ignore @@ ignore @@
Watchdog.fork_exec ~prog ~args (); Watchdog.fork_exec ~prog ~argv ();
(* If there are MICs, use them here (TODO) *) (* If there are MICs, use them here (TODO) *)

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let run ezfio_filename = let run ezfio_filename =
@ -6,12 +6,12 @@ let run ezfio_filename =
let qmcchem_info = let qmcchem_info =
Lazy.force Qmcchem_config.qmcchem_info Lazy.force Qmcchem_config.qmcchem_info
in in
let prog, args = let prog, argv =
qmcchem_info, qmcchem_info,
[ qmcchem_info ; ezfio_filename ] [ qmcchem_info ; ezfio_filename ]
in in
ignore @@ ignore @@
Unix.exec ~prog ~args () Unix.exec ~prog ~argv ()
let spec = let spec =

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let run ?c ?d ~l ~update ezfio_filename = let run ?c ?d ~l ~update ezfio_filename =

View File

@ -1,4 +1,4 @@
open Core.Std open Core
open Qptypes open Qptypes
(** Display a table that can be plotted by gnuplot *) (** Display a table that can be plotted by gnuplot *)
@ -65,7 +65,7 @@ let display_cumulants ~range property =
Printf.printf "Variance = %16.10f\n" cum.(1); Printf.printf "Variance = %16.10f\n" cum.(1);
Printf.printf "Centered k3 = %16.10f\n" cum.(2); Printf.printf "Centered k3 = %16.10f\n" cum.(2);
Printf.printf "Centered k4 = %16.10f\n" cum.(3); Printf.printf "Centered k4 = %16.10f\n" cum.(3);
print_newline (); Printf.printf "\n%!";
let n = 1. /. 12. *. cum.(2) *. cum.(2) +. let n = 1. /. 12. *. cum.(2) *. cum.(2) +.
1. /. 48. *. cum.(3) *. cum.(3) 1. /. 48. *. cum.(3) *. cum.(3)
in in

View File

@ -1,4 +1,4 @@
open Core.Std 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 *)
@ -36,13 +36,13 @@ let full_run ?(start_dataserver=true) ezfio_filename =
(* Start the data server *) (* Start the data server *)
let prog, args = let prog, argv =
qmcchem, [ qmcchem; "run" ; "-d" ; ezfio_filename] qmcchem, [ qmcchem; "run" ; "-d" ; ezfio_filename]
in in
let pid_dataserver = let pid_dataserver =
Watchdog.fork_exec ~prog ~args () Watchdog.fork_exec ~prog ~argv ()
in in
Printf.printf "%7d : %s\n%!" (Pid.to_int pid_dataserver) (String.concat ~sep:" " args) Printf.printf "%7d : %s\n%!" (Pid.to_int pid_dataserver) (String.concat ~sep:" " argv)
end; end;
@ -83,7 +83,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_float 0.5); Time.pause (Time.Span.of_sec 0.5);
count (n-1); count (n-1);
end end
else else
@ -94,7 +94,7 @@ let full_run ?(start_dataserver=true) ezfio_filename =
(* Start the qmc processes *) (* Start the qmc processes *)
let prog, args = let prog, argv =
let launcher = let launcher =
Launcher.(find () |> to_string) Launcher.(find () |> to_string)
in in
@ -110,12 +110,12 @@ let full_run ?(start_dataserver=true) ezfio_filename =
in in
let pid_qmc = let pid_qmc =
try try
Watchdog.fork_exec ~prog ~args () Watchdog.fork_exec ~prog ~argv ()
with with
| Unix.Unix_error _ -> | Unix.Unix_error _ ->
begin begin
let command = let command =
String.concat ~sep:" " args String.concat ~sep:" " argv
in in
Printf.printf " Printf.printf "
============================================================ ============================================================
@ -126,7 +126,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:" " args); Printf.printf "%7d : %s\n%!" (Pid.to_int pid_qmc) (String.concat ~sep:" " argv);
(* Wait for processes to finish *) (* Wait for processes to finish *)
Watchdog.join () Watchdog.join ()

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let run ezfio_filename = let run ezfio_filename =

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let split_re = let split_re =
Str.regexp " +" Str.regexp " +"

View File

@ -1,4 +1,4 @@
open Core.Std open Core
open Qptypes open Qptypes
type t = type t =
@ -64,7 +64,7 @@ end = struct
(x -. mu) *. ( x -. mu) /. sigma2 (x -. mu) *. ( x -. mu) /. sigma2
in in
let pi = let pi =
acos (-1.) Float.acos (-1.)
in in
let c = let c =
1. /. (sqrt (sigma2 *. (pi +. pi))) 1. /. (sqrt (sigma2 *. (pi +. pi)))

View File

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

View File

@ -1,4 +1,6 @@
type t with sexp open Core
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

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
type t = type t =
| SGE | SGE

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
let _list = ref [] ;; let _list = ref [] ;;
let _running = ref false;; let _running = ref false;;
@ -90,9 +90,9 @@ let del pid =
;; ;;
(** Fork and exec a new process *) (** Fork and exec a new process *)
let fork_exec ~prog ~args () = let fork_exec ~prog ~argv () =
let pid = let pid =
Unix.fork_exec ~prog ~args () Unix.fork_exec ~prog ~argv ()
in in
let f () = let f () =

View File

@ -1,7 +1,7 @@
MAIN=qmcchem MAIN=qmcchem
# Main program to build # Main program to build
PACKAGES=-package core,cryptokit,str,ZMQ,sexplib.syntax PACKAGES=-package core,cryptokit,str,ZMQ
#,ppx_sexp_conv #,ppx_sexp_conv
# Required opam packages, for example: # Required opam packages, for example:
# PACKAGES=-package core,sexplib.syntax # PACKAGES=-package core,sexplib.syntax
@ -10,7 +10,7 @@ THREAD=-thread
# If you need threding support, use: # If you need threding support, use:
# THREAD=-thread # THREAD=-thread
SYNTAX=-syntax camlp4o SYNTAX=
# If you need pre-processing, use: # If you need pre-processing, use:
# SYNTAX=-syntax camlp4o # SYNTAX=-syntax camlp4o

View File

@ -196,7 +196,7 @@ MAIN=
PACKAGES= PACKAGES=
# Required opam packages, for example: # Required opam packages, for example:
# PACKAGES=-package core,sexplib.syntax # PACKAGES=-package core
THREAD= THREAD=
# If you need threding support, use: # If you need threding support, use:

View File

@ -1,4 +1,4 @@
open Core.Std open Core
let command = let command =

View File

@ -1,4 +1,4 @@
open Core.Std;; open Core
let input_data = " let input_data = "
* Positive_float : float * Positive_float : float
@ -156,12 +156,12 @@ let untouched = "
let template = format_of_string " let template = format_of_string "
module %s : sig module %s : sig
type t with sexp type t [@@ deriving sexp]
val to_%s : t -> %s val to_%s : t -> %s
val of_%s : %s %s -> t val of_%s : %s %s -> t
val to_string : t -> string val to_string : t -> string
end = struct end = struct
type t = %s with sexp type t = %s [@@ deriving sexp]
let to_%s x = x let to_%s x = x
let of_%s %s x = ( %s x ) let of_%s %s x = ( %s x )
let to_string x = %s.to_string x let to_string x = %s.to_string x
@ -199,13 +199,13 @@ let parse_input input=
let ezfio_template = format_of_string " let ezfio_template = format_of_string "
module %s : sig module %s : sig
type t with sexp type t [@@ deriving sexp]
val to_%s : t -> %s val to_%s : t -> %s
val get_max : unit -> %s val get_max : unit -> %s
val of_%s : ?min:%s -> ?max:%s -> %s -> t val of_%s : ?min:%s -> ?max:%s -> %s -> t
val to_string : t -> string val to_string : t -> string
end = struct end = struct
type t = %s with sexp type t = %s [@@ deriving sexp]
let to_string x = %s.to_string x let to_string x = %s.to_string x
let get_max () = let get_max () =
if (Ezfio.has_%s ()) then if (Ezfio.has_%s ()) then
@ -312,7 +312,7 @@ match msg with " ] @
let () = let () =
let input = let input =
String.concat ~sep:"\n" String.concat ~sep:"\n"
[ "open Core.Std\nlet warning = print_string\n\n" ; [ "open Core\nlet warning = print_string\n\n" ;
parse_input input_data ; parse_input input_data ;
parse_input_ezfio input_ezfio ; parse_input_ezfio input_ezfio ;
create_ezfio_handler (); create_ezfio_handler ();