10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-25 22:52:15 +02:00

Ninja work now /tmp/ninja/ninja -v -d explain build_all_binary!

This commit is contained in:
Thomas Applencourt 2015-05-25 16:07:32 +02:00
parent 091708c16b
commit 47b8ca4873
12 changed files with 394 additions and 203 deletions

View File

@ -62,17 +62,11 @@ qp_run.native: $(MLFILES) $(MLIFILES) executables
$(OCAMLBUILD) $*.native -use-ocamlfind $(PKGS)
ln -s $*.native $*
ezfio.ml: ${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml
cp ${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml .
qptypes_generator.byte: qptypes_generator.ml
$(OCAMLBUILD) qptypes_generator.byte -use-ocamlfind
Qptypes.ml: qptypes_generator.byte
./qptypes_generator.byte > Qptypes.ml
${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml:
$(MAKE) -C ${QPACKAGE_ROOT}/src ezfio
clean:
rm -rf _build Qptypes.ml $(ALL_EXE) $(ALL_TESTS)

View File

@ -48,7 +48,7 @@ def get_hash_key(command, input_data):
return m.hexdigest()
def ruun_and_save_the_data(command, path_output, path_key, is_mod):
def run_and_save_the_data(command, path_output, path_key, is_mod):
# Compile the file -> .o
os.system(command)
@ -56,40 +56,50 @@ def ruun_and_save_the_data(command, path_output, path_key, is_mod):
# Copy the .o in database if is not a module
if not is_mod:
shutil.copyfile(path_output, path_key)
try:
shutil.copyfile(path_output, path_key)
except:
pass
def main():
def cache_utility(command):
# Create temp directory
try:
os.mkdir("/tmp/qp_compiler/")
except OSError:
pass
line = sys.argv[1:]
command = " ".join(line)
raise
# Get the filename of the input.f.90
# and the otput .o
try:
(path_input, path_output) = return_filename_to_cache(command)
except:
os.system(command)
return
raise OSError
with open(path_input, 'r') as f:
input_data = f.read()
# Get the hash
key = get_hash_key(command, input_data)
path_key = os.path.join(TMPDIR, key)
# Try to return the content of the .o file
try:
shutil.copyfile(path_key, path_output)
except IOError:
is_mod = mod.search(input_data.replace('\n', ' '))
ruun_and_save_the_data(command, path_output, path_key, is_mod)
with open(path_input, 'r') as f:
input_data = f.read()
# Get the hash
key = get_hash_key(command, input_data)
path_key = os.path.join(TMPDIR, key)
# Try to return the content of the .o file
try:
shutil.copyfile(path_key, path_output)
except IOError:
is_mod = mod.search(input_data.replace('\n', ' '))
run_and_save_the_data(command, path_output, path_key, is_mod)
except:
raise
if __name__ == '__main__':
main()
line = sys.argv[1:]
command = " ".join(line)
try:
cache_utility(command)
except:
os.system(command)

View File

@ -5,10 +5,26 @@ import os
from os.path import join
from module_handler import module_genealogy
qpackage_root = os.environ['QPACKAGE_ROOT']
qpackage_root_src = join(qpackage_root, 'src')
qpackage_root_ocaml = join(qpackage_root, 'ocaml')
qpackage_root_ezfio = join(qpackage_root, 'EZFIO')
ezfio_lib = join(qpackage_root_ezfio, "lib", "libezfio.a")
from collections import namedtuple
Path = namedtuple('Path', ['abs', 'rel'])
EZ_config_path = namedtuple('EZ_config', ['path_in_module', 'path_in_ezfio'])
EZ_handler = namedtuple('EZ_handler', ['ez_module', 'ez_cfg', 'ez_interface', 'ez_config', 'ez_default', 'ez_ocaml'])
try:
from module_handler import module_genealogy
from cache import cache
except ImportError:
print "source .quantum_package.rc"
# _
@ -26,8 +42,7 @@ def ninja_makefile_depend_rule():
def ninja_makefile_depend_build(l_all_needed_molule, path_module):
l_makefile = [join(qpackage_root_src, i, "Makefile")
for i in l_all_needed_molule]
l_makefile = [join(i.abs, "Makefile") for i in l_all_needed_molule]
# Build
path_mkdepend = join(path_module.abs, "Makefile.depend")
@ -42,13 +57,15 @@ def ninja_makefile_depend_build(l_all_needed_molule, path_module):
return l_string
import glob
# _ __ _ ___ _ _
# |_ / |_ | / \ _ _|_ _
# |_ /_ | _|_ \_/ o (_ | (_|
# _|
def get_module_with_ezfio_cfg():
def get_l_module_with_ezfio_cfg():
from os import listdir
from os.path import isfile, join
qp_src = qpackage_root_src
@ -57,39 +74,36 @@ def get_module_with_ezfio_cfg():
def get_ezfio_config():
return glob.glob("{0}/*/*.ezfio_config".format(qpackage_root_src))
# Path in module
# Path in EZFIO/config/
# namedtuple('EZ_config', ['path_in_module', 'path_in_ezfio'])
l = []
cmd = "{0}/*/*.ezfio_config".format(qpackage_root_src)
for path_in_module in glob.glob(cmd):
name_lower = os.path.split(path_in_module)[1].lower()
path_in_ezfio = join(qpackage_root_ezfio, "config", name_lower)
l.append(EZ_config_path(path_in_module, path_in_ezfio))
return l
def get_l_ezfio_irp(l_all_needed_molule, path_module):
l_module_abs = [join(qpackage_root_src, m) for m in l_all_needed_molule]
l_irp = []
for m in l_module_abs + [path_module.abs]:
for file in os.listdir(m):
if file.endswith(".irp.f"):
l_irp.append(join(m, file))
if file == "EZFIO.cfg":
l_irp.append(join(m, "ezfio_interface.irp.f"))
return l_irp
@cache
def get_l_irp_for_module(path_module_abs):
dump = []
for file in os.listdir(path_module_abs):
if file.endswith(".irp.f"):
dump.append(join(path_module_abs, file))
if file == "EZFIO.cfg":
dump.append(join(path_module_abs, "ezfio_interface.irp.f"))
return dump
def ninja_ezfio_cfg_rule():
# Rule
l_string = ["rule build_ezfio_interface"]
l_string += [" command = ei_handler.py --path_module $sub_module --irpf90"]
l_string += [""]
return l_string
def ninja_ezfio_interface_config_rule():
# Rule
l_string = ["rule build_ezfio_interface_config"]
l_string += [" command = ei_handler.py --path_module $sub_module --ezfio_config"]
l_string += [" command = ei_handler.py --path_module $sub_module"]
l_string += [""]
return l_string
@ -104,66 +118,120 @@ def ninja_ezfio_config_rule():
return l_string
def ninja_ezfio_cfg_build(l_module_with_ezfio_cfg):
def get_children_of_ezfio_cfg(l_module_with_ezfio_cfg):
# Build
l_string = []
import re
p = re.compile(ur'interface:\s+input')
config_folder = join(qpackage_root_ezfio, "config")
default_folder = join(qpackage_root, "data", "ezfio_defaults")
l_util = dict()
for m in l_module_with_ezfio_cfg:
ez_interface = join(m, "ezfio_interface.irp.f")
ez_cfg = join(m, "EZFIO.cfg")
l_string += ["build {0}: build_ezfio_interface {1}".format(ez_interface,
ez_cfg)]
l_string += [" sub_module = {0}".format(m)]
l_string += [""]
name_module = os.path.split(m)[1]
name_module_lower = name_module.lower()
rel = name_module
abs_ = m
ez_module = Path(abs_, rel)
rel = "EZFIO.cfg"
abs_ = join(m, "EZFIO.cfg")
ez_cfg = Path(abs_, rel)
rel = "ezfio_interface.irp.f"
abs_ = join(m, rel)
ez_interface = Path(abs_, rel)
rel = "{0}.ezfio_interface_config".format(name_module_lower)
abs_ = join(config_folder, rel)
ez_config = Path(abs_, rel)
with open(ez_cfg.abs, 'r') as file_:
if p.search(file_.read()):
rel = "{0}.ezfio_interface_default".format(name_module_lower)
abs_ = join(default_folder, rel)
ez_default = Path(abs_, rel)
rel = "Input_{0}.ml".format(name_module_lower)
abs_ = join(qpackage_root_ocaml, rel)
ez_ocaml = Path(abs_, rel)
else:
ez_default = None
ez_ocaml = None
l_util[ez_module.rel] = EZ_handler(ez_module,
ez_cfg,
ez_interface,
ez_config,
ez_default, ez_ocaml)
return l_util
def ninja_ezfio_cfg_build(l_util):
l_string = []
for m in l_util.itervalues():
try:
str_ = "build {1} {2} {3} {4}: build_ezfio_interface {0}"
l_string += [str_.format(m.ez_cfg.abs,
m.ez_interface.abs,
m.ez_config.abs,
m.ez_default.abs,
m.ez_ocaml.abs)]
except AttributeError:
str_ = "build {1} {2}: build_ezfio_interface {0}"
l_string += [str_.format(m.ez_cfg.abs,
m.ez_interface.abs,
m.ez_config.abs)]
finally:
l_string += [" sub_module = {0}".format(m.ez_module.abs)]
l_string += [""]
return l_string
def ninja_ezfio_config_build(l_module_with_ezfio_cfg,l_ezfio_config):
def ninja_ezfio_config_build(l_ezfio_config):
# Build
l_string = []
l_file_create = []
ezfio_folder = join(qpackage_root, "EZFIO/config")
for m in l_module_with_ezfio_cfg:
file_source = join(m, "EZFIO.cfg")
name = "{0}.ezfio_interface_config".format(os.path.split(m)[1].lower())
file_create = join(ezfio_folder, name)
l_file_create.append(file_create)
l_string += ["build {0}: build_ezfio_interface_config {1}".format(file_create, file_source)]
l_string += [" sub_module = {0}".format(m)]
l_string += [""]
for m in l_ezfio_config:
file_source = m
name = os.path.split(m)[1].lower()
file_create = join(ezfio_folder, name)
file_source = m.path_in_module
file_create = m.path_in_ezfio
l_file_create.append(file_create)
l_string += ["build {0}: build_ezfio_config {1}".format(file_create, file_source)]
l_string += [""]
return l_string, l_file_create
return l_string
def ninja_ezfio_rule():
# Rule
l_string = ["rule build_ezfio"]
ezfio_folder = join(qpackage_root, "EZFIO")
l_string += [" command = cd {0}; make ; cd -".format(ezfio_folder)]
l_string += [" command = cd {0}; make ; cd -".format(qpackage_root_ezfio)]
l_string += [" description = Make ezfio"]
return l_string
def ninja_ezfio_build(l_file_create):
def ninja_ezfio_build(l_ezfio_config, l_util):
# Rule
ezfio_lib = join(qpackage_root, "EZFIO", "lib", "libezfio.a")
str_ = " ".join(l_file_create)
ezfio_ocam_lib = join(qpackage_root, "EZFIO", "Ocaml", "ezfio.ml")
l_string = ["build {0}: build_ezfio {1}".format(ezfio_lib, str_)]
l = [i.path_in_ezfio for i in l_ezfio_config]
str_ = " ".join(l + [i.ez_config.abs for i in l_util.itervalues()])
l_string = ["build {0} {1}: build_ezfio {2}".format(ezfio_lib,
ezfio_ocam_lib,
str_)]
l_string += [""]
return l_string
@ -174,12 +242,10 @@ def ninja_ezfio_build(l_file_create):
# __) \/ | | | | | | | |<
# /
def get_source_destination(l_all_needed_molule, path_module):
l_all_needed_molule_include = l_all_needed_molule + ["include"]
l_source = [join(qpackage_root_src, m)
for m in l_all_needed_molule_include]
l_destination = [join(qpackage_root_src, path_module.rel, m)
for m in l_all_needed_molule_include]
l_source = [m.abs for m in l_all_needed_molule]
l_destination = [join(qpackage_root_src, path_module.rel, m.rel)
for m in l_all_needed_molule]
return l_source, l_destination
@ -187,21 +253,26 @@ def get_source_destination(l_all_needed_molule, path_module):
def ninja_symlink_rule():
# Rule
l_string = ["rule build_symlink"]
l_string += [" command = ln -s $module_source $module_destination"]
l_string += [" command = ln -sf $in $out"]
l_string += [""]
return l_string
def ninja_symlink_build(l_source, l_destination):
def ninja_symlink_build(l_source, l_destination, path_module):
# Rule
l_string = []
for source, destination in zip(l_source, l_destination):
l_string += ["build {0}: build_symlink".format(destination)]
l_string += [" module_source = {0}".format(source)]
l_string += [" module_destination = {0}".format(destination)]
l_string += ["build {0}: build_symlink {1}".format(destination,
source)]
l_string += [""]
out = "l_symlink_{0}".format(path_module.rel)
dep = " ".join(l_destination)
l_string += ["build {0} : phony {1}".format(out, dep)]
l_string += [""]
return l_string
@ -209,6 +280,34 @@ def ninja_symlink_build(l_source, l_destination):
# o ._ ._ _|_ (_| / \ ._ _ _. | _
# | | |_) | | \_/ o | | | (_| |< (/_
# |
def dict_needed_modules(l_module_to_compile):
d = dict()
for module_rel in l_module_to_compile:
module_abs = join(qpackage_root_src, module_rel)
path_neeeded_module = join(module_abs, "NEEDED_CHILDREN_MODULES")
d[Path(module_abs, module_rel)] = [Path(join(qpackage_root_src, m_children), m_children) for m_children in module_genealogy(path_neeeded_module)]
return d
def get_irp_dependancy(d_info_module):
l_all_module = [m for m in d_info_module.keys()]
for l_m_children in d_info_module.values():
for m_children in l_m_children:
if m_children not in l_all_module:
l_all_module.append(m_children)
d_irp = dict()
for module in l_all_module:
d_irp[module.rel] = get_l_irp_for_module(module.abs)
return d_irp
def ninja_irpf90_make_rule():
# Rule
l_string = ["pool irp_pool"]
@ -223,15 +322,28 @@ def ninja_irpf90_make_rule():
return l_string
def ninja_irpf90_make_build(path_module,
l_all_needed_molule_include,
l_irp,
l_destination):
def ninja_create_l_irp_build(d_irp):
l_string = []
for m, l_irp in d_irp.iteritems():
dep = " ".join(l_irp)
l_string += ["build l_irp_{0}: phony {1}".format(m, dep)]
l_string += [""]
return l_string
def ninja_irpf90_make_build(l_all_needed_molule,
path_module):
path_irpf90_make = join(path_module.abs, "irpf90.make")
str_l_irp_need = " ".join(l_irp)
str_l_destination = " ".join(l_destination)
l_irp_need = ["l_irp_{0}".format(i.rel) for i in l_all_needed_molule]
str_l_irp_need = " ".join(l_irp_need)
path_makefiledepend = join(path_module.abs, "Makefile.depend")
str_l_destination = "l_symlink_{0}".format(path_module.rel)
str_depend = "{0} {1} {2}".format(str_l_irp_need,
path_makefiledepend,
@ -243,8 +355,8 @@ def ninja_irpf90_make_build(path_module,
l_string += [" module = {0}".format(path_module.abs)]
# Option
str_include_dir = " ".join(["-I {0}".format(m)
for m in l_all_needed_molule_include])
str_include_dir = " ".join(["-I {0}".format(m.rel)
for m in l_all_needed_molule])
l_string += [" include_dir = {0}".format(str_include_dir)]
l_string += [" irpf90_flag = {0}".format("--align=32 --openmp")]
@ -253,6 +365,89 @@ def ninja_irpf90_make_build(path_module,
return l_string
# _
# / \ _ _. ._ _ |
# \_/ (_ (_| | | | |
def get_qp_file():
qp_edit = join(qpackage_root_ocaml, "qp_edit.ml")
l = glob.glob(join(qpackage_root_ocaml, "qp_*.ml"))
if qp_edit not in l:
l.append(qp_edit)
return l
def get_ml_file(l_util, l_qp):
"""
Get all the ml file
Remove the binary
"""
ezfio_ml = join(qpackage_root_ocaml, "ezfio.ml")
l_ml_auto_generated = [i.ez_ocaml.abs for i in l_util.itervalues() if i.ez_ocaml] + [ezfio_ml]
# .ml present
l_ml_present = glob.glob("{0}/*.ml".format(qpackage_root_ocaml))
l_ml = list(set(l_ml_present + l_ml_auto_generated))
# Return all the .ml who are not ocaml_binary
return [ml for ml in l_ml if ml not in l_qp]
def ninja_ocaml_rule():
# Rule
cmd = " command = cd {0} ; make -j 1 $binary ; touch $binary; cd -"
l_string = ["rule build_ocaml"]
l_string += [cmd.format(qpackage_root_ocaml)]
l_string += [""]
l_string += ["rule cp_input.ml"]
l_string += [" command = cp $in $out"]
l_string += [""]
l_string += ["rule build_qp_edit.ml"]
l_string += [" command = ei_handler.py ocaml_global"]
l_string += [""]
return l_string
def ninja_ml_build(l_util):
source = join(qpackage_root_ezfio, "Ocaml", "ezfio.ml")
dest = join(qpackage_root_ocaml, "ezfio.ml")
l_string = ["build {0}: cp_input.ml {1}".format(dest, source)]
l_string += [""]
ocaml_ml = [join(qpackage_root_ocaml, i) for i in ["qp_edit.ml", "Input_auto_generated.ml"]]
ocaml_ml_str = " ".join(ocaml_ml)
qp_edit_template = join(qpackage_root, "scripts", "ezfio_interface", "qp_edit_template")
l_depend = [i.ez_ocaml.abs for i in l_util.itervalues() if i.ez_ocaml] + [qp_edit_template]
depend_str = " ".join(l_depend)
l_string = ["build {0}: build_qp_edit.ml {1}".format(ocaml_ml_str, depend_str)]
return l_string
def ninja_ocaml_build(l_bin_ml, l_ml):
# Rule
l_string = [""]
str_depend = " ".join(l_ml + l_bin_ml)
for bin_ in [i.replace(".ml", ".native") for i in l_bin_ml]:
binary_name = os.path.split(bin_)[1]
l_string += ["build {0}: build_ocaml {1}".format(bin_, str_depend)]
l_string += [" binary = {0}".format(binary_name)]
l_string += [""]
return l_string
# _
# |_) o ._ _. ._
# |_) | | | (_| | \/
@ -271,7 +466,6 @@ def get_program(path_module):
def ninja_binary_rule():
# Rule
l_string = ["rule build_binary"]
l_string += [" command = cd $module ; make -j 1 $binary ; touch $binary; cd -"]
@ -284,21 +478,22 @@ def ninja_binary_build(l_bin, path_module):
# Build
irpf90mk_path = join(path_module.abs, "irpf90.make")
ezfio_lib = join(qpackage_root, "EZFIO", "lib", "libezfio.a")
l_string = []
l_abs_bin = [join(path_module.abs, binary) for binary in l_bin]
l_string = []
for path, abs_path in zip(l_bin, l_abs_bin):
l_string += ["build {0}: build_binary {1} {2}".format(abs_path,
ezfio_lib,
irpf90mk_path)]
l_string += [" module = {0}".format(path_module.abs)]
l_string += [" binary = {0}".format(path)]
l_string += [""]
str_l_abs_bin = " ".join(l_abs_bin)
ocaml_bin = [join(qpackage_root_ocaml, i) for i in ["qp_run.native", "qp_edit.native"]]
str_l_abs_bin = " ".join(l_abs_bin + ocaml_bin)
l_string += ["build build_all_binary_{0}: phony {1}".format(path_module.rel,
str_l_abs_bin)]
@ -316,68 +511,71 @@ def ninja_all_binary_build(l_module):
return l_string
if __name__ == "__main__":
with open(join(qpackage_root_src, "NEEDED_MODULES"), "r") as f:
l_module_to_compile = f.read().split()
# _
# |_) | _
# | \ |_| | (/_
#
l_string = ninja_makefile_depend_rule()
l_string += ninja_ezfio_cfg_rule()
l_string += ninja_symlink_rule()
l_string += ninja_irpf90_make_rule()
l_string += ninja_binary_rule()
l_string += ninja_ezfio_interface_config_rule()
l_string += ninja_ezfio_config_rule()
l_string += ninja_ezfio_rule()
from collections import namedtuple
# l_module_to_compile = ["AOs", "CAS_SD", "Hartree_Fock"]
for module_to_consider in l_module_to_compile:
Path = namedtuple('Path', ['abs', 'rel'])
path_module = Path(join(qpackage_root_src, module_to_consider),
module_to_consider)
path_neeeded_module = join(path_module.abs, "NEEDED_CHILDREN_MODULES")
l_all_needed_molule = module_genealogy(path_neeeded_module)
# Make.depend rule and build
l_string += ninja_makefile_depend_build(l_all_needed_molule, path_module)
# EZFIO.cfg rule and build
l_irp = get_l_ezfio_irp(l_all_needed_molule, path_module)
# Symlink rule and build
l_source, l_destination = get_source_destination(l_all_needed_molule,
path_module)
l_string += ninja_symlink_build(l_source, l_destination)
# irpf90.make
l_string += ninja_irpf90_make_build(path_module,
l_all_needed_molule + ["include"],
l_irp,
l_destination)
# ninja_binary
l_binary = get_program(path_module)
l_string += ninja_binary_build(l_binary, path_module)
l_module = get_module_with_ezfio_cfg()
l_string += ninja_ezfio_cfg_build(l_module)
l_string += ninja_ocaml_rule()
# _
# |_) o | _| _ _ ._ _ ._ _. |
# |_) |_| | | (_| (_| (/_ | | (/_ | (_| |
# _|
l_module_with_ezfio_cfg = get_l_module_with_ezfio_cfg()
l_util = get_children_of_ezfio_cfg(l_module_with_ezfio_cfg)
l_ezfio_config = get_ezfio_config()
l_string_dump, l_file_create = ninja_ezfio_config_build(l_module_with_ezfio_cfg=l_module,
l_ezfio_config=l_ezfio_config)
l_string += l_string_dump
l_string += ninja_ezfio_cfg_build(l_util)
l_string += ninja_ezfio_config_build(l_ezfio_config)
l_string += ninja_ezfio_build(l_ezfio_config, l_util)
l_qp = get_qp_file()
l_ml = get_ml_file(l_util, l_qp)
l_string += ninja_ml_build(l_util)
l_string += ninja_ocaml_build(l_qp, l_ml)
# _ _
# |_) o | _| _|_ _ ._ ._ _ _ _| | _
# |_) |_| | | (_| | (_) | | | | (_) (_| |_| | (/_
#
#
with open(join(qpackage_root_src, "NEEDED_MODULES"), "r") as f:
l_module_to_compile = f.read().split()
d_info_module = dict_needed_modules(l_module_to_compile)
d_irp = get_irp_dependancy(d_info_module)
l_string += ninja_create_l_irp_build(d_irp)
for module, l_children in d_info_module.iteritems():
l_source, l_destination = get_source_destination(l_children, module)
l_string += ninja_makefile_depend_build(l_children, module)
# irpf90.make
l_string += ninja_symlink_build(l_source, l_destination, module)
l_string += ninja_irpf90_make_build(l_children, module)
# ninja_binary
l_binary = get_program(module)
l_string += ninja_binary_build(l_binary, module)
l_string += ninja_all_binary_build(l_module_to_compile)
l_string += ninja_ezfio_build(l_file_create)
print "\n".join(l_string)

View File

@ -16,7 +16,6 @@ By default all the option are executed.
Options:
-h --help
--recursif Folow the dependancy of the module
--irpf90 Create the `ezfio_interface.irpf90`
which contains all the providers needed
(aka all with the `interface: input` parameter)
@ -437,6 +436,7 @@ def create_ezfio_stuff(dict_ezfio_cfg, config_or_default="config"):
raise KeyError
# Append
result.append(s)
result.append("\n")
return "\n".join(result)
@ -500,6 +500,7 @@ def create_ocaml_input(dict_ezfio_cfg, module_lower):
if not l_ezfio_name:
raise ValueError
e_glob = EZFIO_ocaml(l_ezfio_name=l_ezfio_name,
l_type=l_type,
l_doc=l_doc)
@ -586,7 +587,7 @@ def save_ocaml_input(module_lower, str_ocaml_input):
f.write(str_ocaml_input)
def get_l_module_lower():
def get_l_module_with_auto_generate_ocaml_lower():
"""
Get all module who have EZFIO.cfg with input data
(NB `search` in all the ligne and `match` only in one)
@ -626,18 +627,11 @@ def get_l_module_lower():
return l_module_lower
def create_ocaml_input_global():
def create_ocaml_input_global(l_module_with_auto_generate_ocaml_lower):
"""
Check for all the EZFIO.cfg get the module lower
then create incule {module_lower}.ml
Create the Input_auto_generated.ml and qp_edit.ml str
"""
# ~#~#~#~# #
# I n i t #
# ~#~#~#~# #
l_module_lower = get_l_module_lower()
# ~#~#~#~#~#~#~#~# #
# C r e a t i o n #
# ~#~#~#~#~#~#~#~# #
@ -650,7 +644,7 @@ def create_ocaml_input_global():
with open(path, "r") as f:
template_raw = f.read()
e = EZFIO_ocaml(l_module_lower=l_module_lower)
e = EZFIO_ocaml(l_module_lower=l_module_with_auto_generate_ocaml_lower)
template = template_raw.format(keywords=e.create_qp_keywords(),
keywords_to_string=e.create_qp_keywords_to_string(),
@ -671,9 +665,8 @@ def save_ocaml_input_auto(str_ocaml_input_global):
path = "{0}/ocaml/Input_auto_generated.ml".format(os.environ['QPACKAGE_ROOT'])
if str_ocaml_input_global != old_output:
with open(path, "w+") as f:
f.write(str_ocaml_input_global)
with open(path, "w+") as f:
f.write(str_ocaml_input_global)
def save_ocaml_qp_edit(str_ocaml_qp_edit):
@ -684,9 +677,8 @@ def save_ocaml_qp_edit(str_ocaml_qp_edit):
path = "{0}/ocaml/qp_edit.ml".format(os.environ['QPACKAGE_ROOT'])
if str_ocaml_qp_edit != old_output:
with open(path, "w+") as f:
f.write(str_ocaml_qp_edit)
with open(path, "w+") as f:
f.write(str_ocaml_qp_edit)
def code_generation(arguments, dict_ezfio_cfg, m):
@ -750,7 +742,14 @@ if __name__ == "__main__":
#
if arguments["ocaml_global"]:
str_ocaml_qp_edit, str_ocaml_input_auto = create_ocaml_input_global()
# ~#~#~#~# #
# I n i t #
# ~#~#~#~# #
l_module = get_l_module_with_auto_generate_ocaml_lower()
str_ocaml_qp_edit, str_ocaml_input_auto = create_ocaml_input_global(l_module)
save_ocaml_input_auto(str_ocaml_input_auto)
save_ocaml_qp_edit(str_ocaml_qp_edit)
sys.exit(0)

View File

@ -348,6 +348,7 @@ class EZFIO_ocaml(object):
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
# C r e a t e _ t e m pl a t e #
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
l_template = ["(* Auto generate. Do not modify by Hand *)"]
l_template = ['open Qputils;;',
'open Qptypes;;',

View File

@ -82,8 +82,7 @@ def get_it_and_children(l_module):
try:
l.extend(get_it_and_children(d_ref[module]))
except KeyError:
print >> sys.stderr, "`{0}` in not a good submodule name".format(
module)
print >> sys.stderr, "`{0}` in not a good submodule name".format(module)
print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES"
sys.exit(1)

View File

@ -9,7 +9,7 @@ double precision function ao_bielec_integral(i,j,k,l)
double precision :: I_center(3),J_center(3),K_center(3),L_center(3)
integer :: num_i,num_j,num_k,num_l,dim1,I_power(3),J_power(3),K_power(3),L_power(3)
double precision :: integral
include 'include/constants.F'
include 'constants.F'
double precision :: P_new(0:max_dim,3),P_center(3),fact_p,pp
double precision :: Q_new(0:max_dim,3),Q_center(3),fact_q,qq
integer :: iorder_p(3), iorder_q(3)
@ -115,7 +115,7 @@ double precision function ao_bielec_integral_schwartz_accel(i,j,k,l)
double precision :: I_center(3),J_center(3),K_center(3),L_center(3)
integer :: num_i,num_j,num_k,num_l,dim1,I_power(3),J_power(3),K_power(3),L_power(3)
double precision :: integral
include 'include/constants.F'
include 'constants.F'
double precision :: P_new(0:max_dim,3),P_center(3),fact_p,pp
double precision :: Q_new(0:max_dim,3),Q_center(3),fact_q,qq
integer :: iorder_p(3), iorder_q(3)

View File

@ -1,5 +1,5 @@
# Define here all new external source files and objects.Don't forget to prefix the
# object files with IRPF90_temp/
# object files with IRPF90_temp/constants.F
SRC=map_module.f90
OBJ=IRPF90_temp/map_module.o

View File

@ -415,7 +415,7 @@ double precision function F_integral(n,p)
double precision :: p
integer :: i,j
double precision :: accu,sqrt_p,fact_ratio,tmp,fact
include 'include/constants.F'
include 'constants.F'
if(n < 0)then
F_integral = 0.d0
endif
@ -441,7 +441,7 @@ double precision function rint(n,rho)
! \int_0^1 dx \exp(-p x^2) x^n
!
END_DOC
include 'include/constants.F'
include 'constants.F'
double precision :: rho,u,rint1,v,val0,rint_large_n,u_inv
integer :: n,k
double precision :: two_rho_inv
@ -486,7 +486,7 @@ double precision function rint_sum(n_pt_out,rho,d1)
BEGIN_DOC
! Needed for the calculation of two-electron integrals.
END_DOC
include 'include/constants.F'
include 'constants.F'
integer, intent(in) :: n_pt_out
double precision, intent(in) :: rho,d1(0:n_pt_out)
double precision :: u,rint1,v,val0,rint_large_n,u_inv

View File

@ -6,7 +6,7 @@ double precision function overlap_gaussian_x(A_center,B_center,alpha,beta,power_
! \sum_{-infty}^{+infty} (x-A_x)^ax (x-B_x)^bx exp(-alpha(x-A_x)^2) exp(-beta(x-B_X)^2) dx
!
END_DOC
include 'include/constants.F'
include 'constants.F'
integer,intent(in) :: dim ! dimension maximum for the arrays representing the polynomials
double precision,intent(in) :: A_center,B_center ! center of the x1 functions
integer,intent(in) :: power_A, power_B ! power of the x1 functions
@ -120,7 +120,7 @@ subroutine overlap_gaussian_xyz(A_center,B_center,alpha,beta,power_A,&
! S = S_x S_y S_z
!
END_DOC
include 'include/constants.F'
include 'constants.F'
integer,intent(in) :: dim ! dimension maximum for the arrays representing the polynomials
double precision,intent(in) :: A_center(3),B_center(3) ! center of the x1 functions
double precision, intent(in) :: alpha,beta

View File

@ -51,7 +51,7 @@ integer function align_double(n)
! Compute 1st dimension such that it is aligned for vectorization.
END_DOC
integer :: n
include 'include/constants.F'
include 'constants.F'
if (mod(n,SIMD_vector/4) /= 0) then
align_double= n + SIMD_vector/4 - mod(n,SIMD_vector/4)
else

View File

@ -1,10 +0,0 @@
integer, parameter :: max_dim = 255
integer, parameter :: SIMD_vector = 32
double precision, parameter :: pi = dacos(-1.d0)
double precision, parameter :: sqpi = dsqrt(dacos(-1.d0))
double precision, parameter :: pi_5_2 = 34.9868366552d0
double precision, parameter :: dfour_pi = 4.d0*dacos(-1.d0)
double precision, parameter :: dtwo_pi = 2.d0*dacos(-1.d0)
double precision, parameter :: inv_sq_pi = 1.d0/dsqrt(dacos(-1.d0))
double precision, parameter :: inv_sq_pi_2 = 0.5d0/dsqrt(dacos(-1.d0))