Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Ntasks Flexibility Function #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
24 changes: 24 additions & 0 deletions visualCaseGen/custom_widget_types/case_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,30 @@ def _apply_all_xmlchanges(self, do_exec):
else:
assert lnd_grid_mode in [None, "", "Standard"], f"Unknown land grid mode: {lnd_grid_mode}"

# Set NTASKS_OCN based on grid size. e.g. NX * NY < max_pts_per_core
self._set_ntasks_ocean_based_on_grid(do_exec)

def _set_ntasks_ocean_based_on_grid(self, do_exec, min_points_per_core = 32, max_points_per_core = 800):
"""Set NTASKS OCN based on Grid Size"""

with self._out:
print(f"{COMMENT}Apply NTASK grid xml changes:{RESET}\n")
num_points = int(cvars["OCN_NX"].value) * int(cvars["OCN_NY"].value)
cores = 128 # Start from 128 which is the default 128 cores per node in derecho
iteration_amount = 16
pts_per_core = num_points/cores

while pts_per_core > max_points_per_core:
cores = cores + iteration_amount
pts_per_core = num_points/cores

while pts_per_core < min_points_per_core and cores > 1: # Don't let cores get below 1
cores = cores - iteration_amount
pts_per_core = num_points/cores

xmlchange("NTASKS_OCN",cores, do_exec, self._is_non_local(), self._out)
return

def _apply_user_nl_changes(self, model, var_val_pairs, do_exec, comment=None, log_title=True):
"""Apply changes to a given user_nl file."""
append_user_nl(model, var_val_pairs, do_exec, comment, log_title, self._out)
Expand Down
Loading