| 1 |
program main |
| 2 |
use, intrinsic :: iso_fortran_env, only: stderr=>error_unit |
| 3 |
use omp_lib, only: omp_get_max_threads |
| 4 |
implicit none |
| 5 |
|
| 6 |
integer :: N, ierr |
| 7 |
character(80) :: buf ! can't be allocatable in this use case. Just set arbitrarily large. |
| 8 |
|
| 9 |
call get_environment_variable('OMP_NUM_THREADS', buf, status=ierr) |
| 10 |
if (ierr/=0) error stop 'environment variable OMP_NUM_THREADS could not be read' |
| 11 |
read(buf,*) N |
| 12 |
|
| 13 |
if (omp_get_max_threads() /= N) then |
| 14 |
write(stderr, *) 'Max Fortran threads: ', omp_get_max_threads(), '!=', N |
| 15 |
error stop |
| 16 |
endif |
| 17 |
|
| 18 |
end program |