Skip to content

Commit 6ae49ac

Browse files
authored
NTasks & Timestep Changes suggested by Mike (#18)
* Changes requested by Mike * Bleh * Test ' * Update m6c commit * Add min cores thing * m6b update
1 parent 52cea7e commit 6ae49ac

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

tests/1_unit/test_cores_case_creator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def test_calc_cores_based_on_grid_cases():
1717
assert CaseCreator._calc_cores_based_on_grid(33) == 1
1818

1919
# Test ideal cores amount
20-
assert CaseCreator._calc_cores_based_on_grid(800*128) == 128
20+
assert CaseCreator._calc_cores_based_on_grid(300*128) == 128
2121

22-
assert CaseCreator._calc_cores_based_on_grid(800*32) == 128
22+
assert CaseCreator._calc_cores_based_on_grid(300*32) == 128
2323

24-
assert CaseCreator._calc_cores_based_on_grid(740 * 780) == 768
24+
assert CaseCreator._calc_cores_based_on_grid(740 * 780) == 2048
2525

2626

2727

visualCaseGen/custom_widget_types/case_creator.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,19 +517,21 @@ def _apply_all_xmlchanges(self, do_exec):
517517
xmlchange("NTASKS_OCN",cores, do_exec, self._is_non_local(), self._out)
518518

519519
@staticmethod
520-
def _calc_cores_based_on_grid( num_points, min_points_per_core = 32, max_points_per_core = 800, ideal_multiple_of_cores_used = 128):
520+
def _calc_cores_based_on_grid( num_points, min_points_per_core = 32, max_points_per_core = 300, ideal_multiple_of_cores_used = 128):
521521
"""Calculate the number of cores based on the grid size."""
522522

523523

524524
min_cores = math.ceil(num_points/max_points_per_core)
525-
max_cores = math.ceil(num_points/min_points_per_core)
525+
max_cores = math.ceil(num_points/min_points_per_core)
526+
527+
# If min_cores is less than the first multiple of ideal cores, just return the min_cores
528+
if min_cores < ideal_multiple_of_cores_used:
529+
return min_cores
526530

527531
# Request a multiple of the entire core (ideal_multiple_of_cores_used) starting from the min
528532
ideal_cores = ((min_cores + ideal_multiple_of_cores_used - 1) // ideal_multiple_of_cores_used) * ideal_multiple_of_cores_used
529-
if ideal_cores <= max_cores:
530-
return ideal_cores
531-
else:
532-
return (max_cores+min_cores)//2
533+
return ideal_cores
534+
533535

534536
def _apply_user_nl_changes(self, model, var_val_pairs, do_exec, comment=None, log_title=True):
535537
"""Apply changes to a given user_nl file."""
@@ -586,7 +588,7 @@ def _apply_mom_namelist_changes(self, do_exec):
586588
# Determine timesteps based on the grid resolution (assuming coupling frequency of 1800.0 sec):
587589
res_x = float(cvars['OCN_LENX'].value) / int(cvars["OCN_NX"].value)
588590
res_y = float(cvars['OCN_LENY'].value) / int(cvars["OCN_NY"].value)
589-
dt = 600.0 * min(res_x,res_y) # A 1-deg grid should have ~600 sec tstep (a safe value)
591+
dt = 7200.0 * min(res_x,res_y) # A 1-deg grid should have ~600 sec tstep (a safe value)
590592
# Make sure 1800.0 is a multiple of dt and dt is a power of 2 and/or 3:
591593
dt = min((1800.0 / n for n in [2**i * 3**j for i in range(10) for j in range(6)] if 1800.0 % n == 0), key=lambda x: abs(dt - x))
592594
# Try setting dt_therm to dt*4, or dt*3, or dt*3, depending on whether 1800.0 becomes a multiple of dt:

0 commit comments

Comments
 (0)