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

ifort -openmp

Ahmad_Falahatpisheh
3,395 Views
Hi,

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

0 Kudos
1 Solution
IanH
Honored Contributor III
3,395 Views
You are using the switches that apply for Linux and Mac OS.

On windows the switch to enable OpenMP is /Qopenmp

Similarly the switch for the output exe file name is /exe:xxxx

View solution in original post

0 Kudos
2 Replies
IanH
Honored Contributor III
3,396 Views
You are using the switches that apply for Linux and Mac OS.

On windows the switch to enable OpenMP is /Qopenmp

Similarly the switch for the output exe file name is /exe:xxxx
0 Kudos
Michael_J_Slater__In
New Contributor I
3,395 Views

Hey!

-openmp is an option for the Linux version of our compiler, the flags for Windows are usually slightly different

http://software.intel.com/sites/products/documentation/hpc/composerxe/en-us/fortran/win/hh_goto.htm#copts/common_options/option_openmp.htm

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


0 Kudos
Reply