From 6785ccc302dca528cae2a1f2b577389428cd86ff Mon Sep 17 00:00:00 2001 From: Marcos Longo <5891904+mpaiao@users.noreply.github.com> Date: Fri, 12 Jun 2026 07:25:10 -0300 Subject: [PATCH 1/2] Make allocation of cpus and threads dynamic This is an attempt to fix issue #436. Instead of hard coding the number of threads and cpus, we allocate them based on the information retrieved by the intrinsic functions. --- ED/src/driver/edmain.F90 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ED/src/driver/edmain.F90 b/ED/src/driver/edmain.F90 index 7be848c37..67161ea30 100644 --- a/ED/src/driver/edmain.F90 +++ b/ED/src/driver/edmain.F90 @@ -49,8 +49,8 @@ program main integer :: num_procs !<= omp_get_num_procs() integer :: thread integer :: cpu - integer, dimension(64) :: thread_use - integer, dimension(64) :: cpu_use + integer, dimension(:), allocatable :: thread_use + integer, dimension(:), allocatable :: cpu_use integer, external :: findmycpu !---------------------------------------------------------------------------------------! @@ -191,6 +191,8 @@ program main cpu_use(:) = 0 !$ max_threads = omp_get_max_threads() !$ num_procs = omp_get_num_procs() + allocate(thread_use(max_threads)) + allocate(cpu_use(num_procs)) !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(thread,cpu) do n = 1,max_threads @@ -308,6 +310,12 @@ program main end select !---------------------------------------------------------------------------------------! + + !----- Deallocate arrays ---------------------------------------------------------------! + deallocate(thread_use) + deallocate(cpu_use) + !---------------------------------------------------------------------------------------! + stop end program main !==========================================================================================! From 108d598dbf18775d1d117d77860dd93013a51e2a Mon Sep 17 00:00:00 2001 From: Marcos Longo <5891904+mpaiao@users.noreply.github.com> Date: Fri, 12 Jun 2026 11:24:49 -0300 Subject: [PATCH 2/2] Update edmain.F90 --- ED/src/driver/edmain.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ED/src/driver/edmain.F90 b/ED/src/driver/edmain.F90 index 67161ea30..3b0bbba53 100644 --- a/ED/src/driver/edmain.F90 +++ b/ED/src/driver/edmain.F90 @@ -187,12 +187,12 @@ program main num_procs = 1 thread = 1 cpu = 1 - thread_use(:) = 0 - cpu_use(:) = 0 !$ max_threads = omp_get_max_threads() !$ num_procs = omp_get_num_procs() allocate(thread_use(max_threads)) allocate(cpu_use(num_procs)) + thread_use(:) = 0 + cpu_use(:) = 0 !$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(thread,cpu) do n = 1,max_threads