Skip to content

Commit a010381

Browse files
authored
Merge pull request #225 from cbegeman/fixup-partition-file-presence
Fixup partition file presence Include graph partition file only when the ocean model is MPAS-Ocean so there aren't unnecessary files in Omega tests.
2 parents 5caa4d2 + d284d33 commit a010381

File tree

25 files changed

+97
-64
lines changed

25 files changed

+97
-64
lines changed

docs/developers_guide/framework/model.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ method, you can set number of tasks, threads, etc. determined from the
2020
`openmp_threads` attributes. These resources need to be set at construction or
2121
in the {ref}`dev-step-setup` method (i.e. before calling {ref}`dev-step-run`)
2222
so that the polaris framework can ensure that the required resources are
23-
available.
23+
available. If the graph partition file has been constructed prior to the ocean
24+
model step, the path to the graph file should be provided in the
25+
`graph_target` argument to {py:meth}`polaris.ocean.OceanModelStep.__init__()`.
2426

2527
(dev-model-yaml-namelists-and-streams)=
2628

docs/developers_guide/ocean/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
216216
init.Init
217217
init.Init.run
218+
init.Init.setup
218219
219220
viz.Viz
220221
viz.Viz.run

docs/developers_guide/organization/steps.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ class SetupMesh(Step):
244244
self.add_input_file(filename='mpas_grid.nc',
245245
target='dome_varres_grid.nc', database='')
246246

247-
self.add_output_file(filename='graph.info')
248247
self.add_output_file(filename='landice_grid.nc')
249248
```
250249

@@ -366,8 +365,6 @@ class Forward(OceanModelStep):
366365

367366
self.add_input_file(filename='initial_state.nc',
368367
target='../../init/initial_state.nc')
369-
self.add_input_file(filename='graph.info',
370-
target='../../init/culled_graph.info')
371368

372369
self.add_yaml_file('polaris.ocean.tasks.baroclinic_channel',
373370
'forward.yaml')
@@ -803,9 +800,6 @@ def __init__(self, component, mesh, init):
803800
self.add_input_file(
804801
filename='forcing_data.nc',
805802
work_dir_target=f'{init.path}/init/init_mode_forcing_data.nc')
806-
self.add_input_file(
807-
filename='graph.info',
808-
work_dir_target=f'{mesh_path}/culled_graph.info')
809803
```
810804

811805
(dev-step-input-polaris)=

docs/tutorials/dev_add_test_group.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,7 @@ class Init(Step):
10241024
10251025
self.resolution = resolution
10261026
1027-
for file in ['base_mesh.nc', 'culled_mesh.nc', 'culled_graph.info',
1028-
'initial_state.nc']:
1027+
for file in ['base_mesh.nc', 'culled_mesh.nc', 'initial_state.nc']:
10291028
self.add_output_file(file)
10301029
```
10311030

@@ -1286,8 +1285,6 @@ class Forward(OceanModelStep):
12861285
12871286
self.add_input_file(filename='initial_state.nc',
12881287
target='../init/initial_state.nc')
1289-
self.add_input_file(filename='graph.info',
1290-
target='../init/culled_graph.info')
12911288
12921289
self.add_output_file(filename='output.nc')
12931290
```

polaris/ocean/convergence/forward.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ConvergenceForward(OceanModelStep):
2121

2222
def __init__(self, component, name, subdir, resolution, mesh, init,
2323
package, yaml_filename='forward.yaml', options=None,
24-
graph_filename='graph.info', output_filename='output.nc',
24+
graph_target=None, output_filename='output.nc',
2525
validate_vars=None):
2626
"""
2727
Create a new step
@@ -50,6 +50,10 @@ def __init__(self, component, name, subdir, resolution, mesh, init,
5050
A nested dictionary of options and value for each ``config_model``
5151
to replace model config options with new values
5252
53+
graph_target : str, optional
54+
The graph file name (relative to the base work directory).
55+
If none, it will be created.
56+
5357
output_filename : str, optional
5458
The output file that will be written out at the end of the forward
5559
run
@@ -58,7 +62,7 @@ def __init__(self, component, name, subdir, resolution, mesh, init,
5862
A list of variables to validate against a baseline if requested
5963
"""
6064
super().__init__(component=component, name=name, subdir=subdir,
61-
openmp_threads=1)
65+
openmp_threads=1, graph_target=graph_target)
6266

6367
self.resolution = resolution
6468
self.package = package
@@ -75,9 +79,6 @@ def __init__(self, component, name, subdir, resolution, mesh, init,
7579
self.add_input_file(
7680
filename='init.nc',
7781
work_dir_target=f'{init.path}/initial_state.nc')
78-
self.add_input_file(
79-
filename='graph.info',
80-
work_dir_target=f'{mesh.path}/{graph_filename}')
8182

8283
self.add_output_file(filename=output_filename,
8384
validate_vars=validate_vars)

polaris/ocean/ice_shelf/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, component, min_resolution, name, subdir, sshdir=None):
5050
self.component = component
5151
self.min_resolution = min_resolution
5252

