summaryrefslogtreecommitdiffstats
path: root/test cases/fortran/16 openmp/main.f90
blob: 26b792fe8664d725f42ddbf0bebe6727aec33499 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program main
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