print PyLammps deprecation warning only once and only from MPI rank 0

This commit is contained in:
Axel Kohlmeyer
2025-01-13 00:04:14 -05:00
parent dd6fea3fcd
commit d692a99e4d

View File

@ -449,12 +449,6 @@ class PyLammps(object):
"""
def __init__(self, name="", cmdargs=None, ptr=None, comm=None, verbose=False):
print("WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING")
print()
print("The PyLammps interface is deprecated and will be removed in future versions.")
print("Please use the lammps Python class instead.")
print()
print("WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING")
self.has_echo = False
self.verbose = verbose
@ -477,7 +471,10 @@ class PyLammps(object):
self.comm_me = self.lmp.extract_setting("world_rank")
if self.comm_me == 0:
print("\nWARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING")
print("WARNING:")
print("WARNING: The PyLammps class is obsolete and will be removed from LAMMPS soon.")
print("WARNING: Please use the lammps Python class instead.")
print("WARNING:")
print("WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n")
print("LAMMPS output is captured by PyLammps wrapper")
if self.comm_nprocs > 1: