0

I want to set my thread number to 10, by doing:

CALL OMP_SET_NUM_THREADS(10)
!$OMP PARALLEL 
T=OMP_GET_NUM_THREADS()
!$OMP END PARALLEL
PRINT*, T

It prints out 10, which is correct. However, if I define a variable NUM_THREADS, and pass it into the get threads number subroutine, like this:

INTEGER(KIND=16), PARAMETER :: NUM_THREADS=10
CALL OMP_SET_NUM_THREADS(NUM_THREADS)

And run it, it gives me the bug:

Error: There is no specific subroutine for the generic ‘omp_set_num_threads’ at (1).

Why is that?

Shiqi He
  • 95
  • 3
  • 10
  • Please give the whole program for the non-working part. `OMP_SET_NUM_THREADS` is a subroutine, so you'd need to `CALL` it. But that error would have given a different error message. – chw21 Mar 14 '19 at 00:25
  • I add CALL, it still gives me the same bug. I comment out all other part, just to test the omp_set_num_threads() – Shiqi He Mar 14 '19 at 00:33
  • 2
    Can you take out the `(KIND=16)` from the `INTEGER` declaration? – chw21 Mar 14 '19 at 00:46
  • @chw21 You are right! If I cancel out the kind=16, it works. Thank you! – Shiqi He Mar 14 '19 at 00:53
  • See https://stackoverflow.com/questions/3170239/fortran-integer4-vs-integer4-vs-integerkind-4 and questions with the same error as https://stackoverflow.com/questions/8044568/how-to-debug-fortran-90-compile-error-there-is-no-specific-subroutine-for-the-g – Vladimir F Героям слава Mar 14 '19 at 07:04

1 Answers1

1

I don't know which type of integer your compiler has as KIND=16 but it seems that it's a non-standard type for which OpenMP does not have a corresponding subroutine.

There is really no reason to use a non-standard internet kind for a number that can easily be represented by standard 16 or 32 bit integers.

Leave the kind descriptor out of the INTEGER declaration, and it should work.

chw21
  • 7,970
  • 1
  • 16
  • 31
  • 1
    Also note you compiler is not required to support an Integer with kind 16. If you want to use non-default interger kinds look at Select_Int_kind, or if using a compiler that supports the relevant part of Fortran 2008, the constants in the intrinsic module iso_fortran_env. – Ian Bush Mar 14 '19 at 07:42