- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to compile the following sample code by using openmp switch.
C******************************************************************************
C FILE: omp_hello.f
C DESCRIPTION:
C OpenMP Example - Hello World - Fortran Version
C In this simple example, the master thread forks a parallel region.
C All threads in the team obtain their unique thread number and print it.
C The master thread only prints the total number of threads. Two OpenMP
C library routines are used to obtain the number of threads and each
C thread's number.
C AUTHOR: Blaise Barney 5/99
C LAST REVISED:
C******************************************************************************
PROGRAM HELLO
INTEGER NTHREADS, TID, OMP_GET_NUM_THREADS,
+ OMP_GET_THREAD_NUM
C Fork a team of threads giving them their own copies of variables
!$OMP PARALLEL PRIVATE(NTHREADS, TID)
C Obtain thread number
TID = OMP_GET_THREAD_NUM()
PRINT *, 'Hello World from thread = ', TID
C Only master thread does this
IF (TID .EQ. 0) THEN
NTHREADS = OMP_GET_NUM_THREADS()
PRINT *, 'Number of threads = ', NTHREADS
END IF
C All threads join master thread and disband
!$OMP END PARALLEL
END
When I use ifort I get the following message. Could someone help me figure out what I am missing? I checked the ifort switches and openmp is also listed when I type in ifort /? in command prompt.
C:\\>ifort -openmp omp_hello.f -o hello
Intel Visual Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
ifort: command line remark #10148: option '/openmp' not supported
Microsoft Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
-out:hello.exe
-subsystem:console
omp_hello.obj
omp_hello.obj : error LNK2019: unresolved external symbol OMP_GET_THREAD_NUM referenced in function MAIN__
omp_hello.obj : error LNK2019: unresolved external symbol OMP_GET_NUM_THREADS referenced in function MAIN__
hello.exe : fatal error LNK1120: 2 unresolved externals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On windows the switch to enable OpenMP is /Qopenmp
Similarly the switch for the output exe file name is /exe:xxxx
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On windows the switch to enable OpenMP is /Qopenmp
Similarly the switch for the output exe file name is /exe:xxxx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey!
-openmp is an option for the Linux version of our compiler, the flags for Windows are usually slightly different
So try the following:
ifort /Qopenmp omp_hello.f
By the way, your program compiled and ran for me!
> ifort /Qopenmp ifortopenmp.f
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Microsoft Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
-out:ifortopenmp.exe
-subsystem:console
-nodefaultlib:libiompprof5mt.lib
-nodefaultlib:libiompprof5md.lib
-defaultlib:libiomp5md.lib
-nodefaultlib:vcomp.lib
-nodefaultlib:vcompd.lib
ifortopenmp.obj
> ifortopenmp.exe
Hello World from thread = 0
Hello World from thread = 1
Number of threads = 2

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page