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

ifort !DEC$ directives not functional...

miro_ilias
Beginner
1,461 Views
Dear all,

on my x86_64 linux machine I tried to compile this simple program (test.F):

program test_mkl
INCLUDE "mkl.fi"
#if defined __INTEL_MKL__
print *,__INTEL_MKL__
#endif
#if defined __INTEL_COMPILER
print *,__INTEL_COMPILER
#endif
!DEC$ DEFINE XX = 10
print *,'DEC$ DEFINED XX=',XX
#define XXX 20
print *,'#defined XXX=',XXX
!DEC$ IF DEFINED INTEL_MKL_VERSION
print *,'hello, INTEL_MKL_VERSION=',INTEL_MKL_VERSION
!DEC$ ENDIF
end

However, compilation gives 'Syntax error':

milias@grafix.fpv.umb.sk:~/work/programming/various/ifort_mkl_info/.ifort test.F
test.F(13): remark #5082: Directive ignored - Syntax error, found IDENTIFIER 'INTEL_MKL_VERSION' when expecting one of: (
!DEC$ IF DEFINED INTEL_MKL_VERSION
-----------------^
test.F(15): remark #5169: Misplaced conditional compilation directive or nesting too deep
!DEC$ ENDIF
------^

and executable run shows that "DEC" assignement of variables does not work:

milias@grafix.fpv.umb.sk:~/work/programming/various/ifort_mkl_info/.a.out
1210
DEC$ DEFINED XX= 0.0000000E+00
#defined XXX= 20
hello, INTEL_MKL_VERSION= 0

I wanted to employ Ifort predefined macros of mkl.fi include file.

I am using Intel Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.3.293 Build 20120212.

Any help please ?

Miro


0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,461 Views
The syntax for that is:

!DEC$ IF DEFINED(name)

But why not continue to use #ifdef here, if you're already using fpp directives?
0 Kudos
miro_ilias
Beginner
1,461 Views
Hi Steve,

thanks for the quick fix.

So in the code I changed the line
!DEC$ IF DEFINED(INTEL_MKL_VERSION)
and it compiles without problem.

BUT: the output shows that INTEL_MKL_VERSION variable, defined in Fortran include file /opt/intel/mkl/include/mkl.fi as "!DEC$ DEFINE INTEL_MKL_VERSION = 100309", is still giving zero...

hello, INTEL_MKL_VERSION= 0

Is the "DEC" assignement working ? I need it to print out the INTEL_MKL_VERSION variable.

Best,

Miro





0 Kudos
Steven_L_Intel1
Employee
1,461 Views
You can't do what you want. Values defined by !DEC$ DEFINE are usable only in !DEC$ IF ... conditional compilation statements. The Language Reference says:

DEFINE creates and UNDEFINE removes symbols for use with the IF (or IF DEFINED) compiler directive. Symbols defined with DEFINE directive are local to the directive. They cannot be declared in the Fortran program.

Because Fortran programs cannot access the named variables, the names can duplicate Fortran keywords, intrinsic functions, or user-defined names without conflict.

Sorry. The purpose of these values is to allow you to conditionalize code based on which MKL version is used.

The preprocessor values such as __INTEL_COMPILER are defined at the command-line level (using -D) and are available in the FPP preprocessor, which does macro substitution. But the !DEC$ DEFINE values in mkl.fi are not available for that.
0 Kudos
Reply