10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-07-11 13:53:44 +02:00

Change global variable

This commit is contained in:
Thomas Applencourt 2015-06-18 11:11:14 +02:00
parent 4708a2d93c
commit abbcb3195a
4 changed files with 44 additions and 53 deletions

12
ocaml/.gitignore vendored
View File

@ -5,7 +5,6 @@ qptypes_generator.byte
_build _build
qp_basis_clean.native qp_basis_clean.native
qp_create_ezfio_from_xyz.native qp_create_ezfio_from_xyz.native
qp_edit.native
qp_print.native qp_print.native
qp_run.native qp_run.native
qp_set_ddci.native qp_set_ddci.native
@ -33,17 +32,16 @@ test_molecule
test_point3d test_point3d
qp_basis_clean qp_basis_clean
qp_create_ezfio_from_xyz qp_create_ezfio_from_xyz
qp_edit
qp_print qp_print
qp_run qp_run
qp_set_ddci qp_set_ddci
qp_set_mo_class qp_set_mo_class
Input_determinants.ml
Input_hartree_fock.ml
Input_integrals_bielec.ml
Input_perturbation.ml
Input_properties.ml
Input_pseudo.ml Input_pseudo.ml
Input_integrals_bielec.ml
Input_hartree_fock.ml
Input_perturbation.ml
Input_determinants.ml
Input_properties.ml
qp_edit.ml qp_edit.ml
qp_edit qp_edit
qp_edit.native qp_edit.native

View File

