aboutsummaryrefslogtreecommitdiff
path: root/test cases/fortran/16 openmp
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-06-25 10:55:26 -0400
committerDylan Baker <dylan@pnwbakers.com>2019-06-25 09:17:48 -0700
commit31e069e93f1ab73214a10c3928e9dba4e7c7bb6c (patch)
treecb6ec9107db59933346848e2c5350742c493a6b3 /test cases/fortran/16 openmp
parentec97bedd8afbf3bcb53b03365fb06fcf8c51b516 (diff)
downloadmeson-31e069e93f1ab73214a10c3928e9dba4e7c7bb6c.zip
meson-31e069e93f1ab73214a10c3928e9dba4e7c7bb6c.tar.gz
meson-31e069e93f1ab73214a10c3928e9dba4e7c7bb6c.tar.bz2
fortran-specific openMP tests
Diffstat (limited to 'test cases/fortran/16 openmp')
-rw-r--r--test cases/fortran/16 openmp/main.f9017
-rw-r--r--test cases/fortran/16 openmp/meson.build34
2 files changed, 51 insertions, 0 deletions
diff --git a/test cases/fortran/16 openmp/main.f90 b/test cases/fortran/16 openmp/main.f90
new file mode 100644
index 0000000..8ab38d3
--- /dev/null
+++ b/test cases/fortran/16 openmp/main.f90
@@ -0,0 +1,17 @@
+use, intrinsic :: iso_fortran_env, only: stderr=>error_unit
+use omp_lib, only: omp_get_max_threads
+implicit none
+
+integer :: N, ierr
+character(80) :: buf ! can't be allocatable in this use case. Just set arbitrarily large.
+
+call get_environment_variable('OMP_NUM_THREADS', buf, status=ierr)
+if (ierr/=0) error stop 'environment variable OMP_NUM_THREADS could not be read'
+read(buf,*) N
+
+if (omp_get_max_threads() /= N) then
+ write(stderr, *) 'Max Fortran threads: ', omp_get_max_threads(), '!=', N
+ error stop
+endif
+
+end program
diff --git a/test cases/fortran/16 openmp/meson.build b/test cases/fortran/16 openmp/meson.build
new file mode 100644
index 0000000..f021ce2
--- /dev/null
+++ b/test cases/fortran/16 openmp/meson.build
@@ -0,0 +1,34 @@
+# This test is complementary to and extends "common/190 openmp" so that
+# we can examine more compilers and options than would be warranted in
+# the common test where C/C++ must also be handled.
+project('openmp', 'fortran',
+ meson_version: '>= 0.46')
+
+
+fc = meson.get_compiler('fortran')
+if fc.get_id() == 'gcc' and fc.version().version_compare('<4.2.0')
+ error('MESON_SKIP_TEST gcc is too old to support OpenMP.')
+endif
+if host_machine.system() == 'darwin'
+ error('MESON_SKIP_TEST macOS does not support OpenMP.')
+endif
+
+openmp = dependency('openmp')
+
+env = environment()
+env.set('OMP_NUM_THREADS', '2')
+
+exef = executable('exef',
+ 'main.f90',
+ dependencies : [openmp])
+test('OpenMP Fortran', exef, env : env)
+
+openmp_f = dependency('openmp', language : 'fortran')
+exe_f = executable('exe_f',
+ 'main.f90',
+ dependencies : [openmp_f])
+test('OpenMP Fortran-specific', exe_f, env : env)
+
+
+# Check we can apply a version constraint
+dependency('openmp', version: '>=@0@'.format(openmp.version()))