@@ -1180,7 +1180,7 @@ you might try to stress-test your own test case.
11801180
11811181## Adding the forward step
11821182
1183- Now that we know that the first step steems to be working, we're ready to add
1183+ Now that we know that the first step seems to be working, we're ready to add
11841184another. We will add a ` forward ` step for running the MPAS-Ocean model forward
11851185in time from the initial condition created in ` init ` . ` forward `
11861186will be a little more complicated than ` init ` as we get started.
@@ -2022,16 +2022,15 @@ dt_per_km = 30
20222022btr_dt_per_km = 1.5
20232023```
20242024
2025- Unlike in `compute_cell_count()`, we don't do anything differently in
2026- `dynamic_model_config()` here whether it's run at setup or at runtime. The
2027- reason we run it twice is to update the model config options in case the user
2028- modified `dt_per_km` or `btr_dt_per_km` in the config file in the work
2029- directory before running the step.
2025+ We don't do anything differently in `dynamic_model_config()` here whether it's
2026+ run at setup or at runtime. The reason we run it twice is to update the model
2027+ config options in case the user modified `dt_per_km` or `btr_dt_per_km` in the
2028+ config file in the work directory before running the step.
20302029
20312030### Computing the cell count
20322031
20332032In the ocean component, we have infrastructure for determining good values
2034- for `ntask ` and `min_tasks` (the reasonable range of MPI tasks that a forward
2033+ for `ntasks ` and `min_tasks` (the reasonable range of MPI tasks that a forward
20352034model step should use). Using this infrastructure requires overriding the
20362035{py:meth}`polaris.ocean.model.OceanModelStep.compute_cell_count()` method:
20372036
@@ -2045,7 +2044,7 @@ class Forward(OceanModelStep):
20452044
20462045 ...
20472046
2048- def compute_cell_count(self, at_setup ):
2047+ def compute_cell_count(self):
20492048 """
20502049 Compute the approximate number of cells in the mesh, used to constrain
20512050 resources
@@ -2061,32 +2060,21 @@ class Forward(OceanModelStep):
20612060 cell_count : int or None
20622061 The approximate number of cells in the mesh
20632062 """
2064- if at_setup:
2065- # no file to read from, so we'll compute it based on config options
2066- section = self.config['yet_another_channel']
2067- lx = section.getfloat('lx')
2068- ly = section.getfloat('ly')
2069- nx, ny = compute_planar_hex_nx_ny(lx, ly, self.resolution)
2070- cell_count = nx * ny
2071- else:
2072- # get nCells from the input file
2073- with xr.open_dataset('initial_state.nc') as ds:
2074- cell_count = ds.sizes['nCells']
2063+ section = self.config['yet_another_channel']
2064+ lx = section.getfloat('lx')
2065+ ly = section.getfloat('ly')
2066+ nx, ny = compute_planar_hex_nx_ny(lx, ly, self.resolution)
2067+ cell_count = nx * ny
20752068 return cell_count
20762069```
2077- This method gets called once at setup (with `at_setup=True`) and once at
2078- runtime (with `at_setup=False`). We do this because we need to compute or
2079- estimate the size of the mesh during setup so we have a good guess at the
2070+ We need to estimate the size of the mesh so we have a good guess at the
20802071resources it will need when we add it to a test suite and make a job script for
2081- running it. Then, at runtime, we may need to revise that size, either because
2082- it was an estimate only or because it was based on config options that a user
2083- may have changed after setup. Here, we use
2072+ running it. Here, we use
20842073{py:func}`polaris.mesh.planar.compute_planar_hex_nx_ny()` to get `nx` and `ny`
20852074(and thus the total cell count) during setup because we have no other way to
2086- get them (the initial condition has not yet been created, for example). But
2087- at runtime, rather than recomputing them, we look at the initial condition
2088- file that must exist (otherwise the step already would have failed) to see
2089- what the actual number of cells ended up being.
2075+ get them. When using task parallelism, we must use this approximation at
2076+ runtime, because we cannot rely on any tests being completed to use as a basis
2077+ for computation.
20902078
20912079`cell_count` is used in `OceanModelStep` to compute `ntasks` and `min_tasks`
20922080by also using 2 config options:
0 commit comments