Skip to content

Vectorize subcolumn loop, enhance parallelism, and update dependencies - #161

Merged
isilber merged 3 commits into
ARM-DOE:masterfrom
isilber:optimize_subcolumn
Jul 31, 2026
Merged

Vectorize subcolumn loop, enhance parallelism, and update dependencies#161
isilber merged 3 commits into
ARM-DOE:masterfrom
isilber:optimize_subcolumn

Conversation

@isilber

@isilber isilber commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements to the parallel processing capabilities and dependency management for the subcolumn module. The main focus is on enhancing flexibility and performance for parallel execution, simplifying code paths, and ensuring all required dependencies are explicitly listed.

Dependency and Environment Updates:

  • Added tqdm to the dependencies
    Parallelization and Code Structure Improvements:
  • Updated parallelization logic in subcolumn.py
    Algorithmic and Code Quality Improvements:
  • Refactored the stratiform subcolumn allocation logic to use lists instead of dynamic variable names, which improves code clarity and robustness.
  • Optimized the convective subcolumn profile allocation with a vectorized approach for improved performance and simplicity.

These changes collectively enhance the usability, flexibility, and performance of the simulation code, especially for users running on different hardware setups or requiring better progress monitoring during parallel execution.

isilber added 3 commits July 31, 2026 21:25
In set_convective_sub_col_frac:
Replace nested for-i/for-k loop with a single broadcast expression:
  conv_profs = (np.arange(1, N+1)[:, None, None] <= data_frac[None, :, :])
in _allocate_strat_sub_col:
- np.argwhere → np.flatnonzero for overlying_locs1/2
- Replace all locals()["overlying_locs%d" % (Iover_min/max + 1)]
…lumn.py`)

In set_stratiform_sub_col_frac / set_precip_sub_col_frac / set_q_n:
- Replace lambda closures with functools.partial so the worker callable is
  picklable by both Dask and multiprocessing backends.
- Add a second parallel call path: parallel='processes' uses
  ProcessPoolExecutor + tqdm (lower overhead on a single workstation);
  parallel=True or 'dask' (default, unchanged behaviour) uses dask.bag +
  dask.diagnostics.ProgressBar (compatible with multi-node Dask schedulers on HPC).
  parallel=False runs serially as before.
- Remove the manual chunked while-loop that was a workaround for Dask task-queue
  freezes caused by unpicklable lambdas; no longer needed.
- Add a labelled progress indicator for each path: desc= label on tqdm bars
  ('processes'), and a matching print label immediately before each ProgressBar
  context (Dask).

dependencies:
- Add numba and tqdm to requirements.txt, setup.py install_requires, and all five
  conda environment YMLs under continuous_integration/.
@isilber
isilber merged commit bc890a9 into ARM-DOE:master Jul 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant