10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-11-07 14:43:39 +01:00
qmcchem/ocaml/Qputils.ml

72 lines
1.4 KiB
OCaml
Raw Normal View History

2015-12-19 02:35:13 +01:00
let split_re =
Str.regexp " +"
let split s =
2019-07-14 18:50:44 +02:00
String.trim s
2015-12-19 02:35:13 +01:00
|> Str.split split_re
let set_ezfio_filename ezfio_filename =
let () =
2019-07-14 18:50:44 +02:00
if (not (Sys.file_exists ezfio_filename)) then
failwith (ezfio_filename^" does not exist")
in
let () =
2019-07-23 17:27:02 +02:00
if Sys.file_exists ezfio_filename && Sys.is_directory ezfio_filename then
2019-07-14 18:50:44 +02:00
Ezfio.set_file ezfio_filename
else
failwith ("Error : "^ezfio_filename^" is not a directory")
in
let dir, result =
2019-07-14 18:50:44 +02:00
Filename.dirname ezfio_filename,
Filename.basename ezfio_filename
in
Unix.chdir dir ;
Ezfio.set_file result
2015-12-19 02:35:13 +01:00
let ezfio_filename = lazy (
let f =
!Ezfio.ezfio_filename
in
let full_path =
match f with
| "EZFIO_File" ->
2015-12-19 02:35:13 +01:00
begin
2019-07-23 17:27:02 +02:00
let args =
Command_line.anon_args ()
|> Array.of_list
in
if (Array.length args < 1) then
2015-12-19 02:35:13 +01:00
failwith "Error : EZFIO directory not specified on the command line\n";
2019-07-23 17:27:02 +02:00
args.(0)
2015-12-19 02:35:13 +01:00
end
| f -> f
2015-12-19 02:35:13 +01:00
in
set_ezfio_filename full_path;
2019-07-23 17:27:02 +02:00
!Ezfio.ezfio_filename
2015-12-19 02:35:13 +01:00
)
let elec_num = lazy (
Ezfio.set_file (Lazy.force ezfio_filename);
Ezfio.get_electrons_elec_alpha_num () +
Ezfio.get_electrons_elec_beta_num ()
)
let walk_num = lazy (
Ezfio.set_file (Lazy.force ezfio_filename);
Ezfio.get_electrons_elec_walk_num ()
)
let warn msg =
Printf.printf "Warning : %s\n%!" msg
let () =
Random.self_init ()