diff --git a/INSTALL.md b/INSTALL.md index 01c7eee6..9433be64 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -3,24 +3,27 @@ ## Requirements * curl -* wget * m4 * GNU make -* Intel Fortran compiler -* Python +* Fortran compiler (ifort or gfortran) +* Python 2.7 or new * Bash -By default, the Ocaml compiler will be installed in `$HOME/ocamlbrew`. -To install it somewhere else, set the `$OCAMLBREW_BASE` environment -variable to the required destination, for example: +## Installing <> - export OCAMLBREW_BASE=/usr/local/ocamlbrew +1) Run `./setup_environment.sh` + It will doawnload and install all the requirement + (Installing OCaml will take somme time 20min) -For more info about the Ocaml installation, check the ocamlbrew -website : https://github.com/hcarty/ocamlbrew +2) `source /home/razoa/quantum_package/quantum_package.rc` + It containt all the environement variable neeeded by the quantum package +3) Create the Makefile.config who containt all the flag needed by the compilator. + (`cp ./src/Makefile.config.gfortran ./src/Makefile.config`) +4) make build + It will compile all the fortran ## Installing behind a firewall diff --git a/scripts/ezfio_interface.py b/scripts/ezfio_interface.py index beebd8a2..6bcb518e 100755 --- a/scripts/ezfio_interface.py +++ b/scripts/ezfio_interface.py @@ -32,8 +32,6 @@ from collections import defaultdict from collections import namedtuple Type = namedtuple('Type', 'ocaml fortran') -def bool_convertor(b): - return ( b.lower() in [ "true", ".true." ] ) def get_type_dict(): @@ -62,13 +60,13 @@ def get_type_dict(): # ~#~#~#~#~#~#~#~ # fancy_type['integer'] = Type("int", "integer") - fancy_type['int' ] = Type("int", "integer") + fancy_type['int'] = Type("int", "integer") - fancy_type['float' ] = Type("float", "double precision") + fancy_type['float'] = Type("float", "double precision") fancy_type['double precision'] = Type("float", "double precision") fancy_type['logical'] = Type("bool", "logical") - fancy_type['bool' ] = Type("bool", "logical") + fancy_type['bool'] = Type("bool", "logical") # ~#~#~#~#~#~#~#~ # # q p _ t y p e s # @@ -92,18 +90,39 @@ def get_type_dict(): type_dict = get_type_dict() -def get_dict_config_file(config_file_path,folder): +def get_dict_config_file(config_file_path, module_lower): """ - Read a ezfio.cfg - Return a dict d[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} + Input: + config_file_path is the config file path + (for example FULL_PATH/EZFIO.cfg) + module_lower is the MODULE name lowered + (Ex fullci) + + Return a dict d[provider_name] = {type, + doc, + ezfio_name, + ezfio_dir, + interface, + default} + + Type : Is a fancy_type named typle who containt fortran and ocaml type + doc : Is the doc + ezfio_name : Will be the name of the file + ezfio_dir : Will be the folder who containt the ezfio_name + * /ezfio_dir/ezfio_name + * equal to MODULE_lower name for the moment. + interface : The provider is a imput or a output + if is a output: + default : The default value + """ # ~#~#~#~ # # I n i t # # ~#~#~#~ # d = defaultdict(dict) - list_option_required = ["default", "doc"] - list_option = ["ezfio_name", "output"] + l_info_required = ["doc", "interface"] + l_info_optional = ["ezfio_name"] # ~#~#~#~#~#~#~#~#~#~#~ # # L o a d _ C o n f i g # @@ -116,43 +135,63 @@ def get_dict_config_file(config_file_path,folder): # F i l l _ d i c t # # ~#~#~#~#~#~#~#~#~ # - provider_names = config_file.sections() - for p in provider_names: - provider_name = p.lower() - default_d = {"ezfio_name": provider_name, "output": "false" } + def error(o, p, c): + "o option ; p provider_name ;c config_file_path" + print "You need a {0} for {1} in {2}".format(o, p, c) + + for section in config_file.sections(): + # pvd = provider + pvd = section.lower() + + # Create the dictionary who containt the value per default + d_default = {"ezfio_name": pvd} + + # Set the ezfio_dir + d[pvd]["ezfio_dir"] = module_lower + # Check if type if avalaible - type_ = config_file.get(p, "type") + type_ = config_file.get(section, "type") if type_ not in type_dict: print "{0} not avalaible. Choose in:".format(type_) print ", ".join([i for i in type_dict]) sys.exit(1) else: - d[provider_name]["type"] = type_dict[type_] + d[pvd]["type"] = type_dict[type_] - # Fill the dict with allother the information - for k in list_option_required: + # Fill the dict with REQUIRED information + for option in l_info_required: try: - d[provider_name][k] = config_file.get(p, k) + d[pvd][option] = config_file.get(section, option) except ConfigParser.NoOptionError: - print "You need a {0} for {1} in {2}".format(k, - provider_name, - config_file_path) - d[provider_name]["ezfio_dir"] = folder - for k in list_option: - try: - d[provider_name][k] = config_file.get(p, k).lower() - except ConfigParser.NoOptionError: - d[provider_name][k] = default_d[k] + error(option, pvd, config_file_path) + sys.exit(1) - # Convert string to bool - d[provider_name]["output"] = bool_convertor(d[provider_name]["output"]) + # Fill the dict with OPTIONAL information + for option in l_info_optional: + try: + d[pvd][option] = config_file.get(section, option).lower() + except ConfigParser.NoOptionError: + d[pvd][option] = d_default[option] + + # If interface is output we need a default value information + if d[pvd]["interface"] == "output": + try: + d[pvd]["default"] = config_file.get(section, "default") + except ConfigParser.NoOptionError: + error("default", pvd, config_file_path) + sys.exit(1) return dict(d) def create_ezfio_provider(dict_ezfio_cfg): """ - From dict d[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} + From dict d[provider_name] = {type, + doc, + ezfio_name, + ezfio_dir, + interface, + default} create the a list who containt all the code for the provider return [code, ...] """ @@ -162,14 +201,14 @@ def create_ezfio_provider(dict_ezfio_cfg): ez_p = EZFIO_Provider() for provider_name, dict_info in dict_ezfio_cfg.iteritems(): - if not dict_info["output"]: + if "default" in dict_info: ez_p.set_type(dict_info['type'].fortran) ez_p.set_name(provider_name) ez_p.set_doc(dict_info['doc']) ez_p.set_ezfio_dir(dict_info['ezfio_dir']) ez_p.set_ezfio_name(dict_info['ezfio_name']) ez_p.set_default(dict_info['default']) - + ez_p.set_output("output_%s" % dict_info['ezfio_dir']) dict_code_provider[provider_name] = str(ez_p) @@ -178,8 +217,7 @@ def create_ezfio_provider(dict_ezfio_cfg): def save_ezfio_provider(path_head, dict_code_provider): """ - Write in "ezfio_interface.irp.f" the - value of dict_code_provider + Write in path_head/"ezfio_interface.irp.f" the value of dict_code_provider """ path = "{0}/ezfio_interface.irp.f".format(path_head) @@ -195,74 +233,79 @@ def save_ezfio_provider(path_head, dict_code_provider): f.write(code + "\n") -def create_ezfio_config(dict_ezfio_cfg, opt, folder): +def create_ezfio_config(dict_ezfio_cfg, opt, module_lower): """ From dict_ezfio_cfg[provider_name] = {type, default, ezfio_name,ezfio_dir,doc} Return the string ezfio_interface_config """ - result = [ folder ] - lenmax = max( [ len(i) for i in dict_ezfio_cfg ] )+2 + result = [module_lower] + lenmax = max([len(i) for i in dict_ezfio_cfg]) + 2 l = sorted(dict_ezfio_cfg.keys()) for provider_name in l: - provider_info = dict_ezfio_cfg[provider_name] - s = " {0} {1}".format( provider_name.lower().ljust(lenmax), provider_info["type"].fortran ) - result.append(s) + provider_info = dict_ezfio_cfg[provider_name] + s = " {0} {1}".format( + provider_name.lower().ljust(lenmax), + provider_info["type"].fortran) + result.append(s) return "\n".join(result) -def save_ezfio_config(folder, str_ezfio_config): + +def save_ezfio_config(module_lower, str_ezfio_config): """ Write the str_ezfio_config in - $QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(folder) + $QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) """ ezfio_dir = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) path = "{0}/config/{1}.ezfio_interface_config".format(ezfio_dir, - folder) + module_lower) print "Path = {}".format(path) with open(path, "w") as f: f.write(str_ezfio_config) + def main(): - """Take in argument a EZFIO.cfg""" + """ + Two condition: + -Take the EZFIO.cfg path in arg + or + -Look if EZFIO.cfg is present in the pwd + """ try: - path = sys.argv[1] + config_file_path = sys.argv[1] except: - path = "EZFIO.cfg" - if "EZFIO.cfg" not in os.listdir(os.getcwd()): - sys.exit(0) + config_file_path = "EZFIO.cfg" + if "EZFIO.cfg" not in os.listdir(os.getcwd()): + sys.exit(0) - path = os.path.expanduser(path) - path = os.path.expandvars(path) - path = os.path.abspath(path) - print path + config_file_path = os.path.expanduser(config_file_path) + config_file_path = os.path.expandvars(config_file_path) + config_file_path = os.path.abspath(config_file_path) + print config_file_path - path_dirname = os.path.dirname(path) - folder = [i for i in path_dirname.split("/") if i][-1] - folder = folder.lower() + path_dirname = os.path.dirname(config_file_path) + module = [i for i in path_dirname.split("/") if i][-1] + module_lower = module.lower() - print "Find a EZFIO.cfg in {}".format(path) - dict_info_provider = get_dict_config_file(path,folder) + print "Read {0}".format(config_file_path) + dict_info_provider = get_dict_config_file(config_file_path, module_lower) print "Generating the ezfio_interface.irp.f: \n" d_config = create_ezfio_provider(dict_info_provider) -# for provider, code in d_config.iteritems(): -# print code print "Saving the ezfio_interface.irp.f" save_ezfio_provider(path_dirname, d_config) print "Generating the ezfio_config" - config_ezfio = create_ezfio_config(dict_info_provider, "config", folder) -# print config_ezfio + config_ezfio = create_ezfio_config(dict_info_provider, "config", module_lower) print "Saving ezfio_config" - save_ezfio_config(folder, config_ezfio) + save_ezfio_config(module_lower, config_ezfio) if __name__ == "__main__": - main() - + main() diff --git a/scripts/install_ocaml.sh b/scripts/install_ocaml.sh index 3c695df4..16d68fff 100755 --- a/scripts/install_ocaml.sh +++ b/scripts/install_ocaml.sh @@ -49,10 +49,14 @@ scripts/fetch_from_web.py "https://raw.github.com/ocaml/opam/master/shell/opam_i chmod +x opam_installer.sh echo N | ./opam_installer.sh ${QPACKAGE_ROOT}/bin -if [[ ! -f ${QPACKAGE_ROOT}/bin/opam ]]; then +if [[ ! -f ${QPACKAGE_ROOT}/bin/opam ]] +then echo "Installation of OPAM failed" exit 2 +else + rm "opam_installer.sh" fi + ${QPACKAGE_ROOT}/bin/opam config setup -a --dot-profile ${QPACKAGE_ROOT}/quantum_package.rc source ${QPACKAGE_ROOT}/quantum_package.rc diff --git a/scripts/install_zlib.sh b/scripts/install_zlib.sh index ee0cdf38..9250edf1 100755 --- a/scripts/install_zlib.sh +++ b/scripts/install_zlib.sh @@ -23,7 +23,7 @@ EOF gcc /tmp/main.c -lz if [[ $? -eq 0 ]] then - rm /tmp/main.c + rm /tmp/main.c "a.out" exit 0 fi rm /tmp/main.c diff --git a/src/Full_CI/EZFIO.cfg b/src/Full_CI/EZFIO.cfg index 59893176..febd0530 100644 --- a/src/Full_CI/EZFIO.cfg +++ b/src/Full_CI/EZFIO.cfg @@ -1,37 +1,42 @@ [N_det_max_fci] -doc: Max number of determinants in the wave function type: Det_number_max +doc: Max number of determinants in the wave function +interface: output default: 10000 [N_det_max_fci_property] -doc: Max number of determinants in the wave function when you select for a given property type: Det_number_max +doc: Max number of determinants in the wave function when you select for a given property +interface: output default: 10000 [do_pt2_end] type: logical doc: If true, compute the PT2 at the end of the selection +interface: output default: true [PT2_max] type: PT2_energy doc: The selection process stops when the largest PT2 (for all the state is lower than pt2_max in absolute value +interface: output default: 0.0001 [var_pt2_ratio] type: Normalized_float doc: The selection process stops when the energy ratio variational/(variational+PT2) is equal to var_pt2_ratio +interface: output default: 0.75 [energy] type: double precision doc: "Calculated Full CI energy" -output: true +interface: input [energy_pt2] type: double precision doc: "Calculated Full CI energy" -output: true +interface: input