diff --git a/mbtrack2/__init__.py b/mbtrack2/__init__.py index 77657f558f4fc809c692c871ace05babc4f38af0..83082c2c222729087eb3770fe2cc4b55750de30a 100644 --- a/mbtrack2/__init__.py +++ b/mbtrack2/__init__.py @@ -32,17 +32,29 @@ except: dirty = False -print(("mbtrack2 version " + __version__)) -if dirty: - print("(dirty git work tree)") -print(50 * '-') -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)." -) -print( - "[1] A. Gamelin, W. Foosang, N. Yamamoto, V. Gubaidulin and R. Nagaoka, “mbtrack2â€. Zenodo, Jull. 17, 2024. doi: 10.5281/zenodo.12749990." -) -print( - "[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") + +def print_version(): + print(("mbtrack2 version " + __version__)) + if dirty: + print("(dirty git work tree)") + print(50 * '-') + 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)." + ) + print( + "[1] A. Gamelin, W. Foosang, N. Yamamoto, V. Gubaidulin and R. Nagaoka, “mbtrack2â€. Zenodo, Jull. 17, 2024. doi: 10.5281/zenodo.12749990." + ) + print( + "[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() diff --git a/mbtrack2/tracking/monitors/monitors.py b/mbtrack2/tracking/monitors/monitors.py index ee16f66703a994f8065a8d161252dc308bdee78d..029c21cd255a6db771c48e2f91b7eafbbb088b9f 100644 --- a/mbtrack2/tracking/monitors/monitors.py +++ b/mbtrack2/tracking/monitors/monitors.py @@ -197,7 +197,6 @@ class Monitor(Element, metaclass=ABCMeta): self.file[ self.group_name][key][slice_tuple] = self.__getattribute__(key) - self.file.flush() self.write_count += 1 def to_buffer(self, object_to_save): @@ -944,7 +943,6 @@ class WakePotentialMonitor(Monitor): self.buffer_size] = self.__getattribute__("dipole_" + dim) - self.file.flush() self.write_count += 1 def track(self, object_to_save, wake_potential_to_save): @@ -1304,7 +1302,6 @@ class BunchSpectrumMonitor(Monitor): self.buffer_size:(self.write_count + 1) * self.buffer_size] = self.coherent_o - self.file.flush() self.write_count += 1 def get_incoherent_spectrum(self, positions):