Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compass/landice/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,21 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
check_call(args, logger=logger)


def constrain_resources(self, available_resources):
"""
Update ``cpus_per_task`` to use all available cores

Parameters
----------
available_resources : dict
A dictionary containing available resources (cores, tasks, nodes
and cores_per_node)
"""
from compass.step import Step
Step.constrain_resources(self, available_resources)
self.cpus_per_task = available_resources['cores']


def make_region_masks(self, mesh_filename, mask_filename,
cores, tags, component='landice', all_tags=True):
"""
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/antarctica/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
add_bedmachine_thk_to_ais_gridded_data,
build_cell_width,
build_mali_mesh,
constrain_resources,
get_optional_interp_datasets,
make_region_masks,
preprocess_ais_data,
Expand Down Expand Up @@ -35,8 +36,7 @@ def __init__(self, test_case):
The test case this step belongs to

"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

self.mesh_filename = 'Antarctica.nc'
self.add_output_file(filename='graph.info')
Expand All @@ -52,6 +52,9 @@ def __init__(self, test_case):

# no setup() method is needed

def constrain_resources(self, available_resources):
Comment thread
trhille marked this conversation as resolved.
Outdated
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/crane/mesh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.landice.mesh import (
build_cell_width,
build_mali_mesh,
constrain_resources,
get_mesh_config_bounding_box,
get_optional_interp_datasets,
run_optional_interpolation,
Expand All @@ -21,8 +22,7 @@ def __init__(self, test_case):
test_case : compass.TestCase
The test case this step belongs to
"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

self.add_output_file(filename='graph.info')
self.add_output_file(filename='Crane.nc')
Expand All @@ -39,6 +39,9 @@ def __init__(self, test_case):

# no setup() method is needed

def constrain_resources(self, available_resources):
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/greenland/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from compass.landice.mesh import (
build_cell_width,
build_mali_mesh,
constrain_resources,
get_mesh_config_bounding_box,
get_optional_interp_datasets,
make_region_masks,
Expand Down Expand Up @@ -32,8 +33,7 @@ def __init__(self, test_case):
The test case this step belongs to

"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

# output files
self.mesh_filename = 'GIS.nc'
Expand Down Expand Up @@ -64,6 +64,9 @@ def setup(self):
target=geojson_filename,
database=None)

def constrain_resources(self, available_resources):
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/humboldt/mesh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.landice.mesh import (
build_cell_width,
build_mali_mesh,
constrain_resources,
get_mesh_config_bounding_box,
get_optional_interp_datasets,
run_optional_interpolation,
Expand Down Expand Up @@ -30,8 +31,7 @@ def __init__(self, test_case):
mesh_type : str
The resolution or mesh type of the test case
"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

self.add_output_file(filename='graph.info')
self.add_output_file(filename='Humboldt.nc')
Expand All @@ -49,6 +49,9 @@ def __init__(self, test_case):

# no setup() method is needed

def constrain_resources(self, available_resources):
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/kangerlussuaq/mesh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.landice.mesh import (
build_cell_width,
build_mali_mesh,
constrain_resources,
get_mesh_config_bounding_box,
get_optional_interp_datasets,
run_optional_interpolation,
Expand Down Expand Up @@ -31,8 +32,7 @@ def __init__(self, test_case):
mesh_type : str
The resolution or mesh type of the test case
"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

self.add_output_file(filename='graph.info')
self.add_output_file(filename='Kangerlussuaq.nc')
Expand All @@ -50,6 +50,9 @@ def __init__(self, test_case):

# no setup() method is needed

def constrain_resources(self, available_resources):
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/koge_bugt_s/mesh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.landice.mesh import (
build_cell_width,
build_mali_mesh,
constrain_resources,
get_mesh_config_bounding_box,
get_optional_interp_datasets,
run_optional_interpolation,
Expand Down Expand Up @@ -31,8 +32,7 @@ def __init__(self, test_case):
mesh_type : str
The resolution or mesh type of the test case
"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

self.add_output_file(filename='graph.info')
self.add_output_file(filename='Koge_Bugt_S.nc')
Expand All @@ -50,6 +50,9 @@ def __init__(self, test_case):

# no setup() method is needed

def constrain_resources(self, available_resources):
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down
7 changes: 5 additions & 2 deletions compass/landice/tests/thwaites/mesh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compass.landice.mesh import (
build_cell_width,
build_mali_mesh,
constrain_resources,
get_mesh_config_bounding_box,
get_optional_interp_datasets,
run_optional_interpolation,
Expand All @@ -21,8 +22,7 @@ def __init__(self, test_case):
test_case : compass.TestCase
The test case this step belongs to
"""
super().__init__(test_case=test_case, name='mesh', cpus_per_task=128,
min_cpus_per_task=1)
super().__init__(test_case=test_case, name='mesh')

self.add_output_file(filename='graph.info')
self.add_output_file(filename='Thwaites.nc')
Expand All @@ -39,6 +39,9 @@ def __init__(self, test_case):

# no setup() method is needed

def constrain_resources(self, available_resources):
constrain_resources(self, available_resources)

def run(self):
"""
Run this step of the test case
Expand Down