Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added cmake option to test whether do concurrent accepts local-spec. …
Browse files Browse the repository at this point in the history
…Newer versions of ifort segfault without it. Old ones can't compile with it.
  • Loading branch information
daminton committed May 19, 2023
1 parent a85d5ad commit cda911f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
23 changes: 22 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,25 @@ IF(BT STREQUAL "DEBUG")
ADD_DEFINITIONS(-DDEBUG)
ELSEIF(BT STREQUAL "PROFILE")
ADD_DEFINITIONS(-DPROFILE)
ENDIF()
ENDIF()

# Check to see if the compiler allows for local-spec in do concurrent statements. Set a preprocessor variable if it does
IF (USE_OPENMP)
SET(TESTFILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
SET(TESTFILE "${TESTFILE}/CMakeTmp/testFortranDoConcurrentLoc.f90")
FILE(WRITE "${TESTFILE}"
"
program TestDoConcurrentLoc
integer :: i
real,dimension(10) :: a
do concurrent(i = 1:10) shared(a)
a(i) = i
end do
end program TestDoConcurrentLoc
")
TRY_COMPILE(DOCONLOC_WORKS ${CMAKE_BINARY_DIR} ${TESTFILE}
COMPILE_DEFINITIONS "${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE OUTPUT)
IF (DOCONLOC_WORKS)
TARGET_COMPILE_DEFINITIONS(${SWIFTEST_DRIVER} PRIVATE -DDOCONLOC)
ENDIF (DOCONLOC_WORKS)
ENDIF (USE_OPENMP)
19 changes: 9 additions & 10 deletions src/encounter/encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, rplm, vplm, rplt,
integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! List of indices for body 2 in each encounter
logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x
! Internals
! type(interaction_timer), save :: itimer
logical, save :: lfirst = .true.
logical, save :: skipit = .false.
integer(I8B) :: nplplm = 0_I8B
integer(I4B) :: npl
logical, dimension(:), allocatable :: plmplt_lvdotr !! Logical flag indicating the sign of v .dot. x in the plm-plt group
integer(I4B), dimension(:), allocatable :: plmplt_index1 !! List of indices for body 1 in each encounter in the plm-plt group
integer(I4B), dimension(:), allocatable :: plmplt_index2 !! List of indices for body 2 in each encounter in the plm-lt group
Expand Down Expand Up @@ -387,7 +382,11 @@ subroutine encounter_check_all_triangular_one(i, n, xi, yi, zi, vxi, vyi, vzi, x
real(DP) :: xr, yr, zr, vxr, vyr, vzr, renc12
logical, dimension(n) :: lencounteri, lvdotri

#ifdef DOCONLOC
do concurrent(j = i+1:n) shared(lencounteri, lvdotri)
#else
do concurrent(j = i+1:n)
#endif
xr = x(j) - xi
yr = y(j) - yi
zr = z(j) - zi
Expand Down Expand Up @@ -605,11 +604,11 @@ module subroutine encounter_check_collapse_ragged_list(ragged_list, n1, nenc, in
implicit none
! Arguments
class(encounter_list), dimension(:), intent(in) :: ragged_list !! The ragged encounter list
integer(I4B), intent(in) :: n1 !! Number of bodies 1
integer(I8B), intent(out) :: nenc !! Total number of encountersj
integer(I4B), dimension(:), allocatable, intent(out) :: index1 !! Array of indices for body 1
integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! Array of indices for body 1
logical, dimension(:), allocatable, intent(out), optional :: lvdotr !! Array indicating which bodies are approaching
integer(I4B), intent(in) :: n1 !! Number of bodies 1
integer(I8B), intent(out) :: nenc !! Total number of encountersj
integer(I4B), dimension(:), allocatable, intent(out) :: index1 !! Array of indices for body 1
integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! Array of indices for body 1
logical, dimension(:), allocatable, intent(out), optional :: lvdotr !! Array indicating which bodies are approaching
! Internals
integer(I4B) :: i
integer(I8B) :: j1, j0, nenci
Expand Down

0 comments on commit cda911f

Please sign in to comment.