Skip to content
Snippets Groups Projects
Commit aa9128da authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Fix monitor flush.

Only print version information for one process.
parent 05bd1af9
No related branches found
No related tags found
2 merge requests!280.8.0,!23Fix monitor flush
...@@ -32,17 +32,29 @@ except: ...@@ -32,17 +32,29 @@ except:
dirty = False dirty = False
print(("mbtrack2 version " + __version__))
if dirty: def print_version():
print("(dirty git work tree)") print(("mbtrack2 version " + __version__))
print(50 * '-') if dirty:
print( print("(dirty git work tree)")
"If used in a publication, please cite mbtrack2 paper and the zenodo archive for the corresponding code version (and other papers for more specific features)." print(50 * '-')
) print(
print( "If used in a publication, please cite mbtrack2 paper and the zenodo archive for the corresponding code version (and other papers for more specific features)."
"[1] A. Gamelin, W. Foosang, N. Yamamoto, V. Gubaidulin and R. Nagaoka, “mbtrack2”. Zenodo, Jull. 17, 2024. doi: 10.5281/zenodo.12749990." )
) print(
print( "[1] A. Gamelin, W. Foosang, N. Yamamoto, V. Gubaidulin and R. Nagaoka, “mbtrack2”. Zenodo, Jull. 17, 2024. doi: 10.5281/zenodo.12749990."
"[2] A. Gamelin, W. Foosang, and R. Nagaoka, “mbtrack2, a Collective Effect Library in Python”, presented at the 12th Int. Particle Accelerator Conf. (IPAC'21), Campinas, Brazil, May 2021, paper MOPAB070." )
) print(
print("\n") "[2] A. Gamelin, W. Foosang, and R. Nagaoka, “mbtrack2, a Collective Effect Library in Python”, presented at the 12th Int. Particle Accelerator Conf. (IPAC'21), Campinas, Brazil, May 2021, paper MOPAB070."
)
print("\n")
try:
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
if rank == 0:
print_version()
except:
print_version()
...@@ -197,7 +197,6 @@ class Monitor(Element, metaclass=ABCMeta): ...@@ -197,7 +197,6 @@ class Monitor(Element, metaclass=ABCMeta):
self.file[ self.file[
self.group_name][key][slice_tuple] = self.__getattribute__(key) self.group_name][key][slice_tuple] = self.__getattribute__(key)
self.file.flush()
self.write_count += 1 self.write_count += 1
def to_buffer(self, object_to_save): def to_buffer(self, object_to_save):
...@@ -944,7 +943,6 @@ class WakePotentialMonitor(Monitor): ...@@ -944,7 +943,6 @@ class WakePotentialMonitor(Monitor):
self.buffer_size] = self.__getattribute__("dipole_" + self.buffer_size] = self.__getattribute__("dipole_" +
dim) dim)
self.file.flush()
self.write_count += 1 self.write_count += 1
def track(self, object_to_save, wake_potential_to_save): def track(self, object_to_save, wake_potential_to_save):
...@@ -1304,7 +1302,6 @@ class BunchSpectrumMonitor(Monitor): ...@@ -1304,7 +1302,6 @@ class BunchSpectrumMonitor(Monitor):
self.buffer_size:(self.write_count + 1) * self.buffer_size:(self.write_count + 1) *
self.buffer_size] = self.coherent_o self.buffer_size] = self.coherent_o
self.file.flush()
self.write_count += 1 self.write_count += 1
def get_incoherent_spectrum(self, positions): def get_incoherent_spectrum(self, positions):
......
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