diff --git a/test/fc_omp/cmake/autocmake.cfg b/test/fc_omp/cmake/autocmake.cfg new file mode 100644 index 0000000..ba159e3 --- /dev/null +++ b/test/fc_omp/cmake/autocmake.cfg @@ -0,0 +1,14 @@ +[project] +name: example + +[fc] +source: ../../../modules/fc.cmake + +[omp] +source: ../../../modules/omp.cmake + +[default_build_paths] +source: ../../../modules/default_build_paths.cmake + +[src] +source: ../../../modules/src.cmake diff --git a/test/fc_omp/src/CMakeLists.txt b/test/fc_omp/src/CMakeLists.txt new file mode 100644 index 0000000..8b38868 --- /dev/null +++ b/test/fc_omp/src/CMakeLists.txt @@ -0,0 +1,6 @@ +if (OPENMP_FOUND) + add_executable(example example.f90) +else() + message(FATAL "OPENMP not found!") +endif() + diff --git a/test/fc_omp/src/example.f90 b/test/fc_omp/src/example.f90 new file mode 100644 index 0000000..c44c6b3 --- /dev/null +++ b/test/fc_omp/src/example.f90 @@ -0,0 +1,19 @@ +program example + implicit none + integer :: nthreads, tid + integer, external :: omp_get_num_threads, omp_get_thread_num + logical :: test_ok, tid_ok +!$OMP PARALLEL SHARED (nthreads, tid_ok), PRIVATE(tid) + tid = omp_get_thread_num() + if (tid .eq. 0) then + nthreads = omp_get_num_threads() + endif + tid_ok=(tid == 0 .or. tid == 1) +!$OMP END PARALLEL + test_ok=(nthreads==2 .and. tid_ok) + if (test_ok) then + print *, "PASSED" + else + stop "test fc_omp failed!" + endif +end program diff --git a/test/test.py b/test/test.py index 1a6848d..59767e9 100644 --- a/test/test.py +++ b/test/test.py @@ -160,6 +160,14 @@ def test_fc_mpi(): # ------------------------------------------------------------------------------ +@no_windows +def test_fc_omp(): + os.environ['OMP_NUM_THREADS'] = '2' + configure_build_and_exe('fc_omp', 'python setup.py --omp --fc=gfortran') + +# ------------------------------------------------------------------------------ + + @no_windows def test_fc_blas(): configure_build_and_exe('fc_blas', 'python setup.py --fc=gfortran')