diff --git a/ocaml/qptypes_generator.ml b/ocaml/qptypes_generator.ml index f5a62356..633727f8 100644 --- a/ocaml/qptypes_generator.ml +++ b/ocaml/qptypes_generator.ml @@ -161,8 +161,36 @@ end = struct | \"hcore\" -> HCore | _ -> failwith (\"Wrong Guess type : \"^s) +end + +module Disk_access : sig + type t with sexp + val to_string : t -> string + val of_string : string -> t +end = struct + type t = + | Read + | Write + | None + with sexp + + let to_string = function + | Read -> \"Read\" + | Write -> \"Write\" + | None -> \"None\" + let of_string s = + let s = + String.lowercase s + in + match s with + | \"read\" -> Read + | \"write\" -> Write + | \"none\" -> None + | _ -> failwith (\"Wrong IO type : \"^s) + end " + ;; let template = format_of_string " diff --git a/scripts/ezfio_interface/convert_ezfio.sh b/scripts/ezfio_interface/convert_ezfio.sh old mode 100644 new mode 100755 index a7752f54..ec0ab770 --- a/scripts/ezfio_interface/convert_ezfio.sh +++ b/scripts/ezfio_interface/convert_ezfio.sh @@ -4,10 +4,24 @@ # Hartree Fock # Changin the case, don't know if is needed or not -mv $1/Hartree_Fock $1/hartree_fock -mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf +mv $1/Hartree_Fock $1/hartree_fock 2> /dev/null -mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf +mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf 2> /dev/null # BiInts -mv $1/bi_integrals $1/bielect_integrals \ No newline at end of file +mv $1/bi_integrals $1/bielect_integrals 2> /dev/null + +if [ -f $1/bielect_integrals/read_ao_integrals ]; then + if [ `cat $1/bielect_integrals/read_ao_integrals` -eq "True" ] + then + echo "Read" > $1/bielect_integrals/disk_access_ao_integrals + + elif [ `cat bielect_integrals/write_ao_integrals` -eq "True" ] + then + echo "Write" > $1/bielect_integrals/disk_access_ao_integrals + + else + echo "None" > $1/bielect_integrals/disk_access_ao_integrals + + fi +fi \ No newline at end of file diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index fd08a152..95a3e38c 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -105,8 +105,6 @@ def get_type_dict(): fancy_type['logical'] = Type(None, "bool", "logical") fancy_type['bool'] = Type(None, "bool", "logical") - fancy_type['MO_guess'] = Type("MO_guess", "string", "character*(32)") - fancy_type['character*(32)'] = Type(None, "string", "character*(32)") fancy_type['character*(60)'] = Type(None, "string", "character*(60)") fancy_type['character*(256)'] = Type(None, "string", "character*(256)") @@ -121,16 +119,34 @@ def get_type_dict(): "logical": "logical", "string": "character*32"} - # Read and parse qptype + # Read and parse qptype generate src = qpackage_root + "/ocaml/qptypes_generator.ml" with open(src, "r") as f: - l = [i for i in f.read().splitlines() if i.strip().startswith("*")] + r = f.read() + + # Generate + l_gen = [i for i in r.splitlines() if i.strip().startswith("*")] + + # Untouch + b = r.find('let untouched = "') + e = r.find(';;', b) + + l_un = [i for i in r[b:e].splitlines() if i.strip().startswith("module")] + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + # q p _ t y p e s _ g e n e r a t e # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # # Read the fancy_type, the ocaml. and convert the ocam to the fortran - for i in l: + for i in l_gen + l_un: str_fancy_type = i.split()[1].strip() str_ocaml_type = i.split()[3] - str_fortran_type = ocaml_to_fortran[str_ocaml_type] + + if str_ocaml_type != 'sig': + str_fortran_type = ocaml_to_fortran[str_ocaml_type] + else: + str_fortran_type = 'character*(32)' + str_ocaml_type = 'string' fancy_type[str_fancy_type] = Type(str_fancy_type, str_ocaml_type, @@ -277,7 +293,7 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p.set_ezfio_name(dict_info['ezfio_name']) ez_p.set_output("output_%s" % dict_info['ezfio_dir']) - dict_code_provider[provider_name] = str(ez_p) + dict_code_provider[provider_name] = str(ez_p) + "\n" return dict_code_provider @@ -304,10 +320,10 @@ def save_ezfio_provider(path_head, dict_code_provider): l_output += [code for code in dict_code_provider.values()] - output = "\n\n".join(l_output) + output = "\n".join(l_output) if output != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(output) @@ -424,7 +440,7 @@ def save_ezfio_config(module_lower, str_ezfio_config): f.close() if str_ezfio_config != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(str_ezfio_config) @@ -453,7 +469,7 @@ def save_ezfio_default(module_lower, str_ezfio_default): f.close() if str_ezfio_default != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(str_ezfio_default) @@ -566,7 +582,7 @@ def save_ocaml_input(module_lower, str_ocaml_input): f.close() if str_ocaml_input != old_output: - with open(path, "w") as f: + with open(path, "w+") as f: f.write(str_ocaml_input) diff --git a/scripts/ezfio_interface/ezfio_generate_provider.py b/scripts/ezfio_interface/ezfio_generate_provider.py index a99c0089..af4fcd6a 100755 --- a/scripts/ezfio_interface/ezfio_generate_provider.py +++ b/scripts/ezfio_interface/ezfio_generate_provider.py @@ -8,6 +8,7 @@ Creates the provider of a variable that has to be fetched from the EZFIO file. """ +import sys class EZFIO_Provider(object): @@ -27,7 +28,6 @@ BEGIN_PROVIDER [ %(type)s, %(name)s ] print *, '%(ezfio_dir)s/%(ezfio_name)s not found in EZFIO file' stop 1 endif - %(write)s END_PROVIDER """.strip() @@ -57,9 +57,12 @@ END_PROVIDER output = self.output name = self.name - l_write = [" call write_time(%(output)s)", + l_write = ["", + " call write_time(%(output)s)", " call %(write)s(%(output)s, %(name)s, &", - " '%(name)s')"] + " '%(name)s')", + ""] + self.write = "\n".join(l_write) % locals() def set_type(self, t): diff --git a/src/Bielec_integrals/EZFIO.cfg b/src/Bielec_integrals/EZFIO.cfg index 3d685193..bd1d774a 100644 --- a/src/Bielec_integrals/EZFIO.cfg +++ b/src/Bielec_integrals/EZFIO.cfg @@ -5,29 +5,17 @@ interface: input default: False ezfio_name: direct -[write_ao_integrals] -type: logical -doc: Write AO integrals from disk (EZFIO folder) +[disk_access_mo_integrals] +type: Disk_access +doc: Write, Read, None for MO integrals from disk (EZFIO folder) interface: input -default: False +default: None -[write_mo_integrals] -type: logical -doc: Write MO integrals from disk (EZFIO folder) +[disk_access_ao_integrals] +type: Disk_access +doc: Write or Read or None for AO integrals from disk (EZFIO folder) interface: input -default: False - -[read_ao_integrals] -type: logical -doc: Read AO integrals from disk (EZFIO folder) -interface: input -default: False - -[read_mo_integrals] -type: logical -doc: Read MO integrals from disk (EZFIO folder) -interface: input -default: False +default: None [ao_integrals_threshold] type: Threshold diff --git a/src/Bielec_integrals/ao_bi_integrals.irp.f b/src/Bielec_integrals/ao_bi_integrals.irp.f index f2645c6d..0da76021 100644 --- a/src/Bielec_integrals/ao_bi_integrals.irp.f +++ b/src/Bielec_integrals/ao_bi_integrals.irp.f @@ -319,13 +319,6 @@ subroutine compute_ao_bielec_integrals(j,k,l,sze,buffer_value) end - - - - - - - BEGIN_PROVIDER [ logical, ao_bielec_integrals_in_map ] implicit none use map_module diff --git a/src/Bielec_integrals/read_write.irp.f b/src/Bielec_integrals/read_write.irp.f new file mode 100644 index 00000000..6319641b --- /dev/null +++ b/src/Bielec_integrals/read_write.irp.f @@ -0,0 +1,41 @@ +BEGIN_PROVIDER [ logical, read_ao_integrals ] +&BEGIN_PROVIDER [ logical, read_mo_integrals ] +&BEGIN_PROVIDER [ logical, write_ao_integrals ] +&BEGIN_PROVIDER [ logical, write_mo_integrals ] + + BEGIN_DOC +! One level of abstraction for disk_access_ao_integrals and disk_access_mo_integrals + END_DOC +implicit none + + if (disk_access_ao_integrals.EQ.'Read') then + read_ao_integrals = .True. + write_ao_integrals = .False. + + else if (disk_access_ao_integrals.EQ.'Write') then + read_ao_integrals = .False. + write_ao_integrals = .True. + + else if (disk_access_ao_integrals.EQ.'None') then + read_ao_integrals = .False. + write_ao_integrals = .False. + + else if (disk_access_mo_integrals.EQ.'Read') then + read_mo_integrals = .True. + write_mo_integrals = .False. + + else if (disk_access_mo_integrals.EQ.'Write') then + read_mo_integrals = .False. + write_mo_integrals = .True. + + else if (disk_access_mo_integrals.EQ.'None') then + read_mo_integrals = .False. + write_mo_integrals = .False. + + else + print *, 'bielec_integrals/disk_acces not of a the good type' + stop "1" + + endif + +END_PROVIDER diff --git a/tests/unit_test/unit_test.py b/tests/unit_test/unit_test.py index 47155776..5a1ed2dd 100755 --- a/tests/unit_test/unit_test.py +++ b/tests/unit_test/unit_test.py @@ -54,6 +54,10 @@ def get_error_message(l_exepected, l_cur): return "\n".join(l_msg) +def check_hf(geo, basis): + ezfio.bielec_integrals_disk_access_ao_integrals = "None" + + def run_hf(geo, basis): """ Run a simle by default hf @@ -86,12 +90,10 @@ def run_hf(geo, basis): # ~#~#~#~#~#~#~#~#~#~#~#~#~ # ezfio.bielec_integrals_direct = False ezfio.bielec_integrals_threshold_ao = 1.e-15 - ezfio.bielec_integrals_write_ao_integrals = False - ezfio.bielec_integrals_read_ao_integrals = False + ezfio.bielec_integrals_disk_access_ao_integrals = "None" ezfio.bielec_integrals_threshold_mo = 1.e-15 - ezfio.bielec_integrals_write_mo_integrals = False - ezfio.bielec_integrals_read_mo_integrals = False + ezfio.bielec_integrals_disk_access_mo_integrals = "None" ezfio.hartree_fock_mo_guess_type = "Huckel" ezfio.hartree_fock_thresh_scf = 1.e-10