def __init__(self, fortran=None, *args, **kwargs):
"""
To use the pyOM2 legacy interface point the fortran argument to the Veros fortran library:
> simulation = GlobalOneDegree(fortran = "pyOM_code.so")
"""
if fortran:
self.legacy_mode = True
try:
self.fortran = LowercaseAttributeWrapper(imp.load_dynamic("pyOM_code", fortran))
self.use_mpi = False
except ImportError:
self.fortran = LowercaseAttributeWrapper(imp.load_dynamic("pyOM_code_MPI", fortran))
self.use_mpi = True
from mpi4py import MPI
self.mpi_comm = MPI.COMM_WORLD
self.main_module = LowercaseAttributeWrapper(self.fortran.main_module)
self.isoneutral_module = LowercaseAttributeWrapper(self.fortran.isoneutral_module)
self.idemix_module = LowercaseAttributeWrapper(self.fortran.idemix_module)
self.tke_module = LowercaseAttributeWrapper(self.fortran.tke_module)
self.eke_module = LowercaseAttributeWrapper(self.fortran.eke_module)
else:
self.legacy_mode = False
self.use_mpi = False
self.fortran = self
self.main_module = self
self.isoneutral_module = self
self.idemix_module = self
self.tke_module = self
self.eke_module = self
self.modules = (self.main_module, self.isoneutral_module, self.idemix_module,
self.tke_module, self.eke_module)
if self.use_mpi and self.mpi_comm.Get_rank() != 0:
kwargs["loglevel"] = "critical"
super(VerosLegacy, self).__init__(*args, **kwargs)
评论列表
文章目录