Visible to Intel only — GUID: GUID-9C46EC19-115A-4B90-9AB0-19E78D6484B9
Visible to Intel only — GUID: GUID-9C46EC19-115A-4B90-9AB0-19E78D6484B9
DEFINE and UNDEFINE
General Compiler Directives: DEFINE creates a symbolic variable whose existence or value can be tested during conditional compilation. UNDEFINE removes a defined symbol.
!DIR$ DEFINE name[ = val]
!DIR$ UNDEFINE name
name |
Is the name of the variable. |
val |
INTEGER(4). The value assigned to name. |
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.
To test whether a symbol has been defined, use the IF DEFINED ( name) directive. You can assign an integer value to a defined symbol. To test the assigned value of name, use the IF directive. IF test expressions can contain most logical and arithmetic operators.
Attempting to undefine a symbol that has not been defined produces a compiler warning.
The DEFINE and UNDEFINE directives can appear anywhere in a program, enabling and disabling symbol definitions.
Example
!DIR$ DEFINE testflag
!DIR$ IF DEFINED (testflag)
write (*,*) 'Compiling first line'
!DIR$ ELSE
write (*,*) 'Compiling second line'
!DIR$ ENDIF
!DIR$ UNDEFINE testflag