mirror of
https://github.com/LCPQ/quantum_package
synced 2024-11-05 13:43:57 +01:00
44 lines
1.1 KiB
Python
Executable File
44 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python2
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
import ConfigParser
|
|
|
|
|
|
def get_l_option_section(config):
|
|
"""List of options chosen by the user"""
|
|
l = [o for o in ['OPENMP'] if config.getboolean("OPTION", o)]
|
|
l.append(config.get("OPTION", "MODE").strip())
|
|
return l
|
|
|
|
|
|
def get_compilation_option(pwd_cfg, flag_name):
|
|
"""
|
|
Return the flag compilation of a compile.cfg located in pwd_cfg
|
|
"""
|
|
config = ConfigParser.ConfigParser()
|
|
config.read(pwd_cfg)
|
|
|
|
if flag_name == "FC" and config.getboolean("OPTION","CACHE"):
|
|
l = ["cache_compile.py"]
|
|
else:
|
|
l = []
|
|
|
|
l_option_section = get_l_option_section(config)
|
|
|
|
for section in ["COMMON"] + l_option_section:
|
|
try:
|
|
l.extend(config.get(section, flag_name).split())
|
|
except ConfigParser.NoOptionError:
|
|
pass
|
|
|
|
return " ".join(l)
|
|
|
|
if __name__ == '__main__':
|
|
|
|
qpackage_root = os.environ['QP_ROOT']
|
|
pwd_cfg = os.path.join(qpackage_root, "config/ifort_gpi2.cfg")
|
|
|
|
print get_compilation_option(pwd_cfg, "FC")
|
|
print get_compilation_option(pwd_cfg, "FCFLAGS")
|