From eec834be961c8e5696ea160554755f647a2a3206 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 16 Apr 2016 21:18:38 +0200 Subject: [PATCH] Print mask --- configure | 7 ++- ocaml/qp_set_mo_class.ml | 60 ++++++++++++++++++++++---- scripts/compilation/qp_create_ninja.py | 2 +- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/configure b/configure index b217cbea..c3a22683 100755 --- a/configure +++ b/configure @@ -46,7 +46,12 @@ if len(sys.argv) != 3: # \_| |_ (_) |_) (_| | | | | | (_) # -QP_ROOT = os.getcwd() +try: + QP_ROOT = os.environ["QP_ROOT"] +except KeyError: + QP_ROOT = os.getcwd() + os.environ["QP_ROOT"] = QP_ROOT + QP_ROOT_BIN = join(QP_ROOT, "bin") QP_ROOT_LIB = join(QP_ROOT, "lib") QP_ROOT_INSTALL = join(QP_ROOT, "install") diff --git a/ocaml/qp_set_mo_class.ml b/ocaml/qp_set_mo_class.ml index f5555c9c..aaf11422 100644 --- a/ocaml/qp_set_mo_class.ml +++ b/ocaml/qp_set_mo_class.ml @@ -49,20 +49,20 @@ let t_to_string = function | None -> assert false ;; -let run ?(core="[]") ?(inact="[]") ?(act="[]") ?(virt="[]") ?(del="[]") ezfio_filename = +let set ~core ~inact ~act ~virt ~del = - Ezfio.set_file ezfio_filename ; - if not (Ezfio.has_mo_basis_mo_tot_num ()) then - failwith "mo_basis/mo_tot_num not found" ; - - let mo_tot_num = Ezfio.get_mo_basis_mo_tot_num () in + let mo_tot_num = + Ezfio.get_mo_basis_mo_tot_num () + in let n_int = try N_int_number.of_int (Ezfio.get_determinants_n_int ()) with _ -> Bitlist.n_int_of_mo_tot_num mo_tot_num in - let mo_class = Array.init mo_tot_num ~f:(fun i -> None) in + let mo_class = + Array.init mo_tot_num ~f:(fun i -> None) + in (* Check input data *) let apply_class l = @@ -196,6 +196,49 @@ let run ?(core="[]") ?(inact="[]") ?(act="[]") ?(virt="[]") ?(del="[]") ezfio_fi |> Ezfio.set_bitmasks_cas; ;; +let get () = + + let mo_tot_num = + Ezfio.get_mo_basis_mo_tot_num () + in + let n_int = + try N_int_number.of_int (Ezfio.get_determinants_n_int ()) + with _ -> Bitlist.n_int_of_mo_tot_num mo_tot_num + in + + let bitmasks = + match Input.Bitmasks.read () with + | Some x -> x + | None -> failwith "No data to print" + in + assert (bitmasks.Input.Bitmasks.n_mask_gen |> Bitmask_number.to_int = 1); + assert (bitmasks.Input.Bitmasks.n_mask_cas |> Bitmask_number.to_int = 1); + + let (generators,cas) = + Bitlist.of_int64_array bitmasks.Input.Bitmasks.generators, + Bitlist.of_int64_array bitmasks.Input.Bitmasks.cas + in + + Printf.printf "MO : %d\n" mo_tot_num; + Printf.printf "n_int: %d\n" (N_int_number.to_int n_int); + Printf.printf "Gen : %s\nCAS : %s\n" + (Bitlist.to_string generators) + (Bitlist.to_string cas) + +;; + +let run ~print ?(core="[]") ?(inact="[]") ?(act="[]") ?(virt="[]") ?(del="[]") ezfio_filename = + + Ezfio.set_file ezfio_filename ; + if not (Ezfio.has_mo_basis_mo_tot_num ()) then + failwith "mo_basis/mo_tot_num not found" ; + + if print then + get () + else + set ~core ~inact ~act ~virt ~del +;; + let ezfio_file = let failure filename = eprintf "'%s' is not an EZFIO file.\n%!" filename; @@ -240,6 +283,7 @@ let spec = +> flag "act" (optional string) ~doc:"range Range of active orbitals" +> flag "virt" (optional string) ~doc:"range Range of virtual orbitals" +> flag "del" (optional string) ~doc:"range Range of deleted orbitals" + +> flag "print" no_arg ~doc:" Print the current masks" +> anon ("ezfio_filename" %: ezfio_file) ;; @@ -251,7 +295,7 @@ let command = The range of MOs has the form : \"[36-53,72-107,126-131]\" ") spec - (fun core inact act virt del ezfio_filename () -> run ?core ?inact ?act ?virt ?del ezfio_filename ) + (fun core inact act virt del print ezfio_filename () -> run ~print ?core ?inact ?act ?virt ?del ezfio_filename ) ;; let () = diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index d089e76b..adcfb6f7 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -184,7 +184,7 @@ def ninja_ezfio_config_rule(): def get_children_of_ezfio_cfg(l_module_with_ezfio_cfg): """ - From a module list of ezfio_cfg return all the stuff create by him + From a module list of ezfio_cfg return all the stuff created by it """ config_folder = join(QP_EZFIO, "config")