10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-10-06 16:25:57 +02:00

Compare commits

..

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

25 changed files with 235 additions and 135 deletions

View File

@ -28,7 +28,7 @@ rule compile_ocaml_dep
pool = console
rule compile_ocaml
command = cd ocaml ; make $target
command = cd ocaml ; ninja $target
description = Compiling OCaml tools
pool = console
@ -77,7 +77,7 @@ build ocaml/qmcchem : compile_ocaml | EZFIO/Ocaml/ezfio.ml ocaml/Property.ml
build bin/qmc: copy_to_bin src/MAIN/qmc
build bin/qmcchem_info: copy_to_bin src/MAIN/qmcchem_info
build bin/qmc_create_walkers: copy_to_bin src/MAIN/qmc_create_walkers
build bin/qmcchem: copy_to_bin ocaml/qmcchem
build bin/qmcchem: copy_to_bin ocaml/qmcchem
default bin/qmc bin/qmcchem_info bin/qmc_create_walkers bin/qmcchem

View File

@ -8,12 +8,12 @@ ao_basis
ao_expo real (ao_basis_ao_num,ao_basis_ao_prim_num_max)
mo_basis
mo_num integer
mo_coef real (ao_basis_ao_num,mo_basis_mo_num)
mo_classif character (mo_basis_mo_num)
mo_energy real (mo_basis_mo_num)
mo_occ real (mo_basis_mo_num)
mo_symmetry character*(8) (mo_basis_mo_num)
mo_tot_num integer
mo_coef real (ao_basis_ao_num,mo_basis_mo_tot_num)
mo_classif character (mo_basis_mo_tot_num)
mo_energy real (mo_basis_mo_tot_num)
mo_occ real (mo_basis_mo_tot_num)
mo_symmetry character*(8) (mo_basis_mo_tot_num)
electrons
elec_alpha_num integer

View File

@ -86,7 +86,7 @@ let update_raw_data ?(locked=true) () =
in
let files =
let result =
if Sys.file_exists dir_name && Sys.is_directory dir_name then
if Sys.is_directory dir_name then
begin
Sys.readdir dir_name
|> Array.map (fun x -> dir_name^x)
@ -150,7 +150,7 @@ let raw_data ?(locked=true) () =
let properties = lazy (
let h = Hashtbl.create 63 in
List.iter (fun x ->
Hashtbl.replace h (Property.to_string x.property) x.property)
Hashtbl.add h (Property.to_string x.property) x.property)
(raw_data ());
Hashtbl.fold (fun k v a -> v :: a) h []
)

View File

