10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-20 04:02:16 +02:00

provider.irp.f90 only read value in ezfio. Is value is not set, just exit

This commit is contained in:
Thomas Applencourt 2015-03-26 14:28:32 +01:00
parent 22bae15794
commit 8ffdd3bc4f
2 changed files with 26 additions and 4 deletions

View File

@ -50,6 +50,15 @@ from collections import namedtuple
Type = namedtuple('Type', 'ocaml fortran')
def is_bool(str_):
if str_.lower() in ['true', '.true.']:
return Type("true", ".True.")
elif str_.lower() in ['false', '.False.']:
return Type("false", ".False")
else:
raise TypeError
def get_type_dict():
"""
This function makes the correspondance between the type of value read in
@ -199,11 +208,16 @@ def get_dict_config_file(config_file_path, module_lower):
# If interface is output we need a default value information
if d[pvd]["interface"] == "output":
try:
d[pvd]["default"] = config_file.get(section, "default")
default_raw = config_file.get(section, "default")
except ConfigParser.NoOptionError:
error("default", pvd, config_file_path)
sys.exit(1)
try:
d[pvd]["default"] = is_bool(default_raw)
except:
d[pvd]["default"] = Type(default_raw, default_raw)
return dict(d)
@ -231,7 +245,11 @@ def create_ezfio_provider(dict_ezfio_cfg):
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'])
# default = "{0} = {1}".format(provider_name,
# dict_info['default'].fortran)
# ez_p.set_default(default)
ez_p.set_default("stop 1")
ez_p.set_output("output_%s" % dict_info['ezfio_dir'])
dict_code_provider[provider_name] = str(ez_p)
@ -281,6 +299,7 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower):
If the value are between parenthsesis donothing
Else put the parenthsesis
"""
size_raw = str(size_raw)
if any([size_raw.startswith('='),
size_raw.startswith("(") and size_raw.endswith(")")]):
@ -326,10 +345,12 @@ def create_ezfio_config(dict_ezfio_cfg, opt, module_lower):
else:
size_raw = None
# It is the last so we don't need to right align it
str_size = size_format_to_ezfio(size_raw) if size_raw else ""
# Get the string in to good format (left align and co)
str_name = str_name_format(name_raw)
str_fortran_type = str_type_format(fortran_type_raw)
str_size = size_format_to_ezfio(size_raw) if size_raw else ""
# Return the string
s = " {0} {1} {2}".format(str_name, str_fortran_type, str_size)

View File

@ -43,7 +43,8 @@ END_PROVIDER
exec "self.%s = None" % (v) in locals()
def __repr__(self):
self.get_default()
if not self.default:
self.get_default()
self.set_write()
for v in self.values:
exec "test = self.%s is None" % (v) in locals()