From 39a8d4101f944ae02b366539ec44a1263fada50d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 31 Oct 2014 22:21:38 +0100 Subject: [PATCH] Added read rst for Full-CI/Hartree-Fock.ml --- ocaml/Input_full_ci.ml | 18 ++++++++++++++++++ ocaml/test_input.ml | 9 ++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ocaml/Input_full_ci.ml b/ocaml/Input_full_ci.ml index abe4e959..516ca0cf 100644 --- a/ocaml/Input_full_ci.ml +++ b/ocaml/Input_full_ci.ml @@ -12,6 +12,7 @@ module Full_ci : sig val read : unit -> t val to_string : t -> string val to_rst : t -> Rst_string.t + val of_rst : Rst_string.t -> t end = struct type t = { n_det_max_fci : Det_number_max.t; @@ -90,6 +91,23 @@ Compute E(PT2) at the end :: (Bool.to_string b.do_pt2_end) |> Rst_string.of_string ;; + + let of_rst s = + let s = Rst_string.to_string s + |> String.split ~on:'\n' + |> List.filter ~f:(fun line -> + String.contains line '=') + |> List.map ~f:(fun line -> + "("^( + String.tr line ~target:'=' ~replacement:' ' + )^")" ) + |> String.concat + in + Sexp.of_string ("("^s^")") + |> t_of_sexp + ;; + + end diff --git a/ocaml/test_input.ml b/ocaml/test_input.ml index 30b1ed9c..0c2bd5eb 100644 --- a/ocaml/test_input.ml +++ b/ocaml/test_input.ml @@ -76,6 +76,13 @@ let test_fci () = let b = Input.Full_ci.read () in print_endline (Input.Full_ci.to_string b); + let rst = Input.Full_ci.to_rst b in + let new_b = Input.Full_ci.of_rst rst in + print_endline (Input.Full_ci.to_string b); + if (b = new_b) then + print_endline "OK" + else + print_endline "Failed in rst" ;; let test_hf () = @@ -124,4 +131,4 @@ test_bielec_intergals ();; test_electrons(); *) -test_hf(); +test_fci();