@ -166,7 +166,7 @@ let help () =
let set_specs ?(no_help=false) specs_in =
let set_specs specs_in =
specs := { short='h' ;
long ="help" ;
doc ="Prints the help message." ;
@ -188,20 +188,11 @@ let set_specs ?(no_help=false) specs_in =
)
in
let cmdline =
Sys.argv
|> Array.to_list
|> List.filter (fun x -> x <> "")
|> Array.of_list
in
Getopt.parse cmd_specs (fun x -> anon_args := !anon_args @ [x])
cmdline 1 (Array.length cmdline -1);
Getopt.parse_cmdline cmd_specs (fun x -> anon_args := !anon_args @ [x]);
if not no_help && (show_help ()) then
if show_help () then
(help () ; exit 0);
(* Check that all mandatory arguments are set *)
List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs
|> List.iter (fun x ->

View File

@ -117,7 +117,7 @@ val help : unit -> unit
(** Sets the specification list as a list of tuples:
( short option, long option, documentation, argument ) *)
val set_specs : ?no_help:bool -> description list -> unit
val set_specs : description list -> unit
(** Returns the list of anonymous arguments *)

View File

@ -788,7 +788,7 @@ end = struct
let doc = "Type of Jastrow factor [ None | Core | Simple ]"
let of_string s =
match String.capitalize_ascii (String.trim s) with
match String.capitalize (String.trim s) with
| "Core" -> Core
| "Simple" -> Simple
| "None" -> None

View File

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

149
ocaml/Md5.ml Normal file
View File

@ -0,0 +1,149 @@
open Core
(** Directory containing the list of input files. The directory is created is inexistant. *)
let input_directory = lazy (
let ezfio_filename =
Lazy.force Qputils.ezfio_filename
in
let dirname =
Filename.concat ezfio_filename "input"
in
begin
match ( Sys.is_directory dirname ) with
| `No -> Unix.mkdir dirname
| _ -> ()
end ;
dirname
)
(** List of files responsible for the MD5 key of the input *)
let files_to_track = [
"ao_basis/ao_coef.gz" ;
"ao_basis/ao_expo.gz" ;
"ao_basis/ao_nucl.gz" ;
"ao_basis/ao_num" ;
"ao_basis/ao_power.gz" ;
"ao_basis/ao_prim_num.gz" ;
"electrons/elec_alpha_num" ;
"electrons/elec_beta_num" ;
"electrons/elec_walk_num" ;
"jastrow/jast_type" ;
"mo_basis/mo_coef.gz" ;
"mo_basis/mo_tot_num" ;
"nuclei/nucl_charge.gz" ;
"nuclei/nucl_coord.gz" ;
"nuclei/nucl_num" ;
"simulation/ci_threshold" ;
"simulation/nucl_fitcusp_factor" ;
"simulation/jast_a_up_dn" ;
"simulation/jast_a_up_up" ;
"simulation/jast_b_up_dn" ;
"simulation/jast_b_up_up" ;
"simulation/jast_core_a1" ;
"simulation/jast_core_a2" ;
"simulation/jast_core_b1" ;
"simulation/jast_core_b2" ;
"simulation/jast_een_e_a.gz" ;
"simulation/jast_een_e_b.gz" ;
"simulation/jast_een_n.gz" ;
"simulation/jast_pen.gz" ;
"simulation/method" ;
"simulation/time_step" ;
"simulation/dmc_projection_time" ;
"spindeterminants/bit_kind" ;
"spindeterminants/n_det" ;
"spindeterminants/n_det_alpha" ;
"spindeterminants/n_det_beta" ;
"spindeterminants/n_int" ;
"spindeterminants/n_states" ;
"spindeterminants/psi_coef_matrix_columns.gz" ;
"spindeterminants/psi_coef_matrix_rows.gz" ;
"spindeterminants/psi_coef_matrix_values.gz" ;
"spindeterminants/psi_det_alpha.gz" ;
"spindeterminants/psi_det_beta.gz" ;
"/pseudo/do_pseudo" ;
"/pseudo/mo_pseudo_grid.gz" ;
"/pseudo/pseudo_dz_kl.gz";
"/pseudo/pseudo_klocmax" ;
"/pseudo/pseudo_n_k.gz" ;
"/pseudo/pseudo_v_kl.gz" ;
"/pseudo/pseudo_grid_rmax" ;
"/pseudo/pseudo_kmax" ;
"/pseudo/pseudo_n_kl.gz" ;
"/pseudo/pseudo_dz_k.gz" ;
"/pseudo/pseudo_grid_size" ;
"/pseudo/pseudo_v_k.gz" ;
]
(** Get an MD5 ke from the content of a file. *)
let hash_file filename =
match Sys.is_file filename with
| `Yes ->
begin
In_channel.with_file filename ~f:(fun ic ->
Cryptokit.hash_channel (Cryptokit.Hash.md5 ()) ic
|> Cryptokit.transform_string (Cryptokit.Hexa.encode ()) )
end
| _ -> ""
(** Cache containing the current value of the MD5 hash. *)
let _hash =
ref None
(** Get the hash correcponding to the EZFIO file. *)
let hash () =
let compute_hash () =
let ezfio_filename =
Lazy.force Qputils.ezfio_filename
in
let old_md5 =
if Ezfio.has_simulation_md5_key () then
Ezfio.get_simulation_md5_key ()
else
""
in
let md5_string =
files_to_track
|> List.map ~f:(fun x -> Printf.sprintf "%s/%s" ezfio_filename x)
|> List.map ~f:hash_file
|> String.concat
in
let new_md5 =
md5_string
|> Cryptokit.hash_string (Cryptokit.Hash.md5 ())
|> Cryptokit.transform_string (Cryptokit.Hexa.encode ())
in
if (new_md5 <> old_md5) then
begin
Printf.eprintf "Info : MD5 key changed\n %s\n-> %s\n%!" old_md5 new_md5 ;
Ezfio.set_simulation_md5_key new_md5
end
;
new_md5
in
match (!_hash) with
| Some key -> key
| None ->
begin
let key =
compute_hash ()
in
_hash := Some key ;
key
end
(** Reset the cache of the MD5 hash. *)
let reset_hash () =
_hash := None;
ignore (hash ())

View File

@ -10,7 +10,7 @@ let input_directory = lazy (
in
begin
if not (Sys.file_exists dirname && Sys.is_directory dirname) then
if not (Sys.is_directory dirname) then
Unix.mkdir dirname 0o777
end ;

View File

@ -36,12 +36,13 @@ let run ?(daemon=true) ezfio_filename =
Printf.printf "Generating initial walkers...\n%!";
match Unix.fork () with
| 0 ->
Unix.execvp
Unix.execv
(Lazy.force Qmcchem_config.qmc_create_walkers)
[|"qmc_create_walkers" ; ezfio_filename|]
| pid ->
begin
ignore @@ Unix.waitpid [] pid;
let pid', status = Unix.waitpid [] pid in
assert (status = Unix.WEXITED 0);
Printf.printf "Initial walkers ready\n%!"
end
end
@ -347,8 +348,8 @@ let run ?(daemon=true) ezfio_filename =
Lazy.force Block.dir_name
in
let () =
if not ( Sys.file_exists dirname && Sys.is_directory dirname ) then
Unix.mkdir dirname 0o755
if not (Sys.is_directory dirname) then
Unix.mkdir dirname 0o600
in
Filename.concat dirname (
hostname ^ "." ^ (string_of_int dataserver_pid)
@ -392,10 +393,7 @@ let run ?(daemon=true) ezfio_filename =
Unix.rename block_channel_filename_locked block_channel_filename_tmp;
Random_variable.compress_files ();
send_log "status" 0 t0 "Compressed block file";
if Sys.file_exists block_channel_filename_locked then
block_channel := open_out_gen [ Open_append ] 0o660 block_channel_filename_locked
else
block_channel := open_out block_channel_filename_locked
block_channel := open_out_gen [ Open_append ] 0o660 block_channel_filename_locked
in

View File

@ -252,12 +252,12 @@ let run ~c ?f ?t ?l ?m ?e ?et ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename =
Filename.concat (Filename.concat ezfio_filename "blocks") (QmcMd5.hash ())
in
let rec clean_dir y =
if Sys.file_exists y && Sys.is_directory y then
if Sys.is_directory y then
begin
Sys.readdir y
|> Array.map (fun x -> Filename.concat y x)
|> Array.iter (function x ->
if Sys.file_exists x && Sys.is_directory x then
if Sys.is_directory x then
clean_dir x
else
Sys.remove x

View File

@ -48,7 +48,7 @@ let run ezfio_filename dataserver =
*)
let () =
try
Unix.mkdir tmpdir 0o755;
Unix.mkdir tmpdir 0o600;
Unix.chdir tmpdir
with
| Unix.Unix_error _ ->
@ -69,7 +69,7 @@ let run ezfio_filename dataserver =
| pid ->
try
Unix.kill pid 0 ;
ignore @@ Unix.execvp prog argv
ignore @@ Unix.execv prog argv
with
| Unix.Unix_error (Unix.ESRCH, _, _) -> ()
end

View File

@ -10,7 +10,7 @@ let run ezfio_filename =
[| qmcchem_info ; ezfio_filename |]
in
ignore @@
Unix.execvp prog argv
Unix.execv prog argv
let command () =
let open Command_line in

View File

@ -224,7 +224,7 @@ let command () =
doc="Display the convergence of the error of the property by merging blocks";
arg=With_arg "<string>"; };
{ short='i' ; long="histogram" ; opt=Optional ;
{ short='h' ; long="histogram" ; opt=Optional ;
doc="Display the histogram of the property blocks" ;
arg=With_arg "<string>"; };

View File

@ -48,6 +48,7 @@ let full_run ?(start_dataserver=true) ezfio_filename =
end;
(*
(* Check if the Zmq Rep socket is open *)
let test_open_rep_socket () =
let zmq_context =
@ -85,7 +86,7 @@ let full_run ?(start_dataserver=true) ezfio_filename =
| n ->
if (not (test_open_rep_socket ())) then
begin
Unix.sleep 2;
Unix.sleepf 0.5;
count (n-1);
end
else
@ -93,6 +94,7 @@ let full_run ?(start_dataserver=true) ezfio_filename =
in
if (not (count 300)) then
Watchdog.kill ();
*)
Unix.sleep 3;

View File

@ -13,7 +13,7 @@ let set_ezfio_filename ezfio_filename =
failwith (ezfio_filename^" does not exist")
in
let () =
if Sys.file_exists ezfio_filename && Sys.is_directory ezfio_filename then
if Sys.is_directory ezfio_filename then
Ezfio.set_file ezfio_filename
else
failwith ("Error : "^ezfio_filename^" is not a directory")
@ -34,30 +34,13 @@ let ezfio_filename = lazy (
match f with
| "EZFIO_File" ->
begin
let args =
Command_line.anon_args ()
|> Array.of_list
in
if (Array.length args < 1) then
if (Array.length Sys.argv = 1) then
failwith "Error : EZFIO directory not specified on the command line\n";
args.(0)
Sys.argv.(1)
end
| f -> f
in
set_ezfio_filename full_path;
(*
(* Check if input directory is present *)
let dirname = Filename.concat full_path "input" in
if not (Sys.file_exists dirname) then
Unix.mkdir dirname 0o755;
(* Check if blocks directory is present *)
let dirname = Filename.concat full_path "blocks" in
if not (Sys.file_exists dirname) then
Unix.mkdir dirname 0o755;
*)
!Ezfio.ezfio_filename
)

View File

@ -681,15 +681,14 @@ let compress_files () =
let out_channel_dir =
let rand_num = Random.int 1000000 |> string_of_int in
let tmp_dir =
Filename.concat !Ezfio.ezfio_filename @@
Filename.concat "blocks" "qmc"^rand_num
Filename.concat "!Ezfio.ezfio_filename" @@
Filename.concat "blocks" @@
Filename.concat "qmc" rand_num
in
try
Unix.mkdir tmp_dir 0o755;
Unix.mkdir tmp_dir 0o600;
tmp_dir
with _ ->
let message = Printf.sprintf "Cannot create temp dir %s" tmp_dir in
raise (Sys_error message)
with _ -> raise (Sys_error "Cannot create temp dir")
in
let out_channel_name =

View File

@ -10,15 +10,15 @@ let to_sec t =
sec +
min * 60 +
hour * 60 * 60 +
(mday-1) * 60 * 60 * 24
mday * 60 * 60 * 24
let string_of_t t =
let mday = t.Unix.tm_mday - 1 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 + 24*mday
in
Printf.sprintf "%2d:%2.2d:%2.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
@ -35,7 +35,7 @@ let string_of_date t =
| 8 -> "Sep" | 9 -> "Oct" | 10 -> "Nov" | 11 -> "Dec"
| _ -> assert false
in
Printf.sprintf "%2d %3s %4d - %2d:%2.2d:%2.2d" mday month year hour min sec
Printf.sprintf "%2d %3s %4d - %2.2d:%2.2d:%2.2d" mday month year hour min sec
let string_of_now () =

View File

@ -1,16 +1,16 @@
let _list = ref []
let _running = ref false
let _threads = ref []
let _list = ref [] ;;
let _running = ref false;;
let _threads = ref [] ;;
(** Kill the current process and all children *)
let kill () =
let kill pid =
Unix.kill pid Sys.sigkill;
Unix.kill pid Sys.sigint;
Printf.printf "Killed %d\n%!" pid
in
List.iter kill (!_list);
exit 1
;;
(** Start watchdog *)
@ -50,7 +50,7 @@ let start () =
in
_threads := ( (Thread.create f) () ) :: (!_threads)
end
;;
(** Stop watchdog *)
let stop () =
@ -58,14 +58,14 @@ let stop () =
_running := false
else
failwith "Watchdog error: Already stopped"
;;
(** Add a PID to tracking *)
let add pid =
if (not !_running) then
start ();
_list := pid :: (!_list)
;;
(** Remove a PID from tracking *)
let del pid =
@ -82,13 +82,14 @@ let del pid =
match (!_list) with
| [] -> if (!_running) then stop ()
| _ -> ()
;;
(** Fork and exec a new process *)
let fork_exec ~prog ~args () =
let pid =
match Unix.fork () with
| 0 -> Unix.execvp prog args
| 0 -> (* Chile process *)
let _ = Unix.execv prog args in 0
| pid -> pid
in
@ -110,11 +111,11 @@ let fork_exec ~prog ~args () =
in
_threads := ( (Thread.create f) () ) :: (!_threads);
pid
;;
(** Wait for threads to finish *)
let join () =
(* if (!_running) then stop (); *)
List.iter Thread.join (!_threads);
assert (not !_running)
;;

View File

@ -1,60 +1,36 @@
let update_command_line () =
let last = (Array.length Sys.argv) - 2 in
Sys.argv.(0) <- Sys.argv.(0) ^ "_" ^ Sys.argv.(1);
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) <- ""
Sys.argv.(last+1) <- "--"
let help () =
Printf.printf "
qmcchem - QMC=Chem command
Usage:
qmcchem [-h] COMMAND
Arguments:
COMMAND QMC=Chem command to run :
[run|edit|stop|result|md5|info|debug]
Options:
-h --help Prints the help message.
Description:
Driver for subcommands.
"
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
(help (); failwith "Inconsistent command line") ;
match String.trim Sys.argv.(1) with
| "-h" | "--help" ->
begin
help () ;
exit 0
end
| _ ->
begin
let command =
Sys.argv.(1)
in
update_command_line ();
(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")
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 ()
| _ -> (help () ; failwith "Inconsistent command line")
end

View File

@ -296,7 +296,7 @@ let input_lines filename =
let create_ezfio_handler () =
let lines =
input_lines "ezfio.ml"
|> List.mapi (fun i l -> if i > 474 then Some l else None)
|> List.mapi (fun i l -> if i > 470 then Some l else None)
|> List.filter (fun x -> x <> None)
|> List.map (fun x ->
match x with

View File

@ -1,7 +1,7 @@
#!/bin/bash
# This script is supposed to run in $QMCCHEM_PATH
make -C ocaml clean
ninja -C ocaml clean
if [[ -d src/IRPF90_temp ]]
then
ninja -C src/IRPF90_temp -t clean

View File

@ -8,4 +8,4 @@ fi
cd ${QMCCHEM_PATH}/ocaml || exit -1
exec make
exec ninja -f generated.ninja ${@} || exit -1

View File

@ -52,7 +52,7 @@ data = [ \
]
data_no_set = [\
("mo_basis_mo_num" , "integer" , ""),
("mo_basis_mo_tot_num" , "integer" , ""),
("pseudo_ao_pseudo_grid" , "double precision" , "(ao_num,pseudo_lmax+pseudo_lmax+1,pseudo_lmax-0+1,nucl_num,pseudo_grid_size)"),
("pseudo_mo_pseudo_grid" , "double precision" , "(ao_num,pseudo_lmax+pseudo_lmax+1,pseudo_lmax-0+1,nucl_num,pseudo_grid_size)"),
("pseudo_pseudo_dz_k" , "double precision" , "(nucl_num,pseudo_klocmax)"),

View File

@ -410,7 +410,7 @@ BEGIN_PROVIDER [ integer, mo_tot_num ]
END_DOC
mo_tot_num = -1
call get_mo_basis_mo_num(mo_tot_num)
call get_mo_basis_mo_tot_num(mo_tot_num)
if (mo_tot_num <= 0) then
call abrt(irp_here,'Total number of MOs can''t be <0')
endif