Skip to content

Commit

Permalink
openmp: correct logic
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Apr 19, 2020
1 parent fe19f9f commit 528460b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
cmake_minimum_required(VERSION 3.14)
project(OpenMP_Fortran
LANGUAGES Fortran)
enable_testing()

find_package(OpenMP COMPONENTS Fortran)

include(CheckFortranSourceCompiles)
set(CMAKE_REQUIRED_FLAGS ${OpenMP_Fortran_FLAGS})
set(CMAKE_REQUIRED_INCLUDES ${OpenMP_Fortran_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${OpenMP_Fortran_LIBRARIES})
check_fortran_source_compiles("use omp_lib; rate = omp_get_wtick(); end" hasOMP SRC_EXT f90)
check_fortran_source_compiles("use, intrinsic:: iso_fortran_env, only: dp=>real64, int64
implicit none (type, external)
integer(int64), external :: omp_get_wtick
integer(int64) :: rate
rate = omp_get_wtick()
end program" hasOMP SRC_EXT f90)

if(NOT hasOMP)
return()
Expand Down
6 changes: 4 additions & 2 deletions openmp/timeprec.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ program timeprec
call timempi()
call system_clock(toc)

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

contains

subroutine timempi()

use omp_lib
use omp_lib, only : omp_get_wtime, omp_get_num_procs, omp_get_num_threads, omp_get_thread_num

integer(int64), external :: omp_get_wtick

integer :: Ncore, Nthread
real(dp) :: tic,toc,rate
Expand Down

0 comments on commit 528460b

Please sign in to comment.