10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-27 15:42:30 +02:00
quantum_package/scripts/compilation/read_compilation_cfg.py

34 lines
805 B
Python
Raw Normal View History

2015-05-26 16:08:52 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import ConfigParser
2015-05-27 11:02:13 +02:00
def get_l_option_section(config):
return [o for o in ['OPENMP', 'PROFILE', 'DEBUG'] if config.getboolean("OPTION", o)]
2015-05-26 16:08:52 +02:00
2015-05-27 11:02:13 +02:00
def get_compilation_option(pwd_cfg, flag_name):
2015-05-26 16:08:52 +02:00
2015-05-27 11:02:13 +02:00
config = ConfigParser.ConfigParser()
config.read(pwd_cfg)
2015-05-26 16:08:52 +02:00
2015-05-27 11:02:13 +02:00
l_option_section = get_l_option_section(config)
2015-05-26 16:08:52 +02:00
l = []
for section in ["COMMON"] + l_option_section:
try:
2015-05-27 11:02:13 +02:00
l.extend(config.get(section, flag_name).split())
2015-05-26 16:08:52 +02:00
except ConfigParser.NoOptionError:
pass
return " ".join(l)
if __name__ == '__main__':
2015-05-27 11:02:13 +02:00
qpackage_root = os.environ['QPACKAGE_ROOT']
pwd_cfg = os.path.join(qpackage_root, "scripts/compilation/compilation_ifort.cfg")
2015-05-26 16:08:52 +02:00
2015-05-27 11:02:13 +02:00
print get_compilation_option(pwd_cfg, "FC")