Allow OMP_SCHEDULE to control schedule of main parallel do loop

This commit is contained in:
Paul Romano 2018-01-08 13:01:32 -06:00
parent 93746953cc
commit a859b734ea
2 changed files with 12 additions and 1 deletions

View file

@ -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()

View file

@ -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