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

Fix handling of OpenMP. #77

Merged
merged 3 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ endif()
# Use OpenMP API in MOPAC for "THREADS" keyword
option(THREADS_KEYWORD "Enable THREADS keyword using OpenMP API" ON)
if(THREADS_KEYWORD)
add_definitions(-DOMP_ENABLED)
find_package(OpenMP)
if(OpenMP_FOUND)
target_compile_options(mopac-core PUBLIC ${OpenMP_Fortran_FLAGS})
endif()
endif()

# Additional link line
Expand Down
2 changes: 1 addition & 1 deletion src/input/wrtkey.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ subroutine wrtwor (allkey)
i = Index (keywrd, " THREADS")
i = nint(reada(keywrd, i))
i = max(i,1)
#ifdef OMP_ENABLED
#ifdef _OPENMP
if (i == 1) then
write (iw,'(" * THREADS=1 - MULTI-THREADING NOT USED")')
else if (i < 10) then
Expand Down
4 changes: 2 additions & 2 deletions src/run_mopac.F90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ subroutine run_mopac
logical :: exists, opend, sparkles_available, l_OLDDEN
double precision, external :: C_triple_bond_C, reada, seconds
character :: nokey(20)*10
#ifdef OMP_ENABLED
#ifdef _OPENMP
integer :: num_threads, default_num_threads
integer, external :: omp_get_max_threads
#endif
Expand Down Expand Up @@ -246,7 +246,7 @@ subroutine run_mopac
if (moperr .and. numcal == 1 .and. index(keywrd_txt," GEO_DAT") == 0) goto 100
if (moperr) goto 101
! Adjust maximum number of threads using the OpenMP API
#ifdef OMP_ENABLED
#ifdef _OPENMP
if (numcal == 1) default_num_threads = omp_get_max_threads()
i = index(keywrd, " THREADS")
if (i > 0) then
Expand Down