*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit d8c20522 authored by Patrick Kappl's avatar Patrick Kappl
Browse files

Make unique copy of config file

Adding a unique ID to the temporary files was not enough to allow
multiple jackknives to run at the same time. The config file must also
be unique.
parent cd445da0
No related branches found
No related tags found
No related merge requests found
......@@ -26,14 +26,17 @@ class Adga(object):
self.n_processes = n_processes
self.executable = adga_root_path + "/bin/abinitiodga"
self.symmetrize_script = adga_root_path + "/scripts/symmetrize.py"
self.config_file_name = adga_config_file_name
# Generate and a unique id for the names of the temporary files.
# This allows to run multiple Jackknives at once.
# Together with a unique copy of the config file, this allows to
# run multiple jackknives at once.
self.unique_id = int(time.time() * 1e6)
self.output_file_name = "adga{}.hdf5".format(self.unique_id)
g4iw_file_name = "g4iw{}.hdf5".format(self.unique_id)
self.symmetry_file_name = "g4iw{}_sym.hdf5".format(self.unique_id)
self.config_file_name = adga_config_file_name.split(".")[0] \
+ str(self.unique_id) + ".conf"
copyfile(adga_config_file_name, self.config_file_name)
self.g2_file = h5py.File(two_particle_greens_function_file_name, "r")
copyfile(two_particle_greens_function_file_name, g4iw_file_name)
......@@ -101,8 +104,9 @@ class Adga(object):
return
def _do_dga_calculation(self):
# Make sure, abinitiodga uses the correct 2-particle and output
# file
# Copy the config file, add the unique ID and set the correct
# 2-particle and output file. This allows to run multiple
# jackknives at the same time without interference.
self._set_value_in_config_file("Two-Particle", "2PFile",
self.symmetry_file_name)
self._set_value_in_config_file("General", "Outfile",
......@@ -120,7 +124,7 @@ class Adga(object):
# config file
file_name = self.config_file_name
new_line = key + " = " + value + "\n"
lines = open(file_name).readlines()
line_is_in_section = False
for line in lines:
......@@ -139,7 +143,7 @@ class Adga(object):
# Add the key-value pair at the end of the section
lines.insert(lines.index(line) - 1, new_line)
break
with open(file_name, "w") as config_file:
for line in lines:
config_file.write(line)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment