I have a code with multi-threading features in it. However, when I tried to excute and debug the code, I got error "LNK2019: unresolved external sybol OMP_GET_THREAD_NUM referenced in function abc..." and error 'LNK2001:unresolved external sybol OMP_GET_THREAD_NUM', also other error LNK2001 for related variables, methods with OpenMP.
I guess, I did NOT specified library or other commends correctly for the compiler???
The core code is the following:
!$omp parallel private(id)
id = omp_get_thread_num() ! id starts with 0
!$omp end parallel
I am using Intel Visual Fortan Compiler (Professional Edition) for Windows - Version 10 and Microsoft Visual Studion on a x64 bit Machine.
See if anybody has some ideas on this. Thank you very much in advance!
after your PROGRAM, SUBROUTINE or FUNCTION statement to properly declare the routine. You should also be sure to have set the "Process OpenMP Directives" option under Fortran > Language in Visual Studio, or use the /Qopenmp option on the command line.
In order to make a program which works regardless of whether /Qopenmp is set, according to OpenMP standard, you guard those by #ifdef _OPENMP: #ifdef _OPENMP use omp_lib #endif .... #ifdef _OPENMP ... =omp_get_thread_num() .. #endif
but then you must set /fpp for Windows compilation. I've never seen anyone attempt to use the version date aspect of _OPENMP. I do frequently see legacy programs which declare e.g. integer omp_get_thread_num which should be flagged as at least a warning with strict checking enabled.