Skip to content

Commit 528460b

Browse files
committed
openmp: correct logic
1 parent fe19f9f commit 528460b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

openmp/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(OpenMP_Fortran
3+
LANGUAGES Fortran)
4+
enable_testing()
5+
16
find_package(OpenMP COMPONENTS Fortran)
27

8+
include(CheckFortranSourceCompiles)
39
set(CMAKE_REQUIRED_FLAGS ${OpenMP_Fortran_FLAGS})
10+
set(CMAKE_REQUIRED_INCLUDES ${OpenMP_Fortran_INCLUDE_DIRS})
411
set(CMAKE_REQUIRED_LIBRARIES ${OpenMP_Fortran_LIBRARIES})
5-
check_fortran_source_compiles("use omp_lib; rate = omp_get_wtick(); end" hasOMP SRC_EXT f90)
12+
check_fortran_source_compiles("use, intrinsic:: iso_fortran_env, only: dp=>real64, int64
13+
implicit none (type, external)
14+
integer(int64), external :: omp_get_wtick
15+
integer(int64) :: rate
16+
rate = omp_get_wtick()
17+
end program" hasOMP SRC_EXT f90)
618

719
if(NOT hasOMP)
820
return()

openmp/timeprec.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ program timeprec
1010
call timempi()
1111
call system_clock(toc)
1212

13-
print '(A,ES12.5,A)','instrinsic time: ',(toc-tic)/real(rate,dp),' seconds.'
13+
print '(A,ES12.5,A)','intrinsic time: ',(toc-tic)/real(rate,dp),' seconds.'
1414

1515
contains
1616

1717
subroutine timempi()
1818

19-
use omp_lib
19+
use omp_lib, only : omp_get_wtime, omp_get_num_procs, omp_get_num_threads, omp_get_thread_num
20+
21+
integer(int64), external :: omp_get_wtick
2022

2123
integer :: Ncore, Nthread
2224
real(dp) :: tic,toc,rate

0 commit comments

Comments
 (0)