10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-11-12 17:13: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 Qptypes;;
open Core
open Qptypes
type t =
{ property : Property.t ;

View File

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

View File

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

View File

@ -1,4 +1,4 @@
open Core.Std;;
open Core
type t =
| 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. *)
let input_directory = lazy (

View File

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

View File

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

View File

@ -1,4 +1,4 @@
open Core.Std
open Core
open Qptypes
(** Data server of QMC=Chem.
@ -36,7 +36,7 @@ let run ?(daemon=true) ezfio_filename =
begin
Printf.printf "Generating initial walkers...\n%!";
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 ;
Printf.printf "Initial walkers ready\n%!"
end ;

View File

@ -1,4 +1,4 @@
open Core.Std
open Core
let run ~t ezfio_filename=
@ -49,7 +49,7 @@ let run ~t ezfio_filename=
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.)
Time.pause (Time.Span.of_sec 1.)
done
end
else

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
open Core.Std
open Core
open Qptypes
(** 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 "Centered k3 = %16.10f\n" cum.(2);
Printf.printf "Centered k4 = %16.10f\n" cum.(3);
print_newline ();
Printf.printf "\n%!";
let n = 1. /. 12. *. cum.(2) *. cum.(2) +.
1. /. 48. *. cum.(3) *. cum.(3)
in

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
open Core.Std
open Core
type t =
| One_dimensional of float
| Multidimensional of (float array * int)
with sexp
[@ deriving sexp]
let dimension = function
| 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_array : t -> float array
val of_float : float -> t

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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