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 026c9c61e7..ef29e7832b 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -101,7 +101,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