53-
def setup_ssh_adjustment_steps(self, mesh_filename, graph_filename,
53+
def setup_ssh_adjustment_steps(self, mesh_filename, graph_target,
5454
init_filename, config, config_filename,
5555
ForwardStep, package=None,
5656
yaml_filename='ssh_forward.yaml',
@@ -67,7 +67,7 @@ def setup_ssh_adjustment_steps(self, mesh_filename, graph_filename,
6767
mesh_filename : str
6868
the mesh filename (relative to the base work directory)
6969
70-
graph_filename : str
70+
graph_target: str
7171
the graph filename (relative to the base work directory)
7272
7373
init_filename : str
@@ -114,7 +114,7 @@ def setup_ssh_adjustment_steps(self, mesh_filename, graph_filename,
114114
else:
115115
ssh_forward = ForwardStep(
116116
component=component, min_resolution=min_resolution,
117-
indir=indir, graph_filename=graph_filename,
117+
indir=indir, graph_target=graph_target,
118118
init_filename=current_init_filename, name=name,
119119
package=package, yaml_filename=yaml_filename,
120120
yaml_replacements=yaml_replacements)

polaris/ocean/ice_shelf/ssh_forward.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SshForward(OceanModelStep):
2222
file
2323
"""
2424
def __init__(self, component, min_resolution, init_filename,
25-
graph_filename, name='ssh_forward', subdir=None,
25+
graph_target, name='ssh_forward', subdir=None,
2626
package=None, yaml_filename='ssh_forward.yaml',
2727
yaml_replacements=None, indir=None, ntasks=None,
2828
min_tasks=None, openmp_threads=1):
@@ -41,7 +41,7 @@ def __init__(self, component, min_resolution, init_filename,
4141
the initial condition filename (relative to the base work
4242
directory)
4343
44-
graph_filename : str
44+
graph_target: str
4545
the graph filename (relative to the base work directory)
4646
4747
name : str, optional
@@ -78,7 +78,8 @@ def __init__(self, component, min_resolution, init_filename,
7878
"""
7979
super().__init__(component=component, name=name, subdir=subdir,
8080
indir=f'{indir}/ssh_adjustment', ntasks=ntasks,
81-
min_tasks=min_tasks, openmp_threads=openmp_threads)
81+
min_tasks=min_tasks, openmp_threads=openmp_threads,
82+
graph_target=graph_target)
8283

8384
self.min_resolution = min_resolution
8485
self.package = package
@@ -91,7 +92,7 @@ def __init__(self, component, min_resolution, init_filename,
9192
self.add_input_file(filename='init.nc',
9293
work_dir_target=init_filename)
9394
self.add_input_file(filename='graph.info',
94-
work_dir_target=graph_filename)
95+
work_dir_target=graph_target)
9596

9697
self.add_output_file(
9798
filename='output.nc',

polaris/ocean/model/ocean_model_step.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ class OceanModelStep(ModelStep):
2020
map : dict
2121
A nested dictionary that maps from MPAS-Ocean to Omega model config
2222
options
23+
24+
graph_target : str
25+
The name of the graph partition file to link to (relative to the base
26+
working directory)
2327
"""
2428
def __init__(self, component, name, subdir=None, indir=None, ntasks=None,
2529
min_tasks=None, openmp_threads=None, max_memory=None,
2630
cached=False, yaml=None, update_pio=True, make_graph=False,
27-
mesh_filename=None, partition_graph=True,
28-
graph_filename='graph.info'):
31+
mesh_filename=None, partition_graph=True, graph_target=None):
2932
"""
3033
Make a step for running the model
3134
@@ -84,20 +87,25 @@ def __init__(self, component, name, subdir=None, indir=None, ntasks=None,
8487
If so, the partitioning executable is taken from the ``partition``
8588
option of the ``[executables]`` config section.
8689
87-
graph_filename : str, optional
88-
The name of the graph file to partition
90+
graph_target : str, optional
91+
The graph file name (relative to the base work directory).
92+
If none, it will be created.
8993
"""
94+
if graph_target is None:
95+
self.make_graph = True
96+
9097
super().__init__(
9198
component=component, name=name, subdir=subdir, indir=indir,
9299
ntasks=ntasks, min_tasks=min_tasks, openmp_threads=openmp_threads,
93100
max_memory=max_memory, cached=cached, yaml=yaml,
94101
update_pio=update_pio, make_graph=make_graph,
95102
mesh_filename=mesh_filename, partition_graph=partition_graph,
96-
graph_filename=graph_filename)
103+
graph_filename='graph.info')
97104

98105
self.dynamic_ntasks = (ntasks is None and min_tasks is None)
99106

100107
self.map: Union[None, List[Dict[str, Dict[str, str]]]] = None
108+
self.graph_target = graph_target
101109

102110
def setup(self):
103111
"""
@@ -112,9 +120,14 @@ def setup(self):
112120
self.config_models = ['ocean', 'Omega']
113121
self.yaml = 'omega.yml'
114122
self._read_map()
123+
self.partition_graph = False
115124
elif model == 'mpas-ocean':
116125
self.config_models = ['ocean', 'mpas-ocean']
117126
self.make_yaml = False
127+
self.add_input_file(
128+
filename='graph.info',
129+
work_dir_target=self.graph_target)
130+
118131
else:
119132
raise ValueError(f'Unexpected ocean model: {model}')
120133

polaris/ocean/tasks/baroclinic_channel/decomp/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def __init__(self, component, resolution, indir, init):
3939
self.add_step(Forward(
4040
component=component, name=name, indir=self.subdir,
4141
ntasks=procs, min_tasks=procs, openmp_threads=1,
42-
resolution=resolution, run_time_steps=3))
42+
resolution=resolution, run_time_steps=3,
43+
graph_target=f'{init.path}/culled_graph.info'))
4344
subdirs.append(name)
4445
self.add_step(Validate(component=component, step_subdirs=subdirs,
4546
indir=self.subdir))

polaris/ocean/tasks/baroclinic_channel/default/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def __init__(self, component, resolution, indir, init):
3434
self.add_step(
3535
Forward(component=component, indir=self.subdir, ntasks=None,
3636
min_tasks=None, openmp_threads=1, resolution=resolution,
37-
run_time_steps=3))
37+
run_time_steps=3,
38+
graph_target=f'{init.path}/culled_graph.info'))
3839

3940
self.add_step(
4041
Viz(component=component, indir=self.subdir))

0 commit comments

Comments
 (0)