Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

OMP_GET_THREAD_NUM() returns NaN

anishtain4
Beginner
948 Views
I was working with OpenMP sometimes ago and it was working good, today when I wanted to check something back this function returns NaN value!! even a hello project gets like it:

[bash]program test

I=10
!$OMP PARALLEL NUM_THREADS(5)
  PRINT*,I,OMP_GET_THREAD_NUM()
!$OMP END PARALLEL

END PROGRAM test[/bash]
it prints five time "10 Nan" what can be wrong? any probability some files got damaged? Fix option didn't work
0 Kudos
1 Solution
TimP
Honored Contributor III
948 Views
You need
USE omp_lib

You can't get away with allowing default data typing into this.

View solution in original post

0 Kudos
3 Replies
TimP
Honored Contributor III
949 Views
You need
USE omp_lib

You can't get away with allowing default data typing into this.
0 Kudos
anishtain4
Beginner
948 Views
Yeah that`s it, Thank youuuu
0 Kudos
mecej4
Honored Contributor III
948 Views
According to the implicit typing rules of Fortran, a variable/function starting with (A-H, O-Z) is of type real. Thus, the integer result returned by the function is being interpreted as an IEEE real, which produces the NaNs that you saw.

Either USE the OMP module as TimP told you, or declare OMP_GET_THREAD_NUM as INTEGER.
0 Kudos
Reply