I am new to OpenMP programing. I am trying to add a piece of C++ code using openmp to an old program which uses c++, c and Fortran. When I linked the openmp code to others, omp_get_max_threads() always returned 1. I have explicitly set omp_set_dynamic(0) and omp_set_num_threads(4) but still get max thread=1 and receive 4 same thread number from the parallel region. For example, I linked an openmp hello world to the old codes. When the "hello world" is called from the main program, there are 4 "hello world" messages from thread 1 instead of from thread 0,1,2,3 and 4. However, the openmp hello world code worked correctly on the same machine when it was separated from other codes.
The original makefile doesn't use openmp. I just simply added flag openmp to the corresponding CXX compiler and linker as follows:
CXX = icpc -pthread --> CXX= icpc -pthread -openmp
LINK_EXE =$CXX -thread -o --> LINK_EXE =$CXX -thread -openmp -o
I am wondering whether there is anything wrong in my makefile. Did anyone encounter a similar problem?