Skip to content

Commit

Permalink
Create Ntasks Flexibility Function, Put in Apply All XML Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
manishvenu committed Jan 16, 2025
1 parent 9a9b906 commit ab57c0d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 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,27 @@ 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 based on grid size. e.g. NX * NY < max_pts_per_core
self._set_ntasks_based_on_grid(self, do_exec)

def _set_ntasks_based_on_grid(self, do_exec, min_points_per_core = 16, max_points_per_core = 800):
"""Set NTASKS based on Grid Size"""
num_points = int(cvars["OCN_NX"].value) * int(cvars["OCN_NY"].value)
cores = 128 # Default

pts_per_core = num_points/cores

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

while pts_per_core < min_points_per_core:
cores = cores - 1
pts_per_core = num_points/cores

xmlchange("NTASKS",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

0 comments on commit ab57c0d

Please sign in to comment.