@ -48,9 +48,7 @@ header = r"""#
# \_| | (_) |_) (_| | \/ (_| | | (_| |_) | (/_ _> # \_| | (_) |_) (_| | \/ (_| | | (_| |_) | (/_ _>
# #
QP_ROOT = os.environ['QP_ROOT'] from qp_path import QP_ROOT, QP_SRC, QP_EZFIO
QP_ROOT_SRC = join(QP_ROOT, 'src')
QP_ROOT_EZFIO = join(QP_ROOT, 'install', 'EZFIO')
EZFIO_LIB = join(QP_ROOT, "lib", "libezfio.a") EZFIO_LIB = join(QP_ROOT, "lib", "libezfio.a")
ROOT_BUILD_NINJA = join(QP_ROOT, "config", "build.ninja") ROOT_BUILD_NINJA = join(QP_ROOT, "config", "build.ninja")
@ -105,13 +103,13 @@ def dict_module_genelogy_path(d_module_genelogy):
""" """
d = dict() d = dict()
for module_rel, l_children_rel in d_module_genelogy.iteritems(): for module_rel, l_children_rel in d_module_genelogy.iteritems():
module_abs = real_join(QP_ROOT_SRC, module_rel) module_abs = real_join(QP_SRC, module_rel)
p = Path(module_abs, module_rel) p = Path(module_abs, module_rel)
try: try:
d[p] = Path(real_join(QP_ROOT_SRC, l_children_rel), l_children_rel) d[p] = Path(real_join(QP_SRC, l_children_rel), l_children_rel)
except: except:
d[p] = [Path(real_join(QP_ROOT_SRC, children), children) d[p] = [Path(real_join(QP_SRC, children), children)
for children in l_children_rel] for children in l_children_rel]
return d return d
@ -129,8 +127,8 @@ def get_l_module_with_ezfio_cfg():
from os import listdir from os import listdir
from os.path import isfile from os.path import isfile
return [real_join(QP_ROOT_SRC, m) for m in listdir(QP_ROOT_SRC) return [real_join(QP_SRC, m) for m in listdir(QP_SRC)
if isfile(real_join(QP_ROOT_SRC, m, "EZFIO.cfg"))] if isfile(real_join(QP_SRC, m, "EZFIO.cfg"))]
def get_l_ezfio_config(): def get_l_ezfio_config():
@ -140,13 +138,13 @@ def get_l_ezfio_config():
l = [] l = []
cmd = "{0}/*/*.ezfio_config".format(QP_ROOT_SRC) cmd = "{0}/*/*.ezfio_config".format(QP_SRC)
for path_in_module in glob.glob(cmd): for path_in_module in glob.glob(cmd):
real_path = real_join(path_in_module) real_path = real_join(path_in_module)
name_lower = os.path.split(real_path)[1].lower() name_lower = os.path.split(real_path)[1].lower()
path_in_ezfio = join(QP_ROOT_EZFIO, "config", name_lower) path_in_ezfio = join(QP_EZFIO, "config", name_lower)
l.append(EZ_config_path(real_path, path_in_ezfio)) l.append(EZ_config_path(real_path, path_in_ezfio))
return l return l
@ -177,7 +175,7 @@ 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 create by him
""" """
config_folder = join(QP_ROOT_EZFIO, "config") config_folder = join(QP_EZFIO, "config")
l_util = dict() l_util = dict()
@ -254,7 +252,7 @@ def ninja_ezfio_rule():
for flag in ["FC", "FCFLAGS", "IRPF90"]] for flag in ["FC", "FCFLAGS", "IRPF90"]]
install_lib_ezfio = join(QP_ROOT, 'install', 'EZFIO', "lib", "libezfio.a") install_lib_ezfio = join(QP_ROOT, 'install', 'EZFIO', "lib", "libezfio.a")
l_cmd = ["cd {0}".format(QP_ROOT_EZFIO)] + l_flag l_cmd = ["cd {0}".format(QP_EZFIO)] + l_flag
l_cmd += ["ninja && ln -f {0} {1}".format(install_lib_ezfio, EZFIO_LIB)] l_cmd += ["ninja && ln -f {0} {1}".format(install_lib_ezfio, EZFIO_LIB)]
l_string = ["rule build_ezfio", l_string = ["rule build_ezfio",
@ -288,7 +286,7 @@ def get_source_destination(path_module, l_needed_molule):
Return a list of Sym_link = namedtuple('Sym_link', ['source', 'destination']) Return a list of Sym_link = namedtuple('Sym_link', ['source', 'destination'])
for a module for a module
""" """
return [Sym_link(m.abs, join(QP_ROOT_SRC, path_module.rel, m.rel)) return [Sym_link(m.abs, join(QP_SRC, path_module.rel, m.rel))
for m in l_needed_molule] for m in l_needed_molule]
@ -560,7 +558,7 @@ def get_dict_binaries(l_module, mode="production"):
l_binaries = [] l_binaries = []
for binaries in d_binaries[module]: for binaries in d_binaries[module]:
p_abs = real_join(QP_ROOT_SRC, root_module.rel) p_abs = real_join(QP_SRC, root_module.rel)
p_abs = join(p_abs, module.rel, binaries.rel) p_abs = join(p_abs, module.rel, binaries.rel)
p_rel = binaries.rel p_rel = binaries.rel
p = Path(p_abs, p_rel) p = Path(p_abs, p_rel)
@ -719,7 +717,7 @@ def create_build_ninja_global():
""] ""]
l_string += ["rule make_clean", l_string += ["rule make_clean",
" command = cd {0} ; clean_modules.sh *".format(QP_ROOT_SRC), " command = cd {0} ; clean_modules.sh *".format(QP_SRC),
" description = Cleaning all modules", ""] " description = Cleaning all modules", ""]
l_string += ["build dummy_target: update_build_ninja_root", l_string += ["build dummy_target: update_build_ninja_root",

View File

@ -68,10 +68,12 @@ from collections import namedtuple
from decorator import cache from decorator import cache
from os import listdir from os import listdir
from os.path import isdir, join, exists from os.path import isdir, join, exists
from qp_path import QP_ROOT, QP_SRC, QP_OCAML, QP_EZFIO
Type = namedtuple('Type', 'fancy ocaml fortran') Type = namedtuple('Type', 'fancy ocaml fortran')
@ -97,10 +99,6 @@ def get_type_dict():
For example fancy_type['Ndet'].fortran = interger For example fancy_type['Ndet'].fortran = interger
.ocaml = int .ocaml = int
""" """
# ~#~#~#~#~ #
# P i c l e #
# ~#~#~#~#~ #
qpackage_root = os.environ['QP_ROOT']
# ~#~#~#~ # # ~#~#~#~ #
# I n i t # # I n i t #
@ -138,7 +136,8 @@ def get_type_dict():
"string": "character*32"} "string": "character*32"}
# Read and parse qptype generate # Read and parse qptype generate
src = qpackage_root + "/ocaml/qptypes_generator.ml" src = join(QP_OCAML, "qptypes_generator.ml")
with open(src, "r") as f: with open(src, "r") as f:
r = f.read() r = f.read()
@ -455,7 +454,7 @@ def save_ezfio_config(module_lower, str_ezfio_config):
"$QP_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) "$QP_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower)
""" """
name = "{0}.ezfio_interface_config".format(module_lower) name = "{0}.ezfio_interface_config".format(module_lower)
path = os.path.join(os.environ['QP_EZFIO'], "config", name) path = os.path.join(QP_EZFIO, "config", name)
with open(path, "w+") as f: with open(path, "w+") as f:
f.write(str_ezfio_config) f.write(str_ezfio_config)
@ -473,7 +472,7 @@ def save_ezfio_default(module_lower, str_ezfio_default):
""" """
root_ezfio_default = "{0}/data/ezfio_defaults/".format( root_ezfio_default = "{0}/data/ezfio_defaults/".format(
os.environ['QP_ROOT']) QP_ROOT)
path = "{0}/{1}.ezfio_interface_default".format(root_ezfio_default, path = "{0}/{1}.ezfio_interface_default".format(root_ezfio_default,
module_lower) module_lower)
with open(path, "w+") as f: with open(path, "w+") as f:
@ -501,7 +500,6 @@ def create_ocaml_input(dict_ezfio_cfg, module_lower):
if not l_ezfio_name: if not l_ezfio_name:
raise ValueError raise ValueError
e_glob = EZFIO_ocaml(l_ezfio_name=l_ezfio_name, e_glob = EZFIO_ocaml(l_ezfio_name=l_ezfio_name,
l_type=l_type, l_type=l_type,
l_doc=l_doc) l_doc=l_doc)
@ -578,11 +576,12 @@ def create_ocaml_input(dict_ezfio_cfg, module_lower):
def save_ocaml_input(module_lower, str_ocaml_input): def save_ocaml_input(module_lower, str_ocaml_input):
""" """
Write the str_ocaml_input in Write the str_ocaml_input in
$QP_ROOT/ocaml/Input_{0}.ml".format(module_lower) qp_path.QP_OCAML/Input_{0}.ml".format(module_lower)
""" """
path = "{0}/ocaml/Input_{1}.ml".format(os.environ['QP_ROOT'], name = "Input_{0}.ml".format(module_lower)
module_lower)
path = join(QP_OCAML, name)
with open(path, "w+") as f: with open(path, "w+") as f:
f.write(str_ocaml_input) f.write(str_ocaml_input)
@ -594,17 +593,11 @@ def get_l_module_with_auto_generate_ocaml_lower():
(NB `search` in all the ligne and `match` only in one) (NB `search` in all the ligne and `match` only in one)
""" """
# ~#~#~#~ #
# I n i t #
# ~#~#~#~ #
mypath = "{0}/src".format(os.environ['QP_ROOT'])
# ~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~ #
# L _ f o l d e r # # L _ f o l d e r #
# ~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~ #
l_folder = [f for f in listdir(mypath) if isdir(join(mypath, f))] l_folder = [f for f in listdir(QP_SRC) if isdir(join(QP_SRC, f))]
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ #
# L _ m o d u l e _ l o w e r # # L _ m o d u l e _ l o w e r #
@ -615,7 +608,7 @@ def get_l_module_with_auto_generate_ocaml_lower():
p = re.compile(ur'interface:\s+input') p = re.compile(ur'interface:\s+input')
for f in l_folder: for f in l_folder:
path = "{0}/{1}/EZFIO.cfg".format(mypath, f) path = "{0}/{1}/EZFIO.cfg".format(QP_SRC, f)
if exists(path): if exists(path):
with open(path, 'r') as file_: with open(path, 'r') as file_:
if p.search(file_.read()): if p.search(file_.read()):
@ -639,8 +632,7 @@ def create_ocaml_input_global(l_module_with_auto_generate_ocaml_lower):
from ezfio_generate_ocaml import EZFIO_ocaml from ezfio_generate_ocaml import EZFIO_ocaml
qpackage_root = os.environ['QP_ROOT'] path = QP_ROOT + "/scripts/ezfio_interface/qp_edit_template"
path = qpackage_root + "/scripts/ezfio_interface/qp_edit_template"
with open(path, "r") as f: with open(path, "r") as f:
template_raw = f.read() template_raw = f.read()
@ -661,10 +653,11 @@ def create_ocaml_input_global(l_module_with_auto_generate_ocaml_lower):
def save_ocaml_input_auto(str_ocaml_input_global): def save_ocaml_input_auto(str_ocaml_input_global):
""" """
Write the str_ocaml_input in Write the str_ocaml_input in
$QP_ROOT/ocaml/Input_auto_generated.ml qp_path.QP_OCAML/Input_auto_generated.ml
""" """
path = "{0}/ocaml/Input_auto_generated.ml".format(os.environ['QP_ROOT']) name = "Input_auto_generated.ml"
path = join(QP_OCAML, name)
with open(path, "w+") as f: with open(path, "w+") as f:
f.write(str_ocaml_input_global) f.write(str_ocaml_input_global)
@ -673,10 +666,11 @@ def save_ocaml_input_auto(str_ocaml_input_global):
def save_ocaml_qp_edit(str_ocaml_qp_edit): def save_ocaml_qp_edit(str_ocaml_qp_edit):
""" """
Write the str_ocaml_qp_edit in Write the str_ocaml_qp_edit in
$QP_ROOT/ocaml/qp_edit.ml qp_path.QP_OCAML/qp_edit.ml
""" """
path = "{0}/ocaml/qp_edit.ml".format(os.environ['QP_ROOT']) name = "qp_edit.ml"
path = join(QP_OCAML, name)
with open(path, "w+") as f: with open(path, "w+") as f:
f.write(str_ocaml_qp_edit) f.write(str_ocaml_qp_edit)
@ -771,14 +765,12 @@ if __name__ == "__main__":
# G e t _ l _ d i c t _ e z f i o _ c f g # # G e t _ l _ d i c t _ e z f i o _ c f g #
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# #
qpackage_root_src = join(os.environ['QP_ROOT'], "src")
l_module_with_ezfio = [] l_module_with_ezfio = []
Module = namedtuple('Module', 'path lower') Module = namedtuple('Module', 'path lower')
for f in l_module: for f in l_module:
path = join(qpackage_root_src, f, "EZFIO.cfg") path = join(QP_SRC, f, "EZFIO.cfg")
if exists(path): if exists(path):
l_module_with_ezfio.append(Module(path, f.lower())) l_module_with_ezfio.append(Module(path, f.lower()))

View File

@ -2,11 +2,14 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import sys
try: try:
qp_root = os.environ['QP_ROOT'] QP_ROOT = os.environ['QP_ROOT']
except: except:
print "source quantum_package.rc" print "source quantum_package.rc"
sys.exit(1) sys.exit(1)
else: else:
qp_root_src = os.path.join(qp_root, "src") QP_SRC = os.path.join(QP_ROOT, "src")
QP_EZFIO = os.path.join(QP_ROOT, "install", "EZFIO")
QP_OCAML = os.path.join(QP_ROOT, "ocaml")