From a859b734ea53fcc798a8e403854f239d87c3a018 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 8 Jan 2018 13:01:32 -0600 Subject: [PATCH] Allow OMP_SCHEDULE to control schedule of main parallel do loop --- src/initialize.F90 | 11 +++++++++++ src/simulation.F90 | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/initialize.F90 b/src/initialize.F90 index 392e8d6bab..dd7894f96b 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -45,6 +45,9 @@ contains integer, intent(in), optional :: intracomm ! MPI intracommunicator integer :: err +#ifdef _OPENMP + character(MAX_WORD_LEN) :: envvar +#endif ! Copy the communicator to a new variable. This is done to avoid changing ! the signature of this subroutine. If MPI is being used but no communicator @@ -76,6 +79,14 @@ contains call initialize_mpi(comm) #endif +#ifdef _OPENMP + ! Change schedule of main parallel-do loop if OMP_SCHEDULE is set + call get_environment_variable("OMP_SCHEDULE", envvar) + if (len_trim(envvar) == 0) then + call omp_set_schedule(omp_sched_static, 0) + end if +#endif + ! Initialize HDF5 interface call hdf5_initialize() diff --git a/src/simulation.F90 b/src/simulation.F90 index e8997fc9b8..c80954f3f9 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -100,7 +100,7 @@ contains ! ==================================================================== ! LOOP OVER PARTICLES -!$omp parallel do schedule(static) firstprivate(p) copyin(tally_derivs) +!$omp parallel do schedule(runtime) firstprivate(p) copyin(tally_derivs) PARTICLE_LOOP: do i_work = 1, work current_work = i_work