Skip to content

Commit

Permalink
MOM: Mask table file search
Browse files Browse the repository at this point in the history
We have included an option for MOM models to search for a mask_table
file suitable for the run.  This is very limited in scope, and will only
work if there is a file of format `mask_table.NMASK.MxN` where NMASK is
the number of masked CPUs and MxN is the nominal CPU layout.
In particular, the CPU request must match `M*N - NMASK` and the `layout`
namelist variable must be equal to (M, N).

This may only have limited use, and may not persist for much longer, but
is useful for dynamically selecting a mask table against a precomputed
set of tables.
  • Loading branch information
marshallward committed Dec 4, 2018
1 parent b5229d0 commit d8dc05e
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion payu/models/mom.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import f90nml
import payu.envmod
from payu.models.fms import Fms
from payu.fsops import mkdir_p
from payu.fsops import mkdir_p, make_symlink


class Mom(Fms):
Expand Down Expand Up @@ -92,8 +92,40 @@ def setup(self):

# Construct the land CPU mask
if self.expt.config.get('mask_table', False):
# NOTE: This function actually creates a mask table using the
# `check_mask` command line tool. But it is not very usable
# since you need to know the number of masked CPUs to submit
# the job. It needs a rethink of the submission process.
self.create_mask_table(input_nml)

# NOTE: Don't expect this to be here forever...
# Attempt to set a mask table from the input
if self.config.get('mask', False):
mask_path = os.path.join(self.work_input_path, 'ocean_mask_table')

# Remove any existing mask
# (If no reference mask is available, then we will not use one)
if os.path.isfile(mask_path):
os.remove(mask_path)

# Reference mask table
assert('layout' in input_nml['ocean_model_nml'])
nx, ny = input_nml['ocean_model_nml'].get('layout')
n_masked_cpus = nx * ny - self.config.get('ncpus')

mask_table_fname = 'mask_table.{nmask}.{nx}x{ny}'.format(
nmask=n_masked_cpus,
nx=nx,
ny=ny
)

ref_mask_path = os.path.join(self.work_input_path,
mask_table_fname)

# Set (or replace) mask table if reference is available
if os.path.isfile(ref_mask_path):
make_symlink(ref_mask_path, mask_path)

def set_timestep(self, timestep):

input_nml_path = os.path.join(self.work_path, 'input.nml')
Expand Down

0 comments on commit d8dc05e

Please sign in to comment.