Skip to content

Commit a5d1cb0

Browse files
committed
fixup
1 parent d1c74f4 commit a5d1cb0

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

runs/icon_etopo_global.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -744,21 +744,11 @@ def parallel_wrapper(grid, params, reader, writer, chunk_output_dir, clat_rad, c
744744
n_workers = batch_config['n_workers']
745745
memory_per_worker = f"{int(batch_config['memory_per_worker_gb'])}GB"
746746

747-
# Calculate threads per worker based on configuration
748-
if config['memory_per_cpu_mb'] is not None:
749-
# HPC mode: Distribute total cores evenly across workers
750-
# (Don't use memory_per_cpu_mb to calculate threads - it's unreliable)
751-
threads_per_worker = max(1, config['total_cores'] // n_workers)
752-
else:
753-
# Laptop mode: Calculate based on total available resources
754-
# How many workers can we fit given memory constraints?
755-
max_workers_by_memory = max(1, int(
756-
config['total_memory_gb'] / batch_config['memory_per_worker_gb']
757-
))
758-
# Limit workers to what we actually configured
759-
actual_workers = min(max_workers_by_memory, n_workers)
760-
# Distribute threads evenly across workers
761-
threads_per_worker = max(1, config['total_cores'] // actual_workers)
747+
# CRITICAL: threads_per_worker MUST be 1 because HDF5 is not thread-safe
748+
# HDF5 was not compiled with --enable-threadsafe on this system.
749+
# Even opening different NetCDF files from different threads causes crashes.
750+
# Use more workers instead of threads for parallelism.
751+
threads_per_worker = 1
762752

763753
logger.info(f"\n Starting Dask client for memory batch {mem_batch_idx}:")
764754
logger.info(f" Workers: {n_workers} × {memory_per_worker}")

0 commit comments

Comments
 (0)