Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28742 Discussions

VS2022 Fortran OpenMP number of processes always one

Scorp
Novice
959 Views

I have a large project I'm attempting to partially parallelize.  I have the following settings on the project property pages:

debug: environment: OMP_NUM_THREADS=8

fortran: language: process OpenMP directives: Generate Parallel Code (/Qopenmp)

fortran: runtime library: debug multithreaded

 

The below subroutine should print the thread id from 0 to 5, but instead it prints. Why?

F  6

# threads:  1

hello from thread:  0

 

subroutine clauses
USE OMP_LIB
implicit none

call omp_set_num_threads(6)
PRINT *, OMP_IN_PARALLEL(), OMP_GET_MAX_THREADS()
!$OMP PARALLEL
print *, "# threads:", OMP_GET_NUM_THREADS()
print *, 'hello from thread:', OMP_GET_THREAD_NUM()
!$OMP END PARALLEL

end subroutine clauses

0 Kudos
1 Solution
Scorp
Novice
933 Views

If you have a solution with multiple projects, you have enable the same project properties as those for the startup. I only had it only for the startup and it didn't work for those files in another project.

 

All fixed now.

View solution in original post

3 Replies
jimdempseyatthecove
Honored Contributor III
944 Views

Scorp,

Check to see if you are building with the OpenMP stubs library.

Jim Dempsey

 

0 Kudos
Scorp
Novice
939 Views

Jim,

 

I am not. Language -> Process OpenMP Directives, which I already set to Generate Parallel Code (/Qopenmp). Setting it to Generate Sequential Code (/Qopenmp-stubs) results in:

 

F  1
# threads:  1
hello from thread:  0

0 Kudos
Scorp
Novice
934 Views

If you have a solution with multiple projects, you have enable the same project properties as those for the startup. I only had it only for the startup and it didn't work for those files in another project.

 

All fixed now.

Reply