Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmtb-gfsphysics (aka ccpp-physics): fix for PGI with OpenMP #60

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions IPD_layer/IPD_CCPP_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,28 @@ subroutine IPD_step (IPD_Control, IPD_Data, IPD_Diag, IPD_Restart, IPD_Interstit
! Allocate cdata structures
allocate(cdata_block(1:nBlocks,1:nThreads))

#ifndef __PGI
! Loop over blocks for each of the threads
!$OMP parallel default (shared) &
!$OMP parallel num_threads (nThreads) &
!$OMP default (shared) &
!$OMP private (nb,nt) &
!$OMP reduction (+:ierr)
#ifdef OPENMP
nt = omp_get_thread_num()+1
#else
nt = 1
#endif
#else
do nt=1,nThreads
#endif
do nb = 1,nBlocks
#ifndef __PGI
!--- Initialize CCPP, use suite from scalar cdata to avoid reading the SDF multiple times
call ccpp_init(ccpp_suite, cdata_block(nb,nt), ierr, suite=cdata%suite)
#else
!--- Initialize CCPP, cannot use suite from scalar cdata with PGI (crashes)
call ccpp_init(ccpp_suite, cdata_block(nb,nt), ierr)
#endif
if (ierr/=0) then
write(0,'(2(a,i4))') "An error occurred in IPD_step 0 for block ", nb, " and thread ", nt
exit
Expand All @@ -140,7 +150,11 @@ subroutine IPD_step (IPD_Control, IPD_Data, IPD_Diag, IPD_Restart, IPD_Interstit
#include "ccpp_fields.inc"
! End include auto-generated list of calls to ccpp_field_add
end do
#ifndef __PGI
!$OMP end parallel
#else
end do
#endif
if (ierr/=0) return

! Time vary steps
Expand All @@ -161,7 +175,8 @@ subroutine IPD_step (IPD_Control, IPD_Data, IPD_Diag, IPD_Restart, IPD_Interstit
! Radiation, physics and stochastics
else if (step==2 .or. step==3 .or. step==4) then

!$OMP parallel do default (none) &
!$OMP parallel do num_threads (nThreads) &
!$OMP default (none) &
!$OMP schedule (dynamic,1) &
!$OMP shared (nBlocks, cdata_block, step, IPD_Interstitial) &
!$OMP private (nb, nt) &
Expand All @@ -184,7 +199,8 @@ subroutine IPD_step (IPD_Control, IPD_Data, IPD_Diag, IPD_Restart, IPD_Interstit
! Finalize
else if (step==5) then

!$OMP parallel default (shared) &
!$OMP parallel num_threads (nThreads) &
!$OMP default (shared) &
!$OMP private (nb,nt) &
!$OMP reduction (+:ierr)
#ifdef OPENMP
Expand Down