fortran-compiler_developer-guide-reference_2023.0-767251-767252
fortran-compiler_developer-guide-reference_2023.0-767251-767252
Contents
Intel® Fortran Compiler Classic and Intel® Fortran Compiler
Developer Guide and Reference ..9
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Introduction ......... 10
Get Help and Support ...................................................................... 11
Related Information......................................................................... 12
Compiler Setup ....................................................................................... 12
Use the Command Line .................................................................... 13
Specify Component Locations ................................................... 13
Invoke the Compiler ................................................................ 14
Use the Command Line on Windows .......................................... 18
Run Fortran Applications from the Command Line........................ 18
File Extensions ....................................................................... 19
Use Makefiles for Compilation ................................................... 20
Use Microsoft Visual Studio............................................................... 22
Use Microsoft Visual Studio* Solution Explorer ............................ 22
Create a New Project............................................................... 22
Perform Common Tasks with Microsoft Visual Studio* .................. 24
Select a Version of the Intel® Fortran Compiler ............................ 24
Specify Fortran File Extensions ................................................. 24
Understand Solutions, Projects, and Configurations ..................... 25
Navigate Programmatic Components in a Fortran File................... 26
Specify Path, Library, and Include Directories.............................. 26
Set Compiler Options in the Microsoft Visual Studio* IDE
Property Pages ................................................................... 27
Supported Build Macros ........................................................... 28
Use Manifests ......................................................................... 29
Use Intel® Libraries with Microsoft Visual Studio* ........................ 29
Use Guided Auto Parallelism in Microsoft Visual Studio* ............... 30
Use Code Coverage in Microsoft Visual Studio* ........................... 31
Use Profile Guided Optimization in Microsoft Visual Studio*........... 31
Use Source Editor Enhancements in Microsoft Visual Studio* ........ 32
Create the Executable Program ................................................. 33
Convert and Copy Projects ....................................................... 35
About Fortran Project Types...................................................... 36
Optimization Reports .............................................................. 47
Dialog Box Help ...................................................................... 50
Compiler Reference ................................................................................. 59
Compiler Limits............................................................................... 59
Use Visual Studio* IDE Automation Objects ........................................ 61
Compiler Options ............................................................................ 66
Alphabetical Option List ........................................................... 68
General Rules for Compiler Options ........................................... 85
What Appears in the Compiler Option Descriptions ...................... 86
Optimization Options ............................................................... 87
Code Generation Options ....................................................... 100
Interprocedural Optimization Options....................................... 136
Advanced Optimization Options............................................... 146
Profile Guided Optimization Options......................................... 198
2
Contents
3
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
4
Contents
5
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
6
Contents
7
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
8
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This guide provides information about Intel® Fortran Compiler Classic (ifort) and its runtime environment,
and about Intel® Fortran Compiler (ifx), which is a new compiler based on the Intel Fortran Compiler Classic
(ifort) frontend and runtime libraries, using LLVM backend technology.
Refer to the Intel® Fortran Compiler product page and the Release Notes for more information about features,
specifications, and downloads.
Use this guide to learn about:
• Compiler Setup: How to invoke the compiler on the command line or from within an IDE.
• Compiler Options: Information about options you can use to affect optimization, code generation, and
more.
• Language Reference: Information on language syntax and semantics, on adherence to various Fortran
standards, and on extensions to those standards.
• OpenMP* Support: Details about compiler support for OpenMP 5.0 Version TR4 features and some
OpenMP Version 5.1 features.
• Fortran Language Extensions: Information on using additional implementation features, including
creating a Component Object Model server, generating listing and map files, and more.
• Mixed-Language Programming: Information about Fortran and C interoperable procedures and data
types, as well as various specifics of mixed-language programming.
• Runtime Error Messages: Information about the errors processed by the Intel® Fortran runtime library
(RTL).
For more information, refer to Introducing the Intel® Fortran Compiler Classic and Intel® Fortran Compiler.
xcode-select --install
9
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Download Previous Versions of the Developer Guide and Reference :Visit the Download
Documentation: Intel® Compiler (Current and Previous) page to download PDF or FAR HTML versions of
previous compiler documentation.
NOTE
For the best search experience, use a Google Chrome* or Internet Explorer* browser to view your
downloaded copy of the Intel Fortran Compiler Developer Guide and Reference.
If you use Mozilla Firefox*, you may encounter an issue where the Search tab does not work. As a
workaround, you can use the Contents and Index tabs or a third-party search tool to find your
content.
Architecture Support
The compiler supports Intel® 64 architecture.
OS Support
Compiler applications can run on the following operating systems:
• Linux operating systems for Intel® 64 architecture-based systems.
• Windows operating systems for Intel® 64 architecture-based systems.
• macOS operating systems for Intel® 64 architecture-based systems.
You can use the compiler in the command-line or in a supported Integrated Development Environment (IDE):
• Microsoft Visual Studio* (Windows only)
The Intel Fortran Compiler (ifx) is a new compiler based on the Intel Fortran Compiler Classic (ifort) front-
end and runtime libraries, using LLVM back-end technology. At this time, ifx supports features of the Fortran
95 language, OpenMP* 5.0 Version TR4 and some OpenMP Version 5.1 directives and offloading features.
ifx is binary (.o/.obj) and module (.mod) file compatible; binaries and libraries generated with ifort can
be linked with binaries and libraries built with ifx, and .mod files generated with one compiler can be used
by the other. Both compilers use the ifort runtime libraries. ifx supports GPU offloading, which ifort does
not support. Fortran users that are uninterested in GPU offloading should continue to use ifort.
Standards Support
The compiler uses the latest standards including Fortran 2003, Fortran2018 and OpenMP 5.0 and 5.1 for GPU
offload. Refer to the Conformance, Compatibility, and Fortran Features for more information.
Feature Requirements
This table lists dependent features and their corresponding required products. For certain compiler options,
the compilation may fail if the option is specified but the required product is not installed. In this case,
remove the option from the command line and recompile.
10
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Feature Requirement
-mkl, -qmkl, -qmkl-ilp64, /Qmkl and /Qmkl- Intel® oneAPI Math Kernel Library (oneMKL) install.
ilp64 options
Intel® Inspector install.
Thread Checking
Intel® Trace Analyzer and Collector install.
Trace Analyzing and Collecting
Compiler options related to this feature may require
a set-up script. For further information, see the
product documentation.
See the Release Notes for complete information on supported architectures, operating systems, and IDEs for
this release.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
Windows
Documentation is available from within the version of Microsoft Visual Studio. You must install the
documentation on your local system. To use the feature, visit the Download Documentation: Intel® Compiler
(Current and Previous) page and follow the instructions provided there. From the Help menu, choose Intel
Compilers and Libraries to view the installed user and reference documentation.
NOTE To access support, you must register your product at the Intel Registration Center.
11
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Release Notes
For detailed information on system requirements, late changes to the products, supported architectures,
operating systems, and Integrated Development Environments (IDE) see the Release Notes for the product.
Forums
You can find helpful information in the Intel Software user forums. You can also submit questions to the
forums. To see the list of the available forums, go to the Software Development Tools forum for general
information, or visit a specific forum for:
• Intel® Fortran Compilers
Related Information
Compiler Setup
You can use the Intel® Fortran from the command line, Eclipse, Microsoft Visual Studio.
These IDEs are described in further detail in their corresponding sections.
See Also
Use the Command Line
Use Microsoft Visual Studio
12
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Using source:
. /opt/intel/oneapi/setvars.sh intel64
Use source /<install-dir>/setvars.sh --help for more setvars usage information.
The compiler environment script file accepts an optional target architecture argument <arg>:
• intel64: Generate code and use libraries for Intel® 64 architecture-based targets.
If you want the setvars.sh script to run automatically in all of your terminal sessions, add the source
setvars.sh command to your startup file. For example, inside your .bash_profile entry for Intel® 64
architecture targets.
If the proper environment variables are not set, errors similar to the following may appear when attempting
to execute a compiled program:
Windows
Under normal circumstances, you do not need to run the setvars.bat batch file. The terminal shortcuts in
the Windows Start menu, Intel oneAPI command prompt for <target architecture> for Visual Studio
<year>, set these variables automatically.
For additional information, see Use the Command Line on Windows.
You need to run the setvars batch file if a command line is opened without using one of the provided
Command Prompt menu items in the Start menu, or if you want to use the compiler from a script of your
own.
13
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The setvars batch file inserts DLL directories used by the compiler and libraries at the beginning of the
existing Path. Because these directories appear first, they are searched before any directories that were part
of the original Path provided by Windows (and other applications). This is especially important if the original
Path includes directories with files that have the same names as those added by the compiler and libraries.
The setvars batch file takes multiple optional arguments; the following two arguments are recognized for
compiler and library initialization:
NOTE Support for Microsoft Visual Studio 2017 is deprecated as of the Intel® oneAPI 2022.1 release
and will be removed in a future release.
If <arg1> is not specified, the script uses the intel64 argument by default. If <arg2> is not specified, the
script uses the highest installed version of Microsoft Visual Studio detected during the installation procedure.
See Also
oneAPI Development Environment Setup
Compiler Drivers
The Intel® Fortran Compiler Classic and Intel® Fortran Compiler each have a driver:
Compiler Notes Linux Driver Windows Driver
14
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ifx [option]input_file
The ifx command can compile and link projects in one step, or can compile them and then link them as a
separate step.
In most cases, a single ifx command invokes the compiler and linker. You can also use ld (Linux and
macOS) or link (Windows) to build libraries of object modules. These commands provide syntax
instructions at the command line if you request it with the -help (Linux and macOS), or the /help or /?
(Windows) options.
The ifx command automatically references the appropriate runtime libraries when it invokes the linker. To
link one or more object files created by the compiler, you should use the ifx command instead of the link
command.
The ifx command invokes a driver program that is the user interface to the compiler and linker. It accepts a
list of command options and file names and directs processing for each file. The driver program does the
following:
• Calls the compiler to process Fortran files.
• Passes the linker options to the linker.
• Passes object files created by the compiler to the linker.
• Passes libraries to the linker.
• Calls the linker or librarian to create the executable or library file.
Because the compiler driver calls other software components, they may return error messages. For instance,
the linker may return a message if it cannot resolve a global reference. The watch option can help clarify
which component is generating an error.
For a complete listing of compiler options, see the Alphabetical Option List.
Windows systems support characters in Unicode (multibyte) format. The compiler processes the file names
containing Unicode characters.
Syntax Rules
The following rules apply when specifying ifx on the command line:
Argument Description
options An option is specified by one or more letters preceded by a hyphen (-) for Linux and
macOS or a slash (/) for Windows. (You can use a hyphen (-) instead of a slash (/)
for Windows, but it is not the preferred method.)
Options cannot be combined with a single slash or hyphen; you must specify the
slash or hyphen for each option specified. For example: /1 /c is correct, but /1c is
not.
Options can take arguments in the form of file names, strings, letters, and numbers.
If a string includes spaces, they must be enclosed in quotation marks.
Some options take arguments in the form of file names, strings, letters, or numbers.
Except where otherwise noted, a space between the option and its argument(s) can
be entered or combined. For a complete listing of compiler options, see the Compiler
Options reference.
15
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Argument Description
Some compiler options are case-sensitive. For example, c and C are two different
options.
Option names can be abbreviated, enter as many characters as are needed to
identify the option.
Compiler options remain in effect for the whole compilation unless overridden by a
compiler directive.
Certain options accept one or more keyword arguments following the option name
on Windows. To specify multiple keywords, you typically specify the option multiple
times. However, some options allow comma-separated keywords. For example:
• Options that use a colon can use an equal sign (=) instead.
• Standard output and standard error can be redirected to a file, avoiding
displaying excess text, which slows down execution. Scrolling text in a terminal
window on a workstation can cause an I/O bottleneck (increased elapsed time)
and use more CPU time. See the examples in the next section.
Options on the command line apply to all files. In the following example, the -c and
-nowarn options apply to both files x.f and y.f:
input file(s) Multiple input_files can be specified, using a space as a delimiter. When a file is not
in PATH or working directory, specify the directory path before the file name. The file
name extension specifies the type of file. See Understanding File Extensions.
Xlinker (Linux Unless specified with certain options, the command line compiles and links the files
and macOS) you specify. To compile without linking, specify the c option.
or /link
All compiler options must precede the /link (Windows) options. -Xlinker can be
(Windows)
used anywhere on the command line, only single options/files can be specified after
-Xlinker. Options that appear following -Xlinker or /link are passed directly to
the linker.
ifx x.for
This command compiles x.for and generates the object file x.o (Linux and macOS) or x.obj (Windows).
The c option prevents linking (it does not link the object file into an executable file):
ifx -c x.for
Windows
ifx x.for /c
This command links x.o or x.obj into an executable file. This command automatically links with the default
libraries:
Linux and macOS
ifx x.o
16
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows
ifx x.obj
This command compiles a.for, b.for, and c.for, creating three temporary object files, then linking the
object files into an executable file named a.out (Linux and macOS) or a.exe (Windows).
Other Methods for Using the Command Line to Invoke the Compiler
• Using makefiles from the Command Line: Use makefiles to specify a number of files with various
paths and to save this information for multiple compilations. For more information on using makefiles, see
Use Makefiles to Compile Your Application.
• Using the devenv Command from the Command Line (Windows only): Use devenv to set various
options for the IDE, and to build, clean, and debug projects from the command line. For more information
on the devenv command, see the devenv description in the Microsoft Visual Studio documentation.
• Using a Batch File from the Command Line: Create and use a .bat file to execute the compiler with a
desired set of options instead of retyping the command each time you need to recompile.
See Also
Specify the Location of Compiler Components
Understand File Extensions
Use Microsoft Visual Studio
Use Makefiles to Compile Your Application
watch compiler option
17
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Multithreaded Programs
If the program is multithreaded, each thread starts on whichever processor is available at the time. On a
computer with one processor, the threads all run in parallel, but not simultaneously; the single processor
switches among them. On a computer with multiple processors, the threads can run simultaneously.
Each file name on the command line must be separated from the names around it by one or more spaces, or
tab characters. You can enclose each name in quotation marks ("<filename>"), but this is not required
unless the argument contains spaces or tabs. A null argument consists of an empty set of quotation marks
with no file name enclosed ("").
The following example runs the program MYPROG.EXE from the command line:
18
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Call the GETARG library routine to return the specified command-line argument. To execute the program in
the Microsoft Visual Studio IDE, provide the command-line arguments to be passed to the program using
Project > Properties. Choose the Debugging category and enter the arguments in the Command
Arguments text box.
• On Windows, call the GetOpenFileName Windows API routine to request the file name using a dialog box.
See Also
-fpscomp option
File Extensions
Typical Fortran source files have a file extension of .f90, .for, and .f. When editing your source files,
you need to choose the source form, either free-source form or fixed-source form (or a variant of fixed
form called tab form). You can use a compiler option to specify the source form used by the source files
(see the description for the free or fixed compiler option) or you can use specific file extensions when
creating or renaming your files. For example, the compiler assumes that files with an extension of:
• .f90 or .i90 are free-form source files.
• .f, .for, .ftn, or .i are fixed-form (or tab-form) files.
• Files passed to the linker: .a, .lib, .obj, .o, .exe, .res, .rbj, .def, .dll
File Name (OS File Name for File Name for Interpretation Action
Agnostic) Linux and macOS Windows
19
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
File Name (OS File Name for File Name for Interpretation Action
Agnostic) Linux and macOS Windows
When you compile from the command line, you can use the compiler configuration file to specify default
directories for input libraries. To specify additional directories for input files, temporary files, libraries, and for
the files used by the assembler and the linker, use compiler options that specify output file and directory
names.
/Fafile .ASM
/dll:file .DLL
/exe:file .EXE
/map:file .MAP
See Also
Invoke the Compiler
Linux or macOS
To run make from the command line using the compiler, make sure that /usr/bin and /usr/local/bin are
in your PATH environment variable.
If you use the C shell, you can edit your .cshrc file and add the following:
20
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
make -f yourmakefile
Where -f is the make command option to specify a particular makefile name.
Windows
To use a makefile to compile your source files, use the nmake command. For example, if your project is
your_project.mak, you can use the following syntax:
Example:
Argument Description
/f The nmake option to specify a makefile.
The nmake command creates object files (.obj) and executable files () from the information specified in the
your_project.mak makefile.
Build dependencies include a list of all files included with INCLUDE statements and .mod files accessed with
USE statements. The resulting output can be used to create a makefile to with the appropriate dependencies
resolved.
Consider a source file that contains the following:
module b
include 'gendep001b.inc'
end module b
program gendep001
use b
a_global = b_global
end
When you compile the source using the gen-dep option, the following output is produced:
b.mod : \
gendep001.f90
gendep001.obj : \
gendep001.f90 gendep001b.inc
This output indicates that the generated file, b.mod, depends on the source file, gendep001.f90. Similarly,
the generated file, gendep001.obj, depends on the files, gendpe001.f90 and gendep001b.inc.
21
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Performing Common Tasks with Microsoft Visual Studio
Using Microsoft Visual Studio Solution Explorer
Using Breakpoints in the Debugger
NOTE Exact steps may vary depending on the version of Microsoft Visual Studio in use.
22
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The project and its files appear in the Solution Explorer view. For a COM Server project, you will see a
second page with additional user options.
A module file is a precompiled, binary version of a module definition, stored as a .mod file. When you change
the source definition of a module, you can update the .mod file before you rebuild your project. To do this,
compile the corresponding source file separately by selecting the file in the Solution Explorer window and
selecting Build > Compile. If the module source file is part of your project, you do not need to compile the
file separately. When you build your project, the Intel® Fortran Compiler determines what files need to be
compiled.
To control the placement of module files in directories, use Project > Properties > Fortran > Output
Files > Module Path in the IDE or the compiler option module:path on the command line. The location you
specify is automatically searched for .mod files.
To control the search for module files in directories, select one of the following:
• In the IDE:
• Project > Properties > Fortran > Preprocessor > Default Include and Use Path
• Project > Properties > Fortran > Preprocessor > Ignore Standard Include Path
• On the Command Line:
• X and assume:[no]source_include compiler options.
23
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For a newly created project (or any other project), the IDE scans the file list for sources that define modules
and compiles them before compiling the program units that use them. The IDE automatically scans the
added project files for modules specified in USE statements, as well as any INCLUDE statements. It scans the
source files for all tools used in building the project.
See Also
Understanding Project Types
I
X
assume
See Also
Creating a New Project
Convert and Copy Projects
24
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Project .sln Stores solution information, including the projects and items in the
Solution file solution and their locations on disk.
Project file .vfproj Contains information used to build a single project or sub-project.
.vcxproj
Solution .suo Contains IDE customization for the solution, based on the selected
options file options.
Caution
• Directly modifying these files with a text editor is not supported.
• Before opening Compaq* Visual Fortran 6.0 projects or Intel® Visual Fortran 7.x projects in
Microsoft Visual Studio, review the guidelines listed in Convert and Copy Projects.
Each project can specify one or more configurations to build from its source files. A configuration specifies
such information as the type of application to build, the platform it runs on, and the tool settings to use when
building. Having multiple configurations extends the scope of a project, but maintains a consistent source
code base to work with.
Microsoft Visual Studio automatically creates Debug and Release (also known as Retail) configurations
when a new project is started. The default configuration is the Debug configuration. To specify the current
configuration, select Configuration Manager from the Build menu.
Specify build options in the Project > Properties dialog box, for one of the following:
• For all configurations (project-wide).
• For certain configurations (per configuration).
• For certain files (per file).
For example, specify compiler optimizations for all general configurations, but turn them off for certain
configurations or certain files.
Once the files in the project are specified and the configurations for your project build are set, including the
tool settings, build the project with the commands on the Build menu.
25
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE For a multiple-project solution, make sure that the executable project is designated as the
startup project (shown in bold in the Solution Explorer view). To modify the startup project, right-
click on the project and select Set as StartUp Project.
See Also
Convert and Copy Projects
26
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE If you specify devenv or useenv on the command line to start the IDE, the IDE uses the PATH,
INCLUDE, and LIB environment variables as defined for that command line when performing a build. It
uses these values instead of the values defined in Tools > Options.
For more information on the devenv command, see the devenv description in the Microsoft Visual
Studio* documentation.
See Also
Supported Environment Variables
Set Compiler Options in the Microsoft Visual Studio* IDE Property Pages
To set compilation and related options for the current project:
1. Select the project name in the Solution Explorer view.
2. In the Project menu, select Properties.
The Intel® Fortran Compiler lets you specify compiler options for individual source files by selecting the file
name and clicking View > Property Pages.
NOTE For convenience, context-sensitive pop-up menus containing commonly used menu options are
available by right-clicking on an item (for example, a file name or solution) in the IDE.
NOTE Option values that are different from the compiler defaults are displayed in bold.
27
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
28
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The Intel® Fortran Compiler also supports the following macros (not supported by Visual Studio*).
For additional information on using build macros, see the Microsoft MSDN* online documentation.
Use Manifests
The Intel® Compiler supports manifests, a Microsoft Visual Studio* feature. Manifests describe runtime
dependencies of a built application. A manifest file can be embedded in the assembly, which is the default
behavior, or can be a separate standalone file. You can use the Manifest Tool property pages, which are
accessed through Project > Properties, to change project settings that affect the manifest.
NOTE
In earlier releases, manifest files were embedded in the assembly, and were not able to be accessed or
changed.
29
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
GAP Scenarios
To illustrate how the various GAP settings work together, consider the following scenarios:
Scenario Result
The GAP analysis setting in the Analysis always occurs for the project, whenever a regular project
property pages is set to Enabled. build occurs. Other analysis settings specified in the property pages
are used. Analysis setting in Tools > Options are ignored.
The Gap analysis setting in the Analysis occurs for this one run. The default values for this analysis
property pages is set to Disabled, are taken from Tools > Options and can be overridden in the
and GAP is run from the Tools dialog box. Options specified in the property pages are also used,
menu. but will be overridden by any specified analysis option.
30
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Scenario Result
The GAP analysis setting in the No analysis occurs, unless analysis is explicitly run from the Tools
property pages is set to Disabled, menu.
and GAP options are set in Tools >
Options.
See Also
Options: Guided Auto Parallelism dialog box
See Also
Code Coverage dialog box
31
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To start PGO:
1. Choose Tools > Intel Compiler > Profile Guided Optimization...
2. Specify settings for the various phases.
3. Click Run.
The Output windows show the results of the optimization with a link to the composite log.
See Also
Profile Guided Optimization dialog box
32
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE If the procedures in your project do not show when browsing in My Solution, you can right-
click the message (No information. Try browsing a different component set.) and select View
Containers as a possible solution.
Disable Database: Choose this option to disable creation of the code browsing database. This may help
increase performance on slow machines. If you disable the database, all features that rely on code browsing
information will not work.
Enable Find all References: Choose this option to enable display of the location(s) in your code where a
symbol is referenced. When this option is enabled, you can use the right-click context menu Find All
References option to display a list of references to the selected symbol. Double-click a reference to find that
reference.
Enable Go To Definition: Choose this option to enable quick navigation to an object definition. When this
option is enabled, you can use the right-click context menu Go to Definition option to locate where the
selected object was declared, opening the associated source file if required. (If you have also enabled Scan
system includes, any objects declared in system modules such as IFWINTY cause the associated source for
that module to be opened.)
Scan system includes: Choose this option to scan system include files. This option is used with one or
more of the following options: Collect Object Browser Information, Enable Find All References,
Enable Go To Definition.
Intrinsics Section
Enable Intrinsic Parameter Info: Choose this option to enable the display of intrinsic function and
subroutine parameter information. When this option is enabled, you can type a name of an intrinsic
procedure, followed by an open parenthesis, and information about the procedure and its arguments
appears.
Enable Intrinsic Quick Info: Choose this option to enable the display of additional information when the
cursor is moved over an intrinsic function or subroutine name.
Miscellaneous Section
Enumerate Comment Tasks: Choose this option to enable the display of a list of tasks consisting of source
files containing comments. Comments take the form of the ! character, followed by a token such as TO DO.
Valid tokens are listed in Tools > Options > Environment > Task List. When this option is enabled, you
can select Comments from the task list using View > Task List. Double-click a comment in the list to jump
to its location.
Highlight Matching Tokens: Choose this option to allow identifier highlighting and block delimiter
matching. When enabled, this option highlights all references to the identifier under the cursor.
Outlining Section
Enable Outlining: Choose this option to allow the collapsing of whole program units. When this option is
enabled, you can click the minus (-) or plus (+) symbols for PROGRAM, SUBROUTINE, FUNCTION, MODULE,
and BLOCK DATA statements.
Outline Statement Blocks: Choose this option to allow collapsing of block constructs such as IF and DO.
You must also choose Enable Outlining.
33
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Clean a project or solution (which deletes all files created during the Build).
• Select the active solution and configuration.
• Edit the project configuration.
When you have completed your project definition, you can build the executable program.
When you select Build <projectname> from the Build menu (or Build toolbar), the integrated
development environment (IDE) automatically updates dependencies, compiles and links all files in your
project. When you build a project, the IDE processes only the files in the project that have changed since the
last build and those files dependent on the changed files. The following example illustrates this.
NOTE To define the build order of projects, right-click on the solution and choose Properties >
Project Dependencies.
Example: Assume you have multiple projects (A, B, and C) in a solution with the following defined
dependencies:
• A depends on B
• B depends on C
If you build A, the build process verifies that B is up-to-date. During verification of B, C is also verified that it
is likewise up-to-date. When either, or both, are determined to be out of date, the appropriate build
operations will occur to update them. When C and B produce .lib or .dll output, the output of C is linked
into B and the output of B is linked into A.
The Rebuild <project name> option forces a new compilation of all source files listed for the project.
You either can choose to build a single project, the current project, or multiple project configurations (using
the Batch Build... option) in one operation. You can also choose to build the entire solution.
You can execute your program from the IDE using Debug > Start Without Debugging (Ctrl and F5) or
Debug > Start (F5). You can also execute your program from the command line prompt.
Compilation Errors
When the compiler encounters an error in a file, compilation stops and the error is reported. You can change
this default behavior and allow compilation to continue despite an error in the current file. When you do this,
an error in the current file will cause the compiler to begin compiling the next file.
To enable Continue on errors behavior:
1. In Tools > Options > Intel Compilers and Libraries > IFORT Intel Fortran Classic for ifort or
Tools > Options > Intel Compilers and Libraries > IFX Intel Fortran for ifx, select the General
category.
2. Check Continue on errors and click OK.
To set the maximum number of errors to encounter before compilation stops, choose Configuration
Properties > Fortran > Diagnostics > Error Limit.
34
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Convert Projects
In general, you can open projects created by older versions of Intel® Visual Fortran and use them directly. If
the projects were created in older versions of Microsoft Visual Studio*, the solution file is converted first and
then any non-Fortran projects it contains. Projects created in newer versions of Intel® Visual Fortran might
not be usable in older versions.
Projects created in Compaq* Visual Fortran 6.0 or later can usually be converted to Intel® Visual Fortran as
follows:
1. Open the Microsoft Visual Studio 6 workspace file (.dsw) in a newer version of Microsoft Visual Studio.
The project is converted to the new format.
2. Right click on the solution and select Extract Compaq Visual Fortran Project Items. This option
is available only if your installation of Microsoft Visual Studio includes Microsoft Visual C++ (MSVC).
Some general conversion principles apply:
• It is good practice to make a backup copy of the project before starting conversions.
• Intel® Fortran projects are created and built in a particular version of Microsoft Visual Studio. If you open
the project in a later version, you will be prompted to convert the solution. Once converted, a solution
cannot be used in its previous environment.
• Compaq Visual Fortran 6.x projects can be converted to Intel® Fortran projects in Microsoft Visual Studio
2017, 2019, or 2022 environments. Fortran-only projects are simpler to convert.
NOTE Support for Microsoft Visual Studio 2017 is deprecated as of the Intel® oneAPI 2022.1 release,
and will be removed in a future release.
• Project conversion support is provided for Compaq Visual Fortran Version 6.x only. Compaq Visual Fortran
projects created with earlier versions may not convert correctly.
• Fortran source files, resource files, and MIDL files lose any custom build step information when converted
from Compaq Visual Fortran to Intel® Fortran. For other file types, custom build steps are propagated
during the project's conversion.
• Conversion of Fortran and C/C++ mixed language projects results in the creation of two separate projects
(a Fortran project and a C/C++ project) in a single solution.
• Intel® Fortran projects that are created with a point release (for instance, 2022.x) are typically backward
compatible to the first release of that number (in this case, 2022.0). Projects are not backward-
compatible between major release numbers.
Copy Projects
You need to follow certain procedures to move a project's location if you copy a project to:
• Another disk or directory location on the same system.
• Another system where the Intel® Fortran Compiler is installed.
If you upgrade your operating system version on your current system, you should delete the *.SUO and
*.NCB files in each main project directory before you open solutions with the new operating system.
It is good practice to clean a solution before moving and copying project files. To do this, select Clean in the
Build menu.
35
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE The internal structure of module files can change between Intel® Fortran releases.
If you copied the project files to the same system or a system running the same platform and major
Intel® Fortran version, do the following steps to remove most or all of the files in the configuration
subdirectory:
1.
Open the appropriate solution. In the File menu, either select Open Solution or select Recent
Solutions. If you use Open Solution, select the appropriate .SLN file.
Select Clean in the Build menu.
2.
Repeat the previous two steps for other configurations whose subdirectories have been copied.
3.
4. If possible, after copying a project, verify that you can open the project at its new location using the
same Fortran version that it was created in. This ensures that the project has been moved successfully
and minimizes the chance of conversion problems. If you open the project with a later version of
Fortran, the project will be converted and you will not be able to convert the project back. For this
reason, making an archive copy of the project files before you start is recommended.
5. View the existing configurations. To view the existing configurations associated with the project, open
the solution and view available configurations using the drop-down box at the top of the screen.
6. Check and reset project options.
Because not all settings are transportable across different disks and systems, you should verify your
project settings on the new platform. To verify your project settings:
a. From the Project menu, choose Properties. The Project Property Pages dialog box appears.
b. Configure settings as desired. Pay special attention to the following items:
•General: Review the directories for intermediate and output files. If you moved the project to
a different system, be aware that any absolute directory paths (such as C:\TEMP or \Myproj
\TEMP) will most likely need to be changed. Instead, use relative path directory names
(without a leading back slash), such as Debug
• Custom Build Step: Review for any custom commands that might change between platforms.
• Pre-build, Pre-link, and Post-build Steps in Build Events: Review for any custom
commands that may have changed.
7. Check your source code for directory paths referenced in INCLUDE or similar statements. Microsoft
Visual Studio* provides a multi-file search capability called Find in Files, available from the Edit
menu.
36
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Use Fortran Single window main projects without graphics (resembles character-cell
Console applications). Requires no special programming expertise.
Application
Projects (.EXE)
Use Fortran Single window main projects with graphics. The programming complexity is simple
Standard Graphics to moderate, depending on the graphics and user interaction used.
Application
Projects (.EXE)
Use Fortran Multiple window main projects with graphics. The programming complexity is simple
QuickWin to moderate, depending on the graphics and user interaction used.
Application
Projects (.EXE)
Use Fortran Multiple window main projects with full graphical interface and access to all
Windowing Windows* API routines. Requires advanced programming expertise and knowledge
Application of the Call Windows API Routines.
Projects (.EXE)
If you need to use the command line to build your project, you can:
• Use the command line compiler options to specify the project type (see Specify Project Types with ifort
Command Options).
• Create the application from the command line (see Invoke the Intel® Fortran Compiler).
See Also
Understand Solutions Projects and Configurations
37
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• To create console application projects, you do not need to specify any options. (If you link separately,
specify the link option /subsystem:console.) A console application is the default project type created.
• To create standard graphics application projects, specify the libs option with keyword qwins (also sets
certain linker options).
• To create QuickWin application projects, specify the libs option with keyword qwin (also sets certain
linker options).
• To create windowing application projects, specify the winapp option (also sets certain linker options).
See Also
Understand Project Types
Use Fortran Console Application Projects
Use Fortran Standard Graphics Application Projects
Use Fortran QuickWin Application Projects
Use Fortran Windowing Application Projects
Use Fortran Dynamic-Link Library Projects
Use Fortran Static Library Projects
38
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
With a Fortran Console project, you cannot use the QuickWin functions. However, you can use single- or
multi-threaded static libraries, DLLs, and dialog boxes.
As with all Windows* command consoles, you can toggle between console viewing modes by pressing ALT
and ENTER.
See Also
Use the Console
Create a Standard Graphics Application with the Microsoft Visual Studio* IDE
1. Select the QuickWin Application project type.
2. Select the Standard Graphics Application template.
When you select the Fortran standard graphics project type, the IDE includes the QuickWin library
automatically, which lets you use the graphics functions. When building from the command line, you must
specify the libs option with keyword qwins. You cannot use the runtime functions meant for multiple-
window projects if you are building a standard graphics project. You cannot make a standard graphics
application a DLL.
See Also
Create Fortran Applications that Use Windows* Features
39
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
and be able to switch between them while also having a window for controlling the execution of your
program. These windows can be full screen or reduced in size and can be placed in various parts of the
screen.
QuickWin library routines let you build applications with a simplified version of the Windows* interface using
Intel® Fortran. The QuickWin library provides a rich set of Windows* features, but it does not include the
complete Windows* Applications Programming Interface (API). If you need additional capabilities, you must
set up a Windows* application to call the Windows* API directly rather than using QuickWin to build your
program.
Applications that use a multiple-document interface (MDI) have a menu bar at the top of the window and a
status bar at the bottom. The QuickWin library provides a default set of menus and menu items that you can
customize with the QuickWin APIs. An application that uses MDI creates many "child" windows within an
outer application window. The user area in an MDI application is a child window that appears in the space
between the menu bar and status bar of the application window. Your application can have more than one
child window open at a time.
Fortran QuickWin applications can use the IFLOGM module to access functions to control dialog boxes. These
functions allow you to display, initialize, and communicate with special dialog boxes in your application. They
are a subset of Windows* API functions, which Windows* applications can call directly.
See Also
Create Fortran Applications that Use Windows* Features
40
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Using multimedia functions, your application can create documents and presentations that incorporate music,
sound effects, and video clips as well as text and graphics. Multimedia functions provide services for audio,
video, file I/O, media control, joystick, and timers.
Remote Procedure Calls (RPC) gives you the means to carry out distributed computing, letting applications
tap the resources of computers on a network. A distributed application runs as a process in one address
space and makes procedure calls that execute in an address space on another computer. You can create
distributed applications using RPC, each consisting of a client that presents information to the user and a
server that stores, retrieves, and manipulates data as well as handling computing tasks. Shared databases
and remote file servers are examples of distributed applications.
See Also
Call Windows* API Routines
Create Fortran Applications that Use Windows* OS Features
NOTE
When compiling a static library from the command line, include the c option to suppress linking.
Without this option, the compiler generates an error because the library does not contain a main
program.
When you create a static library, you are asked to specify whether you want to prevent the insertion of link
directives for default libraries. By default, this checkbox is selected, which means insertion of link directives
is prevented. Select this option if you plan to use this static library with other Fortran projects. The option
prevents the static library from specifying a version of the Fortran runtime library. When the static library is
linked with another Fortran project, the Fortran runtime library choice in the other Fortran project is used for
the static library as well.
You may decide against selecting this option if you plan to use this static library with C/C++ projects. If you
do select it, you need to explicitly name the Fortran runtime library to use in the Linker Additional
Dependencies property. You can change your selection after creating the project using the Fortran Disable
Default Library Search Rules property.
A static library is a collection of source and object code defined in the Solution Explorer window. The
source code is compiled when you build the project. The object code is assembled into a .LIB file without
going through a linking process. The name of the project is used as the name of the library file by default.
Static libraries offer important advantages in organizing large programs and in sharing routines between
several programs. These libraries contain only subprograms, not main programs. A static library file has
a .LIB extension and contains object code.
When you associate a static library with a program, any necessary routines are linked from the library into
your executable program when it is built. Static libraries are usually kept in their own directories. If you use a
static library, only those routines actually needed by the program are incorporated into the executable image
(.EXE). This means that your executable image will be smaller than if you included all the routines in the
library in your executable image. The Linker determines which routines to include.
Because applications built with a static library all contain the same version of the routines in the library, you
can use static libraries to help keep applications current. When you revise the routines in a static library, you
can easily update all the applications that use it by relinking the applications.
If you have a library of substantial size, you should maintain it in a dedicated directory. Projects using the
library access it during linking.
When you link a project that uses the library, selected object code from the library is linked into that project's
executable code to satisfy calls to external procedures. Unnecessary object files are not included.
41
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To debug a static library, you must use a main program that calls the library routines. Both the main program
and the static library should have been compiled using the debug option. After compiling and linking is
completed, open the Debug menu and choose Go to reach breakpoints, or use the step controls on the
Debug toolbar.
See Also
Create Fortran Applications that Use Windows* OS Features
42
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Fortran Console applications automatically provide a console. Fortran QuickWin (and Fortran Standard
Graphics) applications do not provide a console, but display output and accept input from Fortran statements
by using the program window.
The following Fortran Project Types provide an application console window:
Fortran Provides a console window intended to be used for character-cell applications that use
Console text only.
When running a Fortran Console application from the command prompt, the existing
console environment is used. When you run the application from Windows* or Developer
Studio* (by selecting Start Without Debugging in the Debug menu), a new console
environment is created.
Basic console use is described in Code Samples of Console Use.
Fortran Does not provide a console, but output to unit 6 and input to unit 5 are directed to the
QuickWin or application program window, which can handle both text and graphics. Because the
Fortran program window must handle both text and graphics, it is not as efficient as the console
Standard for just text-only use. A Fortran QuickWin or Fortran Standard Graphics program window
Graphics (or child window) provides a console-like window.
See Console Use for Fortran QuickWin and Fortran Standard Graphics Applications.
Fortran Does not provide a console window, but the user can create a console by using Windows*
Windows API routines. See Console Use for Fortran Windows* Applications and Fortran DLL
Applications.
Fortran DLL Does not provide a console window, but the user can create a console by using Win32
routines. See Console Use for Fortran Windows* Applications and Fortran DLL
Applications.
Fortran Static Depends upon the project type of the main application that references the object code in
Library the library (see above project types).
In addition to the Windows* API routines mentioned below, there are other routines related to console use
described in the Microsoft Platform SDK* documentation.
Console Use for Fortran QuickWin and Fortran Standard Graphics Applications
For a Fortran QuickWin or Fortran Standard Graphics application, because the default program window
handles both graphics and text, the use of a QuickWin window may not be very efficient:
• QuickWin windows use lots of memory and therefore have size limitations.
• They can be slow to scroll.
Although you can access the console window using WRITE and READ (or other) statements, applications that
require display of substantial lines of text, consider creating a DLL that creates a separate console window for
efficiency. The DLL application needs to call Windows* API routines to allocate the console, display text,
accept keyed input, and free the console resources.
Basic use of a console is described in Code Samples of Console Use.
Console Use for Fortran Windows Applications and Fortran DLL Applications
With a Fortran Windows* or Fortran DLL application, attempting to write to the console using WRITE and
READ (or other) statements before a console is created results in a runtime error (such as error performing
WRITE).
43
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A console created by a Fortran DLL is distinct from any application console window associated with the main
application. A Fortran DLL application has neither a console nor an application window created for it, so it
must create (allocate) its own console using Windows* API routines. When used with a Fortran QuickWin or
Fortran Standard Graphics application main program, the Fortran DLL can provide its main application with a
very efficient console window for text-only use.
Like a Fortran DLL application, a Fortran Windows application has neither a console nor an application
window created for it, so it must create its own console using Windows* API routines. After allocating a
console in a Fortran DLL, the handle identifier returned by the GetStdHandle Windows* API routine refers
to the actual console the DLL creates.
When the Fortran Windows application does create a console window, it is very efficient for text-only use.
The handle identifier returned by the GetStdHandle Calling Windows* API Routines refers to the actual
console the Fortran Windows application creates.
For information about creating a console, see Allocating and Deallocating a Console below.
44
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you are using a DLL, your DLL code will need to create subprograms and export their symbols to the main
program.
Basic use of a console is described in Extend the Size of the Console Window and Console Buffer and Write
and Read Characters at a Cursor Position.
For example:
45
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
46
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Console Use for Fortran Windows* Applications and Fortran DLL Applications
Allocate and Deallocate a Console
Extend the Size of the Console Window and Console Buffer
Write and Read Characters at a Cursor Position
See Also
Intel® Software Documentation Library
Optimization Reports
47
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE You can specify how you want the optimization reporting to appear with the Optimization
Reports dialog box. Access this dialog box by selecting Tools > Options > Intel Compilers and
Libraries > Optimization Reports.
View Reports
When the compiler generates optimization diagnostics, the Compiler Optimization Report and the
Compiler Inline Report windows open, and optimization report annotations appear in the editor.
The Compiler Optimization Report window displays diagnostics for the following phases of the
optimization report:
• PGO
• LNO
• PAR
• VEC
• Offload (Linux* only)
• OpenMP*
• CG
Information appears in this window grouped by loops, or in a flat format. To switch the presentation format,
click the gear button on the toolbar of the window, and uncheck Group by loops.
In addition to sorting information by clicking column headers and resizing columns, you can use the windows
described in the following table:
Do This To Do This
Click a link in the Inlined into column. Jump to the call site of the function where the loop
is inlined.
Expand or collapse a diagnostic in Group by loops View detailed information for the diagnostic.
view.
Click the filter button. Select a scope by which to filter the diagnostics
that appear in the window.
The title bar of the Compiler Optimization
Report window shows the applied filter. Labels on
optimization phase filter buttons show how many
diagnostics of each phase are in the current scope.
Click a Compiler Optimization Report window Turn filtering diagnostics on or off for an
toolbar button corresponding to an optimization optimization phase.
report phase.
Labels on optimization phase filter buttons show
the total number of diagnostics for each phase.
By default all phases turned on.
Enter text in the search box in the Compiler Filter diagnostics using the text pattern.
Optimization Report window toolbar.
Diagnostics are filtered when you stop typing.
Pressing Enter saves this pattern in the search
history.
To disable filtering, clear the search box.
To use a pattern from the search history, click on
the down arrow next to the search box.
48
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The Compiler Inline Report window displays diagnostics for the IPO phase of the optimization report.
Information appears in this window in a tree. Each entry in the tree has corresponding information in the
right-hand pane under the Properties tab and the Inlining options tab.
You can use the window as described in the following table:
Do This To Do This
Double-click a diagnostic in the tree, or click on the Jump to the corresponding position in the editor.
source position link under the Properties tab.
Click Just My Code. Only display functions from your code, filter all
records from files that don't belong to the current
solution file tree.
Right-click on a function body in the editor and View detailed information for the specified function.
select Intel Compiler > Show Inline report for
function name.
Right-click on a function body in the editor and Show where the specified function is inlined.
select Intel Compiler > Show where function
name in inlined.
Enter text in the search box in the Compiler Inline Filter diagnostics using the text pattern.
Report window toolbar.
Diagnostics are filtered when you stop typing.
Pressing Enter saves this pattern in the search
history.
To disable filtering, clear the search box.
To use a pattern from the search history, click on
the down arrow next to the search box.
The Viewing Optimization Notes window in the editor provides context for the diagnostics that the
compiler generates:
• In Caller Site
• In Callee Site
• In Caller and Callee Site
You can use optimization notes as described in the following table:
Do This To Do This
Double-click an optimization note heading. Expand or collapse the current optimization note.
Click a hyperlink in the optimization note. Show where the specified function is inlined.
Click the help (?) icon. Get detailed help for the selected diagnostic. The
default browser opens and, if you are connected to
the internet, displays the help topic for this
diagnostic.
49
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Do This To Do This
Hover the mouse over a collapsed optimization View a detailed tool tip about that optimization
note. note.
See Also
Options: Optimization Reports dialog box
qopt-report-phase, Qopt-report-phase
Build Options
Continue on Errors: Check this box to allow compilation to continue regardless of an error in the current
file. The compiler will begin compiling the next file. (To set the maximum number of errors to encounter
before compilation stops, choose Configuration Properties > Fortran > Diagnostics > Error Limit).
Generate Build Logs: Check this box to generate build logs.
Show Environment in Log: Check this box to show environment variable settings in the log file.
50
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE The compiler details are shown in the two boxes directly below.
Executables: Specifies the directory location for executable files. You may specify this setting for each
selected compiler.
Includes: Specifies the directory location for included files. You may specify this setting for each selected
compiler.
Libraries: Specifies the directory location for libraries. You may specify this setting for each selected
compiler.
Default options: Sets the default options for a selected compiler You may specify this setting for each
selected compiler.
Reset...: Resets the settings for the compiler.
NOTE The compiler details are shown in the two boxes directly below.
Executables: Specifies the directory location for executable files. You may specify this setting for each
selected compiler.
Includes: Specifies the directory location for included files. You may specify this setting for each selected
compiler.
Libraries: Specifies the directory location for libraries. You may specify this setting for each selected
compiler.
Default options: Sets the default options for a selected compiler You may specify this setting for each
selected compiler.
Reset...: Resets the settings for the compiler.
See Also
Selecting the Compiler Version
Specifying Path, Library, and Include Directories
Browsing/Navigation Section
Collect Call/Callers graph information: Choose this option to enable or disable information collection for
the Call/Callers graph. Once enabled, you can right-click on a member name in the Code Editor, then click
Call Browser to view the member's call hierarchy.
Collect Object Browser information: Choose this option to enable the display of procedures in your
project in a hierarchical tree. Once enabled, you can use View > Object Browser to display your
procedures.
Disable Database: Choose this option to disable creation of the code browsing database. This may help
increase performance on slow machines. When you disable the database, all features that rely on code
browsing information do not work.
51
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Enable Database Saving/Loading: Choose this option to save collected data to a file on disk so that all
source browsing features are available immediately when you open the project. When this option is disabled,
the code browsing database is generated via background source parsing, so many features that rely on code
browsing information do not work until this process completes. Saving and loading the database requires
some additional time when saving and loading the project.
Enable Find All References: Choose this option to enable display of the location(s) in your code where a
symbol is referenced. When this option is enabled, you can use the right-click context menu Find All
References option to display a list of references to the selected symbol. Double-click on a reference to find
that reference.
Enable Go To Definition: Choose this option to enable quick navigation to an object definition. When this
option is enabled, you can use the right-click context menu Go to Definition option to locate where the
selected object was declared, opening the associated source file if required. (If you have also enabled Scan
system includes, any objects declared in system modules such as IFWINTY cause the associated source for
that module to be opened.)
Scan system includes: Choose this option to scan system include files. This option is used with one or
more of the following options: Collect Object Browser Information, Enable Find All References,
Enable Go To Definition.
Intrinsics Section
Enable Intrinsic Parameter Info: Choose this option to enable the display of intrinsic function and
subroutine parameter information. When this option is enabled, you can type a name of an intrinsic
procedure, followed by an open parenthesis, and information about the procedure and its arguments
appears.
Enable Intrinsic Quick Info: Choose this option to enable the display of additional information when the
mouse pointer is moved over an intrinsic function or subroutine name.
Miscellaneous Section
Enumerate Comment Tasks: Choose this option to enable the display of a list of tasks consisting of source
files containing comments. Comments take the form of the ! character, followed by a token such as TO DO.
Valid tokens are those listed in Tools > Options > Environment > Task List. When this option is enabled,
you can select Comments from the task list using either:
• View > Task List for Microsoft Visual Studio* 2017/2019
-OR-
• View > Other Windows > Task List for Microsoft Visual Studio 2022
You can double-click on a comment in the list to jump to its location.
Highlight Matching Tokens: Choose this option to allow identifier highlighting and block delimiter
matching. When enabled, this option highlights all references to the identifier under the cursor.
Outlining Section
Enable Outlining: Choose this option to allow the collapsing of whole program units. When this option is
enabled, you can click the minus (-) or plus (+) symbols for PROGRAM, SUBROUTINE, FUNCTION, MODULE,
and BLOCK DATA statements.
Outline Statement Blocks: Choose this option to allow collapsing of block constructs such as IF and DO.
You must also choose Enable Outlining.
52
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To access this dialog box, click Tools > Intel Compiler > Guided Auto Parallelism > Run Analysis on
file... for files, or Tools > Intel Compiler > Guided Auto Parallelism > Run Analysis on project... for
projects.
See Also
Options: Guided Auto Parallelism dialog box
General
Always Show Compiler Inline Report: Specify if the Compiler Inline Report appears after building or
rebuilding your solution or project when inline diagnostics are present.
Always Show Compiler Optimization Report: Specify if Compiler Optimization Report appears after
building or rebuilding your solution or project when optimization diagnostics are present. This option has
higher priority than Always Show Compiler Inline Report. If both options are set to True, then this
window has focus by default.
Show Optimization Notes in Text Editor Margin: Specify if optimization notes appear in the editor as
source code annotations.
53
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Optimization Reports: Enabling in Visual Studio*
NOTE The Guided Auto Parallelism dialog box is only available for ifort.
To access the Guided Auto Parallelism page click Tools > Options and then select: Intel Compilers and
Libraries > IFORT Intel Fortran Classic > Guided Auto Parallelism.
These settings are used when running analysis using Tools > Intel Compiler > Guided Auto
Parallelism > Run Analysis on project...
54
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Send remarks to a file: Check this box to send GAP remarks to a specified text file.
Remarks file: Specify the filename where GAP remarks will be sent.
Save these settings as the default (in Tools > Options for Guided Auto Parallelism): Check this box
to save the specified settings as the default settings.
Show this dialog next time (in Tools > Intel Compiler): Check this box to display this dialog box next
time.
When you are done specifying settings, click Run Analysis.
See Also
Options: Guided Auto Parallelism dialog box
PGO Options
Show PGO Dialog: Specify whether to display the Profile Guided Optimization dialog box when you
begin PGO.
See Also
Using Profile Guided Optimization in Microsoft* Visual Studio*
Profile-Guided Optimizations
55
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Instrument with guards for threaded application: Select this checkbox to produce an instrumented
object file that includes the collection of PGO data on applications that use a high level of parallelism.
Selecting an option produces a static profile information file (.spi), but also increases the time needed to do
a parallel build.
Deselect the checkbox to skip this phase to save time running profile guided optimization. When you skip this
phase, you use the existing profile information when running profile guided optimization. For example, you
may want to skip this phase when you change the code to fix a bug and the fix doesn't affect the architecture
of the project.
Phase 2 - Run Instrumented Application(s): This phase runs the instrumented application produced in
the previous phase as well as other applications in the Applications Invocations dialog box. To add a new
application or edit an existing application in the list, click Applications Invocations.
Deselect the checkbox to skip this phase to save time running profile guided optimization. When you skip this
phase, you do not run the applications in the list when running profile guided optimization. For example, you
might want to skip this phase when you change the code to fix a bug and the fix doesn't affect the
architecture of the project.
Phase 3 - Optimize with Profile Data: This phase performs the profile guided optimization.
Deselect the checkbox to skip this phase.
Profile Directory: The directory that contains the profile. Click Edit to edit the profile directory or the
Browse button to browse for the profile directory.
Show this dialog next time: Deselect this checkbox to run profile guided optimization without displaying
this dialog box. The profile guided optimization will use these settings.
Save Settings: Click to save your settings.
Run: Click to start the profile guided optimization.
Cancel: Click to close this dialog box without starting the profile guided optimization.
56
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Command: Add a new or edit an existing application. Click Edit to open the Command dialog box with a list
of macros. Click Browse to navigate to another directory that contains the application.
Command Arguments: Enter the arguments required by the application.
Working Directory: Enter a new or edit the working directory for the application. Click Edit to open the
Working Directory dialog box with a list of macros. Click Browse to navigate to working directory of the
application.
Environment: Enter the environment variable required by this application.
Merge Environment: Select this checkbox to merge the application environment with the environment
defined by the operating system.
Load from Debugging Settings: Click to load the debug settings for this application.
OK: Click to save the settings and close this dialog box.
Cancel: Click to discard the settings and close this dialog box.
NOTE The Edit Command and Add Command dialog boxes are similar. To use the Edit Command
dialog box, substitute Edit for Add in the selections above.
See Also
Profile-Guided Optimization
Using Function Order Lists, Function Grouping, Function Ordering, and Data Ordering
Optimizations
Codecov Options
Use the available options to:
• Select colors to be used to show covered and uncovered code.
57
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
General
Show Code Coverage Dialog: Specify whether to display the Code Coverage dialog box when you begin
code coverage.
Profmerge Options
Suppress Startup Banner: Specify whether version information is displayed.
Verbose: Specify whether additional informational and warning messages should be displayed.
See Also
Using Code Coverage in Microsoft Visual Studio*
See Also
Using Code Coverage in Microsoft Visual Studio*
Code Coverage Settings dialog box
code coverage Tool
58
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Codecov Options
Additional Options: Any command that you enter in the edit box will be passed through to the tool:
Codecov.exe.
Ignore Object Unwind Handlers: Set to True to ignore the object unwind handlers.
Show Execution Counts: Set to True to show the dynamic execution counts in the report.
Treat Partially-covered Code As Fully-covered: Set to True to treat partially covered code as fully
covered code.
Profmerge Options
Additional Options: Any command that you enter in the edit box will be passed through to the tool:
Profmerge.exe.
Dump Profile Information: Set to True to include profile information in the report.
Exclude Functions: Enter the functions that will be excluded from the profile. The functions must be
separated by a comma (","). A period (".") can be used as a wildcard character in function names.
OK: Click to save your settings and close this dialog box.
Cancel: Click to discard the settings and close this dialog box.
See Also
Code Coverage dialog box
Using Code Coverage in the Microsoft Visual Studio* IDE
code coverage Tool
Compiler Reference
This section contains compiler reference information. For example, it contains information about compiler
options, compiler limits, and libraries.
Compiler Limits
The amount of data storage, the size of arrays, and the total size of executable programs are limited only by
the amount of process virtual address space available, as determined by system parameters.
The table below shows the limits to the size and complexity of a single Intel® Fortran program unit and to
individual statements contained within it:
Array dimensions 31
(The Fortran 2018 standard supports a maximum array
dimension of 15.)
59
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Continuation lines No fixed limit; at least 255 lines of 132 or fewer characters.
Longer lines may reduce the number of allowed continuations,
subject to the limit on lexical tokens per statement.
Fortran source line length fixed form: 72 (or 132 if /extend_source is in effect)
characters
free form: 7200 characters
Structure nesting 30
Width field for a numeric edit descriptor 2**15-1 on systems using IA-32 architecture
2**31-1 on systems using Intel® 64 architecture
60
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For limits of other edit descriptor fields, see Forms for Data
Edit Descriptors.
For more information on memory limits for large data objects, see:
• The AUTOMATIC statement
• The /F compiler option
• The heap-array compiler option
• The product Release Notes
See Also
Forms for Data Edit Descriptors
NOTE
The objects listed here are provided as an advanced feature for developers who are already familiar
with using Automation objects and the Visual Studio* object model.
Object Description
VFCustomBuildTool Programmatically accesses the properties in the Custom Build Step property page
in a project's Property Pages dialog box.
VFDebugSettings Contains properties that allow the user to programmatically manipulate the settings
in the Debug property page.
VFFile Describes the operations that can take place on a file in the active project.
VFFileConfiguration Contains build information about a file (VFFile object), including such things as what
tool is attached to the file for that configuration.
VFFilter Exposes the functionality on a folder in Solution Explorer for an Intel® Visual Fortran
project.
VFFortranCompiler Provides access to properties relating to the Intel® Visual Fortran Compiler version.
Version
61
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
VFManifestTool Programmatically accesses the properties in the Manifest Tool folder of a project's
Property Pages dialog box.
VFMidlTool Programmatically accesses the properties in the MIDL folder of a project's Property
Pages dialog box.
VFPreBuildEventTo Programmatically accesses the properties on the Pre-Build Event property page, in
ol the Build Events folder in a project's Property Pages dialog box.
VFPreLinkEventToo Programmatically accesses the properties on the PreLink Event property page, in
l the Build Events folder in a project's Property Pages dialog box.
VFPostBuildEventT Programmatically accesses the properties on the Post-Build Event property page,
ool in the Build Events folder in a project's Property Pages dialog box.
The following example, written in Visual Basic*, demonstrates how to use automation objects to modify the
list of available platforms and versions in the Visual Studio* IDE Configuration Manager:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VFProject
Imports System.Collections
Public Module MultiPV
' Create a Console application before executing this module
' Module demonstrates Multi Platform & Multi Version Automation Support
' Variable definition
Dim Prj As Project ' VS project
Dim VFPrj As VFProject ' Intel VF project
Dim o As Object ' Object
Sub run()
' Get the Project
Prj = DTE.Solution.Projects.Item(1)
'
' Get Intel VF project
VFPrj = Prj.Object
'
' Get list of Supported platforms
Dim pList As ArrayList = New ArrayList() ' list of platforms
Dim cList As ArrayList = New ArrayList() ' lost of compilers
Dim i As Integer
pList = getSupportedPlatforms()
For i = 0 To pList.Count - 1
cList = getCompilers(pList.Item(i))
printCompilers(pList.Item(i), cList)
Next
'
' Add configurations - x64
For i = 0 To pList.Count - 1
If pList.Item(i) <> "Win32" Then
addConfiguration(pList.Item(i))
End If
Next
62
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
63
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
64
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
65
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Next
Next
End Sub
Sub SolutionRebuild()
DTE.Solution.SolutionBuild.Clean(True)
DTE.Solution.SolutionBuild.Build(True)
End Sub
End Module
Compiler Options
This compiler supports many compiler options you can use in your applications.
The LLVM-based Intel® Fortran Compiler (ifx) supports many Intel® Fortran Compiler Classic compiler options,
but full implementation is not yet available. Implementation will be improved in future releases.
In this section, we provide the following:
• An alphabetical list of compiler options that includes their short descriptions
• Lists of deprecated and removed options
• General rules for compiler options and the conventions we use when referring to options
• Details about what appears in the compiler option descriptions
• A description of each compiler option. The descriptions appear under the option's functional category.
Within each category, the options are listed in alphabetical order.
Several Clang compiler options are supported for the ifx compiler, such as some of the -fprofile options.
We do not document these options. For more information about Clang options, see the Clang documentation.
Note that for ifx, the Clang -fprofile options replace the functionality of the [Q]prof options that are only
supported for ifort.
For details about new functionality, such as new compiler options, see the Release Notes for the product.
compiler option name shortcuts The following conventions are used as shortcuts
when referencing compiler option names in
descriptions:
• No initial – or /
This shortcut is used for option names that are
the same for Linux and Windows except for the
initial character.
For example, Fa denotes:
66
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
67
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the Windows
option /[no]traceback, /traceback enables the
option, while /notraceback disables it.
4Nportlib, 4Yportlib Determines whether the compiler links to the library of portability
routines.
ansi-alias, Qansi-alias Tells the compiler to assume certain rules of the Fortran standard
regarding aliasing and array bounds.
arch Tells the compiler which features it may target, including which
instruction sets it may generate.
auto-scalar, Qauto-scalar Causes scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and
LOGICAL that do not have the SAVE attribute to be allocated to the run-
time stack.
bigobj Increases the number of sections that an object file can contain. This
feature is only available for ifort.
bintext Places a text string into the object file (.obj) being generated by the
compiler. This feature is only available for ifort.
B Specifies a directory that can be used to find include files, libraries, and
executables.
c Prevents linking.
ccdefault Specifies the type of carriage control used when a file is displayed at a
terminal screen.
68
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
coarray-config-file, Qcoarray- Specifies the name of a Message Passing Interface (MPI) configuration
config-file file.
coarray-num-images, Specifies the default number of images that can be used to run a coarray
Qcoarray-num-images executable.
cxxlib Determines whether the compiler links using the C++ run-time libraries
provided by gcc.
dbglibs Tells the linker to search for unresolved references in a debug run-time
library.
debug-parameters Tells the compiler to generate debug information for PARAMETERs used in
a program.
diag-dump, Qdiag-dump Tells the compiler to print all enabled diagnostic messages.
diag-error-limit, Qdiag-error- Specifies the maximum number of errors allowed before compilation
limit stops.
diag-id-numbers, Qdiag-id- Determines whether the compiler displays diagnostic messages by using
numbers their ID number values.
diag-once, Qdiag-once Tells the compiler to issue one or more diagnostic messages only once.
double-size Specifies the default KIND for DOUBLE PRECISION and DOUBLE COMPLEX
declarations, constants, functions, and intrinsics.
dryrun Specifies that driver tool commands should be shown but not executed.
dynamiclib Invokes the libtool command to generate dynamic libraries. This feature
is only available for ifort.
69
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
extend-source Specifies the length of the statement field in a fixed-form source file.
F ( macOS* ) Adds a framework directory to the head of an include file search path.
This feature is only available for ifort.
f77rtl Tells the compiler to use the run-time behavior of FORTRAN 77.
falias, Oa Specifies whether or not a procedure call may have hidden aliases of local
variables not supplied as actual arguments.
falign-functions, Qfnalign Tells the compiler to align procedures on an optimal byte boundary.
falign-loops, Qalign-loops Aligns loops to a power-of-two byte boundary. This feature is only
available for ifort.
falign-stack Tells the compiler the stack alignment to use on entry to routines. This
option is deprecated and will be removed in a future release. This feature
is only available for ifort.
fast-transcendentals, Qfast- Enables the compiler to replace calls to transcendental functions with
transcendentals faster but less precise implementations. This feature is only available for
ifort.
fcode-asm Produces an assembly listing with machine code annotations. This feature
is only available for ifort.
Fd Lets you specify a name for a program database (PDB) file created by the
compiler. This feature is only available for ifort.
70
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fexceptions Enables exception handling table generation. This feature is only available
for ifort.
fimf-absolute-error, Qimf- Defines the maximum allowable absolute error for math library function
absolute-error results.
fimf-accuracy-bits, Qimf- Defines the relative error for math library function results, including
accuracy-bits division and square root.
fimf-arch-consistency, Qimf- Ensures that the math library functions produce consistent results across
arch-consistency different microarchitectural implementations of the same architecture.
fimf-domain-exclusion, Qimf- Indicates the input arguments domain on which math functions must
domain-exclusion provide correct results.
fimf-force-dynamic-target, Instructs the compiler to use run-time dispatch in calls to math functions.
Qimf-force-dynamic-target
fimf-max-error, Qimf-max- Defines the maximum allowable relative error for math library function
error results, including division and square root.
fimf-precision, Qimf-precision Lets you specify a level of accuracy (precision) that the compiler should
use when determining which math library functions to use.
fimf-use-svml, Qimf-use-svml Instructs the compiler to use the Short Vector Math Library (SVML) rather
than the Intel® Fortran Compiler Classic and Intel® Fortran Compiler Math
Library (LIBM) to implement math library functions.
finline Tells the compiler to inline functions declared with !DIR$ ATTRIBUTES
FORCEINLINE .
finstrument-functions, Determines whether routine entry and exit points are instrumented.
Qinstrument-functions
fkeep-static-consts , Qkeep- Tells the compiler to preserve allocation of variables that are not
static-consts referenced in the source. This feature is only available for ifort.
flto Enables whole program link time optimization (LTO). This feature is only
available for ifx.
fma, Qfma Determines whether the compiler generates fused multiply-add (FMA)
instructions if such instructions exist on the target processor.
fmath-errno Tells the compiler that errno can be reliably tested after calls to standard
math library functions. This feature is only available for ifort.
71
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fmerge-constants Determines whether the compiler and linker attempt to merge identical
constants (string constants and floating-point constants) across
compilation units. This feature is only available for ifort.
fmpc-privatize Enables or disables privatization of all static data for the MultiProcessor
Computing environment (MPC) unified parallel runtime. This feature is
only available for ifort.
fnsplit, Qfnsplit Enables function splitting. This feature is only available for ifort.
fopenmp-target-buffers, Enables a way to overcome the problem where some OpenMP* offload
Qopenmp-target-buffers SPIR-V* devices produce incorrect code when a target object is larger
than 4GB. This feature is only available for ifx.
fopenmp-targets, Qopenmp- Enables offloading to a specified GPU target if OpenMP* features have
targets been enabled. This feature is only available for ifx.
foptimize-sibling-calls Determines whether the compiler optimizes tail recursive calls. This
feature is only available for ifort.
fpe Allows some control over floating-point exception handling for the main
program at run-time.
fpe-all Allows some control over floating-point exception handling for each
routine in a program at run-time.
72
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fp-port, Qfp-port Rounds floating-point results after floating-point operations. This feature
is only available for ifort.
fprotect-parens, Qprotect- Determines whether the optimizer honors parentheses when floating-
parens point expressions are evaluated.
fpscomp Controls whether certain aspects of the run-time system and semantic
language features within the compiler are compatible with Intel® Fortran
or Microsoft* Fortran PowerStation.
fp-speculation, Qfp- Tells the compiler the mode in which to speculate on floating-point
speculation operations.
fp-stack-check, Qfp-stack- Tells the compiler to generate extra code after every function call to
check ensure that the floating-point stack is in the expected state. This feature
is only available for ifort.
fsource-asm Produces an assembly listing with source code annotations. This feature is
only available for ifort.
fstack-protector Enables or disables stack overflow security checks for certain (or all)
routines.
fstack-security-check Determines whether the compiler generates code that detects some
buffer overruns.
fsycl Enables linking Fortran object files with DPC++ SYCL-based object files.
This feature is only available for ifx.
fsycl-device-code-split Specifies a SYCL* device code module assembly. This feature is only
available for ifx.
fsycl-device-lib Enables or disables certain device libraries for a SYCL* target. This
feature is only available for ifx.
fsycl-link-huge-device-code Tells the compiler to place device code later in the linked binary. This is to
prevent 32-bit PC-relative relocations between surrounding Executable
and Linkable Format (ELF) sections when the device code is larger than
2GB. This feature is only available for ifx.
ftrapuv , Qtrapuv Initializes stack local variables to an unusual value to aid error detection.
This feature is only available for ifort.
fuse-ld Tells the compiler to use a different linker instead of the default linker,
which is ld on Linux and link on Windows.
fvec-peel-loops, Qvec-peel- Enables peel loop vectorization. This feature is only available for ifx.
loops
fvec-remainder-loops, Qvec- Enables remainder loop vectorization. This feature is only available for ifx.
remainder-loops
fvec-with-mask, Qvec-with- Enables vectorization for short trip-count loops with masking. This feature
mask is only available for ifx.
73
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fvisibility Specifies the default visibility for global symbols or the visibility for
symbols in a file. This feature is only available for ifort.
fzero-initialized-in-bss, Qzero- Determines whether the compiler places in the DATA section any
initialized-in-bss variables explicitly initialized with zeros. This feature is only available for
ifort.
gcc-name Lets you specify the name of the GCC compiler that should be used to set
up the link-time environment, including the location of standard libraries.
gdwarf Lets you specify a DWARF Version format when generating debug
information.
gen-dep Tells the compiler to generate build dependencies for the current
compilation.
gen-depformat Specifies the form for the output generated when option gen-dep is
specified.
gen-interfaces Tells the compiler to generate an interface block for each routine in a
source file.
global-hoist, Qglobal-hoist Enables certain optimizations that can move memory loads to a point
earlier in the program execution than where they appear in the source.
This feature is only available for ifort.
grecord-gcc-switches Causes the command line options that were used to invoke the compiler
to be appended to the DW_AT_producer attribute in DWARF debugging
information.
Gs Lets you control the threshold at which the stack checking routine is
called or not called.
guide, Qguide Lets you set a level of guidance for auto-vectorization, auto parallelism,
and data transformation. This feature is only available for ifort.
guide-data-trans, Qguide- Lets you set a level of guidance for data transformation. This feature is
data-trans only available for ifort.
guide-file, Qguide-file Causes the results of guided auto parallelism to be output to a file. This
feature is only available for ifort.
guide-file-append, Qguide- Causes the results of guided auto parallelism to be appended to a file.
file-append This feature is only available for ifort.
74
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
guide-opts, Qguide-opts Tells the compiler to analyze certain code and generate recommendations
that may improve optimizations. This feature is only available for ifort.
guide-par, Qguide-par Lets you set a level of guidance for auto parallelism. This feature is only
available for ifort.
guide-vec, Qguide-vec Lets you set a level of guidance for auto-vectorization. This feature is only
available for ifort.
gxx-name Lets you specify the name of the g++ compiler that should be used to set
up the link-time environment, including the location of standard libraries.
heap-arrays Puts automatic arrays and arrays created for temporary computations on
the heap instead of the stack.
homeparams Tells the compiler to store parameters passed in registers to the stack.
This feature is only available for ifort.
hotpatch Tells the compiler to prepare a routine for hotpatching. This feature is
only available for ifort.
init, Qinit Lets you initialize a class of variables to zero or to various numeric
exceptional values.
inline-factor, Qinline-factor Specifies the percentage multiplier that should be applied to all inlining
options that define upper limits. This feature is only available for ifort.
inline-forceinline, Qinline- Instructs the compiler to force inlining of functions suggested for inlining
forceinline whenever the compiler is capable doing so. This feature is only available
for ifort.
inline-max-per-routine, Specifies the maximum number of times the inliner may inline into a
Qinline-max-per-routine particular routine. This feature is only available for ifort.
inline-max-size, Qinline-max- Specifies the lower limit for the size of what the inliner considers to be a
size large routine. This feature is only available for ifort.
inline-max-total-size, Qinline- Specifies how much larger a routine can normally grow when inline
max-total-size expansion is performed. This feature is only available for ifort.
inline-min-caller-growth, Lets you specify a procedure size n for which procedures of size <= n do
Qinline-min-caller-growth not contribute to the estimated growth of the caller when inlined. This
feature is only available for ifort.
inline-min-size, Qinline-min- Specifies the upper limit for the size of what the inliner considers to be a
size small routine. This feature is only available for ifort.
75
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
intconstant Tells the compiler to use FORTRAN 77 semantics to determine the kind
parameter for integer constants.
integer-size Specifies the default KIND for integer and logical variables.
intel-freestanding-target-os Lets you specify the target operating system for compilation.
ip-no-inlining, Qip-no-inlining Disables full and partial inlining enabled by interprocedural optimization
options. This feature is only available for ifort.
ipo-c, Qipo-c Tells the compiler to optimize across multiple files and generate a single
object file.
ipo-S, Qipo-S Tells the compiler to optimize across multiple files and generate a single
assembly file. This feature is only available for ifort.
ipo-separate, Qipo-separate Tells the compiler to generate one object file for every source file. This
feature is only available for ifort.
isystem Specifies a directory to add to the start of the system include path.
libdir Controls whether linker options for search libraries are included in object
files generated by the compiler.
libs Tells the compiler which type of run-time library to link to.
list-line-len Specifies the line length for the listing generated when option list is
specified.
list-page-len Specifies the page length for the listing generated when option list is
specified.
m32, m64 , Qm32 , Qm64 Tells the compiler to generate code for a specific architecture. Option m32
(and /Qm32) is deprecated and will be removed in a future release. 32-
bit options are only available for ifort.
76
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
map-opts, Qmap-opts Maps one or more compiler options to their equivalent on a different
operating system.
march Tells the compiler to generate code for processors that support certain
features.
masm Tells the compiler to generate the assembler output file using a selected
dialect.
mbranches-within-32B- Tells the compiler to align branches and fused branches on 32-byte
boundaries, Qbranches- boundaries for better performance.
within-32B-boundaries
mcmodel Tells the compiler to use a specific memory model to generate code and
store data.
mconditional-branch, Lets you identify and fix code that may be vulnerable to speculative
Qconditional-branch execution side-channel attacks, which can leak your secure data as a
result of bad speculation of a conditional branch direction. This feature is
only available for ifort.
minstruction, Qinstruction Determines whether MOVBE instructions are generated for certain Intel®
processors. This feature is only available for ifort.
module Specifies the directory where module files should be placed when created
and where they should be searched for.
momit-leaf-frame-pointer Determines whether the frame pointer is omitted or kept in leaf functions.
mp1, Qprec Improves floating-point precision and consistency. This feature is only
available for ifort.
mstringop-inline-threshold, Tells the compiler to not inline calls to buffer manipulation functions such
Qstringop-inline-threshold as memcpy and memset when the number of bytes the functions handle
are known at compile time and greater than the specified value. This
feature is only available for ifort.
mstringop-strategy, Lets you override the internal decision heuristic for the particular
Qstringop-strategy algorithm used when implementing buffer manipulation functions such as
memcpy and memset. This feature is only available for ifort.
mtune, tune Performs optimizations for specific processors but does not cause
extended instruction sets to be used (unlike -march).
77
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
multiple-processes , MP Creates multiple processes that can be used to compile large numbers of
source files at the same time.
names Specifies how source code identifiers and external names are interpreted.
no-bss-init, Qnobss-init Tells the compiler to place in the DATA section any uninitialized variables
and explicitly zero-initialized variables. This option is deprecated and will
be removed in a future release. This feature is only available for ifort.
nodefaultlibs Prevents the compiler from using standard libraries when linking.
no-intel-lib, Qno-intel-lib Disables linking to specified Intel® libraries, or to all Intel® libraries.
nolibsycl Disables linking of the SYCL* runtime library. This feature is only
available for ifx.
nostartfiles Prevents the compiler from using standard startup files when linking.
nostdlib Prevents the compiler from using standard libraries and startup files when
linking.
Ofast Sets certain aggressive options to improve the speed of your application.
p Compiles and links for function profiling with gprof(1). This feature is only
available for ifort.
pad, Qpad Enables the changing of the variable and array memory layout.
par-affinity, Qpar-affinity Specifies thread affinity. This feature is only available for ifort.
parallel, Qparallel Tells the auto-parallelizer to generate multithreaded code for loops that
can be safely executed in parallel. This feature is only available for ifort.
par-num-threads, Qpar-num- Specifies the number of threads to use in a parallel region. This feature is
threads only available for ifort.
par-runtime-control, Qpar- Generates code to perform run-time checks for loops that have symbolic
runtime-control loop bounds. This feature is only available for ifort.
par-schedule, Qpar-schedule Lets you specify a scheduling algorithm for loop iterations. This feature is
only available for ifort.
par-threshold, Qpar-threshold Sets a threshold for the auto-parallelization of loops. This feature is only
available for ifort.
78
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pdbfile Lets you specify the name for a program database (PDB) file created by
the linker. This feature is only available for ifort.
prec-div, Qprec-div Improves precision of floating-point divides. This feature is only available
for ifort.
prec-sqrt, Qprec-sqrt Improves precision of square root implementations. This feature is only
available for ifort.
prof-data-order, Qprof-data- Enables or disables data ordering if profiling information is enabled. This
order feature is only available for ifort.
prof-dir, Qprof-dir Specifies a directory for profiling information output files. This feature is
only available for ifort.
prof-file, Qprof-file Specifies an alternate file name for the profiling summary files. This
feature is only available for ifort.
prof-gen, Qprof-gen Produces an instrumented object file that can be used in profile guided
optimization. This feature is only available for ifort.
prof-gen-sampling Tells the compiler to generate debug discriminators in debug output. This
aids in developing more precise sampled profiling output. This option is
deprecated and will be removed in a future release. This feature is only
available for ifort.
prof-hotness-threshold, Lets you set the hotness threshold for function grouping and function
Qprof-hotness-threshold ordering. This feature is only available for ifort.
prof-src-dir, Qprof-src-dir Determines whether directory information of the source file under
compilation is considered when looking up profile data records. This
feature is only available for ifort.
prof-src-root, Qprof-src-root Lets you use relative directory paths when looking up profile data and
specifies a directory as the base. This feature is only available for ifort.
prof-src-root-cwd, Qprof-src- Lets you use relative directory paths when looking up profile data and
root-cwd specifies the current working directory as the base. This feature is only
available for ifort.
prof-use, Qprof-use Enables the use of profiling information during optimization. This feature
is only available for ifort.
prof-use-sampling Lets you use data files produced by hardware profiling to produce an
optimized executable. This option is deprecated and will be removed in a
future release. This feature is only available for ifort.
prof-value-profiling, Qprof- Controls which values are value profiled. This feature is only available for
value-profiling ifort.
79
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pthread Tells the compiler to use pthreads library for multithreading support.
Qcov-dir Specifies a directory for profiling information output files that can be used
with the codecov or tselect tool. This feature is only available for ifort.
Qcov-file Specifies an alternate file name for the profiling summary files that can
be used with the codecov or tselect tool. This feature is only available for
ifort.
Qcov-gen Produces an instrumented object file that can be used with the codecov
or tselect tool. This feature is only available for ifort.
Qinline-dllimport Determines whether dllimport functions are inlined. This feature is only
available for ifort.
Qinstall Specifies the root directory where the compiler installation was
performed.
qmkl, Qmkl Tells the compiler to link to certain libraries in the Intel® oneAPI Math
Kernel Library ( oneMKL ) . On Windows systems, you must specify this
option at compile time.
qmkl-ilp64, Qmkl-ilp64 Tells the compiler to link to the ILP64-specific version of the Intel® oneAPI
Math Kernel Library ( oneMKL ) . On Windows systems, you must specify
this option at compile time.
qopenmp, Qopenmp Enables recognition of OpenMP* features and tells the parallelizer to
generate multi-threaded code based on OpenMP* directives.
qopenmp-lib, Qopenmp-lib Lets you specify an OpenMP* run-time library to use for linking.
qopenmp-link Controls whether the compiler links to static or dynamic OpenMP* run-
time libraries.
qopt-args-in-regs, Qopt-args- Determines whether calls to routines are optimized by passing arguments
in-regs in registers instead of on the stack. This option is deprecated and will be
removed in a future release. This feature is only available for ifort.
qopt-assume-safe-padding, Determines whether the compiler assumes that variables and dynamically
Qopt-assume-safe-padding allocated memory are padded past the end of the object. This feature is
only available for ifort.
qopt-block-factor, Qopt-block- Lets you specify a loop blocking factor. This feature is only available for
factor ifort.
qopt-for-throughput, Qopt- Determines how the compiler optimizes for throughput depending on
for-throughput whether the program is to run in single-job or multi-job mode. This
feature is only available for ifx.
80
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-jump-tables, Qopt- Enables or disables generation of jump tables for switch statements. This
jump-tables feature is only available for ifort.
qopt-malloc-options Lets you specify an alternate algorithm for malloc(). This feature is only
available for ifort.
qopt-multi-version- Tells the compiler to use aggressive multi-versioning to check for pointer
aggressive, Qopt-multi- aliasing and scalar replacement. This feature is only available for ifort.
version-aggressive
qopt-prefetch, Qopt-prefetch Enables or disables prefetch insertion optimization. This feature is only
available for ifort.
qopt-ra-region-strategy, Selects the method that the register allocator uses to partition each
Qopt-ra-region-strategy routine into regions. This feature is only available for ifort.
qopt-report, Qopt-report (ifort Tells the compiler to generate an optimization report. This description is
only) only for ifort.
qopt-report, Qopt-report (ifx Enables the generation of a YAML file that includes optimization
only) transformation information. This description is only for ifx.
qopt-report-annotate, Qopt- Enables the annotated source listing feature and specifies its format. This
report-annotate feature is only available for ifort.
qopt-report-annotate- Enables the annotated source listing feature and specifies the site where
position, Qopt-report- optimization messages appear in the annotated source in inlined cases of
annotate-position loop optimizations. This feature is only available for ifort.
qopt-report-file, Qopt-report- Specifies whether the output for the generated optimization report goes
file to a file, stderr, or stdout.
qopt-report-filter, Qopt- Tells the compiler to find the indicated parts of your application, and
report-filter generate optimization reports for those parts of your application. This
feature is only available for ifort.
qopt-report-format, Qopt- Specifies the format for an optimization report. This feature is only
report-format available for ifort.
qopt-report-help, Qopt- Displays the optimizer phases available for report generation and a short
report-help description of what is reported at each level. This feature is only available
for ifort.
81
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-report-names, Qopt- Specifies whether mangled or unmangled names should appear in the
report-names optimization report. This feature is only available for ifort.
qopt-report-per-object, Qopt- Tells the compiler that optimization report information should be
report-per-object generated in a separate file for each object. This feature is only available
for ifort.
qopt-report-phase, Qopt- Specifies one or more optimizer phases for which optimization reports are
report-phase generated. This feature is only available for ifort.
qopt-report-routine, Qopt- Tells the compiler to generate an optimization report for each of the
report-routine routines whose names contain the specified substring. This feature is only
available for ifort.
qopt-subscript-in-range, Determines whether the compiler assumes that there are no "large"
Qopt-subscript-in-range integers being used or being computed inside loops. This feature is only
available for ifort.
qoverride-limits, Qoverride- Lets you override certain internal compiler limits that are intended to
limits prevent excessive memory usage or compile times for very large,
complex compilation units. This feature is only available for ifort.
Qpar-adjust-stack Tells the compiler to generate code to adjust the stack size for a fiber-
based main thread. This feature is only available for ifort.
Qpatchable-addresses Tells the compiler to generate code such that references to statically
assigned addresses can be patched. This feature is only available for ifort.
Qsfalign Specifies stack alignment for functions. This option is deprecated and will
be removed in a future release. This feature is only available for ifort.
qsimd-honor-fp-model, Tells the compiler to obey the selected floating-point model when
Qsimd-honor-fp-model vectorizing SIMD loops. This feature is only available for ifort.
Quse-msasm-symbols Tells the compiler to use a dollar sign ("$") when producing symbol
names. This feature is only available for ifort.
real-size Specifies the default KIND for real and complex declarations, constants,
functions, and intrinsics.
recursive Tells the compiler that all routines should be compiled for possible
recursive execution.
S Causes the compiler to compile to an assembly file only and not link.
82
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
safe-cray-ptr, Qsafe-cray-ptr Tells the compiler that Cray* pointers do not alias other variables.
save-temps , Qsave-temps Tells the compiler to save intermediate files created during compilation.
scalar-rep, Qscalar-rep Enables or disables the scalar replacement optimization done by the
compiler as part of loop transformations. This feature is only available for
ifort.
show Controls the contents of the listing generated when option list is specified.
sox Tells the compiler to save the compilation options and version number in
the executable file. It also lets you choose whether to include lists of
certain routines . This feature is only available for ifort.
standard-realloc-lhs Determines whether the compiler uses the current Fortran Standard rules
or the old Fortran 2003 rules when interpreting assignment statements.
staticlib Invokes the libtool command to generate static libraries. This feature is
only available for ifort.
sysroot Specifies the root directory where headers and libraries are located.
tcollect, Qtcollect Inserts instrumentation probes calling the Intel® Trace Collector API. This
feature is only available for ifort.
tcollect-filter, Qtcollect-filter Lets you enable or disable the instrumentation of specified functions. You
must also specify option [Q]tcollect. This feature is only available for ifort.
traceback Tells the compiler to generate extra information in the object file to
provide source file traceback information when a severe error occurs at
run time.
83
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
unroll , Qunroll Tells the compiler the maximum number of times to unroll loops.
unroll-aggressive, Qunroll- Determines whether the compiler uses more aggressive unrolling for
aggressive certain loops. This feature is only available for ifort.
use-asm, Quse-asm Tells the compiler to produce objects through the assembler. This is a
deprecated option. There is no replacement option. This feature is only
available for ifort.
vecabi, Qvecabi Determines which vector function application binary interface (ABI) the
compiler uses to create or call vector functions. This feature is only
available for ifort.
vec-guard-write, Qvec-guard- Tells the compiler to perform a conditional check in a vectorized loop. This
write feature is only available for ifort.
vms Causes the run-time system to behave like HP* Fortran on OpenVMS*
Alpha systems and VAX* systems (VAX FORTRAN*).
watch Tells the compiler to display certain information to the console output
window.
winapp Tells the compiler to create a graphics or Fortran Windows application and
link against the most commonly used libraries.
Winline Warns when a function that is declared as inline is not inlined. This
feature is only available for ifort.
wrap-margin Provides a way to disable the right margin wrapping that occurs in
Fortran list-directed output.
x, Qx Tells the compiler which processor features it may target, including which
instruction sets and optimizations it may generate.
xHost, QxHost Tells the compiler to generate instructions for the highest instruction set
available on the compilation host processor.
84
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
zero, Qzero Initializes to zero variables of intrinsic type INTEGER, REAL, COMPLEX, or
LOGICAL that are not yet initialized. This is a deprecated option. The
replacement option is /Qinit:[no]zero or -init=[no]zero.
Options specified on the command line apply to all files named on the command line.
Options can take arguments in the form of file names, strings, letters, or numbers. If a string includes
spaces, the string must be enclosed in quotation marks.
Compiler options can appear in any order.
Unless you specify certain options, the command line will both compile and link the files you specify.
You can abbreviate some option names, entering as many characters as are needed to uniquely identify the
option.
Certain options accept one or more keyword arguments following the option name. For example, architecture
option x option accepts several keywords.
To specify multiple keywords, you typically specify the option multiple times.
To disable an option, specify the negative form of the option if one exists.
If there are enabling and disabling versions of an option on the command line, the last one on the command
line takes precedence.
Compiler options remain in effect for the whole compilation unless overridden by a compiler directive.
Linux and macOS
You cannot combine options with a single dash. For example, this form is incorrect: -Ec; this form is correct:
-E -c
Windows
You cannot combine options with a single slash. For example: This form is incorrect: /Ec; this form is
correct: /E /c
All compiler options must precede /link options, if any, on the command line.
Compiler options remain in effect for the whole compilation unless overridden by a compiler directive.
85
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
You can sometimes use a comma to separate keywords. For example, the following is valid:
You can disable one or more optimization options by specifying option /Od last on the command line.
NOTE
The /Od option is part of a mutually-exclusive group of options that includes /Od, /O1, /O2, /O3,
and /Ox. The last of any of these options specified on the command line will override the previous
options from this group.
• [Q]option-name
This shortcut is used for option names that only differ because the Windows form starts with a Q.
For example, [Q]ipo denotes:
• Linux and macOS: -ipo
• Windows: /Qipo
• [q or Q]option-name
This shortcut is used for option names that only differ because the Linux form starts with a q and the
Windows form starts with a Q.
For example, [q or Q]opt-report denotes:
• Linux and macOS: -qopt-report
• Windows: /Qopt-report
86
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Architecture Restrictions: This section only appears if there is a known architecture restriction for the
option. Restrictions can appear for any of the following architectures:
• Intel® 64 architecture
• IA-32 architecture
IA-32 support is deprecated and will be removed in a future release. 32-bit options are only available
for ifort.
Certain operating systems are not available on the above architectures. For the latest information, check
your Release Notes.
• Syntax: This section shows the syntax on Linux and macOS systems and the syntax on Windows systems.
If the option is not valid on a particular operating system, it will specify None.
• Arguments: This section shows any arguments (parameters) that are related to the option. If the option
has no arguments, it will specify None.
• Default: This section shows the default setting for the option.
• Description: This section shows the full description of the option. It may also include further information
on any applicable arguments.
• IDE Equivalent: This section shows information related to the Intel® Integrated Development Environment
(Intel® IDE) Property Pages on Linux, macOS, and Windows systems. It shows on which Property Page the
option appears, and under what category it's listed. The Windows IDE is Microsoft Visual Studio .NET. If
the option has no IDE equivalent, it will specify None. Note that in this release, there is no IDE support
for Fortran on Linux.
• Alternate Options: This section lists any options that are synonyms for the described option. If there are
no alternate option names, it will show None. Some alternate option names are deprecated and may be
removed in future releases. Many options have an older spelling where underscores ("_") instead of
hyphens ("-") connect the main option names. The older spelling is a valid alternate option name.
Some option descriptions may also have the following:
• Example (or Examples): This section shows one or more examples that demonstrate the option.
• See Also: This section shows where you can get further information on the option or it shows related
options.
Optimization Options
This section contains descriptions for compiler options that pertain to optimization. They are listed in
alphabetical order.
falias, Oa
Specifies whether or not a procedure call may have
hidden aliases of local variables not supplied as actual
arguments.
Syntax
Linux OS:
-falias
-fno-alias
macOS:
-falias
-fno-alias
Windows OS:
/Oa
/Oa-
87
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option specifies whether or not the compiler can assume that during a procedure call, local variables in
the caller that are not present in the actual argument list and not visible by host association, are not
referenced or redefined due to hidden aliasing. The Fortran standard generally prohibits such aliasing.
If you specify -falias (Linux* and macOS) or /Oa- (Windows*), aliasing during a procedure call is
assumed; this can possibly affect performance.
If you specify -fno-alias or /Oa (the default), aliasing during a procedure call is not assumed.
IDE Equivalent
None
Alternate Options
None
See Also
ffnalias compiler option
fast
Maximizes speed across the entire program.
Syntax
Linux OS:
-fast
macOS:
-fast
Windows OS:
/fast
Arguments
None
Default
Description
This option maximizes speed across the entire program.
Linux
It sets the following options:
-ipo, -O3, -no-prec-div,-static, -fp-model fast=2, and -xHost
88
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS
It sets the following options:
-ipo, -mdynamic-no-pic,-O3, -no-prec-div,-fp-model fast=2, and -xHost
Windows
It sets the following options:
/O3, /Qipo, /Qprec-div-, /fp:fast=2, and /QxHost
When option fast is specified, you can override the [Q]xHost option setting by specifying a different
processor-specific [Q]x option on the command line. However, the last option specified on the command line
takes precedence.
For example:
Linux
If you specify option -fast -xSSE3, option -xSSE3 takes effect. However, if you specify -xSSE3 -fast,
option -xHost takes effect.
Windows
If you specify option /fast /QxSSE3, option/QxSSE3 takes effect. However, if you specify /QxSSE3 /fast,
option /QxHost takes effect.
NOTE
Option fast sets some aggressive optimizations that may not be appropriate for all
applications. The resulting executable may not run on processor types different from the one
on which you compile. You should make sure that you understand the individual
optimization options that are enabled by option fast.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
xHost, QxHost
compiler option
89
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
x, Qx
compiler option
ffnalias, Ow
Determines whether aliasing is assumed within
functions. This feature is only available for ifort.
Syntax
Linux OS:
-ffnalias
-fno-fnalias
macOS:
-ffnalias
-fno-fnalias
Windows OS:
/Ow
/Ow-
Arguments
None
Default
Description
This option determines whether aliasing is assumed within functions.
If you specify -fno-fnalias or /Ow-, aliasing is not assumed within functions, but it is assumed across
calls.
If you specify -ffnalias or /Ow, aliasing is assumed within functions.
IDE Equivalent
None
Alternate Options
None
See Also
falias compiler option
foptimize-sibling-calls
Determines whether the compiler optimizes tail
recursive calls. This feature is only available for ifort.
Syntax
Linux OS:
-foptimize-sibling-calls
90
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-fno-optimize-sibling-calls
macOS:
-foptimize-sibling-calls
-fno-optimize-sibling-calls
Windows OS:
None
Arguments
None
Default
Description
This option determines whether the compiler optimizes tail recursive calls. It enables conversion of tail
recursion into loops.
If you do not want to optimize tail recursive calls, specify -fno-optimize-sibling-calls.
Tail recursion is a special form of recursion that doesn't use stack space. In tail recursion, a recursive call is
converted to a GOTO statement that returns to the beginning of the function. In this case, the return value of
the recursive call is only used to be returned. It is not used in another expression. The recursive function is
converted into a loop, which prevents modification of the stack space used.
IDE Equivalent
None
Alternate Options
None
fprotect-parens, Qprotect-parens
Determines whether the optimizer honors parentheses
when floating-point expressions are evaluated.
Syntax
Linux OS:
-fprotect-parens
-fno-protect-parens
macOS:
-fprotect-parens
-fno-protect-parens
Windows OS:
/Qprotect-parens
/Qprotect-parens-
91
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option determines whether the optimizer honors parentheses when determining the order of floating-
point expression evaluation.
When option -fprotect-parens (Linux* and macOS) or /Qprotect-parens (Windows*) is specified, the
optimizer will maintain the order of evaluation imposed by parentheses in the code.
When option -fno-protect-parens (Linux* and macOS) or /Qprotect-parens- (Windows*) is specified,
the optimizer may reorder floating-point expressions without regard for parentheses if it produces faster
executing code.
IDE Equivalent
None
Alternate Options
Linux and macOS: -assume protect_parens
Windows: /assume:protect_parens
Example
Consider the following expression:
A+(B+C)
By default, the parentheses are ignored and the compiler is free to re-order the floating-point operations
based on the optimization level, the setting of option -fp-model (Linux* and macOS) or /fp (Windows*),
etc. to produce faster code. Code that is sensitive to the order of operations may produce different results
(such as with some floating-point computations).
However, if -fprotect-parens (Linux* and macOS) or /Qprotect-parens (Windows*) is specified,
parentheses around floating-point expressions (including complex floating-point and decimal floating-point)
are honored and the expression will be interpreted following the normal precedence rules, that is, B+C will
be computed first and then added to A.
This may produce slower code than when parentheses are ignored. If floating-point sensitivity is a specific
concern, you should use option -fp-model precise (Linux* and macOS) or /fp:precise (Windows*) to
ensure precision because it controls all optimizations that may affect precision.
See Also
fp-model, fp compiler option
GF
Enables read-only string-pooling optimization.
Syntax
Linux OS:
None
92
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/GF
Arguments
None
Default
Description
This option enables read only string-pooling optimization.
IDE Equivalent
None
Alternate Options
None
nolib-inline
Disables inline expansion of standard library or
intrinsic functions.
Syntax
Linux OS:
-nolib-inline
macOS:
-nolib-inline
Windows OS:
None
Arguments
None
Default
OFF The compiler inlines many standard library and intrinsic functions.
Description
This option disables inline expansion of standard library or intrinsic functions. It prevents the unexpected
results that can arise from inline expansion of these functions.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
93
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
O
Specifies the code optimization for applications.
Syntax
Linux OS:
-O[n]
macOS:
-O[n]
Windows OS:
/O[n]
Arguments
Default
O2 Optimizes for code speed. This default may change depending on which other compiler options
are specified. For details, see below.
Description
This option specifies the code optimization for applications.
Option Description
94
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
This option may set other options. This is determined by the compiler,
depending on which operating system and architecture you are using. The
options that are set may change from release to release.
The O1 option may improve performance for applications with very large
code size, many branches, and execution time not dominated by code
within loops.
95
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
Many routines in the shared libraries are more highly optimized for Intel®
microprocessors than for non-Intel microprocessors.
The last O option specified on the command line takes precedence over any others.
IDE Equivalent
Windows
Visual Studio: General > Optimization (/Od, /O1, /O2, /O3, /fast)
Alternate Options
See Also
Od compiler option
fltconsistency compiler option
fast compiler option
Od
Disables all optimizations.
Syntax
Linux OS:
None
96
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/Od
Arguments
None
Default
Description
This option disables all optimizations. It can be used for selective optimizations, such as a combination of /Od
and /Ob1 (disables all optimizations, but enables inlining).
ifort only: On IA-32 architecture, this option sets the /Oy- option.
IDE Equivalent
Windows
Visual Studio: Optimization > Optimization
Alternate Options
Linux and macOS: -O0
Windows: /optimize:0
See Also
O compiler option (see O0)
Ofast
Sets certain aggressive options to improve the speed
of your application.
Syntax
Linux OS:
-Ofast
macOS:
-Ofast
Windows OS:
None
Arguments
None
97
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF The aggressive optimizations that improve speed are not enabled.
Description
This option improves the speed of your application.
It sets compiler options -O3, -no-prec-div, and -fp-model fast=2.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
O compiler option
prec-div, Qprec-div compiler option
fast compiler option
fp-model, fp compiler option
Os
Enables optimizations that do not increase code size;
it produces smaller code size than O2.
Syntax
Linux OS:
-Os
macOS:
-Os
Windows OS:
/Os
Arguments
None
Default
OFF Optimizations are made for code speed. However, if O1 is specified, Os is the default.
Description
This option enables optimizations that do not increase code size; it produces smaller code size than O2. It
disables some optimizations that increase code size for a small speed benefit.
98
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option tells the compiler to favor transformations that reduce code size over transformations that
produce maximum performance.
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Favor Size or Speed
Alternate Options
None
See Also
O compiler option
Ot compiler option
Ot
Enables all speed optimizations.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Ot
Arguments
None
Default
Description
This option enables all speed optimizations.
IDE Equivalent
Windows
Visual Studio: Optimization > Favor Size or Speed (/Ot, /Os)
Alternate Options
None
See Also
O compiler option
Os compiler option
99
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
arch
Tells the compiler which features it may target,
including which instruction sets it may generate.
Syntax
Linux OS:
-arch code
macOS:
-arch code
Windows OS:
/arch:code
Arguments
code Indicates to the compiler a feature set that it may target, including which instruction sets it
may generate. Many of the following descriptions refer to Intel® Streaming SIMD Extensions
(Intel® SSE) and Supplemental Streaming SIMD Extensions (SSSE). Possible values are:
100
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SSE4.1 May generate Intel® SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions.
IA32 (ifort only) Generates x86/x87 generic code that is compatible with
IA-32 architecture. Disables any default extended
instruction settings, and any previously set extended
instruction settings. It also disables all feature-specific
optimizations and instructions.
This value is only available on Linux* and Windows*
systems using IA-32 architecture. IA-32 support is
deprecated, and will be removed in a future release.
Default
varies If option arch is not specified, the default target architecture supports
Intel® SSE2 instructions.
Description
This option tells the compiler which features it may target, including which instruction sets it may generate.
Code generated with these options should execute on any compatible, non-Intel processor with support for
the corresponding instruction set.
Options /arch and /Qx are mutually exclusive. If both are specified, the compiler uses the last one specified
and generates a warning.
If you specify both the /Qax and /arch options, the compiler will not generate Intel-specific instructions.
101
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
For compatibility with Compaq* Visual Fortran, the ifort compiler allows the following keyword values.
However, you should use the suggested replacements.
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Enable Enhanced Instruction Set
Alternate Options
None
See Also
x, Qx compiler option
xHost, QxHost compiler option
ax, Qax compiler option
arch compiler option
march compiler option
m compiler option
m32, m64 compiler option
ax, Qax
Tells the compiler to generate multiple, feature-
specific auto-dispatch code paths for Intel® processors
if there is a performance benefit.
Syntax
Linux OS:
-axcode
macOS:
-axcode
Windows OS:
/Qaxcode
102
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
code Indicates to the compiler a feature set that it may target, including which instruction sets it
may generate. The following descriptions refer to Intel® Streaming SIMD Extensions (Intel®
SSE) and Supplemental Streaming SIMD Extensions (SSSE). Possible values are:
103
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SSE4.1 May generate Intel® SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions for Intel® processors.
SSE3 May generate Intel® SSE3, SSE2, and SSE instructions for
Intel® processors. This value is not available on macOS
systems.
SSE2 May generate Intel® SSE2 and SSE instructions for Intel®
processors. This setting is only supported for ifort. This
value is not available on macOS systems.
You can specify more than one code value. When specifying more than one code value, each value must be
separated with a comma. See the Examples section below.
Default
OFF No auto-dispatch code is generated. Feature-specific code is generated and is controlled by the
setting of the following compiler options:
• Linux*: -m and -x
• Windows*: /arch and /Qx
• macOS: -x
Description
This option tells the compiler to generate multiple, feature-specific auto-dispatch code paths for Intel®
processors if there is a performance benefit. It also generates a baseline code path. The Intel feature-specific
auto-dispatch path is usually more optimized than the baseline path. Other options, such as O3, control how
much optimization is performed on the baseline path.
The baseline code path is determined by the architecture specified by options -m or -x (Linux* and macOS)
or options /arch or /Qx (Windows*). While there are defaults for the [Q]x option that depend on the
operating system being used, you can specify an architecture and optimization level for the baseline code
that is higher or lower than the default. The specified architecture becomes the effective minimum
architecture for the baseline code path.
If you specify both the [Q]ax and [Q]x options, the baseline code will only execute on Intel® processors
compatible with the setting specified for the [Q]x.
If you specify both the -ax and -m options (Linux and macOS) or the /Qax and /arch options (Windows),
the baseline code will execute on non-Intel® processors compatible with the setting specified for the -m
or /arch option.
A Non-Intel® baseline and an Intel® baseline have the same set of optimizations enabled, and the default for
both is SSE4.2 for x86-based architectures.
104
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify both the -ax and -march options (Linux and macOS), or the /Qax and /arch options
(Windows), the compiler will not generate Intel-specific instructions. This is because specifying -march
disables -ax and specifying /arch disables /Qax.
The [Q]ax option tells the compiler to find opportunities to generate separate versions of functions that take
advantage of features of the specified instruction features.
If the compiler finds such an opportunity, it first checks whether generating a feature-specific version of a
function is likely to result in a performance gain. If this is the case, the compiler generates both a feature-
specific version of a function and a baseline version of the function. At run time, one of the versions is
chosen to execute, depending on the Intel® processor in use. In this way, the program can benefit from
performance gains on more advanced Intel processors, while still working properly on older processors and
non-Intel processors. A non-Intel processor always executes the baseline code path.
You can use more than one of the feature values by combining them. For example, you can specify
-axSSE4.1,SSSE3 (Linux and macOS) or /QaxSSE4.1,SSSE3 (Windows). You cannot combine the old style,
deprecated options and the new options. For example, you cannot specify -axSSE4.1,T (Linux and macOS)
or /QaxSSE4.1,T (Windows).
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Add Processor-Optimized Code Path
Alternate Options
None
Examples
The following shows an example of how to specify this option:
See Also
x, Qx compiler option
xHost, QxHost compiler option
march compiler option
arch compiler option
105
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
m compiler option
fasynchronous-unwind-tables
Determines whether unwind information is precise at
an instruction boundary or at a call boundary.
Syntax
Linux OS:
-fasynchronous-unwind-tables
-fno-asynchronous-unwind-tables
macOS:
-fasynchronous-unwind-tables
-fno-asynchronous-unwind-tables
Windows OS:
None
Arguments
None
Default
IA-32 architecture (ifort only): The unwind table generated is precise at call boundaries only.
-fno-asynchronous-unwind-tables
Description
This option determines whether unwind information is precise at an instruction boundary or at a call
boundary. The compiler generates an unwind table in DWARF2 or DWARF3 format, depending on which
format is supported on your system.
If -fno-asynchronous-unwind-tables is specified, the unwind table is precise at call boundaries only. In
this case, the compiler will avoid creating unwind tables for routines such as the following:
• A C++ routine that does not declare objects with destructors and does not contain calls to routines that
might throw an exception.
• A C/C++ or Fortran routine compiled without -fexceptions, and on Intel® 64 architecture, without
-traceback.
• A C/C++ or Fortran routine compiled with -fexceptions that does not contain calls to routines that
might throw an exception.
IDE Equivalent
None
Alternate Options
None
See Also
fexceptions compiler option
106
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fcf-protection, Qcf-protection
Enables Intel® Control-Flow Enforcement Technology
(Intel® CET) protection, which defends your program
from certain attacks that exploit vulnerabilities. This
option offers preliminary support for Intel® CET.
Syntax
Linux OS:
-fcf-protection[=keyword]
macOS:
None
Windows OS:
/Qcf-protection[:keyword]
Arguments
keyword Specifies the level of protection the compiler should perform. Possible values are:
Default
Description
This option enables Intel® CET protection, which defends your program from certain attacks that exploit
vulnerabilities.
Intel® CET protections are enforced on processors that support Intel® CET. They are ignored on processors
that do not support Intel® CET, so they are safe to use in programs that might run on a variety of processors.
Specifying shadow_stack helps to protect your program from return-oriented programming (ROP). Return-
oriented programming (ROP) is a technique to exploit computer security defenses such as non-executable
memory and code signing by gaining control of the call stack to modify program control flow and then
execute certain machine instruction sequences.
Specifying branch_tracking helps to protect your program from call/jump-oriented programming (COP/
JOP). Jump-oriented programming (JOP) is a variant of ROP that uses indirect jumps and calls to emulate
return instructions. Call-oriented programming (COP) is a variant of ROP that employs indirect calls.
To get both protections, specify this compiler option with no keyword, or specify -fcf-protection=full
(Linux*) or /Qcf-protection:full (Windows*).
IDE Equivalent
None
107
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Linux and macOS: -qcf-protection
Windows: None
fexceptions
Enables exception handling table generation. This
feature is only available for ifort.
Syntax
Linux OS:
-fexceptions
-fno-exceptions
macOS:
-fexceptions
-fno-exceptions
Windows OS:
None
Arguments
None
Default
Description
This option enables C++ exception handling table generation, preventing Fortran routines in mixed-language
applications from interfering with exception handling between C++ routines. The -fno-exceptions option
disables C++ exception handling table generation, resulting in smaller code. When this option is used, any
use of C++ exception handling constructs (such as try blocks and throw statements) when a Fortran routine
is in the call chain will produce an error.
IDE Equivalent
None
Alternate Options
None
fomit-frame-pointer, Oy
Determines whether EBP is used as a general-purpose
register in optimizations. Option /Oy is deprecated and
will be removed in a future release.This feature is only
available for ifort.
Architecture Restrictions
Option /Oy[-] is only available on IA-32 architecture. IA-32 support is deprecated and will be removed in a
future release.
108
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fomit-frame-pointer
-fno-omit-frame-pointer
macOS:
-fomit-frame-pointer
-fno-omit-frame-pointer
Windows OS:
/Oy
/Oy-
Arguments
None
Default
Windows
If option /Od is specified, the default is /Oy- .
Description
These options determine whether EBP is used as a general-purpose register in optimizations. Option
-fomit-frame-pointer and option /Oy allows this use. Option -fno-omit-frame-pointer and
option /Oy- disallows it.
Some debuggers expect EBP to be used as a stack frame pointer, and cannot produce a stack backtrace
unless this is so. The -fno-omit-frame-pointer and the /Oy- option directs the compiler to generate code
that maintains and uses EBP as a stack frame pointer for all functions so that a debugger can still produce a
stack backtrace without doing the following:
Using the -fno-omit-frame-pointer or /Oy- option reduces the number of available general-purpose
registers by 1, and can result in slightly less efficient code.
IDE Equivalent
Windows
Visual Studio: Optimization > Omit Frame Pointers
109
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Linux and macOS: -fp (this is a deprecated option)
Windows: None
See Also
momit-leaf-frame-pointer compiler option
guard
Enables the control flow protection mechanism.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/guard:keyword
Arguments
keyword Specifies the the control flow protection mechanism. Possible values are:
cf[-] Tells the compiler to analyze control flow of valid targets for indirect calls and to insert
code to verify the targets at runtime.
To explicitly disable this option, specify /guard:cf-.
Default
Description
This option enables the control flow protection mechanism. It tells the compiler to analyze control flow of
valid targets for indirect calls and inserts a call to a checking routine before each indirect call to verify the
target of the given indirect call.
The /guard:cf option must be passed to both the compiler and linker.
Code compiled using /guard:cf can be linked to libraries and object files that are not compiled using the
option.
This option has been added for Microsoft compatibility. It uses the Microsoft implementation.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
110
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
hotpatch
Tells the compiler to prepare a routine for
hotpatching. This feature is only available for ifort.
Syntax
Linux OS:
-hotpatch[=n]
macOS:
None
Windows OS:
/hotpatch[:n]
Arguments
Default
Description
This option tells the compiler to prepare a routine for hotpatching. The compiler inserts nop padding around
function entry points so that the resulting image is hot patchable.
Specifically, the compiler adds nop bytes after each function entry point and enough nop bytes before the
function entry point to fit a direct jump instruction on the target architecture.
If n is specified, it overrides the default number of bytes that the compiler adds before the function entry
point.
IDE Equivalent
None
Alternate Options
None
m, Qm
Tells the compiler which features it may target,
including which instruction set architecture (ISA) it
may generate.
Syntax
Linux OS:
-mcode
111
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-mcode
Windows OS:
/Qmcode (ifx)
None (ifort)
Arguments
code Indicates to the compiler a feature set that it may target, including which instruction sets it
may generate. Many of the following descriptions refer to Intel® Streaming SIMD Extensions
(Intel® SSE) and Supplemental Streaming SIMD Extensions (SSSE). Possible values are:
sse4.1 May generate Intel® SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions.
sse2 May generate Intel® SSE2 and SSE instructions. This value
is not available on macOS systems.
ia32 (ifort only) Generates x86/x87 generic code that is compatible with
IA-32 architecture. Disables any default extended
instruction settings, and any previously set extended
instruction settings. It also disables all feature-specific
optimizations and instructions.
This value is only available on Linux* systems using IA-32
architecture. IA-32 support is deprecated and will be
removed in a future release.
This compiler option also supports many of the -m option settings available with gcc. For
more information on gcc settings for -m, see the gcc documentation.
Default
varies If option arch is not specified, the default target architecture supports
Intel® SSE2 instructions.
The default on macOS systems is mssse3.
Description
This option tells the compiler which features it may target, including which instruction sets it may generate.
112
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Code generated with these options should execute on any compatible, non-Intel processor with support for
the corresponding instruction set.
Linux* systems: For compatibility with gcc, the compiler allows the following options but they have no effect.
You will get a warning error, but the instructions associated with the name will not be generated. You should
use the suggested replacement options.
-mfma -march=core-avx2
-mvzeroupper -march=corei7-avx
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
xHost, QxHost compiler option
ax, Qax compiler option
arch compiler option
march compiler option
m32, m64 compiler option
Syntax
Linux OS:
-m32 (ifort only)
-m64
macOS:
-m32 (ifort only)
113
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-m64
Windows OS:
/Qm32 (ifort only)
/Qm64
Arguments
None
Default
Description
These options tell the compiler to generate code for a specific architecture.
Option Description
For ifort, the -m64 option is the same as macOS option -arch x86_64. This option is not related to the
Intel®Fortran Compiler option arch.
On Linux* systems, these options are provided for compatibility with gcc.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
m80387
Specifies whether the compiler can use x87
instructions.
Syntax
Linux OS:
-m80387
114
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-mno-80387
macOS:
-m80387
-mno-80387
Windows OS:
None
Arguments
None
Default
Description
This option specifies whether the compiler can use x87 instructions.
If you specify option -mno-80387, it prevents the compiler from using x87 instructions. If the compiler is
forced to generate x87 instructions, it issues an error message.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
-m[no-]x87
march
Tells the compiler to generate code for processors that
support certain features.
Syntax
Linux OS:
-march=processor
macOS:
-march=processor
Windows OS:
None
Arguments
processor Tells the compiler the code it can generate. Possible values are:
115
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
116
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the compiler to generate code for processors that support certain features.
If you specify both the -ax and -march options, the compiler will not generate Intel-specific instructions.
Options -x and -march are mutually exclusive. If both are specified, the compiler uses the last one specified
and generates a warning.
Specifying -march=pentium4 sets -mtune=pentium4.
For compatibility, a number of historical processor values are also supported, but the generated code will not
differ from the default.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
macOS: None
Windows: None
macOS: None
117
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: None
See Also
xHost, QxHost compiler option
x, Qx compiler option
ax, Qax compiler option
arch compiler option
minstruction, Qinstruction compiler option
m compiler option
masm
Tells the compiler to generate the assembler output
file using a selected dialect.
Syntax
Linux OS:
-masm=dialect
macOS:
None
Windows OS:
None
Arguments
dialect Is the dialect to use for the assembler output file. Possible values are:
Default
-masm=att The compiler generates the assembler output file using AT&T* syntax.
Description
This option tells the compiler to generate the assembler output file using a selected dialect.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
118
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
mauto-arch, Qauto-arch
Tells the compiler to generate multiple, feature-
specific auto-dispatch code paths for x86 architecture
processors if there is a performance benefit. This
feature is only available for ifort.
Syntax
Linux OS:
-mauto-arch=value
macOS:
-mauto-arch=value
Windows OS:
/Qauto-arch:value
Arguments
Default
Description
This option tells the compiler to generate multiple, feature-specific auto-dispatch code paths for x86
architecture processors if there is a performance benefit. It also generates a baseline code path.
This option cannot be used together with any options that may require Intel-specific optimizations (such as
[Q]x or [Q]ax).
IDE Equivalent
None
Alternate Options
None
See Also
ax, Qax compiler option
mbranches-within-32B-boundaries, Qbranches-within-32B-boundaries
Tells the compiler to align branches and fused
branches on 32-byte boundaries for better
performance.
Syntax
Linux OS:
-mbranches-within-32B-boundaries
-mno-branches-within-32B-boundaries
macOS:
-mbranches-within-32B-boundaries
119
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-mno-branches-within-32B-boundaries
Windows OS:
/Qbranches-within-32B-boundaries
/Qbranches-within-32B-boundaries-
Arguments
None
Default
Description
This option tells the compiler to align branches and fused branches on 32-byte boundaries for better
performance.
NOTE
When you use this option, it may affect binary utilities usage experience, such as
debugability.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
mconditional-branch, Qconditional-branch
Lets you identify and fix code that may be vulnerable
to speculative execution side-channel attacks, which
can leak your secure data as a result of bad
speculation of a conditional branch direction. This
feature is only available for ifort.
Syntax
Linux OS:
-mconditional-branch=keyword
macOS:
-mconditional-branch=keyword
Windows OS:
/Qconditional-branch:keyword
120
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
keyword Tells the compiler the action to take. Possible values are:
keep Tells the compiler to not attempt any vulnerable code detection
or fixing. This is equivalent to not specifying the
-mconditional-branch option.
all-fix Tells the compiler to fix all of the vulnerable code so that it is
either not executed speculatively, or there is no observable
side-channel created from their speculative execution. Since it
is a complete mitigation against Spectre variant 1 attacks, this
setting will have the most run-time performance cost.
In contrast to the pattern-fix setting, the compiler will not
attempt to identify the exact conditional branches that may
have led to the mis-speculated execution.
121
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option lets you identify code that may be vulnerable to speculative execution side-channel attacks,
which can leak your secure data as a result of bad speculation of a conditional branch direction. Depending
on the setting you choose, vulnerabilities may be detected and code may be generated to attempt to mitigate
the security risk.
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Spectre Variant 1 Mitigation
Alternate Options
None
minstruction, Qinstruction
Determines whether MOVBE instructions are
generated for certain Intel® processors. This feature is
only available for ifort.
Syntax
Linux OS:
-minstruction=[no]movbe
macOS:
-minstruction=[no]movbe
Windows OS:
/Qinstruction:[no]movbe
Arguments
None
Default
Description
This option determines whether MOVBE instructions are generated for Intel Atom® processors. To use this
option, you must also specify [Q]xATOM_SSSE3 or [Q]xATOM_SSE4.2.
• MOVBE instructions are generated that are specific to the Intel Atom® processor.
• Generated executables can only be run on Intel Atom® processors or processors that support
Supplemental Streaming SIMD Extensions 3 (Intel® SSSE3) or Intel® Streaming SIMD Extensions 4.2
(Intel® SSE4.2) and MOVBE.
122
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The compiler optimizes code for the Intel Atom® processor, but it does not generate MOVBE instructions.
• Generated executables can be run on non-Intel Atom® processors that support Intel® SSE3 or Intel®
SSE4.2.
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
momit-leaf-frame-pointer
Determines whether the frame pointer is omitted or
kept in leaf functions.
Syntax
Linux OS:
-momit-leaf-frame-pointer
-mno-omit-leaf-frame-pointer
macOS:
-momit-leaf-frame-pointer
-mno-omit-leaf-frame-pointer
Windows OS:
None
Arguments
None
Default
Varies If you specify option -fomit-frame-pointer (or it is set by default), the default is
-momit-leaf-frame-pointer. If you specify option -fno-omit-frame-pointer, the default is
-mno-omit-leaf-frame-pointer.
Description
This option determines whether the frame pointer is omitted or kept in leaf functions. It is related to option
-f[no-]omit-frame-pointer and the setting for that option has an effect on this option.
Consider the following option combinations:
123
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
fomit-frame-pointer, Oy compiler option
mstringop-inline-threshold, Qstringop-inline-threshold
Tells the compiler to not inline calls to buffer
manipulation functions such as memcpy and memset
when the number of bytes the functions handle are
known at compile time and greater than the specified
value. This feature is only available for ifort.
Syntax
Linux OS:
-mstringop-inline-threshold=val
macOS:
-mstringop-inline-threshold=val
Windows OS:
/Qstringop-inline-threshold:val
124
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
val Is a positive 32-bit integer. If the size is greater than val, the compiler
will never inline it.
Default
OFF The compiler uses its own heuristics to determine the default.
Description
This option tells the compiler to not inline calls to buffer manipulation functions such as memcpy and memset
when the number of bytes the functions handle are known at compile time and greater than the specified val.
IDE Equivalent
None
Alternate Options
None
See Also
mstringop-strategy, Qstringop-strategy compiler option
mstringop-strategy, Qstringop-strategy
Lets you override the internal decision heuristic for the
particular algorithm used when implementing buffer
manipulation functions such as memcpy and memset.
This feature is only available for ifort.
Syntax
Linux OS:
-mstringop-strategy=alg
macOS:
-mstringop-strategy=alg
Windows OS:
/Qstringop-strategy:alg
Arguments
const_size_loop Tells the compiler to expand the string operations into an inline
loop when the size is known at compile time and it is not
greater than threshold value. Otherwise, the compiler uses its
own heuristics to decide how to implement the string
operation.
rep Tells the compiler to use its own heuristics to decide what form
of rep movs | stos to use when inlining string operations.
125
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
varies If optimization option Os is specified, the default is rep. Otherwise, the default is
const_size_loop.
Description
This option lets you override the internal decision heuristic for the particular algorithm used when
implementing buffer manipulation functions such as memcpy and memset.
This option may have no effect on compiler-generated string functions, for example, a call to memcpy
generated by the compiler to implement an array copy or structure copy.
IDE Equivalent
None
Alternate Options
None
See Also
mstringop-inline-threshold, Qstringop-inline-threshold compiler option
Os compiler option
mtune, tune
Performs optimizations for specific processors but
does not cause extended instruction sets to be used
(unlike -march).
Syntax
Linux OS:
-mtune=processor
macOS:
-mtune=processor
Windows OS:
/tune:processor
Arguments
processor Is the processor for which the compiler should perform optimizations. Possible values
are:
126
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
haswell
icelake-client (or
icelake)
icelake-server
ivybridge
kabylake
rocketlake
sandybridge
sapphirerapids
silvermont
skylake
skylake-avx512
tigerlake
tremont
whiskeylake
core-avx2 Optimizes code for processors that support Intel®
Advanced Vector Extensions 2 (Intel® AVX2), Intel®
AVX, SSE4.2, SSE4.1, SSE3, SSE2, SSE, and SSSE3
instructions.
pentiumpro Optimizes for Intel® Pentium® Pro, Intel Pentium II, and
Intel Pentium III processors.
127
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option performs optimizations for specific processors but does not cause extended instruction sets to be
used (unlike -march).
The resulting executable is backwards compatible and generated code is optimized for specific processors.
For example, code generated with -mtune=core2 or /tune:core2 runs correctly on 4th Generation Intel®
Core™ processors, but it might not run as fast as if it had been generated using -mtune=haswell
or /tune:haswell. Code generated with -mtune=haswell (/tune:haswell) or -mtune=core-avx2
(/tune:core-avx2) will also run correctly on Intel® Core™2 processors, but it might not run as fast as if it
had been generated using -mtune=core2 or /tune:core2. This is in contrast to code generated with
-march=core-avx2 or /arch:core-avx2, which will not run correctly on older processors such as Intel®
Core™2 processors.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Windows
Visual Studio: Code Generation >Intel Processor Microarchitecture-Specific Optimization
Alternate Options
macOS: None
Windows: None
See Also
march compiler option
128
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Qpatchable-addresses
Tells the compiler to generate code such that
references to statically assigned addresses can be
patched. This feature is only available for ifort.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qpatchable-addresses
Arguments
None
Default
Description
This option tells the compiler to generate code such that references to statically assigned addresses can be
patched with arbitrary 64-bit addresses.
Normally, the Windows* system compiler that runs on Intel® 64 architecture uses 32-bit relative addressing
to reference statically allocated code and data. That assumes the code or data is within 2GB of the access
point, an assumption that is enforced by the Windows object format.
However, in some patching systems, it is useful to have the ability to replace a global address with some
other arbitrary 64-bit address, one that might not be within 2GB of the access point.
This option causes the compiler to avoid 32-bit relative addressing in favor of 64-bit direct addressing so that
the addresses can be patched in place without additional code modifications. This option causes code size to
increase, and since 32-bit relative addressing is usually more efficient than 64-bit direct addressing, you may
see a performance impact.
IDE Equivalent
None
Alternate Options
None
x, Qx
Tells the compiler which processor features it may
target, including which instruction sets and
optimizations it may generate.
129
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-xcode
macOS:
-xcode
Windows OS:
/Qxcode
Arguments
code Specifies a feature set that the compiler can target, including which instruction sets and
optimizations it may generate. Many of the following descriptions refer to Intel® Streaming
SIMD Extensions (Intel® SSE) and Supplemental Streaming SIMD Extensions (Intel® SSSE).
Possible values are:
130
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
131
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SSSE3 May generate SSSE3 and Intel® SSE3, SSE2, and SSE
instructions for Intel® processors. Optimizes for Intel
processors that support SSSE3 instructions. For macOS
systems, this value is only supported on Intel® 64
architecture. This replaces value T, which is deprecated.
SSE3 May generate Intel® SSE3, SSE2, and SSE instructions for
Intel® processors. Optimizes for Intel processors that
support Intel® SSE3 instructions. This value is not available
on macOS systems.
SSE2 May generate Intel® SSE2 and SSE instructions for Intel®
processors. Optimizes for Intel processors that support
Intel® SSE2 instructions. This setting is only supported for
ifort. This value is not available on macOS systems.
You can also specify a Host. For more information, see option [Q]xHost.
Default
varies On Windows systems, if neither /Qx nor /arch is specified, the default
target architecture supports Intel® SSE2 instructions.
On Linux systems, if neither -x nor -m is specified, the default target
architecture supports Intel® SSE2 instructions.
The default on macOS systems is [Q]xSSSE3.
Description
This option tells the compiler which processor features it may target, including which instruction sets and
optimizations it may generate. It also enables optimizations in addition to Intel feature-specific optimizations.
The specialized code generated by this option may only run on a subset of Intel® processors.
The resulting executables created from these option code values can only be run on Intel® processors that
support the indicated instruction set.
The binaries produced by these code values will run on Intel® processors that support the specified features.
Do not use code values to create binaries that will execute on a processor that is not compatible with the
targeted processor. The resulting program may fail with an illegal instruction exception or display other
unexpected behavior.
Compiling the main program with any of the code values produces binaries that display a fatal runtime error
if they are executed on unsupported processors, including all non-Intel processors.
Compiler options m and arch produce binaries that should run on processors not made by Intel that
implement the same capabilities as the corresponding Intel® processors.
The -x and /Qx options enable additional optimizations not enabled with options -m or /arch (nor with
options -ax and /Qax).
Linux
Options -x and -m are mutually exclusive. If both are specified, the compiler uses the last one specified and
generates a warning.
Windows
Options /Qx and /arch are mutually exclusive. If both are specified, the compiler uses the last one specified
and generates a warning.
132
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
All settings except SSE2 do a CPU check. However, if you specify option -O0 (Linux and
macOS) or option /Od (Windows), no CPU check is performed.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Intel Processor-Specific Optimization
Alternate Options
None
See Also
xHost, QxHost compiler option
ax, Qax compiler option
arch compiler option
march compiler option
minstruction, Qinstruction compiler option
m compiler option
xHost, QxHost
Tells the compiler to generate instructions for the
highest instruction set available on the compilation
host processor.
Syntax
Linux OS:
-xHost
macOS:
-xHost
Windows OS:
/QxHost
Arguments
None
133
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
varies On Windows systems, if neither /Qx nor /arch is specified, the default
target architecture supports Intel® SSE2 instructions.
On Linux systems, if neither -x nor -m is specified, the default target
architecture supports Intel® SSE2 instructions.
The default on macOS systems is [Q]xSSSE3.
Description
This option tells the compiler to generate instructions for the highest instruction set available on the
compilation host processor.
The instructions generated by this compiler option differ depending on the compilation host processor.
The following table describes the effects of specifying the [Q]xHost option and it tells whether the resulting
executable will run on processors different from the host processor.
Descriptions in the table refer to Intel® Advanced Vector Extensions 2 (Intel® AVX2), Intel® Advanced Vector
Extensions (Intel® AVX), Intel® Streaming SIMD Extensions (Intel® SSE), and Supplemental Streaming SIMD
Extensions (SSSE).
Instruction Set Effects When the -xHost or /QxHost Compiler Option is Specified
of Host
Processor
134
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Instruction Set Effects When the -xHost or /QxHost Compiler Option is Specified
of Host
Processor
For more information on other settings for option [Q]x, see that option description.
135
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Intel Processor-Specific Optimization
Alternate Options
None
See Also
x, Qx compiler option
ax, Qax compiler option
m compiler option
arch compiler option
NOTE
For the ifort compiler, support for Interprocedural Optimization (IPO) is disabled for macOS SDK 11
or higher.
ffat-lto-objects
Determines whether a fat link-time optimization (LTO)
object, containing both intermediate language and
object code, is generated during an interprocedural
optimization compilation (-c –ipo). This feature is only
available for ifort.
Syntax
Linux OS:
-ffat-lto-objects
-fno-fat-lto-objects
macOS:
None
Windows OS:
None
136
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option determines whether a fat link time optimization (LTO) object, containing both intermediate
language and object code, is generated during an interprocedural optimization compilation (-c -ipo).
• If you specify -ffat-lto-objects, the compiler generates a fat link-time optimization (LTO) object that
has both a true object and a discardable intermediate language section. This enables both link-time
optimization (LTO) linking and normal linking.
• If you specify -fno-fat-lto-objects, the compiler generates a fat link-time optimization (LTO) object
that only has a discardable intermediate language section; no true object is generated. This option may
improve compilation time.
Note that these files will be inserted into archives in the form in which they were created.
This option is provided for compatibility with gcc. For more information about this option, see the gcc
documentation.
NOTE
Intel's intermediate language representation is not compatible with gcc's intermediate
language representation.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
flto
Enables whole program link time optimization (LTO).
This feature is only available for ifx.
Syntax
Linux OS:
-flto[=arg]
-fno-lto
macOS:
None
137
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
-flto[=arg]
-fno-lto
Arguments
Default
Description
This option enables whole program link time optimization (LTO).
If you specify option -fno-lto, it disables whole program link time optimization.
If you specify -flto or -flto=full, compilation time may increase because of the additional optimizations.
Linux:
You can specify option -ipo as an alias for -flto. -ipo is equivalent to -flto.
If you want to specify a non-default linker, you must also specify option fuse-ld. Otherwise, the default
linker ld will be used.
Windows:
You can specify /Qipo as an alias for -flto.
/Qipo is the same as -flto during the compile step. During the link step, the compiler automatically adds
-fuse-ld=lld so the proper linker (lld) will be picked up to perform the expected optimizations. This
automatic inclusion is only performed for /Qipo; it is not performed for -flto on Windows.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation.
IDE Equivalent
None
138
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
ipo, Qipo compiler option
fuse-ld compiler option
ip, Qip
Determines whether additional interprocedural
optimizations for single-file compilation are enabled.
This feature is only available for ifort.
Syntax
Linux OS:
-ip
-no-ip
macOS:
-ip
-no-ip
Windows OS:
/Qip
/Qip-
Arguments
None
Default
OFF Some limited interprocedural optimizations occur, including inline function expansion for calls to
functions defined within the current source file. These optimizations are a subset of full intra-file
interprocedural optimizations. Note that this setting is not the same as -no-ip (Linux* and
macOS) or /Qip- (Windows*).
Description
This option determines whether additional interprocedural optimizations for single-file compilation are
enabled.
The [Q]ip option enables additional interprocedural optimizations for single-file compilation.
Options -no-ip (Linux and macOS) and /Qip- (Windows) may not disable inlining. To ensure that inlining of
user-defined functions is disabled, specify -inline-level=0or -fno-inline (Linux and macOS), or
specify /Ob0 (Windows).
IDE Equivalent
Windows
Visual Studio: Optimization > Interprocedural Optimization
Alternate Options
None
139
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
finline-functions compiler option
ip-no-inlining, Qip-no-inlining
Disables full and partial inlining enabled by
interprocedural optimization options. This feature is
only available for ifort.
Syntax
Linux OS:
-ip-no-inlining
macOS:
-ip-no-inlining
Windows OS:
/Qip-no-inlining
Arguments
None
Default
Description
This option disables full and partial inlining enabled by the following interprocedural optimization options:
IDE Equivalent
None
Alternate Options
None
ip-no-pinlining, Qip-no-pinlining
Disables partial inlining enabled by interprocedural
optimization options. This feature is only available for
ifort.
Syntax
Linux OS:
-ip-no-pinlining
macOS:
-ip-no-pinlining
140
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qip-no-pinlining
Arguments
None
Default
Description
This option disables partial inlining enabled by the following interprocedural optimization options:
IDE Equivalent
None
Alternate Options
None
ipo, Qipo
Enables interprocedural optimization between files.
Syntax
Linux OS:
-ipo[n]
-no-ipo
macOS:
-ipo[n]
-no-ipo
Windows OS:
/Qipo[n]
/Qipo-
Arguments
Default
141
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables interprocedural optimization between files. This is also called multifile interprocedural
optimization (multifile IPO) or Whole Program Optimization (WPO).
When you specify this option, the compiler performs inline function expansion for calls to functions defined in
separate files.
You cannot specify the names for the files that are created.
If n is 0, the compiler decides whether to create one or more object files based on an estimate of the size of
the application. It generates one object file for small applications, and two or more object files for large
applications.
If n is greater than 0, the compiler generates n object files, unless n exceeds the number of source files (m),
in which case the compiler generates only m object files.
If you do not specify n, the default is 0.
NOTE
When you specify option [Q]ipo with option [q or Q]opt-report, IPO information is
generated in the compiler optimization report at link time. After linking, you will see a report
named ipo_out.optrpt in the folder where you linked all of the object files.
NOTE
On Windows, option /Qipo automatically sets option -fuse-ld=lld.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Windows
Visual Studio: Optimization > Interprocedural Optimization
General > Whole Program Optimization
Alternate Options
None
See Also
fuse-ld compiler option
ipo-c, Qipo-c
Tells the compiler to optimize across multiple files and
generate a single object file.
Syntax
Linux OS:
-ipo-c
142
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-ipo-c
Windows OS:
/Qipo-c
Arguments
None
Default
Description
This option tells the compiler to optimize across multiple files and generate a single object file (named
ipo_out.o on Linux* and macOS systems; ipo_out.obj on Windows* systems).
It performs the same optimizations as the [Q]ipo option, but compilation stops before the final link stage,
leaving an optimized object file that can be used in further link steps.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ipo-jobs, Qipo-jobs
Specifies the number of commands (jobs) to be
executed simultaneously during the link phase of
Interprocedural Optimization (IPO). This feature is
only available for ifort.
Syntax
Linux OS:
-ipo-jobsn
macOS:
-ipo-jobsn
Windows OS:
/Qipo-jobs:n
Arguments
143
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option specifies the number of commands (jobs) to be executed simultaneously during the link phase of
Interprocedural Optimization (IPO). It should only be used if the link-time compilation is generating more
than one object. In this case, each object is generated by a separate compilation, which can be done in
parallel.
This option can be affected by the following compiler options:
• [Q]ipo when applications are large enough that the compiler decides to generate multiple object files.
• [Q]ipon when n is greater than 1.
• [Q]ipo-separate
Caution
Be careful when using this option. On a multi-processor system with lots of memory, it can
speed application build time. However, if n is greater than the number of processors, or if
there is not enough memory to avoid thrashing, this option can increase application build
time.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ipo-separate, Qipo-separate compiler option
ipo-S, Qipo-S
Tells the compiler to optimize across multiple files and
generate a single assembly file. This feature is only
available for ifort.
Syntax
Linux OS:
-ipo-S
macOS:
-ipo-S
Windows OS:
/Qipo-S
Arguments
None
144
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the compiler to optimize across multiple files and generate a single assembly file (named
ipo_out.s on Linux* and macOS systems; ipo_out.asm on Windows* systems).
It performs the same optimizations as the [Q]ipo option, but compilation stops before the final link stage,
leaving an optimized assembly file that can be used in further link steps.
IDE Equivalent
None
Alternate Options
None
See Also
ipo, Qipo compiler option
ipo-separate, Qipo-separate
Tells the compiler to generate one object file for every
source file. This feature is only available for ifort.
Syntax
Linux OS:
-ipo-separate
macOS:
None
Windows OS:
/Qipo-separate
Arguments
None
Default
OFF The compiler decides whether to create one or more object files.
Description
This option tells the compiler to generate one object file for every source file. It overrides any [Q]ipo option
specification.
IDE Equivalent
None
Alternate Options
None
145
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ipo, Qipo compiler option
ansi-alias, Qansi-alias
Tells the compiler to assume certain rules of the
Fortran standard regarding aliasing and array bounds.
Syntax
Linux OS:
-ansi-alias
-no-ansi-alias
macOS:
-ansi-alias
-no-ansi-alias
Windows OS:
/Qansi-alias
/Qansi-alias-
Arguments
None
Default
-ansi-alias Programs adhere to the Fortran standard's rules regarding aliasing and
or /Qansi-alias array bounds.
Description
This option tells the compiler to assume certain rules of the Fortran standard regarding aliasing and array
bounds.
It tells the compiler to assume that the program adheres to the following rules of the Fortran standard:
This option is similar to option assume nodummy_aliases with the additional restriction on array bounds.
If -no-ansi-alias (Linux* and macOS) or /Qansi-alias- (Windows*) is specified, the compiler assumes
that the program might not follow the Fortran standard's rules regarding dummy argument aliasing and array
bounds; this can possibly affect performance.
IDE Equivalent
None
146
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
assume compiler option, setting [no]dummy_aliases
coarray, Qcoarray
Enables the coarray feature.
Syntax
Linux OS:
-coarray[=keyword]
macOS:
None
Windows OS:
/Qcoarray[:keyword]
Arguments
keyword Specifies the memory system where the coarrays will be implemented. Possible values are:
single Indicates a configuration where the image does not contain self-
replication code. This results in an executable with a single running
image. This configuration can be useful for debugging purposes, even
though there are no inter-image interactions.
Default
OFF Coarrays are not enabled unless you specify this option.
Description
This option enables the coarray feature of the Fortran 2008 Standard. It enables any coarray syntax in your
program. If this option is not specified, coarray syntax is rejected.
It also tells the driver to link against appropriate libraries, and to create the appropriate executables.
Only one keyword can be in effect. If you specify more than one keyword, the last one specified takes
precedence. However, if keyword single is specified anywhere on the command line, it takes precedence.
You can specify option [Q]coarray-num-images to specify the default number of images that can be used
to run a coarray executable. If you do not specify that option, you get the number of execution units on the
current system.
You can specify the [Q]coarray-config-file option to specify the name of a Message Passing Interface
(MPI) configuration file.
Options [Q]coarray-num-images and [Q]coarray-config-file are valid for all keyword values.
147
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Coarrays are only supported on 64-bit architectures.
IDE Equivalent
Windows
Visual Studio: Language > Enable Coarrays
Alternate Options
None
Example
The following command runs a coarray program on shared memory using n images:
See Also
coarray-num-images, Qcoarray-num-images compiler option
coarray-config-file, Qcoarray-config-file compiler option
Coarrays
Using Coarrays
coarray-config-file, Qcoarray-config-file
Specifies the name of a Message Passing Interface
(MPI) configuration file.
Syntax
Linux OS:
-coarray-config-file=filename
148
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/Qcoarray-config-file:filename
Arguments
filename Is the name of the MPI configuration file. You can specify a path.
Default
OFF When coarrays are enabled, the compiler uses default settings for MPI.
Description
This option specifies the name of a Message Passing Interface (MPI) configuration file. This file is used by the
compiler when coarrays are processed; it configures the MPI for multi-node operations.
This option has no affect unless you also specify the [Q]coarray option, which is required to create the
coarray executable.
Note that when a setting is specified in environment variable FOR_COARRAY_CONFIG_FILE, it overrides the
compiler option setting.
IDE Equivalent
Windows
Visual Studio: Language > MPI Configuration File
Alternate Options
None
See Also
coarray, Qcoarray compiler option
coarray-num-images, Qcoarray-num-images
Specifies the default number of images that can be
used to run a coarray executable.
Syntax
Linux OS:
-coarray-num-images=n
macOS:
None
Windows OS:
/Qcoarray-num-images:n
Arguments
n Is the default number of images. The limit is determined from the system
configuration.
149
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option specifies the default number of images that can be used to run a coarray executable.
This option has no affect unless you also specify the [Q]coarray option. This option is required to create the
coarray executable.
You can specify option [Q]coarray-num-images to specify the default number of images that can be used
to run a coarray executable. If you do not specify that option, you get the number of execution units on the
current system.
Note that when a setting is specified in environment variable FOR_COARRAY_NUM_IMAGES, it overrides the
compiler option setting.
IDE Equivalent
Windows
Visual Studio: Language > Coarray Images
Alternate Options
None
See Also
coarray, Qcoarray compiler option
complex-limited-range, Qcomplex-limited-range
Determines whether the use of basic algebraic
expansions of some arithmetic operations involving
data of type COMPLEX is enabled. This feature is only
available for ifort.
Syntax
Linux OS:
-complex-limited-range
-no-complex-limited-range
macOS:
-complex-limited-range
-no-complex-limited-range
Windows OS:
/Qcomplex-limited-range
/Qcomplex-limited-range-
Arguments
None
150
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option determines whether the use of basic algebraic expansions of some arithmetic operations involving
data of type COMPLEX is enabled.
When the option is enabled, this can cause performance improvements in programs that use a lot of
COMPLEX arithmetic. However, values at the extremes of the exponent range may not compute correctly.
IDE Equivalent
Windows
Visual Studio: Floating point > Limit COMPLEX Range
Alternate Options
None
fvec-peel-loops, Qvec-peel-loops
Enables peel loop vectorization. This feature is only
available for ifx.
Syntax
Linux OS:
-fvec-peel-loops
-fno-vec-peel-loops
macOS:
None
Windows OS:
/Qvec-peel-loops
/Qvec-peel-loops-
Arguments
None
Default
Description
This option enables vectorization of peeling loops created during loop vectorization. It causes the compiler to
perform additional steps to vectorize a peel loop that was created to improve alignment of memory
references in the main vectorized loop.
The peel loop can be vectorized only when the masked mode of vectorization is enabled by specifying option
-fvec-with-mask or /Qvec-with-mask.
151
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The vectorization of a peel loop cannot be enforced because the compiler uses the cost model to determine
whether it should be done.
IDE Equivalent
None
Alternate Options
None
See Also
fvec-with-mask, Qvec-with-mask compiler option
fvec-remainder-loops, Qvec-remainder-loops compiler option
fvec-remainder-loops, Qvec-remainder-loops
Enables remainder loop vectorization. This feature is
only available for ifx.
Syntax
Linux OS:
-fvec-remainder-loops
-fno-vec-remainder-loops
macOS:
None
Windows OS:
/Qvec-remainder-loops
/Qvec-remainder-loops-
Arguments
None
Default
Description
This option enables vectorization of remainder loops created during loop vectorization. It causes the compiler
to perform additional steps to vectorize the remainder loop that was created for the vectorized main loop.
The compiler uses the cost model to determine vector factor and mode of vectorization for remainder loops.
The vectorization of remainder can be enforced using !DIR$ VECTOR VECREMAINDER on the loop.
IDE Equivalent
None
Alternate Options
None
152
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fvec-vec-peel-loops, Qvec-peel-loops compiler option
fvec-with-mask, Qvec-with-mask compiler option
VECTOR directive
fvec-with-mask, Qvec-with-mask
Enables vectorization for short trip-count loops with
masking. This feature is only available for ifx.
Syntax
Linux OS:
-fvec-with-mask
-fno-vec-with-mask
macOS:
None
Windows OS:
/Qvec-with-mask
/Qvec-with-mask-
Arguments
None
Default
Description
This option enables a special mode of vectorization, which is applicable for loops with small number of
iterations known at compile time. The peeling and remainder loops created during vectorization also fit into
this category.
In this mode, the compiler uses a vector factor that is the lowest power-of-two integer greater than the
known (maximum) number of loop iterations. Usually, such vectorized loops have one iteration with most of
operations masked.
IDE Equivalent
None
Alternate Options
None
See Also
fvec-vec-peel-loops, Qvec-peel-loops compiler option
fvec-remainder-loops, Qvec-remainder-loops compiler option
153
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
guide, Qguide
Lets you set a level of guidance for auto-vectorization,
auto parallelism, and data transformation. This feature
is only available for ifort.
Syntax
Linux OS:
-guide[=n]
macOS:
-guide[=n]
Windows OS:
/Qguide[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for
parallelism, vectorization, and data transformation.
Description
This option lets you set a level of guidance (advice) for auto-vectorization, auto parallelism, and data
transformation. It causes the compiler to generate messages suggesting ways to improve these
optimizations.
When this option is specified, the compiler does not produce any objects or executables.
You must also specify the [Q]parallel option to receive auto parallelism guidance.
You can set levels of guidance for the individual guide optimizations by specifying one of the following
options:
If you specify the [Q]guide option and also specify one of the options setting a level of guidance for an
individual guide optimization, the value set for the individual guide optimization will override the setting
specified in [Q]guide.
If you do not specify [Q]guide, but specify one of the options setting a level of guidance for an individual
guide optimization, option [Q]guide is enabled with the greatest value passed among any of the three
individual guide optimizations specified.
In debug mode, this option has no effect unless option O2 (or higher) is explicitly specified in the same
command line.
154
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The compiler speculatively performs optimizations as part of guide analysis. As a result,
when you use guided auto-parallelism options with options that produce vectorization or
auto-parallelizer reports (such as option [q or Q]opt-report), the compiler generates
"LOOP WAS VECTORIZED" or similar messages as if the compilation was performed with the
recommended changes.
When compilation is performed with the [Q]guide option, you should use extra caution when
interpreting vectorizer diagnostics and auto-parallelizer diagnostics.
NOTE
You can specify [Q]diag-disable to prevent the compiler from issuing one or more
diagnostic messages.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Guided Auto Parallelism > Guided Auto Parallelism Analysis
Alternate Options
None
See Also
guide-data-trans, Qguide-data-trans compiler option
guide-par, Qguide-par compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-file-append, Qguide-file-append compiler option
guide-opts, Qguide-opts compiler option
diag, Qdiag compiler option
qopt-report, Qopt-report compiler option
guide-data-trans, Qguide-data-trans
Lets you set a level of guidance for data
transformation. This feature is only available for ifort.
Syntax
Linux OS:
-guide-data-trans[=n]
macOS:
-guide-data-trans[=n]
Windows OS:
/Qguide-data-trans[:n]
Arguments
155
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF You do not receive guidance about how to improve optimizations for data
transformation.
Description
This option lets you set a level of guidance for data transformation. It causes the compiler to generate
messages suggesting ways to improve that optimization.
IDE Equivalent
None
Alternate Options
None
See Also
guide, Qguide compiler option
guide-par, Qguide-par compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-file, Qguide-file
Causes the results of guided auto parallelism to be
output to a file. This feature is only available for ifort.
Syntax
Linux OS:
-guide-file[=filename]
macOS:
-guide-file[=filename]
Windows OS:
/Qguide-file[:filename]
Arguments
filename Is the name of the file for output. It can include a path.
Default
OFF Messages that are generated by guided auto parallelism are output to stderr.
Description
This option causes the results of guided auto parallelism to be output to a file.
This option is ignored unless you also specify one or more of the following options:
156
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• [Q]guide
• [Q]guide-vec
• [Q]guide-data-trans
• [Q]guide-par
If you do not specify a path, the file is placed in the current working directory.
If there is already a file named filename, it will be overwritten.
You can include a file extension in filename. For example, if file.txt is specified, the name of the output file is
file.txt. If you do not provide a file extension, the name of the file is filename.guide.
If you do not specify filename, the name of the file is name-of-the-first-source-file.guide. This is also the
name of the file if the name specified for filename conflicts with a source file name provided in the command
line.
NOTE
If you specify the [Q]guide-file option and you also specify option [Q]guide-file-append,
the last option specified on the command line takes precedence.
IDE Equivalent
Windows
Visual Studio: Diagnostics > Guided Auto Parallelism > Emit Guided Auto Parallelism Diagnostics to
File
Diagnostics > Guided Auto Parallelism Diagnostics File
Alternate Options
None
Example
The following example shows how to cause guided auto parallelism messages to be output to a file named
my_guided_autopar.guide:
See Also
guide, Qguide compiler option
guide-file-append, Qguide-file-append compiler option
guide-file-append, Qguide-file-append
Causes the results of guided auto parallelism to be
appended to a file. This feature is only available for
ifort.
Syntax
Linux OS:
-guide-file-append[=filename]
macOS:
-guide-file-append[=filename]
157
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qguide-file-append[:filename]
Arguments
filename Is the name of the file to be appended to. It can include a path.
Default
OFF Messages that are generated by guided auto parallelism are output to stderr.
Description
This option causes the results of guided auto parallelism to be appended to a file.
This option is ignored unless you also specify one or more of the following options:
• [Q]guide
• [Q]guide-vec
• [Q]guide-data-trans
• [Q]guide-par
If you do not specify a path, the compiler looks for filename in the current working directory.
If filename is not found, then a new file with that name is created in the current working directory.
If you do not specify a file extension, the name of the file is filename.guide.
If the name specified for filename conflicts with a source file name provided in the command line, the name
of the file is name-of-the-first-source-file.guide.
NOTE
If you specify the [Q]guide-file-append option and you also specify option [Q]guide-file,
the last option specified on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to cause guided auto parallelism messages to be appended to a file named
my_messages.txt:
See Also
guide, Qguide compiler option
guide-file, Qguide-file compiler option
158
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
guide-opts, Qguide-opts
Tells the compiler to analyze certain code and
generate recommendations that may improve
optimizations. This feature is only available for ifort.
Syntax
Linux OS:
-guide-opts=string
macOS:
-guide-opts=string
Windows OS:
/Qguide-opts:string
Arguments
string Is the text denoting the code to analyze. The string must appear within quotes. It can take
one or more of the following forms:
filename
filename, routine
filename, range [, range]...
filename, routine, range [, range]...
If you specify more than one of the above forms in a string, a semicolon must appear
between each form. If you specify more than one range in a string, a comma must appear
between each range. Optional blanks can follow each parameter in the forms above and
they can also follow each form in a string.
159
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF You do not receive guidance on how to improve optimizations. However, if you specify the
[Q]guide option, the compiler analyzes and generates recommendations for all the code in an
application
Description
This option tells the compiler to analyze certain code and generate recommendations that may improve
optimizations.
This option is ignored unless you also specify one or more of the following options:
• [Q]guide
• [Q]guide-vec
• [Q]guide-data-trans
• [Q]guide-par
When the [Q]guide-opts option is specified, a message is output that includes which parts of the input files
are being analyzed. If a routine is selected to be analyzed, the complete routine name will appear in the
generated message.
When inlining is involved, you should specify callee line numbers. Generated messages also use callee line
numbers.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Guided Auto Parallelism > Guided Auto Parallelism Code Selection
Options
Alternate Options
None
Example
Consider the following:
Linux*: -guide-opts="m.f, 1-10; m2.f90, 1-40, 50-90, 100-200; m5.f, 300-400; x.f, 'funca(j)',
22-44, 55-77, 88-99; y.f, 'subrb'"
Windows*: /Quide-opts="m.f, 1-10; m2.f90, 1-40, 50-90, 100-200; m5.f, 300-400; x.f, 'funca(j)',
22-44, 55-77, 88-99; y.f, 'subrb'"
The above command causes the following to be analyzed:
See Also
guide, Qguide compiler option
guide-data-trans, Qguide-data-trans compiler option
160
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
guide-par, Qguide-par
Lets you set a level of guidance for auto parallelism.
This feature is only available for ifort.
Syntax
Linux OS:
-guide-par[=n]
macOS:
-guide-par[=n]
Windows OS:
/Qguide-par[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for
parallelism.
Description
This option lets you set a level of guidance for auto parallelism. It causes the compiler to generate messages
suggesting ways to improve that optimization.
You must also specify the [Q]parallel option to receive auto parallelism guidance.
IDE Equivalent
None
Alternate Options
None
See Also
guide, Qguide compiler option
guide-data-trans, Qguide-data-trans compiler option
guide-vec, Qguide-vec compiler option
guide-file, Qguide-file compiler option
guide-vec, Qguide-vec
Lets you set a level of guidance for auto-vectorization.
This feature is only available for ifort.
161
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-guide-vec[=n]
macOS:
-guide-vec[=n]
Windows OS:
/Qguide-vec[:n]
Arguments
Default
OFF You do not receive guidance about how to improve optimizations for
vectorization.
Description
This option lets you set a level of guidance for auto-vectorization. It causes the compiler to generate
messages suggesting ways to improve that optimization.
IDE Equivalent
None
Alternate Options
None
See Also
guide, Qguide compiler option
guide-data-trans, Qguide-data-trans compiler option
guide-par, Qguide-par compiler option
guide-file, Qguide-file compiler option
heap-arrays
Puts automatic arrays and arrays created for
temporary computations on the heap instead of the
stack.
Syntax
Linux OS:
-heap-arrays [size]
-no-heap-arrays
macOS:
-heap-arrays [size]
162
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-no-heap-arrays
Windows OS:
/heap-arrays[:size]
/heap-arrays-
Arguments
size Is an integer value representing the size of the arrays in kilobytes. Arrays smaller than size are
put on the stack.
Default
-no-heap-arrays The compiler puts automatic arrays and temporary arrays in the stack storage
or /heap-arrays- area.
Description
This option puts automatic arrays and arrays created for temporary computations on the heap instead of the
stack.
If size is specified:
• Automatic (temporary) arrays that have a compile-time size greater than the value specified for size are
put on the heap, rather than on the stack. If the compiler cannot determine the size at compile time, it
puts the automatic array on the heap.
• The value is only used when the total size of the temporary array or automatic array can be determined at
compile time, using compile-time constants.
Any arrays known at compile-time to be larger than size are allocated on the heap instead of the stack. For
example, if 10 is specified for size:
• All automatic and temporary arrays equal to or larger than 10 KB are put on the heap.
• All automatic and temporary arrays smaller than 10 KB are put on the stack.
If size is omitted, and the size of the temporary array or automatic array cannot be determined at compile
time, it is assumed that the total size is greater than size and the array is allocated on the heap.
Linux and macOS
You can use the shell command unlimit to increase the size of the run-time stack before execution.
Windows
You can use compiler option /F to tell the linker to increase the size of the run-time stack to allow for large
objects on the stack.
IDE Equivalent
Windows
Visual Studio: Optimization > Heap Arrays
Alternate Options
None
163
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
In Fortran, an automatic array gets its size from a run-time expression. In the following example, array X is
affected by the heap-array option; array Y is not:
RECURSIVE SUBROUTINE F( N )
INTEGER :: N
REAL :: X ( N ) ! an automatic array
REAL :: Y ( 1000 ) ! an explicit-shape local array on the stack
Temporary arrays are often created before making a routine call, or when an array operation detects overlap.
In the following example, the array assignment uses a temporary intermediate array because there is clearly
an overlap between the right hand side and the left hand side of the assignment:
integer a(10000)
a(2:) = a(1:ubound(a,dim=1)-1)
If you specify the heap-arrays option and omit size, the compiler creates the temporary array on the heap.
If you specify the heap-arrays option with size 50, the compiler creates the temporary array on the stack.
This is because the size of the temporary intermediate array can be determined at compile time (40Kb), and
it's size is less than the size value.
In the following example, a contiguous array is created from the array slice declaration and passed on:
call somesub(a(1:10000:2))
If you specify the heap-arrays option and omit size, the compiler creates the temporary array on the heap.
If you specify the heap-arrays option with size 25, the compiler creates the temporary array on the stack.
This is because the size of the temporary intermediate array at compile time is only 20Kb.
See Also
F compiler option
pad, Qpad
Enables the changing of the variable and array
memory layout.
Syntax
Linux OS:
-pad
-nopad
macOS:
-pad
-nopad
Windows OS:
/Qpad
/Qpad-
Arguments
None
164
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-nopad or /Qpad- Variable and array memory layout is performed by default methods.
Description
This option enables the changing of the variable and array memory layout.
This option is effectively not different from the align option when applied to structures and derived types.
However, the scope of pad is greater because it applies also to common blocks, derived types, sequence
types, and structures.
IDE Equivalent
None
Alternate Options
None
See Also
align compiler option
qmkl, Qmkl
Tells the compiler to link to certain libraries in the
Intel® oneAPI Math Kernel Library (oneMKL). On
Windows systems, you must specify this option at
compile time.
Syntax
Linux OS:
-qmkl[=lib]
macOS:
-qmkl[=lib]
Windows OS:
/Qmkl[:lib]
Arguments
lib Indicates which oneMKL library files should be linked. Possible values are:
Default
165
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option tells the compiler to link to certain libraries in the Intel® oneAPI Math Kernel Library (oneMKL).
On Linux* and macOS systems, dynamic linking is the default when you specify -qmkl.
-qmkl -static-intel
On Windows* systems, static linking is the default when you specify /Qmkl. To link with oneMKL dynamically,
you must specify:
NOTE
On Windows* systems, this option adds directives to the compiled code, which the linker
then reads without further input from the driver. You do not need to specify a separate link
command.
On Linux* and macOS systems, the driver must add the library names explicitly to the link command.
You must use option -qmkl to perform the link to pull in the dependent libraries.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Intel® oneAPI Math Kernel Library
Alternate Options
Linux and macOS on ifort: -mkl (this is a deprecated option)
See Also
qmkl-ilp64, Qmkl-ilp64 compiler option
static-intel compiler option
MD compiler option
libs compiler option
qmkl-ilp64, Qmkl-ilp64
Tells the compiler to link to the ILP64-specific version
of the Intel® oneAPI Math Kernel Library (oneMKL). On
Windows systems, you must specify this option at
compile time.
Syntax
Linux OS:
-qmkl-ilp64[=lib]
macOS:
-qmkl-ilp64[=lib]
166
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qmkl-ilp64[:lib]
Arguments
lib Indicates which ILP64-specific oneMKL library files should be linked. Possible values are:
Default
Description
This option tells the compiler to link to the ILP64-specific version of the Intel® oneAPI Math Kernel Library
(oneMKL).
If both option -qmkl-ilp64 (or /Qmkl-ilp64) and -qmkl (or /Qmkl) are specified on the command line, the
rightmost specified option takes precedence.
For more information about using oneMKL libraries, see the article titled: Intel® oneAPI Math Kernel Library
Link Line Advisor.
Linux and macOS
Dynamic linking is the default when you specify -qmkl-ilp64.
-qmkl-ilp64 -static-intel
The driver must add the library names explicitly to the link command. You must use option -qmkl-ilp64 to
perform the link to pull in the dependent libraries.
Windows
Static linking is the default when you specify /Qmkl-ilp64. To link with oneMKL dynamically, you must
specify:
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Use ILP64 interfaces
Alternate Options
None
167
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
qmkl compiler option
static-intel compiler option
MD compiler option
libs compiler option
qopt-args-in-regs, Qopt-args-in-regs
Determines whether calls to routines are optimized by
passing arguments in registers instead of on the
stack. This is a deprecated option that may be
removed in a future release. This feature is only
available for ifort.
Architecture Restrictions
Only available on IA-32 architecture. IA-32 support has been deprecated, and will be removed in a future
release.
Syntax
Linux OS:
-qopt-args-in-regs[=keyword]
macOS:
None
Windows OS:
/Qopt-args-in-regs[:keyword]
Arguments
keyword Specifies whether the optimization should be performed and under what conditions. Possible
values are:
none The optimization is not performed. No arguments are passed in registers. They are
put on the stack.
seen Causes arguments to be passed in registers when they are passed to routines
whose definition can be seen in the same compilation unit.
all Causes arguments to be passed in registers, whether they are passed to routines
whose definition can be seen in the same compilation unit, or not. This value is
only available on Linux* systems.
Default
-qopt-args-in-regs=seen Arguments are passed in registers when they are passed to routines
or /Qopt-args-in-regs:seen whose definition is seen in the same compilation unit.
Description
This option determines whether calls to routines are optimized by passing arguments in registers instead of
on the stack. It also indicates the conditions when the optimization will be performed.
This is a deprecated option that may be removed in a future release. There is no replacement option.
168
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option can improve performance for Application Binary Interfaces (ABIs) that require arguments to be
passed in memory and compiled without interprocedural optimization (IPO).
Note that on Linux* systems, if all is specified, a small overhead may be paid when calling "unseen"
routines that have not been compiled with the same option. This is because the call will need to go through a
"thunk" to ensure that arguments are placed back on the stack where the callee expects them.
IDE Equivalent
None
Alternate Options
None
qopt-assume-safe-padding, Qopt-assume-safe-padding
Determines whether the compiler assumes that
variables and dynamically allocated memory are
padded past the end of the object. This feature is only
available for ifort.
Architecture Restrictions
Only available on all architectures that support Intel® Advanced Vector Extensions 512 (Intel® AVX-512)
Foundation instructions
Syntax
Linux OS:
-qopt-assume-safe-padding
-qno-opt-assume-safe-padding
macOS:
-qopt-assume-safe-padding
-qno-opt-assume-safe-padding
Windows OS:
/Qopt-assume-safe-padding
/Qopt-assume-safe-padding-
Arguments
None
Default
-qno-opt-assume-safe-padding The compiler will not assume that variables and dynamically allocated
or /Qopt-assume-safe-padding- memory are padded past the end of the object. It will adhere to the
sizes specified in your program.
Description
This option determines whether the compiler assumes that variables and dynamically allocated memory are
padded past the end of the object.
When you specify option [q or Q]opt-assume-safe-padding, the compiler assumes that variables and
dynamically allocated memory are padded. This means that code can access up to 64 bytes beyond what is
specified in your program.
169
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The compiler does not add any padding for static and automatic objects when this option is used, but it
assumes that code can access up to 64 bytes beyond the end of the object, wherever the object appears in
the program. To satisfy this assumption, you must increase the size of static and automatic objects in your
program when you use this option.
This option may improve performance of memory operations.
IDE Equivalent
None
Alternate Options
None
qopt-block-factor, Qopt-block-factor
Lets you specify a loop blocking factor. This feature is
only available for ifort.
Syntax
Linux OS:
-qopt-block-factor=n
macOS:
-qopt-block-factor=n
Windows OS:
/Qopt-block-factor:n
Arguments
Default
Description
This option lets you specify a loop blocking factor.
IDE Equivalent
None
Alternate Options
None
qopt-dynamic-align, Qopt-dynamic-align
Enables or disables dynamic data alignment
optimizations.
Syntax
Linux OS:
-qopt-dynamic-align
170
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-qno-opt-dynamic-align
macOS:
-qopt-dynamic-align
-qno-opt-dynamic-align
Windows OS:
/Qopt-dynamic-align
/Qopt-dynamic-align-
Arguments
None
Default
Description
This option enables or disables dynamic data alignment optimizations.
If you specify -qno-opt-dynamic-align or /Qopt-dynamic-align-, the compiler generates no code
dynamically dependent on alignment. It will not do any optimizations based on data location and results will
depend on the data values themselves.
When you specify [q or Q]qopt-dynamic-align, the compiler may implement conditional optimizations
based on dynamic alignment of the input data. These dynamic alignment optimizations may result in
different bitwise results for aligned and unaligned data with the same values.
Dynamic alignment optimizations can improve the performance of some vectorized code, especially for long
trip count loops, but there is an associated cost of increased code size and compile time. Disabling such
optimizations can improve the performance of some other vectorized code. It may also improve bitwise
reproducibility of results, factoring out data location from possible sources of discrepancy.
IDE Equivalent
None
Alternate Options
None
qopt-for-throughput, Qopt-for-throughput
Determines how the compiler optimizes for throughput
depending on whether the program is to run in single-
job or multi-job mode. This feature is only available
for ifx.
171
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopt-for-throughput[=value]
macOS:
None
Windows OS:
/Qopt-for-throughput[:value]
Arguments
Default
OFF If this option is not specified, the compiler will not optimize for throughput performance.
Description
This option determines whether throughput performance optimization occurs for a program that is run as a
single job or one that is run in a multiple job environment.
The memory optimizations for a single job versus multiple jobs can be tuned in different ways by the
compiler. For example, the cost model for loop tiling and prefetching are different for a single job versus
multiple jobs. When a single job is running, more memory is available and the tunings will be different.
IDE Equivalent
None
Alternate Options
None
qopt-jump-tables, Qopt-jump-tables
Enables or disables generation of jump tables for
switch statements. This feature is only available for
ifort.
Syntax
Linux OS:
-qopt-jump-tables=keyword
-qno-opt-jump-tables
macOS:
-qopt-jump-tables=keyword
-qno-opt-jump-tables
Windows OS:
/Qopt-jump-tables:keyword
/Qopt-jump-tables-
172
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
keyword Is the instruction for generating jump tables. Possible values are:
never Tells the compiler to never generate jump tables. All switch
statements are implemented as chains of if-then-elses.
This is the same as specifying -qno-opt-jump-tables
(Linux* and macOS) or /Qopt-jump-tables-
(Windows*).
Default
Description
This option enables or disables generation of jump tables for switch statements. When the option is enabled,
it may improve performance for programs with large switch statements.
IDE Equivalent
None
Alternate Options
None
qopt-malloc-options
Lets you specify an alternate algorithm for malloc().
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-malloc-options=n
macOS:
-qopt-malloc-options=n
Windows OS:
None
Arguments
173
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-qopt-malloc-options=0 The compiler uses the default algorithm when malloc() is called.
No call is made to mallopt().
Description
This option lets you specify an alternate algorithm for malloc().
If you specify a non-zero value for n, it causes alternate configuration parameters to be set for how malloc()
allocates and frees memory. It tells the compiler to insert calls to mallopt() to adjust these parameters to
malloc() for dynamic memory allocation. This may improve speed.
IDE Equivalent
None
Alternate Options
None
See Also
malloc(3) man page
mallopt function (defined in malloc.h)
qopt-matmul, Qopt-matmul
Enables or disables a compiler-generated Matrix
Multiply (matmul) library call.
Syntax
Linux OS:
-qopt-matmul
-qno-opt-matmul
macOS:
None
174
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qopt-matmul
/Qopt-matmul-
Arguments
None
Default
-qno-opt-matmul The matmul library call optimization does not occur unless this option is
or /Qopt-matmul- enabled or certain other compiler options are specified (see below).
Description
This option enables or disables a compiler-generated Matrix Multiply (MATMUL) library call.
The [q or Q]opt-matmul option tells the compiler to identify matrix multiplication loop nests (if any) and
replace them with a matmul library call for improved performance. The resulting executable may improve
performance on Intel® microprocessors.
NOTE
This option is dependent upon the OpenMP* library. If your product does not support
OpenMP, this option will have no effect.
NOTE
Many routines in the MATMUL library are more highly optimized for Intel® microprocessors
than for non-Intel microprocessors.
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Enable Matrix Multiply Library Call
Alternate Options
None
See Also
O compiler option
qopt-mem-layout-trans, Qopt-mem-layout-trans
Controls the level of memory layout transformations
performed by the compiler.
Syntax
Linux OS:
-qopt-mem-layout-trans[=n]
-qno-opt-mem-layout-trans
175
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-qopt-mem-layout-trans[=n]
-qno-opt-mem-layout-trans
Windows OS:
/Qopt-mem-layout-trans[:n]
/Qopt-mem-layout-trans-
Arguments
Default
Description
This option controls the level of memory layout transformations performed by the compiler. This option can
improve cache reuse and cache locality.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
176
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-multi-version-aggressive, Qopt-multi-version-aggressive
Tells the compiler to use aggressive multi-versioning
to check for pointer aliasing and scalar replacement.
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-multi-version-aggressive
-qno-opt-multi-version-aggressive
macOS:
-qopt-multi-version-aggressive
-qno-opt-multi-version-aggressive
Windows OS:
/Qopt-multi-version-aggressive
/Qopt-multi-version-aggressive-
Arguments
None
Default
Description
This option tells the compiler to use aggressive multi-versioning to check for pointer aliasing and scalar
replacement. This option may improve performance.
The performance can be affected by certain options, such as /arch or /Qx (Windows*) or -m or -x (Linux*
and macOS).
IDE Equivalent
None
Alternate Options
None
qopt-multiple-gather-scatter-by-shuffles, Qopt-multiple-gather-scatter-by-shuffles
Enables or disables the optimization for multiple
adjacent gather/scatter type vector memory
references.
Syntax
Linux OS:
-qopt-multiple-gather-scatter-by-shuffles
-qno-opt-multiple-gather-scatter-by-shuffles
177
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-qopt-multiple-gather-scatter-by-shuffles
-qno-opt-multiple-gather-scatter-by-shuffles
Windows OS:
/Qopt-multiple-gather-scatter-by-shuffles
/Qopt-multiple-gather-scatter-by-shuffles-
Arguments
None
Default
varies When this option is not specified, the compiler uses default heuristics for
optimization.
Description
This option controls the optimization for multiple adjacent gather/scatter type vector memory references.
This optimization hint is useful for performance tuning. It tries to generate more optimal software sequences
using shuffles.
If you specify this option, the compiler will apply the optimization heuristics. If you specify
-qno-opt-multiple-gather-scatter-by-shuffles
or /Qopt-multiple-gather-scatter-by-shuffles-, the compiler will not apply the optimization.
NOTE
Optimization is affected by optimization compiler options, such as [Q]x, -march (Linux* or
macOS), and /arch (Windows*).
To override the effect of this option (or the default) per loop basis, you can use directive VECTOR
[NO]MULTIPLE_GATHER_SCATTER_BY_SHUFFLE.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
VECTOR directive
x, Qx compiler option
march compiler option
arch compiler option
178
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-prefetch, Qopt-prefetch
Enables or disables prefetch insertion optimization.
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-prefetch[=n]
-qno-opt-prefetch
macOS:
-qopt-prefetch[=n]
-qno-opt-prefetch
Windows OS:
/Qopt-prefetch[:n]
/Qopt-prefetch-
Arguments
Default
Description
This option enables or disables prefetch insertion optimization. The goal of prefetching is to reduce cache
misses by providing hints to the processor about when data should be loaded into the cache.
This option enables prefetching when higher optimization levels are specified.
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Prefetch Insertion
Alternate Options
None
See Also
qopt-prefetch-distance, Qopt-prefetch-distance compiler option
179
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-prefetch-distance, Qopt-prefetch-distance
Specifies the prefetch distance to be used for
compiler-generated prefetches inside loops. This
feature is only available for ifort.
Syntax
Linux OS:
-qopt-prefetch-distance=n1[, n2]
macOS:
None
Windows OS:
/Qopt-prefetch-distance:n1[, n2]
Arguments
Default
OFF The compiler uses default heuristics to determine the prefetch distance.
Description
This option specifies the prefetch distance to be used for compiler-generated prefetches inside loops. The unit
(n1 and optionally n2) is the number of iterations. If the loop is vectorized by the compiler, the unit is the
number of vectorized iterations.
The value of n1 will be used as the distance for prefetches from memory to L2 (for example, the vprefetch1
instruction). If n2 is specified, it will be used as the distance for prefetches from L2 to L1 (for example, the
vprefetch0 instruction).
This option is ignored if option -qopt-prefetch=0 (Linux*) or /Qopt-prefetch:0 (Windows*) is specified.
IDE Equivalent
None
Alternate Options
None
Example
Consider the following Linux* examples:
-qopt-prefetch-distance=64,32
The above causes the compiler to use a distance of 64 iterations for memory to L2 prefetches, and a distance
of 32 iterations for L2 to L1 prefetches.
-qopt-prefetch-distance=24
180
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The above causes the compiler to use a distance of 24 iterations for memory to L2 prefetches. The distance
for L2 to L1 prefetches will be determined by the compiler.
-qopt-prefetch-distance=0,4
The above turns off all memory to L2 prefetches inserted by the compiler inside loops. The compiler will use
a distance of 4 iterations for L2 to L1 prefetches.
-qopt-prefetch-distance=16,0
The above causes the compiler to use a distance of 16 iterations for memory to L2 prefetches. No L2 to L1
loop prefetches are issued by the compiler.
See Also
qopt-prefetch, Qopt-prefetch compiler option
PREFETCH directive
qopt-prefetch-issue-excl-hint, Qopt-prefetch-issue-excl-hint
Supports the prefetchW instruction in Intel®
microarchitecture code name Broadwell and later. This
feature is only available for ifort.
Syntax
Linux OS:
-qopt-prefetch-issue-excl-hint
macOS:
None
Windows OS:
/Qopt-prefetch-issue-excl-hint
Arguments
None
Default
Description
This option supports the PREFETCHW instruction in Intel® microarchitecture code name Broadwell and later.
When you specify this option, you must also specify option [q or Q]opt-prefetch.
The prefetch instruction is merely a hint and does not affect program behavior. If executed, this instruction
moves data closer to the processor and invalidates any other cached copy in anticipation of the line being
written to in the future.
IDE Equivalent
None
Alternate Options
None
181
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
qopt-prefetch/Qopt-prefetch compiler option
qopt-ra-region-strategy, Qopt-ra-region-strategy
Selects the method that the register allocator uses to
partition each routine into regions. This feature is only
available for ifort.
Syntax
Linux OS:
-qopt-ra-region-strategy[=keyword]
macOS:
-qopt-ra-region-strategy[=keyword]
Windows OS:
/Qopt-ra-region-strategy[:keyword]
Arguments
Default
Description
This option selects the method that the register allocator uses to partition each routine into regions.
When setting default is in effect, the compiler attempts to optimize the tradeoff between compile-time
performance and generated code performance.
This option is only relevant when optimizations are enabled (option O1 or higher).
IDE Equivalent
None
Alternate Options
None
182
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
O compiler option
qopt-streaming-stores, Qopt-streaming-stores
Enables generation of streaming stores for
optimization.
Syntax
Linux OS:
-qopt-streaming-stores=keyword
-qno-opt-streaming-stores
macOS:
-qopt-streaming-stores=keyword
-qno-opt-streaming-stores
Windows OS:
/Qopt-streaming-stores:keyword
/Qopt-streaming-stores-
Arguments
keyword Specifies whether streaming stores are generated. Possible values are:
Default
183
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables generation of streaming stores for optimization. This method stores data with
instructions that use a non-temporal buffer, which minimizes memory hierarchy pollution.
This option may be useful for applications that can benefit from streaming stores.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows one way to insert memory barriers (fences) when specifying
-qopt-streaming-stores=always or /Qopt-streaming-stores:always. It uses the procedure interface
for_sfence from the module IFCORE, which maps to the C/C++ function _mm_sfence:
!$omp parallel do
do j = 1, n1
a(j) = 1.0
b(j) = 2.0
c(j) = 3.0
enddo
!$omp end parallel do
call for_sfence()
!$omp parallel do
do i = 1, n2
a(i) = a(i) + b(i) * c(i)
enddo
!$omp end parallel do
end
See Also
ax, Qax compiler option
x, Qx compiler option
qopt-subscript-in-range, Qopt-subscript-in-range
Determines whether the compiler assumes that there
are no "large" integers being used or being computed
inside loops. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-subscript-in-range
-qno-opt-subscript-in-range
184
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-qopt-subscript-in-range
-qno-opt-subscript-in-range
Windows OS:
/Qopt-subscript-in-range
/Qopt-subscript-in-range-
Arguments
None
Default
-qno-opt-subscript-in-range The compiler assumes there are "large" integers being used or being
or /Qopt-subscript-in-range- computed within loops.
Description
This option determines whether the compiler assumes that there are no "large" integers being used or being
computed inside loops.
If you specify [q or Q]opt-subscript-in-range, the compiler assumes that there are no "large" integers
being used or being computed inside loops. A "large" integer is typically > 231.
This feature can enable more loop transformations.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how these options can be useful. Variable m is declared as type
integer(kind=8) (64-bits) and all other variables inside the subscript are declared as type integer(kind=4)
(32-bits):
A[ i + j + ( n + k) * m ]
qopt-zmm-usage, Qopt-zmm-usage
Defines a level of zmm registers usage.
Syntax
Linux OS:
-qopt-zmm-usage=keyword
macOS:
-qopt-zmm-usage=keyword
Windows OS:
/Qopt-zmm-usage:keyword
185
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
keyword Specifies the level of zmm registers usage. Possible values are:
Default
Description
This option may provide better code optimization for Intel® processors that are on the Intel®
microarchitecture formerly code-named Skylake.
This option defines a level of zmm registers usage. The low setting causes the compiler to generate code
with zmm registers very carefully, only when the gain from their usage is proven. The high setting causes
the compiler to use much less restrictive heuristics for zmm code generation.
It is not always easy to predict whether the high or the low setting will yield better performance. Programs
that enjoy high performance gains from the use of xmm or ymm registers may expect performance
improvement by moving to use zmm registers. However, some programs that use zmm registers may not
gain as much or may even lose performance. We recommend that you try both option values to measure the
performance of your programs.
This option is ignored if you do not specify an option that enables Intel® AVX-512, such as [Q]xCORE-AVX512
or option [Q]xCOMMON-AVX512.
This option has no effect on loops that use directive SIMD SIMDLEN(n) or on functions that are generated by
vector specifications specific to CORE-AVX512.
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
SIMD Directive (OpenMP* API) clause SIMDLEN
qoverride-limits, Qoverride-limits
Lets you override certain internal compiler limits that
are intended to prevent excessive memory usage or
compile times for very large, complex compilation
units. This feature is only available for ifort.
186
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qoverride-limits
macOS:
-qoverride-limits
Windows OS:
/Qoverride-limits
Arguments
None
Default
OFF Certain internal compiler limits are not overridden. These limits are determined by default
heuristics.
Description
This option provides a way to override certain internal compiler limits that are intended to prevent excessive
memory usage or compile times for very large, complex compilation units.
If this option is not used and your program exceeds one of these internal compiler limits, some optimizations
will be skipped to reduce the memory footprint and compile time. If you chose to create an optimization
report by specifying [q or Q]opt-report, you may see a related diagnostic remark as part of the report.
Specifying this option may substantially increase compile time and/or memory usage.
NOTE
If you use this option, it is your responsibility to ensure that sufficient memory is available.
If there is not sufficient available memory, the compilation may fail.
This option should only be used where there is a specific need; it is not recommended for
inexperienced users.
IDE Equivalent
None
Alternate Options
None
reentrancy
Tells the compiler to generate reentrant code to
support a multithreaded application.
Syntax
Linux OS:
-reentrancy keyword
-noreentrancy
187
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-reentrancy keyword
-noreentrancy
Windows OS:
/reentrancy:keyword
/noreentrancy
Arguments
none Tells the run-time library (RTL) that the program does not rely on
threaded or asynchronous reentrancy. The RTL will not guard against
such interrupts inside its own critical regions. This is the same as
specifying noreentrancy.
async Tells the run-time library (RTL) that the program may contain
asynchronous (AST) handlers that could call the RTL. This causes the
RTL to guard against AST interrupts inside its own critical regions.
threaded Tells the run-time library (RTL) that the program is multithreaded, such
as programs using the POSIX threads library. This causes the RTL to use
thread locking to guard its own critical regions.
Default
threaded The compiler tells the run-time library (RTL) that the program is multithreaded.
Description
This option tells the compiler to generate reentrant code to support a multithreaded application.
If you do not specify a keyword for reentrancy, it is the same as specifying reentrancy threaded.
To ensure that a threadsafe and/or reentrant run-time library is linked and correctly initialized, option
reentrancy threaded should also be used for the link step and for the compilation of the main routine.
Note that if option threads is specified, it sets option reentrancy threaded, since multithreaded code must
be reentrant.
IDE Equivalent
Windows
Visual Studio: Code Generation > Generate Reentrant Code
Alternate Options
None
See Also
threads compiler option
safe-cray-ptr, Qsafe-cray-ptr
Tells the compiler that Cray* pointers do not alias
other variables.
188
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-safe-cray-ptr
macOS:
-safe-cray-ptr
Windows OS:
/Qsafe-cray-ptr
Arguments
None
Default
OFF The compiler assumes that Cray pointers alias other variables.
Description
This option tells the compiler that Cray pointers do not alias (that is, do not specify sharing memory with)
other variables.
IDE Equivalent
Windows
Visual Studio: Data > Assume CRAY Pointers Do Not Share Memory Locations (/Qsafe-cray-ptr)
Alternate Options
None
Example
Consider the following:
pointer (pb, b)
pb = getstorage()
do i = 1, n
b(i) = a(i) + 1
enddo
By default, the compiler assumes that b and a are aliased. To prevent such an assumption, specify the
-safe-cray-ptr (Linux* and macOS) or /Qsafe-cray-ptr (Windows*) option, and the compiler will treat
b(i) and a(i) as independent of each other.
However, if the variables are intended to be aliased with Cray pointers, using the option produces incorrect
results. In the following example, you should not use the option:
pointer (pb, b)
pb = loc(a(2))
do i=1, n
b(i) = a(i) +1
enddo
189
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
scalar-rep, Qscalar-rep
Enables or disables the scalar replacement
optimization done by the compiler as part of loop
transformations. This feature is only available for ifort.
Syntax
Linux OS:
-scalar-rep
-no-scalar-rep
macOS:
-scalar-rep
-no-scalar-rep
Windows OS:
/Qscalar-rep
/Qscalar-rep-
Arguments
None
Default
Description
This option enables or disables the scalar replacement optimization done by the compiler as part of loop
transformations. This option takes effect only if you specify an optimization level of O2 or higher.
IDE Equivalent
None
Alternate Options
None
See Also
O compiler option
simd, Qsimd
Enables or disables compiler interpretation of SIMD
directives.This feature is only available for ifort.
Syntax
Linux OS:
-simd
-no-simd
macOS:
-simd
190
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-no-simd
Windows OS:
/Qsimd
/Qsimd-
Arguments
None
Default
Description
This option enables or disables compiler interpretation of SIMD directives.
To disable interpretation of SIMD directives, specify -no-simd (Linux* and macOS) or /Qsimd- (Windows*).
Note that the compiler may still vectorize loops based on its own heuristics (leading to generation of SIMD
instructions) even when -no-simd (or /Qsimd-) is specified.
To disable all compiler vectorization, use the "-no-vec -no-simd" (Linux* and macOS) or
"/Qvec- /Qsimd-" (Windows*) compiler options. The option -no-vec (and /Qvec-) disables all auto-
vectorization, including vectorization of array notation statements. The option -no-simd (and /Qsimd-)
disables vectorization of loops that have SIMD directives.
NOTE
If you specify option -mia32 (Linux*) or option /arch:IA32 (Windows*), SIMD directives are
disabled by default and vector instructions cannot be used. Therefore, you cannot explicitly
enable SIMD directives by specifying option [Q]simd.
IDE Equivalent
None
Alternate Options
None
See Also
vec, Qvec compiler option
SIMD Directive
unroll, Qunroll
Tells the compiler the maximum number of times to
unroll loops.
Syntax
Linux OS:
-unroll[=n]
macOS:
-unroll[=n]
191
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qunroll[:n]
Arguments
n Is the maximum number of times a loop can be unrolled. To disable loop enrolling, specify 0.
Default
Description
This option tells the compiler the maximum number of times to unroll loops.
If you do not specify n, the optimizer determines how many times loops can be unrolled.
IDE Equivalent
Windows
Visual Studio: Optimization > Loop Unroll Count
Alternate Options
Linux and macOS: -funroll-loops
unroll-aggressive, Qunroll-aggressive
Determines whether the compiler uses more
aggressive unrolling for certain loops. This feature is
only available for ifort.
Syntax
Linux OS:
-unroll-aggressive
-no-unroll-aggressive
macOS:
-unroll-aggressive
-no-unroll-aggressive
Windows OS:
/Qunroll-aggressive
/Qunroll-aggressive-
Arguments
None
Default
192
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
or /Qunroll-aggressive-
Description
This option determines whether the compiler uses more aggressive unrolling for certain loops. The positive
form of the option may improve performance.
This option enables aggressive, complete unrolling for loops with small constant trip counts.
IDE Equivalent
None
Alternate Options
None
vec, Qvec
Enables or disables vectorization.
Syntax
Linux OS:
-vec
-no-vec
macOS:
-vec
-no-vec
Windows OS:
/Qvec
/Qvec-
Arguments
None
Default
Description
This option enables or disables vectorization.
To disable vectorization, specify -no-vec (Linux* and macOS) or /Qvec- (Windows*).
To disable interpretation of SIMD directives, specify -no-simd (Linux* and macOS) or /Qsimd- (Windows*).
To disable all compiler vectorization, use the "-no-vec -no-simd" (Linux* and macOS) or
"/Qvec- /Qsimd-" (Windows*) compiler options. The option -no-vec (and /Qvec-) disables all auto-
vectorization, including vectorization of array notation statements. The option -no-simd (and /Qsimd-)
disables vectorization of loops that have SIMD directives.
193
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Using this option enables vectorization at default optimization levels for both Intel®
microprocessors and non-Intel microprocessors. Vectorization may call library routines that
can result in additional performance gain on Intel microprocessors than on non-Intel
microprocessors. The vectorization can also be affected by certain options, such as /arch
(Windows), -m (Linux and macOS), or [Q]x.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
simd, Qsimd compiler option
ax, Qax compiler option
x, Qx compiler option
vec-guard-write, Qvec-guard-write compiler option
vec-threshold, Qvec-threshold compiler option
vec-guard-write, Qvec-guard-write
Tells the compiler to perform a conditional check in a
vectorized loop. This feature is only available for ifort.
Syntax
Linux OS:
-vec-guard-write
-no-vec-guard-write
macOS:
-vec-guard-write
-no-vec-guard-write
Windows OS:
/Qvec-guard-write
/Qvec-guard-write-
Arguments
None
Default
194
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
or /Qvec-guard-write
Description
This option tells the compiler to perform a conditional check in a vectorized loop. This checking avoids
unnecessary stores and may improve performance.
IDE Equivalent
None
Alternate Options
None
vec-threshold, Qvec-threshold
Sets a threshold for the vectorization of loops.
Syntax
Linux OS:
-vec-threshold[n]
macOS:
-vec-threshold[n]
Windows OS:
/Qvec-threshold[[:]n]
Arguments
Default
Description
This option sets a threshold for the vectorization of loops based on the probability of profitable execution of
the vectorized loop in parallel.
This option is useful for loops whose computation work volume cannot be determined at compile-time. The
threshold is usually relevant when the loop trip count is unknown at compile-time.
195
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The compiler applies a heuristic that tries to balance the overhead of creating multiple threads versus the
amount of work available to be shared amongst the threads.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Windows
Visual Studio: Optimization > Threshold For Vectorization
Alternate Options
None
vecabi, Qvecabi
Determines which vector function application binary
interface (ABI) the compiler uses to create or call
vector functions. This feature is only available for ifort.
Syntax
Linux OS:
-vecabi=keyword
macOS:
-vecabi=keyword
Windows OS:
/Qvecabi:keyword
Arguments
keyword Specifies which vector function ABI to use. Possible values are:
gcc Tells the compiler to use the gcc vector function ABI.
Use this setting only in cases when you want to link
with modules compiled by gcc. This setting is not
available on Windows* systems.
196
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
legacy Tells the compiler to use the legacy vector function ABI.
Use this setting if you need to keep the generated
vector function binary backward compatible with the
vectorized binary generated by older versions of the
Intel® compilers (V13.1 or older).
Default
Description
This option determines which vector function application binary interface (ABI) the compiler uses to create or
call vector functions.
NOTE
To avoid possible link-time and runtime errors, use identical [Q]vecabi settings when
compiling all files in an application that define or use vector functions, including libraries. If
setting cmdtarget is specified, options [Q]x and/or [Q]ax must have identical values.
Be careful using setting cmdtarget with libraries or program modules/routines with vector function
definitions that cannot be recompiled. In such cases, setting cmdtarget may cause link errors.
On Linux* systems, since the default is compat, you must specify legacy if you need to keep the generated
vector function binary backward compatible with the vectorized binary generated by the previous version of
Intel® compilers.
When cmdtarget is specified, the additional vector function versions are created by copying each vector
specification and changing target processor in the copy. The number of vector functions is determined by the
settings specified in options [Q]x and/or [Q]ax.
interface
integer function foo(a)
!dir$ attributes vector:(processor(core_2_duo_sse4_1)) :: foo
integer a
end function
end interface
and the following options are specified: -axAVX,CORE-AVX2
The following table shows the different results for the above declaration and option specifications when
setting compat or setting cmdtarget is used:
compat cmdtarget
One vector version is created for Intel® SSE4.1 (by Four vector versions are created for the following
vector function specification). targets:
• Intel® SSE2 (default because no -x option is
used)
• Intel® SSE4.1 (by vector function specification)
• Intel® AVX (by the first -ax option value)
• Intel® AVX2 (by the second -ax option value)
197
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For more information about the Intel®-compatible vector functions ABI, see the downloadable PDF titled
Vector Function Application Binary Interface.
For more information about the GCC vector functions ABI, see the item Libmvec - vector math library
document in the GLIBC wiki at sourceware.org.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
finstrument-functions, Qinstrument-functions
Determines whether routine entry and exit points are
instrumented.
Syntax
Linux OS:
-finstrument-functions
-fno-instrument-functions
macOS:
-finstrument-functions
-fno-instrument-functions
Windows OS:
/Qinstrument-functions
/Qinstrument-functions-
Arguments
None
Default
Description
This option determines whether routine entry and exit points are instrumented. It may increase execution
time.
198
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following profiling functions are called with the address of the current routine and the address of where
the routine was called (its "call site"):
IDE Equivalent
None
Alternate Options
None
fnsplit, Qfnsplit
Enables function splitting. This feature is only
available for ifort.
Syntax
Linux OS:
-fnsplit[=n]
-no-fnsplit
macOS:
None
Windows OS:
/Qfnsplit[:n]
/Qfnsplit-
Arguments
199
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables function splitting. If you specify [Q]fnsplit with no n, you must also specify option
[Q]prof-use, or the option will have no effect and no function splitting will occur.
If you specify n, function splitting is enabled and you do not need to specify option [Q]prof-use.
To disable function splitting when you use option [Q]prof-use, specify /Qfnsplit- (Windows*) or
-no-fnsplit (Linux*).
NOTE
Function splitting is generally not supported when exception handling is turned on for C/C+
+ routines in the stack of called routines. See also -fexceptions (Linux*).
IDE Equivalent
None
Alternate Options
Linux: -freorder-blocks-and-partition (a gcc option)
Windows: None
p
Compiles and links for function profiling with gprof(1).
This feature is only available for ifort.
Syntax
Linux OS:
-p
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option compiles and links for function profiling with gprof(1).
When you specify this option, inlining is disabled. However, you can override this by specifying directive
FORCEINLINE, or a compiler option such as [Q]inline-forceinline.
200
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
Linux and macOS: -pg,-qp (this is a deprecated option)
Windows: None
prof-data-order, Qprof-data-order
Enables or disables data ordering if profiling
information is enabled. This feature is only available
for ifort.
Syntax
Linux OS:
-prof-data-order
-no-prof-data-order
macOS:
None
Windows OS:
/Qprof-data-order
/Qprof-data-order-
Arguments
None
Default
Description
This option enables or disables data ordering if profiling information is enabled. It controls the use of profiling
information to order static program data items.
For this option to be effective, you must do the following:
• For instrumentation compilation, you must specify option [Q]prof-gen setting globdata.
• For feedback compilation, you must specify the [Q]prof-use option. You must not use multi-file
optimization by specifying options such as [Q]ipo or [Q]ipo-c.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
201
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
prof-dir, Qprof-dir
Specifies a directory for profiling information output
files. This feature is only available for ifort.
Syntax
Linux OS:
-prof-dir dir
macOS:
-prof-dir dir
Windows OS:
/Qprof-dir:dir
Arguments
dir Is the name of the directory. You can specify a relative pathname or
an absolute pathname.
Default
OFF Profiling output files are placed in the directory where the program is compiled.
Description
This option specifies a directory for profiling information output files (*.dyn and *.dpi). The specified
directory must already exist.
You should specify this option using the same directory name for both instrumentation and feedback
compilations. If you move the .dyn files, you need to specify the new path.
Option /Qprof-dir is equivalent to option /Qcov-dir. If you specify both options, the last option specified
on the command line takes precedence.
IDE Equivalent
Windows
Visual Studio: Output Files > Profile Directory
Alternate Options
None
prof-file, Qprof-file
Specifies an alternate file name for the profiling
summary files. This feature is only available for ifort.
Syntax
Linux OS:
-prof-file filename
macOS:
-prof-file filename
202
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qprof-file:filename
Arguments
Default
OFF The profiling summary files have the file name pgopti.*
Description
This option specifies an alternate file name for the profiling summary files. The filename is used as the base
name for files created by different profiling passes.
If you add this option to profmerge, the .dpi file will be named filename.dpi instead of pgopti.dpi.
If you specify this option with option [Q]prof-use, the .dpi file will be named filename.dpi instead of
pgopti.dpi.
Option /Qprof-file is equivalent to option /Qcov-file. If you specify both options, the last option
specified on the command line takes precedence.
NOTE
When you use option [Q]prof-file, you can only specify a file name. If you want to specify
a path (relative or absolute) for filename, you must also use option [Q]prof-dir.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-dir, Qprof-dir compiler option
prof-func-groups
Enables or disables function grouping if profiling
information is enabled. This feature is only available
for ifort.
Syntax
Linux OS:
-prof-func-groups
-no-prof-func-groups
macOS:
None
203
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
None
Arguments
None
Default
Description
This option enables or disables function grouping if profiling information is enabled.
A "function grouping" is a profiling optimization in which entire routines are placed either in the cold code
section or the hot code section.
If profiling information is enabled by option -prof-use, option -prof-func-groups is set and function
grouping is enabled. However, if you explicitly enable -prof-func-order, function ordering is performed
instead of function grouping.
If you want to disable function grouping when profiling information is enabled, specify
-no-prof-func-groups.
To set the hotness threshold for function grouping, use option -prof-hotness-threshold.
IDE Equivalent
None
See Also
prof-use, Qprof-use compiler option
prof-func-order, Qprof-func-order
compiler option
prof-hotness-threshold, Qprof-hotness-threshold
compiler option
prof-func-order, Qprof-func-order
Enables or disables function ordering if profiling
information is enabled. This feature is only available
for ifort.
Syntax
Linux OS:
-prof-func-order
-no-prof-func-order
macOS:
None
Windows OS:
/Qprof-func-order
/Qprof-func-order-
204
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
Description
This option enables or disables function ordering if profiling information is enabled.
For this option to be effective, you must do the following:
• For instrumentation compilation, you must specify option [Q]prof-gen setting srcpos.
• For feedback compilation, you must specify [Q]prof-use. You must not use multi-file optimization by
specifying options such as [Q]ipo or [Q]ipo-c.
If you enable profiling information by specifying option [Q]prof-use, option [Q]prof-func-groups is set
and function grouping is enabled. However, if you explicitly enable the [Q]prof-func-order option, function
ordering is performed instead of function grouping.
On Linux* systems, this option is only available for Linux linker 2.15.94.0.1, or higher.
To set the hotness threshold for function grouping and function ordering, use option
[Q]prof-hotness-threshold.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to use this option on a Windows system:
See Also
prof-hotness-threshold, Qprof-hotness-threshold compiler option
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-data-order, Qprof-data-order compiler option
prof-func-groups compiler option
prof-gen, Qprof-gen
Produces an instrumented object file that can be used
in profile guided optimization. This feature is only
available for ifort.
205
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-prof-gen[=keyword[, keyword],...]
-no-prof-gen
macOS:
-prof-gen[=keyword[, keyword],...]
-no-prof-gen
Windows OS:
/Qprof-gen[:keyword[,keyword],...]
/Qprof-gen-
Arguments
keyword Specifies details for the instrumented file. Possible values are:
Default
Description
This option produces an instrumented object file that can be used in profile guided optimization. It gets the
execution count of each basic block.
You can specify more than one setting for [Q]prof-gen. For example, you can specify the following:
206
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When the [Q]prof-gen option is used to produce an instrumented binary file for profile generation, some
optimizations are disabled. Those optimizations are not disabled for any subsequent profile-guided
compilation with option [Q]prof-use that makes use of the generated profiles.
IDE Equivalent
None
Alternate Options
None
See Also
prof-use, Qprof-use compiler option
Profile an Application with Instrumentation
prof-gen-sampling
Tells the compiler to generate debug discriminators in
debug output. This aids in developing more precise
sampled profiling output. This is a deprecated option
that may be removed in a future release. This feature
is only available for ifort.
Syntax
Linux OS:
-prof-gen-sampling
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF The compiler does not generate debug discriminators in the debug
output.
Description
This option tells the compiler to generate debug discriminators in debug output. Debug discriminators are
used to distinguish code from different basic blocks that have the same source position information. This aids
in developing more precise sampled hardware profiling output.
This is a deprecated option that may be removed in a future release. There is no replacement option.
To build an executable suitable for generating hardware profiled sampled output, compile with the following
options:
-prof-gen-sampling -g
To use the data files produced by hardware profiling, compile with option -prof-use-sampling.
IDE Equivalent
None
207
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
prof-use-sampling compiler option
g compiler option
Profile an Application with Instrumentation
prof-hotness-threshold, Qprof-hotness-threshold
Lets you set the hotness threshold for function
grouping and function ordering. This feature is only
available for ifort.
Syntax
Linux OS:
-prof-hotness-threshold=n
macOS:
None
Windows OS:
/Qprof-hotness-threshold:n
Arguments
Default
OFF The compiler's default hotness threshold setting of 10 percent is in effect for function
grouping and function ordering.
Description
This option lets you set the hotness threshold for function grouping and function ordering.
The "hotness threshold" is the percentage of functions in the application that should be placed in the
application's hot region. The hot region is the most frequently executed part of the application. By grouping
these functions together into one hot region, they have a greater probability of remaining resident in the
instruction cache. This can enhance the application's performance.
For this option to take effect, you must specify option [Q]prof-use and one of the following:
IDE Equivalent
None
Alternate Options
None
208
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
prof-use, Qprof-use compiler option
prof-func-groups compiler option
prof-func-order, Qprof-func-order compiler option
prof-src-dir, Qprof-src-dir
Determines whether directory information of the
source file under compilation is considered when
looking up profile data records. This feature is only
available for ifort.
Syntax
Linux OS:
-prof-src-dir
-no-prof-src-dir
macOS:
-prof-src-dir
-no-prof-src-dir
Windows OS:
/Qprof-src-dir
/Qprof-src-dir-
Arguments
None
Default
Description
This option determines whether directory information of the source file under compilation is considered when
looking up profile data records in the .dpi file. To use this option, you must also specify the [Q]prof-use
option.
If the option is enabled, directory information is considered when looking up the profile data records within
the .dpi file. You can specify directory information by using one of the following options:
IDE Equivalent
None
209
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
prof-use, Qprof-use compiler option
prof-src-root, Qprof-src-root compiler option
prof-src-root-cwd, Qprof-src-root-cwd compiler option
prof-src-root, Qprof-src-root
Lets you use relative directory paths when looking up
profile data and specifies a directory as the base. This
feature is only available for ifort.
Syntax
Linux OS:
-prof-src-root=dir
macOS:
-prof-src-root=dir
Windows OS:
/Qprof-src-root:dir
Arguments
Default
OFF The setting of relevant options determines the path used when looking up profile data records.
Description
This option lets you use relative directory paths when looking up profile data in .dpi files. It lets you specify a
directory as the base. The paths are relative to a base directory specified during the [Q]prof-gen
compilation phase.
This option is available during the following phases of compilation:
To be effective, this option or option [Q]prof-src-root-cwd must be specified during the [Q]prof-gen
phase. In addition, if one of these options is not specified, absolute paths are used in the .dpi file.
IDE Equivalent
None
210
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
Example
Consider the initial [Q]prof-gen compilation of the source file c:\user1\feature_foo\myproject\common
\glob.f90 shown below:
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-src-dir, Qprof-src-dir compiler option
prof-src-root-cwd, Qprof-src-root-cwd compiler option
prof-src-root-cwd, Qprof-src-root-cwd
Lets you use relative directory paths when looking up
profile data and specifies the current working directory
as the base. This feature is only available for ifort.
Syntax
Linux OS:
-prof-src-root-cwd
macOS:
-prof-src-root-cwd
Windows OS:
/Qprof-src-root-cwd
Arguments
None
Default
OFF The setting of relevant options determines the path used when looking up profile data records.
211
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option lets you use relative directory paths when looking up profile data in .dpi files. It specifies the
current working directory as the base. To use this option, you must also specify option [Q]prof-use.
To be effective, this option or option [Q]prof-src-root must be specified during the [Q]prof-gen phase.
In addition, if one of these options is not specified, absolute paths are used in the .dpi file.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
prof-src-dir, Qprof-src-dir compiler option
prof-src-root, Qprof-src-root compiler option
prof-use, Qprof-use
Enables the use of profiling information during
optimization. This feature is only available for ifort.
Syntax
Linux OS:
-prof-use[=keyword]
-no-prof-use
macOS:
-prof-use[=keyword]
-no-prof-use
Windows OS:
/Qprof-use[:keyword]
/Qprof-use-
Arguments
212
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables the use of profiling information (including function splitting and function grouping) during
optimization. It enables option /Qfnsplit (Windows*) and -fnsplit (Linux* and macOS) .
This option instructs the compiler to produce a profile-optimized executable and it merges available profiling
output files into a pgopti.dpi file.
Note that there is no way to turn off function grouping if you enable it using this option.
To set the hotness threshold for function grouping and function ordering, use option
[Q]prof-hotness-threshold.
IDE Equivalent
None
Alternate Options
None
See Also
prof-hotness-threshold, Qprof-hotness-threshold compiler option
prof-gen, Qprof-gen compiler option
Profile an Application with Instrumentation
prof-use-sampling
Lets you use data files produced by hardware profiling
to produce an optimized executable. This is a
deprecated option that may be removed in a future
release. This feature is only available for ifort.
213
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-prof-use-sampling=list
macOS:
None
Windows OS:
None
Arguments
list Is a list of one or more data files. If you specify more than one data
file, they must be separated by colons.
Default
OFF Data files produced by hardware profiling will not be used to produce
an optimized executable.
Description
This option lets you use data files produced by hardware profiling to produce an optimized executable.
This is a deprecated option that may be removed in a future release. There is no replacement option.
The data files are named and produced by using Intel® VTune™.
The executable should have been produced using the following options:
-prof-gen-sampling -g
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen-sampling compiler option
Profile an Application with Instrumentation
prof-value-profiling, Qprof-value-profiling
Controls which values are value profiled. This feature
is only available for ifort.
Syntax
Linux OS:
-prof-value-profiling[=keyword]
macOS:
-prof-value-profiling[=keyword]
Windows OS:
/Qprof-value-profiling[:keyword]
214
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
keyword Controls which type of value profiling is performed. Possible values are:
You can specify more than one keyword, but they must be separated by commas.
Default
all All value profile types are enabled and value profiling is performed.
Description
This option controls which features are value profiled.
If this option is specified with option [Q]prof-gen, it turns off instrumentation of operations of the specified
type. This also prevents feedback of values for the operations.
If this option is specified with option [Q]prof-use, it turns off feedback of values collected of the specified
type.
If you specify level 2 or higher for option[q or Q]opt-report, the value profiling specialization information
will be reported within the PGO optimization report.
IDE Equivalent
None
Alternate Options
None
See Also
prof-gen, Qprof-gen compiler option
prof-use, Qprof-use compiler option
qopt-report, Qopt-report compiler option (ifort)
Qcov-dir
Specifies a directory for profiling information output
files that can be used with the codecov or tselect tool.
This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qcov-dir:dir
215
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
Default
OFF Profiling output files are placed in the directory where the program is compiled.
Description
This option specifies a directory for profiling information output files (*.dyn and *.dpi) that can be used with
the code-coverage tool (codecov) or the test prioritization tool (tselect). The specified directory must already
exist.
You should specify this option using the same directory name for both instrumentation and feedback
compilations. If you move the .dyn files, you need to specify the new path.
Option /Qcov-dir is equivalent to option /Qprof-dir. If you specify both options, the last option specified
on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
See Also
Qcov-gen compiler option
Qcov-file compiler option
Qcov-file
Specifies an alternate file name for the profiling
summary files that can be used with the codecov or
tselect tool. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qcov-file:filename
Arguments
Default
OFF The profiling summary files have the file name pgopti.*.
216
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option specifies an alternate file name for the profiling summary files. The file name can be used with
the code-coverage tool (codecov) or the test prioritization tool (tselect).
The filename is used as the base name for the set of files created by different profiling passes.
If you specify this option with option /Qcov-gen, the .spi and .spl files will be named filename.spi and
filename.spl instead of pgopti.spi and pgopti.spl.
Option /Qcov-file is equivalent to option /Qprof-file. If you specify both options, the last option
specified on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
See Also
Qcov-gen compiler option
Qcov-dir compiler option
Qcov-gen
Produces an instrumented object file that can be used
with the codecov or tselect tool. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qcov-gen
/Qcov-gen-
Arguments
None
Default
Description
This option produces an instrumented object file that can be used with the code-coverage tool (codecov) or
the test prioritization tool (tselect). The instrumented code is included in the object file in preparation for
instrumented execution.
This option also creates a static profile information file (.spi) that can be used with the codecov or tselect
tool.
217
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option /Qcov-gen should be used to minimize the instrumentation overhead if you are interested in using
the instrumentation only for code coverage. You should use /Qprof-gen:srcpos if you intend to use the
collected data for code coverage and profile feedback.
IDE Equivalent
None
Alternate Options
None
See Also
Qcov-dir compiler option
Qcov-file compiler option
Syntax
Linux OS:
-qopt-report[=n]
macOS:
-qopt-report[=n]
Windows OS:
/Qopt-report[:n]
Arguments
n (Optional) Indicates the level of detail in the report. You can specify
values 0 through 5.
If you specify zero, no report is generated.
For levels n=1 through n=5, each level includes all the information of
the previous level, as well as potentially some additional information.
Level 5 produces the greatest level of detail. If you do not specify n,
the default is level 2, which produces a medium level of detail.
Default
Description
This option tells the compiler to generate a collection of optimization report files, one per object; this is the
same output produced by option [q or Q]opt-report-per-object.
If you prefer another form of output, you can specify option [q or Q]opt-report-file.
218
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify a level (n) higher than 5, a warning will be displayed and you will get a level 5 report.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* or macOS)
or /Qopt-report-phase:all (Windows*).
For a description of the information that each n level provides, see the Example section in option
[q or Q]opt-report-phase.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Optimization Diagnostic Level
Alternate Options
None
Example
If you only want reports about certain diagnostics, you can use this option with option
[q or Q]opt-report-phase. The phase you specify determines which diagnostics you will receive.
For example, the following examples show how to get reports about certain specific diagnostics.
See Also
qopt-report-file, Qopt-report-file compiler option
qopt-report-per-object, Qopt-report-per-object compiler option
qopt-report-phase, Qopt-report-phase compiler option
Syntax
Linux OS:
-qopt-report[=arg]
219
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qopt-report[=arg]
Arguments
arg Determines the level of detail in the report. Possible values are:
2 or med Tells the compiler to create a report with medium details. This is the
default if you do not specify arg.
Levels 1, 2, and 3 (min, med, and max) include all the information of the previous level, as
well as potentially some additional information.
Default
Description
This option enables the generation of a YAML file that includes optimization transformation information.
The YAML-formatted file provides the optimization information for the source file being compiled. For
example:
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report-file, Qopt-report-file compiler option
220
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-report-annotate, Qopt-report-annotate
Enables the annotated source listing feature and
specifies its format. This feature is only available for
ifort.
Syntax
Linux OS:
-qopt-report-annotate[=keyword]
macOS:
-qopt-report-annotate[=keyword]
Windows OS:
/Qopt-report-annotate[:keyword]
Arguments
keyword Specifies the format for the annotated source listing. You can specify one of the following:
text Indicates that the listing should be in text format. This is the default if you do not
specify keyword.
Default
Description
This option enables the annotated source listing feature and specifies its format. The feature annotates
source files with compiler optimization reports.
By default, one annotated source file is output per object. The annotated file is written to the same directory
where the object files are generated. If the object file is a temporary file and an executable is generated,
annotated files are placed in the directory where the executable is placed. You cannot generate annotated
files to a directory of your choosing.
However, you can output annotated listings to stdout, stderr, or to a file if you also specify option
[q or Q]opt-report-file.
By default, this option sets option [q or Q]opt-report with default level 2.
The following shows the file extension and listing details for the two possible keywords.
text The annotated source listing has an .annot extension. It includes line numbers and
compiler diagnostics placed after correspondent lines. IPO footnotes are inserted at
the end of annotated file.
html The annotated source listing has an .annot.html extension. It includes line numbers
and compiler diagnostics placed after correspondent lines (as the text format does).
It also provides hyperlinks in compiler messages and quick navigation with the
routine list. IPO footnotes are displayed as tooltips.
221
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report-file, Qopt-report-file compiler option
qopt-report-annotate-position, Qopt-report-annotate-position compiler option
qopt-report-annotate-position, Qopt-report-annotate-position
Enables the annotated source listing feature and
specifies the site where optimization messages appear
in the annotated source in inlined cases of loop
optimizations. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-annotate-position=keyword
macOS:
-qopt-report-annotate-position=keyword
Windows OS:
/Qopt-report-annotate-position:keyword
Arguments
keyword Specifies the site where optimization messages appear in the annotated source. You can specify
one of the following:
caller Indicates that the messages should appear in the caller site.
callee Indicates that the messages should appear in the callee site.
both Indicates that the messages should appear in both the caller and the callee sites.
Default
Description
This option enables the annotated source listing feature and specifies the site where optimization messages
appear in the annotated source in inlined cases of loop optimizations.
This option enables option [q or Q]opt-report-annotate if it is not explicitly specified.
If annotated source listing is enabled and this option is not passed to compiler, loop optimizations are placed
in caller position by default.
IDE Equivalent
None
222
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report-annotate, Qopt-report-annotate compiler option
qopt-report-embed, Qopt-report-embed
Determines whether special loop information
annotations will be embedded in the object file and/or
the assembly file when it is generated. This feature is
only available for ifort.
Syntax
Linux OS:
-qopt-report-embed
-qno-opt-report-embed
macOS:
-qopt-report-embed
-qno-opt-report-embed
Windows OS:
/Qopt-report-embed
/Qopt-report-embed-
Arguments
None
Default
OFF When an assembly file is being generated, special loop information annotations will not be
embedded in the assembly file.
However, if option -g (Linux* and macOS) or /Zi (Windows*) is specified, special loop
information annotations will be embedded in the assembly file unless option
-qno-opt-report-embed (Linux and macOS) or /Qopt-report-embed- (Windows) is specified.
Description
This option determines whether special loop information annotations will be embedded in the object file
and/or the assembly file when it is generated. Specify the positive form of the option to include the
annotations in the assembly file.
If an object file (or executable) is being generated, the annotations will be embedded in the object file (or
executable).
If you use this option, you do not have to specify option [q or Q]opt-report.
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
223
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
qopt-report-file, Qopt-report-file
Specifies whether the output for the generated
optimization report goes to a file, stderr, or stdout.
Syntax
Linux OS:
-qopt-report-file=keyword
macOS:
-qopt-report-file=keyword
Windows OS:
/Qopt-report-file:keyword
Arguments
keyword Specifies where the output for the report goes. You can specify one of the following:
filename Specifies the name of the file where the generated report should go.
Default
Description
This option specifies whether the output for the generated optimization report goes to a file, stderr, or stdout.
If you use this option, you do not have to specify option [q or Q]opt-report.
When optimization reporting is enabled on ifort, the default is -qopt-report-phase=all (Linux* and
macOS) or /Qopt-report-phase:all (Windows*).
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Emit Optimization Diagnostics to File
Diagnostics > Optimization Diagnostic File
Alternate Options
None
224
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report, Qopt-report compiler option (ifx)
qopt-report-filter, Qopt-report-filter
Tells the compiler to find the indicated parts of your
application, and generate optimization reports for
those parts of your application. This feature is only
available for ifort.
Syntax
Linux OS:
-qopt-report-filter=string
macOS:
-qopt-report-filter=string
Windows OS:
/Qopt-report-filter:string
Arguments
string Is the information to search for. The string must appear within quotes. It can take one or
more of the following forms:
filename
filename, routine
filename, range [, range]...
filename, routine, range [, range]...
If you specify more than one of the above forms in a string, a semicolon must appear
between each form. If you specify more than one range in a string, a comma must appear
between each range. Optional blanks can follow each parameter in the forms above and
they can also follow each form in a string.
225
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
first_line_number-last_line_number
The hyphen between the line numbers is required.
Default
Description
This option tells the compiler to find the indicated parts of your application, and generate optimization
reports for those parts of your application. Optimization reports will only be generated for the routines that
contain the specified string.
On Linux* and macOS, if you specify both -qopt-report-routine=string1 and
-qopt-report-filter=string2, it is treated as -qopt-report-filter=string1;string2. On
Windows*, if you specify both /Qopt-report-routine:string1 and /Qopt-report-filter:string2, it is
treated as/Qopt-report-filter:string1;string2.
If you use this option, you do not have to specify option [q or Q]opt-report.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report-format, Qopt-report-format
Specifies the format for an optimization report. This
feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-format=keyword
macOS:
-qopt-report-format=keyword
Windows OS:
/Qopt-report-format:keyword
Arguments
keyword Specifies the format for the report. You can specify one of the following:
226
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
vs Indicates that the report should be in Visual Studio* (IDE) format. The Visual Studio
IDE uses the information to visualize the optimization report in the context of your
program source code.
Default
Description
This option specifies the format for an optimization report. If you use this option, you must specify either
text or vs.
If you do not specify this option and another option causes an optimization report to be generated, the
default format is text.
If the [q or Q]opt-report-file option is also specified, it will affect where the output goes:
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report-file, Qopt-report-file compiler option
qopt-report-help, Qopt-report-help
Displays the optimizer phases available for report
generation and a short description of what is reported
at each level. This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-help
Windows OS:
/Qopt-report-help
Arguments
None
227
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option displays the optimizer phases available for report generation using [q or Q]opt-report-phase,
and a short description of what is reported at each level. No compilation is performed.
To indicate where output should go, you can specify one of the following options:
• [q or Q]opt-report-file
• [q or Q]opt-report-per-object
If you use this option, you do not have to specify option [q or Q]opt-report.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report-phase, Qopt-report-phase compiler option
qopt-report-file, Qopt-report-file compiler option
qopt-report-per-object, Qopt-report-per-object compiler option
qopt-report-names, Qopt-report-names
Specifies whether mangled or unmangled names
should appear in the optimization report. This feature
is only available for ifort.
Syntax
Linux OS:
-qopt-report-names=keyword
macOS:
-qopt-report-names=keyword
Windows OS:
/Qopt-report-names:keyword
Arguments
keyword Specifies the form for the names. You can specify one of the following:
228
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option specifies whether mangled or unmangled names should appear in the optimization report. If you
use this option, you must specify either mangled or unmangled.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
None
Alternate Options
None
qopt-report-per-object, Qopt-report-per-object
Tells the compiler that optimization report information
should be generated in a separate file for each object.
This feature is only available for ifort.
Syntax
Linux OS:
-qopt-report-per-object
macOS:
-qopt-report-per-object
Windows OS:
/Qopt-report-per-object
Arguments
None
Default
Description
This option tells the compiler that optimization report information should be generated in a separate file for
each object.
229
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify this option for a single-file compilation, a file with a .optrpt extension is produced for every
object file or assembly file that is generated by the compiler. For a multifile Interprocedural Optimization
(IPO) compilation, one file is produced for each of the N true objects generated in the compilation. If only
one true object file is generated, the optimization report file generated is called ipo_out.optrpt. If multiple
true object files are generated (N>1), the names used are ipo_out1.optprt, ipo_out2.optrpt, …
ipo_outN.optrpt.
The .optrpt files are written to the target directory of the compilation process. If an object or assembly file is
explicitly generated, the corresponding .optrpt file is written to the same directory where the object file is
generated. If the object file is just a temporary file and an executable is generated, the corresponding .optrpt
files are placed in the directory in which the executable is placed.
If you use this option, you do not have to specify option [q or Q]opt-report.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option
qopt-report-phase, Qopt-report-phase
Specifies one or more optimizer phases for which
optimization reports are generated. This feature is
only available for ifort.
Syntax
Linux OS:
-qopt-report-phase[=list]
macOS:
-qopt-report-phase[=list]
Windows OS:
/Qopt-report-phase[:list]
Arguments
list (Optional) Specifies one or more phases to generate reports for. If you
specify more than one phase, they must be separated with commas.
The values you can specify are:
230
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option specifies one or more optimizer phases for which optimization reports are generated.
For certain phases, you also need to specify other options:
• If you specify phase cg, you must also specify option O1, O2 (default), or O3.
• If you specify phase ipo, you must also specify option [Q]ipo.
• If you specify phase loop, you must also specify option O2 (default) or O3.
• If you specify phase openmp, you must also specify option [q or Q]openmp.
• If you specify phase par, you must also specify option [Q]parallel.
• If you specify phase pgo, you must also specify option [Q]prof-use.
• If you specify phase tcollect, you must also specify option [Q]tcollect.
• If you specify phase vec, you must also specify option O2 (default) or O3. If you are interested in explicit
vectorization by OpenMP* SIMD, you must also specify option [q or Q]openmp.
If you use this option, you do not have to specify option [q or Q]opt-report.
However, if you want to get more details for each phase, specify option [q or Q]opt-report=n along with
this option and indicate the level of detail you want by specifying an appropriate value for n. (See also the
Example section below.)
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* or macOS)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Optimization Diagnostic Phase
Alternate Options
None
Example
The following shows examples of the details you may receive when you specify one of the optimizer phases
and a particular level (n) for option [q or Q]opt-report. Note that details may change in future releases.
231
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
232
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
233
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
qopt-report, Qopt-report compiler option (ifort)
qopt-report-help, Qopt-report-help compiler option
qopt-report-routine, Qopt-report-routine
Tells the compiler to generate an optimization report
for each of the routines whose names contain the
specified substring. This feature is only available for
ifort.
Syntax
Linux OS:
-qopt-report-routine=substring
macOS:
-qopt-report-routine=substring
Windows OS:
/Qopt-report-routine:substring
Arguments
Default
Description
This option tells the compiler to generate an optimization report for each of the routines whose names
contain the specified substring.
You can also specify a sequence of substrings separated by commas. If you do this, the compiler will
generate an optimization report for each of the routines whose name contains one or more of these
substrings.
234
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you use this option, you do not have to specify option [q or Q]opt-report.
When optimization reporting is enabled, the default is -qopt-report-phase=all (Linux* and macOS)
or /Qopt-report-phase:all (Windows*).
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Optimization Diagnostic Routine
Alternate Options
None
tcollect, Qtcollect
Inserts instrumentation probes calling the Intel® Trace
Collector API. This feature is only available for ifort.
Syntax
Linux OS:
-tcollect[lib]
macOS:
None
Windows OS:
/Qtcollect[:lib]
Arguments
lib Is one of the Intel® Trace Collector libraries; for example, VT, VTcs,
VTmc, or VTfs. If you do not specify lib, the default library is VT.
Default
Description
This option inserts instrumentation probes calling the Intel® Trace Collector API.
This trace analyzing/collecting feature requires installation of another product. For more information, see the
Feature Requirements section.
This option provides a flexible and convenient way of instrumenting functions of a compiled application. For
every function, the entry and exit points are instrumented at compile time to let the Intel® Trace Collector
record functions beyond the default MPI calls. For non-MPI applications (for example, threaded or serial), you
must ensure that the Intel® Trace Collector is properly initialized (VT_initialize/VT_init).
Caution
Be careful with full instrumentation because this feature can produce very large trace files.
IDE Equivalent
None
235
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
tcollect-filter, Qtcollect-filter compiler option
tcollect-filter, Qtcollect-filter
Lets you enable or disable the instrumentation of
specified functions. You must also specify option
[Q]tcollect. This feature is only available for ifort.
Syntax
Linux OS:
-tcollect-filter filename
macOS:
None
Windows OS:
/Qtcollect-filter:filename
Arguments
filename Is a configuration file that lists filters, one per line. Each filter consists
of a regular expression string and a switch. Strings with leading or
trailing white spaces must be quoted. Other strings do not have to be
quoted. The switch value can be ON, on, OFF, or off.
Default
OFF Functions are not instrumented. However, if option -tcollect (Linux) or /Qtcollect (Windows)
is specified, the filter setting is ".* ON" and all functions get instrumented.
Description
This option lets you enable or disable the instrumentation of specified functions.
To get instrumentation with a specified filter (or filters), you must specify both option [Q]tcollect and
option [Q]tcollect-filter.
During instrumentation, the regular expressions in the file are matched against the function names. The
switch specifies whether matching functions are to be instrumented or not. Multiple filters are evaluated from
top to bottom with increasing precedence.
The names of the functions to match against are formatted as follows:
• The source file name is followed by a colon-separated function name. Source file names should contain
the full path, if available. For example:
/home/joe/src/file.f:FOO_bar
• Classes and function names are separated by double colons. For example:
/home/joe/src/file.fpp:app::foo::bar
You can use option [q or Q]opt-report to get a full list of file and function names that the compiler
recognizes from the compilation unit. This list can be used as the basis for filtering in the configuration file.
236
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This trace analyzing/collecting feature requires installation of another product. For more information, see
Feature Requirements.
IDE Equivalent
None
Alternate Options
None
Consider the following filters in a configuration file:
See Also
tcollect, Qtcollect compiler option
qopt-report, Qopt-report compiler option (ifort)
device-math-lib
Enables or disables certain device libraries. This is a
deprecated option that may be removed in a future
release.
Syntax
Linux OS:
-device-math-lib=library
-no-device-math-lib=library
macOS:
None
Windows OS:
/device-math-lib:library
/no-device-math-lib:library
237
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
To link more than one library, include a comma between the library names.
For example, if you want to link both the fp32 and fp64 device libraries, specify: fp32,
fp64
Default
fp32, fp64 Both the fp32 and fp64 device libraries are linked.
Description
This option enables or disables certain device libraries.
This is a deprecated option that may be removed in a future release. There is no replacement option.
IDE Equivalent
None
Alternate Options
None
See Also
fopenmp-device-lib compiler option
fmpc-privatize
Enables or disables privatization of all static data for
the MultiProcessor Computing environment (MPC)
unified parallel runtime. This feature is only available
for ifort.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
-fmpc-privatize
-fno-mpc-privatize
macOS:
None
Windows OS:
None
Arguments
None
238
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-fno-mpc-privatize The privatization of all static data for the MPC unified parallel runtime
is disabled.
Description
This option enables or disables privatization of all static data for the MultiProcessor Computing environment
(MPC) unified parallel runtime.
Option -fmpc-privatize causes calls to extended thread-local-storage (TLS) resolution, run-time routines
that are not supported on standard Linux* distributions.
This option requires installation of another product. For more information, see Feature Requirements.
IDE Equivalent
None
Alternate Options
None
fopenmp
Option -fopenmp is a deprecated option that will be
removed in a future release.
Syntax
Linux OS:
-fopenmp
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
Enables recognition of OpenMP* features and tells the parallelizer to generate multi-threaded code based on
OpenMP* directives.
Option -fopenmp is a deprecated option that will be removed in a future release. For most users, we
recommend that you instead use option qopenmp, Qopenmp.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
239
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
fopenmp-declare-target-scalar-defaultmap, Qopenmp-declare-target-scalar-defaultmap
Determines which implicit data-mapping/sharing rules
are applied for a scalar variable referenced in a
TARGET directive. This feature is only available for ifx.
Syntax
Linux OS:
-fopenmp-declare-target-scalar-defaultmap=keyword
macOS:
None
Windows OS:
/Qopenmp-declare-target-scalar-defaultmap:keyword
Arguments
keyword Is the rule to be applied for a scalar variable referenced in a target pragma.TARGET
directive.. Possible values are:
Default
Description
This option determines which implicit data-mapping/sharing rules are applied for a scalar variable referenced
in a TARGET directive, when that scalar variable appears in a DECLARE TARGET directive that has a TO
clause.
240
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
It tells the compiler to assume that a scalar DECLARE TARGET variable with implicit data-mapping/sharing
referenced in a TARGET construct has the same value before the TARGET construct (in the host environment)
and at the beginning the target region (in the device environment). This may enable some optimizations in
the host code invoking the target region for execution.
The option only affects data-mapping/sharing rules for scalar variables referenced in a TARGET construct that
do not appear in one of the TARGET clauses MAP, IS_DEVICE_PTR, or HAS_DEVICE_ADDR.
For more information about implicit data-mapping/sharing rules, see the OpenMP 5.2 specification. For
example, see section 5.8.1 in that specification.
IDE Equivalent
None
Alternate Options
None
Examples
Consider the following:
module data
integer :: N
!$omp declare target(N)
end module data
...
program main
use data
!$omp target teams distribute parallel do
do i = 1, N
...
enddo
Specifying -fopenmp-declare-target-scalar-defaultmap=firstprivate
(or /Qopenmp-declare-target-scalar-defaultmap:firstprivate) or an explicit "FIRSTPRIVATE(N)"
lets the compiler generate efficient host code that issues the most appropriate number of teams and threads
to execute the iterations of the DISTRIBUTE PARALLEL DO loop, assuming that N does not change its value
between the beginning of the TARGET region and the beginning of the DISTRIBUTE PARALLEL DO region.
If the compiler option (or "FIRSTPRIVATE(N)") is not specified, then the value of N in the host code (before
the TARGET construct) may be different from the value of N in the DO statement. To compute the right
number of teams/threads on the host, the value of N must be transferred from the device to the host, which
may result in a performance penalty.
The option may not behave correctly for all OpenMP programs. In particular, it may behave incorrectly for
programs that allow different values of the same DECLARE TARGET scalar variables on entry to TARGET
regions.
For example, consider the following:
module data
integer :: x = 0 ! host 'x' is 0, target 'x' is 0
!$omp declare target(x)
end module data
program main
use data
x = -1
241
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
x = 1
!$omp end target
target: 1 == 1
host: 1 == 1
However, this is the output when option -fopenmp-declare-target-scalar-defaultmap=firstprivate
(or /Qopenmp-declare-target-scalar-defaultmap:firstprivate) is specified:
target: -1 == 1
host: 0 == 1
target: -1 == 1
host: 0 == 1
See Also
TARGET directive
See Also
DECLARE TARGET
fopenmp-device-lib
Enables or disables certain device libraries for an
OpenMP* target.
Syntax
Linux OS:
-fopenmp-device-lib=library[,library,...]
-fno-openmp-device-lib=library[,library,...]
macOS:
None
Windows OS:
-fopenmp-device-lib=library[,library,...]
-fno-openmp-device-lib=library[,library,...]
Arguments
242
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To link more than one library, include a comma between the library
names. For example, if you want to link both the libm-fp32 device
library and the C library, specify: libm-fp32,libc.
Do not add spaces between library names.
Note that if you specify "all", it supersedes any additional value you
may specify.
Default
Description
This option enables or disables certain device libraries for an OpenMP* target.
If you specify fno-openmp-device-lib=library, linking to the specified library is disabled for the
OpenMP* target.
NOTE
When OpenMP* offloading is enabled, this option only applies to device-specific compilation.
Offloading can only be enabled when using ifx.
IDE Equivalent
Windows
Visual Studio: Linker > General > Enable linking of the device libraries for OpenMP offload
Linker > General > Disable linking of the device libraries for OpenMP offload
Alternate Options
None
fopenmp-target-buffers, Qopenmp-target-buffers
Enables a way to overcome the problem where some
OpenMP* offload SPIR-V* devices produce incorrect
code when a target object is larger than 4GB. This
feature is only available for ifx.
Syntax
Linux OS:
-fopenmp-target-buffers=keyword
243
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/Qopenmp-target-buffers:keyword
Arguments
default Tells the compiler to use default heuristics. This may produce incorrect
code on some OpenMP* offload SPIR-V* devices when a target object is
larger than 4GB.
4GB Tells the compiler to generate code to prevent the issue described by
default. OpenMP* offload programs that access target objects of size
larger than 4GB in target code require this option.
This setting applies to the following:
Default
default If you do not specify this option, the compiler may produce incorrect code on some OpenMP*
offload SPIR-V* devices when a target object is larger than 4GB.
Description
This option enables a way to overcome the problem where some OpenMP* offload SPIR-V* devices produce
incorrect code when a target object is larger than 4GB (4294959104 bytes).
However, note that when -fopenmp-target-buffers=4GB (or /Qopenmp-target-buffers:4GB) is
specified on Intel® GPUs, there may be a decrease in performance.
To use this option, you must also specify option -fopenmp-targets (Linux*) or /Qopenmp-targets
(Windows*).
NOTE
This option may have no effect for some OpenMP* offload SPIR-V* devices, and for
OpenMP* offload targets different from SPIR*.
NOTE
When OpenMP* offloading is enabled, this option only applies to device-specific compilation.
244
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Code Generation > Specify buffer size for OpenMP offload kernel access limitations
(ifx only)
Alternate Options
None
See Also
fopenmp-targets, Qopenmp-targets compiler option
fopenmp-target-do-concurrent, Qopenmp-target-do-concurrent
Determines whether a DO CONCURRENT construct is
automatically converted into an OpenMP* TARGET
region. This feature is only available for ifx.
Syntax
Linux OS:
-fopenmp-target-do-concurrent
-fno-openmp-target-do-concurrent
macOS:
None
Windows OS:
/Qopenmp-target-do-concurrent
/Qopenmp-target-do-concurrent-
Arguments
None
Default
Description
This option determines whether a DO CONCURRENT construct is automatically converted (offloaded) into an
OpenMP* TARGET region. This option works in combination with OpenMP* offloading options.
The DO CONCURRENT construct is automatically converted if you specify the following:
Linux
245
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Option -fopenmp-target-do-concurrent and /Qopenmp-target-do-concurrent must be
specified for both the host and target compilation steps.
IDE Equivalent
None
Alternate Options
None
fopenmp-targets, Qopenmp-targets
Enables offloading to a specified GPU target if
OpenMP* features have been enabled. This feature is
only available for ifx.
Syntax
Linux OS:
-fopenmp-targets=triple
macOS:
None
Windows OS:
/Qopenmp-targets:triple
Arguments
Default
246
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables offloading to a specified GPU target if OpenMP* features have been enabled.
To use this option, you must enable recognition of OpenMP* features by specifying one of the following
options:
Linux
• -qopenmp
• -fiopenmp (ifx only)
This options is equivalent in ifx to -qopenmp
• -fopenmp (ifx; deprecated)
This option is equivalent to -qopenmp
Windows
• /Qopenmp
• /Qiopenmp (ifx only)
This option is equivalent in ifx to /Qopenmp
NOTE
When OpenMP* offloading is enabled, this option only applies to device-specific compilation.
IDE Equivalent
Windows
Visual Studio: Code Generation > Enable OpenMP Offloading
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
fsycl
Enables linking Fortran object files with SYCL-based
object files. This feature is only available for ifx.
Syntax
Linux OS:
-fsycl
247
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
-fsycl
Arguments
None
Default
OFF Fortran object files are not linked with SYCL object files.
Description
This option enables linking Fortran object files with SYCL-based object files.
NOTE
This option is only valid when using ifx to link your executable.
IDE Equivalent
None
Alternate Options
None
fsycl-dead-args-optimization
Enables elimination of SYCL dead kernel arguments.
This feature is only available for ifx.
Syntax
Linux OS:
-fsycl-dead-args-optimization
-fno-sycl-dead-args-optimization
macOS:
None
Windows OS:
-fsycl-dead-args-optimization
-fno-sycl-dead-args-optimization
Arguments
None
Default
OFF SYCL dead kernel arguments are not eliminated. This default may change in the future.
248
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables elimination of SYCL dead kernel arguments. This optimization can improve performance.
NOTE
When using this option, you must also specify option -fsycl.
For information about available SYCL drivers, refer to Invoke the Compiler.
NOTE
When SYCL offloading is enabled, this option only applies to device-specific compilation.
IDE Equivalent
None
Alternate Options
None
fsycl-device-code-split
Specifies a SYCL* device code module assembly. This
feature is only available for ifx.
Syntax
Linux OS:
-fsycl-device-code-split[=value]
macOS:
None
Windows OS:
-fsycl-device-code-split[=value]
Arguments
249
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
auto This is the default whether you do not specify the compiler option or you do specify the compiler
option, but omit a value. The compiler will use a heuristic to select the best way of splitting device
code.
Description
This option specifies a SYCL* device code module assembly.
NOTE
When using this option, you must also specify option -fsycl.
For information about available SYCL drivers, refer to Invoke the Compiler.
NOTE
When SYCL offloading is enabled, this option only applies to device-specific compilation.
IDE Equivalent
None
Alternate Options
None
fsycl-device-lib
Enables or disables certain device libraries for a SYCL*
target. This feature is only available for ifx.
Syntax
Linux OS:
-fsycl-device-lib=library[,library,...]
-fno-sycl-device-lib=library[,library,...]
macOS:
None
Windows OS:
-fsycl-device-lib=library[,library,...]
-fsycl-device-lib=library[,library,...]
250
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
To link more than one library, include a comma between the library
names. For example, if you want to link both the libm-fp32 device
library and the C library, specify: libm-fp32,libc.
Do not add spaces between library names.
Note that if you specify "all", it supersedes any additional value you
may specify.
Default
Description
This option enables or disables certain device libraries for a SYCL* target.
NOTE
When using this option, you must also specify option -fsycl.
If you specify fno-sycl-device-lib=library, linking to the specified library is disabled for the SYCL*
target.
For information about available SYCL drivers, refer to Invoke the Compiler.
NOTE
When SYCL offloading is enabled, this option only applies to device-specific compilation.
IDE Equivalent
None
Alternate Options
None
fsycl-instrument-device-code
Enables or disables linking of the Instrumentation and
Tracing Technology (ITT) device libraries for VTune™.
This feature is only available for ifx.
251
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fsycl-instrument-device-code-split
-fno-sycl-instrument-device-code-split
macOS:
None
Windows OS:
-fsycl-instrument-device-code-split
-fno-sycl-instrument-device-code-split
Arguments
None
Default
ON The device libraries needed for Instrumentation and Tracing Technology (ITT) are enabled.
Description
This option enables or disables linking of the Instrumentation and Tracing Technology (ITT) device libraries
for VTune™. This provides annotations to intercept various events inside kernels generated by Just in Time
(JIT) compilation.
NOTE
When using this option, you must also specify option -fsycl.
NOTE
When SYCL offloading is enabled, this option only applies to device-specific compilation.
IDE Equivalent
None
Alternate Options
None
fsycl-link-huge-device-code
Tells the compiler to place device code later in the
linked binary. This is to prevent 32-bit PC-relative
relocations between surrounding Executable and
Linkable Format (ELF) sections when the device code
is larger than 2GB. This feature is only available for
ifx.
252
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fsycl-link-huge-device-code
-fno-sycl-link-huge-device-code
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option tells the compiler to place device code later in the linked binary. This is to prevent 32-bit PC-
relative relocations between surrounding Executable and Linkable Format (ELF) sections when the device
code is larger than 2GB.
This option impacts the host link for a full offload compilation. It does not impact device compilation directly,
but it is only useful when offloading is performed.
NOTE
When using this option, you must also specify option -fsycl.
NOTE
This option only takes effect if a link action needs to be executed. For example, it will not
have any effect if certain other options are specified, such as -c or -E.
IDE Equivalent
None
Alternate Options
None
Example
The following shows an example of using this option:
nolibsycl
Disables linking of the SYCL* runtime library. This
feature is only available for ifx.
253
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-nolibsycl
macOS:
None
Windows OS:
-nolibsycl
Arguments
None
Default
Description
This option disables linking of the SYCL* runtime library.
This option is only effective if you have specified option -fsycl.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
par-affinity, Qpar-affinity
Specifies thread affinity. This feature is only available
for ifort.
Syntax
Linux OS:
-par-affinity=[modifier,...]type[,permute][,offset]
macOS:
None
Windows OS:
/Qpar-affinity:[modifier,...]type[,permute][,offset]
254
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
type Indicates the thread affinity. This argument is required and must be
one of the following values: compact, disabled, explicit, none,
scatter, logical, physical. The default is none. Values logical
and physical are deprecated. Use compact and scatter,
respectively, with no permute value.
permute Is a positive integer. You cannot use this argument with type setting
explicit, none, or disabled. The default is 0.
offset Is a positive integer. You cannot use this argument with type setting
explicit, none, or disabled. The default is 0.
Default
Description
This option specifies thread affinity, which binds threads to physical processing units. It has the same effect
as environment variable KMP_AFFINITY.
This option overrides the environment variable when both are specified.
This option only has an effect if the following is true:
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
None
Alternate Options
None
See Also
parallel, Qparallel compiler option
qopt-report, Qopt-report compiler option (ifort)
par-num-threads, Qpar-num-threads
Specifies the number of threads to use in a parallel
region. This feature is only available for ifort.
255
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-par-num-threads=n
macOS:
-par-num-threads=n
Windows OS:
/Qpar-num-threads:n
Arguments
Default
Description
This option specifies the number of threads to use in a parallel region. It has the same effect as environment
variable OMP_NUM_THREADS.
This option overrides the environment variable when both are specified.
This option only has an effect if the following is true:
IDE Equivalent
None
Alternate Options
None
See Also
parallel, Qparallel compiler option
qopt-report, Qopt-report compiler option (ifort)
par-runtime-control, Qpar-runtime-control
Generates code to perform run-time checks for loops
that have symbolic loop bounds. This feature is only
available for ifort.
Syntax
Linux OS:
-par-runtime-control[n]
-no-par-runtime-control
macOS:
-par-runtime-control[n]
-no-par-runtime-control
256
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qpar-runtime-control[n]
/Qpar-runtime-control-
Arguments
Default
Description
This option generates code to perform run-time checks for loops that have symbolic loop bounds.
If the granularity of a loop is greater than the parallelization threshold, the loop will be executed in parallel.
If you do not specify this option, the compiler may not parallelize loops with symbolic loop bounds if the
compile-time granularity estimation of a loop can not ensure it is beneficial to parallelize the loop.
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
None
Alternate Options
None
par-schedule, Qpar-schedule
Lets you specify a scheduling algorithm for loop
iterations. This feature is only available for ifort.
257
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-par-schedule-keyword[=n]
macOS:
-par-schedule-keyword[=n]
Windows OS:
/Qpar-schedule-keyword[[:]n]
Arguments
keyword Specifies the scheduling algorithm or tuning method. Possible values are:
n Is the size of the chunk or the number of iterations for each chunk.
This setting can only be specified for static, dynamic, and guided. For
more information, see the descriptions of each keyword below.
Default
static-balanced Iterations are divided into even-sized chunks and the chunks are assigned
to the threads in the team in a round-robin fashion in the order of the
thread number.
Description
This option lets you specify a scheduling algorithm for loop iterations. It specifies how iterations are to be
divided among the threads of the team.
This option is only useful when specified with option [Q]parallel.
This option affects performance tuning and can provide better performance during auto-parallelization. It
does nothing if it is used with option [q or Q]openmp.
Option Description
258
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
259
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
None
Alternate Options
None
par-threshold, Qpar-threshold
Sets a threshold for the auto-parallelization of loops.
This feature is only available for ifort.
Syntax
Linux OS:
-par-threshold[n]
macOS:
-par-threshold[n]
Windows OS:
/Qpar-threshold[[:]n]
Arguments
260
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option sets a threshold for the auto-parallelization of loops based on the probability of profitable
execution of the loop in parallel. To use this option, you must also specify option [Q]parallel.
This option is useful for loops whose computation work volume cannot be determined at compile-time. The
threshold is usually relevant when the loop trip count is unknown at compile-time.
The compiler applies a heuristic that tries to balance the overhead of creating multiple threads versus the
amount of work available to be shared amongst the threads.
NOTE
This option may behave differently on Intel® microprocessors than on non-Intel
microprocessors.
IDE Equivalent
Windows
Visual Studio: Optimization > Threshold For Auto-Parallelization
Alternate Options
None
parallel, Qparallel
Tells the auto-parallelizer to generate multithreaded
code for loops that can be safely executed in parallel.
This feature is only available for ifort.
Syntax
Linux OS:
-parallel
macOS:
-parallel
Windows OS:
/Qparallel(or /Qpar)
Arguments
None
261
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF Multithreaded code is not generated for loops that can be safely executed in parallel.
Description
This option tells the auto-parallelizer to generate multithreaded code for loops that can be safely executed in
parallel.
To use this option, you must also specify option O2 or O3.
NOTE
Using this option enables parallelization for both Intel® microprocessors and non-Intel
microprocessors. The resulting executable may get additional performance gain on Intel
microprocessors than on non-Intel microprocessors. The parallelization can also be affected
by certain options, such as /arch or /Qx (Windows*) or -m or -x (Linux* and macOS).
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Optimization > Parallelization
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
par-affinity, Qpar-affinity compiler option
par-num-threads, Qpar-num-threads compiler option
par-runtime-control, Qpar-runtime-control compiler option
par-schedule, Qpar-schedule compiler option
qopt-matmul, Qopt-matmul compiler option
O compiler option
parallel-source-info, Qparallel-source-info
Enables or disables source location emission when
OpenMP* or auto-parallelism code is generated. This
feature is only available for ifort.
Syntax
Linux OS:
-parallel-source-info[=n]
-no-parallel-source-info
262
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-parallel-source-info[=n]
-no-parallel-source-info
Windows OS:
/Qparallel-source-info
/Qparallel-source-info-[:n]
Arguments
Default
Description
This option enables or disables source location emission when OpenMP code or auto-parallelism code is
generated. It also lets you set the level of emission.
IDE Equivalent
None
Alternate Options
None
qopenmp, Qopenmp
Enables recognition of OpenMP* features and tells the
parallelizer to generate multi-threaded code based on
OpenMP* directives.
Syntax
Linux OS:
-qopenmp
263
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-qno-openmp
macOS:
-qopenmp
-qno-openmp
Windows OS:
/Qopenmp
/Qopenmp-
Arguments
None
Default
Description
This option enables recognition of OpenMP* features and tells the parallelizer to generate multi-threaded
code based on OpenMP* directives. The code can be executed in parallel on both uniprocessor and
multiprocessor systems.
If you use this option, multithreaded libraries are used, but option fpp is not automatically invoked.
This option works with any optimization level. Specifying no optimization (-O0 on Linux* or /Od on
Windows*) helps to debug OpenMP applications.
To ensure that a threadsafe and/or reentrant run-time library is linked and correctly initialized, option
[q or Q]openmp should also be used for the link step and for the compilation of the main routine.
NOTE
If you want to do offloading, specify option -fiopenmp. This option is only available for ifx.
NOTE
To enable offloading to a specified GPU target, you must also specify option
fopenmp-targets (Linux*) or /Qopenmp-targets (Windows). This option is only available for
ifx.
NOTE
Options that use OpenMP* API are available for both Intel® microprocessors and non-Intel
microprocessors, but these options may perform additional optimizations on Intel®
microprocessors than they perform on non-Intel microprocessors. The list of major, user-
visible OpenMP constructs and features that may perform differently on Intel®
microprocessors versus non-Intel microprocessors include: locks (internal and user visible),
the SINGLE construct, barriers (explicit and implicit), parallel loop scheduling, reductions,
memory allocation, thread affinity, and binding.
264
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Language > Process OpenMP Directives
Language > OpenMP Support (for ifx /Qiopenmp)
Alternate Options
Linux and macOS: -fopenmp (deprecated), -fiopenmp (ifx only)
See Also
fopenmp-targets, Qopenmp-targets compiler option
auto compiler option
qopenmp-lib, Qopenmp-lib
Lets you specify an OpenMP* run-time library to use
for linking.
Syntax
Linux OS:
-qopenmp-lib=type
macOS:
-qopenmp-lib=type
Windows OS:
/Qopenmp-lib:type
Arguments
type Specifies the type of library to use; it implies compatibility levels. Currently, the only
possible value is:
Default
Description
This option lets you specify an OpenMP* run-time library to use for linking.
265
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The compatibility OpenMP run-time libraries are compatible with object files created using the Microsoft*
OpenMP run-time library (vcomp) or the GNU OpenMP run-time library (libgomp).
To use the compatibility OpenMP run-time library, compile and link your application using the compat setting
for option [q or Q]openmp-lib. To use this option, you must also specify one of the following compiler
options:
NOTE The compatibility OpenMP run-time library is not compatible with object files created
using versions of the Intel compilers earlier than 10.0.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
qopenmp-stubs, Qopenmp-stubs compiler option
qopenmp-link
Controls whether the compiler links to static or
dynamic OpenMP* run-time libraries.
266
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopenmp-link=library
macOS:
-qopenmp-link=library
Windows OS:
None
Arguments
Default
Description
This option controls whether the compiler links to static or dynamic OpenMP* run-time libraries.
To link to the static OpenMP run-time library (RTL) and create a purely static executable, you must specify
-qopenmp-link=static. However, we strongly recommend you use the default setting,
-qopenmp-link=dynamic.
Option -qopenmp-link=dynamic cannot be used in conjunction with option -static. If you try to specify
both options together, an error will be displayed.
NOTE
Compiler options -static-intel and -shared-intel (Linux* and macOS) have no effect on
which OpenMP run-time library is linked.
NOTE
On Linux systems, the OpenMP runtime library depends on using libpthread and libc (libgcc
when compiled with gcc). Libpthread and libc (libgcc) must both be static or both be
dynamic.
If both libpthread and libc (libgcc) are static, then the static version of the OpenMP runtime should be
used. If both libpthread and libc (libgcc) are dynamic, then either the static or dynamic version of the
OpenMP runtime may be used.
267
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
qopenmp-simd, Qopenmp-simd
Enables or disables OpenMP* SIMD compilation.
Syntax
Linux OS:
-qopenmp-simd
-qno-openmp-simd
macOS:
-qopenmp-simd
-qno-openmp-simd
Windows OS:
/Qopenmp-simd
/Qopenmp-simd-
Arguments
None
Default
• ifort: O2 or higher
• ifx: O1 or higher
OpenMP* SIMD compilation is always disabled at this
optimization level:
268
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables or disables OpenMP* SIMD compilation.
You can use this option if you want to enable or disable the SIMD support with no impact on other OpenMP
features. In this case, no OpenMP runtime library is needed to link and the compiler does not need to
generate OpenMP runtime initialization code.
When you specify [q or Q]openmp, it implies [q or Q]openmp-simd.
If you specify this option with the [q or Q]openmp option, it can impact other OpenMP features.
IDE Equivalent
None
Alternate Options
ifort: None
ifx:
Linux: -fopenmp-simd and -fiopenmp-simd
Windows: /Qiopenmp-simd
Example
The lines in the following example are equivalent to specifying only [q or Q]openmp-simd. In this case,
only SIMD support is provided, the OpenMP* library is not linked, and only the !$OMP directives related to
SIMD are processed:
Linux and macOS
-qno-openmp -qopenmp-simd
Windows
/Qopenmp- /Qopenmp-simd
In the following example, SIMD support is provided, the OpenMP library is linked, and OpenMP runtime
initialization code is generated:
Linux and macOS
-qopenmp -qopenmp-simd
Windows
/Qopenmp /Qopenmp-simd
See Also
qopenmp, Qopenmp compiler option
O compiler option
DECLARE SIMD
SIMD Directive (OpenMP* API)
qopenmp-stubs, Qopenmp-stubs
Enables compilation of OpenMP* programs in
sequential mode.
269
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-qopenmp-stubs
macOS:
-qopenmp-stubs
Windows OS:
/Qopenmp-stubs
Arguments
None
Default
Description
This option enables compilation of OpenMP* programs in sequential mode. The OpenMP directives are
ignored and a stub OpenMP library is linked.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Windows
Visual Studio: Language > Process OpenMP Directives
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
qopenmp-threadprivate, Qopenmp-threadprivate
Lets you specify an OpenMP* threadprivate
implementation.
Syntax
Linux OS:
-qopenmp-threadprivate=type
macOS:
None
Windows OS:
/Qopenmp-threadprivate:type
270
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
Default
Description
This option lets you specify an OpenMP* threadprivate implementation.
The threadprivate implementation of the legacy OpenMP run-time library may not be compatible with object
files created using OpenMP run-time libraries supported in other compilers.
To use this option, you must also specify one of the following compiler options:
NOTE
On Windows* systems, if you specify option /Qopenmp-threadprivate:compat, the compiler
does not generate threadsafe code for common blocks in an !$OMP THREADPRIVATE
directive unless at least one element in the common block is explicitly initialized.
NOTE
On macOS systems, legacy is the only type of threadprivate supported. Option
-qopenmp-threadprivate is not recognized by the compiler.
IDE Equivalent
None
271
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
qopenmp, Qopenmp compiler option
qopenmp-stubs, Qopenmp-stubs compiler option
Qpar-adjust-stack
Tells the compiler to generate code to adjust the stack
size for a fiber-based main thread. This feature is only
available for ifort.
Syntax
Linux OS and macOS:
None
Windows OS:
/Qpar-adjust-stack:n
Arguments
n Is the stack size (in bytes) for the fiber-based main thread. It must be
a number equal to or greater than zero.
Default
Description
This option tells the compiler to generate code to adjust the stack size for a fiber-based main thread. This
can reduce the stack size of threads.
For this option to be effective, you must also specify option /Qparallel.
IDE Equivalent
None
Alternate Options
None
See Also
parallel, Qparallel compiler option
Xopenmp-target
Enables options to be passed to the specified tool in
the device compilation tool chain for the target. This
feature is only available for ifx.
Syntax
Linux OS:
-Xopenmp-target-tool=T "options"
272
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
-Xopenmp-target-tool=T "options"
Arguments
Some targets may have frontend and backend in one component; in that case, options are
merged.
Default
Description
This option enables options to be passed to the specified tool in the device compilation tool chain for the
target.
NOTE
When OpenMP* offloading is enabled, this option only applies to device-specific compilation.
IDE Equivalent
None
Alternate Options
None
Floating-Point Options
This section contains descriptions for compiler options that pertain to floating-point calculations. They are
listed in alphabetical order.
273
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fast-transcendentals, Qfast-transcendentals
Enables the compiler to replace calls to transcendental
functions with faster but less precise implementations.
This feature is only available for ifort.
Syntax
Linux OS:
-fast-transcendentals
-no-fast-transcendentals
macOS:
-fast-transcendentals
-no-fast-transcendentals
Windows OS:
/Qfast-transcendentals
/Qfast-transcendentals-
Arguments
None
Default
Description
This option enables the compiler to replace calls to transcendental functions with implementations that may
be faster but less precise.
It allows the compiler to perform certain optimizations on transcendental functions, such as replacing
individual calls to sine in a loop with a single call to a less precise vectorized sine library routine. These
optimizations can cause numerical differences that would not otherwise exist if you are also compiling with a
value-safe option such as -fp-model precise (Linux* and macOS*) or /fp:precise (Windows).
For example, you may get different results if you specify option O0 versus option O2, or you may get different
results from calling the same function with the same input at different points in your program. If these kinds
of numerical differences are problematic, consider using option -fimf-use-svml (Linux* and macOS*)
or /Qimf-use-svml (Windows) as an alternative. When used with a value-safe option such as
-fp-model precise or /fp:precise, option -fimf-use-svml or /Qimf-use-svml provides many of the
positive performance benefits of [Q]fast-transcendentals without negatively affecting numeric
consistency. For more details, see the description of option -fimf-use-svml and /Qimf-use-svml.
This option does not affect explicit Short Vector Math Library (SVML) intrinsics. It only affects scalar calls to
the standard math library routines.
You cannot use option -fast-transcendentals with option -fp-model strict and you cannot use
option /Qfast-transcendentals with option /fp:strict.
274
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option determines the setting for the maximum allowable relative error for math library function results
(max-error) if none of the following options are specified:
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
fimf-use-svml, Qimf-use-svml compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-absolute-error, Qimf-absolute-error
Defines the maximum allowable absolute error for
math library function results.
Syntax
Linux OS:
-fimf-absolute-error=value[:funclist]
macOS:
-fimf-absolute-error=value[:funclist]
Windows OS:
/Qimf-absolute-error:value[:funclist]
Optional argument funclist is not supported for ifx.
Arguments
value Is a positive, floating-point number. Errors in math library function results may exceed
the maximum relative error (max-error) setting if the absolute-error is less than or
equal to value.
The format for the number is [digits] [.digits] [ { e | E }[sign]digits]
275
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
funclist Is an optional list of one or more math library functions to which the attribute should
be applied. Do not specify the standard Fortran name of the math function; you must
specify the actual math library name. If you specify more than one function, they must
be separated with commas.
Precision-specific variants like sin and sinf are considered different functions, so you
would need to use -fimf-absolute-error=0.00001:sin,sinf
(or /Qimf-absolute-error:0.00001:sin,sinf) to specify the maximum allowable
absolute error for both the single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides, symbol / to
denote double-precision divides, symbol /l to denote extended-precision divides, and
symbol /q to denote quad-precision divides. For example you can specify
-fimf-absolute-error=0.00001:/ or /Qimf-absolute-error: 0.00001:/.
Default
Zero ("0") An absolute-error setting of 0 means that the function is bound by the relative error
setting. This is the default behavior.
Description
This option defines the maximum allowable absolute error for math library function results.
This option can improve run-time performance, but it may decrease the accuracy of results.
This option only affects functions that have zero as a possible return value, such as log, sin, asin, etc.
The relative error requirements for a particular function are determined by options that set the maximum
relative error (max-error) and precision. The return value from a function must have a relative error less
than the max-error value, or an absolute error less than the absolute-error value.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-absolute-error=0.00001:sin
or /Qimf-absolute-error:0.00001:sin, or -fimf-absolute-error=0.00001:sqrtf
or /Qimf-absolute-error:0.00001:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
276
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To define the maximum allowable absolute error for the single-precision sine function, you should
specify:
Linux and macOS
-fimf-absolute-error=sinf
Windows
/Qimf-absolute-error:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
277
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fimf-accuracy-bits, Qimf-accuracy-bits
Defines the relative error for math library function
results, including division and square root.
Syntax
Linux OS:
-fimf-accuracy-bits=bits[:funclist]
macOS:
-fimf-accuracy-bits=bits[:funclist]
Windows OS:
/Qimf-accuracy-bits:bits[:funclist]
Optional argument funclist is not supported for ifx.
Arguments
bits Is a positive, floating-point number indicating the number of correct bits the compiler
should use.
The format for the number is [digits] [.digits] [ { e | E }[sign]digits].
funclist Is an optional list of one or more math library functions to which the attribute should
be applied. Do not specify the standard Fortran name of the math function; you must
specify the actual math library name. If you specify more than one function, they must
be separated with commas.
Precision-specific variants like sin and sinf are considered different functions, so you
would need to use -fimf-accuracy-bits=23:sin,sinf
(or /Qimf-accuracy-bits:23:sin,sinf) to specify the relative error for both the
single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides, symbol / to
denote double-precision divides, symbol /l to denote extended-precision divides, and
symbol /q to denote quad-precision divides. For example you can specify
-fimf-accuracy-bits=10.0:/f or /Qimf-accuracy-bits:10.0:/f.
Default
-fimf-precision=medium or /Qimf- The compiler uses medium precision when calling math library
precision:medium functions. Note that other options can affect precision; see below
for details.
Description
This option defines the relative error, measured by the number of correct bits, for math library function
results.
The following formula is used to convert bits into ulps: ulps = 2p-1-bits, where p is the number of the target
format mantissa bits (24, 53, and 113 for single, double, and quad precision, respectively).
This option can affect run-time performance and the accuracy of results.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in the following:
Linux and macOS
278
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• -fimf-accuracy-bits=23:sinf,cosf,logf
• -fimf-accuracy-bits=52:sqrt,/,trunc
• -fimf-accuracy-bits=10:powf
Windows
• /Qimf-accuracy-bits:23:sinf,cosf,logf
• /Qimf-accuracy-bits:52:sqrt,/,trunc
• /Qimf-accuracy-bits:10:powf
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
There are three options you can use to express the maximum relative error. They are as follows:
Linux and macOS
• -fimf-precision
• -fimf-max-error
• -fimf-accuracy-bits
Windows
• /Qimf-precision
• /Qimf-max-error
• /Qimf-accuracy-bits
If more than one of these options are specified, the default value for the maximum relative error is
determined by the last one specified on the command line.
If none of the above options are specified, the default values for the maximum relative error are determined
by the setting of the following options:
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
279
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To request the relative error for the single-precision sine function, you should specify:
Linux and macOS
-fimf-accuracy-bits=sinf
Windows
/Qimf-accuracy-bits:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
280
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fimf-arch-consistency, Qimf-arch-consistency
Ensures that the math library functions produce
consistent results across different microarchitectural
implementations of the same architecture.
Syntax
Linux OS:
-fimf-arch-consistency=value[:funclist]
macOS:
-fimf-arch-consistency=value[:funclist]
Windows OS:
/Qimf-arch-consistency:value[:funclist]
Optional argument funclist is not supported for ifx.
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-arch-consistency=true:sin,sinf
(or /Qimf-arch-consistency:true:sin,sinf) to specify consistent
results for both the single-precision and double-precision sine
functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example you can specify
-fimf-arch-consistency=true:/
or /Qimf-arch-consistency:true:/.
Default
false Implementations of some math library functions may produce slightly different results on
implementations of the same architecture.
Description
This option ensures that the math library functions produce consistent results across different
microarchitectural implementations of the same architecture (for example, across different microarchitectural
implementations of Intel® 64 architecture). Consistency is only guaranteed for a single binary. Consistency is
not guaranteed across different architectures.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example:
Linux and macOS
281
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you want double precision, you can specify :sin; if you want single precision, you can specify :sinf, as in
-fimf-arch-consistency=true:sin or -fimf-arch-consistency=false:sqrtf.
Windows
If you want double precision, you can specify :sin; if you want single precision, you can specify :sinf, as
in /Qimf-arch-consistency:true:sin or /Qimf-arch-consistency:false:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
The -fimf-arch-consistency (Linux* and macOS) and /Qimf-arch-consistency (Windows*) option
may decrease run-time performance, but the option will provide bit-wise consistent results on all Intel®
processors and compatible, non-Intel processors, regardless of micro-architecture. This option may not
provide bit-wise consistent results between different architectures.
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To ensure consistent results for the single-precision sine function, you should specify:
Linux and macOS
-fimf-arch-consistency=sinf
Windows
/Qimf-arch-consistency:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
282
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
fimf-domain-exclusion, Qimf-domain-exclusion
Indicates the input arguments domain on which math
functions must provide correct results.
Syntax
Linux OS:
-fimf-domain-exclusion=classlist[:funclist]
macOS:
-fimf-domain-exclusion=classlist[:funclist]
Windows OS:
/Qimf-domain-exclusion:classlist[:funclist]
Optional argument funclist is not supported for ifx.
Arguments
• One or more of the following floating-point value classes you can exclude from the
function domain without affecting the correctness of your program. The supported
class names are:
extremes This class is for values which do not lie within the
usual domain of arguments for a given function.
283
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each classlist element corresponds to a power of two. The exclusion attribute is the
logical or of the associated powers of two (that is, a bitmask).
The following shows the current mapping from classlist mnemonics to numerical
values:
extremes 1
nans 2
infinities 4
denormals 8
zeros 16
none 0
all 31
common 15
You must specify the integer value that corresponds to the class that you want to
exclude.
Note that on excluded values, unexpected results may occur.
• One of the following short-hand tokens:
none This means that none of the supported classes are
excluded from the domain. To indicate this token,
specify 0, as in -fimf-domain-exclusion=0
(or /Qimf-domain-exclusion:0).
funclist Is an optional list of one or more math library functions to which the attribute should
be applied. Do not specify the standard Fortran name of the math function; you must
specify the actual math library name. If you specify more than one function, they must
be separated with commas.
Precision-specific variants like sin and sinf are considered different functions, so you
would need to use -fimf-domain-exclusion=4:sin,sinf
(or /Qimf-domain-exclusion:4:sin,sinf) to specify infinities for both the single-
precision and double-precision sine functions.
284
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You also can specify the symbol /f to denote single-precision divides, symbol / to
denote double-precision divides, symbol /l to denote extended-precision divides, and
symbol /q to denote quad-precision divides. For example, you can specify:
-fimf-domain-exclusion=4 or /Qimf-domain-exclusion:4
-fimf-domain-exclusion=5:/,powf or /Qimf-domain-exclusion:5:/,powf
-fimf-domain-exclusion=23:log,logf,/,sin,cosf
or /Qimf-domain-exclusion:23:log,logf,/,sin,cosf
If you don't specify argument funclist, the domain restrictions apply to all math library
functions.
Default
Zero ("0") The compiler uses default heuristics when calling math library functions.
Description
This option indicates the input arguments domain on which math functions must provide correct results. It
specifies that your program will function correctly if the functions specified in funclist do not produce
standard conforming results on the number classes.
This option can affect run-time performance and the accuracy of results. As more classes are excluded, faster
code sequences can be used.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-domain-exclusion=subnormals:sin
or /Qimf-domain-exclusion:subnormals:sin, or -fimf-domain-exclusion=extremes:sqrtf
or /Qimf-domain-exclusion:extremes:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
285
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To indicate the input arguments domain for the single-precision sine function, you should specify:
Linux and macOS
-fimf-domain-exclusion=sinf
Windows
/Qimf-domain-exclusion:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
Example
Consider the following single-precision sequence for function exp2f:
Operation: y = exp2f(x)
Accuracy: 1.014 ulp
Instructions: 4 (2 without fix-up)
286
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
However, the above 2-instruction sequence will not correctly process NaNs. To process Nans correctly, the
following fix-up must be included following the above instruction sequence:
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
fimf-force-dynamic-target, Qimf-force-dynamic-target
Instructs the compiler to use run-time dispatch in calls
to math functions.
Syntax
Linux OS:
-fimf-force-dynamic-target[=funclist]
macOS:
-fimf-force-dynamic-target[=funclist]
Windows OS:
/Qimf-force-dynamic-target[:funclist]
287
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-dynamic-target=sin,sinf
(or /Qimf-dynamic-target:sin,sinf) to specify run-time dispatch
for both the single-precision and double-precision sine functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example, you can specify -fimf-dynamic-target=/
or /Qimf-dynamic-target:/.
Default
OFF Run-time dispatch is not forced in math libraries calls. The compiler can choose to call a CPU-
specific version of a math function if one is available.
Description
This option instructs the compiler to use run-time dispatch in calls to math functions. When this option set to
ON, it lets you force run-time dispatch in math libraries calls.
By default, when this option is set to OFF, the compiler often optimizes math library calls using the target
CPU architecture-specific information available at compile time through the [Q]x and arch compiler options.
If you want to target multiple CPU families with a single application or you prefer to choose a target CPU at
run time, you can force run-time dispatch in math libraries by using this option.
288
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To use run-time dispatch in calls to the single-precision sine function, you should specify:
Linux and macOS
-fimf-force-dynamic-target=sinf
Windows
/Qimf-force-dynamic-target:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
x, Qx compiler option
arch compiler option
mtune, tune compiler option
fimf-max-error, Qimf-max-error
Defines the maximum allowable relative error for
math library function results, including division and
square root.
289
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fimf-max-error=ulps[:funclist]
macOS:
-fimf-max-error=ulps[:funclist]
Windows OS:
/Qimf-max-error:ulps[:funclist]
Optional argument funclist is not supported for ifx.
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-max-error=4.0:sin,sinf
(or /Qimf-max-error=4.0:sin,sinf) to specify the maximum
allowable relative error for both the single-precision and double-
precision sine functions.
You also can specify the symbol /f to denote single-precision divides,
symbol / to denote double-precision divides, symbol /l to denote
extended-precision divides, and symbol /q to denote quad-precision
divides. For example you can specify -fimf-max-error=4.0:/
or /Qimf-max-error:4.0:/.
Default
-fimf-precision=medium or /Qimf- The compiler uses medium precision when calling math library
precision:medium functions. Note that other options can affect precision; see below
for details.
Description
This option defines the maximum allowable relative error, measured in ulps, for math library function results.
This option can affect run-time performance and the accuracy of results.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-max-error=4.0:sin or /Qimf-max-error:4.0:sin, or
-fimf-max-error=4.0:sqrtf or /Qimf-max-error:4.0:sqrtf.
290
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
There are three options you can use to express the maximum relative error. They are as follows:
Linux and macOS
• -fimf-precision
• -fimf-max-error
• -fimf-accuracy-bits
Windows
• /Qimf-precision
• /Qimf-max-error
• /Qimf-accuracy-bits
If more than one of these options are specified, the default value for the maximum relative error is
determined by the last one specified on the command line.
If none of the above options are specified, the default values for the maximum relative error are determined
by the setting of the following options:
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
291
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To define the maximum allowable relative error for the single-precision sine function, you should
specify:
Linux and macOS
-fimf-max-error=sinf
Windows
/Qimf-max-error:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fimf-precision, Qimf-precision compiler option
fimf-use-svml_Qimf-use-svml compiler option
292
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fimf-precision, Qimf-precision
Lets you specify a level of accuracy (precision) that
the compiler should use when determining which math
library functions to use.
Syntax
Linux OS:
-fimf-precision[=value[:funclist]]
macOS:
-fimf-precision[=value[:funclist]]
Windows OS:
/Qimf-precision[:value[:funclist]]
Optional argument funclist is not supported for ifx.
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. At this time, funclist is not supported for
ifx.
Do not specify the standard Fortran name of the math function; you
must specify the actual math library name. If you specify more than
one function, they must be separated with commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-precision=high:sin,sinf
(or /Qimf-precision:high:sin,sinf) to specify high precision for
both the single-precision and double-precision sine functions.
293
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
medium The compiler uses medium precision when calling math library functions. Note that
other options can affect precision; see below for details.
Description
This option lets you specify a level of accuracy (precision) that the compiler should use when determining
which math library functions to use.
This option can be used to improve run-time performance if reduced accuracy is sufficient for the application,
or it can be used to increase the accuracy of math library functions selected by the compiler.
In general, using a lower precision can improve run-time performance and using a higher precision may
reduce run-time performance.
If you need to define the accuracy for a math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sinf, as in -fimf-precision=low:sin or /Qimf-precision:low:sin, or
-fimf-precision=high:sqrtf or /Qimf-precision:high:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
There are three options you can use to express the maximum relative error. They are as follows:
Linux and macOS
• -fimf-precision
• -fimf-max-error
• -fimf-accuracy-bits
Windows
• /Qimf-precision
• /Qimf-max-error
• /Qimf-accuracy-bits
If more than one of these options are specified, the default value for the maximum relative error is
determined by the last one specified on the command line.
If none of the above options are specified, the default values for the maximum relative error are determined
by the setting of the following options:
294
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Many routines in libraries LIBM (Math Library) and SVML (Short Vector Math Library) are
more highly optimized for Intel® microprocessors than for non-Intel microprocessors.
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To specify a level of accuracy for the single-precision sine function, you should specify:
Linux and macOS
-fimf-precision=sinf
Windows
/Qimf-precision:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-arch-consistency, Qimf-arch-consistency compiler option
295
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fimf-use-svml, Qimf-use-svml
Instructs the compiler to use the Short Vector Math
Library (SVML) rather than the Intel® Fortran Compiler
Classic and Intel® Fortran Compiler Math Library
(LIBM) to implement math library functions.
Syntax
Linux OS:
-fimf-use-svml=value[:funclist]
macOS:
-fimf-use-svml=value[:funclist]
Windows OS:
/Qimf-use-svml:value[:funclist]
Arguments
funclist Is an optional list of one or more math library functions to which the
attribute should be applied. Do not specify the standard Fortran name
of the math function; you must specify the actual math library name.
If you specify more than one function, they must be separated with
commas.
Precision-specific variants like sin and sinf are considered different
functions, so you would need to use
-fimf-use-svmlt=true:sin,sinf
(or /Qimf-use-svml:true:sin,sinf) to specify that both the
single-precision and double-precision sine functions should use SVML.
Default
false Math library functions are implemented using the Intel® Fortran Compiler Classic and Intel®
Fortran Compiler Math Library, though other compiler options such as -fast-transcendentals
or /Qfast-transcendentals may give the compiler the flexibility to implement math library
functions with either LIBM or SVML.
Description
This option instructs the compiler to implement math library functions using the Short Vector Math Library
(SVML).
Linux and macOS
When you specify option -fimf-use-svml=true, the specific SVML variant chosen is influenced by other
compiler options such as -fimf-precision and -fp-model.
296
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows
When you specify option /Qimf-use-svml:true, the specific SVML variant chosen is influenced by other
compiler options such as /Qimf-precision and /fp.
This option has no effect on math library functions that are implemented in LIBM but not in SVML.
In value-safe settings of option -fp-model (Linux and macOS) or option /fp (Windows) such as precise, this
option causes a slight decrease in the accuracy of math library functions, because even the high accuracy
SVML functions are slightly less accurate than the corresponding functions in LIBM. Additionally, the SVML
functions might not accurately raise floating-point exceptions, do not maintain errno, and are designed to
work correctly only in round-to-nearest-even rounding mode.
The benefit of using -fimf-use-svml=true or /Qimf-use-svml:true with value-safe settings of
-fp-model (Linux and macOS) or /fp (Windows) is that it can significantly improve performance by enabling
the compiler to efficiently vectorize loops containing calls to math library functions.
If you need to use SVML for a specific math function of a certain precision, specify the function name of the
precision that you need. For example, if you want double precision, you can specify :sin; if you want single
precision, you can specify :sqrtf, as in -fimf-use-svml=true:sin or /Qimf-use-svml:true:sin, or
-fimf-use-svml =false:sqrtf or /Qimf-use-svml:false:sqrtf.
If you do not specify any function names, then the setting applies to all functions (and to all precisions).
However, as soon as you specify an individual function name, the setting applies only to the function of
corresponding precision. So, for example, sinf applies only to the single-precision sine function, sin applies
only to the double-precision sine function, sinl applies only to the extended-precision sine function, etc.
NOTE
Linux and macOS
If you specify option -mia32, vector instructions cannot be used. Therefore, you cannot use option
-mia32 with option -fimf-use-svml=true.
Windows
If you specify option /arch:IA32 (Windows*), vector instructions cannot be used. Therefore, you
cannot use option /arch:IA32 with option /Qimf-use-svml:true.
NOTE
Since SVML functions may raise unexpected floating-point exceptions, be cautious about
using features that enable trapping on floating-point exceptions. For example, be cautious
about specifying option -fimf-use-svml=true with option -fp-trap, or
option /Qimf-use-svml:true with option /Qfp-trap. For some inputs to some math library
functions, such option combinations may cause your program to trap unexpectedly.
297
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The standard Fortran names for the various math intrinsic functions do not match the math
library names of the math intrinsic functions. You must find the actual math library name
that is generated for the relevant Fortran math intrinsic.
One way to do this is to generate assembly code by using one of the following options:
Linux and macOS
-S
Windows
/Fa or /S
The assembly code will show the actual math library name.
For example, if you create a program that contains a call to SIN(x) where x is declared as
REAL(KIND=4) and then use option S to produce assembly code for the program, the assembly code
will show a call to sinf.
To request the use of SVML for the single-precision sine function, you should specify:
Linux and macOS
-fimf-use-svml=true:sinf
Windows
/Qimf-use-svml:true:sinf
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
m compiler option
arch compiler option
fltconsistency
Enables improved floating-point consistency.
298
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fltconsistency
-nofltconsistency
macOS:
-fltconsistency
-nofltconsistency
Windows OS:
/fltconsistency
/nofltconsistency
Arguments
None
Default
Description
This option enables improved floating-point consistency and may slightly reduce execution speed. It limits
floating-point optimizations and maintains declared precision. It also disables inlining of math library
functions.
Floating-point operations are not reordered and the result of each floating-point operation is stored in the
target variable rather than being kept in the floating-point processor for use in a subsequent calculation.
For example, the compiler can change floating-point division computations into multiplication by the
reciprocal of the denominator. This change can alter the results of floating-point division computations
slightly.
Floating-point intermediate results are kept in full 80 bits internal precision. Additionally, all spills/reloads of
the X87 floating point registers are done using the internal formats; this prevents accidental loss of precision
due to spill/reload behavior over which you have no control.
Specifying this option has the following effects on program compilation:
299
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Even if vectorization is enabled by the [Q]x option, the compiler does not vectorize reduction loops (loops
computing the dot product) and loops with mixed precision types. Similarly, the compiler does not enable
certain loop transformations. For example, the compiler does not transform reduction loops to perform
partial summation or loop interchange.
This option causes performance degradation relative to using default floating-point optimization flags.
On Windows systems, an alternative is to use the /Qprec option, which should provide better than default
floating-point precision while still delivering good floating-point performance.
The recommended method to control the semantics of floating-point calculations is to use option -fp-model
(Linux* and macOS) or /fp (Windows*).
IDE Equivalent
None
Alternate Options
Windows: None
Windows: None
See Also
mp1, Qprec compiler option
fp-model, fp compiler option
fma, Qfma
Determines whether the compiler generates fused
multiply-add (FMA) instructions if such instructions
exist on the target processor.
Syntax
Linux OS:
-fma
-no-fma
macOS:
-fma
-no-fma
Windows OS:
/Qfma
/Qfma-
Arguments
None
300
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-fma If the instructions exist on the target processor, the compiler generates fused multiply-
or /Qfma add (FMA) instructions.
However, if you specify -fp-model strict (Linux* and macOS) or /fp:strict
(Windows*), but do not explicitly specify -fma or /Qfma, the default is -no-fma
or /Qfma-.
Description
This option determines whether the compiler generates fused multiply-add (FMA) instructions if such
instructions exist on the target processor. When the [Q]fma option is specified, the compiler may generate
FMA instructions for combining multiply and add operations. When the negative form of the [Q]fma option is
specified, the compiler must generate separate multiply and add instructions with intermediate rounding.
This option has no effect unless setting CORE-AVX2 or higher is specified for option [Q]x,-march (Linux and
macOS), or /arch (Windows).
IDE Equivalent
None
See Also
fp-model, fp compiler option
x, Qx compiler option
ax, Qax compiler option
march compiler option
arch compiler option
fp-model, fp
Controls the semantics of floating-point calculations.
Syntax
Linux OS:
-fp-model=keyword
macOS:
-fp-model=keyword
Windows OS:
/fp:keyword
Arguments
consistent (ifort only) The compiler uses default heuristics to determine results for
different optimization levels or between different processors of
the same architecture.
301
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[no-]except (Linux* and Determines whether strict floating-point exception semantics are
macOS) or except[-] honored.
(Windows*) (ifort only)
Default
Description
This option controls the semantics of floating-point calculations.
The keywords can be considered in groups:
You can specify more than one keyword. However, the following rules apply:
• You cannot specify fast and except together in the same compilation. You can specify any other
combination of group A, group B, and group C.
Since fast is the default, you must not specify except without a group A or group B keyword.
• You should specify only one keyword from group A and only one keyword from group B. If you try to
specify more than one keyword from either group A or group B, the last (rightmost) one takes effect.
• If you specify except more than once, the last (rightmost) one takes effect.
• If you specify consistent and any other keyword from another group, the last (rightmost) one may not
fully override the heuristics set by consistent.
NOTE
The fp-model=fast (or /fp:fast) options and the fp-model=fast=2 (or /fp:fast=2) options
behave differently with ifx and ifort.
With ifort, floating-point compares happen as specified by the IEEE floating-point standard, in that
the code sequence generated for them assumes a compare can involve a NaN.
ifx does not generate the check for NaN operands. If you want to use option fp-model=fast
(or /fp:fast) or option fp-model=fast=2 (or /fp:fast=2) with ifx and you want NaN compares to
match ifort’s behavior, specify option assume nan_compares on the command line.
The floating-point (FP) environment is a collection of registers that control the behavior of FP machine
instructions and indicate the current FP status. The floating-point environment may include rounding-mode
controls, exception masks, flush-to-zero controls, exception status flags, and other floating-point related
features.
302
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
303
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
-fp-model=except or /fp:except (ifort only) Tells the compiler to follow strict floating-point
exception semantics.
The -fp-model and /fp options determine the setting for the maximum allowable relative error for math
library function results (max-error) if none of the following options are specified (the following options are
only available for ifort):
NOTE
This option cannot be used to change the default (source) precision for the calculation of
intermediate results.
304
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
In Microsoft* Visual Studio, when you create a Visual Studio* Fortran project,
option /fp:fast is set by default. It sets the floating-point model to use more aggressive
optimizations when implementing floating-point calculations, which increase speed, but may
affect the accuracy or reproducibility of floating-point computations. /fp:fast is the general
default for the IDE project property for Floating Point Model.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
IDE Equivalent
Visual Studio
Visual Studio: Floating Point > Floating Point Model
Floating Point > Reliable Floating Point Exceptions Model
Alternate Options
None
See Also
O compiler option (specifically O0)
Od compiler option
mp1, Qprec compiler option
fimf-absolute-error, Qimf-absolute-error compiler option
fimf-accuracy-bits, Qimf-accuracy-bits compiler option
fimf-max-error, Qimf-max-error compiler option
fimf-precision, Qimf-precision compiler option
fimf-domain-exclusion, Qimf-domain-exclusion compiler option
fast-transcendentals, Qfast-transcendentals compiler option
Supported Environment Variables
The article titled: Consistency of Floating-Point Results using the Intel® Compiler
fp-port, Qfp-port
Rounds floating-point results after floating-point
operations. This feature is only available for ifort.
Syntax
Linux OS:
-fp-port
-no-fp-port
macOS:
-fp-port
-no-fp-port
305
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qfp-port
/Qfp-port-
Arguments
None
Default
-no-fp-port The default rounding behavior depends on the compiler's code generation decisions
or /Qfp-port- and the precision parameters of the operating system.
Description
This option rounds floating-point results after floating-point operations.
This option is designed to be used with the -mia32 (Linux*) or /arch:IA32 (Windows*) option on a 32-bit
compiler. Under those conditions, the compiler implements floating-point calculations using the x87
instruction set, which uses an internal precision that may be higher than the precision specified in the
program.
By default, the compiler may keep results of floating-point operations in this higher internal precision.
Rounding to program precision occurs at unspecified points. This provides better performance, but the
floating-point results are less deterministic. The [Q]fp-port option rounds floating-point results to user-
specified precision at assignments and type conversions. This has some impact on speed.
When compiling for newer architectures, the compiler implements floating-point calculations with different
instructions, such as Intel® SSE and SSE2. These Intel® Streaming SIMD Extensions round directly to single
precision or double precision at every instruction. In these cases, option [Q]fp-port has no effect.
IDE Equivalent
Windows
Visual Studio: Floating-Point > Round Floating-Point Results
Alternate Options
None
See Also
Floating-point Operations
fp-speculation, Qfp-speculation
Tells the compiler the mode in which to speculate on
floating-point operations.
Syntax
Linux OS:
-fp-speculation=mode
macOS:
-fp-speculation=mode
Windows OS:
/Qfp-speculation:mode
306
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
Default
Windows
In this case, the default is /Qfp-speculation:safe.
Description
This option tells the compiler the mode in which to speculate on floating-point operations.
Disabling speculation may prevent the vectorization of some loops containing conditionals.
IDE Equivalent
Visual Studio
Visual Studio: Floating Point > Floating-Point Speculation
Alternate Options
None
fp-stack-check, Qfp-stack-check
Tells the compiler to generate extra code after every
function call to ensure that the floating-point stack is
in the expected state. This feature is only available for
ifort.
Syntax
Linux OS:
-fp-stack-check
macOS:
-fp-stack-check
307
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qfp-stack-check
Arguments
None
Default
OFF There is no checking to ensure that the floating-point (FP) stack is in the expected state.
Description
This option tells the compiler to generate extra code after every function call to ensure that the floating-point
(FP) stack is in the expected state.
By default, there is no checking. So when the FP stack overflows, a NaN value is put into FP calculations and
the program's results differ. Unfortunately, the overflow point can be far away from the point of the actual
bug. This option places code that causes an access violation exception immediately after an incorrect call
occurs, thus making it easier to locate these issues.
IDE Equivalent
Windows
Visual Studio: Floating-Point > Check Floating-Point Stack
Alternate Options
None
fpe
Allows some control over floating-point exception
handling for the main program at run-time.
Syntax
Linux OS:
-fpen
macOS:
-fpen
Windows OS:
/fpe:n
Arguments
308
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Underflow results from SSE instructions, as well as x87 instructions, will be set to zero.
By contrast, option [Q]ftz only sets SSE underflow results to zero.
NOTE
If you have more than one module, you must build each module,
including the main module, with value fpe0 (Linux) or fpe:0 (Windows) to
avoid floating-point exceptions that may occur within the modules.
Default
Description
This option allows some control over floating-point exception handling at run-time. This includes whether
exceptional floating-point values are allowed and how precisely run-time exceptions are reported.
The fpe option affects how the following conditions are handled:
When enabled exceptions occur, execution is aborted and the cause of the abort reported to the user. If
compiler option traceback is specified at compile time, detailed information about the location of the abort
is also reported.
This option does not enable underflow exceptions, input subnormal exceptions, or inexact exceptions.
309
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Visual Studio
Visual Studio: Floating-Point > Floating-Point Exception Handling
Alternate Options
None
See Also
fpe-all compiler option
ftz, Qftz compiler option
fp-model, fp compiler option
fp-speculation, Qfp-speculation compiler option
traceback compiler option
fpe-all
Allows some control over floating-point exception
handling for each routine in a program at run-time.
Syntax
Linux OS:
-fpe-all=n
macOS:
-fpe-all=n
Windows OS:
/fpe-all:n
Arguments
0 Floating-point invalid, divide-by-zero, and overflow exceptions are enabled. If any such
exceptions occur, execution is aborted. This option sets the [Q]ftz option; therefore
underflow results will be set to zero unless you explicitly specify -no-ftz (Linux and
macOS) or /Qftz- (Windows).
To get more detailed location information about where the error occurred, use option
traceback.
310
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-fpe-all=3 or /fpe-all:3 or the All floating-point exceptions are disabled. Floating-point underflow is
setting of fpe that the main gradual, unless you explicitly specify a compiler option that enables
program was compiled with flush-to-zero.
Description
This option allows some control over floating-point exception handling for each routine in a program at run-
time. This includes whether exceptional floating-point values are allowed and how precisely run-time
exceptions are reported.
The fpe-all option affects how the following conditions are handled:
The current settings of the floating-point exception and status flags are saved on each routine entry and
restored on each routine exit. This may incur some performance overhead.
When option fpe-all is applied to a main program, it has the same effect as when option fpe is applied to
the main program.
When enabled exceptions occur, execution is aborted and the cause of the abort reported to the user. If
compiler option traceback is specified at compile time, detailed information about the location of the abort
is also reported.
This option does not enable underflow exceptions, input subnormal exceptions, or inexact exceptions.
Option fpe-all sets option assume ieee_fpe_flags.
IDE Equivalent
None
Alternate Options
None
See Also
assume compiler option
fpe compiler option
ftz, Qftz compiler option
traceback compiler option
ftz, Qftz
Flushes subnormal results to zero.
Syntax
Linux OS:
-ftz
-no-ftz
macOS:
-ftz
-no-ftz
311
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qftz
/Qftz-
Arguments
None
Default
Description
This option flushes subnormal results to zero when the application is in the gradual underflow mode. It may
improve performance if the subnormal values are not critical to your application's behavior.
The [Q]ftz option has no effect during compile-time optimization.
The [Q]ftz option sets or resets the FTZ and the DAZ hardware flags. If FTZ is ON, subnormal results from
floating-point calculations will be set to the value zero. If FTZ is OFF, subnormal results remain as is. If DAZ
is ON, subnormal values used as input to floating-point instructions will be treated as zero. If DAZ is OFF,
subnormal instruction inputs remain as is. Systems using Intel® 64 architecture have both FTZ and DAZ. FTZ
and DAZ are not supported on all IA-32 architectures.
When the [Q]ftz option is used in combination with an SSE-enabling option on systems using IA-32
architecture (for example, the [Q]xSSE2 option), the compiler will insert code in the main routine to set FTZ
and DAZ. When [Q]ftz is used without such an option, the compiler will insert code to conditionally set
FTZ/DAZ based on a run-time processor check.
If you specify option -no-ftz (Linux and macOS) or option /Qftz- (Windows), it prevents the compiler from
inserting any code that might set FTZ or DAZ.
Option [Q]ftz only has an effect when the main program is being compiled. It sets the FTZ/DAZ mode for
the process. The initial thread and any threads subsequently created by that process will operate in FTZ/DAZ
mode.
If this option produces undesirable results of the numerical behavior of your program, you can turn the
FTZ/DAZ mode off by specifying -no-ftz or /Qftz- in the command line while still benefiting from the O3
optimizations.
NOTE
Option [Q]ftz is a performance option. Setting this option does not guarantee that all
subnormals in a program are flushed to zero. The option only causes subnormals generated
at run time to be flushed to zero.
IDE Equivalent
Windows
Visual Studio: IA-32 architecture: Floating Point > Flush Subnormal Results to Zero
Intel® 64 architecture: None
312
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
x, Qx compiler option
Setting the FTZ and DAZ Flags
Ge
Enables stack-checking for all functions. This is a
deprecated option that may be removed in a future
release.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Ge
Arguments
None
Default
Description
This option enables stack-checking for all functions.
This is a deprecated option that may be removed in a future release. The replacement option is /Gs0.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /Gs0
mp1, Qprec
Improves floating-point precision and consistency.
This feature is only available for ifort.
Syntax
Linux OS:
-mp1
macOS:
-mp1
313
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qprec
Arguments
None
Default
OFF The compiler provides good accuracy and run-time performance at the expense of less consistent
floating-point results.
Description
This option improves floating-point consistency. It ensures the out-of-range check of operands of
transcendental functions and improves the accuracy of floating-point compares.
This option prevents the compiler from performing optimizations that change NaN comparison semantics and
causes all values to be truncated to declared precision before they are used in comparisons. It also causes
the compiler to use library routines that give better precision results compared to the X87 transcendental
instructions.
This option disables fewer optimizations and has less impact on performance than option fltconsistency.
This option disables fewer optimizations and has less impact on performance than option
fltconsistency,-fp-model precise (Linux* and macOS), or option /fp:precise (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
fltconsistency compiler option
pc, Qpc
Enables control of floating-point significand precision.
Syntax
Linux OS:
-pcn
macOS:
-pcn
Windows OS:
/Qpcn
Arguments
314
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables control of floating-point significand precision.
Some floating-point algorithms are sensitive to the accuracy of the significand, or fractional part of the
floating-point value. For example, iterative operations like division and finding the square root can run faster
if you lower the precision with this option.
Note that a change of the default precision control or rounding mode, for example, by using the [Q]pc32
option or by user intervention, may affect the results returned by some of the mathematical functions.
IDE Equivalent
None
Alternate Options
None
prec-div, Qprec-div
Improves precision of floating-point divides. This
feature is only available for ifort.
Syntax
Linux OS:
-prec-div
-no-prec-div
macOS:
-prec-div
-no-prec-div
Windows OS:
/Qprec-div
/Qprec-div-
Arguments
None
315
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF Default heuristics are used. The default is not as accurate as full IEEE division, but it is
slightly more accurate than would be obtained when /Qprec-div- or -no-prec-div
is specified.
If you need full IEEE precision for division, you should specify [Q]prec-div.
Description
This option improves precision of floating-point divides. It has a slight impact on speed.
At default optimization levels, the compiler may change floating-point division computations into
multiplication by the reciprocal of the denominator. For example, A/B is computed as A * (1/B) to improve
the speed of the computation.
However, sometimes the value produced by this transformation is not as accurate as full IEEE division. When
it is important to have fully precise IEEE division, use this option to disable the floating-point division-to-
multiplication optimization. The result is more accurate, with some loss of performance.
If you specify -no-prec-div (Linux* and macOS) or /Qprec-div- (Windows*), it enables optimizations
that give slightly less precise results than full IEEE division.
Option [Q]prec-div is implied by option -fp-model precise (Linux* and macOS) and
option /fp:precise (Windows*).
IDE Equivalent
None
Alternate Options
None
See Also
fp-model, fp compiler option
prec-sqrt, Qprec-sqrt
Improves precision of square root implementations.
This feature is only available for ifort.
Syntax
Linux OS:
-prec-sqrt
-no-prec-sqrt
macOS:
-prec-sqrt
-no-prec-sqrt
Windows OS:
/Qprec-sqrt
/Qprec-sqrt-
Arguments
None
316
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-no-prec-sqrt The compiler uses a faster but less precise implementation of square root.
or /Qprec-sqrt- However, the default is -prec-sqrt or /Qprec-sqrt if any of the following options
are specified: /Od, /fltconsistency, or /Qprec on Windows* systems; -O0,
-fltconsistency, or -mp1 on Linux* and macOS systems.
Description
This option improves precision of square root implementations. It has a slight impact on speed.
This option inhibits any optimizations that can adversely affect the precision of a square root computation.
The result is fully precise square root implementations, with some loss of performance.
IDE Equivalent
None
Alternate Options
None
qsimd-honor-fp-model, Qsimd-honor-fp-model
Tells the compiler to obey the selected floating-point
model when vectorizing SIMD loops. This feature is
only available for ifort.
Syntax
Linux OS:
-qsimd-honor-fp-model
-qno-simd-honor-fp-model
macOS:
-qsimd-honor-fp-model
-qno-simd-honor-fp-model
Windows OS:
/Qsimd-honor-fp-model
/Qsimd-honor-fp-model-
Arguments
None
Default
Description
The OpenMP* SIMD specification and the setting of compiler option -fp-model (Linux* and macOS) or /fp
(Windows*) can contradict in requirements. When contradiction occurs, the default behavior of the compiler
is to follow the OpenMP* specification and therefore vectorize the loop.
317
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option lets you override this default behavior - it causes the compiler to follow the -fp-model (or /fp)
specification. This means that the compiler will serialize the loop.
NOTE
This option does not affect automatic vectorization of loops. By default, the compiler uses
-fp-model (Linux* and macOS) or /fp (Windows*) settings for this.
IDE Equivalent
None
Alternate Options
None
See Also
qsimd-serialize-fp-reduction, Qsimd-serialize-fp-reduction compiler option
fp-model, fp compiler option
SIMD Loop Directive directive
SIMD Directive (OpenMP* API) directive
qsimd-serialize-fp-reduction, Qsimd-serialize-fp-reduction
Tells the compiler to serialize floating-point reduction
when vectorizing SIMD loops. This feature is only
available for ifort.
Syntax
Linux OS:
-qsimd-serialize-fp-reduction
-qno-simd-serialize-fp-reduction
macOS:
-qsimd-serialize-fp-reduction
-qno-simd-serialize-fp-reduction
Windows OS:
/Qsimd-serialize-fp-reduction
/Qsimd-serialize-fp-reduction-
Arguments
None
Default
318
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The OpenMP* SIMD reduction specification and the setting of compiler option -fp-model (Linux* and
macOS) or /fp (Windows*) can contradict in requirements. When contradiction occurs, the default behavior
of the compiler is to follow OpenMP* specification and therefore vectorize the loop, including floating-point
reduction.
This option lets you override this default behavior - it causes the compiler to follow the -fp-model (or /fp)
specification. This means that the compiler will serialize the floating-point reduction while vectorizing the rest
of the loop.
NOTE
When [q or Q]simd-honor-fp-model is specified and OpenMP* SIMD reduction specification
is the only thing causing serialization of the entire loop, addition of option
[q or Q]simd-serialize-fp-reduction will result in vectorization of the entire loop except
for reduction calculation, which will be serialized.
NOTE
This option does not affect automatic vectorization of loops. By default, the compiler uses
-fp-model (Linux* and macOS) or /fp (Windows*) settings for this.
IDE Equivalent
None
Alternate Options
None
See Also
qsimd-honor-fp-model, Qsimd-honor-fp-model compiler option
fp-model, fp compiler option
SIMD Loop Directive directive
SIMD Directive (OpenMP* API) directive
rcd, Qrcd
Enables fast float-to-integer conversions. This is a
deprecated option that may be removed in a future
release. This feature is only available for ifort.
Syntax
Linux OS:
-rcd
macOS:
-rcd
Windows OS:
/Qrcd
Arguments
None
319
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables fast float-to-integer conversions. It can improve the performance of code that requires
floating-point-to-integer conversions.
This is a deprecated option that may be removed in a future release. There is no replacement option.
The system default floating-point rounding mode is round-to-nearest. However, the Fortran language
requires floating-point values to be truncated when a conversion to an integer is involved. To do this, the
compiler must change the rounding mode to truncation before each floating-point-to-integer conversion and
change it back afterwards.
This option disables the change to truncation of the rounding mode for all floating-point calculations,
including floating point-to-integer conversions. This option can improve performance, but floating-point
conversions to integer will not conform to Fortran semantics.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /QIfist (this is a deprecated option)
recursive
Tells the compiler that all routines should be compiled
for possible recursive execution.
Syntax
Linux OS:
-recursive
-norecursive
macOS:
-recursive
-norecursive
Windows OS:
/recursive
/norecursive
Arguments
None
Default
320
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option tells the compiler that all routines should be compiled for possible recursive execution. It sets
option auto.
NOTE
This option will be deprecated in a future release. We recommend you use its replacement
option: assume [no]recursion.
IDE Equivalent
Windows
Visual Studio: Code Generation > Enable Recursive Routines
Alternate Options
Linux and macOS: -assume [no]recursion
Windows: /assume:[no]recursion
See Also
auto compiler option
assume compiler option, setting [no]recursion
Inlining Options
This section contains descriptions for compiler options that pertain to inlining. They are listed in alphabetical
order.
finline
Tells the compiler to inline functions declared with !
DIR$ ATTRIBUTES FORCEINLINE.
Syntax
Linux OS:
-finline
-fno-inline
macOS:
-finline
-fno-inline
Windows OS:
None
Arguments
None
Default
-fno-inline The compiler does not inline functions declared with !DIR$ ATTRIBUTES FORCEINLINE.
321
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option tells the compiler to inline functions declared with !DIR$ ATTRIBUTES FORCEINLINE.
IDE Equivalent
None
Alternate Options
Linux and macOS: -inline-level
Windows: /Ob
finline-functions
Enables function inlining for single file compilation.
Syntax
Linux OS:
-finline-functions
-fno-inline-functions
macOS:
-finline-functions
-fno-inline-functions
Windows OS:
None
Arguments
None
Default
-finline-functions Interprocedural optimizations occur. However, if you specify -O0, the default
is OFF.
Description
This option enables function inlining for single file compilation.
It enables the compiler to perform inline function expansion for calls to functions defined within the current
source file.
The compiler applies a heuristic to perform the function expansion. To specify the size of the function to be
expanded, use the -finline-limit option.
IDE Equivalent
None
Alternate Options
Linux and macOS: -inline-level=2
Windows: /Ob2
322
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ip, Qip compiler option
finline-limit compiler option
finline-limit
Lets you specify the maximum size of a function to be
inlined.
Syntax
Linux OS:
-finline-limit=n
macOS:
-finline-limit=n
Windows OS:
None
Arguments
Default
Description
This option lets you specify the maximum size of a function to be inlined. The compiler inlines smaller
functions, but this option lets you inline large functions. For example, to indicate a large function, you could
specify 100 or 1000 for n.
Note that parts of functions cannot be inlined, only whole functions.
This option is a modification of the -finline-functions option, whose behavior occurs by default.
IDE Equivalent
None
Alternate Options
None
See Also
finline-functions compiler option
inline
Specifies the level of inline function expansion.
Syntax
Linux OS:
None
323
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/inline[:keyword]
Arguments
none Disables inlining of user-defined functions. This is the same as specifying manual.
manual Disables inlining of user-defined functions. Fortran statement functions are always
inlined.
size Enables inlining of any function. However, the compiler decides which functions
are inlined.
This option enables interprocedural optimizations and most speed optimizations.
speed Enables inlining of any function. This is the same as specifying all.
all Enables inlining of any function. However, the compiler decides which functions
are inlined.
This option enables interprocedural optimizations and all speed optimizations. This
is the same as specifying inline with no keyword.
Default
Description
This option specifies the level of inline function expansion.
IDE Equivalent
None
Alternate Options
See Also
finline-functions compiler option
324
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
inline-factor, Qinline-factor
Specifies the percentage multiplier that should be
applied to all inlining options that define upper limits.
This feature is only available for ifort.
Syntax
Linux OS:
-inline-factor=n
-no-inline-factor
macOS:
-inline-factor=n
-no-inline-factor
Windows OS:
/Qinline-factor:n
/Qinline-factor-
Arguments
Default
Description
This option specifies the percentage multiplier that should be applied to all inlining options that define upper
limits:
• [Q]inline-max-size
• [Q]inline-max-total-size
• [Q]inline-max-per-routine
• [Q]inline-max-per-compile
The [Q]inline-factor option takes the default value for each of the above options and multiplies it by n
divided by 100. For example, if 200 is specified, all inlining options that define upper limits are multiplied by
a factor of 2. This option is useful if you do not want to individually increase each option limit.
If you specify -no-inline-factor (Linux* and macOS) or /Qinline-factor- (Windows*), the following
occurs:
• Every function is considered to be a small or medium function; there are no large functions.
• There is no limit to the size a routine may grow when inline expansion is performed.
• There is no limit to the number of times some routine may be inlined into a particular routine.
• There is no limit to the number of times inlining can be applied to a compilation unit.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
325
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
When you use this option to increase default limits, the compiler may do so much additional
inlining that it runs out of memory and terminates with an "out of memory" message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-max-size, Qinline-max-size compiler option
inline-max-total-size, Qinline-max-total-size compiler option
inline-max-per-routine, Qinline-max-per-routine compiler option
inline-max-per-compile, Qinline-max-per-compile compiler option
qopt-report, Qopt-report compiler option (ifort)
inline-forceinline, Qinline-forceinline
Instructs the compiler to force inlining of functions
suggested for inlining whenever the compiler is
capable doing so. This feature is only available for
ifort.
Syntax
Linux OS:
-inline-forceinline
macOS:
-inline-forceinline
Windows OS:
/Qinline-forceinline
Default
OFF The compiler uses default heuristics for inline routine expansion.
Description
This option instructs the compiler to force inlining of functions suggested for inlining whenever the compiler
is capable doing so.
Without this option, the compiler treats functions declared with an INLINE attribute as merely being
recommended for inlining. When this option is used, it is as if they were declared with the directive !DIR$
ATTRIBUTES FORCEINLINE.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
326
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
When you use this option to change the meaning of inline to "forceinline", the compiler may
do so much additional inlining that it runs out of memory and terminates with an "out of
memory" message.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
inline-level, Ob
Specifies the level of inline function expansion.
Syntax
Linux OS:
-inline-level=n
macOS:
-inline-level=n
Windows OS:
/Obn
Arguments
Default
-inline-level=0 or /Ob0 This is the default if option -O0 (Linux* and macOS) or /Od
(Windows*) is specified.
Description
This option specifies the level of inline function expansion. Inlining procedures can greatly improve the run-
time performance of certain programs.
Option Description
-inline-level=0 or /Ob0 Disables inlining of user-defined functions. Note that statement functions
are always inlined.
-inline-level=1 or /Ob1 Enables inlining when an inline keyword or an inline directive is specified.
327
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Optimization > Inline Function Expansion
Alternate Options
None
See Also
inline compiler option
inline-max-per-compile, Qinline-max-per-compile
Specifies the maximum number of times inlining may
be applied to an entire compilation unit. This feature is
only available for ifort.
Syntax
Linux OS:
-inline-max-per-compile=n
-no-inline-max-per-compile
macOS:
-inline-max-per-compile=n
-no-inline-max-per-compile
Windows OS:
/Qinline-max-per-compile=n
/Qinline-max-per-compile-
Arguments
Default
-no-inline-max-per-compile The compiler uses default heuristics for inline routine expansion.
or /Qinline-max-per-compile-
Description
This option the maximum number of times inlining may be applied to an entire compilation unit. It limits the
number of times that inlining can be applied.
For compilations using Interprocedural Optimizations (IPO), the entire compilation is a compilation unit. For
other compilations, a compilation unit is a file.
If you specify -no-inline-max-per-compile (Linux* and macOS) or /Qinline-max-per-compile-
(Windows*), there is no limit to the number of times inlining may be applied to a compilation unit.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
328
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option (ifort)
inline-max-per-routine, Qinline-max-per-routine
Specifies the maximum number of times the inliner
may inline into a particular routine. This feature is
only available for ifort.
Syntax
Linux OS:
-inline-max-per-routine=n
-no-inline-max-per-routine
macOS:
-inline-max-per-routine=n
-no-inline-max-per-routine
Windows OS:
/Qinline-max-per-routine=n
/Qinline-max-per-routine-
Arguments
Default
-no-inline-max-per-routine The compiler uses default heuristics for inline routine expansion.
or /Qinline-max-per-routine-
Description
This option specifies the maximum number of times the inliner may inline into a particular routine. It limits
the number of times that inlining can be applied to any routine.
If you specify -no-inline-max-per-routine (Linux* and macOS) or /Qinline-max-per-routine-
(Windows*), there is no limit to the number of times some routine may be inlined into a particular routine.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
329
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option (ifort)
inline-max-size, Qinline-max-size
Specifies the lower limit for the size of what the inliner
considers to be a large routine. This feature is only
available for ifort.
Syntax
Linux OS:
-inline-max-size=n
-no-inline-max-size
macOS:
-inline-max-size=n
-no-inline-max-size
Windows OS:
/Qinline-max-size=n
/Qinline-max-size-
Arguments
Default
-inline-max-size The compiler sets the maximum size (n) dynamically, based on
or /Qinline-max-size the platform.
Description
This option specifies the lower limit for the size of what the inliner considers to be a large routine (a function
or subroutine). The inliner classifies routines as small, medium, or large. This option specifies the boundary
between what the inliner considers to be medium and large-size routines.
The inliner prefers to inline small routines. It has a preference against inlining large routines. So, any large
routine is highly unlikely to be inlined.
330
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify -no-inline-max-size (Linux* and macOS) or /Qinline-max-size- (Windows*), there are
no large routines. Every routine is either a small or medium routine.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-min-size, Qinline-min-size compiler option
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option (ifort)
inline-max-total-size, Qinline-max-total-size
Specifies how much larger a routine can normally
grow when inline expansion is performed. This feature
is only available for ifort.
Syntax
Linux OS:
-inline-max-total-size=n
-no-inline-max-total-size
macOS:
-inline-max-total-size=n
-no-inline-max-total-size
Windows OS:
/Qinline-max-total-size=n
/Qinline-max-total-size-
Arguments
Default
-no-inline-max-total-size The compiler uses default heuristics for inline routine expansion.
or /Qinline-max-total-size-
331
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option specifies how much larger a routine can normally grow when inline expansion is performed. It
limits the potential size of the routine. For example, if 2000 is specified for n, the size of any routine will
normally not increase by more than 2000.
If you specify -no-inline-max-total-size (Linux* and macOS) or /Qinline-max-total-size-
(Windows*), there is no limit to the size a routine may grow when inline expansion is performed.
To see compiler values for important inlining limits, specify option [q or Q]opt-report.
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-factor, Qinline-factor compiler option
qopt-report, Qopt-report compiler option (ifort)
inline-min-caller-growth, Qinline-min-caller-growth
Lets you specify a procedure size n for which
procedures of size <= n do not contribute to the
estimated growth of the caller when inlined. This
feature is only available for ifort.
Syntax
Linux OS:
-inline-min-caller-growth=n
macOS:
-inline-min-caller-growth=n
Windows OS:
/Qinline-min-caller-growth=n
Arguments
Default
332
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option lets you specify a procedure size n for which procedures of size <= n do not contribute to the
estimated growth of the caller when inlined. It allows you to inline procedures that the compiler would
otherwise consider too large to inline.
NOTE
We recommend that you choose a value of n <= 10; otherwise, compile time and code size
may greatly increase.
IDE Equivalent
None
Alternate Options
None
inline-min-size, Qinline-min-size
Specifies the upper limit for the size of what the
inliner considers to be a small routine. This feature is
only available for ifort.
Syntax
Linux OS:
-inline-min-size=n
-no-inline-min-size
macOS:
-inline-min-size=n
-no-inline-min-size
Windows OS:
/Qinline-min-size=n
/Qinline-min-size-
Arguments
Default
-no-inline-min-size The compiler uses default heuristics for inline routine expansion.
or /Qinline-min-size-
Description
This option specifies the upper limit for the size of what the inliner considers to be a small routine (a function
or subroutine). The inliner classifies routines as small, medium, or large. This option specifies the boundary
between what the inliner considers to be small and medium-size routines.
The inliner has a preference to inline small routines. So, when a routine is smaller than or equal to the
specified size, it is very likely to be inlined.
333
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
When you use this option to increase the default limit, the compiler may do so much
additional inlining that it runs out of memory and terminates with an "out of memory"
message.
IDE Equivalent
None
Alternate Options
None
See Also
inline-max-size, Qinline-max-size compiler option
qopt-report, Qopt-report compiler option (ifort)
Qinline-dllimport
Determines whether dllimport functions are inlined.
This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qinline-dllimport
/Qinline-dllimport-
Arguments
None
Default
Description
This option determines whether dllimport functions are inlined. To disable dllimport functions from being
inlined, specify /Qinline-dllimport-.
IDE Equivalent
None
334
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
bintext
Places a text string into the object file (.obj) being
generated by the compiler. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/bintext:string
/nobintext
Arguments
Default
Description
This option places a text string into the object file (.obj) being generated by the compiler. The string also
gets propagated into the executable file.
For example, this option is useful if you want to place a version number or copyright information into the
object and executable.
If the string contains a space or tab, the string must be enclosed by double quotation marks ("). A backslash
(\) must precede any double quotation marks contained within the string.
If the command line contains multiple /bintext options, the last (rightmost) one is used.
IDE Equivalent
Windows
Visual Studio: Code Generation > Object Text String
Alternate Options
Linux and macOS: None
Windows: /Vstring
335
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
c
Prevents linking.
Syntax
Linux OS:
-c
macOS:
-c
Windows OS:
/c
Arguments
None
Default
Description
This option prevents linking. Compilation stops after the object file is generated.
The compiler generates an object file for each Fortran source file.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /compile-only, /nolink
Syntax
Linux OS:
-debug [keyword]
macOS:
-debug [keyword]
Windows OS:
None
Arguments
336
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For information on the non-default settings for these keywords, see the Description section.
Default
Description
This option enables or disables generation of debugging information.
By default, enabling debugging, will disable optimization. To enable both debugging and optimization use the
-debug option together with one of the optimization level options (-O3, -O2 or -O3).
Keywords semantic-stepping, inline-debug-info, variable-locations, and extended can be used in
combination with each other. If conflicting keywords are used in combination, the last one specified on the
command line has precedence.
Option Description
-debug full or -debug all Generates complete debugging information. It is the same as specifying
-debug with no keyword.
337
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
On inlined functions, symbols are (by default) associated with the caller.
This option causes symbols for inlined functions to be associated with the
source of the called function.
-debug pubnames The compiler generates a DWARF debug_pubnames section. This provides
a means to list the names of global objects and functions in a compilation
unit.
-debug semantic-stepping Generates enhanced debug information useful for breakpoints and
stepping. It tells the debugger to stop only at machine instructions that
achieve the final effect of a source statement.
For example, in the case of an assignment statement, this might be a
store instruction that assigns a value to a program variable; for a function
call, it might be the machine instruction that executes the call. Other
instructions generated for those source statements are not displayed
during stepping.
This option has no impact unless optimizations have also been enabled.
-debug variable-locations Generates enhanced debug information useful in finding scalar local
variables. It uses a feature of the Dwarf object module known as
"location lists".
This feature allows the run-time locations of local scalar variables to be
specified more accurately; that is, whether, at a given position in the
code, a variable value is found in memory or a machine register.
-debug parallel Generates parallel debug code instrumentations needed for the thread
data sharing and reentrant call detection.
On Linux* systems, debuggers read debug information from executable images. As a result, information is
written to object files and then added to the executable by the linker.
On macOS systems, debuggers read debug information from object files. As a result, the executables don't
contain any debug information. Therefore, if you want to be able to debug on these systems, you must retain
the object files.
IDE Equivalent
None
Alternate Options
338
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: None
Windows: None
See Also
debug (Windows*) compiler option
qopenmp, Qopenmp compiler option
debug (Windows*)
Enables or disables generation of debugging
information.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/debug[:keyword]
/nodebug
Arguments
For information on the non-default settings for these keywords, see the Description section.
Default
/debug:none This is the default on the command line and for a release configuration in the IDE.
Description
This option enables or disables generation of debugging information. It is passed to the linker.
By default, enabling debugging, will disable optimization. To enable both debugging and optimization use
the /debug option together with one of the optimization level options (/O3, /O2 or /O3).
If conflicting keywords are used in combination, the last one specified on the command line has precedence.
339
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
IDE Equivalent
Windows
Visual Studio: General > Debug Information Format (/debug:minimal, /debug:full)
Alternate Options
See Also
dbglibs compiler option
debug (Linux* and macOS) compiler option
debug-parameters
Tells the compiler to generate debug information for
PARAMETERs used in a program.
Syntax
Linux OS:
-debug-parameters [keyword]
-nodebug-parameters
macOS:
-debug-parameters [keyword]
-nodebug-parameters
340
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/debug-parameters[:keyword]
/nodebug-parameters
Arguments
keyword Specifies the PARAMETERs to generate debug information for. Possible values are:
none Generates no debug information for any PARAMETERs used in the program.
This is the same as specifying nodebug-parameters.
used Generates debug information for only PARAMETERs that have actually been
referenced in the program. This is the default if you do not specify a
keyword.
all Generates debug information for all PARAMETERs defined in the program.
Default
nodebug-parameters The compiler generates no debug information for any PARAMETERs used in
the program. This is the same as specifying keyword none.
Description
This option tells the compiler to generate debug information for PARAMETERs used in a program.
Note that if a .mod file contains PARAMETERs, debug information is only generated for the PARAMETERs that
have actually been referenced in the program, even if you specify keyword all.
IDE Equivalent
Windows
Visual Studio: Debugging > Information for PARAMETER Constants
Alternate Options
None
exe
Specifies the name for a built program or dynamic-link
library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/exe:{filename | dir}
341
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
dir Is the directory where the built program or dynamic-link library should be placed. It can
include filename.
Default
OFF The name of the file is the name of the first source file on the command line with file
extension .exe, so file.f becomes file.exe.
Description
This option specifies the name for a built program (.EXE) or a dynamic-link library (.DLL).
You can use this option to specify an alternate name for an executable file. This is especially useful when
compiling and linking a set of input files. You can use the option to give the resulting file a name other than
that of the first input file (source or object) on the command line.
You can use this option to specify an alternate name for an executable file. This is especially useful when
compiling and linking a set of input files. You can use the option to give the resulting file a name other than
that of the first input file (source or object) on the command line.
IDE Equivalent
None
Alternate Options
Linux and macOS: -o
Windows: /Fe
Example
The following example creates a dynamic-link library file named file.dll (note that you can use /LD in place
of /dll):
See Also
o compiler option
Fa
Specifies that an assembly listing file should be
generated.
Syntax
Linux OS:
-Fa[filename|dir]
342
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-Fa[filename|dir]
Windows OS:
/Fa[filename|dir]
Arguments
dir Is the directory where the file should be placed. It can include
filename.
Default
Description
This option specifies that an assembly listing file should be generated (optionally named filename).
If filename is not specified, the file name will be the name of the source file with an extension of .asm; the
file is placed in the current directory.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Windows
Visual Studio: Output > ASM Listing Name
Alternate Options
Linux and macOS: -S
FA
Specifies the contents of an assembly listing file.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/FA[specifier]
343
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
specifier Denotes the contents of the assembly listing file. Possible values are c, s, or cs.
Default
OFF No source or machine code annotations appear in the assembly listing file, if one is produced.
Description
These options specify what information, in addition to the assembly code, should be generated in the
assembly listing file.
To use this option, you must also specify option /Fa, which causes an assembly listing to be generated.
Option Description
/FAcs Produces an assembly listing with source and machine code annotations.
The assembly listing file shows the source code as interspersed
comments and shows the hex machine instructions at the beginning of
each line of assembly code. This file cannot be assembled.
IDE Equivalent
Windows
Visual Studio: Output Files > Assembler Output
Alternate Options
Windows: None
Windows: None
fcode-asm
Produces an assembly listing with machine code
annotations. This feature is only available for ifort.
344
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fcode-asm
macOS:
-fcode-asm
Windows OS:
None
Arguments
None
Default
OFF No machine code annotations appear in the assembly listing file, if one is produced.
Description
This option produces an assembly listing file with machine code annotations.
The assembly listing file shows the hex machine instructions at the beginning of each line of assembly code.
The file cannot be assembled; the file name is the name of the source file with an extension of .cod.
To use this option, you must also specify option -S, which causes an assembly listing to be generated.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /FAc
See Also
S compiler option
Fd
Lets you specify a name for a program database
(PDB) file created by the compiler. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Fd[:filename]
345
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
filename Is the name for the PDB file. It can include a path. If you do not
specify a file extension, the extension .pdb is used.
Default
OFF No PDB file is created unless you specify option /Zi. If you specify option /Zi and /Fd, the
default filename is vcx0.pdb, where x represents the version of Visual C++, for example
vc100.pdb.
Description
This option lets you specify a name for a program database (PDB) file that is created by the compiler.
A program database (PDB) file holds debugging and project state information that allows incremental linking
of a Debug configuration of your program. A PDB file is created when you build with option /Zi. Option /Fd
has no effect unless you specify option /Zi.
IDE Equivalent
Windows
Visual Studio: Output Files > Program Database File Name
Alternate Options
None
See Also
Zi, Z7 compiler option
pdbfile compiler option
feliminate-unused-debug-types, Qeliminate-unused-debug-types
Controls the debug information emitted for types
declared in a compilation unit. This feature is only
available for ifort.
Syntax
Linux OS:
-feliminate-unused-debug-types
-fno-eliminate-unused-debug-types
macOS:
-feliminate-unused-debug-types
-fno-eliminate-unused-debug-types
Windows OS:
/Qeliminate-unused-debug-types
/Qeliminate-unused-debug-types-
Arguments
None
346
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-feliminate-unused-debug-types The compiler emits debug information only for types that are actually
or used by a variable/parameter/etc..
/Qeliminate-unused-debug-types
Description
This option controls the debug information emitted for types declared in a compilation unit.
If you specify -fno-eliminate-unused-debug-types (Linux and macOS)
or /Qeliminate-unused-debug-types-, it will cause the compiler to emit debug information for all types
present in the sources. This option may cause a large increase in the size of the debug information.
IDE Equivalent
None
Alternate Options
None
fmerge-constants
Determines whether the compiler and linker attempt
to merge identical constants (string constants and
floating-point constants) across compilation units. This
feature is only available for ifort.
Syntax
Linux OS:
-fmerge-constants
-fno-merge-constants
macOS:
None
Windows OS:
None
Arguments
None
Default
-fmerge-constants The compiler and linker attempt to merge identical constants across
compilation units if the compiler and linker supports it.
Description
This option determines whether the compiler and linker attempt to merge identical constants (string
constants and floating-point constants) across compilation units.
If you do not want the compiler and linker to attempt to merge identical constants across compilation units.
specify -fno-merge-constants.
347
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
fmerge-debug-strings
Causes the compiler to pool strings used in debugging
information.
Syntax
Linux OS:
-fmerge-debug-strings
-fno-merge-debug-strings
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option causes the compiler to pool strings used in debugging information. The linker will automatically
retain this pooling.
This option can reduce the size of debug information, but it may produce slightly slower compile and link
times.
This option is only turned on by default if you are using gcc 4.3 or higher, where this setting is also the
default, since the generated debug tables require binutils version 2.17 or higher to work reliably.
If you do not want the compiler to pool strings used in debugging information, specify option
-fno-merge-debug-strings.
IDE Equivalent
None
Alternate Options
None
fsource-asm
Produces an assembly listing with source code
annotations. This feature is only available for ifort.
348
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fsource-asm
macOS:
-fsource-asm
Windows OS:
None
Arguments
None
Default
OFF No source code annotations appear in the assembly listing file, if one is produced.
Description
This option produces an assembly listing file with source code annotations. The assembly listing file shows
the source code as interspersed comments.
To use this option, you must also specify option -S, which causes an assembly listing to be generated.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /FAs
See Also
S compiler option
ftrapuv, Qtrapuv
Initializes stack local variables to an unusual value to
aid error detection. This feature is only available for
ifort.
Syntax
Linux OS:
-ftrapuv
macOS:
-ftrapuv
Windows OS:
/Qtrapuv (ifort only)
Arguments
None
349
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option initializes stack local variables to an unusual value to aid error detection. Normally, these local
variables should be initialized in the application. It also unmasks the floating-point invalid exception.
The option sets any uninitialized local variables that are allocated on the stack to a value that is typically
interpreted as a very large integer or an invalid address. References to these variables are then likely to
cause run-time errors that can help you detect coding errors.
This option sets option -g (Linux* and macOS) and /Zi or /Z7 (Windows*), which changes the default
optimization level from O2 to -O0 (Linux and macOS) or /Od (Windows). You can override this effect by
explicitly specifying an O option setting.
If option O2 and option -ftrapuv (Linux and macOS) or /Qtrapuv (Windows) are used together, you should
specify option -fp-speculation safe (Linux and macOS) or /Qfp-speculation:safe (Windows) to
prevent exceptions resulting from speculated floating-point operations from being trapped.
For more details on using options -ftrapuv and /Qtrapuv with compiler option O, see the article titled Don't
optimize when using -ftrapuv for uninitialized variable detection.
Another way to detect uninitialized local scalar variables is by specifying keyword uninit for option check.
IDE Equivalent
Windows
Visual Studio: Data > Initialize stack variables to an unusual value
Alternate Options
None
See Also
g compiler option
Zi, Z7 compiler option
O compiler option
check compiler option (see setting uninit)
init, Qinit compiler option (see setting snan)
Locating Run-Time Errors
fverbose-asm
Produces an assembly listing with compiler comments,
including options and version information.
Syntax
Linux OS:
-fverbose-asm
-fno-verbose-asm
macOS:
-fverbose-asm
350
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-fno-verbose-asm
Windows OS:
None
Arguments
None
Default
-fno-verbose-asm No source code annotations appear in the assembly listing file, if one
is produced.
Description
This option produces an assembly listing file with compiler comments, including options and version
information.
To use this option, you must also specify -S, which sets -fverbose-asm.
If you do not want this default when you specify -S, specify -fno-verbose-asm.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
S compiler option
g
Tells the compiler to generate a level of debugging
information in the object file.
Syntax
Linux OS:
-g[n]
macOS:
-g[n]
Windows OS:
See option Zi, Z7.
Arguments
351
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
Option -g tells the compiler to generate symbolic debugging information in the object file, which increases
the size of the object file.
The compiler does not support the generation of debugging information in assemblable files. If you specify
this option, the resulting object file will contain debugging information, but the assemblable file will not.
This option turns off option -O2 and makes option -O0 the default unless option -O2 (or higher) is explicitly
specified in the same command line.
Specifying the -g or -O0 option sets the -fno-omit-frame-pointer option.
NOTE
When option -g is specified, debugging information is generated in the DWARF Version 3
format. Older versions of some analysis tools may require applications to be built with the
-gdwarf-2 option to ensure correct operation.
IDE Equivalent
None
Alternate Options
Linux: None
Windows: /Zi, /Z7
See Also
gdwarf compiler option
Zi, Z7 compiler option
debug (Linux* and macOS) compiler option
gdwarf
Lets you specify a DWARF Version format when
generating debug information.
352
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-gdwarf-n
macOS:
-gdwarf-n
Windows OS:
None
Arguments
Default
Description
This option lets you specify a DWARF Version format when generating debug information.
Note that older versions of some analysis tools may require applications to be built with the -gdwarf-2 option
to ensure correct operation.
IDE Equivalent
None
Alternate Options
None
See Also
g compiler option
grecord-gcc-switches
Causes the command line options that were used to
invoke the compiler to be appended to the
DW_AT_producer attribute in DWARF debugging
information.
Syntax
Linux OS:
-grecord-gcc-switches
353
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF The command line options that were used to invoke the compiler are
not appended to the DW_AT_producer attribute in DWARF debugging
information.
Description
This option causes the command line options that were used to invoke the compiler to be appended to the
DW_AT_producer attribute in DWARF debugging information.
The options are concatenated with whitespace separating them from each other and from the compiler
version.
IDE Equivalent
None
Alternate Options
None
gsplit-dwarf
Creates a separate object file containing DWARF
debug information.
Syntax
Linux OS:
-gsplit-dwarf
macOS:
None
Windows OS:
None
Arguments
None
Default
354
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option creates a separate object file containing DWARF debug information. It causes debug information
to be split between the generated object (.o) file and the new DWARF object (.dwo) file.
The DWARF object file is not used by the linker, so this reduces the amount of debug information the linker
must process and it results in a smaller executable file.
For this option to perform correctly, you must use binutils-2.24 or higher. To debug the resulting executable,
you must use gdb-7.6.1 or higher.
NOTE
If you use the split executable with a tool that does not support the split DWARF format, it
will behave as though the DWARF debug information is absent.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
list
Tells the compiler to create a listing of the source file.
Syntax
Linux OS:
-list[=filename]
-no-list
macOS:
-list[=filename]
-no-list
Windows OS:
/list[:filename]
/list-
Arguments
filename Is the name of the file for output. It can include a path.
Default
355
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option tells the compiler to create a listing of the source file. The listing contains the following:
The line length of the listing can be specified by using option list-line-len.
The page length of the listing can be specified by using option list-page-len.
If you do not specify filename, the output is written to a file in the same directory as the source. The file
name is the name of the source file with an extension of .lst.
IDE Equivalent
Windows
Visual Studio: Output Files > Source Listing (/list)
Output Files > Source Listing File (/list:[filename])
Alternate Options
None
See Also
show compiler option
list-line-len compiler option
list-page-len compiler option
list-line-len
Specifies the line length for the listing generated when
option list is specified.
Syntax
Linux OS:
-list-line-len=n
macOS:
-list-line-len=n
Windows OS:
/list-line-len:n
Arguments
Default
Description
This option specifies the line length for the listing generated when option list is specified.
356
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify option list-line-len and do not specify option list, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
list compiler option
list-page-len compiler option
list-page-len
Specifies the page length for the listing generated
when option list is specified.
Syntax
Linux OS:
-list-page-len=n
macOS:
-list-page-len=n
Windows OS:
/list-page-len:n
Arguments
n Is a positive integer indicating the number of lines on a page to show in the listing.
Default
Description
This option specifies the page length for the listing generated when option list is specified.
If you specify option list-page-len and do not specify option list, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
list compiler option
list-line-len compiler option
357
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
map-opts, Qmap-opts
Maps one or more compiler options to their equivalent
on a different operating system. This feature is only
available for ifort.
Syntax
Linux OS:
-map-opts
macOS:
None
Windows OS:
/Qmap-opts
Arguments
None
Default
Description
This option maps one or more compiler options to their equivalent on a different operating system. The result
is output to stdout.
On Windows systems, the options you provide are presumed to be Windows options, so the options that are
output to stdout will be Linux equivalents.
On Linux systems, the options you provide are presumed to be Linux options, so the options that are output
to stdout will be Windows equivalents.
• Option mapping information for options included in the compiler configuration file
• Alternate forms of the options that are supported but may not be documented
The option mapping can be invoked from the compiler command line or it can be used directly.
No compilation is performed when option mapping is used.
This option is useful if you have both compilers and want to convert scripts or makefiles.
NOTE
Compiler options are mapped to their equivalent on the architecture you are using.
IDE Equivalent
None
Alternate Options
None
358
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following command line maps the Linux options to Windows-based options, and then outputs the results
to stdout:
o
Specifies the name for an output file.
Syntax
Linux OS:
-o filename
359
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-o filename
Windows OS:
None
Arguments
filename Is the name for the output file. The space before filename is optional.
Default
OFF The compiler uses the default file name for an output file.
Description
This option specifies the name for an output file as follows:
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /exe
See Also
object compiler option
exe compiler option
object
Specifies the name for an object file.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/object:filename
360
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
filename Is the name for the object file. It can be a file name or a directory name. A directory name must
be followed by a backslash (\). If a special character appears within the file name or directory
name, the file name or directory name must appear within quotes. To be safe, you should
consider any non-ASCII numeric character to be a special character.
Default
OFF An object file has the same name as the name of the first source file and a file extension of .obj.
Description
This option specifies the name for an object file.
If you specify this option and you omit /c or /compile-only, the /object option gives the object file its
name.
On Linux and macOS systems, this option is equivalent to specifying option -ofilename-c.
IDE Equivalent
Windows
Visual Studio: Output Files > Object File Name
Alternate Options
Linux and macOS: None
Windows: /Fo
Example
The following command shows how to specify a directory:
See Also
o compiler option
pdbfile
Lets you specify the name for a program database
(PDB) file created by the linker. This feature is only
available for ifort.
Syntax
Linux OS:
None
361
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/pdbfile[:filename]
Arguments
filename Is the name for the PDB file. It can include a path. If you do not
specify a file extension, the extension .pdb is used.
Default
OFF No PDB file is created unless you specify option /Zi. If you specify option /Zi the default
filename is executablename.pdb.
Description
This option lets you specify the name for a program database (PDB) file created by the linker. This option
does not affect where the compiler outputs debug information.
To use this option, you must also specify option /debug:full or /Zi.
If filename is not specified, the default file name used is the name of your file with an extension of .pdb.
IDE Equivalent
None
Alternate Options
None
See Also
Zi, Z7 compiler option
debug compiler option
Fd compiler option
print-multi-lib
Prints information about where system libraries should
be found.
Syntax
Linux OS:
-print-multi-lib
macOS:
-print-multi-lib
Windows OS:
None
Arguments
None
362
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option prints information about where system libraries should be found, but no compilation occurs. On
Linux* systems, it is provided for compatibility with gcc.
IDE Equivalent
None
Alternate Options
None
Quse-msasm-symbols
Tells the compiler to use a dollar sign ("$") when
producing symbol names. This feature is only available
for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Quse-msasm-symbols
Arguments
None
Default
OFF The compiler uses a period (".") when producing symbol names
Description
This option tells the compiler to use a dollar sign ("$") when producing symbol names.
Use this option if you require symbols in your .asm files to contain characters that are accepted by the MS
assembler.
IDE Equivalent
None
Alternate Options
None
S
Causes the compiler to compile to an assembly file
only and not link.
363
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-S
macOS:
-S
Windows OS:
/S
Arguments
None
Default
Description
This option causes the compiler to compile to an assembly file only and not link.
On Linux* and macOS systems, the assembly file name has a .s suffix. On Windows* systems, the assembly
file name has an .asm suffix.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /Fa
See Also
Fa compiler option
show
Controls the contents of the listing generated when
option list is specified.
Syntax
Linux OS:
-show keyword[, keyword...]
macOS:
-show keyword[, keyword...]
Windows OS:
/show:keyword[, keyword...]
Arguments
keyword Specifies the contents for the listing. Possible values are:
364
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[no]options Controls whether a list of compiler options used for the compilation
is included when a listing is generated.
Default
include, map, and When a listing is generated, it contains the contents of INCLUDEd files, a symbol list
options with a line number cross reference, and a list of compiler options used.
Description
This option controls the contents of the listing generated when option list is specified.
If you specify option show and do not specify option list, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
list compiler option
use-asm, Quse-asm
Tells the compiler to produce objects through the
assembler. This is a deprecated option that may be
removed in a future release. This feature is only
available for ifort.
Syntax
Linux OS:
-use-asm
-no-use-asm
macOS:
-use-asm
-no-use-asm
Windows OS:
/Quse-asm
/Quse-asm-
Arguments
None
365
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the compiler to produce objects through the assembler.
This is a deprecated option that may be removed in a future release. There is no replacement option.
IDE Equivalent
None
Alternate Options
None
Zi, Z7
Tells the compiler to generate full debugging
information in either an object (.obj) file or a project
database (PDB) file.
Syntax
Linux OS:
See option g.
macOS:
See option g.
Windows OS:
/Zi
/Z7
Arguments
None
Default
Description
Option /Z7 tells the compiler to generate symbolic debugging information in the object (.obj) file for use with
the debugger. No .pdb file is produced by the compiler.
The /Zi option tells the compiler to generate symbolic debugging information in a program database (PDB)
file for use with the debugger. Type information is placed in the .pdb file, and not in the .obj file, resulting in
smaller object files in comparison to option /Z7.
• The compiler creates the program database project.pdb. If you compile a file without a project, the
compiler creates a database named vcx0.pdb, where x represents the major version of Visual C++, for
example vc140.pdb.
This file stores all debugging information for the individual object files and resides in the same directory
as the project makefile. If you want to change this name, use option /Fd.
366
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Both PDB files allow incremental updates. The linker also embeds the path to the .pdb file in the .exe or .dll
file that it creates.
The compiler does not support the generation of debugging information in assemblable files. If you specify
these options, the resulting object file will contain debugging information, but the assemblable file will not.
These options turn off option /O2 and make option /Od the default unless option /O2 (or higher) is explicitly
specified in the same command line.
For more information about the /Z7 and /Zi options, see the Microsoft documentation.
IDE Equivalent
Visual Studio
Visual Studio: General > Generate Debug Information
Alternate Options
Linux: -g
Windows: None
See Also
Fd compiler option
g compiler option
debug (Windows*) compiler option
Zo
Enables or disables generation of enhanced debugging
information for optimized code. This feature is only
available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Zo
/Zo-
Arguments
None
Default
OFF The compiler does not generate enhanced debugging information for optimized code.
367
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option enables or disables the generation of additional debugging information for local variables and
inlined routines when code optimizations are enabled. It should be used with option /Zi or /Z7 to allow
improved debugging of optimized code.
Option /Zo enables generation of this enhanced debugging information. Option /Zo- disables this
functionality.
For more information on code optimization, see option /O.
IDE Equivalent
None
Alternate Options
None
See Also
Zi, Z7 compiler option
debug (Windows*) compiler option
O compiler option
Preprocessor Options
This section contains descriptions for compiler options that pertain to preprocessing. They are listed in
alphabetical order.
B
Specifies a directory that can be used to find include
files, libraries, and executables.
Syntax
Linux OS:
-Bdir
macOS:
-Bdir
Windows OS:
None
Arguments
Default
OFF The compiler looks for files in the directories specified in your PATH environment variable.
Description
This option specifies a directory that can be used to find include files, libraries, and executables.
The compiler uses dir as a prefix.
368
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For include files, the dir is converted to -I/dir/include. This command is added to the front of the includes
passed to the preprocessor.
For libraries, the dir is converted to -L/dir. This command is added to the front of the standard -L inclusions
before system libraries are added.
For executables, if dir contains the name of a tool, such as ld or as, the compiler will use it instead of those
found in the default directories.
The compiler looks for include files in dir /include while library files are looked for in dir.
IDE Equivalent
None
Alternate Options
None
D
Defines a symbol name that can be associated with an
optional value.
Syntax
Linux OS:
-Dname[=value]
macOS:
-Dname[=value]
Windows OS:
/Dname[=value]
Arguments
Default
Description
Defines a symbol name that can be associated with an optional value. This definition is used during
preprocessing in both Intel® Fortran conditional compilation directives and the fpp preprocessor. The
Dname=value will be ignored if there are any non-alphabetic, non-numeric characters in name.
If a value is not specified, name is defined as "1".
If you want to specify more than one definition, you must use separate D options.
If you specify noD, all preprocessor definitions apply only to fpp and not to Intel® Fortran conditional
compilation directives. To use this option, you must also specify the fpp option.
369
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
Linux and macOS
If you are not specifying a value, do not use D for name, because it will conflict with the -DD option.
IDE Equivalent
Windows
Visual Studio: General > Preprocessor Definitions
Preprocessor> Preprocessor Definitions
Preprocessor > Preprocessor Definitions to FPP only
Alternate Options
See Also
Using Predefined Preprocessor Symbols
d-lines, Qd-lines
Compiles debug statements.
Syntax
Linux OS:
-d-lines
-nod-lines
macOS:
-d-lines
-nod-lines
Windows OS:
/d-lines
/nod-lines
/Qd-lines
Arguments
None
Default
Description
This option compiles debug statements. It specifies that lines in fixed-format files that contain a D in column
1 (debug statements) should be treated as source code.
370
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Language > Compile Lines With D in Column 1 (/d-lines)
Alternate Options
Linux and macOS: -DD
Windows: None
E
Causes the preprocessor to send output to stdout.
Syntax
Linux OS:
-E
macOS:
-E
Windows OS:
/E
Arguments
None
Default
Description
This option causes the preprocessor to send output to stdout. Compilation stops when the files have been
preprocessed.
When you specify this option, the compiler's preprocessor expands your source module and writes the result
to stdout. The preprocessed source contains #line directives, which the compiler uses to determine the
source file and line number.
IDE Equivalent
None
Alternate Options
None
EP
Causes the preprocessor to send output to stdout,
omitting #line directives.
Syntax
Linux OS:
-EP
371
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-EP
Windows OS:
/EP
Arguments
None
Default
Description
This option causes the preprocessor to send output to stdout, omitting #line directives.
If you also specify option preprocess-only, option P, or option F, the preprocessor will write the results
(without #line directives) to a file instead of stdout.
IDE Equivalent
None
Alternate Options
None
fpp
Runs the Fortran preprocessor on source files before
compilation.
Syntax
Linux OS:
-fpp
-nofpp
macOS:
-fpp
-nofpp
Windows OS:
/fpp
/fpp[:"fpp_option"]
/nofpp
Arguments
fpp_option Is a Fortran preprocessor (fpp) option; it must start with a slash (/)
and appear in quotes. This argument is only allowed on Windows*
systems.
372
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option runs the Fortran preprocessor on source files before they are compiled.
If you want to pass fpp options to the Fortran preprocessor, you can use any of the following methods:
To see a list of all available fpp options, specify the following on the command line:
Linux and macOS
fpp -help
Windows
fpp /help
IDE Equivalent
Windows
Visual Studio: Preprocessor > Preprocess Source File
Alternate Options
Linux and macOS: -cpp (this is a deprecated option)
Windows: None
Example
The following examples show the recommended method of passing fpp options to the Fortran preprocessor.
See Also
Qoption compiler option
Using Fortran Preprocessor Options
Wp compiler option
fpp-name
Lets you specify an alternate preprocessor to use with
Fortran.
373
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-fpp-name=name
macOS:
-fpp-name=name
Windows OS:
/fpp-name:name
Arguments
name Is the name of the preprocessor executable. It can include a path. See the description below for
more details.
Default
Description
This option lets you specify an alternate preprocessor to use with Fortran.
The compiler invokes the user-specified Fortran preprocessor by spawning a command with the following
signature:
alt_fpp @fpp.arg
where alt_fpp is the name of the Fortran preprocessor you want to use, and fpp.arg is an input file
containing the preprocessor's command line arguments.
fpp.arg is generated by the Fortran compiler driver, and contains the -D<define>,
-I<include directory>, and input file names from the compiler command line. Compiler predefined
options -D<define> and -I<include directory> are also included. Output from the preprocessor goes to
STDOUT and will be captured for any further processing.
You can use option Qoption,fpp,… to pass other definitions (using -D<define>), include directories (using
-I<include directory>), or other options accepted by the preprocessor.
You can use option Qlocation, fpp,… to specify a directory for supporting tools.
IDE Equivalent
None
Alternate Options
None
See Also
fpp Preprocessing
fpp compiler option
Qoption compiler option
Qlocation compiler option
374
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
gen-dep
Tells the compiler to generate build dependencies for
the current compilation.
Syntax
Linux OS:
-gen-dep[=filename]
-no-gen-dep
macOS:
-gen-dep[=filename]
-no-gen-dep
Windows OS:
/gen-dep[:filename]
/gen-dep-
Arguments
filename Is the name of the file for output. It can include a path.
If you specify filename, it is similar to specifying option [Q]MFfilename. If you do not specify
filename, it is similar to specifying option [Q]MD or [Q]MMD.
Default
-no-gen-dep or /gen-dep- The compiler does not generate build dependencies for the compilation.
Description
This option tells the compiler to generate build dependencies for the current compilation. The build
dependencies include a list of all files included with INCLUDE statements or .mod files accessed with USE
statements.
If you do not specify filename, the dependencies are written to stdout.
You can use option gen-depformat to specify the form of the output for the build dependencies generated.
If you specify option gen-dep and you do not specify option gen-depformat, the output format is in a form
acceptable to the make utility.
Note that if option fpp is used to process #include files, those files will also appear in the list of build
dependencies.
If you want to generate build dependencies but you do not want to compile the sources, you must also
specify option syntax-only.
IDE Equivalent
Visual Studio
Visual Studio: Output Files > Build Dependencies (/gen-dep)
Output Files > Emit Build Dependencies to File (/gen-dep:filename)
Output Files > Build Dependencies File (/gen-dep:filename)
375
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Windows: /QMF
See Also
gen-depformat compiler option
gen-depshow compiler option
syntax-only compiler option
gen-depformat
Specifies the form for the output generated when
option gen-dep is specified.
Syntax
Linux OS:
-gen-depformat=form
macOS:
-gen-depformat=form
Windows OS:
/gen-depformat:form
Arguments
form Is the output form for the list of build dependencies. Possible values are make or nmake.
Default
make The output form for the list of build dependencies is in a form acceptable to the make utility.
Description
This option specifies the form for the output generated when option gen-dep is specified.
If you specify option gen-depformat and do not specify option gen-dep, the option is ignored.
IDE Equivalent
None
Alternate Options
None
See Also
gen-dep compiler option
376
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
gen-depshow
Determines whether certain features are excluded
from dependency analysis. Currently, it only applies to
intrinsic modules.
Syntax
Linux OS:
-gen-depshow=keyword
macOS:
-gen-depshow=keyword
Windows OS:
/gen-depshow:keyword
Arguments
keyword Specifies inclusion or exclusion from dependency analysis. Possible values are:
Default
nointr_mod Tells the compiler to exclude Fortran intrinsic modules in dependency analysis.
Description
This option determines whether certain features are excluded from dependency analysis. Currently, it only
applies to intrinsic modules.
Option Description
gen-depshow intr_mod Tells the compiler to include Fortran intrinsic modules in dependency
analysis.
If you do not specify option gen-dep, the compiler does not generate build dependencies for the compilation.
If you specify option gen-depshow and do not specify option gen-dep, the option is ignored.
IDE Equivalent
None
Alternate Options
Windows: /QMMD
See Also
gen-dep compiler option
I
Specifies an additional directory for the include path.
377
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-Idir
macOS:
-Idir
Windows OS:
/Idir
Arguments
Default
Description
This option specifies an additional directory for the include path, which is searched for module files
referenced in USE statements and include files referenced in INCLUDE statements. To specify multiple
directories on the command line, repeat the option for each directory you want to add.
For all USE statements and for those INCLUDE statements whose file name does not begin with a device or
directory name, the directories are searched in this order:
This option affects fpp preprocessor behavior and the USE statement.
IDE Equivalent
Windows
Visual Studio: General > Additional Include Directories (/I)
Preprocessor > Additional Include Directories (/I)
Alternate Options
Linux and macOS: None
Windows: /include
See Also
X compiler option
assume compiler option
378
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
idirafter
Adds a directory to the second include file search
path.
Syntax
Linux OS:
-idirafterdir
macOS:
-idirafterdir
Windows OS:
None
Arguments
Default
Description
This option adds a directory to the second include file search path (after -I).
IDE Equivalent
None
Alternate Options
None
isystem
Specifies a directory to add to the start of the system
include path.
Syntax
Linux OS:
-isystemdir
macOS:
-isystemdir
Windows OS:
None
Arguments
379
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option specifies a directory to add to the system include path. The compiler searches the specified
directory for include files after it searches all directories specified by the -I compiler option but before it
searches the standard system directories.
On Linux* systems, this option is provided for compatibility with gcc.
IDE Equivalent
None
Alternate Options
None
module
Specifies the directory where module files should be
placed when created and where they should be
searched for.
Syntax
Linux OS:
-module path
macOS:
-module path
Windows OS:
/module:path
Arguments
Default
Description
This option specifies the directory (path) where module (.mod) files should be placed when created and
where they should be searched for (USE statement).
IDE Equivalent
Windows
Visual Studio: Output > Module Path
Alternate Options
None
380
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
preprocess-only
Causes the Fortran preprocessor to send output to a
file.
Syntax
Linux OS:
-preprocess-only
macOS:
-preprocess-only
Windows OS:
/preprocess-only
Arguments
None
Default
Description
This option causes the Fortran preprocessor to send output to a file.
The source file is preprocessed by the Fortran preprocessor, and the result for each source file is output to a
corresponding .i or .i90 file.
Note that the source file is not compiled.
IDE Equivalent
None
Alternate Options
Linux and macOS: -P
Windows: /P
u (Windows*)
Undefines all previously defined preprocessor values.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/u
Arguments
None
381
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF Defined preprocessor values are in effect until they are undefined.
Description
This option undefines all previously defined preprocessor values.
To undefine specific preprocessor values, use the /U option.
IDE Equivalent
Windows
Visual Studio: Preprocessor > Undefine All Preprocessor Definitions
Alternate Options
None
See Also
U compiler option
U
Undefines any definition currently in effect for the
specified symbol.
Syntax
Linux OS:
-Uname
macOS:
-Uname
Windows OS:
/Uname
Arguments
Default
Description
This option undefines any definition currently in effect for the specified symbol.
On Windows systems, use the /u option to undefine all previously defined preprocessor values.
IDE Equivalent
Windows
Visual Studio: Preprocessor > Undefine Preprocessor Definitions
Alternate Options
Linux and macOS: None
382
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /undefine:name
See Also
u (Windows) compiler option
undef
Disables all predefined symbols.
Syntax
Linux OS:
-undef
macOS:
-undef
Windows OS:
None
Arguments
None
Default
Description
This option disables all predefined symbols.
IDE Equivalent
None
Alternate Options
None
X
Removes standard directories from the include file
search path.
Syntax
Linux OS:
-X
macOS:
-X
Windows OS:
/X
Arguments
None
383
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option removes standard directories from the include file search path. It prevents the compiler from
searching the default path specified by the CPATH environment variable.
On Linux* and macOS systems, specifying -X (or -noinclude) prevents the compiler from searching
in /usr/include for files specified in an INCLUDE statement.
You can use this option with the I option to prevent the compiler from searching the default path for include
files and direct it to use an alternate path.
This option affects fpp preprocessor behavior and the USE statement.
IDE Equivalent
Windows
Visual Studio: Preprocessor > Ignore Standard Include Path (/X)
Alternate Options
Linux and macOS: -nostdinc
Windows: /noinclude
See Also
I compiler option
Qinstall
Specifies the root directory where the compiler
installation was performed.
Syntax
Linux OS:
-Qinstalldir
macOS:
-Qinstalldir
Windows OS:
None
Arguments
384
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF The default root directory for compiler installation is searched for the compiler.
Description
This option specifies the root directory where the compiler installation was performed. It is useful if you want
to use a different compiler or if you did not use a shell script to set your environment variables.
IDE Equivalent
None
Alternate Options
None
Qlocation
Specifies the directory for supporting tools.
Syntax
Linux OS:
-Qlocation,string,dir
macOS:
-Qlocation,string,dir
Windows OS:
/Qlocation,string,dir
Arguments
Default
Description
This option specifies the directory for supporting tools.
string can be any of the following:
385
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• gas - Indicates the GNU assembler. This setting is for Linux* only.
• ld - Indicates the loader.
• gld - Indicates the GNU loader. This setting is for Linux* only.
• lib - Indicates an additional library.
• crt - Indicates the crt%.o files linked into executables to contain the place to start execution.
On Windows and macOS systems, you can also specify a tool command name.
The following shows an example on macOS systems:
-Qlocation,ld,/usr/bin ! This tells the driver to use /usr/bin/ld for the loader
-Qlocation,ld,/usr/bin/gld ! This tells the driver to use /usr/bin/gld as the loader
The following shows an example on Windows* systems:
IDE Equivalent
None
Alternate Options
None
Example
The following command provides the path for the fpp tool:
See Also
Qoption compiler option
Qoption
Passes options to a specified tool.
Syntax
Linux OS:
-Qoption,string,options
macOS:
-Qoption,string,options
Windows OS:
/Qoption,string,options
Arguments
options Are one or more comma-separated, valid options for the designated
tool.
Note that certain tools may require that options appear within
quotation marks (" ").
386
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option passes options to a specified tool.
If an argument contains a space or tab character, you must enclose the entire argument in quotation marks
(" "). You must separate multiple arguments with commas.
string can be any of the following:
• fpp (or cpp) - Indicates the Intel® Fortran preprocessor or a user-specified (alternate) Fortran
preprocessor.
• asm - Indicates the assembler.
• link - Indicates the linker.
• prof - Indicates the profiler.
• On Windows* systems, the following is also available:
• masm - Indicates the Microsoft assembler.
• On Linux* and macOS systems, the following are also available:
• as - Indicates the assembler.
• gas - Indicates the GNU assembler.
• ld - Indicates the loader.
• gld - Indicates the GNU loader.
• lib - Indicates an additional library.
• crt - Indicates the crt%.o files linked into executables to contain the place to start execution.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
ifort -Qoption,fpp,"-fpp=macro=no
387
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ifort /Qoption,fpp,"/fpp:macro=no"
See Also
Qlocation compiler option
Language Options
This section contains descriptions for compiler options that pertain to language compatibility, conformity,
etc.. They are listed in alphabetical order.
allow
Determines whether the compiler allows certain
behaviors.
Syntax
Linux OS:
-allow keyword
macOS:
-allow keyword
Windows OS:
/allow:keyword
Arguments
Default
Description
This option determines whether the compiler allows certain behaviors.
Option Description
388
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
Example
Consider the following:
altparam
Allows alternate syntax (without parentheses) for
PARAMETER statements.
Syntax
Linux OS:
-altparam
-noaltparam
macOS:
-altparam
-noaltparam
Windows OS:
/altparam
/noaltparam
Arguments
None
Default
Description
This option specifies that the alternate syntax for PARAMETER statements is allowed. The alternate syntax is:
389
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In this alternative statement, the form of the constant, rather than implicit or explicit typing of the name,
determines the data type of the variable.
IDE Equivalent
Windows
Visual Studio: Language > Enable Alternate PARAMETER Syntax
Alternate Options
assume
Tells the compiler to make certain assumptions.
Syntax
Linux OS:
-assume keyword[, keyword...]
macOS:
-assume keyword[, keyword...]
Windows OS:
/assume:keyword[, keyword...]
Arguments
390
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
391
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
392
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
nobuffered_io Data in the internal buffer is immediately read from or written (flushed)
to disk (OPEN specifier BUFFERED='NO'). Data read from variable length,
unformatted files is read directly from disk to a user's variables.
If you set the FORT_BUFFERED environment variable to true, the default
is assume buffered_io.
nobuffered_stdout Data is not buffered for the standard output device but instead is written
immediately to the device.
nobyterecl Units for OPEN statement RECL values with unformatted files are in four-
byte (longword) units.
393
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
noieee_fpe_flags The flags are not saved on routine entry and they are not restored on
routine exit.
nominus0 The compiler uses Fortran 90/77 standard semantics in the SIGN intrinsic
to treat -0.0 and +0.0 as 0.0, and writes a value of 0.0 with no sign on
formatted output.
nan_compares Code is generated for floating-point compares to check for NaNs and give
the same results as are performed when assume ieee_compares is
specified, except a compare to a signaling NaN behaves as if it was a
quiet NaN.
old_e0g0_format Formats output for the G0.0, E0 and ES0 edit descriptors as it did prior to
conforming to the Fortran 2018 standard. G0.0 does not use the minimal
width needed for a real value.
This setting causes the runtime to always remove the exponent letter E
from the output for real values produced with the E0 and ES0 format edit
descriptors.
old_ldout_format For list-directed and namelist-directed output, integers are written with a
fixed width that is dependent on the integer kind, and zero real values
are written using the E format.
394
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
noold_logical_ldio Tells the compiler that NAMELIST and list-directed input cannot accept
logical values (T, F, etc.) for numeric (integer, real, and complex) IO-list
items or numeric values for logical IO-list items. If this option is specified
and a logical value is given for a numeric item or a numeric value is given
for a logical item in NAMELIST and list-directed input, a run-time error
will be produced.
noprotect_allocates Memory allocation requests using the ALLOCATE statement are not
protected with critical sections and may encounter random timing
problems in a multi-threaded environment.
noprotect_parens The optimizer reorders REAL and COMPLEX expressions without regard
for parentheses by reassociating operations if it produces faster executing
code.
realloc_lhs Tells the compiler that when the left-hand side of an assignment is an
allocatable object, it should be reallocated to the shape of the right-hand
side of the assignment before the assignment occurs. This is the current
Fortran Standard definition. This feature may cause extra overhead at run
time. The option standard-realloc-lhs has the same effect as
assume realloc_lhs.
norecursion Tells the compiler that all procedures are not compiled for recursion,
unless declared with the RECURSIVE keyword. Fortran 2018 specifies the
default mode of compilation is recursion; previous standards specified no
recursion. This default will change in a future release.
source_include The compiler searches for USE modules and INCLUDE files in the
directory where the source file is located.
std_intent_in The compiler assumes that dummy arguments with the INTENT(IN)
attribute in a called procedure are not modified across a call, in
accordance with the Fortran standard.
std_minus0_rounding A negative value that is not zero but rounds to zero on output is
displayed with a leading minus sign. For example, the value -0.00000001
in F5.1 format will be displayed as -0.0 rather than as 0.0.
nostd_mod_proc_name The compiler allows the names of module procedures to conflict with user
external symbol names.
395
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
std_value The compiler assumes that the VALUE attribute has the effect as if the
actual argument is assigned to a temporary, and the temporary is then
passed to the called procedure so that subsequent changes to the value
of the dummy argument do not affect the actual argument, in accordance
with the Fortran standard.
Windows: nounderscore On Windows* systems, the compiler does not append an underscore
Linux and macOS: underscore character to external user-defined names. On Linux* and macOS
systems, the compiler appends an underscore character to external user-
defined names.
no2underscores The compiler does not append two underscore characters to external
(Linux and macOS) user-defined names that contain an embedded underscore.
Description
This option specifies assumptions to be made by the compiler.
Option Description
assume bscc Tells the compiler to treat the backslash character (\) as a C-
style control (escape) character syntax in character literals.
The "bscc" keyword means "BackSlashControlCharacters."
assume buffered_io Tells the compiler to accumulate records in a buffer. This sets
the default for opening sequential files to BUFFERED='YES',
which also occurs if the FORT_BUFFERED run-time
environment variable is specified.
When this option is specified, the internal buffer is filled,
possibly by many record input statements (READ) or output
statements (WRITE), before it is read from disk, or written to
disk, by the Fortran run-time system. If a file is opened for
direct access, I/O buffering is ignored.
Using buffered reads and writes usually makes disk I/O more
efficient by handling larger blocks of data on disk less often.
However, if you request buffered writes, records not yet
written to disk may be lost in the event of a system failure.
The OPEN statement BUFFERED specifier applies to a specific
logical unit. In contrast, the assume [no]buffered_io option
and the FORT_BUFFERED environment variable apply to all
Fortran units.
assume buffered_stdout Tells the Fortran run-time system to accumulate data for the
standard output device in a buffer. When the buffer is full or
the user executes a FLUSH on OUTPUT_UNIT in intrinsic
module ISO_FORTRAN_ENV, the data is displayed on the
standard output unit.
Using buffered writes may be a more efficient in time and
space but use assume nobuffered_stdout if you want data
displayed immediately on the standard output device, like for
an input prompt.
396
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume byterecl Specifies that the units for the OPEN statement RECL specifier
(record length) value are in bytes for unformatted data files,
not longwords (four-byte units). For formatted files, the RECL
value is always in bytes.
If a file is open for unformatted data and assume byterecl is
specified, INQUIRE returns RECL in bytes; otherwise, it returns
RECL in longwords. An INQUIRE returns RECL in bytes if the
unit is not open.
assume contiguous_pointer Tells the compiler to assume contiguity for pointers. This may
aid in optimization. However, if you are mistaken about the
contiguity of your data, it could result in run-time failures.
assume failed_images Tells the run-time system to check for failed images on the
current team when executing an image control statement that
does not have a STAT= specifier, or when a MOVE_ALLOC or
collective or atomic subroutine without a STAT argument is
executed.
397
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume ieee_fpe_flags Tells the compiler to save floating-point exception and status
flags on routine entry and restore them on routine exit.
This option can slow runtime performance because it provides
extra code to save and restore the floating-point exception and
status flags (and the rounding mode) on entry to and exit from
every routine compiled with the option.
This option can be used to get the full Fortran Standard
behavior of intrinsic modules IEEE EXCEPTIONS, IEEE
ARITHMETIC, and IEEE FEATURES, which require that if a flag
is signaling on routine entry, the processor will set it to quiet
on entry and restore it to signaling on return. If a flag signals
while the routine is executing, it will not be set to quiet on
routine exit.
Options fpe and fpe-all can be used to set the initial state
for which floating-point exceptions will signal.
assume minus0 Tells the compiler to use Fortran 95 standard semantics for the
treatment of the IEEE* floating value -0.0 in the SIGN
intrinsic, which distinguishes the difference between -0.0 and
+0.0, and to write a value of -0.0 with a negative sign on
formatted output.
assume old_boz Tells the compiler that the binary, octal, and hexadecimal
constant arguments in intrinsic functions INT, REAL, DBLE, and
CMPLX should be treated as signed integer constants.
398
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume noold_e0g0_format Tells the compiler to use Fortran 2018 standard format for real
numbers that are output using the G0.0, E0, and ES0 edit
descriptors.
assume noold_inquire_recl Tells the compiler to use Fortran 2018 semantics for RECL= on
an INQUIRE statement. If the unit is unconnected, the scalar-
int-variable of the RECL= specifier becomes defined with the
value -1; if the unit is connected for stream access, it becomes
defined with the value -2.
assume noold_ldout_format Tells the compiler to use Fortran 2003 standard semantics for
output of integer and real values in list-directed and namelist-
directed output.
Integers are written using an I0 format with a leading blank
for spacing.
Real and complex values are written using and E or F format
with a leading blank for spacing. The format used depends on
the magnitude of the value. Values that are zero are written
using an F format.
assume old_logical_ldio Logical values are allowed for numeric items and numeric
values are allowed for logical items.
assume noold_maxminloc Tells the compiler that MAXLOC and MINLOC should return 0
when given an empty array as an argument or every element
of the mask is false. Compared to the default setting
(old_maxminloc), this behavior may slow performance
because of the extra code needed to check for an empty array
argument or for an all-false mask.
assume noold_unit_star Tells the compiler that READs or WRITEs to UNIT=* go to the
file to which UNIT=5 or 6 is connected.
399
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume protect_allocates Memory allocation requests using the ALLOCATE statement are
protected with critical sections to avoid random timing
problems in a multi-threaded environment in some
distributions and configurations.
assume protect_parens Tells the optimizer to honor parentheses in REAL and COMPLEX
expression evaluations by not reassociating operations. For
example, (A+B)+C would not be evaluated as A+(B+C).
If assume noprotect_parens is specified, (A+B)+C would be
treated the same as A+B+C and could be evaluated as A+(B
+C) if it produced faster executing code.
Such reassociation could produce different results depending
on the sizes and precision of the arguments.
For example, in (A+B)+C, if B and C had opposite signs and
were very large in magnitude compared to A, A+B could result
in the value as B; adding C would result in 0.0. With
reassociation, B+C would be 0.0; adding A would result in a
non-zero value.
assume norealloc_lhs The compiler uses the old Fortran 2003 rules when interpreting
assignment statements. The left-hand side is assumed to be
allocated with the correct shape to hold the right-hand side. If
it is not, incorrect behavior will occur. The option
nostandard-realloc-lhs has the same effect as
assume norealloc_lhs.
assume recursion Tells the compiler to compile procedures that are declared
without the RECURSIVE or NON_RECURSIVE keyword as
recursive procedures. In Fortran 2018, these procedures are
compiled for recursion by default; in previous standards they
were compiled as non-recursive procedures. The current
default behavior is non-recursive. This will change in a future
release.
assume nosource_include Tells the compiler to search the default directory for module
files specified by a USE statement or source files specified by
an INCLUDE statement. This option affects fpp preprocessor
behavior and the USE statement.
assume nostd_intent_in Tells the compiler to assume that dummy arguments with the
INTENT(IN) attribute in a called procedure may be modified
across a call. This is not in accordance with the Fortran
standard.
If you specify option standard_semantics, it sets option
assume std_intent_in.
400
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume nostd_minus0_rounding Tells the compiler to use pre-Fortran 2008 standard semantics
for the treatment of IEEE* floating values that are negative,
non-zero, and when rounded for display are zero. The value
should be printed without a leading minus sign.
For example, the floating value -0.00000001 when rounded in
F5.1 format will be displayed as 0.0. Use
assume std_minus0_rounding to use Fortran 2008 standard
semantics to display this value as -0.0 when rounded in F5.1
format.
assume [no]std_minus0_rounding does not affect and is
not affected by assume [no]minus0. The former controls
printing of a minus sign for non-zero numbers while the latter
controls printing of actual signed zero values.
assume std_mod_proc_name Tells the compiler to revise the names of module procedures
so they do not conflict with user external symbol names. For
example, procedure proc in module m would be named
m_MP_proc. The Fortran 2003 Standard requires that module
procedure names not conflict with other external symbols.
By default, procedure proc in module m would be named
m_mp_proc, which could conflict with a user-defined external
name m_mp_proc.
assume nostd_value Tells the compiler to use pre-Fortran 2003 standard semantics
for the VALUE attribute so that the value of the actual
argument is passed to the called procedure, not the address of
the actual argument nor the address of a copy of the actual
argument.
401
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
assume writeable-strings Tells the compiler to put character constants into non-read-
only memory.
IDE Equivalent
Visual Studio
Visual Studio: Code Generation > Enable Recursive Routines (/assume:[no]recursion)
Alternate Options
Windows: /nbs
Windows: /Qcommon-args
Windows: /Qprotect-parens
Windows: /standard-realloc-lhs
Windows: /recursive
See Also
fp-model, fp compiler option
fpe compiler option
fpe-all compiler option
standard-semantics compiler option
standard-realloc-lhs compiler option
fpscomp compiler option, setting logicals
Rules for Unformatted Sequential READ Statements
402
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ccdefault
Specifies the type of carriage control used when a file
is displayed at a terminal screen.
Syntax
Linux OS:
-ccdefault keyword
macOS:
-ccdefault keyword
Windows OS:
/ccdefault:keyword
Arguments
fortran Tells the compiler to use normal Fortran interpretation of the first character.
For example, the character 0 causes output of a blank line before a record.
list Tells the compiler to output one line feed between records.
Default
ccdefault default The compiler uses the default carriage control setting.
Description
This option specifies the type of carriage control used when a file is displayed at a terminal screen (units 6
and *). It provides the same functionality as using the CARRIAGECONTROL specifier in an OPEN statement.
The default carriage-control setting can be affected by the vms option. If option vms is specified with
ccdefault default, carriage control defaults to normal Fortran interpretation (ccdefault fortran) if the
file is formatted and the unit is connected to a terminal. If option novms (the default) is specified with
ccdefault default, carriage control defaults to list (ccdefault list).
IDE Equivalent
Windows
Visual Studio: Run-time > Default Output Carriage Control
Alternate Options
None
check
Checks for certain conditions at run time.
Syntax
Linux OS:
-check [keyword[, keyword...]]
403
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-nocheck
macOS:
-check [keyword[, keyword...]]
-nocheck
Windows OS:
/check[:keyword[, keyword...]]
/nocheck
Arguments
[no]output_conversion Determines whether checking occurs for the fit of data items
within a designated format descriptor field.
Default
nocheck No checking is performed for run-time failures. Note that if option vms is specified, the defaults
are check format and check output_conversion.
404
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option checks for certain conditions at run time.
Option Description
check arg_temp_created Enables run-time checking on whether actual arguments are copied
into temporary storage before routine calls. If a copy is made at run-
time, an informative message is displayed.
check bounds Enables compile-time and run-time checking for array subscript and
character substring expressions. An error is reported if the expression
is outside the dimension of the array or the length of the string.
For array bounds, each individual dimension is checked. For arrays that
are dummy arguments, only the lower bound is checked for a
dimension whose upper bound is specified as * or where the upper and
lower bounds are both 1.
For some intrinsics that specify a DIM= dimension argument, such as
LBOUND, an error is reported if the specified dimension is outside the
declared rank of the array being operated upon.
Once the program is debugged, omit this option to reduce executable
program size and slightly improve run-time performance.
It is recommended that you do bounds checking on unoptimized code.
If you use option check bounds on optimized code, it may produce
misleading messages because registers (not memory locations) are
used for bounds values.
check format Issues the run-time FORVARMIS fatal error when the data type of an
item being formatted for output does not match the format descriptor
being used (for example, a REAL*4 item formatted with an I edit
descriptor).
With check noformat, the data item is formatted using the specified
descriptor unless the length of the item cannot accommodate the
descriptor (for example, it is still an error to pass an INTEGER*2 item
to an E edit descriptor).
check output_conversion Issues the run-time OUTCONERR continuable error message when a
data item is too large to fit in a designated format descriptor field
without loss of significant digits. Format truncation occurs, the field is
filled with asterisks (*), and execution continues.
405
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
check stack Enables checking on the stack frame. The stack is checked for buffer
overruns and buffer underruns. This option also enforces local variables
initialization and stack pointer verification.
This option disables optimization and overrides any optimization level
set by option O.
check stack Enables checking on the stack frame. The stack is checked for buffer
overruns and buffer underruns. This option also enforces local variables
initialization and stack pointer verification.
This option disables optimization and overrides any optimization level
set by option O.
check teams Enables checking for non-standard coarray team usage. For example,
ifort permits the TEAM argument to NUM_IMAGES to be a type
TEAM_TYPE variable which describes a team that is not the current or
an ancestor of the current team. Similarly, ifort permits the
TEAM_NUMBER specifier in an image selector to specify a value of -1
indicating the initial team. Such behavior is not permitted by the
standard.
When check teams is specified, a message is generated each time a
non-standard coarray extension is detected.
check all Enables all check options. This is the same as specifying check with no
keyword.
406
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
To get more detailed location information about where an error occurred, use option traceback.
IDE Equivalent
Visual Studio
Visual Studio: Run-time > Runtime Error Checking (/nocheck, /check:all)
Run-time > Check For Actual Arguments Using Temporary Storage (/check:arg_temp_created)
Run-time > Check For Null Pointers and Allocatable Array References (/check:pointers)
Alternate Options
Windows: /nocheck
Windows: /CB
Windows: /CS
Windows: /check, /C
See Also
traceback compiler option
init, Qinit compiler option
warn compiler option
ASSUME directive
ASSUME_ALIGNED directive
extend-source
Specifies the length of the statement field in a fixed-
form source file.
407
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-extend-source [size]
-noextend-source
macOS:
-extend-source [size]
-noextend-source
Windows OS:
/extend-source[:size]
/noextend-source
Arguments
size Is the length of the statement field in a fixed-form source file. Possible values are: 72, 80, or 132.
Default
72 If you do not specify this option or you specify noextend-source, the statement field ends at
column 72.
132 If you specify extend_source without size, the statement field ends at column 132.
Description
This option specifies the size (column number) of the statement field of a source line in a fixed-form source
file. This option is valid only for fixed-form files; it is ignored for free-form files.
When size is specified, it is the last column parsed as part of the statement field. Any columns after that are
treated as comments.
If you do not specify size, it is the same as specifying extend_source 132.
Option Description
extend-source 132 Specifies that the statement field ends at column 132.
IDE Equivalent
Windows
Visual Studio: Language > Fixed Form Line Length
Alternate Options
Windows: /4L72
408
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /4L80
Windows: /4L132
fixed
Specifies source files are in fixed format.
Syntax
Linux OS:
-fixed
-nofixed
macOS:
-fixed
-nofixed
Windows OS:
/fixed
/nofixed
Arguments
None
Default
OFF The source file format is determined from the file extension.
Description
This option specifies source files are in fixed format. If this option is not specified, format is determined as
follows:
• Files with an extension of .f90, .F90, or .i90 are free-format source files.
• Files with an extension of .f, .for, .FOR, .ftn, .FTN, .fpp, .FPP, or .i are fixed-format files.
Note that on Linux* and macOS systems, file names and file extensions are case sensitive.
IDE Equivalent
Windows
Visual Studio: Language > Source File Format (/free, /fixed)
Alternate Options
Linux and macOS: -FI
free
Specifies source files are in free format.
409
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-free
-nofree
macOS:
-free
-nofree
Windows OS:
/free
/nofree
Arguments
None
Default
OFF The source file format is determined from the file extension.
Description
This option specifies source files are in free format. If this option is not specified, format is determined as
follows:
• Files with an extension of .f90, .F90, or .i90 are free-format source files.
• Files with an extension of .f, .for, .FOR, .ftn, or .i are fixed-format files.
IDE Equivalent
Windows
Visual Studio: Language > Source File Format (/free, /fixed)
Alternate Options
Linux and macOS: -FR
See Also
fixed compiler option
iface
Specifies the default calling convention and argument-
passing convention for an application.
Syntax
Linux OS:
None
macOS:
None
410
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/iface:keyword
Arguments
keyword Specifies the calling convention or the argument-passing convention. Possible values are:
Default
Description
This option specifies the default calling convention and argument-passing convention for an application.
The aspects of calling and argument passing controlled by this option are as follows:
• The calling mechanism (C or STDCALL): On IA-32 architecture, these mechanisms differ in how the stack
register is adjusted when a procedure call returns. On Intel® 64 architecture, the only calling mechanism
available is C; requests for the STDCALL mechanism are ignored.
• The argument passing mechanism (by value or by reference)
• Character-length argument passing (at the end of the argument list or after the argument address)
• The case of external names (uppercase or lowercase)
• The name decoration (prefix and suffix)
You can also use the ATTRIBUTES compiler directive to modify these conventions on an individual basis. Note
that the effects of the ATTRIBUTES directive do not always match that of the iface option of the same name.
Option Description
/iface:default Tells the compiler to use the default calling conventions. These
conventions are as follows:
• The calling mechanism: C
• The argument passing mechanism: by reference
• Character-length argument passing: at end of argument list
• The external name case: uppercase
• The name decoration: Underscore prefix on IA-32 architecture,
no prefix on Intel® 64 architecture; no suffix
411
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
Caution
On Windows systems, if you specify option /iface:cref, it overrides the default for external
names and causes them to be lowercase. It is as if you specified "!dir$ attributes c,
reference" for the external name.
If you specify option /iface:cref and want external names to be uppercase, you must explicitly
specify option /names:uppercase.
412
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
On systems using IA-32 architecture, there must be agreement between the calling program
and the called procedure as to which calling mechanism (C or STDCALL) is used, or
unpredictable errors may occur. If you change the default mechanism to STDCALL, you must
use the ATTRIBUTES DEFAULT directive to reset the calling conventions for any procedure
that is:
• Specified as a FINAL procedure for a derived type
• Specified as a USEROPEN procedure in an OPEN statement
• Referenced in a variable format expression
• Specified as a comparison routine passed to the QSORT library routine from module IFPORT
• Used as a dialog callback procedure with the IFLOGM module
• Called from other contexts or languages that assume the C calling convention
Note that Visual Studio projects that are imported using the Extract Compaq Visual Fortran project
items wizard have /iface:cvf applied automatically; this establishes STDCALL as the default
convention.
IDE Equivalent
Visual Studio
Visual Studio: External Procedures > Calling Convention
(/iface:{cref|stdref|stdcall|cvf|default})
Alternate Options
Windows: None
Windows: None
See Also
ATTRIBUTES Directive
names
Specifies how source code identifiers and external
names are interpreted.
Syntax
Linux OS:
-names keyword
macOS:
-names keyword
413
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/names:keyword
Arguments
keyword Specifies how to interpret the identifiers and external names in source code. Possible values
are:
Default
lowercase This is the default on Linux* and macOS systems. The compiler ignores case
differences in identifiers and converts external names to lowercase.
uppercase This is the default on Windows* systems. The compiler ignores case differences in
identifiers and converts external names to uppercase.
Description
This option specifies how source code identifiers and external names are interpreted. It can be useful in
mixed-language programming.
This naming convention applies whether names are being defined or referenced.
You can use the ALIAS directive to specify an alternate external name to be used when referring to external
subprograms.
Caution
On Windows systems, if you specify option /iface:cref, it overrides the default for external
names and causes them to be lowercase. It is as if you specified "!dir$ attributes c,
reference" for the external name.
If you specify option /iface:cref and want external names to be uppercase, you must explicitly
specify option /names:uppercase.
IDE Equivalent
Windows
Visual Studio: External Procedures > Name Case Interpretation
Alternate Options
None
See Also
iface compiler option
ALIAS Directive
414
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pad-source, Qpad-source
Specifies padding for fixed-form source records.
Syntax
Linux OS:
-pad-source
-nopad-source
macOS:
-pad-source
-nopad-source
Windows OS:
/pad-source
/nopad-source
/Qpad-source
/Qpad-source-
Arguments
None
Default
Description
This option specifies padding for fixed-form source records. It tells the compiler that fixed-form source lines
shorter than the statement field width are to be padded with spaces to the end of the statement field. This
affects the interpretation of character and Hollerith literals that are continued across source records.
The default value setting causes a warning message to be displayed if a character or Hollerith literal that
ends before the statement field ends is continued onto the next source record. To suppress this warning
message, specify setting nousage for option warn.
Specifying [Q]pad-source can prevent warning messages associated with setting usage for option warn.
IDE Equivalent
Windows
Visual Studio: Language > Pad Fixed Form Source Lines
Alternate Options
None
See Also
warn compiler option
stand
Tells the compiler to issue compile-time messages for
nonstandard language elements.
415
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-stand [keyword]
-nostand
macOS:
-stand [keyword]
-nostand
Windows OS:
/stand[:keyword]
/nostand
Arguments
keyword Specifies the language to use as the standard. Possible values are:
f90 Issues messages for language elements that are not standard in Fortran 90.
f95 Issues messages for language elements that are not standard in Fortran 95.
f03 Issues messages for language elements that are not standard in Fortran 2003.
f08 Issues messages for language elements that are not standard in Fortran 2008.
f18 Issues messages for language elements that are not standard in Fortran 2018.
Default
Description
This option tells the compiler to issue compile-time messages for nonstandard language elements.
If you do not specify a keyword for stand, it is the same as specifying stand f18.
Option Description
stand none Tells the compiler to issue no messages for nonstandard language elements. This is
the same as specifying nostand.
stand f90 Tells the compiler to issue messages for language elements that are not standard in
Fortran 90.
stand f95 Tells the compiler to issue messages for language elements that are not standard in
Fortran 95.
stand f03 Tells the compiler to issue messages for language elements that are not standard in
Fortran 2003.
stand f08 Tells the compiler to issue messages for language elements that are not standard in
Fortran 2008.
416
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
stand f18 Tells the compiler to issue messages for language elements that are not standard in
Fortran 2018. This option is set if you specify warn stderrors.
NOTE
When you specify this option, things that are not provided for in the Fortran standard at the
specified standard level are diagnosed with warnings - this includes compiler directives
recognized by ifort.
These standard compliance warnings can be ignored as they are informational only and do not affect
compilation.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Warn For Nonstandard Fortran
Alternate Options
Windows: /4Ys
Windows: None
Windows: None
Windows: /stand
Windows: none
See Also
warn stderrors compiler option
standard-realloc-lhs
Determines whether the compiler uses the current
Fortran Standard rules or the old Fortran 2003 rules
when interpreting assignment statements.
Syntax
Linux OS:
-standard-realloc-lhs
-nostandard-realloc-lhs
417
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-standard-realloc-lhs
-nostandard-realloc-lhs
Windows OS:
/standard-realloc-lhs
/nostandard-realloc-lhs
Arguments
None
Default
standard-realloc-lhs The compiler uses the current Fortran Standard rules when interpreting
assignment statements.
Description
This option determines whether the compiler uses the current Fortran Standard rules or the old Fortran 2003
rules when interpreting assignment statements.
Option standard-realloc-lhs (the default), tells the compiler that when the left-hand side of an
assignment is an allocatable object, it should be reallocated to the shape of the right-hand side of the
assignment before the assignment occurs. This is the current Fortran Standard definition. This feature may
cause extra overhead at run time. This option has the same effect as option assume realloc_lhs.
If you specify nostandard-realloc-lhs, the compiler uses the old Fortran 2003 rules when interpreting
assignment statements. The left-hand side is assumed to be allocated with the correct shape to hold the
right-hand side. If it is not, incorrect behavior will occur. This option has the same effect as option
assume norealloc_lhs.
IDE Equivalent
None
Alternate Options
None
standard-semantics
Determines whether the current Fortran Standard
behavior of the compiler is fully implemented.
Syntax
Linux OS:
-standard-semantics
macOS:
-standard-semantics
Windows OS:
/standard-semantics
418
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
OFF The compiler implements most but not all of the current Fortran Standard behavior.
Description
This option determines whether the current Fortran Standard behavior of the compiler is fully implemented.
If you specify option standard-semantics, it enables all of the options that implement the current Fortran
Standard behavior of the compiler, which is Fortran 2018 features.
Option standard-semantics enables option fpscomp logicals and the following settings for option
assume: byterecl, failed_images, fpe_summary, ieee_compares, ieee_fpe_flags (if the fp-model option
setting is strict or precise), minus0, nan_compares, noold_inquire_recl, noold_ldout_format,
noold_ldout_zero, noold_maxminloc, noold_unit_star, noold_xor, protect_parens, realloc_lhs1, recursion,
std_intent_in, std_minus0_rounding1, std_mod_proc_name, and std_value1.
If you specify option standard-semantics and also explicitly specify a different setting for an affected
assume option, the value you specify takes effect. It overrides the settings enabled by option
standard-semantics.
IDE Equivalent
Windows
Visual Studio: Language > Enable F2008 Semantics
Alternate Options
None
See Also
assume compiler option
stand compiler option
syntax-only
Tells the compiler to check only for correct syntax.
Syntax
Linux OS:
-syntax-only
macOS:
-syntax-only
Windows OS:
/syntax-only
Arguments
None
419
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the compiler to check only for correct syntax. It lets you do a quick syntax check of your
source file.
Compilation stops after the source file has been parsed. No code is generated, no object file is produced, and
some error checking done by the optimizer is bypassed.
This option also generates all appropriate module files for each module found in the source. If Fortran
preprocessing is requested, the preprocessed source file is also created.
Warnings and messages appear on stderr.
IDE Equivalent
None
Alternate Options
Linux: -y, -fsyntax-only, -syntax (this is a deprecated option)
Windows: /Zs
wrap-margin
Provides a way to disable the right margin wrapping
that occurs in Fortran list-directed output.
Syntax
Linux OS:
-wrap-margin
-no-wrap-margin
macOS:
None
Windows OS:
/wrap-margin
/wrap-margin-
Arguments
None
Default
wrap-margin The right margin wraps at column 80 if the record length is greater than 80
characters.
420
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option provides a way to disable the right margin wrapping that occurs in Fortran list-directed output. By
default, when the record being written becomes longer than 80 characters, the record is wrapped to a new
record at what is called the "right margin".
Specify -no-wrap-margin (Linux*) or /wrap-margin- (Windows*) to disable this behavior.
IDE Equivalent
None
Alternate Options
None
Data Options
This section contains descriptions for compiler options that pertain to the treatment of data. They are listed
in alphabetical order.
align
Tells the compiler how to align certain data items.
Syntax
Linux OS:
-align [keyword[, keyword...]]
-noalign
macOS:
-align [keyword[, keyword...]]
-noalign
Windows OS:
/align[:keyword[, keyword...]]
/noalign
Arguments
421
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
all Adds padding bytes whenever possible to data items in common blocks
and structures.
Default
records Aligns derived-type components and record structure fields on default natural
boundaries.
Description
This option specifies the alignment to use for certain data items. The compiler adds padding bytes to perform
the alignment.
Option Description
align none Tells the compiler not to add padding bytes anywhere in common blocks or
structures. This is the same as specifying noalign.
align arraynbyte Aligns the start of arrays on an n-byte boundary. n can be 8, 16, 32, 64, 128, or
256. The default value for n is 8. This affects the starting alignment for all
arrays except for arrays in COMMON.
Arrays do not have padding between their elements.
align commons Aligns all common block entities on natural boundaries up to 4 bytes, by adding
padding bytes as needed.
The align nocommons option adds no padding to common blocks. In this case,
unaligned data can occur unless the order of data items specified in the
COMMON statement places the largest numeric data item first, followed by the
next largest numeric data (and so on), followed by any character data.
align dcommons Aligns all common block entities on natural boundaries up to 8 bytes, by adding
padding bytes as needed.
The align nodcommons option adds no padding to common blocks.
align qcommons Aligns all common block entities on natural boundaries up to 16 bytes, by adding
padding bytes as needed.
The align noqcommons option adds no padding to common blocks.
422
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
align zcommons Aligns all common block entities on natural boundaries up to 32 bytes, by adding
padding bytes as needed.
The align nozcommons option adds no padding to common blocks.
align norecords Aligns components of derived types and fields within record structures on
arbitrary byte boundaries with no padding.
The align records option requests that multiple data items in record structures
and derived-type structures without the SEQUENCE statement be naturally
aligned, by adding padding as needed.
align recnbyte Aligns components of derived types and fields within record structures on the
smaller of the size boundary specified (n) or the boundary that will naturally
align them. n can be 1, 2, 4, 8, 16, or 32. The default value for n is 8. When you
specify this option, each structure member after the first is stored on either the
size of the member type or n-byte boundaries, whichever is smaller. For
example, to specify 16 bytes as the packing boundary (or alignment constraint)
for all structures and unions in the file prog1.f, use the following command:
ifort {-align rec16byte | /align:rec16byte} prog1.f
This option does not affect whether common blocks are naturally aligned or
packed.
align sequence Aligns components of a derived type declared with the SEQUENCE statement
(sequenced components) according to the alignment rules that are currently in
use. The default alignment rules are to align unsequenced components on
natural boundaries.
The align nosequence option requests that sequenced components be packed
regardless of any other alignment rules. Note that align none implies
align nosequence.
If you specify an option for standards checking, align sequence is ignored.
align all Tells the compiler to add padding bytes whenever possible to obtain the natural
alignment of data items in common blocks, derived types, and record structures.
Specifies align dcommons, align records, align nosequence. This is the
same as specifying align with no keyword.
IDE Equivalent
Visual Studio
Visual Studio: Data > Structure Member Alignment (/align:recnbyte)
Data > Alignment of COMMON block entities (/align:[no]commons, /align:[no]dcommons, /align:
[no]qcommons, /align:[no]zcommons)
Data > SEQUENCE Types Obey Alignment Rules (/align:[no]sequence)
Data > Default Array Alignment (/align:arraynbyte)
Alternate Options
Windows: /noalign
423
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /Zp{1|2|4|8|16}
align all Linux and macOS: -align commons -align dcommons -align records
-align nosequence
Windows: /align:nocommons,dcommons,records,nosequence
auto
Causes all local, non-SAVEd variables to be allocated
to the run-time stack.
Syntax
Linux OS:
-auto
-noauto
macOS:
-auto
-noauto
Windows OS:
/auto
/noauto
Arguments
None
Default
-auto-scalar Scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL
or /Qauto-scalar are allocated to the run-time stack.
Note that the default changes to option auto if one of the following options
are specified:
• recursive
• [q or Q]openmp
Description
This option places local variables (scalars and arrays of all types), except those declared as SAVE, on the
run-time stack. It is as if the variables were declared with the AUTOMATIC attribute.
It does not affect variables that have the SAVE attribute or ALLOCATABLE attribute, or variables that appear
in an EQUIVALENCE statement or in a common block.
424
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option may provide a performance gain for your program, but if your program depends on variables
having the same value as the last time the routine was invoked, your program may not function properly.
If you want to cause variables to be placed in static memory, specify option [Q]save. If you want only scalar
variables of certain intrinsic types to be placed on the run-time stack, specify option auto-scalar.
NOTE
On Windows NT* systems, there is a performance penalty for addressing a stack frame that
is too large. This penalty may be incurred with /[Q]auto, because arrays are allocated on
the stack along with scalars. However, with /Qauto-scalar, you would have to have more
than 32K bytes of local scalar variables before you incurred the performance
penalty. /Qauto-scalar enables the compiler to make better choices about which variables
should be kept in registers during program execution.
IDE Equivalent
Visual Studio
Visual Studio: Data > Local Variable Storage
Alternate Options
See Also
auto-scalar, Qauto-scalar compiler option
save, Qsave compiler option
auto-scalar, Qauto-scalar
Causes scalar variables of intrinsic types INTEGER,
REAL, COMPLEX, and LOGICAL that do not have the
SAVE attribute to be allocated to the run-time stack.
Syntax
Linux OS:
-auto-scalar
macOS:
-auto-scalar
Windows OS:
/Qauto-scalar
Arguments
None
425
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-auto-scalar Scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL
or /Qauto-scalar that do not have the SAVE attribute are allocated to the run-time stack.
Note that the default changes to option auto if one of the following options
are specified:
• recursive
• [q or Q]openmp
Description
This option causes allocation of scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL to
the run-time stack. It is as if they were declared with the AUTOMATIC attribute.
It does not affect variables that have the SAVE attribute (which include initialized locals) or that appear in an
EQUIVALENCE statement or in a common block.
This option may provide a performance gain for your program, but if your program depends on variables
having the same value as the last time the routine was invoked, your program may not function properly.
Variables that need to retain their values across subroutine calls should appear in a SAVE statement.
You cannot specify option save or auto with this option.
NOTE
On Windows NT* systems, there is a performance penalty for addressing a stack frame that
is too large. This penalty may be incurred with [Q]auto because arrays are allocated on the
stack along with scalars. However, with /Qauto-scalar, you would have to have more than
32K bytes of local scalar variables before you incurred the performance
penalty. /Qauto-scalar enables the compiler to make better choices about which variables
should be kept in registers during program execution.
IDE Equivalent
Visual Studio
Visual Studio: Data > Local Variable Storage (/Qsave, /Qauto, /Qauto_scalar)
Alternate Options
None
See Also
auto compiler option
save compiler option
convert
Specifies the format of unformatted files containing
numeric data.
Syntax
Linux OS:
-convert keyword
426
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-convert keyword
Windows OS:
/convert:keyword
Arguments
keyword Specifies the format for the unformatted numeric data. Possible values are:
big_endian Specifies that the format will be big endian for integer data and
big endian IEEE floating-point for real and complex data.
cray Specifies that the format will be big endian for integer data and
CRAY* floating-point for real and complex data.
fdx Specifies that the format will be little endian for integer data, and
(Linux*, macOS) VAX processor floating-point format F_floating, D_floating, and
IEEE binary128 for real and complex data.
fgx Specifies that the format will be little endian for integer data, and
(Linux, macOS) VAX processor floating-point format F_floating, G_floating, and
IEEE binary128 for real and complex data.
ibm Specifies that the format will be big endian for integer data and
IBM* System\370 floating-point format for real and complex
data.
little_endian Specifies that the format will be little endian for integer data and
little endian IEEE floating-point for real and complex data.
vaxd Specifies that the format will be little endian for integer data, and
VAX* processor floating-point format F_floating, D_floating, and
H_floating for real and complex data.
vaxg Specifies that the format will be little endian for integer data, and
VAX processor floating-point format F_floating, G_floating, and
H_floating for real and complex data.
Default
Description
This option specifies the format of unformatted files containing numeric data.
Option Description
convert big_endian Specifies that the format will be big endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and big endian IEEE floating-point for
REAL*4, REAL*8, REAL*16, COMPLEX*8, COMPLEX*16, or COMPLEX*32.
427
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
convert cray Specifies that the format will be big endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and CRAY* floating-point for REAL*8 or
COMPLEX*16.
convert fdx Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, D_floating for REAL*8 or
COMPLEX*16, and IEEE binary128 for REAL*16 or COMPLEX*32.
convert fgx Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, G_floating for REAL*8 or
COMPLEX*16, and IEEE binary128 for REAL*16 or COMPLEX*32.
convert ibm Specifies that the format will be big endian for INTEGER*1, INTEGER*2,
or INTEGER*4, and IBM* System\370 floating-point format for REAL*4 or
COMPLEX*8 (IBM short 4) and REAL*8 or COMPLEX*16 (IBM long 8).
convert little_endian Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8 and little endian IEEE floating-point for
REAL*4, REAL*8, REAL*16, COMPLEX*8, COMPLEX*16, or COMPLEX*32.
convert vaxd Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, D_floating for REAL*8 or
COMPLEX*16, and H_floating for REAL*16 or COMPLEX*32.
convert vaxg Specifies that the format will be little endian for INTEGER*1, INTEGER*2,
INTEGER*4, or INTEGER*8, and VAX processor floating-point format
F_floating for REAL*4 or COMPLEX*8, G_floating for REAL*8 or
COMPLEX*16, and H_floating for REAL*16 or COMPLEX*32.
Non-native data conversion works on scalars and arrays of intrinsic types: INTEGER*1, INTEGER*2,
INTEGER*4, INTEGER*8, including LOGICAL*1, LOGICAL*2, LOGICAL*4, LOGICAL*8, and REAL*4, REAL*8,
REAL*16, including COMPLEX*8, COMPLEX*16, and COMPLEX*32. Conversion does not work inside defined
type records on their individual fields. For example:
type REC
integer(8) :: K
real(8) :: X
end type REC
type (REC) :: R
IDE Equivalent
Windows
Visual Studio: Compatibility > Unformatted File Conversion
Alternate Options
None
428
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
double-size
Specifies the default KIND for DOUBLE PRECISION
and DOUBLE COMPLEX declarations, constants,
functions, and intrinsics.
Syntax
Linux OS:
-double-size size
macOS:
-double-size size
Windows OS:
/double-size:size
Arguments
size Specifies the default KIND for DOUBLE PRECISION and DOUBLE COMPLEX declarations,
constants, functions, and intrinsics. Possible values are: 64 (KIND=8) or 128 (KIND=16).
Default
64 DOUBLE PRECISION variables are defined as REAL*8 and DOUBLE COMPLEX variables are defined
as COMPLEX*16.
Description
This option defines the default KIND for DOUBLE PRECISION and DOUBLE COMPLEX declarations, constants,
functions, and intrinsics.
Option Description
double-size 128 Defines DOUBLE PRECISION declarations, constants, functions, and intrinsics as
REAL(KIND=16) (REAL*16) and defines DOUBLE COMPLEX declarations, functions,
and intrinsics as COMPLEX(KIND=16) (COMPLEX*32).
The real-size option overrides the double-size option; for example, on Linux* systems, "-double-size 64
-real-size 128" acts like "-double-size 128 -real-size 128".
IDE Equivalent
Windows
Visual Studio: Data > Default Double Precision KIND
Alternate Options
None
dyncom, Qdyncom
Enables dynamic allocation of common blocks at run
time.
429
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-dyncom "common1,common2,..."
macOS:
-dyncom "common1,common2,..."
Windows OS:
/Qdyncom "common1,common2,..."
Arguments
common1,common2,... Are the names of the common blocks to be dynamically allocated. The list of
names must be within quotes.
Default
Description
This option enables dynamic allocation of the specified common blocks at run time. For example, to enable
dynamic allocation of common blocks a, b, and c at run time, use this syntax:
Linux and macOS
-dyncom "a,b,c"
Windows
/Qdyncom "a,b,c"
The following are some limitations that you should be aware of when using this option:
NOTE
On macOS systems, to successfully enable dynamic allocation of common blocks, you must
specify the link-time option -undefined dynamic_lookup as well as option -dyncom.
IDE Equivalent
Windows
Visual Studio: Data > Dynamic Common Blocks
Alternate Options
None
See Also
Allocating Common Blocks
FOR__SET_FTN_ALLOC
430
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
falign-functions, Qfnalign
Tells the compiler to align procedures on an optimal
byte boundary.
Syntax
Linux OS:
-falign-functions[=n]
-fno-align-functions
macOS:
-falign-functions[=n]
-fno-align-functions
Windows OS:
/Qfnalign[:n]
/Qfnalign-
Arguments
Default
-fno-align-functions The compiler aligns procedures on 2-byte boundaries. This is the same as
or /Qfnalign- specifying -falign-functions=2 (Linux* and macOS) or /Qfnalign:2
(Windows*).
Description
This option tells the compiler to align procedures on an optimal byte boundary. If you do not specify n, the
compiler aligns the start of procedures on 16-byte boundaries.
IDE Equivalent
None
Alternate Options
None
falign-loops, Qalign-loops
Aligns loops to a power-of-two byte boundary. This
feature is only available for ifort.
431
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-falign-loops[=n]
-fno-align-loops
macOS:
-falign-loops[=n]
-fno-align-loops
Windows OS:
/Qalign-loops[:n]
/Qalign-loops-
Arguments
n Is the optional number of bytes for the minimum alignment boundary. It must be a power of 2
between 1 and 4096, such as 1, 2, 4, 8, 16, 32, 64, 128, and so on.
If you specify 1 for n, no alignment is performed; this is the same as specifying the negative form
of the option.
If you do not specify n, the default alignment is 16 bytes.
Default
Description
This option aligns loops to a power-of-two boundary. This alignment may improve performance.
It can be affected by the directives CODE_ALIGN and ATTRIBUTES CODE_ALIGN.
If code is compiled with the -falign-loops=m (Linux* and macOS) or /Qalign-loops:m (Windows*)
option and a CODE_ALIGN:n directive precedes a loop, the loop is aligned on a MAX (m, n) byte boundary. If
a procedure has the CODE_ALIGN:k attribute and a CODE_ALIGN:n directive precedes a loop, then both the
procedure and the loop are aligned on a MAX (k, n) byte boundary.
IDE Equivalent
None
Alternate Options
None
Example
Consider the following code fragment in file test_align_loops.f90:
DO J = 1, N
…
END DO
432
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
falign-functions, Qfnalign compiler option
CODE_ALIGN directive
ATTRIBUTES CODE_ALIGN directive
falign-stack
Tells the compiler the stack alignment to use on entry
to routines. This is a deprecated option that may be
removed in a future release. This feature is only
available for ifort.
Architecture Restrictions
Only available on IA-32 architecture. IA-32 support is deprecated and will be removed in a future release.
Syntax
Linux OS:
-falign-stack=mode
macOS:
None
Windows OS:
None
Arguments
mode Is the method to use for stack alignment. Possible values are:
Default
Description
This option tells the compiler the stack alignment to use on entry to routines.
433
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This is a deprecated option that may be removed in a future release. There is no replacement option.
IDE Equivalent
None
Alternate Options
None
fcommon
Determines whether the compiler treats common
symbols as global definitions. This feature is only
available for ifort.
Syntax
Linux OS:
-fcommon
-fno-common
macOS:
-fcommon
-fno-common
Windows OS:
None
Arguments
None
Default
-fcommon The compiler does not treat common symbols as global definitions.
Description
This option determines whether the compiler treats common symbols as global definitions and to allocate
memory for each symbol at compile time.
Option -fno-common tells the compiler to treat common symbols as global definitions. When using this
option, you can only have a common variable declared in one module; otherwise, a link time error will occur
for multiple defined symbols.
On macOS, if a library built with the ar utility contains objects with Fortran module data but no executable
functions, the symbols corresponding to the module data may not be resolved when an object referencing
them is linked against the library. You can work around this by compiling with option -fno-common.
IDE Equivalent
None
Alternate Options
None
434
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fkeep-static-consts, Qkeep-static-consts
Tells the compiler to preserve allocation of variables
that are not referenced in the source. This feature is
only available for ifort.
Syntax
Linux OS:
-fkeep-static-consts
-fno-keep-static-consts
macOS:
-fkeep-static-consts
-fno-keep-static-consts
Windows OS:
/Qkeep-static-consts
/Qkeep-static-consts-
Arguments
None
Default
Description
This option tells the compiler to preserve allocation of variables that are not referenced in the source.
The negated form can be useful when optimizations are enabled to reduce the memory usage of static data.
IDE Equivalent
None
Alternate Options
None
fmath-errno
Tells the compiler that errno can be reliably tested
after calls to standard math library functions. This
feature is only available for ifort.
Syntax
Linux OS:
-fmath-errno
-fno-math-errno
macOS:
-fmath-errno
435
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-fno-math-errno
Windows OS:
None
Arguments
None
Default
-fno-math-errno The compiler assumes that the program does not test errno after
calls to standard math library functions.
Description
This option tells the compiler to assume that the program tests errno after calls to math library functions.
This restricts optimization because it causes the compiler to treat most math functions as having side effects.
Option -fno-math-errno tells the compiler to assume that the program does not test errno after calls to
math library functions. This frequently allows the compiler to generate faster code. Floating-point code that
relies on IEEE exceptions instead of errno to detect errors can safely use this option to improve
performance.
IDE Equivalent
None
Alternate Options
None
fminshared
Specifies that a compilation unit is a component of a
main program and should not be linked as part of a
shareable object. This feature is only available for
ifort.
Syntax
Linux OS:
-fminshared
macOS:
-fminshared
Windows OS:
None
Arguments
None
Default
OFF Source files are compiled together to form a single object file.
436
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option specifies that a compilation unit is a component of a main program and should not be linked as
part of a shareable object.
This option allows the compiler to optimize references to defined symbols without special visibility settings.
To ensure that external and common symbol references are optimized, you need to specify visibility hidden
or protected by using the -fvisibility, -fvisibility-hidden, or -fvisibility-protected option.
Also, the compiler does not need to generate position-independent code for the main program. It can use
absolute addressing, which may reduce the size of the global offset table (GOT) and may reduce memory
traffic.
IDE Equivalent
None
Alternate Options
None
See Also
fvisibility compiler option
fpconstant
Tells the compiler that single-precision constants
assigned to double-precision variables should be
evaluated in double precision.
Syntax
Linux OS:
-fpconstant
-nofpconstant
macOS:
-fpconstant
-nofpconstant
Windows OS:
/fpconstant
/nofpconstant
Arguments
None
Default
Description
This option tells the compiler that single-precision constants assigned to double-precision variables should be
evaluated in double precision.
This is extended precision. It does not comply with the Fortran 2003 standard, which requires that single-
precision constants assigned to double-precision variables be evaluated in single precision.
437
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
It allows compatibility with FORTRAN 77, where such extended precision was allowed. If this option is not
used, certain programs originally created for FORTRAN 77 compilers may show different floating-point results
because they rely on the extended precision for single-precision constants assigned to double-precision
variables.
IDE Equivalent
Windows
Visual Studio: Floating-Point > Extend Precision of Single-Precision Constants
Alternate Options
None
Example
In the following example, if you specify fpconstant, identical values are assigned to D1 and D2. If you omit
fpconstant, the compiler will obey the Fortran 2003 Standard and assign a less precise value to D1:
fpic
Determines whether the compiler generates position-
independent code.
Syntax
Linux OS:
-fpic
-fno-pic
macOS:
-fpic
-fno-pic
Windows OS:
None
Arguments
None
Default
Description
This option determines whether the compiler generates position-independent code.
Option -fpic specifies full symbol preemption. Global symbol definitions as well as global symbol references
get default (that is, preemptable) visibility unless explicitly specified otherwise.
Option -fpic must be used when building shared objects.
438
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
fpie
Tells the compiler to generate position-independent
code. The generated code can only be linked into
executables.
Syntax
Linux OS:
-fpie
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option tells the compiler to generate position-independent code. It is similar to -fpic, but code
generated by -fpie can only be linked into an executable.
Because the object is linked into an executable, this option causes better optimization of some symbol
references.
To ensure that run-time libraries are set up properly for the executable, you should also specify option -pie
to the compiler driver on the link command line.
Option -fpie can also be specified as -fPIE.
IDE Equivalent
None
Alternate Options
None
See Also
fpic compiler option
pie compiler option
439
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fstack-protector
Enables or disables stack overflow security checks for
certain (or all) routines.
Syntax
Linux OS:
-fstack-protector[-keyword]
-fno-stack-protector[-keyword]
macOS:
-fstack-protector[-keyword]
-fno-stack-protector[-keyword]
Windows OS:
None
Arguments
If no -keyword is specified, option -fstack-protector enables stack overflow security checks for routines
with a string buffer.
Default
-fno-stack-protector, No stack overflow security checks are enabled for the relevant
-fno-stack-protector-strong routines.
-fno-stack-protector-all No stack overflow security checks are enabled for any routines.
Description
This option enables or disables stack overflow security checks for certain (or all) routines. A stack overflow
occurs when a program stores more data in a variable on the execution stack than is allocated to the
variable. Writing past the end of a string buffer or using an index for an array that is larger than the array
bound could cause a stack overflow and security violations.
The -fstack-protector options are provided for compatibility with gcc. They use the gcc/glibc
implementation when possible. If the gcc/glibc implementation is not available, they use the Intel
implementation.
For an Intel-specific version of this feature, see option -fstack-security-check.
IDE Equivalent
None
Alternate Options
None
440
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fstack-security-check compiler option
GS compiler option
fstack-security-check
Determines whether the compiler generates code that
detects some buffer overruns.
Syntax
Linux OS:
-fstack-security-check
-fno-stack-security-check
macOS:
-fstack-security-check
-fno-stack-security-check
Windows OS:
None
Arguments
None
Default
Description
This option determines whether the compiler generates code that detects some buffer overruns that
overwrite the return address. This is a common technique for exploiting code that does not enforce buffer
size restrictions.
This option always uses an Intel implementation.
For a gcc-compliant version of this feature, see option fstack-protector.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /GS
See Also
fstack-protector compiler option
GS compiler option
441
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fvisibility
Specifies the default visibility for global symbols or the
visibility for symbols in a file. This feature is only
available for ifort.
Syntax
Linux OS:
-fvisibility=keyword
-fvisibility-keyword=filename
macOS:
-fvisibility=keyword
-fvisibility-keyword=filename
Windows OS:
None
Arguments
filename Is the pathname of a file containing the list of symbols whose visibility
you want to set. The symbols must be separated by whitespace
(spaces, tabs, or newlines).
Default
Description
This option specifies the default visibility for global symbols (syntax -fvisibility=keyword) or the visibility
for symbols in a file (syntax -fvisibility-keyword=filename).
Option Description
442
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
If an -fvisibility option is specified more than once on the command line, the last specification takes
precedence over any others.
If a symbol appears in more than one visibility filename, the setting with the least visibility takes precedence.
The following shows the precedence of the visibility settings (from greatest to least visibility):
• extern
• default
• protected
• hidden
• internal
Note that extern visibility only applies to functions. If a variable symbol is specified as extern, it is
assumed to be default.
IDE Equivalent
None
Alternate Options
None
Example
A file named prot.txt contains symbols a, b, c, d, and e. Consider the following:
-fvisibility-protected=prot.txt
This option sets protected visibility for all the symbols in the file. It has the same effect as specifying
fvisibility=protected in the declaration for each of the symbols.
443
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
fzero-initialized-in-bss, Qzero-initialized-in-bss
Determines whether the compiler places in the DATA
section any variables explicitly initialized with zeros.
This feature is only available for ifort.
Syntax
Linux OS:
-fzero-initialized-in-bss
-fno-zero-initialized-in-bss
macOS:
-fzero-initialized-in-bss
-fno-zero-initialized-in-bss
Windows OS:
/Qzero-initialized-in-bss
/Qzero-initialized-in-bss-
Arguments
None
Default
-fno-zero-initialized-in-bss Variables explicitly initialized with zeros are placed in the BSS
or /Qzero-initialized-in-bss- section. This can save space in the resulting code.
Description
This option determines whether the compiler places in the DATA section any variables explicitly initialized
with zeros.
If option -fno-zero-initialized-in-bss (Linux* and macOS) or /Qzero-initialized-in-bss-
(Windows*) is specified, the compiler places in the DATA section any variables that are initialized to zero.
IDE Equivalent
None
Alternate Options
None
Gs
Lets you control the threshold at which the stack
checking routine is called or not called. This feature is
only available for ifort.
Syntax
Linux OS:
None
macOS:
None
444
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Gs[n]
Arguments
Default
/Gs Stack checking occurs for routines that require more than 4KB (4096 bytes) of stack space. This
is also the default if you do not specify n.
Description
This option lets you control the threshold at which the stack checking routine is called or not called. If a
routine's local stack allocation exceeds the threshold (n), the compiler inserts a __chkstk() call into the
prologue of the routine.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
GS
Determines whether the compiler generates code that
detects some buffer overruns.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/GS[:keyword]
/GS-
Arguments
keyword Specifies the level of stack protection heuristics used by the compiler. Possible values are:
445
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
off Tells the compiler to ignore buffer overruns. This is the same
as specifying /GS-.
strong Tells the compiler to provide full stack security level checking.
This setting is compatible with more recent Microsoft* Visual
Studio stack protection heuristics. This is the same as
specifying /GS with no keyword.
Default
Description
This option determines whether the compiler generates code that detects some buffer overruns that
overwrite a function's return address, exception handler address, or certain types of parameters.
This option has been added for Microsoft compatibility.
Following Visual Studio 2008, the Microsoft implementation of option /GS became more extensive (for
example, more routines are protected). The performance of some programs may be impacted by the newer
heuristics. In such cases, you may see better performance if you specify /GS:partial.
For more details about option /GS, see the Microsoft documentation.
IDE Equivalent
None
Alternate Options
Linux and macOS: -fstack-security-check
Windows: None
See Also
fstack-security-check compiler option
fstack-protector compiler option
homeparams
Tells the compiler to store parameters passed in
registers to the stack. This feature is only available for
ifort.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
None
macOS:
None
446
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/homeparams
Arguments
None
Default
Description
This option tells the compiler to store parameters passed in registers to the stack.
IDE Equivalent
None
Alternate Options
None
init, Qinit
Lets you initialize a class of variables to zero or to
various numeric exceptional values.
Syntax
Linux OS:
-init=keyword [, keyword ]
macOS:
-init=keyword [, keyword ]
Windows OS:
/Qinit:keyword [, keyword ]
Arguments
keyword Specifies the initial value for a class of variables. Possible values are:
447
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF No initializations are performed by default if you do not specify any of these options.
Description
This option lets you initialize a class of variables to zero or to one or more of the various numeric exceptional
values positive or negative huge, positive or negative Infinity, signaling NaN, or positive or negative tiny.
If you only specify the keyword [minus_]huge, [minus_]infinity, snan, [minus_]tiny, or zero, option
[Q]init affects only scalar variables. To apply an initialization to arrays as well, you must also specify the
keyword arrays.
If you have specified an ALLOCATE statement and you specify one or more [Q]init keywords, the initializers
are applied to the memory that has been allocated by the ALLOCATE statement.
Keywords are applied to the various numeric types in the following order:
• For REAL and COMPLEX variables, keywords [minus_]huge, [minus_]infinity, snan, [minus_]tiny,
and zero initialize to the specified value.
• For INTEGER variables, keywords [minus_]huge and zero initialize to the specified value.
• For LOGICAL variables, keyword zero initializes to .FALSE..
The following classes of variables are initialized by the [Q]init option:
• Variables of intrinsic numeric type, that is, of type COMPLEX, INTEGER, LOGICAL, or REAL, of any KIND
• SAVEd scalar or array variables, not in the main program, that are not initialized in the source code
• Local scalars and arrays
• Module variables that are not initialized in the source code
• Automatic arrays
448
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The keywords [minus_]infinity, snan, and [minus_]tiny only affect certain variables of REAL or
COMPLEX type.
• You cannot initialize variables in equivalence groups to any of the numeric exceptional values.
• In an equivalence group, if no member of that equivalence group has an explicit initialization or a default
initialization (in the case of a derived type), a variable in that equivalence group can be initialized to zero
but not to any of the numeric exceptional values.
• Derived types, arrays of derived types, and their components will not be initialized.
• Dummy arguments including adjustable arrays will not be initialized.
• Variables in COMMON will not be initialized.
The following spellings all cause the same behavior, that is, they initialize certain numeric arrays and scalars
to zero:
1. snan
2. infinity or minus_infinity
3. tiny or minus_tiny
4. huge or minus_huge
5. zero
Because an INTEGER variable can be initialized to huge or minus_huge, or zero, these initializations are
applied in the following order:
1. huge or minus_huge
2. zero
For example, if the you specify [Q]init zero, minus_huge, snan when compiling the following program:
program test
real X
integer K
complex C
end
The variable X will be initialized with a signaling NaN (snan), variable K will be initialized to the integer value
minus_huge, and the real and imaginary parts of variable C will be initialized to a signaling NaN (snan) in
each.
449
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify [Q]init snan, the floating-point exception handling flags will be set to trap signaling NaN and
halt so that when such a value is trapped at run-time, the Fortran library can catch the usage, display an
error message about a possible uninitialized variable, display a traceback, and stop execution. You can use
the debugger to determine where in your code this uninitialized variable is being referenced when execution
stops.
Setting the option [Q]init snan implicitly sets the option fpe 0. A compile time warning will occur if you
specify both option fpe 3 and option [Q]init snan on the command line. In this case, fpe 3 is ignored.
NOTE
If you build with optimization, the compiler may speculate floating-point operations,
assuming the default floating-point environment in which floating-point exceptions are
masked. When you add [Q]init snan, this speculation may result in exceptions, unrelated
to uninitialized variables, that now get trapped. To avoid this, reduce the optimization level
to /O1 or /Od (Windows*), or -O1 or -O0 (Linux* and macOS) when doing uninitialized
variable detection.
If you wish to maintain optimization, you should add option [Q]fp-speculation safe to disable
speculation when there is a possibility that the speculation may result in a floating-point exception.
NOTE
To avoid possible performance issues, you should only use [Q]init for debugging (for
example, [Q]init zero) and checking for uninitialized variables (for example,
[Q]init snan).
Use option [Q]save if you wish all variables to be specifically marked as SAVE.
IDE Equivalent
Visual Studio
Visual Studio: Data > Initialize Variables to Signaling NaN
Data > Initialize Variables to Zero
Data > Initialize Arrays as well as Scalars
Alternate Options
None
Example
The following example shows how to initialize scalars of intrinsic type REAL and COMPLEX to signaling NaN,
and scalars of intrinsic type INTEGER and LOGICAL to zero:
450
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
O compiler option
fp-speculation, Qfp-speculation compiler option
Explicit-Shape Specifications for details on automatic arrays and adjustable arrays
HUGE
TINY
Data Representation Models
intconstant
Tells the compiler to use FORTRAN 77 semantics to
determine the kind parameter for integer constants.
Syntax
Linux OS:
-intconstant
-nointconstant
macOS:
-intconstant
-nointconstant
Windows OS:
/intconstant
/nointconstant
Arguments
None
Default
Description
This option tells the compiler to use FORTRAN 77 semantics to determine the kind parameter for integer
constants.
With FORTRAN 77 semantics, the kind is determined by the value of the constant. All constants are kept
internally by the compiler in the highest precision possible. For example, if you specify option intconstant,
the compiler stores an integer constant of 14 internally as INTEGER(KIND=8) and converts the constant
upon reference to the corresponding proper size. Fortran specifies that integer constants with no explicit
KIND are kept internally in the default INTEGER kind (KIND=4 by default).
Note that the internal precision for floating-point constants is controlled by option fpconstant.
IDE Equivalent
Windows
Visual Studio: Compatibility > Use F77 Integer Constants
Alternate Options
None
451
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
integer-size
Specifies the default KIND for integer and logical
variables.
Syntax
Linux OS:
-integer-size size
macOS:
-integer-size size
Windows OS:
/integer-size:size
Arguments
size Is the size for integer and logical variables. Possible values are: 16, 32, or 64.
Default
integer-size 32 Integer and logical variables are 4 bytes long (INTEGER(KIND=4) and
LOGICAL(KIND=4)).
Description
This option specifies the default size (in bits) for integer and logical variables.
Option Description
integer-size 16 Makes default integer and logical declarations, constants, functions, and intrinsics 2
bytes long. INTEGER and LOGICAL declarations are treated as (KIND=2). Integer
and logical constants of unspecified KIND are evaluated in INTEGER (KIND=2) and
LOGICAL(KIND=2)respectively.
integer-size 32 Makes default integer and logical declarations, constants, functions, and intrinsics 4
bytes long. INTEGER and LOGICAL declarations are treated as (KIND=4). Integer
and logical constants of unspecified KIND are evaluated in INTEGER (KIND=4) and
LOGICAL(KIND=4)respectively.
integer-size 64 Makes default integer and logical declarations, constants, functions, and intrinsics 8
bytes long. INTEGER and LOGICAL declarations are treated as (KIND=8). Integer
and logical constants of unspecified KIND are evaluated in INTEGER (KIND=8) and
LOGICAL(KIND=8)respectively.
IDE Equivalent
Windows
Visual Studio: Data > Default Integer KIND
Alternate Options
Windows: /4I2
452
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /4I4
Windows: /4I8
mcmodel
Tells the compiler to use a specific memory model to
generate code and store data.
Architecture Restrictions
Only available on Intel® 64 architecture
Syntax
Linux OS:
-mcmodel=mem_model
macOS:
None
Windows OS:
None
Arguments
Default
-mcmodel=small On systems using Intel® 64 architecture, the compiler restricts code and data to the
first 2GB of address space. Instruction Pointer (IP)-relative addressing can be used to
access code and data.
Description
This option tells the compiler to use a specific memory model to generate code and store data. It can affect
code size and performance. If your program has COMMON blocks and local data with a total size smaller than
2GB, -mcmodel=small is sufficient. COMMONs larger than 2GB require-mcmodel=medium or
-mcmodel=large. Allocation of memory larger than 2GB can be done with any setting of -mcmodel.
453
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IP-relative addressing requires only 32 bits, whereas absolute addressing requires 64-bits. IP-relative
addressing is somewhat faster. So, the small memory model has the least impact on performance.
NOTE
When you specify option -mcmodel=medium or -mcmodel=large, it sets option -shared-intel.
This ensures that the correct dynamic versions of the Intel run-time libraries are used.
If you specify option -static-intel while -mcmodel=medium or -mcmodel=large is set, an error will
be displayed.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to compile using -mcmodel:
See Also
shared-intel compiler option
fpic compiler option
mdynamic-no-pic
Generates code that is not position-independent but
has position-independent external references. This
feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-mdynamic-no-pic
Windows OS:
None
Arguments
None
Default
Description
This option generates code that is not position-independent but has position-independent external
references.
The generated code is suitable for building executables, but it is not suitable for building shared libraries.
454
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option may reduce code size and produce more efficient code. It overrides the -fpic compiler option.
IDE Equivalent
None
Alternate Options
None
See Also
fpic compiler option
no-bss-init, Qnobss-init
Tells the compiler to place in the DATA section any
uninitialized variables and explicitly zero-initialized
variables. This is a deprecated option that may be
removed in a future release. This feature is only
available for ifort.
Syntax
Linux OS:
-no-bss-init
macOS:
-no-bss-init
Windows OS:
/Qnobss-init
Arguments
None
Default
OFF Uninitialized variables and explicitly zero-initialized variables are placed in the BSS section.
Description
This option tells the compiler to place in the DATA section any uninitialized variables and explicitly zero-
initialized variables.
This is a deprecated option that may be removed in a future release. There is no replacement option.
IDE Equivalent
None
Alternate Options
None
Qsfalign
Specifies stack alignment for functions. This is a
deprecated option that may be removed in a future
release. This feature is only available for ifort.
455
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Architecture Restrictions
Only available on IA-32 architecture. IA-32 support is deprecated and will be removed in a future release.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qsfalign[n]
Arguments
Default
Description
This option specifies stack alignment for functions. It lets you disable the normal optimization that aligns a
stack for 8-byte data.
This is a deprecated option that may be removed in a future release. There is no replacement option.
If you do not specify n, stack alignment occurs for all functions. If you specify /Qsfalign-, no stack
alignment occurs for any function.
IDE Equivalent
None
Alternate Options
None
456
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
real-size
Specifies the default KIND for real and complex
declarations, constants, functions, and intrinsics.
Syntax
Linux OS:
-real-size size
macOS:
-real-size size
Windows OS:
/real-size:size
Arguments
size Is the size for real and complex declarations, constants, functions, and intrinsics. Possible values
are: 32, 64, or 128.
Default
real-size 32 Default real and complex declarations, constants, functions, and intrinsics
are 4 bytes long (REAL(KIND=4) and COMPLEX(KIND=4)).
Description
This option specifies the default size (in bits) for real and complex declarations, constants, functions, and
intrinsics.
Option Description
real-size 32 Makes default real and complex declarations, constants, functions, and intrinsics 4
bytes long. REAL declarations are treated as single precision REAL (REAL(KIND=4))
and COMPLEX declarations are treated as COMPLEX (COMPLEX(KIND=4)). Real and
complex constants of unspecified KIND are evaluated in single precision (KIND=4).
real-size 64 Makes default real and complex declarations, constants, functions, and intrinsics 8
bytes long. REAL declarations are treated as DOUBLE PRECISION (REAL(KIND=8))
and COMPLEX declarations are treated as DOUBLE COMPLEX (COMPLEX(KIND=8)).
Real and complex constants of unspecified KIND are evaluated in double precision
(KIND=8).
real-size 128 Makes default real and complex declarations, constants, functions, and intrinsics 16
bytes long. REAL declarations are treated as extended precision REAL
(REAL(KIND=16)); COMPLEX and DOUBLE COMPLEX declarations are treated as
extended precision COMPLEX (COMPLEX(KIND=16)). Real and complex constants of
unspecified KIND are evaluated in extended precision (KIND=16).
These compiler options can affect the result type of intrinsic procedures, such as CMPLX, FLOAT, REAL, SNGL,
and AIMAG, which normally produce single-precision REAL or COMPLEX results. To prevent this effect, you
must explicitly declare the kind type for arguments of such intrinsic procedures.
For example, if real-size 64 is specified, the CMPLX intrinsic will produce a result of type DOUBLE
COMPLEX (COMPLEX(KIND=8)). To prevent this, you must explicitly declare any real argument to be
REAL(KIND=4), and any complex argument to be COMPLEX(KIND=4).
457
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Data > Default Real KIND
Alternate Options
Windows: /4R4
Windows: /4R16
save, Qsave
Causes variables to be placed in static memory.
Syntax
Linux OS:
-save
macOS:
-save
Windows OS:
/Qsave
Arguments
None
Default
-auto-scalar Scalar variables of intrinsic types INTEGER, REAL, COMPLEX, and LOGICAL
or /Qauto-scalar are allocated to the run-time stack. Note that the default changes to option
auto if one of the following options are specified:
• recursive
• [q or Q]openmp
Description
This option saves all variables in static allocation except local variables within a recursive routine and
variables declared as AUTOMATIC.
If you want all local, non-SAVEd variables to be allocated to the run-time stack, specify option auto.
IDE Equivalent
Visual Studio
Visual Studio: Data > Local Variable Storage
458
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Linux and macOS: -noauto
See Also
auto compiler option
auto_scalar compiler option
zero, Qzero
Initializes to zero variables of intrinsic type INTEGER,
REAL, COMPLEX, or LOGICAL that are not yet
initialized. This is a deprecated option. The
replacement option is /Qinit:[no]zero or -
init=[no]zero.
Syntax
Linux OS:
-zero
-nozero
macOS:
-zero
-nozero
Windows OS:
/Qzero
/Qzero-
Arguments
None
Default
Description
This option initializes to zero variables of intrinsic type INTEGER, REAL, COMPLEX, or LOGICAL that are not
yet initialized.
Use option [Q]save on the command line to make all local variables specifically marked as SAVE.
IDE Equivalent
None
Alternate Options
None
See Also
init, Qinit compiler option (see setting zero)
save compiler option
459
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
diag, Qdiag
Controls the display of diagnostic information during
compilation.
Syntax
Linux OS:
-diag-type=diag-list
macOS:
-diag-type=diag-list
Windows OS:
/Qdiag-type:diag-list
Arguments
460
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option controls the display of diagnostic information during compilation. Diagnostic messages are output
to stderr unless the [Q]diag-file option is specified.
NOTE
The [Q]diag options do not control diagnostics emitted at run-time. For more information
about run-time errors and diagnostics, see Handling Run-Time Errors.
On ifort, to control the diagnostic information reported by the vectorizer, use options [q or Q]opt-report
and [q or Q]opt-report-phase, phase vec.
On ifort, to control the diagnostic information reported by the auto-parallelizer, use options
[q or Q]opt-report and [q or Q]opt-report-phase, phase par.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Disable Specific Diagnostics
461
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Example
The following example shows how to disable all remarks or comments:
See Also
diag-dump, Qdiag-dump compiler option
diag-id-numbers, Qdiag-id-numbers compiler option
diag-file, Qdiag-file compiler option
qopt-report, Qopt-report compiler option (ifort)
qopt-report, Qopt-report compiler option (ifx)
x, Qx compiler option
462
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
diag-dump, Qdiag-dump
Tells the compiler to print all enabled diagnostic
messages.
Syntax
Linux OS:
-diag-dump
macOS:
-diag-dump
Windows OS:
/Qdiag-dump
Arguments
None
Default
Description
This option tells the compiler to print all enabled diagnostic messages. The diagnostic messages are output to
stdout.
This option prints the enabled diagnostics from all possible diagnostics that the compiler can issue, including
any default diagnostics.
If diag-list is specified for the [Q]diag-enable option, the print out will include the diag-list diagnostics.
IDE Equivalent
None
Alternate Options
None
Example
The following example adds vectorizer diagnostic messages to the printout of default diagnostics:
See Also
diag, Qdiag compiler option
diag-error-limit, Qdiag-error-limit
Specifies the maximum number of errors allowed
before compilation stops.
Syntax
Linux OS:
-diag-error-limit=n
-no-diag-error-limit
463
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-diag-error-limit=n
-no-diag-error-limit
Windows OS:
/Qdiag-error-limit:n
/Qdiag-error-limit-
Arguments
Default
Description
This option specifies the maximum number of errors allowed before compilation stops. It indicates the
maximum number of error-level or fatal-level compiler errors allowed for a file specified on the command
line.
If you specify the negative form of the [Q]diag-error-limit option on the command line, there is no limit
on the number of errors that are allowed.
If the maximum number of errors is reached, a warning message is issued and the next file (if any) on the
command line is compiled.
IDE Equivalent
Visual Studio
Visual Studio: Diagnostics > Error Limit
Alternate Options
Linux and macOS: -error-limit and -noerror-limit
diag-file, Qdiag-file
Causes the results of diagnostic analysis to be output
to a file.
Syntax
Linux OS:
-diag-file[=filename]
macOS:
None
Windows OS:
/Qdiag-file[:filename]
464
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
Default
Description
This option causes the results of diagnostic analysis to be output to a file. The file is placed in the current
working directory.
You can include a file extension in filename. For example, if file.txt is specified, the name of the output file is
file.txt. If you do not provide a file extension, the name of the file is filename.diag.
If filename is not specified, the name of the file is name-of-the-first-source-file.diag. This is also the name of
the file if the name specified for file conflicts with a source file name provided in the command line.
NOTE
If you specify the [Q]diag-file option and you also specify the [Q]diag-file-append
option, the last option specified on the command line takes precedence.
IDE Equivalent
Windows
Visual Studio: Diagnostics > Diagnostics File
Alternate Options
None
Example
The following example shows how to cause diagnostic analysis to be output to a file named
my_diagnostics.diag:
diag-file-append, Qdiag-file-append
Causes the results of diagnostic analysis to be
appended to a file.
Syntax
Linux OS:
-diag-file-append[=filename]
macOS:
None
Windows OS:
/Qdiag-file-append[:filename]
465
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
filename Is the name of the file to be appended to. It can include a path.
Default
Description
This option causes the results of diagnostic analysis to be appended to a file. If you do not specify a path, the
driver will look for filename in the current working directory.
If filename is not found, then a new file with that name is created in the current working directory. If the
name specified for file conflicts with a source file name provided in the command line, the name of the file is
name-of-the-first-source-file.diag.
NOTE
If you specify the [Q]diag-file-append option and you also specify the [Q]diag-file
option, the last option specified on the command line takes precedence.
IDE Equivalent
None
Alternate Options
None
Example
The following example shows how to cause diagnostic analysis to be appended to a file named
my_diagnostics.txt:
See Also
diag-file, Qdiag-file compiler option
diag-id-numbers, Qdiag-id-numbers
Determines whether the compiler displays diagnostic
messages by using their ID number values.
Syntax
Linux OS:
-diag-id-numbers
-no-diag-id-numbers
macOS:
-diag-id-numbers
-no-diag-id-numbers
Windows OS:
/Qdiag-id-numbers
466
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/Qdiag-id-numbers-
Arguments
None
Default
-diag-id-numbers The compiler displays diagnostic messages by using their ID number values.
or /Qdiag-id-numbers
Description
This option determines whether the compiler displays diagnostic messages by using their ID number values.
If you specify the negative form of the [Q]diag-id-numbers option, mnemonic names are output for driver
diagnostics only.
IDE Equivalent
None
Alternate Options
None
See Also
diag, Qdiag compiler option
diag-once, Qdiag-once
Tells the compiler to issue one or more diagnostic
messages only once.
Syntax
Linux OS:
-diag-onceid[,id,...]
macOS:
-diag-onceid[,id,...]
Windows OS:
/Qdiag-once:id[,id,...]
Arguments
id Is the ID number of the diagnostic message. If you specify more than one message number, they
must be separated by commas. There can be no intervening white space between each id.
Default
Description
This option tells the compiler to issue one or more diagnostic messages only once.
IDE Equivalent
None
467
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
gen-interfaces
Tells the compiler to generate an interface block for
each routine in a source file.
Syntax
Linux OS:
-gen-interfaces [[no]source]
-nogen-interfaces
macOS:
-gen-interfaces [[no]source]
-nogen-interfaces
Windows OS:
/gen-interfaces[:[no]source]
/nogen-interfaces
Arguments
None
Default
nogen-interfaces The compiler does not generate interface blocks for routines in a source file.
Description
This option tells the compiler to generate an interface block for each routine (that is, for each SUBROUTINE
and FUNCTION statement) defined in the source file. The compiler generates two files for each routine,
a .mod file and a .f90 file, and places them in the current directory or in the directory specified by the include
(-I) or -module option. The .f90 file is the text of the interface block; the .mod file is the interface block
compiled into binary form. The .f90 file is for reference only and may not completely represent the generated
interface used by the compiler.
If source is specified, the compiler creates the procedure-name__GENmod.f90 as well as the procedure-
name__GENmod.mod files. If nosource is specified, the compiler creates the procedure-
name__GENmod.mod but not the procedure-name__GENmod.f90 files. If neither is specified, it is the same
as specifying setting source for the gen-interfaces option.
On Windows* systems, for a Debug configuration in a Visual Studio project, the default
is /warn:interfaces.
IDE Equivalent
Visual Studio
Visual Studio: None
Alternate Options
None
468
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
traceback
Tells the compiler to generate extra information in the
object file to provide source file traceback information
when a severe error occurs at run time.
Syntax
Linux OS:
-traceback
-notraceback
macOS:
-traceback
-notraceback
Windows OS:
/traceback
/notraceback
Arguments
None
Default
notraceback No extra information is generated in the object file to produce traceback information.
Description
This option tells the compiler to generate extra information in the object file to provide source file traceback
information when a severe error occurs at run time.
When the severe error occurs, source file, routine name, and line number correlation information is displayed
along with call stack hexadecimal addresses (program counter trace).
Note that when a severe error occurs, advanced users can also locate the cause of the error using a map file
and the hexadecimal addresses of the stack displayed when the error occurs.
This option increases the size of the executable program, but has no impact on run-time execution speeds.
It functions independently of the debug option.
On Windows* systems, traceback sets the /Oy- option, which forces the compiler to use EBP as the stack
frame pointer.
On Windows* systems, the linker places the traceback information in the executable image, in a section
named ".trace". To see which sections are in an image, use the command:
469
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On Linux* systems, to display the section headers in the image (including the header for the .trace section, if
any), use the command:
objdump -h your_app_name.exe
On macOS systems, to display the section headers in the image, use the command:
otool -l your_app_name.exe
IDE Equivalent
Windows
Visual Studio: Run-time > Generate Traceback Information
Alternate Options
None
warn
Specifies diagnostic messages to be issued by the
compiler.
Syntax
Linux OS:
-warn [keyword[, keyword...]]
-nowarn
macOS:
-warn [keyword[, keyword...]]
-nowarn
Windows OS:
/warn[:keyword[, keyword...]]
/nowarn
Arguments
470
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
alignments Warnings are issued about data that is not naturally aligned.
noignore_bounds The compiler checks array references with constant subscripts and
warns if the reference is to an element outside the declared bounds of
the array.
nointerfaces The compiler does not check interfaces of SUBROUTINEs called and
FUNCTIONs invoked in your compilation against an external set of
interface blocks.
471
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
noshape Array conformance violations are issued as errors if the check shape
option is specified.
notruncated_source No warnings are issued when source exceeds the maximum column
width in fixed-format files.
nounused No warnings are issued for variables that are declared but never used.
Description
This option specifies the diagnostic messages to be issued by the compiler.
Option Description
warn none Disables all warning messages. This is the same as specifying nowarn.
warn noalignments Disables warnings about data that is not naturally aligned.
warn declarations Enables warnings about any undeclared names. The compiler will use
the default implicit data typing rules for such undeclared names. The
IMPLICIT and IMPLICIT NONE statements override this option.
warn errors Tells the compiler to change all warning-level messages to error-level
messages; this includes warnings about Fortran standards violations.
warn externals Enables warnings about dummy procedures and external procedures
that do not have explicit interfaces and have not been declared with
the EXTERNAL attribute.
warn ignore_bounds The compiler does not check array references with constant subscripts
and no warnings are issued if the reference is to an element outside
the declared bounds of the array.
warn ignore_loc Enables warnings when %LOC is stripped from an actual argument.
warn interfaces Tells the compiler to check the interfaces of all SUBROUTINEs called
and FUNCTIONs invoked in your compilation against a set of interface
blocks stored separately from the source being compiled.
The compiler generates a compile-time message if the interface used
to invoke a routine does not match the interface defined in a .mod file
external to the source (that is, in a .mod generated by option
gen-interfaces as opposed to a .mod file USEd in the source). The
compiler looks for these .mods in the current directory or in the
directory specified by the include (-I) or -module option. If interface
mismatches occur, some will result in a compile-time error, others will
only generate a warning.
472
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
warn shape If the check shape option is specified, array conformance violations
are issued as warnings rather than as errors.
warn stderrors Tells the compiler to change all warning-level messages about Fortran
standards violations to error-level messages. This option sets the
stand option.
warn truncated_source Enables warnings when a source line exceeds the maximum column
width in fixed-format source files. The maximum column width for
fixed-format files is 72, 80, or 132, depending on the setting of the
extend-source option. The warn truncated_source option has no
effect on truncation; lines that exceed the maximum column width are
always truncated. This option does not apply to free-format source
files.
warn nouncalled Disables warnings for variables that are declared but never used.
warn unused Enables warnings for variables that are declared but never used.
warn all This is the same as specifying warn. This option does not set options
warn errors or warn stderrors. To enable all the additional
checking to be performed and force the severity of the diagnostic
messages to be severe enough to not generate an object file, specify
options warn all and warn errors or specify options warn all and
warn stderrors.
Windows
In the Property Pages, Custom means that diagnostics will be
specified on an individual basis.
IDE Equivalent
Windows
Visual Studio: General > Compile Time Diagnostics (/warn:all, /warn:none)
Diagnostics > Language Usage Warnings > Compile Time Diagnostics (/warn:all, /warn:none)
473
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
warn none Linux and macOS: -nowarn, -w, -W0, -warn nogeneral
Windows: /4Yd
Windows: /W1
warn nogeneral Linux and macOS: -W0, -w, -nowarn, -warn none
warn stderrors Linux and macOS: -e90, -e95, -e03, -e08, -e18
Windows: None
WB
Turns a compile-time bounds check into a warning.
Syntax
Linux OS:
-WB
macOS:
-WB
Windows OS:
/WB
Arguments
None
474
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option turns a compile-time bounds check into a warning.
IDE Equivalent
None
Alternate Options
None
Winline
Warns when a function that is declared as inline is not
inlined. This feature is only available for ifort.
Syntax
Linux OS:
-Winline
macOS:
-Winline
Windows OS:
None
Arguments
None
Default
OFF No warning is produced when a function that is declared as inline is not inlined.
Description
This option warns when a function that is declared as inline is not inlined.
To see diagnostic messages, including a message about why a particular function was not inlined, you should
generate an optimization report by specifying option -qopt-report=5.
IDE Equivalent
None
Alternate Options
None
See Also
qopt-report, Qopt-report compiler option (ifort)
Compatibility Options
This section contains descriptions for compiler options that pertain to language compatibility.
475
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
f66
Tells the compiler to apply FORTRAN 66 semantics.
Syntax
Linux OS:
-f66
macOS:
-f66
Windows OS:
/f66
Arguments
None
Default
Description
This option tells the compiler to apply FORTRAN 66 semantics when interpreting language features. This
causes the following to occur:
IDE Equivalent
Windows
Visual Studio: Language > Enable FORTRAN 66 Semantics
Alternate Options
None
f77rtl
Tells the compiler to use the run-time behavior of
FORTRAN 77.
Syntax
Linux OS:
-f77rtl
-nof77rtl
macOS:
-f77rtl
476
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-nof77rtl
Windows OS:
/f77rtl
/nof77rtl
Arguments
None
Default
Description
This option tells the compiler to use the run-time behavior of FORTRAN 77.
Specifying this option controls the following run-time behavior:
• When the unit is not connected to a file, some INQUIRE specifiers will return different values:
• NUMBER= returns 0
• ACCESS= returns 'UNKNOWN'
• BLANK= returns 'UNKNOWN'
• FORM= returns 'UNKNOWN'
• There is no support for the PAD= qualifier. FORTRAN 77 does not pad formatted input.
• NAMELIST and list-directed input of character strings must be delimited by apostrophes or quotes.
• When processing NAMELIST input:
• Column 1 of each record is skipped.
• The '$' or '&' that appears prior to the group-name must appear in column 2 of the input record.
IDE Equivalent
Windows
Visual Studio: Compatibility > Enable F77 Run-Time Compatibility
Alternate Options
None
fpscomp
Controls whether certain aspects of the run-time
system and semantic language features within the
compiler are compatible with Intel® Fortran or
Microsoft* Fortran PowerStation.
Syntax
Linux OS:
-fpscomp [keyword[, keyword...]]
-nofpscomp
macOS:
-fpscomp [keyword[, keyword...]]
-nofpscomp
477
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/fpscomp[:keyword[, keyword...]]
/nofpscomp
Arguments
keyword Specifies the compatibility that the compiler should follow. Possible values are:
Default
Description
This option controls whether certain aspects of the run-time system and semantic language features within
the compiler are compatible with Intel Fortran or Microsoft* Fortran PowerStation.
If you experience problems when porting applications from Fortran PowerStation, specify fpscomp (or
fpscomp all). When porting applications from Intel Fortran, use fpscomp none or fpscomp libs (the
default).
Option Description
fpscomp none Specifies that no options should be used for compatibility with Fortran
PowerStation. This is the same as specifying nofpscomp. Option
fpscomp none enables full Intel® Fortran compatibility. If you omit
fpscomp, the default is fpscomp libs. You cannot use the fpscomp and
vms options in the same command.
fpscomp filesfromcmd Specifies Fortran PowerStation behavior when the OPEN statement FILE=
specifier is blank (FILE=' '). It causes the following actions to be taken at
run time:
478
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
• The program reads a file name from the list of arguments (if any) in
the command line that invoked the program. If any of the command-
line arguments contain a null string (''), the program asks the user for
the corresponding file name. Each additional OPEN statement with a
blank FILE= specifier reads the next command-line argument.
• If there are more nameless OPEN statements than command-line
arguments, the program prompts for additional file names.
• In a QuickWin application, a "File Select" dialog box appears to
request file names.
To prevent the run-time system from using the file name specified on the
command line when the OPEN statement FILE specifier is omitted, specify
fpscomp nofilesfromcmd. This allows the application of Intel Fortran
defaults, such as the FORTn environment variable and the FORT. n file
name (where n is the unit number).
The fpscomp filesfromcmd option affects the following Fortran
features:
• The OPEN statement FILE specifier
For example, assume a program OPENTEST contains the following
statements:
OPEN(UNIT = 2, FILE = ' ')
OPEN(UNIT = 3, FILE = ' ')
OPEN(UNIT = 4, FILE = ' ')
fpscomp general Specifies that Fortran PowerStation semantics should be used when a
difference exists between Intel Fortran and Fortran PowerStation. The
fpscomp general option affects the following Fortran features:
• The BACKSPACE statement:
• It allows files opened with ACCESS='APPEND' to be used with the
BACKSPACE statement.
• It allows files opened with ACCESS='DIRECT' to be used with the
BACKSPACE statement.
Note: Allowing files that are not opened with sequential access (such
as ACCESS='DIRECT') to be used with the BACKSPACE statement
violates the Fortran 95 standard and may be removed in the future.
• The READ statement:
479
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
480
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
481
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
fpscomp ioformat Specifies that Fortran PowerStation semantic conventions and record
formats should be used for list-directed formatted and unformatted I/O.
The fpscomp ioformat option affects the following Fortran features:
BYTE I5 I12
LOGICAL L2 L2
(all)
INTEGER(1) I5 I12
INTEGER(2) I7 I12
CHARACTER Aw Aw
482
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
fpscomp nolibs Prevents the portability library from being passed to the linker.
fpscomp ldio_spacing Specifies that at run time a blank should not be inserted after a numeric
value before a character value (undelimited character string). This
representation is used by Intel Fortran releases before Version 8.0 and by
Fortran PowerStation. If you specify fpscomp general, it sets
fpscomp ldio_spacing.
fpscomp logicals Specifies that integers with a non-zero value are treated as true, integers
with a zero value are treated as false. The literal constant .TRUE. has an
integer value of 1, and the literal constant .FALSE. has an integer value of
0. This representation is used by Intel Fortran releases before Version 8.0
and by Fortran PowerStation.
The default is fpscomp nologicals, which specifies that odd integer
values (low bit one) are treated as true and even integer values (low bit
zero) are treated as false.
The literal constant .TRUE. has an integer value of -1, and the literal
constant .FALSE. has an integer value of 0. This representation is used by
Compaq* Visual Fortran. The internal representation of LOGICAL values is
not specified by the Fortran standard. Programs which use integer values
in LOGICAL contexts, or which pass LOGICAL values to procedures
written in other languages, are non-portable and may not execute
correctly. Intel recommends that you avoid coding practices that depend
on the internal representation of LOGICAL values.
The fpscomp logicals option affects the results of all logical
expressions and affects the return value for the following Fortran
features:
• The INQUIRE statement specifiers OPENED, IOFOCUS, EXISTS, and
NAMED
• The EOF intrinsic function
• The BTEST intrinsic function
• The lexical intrinsic functions LLT, LLE, LGT, and LGE
483
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
fpscomp all Specifies that all options should be used for compatibility with Fortran
PowerStation. This is the same as specifying fpscomp with no keyword.
Option fpscomp all enables full compatibility with Fortran PowerStation.
IDE Equivalent
Windows
Visual Studio: Compatibility > Use Filenames from Command Line (/fpscomp:filesfromcmd)
Alternate Options
None
gcc-name
Lets you specify the name of the GCC compiler that
should be used to set up the link-time environment,
including the location of standard libraries.
Syntax
Linux OS:
-gcc-name=name
macOS:
None
Windows OS:
None
Arguments
name Is the name of the GCC compiler to use. It can include the path where
the GCC compiler is located.
Default
OFF The compiler uses the PATH setting to find the GCC compiler and resolve environment settings.
Description
This option lets you specify the name of the GCC compiler that should be used to set up the link-time
environment, including the location of standard libraries. If you do not specify a path, the compiler will
search the PATH settings for the compiler name you provide.
This option is helpful when you are referencing a non-standard GCC installation, or you have multiple GCC
installations on your system. The compiler will match GCC version values to the GCC compiler you specify.
484
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
Example
If the following option is specified, the compiler looks for the GCC compiler named foobar in the PATH
setting:
-gcc-name=foobar
If the following option is specified, the compiler looks for the GCC compiler named foobar in the path
specified:
-gcc-name=/a/b/foobar
See Also
gxx-name compiler option
gxx-name
Lets you specify the name of the g++ compiler that
should be used to set up the link-time environment,
including the location of standard libraries.
Syntax
Linux OS:
-gxx-name=name
macOS:
None
Windows OS:
None
Arguments
name Is the name of the g++ compiler to use. It can include the path where
the g++ compiler is located.
Default
OFF The compiler uses the PATH setting to find the g++ compiler and resolve environment settings.
Description
This option lets you specify the name of the g++ compiler that should be used to set up the link-time
environment, including the location of standard libraries. If you do not specify a path, the compiler will
search the PATH settings for the compiler name you provide.
This option is helpful if you have multiple gcc++ installations on your system. The compiler will match gcc++
version values to the gcc++ compiler you specify.
The C equivalent to option -gxx-name is -gcc-name.
485
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE When compiling a C++ file with , g++ is used to get the environment.
IDE Equivalent
None
Alternate Options
None
Example
If the following option is specified, the compiler looks for the g++ compiler named foobar in the PATH
setting:
-gxx-name=foobar
If the following option is specified, the compiler looks for the g++ compiler named foobar in the path
specified:
-gxx-name=/a/b/foobar
See Also
gcc-name compiler option
Qvc
Specifies which version of Microsoft Visual C++*
(MSVC) or Microsoft Visual Studio* that the compiler
should link to.This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Qvc14.2
Arguments
None
Default
varies When the compiler is installed, it detects which version of Microsoft Visual Studio is on your
system. Qvc defaults to the form of the option that is compatible with that version.
When multiple versions of Microsoft Visual Studio are installed, the compiler installation lets you
select which version you want to link to. In this case, Qvc defaults to the version you choose.
Description
This option specifies which version of MSVC or Microsoft Visual Studio that the compiler should link to.
486
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Option Description
IDE Equivalent
None
Alternate Options
None
vms
Causes the run-time system to behave like HP*
Fortran on OpenVMS* Alpha systems and VAX*
systems (VAX FORTRAN*).
Syntax
Linux OS:
-vms
-novms
macOS:
-vms
-novms
Windows OS:
/vms
/novms
Arguments
None
Default
Description
This option causes the run-time system to behave like HP* Fortran on OpenVMS* Alpha systems and VAX*
systems (VAX FORTRAN*).
It affects the following language features:
• Certain defaults
In the absence of other options, vms sets the defaults as check format and check
output_conversion.
• Alignment
Option vms does not affect the alignment of fields in records or items in common blocks. For compatibility
with HP Fortran on OpenVMS systems, use align norecords to pack fields of records on the next byte
boundary.
• Carriage control default
487
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If option vms and option ccdefault default are specified, carriage control defaults to FORTRAN if the
file is formatted and the unit is connected to a terminal.
• INCLUDE qualifiers
/LIST and /NOLIST are recognized at the end of the file name in an INCLUDE statement at compile time.
If the file name in the INCLUDE statement does not specify the complete path, the path used is the
current directory. Note that if vms is not specified, the path used is the directory where the file that
contains the INCLUDE statement resides.
• Quotation mark character
A quotation mark (") character is recognized as starting an octal constant ("0..7) instead of a character
literal ("...").
• Deleted records in relative files
When a record in a relative file is deleted, the first byte of that record is set to a known character
(currently '@' ). Attempts to read that record later result in ATTACCNON errors. The rest of the record
(the whole record, if vms is not specified) is set to nulls for unformatted files and spaces for formatted
files.
• ENDFILE records
When an ENDFILE is performed on a sequential unit, an actual 1-byte record containing a Ctrl/Z is written
to the file. If vms is not specified, an internal ENDFILE flag is set and the file is truncated. The vms option
does not affect ENDFILE on relative files: these files are truncated.
• Implied logical unit numbers
The vms option enables Intel® Fortran to recognize certain environment variables at run time for ACCEPT,
PRINT, and TYPE statements and for READ and WRITE statements that do not specify a unit number (such
as READ (*,1000)).
• Treatment of blanks in input
The vms option causes the defaults for the keyword BLANK in OPEN statements to become 'NULL' for an
explicit OPEN and 'ZERO' for an implicit OPEN of an external or internal file.
• OPEN statement effects
Carriage control defaults to FORTRAN if the file is formatted, and the unit is connected to a terminal.
Otherwise, carriage control defaults to LIST. The vms option affects the record length for direct access and
relative organization files. The buffer size is increased by 1 to accommodate the deleted record character.
• Reading deleted records and ENDFILE records
The run-time direct access READ routine checks the first byte of the retrieved record. If this byte is '@' or
NULL ("\0"), then an ATTACCNON error is returned. The run-time sequential access READ routine checks
to see if the record it just read is one byte long and contains a Ctrl/Z. If this is true, it returns EOF.
IDE Equivalent
Windows
Visual Studio: Compatibility > Enable VMS Compatibility
Alternate Options
None
See Also
align compiler option
ccdefault compiler option
check compiler option
488
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
4Nportlib, 4Yportlib
Determines whether the compiler links to the library of
portability routines.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/4Nportlib
/4Yportlib
Arguments
None
Default
Description
Option /4Yportlib causes the compiler to link to the library of portability routines. This also includes Intel's
functions for Microsoft* compatibility.
Option /4Nportlib prevents the compiler from linking to the library of portability routines.
IDE Equivalent
Windows
Visual Studio: Libraries > Use Portlib Library
Alternate Options
None
Bdynamic
Enables dynamic linking of libraries at run time.
Syntax
Linux OS:
-Bdynamic
macOS:
None
489
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
None
Arguments
None
Default
Description
This option enables dynamic linking of libraries at run time. Smaller executables are created than with static
linking.
This option is placed in the linker command line corresponding to its location on the user command line. It
controls the linking behavior of any library that is passed using the command line.
All libraries on the command line following option -Bdynamic are linked dynamically until the end of the
command line or until a -Bstatic option is encountered. The -Bstatic option enables static linking of
libraries.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
Bstatic compiler option
Bstatic
Enables static linking of a user's library.
Syntax
Linux OS:
-Bstatic
macOS:
None
Windows OS:
None
Arguments
None
490
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option enables static linking of a user's library.
This option is placed in the linker command line corresponding to its location on the user command line. It
controls the linking behavior of any library that is passed using the command line.
All libraries on the command line following option -Bstatic are linked statically until the end of the
command line or until a -Bdynamic option is encountered. The -Bdynamic option enables dynamic linking of
libraries.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
Bdynamic compiler option
Bsymbolic
Binds references to all global symbols in a program to
the definitions within a user's shared library.
Syntax
Linux OS:
-Bsymbolic
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF When a program is linked to a shared library, it can override the definition within the shared
library.
Description
This option binds references to all global symbols in a program to the definitions within a user's shared
library.
491
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This option is only meaningful on Executable Linkage Format (ELF) platforms that support shared libraries.
Caution
This option can have unintended side-effects of disabling symbol preemption in the shared
library.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
Bsymbolic-functions compiler option
Bsymbolic-functions
Binds references to all global function symbols in a
program to the definitions within a user's shared
library.
Syntax
Linux OS:
-Bsymbolic-functions
macOS:
None
Windows OS:
None
Arguments
None
Default
OFF When a program is linked to a shared library, it can override the definition within the shared
library.
Description
This option binds references to all global function symbols in a program to the definitions within a user's
shared library.
This option is only meaningful on Executable Linkage Format (ELF) platforms that support shared libraries.
492
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
This option can have unintended side-effects of disabling symbol preemption in the shared
library.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
Bsymbolic compiler option
cxxlib
Determines whether the compiler links using the C++
run-time libraries provided by gcc.
Syntax
Linux OS:
-cxxlib
-no-cxxlib
macOS:
-cxxlib
-no-cxxlib
Windows OS:
None
Arguments
None
Default
-no-cxxlib The compiler uses the default run-time libraries and does not link to any
additional C++ run-time libraries.
Description
This option determines whether the compiler links to the standard C++ run-time library (libstdc++). It is
useful for building mixed Fortran/C++ applications.
Option -cxxlib=dir can be used with option -gcc-name=name to specify the location dir/bin/name.
IDE Equivalent
None
493
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
gcc-name compiler option
dbglibs
Tells the linker to search for unresolved references in
a debug run-time library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/dbglibs
/nodbglibs
Arguments
None
Default
/nodbglibs The linker does not search for unresolved references in a debug run-time
library.
Description
This option tells the linker to search for unresolved references in a debug run-time library.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
The following table shows which options to specify for a debug run-time library:
494
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/dbglibs
IDE Equivalent
None
Alternate Options
None
dll
Specifies that a program should be linked as a
dynamic-link (DLL) library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/dll
Arguments
None
Default
Description
This option specifies that a program should be linked as a dynamic-link (DLL) library instead of an executable
(.exe) file. It overrides any previous specification of run-time routines to be used and enables the /libs:dll
option.
If you use this option with the /libs:qwin or /libs:qwins option, the compiler issues a warning.
IDE Equivalent
None
Alternate Options
Linux and macOS: None
Windows: /LD
dynamic-linker
Specifies a dynamic linker other than the default.
495
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-dynamic-linker file
macOS:
None
Windows OS:
None
Arguments
Default
Description
This option lets you specify a dynamic linker other than the default.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
dynamiclib
Invokes the libtool command to generate dynamic
libraries. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-dynamiclib
Windows OS:
None
Arguments
None
496
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option invokes the libtool command to generate dynamic libraries.
When passed this option, the compiler uses the libtool command to produce a dynamic library instead of
an executable when linking.
To build static libraries, you should specify option -staticlib or libtool -static <objects>.
IDE Equivalent
None
Alternate Options
None
See Also
staticlib compiler option
extlnk
Specifies file extensions to be passed directly to the
linker.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/extlnk:ext
Arguments
Default
OFF Only the file extensions recognized by the compiler are passed to the linker.
Description
This option specifies file extensions (ext) to be passed directly to the linker. It is useful if your source file has
a nonstandard extension.
You can specify one or more file extensions. A leading period before each extension is optional; for
example, /extlnk:myobj and /extlnk:.myobj are equivalent.
IDE Equivalent
None
497
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
F (Windows*)
Specifies the stack reserve amount for the program.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/Fn
Arguments
Default
Description
This option specifies the stack reserve amount for the program. The amount (n) is passed to the linker.
Note that the linker property pages have their own option to do this.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
F (macOS)
Adds a framework directory to the head of an include
file search path. This feature is only available for ifort.
Syntax
Linux OS:
None
498
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-Fdir
Windows OS:
None
Arguments
Default
OFF The compiler does not add a framework directory to the head of an include file search path.
Description
This option adds a framework directory to the head of an include file search path.
IDE Equivalent
None
Alternate Options
None
fuse-ld
Tells the compiler to use a different linker instead of
the default linker, which is ld on Linux and link on
Windows.
Syntax
Linux OS:
-fuse-ld=keyword
macOS:
-fuse-ld=keyword
Windows OS:
-fuse-ld=keyword
Arguments
keyword Tells the compiler which non-default linker to use. Possible values are:
bfd Tells the compiler to use the bfd linker. This setting is only available for
Linux and macOS.
gold Tells the compiler to use the gold linker. This setting is only available for
Linux and macOS.
lld Tells the compiler to use the lld linker. This setting is not available for
macOS.
499
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the compiler to use a different linker instead of the default linker, which is ld on Linux and
link on Windows.
On Linux, this option is provided for compatibility with gcc.
NOTE
For ifx on Windows, option /Qipo automatically sets option -fuse-ld=lld.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
flto compiler option
ipo, Qipo compiler option
l
Tells the linker to search for a specified library when
linking.
Syntax
Linux OS:
-lstring
macOS:
-lstring
Windows OS:
None
Arguments
string Specifies the library (libstring) that the linker should search.
500
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option tells the linker to search for a specified library when linking.
When resolving references, the linker normally searches for libraries in several standard directories, in
directories specified by the L option, then in the library specified by the l option.
The linker searches and processes libraries and object files in the order they are specified. So, you should
specify this option following the last object file it applies to.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
L compiler option
L
Tells the linker to search for libraries in a specified
directory before searching the standard directories.
Syntax
Linux OS:
-Ldir
macOS:
-Ldir
Windows OS:
None
Arguments
Default
Description
This option tells the linker to search for libraries in a specified directory before searching for them in the
standard directories.
501
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
l compiler option
libs
Tells the compiler which type of run-time library to
link to.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/libs[:keyword]
Arguments
keyword Specifies the type of run-time library to link to. Possible values are:
Default
Description
This option tells the compiler which type of run-time library to link to.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
502
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
There are several types of libraries you can link to, depending on which compiler options you specify, as
shown in the table below.
If you use the /libs:dll option and an unresolved reference is found in the DLL, it gets resolved when the
program is executed, during program loading, reducing executable program size.
If you use the /libs:qwin or /libs:qwins option with the /dll option, the compiler issues a warning.
You cannot use the /libs:qwin option and options /libs:dll /threads.
The following table shows which options to specify for different run-time libraries:
and /dbglibs
/dbglibs
NOTE
This option adds directives to the compiled code, which the linker then reads without further
input from the driver.
NOTE
Starting with the 13.0 release of the Intel compilers, the Intel® OpenMP* library is provided
in DLL form only.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Runtime Library (/libs:{dll|qwin|qwins}, /threads, /dbglibs)
Alternate Options
503
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /threads
See Also
threads compiler option
dbglibs compiler option
link
Passes user-specified options directly to the linker at
compile time.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/link
Arguments
None
Default
Description
This option passes user-specified options directly to the linker at compile time.
All options that appear following /link are passed directly to the linker.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
504
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Xlinker compiler option
map
Tells the linker to generate a link map file.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/map[:filename]
/nomap
Arguments
filename Is the name for the link map file. It can be a file name or a directory name.
Default
Description
This option tells the linker to generate a link map file.
IDE Equivalent
Windows
Visual Studio: Linker > Debugging > Generate Map File (/MAP)
Alternate Options
None
MD
Tells the linker to search for unresolved references in
a multithreaded, dynamic-link run-time library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/MD
/MDd
505
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arguments
None
Default
OFF The linker searches for unresolved references in a multi-threaded, static run-time library.
Description
This option tells the linker to search for unresolved references in a multithreaded, dynamic-link (DLL) run-
time library. This is the same as specifying options /libs:dll /threads /dbglibs. You can also
specify /MDd, where d indicates a debug version.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Runtime Library
Alternate Options
None
See Also
libs compiler option
threads compiler option
MDs
Tells the linker to search for unresolved references in
a single-threaded, dynamic-link run-time library. This
is a deprecated option. There is no replacement
option.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/MDs
/MDsd
Arguments
None
506
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
OFF The linker searches for unresolved references in a single-threaded, static run-time library.
Description
This option tells the linker to search for unresolved references in a single-threaded, dynamic-link (DLL) run-
time library.
You can also specify /MDsd, where d indicates a debug version.
IDE Equivalent
None
Alternate Options
See Also
libs compiler option
MT
Tells the linker to search for unresolved references in
a multithreaded, static run-time library.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/MT
/MTd
Arguments
None
Default
Description
This option tells the linker to search for unresolved references in a multithreaded, static run-time library. This
is the same as specifying options /libs:static /threads /noreentrancy. You can also specify /MTd,
where d indicates a debug version.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
507
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Runtime Library
Alternate Options
None
See Also
Qvc compiler option
libs compiler option
threads compiler option
reentrancy compiler option
nodefaultlibs
Prevents the compiler from using standard libraries
when linking.
Syntax
Linux OS:
-nodefaultlibs
macOS:
-nodefaultlibs
Windows OS:
None
Arguments
None
Default
Description
This option prevents the compiler from using standard libraries when linking.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
508
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
None
See Also
nostdlib compiler option
nofor-main
Specifies that the main program is not written in
Fortran.
Syntax
Linux OS:
-nofor-main
macOS:
-nofor-main
Windows OS:
None
Arguments
None
Default
Description
This option specifies that the main program is not written in Fortran. It is a link-time option that prevents the
compiler from linking for_main.o into applications.
For example, if the main program is written in C and calls a Fortran subprogram, specify -nofor-main when
compiling the program with the ifort command.
If you omit this option, the main program must be a Fortran program.
IDE Equivalent
None
Alternate Options
None
no-intel-lib, Qno-intel-lib
Disables linking to specified Intel® libraries, or to all
Intel® libraries.
Syntax
Linux OS:
-no-intel-lib[=library]
macOS:
None
509
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
/Qno-intel-lib[:library]
Arguments
library Indicates which Intel® library should not be linked. Possible values are:
If you specify more than one library, they must be separated by commas.
If library is omitted, the compiler will not link to any of the Intel® libraries shown above.
Default
OFF If this option is not specified, the compiler uses default heuristics for linking to
libraries.
Description
This option disables linking to specified Intel® libraries, or to all Intel® libraries.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
nostartfiles
Prevents the compiler from using standard startup
files when linking.
Syntax
Linux OS:
-nostartfiles
510
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
-nostartfiles
Windows OS:
None
Arguments
None
Default
Description
This option prevents the compiler from using standard startup files when linking.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
nostdlib compiler option
nostdlib
Prevents the compiler from using standard libraries
and startup files when linking.
Syntax
Linux OS:
-nostdlib
macOS:
-nostdlib
Windows OS:
None
Arguments
None
Default
OFF The compiler uses standard startup files and standard libraries when linking.
511
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option prevents the compiler from using standard libraries and startup files when linking.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
nodefaultlibs compiler option
nostartfiles compiler option
pie
Determines whether the compiler generates position-
independent code that will be linked into an
executable.
Syntax
Linux OS:
-pie
-no-pie
macOS:
-pie
-no-pie
Windows OS:
None
Arguments
None
Default
varies On Linux* and on macOS versions less than 10.7, the default is -no-pie. On macOS 10.7 or
greater, the default is -pie.
Description
This option determines whether the compiler generates position-independent code that will be linked into an
executable. To enable generation of position-independent code that will be linked into an executable, specify
-pie.
To disable generation of position-independent code that will be linked into an executable, specify -no-pie.
512
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
fpic compiler option
pthread
Tells the compiler to use pthreads library for
multithreading support.
Syntax
Linux OS:
-pthread
macOS:
-pthread
Windows OS:
None
Arguments
None
Default
OFF The compiler does not use pthreads library for multithreading support.
Description
Tells the compiler to use pthreads library for multithreading support.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
Linux and macOS: -reentrancy threaded
Windows: /reentrancy:threaded
shared
Tells the compiler to produce a dynamic shared object
instead of an executable.
513
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-shared
macOS:
None
Windows OS:
None
Arguments
None
Default
Description
This option tells the compiler to produce a dynamic shared object (DSO) instead of an executable. This
includes linking in all libraries dynamically and passing -shared to the linker.
You must specify option fpic for the compilation of each object file you want to include in the shared library.
NOTE
When you specify option shared, the Intel® libraries are linked dynamically. If you want
them to be linked statically, you must also specify option static-intel.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
dynamiclib compiler option
fpic compiler option
Xlinker compiler option
shared-intel
Causes Intel-provided libraries to be linked in
dynamically.
514
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-shared-intel
macOS:
-shared-intel
Windows OS:
None
Arguments
None
Default
OFF Intel® libraries are linked in statically, with the exception of Intel's coarray runtime support library
and Intel's OpenMP* runtime support library, which are linked in dynamically. To link the
OpenMP* runtime support library statically, specify option -qopenmp-link=static.
Description
This option causes Intel-provided libraries to be linked in dynamically. It is the opposite of -static-intel.
This option is processed by the compiler driver command that initiates linking, adding library names explicitly
to the link command.
If you specify option -mcmodel=medium or -mcmodel=large, it sets option -shared-intel.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
static-intel compiler option
qopenmp-link compiler option
shared-libgcc
Links the GNU libgcc library dynamically.
Syntax
Linux OS:
-shared-libgcc
macOS:
None
515
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
None
Arguments
None
Default
Description
This option links the GNU libgcc library dynamically. It is the opposite of option static-libgcc.
This option is processed by the compiler driver command that initiates linking, adding library names explicitly
to the link command.
This option is useful when you want to override the default behavior of the static option, which causes all
libraries to be linked statically.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
static-libgcc compiler option
static
Prevents linking with shared libraries.
Syntax
Linux OS:
-static
macOS:
None
Windows OS:
/static
Arguments
None
516
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
varies The compiler links with shared GNU libraries (Linux* systems) or shared Microsoft* libraries
(Windows* systems) and it links with static Intel libraries, with the exception of the OpenMP*
libraries and coarray library libicaf, which are linked in dynamically.
On Windows* systems, option /static is equivalent to option /MT.
Description
This option prevents linking with shared libraries. It causes the executable to link all libraries statically.
NOTE
This option does not cause static linking of libraries for which no static version is available,
such as the OpenMP run-time libraries on Windows* or the coarray run-time libraries. These
libraries can only be linked dynamically.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
MT compiler option
Qvc compiler option
static-intel compiler option
static-intel
Causes Intel-provided libraries to be linked in
statically.
Syntax
Linux OS:
-static-intel
macOS:
-static-intel
Windows OS:
None
Arguments
None
517
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option causes Intel-provided libraries to be linked in statically with certain exceptions (see the Default
above). It is the opposite of -shared-intel.
This option is processed by the ifort command that initiates linking, adding library names explicitly to the link
command.
If you specify option -static-intel while option -mcmodel=medium or -mcmodel=large is set, an error
will be displayed.
If you specify option -static-intel and any of the Intel-provided libraries have no static version, a
diagnostic will be displayed.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
shared-intel compiler option
qopenmp-link compiler option
static-libgcc
Links the GNU libgcc library statically.
Syntax
Linux OS:
-static-libgcc
macOS:
None
Windows OS:
None
Arguments
None
518
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option links the GNU libgcc library statically. It is the opposite of option -shared-libgcc.
This option is processed by the compiler driver command that initiates linking, adding library names explicitly
to the link command.
This option is useful when you want to override the default behavior, which causes the library to be linked
dynamically.
NOTE
If you want to use traceback, you must also link to the static version of the libgcc library.
This library enables printing of backtrace information.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
shared-libgcc compiler option
static-libstdc++ compiler option
static-libstdc++
Links the GNU libstdc++ library statically.
Syntax
Linux OS:
-static-libstdc++
macOS:
None
Windows OS:
None
Arguments
None
519
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option links the GNU libstdc++ library statically.
This option is processed by the compiler driver command that initiates linking, adding library names explicitly
to the link command.
This option is useful when you want to override the default behavior, which causes the library to be linked
dynamically.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
static-libgcc compiler option
staticlib
Invokes the libtool command to generate static
libraries. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
-staticlib
Windows OS:
None
Arguments
None
Default
Description
This option invokes the libtool command to generate static libraries. This option is processed by the
command that initiates linking, adding library names explicitly to the link command.
520
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When passed this option, the compiler uses the libtool command to produce a static library instead of an
executable when linking.
To build dynamic libraries, you should specify option -dynamiclib or libtool -dynamic <objects>.
IDE Equivalent
None
Alternate Options
None
See Also
dynamiclib compiler option
T
Tells the linker to read link commands from a file.
Syntax
Linux OS:
-Tfilename
macOS:
None
Windows OS:
None
Arguments
Default
OFF The linker does not read link commands from a file.
Description
This option tells the linker to read link commands from a file.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
521
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
threads
Tells the linker to search for unresolved references in
a multithreaded run-time library.
Syntax
Linux OS:
-threads
-nothreads
macOS:
-threads
-nothreads
Windows OS:
/threads
/nothreads
Arguments
None
Default
threads The linker searches for unresolved references in a library that supports enabling thread-safe
operation.
Description
This option tells the linker to search for unresolved references in a multithreaded run-time library.
This option sets option reentrancy threaded.
Windows systems: The following table shows which options to specify for a multithreaded run-time library.
To ensure that a threadsafe and/or reentrant run-time library is linked and correctly initialized, option
threads should also be used for the link step and for the compilation of the main routine.
522
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
On Windows* systems, this option is processed by the compiler, which adds directives to the
compiled object file that are processed by the linker. On Linux* and macOS systems, this
option is processed by the ifort command that initiates linking, adding library names
explicitly to the link command.
IDE Equivalent
None
Alternate Options
None
See Also
reentrancy compiler option
v
Specifies that driver tool commands should be
displayed and executed.
Syntax
Linux OS:
-v [filename]
macOS:
-v [filename]
Windows OS:
None
Arguments
Default
Description
This option specifies that driver tool commands should be displayed and executed.
If you use this option without specifying a source file name, the compiler displays only the version of the
compiler.
If you want to display processing information (pass information and source file names), specify keyword all
for the watch option.
IDE Equivalent
None
Alternate Options
Linux and macOS: -watch cmd
523
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows: /watch:cmd
See Also
dryrun compiler option
watch compiler option
Wa
Passes options to the assembler for processing.
Syntax
Linux OS:
-Wa,option1[,option2,...]
macOS:
-Wa,option1[,option2,...]
Windows OS:
None
Arguments
option Is an assembler option. This option is not processed by the driver and
is directly passed to the assembler.
Default
Description
This option passes one or more options to the assembler for processing. If the assembler is not invoked,
these options are ignored.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
winapp
Tells the compiler to create a graphics or Fortran
Windows application and link against the most
commonly used libraries.
Syntax
Linux OS:
None
524
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/winapp
Arguments
None
Default
Description
This option tells the compiler to create a graphics or Fortran Windows application and link against the most
commonly used libraries.
This option is processed by the compiler, which adds directives to the compiled object file that are processed
by the linker.
IDE Equivalent
Visual Studio
Visual Studio: Libraries > Use Common Windows Libraries
Alternate Options
Linux and macOS: None
Windows: /MG
Wl
Passes options to the linker for processing.
Syntax
Linux OS:
-Wl,option1[,option2,...]
macOS:
-Wl,option1[,option2,...]
Windows OS:
None
Arguments
option Is a linker option. This option is not processed by the driver and is
directly passed to the linker.
Default
525
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This option passes one or more options to the linker for processing. If the linker is not invoked, these options
are ignored.
This option is equivalent to specifying option -Qoption,link,options.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
See Also
Qoption compiler option
Wp
Passes options to the preprocessor.
Syntax
Linux OS:
-Wp,option1[,option2,...]
macOS:
-Wp,option1[,option2,...]
Windows OS:
None
Arguments
Default
Description
This option passes one or more options to the preprocessor. If the preprocessor is not invoked, these options
are ignored.
This option is equivalent to specifying option -Qoption,fpp, options.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
526
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
Qoption compiler option
Xlinker
Passes a linker option directly to the linker.
Syntax
Linux OS:
-Xlinker option
macOS:
-Xlinker option
Windows OS:
None
Arguments
Default
Description
This option passes a linker option directly to the linker. If -Xlinker -shared is specified, only -shared is
passed to the linker and no special work is done to ensure proper linkage for generating a shared object.
-Xlinker just takes whatever arguments are supplied and passes them directly to the linker.
If you want to pass compound options to the linker, for example "-L $HOME/lib", you must use the
following method:
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
Alternate Options
None
527
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
shared compiler option
link compiler option
Miscellaneous Options
This section contains descriptions for compiler options that do not pertain to a specific category. They are
listed in alphabetical order.
bigobj
Increases the number of sections that an object file
can contain. This feature is only available for ifort.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/bigobj
Arguments
None
Default
Description
This option increases the number of sections that an object file can contain. It increases the address capacity
to 4,294,967,296(2**32).
This option may be helpful for .obj files that can hold more sections, such as machine generated code.
IDE Equivalent
None
Alternate Options
None
dryrun
Specifies that driver tool commands should be shown
but not executed.
Syntax
Linux OS:
-dryrun
macOS:
-dryrun
528
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows OS:
None
Arguments
None
Default
Description
This option specifies that driver tool commands should be shown but not executed.
IDE Equivalent
None
Alternate Options
None
See Also
v compiler option
dumpmachine
Displays the target machine and operating system
configuration.
Syntax
Linux OS:
-dumpmachine
macOS:
-dumpmachine
Windows OS:
None
Arguments
None
Default
OFF The compiler does not display target machine or operating system information.
Description
This option displays the target machine and operating system configuration. No compilation is performed.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
529
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
extfor
Specifies file extensions to be processed by the
compiler as Fortran files.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/extfor:ext
Arguments
Default
OFF Only the file extensions recognized by the compiler are processed as Fortran files.
Description
This option specifies file extensions (ext) to be processed by the compiler as Fortran files. It is useful if your
source file has a nonstandard extension.
You can specify one or more file extensions. A leading period before each extension is optional; for
example, /extfor:myf95 and /extfor:.myf95 are equivalent.
IDE Equivalent
None
Alternate Options
None
See Also
Tf compiler option
extfpp
Specifies file extensions to be recognized as a file to
be preprocessed by the Fortran preprocessor.
Syntax
Linux OS:
None
530
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
macOS:
None
Windows OS:
/extfpp:ext
Arguments
Default
OFF Only the file extensions recognized by the compiler are preprocessed by fpp.
Description
This option specifies file extensions (ext) to be recognized as a file to be preprocessed by the Fortran
preprocessor (fpp). It is useful if your source file has a nonstandard extension.
You can specify one or more file extensions. A leading period before each extension is optional; for
example, /extfpp:myfpp and /extfpp:.myfpp are equivalent.
IDE Equivalent
None
Alternate Options
None
global-hoist, Qglobal-hoist
Enables certain optimizations that can move memory
loads to a point earlier in the program execution than
where they appear in the source. This feature is only
available for ifort.
Syntax
Linux OS:
-global-hoist
-no-global-hoist
macOS:
-global-hoist
-no-global-hoist
Windows OS:
/Qglobal-hoist
/Qglobal-hoist-
Arguments
None
531
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
-global-hoist Certain optimizations are enabled that can move memory loads.
or /Qglobal-hoist
Description
This option enables certain optimizations that can move memory loads to a point earlier in the program
execution than where they appear in the source. In most cases, these optimizations are safe and can
improve performance.
The negative form of the option is useful for some applications, such as those that use shared or dynamically
mapped memory, which can fail if a load is moved too early in the execution stream (for example, before the
memory is mapped).
IDE Equivalent
None
Alternate Options
None
help
Displays all supported compiler options or supported
compiler options within a specified category of
options.
Syntax
Linux OS:
-help[category]
macOS:
-help[category]
Windows OS:
/help[category]
Arguments
532
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Default
Description
This option displays all supported compiler options or supported compiler options within a specified category
of options. If you specify category, it will display all available (supported) compiler options in the specified
category.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
IDE Equivalent
None
533
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Linux and macOS: None
Windows: /?
intel-freestanding
Lets you compile in the absence of a gcc environment.
Syntax
Linux OS:
-intel-freestanding[=ver]
macOS:
None
Windows OS:
None
Arguments
ver Is a three-digit number that is used to determine the gcc version that
the compiler should be compatible with for compilation. It also sets
the corresponding GNUC macros.
The number will be normalized to reflect the gcc compiler version
numbering scheme. For example, if you specify 493, it indicates the
compiler should be compatible with gcc version 4.9.3.
Default
OFF The compiler uses default heuristics when choosing the gcc environment.
Description
This option lets you compile in the absence of a gcc environment. It disables any external compiler calls
(such as calls to gcc) that the compiler driver normally performs by default.
This option also removes any default search locations for header and library files. So, for successful
compilation and linking, you must provide these search locations.
This option does not affect ld, as, or fpp. They will be used for compilation as needed.
NOTE
This option does not imply option -nostdinc -nostdlib. If you want to assure a clean
environment for compilation (including removal of Intel-specific header locations and libs),
you should specify -nostdinc and/or -nostdlib.
NOTE
This option is supported for any Linux-target compiler, including a Windows-host to Linux-
target compiler.
534
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
See Also
intel-freestanding-target-os compiler option
nostdlib compiler option
nostdinc compiler option, which is an alternate option for option X
intel-freestanding-target-os
Lets you specify the target operating system for
compilation.
Syntax
Linux OS:
-intel-freestanding-target-os=os
macOS:
None
Windows OS:
None
Arguments
Default
Description
This option lets you specify the target operating system for compilation. It sets option
-intel-freestanding.
NOTE
This option is supported for any Linux-target compiler, including a Windows-host to Linux-
target compiler.
IDE Equivalent
None
Alternate Options
None
See Also
intel-freestanding compiler option
535
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
libdir
Controls whether linker options for search libraries are
included in object files generated by the compiler.
Syntax
Linux OS:
None
macOS:
None
Windows OS:
/libdir[:keyword ]
/nolibdir
Arguments
none Prevents any linker search options from being included into the
object file. This is the same as specifying /nolibdir.
Default
/libdir:all Linker search options for libraries automatically determined by the ifort
command driver (default libraries) and libraries specified by the
OBJCOMMENT directive are included in the object file.
Description
This option controls whether linker options for search libraries (/DEFAULTLIB:library) are included in
object files generated by the compiler.
The linker option /DEFAULTLIB:library adds one library to the list of libraries that the linker searches
when resolving references. A library specified with /DEFAULTLIB:library is searched after libraries
specified on the command line and before default libraries named in .obj files.
536
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
Windows
Visual Studio: Libraries > Disable Default Library Search Rules ( /libdir:[no]automatic)
Alternate Options
logo
Displays the compiler version information.
Syntax
Linux OS:
-logo
-nologo
macOS:
-logo
-nologo
Windows OS:
/logo
/nologo
Arguments
None
Default
Linux* and macOS: nologo The compiler version information is not displayed.
Description
This option displays the startup banner, which contains the following compiler information:
IDE Equivalent
Windows
Visual Studio: General > Suppress Startup Banner (/nologo)
537
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Alternate Options
Linux and macOS: -V
Windows: None
multiple-processes, MP
Creates multiple processes that can be used to
compile large numbers of source files at the same
time.
Syntax
Linux OS:
-multiple-processes[=n]
macOS:
-multiple-processes[=n]
Windows OS:
/MP[:n]
Arguments
Default
Description
This option creates multiple processes that can be used to compile large numbers of source files at the same
time. It can improve performance by reducing the time it takes to compile source files on the command line.
This option causes the compiler to create one or more copies of itself, each in a separate process. These
copies simultaneously compile the source files.
If n is not specified for this option, the default value is as follows:
• On Windows* systems, the value is based on the setting of the NUMBER_OF_PROCESSORS environment
variable.
• On Linux* and macOS systems, the value is 2.
This option applies to compilations, but not to linking or link-time code generation.
To override default heuristics, specify option /MP-force. It ensures that n will be the maximum number of
processes created regardless of other heuristics that may limit the number of processes.
IDE Equivalent
Windows
Visual Studio: General > Multi-processor Compilation
Alternate Options
None
538
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
save-temps, Qsave-temps
Tells the compiler to save intermediate files created
during compilation.
Syntax
Linux OS:
-save-temps
-no-save-temps
macOS:
-save-temps
-no-save-temps
Windows OS:
/Qsave-temps
/Qsave-temps-
Arguments
None
Default
Linux and macOS systems: -no-save-temps On Linux and macOS systems, the compiler deletes
Windows systems: .obj files are saved intermediate files after compilation is completed.
On Windows systems, the compiler saves only
intermediate object files after compilation is
completed.
Description
This option tells the compiler to save intermediate files created during compilation. The names of the files
saved are based on the name of the source file; the files are saved in the current working directory.
If option [Q]save-temps (C++) or is specified, the following occurs:
• The .o file is put into /tmp and deleted after calling ld.
• The preprocessed file is not saved after it has been used by the compiler.
If /Qsave-temps- is specified on Windows systems, the following occurs:
NOTE
This option only saves intermediate files that are normally created during compilation.
539
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
Example
If you compile program my_foo.F on a Linux or macOS system and you specify option -save-temps and
option -use-asm, the compilation will produce files my_foo.o, my_foo.s, and my_foo.i.
If you compile program my_foo.fpp on a Windows system and you specify option /Qsave-temps and
option /Quse-asm, the compilation will produce files my_foo.obj, my_foo.asm, and my_foo.i.
sox
Tells the compiler to save the compilation options and
version number in the executable file. It also lets you
choose whether to include lists of certain routines.
This feature is only available for ifort.
Syntax
Linux OS:
-sox[=keyword[,keyword]]
-no-sox
macOS:
None
Windows OS:
None
Arguments
Default
-no-sox The compiler does not save these informational strings in the object file.
Description
This option tells the compiler to save the compilation options and version number in the executable file. It
also lets you choose whether to include lists of certain routines. The information is embedded as a string in
each object file or assembly output.
540
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify option sox with no keyword, the compiler saves the compiler options and version number used
in the compilation of the objects that make up the executable.
When you specify this option, the size of the executable on disk is increased slightly. Each keyword you
specify increases the size of the executable. When you link the object files into an executable file, the linker
places each of the information strings into the header of the executable. It is then possible to use a tool,
such as a strings utility, to determine what options were used to build the executable file.
IDE Equivalent
None
Alternate Options
None
Example
The following commands are equivalent:
-sox=profile -sox=inline
-sox=profile,inline
You can use the negative form of the option to disable and reset the option. For example:
sysroot
Specifies the root directory where headers and
libraries are located.
Syntax
Linux OS:
--sysroot=dir
macOS:
None
Windows OS:
None
Arguments
dir Specifies the local directory that contains copies of target libraries in
the corresponding subdirectories.
Default
Off The compiler uses default settings to search for headers and libraries.
Description
This option specifies the root directory where headers and libraries are located.
For example, if the headers and libraries are normally located in /usr/include and /usr/lib respectively,
--sysroot=/mydir will cause the compiler to search in /mydir/usr/include and /mydir/usr/lib for the
headers and libraries.
541
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
None
Tf
Tells the compiler to compile the file as a Fortran
source file.
Syntax
Linux OS:
-Tf filename
macOS:
-Tf filename
Windows OS:
/Tf filename
Arguments
Default
OFF Files that do not end in standard Fortran file extensions are not compiled as Fortran files.
Description
This option tells the compiler to compile the file as a Fortran source file.
This option is useful when you have a Fortran file with a nonstandard file extension (that is, not one
of .F, .FOR, or .F90).
This option assumes the file specified uses fixed source form. If the file uses free source form, you must also
specify option free.
IDE Equivalent
None
Alternate Options
None
See Also
extfor compiler option
free compiler option
watch
Tells the compiler to display certain information to the
console output window.
542
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Linux OS:
-watch[=keyword[, keyword...]]
-nowatch
macOS:
-watch[=keyword[, keyword...]]
-nowatch
Windows OS:
/watch[:keyword[, keyword...]]
/nowatch
Arguments
[no]source Determines whether the name of the file being compiled is displayed.
Default
nowatch Pass information and source file names are not displayed to the console output window.
Description
Tells the compiler to display processing information (pass information and source file names) to the console
output window.
none Tells the compiler to not display pass information and source file names
to the console output window. This is the same as specifying nowatch.
cmd Tells the compiler to display and execute driver tool commands.
source Tells the compiler to display the name of the file being compiled.
all Tells the compiler to display pass information and source file names to
the console output window. This is the same as specifying watch with no
keyword. For heterogeneous compilation, the tool commands for the host
and the offload compilations will be displayed.
NOTE
This option only applies to host compilation. When offloading is enabled, it does not impact
device-specific compilation. Offloading can only be enabled when using ifx.
543
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDE Equivalent
None
Alternate Options
Windows: None
See Also
v compiler option
what
Tells the compiler to display its detailed version string.
Syntax
Linux OS:
-what
macOS:
-what
Windows OS:
/what
Arguments
None
Default
Description
This option tells the compiler to display its detailed version string.
IDE Equivalent
None
Alternate Options
None
Deprecated Options
Occasionally, compiler options are marked as "deprecated." Deprecated options are still supported in the
current release, but they may be unsupported in future releases.
The following two tables list options that are currently deprecated.
544
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
arch=IA32 None
axS axSSE4.1
cpp fpp
device-math-lib None
falign-stack None
fopenmp None
m32 None
march=pentiumii None
march=pentiumiii march=pentium3
mcpu mtune
mia32 None
mkl qmkl
msse None
no-bss-init None
prof-gen-sampling None
prof-use-sampling None
qopt-args-in-regs None
rcd None
use-asm None
xS xSSE4.1
xT Linux: xSSSE3
macOS: xSSSE3
[no]zero init=[no]zero
arch:IA32 None
arch:SSE None
545
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
device-math-lib None
Ge Gs0
MDs[d] None
Oy None
QaxS QaxSSE4.1
QaxT QaxSSSE3
QIfist Qrcd
Qm32 None
Qnobss-init None
Qopt-args-in-regs None
Qrcd None
Qsfalign None
Qsox None
Quse-asm None
QxS QxSSE4.1
QxT QxSSSE3
Qzero[-] Qinit:[no]zero
unroll Qunroll
Removed Options
Some compiler options are no longer supported and have been removed. If you use one of these options, the
compiler issues a warning, ignores the option, and then proceeds with compilation.
The following two tables list options that are no longer supported.
Note that removed options are not limited to these lists.
1 f66
66 f66
automatic auto
axB axSSE2
axH axSSE4.2
546
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
axi None
axM None
axW msse2
cm warn nousage
cxxlib-gcc[=dir] cxxlib[=dir]
cxxlib-icc None
dps altparam
F preprocess-only or P
fp fno-omit-frame-pointer
fpstkchk fp-stack-check
func-groups prof-func-groups
fvisibility=internal fvisibility=hidden
guide-profile None
i-dynamic shared-intel
i-static static-intel
mp fp-model
no-cpprt no-cxxlib
nobss-init no-bss-init
547
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Ob inline-level
onetrip f66
openmp qopenmp
openmp-lib qopenmp-lib
openmpP qopenmp
openmp-profile None
openmp-report qopt-report-phase=openmp
openmpS qopenmp-stubs
openmp-simd qopenmp-simd
openmp-stubs qopenmp-stubs
openmp-threadprivate qopenmp-threadprivate
opt-args-in-regs qopt-args-in-regs
opt-assume-safe-padding qopt-assume-safe-padding
opt-block-factor qopt-block-factor
opt-dynamic-align qopt-dynamic-align
opt-gather-scatter-unroll None
opt-jump-tables qopt-jump-tables
opt-malloc-options qopt-malloc-options
opt-matmul qopt-matmul
opt-mem-layout-trans qopt-mem-layout-trans
opt-multi-version-aggressive qopt-multi-version-aggressive
opt-prefetch qopt-prefetch
opt-prefetch-distance qopt-prefetch-distance
opt-ra-region-strategy qopt-ra-region-strategy
opt-report qopt-report
opt-report-embed qopt-report-embed
opt-report-file qopt-report-file
548
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
opt-report-filter qopt-report-filter
opt-report-format qopt-report-format
opt-report-help qopt-report-help
opt-report-level qopt-report
opt-report-per-object qopt-report-per-object
opt-report-phase qopt-report-phase
opt-report-routine qopt-report-routine
opt-streaming-cache-evict None
opt-streaming-stores qopt-streaming-stores
opt-subscript-in-range qopt-subscript-in-range
par-report qopt-report-phase=par
prefetch qopt-prefetch
print-sysroot None
prof-format-32 None
prof-genx prof-gen=srcpos
profile-functions None
profile-loops None
profile-loops-report None
qcf-protection fcf-protection
qoffload None
qoffload-arch None
qoffload-attribute-target None
qoffload-option None
qopenmp-offload None
qopenmp-report qopt-report-phase=openmp
qopenmp-task None
qp p
rct None
shared-libcxa shared-libgcc
ssp None
549
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
static-libcxa static-libgcc
tcheck None
tpp1 None
tpp2 mtune=itanium2
tpp5 None
tpp6 None
tpp7 mtune=pentium4
tprofile None
tune x<code>
us assume underscore
vec-report qopt-report-phase=vec
xB xSSE2
xi None
xM None
xN Linux: xSSE2
macOS: None
xO msse3
xP Linux: xSSE3
macOS: None
xSSE3_ATOM xATOM_SSSE3
xSSSE3_ATOM xATOM_SSSE3
xW msse2
1 f66
4Nb check:none
4Yb check:all
550
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
architecture arch
asmattr:none, noasmattr FA
asmattr:machine FAc
asmattr:source FAs
asmattr:all FAcs
asmfile Fa
automatic auto
cm warn:nousage
debug:parallel None
debug:partial None
Fm map
G1 None
G5 None
G7 None
Gf GF
Og O1, O2, or O3
Op fltconsistency
optimize:0, nooptimize Od
optimize:1, optimize:2 O1
optimize:3, optimize:4 O2
optimize:5 O3
QaxB QaxSSE2
QaxH QaxSSE4.2
Qaxi None
QaxM None
QaxN QaxSSE2
QaxP QaxSSE3
551
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
QaxW arch:SSE2
Qcpp fpp
Qdps altparam
Qextend-source extend-source
Qfpp[0 | 1 | 2 | 3] fpp
Qfpstkchk Qfp-stack-check
Qguide-profile None
Qinline-debug-info debug:inline-debug-info
Qlowercase names:lowercase
Qonetrip f66
Qopenmp-lib:legacy None
Qopenmp-link None
Qopenmp-offload None
Qopenmp-profile None
Qopenmp-report Qopt-report-phase:openmp
Qopt-report-level Qopt-report
Qpar-report Qopt-report-phase:par
Qprefetch Qopt-prefetch
Qprof-format-32 None
Qprof-genx Qprof-gen=srcpos
Qprofile-functions None
Qprofile-loops None
Qprofile-loops-report None
Qrct None
Qssp None
Qtprofile None
Qtcheck None
Quppercase names:uppercase
Quse-vcdebug None
552
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Qvc11 None
Qvc10
Qvc9 and earlier
Qvec-report Qopt-report-phase:vec
Qvms vms
QxB QxSSE2
Qxi None
QxM None
QxN QxSSE2
QxO arch:SSE3
QxP QxSSE3
QxSSE3_ATOM QxATOM_SSSE3
QxSSSE3_ATOM QxATOM_SSSE3
QxW arch:SSE2
source Tf
tune Qx<code>
unix None
us assume:underscore
Zd debug:minimal
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
553
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Linux
Alternate Linux* and macOS Options Primary Option Name
Code Generation:
-fp -fomit-frame-pointer
-mcpu -mtune
Advanced Optimizations:
-funroll-loops -unroll
-fopenmp -qopenmp
Floating-Point:
-mieee-fp -fltconsistency
-V -logo
Preprocessor:
-cpp -fpp
-DD -d-lines
-nodefine -noD
554
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-nostdinc -X
-P -preprocess-only
Language:
-72 -extend-source 72
-80 -extend-source 80
-C -check all
-FI -fixed
-FR -free
-fsyntax-only -syntax-only
-y -syntax-only
Data:
-autodouble -real-size 64
-automatic -auto
-i2 -integer-size 16
-i4 -integer-size 32
-i8 -integer-size 64
-r4 -real-size 32
-r8 -real-size 64
555
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Compiler Diagnostics:
-e95
-e03
-error-limit -diag-error-limit
-u -warn declarations
Compatibility:
-66 -f66
-onetrip -f66
Linking or Linker:
-i-dynamic -shared-intel
-i-static -static-intel
Windows
Alternate Windows* Options Primary Option Name
Optimization:
/Ox /O
/openmp /Qopenmp
Floating Point:
/QIfist /Qrcd
/compile-only /c
/Fe /exe
/Fo /object
/nolink /c
/pdbfile /Fd
556
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/V /bintext
Preprocessor:
/define /D
/include /I
/nodefine /noD
/noinclude /X
/undefine /U
Language:
/4L72 -extend-source:72
/4L80 -extend-source:80
/4L132 -extend-source:132
/4Naltparam /noaltparam
/4Yaltparam /altparam
/4Nf /fixed
/4Yf /free
/4Ns /stand:none
/4Ys /stand:f90
/C /check:all
/CB /check:bounds
/CU /check:uninit
/FI /fixed
/FR /free
/Gm /iface:cvf
/Gz /iface:stdcall
/nbs /assume:nobcss
/Qcommon-args /assume:dummy_aliases
/RTCu /check:uninit
/Zp /align:recnbyte
/Zs /syntax-only
Data:
/4I2 /integer-size:16
557
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/4I4 /integer-size:32
/4I8 /integer-size:64
/4Na /noauto
/4Ya /auto
/4R4 /real-size:32
/4R8 /real-size:64
/4R16 /real-size:128
/automatic /auto
/Qauto /auto
/Qautodouble /real-size:64
/Zp /align:recnbyte
Compiler Diagnostics:
/4Nd /warn:nodeclarations
/4Yd /warn:declarations
/error-limit /Qdiag-error-limit
/w /warn:none or /warn:nogeneral
/W1 /warn:general
Compatibility:
/Qonetrip /f66
Linking or Linker:
/LD /dll
/MG /winapp
/MW /libs
/MWs /libs:qwins
Miscellaneous:
/V /logo
/Zl /libdir:none
Floating-Point Operations
This section contains information about floating-point operations, including IEEE floating-point operations,
and it provides guidelines that can help you improve the performance of floating-point applications.
558
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify the -fp-model fast (Linux and macOS) or /fp:fast (Windows) option in favor of
performance, the compiler generates the following assembly code:
559
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-fimf-max-error=2
To specify twelve bits of accuracy for a sin function, use:
-fimf-accuracy-bits=12:sin
To specify relative error of ten ULPs for a sin function, and four ULPs for other math functions called in the
source file you are compiling, use:
-fimf-max-error=10:sin-fimf-max-error=4
On Windows systems, the compiler defines the default value for the max-error attribute depending on
the /fp option and /Qfast-transcendentals settings. In /fp:fast mode, or if fast but less accurate math
functions are explicitly enabled by /Qfast-transcendentals-, then the compiler sets a max-error=4.0 for
the call. Otherwise, it sets a max-error=0.6.
See Also
Using -fp-model(/fp) Options
fimf-max-error, Qimf-max-error compiler option
Floating-Point Optimizations
Application performance is an important goal of the Intel® Fortran Compiler, even at default optimization
levels. A number of optimizations involve transformations that might affect the floating-point behavior of the
application, such as evaluation of constant expressions at compile time, hoisting invariant expressions out of
560
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
loops, or changes in the order of evaluation of expressions. These optimizations usually help the compiler to
produce the most efficient code possible. However, the optimizations might be contrary to the floating-point
requirements of the application.
Some optimizations are not consistent with strict interpretation of the ANSI or ISO standards for Fortran.
Such optimizations can cause differences in rounding and small variations in floating-point results that may
be more or less accurate than the ANSI-conformant result.
The Intel® Fortran Compiler provides the -fp-model (Linux* and macOS) or /fp (Windows*) option, which
allows you to control the optimizations performed when you build an application. The option allows you to
specify the compiler rules for:
• Value safety: Whether the compiler may perform transformations that could affect the result. For
example, in the SAFE mode, the compiler won't transform x/x to 1.0 because the value of x at runtime
might be a zero or a NaN . The UNSAFE mode is the default.
• Floating-point expression evaluation: How the compiler should handle the rounding of intermediate
expressions.
• Floating-point contractions: Whether the compiler should generate fused multiply-add (FMA)
instructions on processors that support them. When enabled, the compiler may generate FMA instructions
for combining multiply and add operations; when disabled, the compiler must generate separate multiply
and add instructions with intermediate rounding.
• Floating-point environment access: Whether the compiler must account for the possibility that the
program might access the floating-point environment, either by changing the default floating-point control
settings or by reading the floating-point status flags. This is disabled by default. You can use the
-fp-model:strict (Linux* and macOS) /fp:strict (Windows*) option to enable it.
• Precise floating-point exceptions: Whether the compiler should account for the possibility that
floating-point operations might produce an exception. This is disabled by default. You can use
-fp-model:strict (Linux* and macOS) or /fp:strict (Windows*); or -fp-model:except (Linux*
and macOS) or /fp:except (Windows*) to enable it.
The following table describes the impact of different keywords of the option on compiler rules and
optimizations:
NOTE
It is illegal to specify the except keyword in an unsafe safety mode.
Based on the objectives of an application, you can choose to use different sets of compiler options and
keywords to enable or disable certain optimizations, so that you can get the desired result.
See Also
Using -fp-model (/fp) Option
561
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Keyword Description
strict Enables precise and except , disables contractions, and enables the
property that allows modification of the floating-point environment.
[no-]except (Linux and Determines whether strict floating-point exception semantics are used.
macOS) or
except[-] (Windows)
The default value of the option is -fp-model fast=1 or /fp:fast=1, which means that the compiler uses
more aggressive optimizations on floating-point calculations.
NOTE
Using the default option keyword -fp-model fast or /fp:fast, you may get significant differences
in your result depending on whether the compiler uses x87 or Intel® Streaming SIMD Extensions
(Intel® SSE)/Intel® Advanced Vector Extensions (Intel® AVX) instructions to implement floating-point
operations. Results are more consistent when the other option keywords are used.
Several examples are provided to illustrate the usage of the keywords. These examples show:
• A small example of source code.
NOTE
The same source code is considered in all the included examples.
• The semantics that are used to interpret floating-point calculations in the source code.
• One or more possible ways the compiler may interpret the source code.
562
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
There are several ways that the compiler may interpret the code; we show just some of these
possibilities.
See Also
fp-model, fp compiler option
Subnormal Numbers
A normalized number is a number for which both the exponent (including bias) and the most significant bit of
the mantissa are non-zero. For such numbers, all the bits of the mantissa contribute to the precision of the
representation.
The smallest normalized single-precision floating-point number greater than zero is about 1.1754943-38.
Smaller numbers are possible, but those numbers must be represented with a zero exponent and a mantissa
whose leading bit(s) are zero, which leads to a loss of precision. These numbers are called subnormal
numbers or subnormals(older specifications refer to these as denormal numbers).
Subnormal computations use hardware and/or operating system resources to handle denormals; these can
cost hundreds of clock cycles. Subnormal computations take much longer to calculate than normal
computations.
There are several ways to avoid subnormals and increase the performance of your application:
• Scale the values into the normalized range.
• Use a higher precision data type with a larger range.
• Flush subnormals to zero.
See Also
Reducing Impact of Subnormal Exceptions
Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture
563
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Floating-Point Environment
The floating-point environment is a collection of registers that control the behavior of the floating-point
machine instructions and indicate the current floating-point status. The floating-point environment can
include rounding mode controls, exception masks, flush-to-zero (FTZ) controls, exception status flags, and
other floating-point related features.
For example, bit 15 of the MXCSR register enables the flush-to-zero mode, which controls the masked
response to an single-instruction multiple-data (SIMD) floating-point underflow condition.
The floating-point environment affects most floating-point operations; therefore, correct configuration to
meet your specific needs is important. For example, the exception mask bits define which exceptional
conditions will be raised as exceptions by the processor. In general, the default floating-point environment is
set by the operating system. You don't need to configure the floating-point environment unless the default
floating-point environment does not suit your needs.
There are several methods available if you want to modify the default floating-point environment. For
example, you can use inline assembly, compiler built-in functions, library functions, or command line options.
Changing the default floating-point environment affects runtime results only. This does not affect any
calculations that are pre-computed at compile time.
See Also
Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture
Flag When set to ON, the When set to OFF, the Supported on
compiler... compiler...
FTZ ...sets subnormal results from ...does not change the Intel® 64 and
floating-point calculations to subnormal results. some IA-32
zero. architectures
DAZ ...treats subnormal values ...does not change the Intel® 64 and
used as input to floating-point subnormal instruction inputs. some IA-32
instructions as zero. architectures
• FTZ and DAZ are not supported on all IA-32 architectures. The FTZ flag is supported only on IA-32
architectures that support Intel® SSE instructions.
• On systems based on the IA-32 and Intel® 64 architectures, FTZ only applies to Intel® SSE and Intel® AVX
instructions. If the application generates subnormals using x87 instructions, FTZ does not apply.
• DAZ and FTZ flags are not compatible with the IEEE 754 standard, and should only be enabled when
compliance to the IEEE standard is not required.
Options for [Q]ftz are performance options. Setting these options does not guarantee that all subnormals in
a program are flushed to zero. They only cause subnormals generated at runtime to be flushed to zero.
564
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On Intel® 64 and IA-32 systems, the compiler, by default, inserts code into the main routine to set the FTZ
and DAZ flags. When the [Q]ftz option is used on IA-32 systems with the option –msse2 or /arch:sse2,
the compiler inserts code to that conditionally sets the FTZ/DAZ flags based on a runtime processor check.
Using the negative form of [Q]ftz prevents the compiler from inserting any code that sets FTZ or DAZ flags.
When the [Q]ftz option is used in combination with an Intel® SSE-enabling option on systems based on the
IA-32 architecture (for example, -msse2 or /arch:sse2), the compiler inserts code in the main routine to
set FTZ and DAZ. When the option [Q]ftz is used without an Intel® SSE-enabling option, the compiler inserts
code that conditionally sets FTZ or DAZ based on a runtime processor check. The negative form of [Q]ftz
prevents the compiler from inserting any code that might set FTZ or DAZ.
The [Q]ftz option only has an effect when the main program is being compiled. It sets the FTZ/DAZ mode
for the process. The initial thread, and any subsequently created threads, operate in the FTZ/DAZ mode.
On systems based on Intel® 64 and IA-32 architectures, every optimization option O level, except O0, sets
[Q]ftz.
If this option produces undesirable results of the numerical behavior of the program, turn the FTZ/DAZ mode
off by using the negative form of [Q]ftz in the command line while still benefitting from the O3
optimizations.
Manually set the flags by calling the following Intel® Fortran intrinsic:
RESULT = FOR_SET_FPE (FOR_M_ABRUPT_UND)
See Also
ftz, Qftz compiler option
NOTE
The [Q]fp-stack-check option causes significant code generation after every function/subroutine call to
ensure that the floating-point stack is maintained in the correct state. Therefore, using this option
slows down the program being compiled. Use the option only as a debugging aid to find floating point
stack underflow/overflow problems, which can be otherwise hard to find.
See Also
fp-stack-check, Qfp-stack-check compiler option
565
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Tuning Performance
This section describes several programming guidelines that can help you improve the performance of
floating-point applications, including:
• Handling Floating-point Array Operations in a Loop Body
• Reducing the Impact of Subnormal Exceptions
• Avoiding Mixed Data Type Arithmetic Expressions
• Using Efficient Data Types
566
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
After using flush-to-zero, ensure that your program still gives correct results when treating subnormal
values as zero.
INTEGER I, J
I = J / 2.0
Efficient code:
INTEGER I, J
I = J / 2
567
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
In an arithmetic expression, you should avoid mixing integer and floating-point data.
See Also
Programming Guidelines for Vectorization
Setting the FTZ and DAZ Flags
Intel® 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture
Libraries
This section contains information about creating, calling, comparing, and other considerations when using
libraries.
568
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
569
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The -shared or -dynamiclib option is required to create a shared library. The name of the source file is
octagon.f90. You can specify multiple source files and object files.
Because the -o option was omitted, the name of the shared library file is octagon.so (Linux*) or
octagon.dylib (macOS).
You can use the -static-intel option to force the linker to use the static versions of the Intel-supplied
libraries.
You can also create a shared library file with a combination of ifort and ld (Linux*) or libtool (macOS)
commands:
First, create the .o file, such as octagon.o in the following example:
ld -shared octagon.o \
-lifport -lifcoremt -limf -lm -lcxa \
-lpthread -lirc -lunwind -lc -lirc_s
Note the following:
• When you use ld, you need to list all Intel® Fortran libraries. It is easier and safer to use the ifort
command. On macOS, you would use libtool.
• The -shared option is required to create a shared library. On macOS, use the -dynamiclib option, and
also specify the following: -arch_only i386, -noall_load,
-weak_references_mismatches non-weak.
• The name of the object file is octagon.o. You can specify multiple object (.o) files.
• The -lifport option and subsequent options are the standard list of libraries that the ifort command
would have otherwise passed to ld or libtool. When you create a shared library, all symbols must be
resolved.
It is recommended that you review the output of the -dryrun command to find the names of all the libraries
used, to be able to specify them correctly.
If you are using the ifort command to link, you can use the -Qoption command to pass options to the ld
linker. (You cannot use -Qoption on the ld command line.)
For more information on relevant compiler options, see the Compiler Options reference.
See also the ld(1) reference page.
To put a routine in a separate shared library, obtain the source or object file for that routine, recompile if
necessary, and create a separate shared library. You can specify an object file when recompiling with the
ifort command or when creating the shared library with the ld command.
570
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To include a routine in the shared library being created, put the routine (source or object file) with other
source files that make up the shared library and recompile if necessary.
Now create the shared library, and specify the file containing that routine either during recompilation or
when creating the shared library. You can specify an object file when recompiling with the ifort
command or when creating the shared library with the ld or libtool command.
• When creating shared libraries, all symbols must be defined (resolved).
Because all symbols must be defined to ld when you create a shared library, you must specify the shared
libraries on the ld command line, including all standard Intel® Fortran libraries. The list of standard Intel®
Fortran libraries can be specified by using the -lstring option.
571
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Language Reference section Runtime Library Routines lists topics that provide an overview of the different
groups of library routines as well as calling syntax for the routines. For example, add the following USE
statement before any data declaration statements, such as IMPLICIT, NONE, or INTEGER:
USE IFPORT
If you want to minimize compile time for source files that use the Intel® Fortran library routines, add the
ONLY keyword to the USE statement. For example:
USE IFPORT, only: getenv
Using the ONLY keyword limits the number of interfaces for that group of library routines.
To view the actual interface definitions, view the .f90 file that corresponds to the .mod file. For example, if a
routine requires a USE IFCORE, locate and use a text editor to view the file ifcore.f90 in the standard
INCLUDE directory.
You should avoid copying the actual interface definitions contained in the ifport.f90 (or ifcore.f90, ...)
into your program because future versions of Intel® Fortran might change these interface definitions.
Similarly, some of the library interface .f90 files contain USE statements for a subgrouping of routines.
However, if you specify a USE statement for such a subgroup, this module name may change in future
version of the Intel® Fortran Compiler. Although this will make compilation times faster, it might not be
compatible with future versions of the compiler.
See Also
Runtime Library Routines
572
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• May have QQ appended at the end of their names to differentiate them from equivalent Windows*
routines.
• Are described in the Intel® Visual Fortran Compiler Language Reference online documentation, in the A to
Z Reference. The routine description lists the appropriate USE statement needed to include the interface
definitions, such as USE IFPORT.
• Call appropriate Windows* system API routines provided with the operating system.
• Are specific to Windows* systems, with one exception: most of the Intel® Fortran IFPORT Portability
Library routines exist on most Linux* systems.
In contrast, the Windows* API routines provided by the Windows* operating system:
• Are intended to be called from the C language. For example, character arguments are assumed to be null-
terminated C strings.
• Often have multiple words appended together in their names, such as GetSystemTime.
• Are described in the Windows* SDK online documentation. To look up a specific routine, visit the MSDN
Library website. The calling format is listed near the top of the page, followed by a description of the
routine's arguments. The QuickInfo at the bottom of the Windows* API routine documentation page lists
the import library needed.
• Are also specific to Windows*.
Note that the Intel® Visual Fortran Compiler provides interface block definitions that simplify calling
Windows* API routines from the Intel® Visual Fortran Compiler (such as allowing you to specify Fortran data
arguments as being passed by reference). To obtain these interface definitions, add the USE IFWIN
statement to your program.
There are many groups of Windows* routines (see the Platform SDK and other resources). These routines
provide sophisticated window management, memory management, graphics support, threading, security, and
networking.
You can access many Windows* API routines from any Fortran application, including Fortran Console and
Fortran QuickWin applications. Only the Fortran Windows* application Understanding Project Types provides
access to the full set of Win32 routines needed to create GUI applications.
Fortran Console applications are text-only applications. Fortran QuickWin applications allow you to build
Windows*-style applications easily, but access only a small subset of the available Windows* API features.
Fortran QuickWin applications also allow you to use graphics.
See Also
A to Z Reference
IFPORT Portability Library
Understanding Project Types
573
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Fortran DLL Dynamic-link libraries libfcoremd and msvcrt (and their import libraries)
Pure Fortran applications can have mismatched types of libraries. One common scenario is a Fortran
Windows* application that is linking with a Fortran static library. This can cause link-time conflicts as well as
undesired runtime failures. The Fortran library should be rebuilt as a dynamic library to avoid these issues.
Similarly, different C/C++ applications link against different C libraries. If you mix the different types of
applications without modifying the defaults, you can get conflicts. The debug version of a library has a letter
d appended to its base file name:
• Static, multithreaded: libcmt.lib and libcmtd.lib
• Dynamic-link libraries: msvcrt and msvcrtd (.lib import library and .dll)
When using a Debug configuration, Visual C++* selects the debug libraries.
The Intel® Visual Fortran Compiler does not select debug libraries for any configuration, but provides settings
that allow you to request their use. To specify different types of Fortran libraries in the IDE, select Project >
Properties, then select the Libraries category on the Fortran tab:
• To specify static libraries, select the appropriate type of static (non-DLL) library under Runtime Library
(see /libs:static).
• To specify dynamic-link libraries, select the appropriate type of DLL library under Runtime Library
(see /libs:dll).
• To specify the debug libraries, select the appropriate type of Debug library under Runtime Library
(see /[no]dbglibs). If you specify debug libraries (/dbglibs) and also request DLL libraries
(/libs:dll), be aware that this combination selects the debug versions of the Fortran DLLs. These
Fortran DLL files have been linked against the C debug DLLs.
• When you specify QuickWin or Standard Graphics libraries under Runtime Library, this selection implicitly
requests multithreaded libraries.
NOTE This option does not cause static linking of libraries for which no static version is available, such
as the OpenMP runtime libraries on Windows* or the coarray runtime libraries. These libraries can only
be linked dynamically.
574
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Deployment Models
You have two options for deploying the shared libraries from the Intel oneAPI toolkit that your application
depends on:
Private Model Copy the shared libraries from the Intel oneAPI toolkit into your application
environment, and then package and deploy them with your application. Review
the license and third-party files associated with the Intel oneAPI toolkits and/or
components you have installed to determine the files that you can redistribute.
The advantage to this model is that you have control over your library and
version choice, so you only package and deploy the libraries that you have
tested. The disadvantage is that the end users may see multiple libraries
installed on their system, if multiple installed applications all use the private
model. You are also responsible for updating these libraries whenever updates
are required.
Public Model You direct your users to runtime packages provided by Intel. Your users install
these packages on their system when they install your application. The runtime
packages install onto a fixed location, so all applications built with Intel oneAPI
tools can be used.
The advantage is that one copy of each library is shared by all applications, which
results in improved performance. You can rely on updates to the runtime
packages to resolve issues with libraries independently from when you update
your application. The disadvantage is that the footprint of the runtime package is
575
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
larger than a package from the private model. Another disadvantage is that your
tested versions of the runtime libraries may not be the same as your end user's
versions.
Select the model that best fits your environment, your needs, and the needs of your users.
NOTE Intel ensures that newer compiler-support libraries work with older versions of generated
compiler objects, but newer versioned objects require newer versioned compiler-support libraries. If
an incompatibility is introduced that causes newer compiler-support libraries not to work with older
compilers, you will have sufficient warning and the library will be versioned so that deployed
applications continue to work.
Additional Steps
Under either model, you must manually configure certain environment variables that are normally handled by
the setvars/vars scripts or module files.
For example, with the Intel® MPI Library, you must set the following environment variables during
installation:
Linux
I_MPI_ROOT=installPath FI_PROVIDER_PATH=installPath/intel64/libfabric:/usr/lib64/libfabric
Windows
I_MPI_ROOT=installPath
See Also
Using Fortran Static Library Projects
576
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When routines in a shareable library are called, the routines are loaded into memory at runtime as they are
needed. This is most useful when several applications use a common group of routines. By storing these
common routines in a shareable library, you reduce the size of each application that calls the library. In
addition, you can update the routines in the library without having to rebuild any of the applications that call
the library.
Include the Intel® Visual Fortran Interface Definitions for Windows API Routines
Intel® Fortran provides interface definitions for both the Intel Fortran library routines and most of the
Windows* API routines in the standard include directory. Documentation on the Windows API can be found at
msdn.microsoft.com.
To include the Windows API interface definitions, do one of the following:
1. Add the statement USE IFWIN to include all Windows API routine definitions.
The USE IFWIN statement makes all parameters and interfaces for most Windows routines available to
your Intel Fortran program. Any program or subprogram that uses the Windows features can include
the statement USE IFWIN, which is needed in each subprogram that makes Windows API calls.
Add the USE statement before any declaration statements (such as IMPLICIT NONE or INTEGER).
2. You can limit the type of parameters and interfaces for Windows applications to make compilation times
faster. To do this, include only the subsets of the Windows API needed in multiple USE statements (see
the file ...\INCLUDE\IFWIN.F90).
To locate the specific libraries for the routines being called, view the QuickInfo at the bottom of the
routine page in the Windows API documentation at msdn.microsoft.com, which lists the import library
name. For example, to call only GetSystemTime, you need the interface definitions provided in
kernel32.mod (binary form). To do this, add the following USE statement:
USE KERNEL32
If you want to further minimize compile time, add the ONLY keyword to the USE statement. For example:
USE KERNEL32, only: GetSystemTime, GetLastError
Call Windows API Routines Using the Intel® Visual Fortran Interface Definitions
To call the appropriate Windows API routine after including the Intel® Visual Fortran interface definitions,
follow these guidelines:
1. Examine the documentation for the appropriate routine in the Windows API (for example,
GetSystemTime) to obtain the following information:
• The number and order of arguments. You will need to declare and initialize each argument variable
using the correct data type. In the case of the GetSystemTime routine, a structure (derived type) is
passed by reference.
If character arguments are present, add a null character as a terminator to the character variable
before calling the Windows API routine.
577
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Whether the routine returns a result (function) or not (subroutine). For example, because the
GetSystemTime routine calling format starts with VOID, this routine should be called as a subroutine
with a CALL statement.
2. If you are not sure about the data type of arguments or its function return value, you can examine the
interface definitions in the appropriate .F90 file in ...\INCLUDE\. For example, to view the interface
definition for GetSystemTime:
• In a text editor (such as Notepad), open the file kernel32.f90 from ...\INCLUDE\.
• Search (or Find) the routine name (such as GetSystemTime)
• View the interface definition and compare it to the description in the Windows API documentation to
see how the arguments are represented in Fortran. Take note of how arguments are passed; in
some cases, such as when an arbitrary data type is passed by address, you must pass the address
of a variable using the LOC intrinsic rather than the variable directly.
3. If one of the arguments is a structure, look up the definition in IFWINTY.F90 in ...\INCLUDE\. For
example, to view the data type definition for the T_SYSTEMTIME type used in GetSystemTime:
• In a text editor (such as Notepad), open the file IFWINTY.F90 from ...\INCLUDE\.
• Search (or Find) the data type name (such as T_SYSTEMTIME).
• View the data type definition and note the field names. In some cases, these will differ slightly from
those listed in the Windows API documentation.
• Define a variable name to use the derived-type definition in your program, such as:
Integer(HANDLE) :: hwnd
Use the variable definition to call the Win32 routine. For example, the completed program follows:
BYTE INTEGER(BYTE)
578
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DWORD INTEGER(DWORD)
ULONG INTEGER(ULONG)
SHORT INTEGER(SHORT)
LPHANDLE INTEGER(LPHANDLE)
PLONG INTEGER(PLONG)
DOUBLE REAL(DOUBLE)
Use the kind constants instead of explicitly specifying the kind as a number, or assuming a default kind.
Note that the Windows BOOL type is not equivalent to Fortran LOGICAL and should not be used with Fortran
LOGICAL operators and literal constants. Use the constants TRUE and FALSE, defined in IFWINTY, rather than
the Fortran literals .TRUE. and .FALSE., and do not test BOOL values using LOGICAL expressions.
Additional notes about equivalent data types for arguments:
• If an argument is described in the Windows API documentation as a pointer, then the corresponding
Fortran interface definition of that argument would have the REFERENCE property (see the ATTRIBUTES).
Older interface definitions use the POINTER - Integer and pass the address of the argument, or the LOC
intrinsic function.
• Pointer arguments on systems using IA-32 architecture are 32-bit (4 bytes) in length. Pointer arguments
on systems using Intel® 64 architecture are 64 bits (8 bytes) in length.
• Be aware that Fortran character variables need to be null-terminated. You can do this by using the C
string extension (see C Strings in Character Constants):
ADVAPI32
COMCTL32
COMDLG32
579
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GDI32
KERNEL32
LZ32
OLE32
OLEAUT32
PSAPI
SCRNSAVE
SHELL32
USER32
VERSION
WINMM
WINSPOOL
WS2_32
WSOCK32
Additionally, the IFOPNGL module declares OpenGL routines for Windows OS, with Fortran-specific names.
Math Libraries
The Intel® Fortran Compiler includes these math libraries:
libimf.a (Linux* and macOS ) Intel® Fortran Compiler Classic and Intel® Fortran Compiler
Math Libraries, in addition to libm.a, the math library
provided with gcc*
Both of these libraries are linked in by default because certain
math functions supported by the GNU* math library are not
available in the Intel® Fortran Compiler Classic and Intel®
Fortran Compiler Math Library. This linking arrangement allows
the GNU* users to have all functions available when using
ifort, with Intel optimized versions available when
supported.
libimf.a is linked in before libm.a. If you link in libm.a
first, it will change the versions of the math functions that are
used.
Many routines in the libimf library are more optimized for
Intel® microprocessors than for non-Intel microprocessors.
580
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
It is strongly recommended to use the default rounding mode (round-to-nearest-even) when calling
math library transcendental functions and compiling with default optimization or higher. Faster
implementations (in terms of latency and/or throughput) of these functions are validated under the
default round-to-nearest-even mode. Using other rounding modes may make results generated by
these faster implementations less accurate, or set unexpected floating-point status flags. This
behavior may be avoided by -no-fast-transcendentals, which disables calls to the faster
implementations of math functions, or by -fp-model strict, which warns the compiler that it
cannot assume default settings for the floating-point environment.
Many routines in the Math Library are more optimized for Intel® microprocessors than for non-Intel
microprocessors.
Intel® Math Kernel Library (Intel® MKL) Math library of Fortran routines and functions that perform a
wide variety of operations on vectors and matrices. The library
also includes fast Fourier transform (fft) functions, as well as
vector mathematical and vector statistical functions. For more
information, see Using Intel® Performance Libraries with
Microsoft Visual Studio* and the Intel® Math Kernel Library
documentation.
NOTE The Intel Compiler Math Libraries contain performance-optimized implementations for various
Intel platforms. By default, the best implementation for the underlying hardware is selected at
runtime. The library dispatch of multi-threaded code may lead to apparent data races, which may be
detected by certain software analysis tools. However, as long as the threads are running on cores with
the same CPUID, these data races are harmless and are not a cause for concern.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
Data Representation
Intel® Fortran expects numeric data to be in native little endian order, in which the least-significant, right-
most zero bit (bit 0) or byte has a lower address than the most-significant, left-most bit (or byte). For
information on using non-native big endian and VAX* floating-point formats, see Supported Native and Non-
native Numeric Formats.
The following table lists the intrinsic data types used by Intel® Fortran, the storage required, and valid
ranges. For information on declaring Fortran intrinsic data types, see Type Declarations. For example, the
declaration INTEGER(4) is the same as INTEGER(KIND=4) and INTEGER*4.
581
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL See REAL(4), A real floating-point value, either REAL(4), REAL(8), or REAL(16). The
REAL(8), and size is controlled by the real-size compiler option.
REAL(16)
DOUBLE See REAL(8) A double precision floating-point value, either REAL(8) or REAL(16). The
PRECISION and REAL(16) size is controlled by the double-size compiler option.
COMPLEX See A complex floating-point value in a pair of real and imaginary parts that
COMPLEX(4), are either REAL(4), REAL(8), or REAL(16). The size is controlled by the
COMPLEX(8), real-size compiler option.
and
COMPLEX(16
)
DOUBLE See A double complex floating-point value in a pair of real and imaginary
COMPLEX COMPLEX(8) parts that are either REAL(8) or REAL(16). The size is controlled by the
and double-size compiler option.
COMPLEX(16
)
582
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL See A logical value, either LOGICAL(2), LOGICAL(4), or LOGICAL(8). The size
LOGICAL(2), is controlled by the integer-size compiler option.
LOGICAL(4),
and
LOGICAL(8)
583
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
In the figures of the INTEGER representations, the symbol :A specifies the address of the byte
containing bit 0, which is the starting address of the represented data element.
Operations on integers usually result in other integers within this range. Integer computations that produce
values too large or too small to be represented in the desired KIND result in the loss of precision. One
arithmetic rule to remember is that integer division results in truncation (for example, 8/3 evaluates to 2).
Integer data lengths can be 1, 2, 4, or 8 bytes in length.
The default data size used for an INTEGER data declaration is INTEGER(4) (same as INTEGER(KIND=4)).
However, you can specify a compiler option to override the default. Option integer-size 16 can be used to
specify INTEGER(2) and option integer-size 64 can be used to specify INTEGER(8).
Integer data is signed with the sign bit being 0 (zero) for positive numbers and 1 for negative numbers.
INTEGER(KIND=1) Representation
INTEGER(1) values range from -128 to 127 and are stored in 1 byte, as shown below.
INTEGER(KIND=2) Representation
INTEGER(2) values range from -32,768 to 32,767 and are stored in 2 contiguous bytes, as shown below:
584
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(KIND=4) Representation
INTEGER(4) values range from -2,147,483,648 to 2,147,483,647 and are stored in 4 contiguous bytes, as
shown below.
INTEGER(KIND=8) Representation
INTEGER(8) values range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and are stored
in 8 contiguous bytes, as shown below.
585
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) data representations (when fpscomp nologicals
is set) appear below.
The symbol :A in the figure specifies the address of the byte containing bit 0, which is the starting address of
the represented data element.
See Also
integer-size compiler option
assume compiler option, setting [no]old_logical_assign
fpscomp compiler option, setting [no]logicals
Character Representation
A character string is a contiguous sequence of bytes in memory, as shown below.
The symbol :A in the figure specifies the address of the byte containing bit 0, which is the starting address of
the represented data element.
A character string is specified by two attributes: the address A of the first byte of the string, and the length L
of the string in bytes.
Linux and macOS
The length L of a string is in the range 1 through 2,147,483,647 (2**31-1) for systems based on IA-32
architecture and in the range 1 through 9,223,372,036,854,775,807 (2**63-1) for systems based on Intel®
64 architecture.
586
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows
The length L of a string is in the range 1 through 2,147,483,647 (2**31-1) .
Hollerith Representation
Hollerith constants are stored internally, one character per byte, as shown below.
The symbol :A in the figure specifies the address of the byte containing bit 0, which is the starting address of
the represented data element.
Fortran I/O
In Fortran's I/O system, data is stored and transferred among files. All I/O data sources and destinations are
considered files.
587
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Devices such as the screen, keyboard, and printer are external files, as are data files stored on a device such
as a disk.
Variables in memory can also act as a file on a disk and are typically used to convert ASCII representations
of numbers to binary form. When variables are used in this way, they are called internal files.
For more information, see the individual topics in this section.
Logical Devices
Every file, internal or external, is associated with a logical device. You identify the logical device associated
with a file by using Unit Specifier (UNIT=). The unit specifier for an internal file is the name of the character
variable associated with it. The unit specifier for an external file is one of the following:
• A number you assign with the OPEN statement
• A number assigned by the Intel® Fortran runtime library with the OPEN specifier NEWUNIT=
• A number preconnected as a unit specifier to a device
• An asterisk (*)
The OPEN statement connects a unit number with an external file and allows you to explicitly specify file
attributes and runtime options using OPEN statement specifiers. External unit specifiers that are
preconnected to certain devices do not have to be opened. External units that you connect are disconnected
when program execution terminates or when the unit is closed by a CLOSE statement.
A unit must not be connected to more than one file at a time, and a file must not be connected to more than
one unit at a time. You can OPEN an already opened file but only to change some of the I/O options for the
connection, not to connect an already opened file or unit to a different unit or file.
You must use a unit specifier for all I/O statements except in the following cases:
• ACCEPT, which always reads from standard input unless the FOR_ACCEPT environment variable is defined.
• INQUIRE by file, which specifies the filename rather than the unit with which the file is associated.
• PRINT, which always writes to standard output unless the FOR_PRINT environment variable is defined.
• READ statements that contain only an I/O list and format specifier, which read from standard input
(UNIT=5) unless the FOR_READ environment variable is defined.
• WRITE statements that contain only an I/O list and format specifier, which write to standard output unless
the FOR_WRITE environment variable is defined.
• TYPE, which always writes to standard output unless the FOR_TYPE environment variable is defined.
External Files
A unit specifier associated with an external file must be either an integer expression or an asterisk (*). The
integer expression must be in the range 0 (zero) to a maximum value of 2,147,483,640. (The predefined
parameters FOR_K_PRINT_UNITNO, FOR_K_TYPE_UNITNO, FOR_K_ACCEPT_UNITNO, and
FOR_K_READ_UNITNO may not be in that range. For more information, see the Language Reference.)
The following example connects the external file UNDAMP.DAT to unit 10 and writes to it:
Asterisk (*) None Always represents the keyboard and screen (unless the
appropriate environment variable is defined, such as
FOR_READ).
588
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The asterisk (*) specifier is the only unit specifier that cannot be reconnected to another file; attempting to
close such a unit causes a compile-time error. Units 0, 5, and 6 can be connected to any file with the OPEN
statement; if you close one of those units, the file is automatically reconnected to its preconnected device
the next time an I/O statement attempts to use that unit.
Intel® Fortran does not support buffering to stdin, and does not buffer to stdout by default unless the
assume buffered_stdout option is specified. All I/O to units * and 6 use line buffering by default.
Therefore, C and Fortran output to stdout should work well as long as the C code is not performing
buffering. If the C code is performing buffering, the C code will have to flush the buffers after each write. For
more information on stdout and stdin, see Assigning Files to Logical Units.
You can change these preconnected files by doing one of the following:
• Using an OPEN statement to open unit 5, 6, or 0. When you explicitly OPEN a file for unit 5, 6, or 0, the
OPEN statement keywords specify the file-related information to be used instead of the preconnected
standard I/O file.
• Setting the appropriate environment variable (FORTn) to redirect I/O to an external file.
To redirect input or output from the standard preconnected files at runtime, you can set the appropriate
environment variable or use the appropriate shell redirection character in a pipe (such as > or <).
When you omit the file name in the OPEN statement or use an implicit OPEN, you can define the environment
variable FORTn to specify the file name for a particular unit number n. An exception to this is when the
fpscomp filesfromcmd compiler option is specified.
For example, if you want unit 6 to write to a file instead of standard output, set the environment variable
FORT6 to the path and filename to be used before you run the program. If the appropriate environment
variable is not defined, a default filename is used, in the form fort.n where n is the logical unit number.
The following example writes to the preconnected unit 6 (the screen), then reconnects unit 6 to an external
file and writes to it, and finally reconnects unit 6 to the screen and writes to it:
REAL a, b
! Write to the screen (preconnected unit 6).
WRITE(6, '('' This is unit 6'')')
! Use the OPEN statement to connect unit 6
! to an external file named 'COSINES'.
OPEN (UNIT = 6, FILE = 'COSINES', STATUS = 'NEW')
DO k = 1, 63, 1
a = k/10
b = COS (a)
! Write to the file 'COSINES'.
WRITE (6, 100) a, b
100 FORMAT (F3.1, F5.2)
END DO
! Close it.
CLOSE (6)
! Reconnect unit 6 to the screen, by writing to it.
WRITE(6,' ('' Cosines completed'')')
END
589
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Internal Files
The unit specifier associated with an internal file is a scalar or array character variable:
• If the internal file is a scalar character variable, the file has only one record; its length is equal to that of
the variable.
• If the internal file is an array character variable, the file has a record for each element in the array; each
record's length is equal to one array element.
Follow these rules when using internal files:
• Use only formatted I/O, including I/O formatted with a format specification, namelist, and list-directed
I/O. (List-directed and namelist I/O are treated as sequential formatted I/O.)
• If the character variable is an allocatable array or array part of an allocatable array, the array must be
allocated before use as an internal file. If the character variable is a pointer, it must be associated with a
target.
• Use only READ and WRITE statements. You cannot use file connection (OPEN, CLOSE), file positioning
(REWIND, BACKSPACE), or file inquiry (INQUIRE) statements with internal files.
You can read and write internal files with FORMAT I/O statements, namelist I/O statements, or list-directed
I/O statements exactly as you can external files. Before an I/O statement is executed, internal files are
positioned at the beginning of the variable, before the first record.
With internal files, you can use the formatting capabilities of the I/O system to convert values between
external character representations and Fortran internal memory representations. Reading from an internal
file converts the ASCII representations into numeric, logical, or character representations, and writing to an
internal file converts these representations into their ASCII representations.
This feature makes it possible to read a string of characters without knowing its exact format, examine the
string, and interpret its contents. It also makes it possible, as in dialog boxes, for the user to enter a string
and for your application to interpret it as a number.
If less than an entire record is written to an internal file, the rest of the record is filled with blanks.
In the following example, str and fname specify internal files:
CHARACTER(10) str
INTEGER n1, n2, n3
CHARACTER(14) fname
INTEGER i
str = " 1 2 3"
! List-directed READ sets n1 = 1, n2 = 2, n3 = 3.
READ(str, *) n1, n2, n3
i = 4
! Formatted WRITE sets fname = 'FM004.DAT'.
WRITE (fname, 200) i
200 FORMAT ('FM', I3.3, '.DAT')
See Also
assume compiler option
590
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Device Description
PRN Printer
NOTE
If you use the LINE, USER, or ERR name with an extension, for example, LINE.TXT, Fortran will write
to a file rather than to the device.
File connection
OPEN Connects a unit number with an external file and specifies file connection
characteristics.
File inquiry
591
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DEFINE FILE Specifies file characteristics for a direct access relative file and connects the unit
number to the file, similar to an OPEN statement. Provided for compatibility with
compilers older than FORTRAN-77.
INQUIRE Returns information about a named file, a connection to a unit, or the length of an
output item list.
Record position
BACKSPACE Moves the record position to the beginning of the previous record (sequential access
only).
DELETE Marks the record at the current record position in a relative file as deleted (direct
access only).
ENDFILE Writes an end-of-file marker after the current record (sequential access only).
FIND Changes the record position in a direct access file. Provided for compatibility with
compilers older than FORTRAN-77.
REWIND Sets the record position to the beginning of the file (sequential access only).
Record input
READ Transfers data from an external file record or an internal file to internal storage.
ACCEPT Reads input from stdin. Unlike READ, ACCEPT only provides formatted sequential
input and does not specify a unit number.
Record output
WRITE Transfers data from internal storage to an external file record or to an internal file.
REWRITE Transfers data from internal storage to an external file record at the current record
position (direct access relative files only).
PRINT Transfers data from internal storage to stdout. Unlike WRITE, PRINT only provides
formatted sequential output and does not specify a unit number.
FLUSH Flushes the contents of an external unit's buffer to its associated file.
In addition to the READ, WRITE, REWRITE, TYPE, and PRINT statements, other I/O record-related statements
are limited to a specific file organization. For instance:
• The DELETE statement only applies to relative files. (Detecting deleted records is only available if the vms
option was specified when the program was compiled.)
• The BACKSPACE statement only applies to sequential files open for sequential access.
• The REWIND statement only applies to sequential files open for sequential access and to direct access
files.
• The ENDFILE statement only applies to certain types of sequential files open for sequential access and to
direct access files.
The file-related statements (OPEN, INQUIRE, and CLOSE) apply to any relative or sequential file.
592
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Formatted I/O statements contain explicit format specifiers that are used to control the translation of data
from internal (binary) form within a program to external (readable character) form in the records, or vice
versa.
• List-directed and namelist I/O statements are similar to formatted statements in function. However, they
use different mechanisms to control the translation of data: formatted I/O statements use explicit format
specifiers, and list-directed and namelist I/O statements use data types.
• Unformatted I/O statements do not contain format specifiers and therefore do not translate the data
being transferred (important when writing data that will be read later).
Formatted, list-directed, and namelist I/O forms require translation of data from internal (binary) form within
a program to external (readable character) form in the records. Consider using unformatted I/O for the
following reasons:
• Unformatted data avoids the translation process, so I/O tends to be faster.
• Unformatted data avoids the loss of precision in floating-point numbers when the output data will
subsequently be used as input data.
• Unformatted data conserves file storage space (stored in binary form).
To write data to a file using formatted, list-directed, or namelist I/O statements, specify FORM= 'FORMATTED'
when opening the file. To write data to a file using unformatted I/O statements, specify FORM=
'UNFORMATTED' when opening the file.
Data written using formatted, list-directed, or namelist I/O statements is referred to as formatted data. Data
written using unformatted I/O statements is referred to as unformatted data.
When reading data from a file, you should use the same I/O statement form that was used to write the data
to the file. For instance, if data was written to a file with a formatted I/O statement, you should read data
from that file with a formatted I/O statement.
I/O statement form is usually the same for reading and writing data in a file. However, a program can read a
file containing unformatted data (using unformatted input) and write it to a separate file containing
formatted data (using formatted output). Similarly, a program can read a file containing formatted data and
write it to a different file containing unformatted data.
You can access records in any sequential or relative file using sequential access. For relative files and certain
(fixed-length) sequential files, you can also access records using direct access.
The table below shows categories for the main record I/O statements that can be used in Intel® Fortran
programs.
593
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Internal file
Unformatted None
NOTE
You can use the REWRITE statement only for relative files, using direct access.
PRINT *,100
The READ statement associates the logical unit 7 with the file fort.7 (because the FILE specifier was
omitted) by default:
OPEN (UNIT=7,STATUS='NEW')
READ (7,100)
For example:
Implied OPEN
An implied OPEN means that the FILE and DEFAULTFILE specifier values are not specified. If you used an
implied OPEN, or if the FILE specifier in an OPEN statement did not specify a file name, you can use an
environment variable to specify a file name or a pathname. The pathname can contain both a directory and
file name.
594
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can change the file associated with these Intel Fortran environment variables, as you would any other
environment variable, by means of the environment variable assignment command. For example:
NOTE
The association between the logical unit number and the physical file can occur at runtime. Instead of
changing the logical unit numbers specified in the source program, you can change this association at
runtime to match the needs of the program and the available resources. For example, before running
the program, a script file can set the appropriate environment variable or allow the terminal user to
type a directory path, file name, or both.
File Organization
File organization refers to the way records are physically arranged on a storage device. This topic describes
the two main types of file organization.
Related topics describe the following:
595
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Record type refers to whether records in a file are all the same length, are of varying length, or use other
conventions to define where one record ends and another begins. For more information on record types,
see Record Types.
• Record access refers to the method used to read records from or write records to a file, regardless of its
organization. The way a file is organized does not necessarily imply the way in which the records within
that file will be accessed. For more information on record access, see File Access and File Structure and
Record Access.
When creating a relative file, use the RECL value to determine the size of the fixed-length cells. Within the
cells, you can store records of varying length, as long as their size does not exceed the cell size.
Internal Files
When you use sequential access, you can use an internal file to reference character data in a buffer. The
transfer occurs between internal storage spaces (unlike external files), such as between user variables and a
character array.
An internal file consists of any of the following:
• Character variable
• Character-array element
596
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Character array
• Character substring
• Character array section without a vector subscript
Instead of specifying a unit number for the READ or WRITE statement, use an internal file specifier in the
form of a character scalar memory reference or a character-array name reference.
An internal file is a designated internal storage space (variable buffer) of characters that is treated as a
sequential file of fixed-length records. To perform internal I/O, use formatted and list-directed sequential
READ and WRITE statements. You cannot use file-related statements such as OPEN and INQUIRE on an
internal file (no unit number is used).
If an internal file is made up of a single character variable, array element, or substring, that file comprises a
single record whose length is the same as the length of the character variable, array element, or substring it
contains. If an internal file is made up of a character array, that file comprises a sequence of records, with
each record consisting of a single array element. The sequence of records in an internal file is determined by
the order of subscript progression.
A record in an internal file can be read only if the character variable, array element, or substring comprising
the record has been defined (a value has been assigned to the record).
Prior to each READ and WRITE statement, an internal file is always positioned at the beginning of the first
record.
Scratch Files
Scratch files are created by specifying STATUS= 'SCRATCH' in an OPEN statement. By default, these
temporary files are created by an OPEN statement and are deleted when closed.
597
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You create an unformatted file by opening it with the FORM='UNFORMATTED' option, or by omitting the
FORM parameter when creating a direct-access file. An unformatted file is a series of records composed of
physical blocks. Each record contains a sequence of values stored in a representation that is close to what
is used in program memory. Little conversion is required during input/output.
The lack of formatting makes these files quicker to access and more compact than files that store the
same information in a formatted form. However, if the files contain numbers, you will not be able to read
them with a text editor.
• Binary Files
You create a binary file by specifying FORM='BINARY'. Binary files are similar to unformatted files, except
binary files have no internal record format associated with them.
• Sequential-Access Files
Data in sequential files must be accessed in order, one record after the other (unless you change your
position in the file with the REWIND or BACKSPACE statements). Some methods of I/O are possible only
with sequential files, including nonadvancing I/O, list-directed I/O, and namelist I/O. Internal files must
also be sequential files. You must use sequential access for files associated with sequential devices.
A sequential device is a physical storage device that does not allow explicit motion (other than reading or
writing). The keyboard, screen, and printer are all sequential devices.
• Direct-Access Files
Data in direct-access files can be read or written to in any order. Records are numbered sequentially,
starting with record number 1. All records have the length specified by the RECL option in the OPEN
statement. Data in direct-access files is accessed by specifying the record you want within the file. If you
need random access I/O, use direct-access files. A common example of a random-access application is a
database.
• Stream-Access Files
Stream-access I/O is a method of accessing a file without reference to a record structure. With stream
access, a file is seen as a continuous sequence of bytes and is addressed by a positive integer starting
from 1.
To enable stream access, specify ACCESS='STREAM' in the OPEN statement for the file. You can use the
STREAM= specifier in the INQUIRE statement to determine if STREAM is listed in the set of possible
access methods for the file. A value of YES, NO, or UNKNOWN is returned.
A file enabled for stream access is positioned by file storage units (normally bytes) starting at position 1.
To determine the current position, use the POS= specifier in an INQUIRE statement for the unit. You can
indicate a required position in a read or write statement with a POS= specifier.
Stream access can be either formatted or unformatted.
When connected for formatted stream access, an external file has the following characteristics:
• The first file storage unit in the file is at position 1. The relationship between positions of successive file
storage units is processor dependent; not all positive integers need to correspond to valid positions.
• Some file storage units may contain record markers that impose a record structure on the file in
addition to its stream structure. If there is no record marker at the end of the file, the final record is
incomplete. Writing an empty record with no record marker has no effect.
When connected for unformatted stream access, an external file has the following characteristics:
• The first file storage unit in the file is at position 1. The position of each subsequent file storage unit is
one greater than the position of the preceding file storage unit.
• If it is possible to position the file, the file storage units do not need to be read or written in order of
their position. For example, you may be able to write the file storage unit at position 2, even though
the file storage unit at position 1 has not been written.
• Any file storage unit can be read from the file while it is connected to a unit, if the file storage unit has
been written since the file was created, and a READ statement for this connection is allowed.
• You cannot use BACKSPACE in an unformatted stream.
598
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
File Records
Files may be composed of records. Each record is one entry in the file. A record can be a line from a terminal
or a logical record on a magnetic tape or disk file. All records within one file are of the same type.
In Fortran, the number of bytes transferred to a record must be less than or equal to the record length. One
record is transferred for each unformatted READ or WRITE statement. A formatted READ or WRITE statement
can transfer more than one record using the slash (/) edit descriptor.
For binary files, a single READ or WRITE statement reads or writes as many records as needed to
accommodate the number of bytes being transferred. On output, incomplete formatted records are padded
with spaces. Incomplete unformatted and binary records are padded with undefined bytes (zeros).
Record Types
An I/O record is a collection of data items, called fields, which are logically related and are processed as a
unit. The record type refers to the convention for storing fields in records.
The record type of the data within a file is not maintained as an attribute of the file. The results of using a
record type other than the one used to create the file are indeterminate.
A number of record types are available, as shown in the following table. The table also lists the record
overhead. Record overhead refers to bytes associated with each record that are used internally by the file
system and are not available when a record is read or written. Knowing the record overhead helps when
estimating the storage requirements for an application. Although the overhead bytes exist on the storage
media, do not include them when specifying the record length with the RECL specifier in an OPEN statement.
Variable- Sequential file organization only. The variable-length record Eight bytes per record.
length type is generally the most portable record type across multi-
vendor platforms.
Segmented Sequential file organization only and specifically for Four bytes per record.
unformatted sequential access. The segmented record type is One additional padding
unique to Intel Fortran. It should not be used for portability byte (space) is added if
with programs written in languages other than Fortran or for the specified record size
places where Intel Fortran is not used. However, because the is an odd number.
segmented record type is unique to Intel Fortran products,
formatted data in segmented files can be ported across Intel
Fortran platforms.
599
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
(uses LF as
record
terminator)
Fixed-Length Records
When you specify fixed-length records, you are specifying that all records in the file contain the same
number of bytes. When you open a file that is to contain fixed-length records, you must specify the record
size using the RECL keyword. A sequentially organized opened file for direct access must contain fixed-length
records, to allow the record position in the file to be computed correctly.
For relative files, the layout and overhead of fixed-length records depends upon whether the program
accessing the file was compiled using the vms option:
• For relative files where the vms option is omitted (the default), each record has no control information.
• For relative files where the vms option is specified, each record has one byte of control information at the
beginning of the record.
The following figures show the record layout of fixed-length records. The first is for all sequential and relative
files where the vms option is omitted. The second is for relative files where the vms option is specified.
Variable-Length Records
Variable-length records can contain any number of bytes up to a specified maximum record length, and apply
only to sequential files.
Variable-length records are prefixed and suffixed by 4 bytes of control information containing length fields.
The trailing length field allows a BACKSPACE request to skip back over records efficiently. The 4-byte integer
value stored in each length field indicates the number of data bytes (excluding overhead bytes) in that
particular variable-length record.
600
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The character count field of a variable-length record is available when you read the record by issuing a READ
statement with a Q format descriptor. You can then use the count field information to determine how many
bytes should be in an I/O list.
The following shows the record layout of variable-length records that are less than 2 gigabytes:
For a record length greater than 2,147,483,639 bytes, the record is divided into subrecords. The subrecord
can be of any length from 1 to 2,147,483,639, inclusive.
The sign bit of the leading length field indicates whether the record is continued or not. The sign bit of the
trailing length field indicates the presence of a preceding subrecord. The position of the sign bit is determined
by the endian format of the file.
The following rules describe sign bit values:
• A subrecord that is continued has a leading length field with a sign bit value of 1.
• The last subrecord that makes up a record has a leading length field with a sign bit value of 0.
• A subrecord that has a preceding subrecord has a trailing length field with a sign bit value of 1.
• The first subrecord that makes up a record has a trailing length field with a sign bit value of 0.
• If the value of the sign bit is 1, the length of the record is stored in twos-complement notation.
The following shows the record layout of variable-length records that are greater than 2 gigabytes:
Files written with variable-length records by Intel Fortran programs usually cannot be accessed as text files.
Instead, use the Stream_LF record format for text files with records of varying length.
601
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Segmented Records
A segmented record is a single logical record consisting of one or more variable-length, unformatted records
in a sequentially organized disk file. Unformatted data written to sequentially organized files using sequential
access is stored as segmented records by default.
Segmented records are useful when you want to write exceptionally long records but cannot, or you do not
want to define one long variable-length record. For example, you might not want to define one long variable-
length record because virtual memory limitations can prevent program execution. By using smaller,
segmented records, you reduce the chance of problems caused by virtual memory limitations on systems on
which the program may execute.
For disk files, the segmented record is a single logical record that consists of one or more segments. Each
segment is a physical record. A segmented (logical) record can exceed the absolute maximum record length
(2.14 billion bytes), but each segment (physical record) individually cannot exceed the maximum record
length.
To access an unformatted sequential file that contains segmented records, specify FORM='UNFORMATTED'
and RECORDTYPE='SEGMENTED' when you open the file.
The following shows that the layout of segmented records consists of 4 bytes of control information followed
by the user data:
The control information consists of a 2-byte integer record length count (includes the 2 bytes used by the
segment identifier), followed by a 2-byte integer segment identifier that identifies this segment as one of the
following:
1 First segment
2 Last segment
3 Only segment
If the specified record length is an odd number, the user data will be padded with a single blank (one byte),
but this extra byte is not added to the 2-byte integer record size count.
Avoid the segmented record type when the application requires that the same file be used for programs
written in languages other than Intel Fortran and for non-Intel platforms.
602
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
603
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FOR_FMT_TERMINATOR=MODE[:ULIST][;MODE[:ULIST]]
where:
MODE=CR | LF | CRLF
ULIST = U | ULIST,U
U = decimal | decimal - decimal
• MODE specifies the record terminator to be used. The keyword CR means to terminate records with a
carriage return. The keyword LF means to terminate records with a line feed; LF is the default on Linux*
and macOS systems. The keyword CRLF means to terminate records with a carriage return/line feed pair;
CRLF is the default on Windows systems.
• Each list member "U" is a simple unit number or a number of units as a range. The number of list
members is limited to 64.
• "decimal" is a non-negative decimal number less than 232.
No spaces are allowed inside the FOR_FMT_TERMINATOR value.
On Linux* systems, the following shows the command line for the variable setting in a bash-style shell:
NOTE
The environment variable value should be enclosed in quotes if the semicolon is present.
Example:
The following specifies that all input/output operations on unit numbers 10, 11, and 12 have records
terminated with a carriage return/line feed pair:
FOR_FMT_TERMINATOR=CRLF:10-12
Record Length
Use the RECL specifier to specify the record length.
The units used for specifying record length depend on the form of the data:
• Formatted files (FORM= 'FORMATTED'): Specify the record length in bytes.
• Unformatted files (FORM= 'UNFORMATTED'): Specify the record length in 4-byte units, unless you specify
the assume byterecl compiler option to request 1-byte units.
For all but variable-length sequential records on 64-bit addressable systems, the maximum record length is
2.147 billion bytes (2,147,483,647 minus the bytes for record overhead). For variable-length sequential
records on 64-bit addressable systems, the theoretical maximum record length is about 17,000 gigabytes.
When considering very large record sizes, also consider limiting factors such as system virtual memory.
NOTE
The RECL specifier is ignored for stream access.
604
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Record Access
Record access refers to how records will be read from or written to a file, regardless of the file's organization.
Record access is specified each time you open a file; it can be different each time. The type of record access
permitted is determined by the combination of file organization and record type.
For example, you can fo the following:
• Add records to a sequential file with ORGANIZATION= 'SEQUENTIAL' and POSITION= 'APPEND' (or use
ACCESS= 'APPEND').
• Add records sequentially by using multiple WRITE statements, close the file, and then open it again with
ORGANIZATION= 'SEQUENTIAL' and ACCESS= 'SEQUENTIAL' (or ACCESS= 'DIRECT' if the sequential file
has fixed-length records).
Sequential Access
Sequential access transfers records sequentially to or from files or I/O devices such as terminals. You can use
sequential I/O with any type of supported file organization and record type.
When you select sequential access mode for files with sequential or relative organization, records are written
to or read from the file starting at the beginning of the file and continuing through it, one record after
another. A particular record can be retrieved only after all of the records preceding it have been read; new
records can be written only at the end of the file.
Direct Access
Direct access transfers records selected by record number to and from either sequential files stored on disk
with a fixed-length record type or relative organization files.
If you select direct access mode, you can determine the order in which records are read or written. Each
READ or WRITE statement must include the relative record number, indicating the record to be read or
written.
You can directly access a sequential disk file only if it contains fixed-length records. Because direct access
uses cell numbers to find records, you can enter successive READ or WRITE statements requesting records
that either precede or follow previously requested records. For example, the first statement reads record 24;
the second statement reads record 10:
READ (12,REC=24) I
READ (12,REC=10) J
Stream Access
Stream access transfers bytes from records sequentially until a record terminator is found or a specified
number of bytes have been read or written. Formatted stream records are terminated with a new line
character; unformatted stream data contains no record terminators. Bytes can be read from or written to a
file by byte position, where the first byte of the file is position 1. For example:
NOTE
The RECORDTYPE= specifier is ignored for stream access.
605
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Variable Yes No
Segmented Yes No
Stream Yes No
Stream_CR Yes No
Stream_LF Yes No
Stream_CRLF Yes No
NOTE
Direct access and relative files require that the file resides on a disk device.
Record Transfer
I/O statements transfer all data as records. The amount of data that a record can contain depends on the
following circumstances:
• With formatted I/O (except for fixed-length records), the number of items in the I/O statement and its
associated format specifier jointly determine the amount of data to be transferred.
• With namelist and list-directed output, the items listed in the NAMELIST statement or I/O statement list
(in conjunction with the NAMELIST or list-directed formatting rules) determine the amount of data to be
transferred.
• With unformatted I/O (except for fixed-length records), the I/O statement alone specifies the amount of
data to be transferred.
• When you specify fixed-length records (RECORDTYPE= 'FIXED'), all records are the same size. If the size
of an I/O record being written is less than the record length (RECL), extra bytes are added (padding).
Typically, the data transferred by an I/O statement is read from or written to a single record. However, a
single I/O statement can possibly transfer data from or to more than one record, depending on the form of
I/O used.
606
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• For formatted input using nonadvancing I/O (ADVANCE='NO'), an end-of-record (EOR) condition is
returned. If the file was opened with PAD='YES', additional fields are read as spaces.
• For list-directed input, another record is read.
• For NAMELIST input, another record is read.
• For unformatted input, an error occurs.
607
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When the resulting file pathname begins with a tilde character (~), C-shell-style pathname substitution is
used (regardless of what shell is being used), such as a top-level directory (below the root). For additional
information on tilde pathname substitution, see csh(1).
608
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If you specify a file specification that does not match the one specified for the original open, the runtime
system closes the original file and then opens the second file. This action resets the current record
position for the second file.
• If you specify a file specification that matches the one specified for the original open, the file is
reconnected without the internal equivalent of the CLOSE and OPEN. This behavior lets you change one or
more OPEN statement runtime specifiers while maintaining the record position context.
You can use the INQUIRE Statement to obtain information about whether a file is opened by your program.
Especially when creating a new file using the OPEN statement, examine the defaults (see the description of
the OPEN statement) or explicitly specify file attributes with the appropriate OPEN statement specifiers.
609
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• DELIM specifies the delimiter character for character constants in list-directed or namelist output.
• PAD, when reading formatted records, indicates whether padding characters should be added if the item
list and format specification require more data than the record contains.
• BUFFERED indicates whether buffered or non-buffered I/O should be used.
• BLOCKSIZE specifies the physical I/O buffer or transfer size.
• BUFFERCOUNT specifies the number of physical I/O buffers.
• CONVERT specifies the format of unformatted numeric data.
CHARACTER(LEN=9) DOC
WRITE (6,*) 'Type file name '
READ (5,*) DOC
OPEN (UNIT=2, FILE=DOC, DEFAULTFILE='/usr/users/smith',STATUS='OLD')
A slash (backslash on Windows systems) is appended to the end of the default file string if it does not have
one.
On Windows, there is a default limit of 260 characters in a pathname string. Longer strings are truncated to
that limit. Windows provides an override of the limit. To use the override, the pathname must be absolute
(from the drive), not relative (from the current directory). To override, start the pathname with "\\?\". If
DEFAULTFILE is set, it can be prefixed with the override. Fortran supports this override for the FILE and
DEFAULTFILE specifiers, up to a limit of 4095 characters.
On Linux, the pathname limit is always 4095 characters.
610
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Inquiry by Unit
An inquiry by unit is usually done for an opened (connected) file. An inquiry by unit causes the Intel® Fortran
RTL to check whether the specified unit is connected or not. One of the following occurs, depending on
whether the unit is connected or not:
If the unit is connected:
• The EXIST and OPENED specifier variables indicate a true value.
• The pathname and file name are returned in the NAME specifier variable (if the file is named).
• Other information requested on the previously connected file is returned.
• Default values are usually returned for the INQUIRE specifiers also associated with the OPEN statement.
• The RECL value unit for connected formatted files is always 1-byte units. For unformatted files, the RECL
unit is 4-byte units, unless you specify the -assume byterecl option to request 1-byte units.
If no match occurs:
• The OPENED specifier variable indicates a false value.
• The unit NUMBER specifier variable is returned as a value of -1.
• The EXIST specifier variable indicates (true or false) whether the named file exists on the device or not.
• If the file does exist, the NAME specifier variable contains the pathname and file name.
• Any other information returned will be default values for the various specifiers, based on any information
specified when calling INQUIRE.
The following INQUIRE statement returns whether the file named log_file is connected in logical variable
I_OPEN, whether the file exists in logical variable I_EXIST, and the unit number in integer variable
I_NUMBER:
611
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INQUIRE (IOLENGTH=I_RECLENGTH) A, B, H
OPEN (FILE='test.dat', FORM='UNFORMATTED', RECL=I_RECLENGTH, UNIT=9)
For an unformatted file, the IOLENGTH value is returned using 4-byte units, unless you specify the
-assume byterecl option to request 1-byte units.
Inquiry by Directory
An inquiry by directory verifies that a directory exists.
If the directory exists:
• The EXIST specifier variable indicates a true value.
• The full directory pathname is returned in the DIRSPEC specifier variable.
If the directory does not exist:
• The EXIST specified variable indicates a false value.
• The value of the DIRSPEC specifier variable is unchanged.
For example, the following INQUIRE statement returns the full directory pathname:
LOGICAL ::L_EXISTS
CHARACTER (255)::C_DIRSPEC
INQUIRE (DIRECTORY=".", DIRSPEC=C_DIRSPEC, EXIST=L_EXISTS)
The following INQUIRE statement verifies that a directory does not exist:
612
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Depending on the value specified by the ACTION (or READONLY) specifier in the OPEN statement, the file will
be opened by your program for reading, writing, or both reading and writing records. This simply checks that
the program itself executes the type of statements intended.
File locking mechanisms allow users to enable or restrict access to a particular file when that file is being
accessed by another process.
Intel® Fortran file locking features provide three file access modes:
• Implicit Shared mode, which occurs when no mode is specified. This mode is also called No Locking.
• Explicit Shared mode, when all cooperating processes have access to a file. This mode is set in the OPEN
statement by the SHARED specifier or the SHARE='DENYNONE' specifier.
• Exclusive mode, when only one process has access to a file. This mode is set in the OPEN statement by
the NOSHARED specifier or the SHARE='DENYRW' specifier.
The file locking mechanism looks for explicit setting of the corresponding specifier in the OPEN statement.
Otherwise, the Fortran runtime does not perform any setting or checking for file locking. The process can
access the file regardless of the fact that other processes have already opened or locked the file.
613
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If process 2 opens the file with Implicit Shared (No Locking) mode, it gets access to the file.
• If process 2 opens the file with Explicit Shared or Exclusive mode, it receives an error.
The Fortran runtime does not coordinate file entry updates during cooperative access. The user needs to
coordinate access times among cooperating processes to handle the possibility of simultaneous WRITE and
REWRITE statements on the same record positions.
614
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When using nonadvancing input, you can use the SIZE specifier to return the number of characters read. For
example, in the following READ statement, SIZE=X (where variable X is an integer) returns the number of
characters read in X and an end-of-record condition causes a branch to label 700:
150 FORMAT (F10.2, F10.2, I6)
READ (UNIT=20, FMT=150, SIZE=X, ADVANCE='NO', EOR=700) A, F, I
NOTE
If your application requires that you use C to perform the file open and close, as well as all record
operations, call the appropriate C procedure from the Intel® Fortran program without using the Fortran
OPEN statement.
NOTE
If a file name was specified in the OPEN statement that included the USEROPEN specifier, any
subsequent CLOSE statement specifying STATUS=DELETE (or DISPOSE=DELETE) only acts on the file
name specified in the OPEN statement. If you specified a different file name in the function named in
USEROPEN, the CLOSE statement will have no effect on that file name.
EXTERNAL UOPEN
INTEGER UOPEN
.
.
.
OPEN (UNIT=10, FILE='/usr/test/data', STATUS='NEW', USEROPEN=UOPEN)
615
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
During the execution of the OPEN statement, the external procedure called uopen_ receives control. The
function opens the file, may perform other operations, and subsequently returns control (with the file
descriptor) to the RTL. You can use other system calls or library routines within the USEROPEN function.
In most cases, the USEROPEN function modifies the open flags argument passed by the Intel® Fortran RTL or
uses a new value before the open (or create) system call. After the function opens the file, it must return
control to the RTL.
On Linux and macOS, the file descriptor is a 4-byte integer on both 32-bit and 64-bit systems. On Windows,
the file descriptor is a 4-byte integer on 32-bit systems and an 8-byte integer on 64-bit systems:
• If the USEROPEN function is written in C, declare it as a C function.
• If the USEROPEN function is written in Fortran, declare it as a FUNCTION, perhaps with an interface block.
The called function must return the file descriptor to the RTL, or -1 if the function detects an error.
The following shows the available arguments and definitions for Linux* and macOS, and then for Windows*:
Linux* and macOS Arguments and Definitions:
616
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
2. Indicates the pathname to be opened; the pathname includes the file name.
3. Indicates the mode of access. It can be set to read, write, or read/write.
4. Indicates the file protection mode.
5. This line indicates a NULL that is passed as a literal zero by value.
6. This sets flags that specify file modes and several kinds of file features, such as whether to use
sequential access or random access, whether to delete on close, etc.
7. This line indicates a NULL that is passed as a literal zero by value.
8. Indicates the logical unit number.
9. Indicates the pathname length (the hidden character length argument of the pathname).
Argument Notes for Windows*:
The argument list for a USEROPEN routine on Windows is very similar to the argument list for the Microsoft*
Windows function CreateFile. This lets you easily write a USEROPEN routine and pass the input arguments
to a call to CreateFile. The CreateFile system call requires the file name, the desired_access, the
shared_mode, and the flags_attr. These arguments have been set to reflect the file semantics requested in
the OPEN statement. The logical unit number specified in the OPEN statement is passed in case the
USEROPEN function needs it. The hidden character length of the pathname is also passed.
On 32-bit Windows*, a Fortran USEROPEN function must use the default "C, Reference" calling convention. If
you have used the iface compiler option to change the default calling convention to stdcall or cvf, you
will need to add a !DIR$ ATTRIBUTES DEFAULT directive in the function source to have it use the correct
calling convention.
EXTERNAL UOPEN
INTEGER UOPEN
.
.
.
OPEN (UNIT=1,FILE='ex1.dat',STATUS='NEW',USEROPEN=UOPEN,
ERR=9,IOSTAT=errnum)
If UOPEN is a Fortran function, its name is decorated appropriately for Fortran.
Likewise, if UOPEN is a C function, its name is decorated appropriately for C, as long as the following line is
included in the above code:
Examples
The following shows an example on Linux and macOS systems and an example on Windows systems.
Example on Linux and macOS systems:
PROGRAM UserOpenMain
IMPLICIT NONE
EXTERNAL UOPEN
INTEGER(4) UOPEN
617
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CHARACTER(10) :: FileName="UOPEN.DAT"
INTEGER :: IOS
CHARACTER(255):: InqFullName
CHARACTER(100):: InqFileName
INTEGER :: InqLun
CHARACTER(30) :: WriteOutBuffer="Write_One_Record_to_the_File. "
CHARACTER(30) :: ReadInBuffer ="??????????????????????????????"
OPEN(UNIT=10,FILE='UOPEN.DAT',STATUS='REPLACE',USEROPEN=UOPEN, &
IOSTAT=ios, ACTION='READWRITE')
! When the OPEN statement is executed, the uopen_ function receives control.
! The uopen_ function opens the file by calling open(), and subsequently
! returns control with the handle returned by open().
WRITE(10,*) WriteOutBuffer
REWIND(10)
READ(10,*) ReadInBuffer
IF (ReadinBuffer .NE. WriteOutbuffer) THEN
WRITE(*,130) TRIM(FileName)
END IF
CLOSE(10)
WRITE(*,'(X,"FortranMain: Test of USEROPEN Completed")')
9999 CONTINUE
END
!---------------------------------------------------------------
! SUBROUTINE: ParseForFileName
! Takes a full pathname and returns the filename
! with its extension.
!---------------------------------------------------------------
SUBROUTINE ParseForFileName(FullName,FileName)
CHARACTER(255):: FullName
CHARACTER(255):: FileName
INTEGER :: P
618
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
P = INDEX(FullName,'/',.TRUE.)
FileName = FullName(P+1:)
END
//
// File: UserOpen_Sub.c
//
// This routine opens a file using data passed from the Intel(c) Fortran OPEN statement.
//
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <errno.h>
int uopen_ ( char *file_name, /* access read: name of the file to open (null terminated) */
int *open_flags, /* access read: READ/WRITE, see file.h or open(2) */
int *create_mode, /* access read: set if the file is to be created */
int *unit_num, /* access read: logical unit number to be opened */
int filenam_len ) /* access read: number of characters in file_name */
{
/*
** The returned value is the following:
** value != -1 is a valid file descriptor
** value == -1 is returned on an error
*/
int return_value;
return (return_value);
} /* end of uopen_() */
619
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the calling Fortran program, the function named in USEROPEN must first be declared in an EXTERNAL
statement. For example, the following Fortran code might be used to call the USEROPEN procedure UOPEN:
USE IFWIN
IMPLICIT INTEGER (A-Z)
CHARACTER*(FLEN) FILENAME
TYPE(T_SECURITY_ATTRIBUTES), POINTER :: NULL_SEC_ATTR
! Do the CreateFile( ) call and return the status to the Fortran rtl
STS = CreateFile( FILENAME, &
DESIRED_ACCESS, &
SHARE_MODE, &
NULL_SEC_ATTR, &
CREATE_DISP, &
FLAGS_ATTR, &
0 )
UOPEN = STS
RETURN
END
The UOPEN function is declared to use the cdecl calling convention, so it matches the Fortran runtime
library declaration of a USEROPEN routine.
620
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following function definition and arguments are passed from the Fortran runtime Library to the function
named in USEROPEN:
FILENAME Is the address of a null terminated character string that is the name of
the file.
A_NULL Is always null. The Fortran runtime library always passes a NULL for
the pointer to a SECURITY_ATTRIBUTES structure in its
CreateFile( ) call.
CREATE_DISP Is the creation disposition specifying the action to take on files that
exist, and the action to take on files that do not exist. The value is
passed by reference.
FLAGS_ATTR Specifies the file attributes and flags for the file. The value is passed
by reference.
B_NULL Is always null. The Fortran runtime library always passes a NULL for
the handle to a template file in its CreateFile( ) call.
The last 2 arguments are the Fortran unit number and length of the file name:
UNIT Is the Fortran unit number on which this OPEN is being done. The
value is passed by reference.
FLEN Is the length of the file name, not counting the terminating null, and
passed by value.
See Also
OPEN: USEROPEN Specifier
PXFFILENO
621
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Formatted Sequential
• Formatted Direct
• Unformatted Sequential
• Unformatted Direct
• Binary Sequential
• Binary Direct
An example of a program writing three records to a formatted sequential file is given below. The resulting file
is shown in the following figure.
622
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
During output to a formatted direct file, if data does not completely fill a record, the compiler pads the
remaining portion of the record with blank spaces. The blanks ensure that the file contains only completely
filled records, all of the same length. During input, the compiler by default also adds filler bytes (blanks) to
the input record if the input list and format require more data than the record contains.
You can override the default blank padding on input by setting PAD='NO' in the OPEN statement for the file.
If PAD='NO', the input record must contain the amount of data indicated by the input list and format
specification. Otherwise, an error occurs. PAD='NO' has no effect on output.
An example of a program writing two records, record one and record three, to a formatted direct file is given
below. The result is shown in the following figure.
The records in an unformatted sequential file can vary in length. Unformatted sequential files are organized
in chunks of 130 bytes or less called physical blocks. Each physical block consists of the data you send to the
file (up to 128 bytes) plus two 1-byte "length bytes" inserted by the compiler. The length bytes indicate
where each record begins and ends.
A logical record refers to an unformatted record that contains one or more physical blocks. (See the following
figure.) Logical records can be as big as you want; the compiler will use as many physical blocks as
necessary.
623
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When you create a logical record consisting of more than one physical block, the compiler sets the length
byte to 129 to indicate that the data in the current physical block continues on into the next physical block.
For example, if you write 140 bytes of data, the logical record has the structure shown in the following
figure.
The first and last bytes in an unformatted sequential file are reserved; the first contains a value of 75, and
the last holds a value of 130. Fortran uses these bytes for error checking and end-of-file references.
The following program creates the unformatted sequential file shown in the following figure:
624
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following program creates the sample unformatted direct file shown in the following figure:
625
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
To execute a program that uses asynchronous I/O on Linux* or macOS systems, you must explicitly
include one of the following compiler options when you compile and link your program:
• -threads
• -reentrancy threaded
• -qopenmp
On Windows* systems, no extra options are needed to execute a program that uses asynchronous I/O.
626
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• By an explicit WAIT (initno) statement, which performs a wait operation for the specified pending
asynchronous data transfer operation
• By a CLOSE statement for the file
• By a file-positioning statement such as REWIND or BACKSPACE
• By an INQUIRE statement for the file
Use the WAIT statement to ensure that the objects used in the asynchronous data transfer statements are
not prematurely deallocated. This action is especially important for local stack objects and allocatable objects
that may be deallocated before completion of the pending operation. If you do not specify the wait operation,
the program may terminate with an access violation error. The following example shows use of the WAIT
statement:
module mod
real, allocatable :: X(:)
end module mod
subroutine sbr()
use mod
integer :: Y(500)
!X and Y initialization
allocate (X(500))
call foo1(X, Y)
!asynchronous writing
open(1, asynchronous='yes')
write(1, asynchronous='yes') X, Y
!some computation
call foo2()
!wait operation
wait(1)
!X deallocation
deallocate(X)
!stack allocated object Y will be deallocated when the routine returns
end subroutine sbr
You can use the INQUIRE statement with the keyword of ASYNCHRONOUS (ASYNCHRONOUS=specifier) to
determine whether asynchronous I/O is allowed. If it is allowed, a value of YES is returned.
Additionally, you can use the INQUIRE statement with the keyword of PENDING (PENDING= specifier) to
determine whether previously pending asynchronous data transfers are complete.
If an ID= specifier appears and the specified data transfer operation is complete, the variable specified by
PENDING is assigned the value False and the INQUIRE statement performs a wait operation for the specified
data transfer.
If the ID= specifier is omitted and all previously pending data transfer operations for the specified unit are
complete, the variable specified by PENDING is assigned the value False and the INQUIRE statement
performs wait operations for all previously pending data transfers for the specified unit.
Otherwise, the variable specified by PENDING is assigned the value True and no wait operations are
performed. Previously pending data transfers remain pending.
See Also
Asynchronous Specifier (ASYNCHRONOUS=)
OPEN/ASYNCHRONOUS Specifier
INQUIRE/ASYNCHRONOUS Specifier
ASYNCHRONOUS Statement and Attributes
627
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Mixed-Language Programming
Mixed-language programming is the process of building programs in which the source code is written in two
or more languages. It allows you to:
• Call existing code that is written in another language.
• Use procedures that may be difficult to implement in a particular language.
In mixed-language programming, a routine written in one language calls a function, procedure, or subroutine
written in another language. For example, a Fortran program may need to call an existing shared library or
system procedure written in another language.
Although mixed-language programming is possible between Intel® Fortran and other languages, the primary
focus of this section is programming using Intel® Fortran and C. Mixed-language programming between these
languages is relatively straightforward for these reasons:
• Fortran implements functions, subroutines, and procedures in approximately the same way as C.
• Fortran provides many standard features to improve interoperability with C. An entity is considered to be
interoperable if equivalent declarations are possible in both languages. Interoperability is provided for
variables, derived types, and procedures. For more information, see Standard Fortran and C
Interoperability.
module ftn_C_2
interface
integer (C_INT) function C_Library_Function &
(sendbuf, sendcount, recvcounts) &
BIND(C, name='C_Library_Function')
628
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
629
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
void simulation(long alpha, double *beta, long *gamma, double delta[], struct pass *arrays);
C calling sequence example:
NOTE
Existing code using legacy extensions will continue to work; however, if you are writing new code, you
should use the standard syntax.
630
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ISO_C_BINDING
The intrinsic module provides a set of named constants and procedures that can assist you in programming
with mixed languages.
Use the intrinsic module with:
USE, INTRINSIC::ISO_C_BINDING
You have two groups of named constants included in this intrinsic module:
• Constants that hold kind type parameter values for intrinsic types.
631
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Constants that and those that provide a Fortran equivalent to some of the C special characters.
These constants include:
The procedures included in ISO_C_BINDING are all generic, not specific. Aside from C_F_POINTER and
C_F_PROCPOINTER, all of the procedures are pure. They include:
• C_ASSOCIATED
• C_F_POINTER
• C_F_PROCPOINTER
• C_FUNLOC
• C_LOC
• C_SIZEOF
Additionally, ISO_C_BINDING includes the following derived types to interoperate with C pointers:
• C_PTR
• C_FUNPTR
• C_NULL_PTR
• C_NULL_FUNPTR
BIND(C)
Fortran 2003 introduced the language-binding-spec attribute, using the keyword BIND. The syntax is:
BIND(C [, NAME=scalar-default-char-constant-expr])
C is the only language name that you can specify. Generally, an entity with the BIND(C) attribute behaves as
if it were the corresponding entity in the companion C processor.
The optional NAME= specifier allows you to use a different external name than the one the standard
prescribes. The companion C processor does this with the Fortran name forced to lowercase. If the C name
was mixed-case, specify the mixed-case name here without any name decoration, such as leading
underscores. The compiler applies the same decoration the C processor provides. NAME= is not a strict
replacement for the ALIAS attribute extension. This extension is more like ALIAS combined with DECORATE.
BIND(C) is not equivalent to ATTRIBUTES C. Although these both downcase the external name, BIND(C)
does not imply pass-by-value and has other effects that are different from ATTRIBUTES C.
You can specify ATTRIBUTES STDCALL for an interoperable procedure (a procedure whose declaration
includes the BIND(C) language binding attribute). This combination has the following effects for Windows
applications targeting IA-32 architecture:
• The calling mechanism is changed to STDCALL, which affects how the stack is cleaned up on procedure
exit.
• The external name from the BIND attribute is suffixed with @n, where n is the number of bytes to be
removed from the stack on return.
632
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
No other effects from STDCALL, such as pass-by-value, are provided. The Fortran standard VALUE attribute
(not ATTRIBUTES VALUE) may be used if desired. For all other platforms, specifying STDCALL with BIND(C)
has no effect. For more information, see ATTRIBUTES C and STDCALL.
BIND(C) on Procedures
BIND(C) is often used on procedures. It can be specified in INTERFACE blocks to specify the interface of an
external interoperable procedure, and on any Fortran procedures that you want to make interoperable. For
SUBROUTINE and FUNCTION, you need to specify BIND(C) after the argument list. For functions, you can
specify BIND(C) before or after the RESULT clause. For example:
• The external name is what the C compiler would use, with the Fortran name lowercased (unless NAME= is
specified).
• Arguments are passed and received by reference (unless the VALUE attribute is specified for the
argument).
• Only interoperable arguments are allowed.
• No hidden arguments are allowed.
• Function type must be interoperable and function values are returned exactly as the C compiler would
(this mainly affects small derived types).
The standard allows for passing character strings to interoperable procedures. You can pass a character
argument of default kind (kind C_CHAR is the default in Intel® Fortran); the corresponding dummy argument
is an explicit-shape array of single characters. Because no length is passed, you will need to provide the
length another way (usually by appending a NUL character on the end.)
The standard does not provide an easy way to write a Fortran interoperable routine that accepts a string
from C. You must declare the dummy argument as an array of single characters. You can use the
combination of the C_LOC and C_F_POINTER procedures, both defined in intrinsic module ISO_C_BINDING, to
cast a character array argument to a Fortran pointer to a character string. For example:
See Also
BIND
633
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Assumed-Rank
An assumed-rank object is a variable whose rank is assumed from its actual argument. This facilitates
interoperability with C functions that can accept arguments of arbitrary rank. The intrinsic function, RANK,
can be used to obtain the rank of an assumed-rank variable.
A procedure must have an explicit interface if it has an argument that is assumed-rank.
The SHAPE, SIZE, and UBOUND intrinsic functions are defined for an assumed-rank array that is associated
with an assumed-size array.
An assumed-rank argument may correspond to an actual argument of any rank. If the actual argument has
rank zero, the argument has rank zero; the shape is a zero-sized array and the LBOUND and UBOUND intrinsic
functions, with no DIM argument, return zero-sized arrays. If the actual argument has rank greater than
zero, the rank and extents of the argument are assumed from the actual argument, including no final extent
for an assumed-size array. If the actual argument is an array and the argument has the ALLOCATABLE or
POINTER attribute, the bounds of the argument are assumed from the actual argument.
Assumed-Type
An assumed-type object is a variable declared as TYPE(*). This simplifies interoperability with C formal
parameters of type (void *).
An explicit interface is required for a procedure that has an argument that is assumed-type because an
assumed-type argument is polymorphic.
An assumed-type argument must not correspond to an actual argument that is of derived type with type
parameters, type-bound procedures, or final subroutines.
CFI_cdesc
A C descriptor is a C structure of type CFI_cdesc that is defined in the file ISO_Fortran_binding.h.
A variable that is an argument of a procedure that is BIND(C) must be of interoperable type or assumed
type.
A coarray shall not be an argument of a BIND(C) procedure.
The ALLOCATABLE or POINTER attribute must not be specified for a default-initialized argument of a BIND(C)
procedure.
Further Requirements
Variables with the ASYNCHRONOUS attribute can be used for asynchronous communications between Fortran
and C procedures.
634
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When a Fortran procedure that has an INTENT (OUT) allocatable argument is invoked by a C function, and
the actual argument in the C function is the address of a C descriptor that describes an allocated allocatable
variable, the variable is deallocated on entry to the Fortran procedure. When a C function is invoked from a
Fortran procedure via an interface with an INTENT (OUT) allocatable argument, and the actual argument in
the reference to the C function is an allocated allocatable variable, the variable is deallocated on invocation
(before execution of the C function begins).
ISO_Fortran_binding.h
The types, macros, and functions declared in ISO_Fortran_binding.h can be used by a C function to
interpret C descriptors and allocate and deallocate objects represented by C descriptors. These provide a
means to specify a C prototype that interoperates with a Fortran interface that has an allocatable, assumed
character length, assumed-rank, assumed-shape, or data pointer argument.
The ISO_Fortran_binding.h is a C header file that contains these definitions:
• Within a C function, an allocatable object shall be allocated or deallocated only by execution of the
CFI_allocate and CFI_deallocate functions. A Fortran pointer can become associated with a target by
execution of the CFI allocate function.
• Calling CFI_allocate or CFI_deallocate for a C descriptor changes the allocation status of the Fortran
variable it describes and causes the allocation status of any associated allocatable variable to change
accordingly.
• If the address of an object is the value of a formal parameter that corresponds to a nonpointer argument
in a BIND(C) interface, then:
• if the argument has the INTENT (IN) attribute, the object must not be defined or become undefined,
and
635
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• if the argument has the INTENT (OUT) attribute, the object must not be referenced before it is
defined.
• When a Fortran object is deallocated, or execution of its host function is completed, or its association
status becomes undefined, all C descriptors and C pointers to any part of it become undefined, and any
further use of them is undefined behavior.
• A C descriptor whose address is a formal parameter that corresponds to a Fortran argument becomes
undefined on return from a call to the function from Fortran. If the argument does not have either the
TARGET or ASYNCHRONOUS attribute, all C pointers to any part of the object described by the C descriptor
become undefined on return from the call, and any further use of them is undefined behavior.
• When a Fortran object is deallocated, or execution of its host function is completed, or its association
status becomes undefined, all C descriptors and C pointers to any part of it become undefined, and any
further use of them is undefined behavior.
• If the address of a C descriptor is passed as an actual argument to a Fortran procedure, the C lifetime of
the C descriptor shall not end before the return from the procedure call.
• If an object is passed to a Fortran procedure as a nonallocatable, nonpointer argument, its lifetime shall
not end before the return from the procedure call.
• If the lifetime of a C descriptor for an allocatable object that was established by C ends before the
program exits, the object shall be unallocated at that time.
• If a Fortran pointer becomes associated with a C object, the association status of the Fortran pointer
becomes undefined when the lifetime of the C object ends.
See Also
C Structures, Typedefs, and Macros for Interoperability
• void * base_addr: If the object Interoperating with arguments using C descriptors is an unallocated
allocatable variable or a pointer that is disassociated, the value is a null pointer. If the object has zero
size, the value is not a null pointer but is processor-11 dependent. Otherwise, the value is the base
address of the object being described. The base address of a scalar is its C address. The base address of
an array is the C address of the first element in Fortran array element order.
• size_t elem_len: If the object is a scalar, the value is the storage size in bytes of the object; otherwise,
the value is the storage size in bytes of an element of the object.
• int version: The value is the value of CFI_VERSION in the source file ISO_Fortran_binding.h that
defined the format and meaning of this C descriptor when the descriptor was established.
• CFI_rank_t rank: The value is the number of dimensions of the Fortran object being described; if the
object is a scalar, the value is zero.
• CFI_type_t type: The value is the specifier for the type of the object. Each interoperable intrinsic C
type has a specifier. Specifiers are also provided to indicate that the type of the object is an interoperable
structure, or is unknown. The following macros provide values that correspond to each type code specifier.
636
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The value for CFI_type_other is negative and distinct from all other type specifiers.
• CFI_type_struct specifies a C structure that is interoperable with a Fortran derived type; its value is
positive and distinct from all other type specifiers.
• If a C type is not interoperable with a Fortran type and kind supported by the Fortran processor, its
macro evaluates to a negative value.
• Otherwise, the value for an intrinsic type is positive.
• CFI_attribute_t attribute: The value is the value of an attribute code that indicates whether the
object described is allocatable, a data pointer, or a nonallocatable, nonpointer data object. The values are
nonnegative and distinct. The following macros provide values that correspond to each attribute code:
• CFI_attribute_pointer: Specifies a data object with the Fortran POINTER attribute.
637
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The CFI_CDESC_T macro provides the memory for a C descriptor. The address of an entity declared using the
macro is not usable as an actual argument corresponding to a formal parameter of type CFI_cdesc_t *
without an explicit cast.
CFI_index_t is a typedef name for a standard signed integer type capable of representing the result of
subtracting two pointers.
The CFI_MAX_RANK macro has a value equal to the largest rank supported. The typedef CFI_rank_t is a
standard integer type capable of representing the largest supported rank.
The CFI_VERSION macro has a processor-dependent value that encodes the version of the
ISO_Fortran_binding.h source file containing this macro. This value is increased if a new version of the
source file is incompatible with the previous version.
CFI_attribute_t is a typedef name for a standard integer type capable of representing the values of the
attribute codes.
CFI_type_t is a typedef name for a standard integer type capable of representing the values for the
supported type specifiers.
The following macros are used as error codes. The macro CFI_SUCCESS is the integer constant 0. The value
of each macro other than CFI_SUCCESS is nonzero and is different from the values of the other error code
macros.
638
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Interoperating with arguments using C descriptors
Data Types
Fortran and C support many of the same data types, but there are no direct correlations.
One difference is that Fortran has the concept of kinds. C treats these kinds as distinct types. For example,
the Fortran INTEGER. C has integer types that range from short int to long long int, and has specialty
types such as intptr_t. Fortran may not have a corresponding kind. For each interoperable C integer
type, the ISO_C_BINDING declares a named constant (PARAMETER) that gives the kind number for the
implementation's equivalent INTEGER kind.
Consider the simple C int type. This corresponds to INTEGER(C_INT), where C_INT is defined in the
ISO_C_BINDING. In Intel® Fortran, the value is always four, as a C int corresponds with Fortran INTEGER(4).
Other Fortran implementations may use different kind numbers. Using the named constant ensures
portability.
Now consider the C intptr_t type. This integer is large enough to hold a pointer (address). In Intel®
Fortran, this corresponds to INTEGER(C_INTPTR_T). Use INTEGER(4) when building a 32-bit application,
and INTEGER(8) when building a 64-bit application.
Fortran has no unsigned integer types, so there are no constants for C unsigned types. These types are not
interoperable.
If there is a kind of C type that is not supported by the Fortran implementation, the named constant for that
type is defined as -1 and generates a compile-time error if used.
There are constants defined for REAL, COMPLEX, LOGICAL, and CHARACTER. For REAL, the standard offers the
possibility of a C long double type. This is implemented in different ways by various C compilers on various
platforms supported by Intel® Fortran.
• GCC on 32-bit Linux: The long double is an 80-bit floating type, as supported by the X87 instruction
set. It is not supported by Intel® Fortran, so the C_LONG_DOUBLE is -1.
• GCC on macOS: The C_LONG_DOUBLE is defined as 16.
639
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Windows: The long double is treated the same as a double, so the C_LONG_DOUBLE is defined as 8.
• 64-bit Linux: The C_LONG_DOUBLE is defined as 16.
For Intel's DPC++ and C/C++ compilers, long double by default is an 80-bit extended precision
floating-point type. C/C++ files containing long double data types that interoperate with Fortran should
be compiled with the GCC option -mlong-double-128 to force long double variables to 128-bit quad
precision. Intel's Fortran compilers do not support an 80-bit extended precision data type.
NOTE
• Use the constants for kind values and the corresponding types in C to ensure matching.
• In Intel® C/C++ on Linux, a long double can be forced to be a 128-bit IEEE format floating-point
data type using the -mlong-double-128 command line option. On all platforms, Intel® C/C++
supports __float128 in the source code. On Windows, Intel® C/C++ supports the _Quad type in
the source code by using the command line option, /Qoption,cpp,--extended_float_types.
LOGICAL and CHARACTER need special treatment for interoperability. The Fortran standard states that
LOGICAL corresponds to the (ISO_C_BINDING) C _Bool type, and defines a single kind value of C_BOOL,
which is 1 in Intel® Fortran. By default, Intel® Fortran, tests LOGICAL for true/false differently than C does.
Where C uses zero for false and not-zero for true, Intel® Fortran defaults to using -1 (all bits set) as true and
zero as false. If you are going to use LOGICAL types to interoperate with C, specify the option
fpscomp[:]logicals to change the interpretation to be C-like. This is included when using the option
standard-semantics, which is recommended for using Fortran 2003 (or later) features. C does not have
character strings. It has arrays of single characters, and this is how strings in Fortran must be represented.
There is a kind value defined as C_CHAR, which corresponds to the C char type. Only character variables with
a length of one are interoperable. See Procedures for more information.
Derived types can also be interoperable. For additional information and restrictions, see Derived Types.
See Also
Procedures
Derived Types
Scalar Types
The commonly used types are included in the following table. The following applies:
• Integer types in Fortran are always signed. In C, integer types may be specified as signed or unsigned,
but are signed by default.
• The values of C_LONG, C_SIZE_T, C_LONG_DOUBLE, and C_LONG_DOUBLE_COMPLEX are different on
different platforms.
640
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
While there are named constants for all possible C types, every type is not necessarily supported on every
processor. Lack of support is indicated by a negative value for the constant in the module.
For a character type to be interoperable, you must either omit the length type parameter or specify it using a
constant expression with a value of one.
Characters
The C language does not have character strings. Instead, it has arrays of single characters. You must
represent this type of character string in Fortran.
A kind value is defined, C_CHAR, which corresponding to the C char type. However, only character variables
with a length of one (1) are interoperable.
The following shows a Fortran program passing a string to a C routine and the C routine calling a Fortran
routine with a new string.
Fortran program example:
program demo_character_interop
use, intrinsic :: iso_c_binding
implicit none
interface
subroutine c_append (string) bind(C)
character(len=1), dimension(*), intent(in) :: string
end subroutine c_append
end interface
641
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Pointers
For interoperating with C pointers, the module ISO_C_BINDING contains the derived types C_PTR and
C_FUNPTR, which are interoperable with C object and function type pointers, respectively.
These types, as well as certain procedures in the module, provide the mechanism for passing dynamic arrays
between the two languages. Because its elements do not need to be contiguous in memory, a Fortran pointer
target or assumed-shape array cannot be passed to C. However, you can pass an allocated allocatable array
to C, and you can associate an array allocated in C with a Fortran pointer. Additionally, as shown in the
following, you can convert a pointer in C format to one in Fortran format.
Fortran program example:
program demo_c_f_pointer
use, intrinsic :: iso_c_binding
implicit none
interface
function make_array(n_elements) bind(C)
import ! Make iso_c_binding visible here
type(C_PTR) :: make_array
642
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
type(C_PTR) :: cptr_to_array
integer(C_INT), pointer :: array(:) => NULL()
integer, parameter :: n_elements = 3 ! Number of elements
Derived Types
For a derived type to be interoperable with C, you must specify the BIND attribute:
Variables
A scalar Fortran variable is interoperable if its type and type parameters are interoperable, and if it is not a
pointer.
643
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An array Fortran variable is interoperable if its type and type parameters are interoperable, and it has an
explicit shape or assumed size. It interoperates with a C array of the same type, type parameters, and
shape, but with subscripts reversed.
For example, a Fortran array declared as integer :: a(18, 3:7, *) is interoperable with a C array
declared as int b[][5][18].
Scalar variables are interoperable only if the type parameters (kind and length) are interoperable, not a
coarray, do not have the POINTER or ALLOCATABLE attribute, and if character length is not assumed nor
defined by a non-constant expression.
Arrays are interoperable if the base type meets the scalar variable requirements, if they are explicit shape or
assumed-size, and are not zero-sized. Assumed-size arrays are interoperable only with C arrays that have no
size specified. An allocatable array, coarray, or array pointer is not interoperable.
Global Data
A module variable or a common block can interoperate with a C global variable if the Fortran entity uses the
BIND attribute and the members of that entity are also interoperable. Consider the entities c_extern, c2,
com and single in the following module's interoperability example:
module LINK_TO_C_VARS
use, intrinsic :: ISO_C_BINDING
integer(C_INT), BIND(C) :: c_extern
integer(C_LONG) :: c2
BIND(C, name=’myVariable’) :: c2
common /com/ r,s
real(C_FLOAT) :: r,s,t
BIND(C) :: /com/, /single/
common /single/ t
end module LINK_TO_C_VARS
This example can interoperate with the following C external variables:
int c_extern;
long myVariable;
struct {float r, s;} com;
float single;
Accessing global parameters example:
MODULE Examp
integer, BIND(C)::idata(20)
real::rdata(10)
END MODULE
In Fortran, a variable can access a global parameter by using the standard BIND C attribute.
In the above, two external variables are created (the latter with proper case and decoration): idata and
foo_mp_rdata.
Use the BIND attribute to resolve name discrepancies with C, seen in the global variable statement example:
int idata[20]; // declared as global (outside of any function)
Fortran can declare the variable global (COMMON) and other languages can reference it as external, for
example:
! Fortran declaring PI global
real pi_r
COMMON /pi/ pi_r ! Common Block and variable names
BIND(C)::/pi/
644
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Use of BIND(C) above means that the name will be appropriately decorated for the target and made
lowercase. In C, the variable is referenced as an external with the statement:
//C code with external reference to pi
extern float pi;
The global name C references is the name of the Fortran common block (pi), not the name of a variable
within a common block (pi_r). Therefore, you cannot use blank common (unnamed) to make data
accessible between C and Fortran.
COMMON
To reference C structures from Fortran common blocks and vice versa, you must take into account how
common blocks and structures differ in their methods of storing member variables in memory. Fortran places
common block variables into memory in order as close together as possible, with the following rules:
• A single BYTE, INTEGER(1), LOGICAL(1), or CHARACTER variable in common block list begins
immediately following the previous variable or array in memory.
• All other types of single variables begin at the next even address immediately following the previous
variable or array in memory.
• All arrays of variables begin on the next even address immediately following the previous variable or array
in memory, except for CHARACTER arrays which always follow immediately after the previous variable or
array.
• All common blocks begin on a four-byte aligned address.
Because of these rules, you must consider the alignment of C structure elements with Fortran common block
elements. Specifically, you should ensure interoperability either by making all variables exactly equivalent
types and kinds in both languages (using only 4-byte and 8-byte data types in both languages simplifies this)
or by using the C pack pragmas in the C code around the C structure. This makes C data packing compatible
with Fortran data packing.
As an example, suppose your Fortran code has a common block named Really, as shown in the Fortran
example::
USE, INTRINSIC::ISO_C_BINDING
REAL (C_float)::x,y,z(6)
REAL (C_double)::ydbl
COMMON, BIND(C) / Really /x, y, z(6), ydbl
You can access this data structure from your C code with the following external data structures, as shown in
the C example:
#pragma pack(2)
extern struct {
float x, y, z[6];
double ydbl;
} Really;
#pragma pack()
To restore the original packing, you must add #pragma pack() at the end of the C structure.
You can also access C structures from Fortran by creating common blocks that correspond to those
structures. This is the reverse case from that shown above. However, the implementation is the same; after
common blocks and structures have been defined and given a common address (name), and, assuming the
alignment in memory has been accounted for, both languages share the same memory locations for the
variables.
Once you have accounted for alignment and padding, you can give C access to an entire common block or
set of common blocks. Alternatively, you can pass individual members of a Fortran common block in an
argument list, just as you can any other data item.
645
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
BIND C Statement and Attribute: Specifies that an object is interoperable with C and has
external linkage.
Procedures
For a Fortran procedure to be interoperable with C, it must have an explicit interface and be declared with
the BIND attribute, as shown in the BIND interface example:
interface
integer (C_INT) function C_Func(x, y) BIND(C)
use, intrinsic :: ISO_C_BINDING
implicit none
integer (C_INT), value :: x
integer (C_INT) :: y
end function C_Func
end interface
Alternatively, the declaration for y can be specified as a C_PTR passed by value:
Platform Specifics
The topics in this section contain information on platform specific issues that can come up when using mixed-
language programming.
Mixed-Language Issues
There are important differences in Fortran and C/C++ mixed-language programming; argument passing,
naming conventions, and other interface issues must be consistently reconciled between any two languages
to prevent program failure and indeterminate results. However, the advantages of mixed-language
programming often make the extra effort worthwhile.
A summary of major Fortran and C/C++ mixed-language issues:
• Generally, Fortran/C programs are mixed to allow one language to use existing code written in the other.
Either Fortran or C can call the other, so the main routine can be in either language. On Linux and macOS
systems, if Fortran is not the main routine, the -nofor-main compiler option must be specified on the
ifort command line that links the application.
• When the main program is written in Fortran, the Fortran compiler automatically creates any code needed
to initialize the Fortran Runtime Library (RTL). The RTL provides the Fortran environment for input/output
and exception handling. When the main program is written in C/C++, the C main program needs to call
646
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
for_rtl_init_ to initialize the Fortran RTL and for_rtl_finish_ at the end of the C main program to shut down
the Fortran RTL gracefully. With the Fortran RTL initialized, Fortran I/O and error handling will work
correctly even when C/C++ routines are called.
• For mixed-language applications, the Intel® Fortran main program can call subprograms written in C/C++
if the appropriate calling conventions are used.
To use the same Microsoft visual development environment for multiple languages, you must have the
same version of the visual development environment for your languages.
• On Linux and macOS systems, Fortran adds an underscore to the end of external names; C does not.
• Fortran changes the case of external names to lowercase on Linux and macOS and to uppercase on
Windows; C leaves them in their original case.
• By default, Fortran passes data by reference; C by value. In both languages, the other method can be
specified.
NOTE It is possible to override some default Fortran behavior by using BIND(C) specifier. This is the
preferred method. You can also override default Fortran behavior by using ATTRIBUTES and ALIAS.
Compiled objects (.OBJ) and Intel® Visual Fortran, Intel® C++, Intel® Visual Fortran, Intel® C++,
static libraries (.LIB) Microsoft Visual C++* Microsoft Visual C++*
(unmanaged) (unmanaged)
NOTE
Objects and libraries must be link-
compatible and not have conflicting
names in their language support
libraries
647
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Dynamic Link Library (.DLL) Intel® Visual Fortran, Intel® C++, Intel® Visual Fortran, Intel® C++,
Microsoft Visual C++* Microsoft Visual C++* (both
(unmanaged), Microsoft Visual managed and unmanaged),
Basic* (unmanaged), many more Microsoft Visual Basic* (managed
and unmanaged), many others
.NET managed code assembly Microsoft Visual C++ .NET, Intel® Visual Fortran (with
Microsoft Visual Basic .NET, interface generated by Fortran
other .NET languages Module Wizard), .NET languages
See Also
Handling Fortran Array Pointers and Allocatable Arrays
648
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
For 32-bit applications, use of the STDCALL calling convention means that the called procedure
controls the stack. The code to restore the stack resides in the called procedure, so the code needs to
appear only once. For 64-bit applications, the stack adjustment and @n name suffix features of
STDCALL are not used.
The C calling convention makes calling with a variable number of arguments possible. In the C calling
convention, the caller cleans up the stack, so it is possible to write a routine with a variable number of
arguments. Therefore, the return point has the same address relative to the frame pointer, regardless of how
many arguments are actually passed. The calling routine controls the stack, knows how many arguments it
passed, how big they are, and where they reside in the stack. It can skip passing an argument and still keep
track.
You can call routines with a variable number of arguments by including the ATTRIBUTES C option in your
interface to a routine.
Naming Conventions
Naming conventions are as follows:
• A leading (prefix) underscore for Windows operating systems based on IA-32 architecture; no underscores
for Windows operating systems based on other architectures.
• A trailing (postfix) underscore for all Linux operating systems.
• Leading and trailing underscores for all macOS operating systems.
649
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
icl /c cmain.c
ifort cmain.obj forsubs.f90
Intel® Visual Fortran accepts an object file for the main program written in C and compiled by a C compiler.
The compiler compiles the .F90 file and then has the linker create an executable file under the name
CMAIN.EXE using the two object files.
650
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Either compiler (C or Intel® Visual Fortran) can do the linking, regardless of which language the main
program is written in. However, if you use the Intel® Visual Fortran compiler first, you must include
LIBIFCORE.LIB and IFCONSOL.LIB with the C compiler. You may experience some difficulty with the version
of the runtime library used by the C compiler. You may prefer to use the C compiler first or specify your
project settings for both Intel® Visual Fortran and C so there is agreement on the C library to link against.
Ensure that your application links against only one copy of the C library.
If you are using the IDE to build your application, Intel® Visual Fortran uses Fortran and C libraries depending
on the information specified in the Fortran folder in Project > Properties (Project Settings dialog box).
You can also specify linker settings with the Linker folder in the Project Settings dialog box.
In the Fortran folder, within the Libraries property page, the Runtime Library category determines the
libraries selected.
For example, select Debug Multi-threaded DLL in the runtime Library list to specify that DLL (/libs:DLL),
multi-threaded (/threads), and debug (/dbglibs) libraries should be linked against, namely Fortran import
library libifcoremdd.lib and its DLL library libifcoremdd.dll and C/C++ import library msvcrtd.lib
and its DLL library msvcrtd.dll.
A mixed language solution containing a Fortran library project should have Disable Default Library Search
Rules set to No in the IDE. To check this setting, choose Project > Properties and then choose the
Libraries category. If you change the Disable Default Library Search Rules setting to Yes, you will need to
explicitly add the needed runtime libraries to the non-Fortran project. If you are adding libraries explicitly,
make sure you add IFCONSOL.LIB to the libraries of the non-Fortran project. This library is needed to
perform almost any kind of I/O with Intel® Visual Fortran.
When you have a C++ main program and a Fortran library subproject, you need to manually add the library
path to the Intel® Visual Fortran LIB folder. You only need to do this manual add once per user. To add the
path, choose Tools > Options > Projects and Solutions > VC++ Directories. Use the Show
directories for: dropdown item to select Library files. Add the path to the displayed list.
The way Microsoft Visual C++ chooses libraries is also based upon the Project > Properties item, but
within the C/C++ tab. In the Code Generation category, the runtime library item lists the following C
libraries:
Menu Item Selected CL Option or Project Type Default Library Specified in Object
Enabled File
You must take care to choose the same type of runtime libraries in both your Fortran and C project. For
example, if you select Multithreaded DLL in your Fortran project, you must select Multithreaded DLL in your C
project. Otherwise, when your build your mixed Fortran/C application, you will receive errors from the Linker
regarding undefined and/or duplicate symbols.
651
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you are using Microsoft Visual C++ or Intel® C++, the Microsoft Integrated Development Environment can
build mixed Fortran/C applications transparently, with no special directives or steps on your part. You can edit
and browse your C and Fortran programs with appropriate syntax coloring for the language. You need to
place your Fortran source files into a Fortran project and your C/C++ files into a Visual C++ project.
When you debug a mixed Visual C++/Fortran application, the debugger will adjust to the code type as it
steps through: the C or Fortran expression evaluator will be selected automatically based on the code being
debugged, and the stack window will show Fortran data types for Fortran procedures and C data types for C
procedures.
Implementation Specifics
The topics in this section contain information on implementation specific issues.
652
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
653
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Bytes 12 to 15 contain a set of flags used to store information about the array. This includes:
• bit 1 (0x01): array is defined -- set if the array has been defined (storage allocated).
• bit 2 (0x02): no deallocation allowed -- set if the array pointed to cannot be deallocated (that is, it is
an explicit array target).
• bit 3 (0x04): array is contiguous -- set if the array pointed to is a contiguous whole array or slice.
• bit 8 (0x80): set if the array pointed to is ALLOCATABLE.
• Other bits are reserved.
• Bytes 16 to 19 contain the number of dimensions (rank) of the array.
• Bytes 20 to 23 are reserved and should not be explicitly set.
• The remaining bytes contain information about each dimension (up to 31). Each dimension is described by
a set of three 4-byte entities:
• The number of elements (extent).
• The distance between the starting address of two successive elements in this dimension, in bytes.
• The lower bound.
An array of rank one requires three additional 4-byte entities for a total of nine 4-byte entities (6 + 3*1) and
ends at byte 35. An array of rank seven is described in a total of twenty-seven 4-byte entities (6 + 3*7) and
ends at byte 107. Consider the following declaration:
integer,target :: a(10,10)
integer,pointer :: p(:,:)
p => a(9:1:-2,1:9:3)
call f(p)
...
The descriptor for actual argument p would contain the following values:
• Bytes 0 to 3 contain the base address (assigned at runtime).
• Bytes 4 to 7 are set to 4 (size of a single element).
• Bytes 8 to 11 are reserved.
• Bytes 12 to 15 contain 3 (array is defined and deallocation is not allowed).
• Bytes 16 to 19 contain 2 (rank).
• Bytes 20 to 23 are reserved.
• Bytes 24 to 35 contain information for the first dimension, as follows:
• 5 (extent).
• -8 (distance between elements).
• 9 (the lower bound).
• For the second dimension, bytes 36 to 47 contain:
• 3 (extent).
• 120 (distance between elements).
• 1 (the lower bound).
• Byte 47 is the last byte for this example.
NOTE The format for the descriptor on systems using Intel® 64 architecture is identical to that on
systems using IA-32 architecture, except that all fields are 8-bytes long, instead of 4-bytes.
654
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
program FCallsCReturnsCptr
interface
type(C_PTR)function my_croutine1 ( input) bind(c)
import
integer(c_int), value :: input
end function my_croutine1
call my_cprint(my_croutine1(42))
end program
Called C routine example:
#include <stdio.h>
The previous example shows the C code used to call a Fortran routine. The Fortran routine returns a string
that is then printed by the C program. To pass a string back to C from Fortran is simple. The string can be
easily used by the C program because it is null-terminated.
In the previous examples, the following restrictions and behaviors apply:
• The function's length and result do not appear in the call statement; they are added by the compiler.
• The called routine must copy the result string into the location specified by result; it must not copy
more than length characters.
• If fewer than length characters are returned, the return location should be padded on the right with
blanks; Fortran does not use zeros to terminate strings.
• The called procedure is type void.
655
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
#include <stdio.h>
char *GetFortranWords(void);
int main() {
GetFortranWords = C_LOC(returnval)
return
end
Legacy Extensions
The topics in this section contain information on legacy extension issues.
656
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Derived Value, size Value, size Value, size Value, size Value, size
Type dependent dependent dependent dependent dependent
[value]
657
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Case Upper Case Lower Case Lower Case Lower Case Lower Case
(Windows)
Lower Case
(Linux, macOS)
Value The argument value is pushed to the stack. All values are padded to the next 4-byte
boundary.
Reference On systems using IA-32 architecture, the 4-byte argument address is pushed to the stack.
On systems using Intel® 64 architecture, the 8-byte argument address is pushed to the
stack.
658
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
No Len For string arguments, the length of the string is not available to the called procedure.
Descriptor On systems using IA-32 architecture, the 4-byte address of the array descriptor.
On systems using Intel® 64 architecture, the 8-byte address of the array descriptor.
@n On systems using IA-32 architecture, the at sign (@) followed by the number of bytes (in
decimal) required for the argument list.
Size On systems using IA-32 architecture, derived-type arguments specified by value are
dependent passed as follows:
• Arguments from 1 to 4 bytes are passed by value.
• Arguments from 5 to 8 bytes are passed by value in two registers (two arguments).
• Arguments more than 8 bytes provide value semantics by passing a temporary storage
address by reference.
Callee The procedure being called is responsible for removing arguments from the stack before
returning to the caller.
Caller The procedure doing the call is responsible for removing arguments from the stack after
the call is over.
You can use the BIND(C, name=<string>) attribute to resolve discrepancies with C. Alternatively, the
ALIAS option can be used with any other Fortran calling-convention option to preserve mixed-case names.
For Windows operating systems, the compiler option /iface also establishes some default argument passing
conventions. The /iface compiler option has the following choices:
659
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The following applies to Windows: When interfacing to the Windows GUI or making API calls, you will
typically use STDCALL.
See Also
nofor-main compiler option
Error Handling
This section contains information about understanding and handling compile-time and runtime errors.
660
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Diagnostic Meaning
filename Indicates the name of the source file currently being processed.
linenum Indicates the source line where the compiler detects the condition.
severity Indicates the severity of the diagnostic message: Warning, Error, or Fatal error.
NOTE
You can perform compile-time procedure interface checking between routines with no explicit
interfaces present. To do this, generate a module containing the interface for each compiled routine
using the gen-interfaces option and check implicit interfaces using the warn[:]interfaces
compiler option.
661
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can also control the display of diagnostic information with variations of the -diag (Linux* and macOS)
or /Qdiag (Windows*) compiler option. This option accepts numerous arguments and values, allowing you
wide control over displayed diagnostic messages and reports.
Some of the most common variations include the following:
The list items can be one of the keywords warn, remark, or error, a keyword specifying a certain group
(par, vec, driver, cpu-dispatch), or specific diagnostic IDs separated by commas. For more information,
see diag, Qdiag.
Additionally, you can use the following related options:
662
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Comment messages do not terminate translation or linking, they do not interfere with any output files either.
Some examples of the comment messages are:
663
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
2. Press F8. The editor window appears with a marker in the left margin that identifies the line causing
the error. You can continue to press F8 to scroll through additional errors.
After you have corrected any compiler errors reported during the previous build, choose Build project name
from the Build menu. The build engine recompiles only those files that have changed, or which refer to
changed include or module files. If all files in your project compile without errors, the build engine links the
object files and libraries to create your program or library.
You can force the build engine to recompile all source files in the project by selecting Rebuild project name
from the Build menu. This is useful to verify that all of your source code is clean, especially if you are using
a makefile, or if you use a new set of compiler options for all of the files in your project.
When using the IDE:
• Make sure that you have specified the correct path, library, and include directories. For more information,
see Specifying Path Library and Include Directories.
• If a compiler option is not available through Project > Properties in the Intel® Fortran Property pages,
you can type the option in the Command Line category. Use the lower part of the window under
Additional Options, just as you would using the command line. For example, you can enter the linker
option /link /DEFAULTLIB to specify an additional library.
NOTE
If you have a question about a compile-time error, submit your question to the Intel® Fortran forum.
See Also
Specifying Path Library and Include Directories
Supported Environment Variables
warn compiler option
diag, Qdiag compiler option
Runtime Errors
This section contains information about understanding and handling runtime errors.
664
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For instance, the following C shell command sets the FOR_DUMP_CORE_FILE environment variable:
setenv FOR_DUMP_CORE_FILE y
The core file is written to the current directory and can be examined using a debugger.
NOTE
If you requested a core file to be created on severe errors and you do not get one when expected, the
problem might be that your process limit for the allowable size of a core file is set too low (or to zero).
See the man page for your shell for information on setting process limits. For example, the C shell
command limit (with no arguments) will report your current settings, and limit coredumpsize
unlimited will raise the allowable limit to your current system maximum.
See Also
Supported Environment Variables
Runtime Default Error Processing
Runtime Message Display and Format
Values Returned at Program Termination
Methods of Handling Errors
Locate Runtime Errors
List of Runtime Error Messages
Generate Listing and Map Files
Signal Handling
Override the Default Runtime Library Exception Handler
Traceback and related topics
See Also
Runtime Message Display and Format
Values Returned at Program Termination
Locating Runtime Errors
Traceback
Data Representation
665
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Advanced Exception and Termination Handling Considerations
Setting Compiler Options in the Visual Studio* IDE Property Pages
Fortran Console applications Runtime error messages are displayed on the standard
error device (unless redirected).
Fortran QuickWin and Fortran Standard Runtime error messages are displayed in a separate
Graphics applications QuickWin message box.
Severit Description
y
severe Must be corrected. The program's execution is terminated when the error is encountered unless
the program's I/O statements use the END, EOR, or ERR branch specifiers to transfer control,
perhaps to a routine that uses the IOSTAT specifier. (See Using the END EOR and ERR Branch
Specifiers and Using the IOSTAT Specifier and Fortran Exit Codes and Methods of Handling
Errors.)
For severe errors, stack trace information is produced by default, unless environment variable
FOR_DISABLE_STACK_TRACE is set. When that environment variable is set, no stack trace
information is produced.
If compiler option traceback is specified on the command line, the stack trace information
contains program counters set to symbolic information. Otherwise, the information only
contains hexadecimal program counter information.
In some cases stack trace information is also produced by the compiled code at runtime to
provide details about the creation of array temporaries.
error Should be corrected. The program might continue execution, but the output from this execution
might be incorrect.
For errors of severity type error, stack trace information is produced by default, unless the
environment variable FOR_DISABLE_STACK_TRACE is set. When that environment variable is
set, no stack trace information is produced.
If the command line option traceback is specified, the stack trace information contains
program counters set to symbolic information. Otherwise, the information only contains
hexadecimal program counter information.
666
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Severit Description
y
In some cases stack trace information is also produced by the compiled code at runtime to
provide details about the creation of array temporaries.
warning Should be investigated. The program continues execution, but output from this execution might
be incorrect.
For a description of each Intel® Fortran runtime error message, see Runtime Default Error Processing and
related topics.
The following example applies to Linux* and to macOS:
In some cases, stack trace information is produced by the compiled code at runtime to provide details about
the creation of array temporaries.
The following program generates an error at line 12:
program ovf
real*4 x(5),y(5)
integer*4 i
x(1) = -1e32
x(2) = 1e38
x(3) = 1e38
x(4) = 1e38
x(5) = -36.0
do i=1,5
y(i) = 100.0*(x(i))
print *, 'x = ', x(i), ' x*100.0 = ',y(i)
end do
end
The following command line produces stack trace information for the program executable.
x = -1.0000000E+32 x*100.0
= -1.0000000E+34
forrtl: error (72): floating overflow
Image PC Routine Line Source
ovf.exe 08049E4A MAIN__ 14 ovf.f90
ovf.exe 08049F08 Unknown Unknown Unknown
ovf.exe 400B3507 Unknown Unknown Unknown
ovf.exe 08049C51 Unknown Unknown Unknown
Abort
The following suppresses stack trace information because the FOR_DISABLE_STACK_TRACE environment
variable is set.
667
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows* ifcore_msg.dll
ifcore_msg.mc
Windows* irc_msg.dll
irc_msg.mc
Windows* libmUI.dll
libmUI.mc
See Also
Understanding Project Types
Methods of Handling Errors
Runtime Default Error Processing
See Also
Understanding Runtime Errors
668
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• To identify Fortran-specific I/O errors based on the value of Intel® Fortran RTL error codes, use the I/O
status specifier (IOSTAT) in I/O statements (or call the ERRSNS subroutine). See Use the IOSTAT Specifier
and Fortran Exit Codes.
• Obtain system-level error codes by using the appropriate library routines.
• For certain error conditions, use the signal handling facility to change the default action to be taken.
READ (8,50,ERR=400)
If any severe error occurs during execution of this statement, the Intel® Visual Fortran RTL transfers control
to the statement at label 400. Similarly, you can use the END specifier to handle an end-of-file condition that
might otherwise be treated as an error. For example:
READ (12,70,END=550)
When using non-advancing I/O, use the EOR specifier to handle the end-of-record condition. For example:
669
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The value of the (negative) default integer scalar constant IOSTAT_END defined in ISO_FORTRAN_ENV if
no error condition occurs, but an end-of-file condition does occur during the execution of an input
statement.
• For an INQUIRE statement, the value of the default integer constant IOSTAT_INQUIRE_INTERNAL_UNIT
defined in ISO_FORTRAN_ENV if a file-unit-number identifies an internal unit in the execution of the
statement.
• A positive integer value if an error condition occurs. (This value is one of the Fortran-specific IOSTAT
numbers listed in the runtime error message. See List of Runtime Error Messages, which lists the
messages.)
Note that the value assigned to the IOSTAT variable is the same value that would be returned as an exit code
if error termination was initiated.
Following the execution of the I/O statement and assignment of an IOSTAT value, control transfers to the
END=, EOR=, or ERR= statement label, if any. If there is no control transfer, normal execution continues.
The non-standard include file FOR_ISODEF.FOR and the non-standard module FORISODEF contain symbolic
constants for the values returned through an IOSTAT= specifier.
The following example uses the IOSTAT specifier and the module FORIOSDEF to handle an OPEN statement
error (in the FILE specifier).
USE foriosdef
IMPLICIT NONE
CHARACTER(LEN=40) :: FILNM
INTEGER IERR
PRINT *, 'Type file name:'
READ (*,*) FILNM
OPEN (UNIT=1, FILE=FILNM, STATUS='OLD', IOSTAT=IERR, ERR=100)
PRINT *, 'Opening file: ', FILNM
! process the input file
...
CLOSE (UNIT=1)
STOP
100 IF(IERR . EQ. FOR$IOS_FILNOTFOU) THEN
PRINT *, 'File: ', FILNM, ' does not exist '
ELSE
PRINT *, 'Unrecoverable error, code =', IERR
END IF
END PROGRAM
Another way to obtain information about an error is by using the ERRSNS subroutine, which allows you to
obtain the last I/O system error code associated with an Intel® Fortran RTL error.
See Also
List of Runtime Error Messages
IS_IOSTAT_END intrinsic function
IS_IOSTAT_EOR intrinsic function
ERRSNS intrinsic subroutine
670
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The keyword bounds generates code to perform compile-time and runtime checks on array subscript and
character substring expressions. An error is reported if the expression is outside the dimension of the
array or the length of the string.
The keyword uninit generates code for dynamic checks of uninitialized variables. If a variable is read
before written, a runtime error routine will be called.
The keywords noformat and nooutput_conversion reduce the severity level of the associated runtime
error to allow program continuation.
The keyword pointers generates code to test for disassociated pointers and unallocatable arrays.
The following examples show output messages received when the code was specified using option
check[:]pointers.
Examples
The following example shows the message received for an allocatable variable that has not been
allocated:
real, allocatable:: a(:)
!
! A is initially unallocated. To allocate, use:
!
! allocate(a(4))
!
! Because A is unallocated, the next statement will
! issue an error in applications built with "check pointers".
!
a=17
print *,a
end
Output 1:
forrtl: severe (408): fort: (8): Attempt to fetch from allocatable
variable A when it is not allocated
The following example shows the message received for an unassociated pointer:
real, pointer:: a(:)
allocate(a(5))
a=17
print *,a
deallocate(a) ! Once A is deallocated, the next statement
! issues an error in an application built
! with "check pointers".
a=20
print *,a
end
Output 2:
17.00000 17.00000 17.00000 17.00000 17.00000
forrtl: severe (408): fort: (7): Attempt to use pointer A when it is
not associated with a target
The following example shows the message received for a Cray pointer with a zero value:
pointer(p,a)
real, target:: b
!
! P initially has no address assigned to it. To assign an
! address, use:
!
! p=loc(b)
!
671
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Understand Runtime Errors
check compiler option
traceback compiler option
fpe compiler option
warn compiler option
fexceptions compiler option
NOTE
To see the full list of runtime errors, see file ifcore_msg.msg, which is located in the libraries part of
your kit.
For each error shown in the below table of example messages, you will see the error number, the severity
code, error message text, and condition symbol name. Some messages also provide more details about the
error.
To define the condition symbol values (PARAMETER statements) in your program, include the following file:
for_iosdef.for
As described in the table, the severity of the message determines which of the following occurs:
672
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
5 warning (5): requested disposition modified, file not deleted, unit "number", file
"string"
FOR$IOS_REQDISMOD.
673
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
14 info (14): SOURCE length "number" does not equal variable length "number"
FOR$IOS_SOURCELENERR.
674
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
675
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_UNIALROPE. A DEFINE FILE statement specified a logical unit that was already
opened.
NOTE
This error can be returned by STAT in an ALLOCATE or a DEALLOCATE statement.
676
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
50 severe (50): inconsistent key change or duplicate key, unit "number", file "string"
FOR$IOS_INCKEYCHG.
677
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
Note: The ERR transfer is taken after completion of the I/O statement for error number
59. The resulting file status and record position are the same as if no error had occurred.
However, other I/O errors take the ERR transfer as soon as the error is detected, so file
status and record position are undefined.
NOTE
Note: The severity depends on the check[:]keywords option used during the
compilation command. The ERR transfer is taken after completion of the I/O statement
for error numbers 61, 63, 64, and 68. The resulting file status and record position are the
same as if no error had occurred. However, other I/O errors take the ERR transfer as soon
as the error is detected, so file status and record position are undefined.
678
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
Note: The severity depends on the check[:]keywords option used during the
compilation command. The ERR transfer is taken after completion of the I/O statement
for error numbers 61, 63, 64, and 68. The resulting file status and record position are the
same as if no error had occurred. However, other I/O errors take the ERR transfer as soon
as the error is detected, so file status and record position are undefined.
NOTE
The ERR transfer is taken after completion of the I/O statement for error numbers 61, 63,
64, and 68. The resulting file status and record position are the same as if no error had
occurred. However, other I/O errors take the ERR transfer as soon as the error is
detected, so file status and record position are undefined.
NOTE
The ERR transfer is taken after completion of the I/O statement for error numbers 61, 63,
64, and 68. The resulting file status and record position are the same as if no error had
occurred. However, other I/O errors take the ERR transfer as soon as the error is
detected, so file status and record position are undefined.
679
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
680
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
851 info (85): output conversion overflows field, unit "number", file "string"
FOR$IOS_OUTCONOVE.
901 info (90): INQUIRE of internal unit-number is always an error (NOTE: unit identifies a
file)
FOR$IOS_IOSTAT_INTERNAL. The file name specified for an INQUIRE statement is an internal
unit-number.
911 info (91): INQUIRE of internal unit-number is always an error (NOTE: unit does not
identify a file)
FOR$IOS_IOSTAT_INTERNAL_UNIT. The unit number specified for an INQUIRE statement is an
internal unit-number.
94 severe (94): invalid key match specifier for key direction, unit "number", file "string"
FOR$IOS_INVMATKEY .
681
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
97 severe (97): write exceeds the record length of the file, unit "number", file "string"
FOR$IOS_WRIEXCEEDRECL.
98 severe (98): cannot allocate memory for the file buffer - out of memory
FOR_S_NOMEMFORIO. This error often occurs during a file I-O operation such as OPEN, READ,
or WRITE. Either increase the amount of memory available to the program, or reduce its
demand.
101 severe (101): Asynchronous data transfer statement is not allowed to this unit, unit
"number", file "string"
FOR$IOS_AIONOTALLOWED.
102 severe (102): ID value is out of range, unit "number", file "string"
FOR$IOS_IDVALOUT.
103 severe (103): incorrect "string" specifier for connected file, unit "number", file
"string"
FOR$IOS_BADSPEC.
104 severe (104): incorrect "XXXXX=" specifier value for connected file
FOR$IOS_BADSPECVAL. The listed specifier value is invalid for the connected file. Possible
specifier values are one of the following:
• ACTION=
• ASSOCIATEVARIABLE=
• ASYNCHRONOUS=
• BUFFERED=
• DISPOSE=
• FORM=
• IOFOCUS=
• MAXREC=
• MODE=
• ORGANIZATION=
• POSITION=
• RECL=
• RECORDTYPE=
• SHARE=
• STATUS=
• TITLE=
105 severe (105): there is no data-edit-descriptor to match a data-item in the I/O list,
unit "number", file "string"
682
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_NODATAEDIT.
109 info (109): stream data transfer statement is not allowed to an unopened unit
FOR$IOS_SIONOTOPEN. Stream data transfer statement is not allowed to an unopened unit.
110 severe (110): stream data transfer statement is not allowed to this unit, unit
"number", file "string"
FOR$IOS_SIONOTALLOWED.
111 severe (111): position number is outside of the valid range, unit "number", file
"string"
FOR$IOS_POSNUMOUT.
112 severe (112): RECL= specifier may not be applied to stream access file, unit
"number", file "string"
FOR$IOS_STREAMRECL.
113 severe (113): BACKSPACE statement may not be applied to unformatted stream
access file, unit "number", file "string"
FOR$IOS_STREAMBCKSPC.
114 severe (114): A keyword was specified that is not allowed with unformatted I/O; unit
"number", file "string"
FOR$IOS_KWANDUNFMT.
115 severe (115): keyword value error in a CLOSE statement, unit "number", file "string"
FOR$IOS_KEYVALERRCLOSE.
116 severe (116): keyword value error in an I/O statement, unit "number", file "string"
FOR$IOS_KEYVALERRIO.
117 severe (117): If NEWUNIT appears in OPEN statement either FILE or STATUS (with
value SCRATCH) specifier shall appear
FOR$IOS_FILE_OR_SCRATCH.
118 severe (118): The 'RECL=' value in an OPEN statement exceeds the maximum allowed
for the file's record type.
FOR$IOS_MAX_FXD_RECL. The 'RECL=' value in an OPEN statement is too large for the file’s
record type.
683
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
122 severe (122): invalid attempt to assign into a pointer that is not associated
FOR$IOS_UNASSOCPTR. Invalid attempt to assign into a pointer that is not associated.
NOTE
This error can be returned by CMDSTAT in an EXECUTE_COMMAND_LINE statement.
125 severe (125): A derived type variable in this statement requires a DT format specifier
because it has a component that is ALLOCATABLE, POINTER, or PRIVATE, unit
"number", file "string"
FOR$IOS_DT_REQUIRED.
127 severe (127): User Defined I/O procedure returned error <user-iostat, message:
'<user-iomsg>'
FOR$IOS_UDIO_CHILD_IOSTAT_IOMSG. A child I/O action has set the IOMSG and IOSTAT
shown in this message.
129 info (129): User Defined I/O procedure's IOMSG was truncated to fit IOMSG variable
FOR$IOS_UDIO_IOMSG_TRUNCATED. A child I/O action has set IOMSG and IOSTAT. The result
was too large to be held by the parent's IOMSG variable; non-blank text has been truncated.
684
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
1391 severe: (139): Array index out of bounds for index "number"
FOR$IOS_BRK_RANGE2. An array subscript is outside the dimensioned boundaries of that
array. Set the check[:]bounds option and recompile.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
1521 severe (152): Unresolved contention for Intel Fortran RTL global resource
FOR$IOS_RESACQFAI. Failed to acquire an Intel® Fortran RTL global resource for a reentrant
routine. For a multithreaded program, the requested global resource is held by a different
thread in your program. For a program using asynchronous handlers, the requested global
resource is held by the calling part of the program (such as main program) and your
asynchronous handler attempted to acquire the same global resource.
685
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
This error can be returned by STAT in an DEALLOCATE statement.
1551 severe (155): Array index out of bounds for index "number"
FOR$IOS_RANGE2. An array subscript is outside the dimensioned boundaries of that array. Set
the check[:]bounds option and recompile.
686
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
This is an operating system error. See your operating system documentation for more
information.
687
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
1731 severe (173): A pointer passed to DEALLOCATE points to an array that cannot be
deallocated
FOR$IOS_INVDEALLOC2. A pointer that was passed to DEALLOCATE pointed to an explicit
array, an array slice, or some other type of memory that could not be deallocated in a
DEALLOCATE statement. Only whole arrays previous allocated with an ALLOCATE statement
may be validly passed to DEALLOCATE.
NOTE
This error can be returned by STAT in a DEALLOCATE statement.
1751 severe (175): DATE argument to DATE_AND_TIME is too short (LEN=n), required
LEN=8
FOR$IOS_SHORTDATEARG. The number of characters associated with the DATE argument to
the DATE_AND_TIME intrinsic was shorter than the required length. You must increase the
number of characters passed in for this argument to be at least eight characters in length.
Verify that the TIME and ZONE arguments also meet their minimum lengths.
1761 severe (176): TIME argument to DATE_AND_TIME is too short (LEN=n), required
LEN=10
688
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_SHORTTIMEARG. The number of characters associated with the TIME argument to the
DATE_AND_TIME intrinsic was shorter than the required length. You must increase the number
of characters passed in for this argument to be at least ten characters in length. Verify that the
DATE and ZONE arguments also meet their minimum lengths.
1771 severe (177): ZONE argument to DATE_AND_TIME is too short (LEN=n), required
LEN=5
FOR$IOS_SHORTZONEARG. The number of characters associated with the ZONE argument to
the DATE_AND_TIME intrinsic was shorter than the required length. You must increase the
number of characters passed in for this argument to be at least five characters in length. Verify
that the DATE and TIME arguments also meet their minimum lengths.
1791 severe (179): Cannot allocate array - overflow on array size calculation
FOR$IOS_ARRSIZEOVF. An attempt to dynamically allocate storage for an array failed because
the required storage size exceeds addressable memory.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
183 warning (183): FASTMEM allocation is requested but the libmemkind library is not
linked in, so using the default allocator.
FOR$IOS_NOLIBMEMKINDWARN. An allocation requested FASTMEM but the libmemkind library
is not linked into the executable, so memory will be allocated from the default memory
allocator for that platform.
184 severe (184): FASTMEM allocation is requested but the libmemkind library is not
linked into the executable.
FOR$IOS_NOLIBMEMKINDWARN. An allocation request for FASTMEM failed because the
libmemkind library is not linked into the executable.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
185 warning (185): FASTMEM allocation is requested but HBW memory is not available, so
using the default allocator.
689
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
186 severe (186): FASTMEM allocation is requested but HBW memory is not available on
this node.
FOR$IOS_NOLIBMEMKINDWARN. An allocation request for FASTMEM failed because HBW
memory is not available on this node.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
188 severe (188): An assignment was made from an object of one size to an object of a
different size that cannot be deallocated.
FOR$ IOS_INCOMPATIBLE_SIZES. An assignment was made from an object of one size to an
object of a different size that cannot be deallocated.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
189 severe (189): LHS and RHS of an assignment statement have incompatible types.
FOR$ IOS_INCOMPATIBLE_TYPES. The left-hand side (LHS) of an assignment statement is not
type compatible with the right-hand side (RHS) of the assignment statement.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
NOTE
This error can be returned by STAT in an ALLOCATE statement.
193 severe (193): Runtime Check Failure. The variable "string" is being used without
being defined
FOR$IOS_RTC_UNINIT_USE .
1941 severe (194): Runtime Check Failure. The variable "string" is being used in "string"
without being defined.
FOR$IOS_RTC_UNINIT_USE_SRC. The named variable in the named source file is being used
without first being initialized.
690
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
201 severe (201): Intel Pentium fdiv flaw detected, please update the processor
FOR$IOS_FLAWEDPENT.
255 info (255): if a UDIO child sets IOMSG, it must set IOSTAT non-zero, unit "number",
file "string"
FOR$IOS_CHILDSTATMSG.
256 severe (256): Unformatted I/O to unit open for formatted transfers
FOR$IOS_UNFIO_FMT. Attempted unformatted I/O to a unit where the OPEN statement (FORM
specifier) indicated the file was formatted. Check that the correct unit (file) was specified. If the
FORM specifier was not present in the OPEN statement and the file contains unformatted data,
specify FORM='UNFORMATTED' in the OPEN statement. Otherwise, if appropriate, use formatted
I/O (such as list-directed or namelist I/O).
257 severe (257): Formatted I/O to unit open for unformatted transfers
FOR$IOS_FMTIO_UNF. Attempted formatted I/O (such as list-directed or namelist I/O) to a unit
where the OPEN statement indicated the file was unformatted (FORM specifier). Check that the
correct unit (file) was specified. If the FORM specifier was not present in the OPEN statement
and the file contains formatted data, specify FORM='FORMATTED' in the OPEN statement.
Otherwise, if appropriate, use unformatted I/O.
258 severe (258): direct-access I/O to unit open for keyed access, unit "number", file
"string"
FOR$IOS_DIRIO_KEY.
259 severe (259): Sequential-access I/O to unit open for direct access
FOR$IOS_SEQIO_DIR. The OPEN statement for this unit number specified direct access and the
I/O statement specifies sequential access. Check the OPEN statement and make sure the I/O
statement uses the correct unit number and type of access.
260 severe (260): keyed-access I/O to unit open for direct access, unit "number", file
"string"
FOR$IOS_KEYIO_DIR.
265 severe (265): operation requires sequential file organization and access
FOR$IOS_OPEREQSEQ. Attempted to use a BACKSPACE statement on a file whose organization
was not sequential or whose access was not sequential. A BACKSPACE statement can only be
used for sequential files opened for sequential access.
691
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
269 severe (269): Another process has this file locked for shared/exclusive use, unit
"number", file "string"
FOR$IOS_SHAREDCONFLICT.
270 severe (270): A SHARE= lock request in an OPEN statement is incompatible with a
[NO]SHARED specifier and/or the file's open mode, unit "number", file "string"
FOR$IOS_INVALIDLOCKREQUEST.
271 severe (271): a UDIO child routine may not use POS= or REC=, unit "number", file
"string"
FOR$IOS_CHILDNOPOS.
272 severe (272): a UDIO child routine may not set IOSTAT to a negative value other than
-1 or -2, unit "number", file "string"
FOR$IOS_CHILDNEGSTAT.
273 info (273): if a UDIO child sets IOSTAT, it must set IOMSG, unit "number", file
"string"
FOR$IOS_CHILDMSGSTAT.
279 info (279): Image "number" detected some other images had stopped
FOR$IOS_SOME_WERE_STOPPED.
692
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
285 info (285): Image "number" detected some other images had failed
FOR$IOS_SOME_WERE_FAILED.
286 info (286): Image "number" detected some other images had stopped and some had
failed
FOR$IOS_STOPPED_AND_FAILED.
287 info (287): Image "number" could not get an MPI communicator to use
FOR$IOS_NO_COMM. This problem with MPI will prevent formation of a TEAM.
289 info (289): Image "number" was given an invalid new image ID
FOR$IOS_BAD_NEW_IMAGE_ID. This pertains to the FORM TEAM statement.
290 info (290): Image "number" was given a duplicate new image ID
FOR$IOS_DUPLICATE_NEW_ID. This pertains to the FORM TEAM statement.
291 info (291): Image "number" detected new image IDs are not dense
FOR$IOS_NEW_IDS_NOT_DENSE. This pertains to the FORM TEAM statement.
292 info (292): Image "number" detected new image IDs did not start at 1
FOR$IOS_NEW_IDS_NOT_FROM_1. This pertains to the FORM TEAM statement.
295 info (295): Image "number" detected that current team is not active
FOR$IOS_CURRENT_NOT_ACTIVE. This pertains to the FORM TEAM statement. The user tried
an operation which needs the current team to be active, but it isn't.
693
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
301 info (301): Image "number" detected that new team is not active
FOR$IOS_ICAF_NEW_TEAM_ACTIVE.
305 info (305): Image "number" had an internal error, invalid team variable
FOR$IOS_ICAF_BAD_TEAM_VAR.
306 info (306): Image "number" could not define the reduction
FOR$IOS_ICAF_REDUCTION_DEF_FAIL. Pertains to user-defined reduction operations.
307 info (307): Image "number" did not recognize that reduction
FOR$IOS_ICAF_UNKNOWN_REDUCTION. Pertains to user-defined reduction operations.
311 info (311): Image "number" used feature not supported on this architecture
FOR$IOS_ICAF_NOT_SUPPORTED_IA32. Coarray features are not supported on IA-32
architecture for the 2003 Standard or later.
312 info (312): Image "number" had an internal error configuring dynamic memory
FOR$IOS_ICAF_INTERNAL_DYN_CONFIG. Pertains to indirect pointers (one where the pointer is
the address of memory on another image).
313 info (313): Image "number" internal error attaching dynamic memory
FOR$IOS_ICAF_ERROR_DYN_ATTACH. Pertains to indirect pointers (one where the pointer is
the address of memory on another image).
314 info (314): Image "number" internal error detaching dynamic memory
FOR$IOS_ICAF_ERROR_DYN_DETACH. Pertains to indirect pointers (one where the pointer is
the address of memory on another image).
694
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
316 info (316): Image "number" unknown datatype for reduction operator
FOR$IOS_UNKNOWN_FTYPE_REDUCE.
317 info (317): Image "number" non-arithmetic datatype for reduction operator
FOR$IOS_NONARITH_TYPE_REDUCE.
318 info (318): Image "number" (len,root) arguments didn't match image 1's
FOR$IOS_MISMATCHBROADCAST. This pertains to the BROADCAST operation.
319 info (319): Image "number" (len,root, op) arguments didn't match image 1's
FOR$IOS_MISMATCHBROADCAST_OP. This pertains to the BROADCAST operation.
320 error (320): Image "number" ERROR STOP statement is not supported
FOR$IOS_NO_ERROR_STOP.
322 info (322): Environment variable '%s' should be defined to 'YES' or 'NO'
FOR$IOS_ENV_VAR_NEEDS_YES_OR_NO.
323 error (323): Image "number" had internal error in critical region support
FOR$IOS_INTERNAL_ERROR_CRITICAL.
324 error (324): Image "number" could not force unlock of critical region held by failed
image
FOR$IOS_FORCE_UNLOCK_FAIL.
325 error (325): Image "number"; can't do this operation on an inactive team
FOR$IOS_TEAM_NOT_ACTIVE.
327 error (327): Image "number"; mix of default new ids and specified new ids
FOR$IOS_MIXED_DEFAULT_IDS.
328 error (328): Image "number": may not delete or free active team variable
FOR$IOS_TEAM_ACTIVE_NO_FREE.
329 error (329): Image "number": the specified team does not exist
FOR$IOS_NO_SUCH_TEAM.
330 error (330): Image "number": a failed image means a 'hole' in the new image-ids
FOR$IOS_HOLE_IN_IMAGE_IDS.
331 error (331): Image "number": may only change to a team which is the result of FORM
TEAM
FOR$IOS_NOT_FROM_FORM_TEAM.
332 error (332): Image "number": there are no non-failed images for this operation
FOR$IOS_NO_LIVE_IMAGES.
695
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
333 error (333): Image "number": team object has wrong version number
FOR$IOS_BAD_TEAM_VERSION.
335 warning (335): Image "number": the DIM argument "number" to THIS_IMAGE is out-
of-range
FOR$IOS_OUT_OF_COBOUNDS.
399 severe (399): Diagnostic message buffer overflow, hex message number was "hex-
number"
FOR$IOS_MSGBUFOVF.
502 severe (502): Insufficient memory to allocate Fortran RTL message buffer, message
#"number"
FOR$IOS_NO_MEMORY_1.
503 severe (503): Insufficient memory to allocate Fortran RTL message buffer, message
#"number" = hex "hex-number"
FOR$IOS_NO_MEMORY_2.
504 severe (504): FormatMessage failed for system message number "number"
FOR$IOS_MSG_FAILED .
696
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
506 info (506): The allocation of dynamic common "string" of size "string" in procedure
"string" failed
FOR$IOS_ALLOC_DYN_COMM.
508 info (508): The current size of dynamic common "string" is "string"
FOR$IOS_CURR_SIZE_COMM.
509 info (509): The declared size in procedure "string" is "string" bytes
FOR$IOS_DECL_SIZE.
510 info (510): Heap Allocation Failure while creating common "string" in procedure
"string"
FOR$IOS_HEAP_ALLOC.
523 info (523): File name missing or blank - please enter file name
FOR$IOS_NAME_MISSING.
697
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
529 Info (529): Attempt to close a unit which was not open.
FOR$IOS_SYNERRNAM. The unit number specified on a CLOSE statement is not currently open.
530 info (530): FILE= specifier ignored when STATUS has value SCRATCH
FOR$IOS_NAMED_SCRATCH.
531 error (531): SEGMENTED record length includes control bytes, must be greater than
4, unit "number", file "string"
FOR$IOS_SEGINCRLEN.
698
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6104. A real value was too large. Floating-point overflows in either direct or
emulated mode generate NaN (Not-A-Number) exceptions, which appear in the output field as
asterisks (*) or the letters NAN.
551 severe (551): Formatted I/O not consistent with OPEN options
FOR$IOS_F6200. The program tried to perform formatted I/O on a unit opened with
FORM='UNFORMATTED' or FORM='BINARY'.
552 severe (552): List-directed I/O not consistent with OPEN options
FOR$IOS_F6201. The program tried to perform list-directed I/O on a file that was not opened
with FORM='FORMATTED' and ACCESS='SEQUENTIAL'.
553 severe (553): Terminal I/O not consistent with OPEN options
FOR$IOS_F6202. When a special device such as CON, LPT1, or PRN is opened in an OPEN
statement, its access must be sequential and its format must be either formatted or binary. By
default ACCESS='SEQUENTIAL' and FORM='FORMATTED' in OPEN statements.
To generate this error the device's OPEN statement must contain an option not appropriate for
a terminal device, such as ACCESS='DIRECT' or FORM='UNFORMATTED'.
554 severe (554): Direct I/O not consistent with OPEN options
FOR$IOS_F6203. A REC=option was included in a statement that transferred data to a file that
was opened with the ACCESS='SEQUENTIAL' option.
555 severe (555): Unformatted I/O not consistent with OPEN options
FOR$IOS_F6204. If a file is opened with FORM='FORMATTED', unformatted or binary data
transfer is prohibited.
699
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
561 severe (561): Namelist I/O not consistent with OPEN options
FOR$IOS_F6210. The program tried to perform namelist I/O on a file that was not opened with
FORM='FORMATTED' and ACCESS='SEQUENTIAL'.
700
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
701
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6319. The program attempted to DEALLOCATE an array that was never allocated.
702
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6409.
703
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6422. The program tried to transfer data to a file residing on a device (such as a
hard disk) that was out of storage space.
612 severe (612): File not open for reading or file locked
FOR$IOS_F6500. The program tried to read from a file that was not opened for reading or was
locked.
704
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6507. The wrong format was used for the input field for logical data.
The input field for logical data consists of optional blanks, followed by an optional decimal point,
followed by a T for true or F for false. The T or F may be followed by additional characters in
the field, so that .TRUE. and .FALSE. are acceptable input forms.
620 severe (620): Too many bytes read from unformatted record
FOR$IOS_F6508. The program tried to read more data from an unformatted file than the
current record contained. If the program was reading from an unformatted direct file, it tried to
read more than the fixed record length as specified by the RECL option. If the program was
reading from an unformatted sequential file, it tried to read more data than was written to the
record.
705
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
706
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
707
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
663 severe (663): Out of range: substring starting position "pos" is less than 1
FOR$IOS_F6708. A substring starting position must be a positive integer variable or expression
that indicates a position in the string: at least 1 and no greater than the length of the string.
664 severe (664): Out of range: substring ending position "pos" is greater than string
length 'len'
FOR$IOS_F6709. A substring ending position must be a positive integer variable or expression
that indicates a position in the string: at least 1 and no greater than the length of the string.
665 severe (665): Subscript "number" of "string" (value "var") is out of range
('first:last')
FOR$IOS_F6710. The subscript for a substring within a string is not a valid string position: at
least 1 and no greater than the length of the string.
708
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
666 severe (666): Subscript "number" of "string" (value "var") is out of range ('first:*')
FOR$IOS_F6711. The subscript for a substring within a string is not a valid string position: at
least 1 and no greater than the length of the string.
667 severe (667): VECTOR argument to PACK has incompatible character length
FOR$IOS_F6712. The character length of elements in the VECTOR argument to PACK is not the
same as the character length of elements in the array to be packed.
669 severe (669): SOURCE and PAD arguments to RESHAPE have different character
lengths
FOR$IOS_F6714. The character length of elements in the SOURCE and PAD arguments to PACK
must be the same.
671 severe (671): SOURCE too small for specified SHAPE in RESHAPE, and no PAD
FOR$IOS_F6716. If there is no PAD array, the SOURCE argument to RESHAPE must have
enough elements to make an array of the shape specified by SHAPE.
673 severe (673): SHAPE and ORDER arguments to RESHAPE have different sizes ('size1'
and 'size2')
FOR$IOS_F6718. ORDER specifies the order of the array dimensions given in SHAPE, and they
must be vectors of the same size.
674 severe (674): Element "n" of ORDER argument to RESHAPE is out of range (range)
FOR$IOS_F6719. The ORDER argument specifies the order of the dimensions of the reshaped
array, and it must be a permuted list of (1, 2, ..., "n") where "n" is the highest dimension in the
reshaped array.
675 severe (675): Value "n" occurs twice in ORDER argument to RESHAPE
FOR$IOS_F6720. The ORDER vector specifies the order of the dimensions of the reshaped
array, and it must be a permuted list of (1, 2, ..., "n") where "n" is the highest dimension in the
reshaped array. No dimension can occur twice.
677 severe (677): Invalid value "dim" for argument DIM for SPREAD of rank 'rank' source
FOR$IOS_F6722. The argument specified for DIM to SPREAD must be greater than or equal to
1, and less than or equal to one larger than the number of dimensions (rank) of SOURCE.
Consider the following statement:
result = SPREAD (SOURCE= array, DIM = dim, NCOPIES = k)
709
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
In this case, 1 <= dim <= n+ 1, where nis the number of dimensions in array.
682 severe (682): DIM argument ("dim") to CSHIFT is out of range (1:"n")
FOR$IOS_F6727. The optional argument DIM specifies the dimension along which to perform
the circular shift, and must be greater than or equal to 1 and less than or equal to the number
of dimensions in the array to be shifted. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in the array to be shifted.
683 severe (683): Shape mismatch (dimension "dim") between ARRAY and SHIFT in
CSHIFT
FOR$IOS_F6728. The SHIFT argument to CSHIFT must be either scalar or an array one
dimension smaller than the shifted array. If an array, the shape of the SHIFT must conform to
the shape of the array being shifted in every dimension except the one being shifted along.
689 severe (689): VALUES argument to DATE_AND_TIME is too small ("size" elements)
FOR$IOS_F6734. The integer VALUES argument must be a one-dimensional array with a size of
at least eight to hold all returned values.
690 severe (690): Out of range: DIM argument to COUNT has value "dim"
710
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6735. The optional argument DIM specifies the dimension along which to count true
elements of MASK, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in MASK. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in MASK.
691 severe (691): Out of range: DIM argument to COUNT has value "dim" with MASK of
rank "rank"
FOR$IOS_F6736. The optional argument DIM specifies the dimension along which to count true
elements of MASK, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) in MASK. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in MASK.
692 severe (692): Out of range: DIM argument to PRODUCT has value "dim"
FOR$IOS_F6737. The optional argument DIM specifies the dimension along which to compute
the product of elements in an array, and must be greater than or equal to 1 and less than or
equal to the number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the
number of dimensions in array holding the elements to be multiplied.
693 severe (693): Out of range: DIM argument to PRODUCT has value "dim" with ARRAY
of rank "rank"
FOR$IOS_F6738. The optional argument DIM specifies the dimension along which to compute
the product of elements in an array, and must be greater than or equal to 1 and less than or
equal to the number of dimensions (rank) of the array. That is, 1 <= DIM <= "n", where "n"is
the number of dimensions in array holding the elements to be multiplied.
694 severe (694): Out of range: DIM argument to SUM has value "dim" with ARRAY of
rank "rank"
FOR$IOS_F6739. The optional argument DIM specifies the dimension along which to sum the
elements of an array, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) of the array. That is, 1 <= DIM <= "n", where "n"is the number
of dimensions in array holding the elements to be summed.
697 severe (697): Out of range: DIM argument to SUM has value "dim"
FOR$IOS_F6742. The optional argument DIM specifies the dimension along which to sum the
elements of an array, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in array holding the elements to be summed.
698 severe (698): DIM argument ("dim") to EOSHIFT is out of range (1:"n")
FOR$IOS_F6743. The optional argument DIM specifies the dimension along which to perform
an end-off shift in an array, and must be greater than or equal to 1 and less than or equal to
the number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in array holding the elements to be shifted.
699 severe (699): Shape mismatch (dimension "dim") between ARRAY and BOUNDARY in
EOSHIFT
711
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6744. The BOUNDARY argument to EOSHIFT must be either scalar or an array one
dimension smaller than the shifted array. If an array, the shape of the BOUNDARY must
conform to the shape of the array being shifted in every dimension except the one being shifted
along.
701 severe (701): Shape mismatch (dimension "dim") between ARRAY and SHIFT in
EOSHIFT
FOR$IOS_F6746. The SHIFT argument to EOSHIFT must be either scalar or an array one
dimension smaller than the shifted array. If an array, the shape of the SHIFT must conform to
the shape of the array being shifted in every dimension except the one being shifted along.
702 severe (702): BOUNDARY argument to EOSHIFT has wrong LEN ("len1 instead of
len2")
FOR$IOS_F6747. The character length of elements in the BOUNDARY argument and in the
array being end-off shifted must be the same.
703 severe (703): BOUNDARY has LEN "len" instead of "len" to EOSHIFT
FOR$IOS_F6748.
712
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
712 severe (712): SIZE argument ("size") to ISHFTC intrinsic out of range
FOR$IOS_F6757. The argument SIZE must be positive and must not exceed the bit size of the
integer being shifted. The bit size of this integer can be determined with the function BIT_SIZE.
713 severe (713): SHIFT argument ("shift") to ISHFTC intrinsic out of range
FOR$IOS_F6758. The argument SHIFT to ISHFTC must be an integer whose absolute value is
less than or equal to the number of bits being shifted: either all bits in the number being
shifted or a subset specified by the optional argument SIZE.
714 severe (714): Out of range: DIM argument to LBOUND has value "dim"
FOR$IOS_F6759. The optional argument DIM specifies the dimension whose lower bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions in the array. That is, 1 <= DIM <= "n", where "n" is the number of dimensions in
array.
715 severe (715): Out of range: DIM argument ("dim") to LBOUND greater than ARRAY
rank "rank"
FOR$IOS_F6760. The optional argument DIM specifies the dimension whose lower bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
716 severe (716): Out of range: DIM argument to MAXVAL has value "dim"
FOR$IOS_F6761. The optional argument DIM specifies the dimension along which maximum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
717 severe (717): Out of range: DIM argument to MAXVAL has value "dim" with ARRAY of
rank "rank"
FOR$IOS_F6762. The optional argument DIM specifies the dimension along which maximum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number
of dimensions in array.
721 severe (721): Attempt to DEALLOCATE an object which was not allocated
713
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
FOR$IOS_F6766. You cannot deallocate an array unless it has been previously allocated. You
cannot deallocate a pointer whose target was not created by allocation. The intrinsic function
ALLOCATED can be used to determine whether an allocatable array is currently allocated.
714
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
730 severe (730): Out of range: DIM argument to MINVAL has value "dim"
FOR$IOS_F6775. The optional argument DIM specifies the dimension along which minimum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions in the array. That is, 1 <= DIM <= "n", where "n"is the number of
dimensions in array.
731 severe (731): Out of range: DIM argument to MINVAL has value "dim" with ARRAY of
rank "rank"
FOR$IOS_F6776. The optional argument DIM specifies the dimension along which minimum
values are returned, and must be greater than or equal to 1 and less than or equal to the
number of dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n"is the number
of dimensions in array.
715
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
NOTE
RANDOM_SEED can be called with at most one argument at a time.
NOTE
RANDOM_SEED can be called with at most one argument at a time.
743 severe (743): Out of range: DIM argument to UBOUND had value "dim"
FOR$IOS_F6788. The optional argument DIM specifies the dimension whose upper bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions in the array. That is, 1 <= DIM <= "n", where "n" is the number of dimensions in
array.
744 severe (744): DIM argument ("dim") to UBOUND greater than ARRAY rank "rank"
FOR$IOS_F6789. The optional argument DIM specifies the dimension whose upper bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
745 severe (745): Out of range: UBOUND of assumed-size array with DIM==rank ("rank")
FOR$IOS_F6790. The optional argument DIM specifies the dimension whose upper bound is to
be returned.
An assumed-size array is a dummy argument in a subroutine or function, and the upper bound
of its last dimension is determined by the size of actual array passed to it. Assumed-size arrays
have no determined shape, and you cannot use UBOUND to determine the extent of the last
dimension. You can use UBOUND to determine the upper bound of one of the fixed dimensions,
in which case you must pass the dimension number along with the array name.
746 severe (746): Out of range: DIM argument ("dim") to UBOUND greater than ARRAY
rank
FOR$IOS_F6791. The optional argument DIM specifies the dimension whose upper bound is to
be returned, and must be greater than or equal to 1 and less than or equal to the number of
dimensions (rank) in the array. That is, 1 <= DIM <= "n", where "n" is the number of
dimensions in array.
716
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
747 severe (747): Shape mismatch: Dimension "shape" extents are "ext1" and "ext2"
FOR$IOS_F6792.
750 severe (750): DELIM= specifier not allowed for an UNFORMATTED file
FOR$IOS_F6795. The DELIM specifier is only allowed for files connected for formatted data
transfer. It is used to delimit character constants in list-directed an namelist output.
752 severe (752): PAD= specifier not allowed for an UNFORMATTED file
FOR$IOS_F6797. The PAD specifier is only allowed for formatted input records. It indicates
whether the formatted input record is padded with blanks when an input list and format
specification requires more data than the record contains.
717
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
771 severe (771): A SYNC ALL statement could not perform a synchronization of all
images
FOR$IOS_SYNC_ALL_ERR.
772 severe (772): Image number "number" is not a valid image number; valid numbers
are 1 to "number"
718
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
774 severe (774): Image-set array expression must not contain repeated values
FOR$IOS_IMG_SET_REPEATED. A SYNC IMAGES <image-list> statement was attempted. The
<image-list> contains duplicate values. This is not permitted by the standard.
775 severe (775): The lock variable in a LOCK statement is already locked by the
executing image
FOR$IOS_LC_VAR_IS_LOCKED. An attempt was made to use a LOCK statement on a lock.
However, that lock has already been locked by this image.
776 severe (776): The lock variable in an UNLOCK statement is not already locked by the
executing image
FOR$IOS_LC_VAR_NOT_LOCKED. An attempt was made to use an UNLOCK statement on a
lock. However, that lock is currently unlocked; it has not been locked by this image.
777 severe (777): The lock variable in a LOCK statement is already locked by another
image
FOR$IOS_LC_VAR_LOCKED_OTHER_IMAGE. An attempt was made to use a LOCK statement on
a lock. However, that lock is already locked by another image.
778 severe (778): One of the images to be synchronized with has terminated
FOR$IOS_LC_STOPPED_IMAGE. The code has tried to synchronize with a set of images using a
SYNC statement. One of the images to be synchronized with has already terminated.
780 severe (780): The lock variable in an UNLOCK statement is locked by another image
FOR$IOS_LC_VAR_UNLOCKED_OTHER_IMAGE. An attempt was made to use a coarray UNLOCK
operation on a lock. However, that lock is locked by another image.
This may be the result of an error in the program that causes the code to think it has a lock
when it does not.
781 error (781): Only image 1 may read from unit '*'
FOR$IOS_ONLY_IMAGE_L_IO. It is a coarray rule that only image 1 may read from the
'console'.
782 severe (782): One of the images to be synchronized with has failed
FOR$IOS_LC_FAILED_IMAGE. A BARRIER operation was performed and one of the images
failed; the barrier completed with the remaining images.
783 severe (783): The lock variable in an UNLOCK statement is locked by a failed image
FOR$IOS_LC_UNLOCK_FAILED_IMAGE. The UNLOCK has failed.
784 error (784): EOR= must not be specified when the specifier ADVANCE='YES' also
appears
FOR$IOS_EOR_ADVANCE.
785 warning (785): File-path is longer than Intel(r) Fortran limit of 4096
FOR$IOS_FTNPATHLIM.
719
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Numbe Severity Level, Number, and Message Text; Condition Symbol and Explanation
r
Footnotes:
1 Identifies errors not returned by IOSTAT.
Calling the signal routine (specifying the numbers for these signals) results in overwriting the signal-
handling facility set up by the Intel® Fortran RTL. The only way to restore the default action is to save the
returned value from the first call to signal.
When using a debugger, it may be necessary to enter a command to allow the Intel® Fortran RTL to receive
and handle the appropriate signals.
720
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
#include <signal.h>
void clear_signal_() { signal (SIGABRT, SIG_DFL); }
int myabort_() {
abort();
return 0;
}
A call to the clear_signal() local routine must be added to main. Make sure that the call appears before
any call to the local myabort() routine:
program aborts
integer i
call clear_signal()
i = 3
if (i < 5) then
call myabort()
end if
end
721
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O programming errors are not exceptions and cannot be caught by an exception handler. An unhandled I/O
programming error is reported through a different mechanism in the Intel® Visual Fortran runtime system.
Regardless of the application (project) type, unhandled I/O programming error will generate an error
message and traceback output.
See Also
Runtime Message Display and Format
Understanding Runtime Errors
project type
See Also
Establishing Console Event Handlers
722
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
mainCRTStartup() {
C initialization code here
__try {
more initialization code here
mainret = main() /* calls Fortran runtime main() */
exit(mainret)
} __except ( _XcptFilter() )
{ _exit ( GetExceptionCode() ) }
}
In the Fortran runtime system, main() initializes the Fortran runtime system (if not already initialized),
wraps a try-except construct around MAIN__ (the entry point to the Fortran code) with a filter expression
that invokes the Fortran runtime system default handler on exceptions, and calls MAIN__. It also wraps a try-
finally construct around all of this so runtime system clean up gets done (with for_rtl_finish_) when the
program exits. In simplified form, it looks like this:
main() {
__try {
__try {
for_rtl_init()
MAIN__
} __except ( expression-invoking-fortran-default-handler )
{ }
} __finally { for_rtl_finish() }
}
In the Fortran code, symbol MAIN__ is the entry point called by the runtime system's main() routine. MAIN__
has the code to do any further runtime initialization or checks. For example, if the user compiled with the
non-default fpe[:]0 option, there would be a call to FOR_SET_FPE to tell the runtime system how to setup/
react to floating-point exceptions.
723
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The entry point for a QuickWin application is specified as the C library WinMainCRTStartup() routine (see
module crt0.c in the C runtime sources). This gets the C runtime initialized, wraps the Intel® Visual Fortran
defined WinMain() in a try-except construct using the C runtime exception filter (_XcptFilter()) and calls
the Intel® Visual Fortran defined WinMain() routine. In simplified form, it looks like this:
WinMainCRTStartup() {
C initialization code here
__try {
more initialization code here
mainret = WinMain() /* calls qwin library WinMain() */
exit(mainret)
} __except ( _XcptFilter() )
{ _exit ( GetExceptionCode() ) }
}
In the QuickWin library, WinMain() performs some initialization specific to QuickWin, creates a new thread
which begins execution at QWINForkMain, and then sits in a message loop directing the action. The message
loop is wrapped in a try-except-finally construct which invokes the Fortran runtime system default handler if
an exception occurs, and calls for_rtl_finish_ at exit. QWINForkMain() running in the other thread calls the
Fortran runtime system main(), which in turn calls MAIN__. In simplified form, it looks like this:
WinMain() {
Initialization code here
BeginThreadEx (..., QWINForkMain, ... )
__try {
__try {
the message loop...
for_rtl_finish()
return (msg.wParam)
} __except ( expression-invoking-default-fortran-handler )
{ }
} __finally {
for_rtl_finish()
return (msg.wParam)
}
}
QWINForkMain resembles the following:
QWINForkMain() {
main() /* calls the CVF rtl main() which calls MAIN__ */
cleanup and exit...
}
The routines main() and MAIN__ are the same as previously described for a Fortran Console application.
724
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
WinMainCRTStartup() {
C initialization code
__try {
more initialization code
mainret = WinMain() /* calls the user's WinMain() */
exit(mainret)
} __except ( _XcptFilter() )
{ _exit ( GetExceptionCode() ) }
}
The Fortran code contains:
See Also
for_rtl_finish_
FOR_SET_FPE
See Also
Use SIGNALQQ
SIGNALQQ
Handlers for the Application (Project) Types
725
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Custom Handlers for Fortran Console, Fortran QuickWin, and Fortran Standard Graphics
Applications
Fortran Console and Fortran QuickWin (and Fortran Standard Graphics) applications have the full benefit of
the Fortran default exception and error handling processing facilities. You may, however, want to supplement
or replace the default facilities.
726
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ISNAN
FP_CLASS
ALLOCATE
DEALLOCATE
See Also
SIGNALQQ
Default Console Event Handling
727
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Use SIGNALQQ
For lightweight exception handling requirements, a handler established with SIGNALQQ may meet your
needs. This section describes how signal handling with SIGNALQQ works in detail and also how the Fortran
runtime routine GETEXCEPTIONPTRSQQ works.
Reference is made to C runtime sources provided with Microsoft* Visual C++*. The discussion is worth
reviewing even if you do not have Visual C++* available.
728
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STATUS_ACCESS_VIOLATION SIGSEGV
STATUS_ILLEGAL_INSTRUCTION SIGILL
STATUS_PRIVILEGED_INSTRUCTION SIGILL
STATUS_FLOAT_DENORMAL_OPERAND SIGFPE
STATUS_FLOAT_DIVIDE_BY_ZERO SIGFPE
STATUS_FLOAT_INEXACT_RESULT SIGFPE
STATUS_FLOAT_INVALID_OPERATION SIGFPE
STATUS_FLOAT_OVERFLOW SIGFPE
STATUS_FLOAT_STACK_CHECK SIGFPE
STATUS_FLOAT_UNDERFLOW SIGFPE
The value returned by GETEXCEPTIONPTRSQQ can be used in your handler routine to generate a traceback
with TRACEBACKQQ. GETEXCEPTIONPTRSQQ just returns _pxcptinfoptrs. This pointer is only valid while
you are executing within the evaluation of the C runtime filter function _XcptFilter because the exception
information is on the program stack, so do not use GETEXCEPTIONPTRSQQ in any other context.
See Also
GETEXCEPTIONPTRSQQ (W*32)
Handlers for the Application (Project) Types
SIGNALQQ
Language Reference
This document contains the complete description of the Intel® Fortran programming language, which includes
Fortran 2018, Fortran 2008, Fortran 2003, Fortran 95, and Fortran 90. It contains information on language
syntax and semantics, on adherence to various Fortran standards, and on extensions to those standards.
For information about the Fortran standards, visit the Fortran Standards Committee website.
This manual is intended for experienced applications programmers who have a basic understanding of
Fortran concepts and the Standard Fortran language.
Some familiarity with your operating system is helpful. This manual is not a Fortran or programming tutorial.
This document contains the following sections:
729
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
New Language Features Describes any general new features for this release
and points you to summaries of Fortran Standard
features, such as Fortran 2018 features.
New Features for ifx Describes the major new features that have been
added for ifx in this release.
Program Elements and Source Forms Describes Fortran program elements, the Fortran
character set, and source forms.
Data Types, Constants, and Variables Describes intrinsic data types and constants,
derived data types, and variables (scalars, arrays,
and coarrays).
File Operation I/O Statements Summarizes auxiliary I/O statements INQUIRE and
OPEN that you can use to perform file operations,
such as file inquiry, and file connection and
positioning.
730
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Scope and Association Describes scope, which refers to the area in which a
name is recognized, and association, which allows
different names to refer to the same entity in a
particular region of a program.
Deleted and Obsolescent Language Features Describes deleted and obsolescent features
specified in various Fortran standards.
Additional Character Sets Describes the additional character sets that you can
use in programs.
Library Modules and Run-Time Library Routines Summarizes Fortran library modules and the run-
time library routines.
For a summary of Fortran 2018 features in this release, see Fortran 2018 Features.
For a summary of Fortran 2008 features in this release, see Fortran 2008 Features.
For a summary of Fortran 2003 features in this release, see Fortran 2003 Features.
731
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Tells the compiler to use the lld linker. For more information, see fuse-ld.
• New ifx features. For a summary, see New Features for ifx.
For a summary of Fortran 2018 features, see Fortran 2018 Features.
For a summary of Fortran 2008 features, see Fortran 2008 Features.
For a summary of Fortran 2003 features, see Fortran 2003 Features.
For information on new compiler options in this release, see the Release Notes for the product.
For information about the Fortran standards, visit the Fortran Standards Committee website.
For information about the OpenMP* standards, see the OpenMP website.
732
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
733
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
734
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• TEAMS construct
You can now specify a TEAMS construct outside of a TARGET region. For more information about about the
construct, see TEAMS.
• TEAMS LOOP construct
Specifies a shortcut for specifying a LOOP construct inside a TEAMS construct. For more information, see
TEAMS LOOP.
735
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the Language Reference, the information applies to all supported operating systems and architectures
unless it is otherwise labeled.
Program Units
A Fortran program consists of one or more program units. A program unit is usually a sequence of
statements that define the data environment and the steps necessary to perform calculations; it is
terminated by an END statement.
A program unit can be either a main program, an external subprogram, a module, a submodule, or a block
data program unit. An executable program contains one main program, and, optionally, any number of the
other kinds of program units. Program units can be separately compiled.
An external subprogram is a function or subroutine that is not contained within a main program, a module,
a submodule, or another subprogram. It defines a procedure to be performed and can be invoked from other
program units of the Fortran program. Modules, submodules, and block data program units are not
executable, so they are not considered to be procedures. (Modules and submodules can contain module
procedures, though, which are executable.)
Modules contain definitions that can be made accessible to other program units: data and type definitions,
definitions of procedures (called module subprograms), and procedure interfaces. Module subprograms can
be either functions or subroutines. They can be invoked by other module subprograms in the module, or by
other program units that access the module.
A submodule extends a module or another submodule. It can contain the definitions of procedures declared
in a module or submodule.
A block data program unit specifies initial values for data objects in named common blocks. In Standard
Fortran, this type of program unit can be replaced by a module program unit.
Main programs, external subprograms, and module subprograms can contain internal subprograms. The
entity that contains the internal subprogram is its host. Internal subprograms can be invoked only by their
host or by other internal subprograms in the same host. Internal subprograms must not contain internal
subprograms.
The following sections discuss Statements, Names, and Keywords.
See Also
Program Units and Procedures
736
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Statements
Program statements are grouped into two general classes: executable and nonexecutable. An executable
statement specifies an action to be performed. A nonexecutable statement describes program attributes,
such as the arrangement and characteristics of data, as well as editing and data-conversion information.
737
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PUBLIC and PRIVATE statements are only allowed in the scoping units of modules. In Standard Fortran,
NAMELIST statements can appear only among specification statements. However, Intel® Fortran allows them
to also appear among executable statements.
The following table shows other statements restricted from different types of scoping units.
See Also
Scope for details on scoping units
Keywords
A keyword can either be a part of the syntax of a statement (statement keyword), or it can be the name of a
dummy argument (argument keyword). Examples of statement keywords are WRITE, INTEGER, DO, and
OPEN. Examples of argument keywords are arguments to the intrinsic functions.
In the intrinsic function UNPACK (vector, mask, field), for example, vector, mask, and field are argument
keywords. They are dummy argument names, and any variable may be substituted in their place. Dummy
argument names and real argument names are discussed in topic Program Units and Procedures.
Keywords are not reserved. The compiler recognizes keywords by their context. For example, a program can
have an array named IF, read, or Goto, even though this is not good programming practice. The only
exception is the keyword PARAMETER. If you plan to use variable names beginning with PARAMETER in an
assignment statement, you need to use compiler option altparam.
738
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Using keyword names for variables makes programs harder to read and understand. For readability, and to
reduce the possibility of hard-to-find bugs, avoid using names that look like parts of Fortran statements.
Rules that describe the context in which a keyword is recognized are discussed in topic Program Units and
Procedures.
Argument keywords are a feature of Standard Fortran that let you specify dummy argument names when
calling intrinsic procedures, or anywhere an interface (either implicit or explicit) is defined. Using argument
keywords can make a program more readable and easy to follow. This is described more fully in topic
Program Units and Procedures. The syntax statements in the A-Z Reference show the dummy keywords you
can use for each Fortran procedure.
See Also
altparam compiler option
Program Units and Procedures
Names
Names identify entities within a Fortran program unit (such as variables, function results, common blocks,
named constants, procedures, program units, namelist groups, and dummy arguments). In FORTRAN 77,
names were called "symbolic names".
A name can contain letters, digits, underscores ( _ ), and the dollar sign ($) special character. The first
character must be a letter or a dollar sign.
In Fortran 2018 and Fortran 2008, a name can contain up to 63 characters.
The length of a module name (in MODULE and USE statements) may be restricted by your file system.
NOTE
Be careful when defining names that contain dollar signs. A dollar sign can be a symbol for command
or symbol substitution in various shell and utility commands.
In an executable program, the names of the following entities are global and must be unique in the entire
program:
• Program units
• External procedures
• Common blocks
• Modules
Examples
The following examples demonstrate valid and invalid names:
Valid Names
NUMBER
FIND_IT
Invalid Names
5Q Begins with a numeral.
739
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Character Sets
Intel® Fortran supports the following characters:
• The Fortran character set, which consists of the following:
• All uppercase and lowercase letters (A through Z and a through z)
• The numerals 0 through 9
• The underscore ( _ )
• The following special characters:
/ Slash ~ Tilde
: Colon @ Commercial at
• Other printable characters
Printable characters include the tab character (09 hex), ASCII characters with codes in the range 20(hex)
through 7E(hex), and characters in certain special character sets.
Printable characters that are not in the Standard Fortran character set can only appear in comments,
character constants, Hollerith constants, character string edit descriptors, and input/output records.
Uppercase and lowercase letters are treated as equivalent when used to specify program behavior (except in
character constants and Hollerith constants).
See Also
Data Types, Constants, and Variables for further details on character sets and default character
types
ASCII and Key Code Charts for Windows*
740
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Source Forms
Within a program, source code can be in free, fixed, or tab form. Fixed or tab forms must not be mixed with
free form in the same source program, but different source forms can be used in different source programs.
All source forms allow lowercase characters to be used as an alternative to uppercase characters.
Several characters are indicators in source code (unless they appear within a comment or a Hollerith or
character constant). The following are rules for indicators in all source forms:
• Comment indicator
A comment indicator can precede the first statement of a program unit and appear anywhere within a
program unit. If the comment indicator appears within a source line, the comment extends to the end of
the line.
An all blank line is also a comment line.
Comments have no effect on the interpretation of the program unit.
For more information, see comment indicators in free source form, or fixed and tab source forms.
• Statement separator
More than one statement (or partial statement) can appear on a single source line if a statement
separator is placed between the statements. The statement separator is a semicolon character (;).
Consecutive semicolons (with or without intervening blanks) are considered to be one semicolon.
If a semicolon is the first character on a line, the last character on a line, or the last character before a
comment, it is ignored.
• Continuation indicator
A statement can be continued for more than one line by placing a continuation indicator on the line. Intel
Fortran allows at least 511 continuation lines for a fixed or tab source program. Although Standard Fortran
permits up to 256 continuation lines in free-form programs, Intel® Fortran allows up to 511 continuation
lines.
Comments can occur within a continued statement, but comment lines cannot be continued.
For more information, see continuation indicators in free source form, or fixed and tab source forms.
The following table summarizes characters used as indicators in source forms.
Indicators in Source Forms
Source Item Indicator 1 Source Form Position
!, C, or * Fixed In column 1
Tab In column 1
741
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Tab In column 1
1 If the character appears in a Hollerith or character constant, it is not an indicator and is ignored.
2For fixed or tab source form, at least 511 continuation lines are allowed. For free source form, at least
255 continuation lines are allowed.
3 Fixed and tab forms only.
Source form and line length can be changed at any time by using the FREEFORM, NOFREEFORM, or
FIXEDFORMLINESIZE directives. The change remains in effect until the end of the file, or until changed
again.
You can also select free source form by using compiler option free.
Source code can be written so that it is useable for all source forms.
Statement Labels
A statement label (or statement number) identifies a statement so that other statements can refer to it,
either to get information or to transfer control. A label can precede any statement that is not part of another
statement.
A statement label must be one to five decimal digits long; blanks and leading zeros are ignored. An all-zero
statement label is invalid, and a blank statement cannot be labeled.
Labeled FORMAT and labeled executable statements are the only statements that can be referred to by other
statement. FORMAT statements are referred to only in the format specifier of an I/O statement or in an
ASSIGN statement. Two statements within a scoping unit cannot have the same label.
See Also
free compiler option
742
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Some adjacent keywords must have one or more blank characters between them. Others do not require
any; for example, BLOCK DATA can also be spelled BLOCKDATA. The following list shows which keywords
have optional or required blanks:
IN OUT
SELECT CASE
SELECT TYPE
743
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
specified more than once. You cannot specify both IMPURE and PURE. You cannot specify both
NON_RECURSIVE and RECURSIVE.
For information on statement separators (;) in all forms, see Source Forms.
Comment Indicator
In free source form, the exclamation point character (!) indicates a comment if it is within a source line, or a
comment line if it is the first character in a source line.
Continuation Indicator
In free source form, the ampersand character (&) indicates a continuation line (unless it appears in a
Hollerith or character constant, or within a comment). The continuation line is the first noncomment line
following the ampersand. Although Standard Fortran permits up to 256 continuation lines in free-form
programs, Intel® Fortran allows up to 511 continuation lines.
The following shows a continued statement:
See Also
Source Forms for details on the general rules for all source forms
744
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Except in a character context, blanks are not significant and can be used freely throughout the program for
maximum legibility.
Some Fortran compilers use blanks to pad short source lines out to 72 characters. By default, Intel® Fortran
does not. If portability is a concern, you can use the concatenation operator to prevent source lines from
being padded by other Fortran compilers (see the example in "Continuation Indicator" below) or you can
force short source lines to be padded by using compiler option pad-source.
Comment Indicator
In fixed and tab source forms, the exclamation point character (!) indicates a comment if it is within a source
line. It must not appear in column 6 of a fixed form line; that column is reserved for a continuation indicator.
The letter C (or c), an asterisk (*), or an exclamation point (!) indicates a comment line when it appears in
column 1 of a source line.
Continuation Indicator
In fixed and tab source forms, a continuation line is indicated by one of the following:
• For fixed form: Any character (except a zero or blank) in column 6 of a source line
• For tab form: Any digit (except zero) after the first tab
The compiler considers the characters following the continuation indicator to be part of the previous line.
Although Standard Fortran permits up to 19 continuation lines in a fixed-form program, Intel® Fortran allows
up to 511 continuation lines.
If a zero or blank is used as a continuation indicator, the compiler considers the line to be an initial line of a
Fortran statement.
The statement label field of a continuation line must be blank (except in the case of a debugging statement).
When long character or Hollerith constants are continued across lines, portability problems can occur. Use the
concatenation operator to avoid such problems. For example:
CHARACTER*(*) LONG_CONST
PARAMETER (LONG_CONST = 'This is a very long '//
+ 'character constant which is safely continued '//
+ 'across lines')
CHARACTER*100 LONG_VAL
DATA LONG_VAL /LONG_CONST/
Hollerith constants must be converted to character constants before using the concatenation method of line
continuation.
The Fortran Standard requires that, within a program unit, the END statement cannot be continued, and no
other statement in the program unit can have an initial line that appears to be the program unit END
statement. In these instances, Intel Fortran produces warnings when standards checking is requested.
745
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
By default, the compiler treats debugging statements as comments. However, you can specify compiler
option d-lines to force the compiler to treat debugging statements as source text to be compiled.
See Also
Fixed-format lines
Tab-format lines
Source Forms for details on the general rules for all source forms
d-lines compiler option
extend-source compiler option
pad-source compiler option
Fixed-Format Lines
In fixed source form, a source line has columns divided into fields for statement labels, continuation
indicators, statement text, and sequence numbers. Each column represents a single character.
The column positions for each field follow:
Field Column
Continuation indicator 6
By default, a sequence number or other identifying information can appear in columns 73 through 80 of any
fixed-format line in an Intel® Fortran program. The compiler ignores the characters in this field.
If you extend the statement field to position 132, the sequence number field does not exist.
NOTE
If you use the sequence number field, do not use tabs anywhere in the source line, or the compiler
may interpret the sequence numbers as part of the statement field in your program.
See Also
Source Forms
Fixed and Tab Source Forms
extend-source compiler option
Tab-Format Lines
In tab source form, you can specify a statement label field, a continuation indicator field, and a statement
field, but not a sequence number field.
The following figure shows equivalent source lines coded with tab and fixed source form.
746
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The statement label field precedes the first tab character. The continuation indicator field and statement field
follow the first tab character.
The continuation indicator is any nonzero digit. The statement field can contain any Fortran statement. A
Fortran statement cannot start with a digit.
If a statement is continued, a continuation indicator must be the first character (following the first tab) on
the continuation line.
Many text editors and terminals advance the terminal print carriage to a predefined print position when you
press the <Tab> key. However, the Intel® Fortran compiler does not interpret the tab character in this way. It
treats the tab character in a statement field the same way it treats a blank character. In the source listing
that the compiler produces, the tab causes the character that follows to be printed at the next tab stop
(usually located at columns 9, 17, 25, 33, and so on).
NOTE
If you use the sequence number field, do not use tabs anywhere in the source line, or the compiler
may interpret the sequence numbers as part of the statement field in your program.
See Also
Source Forms for details on the general rules for all source forms
Fixed and Tab Source Forms for details on the general rules for fixed and tab source forms
747
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Continuation indicator Use only &. Place in column position 73 of the initial
line and each continuation line, and in column 6 of
each continuation line (no tab character can
precede the ampersand in column 6).
748
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The data type of a variable determines the operations that can be used to manipulate it. Besides intrinsic
operators and operations, you can also define operators and operations.
See Also
Type Declarations
Defined Operations
PARAMETER attribute and statement
Expressions for details on valid operations for data types
749
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For more portable programs, you should not use the forms INTEGER([KIND=]n) or REAL([KIND=]n). You
should instead define a PARAMETER constant using the SELECTED_INT_KIND or SELECTED_REAL_KIND
function, whichever is appropriate. For example, the following statements define a PARAMETER constant for
an INTEGER kind that has 9 digits:
INTEGER, PARAMETER :: MY_INT_KIND = SELECTED_INT_KIND(9)
...
INTEGER(MY_INT_KIND) :: J
...
Note that the syntax :: is used in type declaration statements.
The following sections describe the intrinsic data types and forms for literal constants for each type.
See Also
KIND intrinsic function
Declaration Statements for Noncharacter Types for details on declaration statements for intrinsic
numeric and logical data types
Declaration Statements for Character Types for details on declaration statements for intrinsic
character data types
Expressions for details on operations for intrinsic data types
Data Type Storage Requirements table for details on storage requirements for intrinsic data types
If a kind parameter is specified, the integer has the kind specified. If a kind parameter is not specified,
integer constants are interpreted as follows:
• If the integer constant is within the default integer kind range, the kind is default integer.
• If the integer constant is outside the default integer kind range, the kind of the integer constant is the
smallest integer kind that holds the constant.
Default integer is affected by compiler option integer-size, the INTEGER compiler directive, and the OPTIONS
statement.
The intrinsic inquiry function KIND returns the kind type parameter, if you do not know it. You can use the
intrinsic function SELECTED_INT_KIND to find the kind values that provide a given range of integer values.
The decimal exponent range is returned by the intrinsic function RANGE.
Examples
The following examples show ways an integer variable can be declared.
An entity-oriented example is:
750
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An integer can be used in certain cases when a logical value is expected, such as in a logical expression
evaluating a condition, as in the following:
INTEGER I, X
READ (*,*) I
IF (I) THEN
X = 1
END IF
See Also
Integer Constants
integer-size compiler option
Integer Constants
An integer constant is a whole number with no decimal point. It can have a leading sign and is interpreted as
a decimal number.
Integer constants take the following form:
[s]n[n...][ _k]
Note that compiler option integer-size can affect the KIND type parameter of INTEGER data and integer
constants.
Examples
Valid Integer (base 10) Constants
0
-127
+32123
751
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
47_2
The following seven integers are all assigned a value equal to 3,994,575 decimal:
I = 2#1111001111001111001111
m = 7#45644664
J = +8#17171717
K = #3CF3CF
n = +17#2DE110
L = 3994575
index = 36#2DM8F
The following seven integers are all assigned a value equal to -3,994,575 decimal:
I = -2#1111001111001111001111
m = -7#45644664
J = -8#17171717
K = -#3CF3CF
n = -17#2DE110
L = -3994575
index = -36#2DM8F
You can use integer constants to assign values to data. The following table shows assignments to different
data and lists the integer and hexadecimal values in the data:
LOGICAL(1)X
INTEGER(1)X
X = -128 -128 Z'80'
X = 127 127 Z'7F'
X = 255 -1 Z'FF'
LOGICAL(2)X
INTEGER(2)X
X = 255 255 Z'FF'
X = -32768 -32768 Z'8000'
X = 32767 32767 Z'7FFF'
X = 65535 -1 Z'FFFF'
See Also
Numeric Expressions
integer-size compiler option
752
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL*n
DOUBLE PRECISION
If a kind parameter is specified, the real constant has the kind specified. If a kind parameter is not specified,
the kind is default real.
Default real is affected by compiler options specifying real size and by the REAL directive.
The default KIND for DOUBLE PRECISION is affected by compiler option double-size. If this compiler option is
not specified, default DOUBLE PRECISION is REAL(8).
No kind parameter is permitted for data declared with type DOUBLE PRECISION.
The intrinsic inquiry function KIND returns the kind type parameter. The intrinsic inquiry function RANGE
returns the decimal exponent range, and the intrinsic function PRECISION returns the decimal precision. You
can use the intrinsic function SELECTED_REAL_KIND to find the kind values that provide a given precision
and exponent range.
Examples
The following examples show how real variables can be declared.
An entity-oriented example is:
See Also
General Rules for Real Constants
REAL(4) Constants
REAL(8) or DOUBLE PRECISION Constants
REAL(16) Constants
real-size
753
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
Leading zeros (zeros to the left of the first nonzero digit) are ignored in counting significant digits. For
example, in the constant 0.00001234567, all of the nonzero digits, and none of the zeros, are significant.
(See the following sections for the number of significant digits each kind type parameter typically has).
The exponent represents a power of 10 by which the preceding real or integer constant is to be multiplied
(for example, 1.0E6 represents the value 1.0 * 10**6).
A real constant with no exponent part and no kind type parameter is (by default) a single-precision
(REAL(4)) constant. You can change the default behavior by specifying compiler option fpconstant.
If the real constant has no exponent part, a decimal point must appear in the string (anywhere before the
optional kind parameter). If there is an exponent part, a decimal point is optional in the string preceding the
exponent part; the exponent part must not contain a decimal point.
The exponent letter E denotes a single-precision real (REAL(4)) constant, unless the optional kind parameter
specifies otherwise. For example, -9.E2_8 is a double-precision constant (which can also be written as
-9.D2).
The exponent letter D denotes a double-precision real (REAL(8)) constant.
The exponent letter Q denotes a quad-precision real (REAL(16)) constant.
A minus sign must appear before a negative real constant; a plus sign is optional before a positive constant.
Similarly, a minus sign must appear between the exponent letter (E, D, or Q ) and a negative exponent,
whereas a plus sign is optional between the exponent letter and a positive exponent.
If the real constant includes an exponent letter, the exponent field cannot be omitted, but it can be zero.
To specify a real constant using both an exponent letter and a kind parameter, the exponent letter must be E,
and the kind parameter must follow the exponent part.
See Also
fpconstant compiler option
REAL(4) Constants
A single-precision REAL constant occupies four bytes of memory. The number of digits is unlimited, but
typically only the leftmost seven digits are significant.
IEEE* IEEE binary32 format is used.
Note that compiler option real-size can affect REAL data.
Examples
Valid REAL(4) Constants
3.14159
3.14159_4
621712._4
-.00127
+5.0E3
2E-3_4
754
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
General Rules for Real Constants
real-size compiler option
Compiler Reference > Data and I/O section: Data Representation
Examples
Valid REAL(8) or DOUBLE PRECISION Constants
123456789D+5
123456789E+5_8
+2.7843D00
-.522D-12
2E200_8
2.3_8
3.4E7_8
755
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
General Rules for Real Constants
double-size compiler option
Compiler Reference > Data and I/O section: Data Representation
REAL(16) Constants
A REAL(16) constant has more than four times the accuracy of a REAL(4) number, and a greater range.
A REAL(16) constant occupies 16 bytes of memory. The number of digits that precede the exponent is
unlimited, but typically only the leftmost 33 digits are significant.
IEEE* binary128 format is used.
Examples
Valid REAL(16) Constants
123456789Q4000
-1.23Q-400
+2.72Q0
1.88_16
See Also
General Rules for Real Constants
Compiler Reference > Data and I/O section: Data Representation
If a kind parameter is specified, the complex constant has the kind specified. If no kind parameter is
specified, the kind of both parts is default real, and the constant is of type default complex.
Default real is affected by compiler option real-size and by the REAL directive.
The default KIND for DOUBLE COMPLEX is affected by compiler option double-size. If the compiler option is
not specified, default DOUBLE COMPLEX is COMPLEX(8).
No kind parameter is permitted for data declared with type DOUBLE COMPLEX.
756
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A complex number of any kind is made up of a real part and an imaginary part. The REAL and AIMAG
intrinsic functions return the real and imaginary parts of a complex number respectively. The CMPLX intrinsic
constructs a complex number from two real numbers. The %re and %im complex part designators access the
real and imaginary parts of a complex number respectively.
Examples
The following examples show how complex variables can be declared.
An entity-oriented example is:
COMPLEX(4) cz, cq
DIMENSION(8) cz, cq
The following shows an example of the parts of a complex number:
See Also
General Rules for Complex Constants
AIMAG intrinsic
CMPLX intrinsic
COMPLEX(4) Constants
COMPLEX(8) or DOUBLE COMPLEX Constants
REAL intrinsic
c Is as follows:
• For COMPLEX(4) constants, c is an integer or REAL(4) constant.
• For COMPLEX(8) constants, c is an integer, REAL(4) constant, or
DOUBLE PRECISION (REAL(8)) constant. At least one of the pair
must be DOUBLE PRECISION.
• For COMPLEX(16) constants, c is an integer, REAL(4) constant,
REAL(8) constant, or REAL(16) constant. At least one of the pair
must be a REAL(16) constant.
757
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX(4) Constants
A COMPLEX(4) constant is a pair of integer or single-precision real constants that represent a complex
number.
A COMPLEX(4) constant occupies eight bytes of memory and is interpreted as a complex number.
If the real and imaginary part of a complex literal constant are both real, the kind parameter value is that of
the part with the greater decimal precision.
The rules for REAL(4) constants apply to REAL(4) constants used in COMPLEX constants. (See General Rules
for Complex Constants and REAL(4) Constants for the rules on forming REAL(4) constants.)
The REAL(4) constants in a COMPLEX constant have IEEE* binary32 format.
Note that compiler option real-size can affect REAL data.
Examples
Valid COMPLEX(4) Constants
(1.7039,-1.70391)
(44.36_4,-12.2E16_4)
(+12739E3,0.)
(1,2)
See Also
General Rules for Complex Constants
real-size compiler option
Examples
Valid COMPLEX(8) or DOUBLE COMPLEX Constants
(1.7039,-1.7039D0)
(547.3E0_8,-1.44_8)
758
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
(1.7039E0,-1.7039D0)
(+12739D3,0.D0)
See Also
General Rules for Complex Constants
double-size
COMPLEX(16) Constants
A COMPLEX(16) constant is a pair of constants that represents a complex number. One of the pair must be a
REAL(16) constant, the other can be an integer, single-precision real, double-precision real, or REAL(16)
constant.
A COMPLEX(16) constant occupies 32 bytes of memory and is interpreted as a complex number.
The rules for REAL(16) constants apply to REAL(16) constants used in COMPLEX constants. (See General
Rules for Complex Constants and REAL(16) Constants for the rules on forming REAL(16) constants.)
The REAL(16) constants in a COMPLEX constant have IEEE* binary128 format.
Note that compiler option real-size can affect REAL data.
Examples
Valid COMPLEX(16) Constants
(1.7039,-1.7039Q2)
(547.3E0_16,-1.44)
(+12739D3,0.Q0)
See Also
General Rules for Complex Constants
real-size compiler option
759
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL*n
If a kind parameter is specified, the logical constant has the kind specified. If no kind parameter is specified,
the kind of the constant is default logical.
Examples
The following examples show how logical variables can be declared.
An entity-oriented example is:
See Also
Logical Constants
Logical Constants
A logical constant represents only the logical values true or false, and takes one of the following forms:
.TRUE.[_k]
.FALSE.[_k]
The numeric value of .TRUE. and .FALSE. can be -1 and 0 or 1 and 0 depending on compiler option fpscomp
[no]logicals. Logical data can take on integer data values. Logical data type ranges correspond to their
comparable integer data type ranges. For example, the LOGICAL(2) range is the same as the INTEGER(2)
range.
len Is a string length (not a kind). For more information, see Declaration
Statements for Character Types.
If no kind type parameter is specified, the kind of the constant is default character.
On Windows systems, several Multi-Byte Character Set (MBCS) functions are available to manipulate special
non-English characters.
760
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Character Constants
C Strings
Character Substrings
Character Data Type
Character Constants
A character constant is a character string enclosed in delimiters (apostrophes or quotation marks). It takes
one of the following forms:
[k_]'[ch...]' [C]
[k_]"[ch...]" [C]
ch Is an ASCII character.
Description
The value of a character constant is the string of characters between the delimiters. The value does not
include the delimiters, but does include all blanks or tabs within the delimiters.
If a character constant is delimited by apostrophes, use two consecutive apostrophes ('' ) to place an
apostrophe character in the character constant.
Similarly, if a character constant is delimited by quotation marks, use two consecutive quotation marks ("")
to place a quotation mark character in the character constant.
The length of the character constant is the number of characters between the delimiters, but two consecutive
delimiters are counted as one character.
The length of a character constant must be in the range of 0 to 7188. Each character occupies one byte of
memory.
If a character constant appears in a numeric context (such as an expression on the right side of an arithmetic
assignment statement), it is considered a Hollerith constant.
A zero-length character constant is represented by two consecutive apostrophes or quotation marks.
Examples
Valid Character Constants
"WHAT KIND TYPE? "
''
761
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Declaration Statements for Character Types
\a or \A A bell
\b or \B A backspace
\f or \F A formfeed
\n or \N A new line
\r or \R A carriage return
\t or \T A horizontal tab
\v or \V A vertical tab
\0 A null character
\\ A backslash
If a string contains an escape sequence that isn't in this table, the backslash is ignored.
A C string must also be a valid Fortran string. If the string is delimited by apostrophes, apostrophes in the
string itself must be represented by two consecutive apostrophes ('' ).
For example, the escape sequence \'string causes a compiler error because Fortran interprets the
apostrophe as the end of the string. The correct form is \''string.
If the string is delimited by quotation marks, quotation marks in the string itself must be represented by two
consecutive quotation marks ("").
The sequences \ooo and \xhh allow any ASCII character to be given as a one- to three-digit octal or a one-
to two-digit hexadecimal character code. Each octal digit must be in the range 0 to 7, and each hexadecimal
digit must be in the range 0 to F. For example, the C strings '\010'C and '\x08'C both represent a
backspace character followed by a null character.
The C string '\\abcd'C is equivalent to the string '\abcd' with a null character appended. The string ''C
represents the ASCII null character.
762
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Character Substrings
A character substring is a contiguous segment of a character string. It takes one of the following forms:
v ([e1]:[e2])
a (s [, s] . . . ) ([e1]:[e2])
s Is a subscript expression.
Both e1 and e2 must be within the range 1,2, ..., len, where len is the length of the parent character string.
If e1 exceeds e2, the substring has length zero.
Description
Character positions within the parent character string are numbered from left to right, beginning at 1.
If the value of the numeric expression e1 or e2 is not of type integer, it is converted to integer before use
(any fractional parts are truncated).
If e1 is omitted, the default is 1. If e2 is omitted, the default is len. For example, NAMES(1,3)(:7) specifies
the substring starting with the first character position and ending with the seventh character position of the
character array element NAMES(1,3).
Examples
Consider the following example:
CHARACTER*8 C, LABEL
LABEL = 'XVERSUSY'
C = LABEL(2:7)
LABEL(2:7) specifies the substring starting with the second character position and ending with the seventh
character position of the character variable assigned to LABEL, so C has the value 'VERSUS'.
TYPE ORGANIZATION
INTEGER ID
CHARACTER*35 NAME
END TYPE ORGANIZATION
TYPE(ORGANIZATION) DIRECTOR
CHARACTER*25 BRANCH, STATE(50)
The following are valid substrings based on this example:
763
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Arrays
Array Elements
Structure Components
See Also
Derived-Type Assignment Statements
Defining Generic Operators for details on OPERATOR interfaces
Defining Generic Assignment for details on ASSIGNMENT interfaces
TYPE Statement (Derived Types)
Parameterized Derived-Type Declarations
Records for details on record structures
Default Initialization
Default initialization occurs if initialization appears in a derived-type component definition.
The specified initialization of the component will apply even if the definition is PRIVATE.
Default initialization applies to dummy arguments with INTENT(OUT). It does not imply the derived-type
component has the SAVE attribute.
Explicit initialization in a type declaration statement overrides default initialization.
To specify default initialization of an array component, use a constant expression that includes one of the
following:
• An array constructor
• A single scalar that becomes the value of each array element
Pointers can have an association status of associated, disassociated, or undefined. If no default initialization
status is specified, the status of the pointer is undefined. To specify disassociated status for a pointer
component, use =>NULL( ). To default initialize a pointer component as associated with the target T, use =>
T.
Examples
You do not have to specify initialization for each component of a derived type. For example:
TYPE REPORT
CHARACTER (LEN=20) REPORT_NAME
INTEGER DAY
764
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE MGR_REPORT
TYPE (REPORT) :: STATUS = NOV_REPORT
INTEGER NUM
END TYPE MGR_REPORT
TYPE (MGR_REPORT) STARTUP
In this case, the STATUS component of STARTUP gets its initial value from NOV_REPORT, overriding the
initialization for the YEAR component.
See Also
Initialization expressions
765
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example defines a type that represents a list of procedures with the same interface, which can
be called at some future time:
TYPE PROCEDURE_LIST
PROCEDURE (PROC_INTERFACE), POINTER :: PROC
TYPE (PROCEDURE_LIST), POINTER :: NEXT => NULL()
END TYPE PROCEDURE_LIST
ABSTRACT INTERFACE
SUBROUTINE PROC_INTERFACE
...
END SUBROUTINE PROC_INTERFACE
END INTERFACE
A procedure pointer can be pointer-assigned to a procedure pointer variable, invoked directly, or passed as
an actual argument. For example:
Type-Bound Procedures
In a derived-type definition, you can optionally specify a type-bound-procedure-part, which consists of a
CONTAINS statement, optionally followed by a PRIVATE statement, and one or more procedure binding
statements. Specific, GENERIC, and FINAL procedure bindings are defined below.
A type-bound-procedure-part in a derived-type definition declares one or more type-bound procedures. It
takes the following form:
CONTAINS
[PRIVATE]
proc-binding-stmt
[ proc-binding-stmt]...
specific-binding
A specific type-bound procedure binds a procedure to a type or it specifies a deferred binding to an abstract
type. It takes the following form:
PROCEDURE (interface-name), binding-attr-list :: binding-name [, binding-name]...
PROCEDURE [ [ , binding-attr-list ] :: ] binding-name [ => procedure-name ] [, [binding-name [ =>
procedure-name]]…]
interface-name (Optional) Is the interface for the procedure. It must be the name of an abstract
interface or a procedure that has an explicit interface. interface-name can only
be specified if the binding has the DEFERRED attribute.
binding-attr-list (Optional) Is one or more of the following. The same attribute can only appear
once for the same binding:
766
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• PASS [ (arg-name)]
Defines the "passed-object dummy argument" of the procedure. If arg-name
is specified, the interface of the binding must have a dummy argument named
arg-name.
• NOPASS
Indicates that the procedure has no passed-object dummy argument. Use this
keyword if the procedure pointer component has an implicit interface or has
no arguments. PASS and NOPASS can not both be specified for the same
binding.
• access-spec
Is the PUBLIC or PRIVATE attribute.
• NON_OVERRIDABLE
Determines whether a binding can be overridden in an extended type. You
must not specify NON_OVERRIDABLE for a binding with the DEFERRED
attribute.
• DEFERRED
Indicates that the procedure is deferred. Deferred bindings must only be
specified for derived-type definitions with the ABSTRACT attribute. A
procedure with the DEFERRED binding attribute must specify an interface-
name. An overriding binding can have the DEFERRED attribute only if the
binding it overrides is deferred. The NON_OVERRIDABLE and DEFERRED
binding attributes must not both be specified for the same procedure.
binding-name Is the name of the type-bound procedure. It is referred to in the same way as a
component of a type.
procedure-name (Optional) Is the name of the actual procedure which implements binding-name.
It is the name of an accessible module procedure or an external procedure that
has an explicit interface. It defines the interface for the procedure, and the
procedure to be executed when the procedure is referenced.
If neither =>procedure-name nor interface-name appears, the procedure-name
is the same as the binding-name. If =>procedure-name appears, you must
specify the double-colon separator and you must not specify an interface-name.
In general, the invoking variable, the passed-object dummy argument, is passed as an additional argument.
By default, this is the first dummy argument of the actual procedure. So, the first argument in the argument
list becomes the second argument, etc.
A passed-object dummy argument can be changed by declaring the type-bound procedure with the
PASS(arg-name) attribute. In this case, the variable is passed as the named argument. The PASS attribute
can also be used to confirm the default as the first argument. The NOPASS attribute prevents passing the
object as an argument.
Consider the following:
TYPE MY_TYPE
... ! Component declarations
CONTAINS
PROCEDURE :: PROC1 => MY_PROC
PROCEDURE :: PROC2, PROC3 => MY_PROC3
PROCEDURE :: PROC4 => MY_PROC4, PROC5 => MY_PROC5
END TYPE MY_TYPE
This binds MY_PROC with the PROC1.
If B is a scalar variable of type MY_TYPE, an example of a type-bound call is:
CALL B%PROC1(C, D)
767
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When PASS is in effect, the call passes B to the first argument of the procedure, C to the second argument,
and D to the third argument.
generic-binding
A generic type-bound procedure defines a generic interface that is bound to the type. For more information,
see the GENERIC statement.
final-binding
An extensible derived type can have one or more "final subroutines" associated with it. A final subroutine can
be executed to perform clean-up operations after a data entity of that type is finalized (ceases to exist). For
more information, see the FINAL statement.
See Also
TYPE
Passed-Object Dummy Arguments
PROCEDURE statement
Type Extension
Type extension lets you create new derived types by extending pre-existing derived types.
Any derived type can be extended using the EXTENDS keyword, except for types with the SEQUENCE or
BIND(C) attributes. SEQUENCE types and BIND(C) types (as well as intrinsic types) are non-extensible.
The extended type either inherits or overrides each type-bound procedure of the parent type. An overriding
procedure must be compatible with the parent procedure; in particular, each dummy argument must have
the same type except for the passed-object dummy argument which must have the new type. A type-bound
procedure that is declared to be NON_OVERRIDABLE cannot be overridden during type extension.
The extended type inherits all the components and parameters of the parent type and they are known by the
same name. The extended type can also specify additional components.
For example, consider the following derived-type definition:
TYPE PERSON_INFO
INTEGER :: AGE
CHARACTER (LEN = 60) :: NAME
END TYPE PERSON_INFO
Derived type PERSON_INFO (the parent type) can be extended to create a new type as follows:
TYPE, EXTENDS (PERSON_INFO) :: EMPLOYEE_DATA
INTEGER :: ID
REAL :: SALARY
END TYPE EMPLOYEE_DATA
Extended type EMPLOYEE_DATA inherits all the components in type PERSON_INFO, as well as additional
components ID and SALARY.
See Also
TYPE
Passed-Object Dummy Arguments
kind-selector (Optional) Is one of the kind type parameter numbers allowed for integer data
types. For more information, see Integer Data Types.
768
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
type-param-name Is the name of the type parameter. Each type-param-name must match one of
the type-param-name parameters listed in the derived TYPE statement.
If init-spec is specified, the type parameter has a default value that is specified by the expression init-spec. If
necessary, the value of init-spec is converted to an integer value of the same kind as the type parameter in
accordance with the rules of intrinsic assignment.
Explicit values for the type parameters are normally specified when an object of the parameter type is
declared.
Within the type definition, kind type parameters may be used in constant expressions and specification
expressions. Length type parameters may be used in specification expressions but not in constant
expressions. The type parameters need not be used anywhere in the derived type.
Kind type parameters also participate in generic resolution Unambiguous Generic Procedure References. A
single generic can include two specific procedures that have interfaces distinguished only by the value of a
kind type parameter of a dummy argument.
An explicit interface is required if a parameterized derived type is used as a dummy argument. In a SELECT
TYPE construct, the kind type parameter values of a type guard statement must be the same as those of the
dynamic type of the selector. A BIND(C) type and a SEQUENCE type must not have type parameters.
Advantages to Using This Feature
Adding type parameters to a derived type allows you to declare objects of similar types that differ depending
on the kind and length parameters used in the object declaration. For example, the type definition matrix
below has two type parameters, a kind parameter k and a length parameter b.
TYPE matrix ( k, b )
INTEGER, KIND :: k = 4
INTEGER (8), LEN :: b
REAL (k) :: element (b,b)
END TYPE matrix
The user can declare a matrix named square of 10 by 10 elements of REAL(8) with the following declaration:
See Also
Parameterized TYPE Statements
SELECT TYPE
SEQUENCE
769
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A type-param-spec-list must appear only if the type is parameterized. There must be at most one type-
param-spec corresponding to each parameter of the type. If a type parameter does not have a default value,
there must be a type-param-spec corresponding to that type parameter.
The following topics in this section include cumulative examples demonstrating various kinds of
parameterized TYPE statements.
Examples
Consider the following:
See Also
Parameterized Derived-Type Declarations
derived-type-spec Is a derived type-spec. See Type Declarations for details on derived type
specifications.
Example
Matrix (kind (0.0),1,3) :: my_matrix
my_matrix = matrix (kind (0.0),1,3) ([1.0,2.0,3.0])
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
770
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Structure Constructors
Examples
Consider the following:
Type :: t1 (k1,k2)
Integer, kind :: k1,k2
Real(k1) :: a(k2)
End type
The type parameter order for type t2 is k1, then k2, then k3.
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
771
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Deferred type parameters of functions, including function procedure pointers, have no values. Instead, they
indicate that those type parameters of the function result will be determined by execution of the function, if it
returns an allocated allocatable result or an associated pointer result.
If an ALLOCATE statement specifies a derived type object with deferred type parameters, it must either have
the derived-type specification or a source-expr (a scalar expression). The kind type parameter values and the
non-deferred length type parameter values in the derived-type specification or source-expr must be the
same as the corresponding values of the derived type object.
TYPE(matrix(k=KIND(0.0), d1= 100, d2= :)), pointer :: my_mtrx_alloc
TYPE(matrix(KIND(0.0), 1, 2)) :: my_mtrx_src
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
ALLOCATE
ALLOCATABLE
POINTER - Fortran
! d1 here is assumed and its value '10' is obtained from the actual argument
Type(matrix(k= KIND(0d0), d1=*, d2=:), pointer :: x(:)
ALLOCATE(matrix(KIND(0.0), *, 10) :: x(10))
...
End Subroutine
All length type parameters of the dummy argument must be assumed for a final subroutine. All length type
parameters of the first dummy argument to a user-defined I/O subroutine must be assumed. All of the length
type parameters of a passed-object dummy argument must be assumed. In a SELECT TYPE construct, each
length type parameter in a type-guard-stmt must be assumed.
Array Constructors
If type-spec in an array constructor specifies a parameterized derived type, all ac-value expressions in the
array constructor must be of that derived type and must have the same kind type parameter values as
specified by type-spec. Also, type-spec specifies the declared type and type parameters of the array
constructor.
Each ac-value expression in the array constructor must be compatible with intrinsic assignment to a variable
of this type and type parameter. Each value is converted to the type parameters of the array constructor in
accordance with the rules of intrinsic assignment.
If type-spec is omitted, each ac-value expression in the array constructor must have the same length type
parameters; in which case, the declared type and type parameters of the array constructor are those of the
ac-value expressions.
772
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL(selected_real_kind(10,20)) :: z(100)
..
PRINT *,z%kind ! A single value is printed
This is same as calling KIND(z). However, the type parameter inquiry can be used even when the intrinsic
function is not available.
See Also
Parameterized Derived-Type Declarations
Parameterized TYPE Statements
SELECT TYPE
Structure Components
A reference to a component of a derived-type structure takes the following form:
parent [(s-list)] [image-selector] [%component [(s-list)] [image-selector]] ... %component [(s-list)] [image-
selector]
parent Is the name of a scalar or array of derived type. The percent sign (%)
is called a component selector.
s-list Is a list of one or more subscripts. If the list contains subscript triplets
or vector subscripts, the reference is to an array section.
Each subscript must be a scalar integer (or other numeric) expression
with a value that is within the bounds of its dimension.
The number of subscripts in any s-list must equal the rank of the
immediately preceding parent or component.
773
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
Each parent or component (except the rightmost) must be of derived type.
The parent or one of the components can have nonzero rank (be an array). Any component to the right of a
parent or component of nonzero rank must not have the POINTER attribute.
The rank of the structure component is the rank of the part (parent or component) with nonzero rank (if
any); otherwise, the rank is zero. The type and type parameters (if any) of a structure component are those
of the rightmost part name.
The structure component must not be referenced or defined before the declaration of the parent object.
If the parent object has the INTENT, TARGET, or PARAMETER attribute, the structure component also has the
attribute.
If the rightmost component is of type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING, or of
type TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV, each parent or component must not have an
image-selector.
Examples
The following example shows a derived-type definition with two components:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
The following shows how to declare CONTRACT to be of type EMPLOYEE:
TYPE(EMPLOYEE) :: CONTRACT
Note that both examples started with the keyword TYPE. The first (initial) statement of a derived-type
definition is called a derived-type statement, while the statement that declares a derived-type object is called
a TYPE statement.
The following example shows how to reference component ID of parent structure CONTRACT:
CONTRACT%ID
The following example shows a derived type with a component that is a previously defined type:
TYPE DOT
REAL X, Y
END TYPE DOT
....
TYPE SCREEN
TYPE(DOT) C, D
END TYPE SCREEN
The following declares a variable of type SCREEN:
TYPE(SCREEN) M
Variable M has components M%C and M%D (both of type DOT); M%C has components M%C%X and M%C
%Y of type REAL.
The following example shows a derived type with a component that is an array:
TYPE CAR_INFO
INTEGER YEAR
CHARACTER(LEN=15), DIMENSION(10) :: MAKER
CHARACTER(LEN=10) MODEL, BODY_TYPE*8
REAL PRICE
774
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END TYPE
...
TYPE(CAR_INFO) MY_CAR
Note that MODEL has a character length of 10, but BODY_TYPE has a character length of 8. You can assign a
value to a component of a structure; for example:
MY_CAR%YEAR = 1985
The following shows an array structure component:
MY_CAR%MAKER
In the preceding example, if a subscript list (or substring) was appended to MAKER, the reference would not
be to an array structure component, but to an array element or section.
Consider the following:
MY_CAR%MAKER(2) (4:10)
In this case, the component is substring 4 to 10 of the second element of array MAKER.
Consider the following:
TYPE CHARGE
INTEGER PARTS(40)
REAL LABOR
REAL MILEAGE
END TYPE CHARGE
TYPE(CHARGE) MONTH
TYPE(CHARGE) YEAR(12)
Some valid array references for this type follow:
TYPE NUMBER
INTEGER NUM
END TYPE
A type such as this can be used to construct linked lists of objects of type NUMBER. Note that the pointers
are given the default initialization status of disassociated.
The following example shows a private type:
775
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example shows how to dereference an array of structures with a coarray structure component
that is a real array:
TYPE REAL_ARRAY
REAL,ALLOCATABLE :: RA(:)
END TYPE
TYPE CO_ARRAY
TYPE(REAL_ARRAY) :: CA[*]
END TYPE
TYPE STRUCT
TYPE(CO_ARRAY) :: COMP
END TYPE
ALLOCATE(ARRAY(5,10)%COMP%CA%RA(10))
ARRAY(5,10)%COMP%CA[5]%RA(:) = 0
See Also
Array Elements for details on references to array elements
Array Sections for details on references to array sections
Modules and Module Procedures for examples of derived types in modules
Structure Constructors
A structure constructor lets you specify scalar values of a derived type. It takes the following form:
d-name (comp-spec)
data-target Is a data pointer component. It must have the same rank as its
corresponding component.
Description
A structure constructor must not appear before its derived type is defined.
776
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If keyword= appears, any expr is assigned to the component named by the keyword. If keyword= is omitted,
each comp-data-source is assigned to the corresponding component in component order. The keyword= can
be omitted from a comp-spec only if the keyword= has been omitted from each preceding comp-spec in the
constructor, if any.
If a component of the derived type is an array, the shape in the expression list must conform to the shape of
the component array.
If a component of the derived type is a pointer, the value in the expression list must evaluate to an object
that would be a valid target in a pointer assignment statement. (A constant is not a valid target in a pointer
assignment statement.)
If all the values in a structure constructor are constant expressions, the constructor is a derived-type
constant expression.
The type name and all components of the type for which a comp-spec appears must be accessible in the
scoping unit containing the structure constructor.
For a pointer component, the corresponding comp-data-source must be an allowable data-target or proc-
target for such a pointer in a pointer assignment statement. If the comp-data-source is a pointer, the
association of the component is that of the pointer; otherwise, the component is pointer-associated with the
comp-data-source.
If a component with default initialization has no corresponding comp-data-source, then the default
initialization is applied to that component.
If a component of a derived type is allocatable, the corresponding constructor expression must either be a
reference to the intrinsic function NULL with no arguments or an allocatable entity of the same rank, or it
must evaluate to an entity of the same rank.
If the expression is a reference to the intrinsic function NULL, the corresponding component of the
constructor has a status of unallocated.
If the expression is an allocatable entity, the corresponding component of the constructor has the same
allocation status as that allocatable entity. If the entity is allocated, the constructor component has the same
dynamic type, bounds, and value. If a length parameter of the component is deferred, its value is the same
as the corresponding parameter of the expression.
If the component is allocatable and the expression is not an allocatable entity, the component has an
allocation status of allocated, and the same bounds as the expression. If the component has a deferred
length parameter, its value is the same as the corresponding length parameter of the expression. If the
component is polymorphic, it has the same dynamic type and value. Otherwise, the value is converted, if
necessary, to the declared type of the component.
Examples
Consider the following derived-type definition:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
This can be used to produce the following structure constructor:
TYPE ITEM
REAL COST
CHARACTER(LEN=30) SUPPLIER
CHARACTER(LEN=20) ITEM_NAME
END TYPE ITEM
777
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE PRODUCE
REAL MARKUP
TYPE(ITEM) FRUIT
END TYPE PRODUCE
In this case, you must use an embedded structure constructor to specify the values of that component; for
example:
See Also
Pointer Assignments
Procedure Pointers
See Also
Determining the Data Type of Nondecimal Constants
Bit Sequence Comparisons
Binary Constants
A binary constant is an alternative way to represent a numeric constant. A binary constant takes one of the
following forms:
B'd[d...]'
B"d[d...]"
778
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Valid Binary Constants
B'0101110'
B"1"
See Also
Alternative Syntax for Binary, Octal, and Hexadecimal Constants
Octal Constants
An octal constant is an alternative way to represent numeric constants. An octal constant takes one of the
following forms:
O'd[d...]'
O"d[d...]"
You can specify up to 128 bits (43 octal digits) in octal constants.
Examples
Valid Octal Constants
O'07737'
O"1"
See Also
Alternative Syntax for Binary, Octal, and Hexadecimal Constants
Hexadecimal Constants
A hexadecimal constant is an alternative way to represent numeric constants. A hexadecimal constant takes
one of the following forms:
Z'd[d...]'
Z"d[d...]"
You can specify up to 128 bits (32 hexadecimal digits) in hexadecimal constants.
779
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Valid Hexadecimal Constants
Z'AF9730'
Z"FFABC"
Z'84'
See Also
Alternative Syntax for Binary, Octal, and Hexadecimal Constants
Hollerith Constants
A Hollerith constant is a string of printable ASCII characters preceded by the letter H. Before the H, there
must be an unsigned, nonzero default integer constant stating the number of characters in the string
(including blanks and tabs).
Hollerith constants are strings of 1 to 2000 characters. They are stored as byte strings, one character per
byte.
Examples
Valid Hollerith Constants
16HTODAY'S DATE IS:
1HB
4H ABC
INTEGER(2) ICOUNT
INTEGER(4) JCOUNT
INTEGER(4) N
REAL(8) DOUBLE
780
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RAFFIA = REAL(4) 4
B'1001100111111010011'
DOUBLE = REAL(8) 8
B'1111111111100110011010'
When a specific data type (generally integer) is required, that type is assumed for the constant. For example:
When a binary, octal, or hexadecimal constant is used in any other context, the default integer data type is
assumed. In the following examples, default integer is INTEGER(4):
781
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When nondecimal constants are not the same length as the length implied by a data type, the following
occurs:
• Binary, octal, and hexadecimal constants
These constants can specify up to 16 bytes of data. When the length of the constant is less than the
length implied by the data type, the leftmost digits have a value of zero.
When the length of the constant is greater than the length implied by the data type, the constant is
truncated on the left. An error results if any nonzero digits are truncated.
The Data Type Storage Requirements table lists the number of bytes that each data type requires.
• Hollerith constants
When the length of the constant is less than the length implied by the data type, blanks are appended to
the constant on the right.
When the length of the constant is greater than the length implied by the data type, the constant is
truncated on the right. If any characters other than blank characters are truncated, a warning occurs.
Each Hollerith character occupies one byte of memory.
If = appears in an enumerator, a double-colon separator must appear before the enumerator or list of
enumerators.
The compiler ensures that the integer kind declared for the enumerator is compatible with the integer type
used by the corresponding C enumeration. The processor uses the same representation for the types
declared by all C enumeration specifiers that specify the same values in the same order.
An enumerator is treated as if it were explicitly declared with the PARAMETER attribute.
The order in which the enumerators appear in an enumerator definition is significant.
If you do not explicitly assign each enumerator a value by specifying an expr, the compiler assigns a value
according to the following rules:
782
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If the enumerator is the first enumerator in the enumerator definition, the enumerator has the value 0.
• If the enumerator is not the first enumerator in the enumerator definition, its value is the result of adding
one to the value of the immediately preceding enumerator in the enumerator definition.
You can define the enumerators in multiple ENUMERATOR statements or in one ENUMERATOR statement. The
order in which the enumerators are declared in an enumeration definition is significant, but the number of
ENUMERATOR statements is not.
Examples
The following example shows an enumeration definition:
ENUM, BIND(C)
ENUMERATOR ORANGE
ENUMERATOR :: RED = 5, BLUE = 7
ENUMERATOR GREEN
END ENUM
The kind type parameter for this enumeration is processor dependent, but the processor must select a kind
sufficient to represent the values of the enumerators.
The order of the enumerators is significant if the values are not assigned explicitly. In the above example,
the value of ORANGE becomes defined as a named constant with the value zero and the value of GREEN
becomes defined as a named constant with the value 8. Note that if RED was the enumerator preceding
GREEN, the value of GREEN would be 6 rather than 8.
The following declaration may be considered to be equivalent to the above enumeration definition:
INTEGER(KIND(BLUE)) :: X
Variables
A variable is a data object whose value can be changed (defined or redefined) at any point in a program. A
variable can be any of the following:
• A scalar
A scalar is a single object that has a single value; it can be of any intrinsic or derived (user-defined) type.
• An array
An array is a collection of scalar elements of any intrinsic or derived type. All elements must have the
same type and kind parameters.
• A subobject designator
A subobject is part of an object. The following are subobjects:
An array element
An array section
A structure component
A character substring
For example, B(3) is a subobject (array element) designator for array B. A subobject cannot be a variable
if its parent object is a constant.
• A reference to a function that returns a data pointer
A reference to a function that returns a data pointer is treated as a variable and is permitted in any
variable-definition context .
The name of a variable is associated with a single storage location.
783
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A designator is a name followed by zero or more component selectors, complex part selectors, array section
selectors, array element selectors, image selectors, and substring selectors.
Variables are classified by data type, as constants are. The data type of a variable indicates the type of data
it contains, including its precision, and implies its storage requirements. When data of any type is assigned to
a variable, it is converted to the data type of the variable (if necessary).
A variable is defined when you give it a value. A variable can be defined before program execution by a DATA
statement or a type declaration statement. During program execution, variables can be defined or redefined
in assignment statements and input statements, or undefined (for example, if an I/O error occurs). When a
variable is undefined, its value is unpredictable.
When a variable becomes undefined, all variables associated by storage association also become undefined.
An object with subobjects, such as an array, can only be defined when all of its subobjects are defined.
Conversely, when at least one of its subobjects are undefined, the object itself, such as an array or derived
type, is undefined.
This section also discusses the Data Types of Scalar Variables and Arrays.
See Also
Type Declarations
DATA statement
Data Type of a Numeric Expressions
Storage Association for details on storage association of variables
See Also
Specification of Data Type
Implicit Typing Rules
NOTE
If no kind parameter is specified for a data type, the default kind is used. The default kind can be
affected by compiler options that affect the size of variables.
You can explicitly specify the data type of a scalar variable only once.
If no explicit data type specification appears, any variable with a name that begins with the letter in the
range specified in the IMPLICIT statement becomes the data type of the variable.
784
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Character type declaration statements specify that given variables represent character values with the length
specified. For example, the following statements associate the variable names INLINE, NAME, and NUMBER
with storage locations containing character data of lengths 72, 12, and 9, respectively:
CHARACTER(72) INLINE
CHARACTER NAME*12, NUMBER*9
In single subprograms, assumed-length character arguments can be used to process character strings with
different lengths. The assumed-length character argument has its length specified with an asterisk, for
example:
CHARACTER(*) CHARDUMMY
The argument CHARDUMMY assumes the length of the actual argument.
See Also
Type Declarations
ALPHA JCOUNT
BETA ITEM_1
TOTAL_NUM NTOTAL
See Also
Type Declarations
IMPLICIT statement
Arrays
An array is a set of scalar elements that have the same type and kind parameters. Any object that is
declared with an array specification is an array. Arrays can be declared by using a type declaration
statement, or by using a DIMENSION, COMMON, ALLOCATABLE, POINTER, or TARGET statement.
An array can be referenced by element (using subscripts), by section (using a section subscript list), or as a
whole. A subscript list (appended to the array name) indicates which array element or array section is being
referenced.
A section subscript list consists of subscripts, subscript triplets, or vector subscripts. At least one subscript in
the list must be a subscript triplet or vector subscript.
When an array name without any subscripts appears in an intrinsic operation (for example, addition), the
operation applies to the whole array (all elements in the array).
An array has the following properties:
785
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Data type
An array can have any intrinsic or derived type. The data type of an array (like any other variable) is
specified in a type declaration statement or implied by the first letter of its name. All elements of the
array have the same type and kind parameters. If a value assigned to an individual array element is not
the same as the type of the array, it is converted to the array's type.
• Rank
The rank of an array is the number of dimensions in the array. An array can have up to 31 dimensions. A
rank-one array represents a column of data (a vector), a rank-two array represents a table of data
arranged in columns and rows (a matrix), a rank-three array represents a table of data on multiple pages
(or planes), and so forth.
• Bounds
Arrays have a lower and upper bound in each dimension. These bounds determine the range of values
that can be used as subscripts for the dimension. The value of either bound can be positive, negative, or
zero.
The bounds of a dimension are defined in an array specification.
• Size
The size of an array is the total number of elements in the array (the product of the array's extents).
The extent is the total number of elements in a particular dimension. The extent is determined as follows:
upper bound - lower bound + 1. If the value of any of an array's extents is zero, the array has a size of
zero.
• Shape
The shape of an array is determined by its rank and extents, and can be represented as a rank-one array
(vector) where each element is the extent of the corresponding dimension.
Two arrays with the same shape are said to be conformable. A scalar is conformable to an array of any
shape.
The name and rank of an array must be specified when the array is declared. The extent of each dimension
can be constant, but does not need to be. The extents can vary during program execution if the array is a
dummy argument array, an automatic array, an array pointer, or an allocatable array.
A whole array is referenced by the array name. Individual elements in a named array are referenced by a
scalar subscript or list of scalar subscripts (if there is more than one dimension). A section of a named array
is referenced by a section subscript.
This section also discusses:
• Whole Arrays
• Array Elements
• Array Sections
• Array Constructors
Examples
The following are examples of valid array declarations:
INTEGER L(2:11,3)
The properties of array L are as follows:
786
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Second dimension: 1 to 3
The following example shows other valid ways to declare this array:
DIMENSION L(2:11,3)
INTEGER, DIMENSION(2:11,3) :: L
COMMON L(2:11,3)
The following example shows references to array elements, array sections, and a whole array:
See Also
DIMENSION attribute
Intrinsic data types
Derived data types
Declaration Statements for Arrays for details on array specifications
Categories of Intrinsic Functions for details on intrinsic functions that perform array operations
Whole Arrays
A whole array is a named array; it is either a named constant or a variable. It is referenced by using the
array name (without any subscripts).
If a whole array appears in a nonexecutable statement, the statement applies to the entire array. For
example:
INTEGER, DIMENSION(2:11,3) :: L ! Specifies the type and
! dimensions of array L
If a whole array appears in an executable statement, the statement applies to all of the elements in the
array. For example:
L = 10 ! The value 10 is assigned to all the
! elements in array L
WRITE *, L ! Prints all the elements in array L
787
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Array Elements
An array element is one of the scalar data items that make up an array. A subscript list (appended to the
array or array component) determines which element is being referred to. A reference to an array element
takes the following form:
array(subscript-list)
Description
Each array element inherits the type, kind type parameter, and certain attributes (INTENT, PARAMETER, and
TARGET) of the parent array. An array element cannot inherit the POINTER attribute.
If an array element is of type character, it can be followed by a substring range in parentheses; for example:
REAL A(3, 3)
REAL B(3, 3), C(89), R
B(2, 2) = 4.5 ! Assigns the value 4.5 to element B(2, 2)
R = 7.0
C(INT®*2 + 1) = 2.0 ! Element 15 of C = 2.0
A(1,2) = B(INT(C(15)), INT(SQRT®)) ! Element A(1,2) = element B(2,2) = 4.5
For information on forms for array specifications, see Declaration Statements for Arrays.
788
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following figure shows array storage in one, two, and three dimensions:
Array Storage
For example, in two-dimensional array BAN, element BAN(1,2) has a subscript order value of 4; in three-
dimensional array BOS, element BOS(1,1,1) has a subscript order value of 1.
In an array section, the subscript order of the elements is their order within the section itself. For example, if
an array is declared as B(20), the section B(4:19:4) consists of elements B(4), B(8), B(12), and B(16). The
subscript order value of B(4) in the array section is 1; the subscript order value of B(12) in the section is 3.
See Also
Array association
Character Constants for details on substrings
Structure Components for details on arrays as structure components
Storage Association for details on storage sequence association
789
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Array Sections
An array section is a portion of an array that is an array itself. It is an array subobject. A section subscript
list (appended to the array or array component) determines which portion is being referred to. A reference to
an array section takes the following form:
array(sect-subscript-list)
Description
If no section subscript list is specified, the rank and shape of the array section is the same as the parent
array.
Otherwise, the rank of the array section is the number of vector subscripts and subscript triplets that appear
in the list. Its shape is a rank-one array where each element is the number of integer values in the sequence
indicated by the corresponding subscript triplet or vector subscript.
If any of these sequences is empty, the array section has a size of zero. The subscript order of the elements
of an array section is that of the array object that the array section represents.
Each array section inherits the type, kind type parameter, and certain attributes (INTENT, PARAMETER, and
TARGET) of the parent array. An array section cannot inherit the POINTER attribute.
If an array (or array component) is of type character, it can be followed by a substring range in parentheses.
Consider the following declaration:
CHARACTER(LEN=15) C(10,10)
In this case, an array section referenced as C(:,:) (1:3) is an array of shape (10,10), whose elements are
substrings of length 3 of the corresponding elements of C.
The following shows valid references to array sections. Note that the syntax (/.../) denotes an array
constructor.
REAL, DIMENSION(20) :: B
...
PRINT *, B(2:20:5) ! The section consists of elements
! B(2), B(7), B(12), and B(17)
K = (/3, 1, 4/)
B(K) = 0.0 ! Section B(K) is a rank-one array with shape (3) and
! size 3. (0.0 is assigned to B(1), B(3), and B(4).)
See Also
INTENT attribute
PARAMETER attribute
TARGET attribute
Array constructors
Character Substrings
790
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Subscript Triplets
A subscript triplet is a set of three values representing the lower bound of the array section, the upper
bound of the array section, and the increment (stride) between them. It takes the following form:
[first-bound] : [last-bound] [:stride]
first-bound Is a scalar integer (or other numeric) expression representing the first
value in the subscript sequence. If omitted, the declared lower bound
of the dimension is used.
last-bound Is a scalar integer (or other numeric) expression representing the last
value in the subscript sequence. If omitted, the declared upper bound
of the dimension is used.
When indicating sections of an assumed-size array, this subscript must
be specified.
791
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Array Sections
Vector Subscripts
A vector subscript is a one-dimensional (rank one) array of integer values (within the declared bounds for
the dimension) that selects a section of a whole (parent) array. The elements in the section do not have to be
in order and the section can contain duplicate values.
For example, A is a rank-two array of shape (4,6). B and C are rank-one arrays of shape (2) and (3),
respectively, with the following values:
B = (/1,4/) ! Syntax (/.../) denotes an array constructor
C = (/2,1,1/) ! This constructor produces a many-one array section
Array section A(3,B) consists of elements A(3,1) and A(3,4). Array section A(C,1) consists of elements
A(2,1), A(1,1), and A(1,1). Array section A(B,C) consists of the following elements:
A(1,2) A(1,1) A(1,1)
A(4,2) A(4,1) A(4,1)
An array section with a vector subscript that has two or more elements with the same value is called a
many-one array section. For example:
REAL A(3, 3), B(4)
INTEGER K(4)
! Vector K has repeated values
K = (/3, 1, 1, 2/)
! Sets all elements of A to 5.0
A = 5.0
B = A(3, K)
The array section A(3,K) consists of the elements:
A(3, 3) A(3, 1) A(3, 1) A(3, 2)
A many-one section must not appear on the left of the equal sign in an assignment statement, or as an input
item in a READ statement.
The following assignments to C also show examples of vector subscripts:
INTEGER A(2), B(2), C(2)
...
B = (/1,2/)
C(B) = A(B)
C = A((/1,2/))
An array section with a vector subscript must not be any of the following:
• An internal file
• An actual argument associated with a dummy array that is defined or redefined (if the INTENT attribute is
specified, it must be INTENT(IN))
• The target in a pointer assignment statement
If the sequence specified by the vector subscript is empty, the array section has a size of zero.
See Also
Array sections
Array constructors
792
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Array Constructors
An array constructor can be used to create and assign values to rank-one arrays and array constants. An
array constructor takes one of the following forms:
(/ac-spec/)
[ac-spec]
kind-selector Is ( [KIND=] n ).
do-variable Is the name of a scalar integer variable. Its scope is that of the
implied-DO loop.
expr Is a scalar integer expression. The expr1 and expr2 specify a range of
values for the loop; expr3 specifies the stride. The expr3 must be a
nonzero value; if it is omitted, it is assumed to be 1.
Description
If type-spec is omitted, each ac-value-list expression must have the same type and kind type parameters,
and the same length parameters. In this case, the array constructed has the same type as the ac-value-list
expressions.
If type-spec appears, it specifies the type and type parameters of the array constructor. Each ac-value-list
expression must be compatible with intrinsic assignment to a variable of this type and type parameters. Each
value is converted to the type parameters of the array constructor in accordance with the rules of intrinsic
assignment.
If type-spec specifies an intrinsic type, each ac-value-list expression must be of an intrinsic type that
conforms with a variable of type type-spec.
If type-spec specifies a derived type, all ac-value-list expressions must be of that derived type and must
have the same kind type parameter values as specified by type-spec.
A do-variable of an implied-DO that is in another implied-do must not appear as the do-variable of a
containing implied-DO.
If the sequence of values specified by the array constructor is empty (an empty array expression or the
implied-DO loop produces no values), the rank-one array has a size of zero.
An ac-value is interpreted as follows:
793
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
3
++a --++ab --++abc--++d --
If an implied-DO loop is contained within another implied-DO loop (nested), they cannot have the same DO
variable (do-variable).
To define arrays of more than one dimension, use the RESHAPE intrinsic function.
The following are alternative forms for array constructors:
• Square brackets (instead of parentheses and slashes) to enclose array constructors; for example, the
following two array constructors are equivalent:
INTEGER C(4)
C = (/4,8,7,6/)
C = [4,8,7,6]
794
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• A colon-separated triplet (instead of an implied-DO loop) to specify a range of values and a stride; for
example, the following two array constructors are equivalent:
INTEGER D(3)
D = (/1:5:2/) ! Triplet form - also [1:5:2]
D = (/(I, I=1, 5, 2)/) ! implied-DO loop form
The stride is optional; it defaults to 1. For example, the following two array constructors are equivalent:
INTEGER E(5)
E = (/1:5/) ! Triplet form with default stride – also [1:5]
E = (/(I, I=1, 5)/) ! implied-DO loop form
Examples
The following example shows an array constructor using an implied-DO loop:
INTEGER ARRAY_C(10)
ARRAY_C = (/(I, I=30, 48, 2)/)
The values of ARRAY_C are the even numbers 30 through 48.
Implied-DO expressions and values can be mixed in the value list of an array constructor. For example:
INTEGER A(10)
A = (/1, 0, (I, I = -1, -6, -1), -7, -8 /)
! Mixed values and implied-DO in value list.
This example sets the elements of A to the values, in order, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8.
The following example shows an array constructor of derived type that uses a structure constructor:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=30) NAME
END TYPE EMPLOYEE
TYPE(EMPLOYEE) CC_4T(4)
CC_4T = (/EMPLOYEE(2732,"JONES"), EMPLOYEE(0217,"LEE"), &
EMPLOYEE(1889,"RYAN"), EMPLOYEE(4339,"EMERSON")/)
The following example shows how the RESHAPE intrinsic function can be used to create a multidimensional
array:
TYPE EMPLOYEE
INTEGER AGE
CHARACTER (LEN = 60) NAME
END TYPE EMPLOYEE
795
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following equivalent lines use the above type to construct a derived-type array value:
Coarrays
Coarrays and synchronization constructs are defined by the Fortran 2008 Standard and extended by Fortran
2018. These constructs support parallel programming using a Single Program Multiple Data (SPMD) model.
These features are not available on macOS systems.
NOTE
Coarrays are only supported on 64-bit architectures.
You must specify compiler option [Q]coarray to enable coarrays in your program.
A Fortran program containing coarrays is interpreted as if it were replicated a fixed number of times and all
copies were executed asynchronously.
Each replication is called an "image", and each image has its own set of data objects. The number of images
is set at run-time, but it can also be set by a compiler option or an environment variable.
The array syntax of Fortran is extended with additional trailing subscripts in square brackets to provide a
clear representation of references to data that is spread across images. References without square brackets
are to local data, so source code that can run independently is uncluttered. Any appearance of square
brackets indicates communication between images.
A team is an ordered set of images. Each image is identified by a unique image index, numbered from 1 to
the number of images on the team. The set of all images at program start up is called the initial team. A
team of images can be divided into subteams by executing a FORM TEAM statement. The team executing the
FORM TEAM statement is the parent team of th teams created by the FORM TEAM statement. Each child
team of a parent team is identified by a team number, which is a positive integer value specified on the
FORM TEAM statement. The initial team has no parent team.
While the program is executing, each image executes on a current team. At program start-up, the current
team is the initial team, which consists of all images. An image's current team changes when a CHANGE
TEAM statement is executed, causing the images of the current team to begin executing as images on
subteams of the current team; the subteam an image is on becomes its current team. When an END TEAM
statement is executed by an image, the image's current team becomes the team that was current just before
the corresponding CHANGE TEAM statement was executed. Image indices are relative to the current team,
unless a different team is specified.
Usually, each image resides on one processor. However, several images may share a processor and one
image can execute on a cluster.
To reference any array variable that is coindexed, a subscript list must be present. If no subscript list is
present, then the coindexed object must be a scalar.
796
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Consider the following statement:
a(:) = b(:)[q]
In this case, the coarray b on image q is copied into coarray a on the executing image.
Consider the coindexed reference x[k]. If x is a rank 1 array, this reference to x on image k is incorrect
syntax: a subscript list must be present. The correct form is x(:)[k] to access the entire array x on image
k. If x is a scalar, then the syntax x[k] is correct.
See Also
Image Control Statements
Established Coarrays
Using Coarrays
Image Selectors
An image selector determines the image index for a coindexed object. It takes the following form:
lbracket cosubscript-list [ , selector-spec-list ] rbracket
cosubscript Is a scalar integer expression. Its value must be within the cobounds
for its codimension. The number of cosubscripts must be equal to the
corank of the object. If the lower bound is not specified, it is assumed
to be 1.
selector-spec Is TEAM=team-var
or TEAM_NUMBER=scalar-integer-expression
or STAT=stat-var
Considering the cobounds and bounds, respectively, the cosubscript list in an image selector determines the
image index in the same way that a subscript list in an array element determines the subscript order value.
The selector-specs may appear in any order in the selector-spec-list. TEAM= and TEAM_NUMBER must not
both be specified. A given selector-spec may appear at most once.
If TEAM= is specified, team-var must be the current or an ancestor team. If TEAM_NUMBER= appears and
the initial team is not the current team, scalar-integer-expression must have a value of -1 indicating the
initial team, or a positive integer value that identifies a sibling team of the current team. If the initial team is
the current team and TEAM_NUMBER appears, scalar-integer-expression must have the value -1. If TEAM or
TEAM_NUMBER is specified, the team of the image selector is the specified team; the image index specified
by the cosubscript list applies to the specified team. Otherwise, the team of the image selector is the current
team.
797
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the image selector specifies TEAM_NUMBER=, and the value of scalar-integer-expression is a positive
integer that is not that of the current team, the coarray object must be established on an ancestor team or
be an associating entity on the enclosing CHANGE TEAM construct. Otherwise, the coarray object must be
established in the specified team, or in an ancestor of that team.
An image selector must specify an image index value that is not greater than the number of images on the
specified team.
When a statement containing an image selector with STAT= specified is executed, stat-var becomes defined
with value STAT_FAILED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV if the object referenced
by the image selector is on a failed image. Otherwise, stat-var becomes defined with the value zero.
A stat-var in an image selector cannot depend on the evaluation of any other entity in the same statement.
An expression cannot depend on the value of any stat-var that is specified in the same statement. The value
of stat-var cannot depend on execution of any part of the statement, other than if the object is on a failed
image.
Examples
Assume that there are 16 images and the coarray C is declared as follows:
REAL :: C(15)[5,*]
C(:)[1,4] is valid because it selects image 16, but C(:)[2,4] is invalid because it selects image 17.
C(1)[2, 1, STAT=istatus] will cause istatus to become defined with the value STAT_FAILED_IMAGE if image 6
has failed; otherwise, istatus becomes defined with the value zero.
Consider the following program:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: initial, odd_even
REAL :: ca[4:*], x, y, z
INTEGER :: me
initial = GET_TEAM (CURRENT_TEAM)
me = THIS_IMAGE ()
FORM TEAM (2-MOD(me, 2), odd_even, NEW_INDEX=(me+1)/2)
. . .
CHANGE TEAM (odd_even, ae[2,*]=>ca)
x = ca[2,3, TEAM=initial]
y = ae[2,4, TEAM_NUMBER=2]
x = ae[2,2]
. . .
END TEAM
. . .
END PROGRAM
Assuming there are 16 images, ca is then a 4x4 coarray. The FORM TEAM statement divides the images into
two teams. Team 1 contains images [1, 3, …, 15] and team 2 contains images [2, 4, …, 16] with image
indices on the new teams [1, 2, …, 8] respectively.
The CHANGE TEAM statement has an associating entity ae which is a 2x4 coarray on each team executing
the CHANGE TEAM construct. Within the CHANGE TEAM construct for team 1, ae[1, 1] is ca[1, 1], ae[2, 1] is
ca[3, 1], ae[1, 2] is ca[1, 2], ae[2,2] is ca[3,2], ae[1,3] is ca[1,3], ae[2, 3] is ca[3,3], ae[1,4] is ca[1,4] and
ae[2,4] is ca[3,4], and for team 2, ae[1, 1] is ca[2, 1], ae[2, 1] is ca[4, 1], ae[1, 2] is ca[2, 2], ae[2,2] is
ca[4,2], ae[1,3] is ca[2,3], ae[2, 3] is ca[4,3], ae[1,4] is ca[2,4] and ae[2,4] is ca[4,4].
The first statement in the CHANGE TEAM construct assigns x the value of ca[2,3] on the initial team, which is
on image 10 on the initial team. The second statement in the CHANGE TEAM construct assigns y the value of
ae[2, 2] on team number 2 that is on image 8 of team 2; it is the same as ca[4,4], that is on image 16 of
798
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
the initial team. The third statement in the CHANGE TEAM construct assigns z the value of ae[2,2]. ae[2,2] is
on image 4 of both team 1 and team 2; on team 1 it is the same as ca[3,2] on image 7 of the initial team,
and on team 2 it is the same as ca[4,2], which is on image 8 of the initial team.
See Also
Coarrays
ISO_FORTRAN_ENV Module
FORM TEAM
CHANGE TEAM
Established Coarrays
An established coarray is a coarray that is accessible using an image selector. The following can be said about
coarrays:
• Nonallocatable coarrays that have the SAVE attribute are established in the initial team.
• Allocated allocatable coarrays are established in the team that allocates them. Unallocated allocatable
coarrays are not established.
• An associating entity that appears in a coarray association in a CHANGE TEAM statement is a coarray that
is established in the team that becomes the current team after the CHANGE TEAM statement has been
executed.
• Nonallocatable coarrays that are host associated with a dummy arguments.
Deferred-Coshape Coarrays
A deferred-coshape(allocatable) coarray has cobounds that are determined by allocation or argument
association.
An allocatable coarray has the ALLOCATABLE attribute and a deferred-coshape specification.
A deferred-coshape specification is indicated by a colon (:).
The corank of an allocatable coarray is equal to the number of colons in its deferred-coshape specification.
The cobounds of an unallocated allocatable coarray are undefined. No part of such a coarray can be
referenced or defined; however, the coarray may appear as an argument to an intrinsic inquiry function.
The cobounds of an allocated allocatable coarray are those specified when the coarray is allocated.
The cobounds of an allocatable coarray are unaffected by any subsequent redefinition or undefinition of the
variables on which the cobounds' expressions depend.
See Also
Coarrays
Explicit-Coshape Coarrays
An explicit-coshape coarray is a named coarray that has its corank and cobounds declared by an explicit-
coshape specification.
An explicit-coshape specification takes the following form:
[[lower-cobound:] upper-cobound, ] ... [lower-cobound:] *
799
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following are examples of variables with coarray specifications (coarray-specs):
A [*]
AA [2:*]
B [2, 3, *]
C [3:5, -2:7, *]
See Also
Coarrays
See Also
THIS_IMAGE
IMAGE_INDEX
NUM_IMAGES
800
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Variable-Definition Context
A variable can appear in different contexts that imply definition or undefinition of the variable. A reference to
a function that returns a data pointer is permitted in such variable-definition contexts.
When a function returns a data pointer, that pointer is always associated with a variable that has the TARGET
attribute, either by pointer assignment or by allocation. If a reference to a function that returns a data
pointer appears in a variable-definition context, the definable target (with which the function result is
associated) is the variable that becomes defined or undefined.
This section describes the different variable-definition contexts in which a function reference returning a data
pointer can be used. It also describes the contexts in which data pointer function references are not allowed.
Assignment Statement
Function references returning a data pointer can be used on the left-hand side of an assignment statement.
References to type bound and generic procedures are also permitted on the left-hand side of an intrinsic
assignment. If the variable on the left-hand side is polymorphic, it must be an allocatable. Therefore, a
function returning a polymorphic pointer cannot be used on the left-hand side.
In the following example, function STORAGE returns a data pointer to either the module variable OUTSIDE or
to an element of VAR into which a value is stored:
MODULE TMOD
PUBLIC
INTEGER, PARAMETER :: N = 10
801
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROGRAM MAIN
USE TMOD
OUTSIDE = -1
STORAGE(1) = 11
STORAGE(0) = 0
PRINT *, VAR(1), OUTSIDE ! prints 11, 0
END
The following example shows generic resolution on the left-hand side of an assignment statement:
MODULE MYMODULE
TYPE :: VEC
INTEGER :: X(3)
CONTAINS
GENERIC :: GET => GETELEMENT, GETARRAY
PROCEDURE :: GETELEMENT
PROCEDURE :: GETARRAY
END TYPE VEC
CONTAINS
FUNCTION GETELEMENT( THIS, EL ) RESULT( P )
IMPLICIT NONE
CLASS(VEC), TARGET :: THIS
INTEGER, INTENT(IN) :: EL
INTEGER, POINTER :: P
P => THIS%X(EL)
END FUNCTION GETELEMENT
PROGRAM TEST
USE MYMODULE
IMPLICIT NONE
TYPE(VEC) :: MYVEC
INTEGER :: Y(3)
MYVEC%X = [1,2,3]
Y = [6,7,8]
! expected output 1 2 1 2 3
802
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Argument Association
A function reference returning a data pointer can be used as an actual argument in a reference to a
procedure with an explicit interface. If the corresponding dummy argument has the INTENT (OUT) or INTENT
(INOUT) attribute, then the pointer function is used in a variable definition context.
The following example uses the function STORAGE, which was defined in the above section "Assignment
Statement":
MODULE M200C2
INTEGER, TARGET :: X = 42
CONTAINS
FUNCTION FX()
INTEGER, POINTER :: FX
FX => X
END FUNCTION
END MODULE
PROGRAM Q1
USE M200C2
CALL TEST(X, FX())
! note that corresponding dummy is not INTENT (OUT) or INTENT(INOUT).
! FX() is not used in a variable definition context but it still
! denotes a variable.
803
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CONTAINS
SUBROUTINE TEST(A, B)
INTEGER, TARGET :: B
A = A*10
PRINT *, A, B ! prints 420 420
END SUBROUTINE
END PROGRAM
PROGRAM MAIN
INTEGER, TARGET :: DATA = 123
CONTAINS
FUNCTION FX1()
INTEGER, POINTER :: FX1
FX1 => DATA
END FUNCTION FX1
FUNCTION FX2()
CLASS(*),POINTER :: FX2
FX2 => DATA
END FUNCTION FX2
END PROGRAM MAIN
In the following example, FX() in the ASSOCIATE is a variable and every reference to ALIAS is a reference to
the associated variable, so the assignment also changes the value of ALIAS:
PROGRAM MAIN
INTEGER, TARGET :: DATA = 123
CONTAINS
FUNCTION FX1 ()
804
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FUNCTION FX2()
CLASS(*),POINTER :: FX2
FX2 => DATA
END FUNCTION FX2
Input/Output Statements
A pointer function reference can be used as an input item in a READ statement.
A function reference returning a character pointer can be used as an internal file variable in a WRITE
statement.
A scalar integer pointer function reference can be an IOSTAT= or a SIZE= specifier in an input/output
statement. A scalar character pointer function reference can be an IOMSG= specifier in an input/output
statement.
A function returning a scalar pointer, whose datatype matches the specifier, can be specified in an INQUIRE
statement except for the three specifiers FILE=, ID=, and UNIT=.
A function returning a scalar integer pointer can be a NEWUNIT= specifier in an OPEN statement.
Consider the following example:
...
CHARACTER(50), TARGET :: V(33)
INTEGER, TARGET :: I
..
FUNCTION RET_CHAR(INDEX) RESULT (DCV)
CHARACTER(50), POINTER :: DCV
INTEGER :: INDEX
DCV => V(INDEX)
END FUNCTION
FUNCTION RET_INT() RESULT (P)
INTEGER, POINTER :: P
P => I
END FUNCTION
...
! an input item in a read stmt
READ (6, *) RET_INT()
READ 10, RET_INT()
805
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT=, ERRMSG=, and ACQUIRED_LOCK= Specifiers and STAT and ERRMSG Arguments to
Intrinsic Procedures
A scalar integer pointer function reference can be used as a STAT= variable. A scalar character pointer
function reference can be used as an ERRMSG= variable.
STAT= and ERRMSG= are allowed in CHANGE TEAM, END TEAM, CRITICAL, EVENT POST, EVENT WAIT, FORM
TEAM, SYNC ALL, SYNC IMAGES, SYNC MEMORY, SYNC TEAM, LOCK, UNLOCK, ALLOCATE, and DEALLOCATE
statements.
A STAT= specifier is allowed in an image selector. Collective and atomic procedures have an optional STAT
argument, and the MOVE_ALLOC intrinsic has optional STAT and ERRMSG arguments.
A scalar logical pointer function reference can be an ACQUIRED_LOCK= specifier in a LOCK statement.
The following example uses RET_CHAR and RET_INT, which were defined in the above section "Input/Output
Statements":
TYPE(EVENT_TYPE) :: ET[*]
TYPE(LOCK_TYPE) :: LT[*]
INTEGER, POINTER :: AR(:)
ALLOCATE(AR(2), STAT=RET_INT())
DEALLOCATE(AR, STAT=RET_INT())
806
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Disallowed Contexts
The Fortran Standard defines both a "variable" and a "variable name". For function F, F is a variable name;
F(7) is a function. If F returns a data pointer, F(7) is a variable and can be used in a variable-definition
context.
For the following variable-definition contexts, the Fortran Standard specifies that a "variable name" must be
used and not a "variable":
• The pointer object in a NULLIFY statement
• A data pointer object or procedure pointer object in a pointer assignment statement
• The DO variable in a DO statement or an implied DO construct
• A variable name in a NAMELIST statement if the NAMELIST group name appears in a NML= specifier in a
READ statement
• The object in an ALLOCATE or DEALLOCATE statement
• An event variable in an EVENT POST or EVENT WAIT statement
• The lock variable in a LOCK or UNLOCK statement
A function reference can return a pointer to any data object, even one that cannot be stored into, for
example, a USE associated PROTECTed object or a constant. This will not be caught at compile time. It is
possible that the target of the pointer function is a local variable from a different subprogram or a private
USE associated variable, in which case the pointer returned has an undefined association status.
MODULE TMOD
PUBLIC
TYPE PDT(K, L)
INTEGER, KIND :: K
INTEGER, LEN :: L
INTEGER :: FIELD(L)
END TYPE PDT
END MODULE
PROGRAM MAIN
USE TMOD
IMPLICIT NONE
TYPE(PDT(4,2)), TARGET :: PDTOBJ1, OBJ
TYPE(PDT(2,2)), POINTER :: ACTARG
CHARACTER(10), TARGET :: C1
BAR() = PDT(4,2)((/5,3/))
PRINT *, PDTOBJ1%FIELD ! prints 5 3
AUTO_RES(ACTARG) = PDT(4,2)((/6,4/))
PRINT *, PDTOBJ1%FIELD ! prints 6 4
AUTO_CHAR(10) = "TEST"
PRINT *, C1 ! prints TEST
CONTAINS
FUNCTION BAR() RESULT(LOC)
TYPE(PDT(4,2)), POINTER :: LOC
LOC => PDTOBJ1
END FUNCTION
FUNCTION AUTO_CHAR(DUM1) RESULT(LOC)
INTEGER, INTENT(IN) :: DUM1
CHARACTER(DUM1), POINTER :: LOC
807
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOC => C1
END FUNCTION
Expressions
An expression represents either a data reference or a computation, and is formed from operators, operands,
and parentheses. The result of an expression is either a scalar value or an array of scalar values.
If the value of an expression is of intrinsic type, it has a kind type parameter. (If the value is of intrinsic type
CHARACTER, it also has a length parameter.) If the value of an expression is of derived type, it has no kind
type parameter.
An operand is a scalar or array. An operator can be either intrinsic or defined. An intrinsic operator is known
to the compiler and is always available to any program unit. A defined operator is described explicitly by a
user in a function subprogram and is available to each program unit that uses the subprogram.
The simplest form of an expression (a primary) can be any of the following:
• A constant; for example, 4.2
• A subobject of a constant; for example, 'LMNOP' (2:4)
• A variable; for example, VAR_1
• A structure constructor; for example, EMPLOYEE(3472, "JOHN DOE")
• An array constructor; for example, (/12.0,16.0/)
• A function reference; for example, COS(X)
• Another expression in parentheses; for example, (I+5)
Any variable or function reference used as an operand in an expression must be defined at the time the
reference is executed. If the operand is a pointer, it must be associated with a target object that is defined.
An integer operand must be defined with an integer value rather than a statement label value. All of the
characters in a character data object reference must be defined.
When a reference to an array or an array section is made, all of the selected elements must be defined.
When a structure is referenced, all of the components must be defined.
In an expression that has intrinsic operators with an array as an operand, the operation is performed on each
element of the array. In expressions with more than one array operand, the arrays must be conformable
(they must have the same shape). The operation is applied to corresponding elements of the arrays, and the
result is an array of the same shape (the same rank and extents) as the operands.
In an expression that has intrinsic operators with a pointer as an operand, the operation is performed on the
value of the target associated with the pointer.
For defined operators, operations on arrays and pointers are determined by the procedure defining the
operation.
A scalar is conformable with any array. If one operand of an expression is an array and another operand is a
scalar, it is as if the value of the scalar were replicated to form an array of the same shape as the array
operand. The result is an array of the same shape as the array operand.
808
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following sections describe numeric, character, relational, and logical expressions; defined operations; a
summary of operator precedence; and initialization and specification expressions.
See Also
Arrays
Derived data types
Defining Generic Operators for details on function subprograms that define operators
POINTER statement for details on pointers
Numeric Expressions
Numeric expressions express numeric computations, and are formed with numeric operands and numeric
operators. The evaluation of a numeric operation yields a single numeric value.
The term numeric includes logical data, because logical data is treated as integer data when used in a
numeric context. The default for .TRUE. is -1; .FALSE. is 0. Note that the default can change if compiler
option fpscomp logicals is used.
Numeric operators specify computations to be performed on the values of numeric operands. The result is a
scalar numeric value or an array whose elements are scalar numeric values. The following are numeric
operators:
Operator Function
** Exponentiation
* Multiplication
/ Division
Unary operators operate on a single operand. Binary operators operate on a pair of operands. The plus and
minus operators can be unary or binary. When they are unary operators, the plus or minus operators precede
a single operand and denote a positive (identity) or negative (negation) value, respectively. The
exponentiation, multiplication, and division operators are binary operators.
Valid numeric operations must have results that are defined by the arithmetic used by the processor. For
example, raising a negative-valued base to a real power is invalid.
Numeric expressions are evaluated in an order determined by a precedence associated with each operator, as
follows (see also Summary of Operator Precedence):
Operator Precedence
** Highest
* and / .
Unary + and - .
Operators with equal precedence are evaluated in left-to-right order. However, exponentiation is evaluated
from right to left. For example, A**B**C is evaluated as A**(B**C). B**C is evaluated first, then A is raised
to the resulting power.
Normally, two operators cannot appear together. However, Intel® Fortran allows two consecutive operators if
the second operator is a plus or minus.
Examples
In the following example, the exponentiation operator is evaluated first because it takes precedence over the
multiplication operator:
809
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fpscomp compiler option
810
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If operands of different data types are combined in an expression, the evaluation of that expression and the
data type of the resulting value depend on the ranking associated with each data type. The following table
shows the ranking assigned to each data type:
LOGICAL(2) .
LOGICAL(4) .
LOGICAL(8) .
INTEGER(1) .
INTEGER(2) .
INTEGER(4) .
INTEGER(8) .
REAL(4) .
REAL(8)1 .
REAL(16) .
COMPLEX(4) .
COMPLEX(8)2 .
COMPLEX(16) Highest
1 DOUBLE PRECISION
2 DOUBLE COMPLEX
The data type of the value produced by an operation on two numeric operands of different data types is the
data type of the highest-ranking operand in the operation. For example, the value resulting from an
operation on an integer and a real operand is of real type. However, an operation involving a COMPLEX(4) or
COMPLEX(8) data type and a DOUBLE PRECISION data type produces a COMPLEX(8) result.
The data type of an expression is the data type of the result of the last operation in that expression, and is
determined according to the following conventions:
• Integer operations: Integer operations are performed only on integer operands. (Logical entities used in a
numeric context are treated as integers.) In integer arithmetic, any fraction resulting from division is
truncated, not rounded. For example, the result of 9/10 is 0, not 1.
• Real operations: Real operations are performed only on real operands or combinations of real, integer, and
logical operands. Any integer operands present are converted to real data type by giving each a fractional
part equal to zero. The expression is then evaluated using real arithmetic. However, in the statement Y =
(I /J)*X, an integer division operation is performed on I and J, and a real multiplication is performed on
that result and X.
If one operand is a higher-precision real (REAL(8) or REAL(16)) type, the other operand is converted to
that higher-precision real type before the expression is evaluated.
When a single-precision real operand is converted to a double-precision real operand, low-order binary
digits are set to zero. This conversion does not increase accuracy; conversion of a decimal number does
not produce a succession of decimal zeros. For example, a REAL variable having the value 0.3333333 is
converted to approximately 0.3333333134651184D0. It is not converted to either
0.3333333000000000D0 or 0.3333333333333333D0.
811
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Complex operations: In operations that contain any complex operands, integer operands are converted to
real type, as previously described. The resulting single-precision or double-precision operand is
designated as the real part of a complex number and the imaginary part is assigned a value of zero. The
expression is then evaluated using complex arithmetic and the resulting value is of complex type.
Operations involving a COMPLEX(4) or COMPLEX(8) operand and a DOUBLE PRECISION operand are
performed as COMPLEX(8) operations; the DOUBLE PRECISION operand is not rounded.
These rules also generally apply to numeric operations in which one of the operands is a constant. However,
if a real or complex constant is used in a higher-precision expression, additional precision will be retained for
the constant. The effect is as if a DOUBLE PRECISION (REAL(8)) or REAL(16) representation of the constant
were given. For example, the expression 1.0D0 + 0.3333333 is treated as if it is 1.0D0 +
dble(0.3333333).
Character Expressions
A character expression consists of a character operator (//) that concatenates two operands of type
character. The evaluation of a character expression produces a single value of that type.
The result of a character expression is a character string whose value is the value of the left character
operand concatenated to the value of the right operand. The length of a character expression is the sum of
the lengths of the values of the operands. For example, the value of the character expression 'AB'//'CDE'
is 'ABCDE', which has a length of five.
Parentheses do not affect the evaluation of a character expression; for example, the following character
expressions are equivalent:
('ABC'//'DE')//'F'
'ABC'//('DE'//'F')
'ABC'//'DE'//'F'
Each of these expressions has the value ' ABCDEF'.
If a character operand in a character expression contains blanks, the blanks are included in the value of the
character expression. For example, 'ABC '//'D E'//'F ' has a value of 'ABC D EF '.
Relational Expressions
A relational expression consists of two or more expressions whose values are compared to determine
whether the relationship stated by the relational operator is satisfied. The following are relational operators:
Operator Relationship
.EQ. or == Equal to
The result of the relational expression is .TRUE. if the relation specified by the operator is satisfied; the result
is .FALSE. if the relation specified by the operator is not satisfied.
Relational operators are of equal precedence. Numeric operators and the character operator // have a higher
precedence than relational operators.
In a numeric relational expression, the operands are numeric expressions. Consider the following example:
APPLE+PEACH > PEAR+ORANGE
812
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This expression states that the sum of APPLE and PEACH is greater than the sum of PEAR and ORANGE. If
this relationship is valid, the value of the expression is .TRUE.; if not, the value is .FALSE.
Operands of type complex can only be compared using the equal operator (== or .EQ.) or the not equal
operator (/= or .NE.). Complex entities are equal if their corresponding real and imaginary parts are both
equal.
In a character relational expression, the operands are character expressions. In character relational
expressions, less than (< or .LT.) means the character value precedes in the ASCII collating sequence, and
greater than (> or .GT.) means the character value follows in the ASCII collating sequence. For example:
'AB'//'ZZZ' .LT. 'CCCCC'
This expression states that 'ABZZZ' is less than 'CCCCC'. In this case, the relation specified by the operator
is satisfied, so the result is .TRUE..
Character operands are compared one character at a time, in order, starting with the first character of each
operand. If the two character operands are not the same length, the shorter one is padded on the right with
blanks until the lengths are equal; for example:
'ABC' .EQ. 'ABC '
'AB' .LT. 'C'
The first relational expression has the value .TRUE. even though the lengths of the expressions are not equal,
and the second has the value .TRUE. even though 'AB' is longer than 'C'.
A relational expression can compare two numeric expressions of different data types. In this case, the value
of the expression with the lower-ranking data type is converted to the higher-ranking data type before the
comparison is made.
See Also
Data Type of Numeric Expressions
Logical Expressions
A logical expression consists of one or more logical operators and logical, numeric, or relational operands.
The following are logical operators:
813
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Periods cannot appear consecutively except when the second operator is .NOT. For example, the following
logical expression is valid:
A+B/(A-1) .AND. .NOT. D+B/(D-1)
Defined Operations
When operators are defined for functions, the functions can then be referenced as defined operations.
The operators are defined by using a generic interface block specifying OPERATOR, followed by the defined
operator (in parentheses).
A defined operation is not an intrinsic operation. However, you can use a defined operation to extend the
meaning of an intrinsic operator.
For defined unary operations, the function must contain one argument. For defined binary operations, the
function must contain two arguments.
Interpretation of the operation is provided by the function that defines the operation.
A Standard Fortran defined operator can contain up to 31 letters, and is enclosed in periods (.), or it may be
an intrinsic operator.
814
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following examples show expressions containing defined operators:
.COMPLEMENT. A
X .PLUS. Y .PLUS. Z
M * .MINUS. N
See Also
Defining Generic Operators
Summary of Operator Precedence
Numeric ** .
Numeric * or / .
Numeric Unary + or - .
Numeric Binary + or - .
Character // .
Logical .NOT. .
Logical .AND. .
Logical .OR. .
815
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Constant Expressions
A constant expression is an expression that you can use as a kind type parameter, a named constant, or to
specify an initial value for an entity. It is evaluated when a program is compiled.
In a constant expression, each operation is intrinsic and each primary is one of the following:
• A constant or subobject of a constant
• A specification inquiry where each designator or function argument is one of the following:
• A constant expression
• A variable whose properties inquired about are not assumed, deferred, or defined by an expression
that is not a constant expression
• A reference to the transformational function IEEE_SELECTED_REAL_KIND from the intrinsic module
IEEE_ARITHMETIC, where each argument is a constant expression
• A kind type parameter of the derived type being defined
• A DO variable within an array constructor where each scalar integer expression of the corresponding DO
loop is an constant expression
• Another constant expression enclosed in parentheses, where each subscript, section subscript, substring
starting and ending point, and type parameter value is a constant expression
If a constant expression invokes an inquiry function for a type parameter or an array bound of an object, the
type parameter or array bound must be specified in a prior specification statement (or to the left of the
inquiry function in the same statement). The previous specification cannot be in the same entity declaration.
If a reference to a generic entity is included in a constant expression that is in the specification part of a
module or submodule, that generic entity shall have no specific procedures defined subsequent to the
constant expression in the module or submodule.
Examples
Valid constant Expressions
-1 + 3
7_2
SELECTED_INT_KIND (2)
See Also
Array constructors
Specification Expressions
Structure constructors
Intrinsic procedures
Specification Expressions
A specification expression is a restricted scalar integer expression that you can use in specifications such as
length type parameters and array bounds. Unless a specification expression is in an interface body, the
specification part of a subprogram or BLOCK construct, a derived type definition, or the declaration type spec
of a FUNCTION statement, it must be a constant expression.
816
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In a restricted expression, each operation is intrinsic or defined by a specification function and each primary
is one of the following:
• A constant or subobject of a constant
• An object designator with a base object that is one of the following:
• A dummy argument that does not have the OPTIONAL or INTENT (OUT) attribute
• In a common block
• Made accessible by use or host association
• A local variable of the procedure containing the BLOCK construct in which the restricted expression
appears
• A local variable of an outer BLOCK construct containing the BLOCK construct in which the restricted
expression appears
• An array constructor where each element and each scalar integer expression of each DO loop is a
restricted expression
• A structure constructor whose components are restricted expression
• A specification inquiry where each designator or function argument is a restricted expression or a variable
whose properties inquired about are not one of the following:
• Dependent on the upper bound of the last dimension of an assumed-size array
• Deferred
• Defined by an expression that is not a restricted expression
• A specification inquiry that is a constant expression
• A reference to the PRESENT intrinsic function
• A reference to any other intrinsic function where each argument is a restricted expression
• A reference to an intrinsic transformational function from the intrinsic module ISO_C_BINDING where
each argument is a restricted expression
• A reference to a specification function where each argument is a restricted expression
• A type parameter of the derived type being defined
• A DO variable within an array constructor, where each scalar integer expression of the corresponding
implied-DO is a restricted expression
• A restricted expression enclosed in parentheses, where each subscript, section subscript, substring
starting and ending point, and type parameter value is a restricted expression, and where any final
subroutine that is invoked is pure
A specification inquiry is a reference to one of the following:
• An intrinsic inquiry function other than PRESENT
• A type parameter inquiry
• An intrinsic inquiry function from the modules IEEE_ARITHMETIC or IEEE_EXCEPTIONS
• The function C_SIZEOF from the intrinsic module ISO_C_BINDING
• The COMPILER_VERSION or COMPILER_OPTIONS inquiry function from the intrinsic module
ISO_FORTRAN_ENV
Specification functions can be used in specification expressions to determine the attributes of data objects.
A function is a specification function if it is a pure function, does not have a dummy procedure argument, and
is not one of the following:
• An standard intrinsic function
• An internal function
• A statement function
• A function with a dummy procedure argument
Evaluation of a specification expression must not directly or indirectly cause invocation of a procedure
defined by the subprogram in which it appears.
817
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The requirement that specification functions be pure ensures that they cannot have side effects that
could affect other objects being declared in the same specification.
The restriction that specification functions cannot be internal ensures that they cannot use host
association to inquire about other objects being declared in the same specification. The restriction
against recursion prevents the creation of a new instance of a procedure during construction of that
procedure.
A variable in a specification expression must have its type and type parameters (if any) specified in one of
the following ways:
• By a previous declaration in the same scoping unit
• By the implicit typing rules currently in effect for the scoping unit
• By host or use association
If a variable in a specification expression is typed by the implicit typing rules, its appearance in any
subsequent type declaration statement must confirm the implied type and type parameters.
If a specification expression includes a specification inquiry that depends on a type parameter or an array
bound or cobound of an entity specified in the same specification statement, the type parameter or array
bound or cobound must be specified in a previous specification statement (or to the left of the inquiry
function in the same statement). The previous specification cannot be in the same entity declaration unless
the specification inquiry appears in an initialization. If a specification expression includes a reference to the
value of an element of an array specified in the same specification statement, the array must be completely
specified in previous declarations.
In the specification part of a module or submodule, if a specification expression includes a reference to a
generic entity, that generic entity must have no specific procedures defined in the module or submodule
subsequent to the specification expression.
In a specification expression, the number of arguments for a function reference is limited to 255.
Examples
The following shows valid specification expressions:
See Also
Array constructors
Structure constructors
Constant Expressions
Intrinsic procedures
Implicit typing rules
Use and host association
PURE procedures
Assignments
An assignment causes variables to be defined or redefined.
Assignment is specified by the following:
• An intrinsic assignment statement
This lets you assign a value to a nonpointer variable.
• A defined assignment statement
This lets you specify an assignment operation.
• pointer assignment
This lets you associate a pointer with a target.
818
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
expression Is of intrinsic type or the same derived type as variable. Its shape
must conform with variable. If necessary, it is converted to the same
type and kind as variable.
Description
Before a value is assigned to the variable, the expression part of the assignment statement and any
expressions within the variable are evaluated. No definition of expressions in the variable can affect or be
affected by the evaluation of the expression part of the assignment statement.
NOTE
When the run-time system assigns a value to a scalar integer or character variable and the variable is
shorter than the value being assigned, the assigned value may be truncated and significant bits (or
characters) lost. This truncation can occur without warning, and can cause the run-time system to
pass incorrect information back to the program.
819
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Each length type parameter of the variable must have the same value as the corresponding type
parameter of the expression unless the variable is an allocatable array and its corresponding type
parameter is deferred.
• If the variable is a coindexed object, each deferred-length type parameter must have the same value as
the corresponding type parameter of the expression. Also, the variable must not be polymorphic, and it
must not have an allocatable ultimate component.
• If the type of the assignment is C_PTR, C_FUNPTR, or TEAM_TYPE, the variable becomes undefined if
variable and expression are not on the same image.
The following sections discuss numeric, logical, character, derived- type, and array intrinsic assignment.
See Also
Arrays
Pointers
Derived data types
Defining Generic Assignment for details on subroutine subprograms that define assignment
Examples of Intrinsic Assignment to Polymorphic Variables
820
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the expression (E) is of type logical, it is first converted to type integer as follows:
• If E evaluates to .TRUE. the result is -1 or 1 depending on the setting of the compiler option
fpscomp logicals
• Otherwise the result is 0
The result of this conversion is then interpreted according to the above table.
Examples
Valid Numeric Assignment Statements
BETA = -1./(2.*X)+A*A /(4.*(X*X))
PI = 3.14159
SUM = SUM + 1.
See Also
INT
REAL
DBLE
QEXT
CMPLX
AIMAG
Examples
The following examples demonstrate valid logical assignment statements:
PAGEND = .FALSE.
PRNTOK = LINE .LE. 132 .AND. .NOT. PAGEND
ABIG = A.GT.B .AND. A.GT.C .AND. A.GT.D
LOGICAL_VAR = 123 ! Assigns .TRUE. to LOGICAL_VAR
821
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Valid Character Assignment Statements. (All variables are of type character.)
FILE = 'PROG2'
REVOL(1) = 'MAR'//'CIA'
LOCA(3:8) = 'PLANT5'
TEXT(I,J+1)(2:N-1) = NAME//X
Examples
The following example shows derived-type assignment:
TYPE DATE
LOGICAL(1) DAY, MONTH
INTEGER(2) YEAR
END TYPE DATE
TYPE(APPOINTMENT) MEETING
DO I = 1,7
CALL GET_DATE(TODAY)
822
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
THIS_WEEK(I) = TODAY
END DO
MEETING%APP_DATE = TODAY
See Also
Derived types
Pointer assignments
Examples
X = Y
The corresponding elements of Y are assigned to those of X element by element; the first element of Y is
assigned to the first element of X, and so forth. The processor can perform the element-by-element
assignment in any order.
The following example shows a scalar assigned to an array:
B(C+1:N, C) = 0
This sets the elements B (C+1,C), B (C+2,C),...B (N,C) to zero.
The following example causes the values of the elements of array A to be reversed:
REAL A(20)
...
A(1:20) = A(20:1:-1)
See Also
Arrays
Array constructors
WHERE for details on masked array assignment
FORALL for details on element array assignment
823
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A polymorphic entity that is not an unlimited polymorphic entity is type compatible with entities of the same
declared type or any of its extensions. Even though an unlimited polymorphic entity is not considered to have
a declared type, it is type compatible with all entities.
variable and expr must be of the same rank.
If expr is a scalar and variable is allocated, then expr is treated as an array with the same bounds as
variable, so the bounds of variable would remain unchanged. It is an error if variable is unallocated when
expr is a scalar.
In the examples below, we have the following types:
Type type1
End type
Type type2
End type
824
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Subroutines
825
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Pointer Assignments
In ordinary assignment involving pointers, the pointer is an alias for its target. In pointer assignment, the
pointer is associated with a target. If the target is undefined or disassociated, the pointer acquires the same
status as the target. Pointer assignment has the following form:
pointer-object [ (s-spec) ] => target
target Is a variable or expression. Its type and kind parameters, and rank
must be the same as pointer-object unless bounds remapping is
specified. It cannot be an array section with a vector subscript.
Description
If the target is a variable, it must have the POINTER or TARGET attribute, or be a subobject whose parent
object has the TARGET attribute.
If the target is an expression, the result must be a pointer.
If the target is not a pointer (it has the TARGET attribute), the pointer object is associated with the target.
If the target is a pointer (it has the POINTER attribute), its status determines the status of the pointer object,
as follows:
• If the pointer is associated, the pointer object is associated with the same object as the target
• If the pointer is disassociated, the pointer object becomes disassociated
• If the pointer is undefined, the pointer object becomes undefined
A pointer must not be referenced or defined unless it is associated with a target that can be referenced or
defined.
When pointer assignment occurs, any previous association between the pointer object and a target is
terminated.
Pointers can also be assigned for a pointer structure component by execution of a derived-type intrinsic
assignment statement or a defined assignment statement.
Pointers can also become associated by using the ALLOCATE statement to allocate the pointer.
Pointers can become disassociated by deallocation, nullification of the pointer (using the DEALLOCATE or
NULLIFY statements), or by reference to the NULL intrinsic function.
Pointer assignment for arrays allows lower bounds to be specified. The specified lower bounds can be any
scalar integer expressions.
Remapping of the elements of a rank-one array is permitted. The mapping is in array-element order and the
target array must be large enough. The specified bounds may be any scalar integer expressions.
826
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following are examples of pointer assignments:
INTEGER, POINTER :: P, N
INTEGER, TARGET :: M
INTEGER S
M = 14
N => M ! N is associated with M
P => N ! P is associated with M through N
S = P + 5
The value assigned to S is 19 (14 + 5).
You can use the intrinsic function ASSOCIATED to find out if a pointer is associated with a target or if two
pointers are associated with the same target. For example:
See Also
Arrays
ALLOCATE statement
DEALLOCATE statement
NULLIFY statement
NULL intrinsic function
827
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
POINTER attribute
TARGET attribute
Defined assignments
Intrinsic Assignments for details on derived-type intrinsic assignments
Specification Statements
A specification statement is a nonexecutable statement that declares the attributes of data objects. In
Standard Fortran, many of the attributes that can be defined in specification statements can also be
optionally specified in type declaration statements.
The following are specification statements:
• Type Declarations
Explicitly specify the properties (for example: data type, rank, and extent) for data objects or functions.
• ALLOCATABLE attribute and statement
Specifies that an array is an allocatable array with a deferred shape. The shape of an allocatable array is
determined when an ALLOCATE statement is executed, dynamically allocating space for the array.
• ASYNCHRONOUS attribute and statement
Specifies that a variable can be used for asynchronous input and output.
• AUTOMATIC and STATIC attributes and statements
Control the storage allocation of variables in subprograms.
• BIND attribute and statement
Specifies that an object is interoperable with C and has external linkage.
• CODIMENSION attribute and statement
Specifies that an entity is a coarray.
• COMMON statement
Defines one or more contiguous areas, or blocks, of physical storage (called common blocks) that can be
accessed by any of the scoping units in an executable program. COMMON statements also define the
order in which variables and arrays are stored in each common block, which can prevent misaligned data
items.
• CONTIGUOUS attribute and statement
Specifies that the target of a pointer or an assumed-sized array is contiguous.
• DATA statement
Assigns initial values to variables before program execution.
• DIMENSION attribute and statement
Specifies that an object is an array, and defines the shape of the array.
• EQUIVALENCE statement
Specifies that a storage area is shared by two or more objects in a program unit. This causes total or
partial storage association of the objects that share the storage area.
• EXTERNAL attribute and statement
Allows an external or dummy procedure to be used as an actual argument.
• IMPLICIT statement
Overrides the default implicit typing rules for names.
• INTENT attribute and statement
Specifies the intended use of one or more dummy arguments.
• INTRINSIC attribute and statement
Allows the specific name of an intrinsic procedure to be used as an actual argument. Certain specific
function names cannot be used. For more information, see Intrinsic Functions Not Allowed as Actual
Arguments.
• NAMELIST statement
828
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Associates a name with a list of variables. This group name can be referenced in some input/output
operations.
• OPTIONAL attribute and statement
Allows dummy arguments to be omitted in a procedure reference.
• PARAMETER attribute and statement
Defines a named constant.
• POINTER attribute and statement
Specifies that an object or a procedure is a pointer (a dynamic variable).
• PRIVATE and PUBLIC and attributes and statements
Specifies the accessibility of entities in a module. (These attributes are also called accessibility attributes.)
• PROTECTED attribute and statement
Specifies limitations on the use of module entities.
• SAVE attribute and statement
Causes the values and definition of objects to be retained after execution of a RETURN or END statement
in a subprogram.
• TARGET attribute and statement
Specifies that an object can become the target of a pointer.
• VALUE attribute and statement
Specifies a type of argument association for a dummy argument.
• VOLATILE attribute and statement
Specifies that the value of an object is entirely unpredictable, based on information local to the current
program unit.
See Also
BLOCK DATA statement
PROGRAM statement
Derived data types
DATA
Initialization expressions
Intrinsic Data Types
Implicit Typing Rules
Specification of Data Type
Type Declarations
A type declaration is a nonexecutable statement specifying the data type of one or more variables. The
declaration can be specified in an INTEGER, REAL, DOUBLE PRECISION, COMPLEX, DOUBLE COMPLEX,
CHARACTER, LOGICAL, or TYPE statement. A type declaration statement may also specify attributes for the
variables.
BYTE1
LOGICAL2
829
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER3
REAL4
COMPLEX5
In noncharacter type declarations, you can optionally specify the name of the data object or function as v*n,
where n is the length (in bytes) of v. The length specified overrides the length implied by the data type.
The value for n must be a valid length for the type of v. The type specifiers BYTE, DOUBLE PRECISION, and
DOUBLE COMPLEX have one valid length, so the n specifier is invalid for them.
For an array specification, the n must be placed immediately following the array name; for example, in an
INTEGER declaration, IVEC*2(10) is an INTEGER(2) array of 10 elements.
Note that certain compiler options can affect the defaults for numeric and logical data types.
Examples
In a noncharacter type declaration, a subsequent kind parameter overrides any initial kind parameter. For
example, consider the following statements:
See Also
Type Declarations for details on the general form and rules for type declarations
830
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
len Is a length type parameter. It can have one of the following values:
• A scalar integer expression
• *
• :
The following rules also apply:
• In keyword forms
The len is a specification expression, an asterisk (*), or a colon (:).
If no length is specified, the default length is 1.
If the length evaluates to a negative value, the length of the
character entity is zero.
• In the obsolete form
The len is a specification expression or an asterisk enclosed in
parentheses, or a scalar integer literal constant (with no kind
parameter). The comma is permitted only if no double colon (::)
appears in the type declaration statement.
This form can also (optionally) be specified following the name of
the data object or function (v*len). In this case, the length
specified overrides any length following the CHARACTER type
specifier.
The largest valid value for len in both forms is 2**31-1 on IA-32
architecture; 2**63-1 on Intel® 64 architecture. Negative values are
treated as zero.
Description
An automatic object can appear in a character declaration. The object cannot be a dummy argument, and its
length must be declared with a specification expression that is not a constant expression.
The length specified for a character-valued statement function or statement function dummy argument of
type character must be an integer constant expression.
When an asterisk length specification *(*) is used for a function name or dummy argument, it assumes the
length of the corresponding function reference or actual argument. Similarly, when an asterisk length
specification is used for a named constant, the name assumes the length of the actual constant it represents.
For example, STRING assumes a 9-byte length in the following statements:
CHARACTER*(*) STRING
PARAMETER (STRING = 'VALUE IS:')
A function name must not be declared with a * length unless it is of type CHARACTER and is the name of the
result of an external function or the name of a dummy function.
831
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A function name declared with a * length must not be an array, a pointer, recursive, elemental, or pure.
If the CHARACTER type declaration statement specifies a colon (:) length, the length type parameter is a
deferred type parameter. An entity or component with a deferred type parameter must specify the
ALLOCATABLE or POINTER attribute. A deferred type parameter is a length type parameter whose value can
change during execution of the program.
The obsolete form is an obsolescent feature in the Fortran standard.
Examples
In the following example, the character string last_name is given a length of 20:
CHARACTER*32 string1
CHARACTER string2*32
The following examples show ways to specify strings of unknown length:
CHARACTER string3*(*)
CHARACTER*(*) string4
The following example declares an array NAMES containing 100 32-character elements, an array SOCSEC
containing 100 9-character elements, and a variable NAMETY that is 10 characters long and has an initial
value of 'ABCDEFGHIJ'.
SUBROUTINE AUTO_NAME(NAME1)
CHARACTER(LEN = *) NAME1
CHARACTER(LEN = LEN(NAME1)) NAME2
The following example shows the handling of a deferred-length CHARACTER variables:
832
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Obsolescent Language Features in the Fortran Standard
Data Types of Scalar Variables
Assumed-Length Character Arguments for details on asterisk length specifications
Type Declarations for details on the general form and rules for type declaration statements
Examples
The following are examples of derived-type declarations:
TYPE(EMPLOYEE) CONTRACT
...
TYPE(SETS), DIMENSION(:,:), ALLOCATABLE :: SUBSET_1
The following example shows a public type with private components:
TYPE LIST_ITEMS
PRIVATE
...
TYPE(LIST_ITEMS), POINTER :: NEXT, PREVIOUS
END TYPE LIST_ITEMS
See Also
TYPE
Use and host association
PUBLIC
PRIVATE
Structure constructors
Type Declarations for details on the general form and rules for type declarations
The array specification can be appended to the name of the array when the array is declared.
833
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following examples show array declarations:
SUBROUTINE SUB(N, C, D, Z)
REAL, DIMENSION(N, 15) :: IARRY ! An explicit-shape array
REAL C(:), D(0:) ! An assumed-shape array
REAL, POINTER :: B(:,:) ! A deferred-shape array pointer
REAL, ALLOCATABLE, DIMENSION(:) :: K ! A deferred-shape allocatable array
REAL :: Z(N,*) ! An assumed-size array
INTEGER, PARAMETER :: R(*) = [1,2,3] ! An implied-shape constant array
See Also
Type Declarations for details on the general form and rules for type declaration statements
Explicit-Shape Specifications
An explicit-shape array is declared with explicit values for the bounds in each dimension of the array. An
explicit-shape specification takes the following form:
([dl:] du[, [dl:] du] ...)
834
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Automatic Arrays
An automatic array is an explicit-shape array that is a local variable. Automatic arrays are only allowed in
function and subroutine subprograms, and are declared in the specification part of the subprogram. At least
one bound of an automatic array must be a nonconstant specification expression. The bounds are determined
when the subprogram is called.
The following example shows automatic arrays:
Adjustable Arrays
An adjustable array is an explicit-shape array that is a dummy argument to a subprogram. At least one
bound of an adjustable array must be a nonconstant specification expression. The bounds are determined
when the subprogram is called.
The array specification can contain integer variables that are either dummy arguments or variables in a
common block.
When the subprogram is entered, each dummy argument specified in the bounds must be associated with an
actual argument. If the specification includes a variable in a common block, the variable must have a defined
value. The array specification is evaluated using the values of the actual arguments, as well as any constants
or common block variables that appear in the specification.
The size of the adjustable array must be less than or equal to the size of the array that is its corresponding
actual argument.
To avoid possible errors in subscript evaluation, make sure that the bounds expressions used to declare
multidimensional adjustable arrays match the bounds as declared by the caller.
In the following example, the function calculates the sum of the elements of a rank-two array. Notice how the
dummy arguments M and N control the iteration:
FUNCTION THE_SUM(A, M, N)
DIMENSION A(M, N)
SUMX = 0.0
DO J = 1, N
DO I = 1, M
SUMX = SUMX + A(I, J)
END DO
835
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END DO
THE_SUM = SUMX
END FUNCTION
The following are examples of calls on THE_SUM:
DIMENSION ARRAY(9,5)
L = 9
M = 5
CALL SUB(ARRAY,L,M)
END
SUBROUTINE SUB(X,I,J)
DIMENSION X(-I/2:I/2,J)
X(I/2,J) = 999
J = 1
I = 2
END
The assignments to I and J do not affect the declaration of adjustable array X as X(-4:4,5) on entry to
subroutine SUB.
See Also
Specification expressions
Assumed-Shape Specifications
An assumed-shape array is a dummy argument array that assumes the shape of its associated actual
argument array. An assumed-shape specification takes the following form:
([dl]:[, [dl]:] ...)
Examples
The following is an example of an assumed-shape specification:
INTERFACE
SUBROUTINE SUB(M)
INTEGER M(:, 1:, 5:)
END SUBROUTINE
END INTERFACE
INTEGER L(20, 5:25, 10)
CALL SUB(L)
836
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SUBROUTINE SUB(M)
INTEGER M(:, 1:, 5:)
END SUBROUTINE
Array M has the same extents as array L, but array M has bounds (1:20, 1:21, 5:14).
Note that an explicit interface is required when calling a routine that expects an assumed-shape or pointer
array.
Consider the following:
SUBROUTINE ASSUMED(A)
REAL A(:, :, :)
Array A has rank 3, indicated by the three colons (:) separated by commas (,). However, the extent of each
dimension is unspecified. When the subroutine is called, A takes its shape from the array passed to it. For
example, consider the following:
REAL X (4, 7, 9)
...
CALL ASSUMED(X)
This declaration gives A the dimensions (4, 7, 9). The actual array and the assumed-shape array must have
the same rank.
Consider the following:
SUBROUTINE ASSUMED(A)
REAL A(3:, 0:, -2:)
...
If the subroutine is called with the same actual array X(4, 7, 9), as in the previous example, the lower and
upper bounds of A would be:
Assumed-Size Specifications
An assumed-size array is a dummy argument array that assumes the size (only) of its associated actual
argument array, or the associate name of a RANK (*) block in a SELECT RANK construct. The rank and
extents can differ for the actual and dummy arrays. An assumed-size specification takes the following form:
([expli-shape-spec,] [expli-shape-spec,] ... [dl:] *)
837
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If the actual argument is a default character array, array element, or array element substring, and it
begins at character storage unit b of an array with n character storage units, the size of the dummy array
is as follows:
MAX(INT((n + 1 - b)/y), 0)
The y is the length of an element of the dummy array.
An assumed-size array can only be used as a whole array reference in the following cases:
• When it is an actual argument in a procedure reference that does not require the shape
• In the intrinsic function LBOUND
Because the actual size of an assumed-size array is unknown, an assumed-size array cannot be used as any
of the following in an I/O statement:
• An array name in the I/O list
• A unit identifier for an internal file
• A runtime format specifier
Examples
The following is an example of an assumed-size specification:
SUBROUTINE SUB(A, N)
REAL A, N
DIMENSION A(1:N, *)
...
The following example shows that you can specify lower bounds for any of the dimensions of an assumed-
size array, including the last:
SUBROUTINE ASSUME(A)
REAL A(-4:-2, 4:6, 3:*)
See Also
Array Elements
Assumed-Rank Specifications
An assumed-rank array is a dummy argument whose rank is inherited from the actual argument associated
with it, or it is the associate name of a RANK DEFAULT block of a SELECT RANK construct. It can have zero
rank.
You declare an assumed-rank object (a dummy variable) by using DIMENSION(..) or (..)array bounds in its
declaration.
Its rank is assumed from its effective argument, which means it is passed by descriptor.
An assumed-rank entity must not have the CODIMENSION or VALUE attribute. It can have the CONTIGUOUS
attribute.
An assumed-rank variable name must not appear in a designator or expression except as one of the
following:
• An actual argument corresponding to a dummy argument that is assumed-rank
• The argument of the C_LOC function in the ISO_C_BINDING intrinsic module
• The first argument in a reference to an intrinsic inquiry function
• The selector of a SELECT RANK construct
If an assumed-size or nonallocatable, nonpointer, assumed-rank array is an actual argument corresponding
to a dummy argument that is an INTENT(OUT) assumed-rank array, it must not be polymorphic, finalizable,
of a type with an allocatable ultimate component, or of a type for which default initialization is specified.
You can find the rank of an assumed-rank object by using the RANK intrinsic.
If a procedure has an assumed-rank argument, the procedure must have an explicit interface.
838
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When an assumed-rank object is passed from Fortran to a BIND(C) routine, it is passed by C descriptor. A
Fortran procedure that has the BIND(C) language-binding-spec attribute will also receive an assumed-rank
object by C descriptor.
Examples
The following shows an assumed-rank object:
INTERFACE
SUBROUTINE csub (baz) BIND(C)
REAL, DIMENSION(..) :: baz
END SUBROUTINE
END INTERFACE
See Also
Argument Association
RANK
Deferred-Shape Specifications
A deferred-shape array is an array pointer or an allocatable array.
The array specification contains a colon (:) for each dimension of the array. No bounds are specified. The
bounds (and shape) of allocatable arrays and array pointers are determined when space is allocated for the
array during program execution.
An array pointer is an array declared with the POINTER attribute. Its bounds and shape are determined when
it is associated with a target by pointer assignment, or when the pointer is allocated by execution of an
ALLOCATE statement.
In pointer assignment, the lower bound of each dimension of the array pointer is the result of the LBOUND
intrinsic function applied to the corresponding dimension of the target. The upper bound of each dimension is
the result of the UBOUND intrinsic function applied to the corresponding dimension of the target.
An actual argument that is a pointer can be associated with a nonpointer dummy argument. Normally, a
pointer dummy argument can be associated only with a pointer actual argument. However, a pointer dummy
argument with INTENT(IN) can be argument associated with a non-pointer actual argument with the TARGET
attribute. During the execution of the procedure, it is pointer associated with the actual argument.
A function result can be declared to have the pointer attribute.
An allocatable array is declared with the ALLOCATABLE attribute. Its bounds and shape are determined when
the array is allocated by execution of an ALLOCATE statement.
Examples
The following are examples of deferred-shape specifications:
839
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DIMENSION P(:, :, :)
POINTER P
TARGET B(:,:)
ALLOCATABLE B
If the deferred-shape array is an array of pointers, its size, shape, and bounds are set in an ALLOCATE
statement or in the pointer assignment statement when the pointer is associated with an allocated target. A
pointer and its target must have the same rank.
For example:
program test
integer, target :: j = 17
call f (j)
contains
subroutine f (i)
integer, intent (in), pointer :: i
print *,i
end subroutine f
end program test
See Also
POINTER attribute
ALLOCATABLE attribute
ALLOCATE statement
Pointer assignment
LBOUND intrinsic function
UBOUND intrinsic function
Implied-Shape Specifications
Short Description
An implied-shape array is a named constant that takes its shape from the constant expression in its
declaration. An implied-shape specification takes the following form:
([dl:] du [, [dl:] du] ...)
840
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following examples show implied-shape specifications:
841
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TRIPLE(1,1,1) 1
TRIPLE(2,1,1) 2
TRIPLE(1,2,1) 3
TRIPLE(2,2,1) 4 TABLE(1,1) 1
TRIPLE(1,1,2) 5 TABLE(2,1) 2
TRIPLE(2,1,2) 6 TABLE(1,2) 3
TRIPLE(1,2,2) 7 TABLE(2,2) 4
TRIPLE(2,2,2) 8
Each of the following statements also aligns the two arrays as shown in the above table:
EQUIVALENCE(TABLE, TRIPLE(2,2,1))
EQUIVALENCE(TRIPLE(1,1,2), TABLE(2,1))
You can also make arrays equivalent with nonunity lower bounds. For example, an array defined as A(2:3,4)
is a sequence of eight values. A reference to A(2,2) refers to the third element in the sequence. To make
array A(2:3,4) share storage with array B(2:4,4), you can use the following statement:
EQUIVALENCE(A(3,4), B(2,4))
The entire array A shares part of the storage allocated to array B. The following table shows how these
statements align the arrays. The arrays can also be aligned by the following statements:
EQUIVALENCE(A, B(4,1))
EQUIVALENCE(B(3,2), A(2,2))
Equivalence of Arrays with Nonunity Lower Bounds
Array B Array A
B(2,1) 1
B(3,1) 2
B(4,1) 3 A(2,1) 1
B(2,2) 4 A(3,1) 2
B(3,2) 5 A(2,2) 3
B(4,2) 6 A(3,2) 4
B(2,3) 7 A(2,3) 5
B(3,3) 8 A(3,3) 6
B(4,3) 9 A(2,4) 7
B(2,4) 10 A(3,4) 8
B(3,4) 11
B(4,4) 12
842
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Only in the EQUIVALENCE statement can you identify an array element with a single subscript (the linear
element number), even though the array was defined as multidimensional. For example, the following
statements align the two arrays as shown in the above table:
DIMENSION B(2:4,1:4), A(2:3,1:4)
EQUIVALENCE(B(6), A(4))
Equivalence of Substrings
843
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the character substring references are array elements, the EQUIVALENCE statement sets associations
between the other corresponding characters in the complete arrays.
844
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Character elements of arrays can overlap at any character position. For example, the following statements
cause character arrays FIELDS and STAR to share storage (see the following figure).
CHARACTER FIELDS(100)*4, STAR(5)*5
EQUIVALENCE(FIELDS(1)(2:4), STAR(2)(3:5))
Equivalence of Character Arrays
845
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The EQUIVALENCE statement cannot assign the same storage location to two or more substrings that start at
different character positions in the same character variable or character array. The EQUIVALENCE statement
also cannot assign memory locations in a way that is inconsistent with the normal linear storage of character
variables and arrays.
Examples
The following two figures demonstrate valid and invalid extensions of the common block, respectively.
The second example is invalid because the extended portion, B(1), precedes the first element of the common
block.
The following example shows a valid EQUIVALENCE statement and an invalid EQUIVALENCE statement in the
context of a common block.
COMMON A, B, C
DIMENSION D(3)
EQUIVALENCE(B, D(1)) ! Valid, because common block is extended
! from the end.
COMMON A, B, C
846
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DIMENSION D(3)
EQUIVALENCE(B, D(3)) ! Invalid, because D(1) would extend common
! block to precede A's location.
Dynamic Allocation
Data objects can be static or dynamic. If a data object is static, a fixed amount of memory storage is created
for it at compile time and is not freed until the program exits. If a data object is dynamic, memory storage
for the object can be created (allocated), altered, or freed (deallocated) as a program executes.
Pointers, classes, deferred length character, allocatable scalars and arrays, and automatic arrays are dynamic
data objects.
No storage space is created for a pointer until it is allocated with an ALLOCATE statement or until it is
assigned to an allocated target. The storage space allocated is uninitialized.
An ALLOCATE statement can also be used to create storage for an allocatable array. A DEALLOCATE
statement can be used to free the storage space reserved in a previous ALLOCATE statement. It also causes
any pointers to become disassociated.
A pointer can be dynamically disassociated from a target by using a NULLIFY statement.
Automatic arrays differ from allocatable arrays in that they are automatically allocated and deallocated
whenever you enter or leave a procedure, respectively.
Dynamic allocation occurs at runtime and is handled by the Fortran runtime library. Several restrictions on
allocation and deallocation must be observed when these operations on a specific object are performed in
program units that are separately compiled. When allocation and deallocation of an object are split between
procedures in static code and dynamic shared libraries (.so files on Linux*) or dynamic-link libraries (DLLs on
Windows*), the following applies:
• If the dynamic library is compiled with the [q or Q]openmp compiler option, then the main program
must be compiled and linked with [q or Q]openmp to include the OpenMP memory handling routines in
the program.
• If the dynamic library allocates data in High bandwidth (HBW) memory on Linux*, then the program must
be linked with the libmemkind library to include the HBW memory handling routines in the program.
NOTE
Dynamic memory allocation is limited by several factors, including swap file size and memory
requirements of other applications that are running. Dynamic allocations that are too large or
otherwise attempt to use the protected memory of other applications result in General Protection Fault
errors.
If you encounter an unexpectedly low limit, you may need to reset your virtual memory size through
the Control Panel or redefine the swap file size.
Some programming techniques can help minimize memory requirements, such as using one large
array instead of two or more individual arrays. Allocated arrays that are no longer needed should be
deallocated.
See Also
qopenmp, Qopenmp compiler option
Pointer Assignments
Automatic arrays
NULL intrinsic function, which can also be used to disassociate a pointer
TARGET
Effects of Allocation
847
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When you allocate allocatable variables, allocatable arrays, and pointer targets, it can have various effects on
your program.
For more information, see the topics in this section.
Allocation Status
During program execution, the allocation status of an allocatable array is one of the following:
848
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(4) :: N
READ (5,*) N ! Reads an integer value
CALL MAT(N)
END
! Subroutine MAT uses the typed integer value to display the square
! root values of numbers from 1 to N (the number read)
SUBROUTINE MAT(N)
REAL(4), ALLOCATABLE :: SQR(:) ! Declares SQR as a one-dimensional
! allocatable array
ALLOCATE (SQR(N)) ! Allocates array SQR
DO J=1,N
SQR(J) = SQRT(FLOATJ(J)) ! FLOATJ converts integer to REAL
ENDDO
See Also
ALLOCATED intrinsic function
ALLOCATE statement
849
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The intrinsic function ASSOCIATED can be used to determine whether a pointer is currently associated with a
target. The association status of the pointer must be defined. For example:
See Also
POINTER statement and attribute
Pointer assignments
ASSOCIATED intrinsic function
Effects of Deallocation
When you deallocate allocatable variables, allocatable arrays, and pointer targets, it can have various effects
on your program.
For more information, see the topics in this section.
850
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
There is also an implicit synchronization of all images in association with the deallocation of a coarray or
coarray subcomponent caused by the execution of a RETURN or END statement.
The intrinsic function ALLOCATED can be used to determine whether a variable is allocated or unallocated.
Consider the following example:
SUBROUTINE PROCESS
REAL, ALLOCATABLE :: TEMP(:)
REAL, ALLOCATABLE, SAVE :: X(:)
...
END SUBROUTINE PROCESS
Upon return from subroutine PROCESS, the allocation status of X is preserved because X has the SAVE
attribute. TEMP does not have the SAVE attribute, so it will be deallocated if it was allocated. On the next
invocation of PROCESS, TEMP will have an allocation status of unallocated.
See Also
Host association
TARGET statement and attribute
RETURN statement
END statement
SAVE statement
851
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A pointer must not be deallocated if it is associated with an allocatable array, or it is associated with a portion
of an object (such as an array element or an array section).
If a pointer is deallocated, the association status of any other pointer associated with the target (or portion of
the target) becomes undefined.
Execution of a RETURN or END statement in a subprogram causes the pointer association status of any
pointer declared or accessed in the procedure to become undefined, unless any of the following applies to the
pointer:
• It has the SAVE attribute.
• It is in the scoping unit of a module that is accessed by another scoping unit which is currently executing.
• It is accessible by host association.
• It is in blank common.
• It is in a named common block that appears in another scoping unit that is currently executing.
• It is the return value of a function declared with the POINTER attribute.
If the association status of a pointer becomes undefined, it cannot subsequently be referenced or defined.
Examples
The following example shows deallocation of a pointer:
INTEGER ERR
REAL, POINTER :: PTR_A(:)
...
ALLOCATE (PTR_A(10), STAT=ERR)
...
DEALLOCATE(PTR_A)
See Also
POINTER statement and attribute
COMMON statement
NULL intrinsic function
Host association
TARGET statement and attribute
RETURN statement
END statement
SAVE statement
Execution Control
Execution of a program consists of the asynchronous execution of the program in a fixed number of one or
more of its images. Each image has its own execution environment, including floating-point status, a set of
data objects, input/output units, and procedure pointers.
A program normally executes statements in the order in which they are written. Executable control
constructs and statements, and procedure invocations, modify this normal execution by transferring control
to another statement in the program, or by selecting blocks (groups) of constructs and statements for
execution or repetition.
Procedures may be invoked by the CALL statement (subroutine), during expression evaluation (function), or
as part of data definition and handling (user-defined operators and FINAL procedures). There are many ways
to define a procedure: for example, external, internal, contained, type-bound, defined operator or
assignment, and module. All procedures have one entry point; procedures usually return to their caller.
The control constructs ASSOCIATE, CASE, DO, IF, SELECT RANK, and SELECT TYPE contain blocks and can be
named. The name must be a unique identifier in the scoping unit, and must appear on the initial line and
terminal line of the construct. On the initial line, the name is separated from the statement keyword by a
colon (:).
A block can contain any executable Fortran statement except an END statement. You can transfer control out
of a block, but you cannot transfer control into another block.
852
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DO loops cannot partially overlap blocks. The DO statement and its terminal statement must appear together
in a statement block.
The following are execution control statements or constructs:
• ASSOCIATE construct
Creates a temporary association between a named entity and a variable or the value of an expression.
The association lasts for the duration of the block.
• BLOCK construct
Executes a block of statements or constructs that can contain declarations.
• CALL statement
Transfers control to a subroutine subprogram.
• CASE construct
Conditionally executes one block of constructs or statements depending on the value of a scalar
expression in a SELECT CASE statement.
• CONTINUE statement
Primarily used to terminate a labeled DO construct when the construct would otherwise end improperly
with either a GO TO, arithmetic IF, or other prohibited control statement.
• CRITICAL construct
Limits execution of a block to one image at a time.
• DO construct
Controls the repeated execution of a block of statements or constructs. The following statements are used
in DO constructs:
• DO CONCURRENT statement
Specifies that there are no data dependencies between the iterations of a DO loop.
• DO WHILE statement
Executes the range of a DO construct while a specified condition remains true.
• CYCLE statement
Interrupts the current execution cycle of the innermost (or named) DO construct.
• EXIT statement
Terminates execution of a DO construct
• END statement
Marks the end of a program unit.
• IF construct and IF statement
The IF construct conditionally executes one block of statements or constructs. The IF statement
conditionally executes one statement. The decision to transfer control or to execute the statement or
block is based on the evaluation of a logical expression within the IF statement or construct.
• PAUSE statement
Temporarily suspends program execution until the user or system resumes execution.
These statements are deleted features in the Fortran Standard. Intel® Fortran fully supports features
deleted in the Fortran Standard.
• RETURN statement
Transfers control from a subprogram to the calling program unit.
• SELECT RANK construct
Selects for execution at most one of its constituent blocks based on the rank of an assumed-rank variable.
• SELECT TYPE construct
Selects for execution at most one of its constituent blocks based on the dynamic type of an expression
specified.
• STOP and ERROR STOP statement
The STOP statement initiates normal termination of an image before the execution of an END statement
of the main program. The ERROR STOP statement initiates error termination.
853
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Program Termination
Program termination may involve flushing I/O buffers, closing open I/O files, writing of a STOP code or an
ERROR STOP code, or reporting an error status on one or more images. There are two types of image
termination, normal termination and error termination.
Normal termination occurs when an image executes a STOP statement or an END [PROGRAM] statement. If
there are multiple images running, execution of STOP or END [PROGRAM] statement effects only the image
that executes the statement; it has no effect on other images. When an image initiates normal termination,
its image status becomes STOPPED, and it waits until all other active images initiate normal termination at
which time all images terminate execution. While an image has the status STOPPED, its coarrays are still
accessible for reference or definition by other active images.
Error termination of one image causes termination of all other images. Error termination is not initiated if an
error condition occurs during the execution of an I/O statement which specifies either an IOSTAT= or ERR=
specifier, during the execution of an image control statement that specifies a STAT= specifier, or during a
reference to an intrinsic function with a present STAT argument. Otherwise, if an error condition occurs, error
termination is initiated.
A program terminates execution when all images that have not failed terminate execution.
Statement Restriction
DO terminal statement The branch must be taken from within its nonblock
DO construct1.
END BLOCK The branch must be taken from within its BLOCK
construct.
END SELECT The branch must be taken from within its SELECT
CASE, SELECT RANK, or SELECT TYPE construct.
1Ifthe terminal statement is shared by more than one nonblock DO construct, the branch can only be
taken from within the innermost DO construct.
854
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Statement Restriction
2You can branch to an END IF statement from outside the IF construct; this is a deleted feature in the
Fortran Standard. Intel® Fortran fully supports features deleted in the Fortran Standard.
See Also
ASSOCIATE
BLOCK
DO Statement
FORALL
IF constructs
SELECT CASE
SELECT RANK
SELECT TYPE
WHERE
Effects of DO Constructs
This section discusses ways you can use DO loops and their effects on your program.
For more information, see the topics in this section.
855
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
A DO variable or expression of type real is a deleted feature in the Fortran Standard. Intel® Fortran fully
supports features deleted in the Fortran Standard.
The following steps are performed in iteration loop control:
1. The expressions expr1, expr2, and expr3 are evaluated to respectively determine the initial, terminal,
and increment parameters.
The increment parameter (expr3) is optional and must not be zero. If an increment parameter is not
specified, it is assumed to be of type default integer with a value of 1.
2. The DO variable (do-var) becomes defined with the value of the initial parameter (expr1).
3. The iteration count is determined as follows:
Examples
The following example specifies 25 iterations:
DO 100 K=1,50,2
K=49 during the final iteration, K=51 after the loop.
The following example specifies 27 iterations:
DO 350 J=50,-2,-2
J=-2 during the final iteration, J=-4 after the loop.
The following example specifies 9 iterations:
DO NUMBER=5,40,4
NUMBER=37 during the final iteration, NUMBER=41 after the loop. The terminating statement of this DO loop
must be END DO.
See Also
f66
Deleted and Obsolescent Language Features for details on obsolescent features in Standard
Fortran, as well as features deleted in Standard Fortran
856
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Nested DO Constructs
A DO construct can contain one or more complete DO constructs (loops). The range of an inner nested DO
construct must lie completely within the range of the next outer DO construct. Nested nonblock DO
constructs can share a labeled terminal statement.
The following figure shows correctly and incorrectly nested DO constructs:
857
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In a nested DO construct, you can transfer control from an inner construct to an outer construct. However,
you cannot transfer control from an outer construct to an inner construct.
858
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If two or more nested DO constructs share the same terminal statement, you can transfer control to that
statement only from within the range of the innermost construct. Any other transfer to that statement
constitutes a transfer from an outer construct to an inner construct, because the shared statement is part of
the range of the innermost construct.
When the nested DO constructs contain no statements between the DO statements in the nest of DO
constructs, the nest is called “perfectly nested”. When perfectly nested DO constructs are modified by a
COLLAPSE clause in any of these OpenMP* directives:
• !$OMP DISTRIBUTE
• !$OMP DO
• !$OMP SIMD
There are restrictions on which general compiler directives (see General Compiler Directives) and OpenMP
Fortran compiler directives (see OpenMP Fortran Compiler Directives) can appear before the DO statements
in the nested DO construct:
• Any OpenMP or general directives that are allowed to affect DO loops are allowed prior to the first DO loop
of the "perfectly nested" DO construct.
• It is an error if any of these directives are between any of the perfectly nested DO loop statements for the
loops affected by the COLLAPSE clause.
Examples
In the following example, COLLAPSE (1) on affects the DO I loop. Therefore general directives before the DO
J loop, which is at level 2, are allowed:
do i = …
!dir$ loop count … ! this is allowed since collapse only applies
! to the i-loop, not the j-loop
do j = …
enddo ! end for j-loop
enddo ! end for i-loop
In the following example, COLLAPSE (2) affects the DO I loop and the DO J loop but not the DO k loop.
859
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
do j = …
enddo ! end for j-loop
enddo ! end for i-loop
See Also
!$OMP DISTRIBUTE
!$OMP DO
!$OMP SIMD
Rules for General Directives that Affect DO loops
Extended Range
A DO construct has an extended range if both of the following are true:
• The DO construct contains a control statement that transfers control out of the construct.
• Another control statement returns control back into the construct after execution of one or more
statements.
The range of the construct is extended to include all executable statements between the destination
statement of the first transfer and the statement that returns control to the construct.
The following rules apply to a DO construct with extended range:
• A transfer into the range of a DO statement is permitted only if the transfer is made from the extended
range of that DO statement.
• The extended range of a DO statement must not change the control variable of the DO statement.
860
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following figure shows valid and invalid extended range control transfers:
861
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Collective actions may hang if images have stopped or failed and the other images have not all
detected the stop or fail; for more information, see FAILED_IMAGES.
See Also
Execution Segments for Images
FAILED_IMAGES
862
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the STAT= specifier appears in a SYNC ALL, SYNC IMAGES, or SYNC TEAM statement and the error
STAT_STOPPED_IMAGES occurs, the effect of executing the statement is the same as that of executing the
SYNC_MEMORY statement.
If the STAT= specifier appears in a LOCK statement and the lock variable is located on an image that has
failed, the specified variable becomes defined with the value STAT_FAILED_IMAGE. If the lock variable is
locked by the executing image, the specified variable becomes defined with the value of STAT_LOCKED.
Otherwise, if the lock variable is unlocked because the image that locked it has failed, the specified STAT=
variable becomes defined with the value STAT_UNLOCKED_FAILED_IMAGE defined in the intrinsic module
ISO_FORTRAN_ENV.
If the STAT= specifier appears in an UNLOCK statement and the lock variable is located on an image that has
failed, the specifier becomes defined with the value STAT_FAILED_IMAGE. Otherwise, if the lock variable has
the value unlocked, the variable specified by the STAT= specifier becomes defined with the value of
STAT_UNLOCKED. If the STAT= specifier appears in an UNLOCK statement and the lock variable is locked by
a different image, the specified variable becomes defined with the value STAT_LOCKED_OTHER_IMAGE. The
named constants STAT_LOCKED, STAT_UNLOCKED, and STAT_LOCKED_OTHER_IMAGE are defined in the
intrinsic module ISO_FORTRAN_ENV.
If any other error condition occurs during execution of a LOCK or UNLOCK statement, the specified variable
becomes defined with a positive integer value that is different from STAT_LOCKED, STAT_UNLOCKED,
STAT_UNLOCKED_FAILED_IMAGE, and STAT_LOCKED_OTHER_IMAGE.
If an image completes execution of a CRITICAL statement that has a STAT= specifier and the previous image
that entered the CRITICAL construct failed during execution of the construct, the specifier becomes defined
with the value STAT_FAILED_IMAGE and the execution of the construct executes normally. If any other error
occurs during execution of the construct, the specifier becomes defined with a positive integer value other
different from STAT_FAILED_IMAGE.
If an error condition occurs during execution of an image control statement that does not contain the STAT=
specifier, error termination is initiated.
If an ERRMSG= specifier appears in an image control statement, and an error condition occurs during
execution of that statement, the processor will assign an explanatory message to the specified variable. If no
such condition occurs, the processor will not change the value or definition status of the variable.
The set of error conditions that can occur during execution of an image control statement is processor
dependent.
See Also
ISO_FORTRAN_ENV Module
863
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Incorrect sequencing of image control statements can suspend execution indefinitely. For example, one
image might be executing a SYNC ALL statement while another is executing an ALLOCATE statement for a
coarray.
See Also
Image Control Statements
864
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A function is invoked in an expression using the name of the function or a defined operator. It returns a a
single value (function result) that is used to evaluate the expression.
A subroutine is invoked in a CALL statement or by a defined assignment statement. It does not directly
return a value, but values can be passed back to the calling program unit through arguments (or variables)
known to the calling program.
Recursion (direct or indirect) is permitted for functions and subroutines.
A procedure interface refers to the properties of a procedure that interact with or are of concern to the calling
program. A procedure interface can be explicitly defined in interface blocks. All program units, except block
data program units, can contain interface blocks.
See Also
Program structure
Intrinsic procedures
Scope
RECURSIVE keyword
Main Program
A main program is a program unit whose first statement is not a SUBROUTINE, FUNCTION, MODULE,
SUBMODULE, or BLOCK DATA statement. Program execution always begins with the first executable
statement in the main program, so there must be exactly one main program unit in every executable
program. For more information, see PROGRAM.
Procedure Characteristics
The characteristics of a procedure are as follows:
• Whether it is classified as a function or subroutine
• The characteristics of its result value if it is a function
• The characteristics of its dummy arguments
• Whether it is pure
• Whether it is impure
• Whether it is elemental
• Whether it has the BIND attribute
865
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Whether it is optional
• The explicitness of its interface
• Its characteristics as a procedure if the interface is explicit
• Whether it is a pointer
See Also
PRIVATE attribute
PUBLIC attribute
Use association
866
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Usually, the separate interface body is specified in a module and the separate module procedure is defined in
a descendent submodule.
In the following example, FOO is a separate module procedure whose interface is specified in module M while
the procedure body is defined in submodule A:
module M
type tt
real r
end type tt
interface
real module function FOO (arg)
type(tt), intent(in) :: arg
end function FOO
end interface
end module M
submodule (M) A
contains
real module function FOO (arg) result(res)
type(tt), intent(in) :: arg
res = arg%r
end function FOO
end submodule A
A separate module procedure is accessible by use association only if its interface body is declared in a
module and it is public (for example, FOO in the above example). If a separate module interface is declared
in a submodule, the module procedure is only accessible in that submodule or its descendent submodules.
A separate module procedure interface body (either in a module or submodule) has access to entities in its
host through host association.
NOTE
For an interface body that is not a separate interface body, IMPORT statements are required to make
entities accessible by host association. However, IMPORT statements are not permitted in a separate
interface body.
The initial statement of a separate module procedure body can take one of the two following forms:
• MODULE appears as a prefix for a FUNCTION or SUBROUTINE statement
The following shows an example using this form:
submodule (M) A
contains
real module function foo (arg) result(res)
type(tt), intent(in) :: arg
res = arg%r
end function foo
end submodule A
With this form, a separate module procedure must specify the same characteristics and dummy argument
names as its corresponding separate interface body.
They must both be functions or subroutines; they must both be pure or not; they must both be elemental
or not. The characteristics of its dummy arguments and the characteristics of the function result must also
be the same.
NON_RECURSIVE or RECURSIVE can appear only if NON_RECURSIVE or RECURSIVE appear respectively
as a prefix in the corresponding separate interface body.
867
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Note that the restrictions of matching dummy argument names and matching PURE, NON_RECURSIVE,
and RECURSIVE specifications only apply to separate module procedures. For an external procedure, the
procedure definition and its interface body can differ with regard to dummy argument names, to whether
it is pure, and to whether or not it is recursive.
A procedure defined in a submodule with the BIND attribute cannot have a binding label (that is, BIND(C,
NAME="a-binding-label") unless it is a separate module procedure and its interface is declared in the
ancestor module. The binding label specified in a separate module procedure definition must match the
binding label specified in the separate interface body.
For this form, the result variable name for a function is determined by the FUNCTION statement in the
module subprogram. The result variable name in the interface is ignored.
• MODULE PROCEDURE statement
This has the following form:
MODULE PROCEDURE procedure-name
[specification-part]
[execution-part]
[internal-subprogram-part]
END [PROCEDURE [procedure-name]]
The following shows an example using this form:
submodule (M) A
contains
module procedure foo
foo = arg%r
end procedure foo
end submodule A
This syntax avoids the redeclaration of the function or subroutine in the separate module procedure
definition and just takes the characteristics, dummy argument names, and the function result variable
name from the separate interface body.
A separate module procedure does not have to be defined. The separate module procedure interface can be
used to specify an explicit interface; however, the procedure must not be called.
NOTE
Two modules cannot have USE statements that reference each other because circular reference is not
allowed. However, you can solve that problem by putting at least one side of the USEs in submodules.
This is because submodules cannot be referenced by use association and the USE statements in
submodules are effectively hidden.
Examples
See the examples in SUBMODULE.
See Also
MODULE
SUBMODULE
Intrinsic Modules
Intrinsic modules, like other module program units, contain specifications and definitions that can be made
accessible to other program units. The intrinsic modules are part of the Fortran library.
An intrinsic module is specified in a USE statement, as follows:
USE, INTRINSIC :: mod-name [, rename-list] ...
USE, INTRINSIC :: mod-name, ONLY : [, only-list]
868
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Procedures and types defined in an intrinsic module are not themselves intrinsic.
An intrinsic module can have the same name as other global entities, such as program units, common blocks,
or external procedures. A scoping unit must not access both an intrinsic module and a non-intrinsic module
with the same name.
When INTRINSIC is used, mod-name must be the name of an intrinsic module. If NON_INTRINSIC is used,
mod-name must be the name of an nonintrinsic module. If neither is specified, mod-name must be the name
of an intrinsic or nonintrinsic module. If both are provided, the nonintrinsic module is used.
The following intrinsic modules are included in the Fortran library: ISO_C_BINDING, ISO_FORTRAN_ENV, and
IEEE Intrinsic Modules.
ISO_C_BINDING Module
The ISO_C_BINDING intrinsic module provides access to data entities that are useful in mixed-language
programming. It takes the following form:
USE, INTRINSIC :: ISO_C_BINDING
This intrinsic module provides access to the following data entities:
• Named Constants
• Derived Types
Derived type C_PTR is interoperable with any C object pointer type. Derived type C_FUNPTR is
interoperable with any C function pointer type.
• Intrinsic Module Procedures
See Also
Standard Tools for Interoperability
Intrinsic-Type Constants
The following table shows interoperable Fortran types and C Types.
C_SIZE_T size_t
C_INT8_T int8_t
C_INT16_T int16_t
869
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
C_INT32_T int32_t
C_INT64_T int64_t
C_INT_LEAST8_T int_least8_t
C_INT_LEAST16_T int_least16_t
C_INT_LEAST32_T int_least32_t
C_INT_LEAST64_T int_least64_t
C_INT_FAST8_T int_fast8_t
C_INT_FAST16_T int_fast16_t
C_INT_FAST32_T int_fast32_t
C_INT_FAST64_T int_fast64_t
C_INTMAX_T intmax_t
C_INTPTR_T intptr_t
C_PTRDIFF_T ptrdiff_t
C_DOUBLE double
For example, an integer type with the kind type parameter C_LONG is interoperable with the C integer type
"long" or any C type derived from "long".
The value of C_INT will be a valid value for an integer kind type parameter on the processor. The values for
the other integer named constants (C_INT*) will be a valid value for an integer kind type parameter on the
processor, if any, or one of the following:
• -1 if the C processor defines the corresponding C type and there is no interoperating Fortran processor
kind
• -2 if the C processor does not define the corresponding C type
The values of C_FLOAT, C_DOUBLE, and C_LONG_DOUBLE will be a valid value for a real kind type parameter
on the processor, if any, or one of the following:
870
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• -1 if the C processor's type does not have a precision equal to the precision of any of the Fortran
processor's real kinds
• -2 if the C processor's type does not have a range equal to the range of any of the Fortran processor's
real kinds
• -3 if the C processor's type has neither the precision or range equal to the precision or range of any of the
Fortran processor's real kinds
• -4 if there is no interoperating Fortran processor or kind for other reasons
The values of C_FLOAT_COMPLEX, C_DOUBLE_COMPLEX, and C_LONG_DOUBLE_COMPLEX will be the same
as those of C_FLOAT, C_DOUBLE, and C_LONG_DOUBLE, respectively.
The value of C_BOOL will be a valid value for a logical kind parameter on the processor, if any, or -1.
The value of C_CHAR is the character kind.
Character Constants
The following table shows interoperable named constants and C characters:
Derived-Type Constants
The constant C_NULL_PTR is of type C_PTR; it has the value of a C null data pointer. The constant
C_NULL_FUNPTR is of type C_FUNPTR; it has the value of a C null function pointer.
ISO_FORTRAN_ENV Module
The ISO_FORTRAN_ENV intrinsic module provides information about the Fortran run-time environment. It
takes the following form:
USE, INTRINSIC :: ISO_FORTRAN_ENV
This intrinsic module provides access to the following data entities:
871
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Named Constants
• Derived Types
• Intrinsic Module Procedures
872
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
873
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
874
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
875
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
876
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• To determine whether a divide operation will be supported with the accuracy specified by the IEEE
standard, use intrinsic module function IEEE_SUPPORT_DIVIDE.
• To determine whether you can control halting after an exception has occurred, use intrinsic module
function IEEE_SUPPORT_HALTING.
• To determine which exceptions are supported in a scoping unit, use intrinsic module function
IEEE_SUPPORT_FLAG.
• To determine whether all IEEE features are supported, use intrinsic module function
IEEE_SUPPORT_STANDARD.
The compiler establishes the initial IEEE floating-point environment. The user can affect this initial
environment with several different command-line options. For the IEEE intrinsic module procedures to work
as defined by the Fortran Standard, the following command lines options must be set as follows:
• Option /fpe:3 (Windows*) or -fpe3 (Linux* and macOS) must be set to disable all floating-point
exceptions.
• Option /Qftz- (Windows*) or -no-ftz (Linux* and macOS) must be set to disable flushing subnormal
results to zero (notice that all optimization levels, except O0, set ftz so the user has to explicitly set "no
ftz").
• Option /fp:precise (Windows*) or option -fp-model precise (Linux* and macOS) must be set to
disable floating-point exception semantics.
IEEE_CLASS IEEE_REM
IEEE_COPY_SIGN IEEE_RINT
IEEE_FMA IEEE_SCALB
IEEE_IS_FINITE IEEE_SET_ROUNDING_MODE 3
IEEE_NEGATIVE IEEE_SIGNALING_EQ
IEEE_INT IEEE_SIGNALING_GE
IEEE_IS_NORMAL IEEE_SIGNALING_GT
IEEE_LOGB IEEE_SIGNALING_LE
IEEE_MAX_NUM IEEE_SIGNALING_LT
IEEE_MAX_NUM_MAG IEEE_SIGNALING_NE
IEEE_MIN_NUM IEEE_SIGNBIT
IEEE_MIN_NUM_MAG IEEE_SUPPORT_DENORMAL
IEEE_NEXT_AFTER IEEE_SUPPORT_DIVIDE
IEEE_NEXT_DOWN 1 IEEE_SUPPORT_INF
IEEE_NEXT_UP 1 IEEE_SUPPORT_IO
IEEE_QUIET_EQ IEEE_SUPPORT_NAN
IEEE_QUIET_GE IEEE_SUPPORT_ROUNDING
IEEE_QUIET_GT IEEE_SUPPORT_SQRT
877
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_QUIET_LE IEEE_SUPPORT_SUBNORMAL
IEEE_QUIET_LT IEEE_SUPPORT_UNORDERED
IEEE_QUIET_NE IEEE_SUPPORT_VALUE
IEEE_REAL 2 IEEE_VALUE
1 IEEE_SUPPORT_INF() must be true if IEEE_NEXT_DOWN is called with the argument -HUGE (X) or if
IEEE_NEXT_UP is called with the argument HUGE (X).
2 IEEE_SUPPORT_DATATYPE (IEEE_REAL (A, KIND)) must also be true.
3 IEEE_SUPPORT_ROUNDING(ROUND_VALUE, X) must also be true.
For example, the IEEE_IS_NORMAL(X) function can only be invoked if IEEE_SUPPORT_DATATYPE(X) has the
value true. Consider the following:
USE, INTRINSIC :: IEEE_ARITHMETIC
...
IF IEEE_SUPPORT_DATATYPE(X) THEN
IF IEEE_IS_NORMAL(X) THEN
PRINT *, ' X is a "normal" '
ELSE
PRINT *, ' X is not "normal" '
ENDIF
ELSE
PRINT *, ' X is not a supported IEEE type '
ENDIF
...
Certain other IEEE intrinsic module procedures have similar restrictions:
• IEEE_IS_NAN(X) can only be invoked if IEEE_SUPPORT_NAN(X) has the value true.
• IEEE_SET_HALTING_MODE(FLAG, HALTING) can only be invoked if IEEE_SUPPORT_HALTING(FLAG) has
the value true.
• IEEE_GET_UNDERFLOW_MODE(GRADUAL) can only be invoked if
IEEE_SUPPORT_UNDERFLOW_CONTROL(X) is true for some X.
For intrinsic module function IEEE_CLASS(X), some of the possible return values also have restrictions. These
restrictions are also true for argument CLASS in intrinsic module function IEEE_VALUE(X, CLASS):
• IEEE_POSITIVE_INF and IEEE_NEGATIVE_INF can only be returned if IEEE_SUPPORT_INF(X) has the
value true.
• IEEE_POSITIVE_DENORMAL, IEEE_POSITIVE_SUBNORMAL, IEEE_NEGATIVE_SUBNORMAL, and
IEEE_NEGATIVE_DENORMAL can only be returned if IEEE_SUPPORT_DENORMAL(X) and
IEEE_SUPPORT_SUBNORMAL(X) have the value true.
• IEEE_SIGNALING_NAN and IEEE_QUIET_NAN can only be returned if IEEE_SUPPORT_NAN(X) has the
value true.
IEEE_SIGNALING_NAN IEEE_NEGATIVE_NORMAL
IEEE_QUIET_NAN IEEE_POSITIVE_DENORMAL
878
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_POSITIVE_INF IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_INF IEEE_POSITIVE_ZERO
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_ZERO
IEEE_OTHER_VALUE
• IEEE_ROUND_TYPE: Identifies a rounding mode. Its values are the following named constants:
IEEE_AWAY 1 IEEE_OTHER 4
IEEE_DOWN 2 IEEE_TO_ZERO 5
IEEE_NEAREST 3 IEEE_UP 6
IEEE_INVALID IEEE_DIVIDE_BY_ZERO
IEEE_OVERFLOW IEEE_INEXACT
IEEE_UNDERFLOW
Each of the above exceptions has a flag whose value is either quiet or signaling. The initial value is quiet
and it signals when the associated exception occurs. To determine the value of a flag, use intrinsic module
subroutine IEEE_GET_FLAG. To change the status for a flag, use intrinsic module subroutine
IEEE_SET_FLAG or IEEE_SET_STATUS.
If a flag is signaling on entry to a procedure, the processor sets it to quiet on entry and restores it to
signaling on return.
879
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_DATATYPE IEEE_INF
IEEE_DIVIDE IEEE_NAN
IEEE_ROUNDING IEEE_INEXACT_FLAG
IEEE_SQRT IEEE_INVALID_FLAG
IEEE_SUBNORMAL IEEE_UNDERFLOW_FLAG
IEEE_HALTING
880
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
881
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
882
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Key to Classes
E-Elemental function
I-Inquiry
SI-Impure Subroutine
T-Transformational
883
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Key to Classes
ES-Elemental subroutine
SI-Impure Subroutine
SP-Pure Subroutine
T-Transformational
Examples
An example of a block data program unit follows:
A function reference is used in an expression to invoke a function; it consists of the function name and its
actual arguments. The function reference returns a value to the calling expression that is used to evaluate
the expression.
884
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ENTRY statement
CALL statement
See Also
RECURSIVE procedures
PURE procedures
User-defined ELEMENTAL procedures
Module procedures
Internal procedures
External procedures
Optional arguments
INTENT attribute
standard-semantics compiler option
assume recursion compiler option
Recursive Procedures
A recursive procedure is a function or subroutine that references itself, either directly or indirectly. For more
information, see RECURSIVE.
Pure Procedures
A pure procedure is a procedure that has no side effects. For more information, see PURE.
Impure Procedures
An impure procedure is a user-defined procedure that has side effects. For more information, see IMPURE
Elemental Procedures
An elemental procedure is a user-defined procedure defined on scalar arguments that may be called with
array arguments. An elemental procedure is pure unless you specify that it is impure. For more information,
see PURE, ELEMENTAL, and IMPURE.
885
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Functions Overview
A function subprogram is invoked in an expression and returns a single value (a function result) that is used
to evaluate the expression. For more information, see FUNCTION.
Function References
Functions are invoked by a function reference in an expression or by a defined operation.
A function reference takes the following form:
fun ([a-arg [, a-arg] ...])
Description
When a function is referenced, each actual argument is associated with the corresponding dummy argument
by its position in the argument list or by the name of its keyword. The arguments must agree in type and
kind parameters.
Execution of the function produces a result that is assigned to the function name or to the result name,
depending on whether the RESULT keyword was specified.
The program unit uses the result value to complete the evaluation of the expression containing the function
reference.
If positional arguments and argument keywords are specified, the argument keywords must appear last in
the actual argument list.
If a dummy argument is optional, the actual argument can be omitted.
If a dummy argument is specified with the INTENT attribute, its use may be limited. A dummy argument
whose intent is not specified is subject to the limitations of its associated actual argument.
An actual argument associated with a dummy procedure must be the specific name of a procedure, or be
another dummy procedure. Certain specific intrinsic function names must not be used as actual arguments
(see table Specific Functions Not Allowed as Actual Arguments in Intrinsic Procedures).
Examples
Consider the following example:
X = 2.0
NEW_COS = COS(X) ! A function reference
Intrinsic function COS calculates the cosine of 2.0. The value -0.4161468 is returned (in place of COS(X))
and assigned to NEW_COS.
See Also
INTENT attribute
886
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Subroutines Overview
A subroutine subprogram is invoked in a CALL statement or by a defined assignment statement, and does
not return a particular value. For more information, see SUBROUTINE.
All entry names within a function subprogram are associated with the name of the function subprogram.
Therefore, defining any entry name or the name of the function subprogram defines all the associated names
with the same data type. All associated names with different data types become undefined.
If RECURSIVE is specified in the FUNCTION statement, all entry points in the FUNCTION are recursive. The
interface of the function defined by the ENTRY statement is explicit within the function subprogram.
Examples
The following example shows a function subprogram that computes the hyperbolic functions SINH, COSH,
and TANH:
TANH = TSINH(X)/TCOSH(X)
RETURN
887
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ENTRY SINH(X)
SINH = TSINH(X)/2.0
RETURN
ENTRY COSH(X)
COSH = TCOSH(X)/2.0
RETURN
END
See Also
RESULT keyword
Examples
The following example shows a main program calling a subroutine containing an ENTRY statement:
PROGRAM TEST
...
CALL SUBA(A, B, C) ! A, B, and C are actual arguments
... ! passed to entry point SUBA
END
SUBROUTINE SUB(X, Y, Z)
...
ENTRY SUBA(Q, R, S) ! Q, R, and S are dummy arguments
... ! Execution starts with this statement
END SUBROUTINE
The following example shows an ENTRY statement specifying alternate returns:
External Procedures
External procedures are user-written functions or subroutines. They are located outside of the main program
and can't be part of any other program unit.
External procedures can be invoked by the main program or any procedure of an executable program.
External procedures can include internal subprograms (defining internal procedures). Internal subprograms
are placed after a CONTAINS statement.
An external procedure can reference itself (directly or indirectly).
888
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The interface of an external procedure is implicit unless an interface block is supplied for the procedure.
See Also
Functions, Subroutines, and Statement Functions
Procedure Interfaces
Internal Procedures
Internal procedures are functions or subroutines that follow a CONTAINS statement in a program unit. The
program unit in which the internal procedure appears is called its host.
Internal procedures can appear in the main program, in an external subprogram, or in a module subprogram.
An internal procedure takes the following form:
CONTAINS
internal-subprogram
[internal-subprogram] ...
Description
Internal procedures are the same as external procedures, except for the following:
• Only the host program unit can use an internal procedure.
• An internal procedure has access to host entities by host association; that is, names declared in the host
program unit are useable within the internal procedure.
• An internal procedure must not contain an ENTRY statement.
An internal procedure can reference itself (directly or indirectly); it can be referenced in the execution part of
its host and in the execution part of any internal procedure contained in the same host (including itself).
The interface of an internal procedure is always explicit.
Examples
The following example shows an internal procedure:
PROGRAM COLOR_GUIDE
...
CONTAINS
FUNCTION HUE(BLUE) ! An internal procedure
...
END FUNCTION HUE
END PROGRAM
The following example program contains an internal subroutine find, which performs calculations that the
main program then prints. The variables a, b, and c declared in the host program are also known to the
internal subroutine.
program INTERNAL
! shows use of internal subroutine and CONTAINS statement
real a,b,c
call find
print *, c
contains
subroutine find
read *, a,b
889
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
c = sqrt(a**2 + b**2)
end subroutine find
end
See Also
Functions, Subroutines, and Statement Functions
Host association
Procedure Interfaces
CONTAINS statement
890
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROGRAM TEST
USE MOD_A
CALL SUB_1 (B)
...
END PROGRAM TEST
See Also
CALL for details on argument keywords in subroutine references
Function References for details on argument keywords in function references
Optional Arguments
Dummy arguments can be made optional if they are declared with the OPTIONAL attribute. In this case, an
actual argument does not have to be supplied for it in a procedure reference.
891
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If argument keywords are not used, argument association is positional. The first dummy argument becomes
associated with the first actual argument, and so on. If argument keywords are used, arguments are
associated by the keyword name, so actual arguments can be in a different order than dummy arguments. A
keyword is required for an argument only if a preceding optional argument is omitted or if the argument
sequence is changed.
Positional arguments (if any) must appear first in an actual argument list, followed by keyword arguments (if
any). If an optional argument is the last positional argument, it can simply be omitted if desired.
However, if the optional argument is to be omitted but it is not the last positional argument, keyword
arguments must be used for any subsequent arguments in the list.
Optional arguments must have explicit procedure interfaces so that appropriate argument associations can
be made.
The PRESENT intrinsic function can be used to determine if an actual argument is associated with an optional
dummy argument in a particular reference.
A dummy argument or an entity that is host associated with a dummy argument is not present if any of the
following are true for the dummy argument:
• It does not correspond to an actual argument.
• It corresponds to an actual argument that is not present.
• It does not have the ALLOCATABLE or POINTER attribute, and corresponds to one of the following:
• An actual argument that has the ALLOCATABLE attribute and is not allocated
• An actual argument that has the POINTER attribute and is disassociated
The following example shows optional arguments:
PROGRAM RESULT
TEST_RESULT = LGFUNC(A, B=D)
...
CONTAINS
FUNCTION LGFUNC(G, H, B)
OPTIONAL H, B
...
END FUNCTION
END
In the function reference, A is a positional argument associated with required dummy argument G. The
second actual argument D is associated with optional dummy argument B by its keyword name (B). No
actual argument is associated with optional argument H.
The following shows another example:
! Arguments can be passed out of order, but must be
! associated with the correct dummy argument.
CALL EXT1 (Z=C, X=A, Y=B)
. . .
END
SUBROUTINE EXT1(X,Y,Z)
REAL X, Y
REAL, OPTIONAL :: Z
. . .
END SUBROUTINE
In this case, argument A is associated with dummy argument X by explicit assignment. Once EXT1 executes
and returns, A is no longer associated with X, B is no longer associated with Y, and C is no longer associated
with Z.
892
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you pass an omitted dummy argument as the actual argument to a procedure, the corresponding dummy
argument is considered to be omitted as well. This rule applies to both intrinsic and non-intrinsic procedures.
For example:
CALL SUB1()
CONTAINS
SUBROUTINE SUB1(B)
LOGICAL, OPTIONAL :: B
PRINT *, INDEX('Fortran','r',BACK=B) ! Prints 3
CALL SUB2(B) ! Same as CALL SUB2()
END SUBROUTINE SUB1
SUBROUTINE SUB2(C)
LOGICAL, OPTIONAL :: C
PRINT *, PRESENT(C) ! Prints F
END SUBROUTINE SUB2
END
See Also
OPTIONAL attribute
PRESENT intrinsic function
Argument association for details on general rules for procedure argument association
CALL for details on argument keywords in subroutine references
Function References for details on argument keywords in function references
Array Arguments
Arrays are sequences of elements. Each element of an actual array is associated with the element of the
dummy array that has the same position in array element order.
If the dummy argument is an explicit-shape or assumed-size array, the size of the dummy argument array
must not exceed the size of the actual argument array.
The type and kind parameters of an explicit-shape or assumed-size dummy argument must match the type
and kind parameters of the actual argument, but their ranks need not match.
If the dummy argument is an assumed-shape array, the size of the dummy argument array is equal to the
size of the actual argument array. The associated actual argument must not be an assumed-size array or a
scalar (including a designator for an array element or an array element substring).
If the actual argument is an array section with a vector subscript, the associated dummy argument must not
be defined and it must not have the INTENT (OUT), INTENT (INOUT), VOLATILE, or ASYNCHRONOUS
attribute.
If an actual argument is an array section or an assumed-shape array, and the corresponding dummy
argument has either the VOLATILE or ASYNCHRONOUS attribute, that dummy argument must be an
assumed-shape array.
If an actual argument is a pointer array, and the corresponding dummy argument has either the VOLATILE or
ASYNCHRONOUS attribute, that dummy argument must be an assumed-shape array or a pointer array.
The declaration of an array used as a dummy argument can specify the lower bound of the array.
If a dummy argument is allocatable, the actual argument must be allocatable and the type parameters and
ranks must agree. An example of an allocatable function with allocatable arrays appears in FUNCTION.
Dummy argument arrays declared as assumed-shape, deferred-shape, or pointer arrays require an explicit
interface visible to the caller.
See Also
Arrays
Array association
Procedure Interfaces
893
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Argument association for details on general rules for procedure argument association
Array Elements for details on array element order
Explicit-Shape Specifications for details on explicit-shape arrays
Assumed-Shape Specifications for details on assumed-shape arrays
Assumed-Size Specifications for details on assumed-size arrays
Pointer Arguments
An argument is a pointer if it is declared with the POINTER attribute.
When a procedure is invoked, the dummy argument pointer receives the pointer association status of the
actual argument. If the actual argument is currently associated, the dummy argument becomes associated
with the same target.
The pointer association status of the dummy argument can change during the execution of the procedure,
and any such changes are reflected in the actual argument.
If both the dummy and actual arguments are pointers, an explicit interface is required.
A dummy argument that is a pointer can be associated only with an actual argument that is a pointer.
However, an actual argument that is a pointer can be associated with a nonpointer dummy argument. In this
case, the actual argument is associated with a target and the dummy argument, through argument
association, also becomes associated with that target.
If the dummy argument does not have the TARGET or POINTER attribute, any pointers associated with the
actual argument do not become associated with the corresponding dummy argument when the procedure is
invoked.
If the dummy argument has the TARGET attribute, and is either a scalar or assumed-shape array, and the
corresponding actual argument has the TARGET attribute but is not an array section with a vector subscript,
the following occurs:
• Any pointer associated with the actual argument becomes associated with the corresponding dummy
argument when the procedure is invoked.
• Any pointers associated with the dummy argument remain associated with the actual argument when
execution of the procedure completes.
If the dummy argument has the TARGET attribute, and is an explicit-shape or assumed-size array, and the
corresponding actual argument has the TARGET attribute but is not an array section with a vector subscript,
association of actual and corresponding dummy arguments when the procedure is invoked or when execution
is completed is processor dependent.
If the dummy argument has the TARGET attribute and the corresponding actual argument does not have that
attribute or is an array section with a vector subscript, any pointer associated with the dummy argument
becomes undefined when execution of the procedure completes.
See Also
POINTER statement and attribute
Pointer assignments
TARGET statement and attribute
Argument association for details on general rules for procedure argument association
894
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The passed-object dummy argument must be a scalar, nonpointer, nonallocatable dummy data object. Its
declared type must be the type in which the component or binding appears. All of its length type paramaters
must be assumed.
The determination of the passed-object dummy argument depends on the following:
• The PASS and NOPASS attributes specified or in effect
• The interface of the procedure component or binding procedure
The following rules apply to PASS and NOPASS:
• PASS and NOPASS are mutually exclusive. You can only specify one of these attributes for the same
procedure component or binding.
• If you specify PASS (arg-name), dummy argument arg-name is the passed-object dummy argument. The
interface of the procedure pointer component or binding procedure must have a dummy argument named
arg-name.
• If NOPASS is specified, there is no passed-object dummy argument.
• NOPASS must be specified if the procedure component or binding procedure has an implicit interface.
• If you do not specify PASS or NOPASS, or you specify PASS without arg-name, the first dummy argument
of a procedure pointer component or binding procedure is the passed-object dummy argument. In this
case, there must be at least one dummy argument.
See Also
TYPE
Passed-Object Dummy Arguments
See Also
LEN intrinsic function
895
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Argument association for details on general rules for procedure argument association
See Also
Argument association for details on general rules for procedure argument association
See Also
Argument association for details on general rules for procedure argument association
SUBROUTINE statement
CALL statement
RETURN statement
Deleted and Obsolescent Language Features for details on obsolescent features in Standard
Fortran
896
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The actual argument and corresponding dummy procedure must both be subroutines or both be functions.
If the interface of the dummy procedure is explicit, the type and kind parameters, and rank of the associated
actual procedure must be the same as that of the dummy procedure.
If the interface of the dummy procedure is implicit and the procedure is referenced as a subroutine, the
actual argument must be a subroutine or a dummy procedure.
If the interface of the dummy procedure is implicit and the procedure is referenced as a function or is
explicitly typed, the actual argument must be a function or a dummy procedure.
Dummy procedures can be declared optional, but they must not be declared with an intent.
The following is an example of a procedure used as an argument:
REAL FUNCTION LGFUNC(BAR)
INTERFACE
REAL FUNCTION BAR(Y)
REAL, INTENT(IN) :: Y
END
END INTERFACE
...
LGFUNC = BAR(2.0)
...
END FUNCTION LGFUNC
See Also
Argument association for details on general rules for procedure argument association
Examples
When a procedure is invoked on a particular image, each dummy coarray is associated with its ultimate
argument on the image. During the execution of the procedure, this image can access the coarray
corresponding to the ultimate argument on any other image. For example, consider the following:
INTERFACE
SUBROUTINE MY_SUB(Y)
REAL :: Y[*]
END SUBROUTINE MY_SUB
END INTERFACE
...
REAL :: B(700)[:]
...
CALL MY_SUB(B(10))
When subroutine MY_SUB is invoked, the executing image has access through the syntax Y[P] to B(10) on
image P.
Each invocation of a procedure with a nonallocatable coarray dummy argument establishes a dummy coarray
for the image with its own bounds and cobounds. During the execution of the procedure, this image may use
its own bounds and cobounds to access the coarray corresponding to the ultimate argument on any other
image. For example, consider the following:
INTERFACE
SUBROUTINE MY_SUB(Y,I)
INTEGER :: I
REAL :: Y(I,I)[I,*]
897
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Image Control Statements
See Also
Unambiguous Generic Procedure References
Intrinsic procedures
Resolving Procedure References
Defining Generic Names for Procedures for details on user-defined generic procedures
898
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Normally, an intrinsic procedure name refers to the Fortran library procedure with that name. However, the
name can refer to a user-defined procedure when the name appears in an EXTERNAL statement.
NOTE
If you call an intrinsic procedure by using the wrong number of arguments or an incorrect argument
type, the compiler assumes you are referring to an external procedure. For example, intrinsic
procedure SIN requires one argument; if you specify two arguments, such as SIN(10,4), the compiler
assumes SIN is external and not intrinsic.
The data type of an intrinsic procedure does not change if you use an IMPLICIT statement to change the
implied data type rules.
Intrinsic and user-defined procedures cannot have the same name if they appear in the same program unit.
Examples
The following example shows the local and global properties of an intrinsic function name. It uses the name
SIN in different procedures as follows:
• The name of a statement function
• The generic name of an intrinsic function
• The specific name of an intrinsic function
• The name of a user-defined function
Using and Redefining an Intrinsic Function Name
SUBROUTINE COMPUT(Y)
DOUBLE PRECISION Y
899
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! Makes the generic name SIN reference the double-precision sine DSIN
V(1) = SIN(Y)
SUBROUTINE SUB(A,S)
The statement function named SIN is defined in terms of the generic function name COS. Because the
argument of COS is double precision, the double-precision cosine function is evaluated. The statement
function SIN is itself single precision.
The name SIN is declared intrinsic so that the single-precision intrinsic sine function can be passed as an
actual argument at 5.
The generic function name SIN is used to refer to the double-precision sine function.
900
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The user-defined SIN function is defined as a simple Taylor series using a user-defined function FACTOR
to compute the factorial function.
See Also
EXTERNAL attribute
INTRINSIC attribute
Intrinsic procedures
Names for details on the scope of names
Examples
Consider the following:
See Also
Arrays
Intrinsic procedures for details on elemental procedures
Procedure Interfaces
Every procedure has an interface, which consists of the name and characteristics of a procedure, the name
and characteristics of each dummy argument, and the generic identifier (if any) by which the procedure can
be referenced. The characteristics of a procedure are fixed, but the remainder of the interface can change in
different scoping units.
901
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If these properties are all known within the scope of the calling program, the procedure interface is explicit;
otherwise it is implicit (deduced from its reference and declaration). The following table shows which
procedures have implicit or explicit interfaces:
The interface of a recursive subroutine or function is explicit within the subprogram that defines it.
An explicit interface can come from any of the following:
• An interface block
• The procedure's definition in a module
• An internal procedure
A procedure must not access through use association its own interface.
An abstract interface lets you give a name to a set of characteristics and argument keyword names that
create an explicit interface to a procedure. It does not declare any actual procedure to have those
characteristics.
Depending on the characteristics of the procedure and its dummy arguments, an explicit interface may be
required to be visible to its caller. For more information see Procedures that Require Explicit Interfaces.
You can use a procedure declaration statement to declare procedure pointers, dummy procedures, and
external procedures. It specifies the EXTERNAL attribute for all procedure entities in the procedure
declaration list.
You can use the IMPORT statement to make host entities accessible in the interface body of an interface
block.
You can specify the ALLOCATABLE, OPTIONAL, or POINTER attributes for a dummy argument in a procedure
interface that has the BIND attribute.
Examples
An example of an interface block follows:
INTERFACE
SUBROUTINE Ext1 (x, y, z)
REAL, DIMENSION (100,100) :: x, y, z
END SUBROUTINE Ext1
902
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL q (1000)
END FUNCTION Ext3
END INTERFACE
See Also
INTERFACE
ABSTRACT INTERFACE
PROCEDURE
IMPORT
See Also
Optional arguments
Array arguments
Pointer arguments
CALL for details on argument keywords in subroutine references
Function references for details on argument keywords in function references
Pure procedures
Elemental procedures
Procedure Interfaces
Defining Generic Names for Procedures for details on user-defined generic procedures
Defining Generic Operators for details on defined operators
Defining Generic Assignment for details on defined assignment
Parameterized Derived-Type Declarations
903
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
generic-name Is the generic name. It can be the same as any of the procedure
names in the interface block, or the same as any accessible generic
name (including a generic intrinsic name).
A generic name can be the same as a derived-type name. In this
case, all of the procedures in the interface block must be functions.
SUBROUTINE REAL_LINE_EQ(X1,Y1,X2,Y2,M,B)
REAL,INTENT(IN) :: X1,Y1,X2,Y2
REAL,INTENT(OUT) :: M,B
END SUBROUTINE REAL_LINE_EQ
904
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SUBROUTINE INT_LINE_EQ(X1,Y1,X2,Y2,M,B)
INTEGER,INTENT(IN) :: X1,Y1,X2,Y2
INTEGER,INTENT(OUT) :: M,B
END SUBROUTINE INT_LINE_EQ
END INTERFACE
In this example, LINE_EQUATION is the generic name which can be used for either REAL_LINE_EQ or
INT_LINE_EQ. Fortran selects the appropriate subroutine according to the nature of the arguments passed to
LINE_EQUATION. Even when a generic name exists, you can always invoke a procedure by its specific name.
In the previous example, you can call REAL_LINE_EQ by its specific name (REAL_LINE_EQ), or its generic
name LINE_EQUATION.
See Also
INTERFACE statement for details on interface blocks
GENERIC statement for an alternate to interface blocks for declaring generic procedures
The functions within the interface block must have one or two nonoptional arguments with the INTENT(IN)
and/or the VALUE attribute, and the function result must not be of type character with assumed length. A
defined operation is treated as a reference to the function.
The following shows the form (and an example) of a defined unary and defined binary operation:
For intrinsic operator symbols, the generic properties include the intrinsic operations they represent. Both
forms of each relational operator have the same interpretation, so extending one form (such as >=) defines
both forms (>= and .GE.).
The following is an example of a procedure interface block defining a new operator:
INTERFACE OPERATOR(.BAR.)
FUNCTION BAR(A_1)
INTEGER, INTENT(IN) :: A_1
INTEGER :: BAR
END FUNCTION BAR
END INTERFACE
905
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example shows a way to reference function BAR by using the new operator:
INTEGER B
I = 4 + (.BAR. B)
The following is an example of a procedure interface block with a defined operator extending an existing
operator:
INTERFACE OPERATOR(+)
FUNCTION LGFUNC (A, B)
LOGICAL, INTENT(IN) :: A(:), B(SIZE(A))
LOGICAL :: LGFUNC(SIZE(A))
END FUNCTION LGFUNC
END INTERFACE
The following example shows two equivalent ways to reference function LGFUNC:
LOGICAL, DIMENSION(1:10) :: C, D, E
N = 10
E = LGFUNC(C(1:N), D(1:N))
E = C(1:N) + D(1:N)
See Also
INTENT attribute
INTERFACE for details on interface blocks
Expressions for details on intrinsic operators
Defined Operations for details on defined operators and operations
906
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Defined Assignments
INTENT attribute
INTERFACE statement for details on interface blocks
907
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• C functions must not invoke a function pointer whose value is the result of a reference to C_FUNLOC with
a noninteroperable argument.
• When passing an argument to a C procedure where the corresponding C formal parameter is a C
descriptor, Fortran must pass a C descriptor and, on return, ensure that any updates to the C descriptor
are reflected in Fortran.
• If the interface specifies that the dummy argument is CONTIGUOUS, the passed argument (and the C
descriptor’s description of that argument, if relevant) must be contiguous.
• A Fortran procedure with BIND(C) that has a dummy argument that is assumed-length CHARACTER or is
allocatable, assumed-shape, assumed-rank, or a pointer without CONTIGUOUS must accept that
argument as a C descriptor and make sure that on return, the C descriptor reflects any changes made to
the argument during execution of the Fortran procedure.
• A Fortran procedure with one of the following arguments must accept that argument as a C descriptor and
make sure that on return, the C descriptor reflects any changes made to the argument during execution
of the Fortran procedure:
• A dummy argument that is assumed-length CHARACTER
• A dummy argument that is allocatable, assumed-shape, assumed-rank, or a pointer without
CONTIGUOUS
Procedure Pointers
A procedure pointer has the POINTER attribute and points to a procedure instead of a data object. It can be
associated with an external procedure, a module procedure, an intrinsic procedure, or a dummy procedure
that is not a procedure pointer. It can have an implicit or explicit interface, but the interface cannot be
generic or elemental.
A procedure pointer can be one of the following:
• A named pointer (described below)
• A derived-type component (See Procedure Pointers as Derived-Type Components.)
POINTER :: MyP
INTERFACE
SUBROUTINE MyP(c,d)
REAL, INTENT(INOUT) :: c
REAL, INTENT(IN) :: d
END SUBROUTINE MyP
END INTERFACE
REAL, EXTERNAL, POINTER :: MyR
The above specifies that MyP is a pointer to a subroutine with an explicit interface. It also specifies that MyR
is a pointer to a scalar REAL function with an implicit interface.
Note that in a type declaration statement, you must specify the EXTERNAL attribute as well as the POINTER
attribute when declaring the procedure pointer.
See Also
INTERFACE
908
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ABSTRACT INTERFACE
PROCEDURE
Intrinsic Procedures
Intrinsic procedures are functions and subroutines that are included in the Fortran library. The following are
classes of intrinsic procedures:
• Elemental procedures
These procedures have scalar dummy arguments that can be called with scalar or array actual arguments.
There are many elemental intrinsic functions and one elemental intrinsic subroutine (MVBITS). All
elemental intrinsic procedures are pure.
If the arguments are all scalar, the result is scalar. If an actual argument is array-valued, the intrinsic
procedure is applied to each element of the actual argument, resulting in an array that has the same
shape as the actual argument.
If there is more than one array-valued argument, they must all have the same shape.
Many algorithms involving arrays can now be written conveniently as a series of computations with whole
arrays. For example, consider the following:
a = b + c
... ! a, b, c, and s are all arrays of similar shape
s = sum(a)
The above statements can replace entire DO loops.
Consider the following:
real, dimension (5,5) :: x,y
. . . ! Assign values to x
y = sin(x) ! Pass the entire array as an argument
In this example, since the SIN(X) function is an elemental procedure, it operates element-by-element on
the array x when you pass it the name of the whole array.
• Inquiry functions
These functions have results that depend on the properties of their principal argument, not the value of
the argument (the argument value can be undefined).
• Transformational functions
These functions have one or more array-valued dummy or actual arguments, an array result, or both. The
intrinsic function is not applied elementally to an array-valued actual argument; instead it changes
(transforms) the argument array into another array.
• Nonelemental procedures
These procedures must be called with only scalar arguments; they return scalar results. All subroutines
(except MVBITS) are nonelemental.
• Atomic subroutines
These subroutines perform an action on a variable (its atom argument) atomically. When an atomic
subroutine is executed, it is as if the subroutine were executed instantaneously without overlapping other
atomic actions that might occur asynchronously. For information on the semantics of atomic subroutines,
see Overview of Atomic Subroutines.
• Collective subroutines
These subroutines perform a cooperative calculation on a team of images and require no synchronization.
For information on the semantics of collective subroutines, see Overview of Collective Subroutines.
The intrinsic subroutine MVBITS, and the subroutine MOVE_ALLOC with a noncoarray argument FROM, are
pure. All other intrinsic subroutines are impure.
Intrinsic procedures are invoked the same way as other procedures, and follow the same rules of argument
association.
909
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The intrinsic procedures have generic (or common) names, and many of the intrinsic functions have specific
names. (Some intrinsic functions are both generic and specific.)
In general, generic functions accept arguments of more than one data type; the data type of the result is the
same as that of the arguments in the function reference. For elemental functions with more than one
argument, all arguments must be of the same type (except for the function MERGE).
When an intrinsic function is passed as an actual argument to a procedure, its specific name must be used,
and when called, its arguments must be scalar. Some specific intrinsic functions are not allowed as actual
arguments in all circumstances. The following table lists specific functions that cannot be passed as actual
arguments or as targets in procedure pointer assignment statements.
Starting with Fortran 2018, specific names of intrinsic functions that also have generic names are
obsolescent.
910
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Note that none of the intrinsic subroutines can be passed as actual arguments or as targets in procedure
pointer assignment statements.
The A to Z Reference contains the descriptions of all intrinsics listed in alphabetical order. Each reference
entry indicates whether the procedure is inquiry, elemental, transformational, or nonelemental, and whether
it is a function or a subroutine.
See Also
Argument association
MERGE
Optional arguments
Data representation models
References to Generic Intrinsic Functions
References to Elemental Intrinsic Procedures
Some argument keywords are optional (denoted by square brackets). The following describes some of the
most commonly used optional arguments:
Examples
The syntax for the DATE_AND_TIME intrinsic subroutine shows four optional positional arguments: DATE,
TIME, ZONE, and VALUES. The following shows some valid ways to specify these arguments:
! Keyword example
CALL DATE_AND_TIME (ZONE=Z)
! Positional example
CALL DATE_AND_TIME (DATE, TIME, ZONE)
See Also
CALL for details on argument keywords in subroutine references
Function references for details on argument keywords in function references
Argument Association
911
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
912
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can refer to the bit field contained in bits 3 through 6 by specifying a starting position of 3 and a length
of 4.
Negative integers are represented in two's complement notation. For example, the integer -47 is represented
by the following:
913
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(1) 1
INTEGER(2) 2
INTEGER(4) 4
INTEGER(8) 8
The bit manipulation functions each have a generic form that operates on all of these integer types and a
specific form for each type.
When you specify the intrinsic functions that refer to bit positions or that shift binary patterns within a
storage unit, be careful that you do not create a value that is outside the range of integers representable by
the data type. If you shift by an amount greater than or equal to the size of the object you're shifting, the
result is 0.
Consider the following:
INTEGER(2) I,J
I = 1
J = 17
I = ISHFT(I,J)
The variables I and J have INTEGER(2) type. Therefore, the generic function ISHFT maps to the specific
function IISHFT, which returns an INTEGER(2) result. INTEGER(2) results must be in the range -32768 to
32767, but the value 1, shifted left 17 positions, yields the binary pattern 1 followed by 17 zeros, which
represents the integer 131072. In this case, the result in I is 0.
The previous example would be valid if I was INTEGER(4), because ISHFT would then map to the specific
function JISHFT, which returns an INTEGER(4) value.
If ISHFT is called with a constant first argument, the result will either be the default integer size or the
smallest integer size that can contain the first argument, whichever is larger.
914
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
915
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
916
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
917
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 All of the numeric manipulation, and many of the numeric inquiry functions are defined by the model
sets for integers and reals.
2 The value of the argument does not have to be defined.
3 For more information on bit functions, see Bit functions.
4 The Intel® Fortran processor character set is ASCII, so ACHAR = CHAR and IACHAR = ICHAR.
The following table summarizes the generic intrinsic functions and indicates whether they are elemental,
inquiry, or transformational functions. Optional arguments are shown within square brackets.
Some intrinsic functions are specific with no generic association. These functions are listed below.
918
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
919
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
920
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
921
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
922
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
923
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
924
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MAXLOC (ARRAY, DIM [, MASK, T The rank-one array that has the
KIND, BACK]) or MAXLOC location of the maximum element
(ARRAY [, MASK, KIND, BACK]) in the argument array
MINLOC (ARRAY, DIM [, MASK, T The rank-one array that has the
KIND, BACK]) or MINLOC (ARRAY location of the minimum element
[, MASK, KIND, BACK]) in the argument array
925
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
926
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
927
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
928
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Key to Classes
E-Elemental
I-Inquiry
T-Transformational
The following table lists specific functions that have no generic function associated with them and indicates
whether they are elemental, nonelemental, or inquiry functions. Optional arguments are shown within square
brackets.
929
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Key to Classes
E-Elemental
I-Inquiry
N-Nonelemental
Intrinsic Subroutines
The following table lists the intrinsic subroutines. Optional arguments are shown within square brackets. All
these subroutines are nonelemental except for MVBITS. All of these subroutines, with the exception of
MVBITS, and MOVE_ALLOC with a noncoarray FROM argument, are impure. None of the intrinsic subroutines
can be passed as actual arguments.
930
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Intrinsic Subroutines
Subroutine Value Returned or Result
ATOMIC_CAS (atom, old, compare, new [,stat]) Performs atomic compare and swap.
ATOMIC_FETCH_ADD (atom, value, old [, stat]) Performs atomic fetch and addition.
ATOMIC_FETCH_AND (atom, value, old [, stat]) Performs atomic fetch and bitwise AND.
ATOMIC_FETCH_OR (atom, value, old [, stat]) Performs atomic fetch and bitwise OR.
ATOMIC_FETCH_XOR (atom, value, old [, stat]) Performs atomic fetch and bitwise exclusive OR.
CO_MAX (a, result_image [, stat, errmsg]) Computes maximum value across images.
CO_MIN (a, result_image [, stat, errmsg]) Computes minimum value across images.
CO_REDUCE (a, operation [, result_image, stat, Performs a generalized reduction across images.
errmsg])
CO_SUM (a, result_image [, stat, errmsg]) Performs a sum reduction across images.
DATE_AND_TIME ([date] [,time] [,zone] [,values]) Returns the date and time information from the
real-time clock.
ERRSNS ([io_err] [,sys_err] [,stat] [,unit] [,cond]) Returns information about the most recently
detected error condition.
GETARG (n, buffer [,status]) Returns the specified command line argument
(where the command itself is argument number
zero).
GET_COMMAND ([command, length, status, Returns the entire command that was used to
errmsg]) invoke the program.
931
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MM_PREFETCH (address [,hint] [,fault] Returns data from the specified address on one
[,exclusive]) memory cache line.
MVBITS (from, frompos, len, to, topos)1 Causes a sequence of bits (bit field) to be copied
from one location to another.
SYSTEM_CLOCK ([count] [,count_rate] Returns data from the processors real-time clock.
[,count_max])
932
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PRINT statement is the same as a formatted, sequential WRITE statement, except that the PRINT
statement must never transfer data to user-specified I/O units.
TYPE is a synonym for PRINT. All forms and rules for the PRINT statement also apply to the TYPE
statement.
• REWRITE
It rewrites the current record and it can be formatted or unformatted.
File connection, file inquiry, and file positioning I/O statements are discussed in File Operation I O
Statements.
See Also
Unit Specifier (UNIT=)
io-keyword Is one of the following: ACCEPT, PRINT (or TYPE), READ, REWRITE, or
WRITE.
933
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-list Is an I/O list, which can contain variables (except for assumed-size
arrays) or implied-DO lists. Output statements can contain constants
or expressions.
If a format specifier ([FMT=]format) or namelist specifier ([NML=]group) is present, the data transfer
statement is called a formatted I/O statement; otherwise, it is an unformatted I/O statement.
If a record specifier (REC=) is present, the data transfer statement is a direct-access I/O statement;
otherwise, it is a sequential-access I/O statement.
If an error, end-of-record, or end-of-file condition occurs during data transfer, file positioning and execution
are affected, and certain control-list specifiers (if present) become defined. (For more information, see
Branch Specifiers.)
Following sections describe the I/O control list and I/O lists.
934
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-unit For external files, it identifies a logical unit and is one of the following:
• A scalar integer expression that refers to a specific file, I/O device,
or pipe. If necessary, the value is converted to integer data type
before use. The integer is in the range 0 through 2,147,483,647
(2**31-1), equal to the value of one of the constants INPUT_UNIT,
OUTPUT_UNIT or ERROR_UNIT from intrinsic module
ISO_FORTRAN_ENV, or a value returned by a NEWUNIT= specifier
from an OPEN statement.
Units 5, 6, and 0 are associated with preconnected units.
• An asterisk (*). This is the default (or implicit) external unit, which
is preconnected for formatted sequential access. You can also
preconnect files by using an environment variable.
For internal files, it identifies a scalar or array character variable that
is an internal file. An internal file is designated internal storage space
(a variable buffer) that is used with formatted (including list-directed)
sequential READ and WRITE statements.
The io-unit must be specified in a control list. If the keyword UNIT is omitted, the io-unit must be first in the
control list.
A unit number is assigned either explicitly through an OPEN statement or implicitly by the system. If a READ
statement implicitly opens a file, the file's status is STATUS='OLD'. If a WRITE statement implicitly opens a
file, the file's status is STATUS='UNKNOWN'.
If the internal file is a scalar character variable, the file has only one record; its length is equal to that of the
variable.
If the internal file is an array character variable, the file has a record for each element in the array; each
record's length is equal to one array element.
An internal file can be read only if the variable has been defined and a value assigned to each record in the
file. If the variable representing the internal file is a pointer, it must be associated; if the variable is an
allocatable array, it must be currently allocated.
Before data transfer, an internal file is always positioned at the beginning of the first character of the first
record.
See Also
OPEN statement
935
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the keyword FMT is omitted, the format specifier must be the second specifier in the control list; the io-unit
specifier must be first.
If a format specifier appears in a control list, a namelist group specifier must not appear.
See Also
FORMAT statement
Interaction between FORMAT statements and I/O lists
Rules for List-Directed Sequential READ Statements for details on list-directed input
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
If the keyword NML is omitted, the namelist specifier must be the second specifier in the control list; the io-
unit specifier must be first.
If a namelist specifier appears in a control list, a format specifier must not appear.
See Also
Rules for Namelist Sequential READ Statements for details on namelist input
Rules for Namelist Sequential WRITE Statements for details on namelist output
READ
WRITE
See Also
Alternative Syntax for a Record Specifier
936
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Execution continues with the statement following the data transfer statement, or the statement identified by
a branch specifier (if any).
An end-of-file condition occurs only during execution of a sequential READ statement; an end-of-record
condition occurs only during execution of a nonadvancing READ statement.
See Also
List of Run-Time Error Messages
CLOSE
READ
WRITE
label Is the label of the branch target statement that receives control when
the specified condition occurs.
The branch target statement must be in the same scoping unit as the
data transfer statement.
937
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The end-of-file specifier can appear only in a sequential access READ statement.
An end-of-file condition occurs when no more records exist in a file during a sequential read, or when an
end-of-file record produced by the ENDFILE statement is encountered. End-of-file conditions do not occur
in direct-access READ statements.
If an end-of-file condition occurs, the file is positioned after the end-of-file record, and execution of the
statement terminates.
If IOSTAT was specified, the IOSTAT variable becomes defined as a negative integer value. If a label was
specified, execution continues with the labeled statement.
• EOR
The end-of-record specifier can appear only in a formatted, sequential access READ statement that has
the specifier ADVANCE='NO'(nonadvancing input).
An end-of-record condition occurs when a nonadvancing READ statement tries to transfer data from a
position after the end of a record.
If an end-of-record condition occurs, the file is positioned after the current record, and execution of the
statement terminates.
If IOSTAT was specified, the IOSTAT variable becomes defined as a negative integer value. If PAD='YES'
was specified for file connection, the record is padded with blanks (as necessary) to satisfy the input item
list and the corresponding data edit descriptor. If SIZE was specified, the SIZE variable becomes defined
as an integer value. If a label was specified, execution continues with the labeled statement.
If one of the conditions occurs, no branch specifier appears in the control list, but an IOSTAT specifier
appears, execution continues with the statement following the I/O statement. If neither a branch specifier
nor an IOSTAT specifier appears, the program terminates.
See Also
I/O Status Specifier
Branch Statements
Compiler Reference section: Error Handling for details on error processing
The ADVANCE specifier can appear only in a formatted, sequential data transfer statement that specifies an
external unit. It must not be specified for list-directed or namelist data transfer, for a data transfer statement
within a DO CONCURRENT block, nor for a data transfer statement within a DO CONCURRENT block.
Advancing I/O always positions a file at the end of a record, unless an error condition occurs. Nonadvancing
I/O can position a file at a character position within the current record.
See Also
Compiler Reference: Data and I/O: Fortran I/O: Advancing and Nonadvancing Record I/O
938
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Asynchronous I/O is permitted only for external files opened with an OPEN statement that specifies
ASYNCHRONOUS='YES'.
When an asynchronous I/O statement is executed, the pending I/O storage sequence for the data transfer
operation is defined to be:
• The set of storage units specified by the I/O item list or by the NML= specifier
• The storage units specified by the SIZE= specifier
If PAD='YES' was specified for file connection, blanks inserted as padding are not counted.
For input statements, the SIZE= specifier can appear only in a formatted, sequential READ statement that
has the specifier ADVANCE='NO' (nonadvancing input). It must not be specified for list-directed or namelist
data transfer.
For asynchronous nonadvancing input, the storage units specified in the SIZE= specifier become defined with
the count of the characters transferred when the corresponding wait operation is executed.
ID Specifier (ID=)
The ID specifier identifies a pending data transfer operation for a specified unit. It takes the following form:
ID=id-var
If an ID specifier is used in a data transfer statement, a wait operation is performed for the operation. If it is
omitted, wait operations are performed for all pending data transfers for the specified unit.
If an error occurs during the execution of a data transfer statement containing an ID specifier, the variable
specified becomes undefined.
In an INQUIRE statement, the ID= specifier identifies a pending asynchronous data transfer. It is is used with
the PENDING specifier to determine whether a specific asynchronous pending data transfer is completed.
939
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each file storage unit has a unique file position, represented by a positive integer. The first file storage unit is
a file is at file position 1. The position of each subsequent file storage unit is one greater than that of its
preceding file storage unit.
For a formatted file, the file storage unit is an eight-bit byte. For an unformatted file, the file storage unit is
an eight-bit byte (if option assume byterecl is specified) or a 32-bit word (if option assume nobyterecl, the
default, is specified).
If an error (ERR=), end-of-file (END=), or end-of-record (EOR=) condition occurs during execution of an I/O
statement, msg-var is assigned an explanatory message.
If no error occurs, the value of the variable remains unchanged.
I/O Lists
In a data transfer statement, the I/O list specifies the entities whose values will be transferred. An input list
is made up of implied-do lists and simple lists of variables (except for assumed-size arrays). An output list is
made up of implied-do lists, expressions, and simple lists of variables (except for assumed-size arrays).
In input statements, the I/O list cannot contain constants and expressions because these do not specify
named memory locations that can be referenced later in the program.
However, constants and expressions can appear in the I/O lists for output statements because the compiler
can use temporary memory locations to hold these values during the execution of the I/O statement.
If an input item is a pointer, it must be currently associated with a definable target; data is transferred from
the file to the associated target. If an output item is a pointer, it must be currently associated with a target;
data is transferred from the target to the file.
If an input or output item is an array, it is treated as if the elements (if any) were specified in array element
order. For example, if ARRAY_A is an array of shape (2,1), the following input statements are equivalent:
READ *, ARRAY_A
READ *, ARRAY_A(1,1), ARRAY_A(2,1)
However, no element of that array can affect the value of any expression in the input list, nor can any
element appear more than once in an input list. For example, the following input statements are invalid:
INTEGER B(50)
...
READ *, B(B)
READ *, B(B(1):B(10))
If an input or output item is an allocatable array, it must be currently allocated.
If an input or output item is a derived type, the following rules apply:
• Any derived-type component must be in the scoping unit containing the I/O statement.
• The derived type must not have a pointer component.
• In a formatted I/O statement, a derived type is treated as if all of the components of the structure were
specified in the same order as in the derived-type definition.
• In an unformatted I/O statement, a derived type is treated as a single object.
940
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Simple List Items in I/O Lists
Implied-DO Lists in I/O Lists
The data transfer statement assigns values to (or transfers values from) the list items in the order in which
the items appear, from left to right.
When multiple array names are used in the I/O list of an unformatted input or output statement, only one
record is read or written, regardless of how many array name references appear in the list.
Examples
The following example shows a simple I/O list:
DIMENSION ARRAY(3,3)
If the name ARRAY appears with no subscripts in a READ statement, that statement assigns values from the
input record(s) to ARRAY(1,1), ARRAY(2,1), ARRAY(3,1), ARRAY(1,2), and so on through ARRAY(3,3).
An input record contains the following values:
1,3,721.73
The following example shows how variables in the I/O list can be used in array subscripts later in the list:
DIMENSION ARRAY(3,3)
...
READ (1,30) J, K, ARRAY(J,K)
When the READ statement is executed, the first input value is assigned to J and the second to K, establishing
the subscript values for ARRAY(J,K). The value 721.73 is then assigned to ARRAY(1,3). Note that the
variables must appear before their use as array subscripts.
Consider the following derived-type definition and structure declaration:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
941
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
READ *, CONTRACT
! Namelist I/O:
INTEGER int1
LOGICAL log1
REAL r1
CHARACTER (20) char20
942
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
I/O Lists for details on the general rules for I/O lists
do-var Is the name of a scalar integer or real variable. The variable must not
be one of the input items in list.
expr Are scalar numeric expressions of type integer or real. They do not all
have to be the same type, or the same type as the DO variable.
The implied-DO loop is initiated, executed, and terminated in the same way as a DO construct.
The list is the range of the implied-DO loop. Items in that list can refer to do-var, but they must not change
the value of do-var.
Two nested implied-DO lists must not have the same (or an associated) DO variable.
Use an implied-DO list to do the following:
• Specify iteration of part of an I/O list
• Transfer part of an array
• Transfer array items in a sequence different from the order of subscript progression
If the I/O statement containing an implied-DO list terminates abnormally (with an END, EOR, or ERR branch
or with an IOSTAT value other than zero), the DO variable becomes undefined.
Examples
The following two output statements are equivalent:
943
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The inner DO loop is executed 10 times for each iteration of the outer loop; the second subscript (L)
advances from 1 through 10 for each increment of the first subscript (K). This is the reverse of the normal
array element order. Note that K is incremented by 2, so only the odd-numbered rows of the array are
output.
In the following example, the entire list of the implied-DO list (P(1), Q(1,1), Q(1,2)...,Q(1,10)) are read
before I is incremented to 2:
INTEGER mydata(25)
READ (10, 9000) (mydata(I), I=6,10,1)
9000 FORMAT (5I3)
In this example, the iolist specifies to put the input data into elements 6 through 10 of the array called
mydata. The third value in the implied-DO loop, the increment, is optional. If you leave it out, the increment
value defaults to 1.
See Also
Execution Control
I/O Lists for details on the general rules for I/O lists
Formatted:
READ (eunit, format [, advance] [, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [, round] [, size]
[, iostat] [, err] [, end] [, eor] [, iomsg]) [io-list]
READ form [, io-list]
Formatted - List-Directed:
READ (eunit, * [, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [, round] [, iostat] [, err] [, end]
[, iomsg]) [io-list]
READ * [, io-list]
944
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Formatted - Namelist:
READ (eunit, nml-group [, asynchronous] [, blank] [, decimal] [, id] [, pad ] [, pos] [, round] [, iostat] [, err]
[, end] [, iomsg])
READ nml
Unformatted:
READ (eunit [, asynchronous] [, id] [, pos] [, iostat] [, err] [, end] [, iomsg]) [io-list]
See Also
READ
I/O control-list specifiers
I/O lists
Examples
The following example shows formatted, sequential READ statements:
See Also
READ statement
Forms for Sequential READ Statements
945
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
List-Directed Records
A list-directed external record consists of a sequence of values and value separators. A value can be any of
the following:
• A constant
Each constant must be a literal constant of type integer, real, complex, logical, or character; or a
nondelimited character string. Binary, octal, hexadecimal, Hollerith, and named constants are not
permitted.
In general, the form of the constant must be acceptable for the type of the list item. The data type of the
constant determines the data type of the value and the translation from external to internal form. The
following rules also apply:
• A numeric list item can correspond only to a numeric constant, and a character list item can
correspond only to a character constant. If the data types of a numeric list element and its
corresponding numeric constant do not match, conversion is performed according to the rules for
arithmetic assignment (see the table in Numeric Assignment Statements). Conversion is not performed
between numeric and logical types unless compiler option assume old_logical_ldio is in effect. The
decimal point in a numeric constant can either be a period if DECIMAL='POINT' or a comma if
DECIMAL='COMMA'.
• A complex constant has the form of a pair of real or integer constants separated by a comma if
DECIMAL='POINT' or a semicolon if DECIMAL='COMMA' and enclosed in parentheses. Blanks can
appear between the opening parenthesis and the first constant, before and after the separating comma
or semicolon, and between the second constant and the closing parenthesis.
• A logical constant represents true values (.TRUE. or any value beginning with T, .T, t, or .t) or false
values (.FALSE. or any value beginning with F, .F, f, or .f).
A character string does not need delimiting apostrophes or quotation marks if the corresponding I/O list
item is of type default character, and the following is true:
• The character string does not contain a blank, comma (,), or slash ( / ).
• The character string is not continued across a record boundary.
• The first nonblank character in the string is not an apostrophe or a quotation mark.
• The leading character is not a string of digits followed by an asterisk.
A nondelimited character string is terminated by the first blank, comma, slash, or end-of-record
encountered. Apostrophes and quotation marks within nondelimited character strings are transferred as
is.
• A null value
A null value is specified by two consecutive value separators (such as,,) or a nonblank initial value
separator. (A value separator before the end of the record does not signify a null value.)
A null value indicates that the corresponding list element remains unchanged. A null value can represent
an entire complex constant, but cannot be used for either part of a complex constant.
• A repetition of a null value (r*) or a constant (r*constant), where r is an unsigned, nonzero, integer literal
constant with no kind parameter, and no embedded blanks.
A value separator is any number of blanks, a slash, or a comma if DECIMAL='POINT' or a semicolon if
DECIMAL='COMMA', preceded or followed by any number of blanks. When any of these appear in a character
constant, they are considered part of the character constant, not value separators.
The end of a record is equivalent to a blank character, except when it occurs in a character constant. In this
case, the end of the record is ignored, and the character constant is continued with the next record (the last
character in the previous record is immediately followed by the first character of the next record).
Blanks at the beginning of a record are ignored unless they are part of a character constant continued from
the previous record. In this case, the blanks at the beginning of the record are considered part of the
constant.
946
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Suppose the following statements are specified:
CHARACTER*14 C
DOUBLE PRECISION T
COMPLEX D,E
LOGICAL L,M
READ (1,*) I,R,D,E,L,M,J,K,S,T,C,A,B
Then suppose the following external record is read:
I 4
R 6.3
D (3.4,4.2)
E (3.0,2.0)
L .TRUE.
M .FALSE.
J Unchanged
K 14
S 14.6
T 14.6D0
C ABC,DEF/GHI' JK
A Unchanged
B Unchanged
With DECIMAL='COMMA', the following external record produces the same values as in the table above:
REAL a
INTEGER i
COMPLEX c
LOGICAL up, down
DATA a /2358.2E-8/, i /91585/, c /(705.60,819.60)/
DATA up /.TRUE./, down /.FALSE./
OPEN (UNIT = 9, FILE = 'listout', STATUS = 'NEW')
WRITE (9, *) a, i
WRITE (9, *) c, up, down
REWIND (9)
READ (9, *) a, i
READ (9, *) c, up, down
947
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
WRITE (*, *) a, i
WRITE (*, *) c, up, down
END
The preceding program produces the following output:
2.3582001E-05 91585
(705.6000,819.6000) T F
See Also
READ
Forms for Sequential READ Statements
Intrinsic Data Types for details on the literal constant forms of intrinsic data types
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
Namelist Records
A namelist external record takes the following form:
&group-nameobject = value [{, | ;} object = value] .../
group-name Is the name of the group containing the objects to be given values.
The name must have been previously defined in a NAMELIST
statement in the scoping unit. The name cannot contain embedded
blanks and must be contained within a single record.
948
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
949
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Blanks can precede or follow the beginning ampersand (&), follow the group name, precede or follow the
equal sign, or precede the terminating slash.
Comments (beginning with ! only) can appear anywhere in namelist input. The comment extends to the end
of the source line.
If an entity appears more than once within the input record for a namelist data transfer, the last value is the
one that is used.
If there is more than one object = value pair, they must be separated by value separators.
A value separator is any number of blanks, a slash, or a comma if DECIMAL='POINT' or a semicolon if
DECIMAL='COMMA', preceded or followed by any number of blanks. When any of these appear in a character
constant, they are considered part of the character constant, not value separators.
The end of a record is equivalent to a blank character, except when it occurs in a character constant. In this
case, the end of the record is ignored, and the character constant is continued with the next record (the last
character in the previous record is immediately followed by the first character of the next record).
Blanks at the beginning of a record are ignored unless they are part of a character constant continued from
the previous record. In this case, the blanks at the beginning of the record are considered part of the
constant.
When the name in the input record is an array variable or a variable of derived type, the effect is as if the
variable represented were expanded into a sequence of scalar list items of intrinsic data types. Each input
value following the equal sign must comply with format specifications for the intrinsic type of the list item in
the corresponding position in the expanded sequence.
The number of values following the equal sign must be equal to or less than the number of list items in the
expanded sequence. In the latter case (less than), the effect is as if null values have been added to match
any remaining list items in the expanded sequence.
The string length in the NAMELIST statement is not checked against the size of the CHARACTER variable to
which it will be assigned. This means that an array of n elements written in a NAMELIST statement with
DELIM=NONE may not be read back as n values. For example, consider a three-element array ARR of three-
character elements with values "ABC","DEF","GHI". In DELIM=NONE form, it prints to the data file as follows:
ARR = ABCDEFGHI
If your program reads that data file, the value will be interpreted as one non-delimited string with the value
"ABCDEFGHI" because termination is caused by the trailing blank, tab, or new line.
In some cases, values can be read as more than one string; for example, if the values themselves have final
or internal blanks, tabs, or new lines. Consider that ARR contains strings "WX ","Y\tR", "S\nQ", where "\t" is
a tab character and "\n" is a newline character. In this case, the data file contains:
ARR = WX Y\tRS\nQ
The NAMELIST processing will interpret this as four non-delimited strings: "WX", "Y", "RS" and "Q".
NOTE
In NAMELIST declarations, you may get unexpected results if all of the following are true:
1. DELIM=NONE is in effect on input.
2. A character variable is followed by another variable.
3. The other variable is either an array variable that is subscripted or a string variable that is a
substring.
4. That subscript or substring expression contains blanks.
950
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In Intel® Fortran, a list of values may follow the equal sign when the object is a single array element. In this
case, values are assigned to the specified array element and subsequent elements, in element sequence
order. For example, suppose the following input is read:
&ELEM
ARRAY_A(3)=34.54, 45.34, 87.63, 3*20.00
/
New values are assigned only to array ARRAY_A elements 3 through 8. The other element values are
unchanged.
&NLIST
A
B
C
/
If a blank followed by =? is entered, the following values are displayed:
&NLIST
A = 1.500000,
B = 2,
C = ABCDE
/
Examples
Suppose the following statements are specified:
951
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The NAMELIST statement associates the group name CONTROL with a list of five objects. The corresponding
READ statement reads the following input data from unit 1:
&CONTROL
TITLE='TESTT002AA',
INTERVAL=1,
RESET=.TRUE.,
START=10.2,
STOP =14.5
/
The following values are assigned to objects in group CONTROL:
TITLE TESTT002AA
RESET T
START 10.2
STOP 14.5
INTERVAL 1
It is not necessary to assign values to all of the objects declared in the corresponding NAMELIST group. If a
namelist object does not appear in the input statement, its value (if any) is unchanged.
Similarly, when character substrings and array elements are specified, only the values of the specified
variable substrings and array elements are changed. For example, suppose the following input is read:
&CONTROL TITLE(9:10)='BB' /
The new value for TITLE is TESTT002BB; only the last two characters in the variable change.
The following example shows an array as an object:
DIMENSION ARRAY_A(20)
NAMELIST /ELEM/ ARRAY_A
READ (UNIT=1,NML=ELEM)
Suppose the following input is read:
&ELEM
ARRAY_A=1.1, 1.2,, 1.4
/
The following values are assigned to the ARRAY_A elements:
ARRAY_A(1) 1.1
ARRAY_A(2) 1.2
ARRAY_A(3) Unchanged
ARRAY_A(4) 1.4
ARRAY_A(5)...ARRAY(20) Unchanged
952
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Nondelimited character strings that are written out by using a NAMELIST write may not be read in as
expected by a corresponding NAMELIST read. Consider the following:
NAMELIST/TEST/ CHARR
CHARACTER*3 CHARR(4)
DATA CHARR/'AAA', 'BBB', 'CCC', 'DDD'/
OPEN (UNIT=1, FILE='NMLTEST.DAT')
WRITE (1, NML=TEST)
END
The output file NMLTEST.DAT will contain:
NAMELIST/TEST/ CHARR
CHARACTER*3 CHARR(4)
DATA CHARR/4*' '/
OPEN (UNIT=1, FILE='NMLTEST.DAT')
READ (1, NML=TEST)
PRINT *, 'CHARR read in >', CHARR(1),'< >',CHARR(2),'< >',
1 CHARR(3), '< >', CHARR(4), '<'
END
The result is the following:
See Also
NAMELIST
Alternative Form for Namelist External Records
Rules for Formatted Sequential READ Statements
Rules for Namelist Sequential WRITE Statements
953
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You have previously been able to buffer the output (WRITEs) of variable length, unformatted, sequential files,
by specifying certain values for an OPEN statement, environment variable, or compiler option. You can now
do the same buffering for input (READs) of records. To enable buffering for the input of records, you can
specify any of the following:
• BUFFERED=YES in the file's OPEN statement
• Value YES (Y or y), or TRUE (T or t), or a number > 0 for the environment variable FORT_BUFFERED
• Setting buffered_io for the assume option
When any of the above are specified, the Fortran Runtime Library buffers all input records from variable
length, unformatted, sequential files, regardless of the size of the records in the file. In addition, if the
environment variable FORT_ BUFFERING_THRESHOLD has a positive value n, the following occurs:
• I/O list items with a size <= n are buffered and are moved one at a time from the runtime buffer to the
I/O list item
• I/O list items with a size > n are not buffered and are moved one at a time from the file to the I/O list
item
record length >= block size record length < block size
If an input record's length is less than or equal to the specified block size, then by default, the runtime
system always optimizes for time rather than for space and the input is buffered.
954
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an input record’s length is greater than the specified block size, then the following occurs:
• By default, the runtime system always optimizes for space rather than time and the input is not buffered.
• If you request buffering of input, then the runtime system optimizes for time and the input is buffered.
• If you request no buffering of input, then the runtime system optimizes for space rather than time and the
input is not buffered.
• If you request dynamic buffering of input, the runtime system optimizes based on the size of the I/O list
item and some items are buffered and some are not.
Optimizing for time:
Traditionally, optimizing for time comes at the expense of using more memory.
When the runtime system optimizes for time, it buffers input. It reads as much data as possible during one
disk access into the runtime's internal buffer, extending it if necessary to hold the file's largest record. Fields
within the record are then moved to the user space in response to READs from the file. Typically, minimizing
file accesses is faster.
However, there are circumstances when optimizing for space can actually be faster than optimizing for time.
For example, consider you are reading records whose length exceeds the block size and the data is being
read into a contiguous array. Reading this huge array directly into a user's space is going to be faster than
reading it first into the runtime system's internal buffer, then moving the data to the user's space. In this
case, it is better to optimize for space; that is, you should not buffer the input record.
On the other hand, if the READ is being done into non-contiguous elements of an array, the traditional
method of optimizing for time becomes a huge win. Data being read into non-contiguous array elements
must be moved, or read, into the user's space one element at a time. In this case, you always want to
optimize for time; that is, you should buffer the input data.
If you are reading large, variable length, unformatted records, you should try both buffered and unbuffered
I/O to determine which delivers the better performance.
Optimizing for space:
Traditionally, optimizing for space comes at the expense of time.
When the runtime system optimizes for space, it wants to avoid creating a huge internal buffer in order to
hold a "very large" record. The size of a "very large" record is clearly subjective, but the rule of thumb here
is whether or not a record's size is greater than the specified block size.
If this is the case, the runtime system will read one field at a time from the record, directly into the I/O list
items. The optimal record for this optimization is one whose record length exceeds the default block size of
128 KB (or a user-specified block size) and contains "very large" fields.
Note that because fields are read one at a time from the file to the user space, very large records that
contain very small fields may see a serious performance issue. In these cases, it may be better to buffer the
input. If you are reading large, variable length, unformatted records, you should try both buffered and
unbuffered I/O to determine which delivers the better performance.
Optimizing unformatted sequential input based on field size - dynamic buffering:
Dynamic buffering is a hybrid solution that chooses the time/space trade-off on a per field basis. The decision
is based on a "field size threshold" supplied by the user, deciding, for every field in every record in the file,
regardless of the record length, whether or not to buffer a field from the file to the I/O list item. The runtime
system can do this because it knows the size of a field that is being requested before actually attempting to
read the field.
When a READ statement is first executed, a read from the file is issued to fill the buffer, regardless of its size.
This is necessary so that the runtime system can extract the record size from the first length control field.
(Each unformatted sequential record has 4-byte leading and trailing record lengths to facilitate reading both
955
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
forwards and backwards in the file.) From that point on, dynamic buffering decides whether or not to buffer a
field or to read it directly from the file to the I/O list item. If the buffer holds the beginning portion of a large
field, it will be moved to the start of the I/O list item and the remainder will be read directly from the file.
The following table shows the various buffering options for unformatted, sequential input:
Dynamic buffering You get this kind of buffering by When dynamic buffering is in
specifying: effect:
• FORT_BUFFERING_THRESHOL • The runtime system does not
D=n re-allocate its buffer to
accommodate large records.
- and one of -
• All fields with a size <= n are
• OPEN (BUFFERED=YES)
buffered and are moved one
- or - at a time from the buffer to
• FORT_BUFFERED=YES the I/O list item.
- or - • Fields with a size > n are not
• assume buffered_io buffered and are moved one
at a time from the file to the
I/O list item.
Examples
The following example shows an unformatted, sequential READ statement:
956
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
READ statement
Forms for Sequential READ Statements
Record Types
Formatted:
READ (eunit, format, rec [, asynchronous] [, blank] [, decimal ] [, id] [, pad ] [, pos] [, round] [, size ] [,
iostat] [, err] [, iomsg]) [io-list]
Unformatted:
READ (eunit, rec [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
See Also
READ
I/O control-list specifiers
I/O lists
Examples
The following example shows a formatted, direct-access READ statement:
957
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For data transfer, the file must be positioned so that the record read is an unformatted record or an end-of-
file record.
The unformatted, direct-access READ statement reads a single record. Each value in the record must be of
the same type as the corresponding entity in the input list, unless the value is real or complex.
If the value is real or complex, one complex value can correspond to two real list entities, or two real values
can correspond to one complex list entity. The corresponding values and entities must have the same kind
parameter.
If the number of I/O list items is less than the number of fields in an input record, the statement ignores the
excess fields. If the number of I/O list items is greater than the number of fields in an input record, an error
occurs.
If the file is connected for formatted, list-directed, or namelist I/O, unformatted data transfer is prohibited.
Examples
The following example shows unformatted, direct-access READ statements:
Examples
The following example shows stream READ statements:
See Also
NEW_LINE
958
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Values can be transferred to objects of intrinsic or derived types. For derived types, values of intrinsic types
are transferred to the components of intrinsic types that ultimately make up these structured objects.
Before data transfer occurs, the file is positioned at the beginning of the first record. This record becomes the
current record.
If the number of I/O list items is less than the number of fields in an input record, the statement ignores the
excess fields.
If the number of I/O list items is greater than the number of fields in an input record, the input record is
padded with blanks. However, if PAD='NO' was specified for file connection, the input list and file specification
must not require more characters from the record than it contains.
In list-directed and namelist formatting, character strings have no delimiters.
Examples
The following program segment reads a record and examines the first character to determine whether the
remaining data should be interpreted as decimal, octal, or hexadecimal. It then uses internal READ
statements to make appropriate conversions from character string representations to binary.
INTEGER IVAL
CHARACTER TYPE, RECORD*80
CHARACTER*(*) AFMT, IFMT, OFMT, ZFMT
PARAMETER (AFMT='(Q,A)', IFMT= '(I10)', OFMT= '(O11)', & ZFMT= '(Z8)')
ACCEPT AFMT, ILEN, RECORD
TYPE = RECORD(1:1)
IF (TYPE .EQ. 'D') THEN
READ (RECORD(2:MIN(ILEN, 11)), IFMT) IVAL
ELSE IF (TYPE .EQ. 'O') THEN
READ (RECORD(2:MIN(ILEN, 12)), OFMT) IVAL
ELSE IF (TYPE .EQ. 'X') THEN
READ (RECORD(2:MIN(ILEN, 9)),ZFMT) IVAL
ELSE
PRINT *, 'ERROR'
END IF
END
See Also
I/O control-list specifiers
I/O lists
Rules for List-Directed Sequential READ Statements for details on list-directed input
Rules for Namelist Sequential READ Statement for details on namelist input
Formatted:
WRITE (eunit, format [, advance] [, asynchronous] [, decimal ] [, id] [, pos] [, round] [, sign ] [, iostat] [,
err] [, iomsg]) [io-list]
959
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Formatted - List-Directed:
WRITE (eunit, * [, asynchronous] [, decimal ] [, delim ] [, id] [, pos] [, round ] [, sign ] [, iostat] [, err] [,
iomsg]) [io-list]
Formatted - Namelist:
WRITE (eunit, nml-group [, asynchronous] [, decimal ] [, delim ] [, id] [, pos] [, round ] [, sign ] [, iostat] [,
err] [, iomsg])
Unformatted:
WRITE (eunit [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
See Also
WRITE
I/O control-list specifiers
I/O lists
Examples
The following example shows formatted, sequential WRITE statements:
See Also
WRITE statement
Forms for Sequential WRITE Statements
BYTE I5
960
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL(1) L2
LOGICAL(2) L2
LOGICAL(4) L2
LOGICAL(8) L2
INTEGER(1) I5
INTEGER(2) I7
INTEGER(4) I12
INTEGER(8) I22
REAL(4) 1PG15.7E2 2
REAL(8) 1PG24.15E3 2
REAL(16) 1PG43.33E4 2
COMPLEX(4) '(',1PG14.7E2,',',1PG14.7E2,')' 2
COMPLEX(8) '(',1PG23.15E3,',',1PG23.15E3,')' 2
COMPLEX(16) '(',1PG42.33E4,',',1PG42.33E4,')' 2
CHARACTER Aw1
1 Where w is the length of the character expression.
2 If option assume noold_ldout_format is in effect, the compiler uses Fortran 2018 standard semantics
for output of integer and real values in list-directed and namelist-directed output. This means that for real
and complex values, the output is in E or F format depending on the magnitude of the value. For more
information, see the description of option assume.
By default, character constants are not delimited by apostrophes or quotation marks, and each internal
apostrophe or quotation mark is represented externally by one apostrophe or quotation mark.
This behavior can be changed by the DELIM specifier (in an OPEN statement) as follows:
• If the file is opened with the DELIM='QUOTE' specifier, character constants are delimited by quotation
marks and each internal quotation mark is represented externally by two consecutive quotation marks.
• If the file is opened with the DELIM='APOSTROPHE' specifier, character constants are delimited by
apostrophes and each internal apostrophe is represented externally by two consecutive apostrophes.
Each output statement writes one or more complete records.
If DECIMAL='POINT', the decimal point in a numeric value is displayed as a period, values are separated by
commas, and the separator between the real and imaginary parts of a complex value is a comma. If
DECIMAL='COMMA', the decimal point is displayed as a comma, values are separated by semicolons, and the
separator between the real and imaginary parts of a complex value is a semicolon.
A literal character constant or complex constant can be longer than an entire record. For complex constants,
the end of the record can occur between the comma or semicolon and the imaginary part, if the imaginary
part and closing right parenthesis cannot fit in the current record. For literal constants that are longer than
an entire record, the constant is continued onto as many records as necessary.
Each output record begins with a blank character for carriage control.
Slashes, octal values, null values, and repeated forms of values are not output.
If the file is connected for unformatted I/O, list-directed data transfer is prohibited.
961
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Suppose the following statements are specified:
DIMENSION A(4)
DATA A/4*3.4/
WRITE (1,*) 'ARRAY VALUES FOLLOW'
WRITE (1,*) A,4
The following records are then written to external unit 1:
INTEGER i, j
REAL a, b
LOGICAL on, off
CHARACTER(20) c
DATA i /123456/, j /500/, a /28.22/, b /.0015555/
DATA on /.TRUE./, off/.FALSE./
DATA c /'Here''s a string'/
WRITE (*, *) i, j
WRITE (*, *) a, b, on, off
WRITE (*, *) c
END
The preceding example produces the following output:
123456 500
28.22000 1.555500E-03 T F
Here's a string
See Also
Rules for Formatted Sequential WRITE Statements
Rules for List-Directed Sequential READ Statements for details on list-directed input
962
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A literal character constant or complex constant can be longer than an entire record. For complex constants,
the end of the record can occur between the comma or semicolon and the imaginary part, if the imaginary
part and closing right parenthesis cannot fit in the current record. For literal constants that are longer than
an entire record, the constant is continued onto as many records as necessary.
Each output record begins with a blank character for carriage control, except for literal character constants
that are continued from the previous record.
Slashes, octal values, null values, and repeated forms of values are not output.
If the file is connected for unformatted I/O, namelist data transfer is prohibited.
Examples
Consider the following statements:
&PARAM
NAME(2)(10:)='HEISENBERG',
PITCH=5.0, YAW=0.0, ROLL=5.0,
DIAGNOSTICS=.TRUE.
ITERATIONS=10
/
The following is then written to the file connected to unit 2:
&PARAM
NAME = ' ', ' HEISENBERG',
PITCH = 5.000000,
ROLL = 5.000000,
TYPEVAR = 1, 2.0, 'ABCDE'
YAW = 0.0000000E+00,
POSITION = 3*0.0000000E+00,
DIAGNOSTICS = T,
ITERATIONS = 10
/
Note that character values are not enclosed in apostrophes unless the output file is opened with
DELIM='APOSTROPHE'. The value of POSITION is not defined in the namelist input, so the current value of
POSITION is written.
963
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example declares a number of variables, which are placed in a namelist, initialized, and then
written to the screen with namelist I/O:
INTEGER(1) int1
INTEGER int2, int3, array(3)
LOGICAL(1) log1
LOGICAL log2, log3
REAL real1
REAL(8) real2
COMPLEX z1, z2
CHARACTER(1) char1
CHARACTER(10) char2
int1 = 11
int2 = 12
int3 = 14
log1 = .TRUE.
log2 = .TRUE.
log3 = .TRUE.
real1 = 24.0
real2 = 28.0d0
z1 = (38.0,0.0)
z2 = (316.0d0,0.0d0)
char1 = 'A'
char2 = '0123456789'
array(1) = 41
array(2) = 42
array(3) = 43
WRITE (*, example)
The preceding example produces the following output:
&EXAMPLE
INT1 = 11,
INT2 = 12,
INT3 = 14,
LOG1 = T,
LOG2 = T,
LOG3 = T,
REAL1 = 24.00000,
REAL2 = 28.0000000000000,
Z1 = (38.00000,0.0000000E+00),
Z2 = (316.0000,0.0000000E+00),
CHAR1 = A,
CHAR2 = 0123456789,
ARRAY = 41, 42, 43
/
See Also
NAMELIST
Rules for Formatted Sequential WRITE Statements
Rules for Namelist Sequential READ Statements
964
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows an unformatted, sequential WRITE statement:
Formatted:
WRITE (eunit, format, rec [, asynchronous] [, decimal ] [, delim ] [, id] [, pos] [, round ] [, sign ] [, iostat] [,
err] [, iomsg]) [io-list]
Unformatted:
WRITE (eunit, rec [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
See Also
WRITE
I/O control-list specifiers
I/O lists
Examples
The following example shows a formatted, direct-access WRITE statement:
965
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows unformatted, direct-access WRITE statements:
See Also
NEW_LINE
966
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows an internal WRITE statement:
INTEGER J, K, STAT_VALUE
CHARACTER*50 CHAR_50
...
WRITE (FMT=*, UNIT=CHAR_50, IOSTAT=STAT_VALUE) J, K
See Also
I/O control-list specifiers
I/O lists
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
Rules for Namelist Sequential WRITE Statements for details on namelist output
967
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A DT edit descriptor must correspond to a list item of a derived type. Also, there should be an accessible
interface to a corresponding defined FORMATTED I/O procedure for that derived type.
In a format statement, if the last closing parenthesis of the format string is reached and there are no
effective items left, then format processing terminates. But, if there are more items to be processed, then
format control reverts to the beginning of the format item which was terminated by the next-to-last right
parenthesis.
If there is no such preceding right parenthesis, it reverts to the first left parenthesis of the format
specification. During this format reversion, the right parenthesis that is part of a DT edit descriptor is not
considered as the next-to-last parenthesis. For example, consider the following:
write (10, '(F10.3, I5, DT "sample" (1, 2) )' ) 10.1, 3, obj1, 4.7, 1, obj2
In the above case, format control reverts to the left parenthesis before F10.3 and not to DT.
Examples
The following are valid ways to specify the DT edit descriptor:
DT
DT "z8, i4, e10.2"
DT (1, -1, +1000)
DT 'spec1 type' (0)
Generic Bindings
User-defined I/O procedures can be type-bound procedures that use a defined-io-generic-spec (see Defined
IO Procedures).
Consider the following:
TYPE LIST
TYPE(NODE), POINTER :: FIRST
CONTAINS
PROCEDURE :: FMTREAD => LIST_FMTREAD
PROCEDURE :: FMTWRITE => LIST_FMTWRITE
GENERIC,PUBLIC :: READ(FORMATTED) => FMTREAD
GENERIC,PUBLIC :: WRITE(FORMATTED) => FMTWRITE
END TYPE LIST
968
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the above example, LIST_FMTREAD and LIST_FMTWRITE are the type-bound defined I/O procedures. If
an object of type LIST is an effective item in a formatted READ statement, LIST_FMTREAD will be called to
perform the read operation.
See Also
Type-Bound Procedures
Resolving Defined I/O Procedure References
TYPE LIST
INTEGER :: X
END TYPE
CONTAINS
See Also
TYPE Statement (Derived Types)
Defining Generic Names for Procedures
969
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
var Is a scalar of the derived type. For output, it holds the value to be
written. For input, it will be altered in accordance with the values
read.
unit Is the scalar integer value of the I/O unit on which input or output is
taking place. It is a negative number for an internal file or for an
external unit that is a NEWUNIT value. It is a processor-dependent
number (which may be negative) for the '*' unit.
The following interfaces specify the characteristics of the user-defined I/O procedures:
SUBROUTINE my_read_formatted (var,unit,iotype,vlist,iostat,iomsg)
dtv-type-spec,INTENT(INOUT) :: var
INTEGER,INTENT(IN) :: unit
CHARACTER(*),INTENT(IN) :: iotype
INTEGER,INTENT(IN) :: vlist(:)
INTEGER,INTENT(OUT) :: iostat
CHARACTER(*),INTENT(INOUT) :: iomsg
END
970
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
dtv-type-spec,INTENT(IN) :: var
INTEGER,INTENT(IN) :: unit
INTEGER,INTENT(OUT) :: iostat
CHARACTER(*),INTENT(INOUT) :: iomsg
END
See Also
ISO_FORTRAN_ENV Module
See Also
ISO_FORTRAN_ENV Module
User-Defined Derived-Type I/O
See Also
Characteristics of Defined I/O Procedures
971
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE LIST_MODULE
IMPLICIT NONE
TYPE NODE
! This type declaration represents a singly-linked list that also
! contains a user-defined i/o procedure. The name of the procedure
! is arbitrary, but the order of arguments must conform to the
! standard definition.
INTEGER :: VALUE = -1
TYPE(NODE), POINTER :: NEXT_NODE => NULL()
CONTAINS
PROCEDURE :: PWF
GENERIC :: WRITE(FORMATTED) => PWF ! <=== GENERIC BINDING.
END TYPE NODE
CONTAINS
RECURSIVE SUBROUTINE PWF( DTV, UNIT, IOTYPE, V_LIST, IOSTAT, IOMSG )
! These arguments are defined in the standard.
CLASS(NODE), INTENT(IN) :: DTV
INTEGER, INTENT(IN) :: UNIT
CHARACTER(LEN=*), INTENT(IN) :: IOTYPE
INTEGER, DIMENSION(:), INTENT(IN) :: V_LIST
INTEGER :: IOSTAT
CHARACTER(LEN=*), INTENT(INOUT) :: IOMSG
! The following is a child i/o statement that is called when user-defined i/o
! statement is invoked.
WRITE( UNIT=UNIT, FMT='(I9)', IOSTAT=IOSTAT ) DTV%VALUE
PRINT *, ASSOCIATED(DTV%NEXT_NODE)
IF(IOSTAT /= 0)RETURN
PROGRAM LISTE
USE LIST_MODULE
IMPLICIT NONE
INTEGER :: UNIT, IOSTAT, I
TYPE(NODE), POINTER :: CUR, TO_PRINT
972
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DO I = 1,10
ALLOCATE(CUR%NEXT_NODE)
CUR % VALUE = I
CUR => CUR%NEXT_NODE
END DO
CUR % NEXT_NODE => NULL()
! END CREATION OF LINKED LIST
DO I = 1,15
IF(ASSOCIATED(TO_PRINT)) THEN
PRINT *, I, TO_PRINT%VALUE
TO_PRINT => TO_PRINT % NEXT_NODE
END IF
END DO
Example 1
The following example shows formatted defined I/O using the DT edit descriptor and both generic type-bound
and explicit interface procedures:
MODULE TYPES
TYPE T
INTEGER :: K(10)
CONTAINS
! an explicit interface
INTERFACE WRITE(FORMATTED)
MODULE PROCEDURE UDIO_WRITE_ARRAY
END INTERFACE
CONTAINS
SUBROUTINE UDIO_READ_ARRAY (DTV, UNIT, IOTYPE, V_LIST, IOSTAT, IOMSG)
CLASS(T), INTENT(INOUT) :: DTV
INTEGER, INTENT(IN) :: UNIT
CHARACTER(*), INTENT(IN) :: IOTYPE
INTEGER, INTENT(IN) :: V_LIST (:)
INTEGER, INTENT(OUT) :: IOSTAT
CHARACTER(*), INTENT(INOUT) :: IOMSG
! This is the child I/O that gets performed when the procedure
! is called from a parent I/O – it uses list-directed input to read
! the array K
973
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! This is the child I/O that gets performed when the procedure
! is called from a parent I/O – it uses list-directed output to write
! the array K
PROGRAM TEST1
USE TYPES
TYPE (T) :: V
INTEGER :: COUNTCHAR
1, 3, 5, 7, 9, 2, 4, 6, 8, 10
In this case, the program TEST1 in procedure UDIO_WRITE_ARRAY prints:
1 3 5 7 9 2
4 6 8 10
Example 2
The following example shows list-directed formatted output and user-defined I/O:
MODULE M
TYPE T
REAL, POINTER :: R (:)
CONTAINS
PROCEDURE :: UDIO_WRITE_LD
GENERIC :: WRITE(FORMATTED) => UDIO_WRITE_LD
END TYPE T
CONTAINS
SUBROUTINE UDIO_WRITE_LD (DTV, UNIT, IOTYPE, V_LIST, IOSTAT, IOMSG)
CLASS(T), INTENT(IN) :: DTV
INTEGER, INTENT(IN) :: UNIT
974
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROGRAM TEST2
USE M
TYPE (T) :: X
REAL, TARGET :: V (3)
Example 3
The following example shows user-defined derived-type NAMELIST input/output:
! PROGRAM: udio_nml_read_write.f90
!
! This program tests NAMELIST READ and WRITE. In the WRITE subroutine, there
! are FORMATTED WRITES as well as NAMELIST WRITES.
!
MODULE UDIO
TYPE MYDT
INTEGER F1
INTEGER F2
CONTAINS
PROCEDURE :: MYSUBROUTINE
GENERIC :: READ (FORMATTED) => MYSUBROUTINE
END TYPE MYDT
INTEGER I, J
NAMELIST /SUBRT_NML/ I, J
I=DTV%F1
975
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
J=DTV%F2
! X and Y are aliases for DTV%F1 and DTV%F2 since field references
! cannot be referenced in a NAMELIST statement
INTEGER X, Y
NAMELIST /SUBRT_NML/ X, Y
X = DTV%F1
Y = DTV%F2
PROGRAM UDIO_PROGRAM
USE UDIO
TYPE (MYDT) :: MYDTV
INTEGER :: A, B
NAMELIST /MAIN_NML/ A, MYDTV, B
&MAIN_NML
A=100
MYDTV=20 30
&SUBRT_NML
X=20
Y=30
/
/B=200
/
976
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
&MAIN_NML
A = 100,
MYDTV=NAMELIST 20 30
&SUBRT_NML
I = 20,
J = 30
/
/B = 200
/
Example 4
The following example shows user-defined derived-type UNFORMATTED input/output:
! PROGRAM: udio_unformatted_1.f90
!
! This test first writes unformatted data to a file via user-defined derived type output
! and then reads the data from the file via user-defined derived type input.
!
MODULE UNFORMATTED
TYPE UNFORMATTED_TYPE
INTEGER :: I
CHARACTER*25 :: CHAR
CONTAINS
PROCEDURE :: MY_UNFMT_WRITE
GENERIC :: WRITE (UNFORMATTED) => MY_UNFMT_WRITE
END TYPE UNFORMATTED_TYPE
CONTAINS
SUBROUTINE MY_UNFMT_WRITE (DTV, UNIT, IOSTAT, IOMSG)
CLASS (UNFORMATTED_TYPE), INTENT(IN) :: DTV
INTEGER, INTENT(IN) :: UNIT
INTEGER, INTENT(OUT) :: IOSTAT
CHARACTER(LEN=*), INTENT(INOUT) :: IOMSG
PROGRAM UNFORMATTED_WRITE_PROGRAM
USE UNFORMATTED
977
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
T T
T T
I/O Formatting
A format appearing in an input or output (I/O) statement specifies the form of data being transferred and the
data conversion (editing) required to achieve that form. The format specified can be explicit or implicit.
Explicit format is indicated in a format specification that appears in a FORMAT statement or a character
expression (the expression must evaluate to a valid format specification).
The format specification contains edit descriptors, which can be data edit descriptors, control edit descriptors,
or string edit descriptors.
Implicit format is determined by the processor and is specified using list-directed or namelist formatting.
List-directed formatting is specified with an asterisk (*); namelist formatting is specified with a namelist
group name.
List-directed formatting can be specified for advancing sequential files and internal files. Namelist formatting
can be specified only for advancing sequential files.
See Also
Rules for List-Directed Sequential READ Statements for details on list-directed input
Rules for List-Directed Sequential WRITE Statements for details on list-directed output
Rules for Namelist Sequential READ Statements for details on namelist input
Rules for Namelist Sequential WRITE Statements for details on namelist output
Format Specifications
A format specification can appear in a FORMAT statement or a character expression. In a FORMAT statement,
it is preceded by the keyword FORMAT. A format specification takes one of the following forms:
( [format-items])
( [format-items, ] unlimited-format-item)
978
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
data-edit-desc Is one of the data edit descriptors: I, B, O, Z, F, E, EN, ES, EX, D, DT, G, L, or A.
A repeat specification can precede any data edit descriptor.
control-edit-desc Is one of the control edit descriptors: T, TL, TR, X, S, SP, SS, BN, BZ, P, :, /, $, \,
and Q.
A repeat specification can precede the slash (/) edit descriptor.
char-string-edit-desc Is one of the string edit descriptors: H, 'c', and "c", where c is a character
constant.
If more than one edit descriptor is specified, they must be separated by commas or slashes (/).
A comma can be omitted in the following cases:
• Between a P edit descriptor and an immediately following F, E, EN, ES, EX, D, or G edit descriptor
• Before a slash (/) edit descriptor when the optional repeat specification is not present
• After a slash (/) edit descriptor
• Before or after a colon (:) edit descriptor
Description
A FORMAT statement must be labeled.
Named constants are not permitted in format specifications.
If the associated I/O statement contains an I/O list, the format specification must contain at least one data
edit descriptor or the control edit descriptor Q.
Blank characters can precede the initial left parenthesis, and additional blanks can appear anywhere within
the format specification. These blanks have no meaning unless they are within a character string edit
descriptor.
When a formatted input statement is executed, the setting of the BLANK specifier (for the relevant logical
unit) determines the interpretation of blanks within the specification. If the BN or BZ edit descriptors are
specified for a formatted input statement, they supersede the default interpretation of blanks. (For more
information on BLANK defaults, see BLANK Specifier in OPEN statements.)
For formatted input, you can use the comma as an external field separator. The comma terminates the input
of fields (for noncharacter data types) that are shorter than the number of characters expected. It can also
designate null (zero-length) fields.
The following table summarizes the edit descriptors that can be used in format specifications.
979
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
980
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
981
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To avoid using consecutive apostrophes or quotation marks, you can put the character constant in an I/O list
instead of a format specification, as follows:
SUBROUTINE PRINT(TABLE)
REAL TABLE(10,5)
CHARACTER*5 FORCHR(0:5), RPAR*1, FBIG, FMED, FSML
DATA FORCHR(0),RPAR /'(',')'/
DATA FBIG,FMED,FSML /'F8.2,','F9.4,','F9.6,'/
DO I=1,10
DO J=1,5
IF (TABLE(I,J) .GE. 100.) THEN
FORCHR(J) = FBIG
ELSE IF (TABLE(I,J) .GT. 0.1) THEN
FORCHR(J) = FMED
ELSE
FORCHR(J) = FSML
END IF
END DO
FORCHR(5)(5:5) = RPAR
WRITE (6,FORCHR) (TABLE(I,J), J=1,5)
END DO
END
The DATA statement assigns a left parenthesis to character array element FORCHR(0), and (for later use) a
right parenthesis and three F edit descriptors to character variables.
Next, the proper F edit descriptors are selected for inclusion in the format specification. The selection is
based on the magnitude of the individual elements of array TABLE.
A right parenthesis is added to the format specification just before the WRITE statement uses it.
NOTE
Format specifications stored in arrays are recompiled at run time each time they are used. If a
Hollerith or character runtime format is used in a READ statement to read data into the format itself,
that data is not copied back into the original array, and the array is unavailable for subsequent use as
a runtime format specification.
Examples
The following example shows a format specification:
982
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, the format list is put into an 80-character variable called MYLIST:
CHARACTER(80) MYLIST
MYLIST = '(I5, 3F5.2, A16)'
WRITE (*, MYLIST) iolist
Consider the following two-dimensional array:
1 2 3
4 5 6
In this case, the elements are stored in memory in the order: 1, 4, 2, 5, 3, 6 as follows:
CHARACTER(6) array(3)
DATA array / '(I5', ',3F5.2', ',A16)' /
WRITE (*, array) iolist
In the following example, the WRITE statement uses the character array element array(2) as the format
specifier for data transfer:
CHARACTER(80) array(5)
array(2) = '(I5, 3F5.2, A16)'
WRITE (*, array(2)) iolist
See Also
Data edit descriptors
Control edit descriptors
Character string edit descriptors
Variable Format Expressions
Nested and group repeats
Printing of formatted records
w Is the total number of digits in the field (the field width). If omitted,
the system applies default values (see Default Widths for Data Edit
Descriptors). The range of w is 1 through 2147483647 (2**31-1) on
983
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
Standard Fortran allows the field width to be omitted only for the A descriptor. However, Intel® Fortran allows
the field width to be omitted for any data edit descriptor.
The r, w, m, d, and e must all be positive, unsigned, integer literal constants, or the digit 0 where allowed, or
variable format expressions -- no kind parameter can be specified. They must not be named constants.
Actual useful ranges for r, w, m, d, and e may be constrained by record sizes (RECL) and the file system.
The data edit descriptors have the following specific forms:
Logical: Lw
Character: A[w]
The d must be specified with F, E, EN, ES, EX, D, and G field descriptors even if d is zero. The decimal point
is also required. You must specify both w and d.
A repeat specification can simplify formatting. For example, the following two statements are equivalent:
20 FORMAT (E12.4,E12.4,E12.4,I5,I5,I5,I5)
20 FORMAT (3E12.4,4I5)
Examples
! This WRITE outputs three integers, each in a five-space field
! and four reals in pairs of F7.2 and F5.2 values.
INTEGER(2) int1, int2, int3
984
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
General rules for numeric editing
Nested and group repeats
A minus sign must precede a negative value in an external field; a plus sign is optional before a positive
value.
In input records, constants can include any valid kind parameter. Named constants are not permitted.
If the data field in a record contains fewer than w characters, an input statement will read characters from
the next data field in the record. You can prevent this by padding the short field with blanks or zeros, or by
using commas to separate the input data. The comma terminates the data field, and can also be used to
designate null (zero-length) fields. For more information, see Terminating Short Fields of Input Data.
985
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the value is smaller than the field width specified, leading blanks are inserted (the value is right-justified).
If the value is too large for the field width specified, the entire output field is filled with asterisks (*).
When the value of the field width is zero, the compiler selects the smallest possible positive actual field width
that does not result in the field being filled with asterisks.
See Also
Forms for data edit descriptors
Format Specifications
Integer Editing
Integer editing is controlled by the I (decimal), B (binary), O (octal), and Z (hexadecimal) data edit
descriptors.
I Editing
The I edit descriptor transfers decimal integer values. It takes the following form:
Iw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item must be of type integer; logical and real items are also allowed if the compiler
option check format is not specified.
The G edit descriptor can be used to edit integer data; it follows the same rules as Iw.
986
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the I edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
B Editing
The B data edit descriptor transfers binary (base 2) values. It takes the following form:
Bw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item can be of type integer, real, or logical.
987
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the B edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
O Editing
The O data edit descriptor transfers octal (base 8) values. It takes the following form:
Ow[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item can be of type integer, real, or logical.
988
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
O4.2 7 ^^07
O4.4 7 0007
O0 83 123
See Also
Forms for data edit descriptors
General rules for numeric editing
Z Editing
The Z data edit descriptor transfers hexadecimal (base 16) values. It takes the following form:
Zw[.m]
The value of m (the minimum number of digits in the constant) must not exceed the value of w (the field
width), unless w is zero. The m has no effect on input, only output.
The specified I/O list item can be of type integer, real, or logical.
989
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for data edit descriptors
General rules for numeric editing
NOTE
Do not use the real data edit descriptors when attempting to parse textual input. These descriptors
accept some forms that are purely textual as valid numeric input values. For example, input values T
and F are treated as values -1.0 and 0.0, respectively, for .TRUE. and .FALSE.
See Also
Forms for data edit descriptors
General rules for numeric editing
Scale Factor Editing (P)
Default Widths for Data Edit Descriptors for details on system default values for data edit
descriptors
F Editing
The F data edit descriptor transfers real values. It takes the following form:
Fw.d
The value of d (the number of places after the decimal point) must not exceed the value of w (the field
width) unless w is zero. When w is zero, the processor selects the field width. On input, w must not be zero.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
990
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the field contains an exponent, that exponent is used to establish the magnitude of the value before it is
assigned to the list element.
An input field that is an IEEE exception specification consists of optional blanks, followed by either of the
following:
• An optional sign, followed by the string 'INF' or the string 'INFINITY'; this is an IEEE infinity
This form can not be used if the processor does not support IEEE infinities for the input variable.
• An optional sign, followed by the string 'NAN', optionally followed by zero or more alphanumeric
characters enclosed in parentheses, optionally followed by blanks; this is an IEEE Nan
This form can not be used if the processor does not support IEEE Nans for the input variable.
The NaN value is a quiet NaN if the only nonblank characters in the field are 'NAN' or 'NAN()'.
An input field that is a hexadecimal-significand number contains an optional sign, followed by the digit 0,
followed immediately by the letter X, followed by the hexadecimal significand followed by a hexadecimal
exponent. A hexadecimal significand is a string of one or more hexadecimal characters, optionally
containing a decimal symbol. The position of the hexadecimal point is indicated by the decimal symbol. The
hexadecimal point implicitly follows the last hexadecimal character if decimal symbol appears in the string. A
hexadecimal exponent is the letter P followed by a signed decimal digit string. Embedded blanks are not
allowed; trailing blanks are ignored. The value is equal to the significand multiplied by two raised to the
power of the exponent. If the optional sign is a minus, the value is negated.
The following shows input using the F edit descriptor:
991
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the F edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
assume compiler option
E and D Editing
The E and D data edit descriptors transfer real values in exponential form. They take the following form:
Ew.d[Ee]
Dw.d
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
For the E edit descriptor, if w is zero, the processor selects the field width. If e is zero, the exponent part
contains the minimum number of digits needed to represent the value of the exponent.
For the D edit descriptor, if the value of w is zero, the processor selects the field width.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
992
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks.
The exponent field width (e) is optional for the E edit descriptor; if omitted, the default value is 2. If e is
specified, w should be greater than or equal to d+e+5, or zero.
NOTE
If w is greater than zero, it can be as small as d + 5 or d + e + 3, if the optional fields for the sign and
the zero are omitted.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
A negative value that is not zero but rounds to zero on output is displayed with a leading minus sign. For
example, the value -0.01 in "-5P,E20.5" format will be displayed as -0.00 rather than as 0.00. The setting of
compiler option assume [no]std_minus0_rounding can affect this behavior.
The following shows output using the E and D edit descriptors (the symbol ^ represents a nonprinting blank
character):
EN Editing
The EN data edit descriptor transfers values by using engineering notation. It takes the following form:
993
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ENw.d[Ee]
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
If w is zero, the processor chooses the field width. If e is present and zero, the exponent part contains the
minimal number of digits needed to represent the exponent .
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks.
The exponent field width (e) is optional; if omitted, the default value is 2. If e is specified, w should be
greater than or equal to d + e + 5, or zero.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
994
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the EN edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
ES Editing
The ES data edit descriptor transfers values by using scientific notation. It takes the following form:
ESw.d[Ee]
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
If w is zero, the processor selects the field width. If e is present and zero, the exponent part contains the
minimal number of digits needed to represent the exponent.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
995
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks.
The exponent field width (e) is optional; if omitted, the default value is 2. If e is specified, the w should be
greater than or equal to d + e + 5.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
The following shows output using the ES edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
General rules for numeric editing
EX Editing
The EX data edit descriptor transfers real values represented as hexadecimal-significand numbers. It takes
the following form:
EXw.d[Ee]
w is the external field width, unless it is zero. d is the width of the fractional part of the number, unless it is
0.
If w or d are zero, the processor picks the external field width or the width of the fractional part, respectively.
d cannot be zero if the radix of the internal value is not a power of two. The hexadecimal point appears after
the first hexadecimal digit and it represented by the decimal symbol.
e, if present and nonzero, is the number of digits in the exponent. If Ee is not present, or e is zero, the
exponent contains the minimum number of digits needed to represent the exponent. e is ignored on input.
The specified I/O list item must be of type real, or it must be the real or imaginary part of a complex type.
996
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For EXw.dEe with e greater than zero, the form is P[+|-]z1z2…ze. For EXw.d and EXw.dE0, the form of the
exponent is P[+|-]z1z2…zn where n is the minimum number of digits required to represent the exponent. The
exponent sign is always produced and is plus if the exponent is zero. The choice of the binary exponent is
processor dependent.
The following shows possible output using the EX edit descriptor if SS is in effect:
See Also
F Editing
General rules for numeric editing
G Editing
The G data edit descriptor for generalized editing can be used for input or output with any intrinsic type. It
takes the following forms:
Gw
Gw.d
Gw.dEe
where w is the total field width, d is the number of places after the decimal point, and e is the number of
digits in the exponent.
If w is 0, the field width is selected by the processor. If w is zero, you can only specify forms G0 or G0.d.
If w is nonzero, d must be specified.
If e is present and zero, the exponent part contains the minimal number of digits needed to represent the
exponent. For integer, character, and logical data types d and e are ignored.
When used to specify I/O for integer data, the Gw, Gw.d and Gw.dEe edit descriptors follow the rules for Iw
editing.
When used to specifiy I/O for logical data, the Gw.d and Gw.dEe edit descriptors with nonzero w follow the
rules for Lw editing. On output, if w is 0, the Gw and Gw.d edit descriptors follow the rules for L1 editing.
When used to specify I/O for character data, the Gw.d and Gw.d.Ee edit descriptors with nonzero w follows
the same rules as Aw editing. For output, when w is zero, the Gw and Gw.d edit descriptors follow the rules
for A editing when no w is specified.
997
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
. .
. .
. .
The 'b' is a blank following the numeric data representation. For Gw.d, n('b') is 4 blanks. For Gw.dEe, n('b' )
is e+2 blanks.
The r is defined for each I/O rounding mode as follows:
Rounding Mode r
COMPATIBLE 0.5
UP 1
DOWN 0
Note that the scale factor has no effect on output unless the magnitude of the datum to be edited is outside
the range that permits effective use of F editing.
If w is greater than zero, it should be greater than or equal to d+7 to allow for the following:
• A sign (optional if the value is positive and descriptor SP is not in effect)
• One digit to the left of the decimal point
• The decimal point
• The d digits to the right of the decimal point
• The 4-digit or e+2-digit exponent
If e is specified and positive, w should be greater than or equal to d + e + 5 if w is positive.
If an exponent exceeds its specified or implied width, or the number of characters produced exceeds the field
width, the entire field of width w is filled with asterisks. However, the field width is not filled with asterisks if
the field width is exceeded when optional characters are omitted.
For an internal value that is an IEEE infinity or an IEEE NaN, the form of the output field is the same as for
Fw.d.
998
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the G edit descriptor and compares it to output using equivalent F editing
(the symbol ^ represents a nonprinting blank character):
See Also
Forms for data edit descriptors
General rules for numeric editing
I data edit descriptor
L data edit descriptor
A data edit descriptor
Scale Factor Editing (P)
Complex Editing
A complex value is an ordered pair of real values. Complex editing is specified by a pair of real edit
descriptors, using any combination of the forms: Fw.d, Ew.d[Ee], Dw.d, ENw.d[Ee], ESw.d[Ee], or Gw.d[Ee].
See Also
Forms for data edit descriptors
General rules for numeric editing
General Rules for Complex Constants for details on complex constants
999
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for data edit descriptors
BYTE 1
LOGICAL(1) or LOGICAL*1 1
1000
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL(2) or LOGICAL*2 2
LOGICAL(4) or LOGICAL*4 4
LOGICAL(8) or LOGICAL*8 8
INTEGER(1) or INTEGER*1 1
INTEGER(2) or INTEGER*2 2
INTEGER(4) or INTEGER*4 4
INTEGER(8) or INTEGER*8 8
REAL(4) or REAL*4 4
DOUBLE PRECISION 8
REAL(8) or REAL*8 8
REAL(16) or REAL*16 16
COMPLEX(4) or COMPLEX*81 8
DOUBLE COMPLEX1 16
COMPLEX(8) or COMPLEX*161 16
COMPLEX(16) or COMPLEX*321 32
1 Complex values are treated as pairs of real numbers, so complex editing requires a pair of edit
If w is equal to or greater than the length (len) of the input item, the rightmost characters are assigned to
that item. The leftmost excess characters are ignored.
If w is less than len, or less than the number of characters that can be stored, w characters are assigned to
the list item, left-justified, and followed by trailing blanks.
The following shows input using the A edit descriptor (the symbol ^ represents a nonprinting blank
character):
1001
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows output using the A edit descriptor (the symbol ^ represents a nonprinting blank
character):
See Also
Forms for data edit descriptors
I, B, O, Z, G BYTE 7
INTEGER(1), LOGICAL(1) 7
INTEGER(2), LOGICAL(2) 7
INTEGER(4), LOGICAL(4) 12
INTEGER(8), LOGICAL(8) 23
O, Z REAL(4) 12
REAL(8) 23
REAL(16) 44
L, G LOGICAL(1), LOGICAL(2), 2
LOGICAL(4), LOGICAL(8)
REAL(8), COMPLEX(8) 25 d: 16 e: 2
REAL(16), COMPLEX(16) 42 d: 33 e: 3
EN REAL(4), COMPLEX(4) 15 d: 6 e: 2
REAL(8), COMPLEX(8) 25 d: 16 e: 2
REAL(16), COMPLEX(16) 42 d: 32 e: 3
A1, G LOGICAL(1) 1
1002
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL(2), INTEGER(2) 2
LOGICAL(4), INTEGER(4) 4
LOGICAL(8), INTEGER(8) 8
REAL(4), COMPLEX(4) 4
REAL(8), COMPLEX(8) 8
REAL(16), COMPLEX(16) 16
CHARACTER*len len
1 The default is the actual length of the corresponding I/O list item.
1, -2, 1.0, 35
The following assignments occur:
I = 1
J = -2
A = 1.0
B = 0.35
1003
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A comma can only terminate fields less than w characters long. If a comma follows a field of w or more
characters, the comma is considered part of the next field.
A null (zero-length) field is designated by two successive commas, or by a comma after a field of w
characters. Depending on the field descriptor specified, the resulting value assigned is 0, 0.0, 0.0D0, 0.0Q0,
or .FALSE..
See Also
General Rules for Numeric Editing
c Is one of the following format codes: T, TL, TR, X, S, SP, SS, BN, BZ,
P, RU, RD, RZ, RN, RC, RP, DC, DP, :, /, \, $, and Q.
Description
In general, control edit descriptors are nonrepeatable. The only exception is the slash (/) edit descriptor,
which can be preceded by a repeat specification or a * indicating an unlimited repeat count.
The control edit descriptors have the following specific forms:
Scale factor: kP
Miscellaneous: :, /, \, $, and Q
The P edit descriptor is an exception to the general control edit descriptor syntax. It is preceded by a scale
factor, rather than a character position specifier.
Control edit descriptors can be grouped in parentheses and preceded by a group repeat specification.
1004
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Group repeat specifications
Format Specifications
Positional Editing
The T, TL, TR, and X edit descriptors specify the position where the next character is transferred to or from a
record.
On output, these descriptors do not themselves cause characters to be transferred and do not affect the
length of the record. If characters are transferred to positions at or after the position specified by one of
these descriptors, positions skipped and not previously filled are filled with blanks. The result is as if the
entire record was initially filled with blanks.
The TR and X edit descriptors produce the same results.
See Also
Forms for Control Edit Descriptors
T Editing
The T edit descriptor specifies a character position in an I/O record. It takes the following form:
Tn
The n is a positive integer literal constant (with no kind parameter) indicating the character position of the
record, relative to the left tab limit.
On input, the T descriptor positions the external record at the character position specified by n. On output,
the T descriptor indicates that data transfer begins at the nth character position of the external record.
Examples
In the following examples, the symbol ^ represents a nonprinting blank character.
Suppose a file has a record containing the value ABC^^^XYZ, and the following statements are executed:
PRINT 25
25 FORMAT (T51,'COLUMN 2',T21,'COLUMN 1')
The following line is printed at the positions indicated:
Position 20 Position 50
| |
COLUMN 1 COLUMN 2
Note that the first character of the record printed was reserved as a control character.
See Also
Printing of Formatted Records
TL Editing
The TL edit descriptor specifies a character position to the left of the current position in an I/O record. It
takes the following form:
TLn
The n is a positive integer literal constant (with no kind parameter) indicating the nth character position to
the left of the current character.
1005
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If n is greater than or equal to the current position, the next character accessed is the first character of the
record.
TR Editing
The TR edit descriptor specifies a character position to the right of the current position in an I/O record. It
takes the following form:
TRn
The n is a positive integer literal constant (with no kind parameter) indicating the nth character position to
the right of the current character.
X Editing
The X edit descriptor specifies a character position to the right of the current position in an I/O record. It
takes the following form:
nX
The n is a positive integer literal constant (with no kind parameter) indicating the nth character position to
the right of the current character.
On output, the X edit descriptor does not output any characters when it appears at the end of a format
specification; for example:
WRITE (6,99) K
99 FORMAT ('^K=',I6,5X)
Note that the symbol ^ represents a nonprinting blank character. This example writes a record of only 9
characters. To cause n trailing blanks to be output at the end of a record, specify a format of n('^').
Sign Editing
The SP, SS and S edit descriptors control the output of the optional plus (+) sign within numeric output
fields. These descriptors have no effect during execution of input statements.
These specifiers correspond to the SIGN= specifier values PLUS, SUPPRESS, and PROCESSOR_DEFINED,
respectively.
Within a format specification, a sign editing descriptor affects all subsequent I, F, E, EN, ES, EX, D, and G
descriptors until another sign editing descriptor occurs.
Examples
Consider the following:
INTEGER i
REAL r
1006
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for Control Edit Descriptors
SP Editing
The SP edit descriptor causes the processor to produce a plus sign in any subsequent position where it would
be otherwise optional. It takes the following form:
SP
SS Editing
The SS edit descriptor causes the processor to suppress a plus sign in any subsequent position where it
would be otherwise optional. It takes the following form:
SS
S Editing
The S edit descriptor restores the plus sign as optional for all subsequent positive numeric fields. It takes the
following form:
S
The S edit descriptor restores to the processor the discretion of producing plus characters on an optional
basis.
Blank Editing
The BN and BZ descriptors control the interpretation of embedded and trailing blanks within numeric input
fields. These descriptors have no effect during execution of output statements.
Within a format specification, a blank editing descriptor affects all subsequent I, B, O, Z, F, E, EN, ES, D, and
G descriptors until another blank editing descriptor occurs.
The blank editing descriptors override the effect of the BLANK specifier during execution of a particular input
data transfer statement. (For more information, see the BLANK specifier in OPEN statements.)
See Also
Forms for Control Edit Descriptors
BN Editing
The BN edit descriptor causes the processor to ignore all embedded and trailing blanks in numeric input
fields. It takes the following form:
BN
The input field is treated as if all blanks have been removed and the remainder of the field is right-justified.
An all-blank field is treated as zero.
Examples
If an input field formatted as a six-digit integer (I6) contains '2 3 4', it is interpreted as ' 234'.
Consider the following code:
1007
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you enter any one of the following three records and terminate by pressing Enter, the READ statement
interprets that record as the value 123:
123
123
123 456
Because the repeatable edit descriptor associated with the I/O list item n is I6, only the first six characters of
each record are read (three blanks followed by 123 for the first record, and 123 followed by three blanks for
the last two records). Because blanks are ignored, all three records are interpreted as 123.
The following example shows the effect of BN editing with an input record that has fewer characters than the
number of characters specified by the edit descriptors and iolist. Suppose you enter 123 and press Enter in
response to the following READ statement:
BZ Editing
The BZ edit descriptor causes the processor to interpret all embedded and trailing blanks in numeric input
fields as zeros. It takes the following form:
BZ
Examples
The input field ' 23 4 ' is interpreted as ' 23040'. If ' 23 4' is entered, the formatter adds one blank to pad the
input to the six-digit integer format (I6), but this extra space is ignored, and the input is interpreted as '
2304 '. The blanks following the E or D in real-number input are ignored, regardless of the form of blank
interpretation in effect.
Suppose you enter 123 and press Enter in response to the following READ statement:
Round Editing
The RU, RD, RZ, RN, RC, and RP edit descriptors temporarily change the I/O rounding mode for a connection.
These forms of rounding correspond to the ROUND= specifier values UP, DOWN, ZERO, NEAREST,
COMPATIBLE, and PROCESSOR DEFINED, respectively. Rounding conforms to the ISO/IEC/IEEE 60559:2011
standard.
The I/O rounding mode affects the conversion of real and complex values in formatted I/O. It affects only D,
E, EN, ES, EX, F, and G editing.
Each descriptor continues to be in effect until a different round editing descriptor is encountered or until the
end of the current I/O statement.
See Also
Forms for Control Edit Descriptors
RU Editing
The RU edit descriptor causes rounding to the smallest value that is greater than or equal to the original
value. It takes the following form:
1008
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RU
RD Editing
The RD edit descriptor causes rounding to the largest representable value that is less than or equal to the
original value. It takes the following form:
RD
RZ Editing
The RZ edit descriptor causes rounding to the value closest to the original value, but not greater in
magnitude. It takes the following form:
RZ
RN Editing
The RN edit descriptor selects NEAREST rounding as specified by the ISO/IEC/IEEE 60559:2011 standard. It
takes the following form:
RN
RC Editing
The RC edit descriptor causes rounding to the closer of the two nearest representable values. If the value is
halfway between the two values, the one chosen is the one farther from zero. It takes the following form:
RC
RP Editing
The RP edit descriptor causes rounding to be determined by the default settings in the processor, which may
correspond to one of the other modes. It takes the following form:
RP
Decimal Editing
The DC and DP edit descriptors temporarily change the decimal edit mode for a connection.
These specifiers correspond to the DECIMAL= specifier values COMMA and POINT, respectively.
The decimal editing mode controls the representation of the decimal symbol during conversion of real and
complex values in formatted I/O. It affects only D, E, EN, ES, F, and G editing.
Each descriptor continues to be in effect until a different decimal editing descriptor is encountered or until the
end of the current I/O statement.
See Also
Forms for Control Edit Descriptors
DC Editing
The DC edit descriptor changes the decimal editing mode for a connection to a decimal comma. It takes the
following form:
DC
Note that during list-directed I/O, a semicolon is used as a value separator in place of a comma.
1009
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DP Editing
The DP edit descriptor causes rounding to be determined by the default settings in the processor, which may
correspond to one of the other modes. It takes the following form:
DP
1010
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• For F editing, the external value equals the internal value of the I/O list item multiplied by 10k. This
changes the magnitude of the data.
• For E and D editing, the external decimal field of the I/O list item is multiplied by 10k, and k is subtracted
from the exponent. This changes the form of the data.
A positive scale factor decreases the exponent; a negative scale factor increases the exponent.
For a positive scale factor, k must be less than d + 2 or an output conversion error occurs.
• For G editing, the scale factor has no effect if the magnitude of the data to be output is within the
effective range of the descriptor (the G descriptor supplies its own scaling).
If the magnitude of the data field is outside G descriptor range, E editing is used, and the scale factor has
the same effect as E output editing.
• For EN, ES, and EX editing, the scale factor has no effect.
The following shows output using the P edit descriptor (the symbol ^ represents a nonprinting blank
character):
Examples
The following shows a FORMAT statement containing a scale factor:
DIMENSION A(6)
DO 10 I=1,6
10 A(I) = 25.
WRITE (6, 100) A
100 FORMAT(' ', F8.2, 2PF8.2, F8.2)
The preceding statements produce the following results:
1011
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
a = 12.34
See Also
Forms for Control Edit Descriptors
Slash Editing ( / )
The slash edit descriptor terminates data transfer for the current record and starts data transfer for a new
record. It takes the following form:
[r]/
The r is a repeat specification. It must be a positive default integer literal constant; no kind parameter can be
specified.
The range of r is 1 through 2147483647 (2**31-1) on Intel® 64 architecture; 1 through 32767 (2**15-1) on
IA-32 architecture. If r is omitted, it is assumed to be 1.
Multiple slashes cause the system to skip input records or to output blank records, as follows:
• When n consecutive slashes appear between two edit descriptors, n - 1 records are skipped on input, or n
- 1 blank records are output. The first slash terminates the current record. The second slash terminates
the first skipped or blank record, and so on.
• When n consecutive slashes appear at the beginning or end of a format specification, n records are
skipped or n blank records are output, because the opening and closing parentheses of the format
specification are themselves a record initiator and terminator, respectively. For example, suppose the
following statements are specified:
WRITE (6,99)
99 FORMAT ('1',T51,'HEADING LINE'//T51,'SUBHEADING LINE'//)
The following lines are written:
Column 50, top of page | HEADING LINE
(blank line) SUBHEADING LINE
(blank line)
(blank line)
Note that the first character of the record printed was reserved as a control character (see Printing of
Formatted Records).
Examples
! The following statements write spreadsheet column and row labels:
WRITE (*, 100)
100 FORMAT (' A B C D E' &
& /,' 1',/,' 2',/,' 3',/,' 4',/,' 5')
The above example generates the following output:
A B C D E
1
2
3
4
5
1012
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for Control Edit Descriptors
Examples
Suppose the following statements are specified:
PRINT 1,3
PRINT 2,13
1 FORMAT (' I=',I2,' J=',I2)
2 FORMAT (' K=',I2,:,' L=',I2)
The above code causes the following lines to be written (the symbol ^ represents a nonprinting blank
character):
I=^3^J=
K=13
The following shows another example:
1013
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Forms for Control Edit Descriptors
Examples
Consider the following:
CHARACTER ICHAR(80)
READ (4, 1000) XRAY, K, NCHAR, (ICHAR(I), I= 1, NCHAR)
1000 FORMAT (E15.7, I4, Q, 80A1)
The preceding input statement reads the variables XRAY and K. The number of characters remaining in the
record is NCHAR, specified by the Q edit descriptor. The array ICHAR is then filled by reading exactly the
number of characters left in the record. (Note that this instruction will fail if NCHAR is greater than 80, the
length of the array ICHAR.) By placing Q in the format specification, you can determine the actual length of
an input record.
Note that the length returned by Q is the number of characters left in the record, not the number of reals or
integers or other data types. The length returned by Q can be used immediately after it is read and can be
used later in the same format statement or in a variable format expression. (See Variable Format
Expressions.)
Assume the file Q.DAT contains:
1234.567Hello, Q Edit
1014
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following program reads in the number REAL1, determines the characters left in the record, and reads
those into STR:
CHARACTER STR(80)
INTEGER LENGTH
REAL REAL1
OPEN (UNIT = 10, FILE = 'Q.DAT')
100 FORMAT (F8.3, Q, 80A1)
READ (10, 100) REAL1, LENGTH, (STR(I), I=1, LENGTH)
WRITE(*,'(F8.3,2X,I2,2X,<LENGTH>A1)') REAL1, LENGTH, (STR(I), &
& I= 1, LENGTH)
END
The output on the screen is:
abcdefg
abcd
Consider it is then READ with the following statements:
7
4
See Also
Forms for Control Edit Descriptors
See Also
Nested and Group Repeat Specifications
1015
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To include an apostrophe in a character constant that is enclosed by apostrophes, place two consecutive
apostrophes ('') in the format specification; for example:
50 FORMAT ('TODAY''S^DATE^IS:^',I2,'/',I2,'/',I2)
Note that the symbol ^ represents a nonprinting blank character.
Similarly, to include a quotation mark in a character constant that is enclosed by quotation marks, place two
consecutive quotation marks ("") in the format specification.
On input, the character constant edit descriptor transfers length of string characters to the edit descriptor.
Examples
Consider the following '(3I5)' format in the WRITE statement:
See Also
Character constants
Format Specifications
H Editing
The H edit descriptor transfers data between the external record and the H edit descriptor itself. The H edit
descriptor is a deleted feature in the Fortran Standard. Intel® Fortran fully supports features deleted in the
Fortran Standard.
An H edit descriptor has the form of a Hollerith constant, as follows:
nHstring
1016
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On input, the H edit descriptor transfers n characters from the external field to the edit descriptor. The first
character appears immediately after the letter H. Any characters in the edit descriptor before input are
replaced by the input characters. If the edit descriptor appears in a FORMAT statement, the replaced
characters are preserved for future uses of that FORMAT statement; otherwise, the replacement is discarded.
On output, the H edit descriptor causes n characters following the letter H to be output to an external record.
Examples
! These WRITE statements both print "Don't misspell 'Hollerith'"
! (The leading blanks are carriage-control characters).
! Hollerith formatting does not require you to embed additional
! single quotation marks as shown in the second example.
!
WRITE (*, 960)
960 FORMAT (27H Don't misspell 'Hollerith')
WRITE (*, 961)
961 FORMAT (' Don''t misspell ''Hollerith''')
See Also
Deleted and Obsolescent Language Features
Format Specifications
See Also
String edit descriptors
Control edit descriptors
Forms for Data Edit Descriptors for details on repeat specifications for data edit descriptors
Interaction Between Format Specifications and I/O Lists for details on group repeat specifications
and format reversion
1017
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The numeric expression can be any valid Fortran expression, including function calls and references to
dummy arguments.
If the expression is not of type integer, it is converted to integer type before being used.
If the value of a variable format expression does not obey the restrictions on magnitude applying to its use in
the format, an error occurs.
Variable format expressions cannot be used with the H edit descriptor, and they are not allowed in character
format specifications that are not character constant expressions.
Variable format expressions are evaluated each time they are encountered in the scan of the format. If the
value of the variable used in the expression changes during the execution of the I/O statement, the new
value is used the next time the format item containing the expression is processed.
Examples
Consider the following statement:
FORMAT (I<J+1>)
When the format is scanned, the preceding statement performs an I (integer) data transfer with a field width
of J+1. The expression is reevaluated each time it is encountered in the normal format scan.
Consider the following statements:
DIMENSION A(5)
DATA A/1.,2.,3.,4.,5./
DO 10 I=1,10
WRITE (6,100) I
100 FORMAT (I<MAX(I,5)>)
10 CONTINUE
DO 20 I=1,5
WRITE (6,101) (A(I), J=1,I)
101 FORMAT (<I>F10.<I-1>)
20 CONTINUE
END
On execution, these statements produce the following output:
1
2
3
4
5
6
7
8
9
10
1.
2.0 2.0
3.00 3.00 3.00
4.000 4.000 4.000 4.000
5.0000 5.0000 5.0000 5.0000 5.0000
1018
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
WRITE(6,20) INT1
20 FORMAT(I<MAX(20,5)>)
See Also
Interaction Between Format Specifications and I/O Lists for details on the synchronization of I/O
lists with formats
ASCII NUL1 Overprinting with no advance Outputs the record (at the
current position in the current
line), but no carriage return.
1 Specify as CHAR( 0 ).
1019
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Any other character is interpreted as a blank and is deleted from the print line. If you do not specify a control
character for printing, the first character of the record is not printed.
Examples
The data in file FOR002.DAT is to be processed 2 records at a time. Each record starts with a number to be
put into an element of a vector B, followed by 5 numbers to be put in a row in matrix A.
FOR002.DAT contains the following data:
1020
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example shows how several different format specifications interact with I/O lists to process
data in file FOR002.DAT:
END
This statement reads B(1); then A(1,1) through A(1,5); then B(2) and A(2,1) through A(2,5).
The first record read (starting with 001) starts the processing of the I/O list.
There are two records, each in the format I3, X, 5(I4, X). The slash (/) forces the reading of the second
record after A(1,5) is processed. It also forces the reading of the third record after A(2,5) is processed; no
data is taken from that record.
B is 1 2 ; A is 101 102 103 104 105 201 202 203 204 205
This statement reads the record starting with 004. The slash (/) forces the reading of the next record
after A(1,5) is processed. The colon (:) stops the reading after A(2,5) is processed, but before the slash (/)
forces another read.
B is 4 5 ; A is 401 402 403 404 405 501 502 503 504 505
1021
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This statement reads the record starting with 006. After A(1,5) is processed, format reversion causes the
next record to be read and starts format processing at the left parenthesis before the I3.
B is 6 7 ; A is 601 602 603 604 605 701 702 703 704 705
This statement reads the record starting with 008. After A(1,5) is processed, format reversion causes the
next record to be read and starts format processing at the left parenthesis before the I4.
B is 8 90 ; A is 801 802 803 804 805 9010 9020 9030 9040 100
The record 009 0901 0902 0903 0904 0905 is processed with I4 as "009 " for B(2), which is 90. X skips the
next "0". Then "901 " is processed for A(2,1), which is 9010, "902 " for A(2,2), "903 " for A(2,3), and "904 "
for A(2,4). The repeat specification of 5 is now exhausted and the format ends. Format reversion causes
another record to be read and starts format processing at the left parenthesis before the I4, so "010 " is read
for A(2,5), which is 100.
See Also
Data edit descriptors
Control edit descriptors
Q edit descriptor
Character string edit descriptors
Scale Factor Editing (P)
1022
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
1023
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
DISPOSE=dis (or 'KEEP', 'SAVE', 'DELETE', Specifies the status of a OPEN, CLOSE
DISP=dis) 'PRINT', 'PRINT/ file after the unit is
DELETE', 'SUBMIT', or closed.
'SUBMIT/DELETE'
(default is 'DELETE' for
scratch files; 'KEEP' for
all other files)
ERR=errlabel Integer between 1 and Specifies the label of an All except PRINT
99999 executable statement
where execution is
transferred after an I/O
error.
1024
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
1025
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
POS=pos Positive integer Specifies the file storage INQUIRE, READ, WRITE
unit position in a stream
file.
REC=rec Positive integer variable Specifies the first (or READ, WRITE
or expression only) record of a file to
be read from, or written
to.
1026
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
I/O Specifiers
See Also
Data transfer I/O statements
I/O Control List for details on control specifiers
1027
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
UNIT control specifier
ERR control specifier
ID control specifier
IOMSG control specifier
IOSTAT control specifier
RECL specifier in OPEN statements
FILE specifier in OPEN statements
DEFAULTFILE specifier in OPEN statements
1028
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1029
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1030
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1031
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1032
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
iof Is a scalar default logical variable that is assigned one of the following
values:
1033
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If unit '*' is specified, the default is .FALSE.; otherwise, the default is .TRUE..
A value of .TRUE. causes a call to FOCUSQQ immediately before any READ, WRITE, or PRINT statement to
that window.
If you use this specifier with a non-Windows application, an error occurs.
nme Is a scalar default character variable that is assigned the name of the
file to which the unit is connected. If the file does not have a name,
nme is undefined.
The value assigned to nme is not necessarily the same as the value
given in the FILE specifier. However, the value that is assigned is
always valid for use with the FILE specifier in an OPEN statement,
unless the value has been truncated in a way that makes it
unacceptable. (Values are truncated if the declaration of nme is too
small to contain the entire value.)
NOTE
The FILE and NAME specifiers are synonyms when used with the OPEN statement, but not when used
with the INQUIRE statement.
See Also
The appropriate manual in your operating system documentation set for details on the maximum size of file
pathnames
nmd Is a scalar default logical variable that is assigned one of the following
values:
1034
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1035
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pnd Is a scalar default logical variable that is assigned the value .TRUE.
or .FALSE..
See Also
ID Specifier
1036
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the file is positioned at its terminal position, p is assigned a value one greater than the number of the
highest-numbered file storage unit in the file.
If the file is not connected for stream access or if the position of the file is indeterminate because of previous
error conditions, p is assigned the value one.
If there are pending asynchronous data operations for the specified file, the value assigned to the POS=
specifier is computed as if all pending data transfers have already completed.
1037
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The assigned value is expressed in 4-byte units if the file is currently (or was previously) connected for
unformatted data transfer and the assume byterecl compiler option is not in effect; otherwise, the value is
expressed in bytes.
1038
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The rounding modes conform to the corresponding rounding modes specified in the ISO/IEC/IEEE
60559:2011 standard.
1039
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1040
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SIGN = sn
For a file that is connected for stream access, the file size is the number of the highest-numbered file storage
unit in the file.
For a file that is connected for sequential or direct access, the file size may be different from the number of
storage units implied by the data in the records; the exact relationship is processor-dependent.
If there are pending asynchronous data transfer operations for the specified file, the value assigned to the
SIZE= specifier is computed as if the pending data transfers have already completed.
1041
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1042
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FILE (or NAME) A scalar default File pathname (file fort.n, where n is the
character expression name) unit number.
1043
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
'BINARY'
1044
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INQUIRE Statement for details on using the INQUIRE statement to get file attributes of existing
files
1045
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fpscomp compiler option
Direct access READs, direct access WRITEs, and the FIND, DELETE, and REWRITE statements can affect the
value of asv.
This specifier is valid only for direct access; it is ignored for other access modes.
1046
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default is 'NULL' (for explicitly OPENed files, preconnected files, and internal files). If you specify
compiler option f66 (or OPTIONS/NOF77), the default is 'ZERO'.
If the BN or BZ edit descriptors are specified for a formatted input statement, they supersede the default
interpretation of blanks.
This specifier is not allowed on unformatted input or output.
See Also
Blank Editing for details on the BN and BZ edit descriptors
f66
If you specify a nonzero number for bks, it is rounded up to a multiple of 512 byte blocks. The maximum
valid value of BLOCKSIZE is 2147467264.
If you do not specify BLOCKSIZE or you specify zero for bks, the default value of 128 KB (131,072 bytes) is
assumed. However, if you compile with the assume buffered_stdout option, the default blocksize for
stdout is 8 KB.
1047
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default BLOCKSIZE value can be changed by using the FORT_BLOCKSIZE environment variable or by
specifying the BLOCKSIZE parameter on the unit's OPEN. The BLOCKSIZE value can be changed for stdout
by re-opening the unit corresponding to stdout with an explicit BLOCKSIZE parameter; for example:
OPEN(6,ACCESS='SEQUENTIAL',FORM='FORMATTED',BUFFERED='YES',BLOCKSIZE=1048576
The BLOCKSIZE specifier determines the size of each buffer. For example, if BUFFERCOUNT=3 and
BLOCKSIZE=2048, the total number of bytes allocated for buffers is 3*2048, or 6144 bytes.
If you do not specify BUFFERCOUNT or you specify zero for bc, the default is 1.
See Also
BLOCKSIZE specifier
The default is 'NO' for buffering output. The default is also 'NO' when reading variable length, unformatted
records whose length exceeds that of the block size specified for the file.
If BUFFERED='YES' is specified, the request may or may not be honored, depending on the device and other
file or connection characteristics.
1048
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For direct access, you should specify BUFFERED='YES', although using direct-access I/O to a network file
system may be much slower.
If both BLOCKSIZE and BUFFERCOUNT for OPEN have been specified with positive values, their product
determines the size in bytes of the buffer for that I/O unit. Otherwise, the default size of the internal buffer is
8 KB (8192 bytes).
NOTE
On Windows systems, the default size of the internal buffer is 1024 bytes if compiler option fpscomp
general is used.
The internal buffer will grow to hold the largest single record but will never shrink.
See Also
Rules for Unformatted Sequential READ Statements
The default for binary (W*S) and unformatted files is 'NONE'. The default for formatted files is 'LIST'.
However, if you specify compiler option vms or fpscomp general, and the unit is connected to a terminal, the
default is 'FORTRAN'.
On output, if a file was opened with CARRIAGECONTROL='FORTRAN' in effect or the file was processed by
the fortpr format utility, the first character of a record transmitted to a line printer or terminal is typically a
character that is not printed, but is used to control vertical spacing.
See Also
Printing of Formatted Records for details on valid control characters for printing
vms compiler option
fpscomp compiler option
1049
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can use CONVERT to specify multiple formats in a single program, usually one format for each specified
unit number.
1050
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When reading a nonnative format, the nonnative format on disk is converted to native format in memory. If a
converted nonnative value is outside the range of the native data type, a run-time message appears.
There are other ways to specify numeric format for unformatted files: you can specify an environment
variable, compiler option convert, or OPTIONS/CONVERT. The following shows the order of precedence:
OPEN (CONVERT=) .
OPTIONS/CONVERT .
Compiler option convert and OPTIONS/CONVERT affect all unit numbers used by the program, while
environment variables and OPEN (CONVERT=) affect specific unit numbers.
The following example shows how to code the OPEN statement to read unformatted CRAY* numeric data
from unit 15, which might be processed and possibly written in native little endian format to unit 20:
OPEN (CONVERT='CRAY', FILE='graph3.dat', FORM='UNFORMATTED',
1 UNIT=15)
...
OPEN (FILE='graph3_native.dat', FORM='UNFORMATTED', UNIT=20)
See Also
Data Types, Constants, and Variables for details on supported ranges for data types
convert compiler option
1051
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DEFAULTFILE supplies a value to the Fortran I/O system that is prefixed to the name that appears in FILE.
If def does not end in a slash (/), a slash is added.
If DEFAULTFILE is omitted, the Fortran I/O system uses the current working directory.
1052
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default is 'DELETE' for scratch files. For all other files, the default is 'KEEP'.
On Windows*, PRINT and the PRINT part of PRINT/DELETE do not use the system PRINT command. One of
the following occurs:
• If you set the environment variable FOR_DEFAULT_PRINT_DEVICE to a print device, the Fortran run-time
will copy the file to that device.
• Otherwise, the Fortran run-time will copy the file to a new file named "PRN-FILE". In this case, you will
need to do the actual printing
1053
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fpscomp compiler option
1054
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default is 'FORMATTED' for sequential access files, and 'UNFORMATTED' for direct access files.
The data is stored and retrieved in a file according to the file's access (set by the ACCESS specifier) and the
form of the data the file contains.
A formatted file is a sequence of formatted records. Formatted records are a series of ASCII characters
terminated by an end-of-record mark (a carriage return and line feed sequence). The records in a formatted
direct-access file must all be the same length. The records in a formatted sequential file can have varying
lengths. All internal files must be formatted.
An unformatted file is a sequence of unformatted records. An unformatted record is a sequence of values.
Unformatted direct files contain only this data, and each record is padded to a fixed length with undefined
bytes. Unformatted sequential files contain the data plus information that indicates the boundaries of each
record.
Binary sequential files are sequences of bytes with no internal structure. There are no records. The file
contains only the information specified as I/O list items in WRITE statements referring to the file.
Binary direct files have very little structure. A record length is assigned by the RECL specifier in an OPEN
statement. This establishes record boundaries, which are used only for repositioning and padding before and
after read and write operations and during BACKSPACE operations. Record boundaries do not restrict the
number of bytes that can be transferred during a read or write operation. If an I/O operation attempts to
read or write more values than are contained in a record, the read or write operation is continued on the next
record.
Fortran standard stream access provides similar functionality to FORM='BINARY'. This is specified using
ACCESS='STREAM'.
See Also
Record Access
If unit '*' is specified, the default is .FALSE.; otherwise, the default is .TRUE..
A value of .TRUE. causes a call to FOCUSQQ immediately before any READ, WRITE, or PRINT statement to
that window. OUTTEXT, OUTGTEXT, or any other graphics routine call does not cause the focus to shift.
1055
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MAXREC = mr
If the OPEN is successful, u-var can be used in subsequent I/O statements to access the connected file.
If an error occurs during execution of the OPEN statement containing the NEWUNIT= speciifier, the processor
does not change the value of the variable.
1056
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1057
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
READONLY
READONLY is similar to specifying ACTION='READ', but READONLY prevents deletion of the file if it is closed
with STATUS='DELETE' in effect.
The Fortran I/O system's default privileges for file access are READWRITE. If access is denied, the I/O
system automatically retries accessing the file for READ access.
However, if you use compiler option vms, the I/O system does not retry accessing for READ access. So, run-
time I/O errors can occur if the file protection does not permit WRITE access. To prevent such errors, if you
wish to read a file for which you do not have write access, specify READONLY.
If the file is connected for formatted data transfer, the value must be expressed in bytes (characters).
Otherwise, the value is expressed in 4-byte units (longwords). If the file is connected for unformatted data
transfer, the value can be expressed in bytes if compiler option assume byterecl is specified.
Except for segmented records, the rl is the length for record data only, it does not include space for control
information. If rl is too large, you can exhaust your program's virtual memory resources trying to create
room for the record.
The length specified is interpreted depending on the type of records in the connected file, as follows:
• For segmented records, RECL indicates the maximum length for any segment (including the four bytes of
control information).
• For fixed-length records, RECL indicates the size of each record; it must be specified. If the records are
unformatted, the size must be expressed as an even multiple of four.
You can use the RECL specifier in an INQUIRE statement to get the record length before opening the file.
• For variable-length records, RECL indicates the maximum length for any record.
If you read a fixed-length file with a record length different from the one used to create the file,
indeterminate results can occur.
The maximum length for rl depends on the record type and the setting of the CARRIAGECONTROL specifier,
as shown in the following table:
1058
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default value depends on the setting of the RECORDTYPE specifier, as shown in the following table:
Default Record Lengths (RECL)
RECORDTYPE RECL value
All other settings 132 bytes for formatted records; 510 longwords for
unformatted records.1
1Tochange the default record length values, you can use environment variable FORT_FMT_RECL or
FORT_UFMT_RECL.
For formatted records with other than RECORDTYPE='FIXED', the default RECL is 132.
There is a property of list-directed sequential WRITE statements called the right margin. If you do not
specify RECL as an OPEN statement specifier or in environmental variable FORT_FMT_RECL, the right margin
value defaults to 80. When RECL is specified, the right margin is set to the value of RECL. If the length of a
list-directed sequential WRITE exceeds the value of the right margin value, the remaining characters will
wrap to the next line. Therefore, writing 100 characters will produce two lines of output, and writing 180
characters will produce three lines of output. You can turn off the right margin using the wrap-margin
compiler option or the FORT_FMT_NO_WRAP_MARGIN environment variable.
See Also
assume:byterecl compiler option
vms compiler option
Record Transfer
1059
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A segmented record is a logical record consisting of segments that are physical records. Since the length of a
segmented record can be greater than 65,535 bytes, only use segmented records for unformatted sequential
access to disk or raw magnetic tape files.
Files containing segmented records can be accessed only by unformatted sequential data transfer
statements.
If an output statement does not specify a full record for a file containing fixed-length records, the following
occurs:
• In formatted files, the record is filled with blanks
• In unformatted files, the record is filled with zeros
1060
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default I/O rounding mode is 'PROCESSOR_DEFINED'. For ifort, this corresponds to 'NEAREST'.
The rounding modes conform to the corresponding rounding modes specified in the ISO/IEC/IEEE
60559:2011 standard.
You can only use this specifier for a formatted I/O connection.
The rounding mode can be temporarily changed within a READ or WRITE statement by the corresponding RU,
RD, RZ, RN, RC, and RP edit descriptors.
This specifier is not allowed on unformatted input or output.
On Windows systems, the default is 'DENYWR'. However, if you specify compiler option fpscomp general or
the SHARED specifier, the default is 'DENYNONE'.
On Linux and macOS systems, no restrictions are applied to file opening if you do not use a locking
mechanism.
1061
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
fpscomp compiler option
See Also
fpscomp compiler option
1062
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Scratch files go into a temporary directory and are visible while they are open. Scratch files are deleted when
the unit is closed or when the program terminates normally, whichever occurs first.
To specify the path for scratch files, you can use one of the following environment variables:
• On Windows*: FORT_TMPDIR, TMP, or TEMP, searched in that order
• On Linux* and macOS: FORT_TMPDIR or TMPDIR, searched in that order
If no environment variable is defined, the default is the current directory.
The default is 'UNKNOWN'. This is also the default if you implicitly open a file by using WRITE. However, if
you implicitly open a file using READ, the default is 'OLD'. If you specify compiler option f66 (or OPTIONS/
NOF77), the default is 'NEW'.
NOTE
The STATUS specifier can also appear in CLOSE statements to indicate the file's status after it is
closed. However, in CLOSE statements the STATUS values are the same as those listed for the
DISPOSE specifier.
1063
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
f66 compiler option
If the function is written in Fortran, do not execute a Fortran OPEN statement to open the file named in
USEROPEN.
The Intel® Fortran Run-time Library (RTL) I/O support routines call the function named in USEROPEN in place
of the system calls normally used when the file is first opened for I/O.
On Windows* systems, the Fortran RTL normally calls CreateFile( ) to open a file. When USEROPEN is
specified, the called function opens the file (or pipe, etc.) by using CreateFile( ) and returns the handle of
the file (return value from CreateFile( )) when it returns control to the calling Fortran program.
On Linux* and macOS systems, the Fortran RTL normally calls the open function to open a file. When
USEROPEN is specified, the called function opens the file by calling open and returns the file descriptor of the
file when it returns control to the calling Fortran program.
When opening the file, the called function usually specifies options different from those provided by a normal
Fortran OPEN statement.
NOTE
You may get unexpected results if you specify OPEN with a filename and a USEROPEN specifier that
opens a different filename, and then use a CLOSE statement with STATUS=DELETE (or
DISPOSE=DELETE). In this case, the run-time library assumes you want to delete the file named in
the OPEN statement, not the one you specified in the USEROPEN function.
For more information about how to use the USEROPEN specifier, see User-Supplied OPEN Procedures/
USEROPEN Specifier.
1064
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following prefix forms can be used in place of !DIR$: cDIR$, cDEC$, or !MS$, where c is one of the
following: C (or c), !, or *.
The following prefix forms can be used in place of !$OMP: c$OMP, where c is one of the following: C (or c), !,
or *.
The following are source form rules for directive prefixes:
• In fixed and tab source forms, prefixes begin with !, C (or c), or *.
The prefix must appear in columns 1 through 5; column 6 must be a blank or a tab (except for prefix !MS
$). From column 7 on, blanks are insignificant, so the directive can be positioned anywhere on the line
after column 6.
• In free source form, prefixes begin with !.
The prefix can appear in any column, but it cannot be preceded by any nonblank, nontab characters on
the same line.
• In all source forms, directives spelled with two keywords can be separated by an optional space; for
example, "LOOP COUNT" and "LOOPCOUNT" are both valid spellings for the same directive. However,
when a directive name is preceded by the prefix "NO", this is not considered to be two keywords. For
example, "NO DECLARE" is not a valid spelling; the only valid spelling for this directive is "NODECLARE".
A compiler directive ends in column 72 (or column 132, if compiler option extend-source is specified).
General compiler directives and OpenMP Fortran directives can be continued in the same way as Fortran
statements can be continued:
• In fixed form, the first line of the directive {initial line} has the directive prefix is in columns 1 through 5
and has a blank, a tab, or a zero in column 6; each continued line of the directive has the directive prefix
in columns 1 through 5 and has a character other than a blank, a tab, or a zero in column 6.
• In free form, the initial line of the directive ends with an ampersand followed by an optional comment
beginning with an exclamation point. Each continued line of the directive has the directive prefix
optionally preceded by blanks or tabs, followed by an ampersand optionally preceded by blanks or tabs.
1065
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A comment beginning with an ! can follow a compiler directive on the same line.
Additional Fortran statements (or directives) cannot appear on the same line as the compiler directive.
Compiler directives cannot appear within a continued Fortran statement.
Blank common used in a compiler directive is specified by two slashes (/ /).
If the source line starts with a valid directive prefix but the directive is not recognized, the compiler displays
an informational message and ignores the line.
1066
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• IVDEP
Assists the compiler's dependence analysis of iterative DO loops.
• LOOP COUNT
Specifies the typical trip count for a DO loop; this assists the optimizer.
• MESSAGE
Specifies a character string to be sent to the standard output device during the first compiler pass.
• NOFUSION
Prevents a loop from fusing with adjacent loops.
• OBJCOMMENT
Specifies a library search path in an object file.
• OPTIMIZE and NOOPTIMIZE
Enables or disables optimizations for the program unit.
• OPTIONS
Affects data alignment and warnings about data alignment.
• PACK
Specifies the memory alignment of derived-type items.
• PARALLEL and NOPARALLEL
Facilitates or prevents auto-parallelization by assisting the compiler's dependence analysis of the
immediately following DO loop. This feature is only available for ifort.
• PREFETCH and NOPREFETCH
Enables or disables hint to the compiler to prefetch data from memory.
• PSECT
Modifies certain characteristics of a common block.
• REAL
Specifies the default real kind.
• SIMD
Requires and controls SIMD vectorization of loops. This feature is only available for ifort.
• STRICT and NOSTRICT
Disables or enables language features not found in the language standard specified on the command line.
• UNROLL and NOUNROLL
Tells the compiler's optimizer how many times to unroll a DO loop or disables the unrolling of a DO loop.
• UNROLL_AND_JAM and NOUNROLL_AND_JAM
Enables or disables loop unrolling and jamming.
• VECTOR and NOVECTOR
Overrides default heuristics for vectorization of DO loops.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
See Also
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
1067
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Some directives can appear only at the beginning of a scope and affect the rest of that scope.
• Some directives affect the statements starting at that point in the source and continue until changed by
another directive or until the end of the scope containing the directive.
The scope can be a contained procedure or a program unit. A program unit is a main program, an external
subroutine or function, a module, or a block data program unit. A directive does not affect modules invoked
with the USE statement in the program unit that contains it, but it does affect INCLUDE statements that
follow the directive.
Certain directives may appear before program units or between program units in a source file. These
directives affect only the next program unit that lexically follows the directive. The effect of the directive
ceases at the end of the affected program unit. For example:
!dir$ integer:2
program m
integer k
print *, kind(k), kind(42) ! this prints 2, 2 which means the directive took effect
call sub()
end
subroutine sub()
integer kk
print *, kind(kk), kind(-42) ! this prints 4, 4 because the INTEGER:2 directive has no effect
here
end
The following directives have this behavior:
• ALIAS
• ATTRIBUTES
• DECLARE and NODECLARE
• DEFINE and UNDEFINE
• FIXEDFORMLINESIZE
• FREEFORM and NOFREEFORM
• IDENT
• INTEGER
• OPTIMIZE and NOOPTIMIZE
• PACK
• PREFETCH
• PSECT
• REAL
• STRICT and NOSTRICT
Other rules may apply to these directives. For more information, see the description of each directive.
LOOP COUNT
1068
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOFUSION
NOUNROLL_AND_JAM
See Also
Rules for Loop Directives that Affect Array Assignment Statements
FORCEINLINE SIMD
IVDEP UNROLL_AND_JAM
NOFUSION
NOUNROLL_AND_JAM
Usually only one of the general directives can precede the array assignment statement (one-dimensional-
array = expression) to affect it. The BLOCK_LOOP and NOBLOCK_LOOP directives may precede array
assignment statements with any rank variable on the left-hand-side of the assignment.
Other rules may apply to the general directives. For more information, see the description of each directive.
Examples
Consider the following:
1069
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This has the same effect as writing the following explicit loop:
!DIR$ IVDEP
DO I = 1, 10
A (I) = B (I) + 3
END DO
See Also
Rules for General Directives that Affect DO Loops
1070
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1071
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1072
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• SIMD construct
Requires and controls SIMD vectorization of loops.
• SINGLE construct
Specifies a block of code to be executed by only one thread in a team at a time.
• TARGET construct
Creates a device data environment and executes the construct on the same device. This feature is only
available for ifx.
• TARGET DATA construct
Creates a device data environment for the extent of the region. This feature is only available for ifx.
• TARGET ENTER DATA
Specifies that variables are mapped to a device data environment. This feature is only available for ifx.
• TARGET EXIT DATA
Specifies that variables are unmapped from a device data environment. This feature is only available for
ifx.
• TARGET PARALLEL construct
Creates a device data environment in a parallel region and executes the construct on that device.
• TARGET PARALLEL DO construct
Provides an abbreviated way to specify a TARGET directive containing a PARALLEL DO directive and no
other statements.
• TARGET PARALLEL DO SIMD construct
Specifies a TARGET construct that contains a PARALLEL DO SIMD construct and no other statement.
• TARGET PARALLEL LOOP construct
Specifies a shortcut for specifying a parallel loop inside a TARGET construct that contains no other
statements than the parallel loop. This feature is only available for ifx.
• TARGET SIMD construct
Specifies a TARGET construct that contains a SIMD construct and no other statement.
• TARGET TEAMS construct
Creates a device data environment and executes the construct on the same device. It also creates a
league of thread teams with the primary thread in each team executing the structured block.
• TARGET TEAMS DISTRIBUTE construct
Creates a device data environment and executes the construct on the same device. It also specifies that
loop iterations will be shared among the primary threads of all thread teams in a league created by a
TEAMS construct.
• TARGET TEAMS DISTRIBUTE PARALLEL DO construct
Creates a device data environment and then executes the construct on that device. It also specifies a loop
that can be executed in parallel by multiple threads that are members of multiple teams created by a
TEAMS construct.
• TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD construct
Creates a device data environment and then executes the construct on that device. It also specifies a loop
that can be executed in parallel by multiple threads that are members of multiple teams created by a
TEAMS construct. The loop will be distributed across the teams, which will be executed concurrently using
SIMD instructions.
• TARGET TEAMS DISTRIBUTE SIMD construct
Creates a device data environment and executes the construct on the same device. It also specifies that
loop iterations will be shared among the master threads of all thread teams in a league created by a
teams construct. It will be executed concurrently using SIMD instructions.
• TARGET TEAMS LOOP construct
Specifies a shortcut for specifying a TEAMS LOOP construct inside a TEAMS construct that contains no
other statements. This feature is only available for ifx.
• TARGET UPDATE directive
1073
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Makes the list items in the device data environment consistent with their corresponding original list items.
This feature is only available for ifx.
• TARGET VARIANT DISPATCH directive
Conditionally calls a procedure offload variant if the device is free; otherwise, executes the procedure on
the host. This feature is only available for ifx.
• TASK construct
Defines a task region.
• TASKGROUP construct
Specifies a wait for the completion of all child tasks of the current task and all of their descendant tasks.
• TASKLOOP construct
Specifies that the iterations of one or more associated DO loops should be executed in parallel using
OpenMP* tasks. The iterations are distributed across tasks that are created by the construct and
scheduled to be executed.
• TASKLOOP SIMD construct
Specifies a loop that can be executed concurrently using SIMD instructions and that those iterations will
also be executed in parallel using OpenMP* tasks.
• TASKWAIT directive
Specifies a wait on the completion of child tasks generated since the beginning of the current task.
• TASKYIELD directive
Specifies that the current task can be suspended at this point in favor of execution of a different task.
• TEAMS construct
Creates a group of thread teams to be used in a parallel region. This feature is only available for ifx.
• TEAMS DISTRIBUTE construct
Creates a league of thread teams to execute a structured block in the primary thread of each team. It also
specifies that loop iterations will be shared among the primary threads of all thread teams in a league
created by a TEAMS construct.
• TEAMS DISTRIBUTE PARALLEL DO construct
Creates a league of thread teams to execute a structured block in the primary thread of each team. It also
specifies a loop that can be executed in parallel by multiple threads that are members of multiple teams.
• TEAMS DISTRIBUTE PARALLEL DO SIMD construct
Creates a league of thread teams to execute a structured block in the primary thread of each team. It also
specifies a loop that can be executed in parallel by multiple threads that are members of multiple teams.
The loop will be distributed across the primary threads of the teams region, which will be executed
concurrently using SIMD instructions.
• TEAMS DISTRIBUTE SIMD construct
Creates a league of thread teams to execute the structured block in the primary thread of each team. It
also specifies a loop that will be distributed across the primary threads of the teams region. The loop will
be executed concurrently using SIMD instructions.
• TEAMS LOOP construct
Specifies a shortcut for specifying a LOOP construct inside a TEAMS construct. This feature is only
available for ifx.
• THREADPRIVATE directive
Makes named common blocks private to each thread, but global within the thread.
• UNROLL
Partially or fully unrolls a DO loop. This feature is only available for ifx.
• WORKSHARE construct
Divides the work of executing a block of statements or constructs into separate units.
The OpenMP parallel directives can be grouped into the categories. For more information about the
categories for these directives, see OpenMP* Directives Summary.
1074
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
See Also
Syntax Rules for Compiler Directives
qopenmp, Qopenmp compiler option
Clauses Used in Multiple OpenMP* Fortran Directives
The OpenMP web site
The data copying clauses let you copy data values from private or threadprivate variables in one implicit task
or thread to the corresponding variables in other implicit tasks or threads in the team.
1075
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The data motion clause MAP is used in OpenMP* Fortran TARGET directives. This data motion clause does not
modify the values of any of the internal control variables (ICVs).
List items that appear in this data motion clause may have corresponding new list items created in the device
data environment that is associated with the construct. If a new list item is created, a new list item of the
same type, kind, and rank is allocated. The initial value of the new list item is undefined.
The original list items and new list items may share storage. This means that data races can occur. Data
races are caused by unintended sharing of data; for example, when WRITEs to either item by one task or
device are followed by a READ of the other item by another task or device without intervening
synchronization.
Data Allocation and Data Mapping Clauses
Name Description
The following are other clauses that can be used in more than one OpenMP* Fortran directive.
Miscellaneous Clauses
Name Description
1076
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
c23456789
!$ IAM = OMP_GET_THREAD_NUM( ) +
!$ * INDEX
#IFDEF _OPENMP
IAM = OMP_GET_THREAD_NUM( ) +
* INDEX
#ENDIF
1077
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Binding Rules
The following rules apply to dynamic binding:
• The DO, SECTIONS, SINGLE, MASKED, MASTER, and BARRIER directives bind to the dynamically
enclosing PARALLEL directive, if one exists.
• The ORDERED directive binds to the dynamically enclosing DO directive.
• The ATOMIC directive enforces exclusive access with respect to ATOMIC directives in all threads, not just
the current team.
• The CRITICAL directive enforces exclusive access with respect to CRITICAL directives in all threads, not
just the current team.
• A directive can never bind to any directive outside the closest enclosing PARALLEL directive.
Nesting Rules
The following rules apply to dynamic nesting:
• A PARALLEL directive dynamically inside another PARALLEL directive logically establishes a new team,
which is composed of only the current thread unless nested parallelism is enabled.
• DO, SECTIONS, and SINGLE directives that bind to the same PARALLEL directive are not allowed to be
nested one inside the other.
• DO, SECTIONS, and SINGLE directives are not permitted in the dynamic extent of CRITICAL, MASKED,
and MASTER directives.
• BARRIER directives are not permitted in the dynamic extent of DO, SECTIONS, SINGLE, MASKED,
MASTER, and CRITICAL directives.
• MASKED and MASTER directives are not permitted in the dynamic extent of DO, SECTIONS, and SINGLE
directives.
• ORDERED sections are not allowed in the dynamic extent of CRITICAL sections.
• Any directive set that is legal when executed dynamically inside a PARALLEL region is also legal when
executed outside a parallel region. When executed dynamically outside a user-specified parallel region,
the directive is executed with respect to a team composed of only the primary thread.
Examples
The following example shows nested PARALLEL regions:
1078
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1079
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/real-size:size (Windows)
Scope
Program entities have the following kinds of scope (as shown in the table below):
• Global
Entities that are accessible throughout an executable program. The name of a global entity must be
unique. It cannot be used to identify any other global entity in the same executable program.
• Scoping unit (Local scope)
Entities that are declared within a scoping unit. These entities are local to that scoping unit. The names of
local entities are divided into classes (see the table below).
A scoping unit is one of the following:
• A derived-type definition
• A procedure interface body (excluding any derived-type definitions and interface bodies contained
within it)
• A program unit or subprogram (excluding any derived-type definitions, interface bodies, and
subprograms contained within it)
A scoping unit that immediately surrounds another scoping unit is called the host scoping unit. Named
entities within the host scoping unit are accessible to the nested scoping unit by host association, unless
access is blocked by an IMPORT ONLY or IMPORT NONE statement. For information about host association,
see Use and Host Association.
Once an entity is declared in a scoping unit, its name can be used throughout that scoping unit. An entity
declared in another scoping unit is a different entity even if it has the same name and properties.
Within a scoping unit, a local entity name that is not generic or an OpenMP* reduction identifier must be
unique within its class. However, the name of a local entity in one class can be used to identify a local
entity of another class.
1080
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Within a scoping unit, a generic name can be the same as any one of the procedure names in the
interface block. A generic name can be the same as the name of a derived type.
An OpenMP* reduction identifier can be the same as any local entity name.
A component name has the same scope as the derived type of which it is a component. It can appear only
within a component designator of a structure of that type.
For information on interactions between local and global names, see the table below.
• Statement
Entities that are accessible only within a statement or part of a statement; such entities cannot be
referenced in subsequent statements.
The name of a statement entity can also be the name of a common block, or a local or construct variable
accessible in the same scoping unit or construct; in this case, the name is interpreted within the
statement as that of the statement entity.
• Construct
Construct entities are accessible during the execution of the construct in which they are declared. Entities
declared in the specification part of a BLOCK construct, associate names in ASSOCIATE, SELECT RANK,
and SELECT TYPE constructs, and index variables in FORALL statements or constructs, or DO
CONCURRENT constructs are construct entities. An index name of an inner FORALL statement or
construct, or of a DO CONCURRENT construct cannot be the same as that of an index variable of an outer
(containing) FORALL or DO CONCURRENT construct.
An associate name of a SELECT TYPE construct has a different scope for each block of the construct; the
declared type, dynamic type, type parameters, rank or bounds may differ from block to block. An
associate name for a SELECT RANK construct has a different scope for each block of the construct since
the rank of the associate name is different in each block. An associate name for an ASSOCIATE construct
has the scope of the ASSOCIATE construct.
Scope of Program Entities
Entity Scope
1081
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Entity Scope
Generic Assignment).
Scoping units can contain other scoping units. For example, the following shows six scoping units:
MODULE MOD_1 ! Scoping unit 1
... ! Scoping unit 1
CONTAINS ! Scoping unit 1
FUNCTION FIRST ! Scoping unit 2
TYPE NAME ! Scoping unit 3
... ! Scoping unit 3
END TYPE NAME ! Scoping unit 3
... ! Scoping unit 2
CONTAINS ! Scoping unit 2
SUBROUTINE SUB_B ! Scoping unit 4
TYPE PROCESS ! Scoping unit 5
... ! Scoping unit 5
END TYPE PROCESS ! Scoping unit 5
INTERFACE ! Scoping unit 5
SUBROUTINE SUB_A ! Scoping unit 6
... ! Scoping unit 6
BLOCK ! Scoping unit 7
... ! Scoping unit 7
END BLOCK ! Scoping unit 7
END SUBROUTINE SUB_A ! Scoping unit 6
END INTERFACE ! Scoping unit 5
1082
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Derived data types
Defining Generic Names for Procedures
Intrinsic procedures
Program Units and Procedures
Use and host association
Construct association
BLOCK construct
Defining Generic Operators
Defining Generic Assignment
PRIVATE Attributes and Statements
PUBLIC Attributes and Statements
IMPORT statement
See Also
Defining Generic Names for Procedures for details on generic procedure names
1083
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows how a module can define three separate procedures and give them a generic
name DUP through an interface block. Although the main program calls all three by the generic name, there
is no ambiguity since the arguments are of different data types, and DUP is a function rather than a
subroutine. The module UN_MOD must give each procedure a different name.
MODULE UN_MOD
!
CONTAINS
subroutine dup1(x,y)
real x,y
print *, ' Real arguments', x, y
end subroutine dup1
subroutine dup2(m,n)
integer m,n
print *, ' Integer arguments', m, n
end subroutine dup2
1084
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END MODULE
program unclear
!
! shows how to use generic procedure references
USE UN_MOD
INTERFACE DUP
MODULE PROCEDURE dup1, dup2, dup3
END INTERFACE
real a,b
integer c,d
character (len=2) state
a = 1.5
b = 2.32
c = 5
d = 47
state = 'WA'
call dup(a,b)
call dup(c,d)
print *, dup(state) !actual output is 'S' only
END
Note that the function DUP3 only prints one character, since module UN_MOD specifies no length parameter
for the function result.
If the dummy arguments x and y for DUP were declared as integers instead of reals, then any calls to DUP
would be ambiguous. If this is the case, a compile-time error results.
The subroutine definitions, DUP1, DUP2, and DUP3, must have different names. The generic name is
specified in the first line of the interface block, and in the example is DUP.
1085
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
b. The procedure name has been declared EXTERNAL, and the procedure name is a dummy
argument of that subprogram.
The procedure invoked by the reference is the one supplied as the corresponding actual argument.
2. If the scoping unit contains an interface body or the procedure name has been declared EXTERNAL, and
Rule 1 does not apply, the reference is to an external procedure with that name.
3. If the scoping unit contains an internal procedure or statement function with that procedure name, the
reference is to that entity.
4. If the procedure name has been declared INTRINSIC in the scoping unit, the reference is to the intrinsic
procedure with that name.
5. If the scoping unit contains a USE statement that makes the name of a module procedure accessible,
the reference is to that procedure. Sinec the USE statement allows renaming, the name referenced may
differ from the name of the module procedure.)
6. If none of the preceding rules apply, the reference is resolved by applying these rules to the host
scoping unit.
See Also
Function references
USE statement
CALL Statement for details on subroutine references
Defining Generic Names for Procedures for details on generic procedure names
Association
Association allows different program units to access the same value through different names. Entities are
associated when each is associated with the same storage location.
Association can occur in the following ways:
• Name association
• Pointer association
• Storage association
• Inheritance association
The following example shows name, pointer, and storage association between an external program unit and
an external procedure.
1086
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL A, B(4)
REAL, POINTER :: M(:)
REAL, TARGET :: N(12)
COMMON /COM/...
EQUIVALENCE (A, B(1)) ! Storage association between A and B(1)
M => N ! Pointer association
CALL P (actual-arg,...)
...
REAL Y
CALL Q (actual-arg,...)
CONTAINS
SUBROUTINE Q (dummy-arg,...) ! Name and storage association
between
! these arguments and the calling
! routine's arguments in host procedure
! P (subprogram Q has host association
! with procedure P)
Y = 2.0*(Y-1.0) ! Name association with Y in host procedure P
...
The following example shows inheritance association:
Name Association
Name association allows an entity to be accessed from different scoping units by the same name or by
different names.
Name association can occur in the following ways:
• By argument association
• By use association
• By host association
• By linkage association
• By construct association
Argument Association
Arguments are the values passed to and from functions and subroutines through calling program argument
lists.
1087
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Execution of a procedure reference establishes argument association between an actual argument and its
corresponding dummy argument. The name of a dummy argument can be different from the name of its
associated actual argument (if any).
When the procedure completes execution, the argument association is terminated. A dummy argument of
that procedure can be associated with an entirely different actual argument in a subsequent invocation of the
procedure.
1088
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the dummy argument does not have the TARGET or POINTER attribute, any pointers associated with the
actual argument do not become associated with the corresponding dummy argument on invocation of the
procedure.
If the dummy argument has the TARGET attribute, does not have the VALUE attribute, is either a scalar or an
assumed-shape array, and the corresponding actual argument has the TARGET attribute but is not an array
section with a vector subscript, then the following is true:
• Any pointers associated with the actual argument become associated with the corresponding dummy
argument on invocation of the procedure.
• When execution of the procedure completes, any pointers that do not become undefined and are
associated with the dummy argument remain associated with the actual argument.
Any pointers associated with the dummy argument become undefined when execution of the procedure
completes in these cases:
• If the dummy argument has the TARGET attribute and the corresponding actual argument does not have
the TARGET attribute, or is an array section with a vector subscript.
• If the dummy argument has the TARGET attribute and the VALUE attribute.
If a nonpointer dummy argument has INTENT (OUT) or INTENT (INOUT), the actual argument must be
definable. If a dummy argument has INTENT (OUT), the corresponding actual argument becomes undefined
at the time the association is established, except for components of an object of derived type for which
default initialization has been specified. If the dummy argument is not polymorphic and the type of the actual
argument is an extension of the type of the dummy argument, only the part of the actual argument that is of
the same type as the dummy argument becomes undefined.
1089
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An assumed-rank dummy argument can correspond to an actual argument of any rank. If the actual
argument has rank zero (is a scalar), the dummy argument has rank zero; the shape is a zero-sized array
and the LBOUND and UBOUND intrinsic functions, with no DIM argument, return zero-sized arrays. If the
actual argument has rank greater than zero, the rank and extents of the dummy argument are assumed
from the actual argument, including the lack of a final extent in the case of an assumed-size array. If the
actual argument is an array and the dummy argument is allocatable or a pointer, the bounds of the dummy
argument are assumed from the actual argument.
An assumed-type dummy argument must not correspond to an actual argument that is of a derived type that
has type parameters, type-bound procedures, or final subroutines.
See Also
Argument Association in Procedures
Procedure Characteristics
Examples
The following example shows host and use association:
MODULE SHARE_DATA
REAL Y, Z
END MODULE
PROGRAM DEMO
USE SHARE_DATA ! All entities in SHARE_DATA are available
REAL B, Q ! through use association.
...
CALL CONS (Y)
CONTAINS
SUBROUTINE CONS (Y) ! Y is a local entity (dummy argument).
REAL C, Y
...
Y = B + C + Q + Z ! B and Q are available through host association.
... ! C is a local entity, explicitly declared.
END SUBROUTINE CONS ! is available through use association.
END PROGRAM DEMO
See Also
Use Association
Host Association
1090
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Use Association
Use association allows the entities in a module to be accessible to other scoping units. This association
remains in effect throughout the execution of the program. The mechanism for use association is the USE
statement. The USE statement provides access to all public entities in the module, unless ONLY is specified.
In this case, only the entities named in the ONLY list can be accessed.
If an entity that is accessed by use association has the same nongeneric name as a host entity, the host
entity is inaccessible. A name that appears in the scoping unit as an external name in an EXTERNAL
statement is a global name, and any entity of the host that has this as its nongeneric name is inaccessible.
For more information on rules that apply to use association, see the USE statement.
See Also
USE statement
Host Association
Scope for details on entities with local scope
Host Association
Host association allows the entities in a host scoping unit to be accessible to an internal subprogram, a
module subprogram, or submodule program. This association remains in effect throughout the execution of
the program.
The following also have access to entities from its host:
• A module procedure interface body
• A derived-type definition
• An interface body that is not a separate interface body has access to the named entities from its host that
are made accessible by IMPORT statements in the interface body.
The accessed entities are known by the same name and have the same attributes as in the host, except that
a local entity can have the ASYNCHRONOUS attribute even if the host entity does not, and a noncoarray local
entity can have the VOLATILE attribute even if the host entity does not. The accessed entities can be named
data objects, derived types, abstract interfaces, procedures, generic identifiers, and namelist groups.
Entities that are local to a procedure are not accessible to their hosts.
The following are considered local identifiers within a scoping unit so they are not accessible to their hosts:
• A function name in a statement function, an entity declaration in a type declaration statement, or the
name of an entity declared by an interface body, unless any of these are global identifiers.
• An object name in an entity declaration in a type declaration statement or a POINTER, SAVE,
ALLOCATABLE, or TARGET statement.
• A type name in a derived type statement.
• A procedure pointer that has the EXTERNAL attribute.
• The name of a variable that is wholly or partially initialized in a DATA statement.
• The name of an object that is wholly or partially initialized in an EQUIVALENCE statement.
• A namelist group name in a NAMELIST statement.
• A generic name in a generic specification in an INTERFACE statement.
• The name of a named construct.
• The name of a dummy argument in a FUNCTION, SUBROUTINE, or ENTRY statement, or a statement
function.
• A named constant defined in a PARAMETER statement.
• An array name in a DIMENSION statement.
• A variable name in a common block object in a COMMON statement.
• A result name in a FUNCTION or ENTRY statement.
• An intrinsic procedure name in an INTRINSIC statement.
A name that appears in an ASYNCHRONOUS or VOLATILE statement is not necessarily the name of a local
variable. In an internal or module procedure, if a variable that is accessible via host association is specified in
an ASYNCHRONOUS or VOLATILE statement, that host variable is given the ASYNCHRONOUS or VOLATILE
attribute in the local scope.
1091
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an intrinsic procedure is accessed by means of host association, it must be established to be intrinsic in the
host scoping unit by one of the following methods:
• It must be explicitly given the INTRINSIC attribute.
• It must be invoked as an intrinsic procedure.
• It must be accessed from a module or from its host where it is established to be intrinsic.
If a procedure gains access to a pointer by host association, the association of the pointer with a target that
is current at the time the procedure is invoked remains current within the procedure. This pointer association
can be changed within the procedure. After execution of the procedure, the pointer association remains
current, unless the execution caused the target to become undefined. If this occurs, the host associated
pointer becomes undefined.
NOTE
Implicit declarations can cause problems for host association. It is recommended that you use
IMPLICIT NONE in both the host and the contained procedure, and that you explicitly declare all
entities.
When all entities are explicitly declared, local declarations override host declarations, and host
declarations that are not overridden are available in the contained procedure.
Examples
The following example shows how a host and an internal procedure can use host-associated entities:
program INTERNAL
! shows use of internal subroutine and CONTAINS statement
real a,b,c
call find
print *, c
contains
subroutine find
read *, a,b
c = sqrt(a**2 + b**2)
end subroutine find
end
In this case, the variables a, b, and c are available to the internal subroutine find through host association.
They do not have to be passed as arguments to the internal procedure. In fact, if they are, they become local
variables to the subroutine and hide the variables declared in the host program.
Conversely, the host program knows the value of c, when it returns from the internal subroutine that has
defined c.
See Also
Use Association
Scope for details on entities with local scope
Linkage Association
Linkage association occurs between the following:
• A module variable that has the BIND attribute and the C variable with which it interoperates
• A Fortran common block and the C variable with which it interoperates
This association remains in effect throughout the execution of the program.
See Also
USE statement
Host Association
Scope for details on entities with local scope
1092
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Construct Association
Construct association establishes an association between each selector and the corresponding associate
name of an ASSOCIATE, CHANGE TEAM, SELECT RANK, or SELECT TYPE construct.
If the selector is allocatable, it must be allocated. The associate name is associated with the data object and
does not have the ALLOCATABLE attribute.
If the selector has the POINTER attribute, it must be associated. The associate name is associated with the
target of the pointer and does not have the POINTER attribute; it has the TARGET attribute if the selector is a
variable that has the POINTER or TARGET attribute.
If the selector has the ASYNCHRONOUS or VOLATILE attribute, the entity associated with the corresponding
associate name also has that attribute. If the selector is polymorphic, the associated entity has the same
dynamic type and type parameters as the selector. If the selector has the OPTIONAL attribute, it must be
present. If the selector is contiguous, the associated entity is also contiguous.
If the selector is a variable other than an array section having a vector subscript, the association is with the
data object specified by the selector; otherwise, the association is with the value of the selector expression,
which is evaluated before the execution of the block.
Each associate name remains associated with the corresponding selector throughout the execution of the
executed block. Within the block, each selector is known by, and can be accessed by, the corresponding
associate name. When the construct is terminated, the association is terminated.
See Also
USE statement
Host Association
Additional Attributes Of Associate Names
Scope for details on entities with local scope
See Also
ASSOCIATE
CHANGE TEAM and END TEAM
SELECT RANK
SELECT TYPE
Pointer Association
A pointer can be associated with a target. At different times during the execution of a program, a pointer can
be undefined, associated with different targets, or be disassociated. The initial association status of a pointer
is undefined. A pointer can become associated by the following:
1093
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Pointer assignments
NULL intrinsic function
Dynamic Allocation for details on the ALLOCATE, DEALLOCATE, and NULLIFY statements
Storage Association
Storage association describes the relationships that exist among data objects. It is the association of two or
more data objects that occurs when two or more storage sequences share, or are aligned with, one or more
storage units. Storage sequences are used to describe relationships among variables, common blocks, and
result variables.
See Also
Storage Units and Storage Sequence
Array Association
1094
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A nonpointer scalar of type default real, integer, or logical occupies one numeric storage unit. A nonpointer
scalar of type double precision real or default complex occupies two contiguous numeric storage units. In
Intel® Fortran, one numeric storage unit corresponds to 4 bytes of memory.
A nonpointer scalar of type default character with character length 1 occupies one character storage unit. A
nonpointer scalar of type default character with character length len occupies len contiguous character
storage units. In Intel® Fortran, one character storage unit corresponds to 1 byte of memory.
A nonpointer scalar of nondefault data type occupies a single unspecified storage unit. The number of bytes
corresponding to the unspecified storage unit differs depending on the data type.
The following table lists the storage requirements (in bytes) for the intrinsic data types:
Data Type Storage Requirements
Data Type Storage Requirements (in bytes)
BYTE 1
LOGICAL 2, 4, or 8 1
LOGICAL(1) 1
LOGICAL(2) 2
LOGICAL(4) 4
LOGICAL(8) 8
INTEGER 2, 4, or 8 1
INTEGER(1) 1
INTEGER(2) 2
INTEGER(4) 4
INTEGER(8) 8
REAL 4, 8, or 162
REAL(4) 4
DOUBLE PRECISION 8
REAL(8) 8
REAL(16) 16
COMPLEX(4) 8
DOUBLE COMPLEX 16
COMPLEX(8) 16
COMPLEX(16) 32
CHARACTER 1
CHARACTER*len len 3
CHARACTER*(*) assumed-length 4
1 Depending on default integer, LOGICAL and INTEGER can have 2, 4, or 8 bytes. The default allocation is
four bytes.
1095
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The default allocations are four bytes for REAL and eight bytes for COMPLEX.
3 The value of len is the number of characters specified. The largest valid value is 2**31-1 on IA-32
architecture; 2**63-1 on Intel® 64 architecture. Negative values are treated as zero.
4 The assumed-length format *(*) applies to dummy arguments, PARAMETER statements, or character
functions, and indicates that the length of the actual argument or function is used. (See Assumed-Length
Character Arguments.)
A nonpointer scalar of sequence derived type occupies a sequence of storage sequences corresponding to the
components of the structure, in the order they occur in the derived-type definition. Note that a sequence
derived type has a SEQUENCE statement.
A pointer occupies a single unspecified storage unit that is different from that of any nonpointer object and is
different for each combination of type, type parameters, and rank.
The definition status and value of a data object affects the definition status and value of any storage-
associated entity.
When two objects occupy the same storage sequence, they are totally storage-associated. When two objects
occupy parts of the same storage sequence, they are partially associated. An EQUIVALENCE statement, a
COMMON statement, or an ENTRY statement can cause total or partial storage association of storage
sequences.
See Also
Assumed-Length Character Arguments
COMMON
ENTRY
EQUIVALENCE
Array Association
A nonpointer array occupies a sequence of contiguous storage sequences, one for each array element, in
array element order.
Two or more arrays are associated when each one is associated with the same storage location. They are
partially associated when part of the storage associated with one array is the same as part or all of the
storage associated with another array.
If arrays with different data types are associated, or partially associated, with the same storage location, and
the value of one array is defined (for example, by assignment), the value of the other array becomes
undefined. This happens because an element of an array is considered defined only if the storage associated
with it contains data of the same type as the array name.
An array element, array section, or whole array is defined by a DATA statement before program execution.
Note that the array properties must be declared in a previous specification statement. During program
execution, array elements and sections are defined by an assignment or input statement, and entire arrays
are defined by input statements.
See Also
Arrays
DATA statement
Array Elements for details on array element order
Inheritance Association
Inheritance association occurs between components of a parent component and components inherited by
type extension into an extended type.
This association is not affected by the accessibility of the inherited components.
1096
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Storage Association
Pointer Association
NOTE
Intel® Fortran fully supports features identified as deleted from or obsolescent in the Fortran Standard.
See Also
stand compiler option
1097
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Arithmetic IF statement
The arithmetic IF statement can be replace by an IF-THEN-ELSE construct or a CASE SELECT construct.
For example, replace:
IF (expr) 10, 20, 30
with:
IF (expr .LT. 0) THEN
GO TO 10
ELSE IF (expr .EQ. 0) THEN
GO TO 20
ELSE
GO TO 30
ENDIF
• Assigned FORMAT specifier
The assigned FORMAT specifier sets an integer variable to the label of a FORMAT statement and then the
integer variable is used in an I/O statement instead of the FORMAT label. You can replace the integer
variable with a character variable whose value is the contents of the FORMAT statement, and then use the
character variable in the I/O statement as the format. For example, replace:
ASSIGN 1000 TO IFMT
...
WRITE (6, IFMT) X, Y
...
1000 FORMAT (2E10.2)
with:
CHARACTER(20) :: IFMT = "(2E10.2)"
...
WRITE (6, IFMT) X, Y
• The non-block form of a DO statement
The non-block form of a DO loop contains a statement label in the DO statement identifying the terminal
statement of the DO. The terminal statement may be an executable statement and may be shared with
another non-block DO statement. Use an END DO statement as the terminal statement for each DO loop.
You should not use statement labels on the terminating statement and in the DO statement, because
labeled DO loops are now obsolescent.
For example, replace the following:
DO 10 I = 1, N
DO 10 J = 1, M
10 A(I, J) = F_OF (I, J)
with this:
DO I = 1, N
DO J = 1, M
A(I, J) = F_OF (I, J)
END DO
END DO
• Branching to an END IF statement from outside its IF block
The END IF statement can no longer be a target of a GO TO statement that is outside the IF block that
ends with that END IF statement. Use a CONTINUE statement after the END IF as the target of the GO TO
statement. For example, replace:
IF ...
GO TO 100
ELSE IF ...
100 END IF
1098
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
with:
IF ...
GO TO 100
ELSE IF ...
END IF
100 CONTINUE
• H edit descriptor
Replace the H edit descriptor of the form nHcharacters with "characters". Remember to double any quotes
or apostrophes in the string characters.
• PAUSE statement
The PAUSE statement displays a character string on the standard output device and then suspends
program execution until any character is typed on the standard input device. You can replace the PAUSE
statement with a WRITE statement followed by a READ statement. For example, replace:
PAUSE " don’t forget to buy milk"
with:
WRITE (6, *) " don’t forget to buy milk"
READ (5, *) ! no io-list is necessary, the input is ignored
• Real and double precision DO control variables and DO loop control expressions
REAL variables of any KIND can no longer be used as DO loop control variables and expressions. You can
replace such DO loops with the appropriate DO WHILE loop that explicitly initializes, increments, and tests
the REAL variable. For example, replace:
DO X = 0.1, 0.5, 0.01
...
END DO
with:
X = 0.1
DO WHILE (X .LE. 0.5)
...
X = X + 0.01
END DO
• Vertical format control
Formatted output to certain printing output units used to result in the first character of each record being
interpreted as controlling vertical spacing on the unit. There is no standard way to detect whether output
to such a unit should result in such vertical format control and no way to specify that it should be applied.
The effect can be achieved by post-processing a formatted file after it is created to interpret the first
character as some form of control character. This is left to the user.
Intel Fortran flags these features if you specify compiler option stand.
See Also
Obsolescent Language Features in the Fortran Standard
stand compiler option
1099
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To replace this functionality, it is recommended that you use an integer variable to return a value to the
calling program, and let the calling program use a CASE construct to test the value and perform
operations.
• Assumed-length character functions
To replace this functionality, it is recommended that you use one of the following:
• An automatic character-length function, where the length of the function result is declared in a
specification expression
• A subroutine whose arguments correspond to the function result and the function arguments
Dummy arguments of a function can still have assumed character length; this feature is not obsolescent.
• BLOCK DATA subprograms
BLOCK DATA was used to initialize COMMON block variables. This can be achieved with initialization of
MODULE data when it is declared. MODULE data is the preferred method of sharing data between
compilation units, and for replacing COMMON blocks.
• CHARACTER*(*) form of CHARACTER declaration
To replace this functionality, it is recommended that you use the Fortran 90 forms of specifying a length
selector in CHARACTER declarations (see Declaration Statements for Character Types).
• COMMON blocks
To replace this functionality, it is recommended data specified in COMMON be declared in a MODULE which
can be made available through USE association where the data is needed.
• Computed GO TO statement
To replace this functionality, it is recommended that you use a CASE construct.
• DATA statements among executable statements
This functionality has been included since FORTRAN 66, but is considered to be a potential source of
errors.
• ENTRY statement
To replace this functionality, it is recommended that you use multiple module procedures that can access
shared data in the module.
• EQUIVALENCE
The use of storage association thru EQUIVALENCE statements is not recommended.
• Fixed source form
Newer methods of entering data have made this source form obsolescent and error-prone.
The recommended method for coding is to use free source form.
• FORALL statement and construct
These were added to the language with the expectation they would result in very efficient and possibly
parallel code. The complexity and many restrictions prevented compilers from taking advantage of them.
The DO CONCURRENT construct makes FORALL redundant. Data manipulations which can be done with
FORALL can be done more effectively with pointers using rank remapping. Both the FORALL statement
form and the construct became obsolescent in Fortran 2018.
• Labeled DO loops
To replace this functionality, it is recommended that you use an END DO statements to terminate loops,
and CYCLE statements to branch to the end of the loop to start the next iteration of the loop (or exit the
loop, if the last iteration of the loop takes the branch).
• Statement functions
To replace this functionality, it is recommended that you use an internal function.
• Specific names of intrinsic functions that also have generic names
To replace this functionality, it is recommended that you use the generic names.
1100
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The FORTRAN 66 EXTERNAL statement declares that each name in its list is an external procedure name.
Such a name can then be used as an actual argument to a subprogram, which then can use the
corresponding dummy argument in a function reference or CALL statement.
However, when used as an argument, a complete function reference represents a value, not a subprogram
name; for example, SQRT(B) in CALL SUBR(A, SQRT(B), C). Therefore, it does not need to be defined in an
EXTERNAL statement. Note that the incomplete reference SQRT would need to be defined in an EXTERNAL
statement.
Examples
The following example, when compiled with compiler option f66, shows the FORTRAN 66 EXTERNAL
statement:
1101
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Y = SIN(X)
Y = COS(X)
Y = TAN(X)
Y = SINDEG(X)
The functions SIN and COS are examples of trigonometric functions supplied in the Fortran intrinsic
procedure library. The function TAN is also supplied in the library, but the asterisk (*) in the EXTERNAL
statement specifies that the user-supplied function be used, instead of the intrinsic function. The function
SINDEG is also a user-supplied function. Because no library function has the same name, no asterisk is
required.
See Also
f66 compiler option
Description
Each name c becomes a constant and is defined as the value of expression expr. Once a name is defined as a
constant, it can appear in any position in which a constant is allowed. The effect is the same as if the
constant were written there instead of the name.
The name of a constant cannot appear as part of another constant, except as the real or imaginary part of a
complex constant. For example:
PARAMETER I=3
PARAMETER M=I.25 ! Not allowed
PARAMETER N=(1.703, I) ! Allowed
1102
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The name used in the PARAMETER statement identifies only the name's corresponding constant in that
program unit. Such a name can be defined only once in PARAMETER statements within the same program
unit.
The name of a constant assumes the data type of its corresponding constant expression. The data type of a
parameter constant cannot be specified in a type declaration statement. Nor does the initial letter of the
constant's name implicitly affect its data type.
Examples
The following are valid examples of this form of the PARAMETER statement:
See Also
PARAMETER for details on compile-time constant expressions
You can use a quotation mark (") in place of an apostrophe in all the above syntax forms.
For information on the # syntax for integers not in base 10, see Integer Constants.
See Also
Binary constants
Octal constants
Hexadecimal constants
The value must be greater than or equal to 1, and less than or equal to the maximum number of records
allowed in the file. If necessary, a record number is converted to integer data type before being used.
If this nonkeyword form is used in an I/O control list, it must immediately follow the nonkeyword form of the
io-unit specifier.
1103
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-unit Is the number of the logical unit containing the record to be deleted.
See Also
DELETE statement
group-name Is the name of the group containing the objects to be given values.
The name must have been previously defined in a NAMELIST
statement in the scoping unit.
If more than one object=value or more than one value is specified, they must be separated by value
separators.
A value separator is any number of blanks, or a comma or slash, preceded or followed by any number of
blanks.
See Also
NAMELIST statement
Rules for Namelist Sequential READ Statements for details on namelist input
Rules for Namelist Sequential WRITE Statements for details on namelist output
Record Structures
The record structure was defined in earlier versions of Intel® Fortran as a language extension. It is still
supported, although its functionality has been replaced by Standard Fortran derived data types. Record
structures in existing code can be easily converted to Standard Fortran derived type structures for portability,
but can also be left in their old form. In most cases, an Intel Fortran record and a Standard Fortran derived
type can be used interchangeably.
Intel Fortran record structures are similar to Standard Fortran derived types.
A record structure is an aggregate entity containing one or more elements. (Record elements are also called
fields or components.) You can use records when you need to declare and operate on multi-field data
structures in your programs.
Creating a record is a two-step process:
1. You must define the form of the record with a multistatement structure declaration.
2. You must use a RECORD statement to declare the record as an entity with a name. (More than one
RECORD statement can refer to a given structure.)
1104
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Intel Fortran record structures, using only intrinsic types, easily convert to Standard Fortran derived types.
The conversion can be as simple as replacing the keyword STRUCTURE with TYPE and removing slash ( / )
marks. The following shows an example conversion:
The record structures can be used as subordinate record variables within another record, such as the
employee_data record. The equivalent Standard Fortran derived type would use the derived-type objects as
components in a similar manner, as shown below:
See Also
RECORD Statement
Structure Declarations
A structure declaration defines the field names, types of data within fields, and order and alignment of fields
within a record. Fields and structures can be initialized, but records cannot be initialized. For more
information, see STRUCTURE.
See Also
Type Declarations
Substructure Declarations
Union Declarations
1105
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following rules and behavior apply to type declarations in record structures:
• %FILL can be specified in place of a field name to leave space in a record for purposes such as alignment.
This creates an unnamed field.
%FILL can have an array specification; for example:
INTEGER %FILL (2,2)
Unnamed fields cannot be initialized. For example, the following statement is invalid and generates an
error message:
INTEGER %FILL /1980/
• Initial values can be supplied in field declaration statements. Unnamed fields cannot be initialized; they
are always undefined.
• Field names must always be given explicit data types. The IMPLICIT statement does not affect field
declarations.
• Any required array dimensions must be specified in the field declaration statements. DIMENSION
statements cannot be used to define field names.
• Adjustable or assumed sized arrays and assumed-length CHARACTER declarations are not allowed in field
declarations.
Substructure Declarations
A field within a structure can itself be a structured item composed of other fields, other structures, or both.
You can declare a substructure in two ways:
• By nesting structure declarations within other structure or union declarations (with the limitation that you
cannot refer to a structure inside itself at any level of nesting).
One or more field names must be defined in the STRUCTURE statement for the substructure, because all
fields in a structure must be named. In this case, the substructure is being used as a field within a
structure or union.
Field names within the same declaration nesting level must be unique, but an inner structure declaration
can include field names used in an outer structure declaration without conflict.
• By using a RECORD statement that specifies another previously defined record structure, thereby
including it in the structure being declared.
See the example in STRUCTURE for a sample structure declaration containing both a nested structure
declaration (TIME) and an included structure (DATE).
1106
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
scalar-field-name Is the name of a data item (having a data type) defined within a
structure declaration.
Description
Records and record fields cannot be used in DATA statements, but individual fields can be initialized in the
STRUCTURE definition.
An automatic array cannot be a record field.
A scalar field reference consists of the name of a record (as specified in a RECORD statement) and zero or
more levels of aggregate field names followed by the name of a scalar field. A scalar field reference refers to
a single data item (having a data type) and can be treated like a normal reference to a Fortran variable or
array element.
You can use scalar field references in statement functions and in executable statements. However, they
cannot be used in COMMON, SAVE, NAMELIST, or EQUIVALENCE statements, or as the control variable in an
indexed DO-loop.
Type conversion rules for scalar field references are the same as those for variables and array elements.
An aggregate field reference consists of the name of a record (as specified in a RECORD statement) and zero
or more levels of aggregate field names.
You can only assign an aggregate field to another aggregate field (record = record) if the records have the
same structure. Intel® Fortran supports no other operations (such as arithmetic or comparison) on aggregate
fields.
Intel Fortran requires qualification on all levels. While some languages allow omission of aggregate field
names when there is no ambiguity as to which field is intended, Intel Fortran requires all aggregate field
names to be included in references.
You can use aggregate field references in unformatted I/O statements; one I/O record is written no matter
how many aggregate and array name references appear in the I/O list. You cannot use aggregate field
references in formatted, namelist, and list-directed I/O statements.
You can use aggregate field references as actual arguments and record dummy arguments. The declaration
of the dummy record in the subprogram must match the form of the aggregate field reference passed by the
calling program unit; each structure must have the same number and types of fields in the same order. The
order of map fields within a union declaration is irrelevant.
Records are passed by reference. Aggregate field references are treated like normal variables. You can use
adjustable arrays in RECORD statements that are used as dummy arguments.
Examples
The following examples show record and field references. Consider the following structure declarations:
Structure DATE:
STRUCTURE /DATE/
INTEGER*1 DAY, MONTH
INTEGER*2 YEAR
STRUCTURE
1107
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Structure APPOINTMENT:
STRUCTURE /APPOINTMENT/
RECORD /DATE/ APP_DATE
STRUCTURE /TIME/ APP_TIME(2)
INTEGER*1 HOUR, MINUTE
END STRUCTURE
CHARACTER*20 APP_MEMO(4)
LOGICAL*1 APP_FLAG
END STRUCTURE
The following RECORD statement creates a variable named NEXT_APP and a 10-element array named
APP_LIST. Both the variable and each element of the array take the form of the structure APPOINTMENT.
NEXT_APP
• The field APP_DATE, a 4-byte array field in the record array APP_LIST(3):
APP_LIST(3).APP_DATE
NEXT_APP.APP_FLAG
• The first character of APP_MEMO(1), a CHARACTER*20 field of the record NEXT_APP:
NEXT_APP.APP_MEMO(1)(1:1)
NOTE
Because periods are used in record references to separate fields, you should avoid using relational
operators (.EQ., .XOR.), logical constants (.TRUE., .FALSE.), and logical expressions
(.AND., .NOT., .OR.) as field names in structure declarations. Dots can also be used instead of % to
separate fields of a derived type.
1108
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
rslt = t2%eq%i + i
end function eq_func
end module mod
use mod
type(T2_t) :: t2
integer :: i
t2%eq%i = 0
t2%i = -10
i = -10
print *, t2.eq.i, (t2).eq.i
end
In this case, the reference "t2.eq.i" prints 0. The reference "(t2).eq.i" will invoke eq_func and will print -10.
See Also
RECORD statement
STRUCTURE
for details on structure declarations
UNION
for details on UNION and MAP statements
Aggregate Assignment
For aggregate assignment statements, the variable and expression must have the same structure as the
aggregate they reference.
The aggregate assignment statement assigns the value of each field of the aggregate on the right of an equal
sign to the corresponding field of the aggregate on the left. Both aggregates must be declared with the same
structure.
Examples
The following example shows valid aggregate assignments:
STRUCTURE /DATE/
INTEGER*1 DAY, MONTH
INTEGER*2 YEAR
END STRUCTURE
DO I = 1,7
CALL GET_DATE (TODAY)
THIS_WEEK(I) = TODAY
THIS_WEEK(I).DAY = TODAY.DAY + 1
END DO
MEETING.APP_DATE = TODAY
1109
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Character Sets for details on the Standard Fortran character set
1110
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1111
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1112
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1113
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1114
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SI Shift In SP Space
1115
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The remaining half of each column identifies the character by the binary value of the byte; the value is stated
in three radixes—octal, decimal, and hexadecimal. For example, the uppercase letter A has, under ASCII
conventions, a storage value of hexadecimal 41 (a bit configuration of 01000001), equivalent to 101 in octal
notation and 65 in decimal notation.
ASCII Character Set (L*X, M*X)
1116
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1117
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For more information on the range of values for each data type (and kind), see Data and I/O in the Compiler
Reference.
The following example shows the general integer model for i = -20 using a base (r) of 2:
1118
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
emin emax
The following example shows the general real model for x = 20.0 using a base (b) of 2:
1119
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
BIT_SIZE
IFWINTY Defines Fortran parameter constants and derived data types for
use with Windows APIs
1120
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
The same routine name may appear in different modules. These routines may have different
semantics, so be careful you are using the module that contains the routine that will produce the
results you want.
NOTE
The same routine name may appear in different modules. These routines may have different
semantics, so be careful you are using the module that contains the routine that will produce the
results you want.
See Also
USE
1121
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
At program startup, the current language and country setting is retrieved from the operating system. The
user can change this setting through the Control Panel Regional Settings icon. The current codepage is
also retrieved from the system.
There is a system default console codepage and a system default Windows codepage. Console programs
retrieve the system console codepage, while Windows programs (including QuickWin applications) retrieve
the system Windows codepage.
The NLS Library provides routines to determine the current locale (local code set), to return parameters of
the current locale, to provide a list of all the system supported locales, and to set the locale to another
language, country and/or codepage. Note that the locales and codepages set with these routines affect
only the program or console that calls the routine. They do not change the system defaults or affect other
programs or consoles.
• NLS Formatting routines to format dates, currency, and numbers
You can set time, date, currency and number formats from the Control Panel, by clicking on the Regional
Settings icon. The NLS Library also provides formatting routines for the current locale. These routines
return strings in the current codepage, set by default at program start or by NLSSetLocale.
All the formatting routines return the number of bytes in the formatted string (not the number of
characters, which can vary if multibyte characters are included). If the output string is longer than the
formatted string, the output string is blank padded. If the output string is shorter than the formatted
string, an error occurs, NLS$ErrorInsufficientBuffer is returned, and nothing is written to the output
string.
• Multibyte Character Set (MBCS) routines for using multi-byte characters
Examples of multibyte character sets are Japanese, Korean, and Chinese.
• The MBCS inquiry routines provide information on the maximum length of multibyte characters, the
length, number and position of multibyte characters in strings, and whether a multibyte character is a
leading or trailing byte. The NLS library provides a parameter, MBLenMax, defined in the NLS module
to be the longest length (in bytes) of any character, in any codepage. This parameter can be useful in
comparisons and tests. To determine the maximum character length of the current codepage, use the
MBCurMax function.
• There are four MBCS conversion routines. Two convert Japan Industry Standard (JIS) characters to
Microsoft Kanji characters or vice versa. Two convert between a codepage multibyte character string
and a Unicode string.
• There are several MBCS Fortran equivalent routines. They are the exact equivalents of Fortran intrinsic
routines except that the MBCS equivalents allow character strings to contain multibyte characters.
Examples
The following example uses Locale Setting and Inquiry routines:
USE IFNLS
INTEGER(4) strlen, status
CHARACTER(40) str
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
print *, str ! prints Monday
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
print *, str ! prints Tuesday
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str)
print *, str ! prints Wednesday
! Change locale to Spanish, Mexico
status = NLSSetLocale("Spanish", "Mexico")
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME1, str)
print *, str ! prints lunes
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME2, str)
print *, str ! prints martes
strlen = NLSGetLocaleInfo(NLS$LI_SDAYNAME3, str)
print *, str ! prints miércoles
END
1122
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
USE IFNLS
INTEGER(4) strlen, status
CHARACTER(40) str
strlen = NLSFormatTime(str)
print *, str ! prints 11:42:24 AM
strlen = NLSFormatDate(str, flags= NLS$LongDate)
print *, str ! prints Friday, July 14, 2000
status = NLSSetLocale ("Spanish", "Mexico")
strlen = NLSFormatTime(str)
print *, str ! prints 11:42:24
print *, str ! prints viernes 14 de julio de 2000
The following example uses Multibyte Character Set (MBCS) inquiry routines:
USE IFNLS
CHARACTER(4) str
INTEGER status
status = NLSSetLocale ("Japan")
str = " ·, " ¿"
PRINT '(1X,''String by char = '',\)'
DO i = 1, len(str)
PRINT '(A2,\)',str(i:i)
END DO
PRINT '(/,1X,''MBLead = '',\)'
DO i = 1, len(str)
PRINT '(L2,\)',mblead(str(i:i))
END DO
PRINT '(/,1X,''String as whole = '',A,\)',str
PRINT '(/,1X,''MBStrLead = '',\)'
DO i = 1, len(str)
PRINT '(L1,\)',MBStrLead(str,i)
END DO
END
This code produces the following output for str = · , " ¿
The following example uses Multibyte Character Set (MBCS) Fortran equivalent routines:
USE IFNLS
INTEGER(4) i, len(7), infotype(7)
CHARACTER(10) str(7)
LOGICAL(4) log4
data infotype / NLS$LI_SDAYNAME1, NLS$LI_SDAYNAME2, &
& NLS$LI_SDAYNAME3, NLS$LI_SDAYNAME4, &
& NLS$LI_SDAYNAME5, NLS$LI_SDAYNAME6, &
& NLS$LI_SDAYNAME7 /
WRITE(*,*) 'NLSGetLocaleInfo'
WRITE(*,*) '----------------'
WRITE(*,*) ' '
WRITE(*,*) 'Getting the names of the days of the week...'
1123
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DO i = 1, 7
len(i) = NLSGetLocaleInfo(infotype(i), str(i))
WRITE(*, 11) 'len/str/hex = ', len(i), str(i), str(i)
END DO
11 FORMAT (1X, A, I2, 2X, A10, 2X, '[', Z20, ']')
WRITE(*,*) ' '
WRITE(*,*) 'Lexically comparing the names of the days...'
DO i = 1, 6
log4 = MBLGE(str(i), str(i+1), NLS$IgnoreCase)
WRITE(*, 12) 'Is day ', i, ' GT day ', i+1, '? Answer = ', log4
END DO
12 FORMAT (1X, A, I1, A, I1, A, L1)
WRITE(*,*) ' '
WRITE(*,*) 'Done.'
END
This code produces the following output when the locale is Japan:
See Also
National Language Support Library Routines
Standard Fortran Routines That Handle MBCS Characters
USE
1124
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Some routines work with the computer collating sequence to return a character in a certain position in the
sequence or the position in the sequence of a certain character. These functions are not dependent on a
particular collating sequence. (You should note, however, that elsewhere in this manual the ASCII collating
sequence is mentioned in reference to these functions.) Such functions use position and c values between 0
and 255 (inclusive) and include:
• ACHAR (position)
• CHAR (position[,kind ])
• IACHAR (c)
• ICHAR (c)
Because Fortran uses character lengths instead of NULLs to indicate the length of a string, some functions
work solely from the length of the string, and not with the contents of the string. This function works as
usual on strings containing MBCS characters, and include:
REPEAT (string, ncopies)
Portability Routines
This section summarizes portability routines.
1125
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Other bit manipulation functions such as AND, XOR, OR, LSHIFT, and RSHIFT are intrinsic functions. You do
not need the IFPORT module to access them. Standard Fortran includes many bit operation routines, which
are listed in the Bit Operation and Representation Routines table.
IERRNO is updated only when an error occurs. For example, if a call to the GETC function results in an error,
but two subsequent calls to PUTC succeed, a call to IERRNO returns the error for the GETC call. Examine
IERRNO immediately after returning from one of the portability library routines. Other Standard Fortran
routines might also change the value to an undefined value.
If your application uses multithreading, remember that IERRNO is set on a per-thread basis.
1126
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Additional Routines
You can also use portability routines for program call and control, keyboards and speakers, file management,
arrays, floating-point inquiry and control, IEEE* functionality, and other miscellaneous uses.
NOTE
On Windows* systems, all portability routines that take path names also accept long file names or
UNC (Universal Naming Convention) file names. A forward slash in a path name is treated as a
backslash. All path names can contain drive specifications as well as MBCS (multiple-byte character
set) characters.
See Also
Portability Routines
Overview of Serial Port I/O Routines
USE IFPORT
1127
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The USE IFPORT statement includes the routine definitions in the compilation. You may also need to add a
USE IFWINTY statement to your program because some Windows* constants may be required that are
typically defined in the IFWINTY module.
Many arguments are optional. If a constant is used where an argument is both input and output, a probe for
writeability is done before the output. Thus, in many cases, a constant may be used without creating a
temporary variable. It should be noted, however, that doing so may not be compatible with all Fortran
implementations.
1128
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Portability Routines for a list of the SPORT routines
LOGICAL*4 REAL*4
LOGICAL*8 REAL*8
See Also
Intrinsic Data Types
1129
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1130
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1131
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• SHARED
• TITLE (W*S)
• TYPE as a synonym for STATUS
• USEROPEN
See also OPEN Statement.
A to D
ACOSD BIEOR COSD DBLEQ
1132
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
E to I
EOF HMOD IIDNNT IMVBITS
1133
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
J to P
JFIX JISIGN KIBSET KMOD
Q to Z
QABS QCOSH QNINT SIZEOF
1134
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A to Z Reference
This section contains the following:
• Language Summary Tables
This section organizes the Fortran functions, subroutines, and statements by the operations they perform,
and shows short descriptions of each routine. You can use the tables to locate a particular routine for a
particular task.
• The descriptions of all Fortran statements, intrinsics, directives, and module library routines, which are
listed in alphabetical order.
Certain routine groups, such as POSIX* routines and NLS routines, are in separate sections.
NOTE
In the description of routines, pointers and handles are INTEGER(4) on IA-32 architecture and
INTEGER(8) on Intel® 64 architecture.
ifx does not generate code to run on IA-32 architecture.
The Fortran compiler understands statements and intrinsic functions in your program without any additional
information, such as that provided in modules.
However, modules must be included in programs that contain the following routines. Note that the links in
this list go to the relevant language summary table:
• Quickwin routines and graphics routines
These routines require a USE IFQWIN statement to include the library and graphics modules.
• Portability routines
It is recommended that you specify USE IFPORT when accessing routines in the portability library.
1135
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1136
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1137
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1138
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Compiler Directives
The following tables list available compiler directives.
Each OpenMP* Fortran directive name is preceded by the prefix c$OMP, where c is one of the following: !, C
(or c), or *; for example, !$OMP ATOMIC.
Compiler directives are specially formatted comments in the source file that provide information to the
compiler. Some directives, such as line length or conditional compilation directives, provide the compiler
information that is used in interpreting the source file. Other directives, such as optimization directives,
provide hints or suggestions to the compiler, which, in some cases, may be ignored or overridden by the
compiler, based on the heuristics of the optimizer and/or code generator. If the directive is ignored by the
compiler, no diagnostic message is issued.
You do not need to specify a compiler option to enable general directives.
Some directives may perform differently on Intel® microprocessors than on non-Intel microprocessors.
General Directives
Name Description
1139
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
LOOP COUNT Specifies the typical trip loop count for a DO loop;
which assists the optimizer.
1140
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1141
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1142
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1143
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1144
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1145
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
TARGET TEAMS DISTRIBUTE PARALLEL DO Creates a device data environment and then
executes the construct on that device. It also
specifies a loop that can be executed in parallel by
multiple threads that are members of multiple
teams created by a TEAMS construct.
TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD Creates a device data environment and then
executes the construct on that device. It also
specifies a loop that can be executed in parallel by
multiple threads that are members of multiple
teams created by a TEAMS construct. The loop will
be distributed across the teams, which will be
executed concurrently using SIMD instructions.
TARGET TEAMS DISTRIBUTE SIMD Creates a device data environment and executes
the construct on the same device. It also specifies
that loop iterations will be shared among the
primary threads of all thread teams in a league
created by a teams construct. It will be executed
concurrently using SIMD instructions.
TARGET UPDATE Makes the list items in the device data environment
consistent with their corresponding original list
items. This feature is only available for ifx.
1146
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1147
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
See Also
qopenmp, Qopenmp compiler option
Statements
Name Description
1148
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1149
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1150
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
RADIX Returns the base for data of the same type as the
argument.
1151
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The portability routines RANF, RANDOM, and SEED also supply this functionality.
Atomic Operation
Name Procedure Type Description
Collective Operation
Name Procedure Type Description
1152
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The portability routines GETDAT, GETTIM, SETDAT, and SETTIM also supply this functionality.
1153
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1154
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1155
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1156
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
NOTE
Many routines in the LIBM library (Math Library) are more highly optimized for Intel® microprocessors
than for non-Intel microprocessors.
Name Description
1157
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1158
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1159
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
RADIX Returns the base for data of the same type as the
argument.
1160
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
Name Description
1161
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1162
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Bit Representation
Name Procedure Type Description
NOTE
QuickWin applications are only supported for ifort.
1163
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1164
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1165
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1166
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1167
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1168
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1169
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Process Control
Name Procedure Type Description
1170
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1171
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1172
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1173
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Error Handling
Name Procedure Type Description
Program Control
Name Procedure Type Description
1174
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Speaker
Name Procedure Type Description
File Management
Name Procedure Type Description
1175
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Arrays
Name Procedure Type Description
IEEE Functionality
Name Procedure Type Description
1176
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Miscellaneous
Name Procedure Type Description
1177
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1178
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MBLGE, MBLGT, MBLLE, Function Same as LGE, LGT, LLE, and LLT,
MBLLT,MBLEQ, MBLNE and the logical operators .EQ.
and .NE., except that multibyte
characters can be included in
their arguments.
1179
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1180
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1181
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1182
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1183
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
PXFUMASK Sets a new file creation mask and gets the previous
one.
1184
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Name Description
1 L*X, M*X
1185
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Additional Documentation: Creating Fortran Applications that Use Windows* OS Features
1186
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1187
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1188
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A to B
This section describes language features that start with A or B.
1189
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A to B
ABORT
Portability Subroutine: Flushes and closes I/O
buffers, and terminates program execution.
Module
USE IFPORT
Syntax
CALL ABORT[string]
This subroutine causes the program to terminate and an exit code value of 134 is returned to the program
that launched it.
Example
USE IFPORT
!The following prints "abort: Fortran Abort Called"
CALL ABORT
!The following prints "abort: Out of here!"
Call ABORT ("Out of here!")
See Also
EXIT
STOP
ABS
Elemental Intrinsic Function (Generic): Computes
an absolute value.
Syntax
result=ABS(a)
Results
The result has the same type and kind type parameter as a except if a is complex value, the result type is
real. If a is an integer or real value, the value of the result is | a |; if a is a complex value (X, Y), the result is
the real value SQRT (X**2 + Y**2).
1190
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
ABS (-7.4) has the value 7.4.
ABS ((6.0, 8.0)) has the value 10.0.
The following ABS.F90 program calculates two square roots, retaining the sign:
ABSTRACT INTERFACE
Statement: Defines an abstract interface.
Syntax
ABSTRACT INTERFACE
[interface-body]...
END INTERFACE
1191
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
An abstract interface block defines an interface whose name can be used in a PROCEDURE declaration
statement to declare subprograms with identical arguments and characteristics.
An abstract interface block cannot contain a PROCEDURE statement or a MODULE PROCEDURE statement.
Interface blocks can appear in the specification part of the program unit that invokes the external or dummy
procedure.
An interface block must not appear in a block data program unit.
An interface block comprises its own scoping unit, and does not inherit anything from its host through host
association.
The function or subroutine named in the interface-body cannot have the same name as a keyword that
specifies an intrinsic type.
To make an interface block available to multiple program units (through a USE statement), place the
interface block in a module.
Example
Previously, within an interface block, you needed to individually declare subroutines and functions that had
the same argument keywords and characteristics. For example:
INTERFACE
SUBROUTINE SUB_ONE (X)
REAL, INTENT(IN) :: X
END SUBROUTINE SUB_ONE
SUBROUTINE SUB_TWO (X)
REAL, INTENT(IN) :: X
END SUBROUTINE SUB_TWO
...
END INTERFACE
Now you can use an abstract interface to specify a subprogram name for these identical arguments and
characteristics. For example:
ABSTRACT INTERFACE
SUBROUTINE TEMPLATE (X)
REAL, INTENT(IN) :: X
END SUBROUTINE TEMPLATE
END INTERFACE
You can then use the subprogram in the abstract interface as a template in a PROCEDURE statement to
declare procedures. For example:
See Also
INTERFACE
PROCEDURE
FUNCTION
SUBROUTINE
Procedure Interfaces
Use and Host Association
ACCEPT
Statement: Transfers input data.
1192
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
Formatted:
ACCEPT form[,io-list]
Formatted - List-Directed:
ACCEPT *[,io-list]
Formatted - Namelist:
ACCEPT nml
The ACCEPT statement is the same as a formatted, sequential READ statement, except that an ACCEPT
statement must never be connected to user-specified I/O units. You can override this restriction by using
environment variable FOR_ACCEPT.
Example
In the following example, character data is read from the implicit unit and binary values are assigned to each
of the five elements of array CHARAR:
CHARACTER*10 CHARAR(5)
ACCEPT 200, CHARAR
200 FORMAT (5A10)
ACCESS Function
Portability Function: Determines if a file exists and
how it can be accessed.
Module
USE IFPORT
Syntax
result = ACCESS(name,mode)
Character Meaning
1193
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Character Meaning
Results
The value of the result is INTEGER(4). It is zero if all inquiries specified by mode are true. If either argument
is invalid, or if the file cannot be accessed in all of the modes specified, one of the following error codes is
returned:
• EACCES: Access denied; the file's permission setting does not allow the specified access
• EINVAL: The mode argument is invalid
• ENOENT: File or path not found
For a list of error codes, see IERRNO.
The name argument can contain either forward or backward slashes for path separators.
On Windows* systems, all files are readable. A test for read permission always returns 0.
Example
use ifport
! checks for read and write permission on the file "DATAFILE.TXT"
J = ACCESS ("DATAFILE.TXT", "rw")
PRINT *, J
! checks whether "DATAFILE.TXT" is executable. It is not, since
! it does not end in .COM, .EXE, .BAT, or .CMD
J = ACCESS ("DATAFILE.TXT","x")
PRINT *, J
See Also
INQUIRE
GETFILEINFOQQ
ACHAR
Elemental Intrinsic Function (Generic): Returns
the character in a specified position of the ASCII
character set, even if the processor's default character
set is different. It is the inverse of the IACHAR
function. In Intel® Fortran, ACHAR is equivalent to the
CHAR function.
Syntax
result = ACHAR (i [, kind])
1194
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is character with length 1. If kind is present, the kind parameter of the result is that
specified by kind; otherwise, the kind parameter of the result is that of default character. If the processor
cannot represent the result value in the kind of the result, the result is undefined.
If i has a value within the range 0 to 127, the result is the character in position i of the ASCII character set;
otherwise, it is processor defined. ACHAR (IACHAR(C)) has the value C for any character C capable of
representation in the default character set. For a complete list of ASCII character codes, see Character and
Key Code Charts.
Example
ACHAR (71) has the value 'G'.
See Also
CHAR
IACHAR
ICHAR
ACOS
Elemental Intrinsic Function (Generic): Produces
the arccosine of x.
Syntax
result = ACOS (x)
Results
The result type and kind are the same as x and is expressed in radians.
If the result is real, the value is expressed in radians and lies in the range 0 <= ACOS(X) <= pi.
If the result is complex, the real part is expressed in radians and lies in the range 0 <= REAL(ACOS (x)) <=
pi.
Example
ACOS (0.68032123) has the value .8225955.
1195
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ACOSD
Elemental Intrinsic Function (Generic): Produces
the arccosine of x.
Syntax
result = ACOSD (x)
Results
The result type and kind are the same as x and are expressed in degrees. The value lies in the range −90 to
90 degrees.
Example
ACOSD (0.886579) has the value 27.55354.
ACOSH
Elemental Intrinsic Function (Generic): Produces
the hyperbolic arccosine of x.
Syntax
result = ACOSH (x)
Results
The result type and kind are the same as x.
If the result is complex, the real part is non-negative, and the imaginary part is expressed in radians and lies
in the range -pi <= AIMAG (ACOSH (x)) <= pi.
Example
ACOSH (1.0) has the value 0.0.
ACOSH (180.0) has the value 5.8861.
1196
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ADJUSTL
Elemental Intrinsic Function (Generic): Adjusts a
character string to the left, removing leading blanks
and inserting trailing blanks.
Syntax
result = ADJUSTL (string)
Results
The result type is character with the same length and kind parameter as string. The value of the result is the
same as string, except that any leading blanks have been removed and inserted as trailing blanks.
Example
CHARACTER(16) STRING
STRING= ADJUSTL(' Fortran 90 ') ! returns 'Fortran 90 '
See Also
ADJUSTR
ADJUSTR
Elemental Intrinsic Function (Generic): Adjusts a
character string to the right, removing trailing blanks
and inserting leading blanks.
Syntax
result = ADJUSTR (string)
Results
The result type is character with the same length and kind parameter as string.
The value of the result is the same as string, except that any trailing blanks have been removed and inserted
as leading blanks.
Example
CHARACTER(16) STRING
STRING= ADJUSTR(' Fortran 90 ') ! returns ' Fortran 90'
See Also
ADJUSTL
AIMAG
Elemental Intrinsic Function (Generic): Returns
the imaginary part of a complex number. This function
can also be specified as IMAG.
1197
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = AIMAG (z)
Results
The result type is real with the same kind parameter as z. If z has the value (x, y), the result has the value y.
Example
AIMAG ((4.0, 5.0)) has the value 5.0.
If C is complex, C%IM is the same as AIMAG (C).
The program AIMAG.F90 applies the quadratic formula to a polynomial and allows for complex results:
REAL a, b, c
COMPLEX ans1, ans2, d
WRITE ( *, 100)
100 FORMAT (' Enter A, b, and c of the ', &
'polynomial ax**2 + bx + c: '\)
READ (*, *) a, b, c
d = CSQRT (CMPLX (b**2 - 4.0*a*c)) ! d is either:
! 0.0 + i root, or
! root + i 0.0
ans1 = (-b + d) / (2.0 * a)
ans2 = (-b + d) / (2.0 * a)
WRITE (*, 200)
200 FORMAT (/ ' The roots are:' /)
WRITE (*, 300) REAL(ans1), AIMAG(ans1), &
REAL(ans2), AIMAG(ans2)
300 FORMAT (' X = ', F10.5, ' + i', F10.5)
END
See Also
CONJG
DBLE
AINT
Elemental Intrinsic Function (Generic): Truncates
a value to a whole number.
Syntax
result = AINT (a [,kind])
1198
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is real. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter is that of a.
The result is defined as the largest integer whose magnitude does not exceed the magnitude of a and whose
sign is the same as that of a. If | a | is less than 1, AINT( a) has the value zero.
Example
AINT (3.678) has the value 3.0.
AINT (-1.375) has the value -1.0.
REAL r1, r2
REAL(8) r3(2)
r1 = AINT(2.6) ! returns the value 2.0
r2 = AINT(-2.6) ! returns the value -2.0
r3 = AINT((/1.3, 1.9/), KIND = 8) ! returns the values
! (1.0D0, 1.0D0)
See Also
ANINT
ALARM
Portability Function: Causes a subroutine to begin
execution after a specified amount of time has
elapsed.
Module
USE IFPORT
Syntax
result = ALARM (time,proc)
time (Input) Integer. Specifies the time delay, in seconds, between the call
to ALARM and the time when proc is to begin execution. If time is 0,
the alarm is turned off and no routine is called.
1199
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The return value is INTEGER(4). It is zero if no alarm is pending. If an alarm is pending (has already been
set by a previous call to ALARM), it returns the number of seconds remaining until the previously set alarm is
to go off, rounded up to the nearest second.
After ALARM is called and the timer starts, the calling program continues for time seconds. The calling
program then suspends and calls proc, which runs in another thread. When proc finishes, the alarm thread
terminates, the original thread resumes, and the calling program resets the alarm. Once the alarm goes off,
it is disabled until set again.
If proc performs I/O or otherwise uses the Fortran library, you need to compile it with one of the multithread
libraries.
The thread that proc runs in has a higher priority than any other thread in the process. All other threads are
essentially suspended until proc terminates, or is blocked on some other event, such as I/O.
No alarms can occur after the main process ends. If the main program finishes or any thread executes an
EXIT call, than any pending alarm is deactivated before it has a chance to run.
Example
USE IFPORT
INTEGER(4) numsec, istat
EXTERNAL subprog
numsec = 4
write *, "subprog will begin in ", numsec, " seconds"
ISTAT = ALARM (numsec, subprog)
See Also
RUNQQ
ALIAS Directive
General Compiler Directive: Declares alternate
external names for external subprograms.
Syntax
!DIR$ ALIAS internal-name,external-name
internal-name The name of the entity as used in the current program unit. It can be
a procedure name, a COMMON block name, a module variable that is
initialized, or a PARAMETER in a module. It may not be the name of an
internal procedure.
If a name is specified, the name (in uppercase) is used as the external name for the specified internal-name.
If a character constant is specified, it is used as is; the string is not changed to uppercase, nor are blanks
removed.
The ALIAS directive affects only the external name used for references to the specified internal-name.
Names that are not acceptable to the linker will cause link-time errors.
See Also
ATTRIBUTES ALIAS
ATTRIBUTES DECORATE
ATTRIBUTES DEFAULT
General Compiler Directives
1200
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ALIGNED Clause
Parallel Directive Clause: Specifies that all variables
in a list are aligned.
Syntax
ALIGNED (list [:n])
list Is the name of one or more variables. Each name must be separated
by a comma. Any variable that appears in list cannot appear in more
than one ALIGNED clause.
The ALIGNED clause declares that the location of each list item is aligned to the number of bytes expressed
in the optional alignment parameter n of the ALIGNED clause. If a list item has the ALLOCATABLE attribute,
its allocation status must be allocated. If it has the POINTER attribute, its association status must be
associated. If the type of a list item is type(C_PTR) or a Cray pointer, the item must be defined.
NOTE
Be careful when using the ALIGNED clause. Instructing the compiler to implement all array references
with aligned data movement instructions will cause a runtime exception if some of the access patterns
are actually unaligned.
ALL
Transformational Intrinsic Function (Generic):
Determines if all values are true in an entire array or
in a specified dimension of an array.
Syntax
result = ALL (mask)
result = ALL (mask, dim)
Results
The result is an array or a scalar of type logical.
The result is a scalar if dim is not specified or mask has rank one. A scalar result is true only if all elements
of mask are true, or mask has size zero. The result has the value false if any element of mask is false.
An array result has the same type and kind parameters as mask, and a rank that is one less than mask. Its
shape is (d1, d2, ..., ddim-1, ddim+1, ..., dn), where (d1, d2,..., dn) is the shape of mask.
Each element in an array result is true only if all elements in the one dimensional array defined by mask(s1,
s2, ..., sdim-1, :, sdim+1, ..., sn) are true.
1201
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
LOGICAL mask( 2, 3), AR1(3), AR2(2)
mask = RESHAPE((/.TRUE., .TRUE., .FALSE., .TRUE., .FALSE., &
.FALSE./),(/2,3/))
! mask is true false false
! true true false
AR1 = ALL(mask,DIM = 1) ! evaluates the elements column by
! column yielding [true false false]
AR2 = ALL(mask,DIM = 2) ! evaluates the elements row by row
! yielding [false false].
ALL ((/.TRUE., .FALSE., .TRUE./)) has the value false because some elements of MASK are not true.
ALL ((/.TRUE., .TRUE., .TRUE./)) has the value true because all elements of MASK are true.
A is the array
[ 1 5 7 ]
[ 3 6 8 ]
and B is the array
[ 0 5 7 ]
[ 2 6 9 ].
ALL (A .EQ. B, DIM=1) tests to see if all elements in each column of A are equal to the elements in the
corresponding column of B. The result has the value (false, true, false) because only the second column has
elements that are all equal.
ALL (A .EQ. B, DIM=2) tests to see if all elements in each row of A are equal to the elements in the
corresponding row of B. The result has the value (false, false) because each row has some elements that are
not equal.
See Also
ANY
COUNT
ALLOCATABLE
Statement and Attribute: Specifies that an object is
allocatable. The shape of an allocatable array is
determined when an ALLOCATE statement is
executed, dynamically allocating space for the array. A
character object may have a deferred length that is
determined when the object is allocated with an
ALLOCATE statement. A allocatable scalar object of
any type may be allocated with an ALLOCATE
statement.
Syntax
The ALLOCATABLE attribute can be specified in a type declaration statement or an ALLOCATABLE statement,
and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] ALLOCATABLE [, att-ls] :: a[(d-spec)] [[coarray-spec]][, a[(d-spec)]
[[coarray-spec]]...
Statement:
ALLOCATABLE [::] a[(d-spec)] [[coarray-spec]][, a[(d-spec)] [[coarray-spec]]...
1202
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
A character object declaration uses LEN=: to indicate it is deferred length.
If the array is given the DIMENSION attribute elsewhere in the program, it must be declared as a deferred-
shape array.
When the allocatable object is no longer needed, it can be deallocated by execution of a DEALLOCATE
statement.
An allocatable object cannot be specified in a COMMON, EQUIVALENCE, DATA, or NAMELIST statement.
Allocatable objects are not saved by default. If you want to retain the values of an allocatable object across
procedure calls, you must specify the SAVE attribute for the object.
Example
! Method for declaring and allocating objects.
REAL A, B(:)
ALLOCATABLE :: A(:,:), B
See Also
Type Declarations
Compatible attributes
ALLOCATE
DEALLOCATE
Arrays
Allocation of Allocatable Arrays
1203
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SAVE
ALLOCATE Clause
Directive Clause: Specifies the memory allocator to
be used for one or more private variables or common
blocks of a construct. This feature is only available for
ifx.
Syntax
ALLOCATE ([allocator :] list)
-or-
ALLOCATE (allocator-modifier [, allocator-modifier] : list)
• ALLOCATOR (allocator)
allocator is an integer expression with a kind type of
omp_allocator_handle_kind.
If allocator is not specified, the list items in the clause will be
allocated using the allocator specified by the def-allocator-var
internal control variable (ICV).
At most one ALLOCATOR allocate-modifier is permitted in the
ALLOCATE clause.
• ALIGN (alignment)
alignment is a positive integer scalar expression with a value that
is a positive power of two.
Each list item is allocated with a byte alignment of at least the
maximum of the following:
1.The required alignment specified by Fortran
2.The alignment trait of the specified allocator
3.The alignment value specified by the ALIGN allocate-modifier
If alignment is not specified, each list item is allocated with a byte
alignment of at least the maximum of the following:
1.The required alignment specified by Fortran
2.The alignment trait of the specified allocator
At most one ALIGN allocate-modifier is permitted in the ALLOCATE
clause.
Each list item must appear in a data sharing clause that creates a private copy of the list item in the directive
containing the ALLOCATE clause. The storage for the private copies of an object specified in the list are
allocated using the specified memory allocator.
1204
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An ALLOCATE clause in a TARGET directive or a directive within a TARGET region must specify an allocator
expression unless a REQUIRES directive with the DYNAMIC_ALLOCATORS clause appears in the same
compilation unit.
The result of allocating private variables with a memory allocator whose access trait is set to THREAD by a
TASK, TASKLOOP, or TARGET directive is undefined.
See Also
ALLOCATE Directive
OpenMP* Memory Spaces and Allocators
ALLOCATE Directive
OpenMP* Fortran Compiler Directive: Specifies
memory allocators to use for object allocation and
deallocation. This feature is only available for ifx.
Syntax
!$OMP ALLOCATE (list) [clause [[,] clause]...]
-or-
!$OMP ALLOCATE [(list)] [clause [[,] clause]...]
[!$OMP ALLOCATE (list) [clause [[,] clause]...]
[...]]
ALLOCATE statement
• ALLOCATOR (allocator)
allocator is an integer expression with a kind type of
omp_allocator_handle_kind.
If the ALLOCATOR clause is not specified, the list items in that
directive will be allocated using the allocator specified by the def-
allocator-var internal control variable (ICV).
At most one ALLOCATOR clause is permitted in the ALLOCATE
directive.
• ALIGN (alignment)
alignment is a positive integer scalar expression with a value that
is a positive power of two.
Each list item is allocated with a byte alignment of at least the
maximum of the following:
1.The required alignment specified by Fortran
2.The alignment trait of the specified allocator
3.The alignment value specified by the ALIGN clause
If the ALIGN clause is not specified, each list item is allocated with
a byte alignment of at least the maximum of the following:
1.The required alignment specified by Fortran
2.The alignment trait of the specified allocator
1205
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The first form of the directive is not associated with an ALLOCATE statement. It is a declarative directive and
must appear in the specification part where the list items are declared, and after all declarations of the list
items. The storage for each list item will be allocated by the specified memory allocator and deallocated by
the same memory allocator when the list item goes out of scope.
The list items in a declarative ALLOCATE directive must not have the POINTER or ALLOCATABLE attribute. If a
list item has the SAVE attribute (implicitly or explicitly), is a common block name, or is declared in the scope
of a module or submodule, then the specified allocator must be one of the pre-defined memory allocators.
The list items in a declarative ALLOCATE directive cannot be an array element, a structure component, or a
variable in a common block. The declaration of all list items must be in the same scope as the declarative
ALLOCATE directive and must precede the ALLOCATE directive.
A list item can appear once in a declarative ALLOCATE directive and it can appear in only one declarative
ALLOCATE directive.
The second form of the ALLOCATE directive is associated with an ALLOCATE statement and can appear in the
executable statement part of a subprogram after the first executable statement or OpenMP* construct. It
associates an allocator with each allocate item in the associated ALLOCATE statement. If an ALLOCATE
directive with no list items appears, all the allocate list objects in the ALLOCATE statement that are not listed
in an ALLOCATE directive associated with the same ALLOCATE statement, are allocated by the allocator
specified in the ALLOCATE directive with no list items specified. Multiple ALLOCATE directives with list items
can be specified for an ALLOCATE statement.
A list item can not appear in more than one ALLOCATE directive associated with a given ALLOCATE
statement, or appear more than once in the same directive. Each list item must have the ALLOCATABLE or
POINTER attribute. A list item can be a POINTER or ALLOCATABLE component of a derived type. A list item
cannot be an associate name.
If an object appears as a list item of an ALLOCATE directive, it must also appear in the allocation list of the
associated ALLOCATE statement. When an object is deallocated, it is deallocated using the same allocator
used to allocate it. If an object is deallocated and reallocated during intrinsic assignment, the same allocator
is used for the deallocation and reallocation; otherwise, the allocator specified for a list item is used to
allocate the list item only in the ALLOCATE statement associated with the ALLOCATE directive.
If multiple ALLOCATE directives are associated with an ALLOCATE statement, only one ALLOCATE directive
can appear with no list items.
An ALLOCATOR must be specified in ALLOCATE directives that appear in a TARGET region, unless a
REQUIRES directive with the DYNAMIC_ALLOCATORS clause is specified in the same compilation unit.
When a list item goes out of scope, if it has not been deallocated, it is automatically deallocated with the
same allocator that allocated it.
See Also
ALLOCATE Clause
OpenMP* Memory Spaces and Allocators
ALLOCATE Statement
Statement: Dynamically creates storage for
allocatable variables and pointer targets.
Syntax
ALLOCATE ([type::] object[(s-spec[, s-spec]...)] [, object[(s-spec[, s-spec]...)] ]...
[[coarray-spec]]...[, alloc-opt[, alloc-opt]...])
1206
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
type Is a data type specifier. If specified, the kind type parameters of each
object must be the same as the corresponding type parameter values,
and each object must be type compatible with the specified type. The
type must not have an ultimate subcomponent that is a coarray.
You cannot specify type if you specify SOURCE= or MOLD=.
A type parameter value in type can be an asterisk if and only if each
object is a dummy argument for which the corresponding type
parameter is assumed.
1207
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can specify STAT=, ERRMSG=, and one of MOLD= or SOURCE= in the same ALLOCATE statement. The
keywords can appear in any order.
Description
The storage space allocated is uninitialized unless SOURCE= is specified or the type of the object is default
initialized.
A bound in s-spec must not be an expression containing an array inquiry function whose argument is any
allocatable object in the same ALLOCATE statement; for example, in this code, the last line is not permitted:
INTEGER ERR
INTEGER, ALLOCATABLE :: A(:), B(:)
...
ALLOCATE(A(10:25), B(SIZE(A)), STAT=ERR) ! A is invalid as an argument to function SIZE
If a STAT=stat-var, ERRMSG=err-var, or source-expr is specified, it must not be allocated in the ALLOCATE
statement in which it appears; nor can it depend on the value, bounds, length type parameters, allocation
status, or association status of any object in the same ALLOCATE statement.
1208
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the allocation is successful, the STAT=stat-var becomes defined with the value zero, and the definition
status of the ERRMSG=err-var remains unchanged. If the allocation is not successful, an error condition
occurs, and the STAT=stat-var is set to a positive integer value (representing the run-time error); the
ERRMSG=err-var contains a descriptive message about the error condition.
If the allocation is successful and source-expr is specified, the dynamic type and value of the allocated object
becomes that of the source expression. If the value of a non-deferred length type parameter of object is
different from the value of the corresponding type parameter of source-expr, an error condition occurs.
When an ALLOCATE statement is executed for an object that is a coarray, there is an implicit synchronization
of all images. On each image, execution of the segment following the statement is delayed until all other
images have executed the same statement the same number of times.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images of the current team has initiated normal termination, the STAT=stat-var becomes defined with the
processor-dependent positive integer value of the constant STAT_STOPPED_IMAGE from the intrinsic module
ISO_FORTRAN_ENV. Otherwise, if an allocatable object is a coarray and one or more images of the current
team has failed, the STAT=stat-var becomes defined with the processor-dependent positive integer value of
the constant STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV.
If any other error condition occurs during execution of the ALLOCATE or DEALLOCATE statement, the
STAT=stat-var becomes defined with a processor-dependent positive integer value different from
STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images of the current team has failed, each allocatable object is successfully allocated or deallocated on the
active images of the current team. If any other error occurs, the allocation status of each allocatable object is
processor dependent:
• Successfully allocated allocatable objects have the allocation status of allocated, or associated if the
allocate object is has the POINTER attribute.
• Successfully deallocated allocatable objects have the allocation status of deallocated, or disassociated if
the allocatable object has the POINTER attribute.
• An allocatable object that was not successfully allocated or deallocated has its previous allocation status,
or its previous association status if it has the POINTER attribute.
Example
The following example shows a method for creating and allocating deferred shape arrays:
INTEGER,ALLOCATABLE::matrix(:,:)
REAL, ALLOCATABLE:: vector(:)
. . .
ALLOCATE (matrix(3,5),vector(-2:N+2))
. . .
The following example allocates the scalar objects s and t to be 15 by 25 matrices with the value of r:
INTEGER J, N, ALLOC_ERR
REAL, ALLOCATABLE :: A(:), B(:,:)
...
ALLOCATE(A(0:80), B(-3:J+1, N), STAT = ALLOC_ERR)
1209
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ALLOCATABLE
ALLOCATED
DEALLOCATE
ASSOCIATED
POINTER
Dynamic Allocation
Pointer Assignments
ISO_FORTRAN_ENV Module
ALLOCATED
Inquiry Intrinsic Function (Generic): Indicates
whether an allocatable array or allocatable scalar is
currently allocated.
Syntax
result = ALLOCATED ([ARRAY=]array)
result = ALLOCATED ([SCALAR=]scalar)
Results
The result is a scalar of type default logical.
The result has the value true if argument array or scalar is currently allocated; it has the value false if the
argument is not currently allocated.
NOTE
When the argument keyword ARRAY is used, array must be an allocatable array. When the
argument keyword SCALAR is used, scalar must be an allocatable scalar.
Example
REAL, ALLOCATABLE :: A(:)
...
IF (.NOT. ALLOCATED(A)) ALLOCATE (A (5))
Consider the following:
1210
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ALLOCATABLE
ALLOCATE
DEALLOCATE
Arrays
Dynamic Allocation
ANINT
Elemental Intrinsic Function (Generic): Calculates
the nearest whole number.
Syntax
result = ANINT (a[,kind] )
Results
The result type is real. If kind is present, the kind parameter is that specified by kind; otherwise, the kind
parameter is that of a. If a is greater than zero, ANINT ( a) has the value AINT (a + 0.5); if a is less than or
equal to zero, ANINT (a) has the value AINT (a - 0.5).
Example
ANINT (3.456) has the value 3.0.
ANINT (-2.798) has the value -3.0.
Consider the following:
REAL r1, r2
r1 = ANINT(2.6) ! returns the value 3.0
r2 = ANINT(-2.6) ! returns the value -3.0
1211
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
NINT
ANY
Transformational Intrinsic Function (Generic):
Determines if any value is true in an entire array or in
a specified dimension of an array.
Syntax
result = ANY (mask)
result = ANY (mask, dim)
dim (Input) Must be a scalar integer expression with a value in the range 1
to n, where n is the rank of mask.
Results
The result is an array or a scalar of type logical.
The result is a scalar if dim is not specified or mask has rank one. A scalar result is true if any elements of
mask are true. The result has the value false if no element of mask is true, or mask has size zero.
An array result has the same type and kind parameters as mask, and a rank that is one less than mask. Its
shape is (d1, d2, ..., ddim-1, ddim+1, ..., dn), where (d1, d2, ..., dn) is the shape of mask.
Each element in an array result is true if any elements in the one dimensional array defined by mask(s1,
s2, ..., sdim-1, :, sdim+1, ..., sn) are true.
Example
LOGICAL mask( 2, 3), AR1(3), AR2(2)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
DATA mask /T, T, F, T, F, F/
! mask is true false false
! true true false
AR1 = ANY(mask,DIM = 1) ! evaluates the elements column by
! column yielding [true true false]
AR2 = ANY(mask,DIM = 2) ! evaluates the elements row by row
! yielding [true true]
ANY ((/.FALSE., .FALSE., .TRUE./)) has the value true because one element is true.
A is the array
[ 1 5 7 ]
[ 3 6 8 ]
and B is the array
[ 0 5 7 ]
[ 2 6 9 ].
ANY (A .EQ. B, DIM=1) tests to see if any elements in each column of A are equal to the elements in the
corresponding column of B. The result has the value (false, true, true) because the second and third columns
have at least one element that is equal.
1212
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ANY (A .EQ. B, DIM=2) tests to see if any elements in each row of A are equal to the elements in the
corresponding row of B. The result has the value (true, true) because each row has at least one element that
is equal.
See Also
ALL
COUNT
ASIN
Elemental Intrinsic Function (Generic): Produces
the arcsine of an argument.
Syntax
result = ASIN (x)
Results
The result type and kind are the same as x.
If the result is real, it is expressed in radians and lies in the range - pi/2 <= ASIN (x) <= pi/2.
If the result is complex, the real part is expressed in radians and lies in the range pi/2 <= REAL (ASIN (x))
<= pi/2.
Example
ASIN (0.79345021) has the value 0.9164571.
ASIND
Elemental Intrinsic Function (Generic): Produces
the arcsine of x.
Syntax
result = ASIND (x)
Results
The result type and kind are the same as x and are expressed in degrees. The value lies in the range −90 to
90 degrees.
1213
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
ASIND (0.2467590) has the value 14.28581.
ASINH
Elemental Intrinsic Function (Generic): Produces
the hyperbolic arcsine of x.
Syntax
result = ASINH (x)
Results
The result type and kind are the same as x.
If the result is complex, the imaginary part is expressed in radians and lies in the range - pi/ 2 <= AIMAG
(ASINH (x)) <= pi / 2.
Example
ASINH (1.0) has the value -0.88137.
ASINH (180.0) has the value 5.88611.
Syntax
ASSIGN label TO var
When an ASSIGN statement is executed, the statement label is assigned to the integer variable. The variable
is then undefined as an integer variable and can only be used as a label (unless it is later redefined with an
integer value).
The ASSIGN statement must be executed before the statements in which the assigned variable is used.
1214
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Indirect branching through integer variables makes program flow difficult to read, especially if the integer
variable is also used in arithmetic operations. Using these statements permits inconsistent usage of the
integer variable, and can be an obscure source of error. The ASSIGN statement was used to simulate internal
procedures, which now can be coded directly.
Example
The value of a label is not the same as its number; instead, the label is identified by a number assigned by
the compiler. In the following example, 400 is the label number (not the value) of IVBL:
IVBL = 400
The following example shows ASSIGN statements:
INTEGER ERROR
...
ASSIGN 10 TO NSTART
ASSIGN 99999 TO KSTOP
ASSIGN 250 TO ERROR
Note that NSTART and KSTOP are integer variables implicitly, but ERROR must be previously declared as an
integer variable.
The following statement associates the variable NUMBER with the statement label 100:
NUMBER = NUMBER + 1
To return NUMBER to the status of an integer variable, you can use the following statement:
NUMBER = 10
This statement dissociates NUMBER from statement 100 and assigns it an integer value of 10. Once NUMBER
is returned to its integer variable status, it can no longer be used in an assigned GO TO statement.
See Also
Assignment: intrinsic
Obsolescent Language Features in the Fortran Standard
Syntax
The initial line for such an interface block takes the following form:
INTERFACE ASSIGNMENT (=)
Description
The subroutines within the interface block must have two nonoptional arguments, the first with intent OUT or
INOUT, and the second with intent IN and/or attribute VALUE.
1215
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A defined assignment is treated as a reference to a subroutine. The left side of the assignment corresponds
to the first dummy argument of the subroutine; the right side of the assignment, enclosed in parentheses,
corresponds to the second argument. A defined assignment procedure with an ALLOCATABLE or POINTER
dummy argument cannot be directly invoked through defined assignment; the right-hand side of the
assignment operator becomes an expression, and an expression cannot have the ALLOCATABLE, POINTER, or
TARGET attribute.
The ASSIGNMENT keyword extends or redefines an assignment operation if both sides of the equal sign are
of the same derived type.
Defined elemental assignment is indicated by specifying ELEMENTAL in the SUBROUTINE statement.
Any procedure reference involving generic assignment must be resolvable to one specific procedure; it must
be unambiguous. For more information, see Unambiguous Generic Procedure References.
Example
The following is an example of a procedure interface block defining assignment:
1216
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PROGRAM assign
use mod1
TYPE(CIRCLE) circle1
TYPE(INTERVAL) interval1
INTERFACE ASSIGNMENT(=)
module procedure circle_to_interval
END INTERFACE
!Begin executable part of program
circle1%radius = 2.5
circle1%center_point = (/3.0,5.0/)
interval1 = circle1
. . .
END PROGRAM
See Also
INTERFACE
Assignment Statements
Syntax
variable=expression
expression Is of intrinsic type or the same derived type as variable. Its shape
must conform with variable. If necessary, it is converted to the
same type and kind as variable.
Description
Before a value is assigned to the variable, the expression part of the assignment statement and any
expressions within the variable are evaluated. No definition of expressions in the variable can affect or be
affected by the evaluation of the expression part of the assignment statement.
NOTE
When the run-time system assigns a value to a scalar integer or character variable and the
variable is shorter than the value being assigned, the assigned value may be truncated and
significant bits (or characters) lost. This truncation can occur without warning, and can
cause the run-time system to pass incorrect information back to the program.
If the variable is a pointer, it must be associated with a definable target. The shape of the target and
expression must conform and their type and kind parameters must match.
1217
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the !DIR$ NOSTRICT compiler directive (the default) is in effect, then you can assign a character
expression to a noncharacter variable, and a noncharacter variable or array element (but not an expression)
to a character variable.
Example
REAL a, b, c
LOGICAL abigger
CHARACTER(16) assertion
c = .01
a = SQRT (c)
b = c**2
assertion = 'a > b'
abigger = (a .GT. b)
WRITE (*, 100) a, b
100 FORMAT (' a =', F7.4, ' b =', F7.4)
IF (abigger) THEN
WRITE (*, *) assertion, ' is true.'
ELSE
WRITE (*, *) assertion, ' is false.'
END IF
END
! The program above has the following output:
! a = .1000 b = .0001 a > b is true.
! The following code shows legal and illegal
! assignment statements:
!
INTEGER i, j
REAL rone(4), rtwo(4), x, y
COMPLEX z
CHARACTER name6(6), name8(8)
i = 4
x = 2.0
z = (3.0, 4.0)
rone(1) = 4.0
rone(2) = 3.0
rone(3) = 2.0
rone(4) = 1.0
name8 = 'Hello,'
See Also
Assignment: defined
NOSTRICT directive
1218
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ASSOCIATE
Statement: Marks the beginning of an ASSOCIATE
construct. The ASSOCIATE construct creates a
temporary association between a named entity and a
variable or the value of an expression. The association
lasts for the duration of the block.
Syntax
[name:] ASSOCIATE (assoc-entity[, assoc-entity]...)
block
END ASSOCIATE [name]
Description
If a construct name is specified at the beginning of an ASSOCIATE statement, the same name must appear in
the corresponding END ASSOCIATE statement. The same construct name must not be used for different
named constructs in the same scoping unit. If no name is specified at the beginning of an ASSOCIATE
statement, you cannot specify one following the END ASSOCIATE statement.
During execution of the block within the construct, each associate-name identifies an entity, which is
associated with the corresponding selector. The associating entity assumes the declared type and type
parameters of the selector.
You can only branch to an END ASSOCIATE statement from within its ASSOCIATE construct.
This construct is useful when you want to simplify multiple accesses to a variable that has a lengthy
description; for example, if the variable contains multiple subscripts and component names.
Example
The following shows an expression as a selector:
1219
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Construct Association
Additional Attributes Of Associate Names
ASSOCIATED
Inquiry Intrinsic Function (Generic): Returns the
association status of its pointer argument or indicates
whether the pointer is associated with the target.
Syntax
result = ASSOCIATED (pointer [, target])
pointer (Input) Must be a pointer. It can be of any data type. The pointer
association status must be defined.
Results
The result is a scalar of type default logical. The setting of compiler options specifying integer size can affect
this function.
If only pointer appears, the result is true if it is currently associated with a target; otherwise, the result is
false.
If target also appears and is a target, the result is true if pointer is currently associated with target;
otherwise, the result is false.
If target is a pointer, the result is true if both pointer and target are currently associated with the same
target; otherwise, the result is false. (If either pointer or target is disassociated, the result is false.)
Example
REAL C (:), D(:), E(5)
POINTER C, D
TARGET E
LOGICAL STATUS
C => E ! pointer assignment
D => E ! pointer assignment
STATUS = ASSOCIATED(C) ! returns TRUE; C is associated
STATUS = ASSOCIATED(C, E) ! returns TRUE; C is associated with E
STATUS = ASSOCIATED (C, D) ! returns TRUE; C and D are associated
! with the same target
Consider the following:
1220
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ALLOCATED
POINTER
TARGET
Pointer Assignments
ASSUME
General Compiler Directive: Provides heuristic
information to the compiler optimizer.
Syntax
!DIR$ ASSUME (scalar-Boolean-expression)
At compile time, the scalar-Boolean-expression is always presumed to be true and may be used by the
optimizer to generate better code.
At runtime, the ASSUME directive is evaluated at the point where it is located in the source.
If the check assume option is specified and scalar-Boolean-expression does not evaluate to .TRUE. at run
time, an error message is displayed and execution is aborted. If the check assume option is not specified
and scalar-Boolean-expression does not evaluate to .TRUE. at run time, program behavior is undefined.
Example
In the example below, the compiler is told that A is aligned on a 32-byte boundary using the
ASSUME_ALIGNED directive. The ASSUME directive says that the length of the first dimension of A is a
multiple of 8. Therefore the optimizer knows that A(I,J+1) and A(I,J-1) are 0 mod 64 bytes away from A(I,J)
and are therefore also aligned on 32-byte boundaries. This information helps the optimizer in generating
efficiently vectorized code for these loops.
See Also
General Compiler Directives
1221
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ASSUME_ALIGNED
General Compiler Directive: Specifies that an entity
in memory is aligned.
Syntax
!DIR$ ASSUME_ALIGNED address1:n1 [, address2:n2]...
address An array variable. It can be of any data type, kind, or rank > 0. It can
be an array component of a variable of derived type or a record field
reference, host or use associated, or have the ALLOCATABLE or
POINTER attribute.
It cannot be any of the following:
• An entity in COMMON (or an entity EQUIVALENCEd to something in
COMMON)
• A component of a variable of derived type or a record field
reference
• An entity accessed by use or host association
If it is a module variable, that address is silently ignored.
The ASSUME_ALIGNED directive must appear after the specification statements section or inside the
executable statements section.
If you specify more than one address:n item, they must be separated by a comma.
If address is a Cray POINTER or it has the POINTER attribute, it is the POINTER and not the pointee or the
TARGET that is assumed aligned.
If the check assume option is specified and address is not aligned on an n-byte boundary at run time, an
error message is displayed and execution is aborted.
For more information, see the example in the description of the ASSUME directive.
Example
The following example shows the correct placement and usage of the ASSUME_ALIGNED directive:
SUBROUTINE F(A, N)
TYPE NODE
REAL(KIND=8), POINTER :: A(:,:)
END TYPE NODE
ALLOCATE(NODES)
ALLOCATE(NODES%A(1000,1000))
1222
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ENDDO
…
END
It is illegal to place ASSUME_ALIGNED inside a type definition; for example:
TYPE S
!DIR$ ASSUME_ALIGNED T : 16 ! this is an error
REAL(8), ALLOCATABLE :: T(:)
END TYPE S
See Also
General Compiler Directives
ASYNCHRONOUS
Statement and Attribute: Specifies that a variable
can be used for asynchronous input and output.
Syntax
The ASYNCHRONOUS attribute can be specified in a type declaration statement or an ASYNCHRONOUS
statement, and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] ASYNCHRONOUS [, att-ls] :: var [, var] ...
Statement:
ASYNCHRONOUS [::] var [, var] ...
Description
Asynchronous I/O, or non-blocking I/O, allows a program to continue processing data while the I/O operation
is performed in the background.
A variable can have the ASYNCHRONOUS attribute in a particular scoping unit without necessarily having it in
other scoping units. If an object has the ASYNCHRONOUS attribute, then all of its subobjects also have the
ASYNCHRONOUS attribute.
The ASYNCHRONOUS attribute can also be implied by use of a variable in an asynchronous READ or WRITE
statement.
You can specify variables that are used for asynchronous communication, such as with Message Passing
Interface Standard (MPI). Asynchronous communication has the following restrictions:
• For input, a pending communication affector must not be referenced, become defined, become undefined,
become associated with a dummy argument that has the VALUE attribute, or have its pointer association
status changed.
• For output, a pending communication affector must not be redefined, become undefined, or have its
pointer association status changed.
1223
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
The following example shows how the ASYNCHRONOUS attribute can be applied in an OPEN and READ
statement.
program test
integer, asynchronous, dimension(100) :: array
open (unit=1,file='asynch.dat',asynchronous='YES',&
form='unformatted')
write (1) (i,i=1,100)
rewind (1)
read (1,asynchronous='YES') array
wait(1)
write (*,*) array(1:10)
end
See Also
Type Declarations
Compatible attributes
ATAN
Elemental Intrinsic Function (Generic): Produces
the arctangent of an argument.
Syntax
result = ATAN (x)
result = ATAN (y,x)
x (Input) If y appears, x must be of type real with the same kind type
parameter as y.
If y has the value zero, x must not have the value zero.
If y does not appear, x must be of type real or complex.
Results
The result type and kind are the same as x.
If y appears, the result is the same as the result of ATAN2 (y, x).
If y does not appear, the real part of the result is expressed in radians and lies in the range -pi/2 <= ATAN
(x) <= pi/2.
Example
ATAN (1.5874993) has the value 1.008666.
ATAN (2.679676, 1.0) has the value 1.213623.
1224
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATAN2
Elemental Intrinsic Function (Generic): Produces
an arctangent (inverse tangent). The result is the
principal value of the argument of the nonzero
complex number (x, y).
Syntax
result = ATAN2 (y,x)
x (Input) Must have the same type and kind parameters as y. If y has
the value zero, x cannot have the value zero.
Results
The result type and kind are the same as x and are expressed in radians. The value lies in the range -pi <=
ATAN2 (y, x) <= pi.
If x is not zero, the result is approximately equal to the value of arctan (y/ x).
If y > zero, the result is positive.
If y < zero, the result is negative.
If y is zero and x > zero, the result is y (so for x>0, ATAN2 ((+0.0), x) is +0.0 and ATAN2 ((-0.0), x) is
-0.0).
If y is a positive real zero and x < zero, the result is pi.
If y is a negative real zero and x < zero, the result is -pi.
If x is a positive real zero, the result is pi/2.
If y is a negative real zero, the result is -pi/2.
Example
ATAN2 (2.679676, 1.0) has the value 1.213623.
If Y is an array that has the value
[ 1 1 ]
[ -1 -1 ]
and X is an array that has the value
[ -1 1 ]
[ -1 1 ],
then ATAN2 (Y, X) is
1225
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATAN2D
Elemental Intrinsic Function (Generic): Produces
an arctangent. The result is the principal value of the
argument of the nonzero complex number (x, y).
Syntax
result = ATAN2D (y,x)
x (Input) Must have the same type and kind parameters as y. If y has
the value zero, x cannot have the value zero.
Results
The result type and kind are the same as x and are expressed in degrees. The value lies in the range -180
degrees to 180 degrees. If x zero, the result is approximately equal to the value of arctan (y/ x).
If y > zero, the result is positive.
If y < zero, the result is negative.
If y = zero, the result is zero (if x > zero) or 180 degrees (if x < zero).
If x = zero, the absolute value of the result is 90 degrees.
Example
ATAN2D (2.679676, 1.0) has the value 69.53546.
ATAND
Elemental Intrinsic Function (Generic): Produces
the arctangent of x.
Syntax
result = ATAND (x)
Results
The result type and kind are the same as x and are expressed in degrees between ±90°.
1226
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
ATAND (0.0874679) has the value 4.998819.
ATANH
Elemental Intrinsic Function (Generic): Produces
the hyperbolic arctangent of x.
Syntax
result = ATANH (x)
Results
The result type and kind are the same as x.
If the result is real, it lies in the range -1.0 < ATANH (x) < 1.0.
If the result is complex, the imaginary part is expressed in radians and lies in the range –pi/2 <= AIMAG
(ATANH (x)) <= pi/2.
Example
ATANH (-0.77) has the value -1.02033.
ATANH (0.5) has the value 0.549306.
ATOMIC
OpenMP* Fortran Compiler Directive: Ensures that
a specific memory location is updated atomically. This
prevents the possibility of multiple threads
simultaneously reading and writing the specific
memory location.
Syntax
!$OMP ATOMIC [clause[[[,] clause]...]]
block
[!$OMP END ATOMIC]
1227
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1228
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• statement
• or if CAPTURE is also specified, it can be the following:
1229
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• statement
• capture-statement
The order is not important. capture-statement can appear before
statement.
compare-statement Is as follows:
if (x == e) then
x = d
end
or:
if (x == e) x = d
or if CAPTURE also appears and block contains no capture-statement it
can also be the following:
if (x == e) then
x = d
else
v = x
end if
x = x operator expr
x = expr operator x
x = intrinsic (x, expr-list)
x = intrinsic (expr-list, x)
The following rules apply:
1230
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
intrinsic Is one of the following intrinsic procedures: MAX, MIN, IAND, IOR, or
IEOR.
If x is of size 8, 16, 32, or 64 bits and x is aligned to a multiple of its size, the binding thread set is all
threads on the device. Otherwise, the binding thread set is all threads in the contention group. Atomic
regions enforce exclusive access with respect to other atomic regions that access the same storage location x
among all the threads in the binding thread set without regard to the teams to which the threads belong.
If !$OMP ATOMIC is specified with no atomic-clause, it is the same as specifying !$OMP ATOMIC UPDATE.
If !$OMP ATOMIC CAPTURE is specified, you must include an !$OMP END ATOMIC directive following the
block. Otherwise, the !$OMP END ATOMIC directive is optional.
Note that the following restriction applies to the ATOMIC directive:
• All atomic accesses to the storage locations designated by x throughout the program must have the same
type and type parameters.
The following table describes what happens when you specify one of the values in the atomic-clause in an
ATOMIC construct.
Clause Result
If all of the following conditions are true, the strong flush on entry to the atomic operation is also a RELEASE
flush:
• The atomic-clause is WRITE or UPDATE.
• The atomic operation is not a conditional update for which the comparison fails.
• The effective memory ordering is RELEASE, ACQ_REL, or SEQ_CST.
1231
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If both of the following conditions are true, the strong flush on exit from the atomic operation is also an
ACQUIRE flush:
• The atomic-clause is READ or UPDATE.
• The effective memory ordering is ACQUIRE, ACQ_REL, or SEQ_CST.
Therefore, as the above shows, the effective memory ordering is not RELAXED. RELEASE and ACQUIRE
flushes can be implied and permit synchronization between threads without an explicit FLUSH directive.
Any combination of two or more of these atomic constructs enforces mutually exclusive access to the
locations designated by x.
A race condition exists when two unsynchronized threads access the same shared variable with at least one
thread modifying the variable; this can cause unpredictable results. To avoid race conditions, all accesses of
the locations designated by x that could potentially occur in parallel must be protected with an ATOMIC
construct.
Atomic regions do not guarantee exclusive access with respect to any accesses outside of atomic regions to
the same storage location x even if those accesses occur during a CRITICAL or ORDERED region, while an
OpenMP* lock is owned by the executing task, or during the execution of a REDUCTION clause.
However, other OpenMP* synchronization can ensure the desired exclusive access. For example, a BARRIER
directive following a series of atomic updates to x guarantees that subsequent accesses do not form a race
condition with the atomic accesses.
Example
The following example shows a way to avoid race conditions by using ATOMIC to protect all simultaneous
updates of the location by multiple threads.
Since the ATOMIC directive below applies only to the statement immediately following it, elements of Y are
not updated atomically.
PROGRAM ATOMIC_DEMO
REAL X(1000), Y(10000)
INTEGER INDEX(10000)
1232
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER I
DO I=1,10000
INDEX(I) = MOD(I, 1000) + 1
Y(I) = 0.0
ENDDO
DO I = 1,1000
X(I) = 0.0
ENDDO
CALL SUB(X, Y, INDEX, 10000)
END PROGRAM ATOMIC_DEMO
The following non-conforming example demonstrates the restriction on the ATOMIC construct:
SUBROUTINE ATOMIC_INCORRECT()
INTEGER:: I
REAL:: R
EQUIVALENCE(I,R)
!$OMP PARALLEL
!$OMP ATOMIC UPDATE
I = I + 1
!$OMP ATOMIC UPDATE
R = R + 1.0
! The above is incorrect because I and R reference the same location
! but have different types
!$OMP END PARALLEL
END SUBROUTINE ATOMIC_INCORRECT
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
CRITICAL construct
ORDERED construct
BARRIER directive
FLUSH directive
REDUCTION Clause
Parallel Processing Model for information about Binding Sets
ATOMIC_ADD
Atomic Intrinsic Subroutine (Generic): Performs
atomic addition.
Syntax
CALL ATOMIC_ADD (atom, value [, stat])
value (Input) Must be a scalar integer. The value of value and value + atom
must be representable as integers with kind ATOMIC_INT_KIND.
1233
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_AND
Atomic Intrinsic Subroutine (Generic): Performs
atomic bitwise AND.
Syntax
CALL ATOMIC_AND (atom, value [, stat])
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
1234
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATOMIC_CAS
Atomic Intrinsic Subroutine (Generic): Performs
atomic compare and swap.
Syntax
CALL ATOMIC_CAS (atom, old, compare, new [, stat])
compare (Input) Must be scalar and the same type and kind as atom.
new (Input) Must be scalar and the same type and kind as atom.
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_DEFINE
Atomic Intrinsic Subroutine (Generic): Defines a
variable atomically.
Syntax
CALL ATOMIC_DEFINE (atom, value [, stat])
1235
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_ADD
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and addition.
Syntax
CALL ATOMIC_FETCH_ADD (atom, value, old [, stat])
value (Input) Must be a scalar integer. The value of value and value + atom
must be representable as integers with kind ATOMIC_INT_KIND.
1236
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_AND
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and bitwise AND.
Syntax
CALL ATOMIC_FETCH_AND (atom, value, old [, stat])
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
1237
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATOMIC_FETCH_OR
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and bitwise OR.
Syntax
CALL ATOMIC_FETCH_OR (atom, value, old [, stat])
Example
Consider the following:
ATOMIC_FETCH_OR (N[4], 9, M)
If the value of N on image 4 is 4 when the atomic operation is initiated, N on image 4 is defined with the
value 13, and M is defined with the value 4 when the operation completes and no error occurs during the
subroutine reference.
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_FETCH_XOR
Atomic Intrinsic Subroutine (Generic): Performs
atomic fetch and bitwise exclusive OR.
Syntax
CALL ATOMIC_FETCH_XOR (atom, value, old [, stat])
1238
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_OR
Atomic Intrinsic Subroutine (Generic): Performs
atomic bitwise OR.
Syntax
CALL ATOMIC_OR (atom, value [, stat])
Example
Consider the following:
1239
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_REF
Atomic Intrinsic Subroutine (Generic): Lets you
reference a variable atomically.
Syntax
CALL ATOMIC_REF (value, atom [, stat])
value (Output) Must be a scalar and of the same type as atom. If its kind is
the same as that of atom or its type is logical, it becomes defined with
the value of atom. Otherwise, it is defined with the value of
INT(ATOM, KIND (VALUE)).
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATOMIC_XOR
Atomic Intrinsic Subroutine (Generic): Performs
atomic bitwise exclusive OR.
Syntax
CALL ATOMIC_XOR (atom, value [, stat])
1240
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Atomic Subroutines
ISO_FORTRAN_ENV Module
ATTRIBUTES
General Compiler Directive: Declares properties for
specified variables.
Syntax
!DIR$ ATTRIBUTES att[,att]...:: object[,object]...
C IGNORE_LOC VARYING
CONCURRENCY_SAF MIXED_STR_LEN_AR
E G
CVF NO_ARG_CHECK
DECORATE NOCLONE
DEFAULT NOINLINE
The following table shows which ATTRIBUTES options can be used with various objects:
1241
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ALIGN Yes No No
ALLOCATABLE Yes2 No No
ALLOW_NULL Yes No No
C No Yes Yes
CODE_ALIGN No No Yes5, 6
CONCURRENCY_SAFE No No Yes
DECORATE No No Yes
EXTERN Yes No No
FASTMEM Yes No No
FORCEINLINE No No Yes
IGNORE_LOC Yes4 No No
INLINE No No Yes
MIXED_STR_LEN_ARG No No Yes
NOCLONE No No Yes
NOINLINE No No Yes
OPTIMIZATION_PARAME No No Yes5, 6
TER
VALUE Yes No No
VARYING No No Yes
VECTOR No No Yes5
1A common block name is specified as [/]common-block-name[/]
2This option can only be applied to arrays.
1242
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
These options can be used in function and subroutine definitions, in type declarations, and with the
INTERFACE and ENTRY statements.
Options applied to entities available through use or host association are in effect during the association. For
example, consider the following:
MODULE MOD1
INTERFACE
SUBROUTINE NEW_SUB
!DIR$ ATTRIBUTES C, ALIAS:'othername' :: NEW_SUB
END SUBROUTINE
END INTERFACE
CONTAINS
SUBROUTINE SUB2
CALL NEW_SUB
END SUBROUTINE
END MODULE
In this case, the call to NEW_SUB within SUB2 uses the C and ALIAS options specified in the interface block.
Options C, STDCALL, REFERENCE, VALUE, and VARYING affect the calling conventions of routines:
• You can specify C, STDCALL, REFERENCE, and VARYING for an entire routine.
• You can specify VALUE and REFERENCE for individual arguments.
Examples
INTERFACE
SUBROUTINE For_Sub (I)
!DIR$ ATTRIBUTES C, ALIAS:'_For_Sub' :: For_Sub
INTEGER I
END SUBROUTINE For_Sub
END INTERFACE
You can assign more than one option to multiple variables with the same compiler directive. All assigned
options apply to all specified variables. For example:
1243
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SUBROUTINE ARRAYTEST(arr)
!DIR$ ATTRIBUTES DLLEXPORT :: ARRAYTEST
REAL(4) arr(3, 7)
INTEGER i, j
DO i = 1, 3
DO j = 1, 7
arr (i, j) = 11.0 * i + j
END DO
END DO
END SUBROUTINE
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Programming with Mixed Languages
ATTRIBUTES ALIAS
The ATTRIBUTES directive option ALIAS specifies an
alternate external name to be used when referring to
external subprograms.
Syntax
!DIR$ ATTRIBUTES ALIAS: external-name:: subprogram
The ALIAS option overrides the C (and STDCALL) option. If both C and ALIAS are specified for a subprogram,
the subprogram is given the C calling convention, but not the C naming convention. It instead receives the
name given for ALIAS, with no modifications.
ALIAS cannot be used with internal procedures, and it cannot be applied to dummy arguments.
The following example gives the subroutine happy the name "_OtherName@4" outside this scoping unit:
INTERFACE
SUBROUTINE happy(i)
!DIR$ ATTRIBUTES STDCALL, DECORATE, ALIAS:'OtherName' :: happy
INTEGER i
END SUBROUTINE
END INTERFACE
!DIR$ ATTRIBUTES ALIAS has the same effect as the !DIR$ ALIAS directive.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES DECORATE
ATTRIBUTES ALIGN
The ATTRIBUTES directive option ALIGN specifies the
byte alignment for variables and for allocatable or
pointer components of derived types.
1244
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ ATTRIBUTES ALIGN: n:: object
Objects that can be aligned by this directive include static local variables, automatic variables, module
variables, dynamically allocated arrays, allocatable array components of derived types, and the start of
common blocks. This directive cannot be used to align variables within common blocks
If you specify directive !DIR$ ATTRIBUTES ALIGN on an object with the ALLOCATABLE or POINTER attribute,
an ALLOCATE statement will attempt to use that alignment when the memory is allocated.
For allocatable or pointer components of derived types, the directive must appear within the derived-type
TYPE…END TYPE block.
If the TYPE is an extended type, the directive cannot reference a component in the parent type.
Example
Consider the following:
TYPE EXAMPLE
!DIR$ ATTRIBUTES ALIGN : 64 :: R_alloc
REAL, ALLOCATABLE :: R_alloc ( : )
REAL :: R_scalar
INTEGER :: I_nonalloc(25)
END TYPE EXAMPLE
See Also
ATTRIBUTES
ASSUME_ALIGNED directive
align compiler option (see setting arraynbyte)
Syntax Rules for Compiler Directives
1245
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ATTRIBUTES ALLOCATABLE
The ATTRIBUTES directive option ALLOCATABLE is
provided for compatibility with older programs. It lets
you delay allocation of storage for a particular
declared entity until some point at run time when you
explicitly call a routine that dynamically allocates
storage for the entity.
Syntax
!DIR$ ATTRIBUTES ALLOCATABLE :: entity
entity Is the name of the entity that should have allocation delayed.
The recommended method for dynamically allocating storage is to use the ALLOCATABLE statement or
attribute.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES ALLOW_NULL
The ATTRIBUTES directive option ALLOW_NULL
enables a corresponding dummy argument to pass a
NULL pointer (defined by a zero or the NULL intrinsic)
by value for the argument.
Syntax
!DIR$ ATTRIBUTES ALLOW_NULL :: arg
ALLOW_NULL is only valid if ATTRIBUTES REFERENCE is also specified; otherwise, it has no effect.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
Syntax
!DIR$ ATTRIBUTES C :: object[, object] ...
!DIR$ ATTRIBUTES STDCALL :: object[, object] ...
On Windows* systems on IA-32 architecture, C and STDCALL have slightly different meanings; on all other
platforms, STDCALL is treated as C.
When applied to a subprogram, these options define the subprogram as having a specific set of calling
conventions. The effects depend on whether or not the subprogram is interoperable (has the BIND attribute).
For interoperable subprograms with the BIND attribute, ATTRIBUTES STDCALL has the following effects for
subprograms in applications targeting Windows systems on IA-32 architecture:
1246
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The STDCALL calling convention is used where the called subprogram cleans up the stack at exit.
• The external name has @n appended, where n is the number of bytes of arguments pushed on the stack.
No other effects of ATTRIBUTES STDCALL are applied for interoperable subprograms. If pass-by-value is
desired for a dummy argument to an interoperable subprogram, the Fortran standard VALUE attribute should
be specified for that argument.
For platforms other than Windows systems on IA-32 architecture, ATTRIBUTES STDCALL has no effect on
interoperable subprograms. You should not specify ATTRIBUTES C for interoperable subprograms.
The following table and subsequent text summarizes the differences between the calling conventions for
subprograms that are not interoperable:
Convention C 1 STDCALL 1 Default 2
Case of external L*X, M*X: Lowercase L*X, M*X: Lowercase L*X, M*X: Lowercase
subprogram names
W*S: Lowercase W*S: Lowercase W*S: Uppercase
M*X only:
W*S only:
If C or STDCALL is specified for a subprogram, arguments (except for arrays and characters) are passed by
value. Subprograms using standard Fortran conventions pass arguments by reference.
On IA-32 architecture, an underscore ( _ ) is placed at the beginning of the external name of a subprogram.
If STDCALL is specified, an at sign (@) followed by the number of argument bytes being passed is placed at
the end of the name. For example, a subprogram named SUB1 that has three INTEGER(4) arguments and is
defined with STDCALL is assigned the external name _sub1@12.
Character arguments are passed as follows:
1247
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• By default, hidden lengths are put at the end of the argument list.
On Windows* systems using IA-32 architecture, you can get Compaq* Visual Fortran default behavior by
specifying compiler option iface.
• If C or STDCALL (only) is specified:
On all systems, the first character of the string is passed (and padded with zeros out to INTEGER(4)
length).
• If C or STDCALL is specified, and REFERENCE is specified for the argument:
On all systems, the string is passed with no length.
• If C or STDCALL is specified, and REFERENCE is specified for the routine (but REFERENCE is not specified
for the argument, if any):
On all systems, the string is passed with the length.
See Also
ATTRIBUTES
REFERENCE
BIND
Syntax Rules for Compiler Directives
iface compiler option
Compiler Reference section: Mixed Language Programming
ATTRIBUTES CODE_ALIGN
The ATTRIBUTES directive option CODE_ALIGN
specifies the byte alignment for a procedure.
Syntax
!DIR$ ATTRIBUTES CODE_ALIGN: n:: procedure-name
This directive can be affected by compiler option -falign-loops (Linux* and macOS) or /Qalign-loops
(Windows*), the CODE_ALIGN directive, and the CODE_ALIGN attribute.
If code is compiled with the -falign-loops=m (Linux and macOS) or /Qalign-loops:m (Windows) option
and a procedure has the CODE_ALIGN:k attribute, the procedure is aligned on a MAX (m, k) byte boundary.
If a procedure has the CODE_ALIGN:k attribute and a CODE_ALIGN:n directive precedes a loop, then both
the procedure and the loop are aligned on a MAX (k, n) byte boundary.
Example
Consider the following code fragment in file test_align.f90:
FUNCTION F ()
!DIR$ ATTRIBUTES CODE_ALIGN:32 :: F
…
!DIR$ CODE_ALIGN:16
DO J = 1, N
…
1248
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END DO
…
END FUNCTION F
Compiling test_align.f90 with option -falign-loops=64 (Linux and macOS) or /Qalign-loops:64
(Windows) aligns the function F and the DO J loop on 64-byte boundaries.
See Also
ATTRIBUTES
CODE_ALIGN directive
falign-loops, Qalign-loops compiler option
Syntax Rules for Compiler Directives
ATTRIBUTES CONCURRENCY_SAFE
The ATTRIBUTES directive option
CONCURRENCY_SAFE specifies that there are no
unacceptable side effects and no illegal (or improperly
synchronized) memory access interferences among
multiple invocations of a routine or between an
invocation of the specified routine and other
statements in the program if they were executed
concurrently.
Syntax
!DIR$ ATTRIBUTES CONCURRENCY_SAFE [: clause] :: routine-name-list
When a CONCURRENCY_SAFE routine is called from parallelized code, you can ignore assumed cross-block or
cross-iteration dependencies and side effects of calling the specified routine from parallelized code.
The profitable clause indicates that the loops or blocks that contain calls to the routine can be safely
executed in parallel if the loop or blocks are legal to be parallelized; that is, if it is profitable to parallelize
them.
The cost clause indicates the execution cycles of the routine where the compiler can perform parallelization
profitability analysis while compiling its enclosing loops or blocks.
The attribute can appear in the declaration of the routine; for example:
function f(x)
!DIR$ attributes concurrency_safe :: f
The attribute can also appear in the code of the caller; for example:
main m
integer f
external f
!dir$ attributes concurrency_safe :: f ! or it could be in an interface block describing f
...
Print *, f(x)
1249
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
For every routine named in routine-name-list, you should ensure that any possible side effects are
acceptable or expected, and the memory access interferences are properly synchronized.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES CVF
The ATTRIBUTES direction option CVF tells the
compiler to use calling conventions compatible with
Compaq Visual Fortran* and Microsoft Fortran
PowerStation.
Syntax
!DIR$ ATTRIBUTES CVF :: object[, object] ...
See Also
ATTRIBUTES
ATTRIBUTES DECORATE
The ATTRIBUTES directive option DECORATE specifies
that the external name used in !DIR$ ALIAS or !DIR$
ATTRIBUTES ALIAS should have the prefix and postfix
decorations performed on it that are associated with
the platform and calling mechanism that is in effect.
These are the same decorations performed on the
procedure name when ALIAS is not specified, except
that, on Linux* and macOS systems, DECORATE does
not add a trailing underscore signifying a Fortran
procedure.
Syntax
!DIR$ ATTRIBUTES DECORATE :: exname
1250
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES ALIAS
The summary of prefix and postfix decorations in the description of the ATTRIBUTES options C and
STDCALL
ATTRIBUTES DEFAULT
The ATTRIBUTES directive option DEFAULT overrides
certain compiler options that can affect external
routine and COMMON block declarations.
Syntax
c!DIR$ ATTRIBUTES DEFAULT :: entity
It specifies that the compiler should ignore compiler options that change the default conventions for external
symbol naming and argument passing for routines and COMMON blocks (such as names, assume underscore,
assume 2underscores on Linux systems, and iface on Windows* systems).
This option can be combined with other ATTRIBUTES options, such as STDCALL, C, REFERENCE, ALIAS, etc.
to specify properties different from the compiler defaults.
This option is useful when declaring INTERFACE blocks for external routines, since it prevents compiler
options from changing calling or naming conventions.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
iface compiler option
names compiler option
assume compiler option
Syntax
!DIR$ ATTRIBUTES DLLEXPORT :: object[, object] ...
!DIR$ ATTRIBUTES DLLIMPORT :: object[, object] ...
DLLEXPORT and DLLIMPORT define the interface for the following dynamic-link libraries:
• DLL on Windows*
• DYLIB on macOS
1251
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DLLEXPORT specifies that procedures or data are being exported to other applications or dynamic libraries.
This causes the compiler to produce efficient code; for example, eliminating the need on Windows systems
for a module definition (.def) file to export symbols.
DLLEXPORT should be specified in the routine to which it applies. If the routine's implementation is in a
submodule, specify DLLEXPORT in the parent module's INTERFACE block for the routine. If MODULE
PROCEDURE is used in the submodule, the DLLEXPORT attribute will be inherited; otherwise you must also
specify DLLEXPORT in the submodule routine.
Symbols defined in a DLL are imported by programs that use them. On Windows*, the program must link
with the DLL import library (.lib).
The DLLIMPORT option is used inside the program unit that imports the symbol. DLLIMPORT is specified in a
declaration, not a definition, since you cannot define a symbol you are importing.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES EXTERN
The ATTRIBUTES directive option EXTERN specifies
that a variable is allocated in another source file.
EXTERN can be used in global variable declarations,
but it must not be applied to dummy arguments.
Syntax
!DIR$ ATTRIBUTES EXTERN :: var
This option must be used when accessing variables declared in other languages.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
Syntax
The INLINE option specifies that a function or subroutine can be inlined. The inlining can be ignored by the
compiler if inline heuristics determine it may have a negative impact on performance or will cause too much
of an increase in code size.
!DIR$ ATTRIBUTES INLINE :: procedure
The FORCEINLINE option specifies that a function or subroutine must be inlined unless it will cause errors.
1252
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES IGNORE_LOC
The ATTRIBUTES directive option IGNORE_LOC
enables %LOC to be stripped from an argument.
Syntax
!DIR$ ATTRIBUTES IGNORE_LOC :: arg
IGNORE_LOC is only valid if ATTRIBUTES REFERENCE is also specified; otherwise, it has no effect.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
Syntax
!DIR$ ATTRIBUTES MIXED_STR_LEN_ARG :: procs
!DIR$ ATTRIBUTES NOMIXED_STR_LEN_ARG :: procs
See Also
ATTRIBUTES directive
Syntax Rules for Compiler Directives
iface compiler option
ATTRIBUTES NO_ARG_CHECK
The ATTRIBUTES directive option NO_ARG_CHECK
specifies that type and shape matching rules related
to explicit interfaces are to be ignored. This permits
the construction of an INTERFACE block for an
1253
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ ATTRIBUTES NO_ARG_CHECK :: object
NO_ARG_CHECK can appear only in an INTERFACE block for a non-generic procedure or in a module
procedure. It can be applied to an individual dummy argument name or to the routine name, in which case
the option is applied to all dummy arguments in that interface.
NO_ARG_CHECK cannot be used for procedures with the PURE or ELEMENTAL prefix.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES NOCLONE
The ATTRIBUTES directive option NOCLONE can be
used to prevent a procedure from being considered for
cloning, which is a mechanism performed by
interprocedural constant propagation that produces
specialized copies of the procedure.
Syntax
!DIR$ ATTRIBUTES NOCLONE :: procedure
Note that if you specify ATTRIBUTES NOINLINE, it does not prevent this cloning.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES INLINE
ATTRIBUTES OPTIMIZATION_PARAMETER
The ATTRIBUTES directive option
OPTIMIZATION_PARAMETER passes certain
information about a procedure or main program to the
optimizer.
Syntax
!DIR$ ATTRIBUTES OPTIMIZATION_PARAMETER: string::{ procedure-name | named-main-program}
• TARGET_ARCH= cpu
Tells the compiler to generate code specialized for a particular
processor. For the list of cpus you can specify, see option [Q]x.
• G2S = {ON | OFF}
1254
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The characters in string can appear in any combination of uppercase and lowercase. The following rules also
apply to string:
• If string does not contain an equal sign (=), then the entire value of string is converted to lowercase
before being passed to the optimizer.
• If string contains an equal sign, then all characters to the left of the equal sign are converted to lowercase
before all of string is passed to the optimizer.
Characters to the right of the equal sign are not converted to lowercase since their value may be case
sensitive to the optimizer, for example “target_arch=AVX”.
You can specify multiple ATTRIBUTES OPTIMIZATION_PARAMETER directives for one procedure or one main
program.
For the named procedure or main program, the values specified for ATTRIBUTES OPTIMIZATION_PARAMETER
override any settings specified for the following compiler options:
1255
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• [Q]inline-max-per-routine
• [Q]inline-max-total-size
Example
Consider the two attributes optimization_parameter directives in the following code:
function f (x)
!dir$ attributes optimization_parameter: “inline_max_per_routine=10” :: f
!dir$ attributes optimization_parameter: “inline_max_total_size=2000” :: f
real :: f, x
…
The two directives have the same effect as if the function F had been complied with
"/Qinline-max-per-routine:10 /Qinline-max-total-size:2000" on Windows* or with
"-inline-max-per-routine=10 -inline-max-total-size=2000" on Linux* or macOS, that is, inlining
will not increase the size of F by more than 2000 and the inliner will not inline routines into F more than 10
times.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
x, Qx compiler option
inline-max-per-routine, Qinline-max-per-routine compiler option
inline-max-total-size, Qinline-max-total-size compiler option
Syntax
!DIR$ ATTRIBUTES REFERENCE :: arg
!DIR$ ATTRIBUTES VALUE :: arg
REFERENCE specifies a dummy argument's memory location is to be passed instead of the argument's value.
VALUE specifies a dummy argument's value is to be passed instead of the argument's memory location.
When VALUE is specified for a dummy argument, the actual argument passed to it can be of a different type.
If necessary, type conversion is performed before the subprogram is called.
When a complex (KIND=4 or KIND=8) argument is passed by value, two floating-point arguments (one
containing the real part, the other containing the imaginary part) are passed by immediate value.
Character values, substrings, assumed-size arrays, and adjustable arrays cannot be passed by value.
If REFERENCE (only) is specified for a character argument, the string is passed with no length.
If REFERENCE is specified for a character argument, and C (or STDCALL) has been specified for the routine,
the string is passed with no length. This is true even if REFERENCE is also specified for the routine.
If REFERENCE and C (or STDCALL) are specified for a routine, but REFERENCE has not been specified for the
argument, the string is passed with the length.
VALUE is the default if the C or STDCALL option is specified in the subprogram definition.
1256
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
C and STDCALL
ATTRIBUTES
Syntax Rules for Compiler Directives
Mixed Language Programming: Adjusting Calling Conventions in Mixed-Language Programming Overview
ATTRIBUTES VARYING
The ATTRIBUTES directive option VARYING allows a
Fortran routine to call a C/C++ routine with a variable
number of arguments.
Syntax
!DIR$ ATTRIBUTES VARYING :: var[, var] ...
This attribute can be used in an interface block to create an explicit interface for a C/C++ routine or it can be
used on a variable declared EXTERN that represents a C/C++ routine. When the routine is called from the
Fortran code, a variable number of arguments can be specified.
This attribute cannot be used with a Fortran routine declaration.
If ATTRIBUTES VARYING is specified, the C calling convention must also be used, either implicitly or explicitly.
All actual arguments in the routine call are passed to the called routine, regardless of the number of dummy
arguments specified in the interface. If the called routine tries to access a dummy argument that has no
matching actual argument, it causes a user error and the program may fail unpredictably.
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
ATTRIBUTES VECTOR
The ATTRIBUTES directive option VECTOR tells the
compiler to vectorize the specified function or
subroutine.
Syntax
!DIR$ ATTRIBUTES [att,] VECTOR [:clause] [, att]... :: routine-name
!DIR$ ATTRIBUTES [att,] VECTOR :(clause [, clause]...) [, att] :: routine-name
1257
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Tells the compiler that the values of the specified arguments can be
broadcasted to all iterations as a performance optimization.
Multiple UNIFORM clauses are merged as a union.
• VECTORLENGTH (n[, n]…)
Tells the compiler that each routine invocation at the call site
should execute the computation equivalent to n times the scalar
function execution.
The VECTORLENGTH and VECTORLENGTHFOR clauses are mutually
exclusive. You cannot use the VECTORLENGTH clause with the
VECTORLENGTHFOR clause, and vice versa.
Multiple VECTORLENGTH clauses cause a syntax error.
• VECTORLENGTHFOR (data-type)
INTEGER(1) INTEGER
(KIND=1)
INTEGER(2) INTEGER
(KIND=2)
1258
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(4) INTEGER
(KIND=4)
INTEGER(8) INTEGER
(KIND=8)
COMPLEX(4) COMPLEX
(KIND=4)
COMPLEX(8) COMPLEX
(KIND=8)
If you specify more than one clause, they must be separated by commas and enclosed in parentheses.
When you specify the ATTRIBUTES VECTOR directive, the compiler provides data parallel semantics by
combining with the vectorized operations or loops at the call site. When multiple instances of the vector
declaration are invoked in a parallel context, the execution order among them is not sequenced. If you
specify one or more clauses, they affect the data parallel semantics provided by the compiler.
1259
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify the ATTRIBUTES VECTOR directive with no VECTORLENGTH clause, a default VECTORLENGTH is
computed based on efficiency heuristics of the vectorizer and the following:
• The return type of the function, if the function has a return type.
• The data type of the first non-scalar argument (that is, the first argument that is specified in the scalar
clause), if any.
• Default integer type, if neither of the above is supplied.
If you do not explicitly specify a VECTORLENGTH clause, the compiler will choose a VECTORLENGTH using its
own cost model.
If you specify the ATTRIBUTES VECTOR directive with no clause, the compiler will generate vector code based
on compiler efficiency heuristics and whatever processor compiler options are specified.
The VECTOR attribute implies the C attribute, so that when you specify the VECTOR attribute on a routine,
the C attribute is automatically also set on the same routine. This changes how the routine name is
decorated and how arguments are passed.
NOTE
You should ensure that any possible side effects for the specified routine-name are acceptable or
expected, and the memory access interferences are properly synchronized.
The Fortran Standard keyword ELEMENTAL specifies that a procedure written with scalar arguments can be
extended to conforming array arguments by processing the array elements one at a time in any order. The
ATTRIBUTES VECTOR directive tells the optimizer to produce versions of the procedure routine-name that
execute with contiguous slices of the array arguments as defined by the VECTORLENGTH clause in an
"elemental" fashion. routine-name does not need to be defined as ELEMENTAL to be given the VECTOR
attribute.
The VECTOR attribute causes the compiler to generate a short vector form of the procedure, which can
perform the procedure's operation on multiple elements of its array arguments in a single invocation. The
short vector version may be able to perform multiple operations as fast as the regular implementation
performs a single operation by using the vector instruction set in the CPU.
In addition, when invoked from an OMP construct, the compiler may assign different copies of the elemental
procedures to different threads, executing them concurrently. The end result is that your data parallel
operation executes on the CPU using both the parallelism available in the multiple cores and the parallelism
available in the vector instruction set. If the short vector procedure is called inside a parallel loop or an auto-
parallelized loop that is vectorized, you can achieve both vector-level and thread-level parallelism.
The INTENT(OUT) or INTENT(INOUT) attribute is not allowed for arguments of a procedure with the VECTOR
attribute since the VECTOR attribute forces the procedure to receive its arguments by value.
The Intel C/C++ compiler built in function __intel_simd_lane() may be helpful in removing certain
performance penalties caused by non-unit stride vector access. Consider the following:
interface
! returns a number between 0 and vectorlength – 1 that reflects the current “lane id” within the
SIMD vector
! __intel_simd_lane() will return zero if the loop is not vectorized
function for_simd_lane () bind (C, name = “__intel_simd_lane”)
integer (kind=4) :: for_simd_lane
!DEC$ attributes known_intrinsic, default :: for_simd_lane
end function for_simd_lane
end interface
For more details, see the Intel C++ documentation.
1260
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
Example
The ATTRIBUTES VECTOR directive must be accessible in the caller, either via an INTERFACE block or by USE
association.
The following shows an example of an external function with an INTERFACE block:
function f(x)
!dir$ attributes vector :: f
real :: f, x
...
! attribute vector explicit in calling procedure using an INTERFACE
interface
function f(x)
!dir$ attributes vector :: f
real :: f, x
end
end interface
...
do i=1,n
z(i) = f( x(i) )
end do
The ATTRIBUTES VECTOR directive can be brought into the caller by USE association if the vector function is
a module procedure; for example:
module use_vect
contains
function f(x)
!dir$ attributes vector :: f
real :: f, x
...
end function
end module use_vect
! USE and call of f(x) from another procedure with a module USE statement
do i=1,n
z(i) = f( x(i) )
end do
1261
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can specify more than one SCALAR or LINEAR clause in an ATTRIBUTES VECTOR directive. For example,
all of the following are valid:
See Also
ATTRIBUTES
Syntax Rules for Compiler Directives
AUTOMATIC
Statement and Attribute: Controls the storage
allocation of variables in subprograms (as does
STATIC). Variables declared as AUTOMATIC and
allocated in memory reside in the stack storage area,
rather than at a static memory location.
Syntax
The AUTOMATIC attribute can be specified in a type declaration statement or an AUTOMATIC statement, and
takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] AUTOMATIC [, att-ls] :: v[, v] ...
Statement:
AUTOMATIC [::] v[, v] ...
1262
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
By default, the compiler allocates local scalar variables on the stack. Other non-allocatable variables of non-
recursive subprograms are allocated in static storage by default. This default can be changed through
compiler options. Appropriate use of the SAVE attribute may be required if your program assumes that local
variables retain their definition across subprogram calls.
To change the default for variables, specify them as AUTOMATIC or specify RECURSIVE (in one of the ways
mentioned above).
To override any compiler option that may affect variables, explicitly specify the variables as AUTOMATIC.
NOTE
Variables that are data-initialized, and variables in COMMON and SAVE statements are always static.
This is regardless of whether a compiler option specifies recursion.
A variable cannot be specified as AUTOMATIC more than once in the same scoping unit.
If the variable is a pointer, AUTOMATIC applies only to the pointer itself, not to any associated target.
Some variables cannot be specified as AUTOMATIC. The following table shows these restrictions:
Variable AUTOMATIC
Dummy argument No
Automatic object No
Use-associated item No
Function result No
Example
The following example shows a type declaration statement specifying the AUTOMATIC attribute:
REAL, AUTOMATIC :: A, B, C
The following example uses an AUTOMATIC statement:
...
CONTAINS
INTEGER FUNCTION REDO_FUNC
INTEGER I, J(10), K
REAL C, D, E(30)
AUTOMATIC I, J, K(20)
STATIC C, D, E
...
END FUNCTION
...
C In this example, all variables within the program unit
C are saved, except for "var1" and "var3". These are
C explicitly declared in an AUTOMATIC statement, and thus have
C memory locations on the stack:
1263
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Compatible attributes
RECURSIVE
OPTIONS
POINTER
Modules and Module Procedures
BACKSPACE
Statement: Positions a sequential file at the
beginning of the preceding record, making it available
for subsequent I/O processing. It takes one of the
following forms:
Syntax
BACKSPACE ([UNIT=]io-unit[, ERR=label] [, IOMSG=msg-var] [, IOSTAT=i-var])
BACKSPACE io-unit
label Is the label of the branch target statement that receives control if an
error occurs.
Description
The I/O unit number must specify an open file on disk or magnetic tape.
Backspacing from the current record n is performed by rewinding to the start of the file and then performing
n - 1 successive READs to reach the previous record.
A BACKSPACE statement must not be specified for a file that is open for direct or append access, because n
is not available to the Fortran I/O system.
BACKSPACE cannot be used to skip over records that have been written using list-directed or namelist
formatting.
If a file is already positioned at the beginning of a file, a BACKSPACE statement has no effect.
If the file is positioned between the last record and the end-of-file record, BACKSPACE positions the file at
the start of the last record.
1264
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
BACKSPACE 5
BACKSPACE (5)
BACKSPACE lunit
BACKSPACE (UNIT = lunit, ERR = 30, IOSTAT = ios)
The following statement repositions the file connected to I/O unit 4 back to the preceding record:
BACKSPACE 4
Consider the following statement:
See Also
REWIND
ENDFILE
Data Transfer I/O Statements
Branch Specifiers
BADDRESS
Inquiry Intrinsic Function (Generic): Returns the
address of an argument. This function cannot be
passed as an actual argument. This function can also
be specified as IADDR.
Syntax
result = BADDRESS (x)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the
result represents the address of the data object or, in the case of pointers, the address of its associated
target. If the argument is not valid, the result is undefined.
Example
PROGRAM batest
INTEGER X(5), I
DO I=1, 5
PRINT *, BADDRESS(X(I))
END DO
END
1265
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BARRIER
OpenMP* Fortran Compiler Directive:
Synchronizes all the threads in a team. It causes each
thread to wait until all of the other threads in the
team have reached the barrier.
Syntax
!$OMP BARRIER
The binding thread set for a BARRIER construct is the current team. A barrier region binds to the innermost
enclosing parallel region.
Each barrier region must be encountered by all threads in a team or by none at all, unless cancellation has
been requested for the innermost enclosing parallel region.
The barrier region must also be encountered in the same order by all threads in a team.
Example
INTEGER K
K = 17
!$OMP BARRIER
IF (OMP_GET_THREAD_NUM() == 0) THEN
PRINT *,"2: THREAD# ", OMP_GET_THREAD_NUM (), "K = ", K
ELSE
PRINT *,"3: THREAD# ", OMP_GET_THREAD_NUM (), "K = ", K
ENDIF
!$OMP END PARALLEL
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Nesting and Binding Rules
Parallel Processing Model for information about Binding Sets
BEEPQQ
Portability Subroutine: Sounds the speaker at the
specified frequency for the specified duration in
milliseconds.
Module
USE IFPORT
1266
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL BEEPQQ (frequency,duration)
Example
USE IFPORT
INTEGER(4) frequency, duration
frequency = 4000
duration = 1000
CALL BEEPQQ(frequency, duration)
See Also
SLEEPQQ
Module
USE IFPORT
Syntax
result = BESJ0 (value)
result = BESJ1 (value)
result = BESJN (n, value)
result = BESY0 (posvalue)
result = BESY1 (posvalue)
result = BESYN (n, value)
Results
BESJ0, BESJ1, and BESJN return Bessel functions of the first kind, orders 0, 1, and n, respectively, with the
independent variable posvalue.
BESY0, BESY1, and BESYN return Bessel functions of the second kind, orders 0, 1, and n, respectively, with
the independent variable posvalue.
Negative arguments cause BESY0, BESY1, and BESYN to return QNAN.
1267
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Bessel functions are explained more fully in most mathematics reference books, such as the Handbook of
Mathematical Functions (Abramowitz and Stegun. Washington: U.S. Government Printing Office, 1964).
These functions are commonly used in the mathematics of electromagnetic wave theory.
See the descriptions of the BESSEL_* functions, if you need to use quad-precision (REAL(16)).
See Also
DBESJ0, DBESJ1, DBESJN
BESSEL_J0
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the first kind, order 0.
Syntax
result = BESSEL_J0 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the first kind
and order zero of x.
Example
BESSEL_J0 (1.0) has the approximate value 0.765.
BESSEL_J1
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the first kind, order 1.
Syntax
result = BESSEL_J1 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the first kind
and order 1 of x.
Example
BESSEL_J1 (1.0) has the approximate value 0.440.
BESSEL_JN
Elemental and Transformational Intrinsic
Functions (Generic): Compute Bessel functions of
the first kind.
Syntax
Elemental function: result = BESSEL_JN (n, x)
Transformational function: result = BESSEL_JN (n1, n2, x)
1268
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x.
The result of BESSEL_JN (n, x) is scalar. The result value of BESSEL_JN (n , x) is a processor-dependent
approximation to the Bessel function of the first kind and order n of x.
The result of BESSEL_JN (n1, n2, x) is a rank-one array with extent MAX (n2 - n1 + 1, 0). Element i of the
result value of BESSEL_JN (n1, n2, x) is a processor-dependent approximation to the Bessel function of the
first kind and order n1 + i - 1 of x.
Example
BESSEL_JN (2, 1.0) has the approximate value 0.115.
Consider the following program Bessel.90:
BESSEL_Y0
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the second kind, order 0.
Syntax
result = BESSEL_Y0 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the second
kind and order zero of x.
Example
BESSEL_Y0 (1.0) has the approximate value 0.088.
1269
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BESSEL_Y1
Elemental Intrinsic Function (Generic): Computes
a Bessel function of the second kind, order 1.
Syntax
result = BESSEL_Y1 (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Bessel function of the second
kind and order 1 of x.
Example
BESSEL_Y1 (1.0) has the approximate value -0.781.
BESSEL_YN
Elemental and Transformational Intrinsic
Functions (Generic): Compute Bessel functions of
the second kind.
Syntax
Elemental function: result = BESSEL_YN (n, x)
Transformational function: result = BESSEL_YN (n1, n2, x)
Results
The result type and kind are the same as x.
The result of BESSEL_YN (n, x) is scalar. The result value of BESSEL_YN (n , x) is a processor-dependent
approximation to the Bessel function of the second kind and order n of x.
The result of BESSEL_YN (n1, n2, x) is a rank-one array with extent MAX (n2 - n1 + 1, 0). Element i of the
result value of BESSEL_YN (n1, n2, x) is a processor-dependent approximation to the Bessel function of the
second kind and order n1 + i - 1 of x.
Example
BESSEL_YN (2, 1.0) has the approximate value -1.651.
BGE
Elemental Intrinsic Function (Generic): Performs
a bitwise greater than or equal to on its arguments.
Syntax
result = BGE (i,j)
1270
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is greater than or equal to the sequence of bits
represented by j, according to the method of bit sequence comparison in Bit Sequence Comparisons;
otherwise, the result is false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If BIT_SIZE (J) has the value 8, BGE (Z'FF', J) has the value true for any value of J. BGE (0, -1) has the
value false.
See Also
BIT_SIZE
BGT
Elemental Intrinsic Function (Generic): Performs
a bitwise greater than on its arguments.
Syntax
result = BGT (i,j)
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is greater than the sequence of bits represented by
j, according to the method of bit sequence comparison in Bit Sequence Comparisons; otherwise, the result is
false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
BGT (Z'FF', Z'FC') has the value true. BGT (0, -2) has the value false.
BIC, BIS
Portability Subroutines: Perform a bit-level set and
clear for integers.
1271
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
CALL BIC (bitnum, target)
CALL BIS (bitnum, target)
bitnum (Input) INTEGER(4). Bit number to set. Must be in the range 0 (least
significant bit) to 31 (most significant bit) if target is INTEGER(4). If
target is INTEGER(8), bitnum must be in range 0 to 63.
Example
Consider the following:
USE IFPORT
integer(4) bitnum, target_i4
integer(8) target_i8
target_i4 = Z'AAAA'
bitnum = 1
call BIC(bitnum, target_i4)
target_i8 = Z'FFFFFFFF00000000'
bitnum = 40
call BIC(bitnum, target_i8)
bitnum = 0
call BIS(bitnum, target_i4)
bitnum = 1
call BIS(bitnum, target_i8)
print '(" integer*4 result ",Z)', target_i4
print '(" integer*8 result ",Z)', target_i8
end
See Also
BIT
BIND
Statement and Attribute: Specifies that an object is
interoperable with C and has external linkage.
Syntax
The BIND attribute can be specified in a type declaration statement or a BIND statement, and takes one of
the following forms:
Type Declaration Statement:
type, [att-ls, ] BIND (C [, NAME=ext-name]) [, att-ls] :: object
Statement:
BIND (C [, NAME=ext-name]) [::] object
1272
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
object Is the name of a variable or common block. It can also be the name of
an internal procedure if NAME= is not specified.
Description
If a common block is specified in a BIND statement, it must be specified with the same binding label in each
scoping unit in which it is declared.
For variables and common blocks, BIND also implies the SAVE attribute, which may be explicitly confirmed
with SAVE.
A variable given the BIND attribute (or declared in a BIND statement) must appear in the specification part
of a module. You cannot specify BIND for a subroutine local variable or a variable in a main program.
The BIND attribute is similar to directive !DIR$ ATTRIBUTES C as follows:
• The compiler applies the same naming rules, that is, names are lowercase (unless NAME= specifies
otherwise).
• The compiler applies the appropriate platform decoration, such as a leading underscore.
However, procedure argument passing differs. When BIND is specified, procedure arguments are passed by
reference unless the VALUE attribute is also specified.
The BIND attribute can optionally be used in a PROCEDURE, SUBROUTINE, or FUNCTION declaration. It must
be used in an ENUM declaration.
Example
The following example shows the BIND attribute used in a type declaration statement, a statement, and a
SUBROUTINE statement.
BIND(C,NAME='SharedCommon') :: /SHAREDCOMMON/
! you need empty parens after the subroutine name if BIND is present
SUBROUTINE FOOBAR() BIND(C, NAME='FooBar')
...
END SUBROUTINE
See Also
Modules and Module Procedures
Type Declarations
Compatible attributes
Pointer Assignments
FUNCTION
SUBROUTINE
PROCEDURE
1273
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BIND(C)
in mixed language programming
BIT
Portability Function: Performs a bit-level test for
integers.
Module
USE IFPORT
Syntax
result = BIT (bitnum, source)
bitnum (Input) INTEGER(4). Bit number to test. Must be in the range 0 (least
significant bit) to 31 (most significant bit).
Results
The result type is logical. It is .TRUE. if bit bitnum of source is 1; otherwise, .FALSE..
See Also
BIC, BIS
BIT_SIZE
Inquiry Intrinsic Function (Generic): Returns the
number of bits in an integer type.
Syntax
result = BIT_SIZE (i)
Results
The result is a scalar integer with the same kind parameter as i. The result value is the number of bits (s)
defined by the bit model for integers with the kind parameter of the argument. For information on the bit
model, see Model for Bit Data.
Example
BIT_SIZE (1_2) has the value 16 because the KIND=2 integer type contains 16 bits.
See Also
BTEST
IBCLR
IBITS
IBSET
BLE
Elemental Intrinsic Function (Generic): Performs
a bitwise less than or equal to on its arguments.
Syntax
result = BLE (i,j)
1274
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is less than or equal to the sequence of bits
represented by j, according to the method of bit sequence comparison in Bit Sequence Comparisons;
otherwise, the result is false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
BLE (0, J) has the value true for any value of J. BLE (-2, 0) has the value false.
BLOCK
Statement: Marks the beginning of a BLOCK
construct. The BLOCK construct executes a block of
statements or constructs that can contain
declarations.
Syntax
[name:] BLOCK
[specification-part]
block
END BLOCK [name]
1275
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• ENTRY
• Statement functions
Description
A BLOCK construct is itself a scoping unit. Entities declared in a BLOCK construct are local to the BLOCK
construct and are accessible only in that construct and in any contained constructs. A local entity in a block
construct hides any entity with the same name in its host scope. No transfer of control into a block from
outside the block is allowed, except for the return from a procedure call. Transfers within a block or out of
the block are allowed.
If a construct name is specified at the beginning of a BLOCK statement, the same name must appear in the
corresponding END BLOCK statement. The same construct name must not be used for different named
constructs in the same scoping unit. If no name is specified at the beginning of a BLOCK statement, you
cannot specify one following the END BLOCK statement.
You can only branch to an END BLOCK statement from within its BLOCK construct.
The SAVE attribute specifies that a local variable of a BLOCK construct retains its association status,
allocation status, definition status, and value after termination of the construct unless it is a pointer and its
target becomes undefined. If the BLOCK construct contains a SAVE statement, the SAVE statement cannot
specify the name of a common block. A SAVE statement outside a BLOCK construct does not affect variables
local to the BLOCK construct, because a SAVE statement affects variables in its scoping unit which excludes
nested scoping units in it.
The statements specified within the specification-part are evaluated in a processor-dependent order, followed
by execution of block. When execution exits block, all non-SAVEd automatic and allocatable local variables
are deallocated.
Example
The following shows a BLOCK construct:
block
integer :: i
real :: a(n)
do i = 1,n
a(i) = i
end do
…
end block
When control exits the bottom of the BLOCK, local variables i and a revert to their meaning outside the
block.
The following example shows two nested BLOCK constructs where the inner BLOCK construct has the
construct name INNER and the outer one does not have a name:
BLOCK
...
INNER: BLOCK
...
END BLOCK INNER
...
END BLOCK
In the following example, the appearance and the reference of the FORMAT statement are legal:
PROGRAM MAIN
WRITE(6, FMT=10)
...
1276
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BLOCK
10 FORMAT(“Hello”)
END BLOCK
...
END
Implicit typing is not affected by BLOCK constructs. In the following example, even if NSQP only appears in
the two BLOCK constructs, the scope of NSQP is the whole subroutine S:
SUBROUTINE S(N)
...
IF (N>0) THEN
BLOCK
NSQP = CEILING(SQRT(DBLE(N)))
END BLOCK
END IF
...
IF (N>0) THEN
BLOCK
PRINT *,NSQP
END BLOCK
END IF
END SUBROUTINE S
BLOCK DATA
Statement: Identifies a block-data program unit,
which provides initial values for variables in named
common blocks. BLOCK DATA is an obsolescent
language feature in Standard Fortran.
Syntax
BLOCK DATA [name]
[specification-part]
END [BLOCK DATA [name]]
definition
IMPLICIT SAVE
1For more information, see RECORD statement and record structure
declarations.
2Can only contain attributes: DIMENSION, INTRINSIC, PARAMETER,
POINTER, SAVE, STATIC, or TARGET.
1277
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
A block data program unit need not be named, but there can only be one unnamed block data program unit
in an executable program.
If a name follows the END statement, it must be the same as the name specified in the BLOCK DATA
statement.
An interface block must not appear in a block data program unit and a block data program unit must not
contain any executable statements.
If a DATA statement initializes any variable in a named common block, the block data program unit must
have a complete set of specification statements establishing the common block. However, all of the variables
in the block do not have to be initialized.
A block data program unit can establish and define initial values for more than one common block, but a
given common block can appear in only one block data program unit in an executable program.
The name of a block data program unit can appear in the EXTERNAL statement of a different program unit to
force a search of object libraries for the block data program unit at link time.
Example
The following shows a block data program unit:
C Main Program
CHARACTER(LEN=10) family
INTEGER a, b, c, d, e
REAL X(10), Y(4)
COMMON/Lakes/a,b,c,d,e,family/Blk2/x,y
...
C The following block-data subprogram initializes
C the named common block /Lakes/:
C
BLOCK DATA InitLakes
COMMON /Lakes/ erie, huron, michigan, ontario,
+ superior, fname
DATA erie, huron, michigan, ontario, superior /1, 2, 3, 4, 5/
CHARACTER(LEN=10) fname/'GreatLakes'/
INTEGER erie, huron, michigan, ontario, superior
END
See Also
COMMON
DATA
EXTERNAL
Program Units and Procedures
1278
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ BLOCK_LOOP [clause[[,] clause]...]
!DIR$ NOBLOCK_LOOP
• FACTOR(expr)
The clauses can be specified in any order. If you do not specify any
clause, the compiler chooses the best blocking factor to apply to all
levels of the immediately following nested loop.
The BLOCK_LOOP directive lets you exert greater control over optimizations on a specific DO loop inside a
nested DO loop.
1279
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Using a technique called loop blocking, the BLOCK_LOOP directive separates large iteration counted DO loops
into smaller iteration groups. Execution of these smaller groups can increase the efficiency of cache space
use and augment performance.
If there is no LEVEL and FACTOR clause, the blocking factor will be determined based on the processor's type
and memory access patterns and it will apply to all the levels in the nested loops following this directive.
You can use the NOBLOCK_LOOP directive to tune the performance by disabling loop blocking for nested
loops.
NOTE
The loop-carried dependence is ignored during the processing of BLOCK_LOOP directives.
Example
!dir$ block_loop factor (256) ! the blocking factor applies to all levels of loop nest
!dir$ noblock_loop ! None of the levels in the nested loop following this
! directive will have a blocking factor applied
Consider the following:
do jj=1,n/256+1
do ii = 1,n/256+1
do j = (jj-1)*256+1, min(jj*256, n)
f = 0
do i = (ii-1)*256+1, min(ii*256,n)
f = f + a(i) * b(i)
enddo
c(j) = c(j) + f
1280
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
enddo
enddo
enddo
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Rules for Loop Directives that Affect Array Assignment Statements
Nested DO Constructs
BLT
Elemental Intrinsic Function (Generic): Performs
a bitwise less than on its arguments.
Syntax
result = BLT (i,j)
If the kinds of i and j do not match, the value with the smaller kind is extended with zeros on the left and
the larger kind is used for the operation and the result.
Results
The result is true if the sequence of bits represented by i is less than the sequence of bits represented by j,
according to the method of bit sequence comparison in Bit Sequence Comparisons; otherwise, the result is
false.
The interpretation of a binary, octal, or hexadecimal literal constant as a sequence of bits is described in
Binary, Octal, Hexadecimal, and Hollerith Constants.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
BLT (0, 2) has the value true. BLT (Z'FF', Z'FC') has the value false.
BSEARCHQQ
Portability Function: Performs a binary search of a
sorted one-dimensional array for a specified element.
The array elements cannot be derived types or
structures.
Module
USE IFPORT
Syntax
result = BSEARCHQQ (adrkey,adrarray,length,size)
1281
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
size (Input) INTEGER(4). Positive constant less than 32,767 that specifies
the kind of array to be sorted. The following constants, defined in
IFPORT.F90, specify type and kind for numeric arrays:
SRT$INTEGER1 INTEGER(1)
If the value provided in size is not a symbolic constant and is less than 32,767, the array is assumed to be a
character array with size characters per element.
Results
The result type is INTEGER(4). It is an array index of the matched entry, or 0 if the entry is not found.
The array must be sorted in ascending order before being searched.
Caution
The location of the array and the element to be found must both be passed by address using
the LOC function. This defeats Fortran type checking, so you must make certain that the
length and size arguments are correct, and that size is the same for the element to be found
and the array searched.
If you pass invalid arguments, BSEARCHQQ attempts to search random parts of memory. If the
memory it attempts to search is not allocated to the current process, the program is halted, and you
receive a General Protection Violation message.
Example
USE IFPORT
INTEGER(4) array(10), length
INTEGER(4) result, target
length = SIZE(array)
...
result = BSEARCHQQ(LOC(target),LOC(array),length,SRT$INTEGER4)
1282
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SORTQQ
LOC
BTEST
Elemental Intrinsic Function (Generic): Tests a bit
of an integer argument.
Syntax
result = BTEST (i,pos)
pos (Input) Must be of type integer. It must not be negative and it must
be less than BIT_SIZE(i).
Results
The result type is default logical.
The result is true if bit pos of i has the value 1. The result is false if pos has the value zero. For more
information, see Bit Functions.
For information on the model for the interpretation of an integer value as a sequence of bits, see Model for
Bit Data.
The setting of compiler options specifying integer size can affect this function.
Example
BTEST (9, 3) has the value true.
If A has the value
[ 1 2 ]
[ 3 4 ],
the value of BTEST (A, 2) is
[ false false ]
[ false true ]
and the value of BTEST (2, A) is
[ true false ]
[ false false ].
1283
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(1) i(2)
LOGICAL result(2)
i(1) = 2#10101010
i(2) = 2#01010101
result = BTEST(i, (/3,2/)) ! returns (.TRUE.,.TRUE.)
write(*,*) result
See Also
IBCLR
IBSET
IBCHNG
IOR
IEOR
IAND
BYTE
Statement: Specifies the BYTE data type, which is
equivalent to INTEGER(1).
Example
See Also
INTEGER
Integer Data Types
C to D
This section describes language features that start with C or D.
C to D
C_ASSOCIATED
Intrinsic Module Inquiry function (Generic):
Indicates the association status of one argument, or
whether two arguments are associated with the same
entity.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_ASSOCIATED(c_ptr_1[, c_ptr_2])
1284
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default logical. The result value is one of the following:
• If only c_ptr_1 is specified, the result is false if c_ptr_1 is a C null pointer; otherwise, the result is true.
• If c_ptr_2 is specified, the result is false if c_ptr_1 is a C null pointer. The result is true if c_ptr_1 is equal
to c_ptr_2; otherwise, the result is false.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_F_POINTER
Intrinsic Module Subroutine: Associates a data
pointer with the target of a C pointer and specifies its
shape.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
CALL C_F_POINTER(cptr, fptr [,shape])
cptr (Input) Is a scalar of derived type C_PTR. Its value is the C address of
an interoperable data entity, or the result of a reference to function
C_LOC with a noninteroperable argument. If the value of cptr is the C
address of a Fortran variable, it must have the TARGET attribute.
shape (Optional, input) Must be of type integer and rank one. Its size equals
the rank of fptr.
If the value of cptr is the C address of an interoperable data entity, fptr must be a data pointer with type and
type parameters interoperable with the type of the entity. In this case, fptr becomes pointer-associated with
the target of cptr.
If fptr is an array, it has the shape specified by shape and each lower bound is 1.
If the value of cptr is the result of a reference to C_LOC with a noninteroperable argument x, the following
rules apply:
• C_LOC argument x (or its target) must not have been deallocated or have become undefined due to the
execution of a RETURN or END statement since the reference to C_LOC.
• fptr is a scalar pointer with the same type and type parameters as x. fptr becomes pointer-associated with
x, or it becomes pointer-associated with its target if x is a pointer.
Since the resulting data pointer fptr could point to a target that was not allocated with an ALLOCATE
statement, fptr cannot be freed with a DEALLOCATE statement.
See Also
Intrinsic Modules
1285
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ISO_C_BINDING Module
C_LOC
C_F_PROCPOINTER
Intrinsic Module Subroutine: Associates a Fortran
procedure pointer with the target of a C function
pointer.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
CALL C_F_PROCPOINTER(cptr, fptr)
Examples
Example 1
The following Fortran subroutine can be called from a C program that passes a pointer to a C function to be
called:
main.c:
#include <stdio.h>
1286
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
int main () {
void (*fun_b)(int*) = NULL;
int *i;
int j = 10;
fun_b = foo;
i = &j;
printf (“Test in C\n”);
fun_b (i);
printf (“Test in Fortran\n”);
bar_ (&fun_b);
}
bar.f90
SUBROUTINE bar (c_fptr)
USE ISO_C_BINDING
TYPE(c_funptr) :: c_fptr
PROCEDURE(),POINTER :: proc_ptr
INTEGER(c_int) :: i = 20
Test in C
The value is 10
Test in Fortran
The value is 20
See Also
Intrinsic Modules
ISO_C_BINDING Module
Procedure Pointers
PROCEDURE
C_FUNLOC
Intrinsic Module Inquiry function (Generic):
Returns the C address of a function pointer.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_FUNLOC(x)
1287
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of derived type C_FUNPTR. The result value represents the C address of the argument.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_LOC
Intrinsic Module Inquiry function (Generic):
Returns the C address of an argument.
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_LOC(x)
Results
The result is a scalar of derived type C_PTR. The result value represents the C address of the argument.
The result is a value that can be used as an actual CPTR argument in a call to procedure C_F_POINTER where
fptr has attributes that allow the pointer assignment fptr=>x. Such a call to C_F_POINTER has the effect of
the pointer assignment fptr=>x.
If x is a scalar, the result is determined as if C_PTR were a derived type containing a scalar pointer
component PX of the type and type parameters of x and the pointer assignment CPTR%PX=>x were
executed.
If x is an array, the result is determined as if C_PTR were a derived type containing a scalar pointer
component PX of the type and type parameters of x and the pointer assignment CPTR%PX to the first
element of x were executed.
See Also
Intrinsic Modules
ISO_C_BINDING Module
C_F_POINTER
C_SIZEOF
Intrinsic Module Inquiry function (Generic):
Returns the number of bytes of storage used by the
argument. It cannot be passed as an actual argument.
1288
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE, INTRINSIC :: ISO_C_BINDING
Syntax
result = C_SIZEOF(x)
Results
The result is a scalar of type INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. If x is
scalar, the result value is the size of x in bytes. If x is an array, the result value is the size of a single element
of x multiplied by the number of elements in x.
Example
Consider the following:
INTEGER(4) :: S
INTEGER(4) :: T(3)
C_SIZEOF(S) ! has the value 4
C_SIZEOF(T) ! has the value 12
See Also
Intrinsic Modules
ISO_C_BINDING Module
SIZEOF
CACHESIZE
Inquiry Intrinsic Function (Generic): Returns the
size of a level of the memory cache.
Syntax
result = CACHESIZE (n)
Results
The result type and kind are the same as n. The result value is the number of kilobytes in the level n
memory cache.
n = 1 specifies the first level cache; n = 2 specifies the second level cache; etc. If cache level n does not
exist, the result value is 0.
Example
CACHESIZE(1) returns 16 for a processor with a 16KB first level memory cache.
CALL
Statement: Transfers control to a subroutine
subprogram.
1289
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL sub[( [a-arg[,a-arg]...] )]
Description
When the CALL statement is executed, any expressions in the actual argument list are evaluated, then
control is passed to the first executable statement or construct in the subroutine. When the subroutine
finishes executing, control returns to the next executable statement following the CALL statement, or to a
statement identified by an alternate return label (if any).
If an argument list appears, each actual argument is associated with the corresponding dummy argument by
its position in the argument list or by the name of its keyword. The arguments must agree in type and kind
parameters.
If positional arguments and argument keywords are specified, the argument keywords must appear last in
the actual argument list.
If a dummy argument is optional, the actual argument can be omitted.
An actual argument associated with a dummy procedure must be the specific name of a procedure, or be
another dummy procedure. Certain specific intrinsic function names must not be used as actual arguments
(see table Specific Functions Not Allowed as Actual Arguments in Intrinsic Procedures).
The procedure invoked by the CALL statement must be a subroutine subprogram and not a function. Calling a
function as if it were a subroutine can cause unpredictable results.
Example
The following example shows valid CALL statements:
CALL CURVE(BASE,3.14159+X,Y,LIMIT,R(LT+2))
CALL PNTOUT(A,N,'ABCD')
CALL EXIT
CALL MULT(A,B,*10,*20,C) ! The asterisks and ampersands denote
CALL SUBA(X,&30,&50,Y) ! alternate returns
The following example shows a subroutine with argument keywords:
PROGRAM KEYWORD_EXAMPLE
INTERFACE
SUBROUTINE TEST_C(I, L, J, KYWD2, D, F, KYWD1)
INTEGER I, L(20), J, KYWD1
1290
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL, OPTIONAL :: D, F
COMPLEX KYWD2
...
END SUBROUTINE TEST_C
END INTERFACE
INTEGER I, J, K
INTEGER L(20)
COMPLEX Z1
CALL TEST_C(I, L, J, KYWD1 = K, KYWD2 = Z1)
...
The first three actual arguments are associated with their corresponding dummy arguments by position. The
argument keywords are associated by keyword name, so they can appear in any order.
Note that the interface to subroutine TEST has two optional arguments that have been omitted in the CALL
statement.
The following shows another example of a subroutine call with argument keywords:
See Also
SUBROUTINE
CONTAINS
RECURSIVE
USE
Program Units and Procedures
CANCEL
OpenMP* Fortran Compiler Directive: Requests
cancellation of the innermost enclosing region of the
construct specified, and causes the encountering
implicit or explicit task to proceed to the end of the
canceled construct.
Syntax
!$OMP CANCEL construct-clause [[,] if-clause]
1291
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• DO
• PARALLEL
• SECTIONS
• TASKGROUP
The binding thread set of a CANCEL construct is the current team. The cancel region binds to the innermost
enclosing construct of the type corresponding to the construct-clause specified in the directive specifying the
innermost DO, PARALLEL, SECTIONS, or TASKGROUP construct.
This is a stand-alone directive, so there are some restrictions on its placement within a program:
• It can only be placed at a point where a Fortran executable statement is allowed.
• It cannot be used as the action statement in an IF statement, or as the executable statement following a
label, if the label is referenced in the program.
If construct-clause is TASKGROUP, the CANCEL construct must be closely nested inside a TASK construct.
Otherwise, the CANCEL construct must be closely nested inside an OpenMP construct that matches the type
specified in construct-clause.
The CANCEL construct requests cancellation of the innermost enclosing region of the type specified. The
request is checked at a cancellation point. When a cancellation is observed, execution jumps to the end of
the canceled region.
Cancellation points are implied at certain locations, as follows:
• Implicit barriers
• BARRIER regions
• CANCEL regions
• CANCELLATION POINT regions
When cancellation of tasks occurs with a CANCEL TASKGROUP construct, the encountering task jumps to the
end of its task region and is considered complete. Any task that belongs to the innermost enclosing
taskgroup and has already begun execution, must run to completion or run until a cancellation point is
reached. Any task that belongs to the innermost enclosing taskgroup and has not begun execution may be
discarded and considered completed.
When cancellation occurs for a PARALLEL region, each thread of the binding thread set resumes execution at
the end of the canceled region and any tasks that have been created by a TASK construct and their
descendants are canceled according to the above taskgroup cancellation semantics.
When cancellation occurs for a DO or SECTIONS region, each thread of the binding thread set resumes
execution at the end of the canceled region but no task cancellation occurs.
A DO construct that is being canceled must not have a NOWAIT or an ORDERED clause. A SECTIONS
construct that is being canceled must not have a NOWAIT clause.
The behavior for concurrent cancellation of a region and a region nested within it is unspecified.
NOTE
You must release locks and similar data structures that can cause a deadlock when a CANCEL
construct is encountered; blocked threads cannot be canceled.
If the canceled construct contains a REDUCTION or LASTPRIVATE clause, the final value of the REDUCTION or
LASTPRIVATE variable is undefined.
All private objects or subobjects with the ALLOCATABLE attribute that are allocated inside the canceled
construct are deallocated.
1292
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
CANCELLATION POINT
Parallel Processing Model for information about Binding Sets
CANCELLATION POINT
OpenMP* Fortran Compiler Directive: Defines a
point at which implicit or explicit tasks check to see if
cancellation has been requested for the innermost
enclosing region of the type specified. This construct
does not implement a synchronization between
threads or tasks.
Syntax
!$OMP CANCELLATION POINT construct-clause
• DO
• PARALLEL
• SECTIONS
• TASKGROUP
This is a stand-alone directive, so there are some restrictions on its placement within a program:
• It can only be placed at a point where a Fortran executable statement is allowed.
• It cannot be used as the action statement in an IF statement, or as the executable statement following a
label, if the label is referenced in the program.
A CANCELLATION POINT region binds to the current task region.
If construct-clause is TASKGROUP, the CANCELLATION POINT construct must be closely nested inside a TASK
construct. Otherwise, the CANCELLATION POINT construct must be closely nested inside an OpenMP
construct that matches the type specified by the construct-clause.
When an implicit or explicit task reaches a user-defined cancellation point, the task immediately checks for
cancellation of the region specified in the clause and performs cancellation of this region if cancellation is
observed. If the clause specified is TASKGROUP then the current task region is canceled.
An OpenMP program with orphaned CANCELLATION POINT constructs is non-conforming.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
CANCEL
CASE
Statement: Marks the beginning of a CASE construct.
A CASE construct conditionally executes one block of
constructs or statements depending on the value of a
scalar expression in a SELECT CASE statement.
Syntax
[name:] SELECT CASE (expr)
[CASE (case-value [, case-value] ...) [name]
block]...
1293
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
low:high
low:
:high
Case values must not overlap.
Description
If a construct name is specified in a SELECT CASE statement, the same name must appear in the
corresponding END SELECT statement. The same construct name can optionally appear in any CASE
statement in the construct. The same construct name must not be used for different named constructs in the
same scoping unit.
The case expression ( expr) is evaluated first. The resulting case index is compared to the case values to find
a matching value (there can only be one). When a match occurs, the block following the matching case value
is executed and the construct terminates.
The following rules determine whether a match occurs:
• When the case value is a single value (no colon appears), a match occurs as follows:
1294
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1295
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1296
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You cannot use branching statements to transfer control to a CASE statement. However, branching to a
SELECT CASE statement is allowed. Branching to the END SELECT statement is allowed only from within the
CASE construct.
Example
The following are examples of CASE constructs:
CHARACTER*1 cmdchar
GET_ANSWER: SELECT CASE (cmdchar)
CASE ('0')
WRITE (*, *) "Must retrieve one to nine files"
CASE ('1':'9')
CALL RetrieveNumFiles (cmdchar)
CASE ('A', 'a')
CALL AddEntry
CASE ('D', 'd')
CALL DeleteEntry
1297
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Execution Control
CDFLOAT
Portability Function: Converts a COMPLEX(4)
argument to double-precision real type.
Module
USE IFPORT
Syntax
result = CDFLOAT (input)
Results
The result type is REAL(8).
CEILING
Elemental Intrinsic Function (Generic): Returns
the smallest integer greater than or equal to its
argument.
Syntax
result = CEILING (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The value of the result is equal to the smallest integer greater than or equal to a.
The setting of compiler options specifying integer size can affect this function.
Example
CEILING (4.8) has the value 5.
CEILING (-2.55) has the value -2.0.
The following shows another example:
INTEGER I, IARRAY(2)
I = CEILING(8.01) ! returns 9
I = CEILING(-8.01) ! returns -8
IARRAY = CEILING((/8.01,-5.6/)) ! returns (9, -5)
1298
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
FLOOR
CFI_address
C function prototype: Returns the C address of an
object described by a C descriptor.
Syntax
Result Value
If the object is an array of rank n, the result is the C address of the element of the object that the first n
elements of the subscripts argument would specify if used as subscripts. If the object is scalar, the result is
its C address.
Example
If dv is the address of a C descriptor for the Fortran array A declared as follows:
CFI_index_t subscripts[2];
float *address;
subscripts[0] = 4;
subscripts[1] = 9;
address = (float *) CFI_address(dv, subscripts );
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_allocate
C function prototype: Allocates memory for an
object described by a C descriptor.
Syntax
1299
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Formal Parameters:
lower_bounds The address of an array with at least dv->rank elements. The first dv-
>rank elements of lower_bounds provide the lower Fortran bounds for
each corresponding dimension of the object.
upper_bounds The address of an array with at least dv->rank elements. The first dv-
>rank elements of upper_bounds provide the upper Fortran bounds
for each corresponding dimension of the object.
Description
Successful execution of CFI_allocate allocates memory for the object described by the C descriptor with the
address dv using the same mechanism as the Fortran ALLOCATE statement, and assigns the address of that
memory to dv->base_addr.
The first dv->rank elements of the lower_bounds and upper_bounds arguments provide the lower and upper
Fortran bounds, respectively, for each corresponding dimension of the object. The supplied lower and upper
bounds override any current dimension information in the C descriptor. If the rank is zero, the lower_bounds
and upper_bounds arguments are ignored.
If the type specified in the C descriptor is a character type, the supplied element length overrides the current
element-length information in the descriptor.
If an error is detected, the C descriptor is not modified.
Result Value
The result is an error indicator.
Example
If dv is the address of a C descriptor for the Fortran array A declared as follows:
See Also
ALLOCATE
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
1300
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CFI_deallocate
C function prototype: Deallocates memory for an
object described by a C descriptor.
Syntax
int CFI_deallocate (CFI_cdesc_t *dv);
Formal Parameters:
Description
Successful execution of CFI_deallocate deallocates memory for the object using the same mechanism as the
Fortran DEALLOCATE statement, and the base_addr member of the C descriptor becomes a null pointer.
Result Value
The result is an error indicator.
Example
If dv is the address of a C descriptor for the Fortran array A declared as follows:
int ind;
ind = CFI_deallocate(dv);
See Also
ALLOCATE
DEALLOCATE
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_establish
C function prototype: Establishes a C descriptor.
Syntax
1301
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
attribute One of the attribute codes in Table "Macros for attribute codes" in C
Typedefs and Macros for interoperability. If it is
CFI_attribute_allocatable, base_addr must be a null pointer.
type One of the type codes in Table "Macros for type codes" in C Typedefs
and Macros for interoperability.
Description
Successful execution of CFI_establish updates the object with the address dv to be an established C
descriptor for a nonallocatable nonpointer data object of known shape, an unallocated allocatable object, or a
data pointer.
If base_addr is not a null pointer, it is the address for a nonallocatable entity that is a scalar or a contiguous
array. If the attribute argument has the value CFI_attribute_pointer, the lower bounds of the object
described by dv are set to zero. If base_addr is a null pointer, the established C descriptor is for an
unallocated allocatable, a disassociated pointer, or is a C descriptor that has the attribute
CFI_attribute_other but does not describe a data object. If base_addr is the C address of a Fortran data
object, the type and elem_len arguments must be consistent with the type and type parameters of the
Fortran data object.
The remaining properties of the object are given by the other arguments.
CFI_establish is used to initialize a C descriptor declared in C with CFI_CDESC_T before passing it to any
other functions as an actual argument, in order to set the rank, attribute, type and element length.
A C descriptor with attribute CFI_attribute_other and a base_addr that is a null pointer can be used as
the argument result in calls to CFI_section or CFI_select_part, which will produce a C descriptor for a
nonallocatable nonpointer data object.
If an error is detected, the object with the address dv is not modified.
Result Value
The result is an error indicator.
1302
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following code fragment establishes a C descriptor for an unallocated rank-one allocatable array that can
be passed to Fortran for allocation there:
CFI_rank_t rank;
CFI_CDESC_T(1) field;
int ind;
rank = 1;
ind = CFI_establish((CFI_cdesc_t *)&field, NULL,
CFI_attribute_allocatable,
CFI_type_double, 0, rank, NULL);
If the following Fortran type definition is specified:
TYPE, BIND(C) :: T
REAL(C_DOUBLE) :: X
COMPLEX(C_DOUBLE_COMPLEX) :: Y
END TYPE
and a Fortran subprogram that has an assumed-shape dummy argument of type T, the following code
fragment creates a descriptor a_fortran for an array of size 100 that can be used as the actual argument in
an invocation of the subprogram from C:
extent[0] = 100;
ind = CFI_establish((CFI_cdesc_t *)&a_fortran, a_c,
CFI_attribute_other,
CFI_type_struct, sizeof(t), 1, extent);
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_is_contiguous
C function prototype: Tests contiguity of an array.
Syntax
int CFI_is_contiguous(const CFI_cdesc_t *dv);
Formal Parameters:
Result Value
The value of the result is 1 if the array described by dv is contiguous; otherwise, 0.
Since assumed-size and allocatable arrays are always contiguous, the result of CFI_is_contiguous on a C
descriptor for such an array is 1.
1303
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_section
C function prototype: Updates a C descriptor for an
array section for which each element is an element of
a given array.
Syntax
int CFI_section(CFI_cdesc_t *result, const CFI_cdesc_t *source,
const CFI_index_t lower_bounds[],
const CFI_index_t upper_bounds[],
const CFI_index_t strides[]);
Formal Parameters:
result The address of a C descriptor with rank equal to the rank of source
minus the number of zero strides. The attribute member must have
the value CFI_attribute_other or CFI_attribute_pointer. If the
value of result is the same as either a C formal parameter that
corresponds to a Fortran actual argument or a C actual argument that
corresponds to a Fortran dummy argument, the attribute member
must have the value CFI_attribute_pointer.
1304
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an error is detected, the C descriptor with the address result is not modified.
Result Value
The result is an error indicator.
Example
If source is already the address of a C descriptor for the rank-one Fortran array A, the lower bounds of A are
equal to 1, and the lower bounds in the C descriptor are equal to 0, the following code fragment establishes a
new C descriptor section and updates it to describe the array section A(3::5):
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_select_part
C function prototype: Updates a C descriptor for an
array section for which each element is a part of the
corresponding element of an array.
1305
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result The address of a C descriptor; result->rank must have the same value
as source->rank and result->attribute must have the value
CFI_attribute_other or CFI_attribute_pointer. If the address
specified by result is the value of a C formal parameter that
corresponds to a Fortran actual argument or of a C actual argument
that corresponds to a Fortran dummy argument, result->attribute
must have the value CFI_attribute_pointer. The value of result-
>type specifies the type of the array section.
elem_len A value equal to the storage size in bytes of an element of the array
section if result->type specifies a Fortran character type; otherwise,
elem_len is ignored.
Description
Successful execution of CFI_select_part updates the base_addr, dim, and elem_len members of the C
descriptor with the address result for an array section for which each element is a part of the corresponding
element of the array described by the C descriptor with the address source. The part must be a component of
a structure, a substring, or the real or imaginary part of a complex value.
If an error is detected, the C descriptor with the address result is not modified.
Result Value
The result is an error indicator.
Example
If source is already the address of a C descriptor for the Fortran array A declared as follows:
TYPE, BIND(C) :: T
REAL(C_DOUBLE) :: X
COMPLEX(C_DOUBLE_COMPLEX) :: Y
END TYPE
TYPE(T) A(100)
then the following code fragment establishes a C descriptor for the array A%Y:
typedef struct {
double x; double _Complex y;
} t;
CFI_CDESC_T(1) component;
CFI_cdesc_t * comp_cdesc = (CFI_cdesc_t *)&component;
1306
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CFI_setpointer
C function prototype: Updates a C descriptor for a
Fortran pointer to be associated with the whole of a
given object or to be disassociated.
Syntax
Description
Successful execution of CFI_setpointer updates the base_addr and dim members of the C descriptor with
the address result as follows:
• If source is a null pointer or the address of a C descriptor for a disassociated pointer, the updated C
descriptor describes a disassociated pointer.
• Otherwise, the C descriptor with the address result becomes a C descriptor for the object described by the
C descriptor with the address source, except that if source->rank is nonzero and lower_bounds is not a
null pointer, the lower bounds are replaced by the values of the first source->rank elements of the
lower_bounds array.
Result Value
The result is an error indicator.
1307
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
If ptr is already the address of a C descriptor for an array pointer of rank 1, the following code updates it to
be a C descriptor for a pointer to the same array with lower bound 0:
CFI_index_t lower_bounds[1];
int ind;
lower_bounds[0] = 0;
ind = CFI_setpointer(ptr, ptr, lower_bounds);
See Also
C Structures Typedefs and Macros for interoperability
Interoperating with arguments using C descriptors
CHANGEDIRQQ
Portability Function: Makes the specified directory
the current, default directory.
Module
USE IFPORT
Syntax
result = CHANGEDIRQQ (dir)
Results
The result type is LOGICAL(4). It is .TRUE. if successful; otherwise, .FALSE..
If you do not specify a drive in the dir string, the named directory on the current drive becomes the current
directory. If you specify a drive in dir, the named directory on the specified drive becomes the current
directory.
Example
USE IFPORT
LOGICAL(4) status
status = CHANGEDIRQQ('d:\fps90\bin'))
! We are now CCed to 'd:\fps90\bin'
status = CHANGEDIRQQ('bessel')
! We are now CCed to 'd:\fps90\bin\bessel'
See Also
GETDRIVEDIRQQ
MAKEDIRQQ
DELDIRQQ
CHANGEDRIVEQQ
CHANGEDRIVEQQ
Portability Function: Makes the specified drive the
current, default drive.
Module
USE IFPORT
1308
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = CHANGEDRIVEQQ (drive)
Results
The result type is LOGICAL(4). On Windows* systems, the result is .TRUE. if successful; otherwise, .FALSE.
On Linux* and macOS systems, the result is always .FALSE..
Because drives are identified by a single alphabetic character, CHANGEDRIVEQQ examines only the first
character of drive. The drive letter can be uppercase or lowercase.
CHANGEDRIVEQQ changes only the current drive. The current directory on the specified drive becomes the
new current directory. If no current directory has been established on that drive, the root directory of the
specified drive becomes the new current directory.
Example
USE IFPORT
LOGICAL(4) status
status = CHANGEDRIVEQQ('d')
See Also
GETDRIVESQQ
GETDRIVESIZEQQ
GETDRIVEDIRQQ
CHANGEDIRQQ
Syntax
The CHANGE TEAM construct takes the following form:
[name:] CHANGE TEAM (team-variable [, coarray-association-list][, sync-stat-list])
block
END TEAM [([sync-stat-list])] [name]
stat-var Is a scalar integer variable in which the status of the FORM TEAM
operation is stored.
1309
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The sync-stat-list items can appear in any order, but each sync-stat specifier may appear at most once. A
selector may appear only once in selector-list. stat-var and err-var cannot be coindexed variables. team-
variable must have been previously defined by the execution of a FORM TEAM statement.
Description
A CHANGE TEAM statement begins the CHANGE TEAM construct. The current team of each image that
executes a CHANGE team statement becomes the team specified by the team variable. This remains the
current team of the image until another CHANGE TEAM construct is executed by the image, or until the
corresponding END TEAM statement is executed. The current team of each image executing an END TEAM
statement becomes the team that was current prior to execution of the corresponding CHANGE TEAM
statement.
Branching into or out of a CHANGE TEAM construct is not permitted. A branch to an END TEAM statement is
permitted only from within the corresponding CHANGE TEAM construct. An EXIT statement in a CHANGE
TEAM construct is effectively the same as a branch to the END TEAM statement of the construct. Within a
CHANGE TEAM construct, a CYCLE or EXIT statement is not allowed if it belongs to an outer construct. A
RETURN statement may not appear in a CHANGE TEAM construct.
If a construct name appears on the CHANGE TEAM statement of the construct, the same name must also
appear on the END TEAM construct. If a construct name appears on an END TEAM statement, the same
construct name must appear on the corresponding CHANGE TEAM statement. The construct name must not
be the same as any other construct name in the scoping unit.
The purpose of the coarray-association is to redefine the codimensions of a coarray during execution of the
CHANGE TEAM construct. The associating entity is a coarray with the corank and cobounds specified in the
codimension-decl. This means the coshape and cobounds of an associating entity can be different from that
of the selector. When the CHANGE TEAM statement is executed, the selectors must all be established
coarrays.
The coarray name in a coarray-association must not be the same as the name as the name of another
coarray or of a selector in the CHANGE TEAM statement. The coarray names specified in the codimension-
decl are associate names associated with their corresponding selectors. The type and type parameters of the
associating entity is that of its selector. The associating entity is polymorphic if the selector is polymorphic, in
which case the associating entity assumes the dynamic type and type parameters of the selector.
On each active image that executes the CHANGE TEAM statement, the team variables must have been
defined by corresponding execution of the same FORM TEAM statement. The current team executing prior to
the CHANGE TEAM statement must be the same team that executed the FORM TEAM statement that defined
the team variables. On each image, the team variable specified in the CHANGE TEAM statement cannot
become undefined or redefined during execution of the construct.
An allocatable coarray that has an allocation status of allocated when the CHANGE TEAM construct is entered
cannot be deallocated during execution of the construct. Allocatable coarrays that are allocated during the
CHANGE TEAM construct and remain allocated at the end of the construct are deallocated upon exit from the
construct. This is true even if the allocatable coarray has the SAVE attribute.
Each image executing the CHANGE TEAM statement is implicitly synchronized with all the other active images
that will be on the same team after execution of the CHANGE TEAM construct. Execution of the statements
forming the block of the CHANGE TEAM construct are delayed until all images on the new team have entered
the construct. The construct completes execution when the END TEAM statement is executed. The images of
the team executing the construct are implicitly synchronized when the END TEAM statement is executed.
If STAT= is specified on a CHANGE TEAM or END TEAM statement, stat-var becomes defined with the value 0
if no error condition occurs. If the team executing the statement contains a stopped image, stat-var becomes
defined with the value STAT_STOPPED_IMAGE from the intrinsic module ISO_FORTRAN_ENV. If the team
contains a failed image and no other error condition occurs, stat-var becomes defined with the value
1310
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT_FAILED_IMAGE defined in the module ISO_FORTRAN_ENV. Otherwise, stat-var becomes defined with a
positive integer value other than STAT_FAILED_IMAGE or STAT_STOPPED_IMAGE. If STAT= is not specified,
and the team contains a stopped or failed image, or if any other error occurs, error termination is initiated.
If ERRMSG= is specified in a CHANGE TEAM or an END TEAM statement and an error condition occurs, err-
var becomes defined with a character string containing an informative message about the error. The string is
truncated or padded according to the rules of intrinsic assignment. If no error occurs, err-var is unchanged.
Examples
Example 1:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: odd_even
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
CHANGE TEAM (odd_even)
! Segment 1
. . .
END TEAM
! Segment 2
. . .
END PROGRAM
If a team with 8 images executes the above code, two teams are formed. Team number 1 contains the odd
numbered images [1, 3, 5, 7] of the parent team with new image indices [1, 2, 3, 4], and team number 2
contains the even numbered images [2, 4, 6, 8] of the parent team with new image indices [1, 2, 3, 4].
Segment 1 can be executed by team number 1 once images 1, 3, 5, and 7 of the initial team have arrived at
the CHANGE TEAM construct. Team number 1 can execute segment 2 once the same images have executed
the END TEAM statement. Similarly, segment 1 can be executed by team 2 only after image 2, 4, 6, and 8
have all arrived at the CHANGE TEAM statement, and they can execute segment 2 after they have all reached
the END TEAM statement.
Example 2:
USE ISO_FORTRAN_ENV
INTEGER, PARAMETER :: n = 4
TYPE (TEAM_TYPE) :: column
REAL,CODIMENSION[n, *]:: co_array
INTEGER,DIMENSION(2) :: my_cosubscripts
my_cosubscripts (:) = THIS_IMAGE(co_array)
FORM TEAM (my_cosubscripts(2), column, NEW_INDEX = my_cosubscripts(1))
CHANGE TEAM (column, ca[*] => co_array)
….
END TEAM
If there are 16 images on the initial team, the scalar coarray co_array will be distributed across a 4 x 4 grid
of processors. Execution of the FORM TEAM statement divides the initial team into four teams of four images.
Each team contains the images of one column of the grid of processors. The team number of each team is
the column number in the processor grid, and the image indices on each new team are the row indices of the
processor grid. Inside the CHANGE TEAM construct, the image pattern is a 1 x 4 pattern.
On team 1, ca[1] is co_array[1, 1], ca[2] is co_array[2,1], …, and ca[4] is coarray[4, 1]. On team 2, ca[1] is
co_array[1, 2], ca[2] is co_array [2,2], …, and ca[4] is co_array[2, 4]. On team 3, ca[1] is co_array[1, 3],
ca[2] is co_array[2 ,3], …, and ca[4] is co_array[4, 3]. And on team 4, ca[1] is co_array[1, 4], ca[2] is
co_array[2, 4], …, and ca[4] is co_array[4, 4].
co_array's cosubscripts:
1,1 1,2 1,3 1,4
2,1 2,2 2,3 2,4
1311
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Team 1 2 3 4
Number
1,1 1,2 1,3 1,4
2,1 2,2 2,3 2,4
3,1 3,2 3,3 3,4
4,1 4,2 4,3 4,4
Example 3:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: one_or_two
IF (THIS_IMAGE() .LE. NUM_IMAGES() / 2) THEN
new_team = 1
ELSE
new_team = 2
END IF
FORM TEAM (new_team, one_or_two)
SYNC ALL
CHANGE TEAM (one_or_two)
! Segment 1
. . .
END TEAM
SYNC ALL
! Segment 2
. . .
END PROGRAM
In the above case, the FORM TEAM statement creates two teams, team 1 and team 2. The SYNC ALL
statement before the CHANGE TEAM statement prevents either team from entering the CHANGE TEAM
construct until all images of the other team are ready to enter it also. Similarly, the SYNC ALL after the END
TEAM statement prevents either team from executing segment 2 until all images of the other team have
exited the CHANGE TEAM construct.
Example 4:
This example divides a 4x4 grid of images into 4 2x2 grids of images. The image indices of the 4x4 grid are:
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
The 2x2 grids are laid out and identified symbolically and with team numbers as:
top_lef top_rig
t (1,1) ht (1,2)
bot_lef bot_rig
t (2,1) ht (2,2)
The image numbers on each of the teams in the 2x2 grids become:
1 3 1 3
2 4 2 4
1 3 1 3
1312
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
2 4 2 4
PROGRAM MAIN
USE ISO_FORTRAN_ENV
INTEGER,PARAMETER :: top_left = 11, bot_left = 21, top_right = 12, bot_right = 22
INTEGER,DIMENSION(16) :: quads = [top_left, top_left, bot_left, bot_left, &
top_left, top_left, bot_left, bot_left, &
top_right, top_right, bot_right, bot_right, &
top_right, top_right, bot_right, bot_right]
INTEGER,DIMENSION(16) :: images = [1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 1, 2, 3, 4, 3, 4]
TYPE (TEAM_TYPE) :: quadrants, original_team
REAL :: co_array1[4,*], co_array2 [4, *]
INTEGER :: me
See Also
Image Control Statements
Coarrays
Using Coarrays
Construct Association
FORM TEAM
CHAR
Elemental Intrinsic Function (Generic): Returns
the character in the specified position of the
processor's character set. It is the inverse of the
function ICHAR.
Syntax
result = CHAR (i[,kind])
Results
The result is of type character with length 1. If kind is present, the kind parameter of the result is that
specified by kind; otherwise, the kind parameter of the result is that of default character. If the processor
cannot represent the result value in the kind of the result, the result is undefined.
1313
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The result is the character in position i of the processor's character set. ICHAR(CHAR ( i, kind( c))) has the
value I for 0 to n - 1 and CHAR(ICHAR( c), kind( c)) has the value c for any character c capable of
representation in the processor.
INTEGER(1) CHARACTER
INTEGER(2) CHARACTER
INTEGER(8) CHARACTER
1This specific function cannot be passed as an actual argument.
Example
CHAR (76) has the value 'L'.
See Also
ACHAR
IACHAR
ICHAR
Character and Key Code Charts
CHARACTER
Statement: Specifies the CHARACTER data type.
Syntax
CHARACTER ([LEN=]len [, [KIND=]n])
CHARACTER (KIND=n [, [LEN=]len])
CHARACTER* len
n Is kind 1.
len Is a string length (not a kind). For more information, see Declaration
Statements for Character Types.
If no kind type parameter is specified, the kind of the constant is
default character.
Example
C
C Length of wt and vs is 10, city is 80, and ch is 1
C
CHARACTER wt*10, city*80, ch
CHARACTER (LEN = 10), PRIVATE :: vs
CHARACTER*(*) arg !declares a dummy argument
C name and plume are ten-element character arrays
C of length 20
CHARACTER name(10)*20
CHARACTER(len=20), dimension(10):: plume
C
C Length of susan, emily, and naomi are 2, karen is 12,
1314
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Character Data Type
Character Constants
Character Substrings
C Strings
Declaration Statements for Character Types
CHDIR
Portability Function: Changes the default directory.
Module
USE IFPORT
Syntax
result = CHDIR(dir_name)
Results
The result type is INTEGER(4). It returns zero if the directory was changed successfully; otherwise, an error
code. Possible error codes are:
• ENOENT: The named directory does not exist.
• ENOTDIR: The dir_name parameter is not a directory.
Example
use ifport
integer(4) istatus, enoent, enotdir
character(255) newdir
character(300) prompt, errmsg
write(*,*) TRIM(errmsg)
goto 10
1315
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
CHANGEDIRQQ
CHMOD
Portability Function: Changes the access mode of a
file.
Module
USE IFPORT
Syntax
result = CHMOD (name,mode)
1316
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[ugoa]*[+-=] [rwxXst]*
On Windows* systems, "[ugoa]*" is ignored. On Linux* and macOS systems, a combination of the letters
"ugoa" control which users' access to the file will be changed:
u The user who owns the file
a All users
"[rwxXst]*" indicates the permission to add, subtract, or set. On Windows systems, only "w" is significant
and affects write permission; all other letters are ignored. On Linux and macOS systems, all letters are
significant.
Results
The result type is INTEGER(4). It is zero if the mode was changed successfully; otherwise, an error code.
Possible error codes are:
• ENOENT: The specified file was not found.
• EINVAL: The mode argument is invalid.
• EPERM: Permission denied; the file's mode cannot be changed.
Example
USE IFPORT
integer(4) I,Istatus
I = ACCESS ("DATAFILE.TXT", "w")
if (i) then
ISTATUS = CHMOD ("datafile.txt", "[+w]")
end if
I = ACCESS ("DATAFILE.TXT","w")
print *, i
See Also
SETFILEACCESSQQ
1317
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CLASS
Statement: Declares a polymorphic object. It takes
one of the following forms:
Syntax
CLASS (name) att-list :: v-list
CLASS (*) att-list :: v-list
att-list Is one or more attribute specifiers. These are the same attribute
specifiers allowed for a derived-type TYPE statement.
v-list Is the name of one or more data objects or functions. The name can
optionally be followed by any of the following:
• An array specification, if the object is an array.
In a function declaration, an array must be a deferred-shape array
if it has the POINTER attribute; otherwise, it must be an explicit-
shape array.
• A character length, if the object is of type character.
• A coarray specification, if the object is a coarray.
• A constant expression preceded by an = or, for pointer objects, =>
NULL( ).
Description
A polymorphic object can have differing types during program execution.
The type of the object at a particular point during execution of a program is its dynamic type.
The declared type of a data entity is the type that it is declared to have, either explicitly or implicitly.
If CLASS (*) is specified, it denotes an unlimited polymorphic object. An unlimited polymorphic entity is not
declared to have a type. It is not considered to have the same declared type as any other entity, including
another unlimited polymorphic entity.
An entity declared with the CLASS keyword must be a dummy argument or have the ALLOCATABLE or
POINTER attribute.
A polymorphic entity that is not an unlimited polymorphic entity is type compatible with entities of the same
declared type or any of its extensions. Even though an unlimited polymorphic entity is not considered to have
a declared type, it is type compatible with all entities. An entity is said to be type compatible with a type if it
is type compatible with entities of that type.
A polymorphic allocatable object can be allocated to be of any type with which it is type compatible.
During program execution, a polymorphic pointer or dummy argument can be associated with objects with
which it is type compatible.
See Also
Type declarations
TYPE Statement (Derived Types)
CLEARSTATUSFPQQ
Portability Subroutine: Clears the exception flags in
the floating-point processor status word.
Module
USE IFPORT
1318
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL CLEARSTATUSFPQQ()
Description
The floating-point status word indicates which floating-point exception conditions have occurred. Intel®
Fortran initially clears (sets to 0) all floating-point status flags, but as exceptions occur, the status flags
accumulate until the program clears the flags again. CLEARSTATUSFPQQ will clear the flags.
CLEARSTATUSFPQQ is appropriate for use in applications that poll the floating-point status register as the
method for detecting a floating-point exception has occurred.
For a full description of the floating-point status word, exceptions, and error handling, see Floating-Point
Operations: Floating-Point Environment.
Example
USE IFPORT
REAL*4 A,B,C
INTEGER*2 STS
A = 2.0E0
B = 0.0E0
END
This program is available in the online samples.
See Also
GETSTATUSFPQQ
1319
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SETCONTROLFPQQ
GETCONTROLFPQQ
SIGNALQQ
CLOCK
Portability Function: Converts a system time into an
8-character ASCII string.
Module
USE IFPORT
Syntax
result = CLOCK( )
Results
The result type is character with a length of 8. The result is the current time in the form hh:mm:ss, using a
24-hour clock.
Example
USE IFPORT
character(8) whatimeisit
whatimeisit = CLOCK ()
print *, 'The current time is ',whatimeisit
See Also
DATE_AND_TIME
CLOCKX
Portability Subroutine: Returns the processor clock
in units of microseconds.
Module
USE IFPORT
Syntax
CALL CLOCKX (clock)
On Windows systems, this subroutine has millisecond precision, and the last three digits of the returned
value are not significant.
CLOSE
Statement: Disconnects a file from a unit.
Syntax
CLOSE ( [UNIT=] io-unit[, {STATUS | DISPOSE | DISP} = p] [, ERR= label] [, IOMSG=msg-var]
[, IOSTAT=i-var])
1320
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
label Is the label of the branch target statement that receives control if an
error occurs.
Description
The CLOSE statement specifiers can appear in any order. An I/O unit must be specified, but the UNIT=
keyword is optional if the unit specifier is the first item in the I/O control list.
The status specified in the CLOSE statement supersedes the status specified in the OPEN statement, except
that a file opened as a scratch file cannot be saved, printed, or submitted, and a file opened for read-only
access cannot be deleted.
If a CLOSE statement is specified for a unit that is not open, it has no effect.
You do not need to explicitly close open files. Normal program termination closes each file according to its
default status. The CLOSE statement does not have to appear in the same program unit that opened the file.
Closing unit 0 automatically reconnects unit 0 to the keyboard and screen. Closing units 5 and 6
automatically reconnects those units to the keyboard or screen, respectively.Closing the asterisk (*) unit
causes a compile-time error. In Windows QuickWin applications, use CLOSE with unit 0, 5, or 6 to close the
default window. If all of these units have been detached from the console (through an explicit OPEN), you
must close one of these units beforehand to reestablish its connection with the console. You can then close
the reconnect unit to close the default window.
If a parameter of the CLOSE statement is an expression that calls a function, that function must not cause an
I/O operation or the EOF intrinsic function to be executed, because the results are unpredictable.
1321
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
You may get unexpected results if you specify OPEN with a filename and a USEROPEN
specifier that opens a different filename, and then use a CLOSE statement with
STATUS=DELETE (or DISPOSE=DELETE). In this case, the run-time library assumes you
want to delete the file named in the OPEN statement, not the one you specified in the
USEROPEN function. For more information about how to use the USEROPEN specifier, see
User-Supplied OPEN Procedures: USEROPEN Specifier.
Example
! Close and discard file:
CLOSE (7, STATUS = 'DELETE')
Consider the following statement:
See Also
Data Transfer I/O Statements
Branch Specifiers
CMPLX
Elemental Intrinsic Function (Specific): Converts
the argument to complex type. This function cannot
be passed as an actual argument.
Syntax
This intrinsic function can take one of the following forms:
result = CMPLX (x [,kind])
or
result = CMPLX (x [,y ,kind])
Results
The result type is complex. If kind is present, the kind parameter is that specified by kind; otherwise, the
kind parameter is that of default real type.
If x is type complex, y must not be specified, and the result value is CMPLX (REAL (x), AIMAG (x)), with
default kind if kind is not present, otherwise with the kind type as specified by kind.
If x is present and not of complex type, and y is not present, x is converted into the real part of the result
value and zero is assigned to the imaginary part.
1322
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If x and y are present, the complex value is produced by converting the x into the real part of the value, and
converting the y into the imaginary part.
CMPLX (x, y, kind) has the complex value whose real part is REAL (x, kind) and whose imaginary part is
REAL (y, kind).
The setting of compiler options specifying real size can affect this function.
If the argument is a binary, octal, or hexadecimal literal constant, the result is affected by the
assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that
represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is
specified, the argument is treated as a signed integer and the bits are converted.
NOTE
The result values of CMPLX are defined by references to the intrinsic function REAL with the
same arguments. Therefore, the padding and truncation of binary, octal, and hexadecimal
literal constant arguments to CMPLX is the same as for the intrinsic function REAL.
Example
CMPLX (-3) has the value (-3.0, 0.0).
CMPLX (4.1, 2.3) has the value (4.1, 2.3).
The following shows another example:
COMPLEX z1, z2
COMPLEX(8) z3
z1 = CMPLX(3) ! returns the value 3.0 + i 0.0
z2 = CMPLX(3,4) ! returns the value 3.0 + i 4.0
z3 = CMPLX(3,4,8) ! returns a COMPLEX(8) value 3.0D0 + i 4.0D0
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
DCMPLX
FLOAT
INT
IFIX
REAL
SNGL
CO_BROADCAST
Collective Intrinsic Subroutine (Generic):
Broadcasts a value to other images.
Syntax
CALL CO_BROADCAST (a, source_image [, stat, errmsg])
a (Input; output) Must have the same shape, dynamic type, and type
parameter values in corresponding references across all participating
images. It cannot be a coindexed object. If an error occurs, it
becomes undefined. Otherwise, a becomes defined as if by intrinsic
assignment with the value a on image source_image on all images of
the current team.
1323
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
source_image (Input) Must be a scalar integer. The value of source_image must the
value of an image index of an image on the current team. Its value
must be the same in corresponding references on all images
participating in the collective operation.
Example
Consider the following:
See Also
Overview of Collective Subroutines
CO_MAX
Collective Intrinsic Subroutine (Generic):
Calculates the maximum value across images.
Syntax
CALL CO_MAX (a [, result_image, stat, errmsg])
a (Input; output) Must be of type real, integer, or charater, and have the
same shape, type, and type parameter values in corresponding
references across all images of the current team. It cannot be a
coindexed object. If it is scalar, the computed value is the maximum
value of a in all corresponding references. If it is an array, each
element of the computed value is equal to the maximum value of the
corresponding element of a in all corresponding references.
If no error occurs, the computed value is assigned to a on all images
of the current team if result_image is not present, or on the executing
image if the executing image is the image identified by result_image.
Otherwise, a becomes undefined.
1324
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Collective Subroutines
CO_MIN
Collective Intrinsic Subroutine (Generic):
Calculates the minimum value across images.
Syntax
CALL CO_MIN (a [, result_image, stat, errmsg])
a (Input; output) Must be of type real, integer, or charater, and have the
same shape, type, and type parameter values in corresponding
references across all images of the current team. It cannot be a
coindexed object. If it is scalar, the computed value is the minimum
value of a in all corresponding references. If it is an array, each
element of the computed value is equal to the maximum value of the
corresponding element of a in all corresponding references.
If no error occurs, the computed value is assigned to a on all images
of the current team if result_image is not present, or on the executing
image if the executing image is the image identified by result_image.
Otherwise, a becomes undefined.
1325
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
Overview of Collective Subroutines
CO_REDUCE
Collective Intrinsic Subroutine (Generic):
Performs generalized reduction across images.
Syntax
CALL CO_REDUCE (a, operation [, result_image, stat, errmsg])
operation Is a pure function with exactly two arguments whose result and each
argument are a scalar, nonallocatable, nonpointer, nonpolymorphic
data object with the same type and kind type parameters as a.
Neither argument can be optional. If one argument has the attribute
TARGET, VOLATILE, or ASYNCHRONOUS, the other argument must
have that attribute. operation must implement a mathematical
associative operation and be the same in each corresponding
reference. If operation is not commutative, the computed value may
depend on the order of evaluation.
The computed value of a reduction operation over a set of values is
the result of an iterative process. Each iteration evaluates operation
(x, y) for x and y in that set, the removal of x and y from that set, and
the addition of the result of operation (x, y) to that set. The process
ends when the set has a single value, which is the computed value.
1326
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following subroutine demonstrates how CO_REDUCE can be used to create a collective version of the
intrinsic function ANY.
See Also
Overview of Collective Subroutines
CO_SUM
Collective Intrinsic Subroutine (Generic):
Performs a sum reduction across images.
Syntax
CALL CO_SUM (a [, result_image, stat, errmsg])
1327
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
CODE_ALIGN
General Compiler Directive: Specifies the byte
alignment for a loop.
Syntax
!DIR$ CODE_ALIGN [:n]
Example
Consider the following code fragment in file test_code_align.f90:
!DIR$ CODE_ALIGN
DO J = 1, N
…
END DO
1328
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Compiling test_code_align.f90 aligns the code that begins the DO J loop on a (default) 16-byte boundary.
If you do not specify the CODE_ALIGN directive, the alignment of the loop is implementation-dependent and
may change from compilation to compilation.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
falign-loops, Qalign-loops compiler option
ATTRIBUTES CODE_ALIGN directive
CODIMENSION
Statement and Attribute: Specifies that an entity is
a coarray, and specifies its corank and cobounds, if
any.
Syntax
The CODIMENSION attribute can be specified in a type declaration statement or a CODIMENSION statement,
and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] CODIMENSION [coarray-spec] :: var-list [(array-spec)]...
type, [att-ls,] var-list [(array-spec)] [coarray-spec]...
Statement:
CODIMENSION [::] var-list [coarray-spec]...
Description
In Intel® Fortran, the sum of the rank and corank of an entity must not exceed 31. The Fortran 2018
Standard allows a combined rank of up to 15.
A coarray must be a component or a variable that is not a function result.
A coarray must not be of type C_PTR or C_FUNPTR from the intrinsic module ISO_C_BINDING or of type
TEAM_TYPE from the intrinsic module ISO_FORTRAN_ENV.
An entity whose type has a coarray ultimate component must be a nonpointer nonallocatable scalar, must not
be a coarray, and must not be a function result.
A coarray or an object with a coarray ultimate component must be an associate name, a dummy argument,
or have the ALLOCATABLE or SAVE attribute.
A coarray must not be a dummy argument of a procedure that has a BIND attribute.
A coarray can be a derived type with pointer or allocatable components. The target of such a pointer
component is always on the same image as the pointer.
1329
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
Explicit-shape coarrays that are not dummy arguments must have the SAVE attribute. Because of this,
automatic coarrays are not allowed. For example, coarray TASK in the following code is not valid:
SUBROUTINE SUBA(I,C,D)
INTEGER :: I
REAL :: C(I)[*], D(I)
REAL :: TASK(I)[*] ! Not permitted
The following lines show valid examples of CODIMENSION attribute specifications:
COLLAPSE Clause
Parallel Directive Clause: Specifies how many loops
are associated with a loop construct.
Syntax
COLLAPSE (n)
If COLLAPSE is not specified, the only loop that is associated with the loop construct is the one that
immediately follows the construct.
At most one COLLAPSE clause can appear in a directive that allows the clause.
See Nested DO Constructs for restrictions on perfectly nested loops using COLLAPSE.
If more than one loop is associated with a TASKLOOP construct, then the iterations of all associated loops are
collapsed into one larger iteration space that is then divided according to the specifications in the GRAINSIZE
and NUM_TASKS clauses. The sequential execution of the iterations in all associated loops determines the
order of the iterations in the collapsed iteration space.
COMMAND_ARGUMENT_COUNT
Inquiry Intrinsic Function (Generic): Returns the
number of command arguments.
Syntax
result = COMMAND_ARGUMENT_COUNT ()
1330
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default integer. The result value is equal to the number of command arguments
available. If there are no command arguments available, the result is 0. The command name does not count
as one of the command arguments.
Example
Consider the following:
program echo_command_line
integer i, cnt, len, status
character c*30, b*100
cnt = command_argument_count ()
write (*,*) 'number of command arguments = ', cnt
do i = 1, cnt
call get_command_argument (i, c, len, status)
if (status .ne. 0) then
write (*,*) 'get_command_argument failed: status = ', status, ' arg = ', i
stop
end if
write (*,*) 'command arg ', i, ' = ', c (1:len)
end do
1331
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GET_COMMAND
GET_COMMAND_ARGUMENT
COMMITQQ
Run-Time Function: Forces the operating system to
execute any pending write operations for the file
associated with a specified unit to the file's physical
device.
Module
USE IFCORE
Syntax
result = COMMITQQ (unit)
Results
The result type is LOGICAL(4). If an open unit number is supplied, .TRUE. is returned and uncommitted
records (if any) are written. If an unopened unit number is supplied, .FALSE. is returned.
Data written to files on physical devices is often initally written into operating-system buffers and then
written to the device when the operating system is ready. Data in the buffer is automatically flushed to disk
when the file is closed. However, if the program or the computer crashes before the data is transferred from
buffers, the data can be lost. COMMITQQ tells the operating system to write any cached data intended for a
file on a physical device to that device immediately. This is called flushing the file.
COMMITQQ is most useful when you want to be certain that no loss of data occurs at a critical point in your
program; for example, after a long calculation has concluded and you have written the results to a file, or
after the user has entered a group of data items, or if you are on a network with more than one program
sharing the same file. Flushing a file to disk provides the benefits of closing and reopening the file without
the delay.
Example
USE IFCORE
INTEGER unit / 10 /
INTEGER len
CHARACTER(80) stuff
OPEN(unit, FILE='COMMITQQ.TST', ACCESS='Sequential')
DO WHILE (.TRUE.)
WRITE (*, '(A, \)') 'Enter some data (Hit RETURN to &
exit): '
len = GETSTRQQ (stuff)
IF (len .EQ. 0) EXIT
WRITE (unit, *) stuff
IF (.NOT. COMMITQQ(unit)) WRITE (*,*) 'Failed'
END DO
CLOSE (unit)
END
See Also
PRINT
WRITE
1332
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMMON
Statement: Defines one or more contiguous areas, or
blocks, of physical storage (called common blocks)
that can be accessed by any of the scoping units in an
executable program. COMMON statements also define
the order in which variables and arrays are stored in
each common block, which can prevent misaligned
data items. COMMON is an obsolescent language
feature in Standard Fortran.
Syntax
COMMON [ /[cname]/] var-list[[,] /[cname]/ var-list]...
cname (Optional) Is the name of the common block. The name can be
omitted for blank common (//).
Description
Common blocks can be named or unnamed (a blank common).
A common block is a global entity, and must not have the same name as any other global entity in the
program, such as a subroutine or function.
Any common block name (or blank common) can appear more than once in one or more COMMON
statements in a program unit. The list following each successive appearance of the same common block
name is treated as a continuation of the list for the block associated with that name. Consider the following
COMMON statements:
• A dummy argument
• A result variable
• An allocatable variable
• A derived-type object with an ultimate component that is allocatable
• A procedure pointer
• An automatic object
• A variable with the BIND attribute
• An unlimited polymorphic pointer
• A coarray
1333
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If an array is specified, it can be followed by an explicit-shape array specification, each bound of which must
be a constant specification expression. Such an array must not have the POINTER attribute.
A pointer can only be associated with pointers of the same type and kind parameters, and rank.
An object with the TARGET attribute can only be associated with another object with the TARGET attribute
and the same type and kind parameters.
A nonpointer can only be associated with another nonpointer, but association depends on their types, as
follows:
Any other intrinsic type Must have the same type and kind parameters
So, variables can be associated if they are of different numeric type. For example, the following is valid:
INTEGER A(20)
REAL Y(20)
COMMON /QUANTA/ A, Y
When common blocks from different program units have the same name, they share the same storage area
when the units are combined into an executable program.
Entities are assigned storage in common blocks on a one-for-one basis. So, the data type of entities assigned
by a COMMON statement in one program unit should agree with the data type of entities placed in a common
block by another program unit. For example:
...
When these program units are combined into an executable program, incorrect results can occur if the 2-byte
integer variable MONEY is made to correspond to the lower-addressed two bytes of the real variable CENTS.
Named common blocks must be declared to have the same size in each program unit. Blank common can
have different lengths in different program units.
NOTE
If a common block is initialized by a DATA statement, the module containing the initialization
must declare the common block to be its maximum defined length.
This limitation does not apply if you compile all source modules together.
1334
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
PROGRAM MyProg
COMMON i, j, x, k(10)
COMMON /mycom/ a(3)
...
END
SUBROUTINE MySub
COMMON pe, mn, z, idum(10)
COMMON /mycom/ a(3)
...
END
In the following example, the COMMON statement in the main program puts HEAT and X in blank common,
and KILO and Q in a named common block, BLK1:
...
CALL FIGURE
... RETURN
END
The COMMON statement in the subroutine makes ALFA and BET share the same storage location as HEAT and
X in blank common. It makes LIMA and R share the same storage location as KILO and Q in BLK1.
The following example shows how a COMMON statement can be used to declare arrays:
SUBROUTINE unit1
REAL(8) x(5)
INTEGER J
CHARACTER str*12
TYPE(member) club(50)
COMMON / blocka / x, j, str, club
...
SUBROUTINE unit2
REAL(8) z(5)
INTEGER m
CHARACTER chr*12
TYPE(member) myclub(50)
COMMON / blocka / z, m, chr, myclub
...
See also the example for BLOCK DATA.
See Also
BLOCK DATA
DATA
1335
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE
EQUIVALENCE
Specification expressions
Storage association
Interaction between COMMON and EQUIVALENCE Statements
Obsolescent Language Features in the Fortran Standard
COMPILER_OPTIONS
Module Intrinsic Inquiry Function: Returns a
string containing the compiler options that were used
for compilation.
Module
USE ISO_FORTRAN_ENV
Syntax
result = COMPILER_OPTIONS( )
Results
The result is a scalar of type default character of processor-defined length.
The return value is a list of the compiler options that were used for compilation.
Example
Consider the following file named t.f90:
use ISO_FORTRAN_ENV
res = compiler_options ()
print *, "len of res is: ", len (res)
print *, "('<<', A, '>>')") res
deallocate (res)
end
The following is the output:
Linux
-out:t.exe
-subsystem:console
1336
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
t.obj
Win> t.exe
len of compiler_options is: 48
<</exe:t /warn:alignments /assume:writeable-strings>>
See Also
COMPILER_VERSION
ISO_FORTRAN_ENV Module
COMPILER_VERSION
Module Intrinsic Inquiry Function: Returns a
string containing the name and version number of the
compiler used for compilation.
Module
USE ISO_FORTRAN_ENV
Syntax
result = COMPILER_VERSION( )
Results
The result is a scalar of type default character of processor-defined length.
The return value contains the name and version number of the compiler used for compilation.
Example
Consider the following file named t.f90:
use ISO_FORTRAN_ENV
res = compiler_version ()
print *, "len of res is: ", len (res)
print *, "('<<', A, '>>')", res
deallocate (res)
close (1)
end
The following is the output:
Linux
Lin$
1337
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Windows
-out:t.exe
-subsystem:console
t.obj
Win> t.exe
len of res is: 184
Win>
See Also
COMPILER_OPTIONS
ISO_FORTRAN_ENV Module
COMPLEX Statement
Statement: Specifies the COMPLEX data type.
Syntax
COMPLEX
COMPLEX([KIND=] n)
COMPLEX*s
DOUBLE COMPLEX
n Is kind 4, 8, or 16.
If a kind parameter is specified, the complex constant has the kind specified. If no kind parameter is
specified, the kind of both parts is default real, and the constant is of type default complex.
DOUBLE COMPLEX is COMPLEX(8). No kind parameter is permitted for data declared with type DOUBLE
COMPLEX.
Example
COMPLEX ch
COMPLEX (KIND=4),PRIVATE :: zz, yy !equivalent to COMPLEX*8 zz, yy
COMPLEX(8) ax, by !equivalent to COMPLEX*16 ax, by
COMPLEX (kind(4)) y(10)
complex (kind=8) x, z(10)
See Also
DOUBLE COMPLEX
1338
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = COMPLINT (intval)
result = COMPREAL (realval)
result = COMPLLOG (logval)
Results
The result is INTEGER(4) for COMPLINT, REAL(4) for COMPLREAL and LOGICAL(4) for COMPLLOG with a
value that is the bitwise complement of the argument.
CONJG
Elemental Intrinsic Function (Generic): Calculates
the conjugate of a complex number.
Syntax
result = CONJG (z)
Results
The result type and kind are the same as z. If z has the value (x, y), the result has the value (x, -y).
Example
CONJG ((2.0, 3.0)) has the value (2.0, -3.0).
CONJG ((1.0, -4.2)) has the value (1.0, 4.2).
1339
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX z1
COMPLEX(8) z2
z1 = CONJG((3.0, 5.6)) ! returns (3.0, -5.6)
z2 = DCONJG((3.0D0, 5.6D0)) ! returns (3.0D0, -5.6D0)
See Also
AIMAG
CONTAINS
Statement: Separates the body of a main program,
module, submodule, or external subprogram from any
internal or module procedures it may contain, or it
introduces the type-bound procedure part of a
derived-type definition. It is not executable.
Syntax
CONTAINS
Any number of internal procedures can follow a CONTAINS statement, but a CONTAINS statement cannot
appear in the internal procedures themselves.
An empty CONTAINS section is allowed.
Example
PROGRAM OUTER
REAL, DIMENSION(10) :: A
. . .
CALL INNER (A)
CONTAINS
SUBROUTINE INNER (B)
REAL, DIMENSION(10) :: B
. . .
END SUBROUTINE INNER
END PROGRAM OUTER
See Also
Internal Procedures
Modules and Module Procedures
Main Program
CONTIGUOUS
Statement and Attribute: Specifies that the target
of a pointer or an assumed-sized array is contiguous.
Syntax
The CONTIGUOUS attribute can be specified in a type declaration statement or an CONTIGUOUS statement,
and takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] CONTIGUOUS [, att-ls] :: object [, object] ...
Statement:
CONTIGUOUS [::] object [, object] ...
1340
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
This attribute explicitly indicates that an assumed-shape array is contiguous or that a pointer will only be
associated with a contiguous object.
An entity can be contiguous even if CONTIGUOUS is not specified. An object is contiguous if it is one of the
following:
An object is not contiguous if it is an array subobject, and all of the following are true:
The CONTIGUOUS attribute can make it easier to enable optimizations that rely on the memory layout of an
object occupying a contiguous block of memory.
Examples
The following examples show valid CONTIGUOUS statements:
See Also
Type Declarations
Compatible attributes
CONTINUE
Statement: Primarily used to terminate a labeled DO
construct when the construct would otherwise end
improperly with either a GO TO, arithmetic IF, or other
prohibited control statement.
Syntax
CONTINUE
1341
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The statement by itself does nothing and has no effect on program results or execution sequence.
Example
The following example shows a CONTINUE statement:
DO 150 I = 1,40
40 Y = Y + 1
Z = COS(Y)
PRINT *, Z
IF (Y .LT. 30) GO TO 150
GO TO 40
150 CONTINUE
The following shows another example:
DIMENSION narray(10)
DO 100 n = 1, 10
narray(n) = 120
100 CONTINUE
See Also
END DO
DO
Execution Control
COPYIN Clause
Parallel Directive Clause: Specifies that the data in
the primary thread of the team is to be copied to the
thread private copies of the common block at the
beginning of the parallel region.
Syntax
COPYIN (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
COPYPRIVATE Clause
Parallel Directive Clause: Uses a private variable to
broadcast a value, or a pointer to a shared object,
from one member of a team to the other members.
The COPYPRIVATE clause can only appear in the END
SINGLE directive.
Syntax
COPYPRIVATE (list)
1342
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
Variables in the list must not appear in a PRIVATE or FIRSTPRIVATE clause for the SINGLE directive
construct. A dummy argument that is a pointer with the INTENT (IN) attribute must not appear in a
COPYPRIVATE clause.
If the directive is encountered in the dynamic extent of a parallel region, variables in the list must be private
in the enclosing context.
If a common block is specified, it must be declared as THREADPRIVATE; the effect is the same as if the
variable names in its common block object list were specified.
The effect of the COPYPRIVATE clause on the variables in its list occurs after the execution of the code
enclosed within the SINGLE construct, and before any threads in the team have left the barrier at the end of
the construct.
NOTE
This construct is not supported within a TARGET or a DECLARE TARGET region if the target hardware is
spir64.
COS
Elemental Intrinsic Function (Generic): Produces
the cosine of an argument.
Syntax
result = COS (x)
Results
The result type and kind are the same as x.
If x is of type real, the result is a value in radians.
If x is of type complex, the real part of the result is a value in radians.
1343
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
COS (2.0) has the value -0.4161468.
COS (0.567745) has the value 0.8431157.
COSD
Elemental Intrinsic Function (Generic): Produces
the cosine of x.
Syntax
result = COSD (x)
Results
The result type and kind are the same as x.
Example
COSD (2.0) has the value 0.9993908.
COSD (30.4) has the value 0.8625137.
COSH
Elemental Intrinsic Function (Generic): Produces
a hyperbolic cosine.
Syntax
result = COSH (x)
Results
The result type and kind are the same as x.
If x is of type complex, the imaginary part of the result is in radians.
Example
COSH (2.0) has the value 3.762196.
1344
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COSHAPE
Inquiry Intrinsic Function (Generic): Returns the
sizes of codimensions of a coarray.
Syntax
result = COSHAPE (coarray [, kind])
Results
The result is an integer array of rank one whose size is equal to the corank of coarray. If kind is present, the
kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is that of
default integer.
The result has a value whose ith element is equal to the size of the ith codimension of coarray as provided by
UCOBOUND(coarray, i) − LCOBOUND(coarray, i) + 1.
The setting of compiler options specifying integer size can affect this function.
Example
Consider the following coarray declaration:
• RANK (X) == 2
• corank of X == 3
• SHAPE (X) == [10,20]
• COSHAPE (X) == [10,10,2]
• LCOBOUND (X) == [1, -1, 0]
• UCOBOUND (X) == [10, 8, 1]
See Also
Coarrays
Using Coarrays
CODIMENSION
LCOBOUND
UCOBOUND
COTAN
Elemental Intrinsic Function (Generic): Produces
the cotangent of x.
Syntax
result = COTAN (x)
1345
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x.
Example
COTAN (2.0) has the value -4.576575E-01.
COTAN (0.6) has the value 1.461696.
COTAND
Elemental Intrinsic Function (Generic): Produces
the cotangent of x.
Syntax
result = COTAND (x)
Results
The result type and kind are the same as x.
Example
COTAND (2.0) has the value 0.2863625E+02.
COTAND (0.6) has the value 0.9548947E+02.
COUNT
Transformational Intrinsic Function (Generic):
Counts the number of true elements in an entire array
or in a specified dimension of an array.
Syntax
result = COUNT (mask[,dim][, kind])
1346
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is an array or a scalar of type integer. If kind is present, the kind parameter of the result is that
specified by kind; otherwise, the kind parameter of the result is that of default integer. If the processor
cannot represent the result value in the kind of the result, the result is undefined.
The result is a scalar if dim is omitted or mask has rank one. A scalar result has a value equal to the number
of true elements of mask. If mask has size zero, the result is zero.
An array result has a rank that is one less than mask, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2,..., dn) is the shape of mask.
Each element in an array result equals the number of elements that are true in the one dimensional array
defined by mask(s1, s2, ..., sdim-1, :, sdim+1, ..., sn).
Example
COUNT ((/.TRUE., .FALSE., .TRUE./)) has the value 2 because two elements are true.
COUNT ((/.TRUE., .TRUE., .TRUE./)) has the value 3 because three elements are true.
A is the array
[ 1 5 7 ]
[ 3 6 8 ]
and B is the array
[ 0 5 7 ]
[ 2 6 9 ].
COUNT (A .NE. B, DIM=1) tests to see how many elements in each column of A are not equal to the
elements in the corresponding column of B. The result has the value (2, 0, 1) because:
• The first column of A and B have 2 elements that are not equal.
• The second column of A and B have 0 elements that are not equal.
• The third column of A and B have 1 element that is not equal.
COUNT (A .NE. B, DIM=2) tests to see how many elements in each row of A are not equal to the elements in
the corresponding row of B. The result has the value (1, 2) because:
• The first row of A and B have 1 element that is not equal.
• The second row of A and B have 2 elements that are not equal.
The following shows another example:
See Also
ALL
ANY
1347
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CPU_TIME
Intrinsic Subroutine (Generic): Returns a
processor-dependent approximation of the processor
time in seconds. Intrinsic subroutines cannot be
passed as actual arguments.
Syntax
CALL CPU_TIME (time)
The time returned is summed over all active threads. The result is the sum (in units of seconds) of the
current process's user time and the user and system time of all its child processes, if any.
If a meaningful time cannot be returned, a processor-dependent negative value is returned.
NOTE
If you want to estimate performance or scaling of multithreaded applications, you should use intrinsic
subroutine SYSTEM_CLOCK or portability function DCLOCK. Both of these routines return the elapsed
time from a single clock.
Example
Consider the following:
See Also
DCLOCK
SYSTEM_CLOCK
CRITICAL Directive
OpenMP* Fortran Compiler Directive: Restricts
access to a block of code to only one thread at a time.
Syntax
!$OMP CRITICAL [(name)]
loosely-structured-block
!$OMP END CRITICAL [(name)]
-or-
!$OMP CRITICAL [(name)]
strictly-structured-block
!$OMP END CRITICAL [(name)]
1348
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding thread set for a CRITICAL construct is all threads in the contention group. Region execution is
restricted to a single thread at a time among all threads in the contention group, without regard to the teams
to which the threads belong.
A thread waits at the beginning of a critical section until no other thread in the team is executing a critical
section having the same name. All unnamed CRITICAL directives map to the same name.
If a name is specified in the CRITICAL directive, the same name must appear in the corresponding END
CRITICAL directive. If no name appears in the CRITICAL directive, no name can appear in the corresponding
END CRITICAL directive.
Critical section names are global entities of the program. If the name specified conflicts with any other entity,
the behavior of the program is undefined.
Example
The following example shows a queuing model in which a task is dequeued and worked on. To guard against
multiple threads dequeuing the same task, the dequeuing operation is placed in a critical section.
Because there are two independent queues in this example, each queue is protected by CRITICAL directives
having different names, XAXIS and YAXIS, respectively:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
CRITICAL Statement
Statement: Marks the beginning of a CRITICAL
construct. A CRITICAL construct limits execution of a
block to one image at a time.
Syntax
[name:] CRITICAL [([STAT=stat-var] [, ERRMSG=err-var])]
block
END CRITICAL [name]
1349
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a construct name is specified in a CRITICAL statement, the same name must appear in the corresponding
END CRITICAL statement. If no name is specified at the beginning of a CRITICAL statement, you cannot
specify one following the END CRITICAL statement. The same construct name must not be used for different
named constructs in the same scoping unit.
The block of a CRITICAL construct must not contain a RETURN statement or an image control statement.
A branch within a CRITICAL construct must not have a branch target that is outside the construct. A branch
to the END CRITICAL statement is permitted from within the construct.
STAT= and ERRMSG= specifiers can appear in any order. Each may appear at most once.
Execution of the CRITICAL construct is completed when execution of its block is completed. A procedure that
is invoked, directly or indirectly, from a CRITICAL construct must not execute an image control statement.
If no error condition occurs during the execution of the construct, stat-var becomes defined with the value
zero. If the image that previously entered the construct failed while executing the construct, stat-var
becomes defined with the value STAT_FAILED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV. If
any other error occurs and STAT= is specified, stat-var becomes defined with a positive integer value other
than that of STAT_FAILED_IMAGE. Otherwise, if an error occurs, error termination is initiated.
If ERRMSG= is specified and an error condition occurs during execution of the construct, err-var becomes
defined with a descriptive message describing the nature of the error.
The processor ensures that once an image has commenced executing block, no other image can start
executing block until this image has completed executing block. The image must not execute an image
control statement during the execution of block. The sequence of executed statements is therefore a
segment. If image S is the next to execute the construct after image N, the segment on image N precedes
the segment on image S.
If more than one image executes the block of a CRITICAL construct, its execution by one image always
precedes or succeeds its execution by another image. Normally no other statement ordering is needed.
Example
Consider the following example:
CONA: CRITICAL
MY_COUNTER[1] = MY_COUNTER[1] + 1
END CRITICAL CONA
The definition of MY_COUNTER [1] by a particular image will always precede the reference to the same
variable by the next image to execute the block.
The following example shows a way to share a large number of tasks among images:
1350
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Image Control Statements
Coarrays
Using Coarrays
ISO_FORTRAN_ENV Module
CSHIFT
Transformational Intrinsic Function (Generic):
Performs a circular shift on a rank-one array, or
performs circular shifts on all the complete rank-one
sections (vectors) along a given dimension of an array
of rank two or greater.
Syntax
Elements shifted off one end are inserted at the other end. Different sections can be shifted by different
amounts and in different directions.
result = CSHIFT (array,shift [,dim])
array (Input) Array whose elements are to be shifted. It can be of any data
type.
dim (Input; optional) Optional dimension along which to perform the shift.
Must be a scalar integer with a value in the range 1 to n, where n is
the rank of array. If dim is omitted, it is assumed to be 1.
Results
The result is an array with the same type and kind parameters, and shape as array.
If array has rank one, element i of the result is array(1 + MODULO (i + shift- 1, SIZE ( array))). (The same
shift is applied to each element.)
If array has rank greater than one, each section (s1,s2, ..., sdim-1, :, sdim+1, ..., sn) of the result is shifted as
follows:
• By the value of shift, if shift is scalar
• According to the corresponding value in shift(s1, s2,..., sdim-1, sdim+1,..., sn), if shift is an array
The value of shift determines the amount and direction of the circular shift. A positive shift value causes a
shift to the left (in rows) or up (in columns). A negative shift value causes a shift to the right (in rows) or
down (in columns). A zero shift value causes no shift.
Example
V is the array (1, 2, 3, 4, 5, 6).
CSHIFT (V, SHIFT=2) shifts the elements in V circularly to the left by 2 positions, producing the value (3, 4,
5, 6, 1, 2). 1 and 2 are shifted off the beginning and inserted at the end.
1351
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CSHIFT (V, SHIFT= -2) shifts the elements in V circularly to the right by 2 positions, producing the value (5,
6, 1, 2, 3, 4). 5 and 6 are shifted off the end and inserted at the beginning.
M is the array
[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ].
CSHIFT (M, SHIFT = 1, DIM = 2) produces the result
[ 2 3 1 ]
[ 5 6 4 ]
[ 8 9 7 ].
Each element in rows 1, 2, and 3 is shifted to the left by 1 position. The elements shifted off the beginning
are inserted at the end.
CSHIFT (M, SHIFT = -1, DIM = 1) produces the result
[ 7 8 9 ]
[ 1 2 3 ]
[ 4 5 6 ].
Each element in columns 1, 2, and 3 is shifted down by 1 position. The elements shifted off the end are
inserted at the beginning.
CSHIFT (M, SHIFT = (/1, -1, 0/), DIM = 2) produces the result
[ 2 3 1 ]
[ 6 4 5 ]
[ 7 8 9 ].
Each element in row 1 is shifted to the left by 1 position; each element in row 2 is shifted to the right by 1
position; no element in row 3 is shifted at all.
The following shows another example:
See Also
EOSHIFT
ISHFT
ISHFTC
1352
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CSMG
Portability Function: Performs an effective BIT-
WISE store under mask.
Module
USE IFPORT
Syntax
result = CSMG (x,y,z)
x, y, z (Input) INTEGER(4).
Results
The result type is INTEGER(4). The result is equal to the following expression:
(x & z) | (y & ~z )
where "&" is a bitwise AND operation, | - bitwise OR, ~ - bitwise NOT.
The function returns the value based on the following rule: when a bit in z is 1, the output bit is taken from
x. When a bit in z is zero, the corresponding output bit is taken from y.
CTIME
Portability Function: Converts a system time into a
24-character ASCII string.
Module
USE IFPORT
Syntax
result = CTIME (stime)
Results
The result is a value in the form Mon Jan 31 04:37:23 1994. Hours are expressed using a 24-hour clock.
The value of stime can be determined by calling the TIME function. CTIME(TIME( )) returns the current time
and date.
Example
USE IFPORT
character (24) systime
systime = CTIME (TIME( ))
print *, 'Current date and time is ',systime
See Also
DATE_AND_TIME
CYCLE
Statement: Interrupts the current execution cycle of
the innermost (or named) DO construct.
1353
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CYCLE [name]
Description
When a CYCLE statement is executed, the following occurs:
1. The current execution cycle of the named (or innermost) DO construct is terminated.
If a DO construct name is specified, the CYCLE statement must be within the range of that construct.
2. The iteration count (if any) is decremented by 1.
3. The DO variable (if any) is incremented by the value of the increment parameter (if any).
4. A new iteration cycle of the DO construct begins.
Any executable statements following the CYCLE statement (including a labeled terminal statement) are not
executed.
A CYCLE statement can be labeled, but it cannot be used to terminate a DO construct.
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that
iteration of the construct.
Example
The following example shows a CYCLE statement:
DO I =1, 10
A(I) = C + D(I)
IF (D(I) < 0) CYCLE ! If true, the next statement is omitted
A(I) = 0 ! from the loop and the loop is tested again.
END DO
The following shows another example:
sample_loop: do i = 1, 5
print *,i
if( i .gt. 3 ) cycle sample_loop
print *,i
end do sample_loop
print *,'done!'
!output:
! 1
! 1
! 2
! 2
! 3
! 3
! 4
! 5
! done!
See Also
DO
DO WHILE
Execution Control
1354
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DATA
Statement: Assigns initial values to variables before
program execution.
Syntax
DATA var-list /clist/ [[,] var-list /clist/]...
-or-
DATA (var = const (, var = const)...)
kind-selector Is ( [KIND=] n ).
Description
A variable can be initialized only once in an executable program. A variable that appears in a DATA statement
and is typed implicitly can appear in a subsequent type declaration which may change the implicit typing.
1355
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The number of constants in c-list must equal the number of variables in var-list. The constants are assigned
to the variables in the order in which they appear (from left to right).
The following objects cannot be initialized in a DATA statement:
• A dummy argument
• A function
• A function result
• An automatic object
• An allocatable array
• A variable that is accessible by use or host association
• A variable in a named common block (unless the DATA statement is in a block data program unit)
• A variable in blank common
Except for variables in named COMMON blocks, a named variable has the SAVE attribute if any part of it is
initialized in a DATA statement. You can confirm this property by specifying the variable in a SAVE statement
or a type declaration statement containing the SAVE attribute.
When an unsubscripted array name appears in a DATA statement, values are assigned to every element of
that array in the order of subscript progression. If the associated constant list does not contain enough
values to fill the array, a warning is issued and the remaining array elements become undefined.
Array element values can be initialized in three ways: by name, by element, or by an implied-DO list
(interpreted in the same way as a DO construct).
The following conversion rules and restrictions apply to variable and constant list items:
• If the constant and the variable are both of numeric type, the following conversion occurs:
• The constant value is converted to the data type of the variable being initialized, if necessary.
• When a binary, octal, or hexadecimal constant is assigned to a variable or array element, the number
of digits that can be assigned depends on the data type of the data item. If the constant contains
fewer digits than the capacity of the variable or array element, the constant is extended on the left
with zeros. If the constant contains more digits than can be stored, the constant is truncated on the
left. An error results if any nonzero digits are truncated.
• If the constant and the variable are both of character type, the following conversion occurs:
• If the length of the constant is less than the length of the variable, the rightmost character positions of
the variable are initialized with blank characters.
• If the length of the constant is greater than the length of the variable, the character constant is
truncated on the right.
• If the constant is of numeric type and the variable is of character type, the following restrictions apply:
• The character variable must have a length of one character.
• The constant must be an integer, binary, octal, or hexadecimal constant, and must have a value in the
range 0 through 255.
When the constant and variable conform to these restrictions, the variable is initialized with the character
that has the ASCII code specified by the constant. (This lets you initialize a character object to any 8-bit
ASCII code.)
• If the constant is a Hollerith or character constant, and the variable is a numeric variable or numeric array
element, the number of characters that can be assigned depends on the data type of the data item.
If the Hollerith or character constant contains fewer characters than the capacity of the variable or array
element, the constant is extended on the right with blank characters. If the constant contains more
characters than can be stored, the constant is truncated on the right.
1356
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows the four ways that DATA statements can initialize array element values:
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
TYPE(EMPLOYEE) MAN_NAME, CON_NAME
DATA MAN_NAME / EMPLOYEE(417, 'Henry Adams') /
DATA CON_NAME%ID, CON_NAME%NAME /891, "David James"/
In the following example, the first DATA statement assigns zero to all 10 elements of array A, and four
asterisks followed by two blanks to the character variable STARS:
1357
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In this example, the character variable NAME is initialized with the value JOHN DOE with two trailing blanks
to fill out the declared length of the variable. The ten elements of MILES are initialized to zero. The two-
dimensional array SKEW is initialized so that its lower triangle is zero and its upper triangle is one. The
structures MYNAME and YOURS are declared using the derived type MEMBER. The derived-type variable
MYNAME is initialized by a structure constructor. The derived-type variable YOURS is initialized by supplying a
separate value for each component.
The first DATA statement in the previous example could also be written as:
INTEGER, POINTER :: P
DATA P/NULL( )/
END
The implied-DO limits can be any constant expressions in a DATA statement. For example:
See Also
CHARACTER
INTEGER
REAL
COMPLEX
COMMON
Data Types, Constants, and Variables
I/O Lists
Derived Data Types
Allocating Common Blocks
Syntax
CALL DATE (buf)
The date is returned as a 9-byte ASCII character string taking the form dd-mmm-yy, where:
If buf is of numeric type and smaller than 9 bytes, data corruption can occur.
1358
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If buf is of character type, its associated length is passed to the subroutine. If buf is smaller than 9 bytes,
the subroutine truncates the date to fit in the specified length. If an array of type character is passed, the
subroutine stores the date in the first array element, using the element length, not the length of the entire
array.
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
CHARACTER*1 DAY(9)
…
CALL DATE (DAY)
The length of the first array element in CHARACTER array DAY is passed to the DATE subroutine. The
subroutine then truncates the date to fit into the 1-character element, producing an incorrect result.
See Also
DATE_AND_TIME
Module
USE IFPORT
Syntax
Function Syntax:
result = DATE( )
Subroutine Syntax:
CALL DATE (dstring)
DATE in its function form returns a CHARACTER string of length 8 in the form mm/dd/yy, where mm, dd, and
yy are two-digit representations of the month, day, and year, respectively.
DATE in its subroutine form returns dstring in the form dd-mmm-yy, where dd is a two-digit representation
of the current day of the month, mmm is a three-character abbreviation for the current month (for example,
Jan) and yy are the last two digits of the current year.
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
1359
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
!If today's date is March 02, 2000, the following
!code prints "02-Mar-00"
CHARACTER(9) TODAY
CALL DATE(TODAY)
PRINT *, TODAY
!The next line prints "03/02/00"
PRINT *, DATE( )
See Also
DATE_AND_TIME
DATE4
Portability Subroutine: Returns the current system
date.
Module
USE IFPORT
Syntax
CALL DATE4 (datestr)
This subroutine returns datestr in the form dd-mmm-yyyy, where dd is a two-digit representation of the
current day of the month, mmm is a three-character abbreviation for the current month (for example, Jan)
and yyyy are the four digits of the current year.
DATE_AND_TIME
Intrinsic Subroutine (Generic): Returns character
and binary data on the real-time clock and date.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL DATE_AND_TIME ([date,time,zone,values])
date (Output; optional) Must be scalar and of type default character; its
length must be at least 8 to contain the complete value. Its leftmost 8
characters are set to a value of the form CCYYMMDD, where:
CC Is the century
1360
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
time (Output; optional) Must be scalar and of type default character; its
length must be at least 10 to contain the complete value. Its leftmost
10 characters are set to a value of the form hhmmss.sss, where:
zone (Output; optional) Must be scalar and of type default character; its
length must be at least 5 to contain the complete value. Its leftmost 5
characters are set to a value of the form +hhmm or -hhmm, where hh
and mm are the time difference with respect to Coordinated Universal
Time (UTC) in hours and parts of an hour expressed in minutes,
respectively.
UTC is also known as Greenwich Mean Time.
Example
Consider the following example executed on 2000 March 28 at 11:04:14.5:
1361
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CHARACTER(10) t
CHARACTER(5) z
CALL DATE_AND_TIME(TIME = t, ZONE = z)
See Also
GETDAT
GETTIM
FDATE
ITIME
RTC
CLOCK
Module
USE IFPORT
Syntax
result = DBESJ0 (value)
result = DBESJ1 (value)
result = DBESJN (n, value)
result = DBESY0 (posvalue)
result = DBESY1 (posvalue)
result = DBESYN (n, posvalue)
Results
DBESJ0, DBESJ1, and DBESJN return Bessel functions of the first kind, orders 0, 1, and n, respectively, with
the independent variable value.
DBESY0, DBESY1, and DBESYN return Bessel functions of the second kind, orders 0, 1, and n, respectively,
with the independent variable posvalue.
1362
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Negative arguments cause DBESY0, DBESY1, and DBESYN to return a huge negative value.
Bessel functions are explained more fully in most mathematics reference books, such as the Handbook of
Mathematical Functions(Abramowitz and Stegun. Washington: U.S. Government Printing Office, 1964). These
functions are commonly used in the mathematics of electromagnetic wave theory.
See the descriptions of the BESSEL_* functions, if you need to use quad-precision (REAL(16)).
Example
USE IFPORT
real(8) besnum, besout
10 read *, besnum
besout = dbesj0(besnum)
print *, 'result is ',besout
goto 10
end
See Also
BESJ0, BESJ1, BESJN, BESY0, BESY1, BESYN
DBLE
Elemental Intrinsic Function (Generic): Converts
a number to double-precision real type.
Syntax
result = DBLE (a)
Results
The result type is double precision real (by default, REAL(8) or REAL*8). Functions that cause conversion of
one data type to another type have the same effect as the implied conversion in assignment statements.
If a is of type double precision, the result is the value of the a with no conversion (DBLE( a) = a).
If a is of type integer or real, the result has as much precision of the significant part of a as a double
precision value can contain.
If a is of type complex, the result has as much precision of the significant part of the real part of a as a
double precision value can contain.
INTEGER(1) REAL(8)
INTEGER(2) REAL(8)
INTEGER(4) REAL(8)
INTEGER(8) REAL(8)
REAL(8) REAL(8)
COMPLEX(4) REAL(8)
1363
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX(8) REAL(8)
COMPLEX(16) REAL(8)
1These specific functions cannot be passed as actual arguments.
2 The setting of compiler options specifying double size can affect DBLE.
If the argument is a binary, octal, or hexadecimal literal constant, the result is affected by the
assume old-boz option. The default option setting, noold-boz, treats the argument as a bit string that
represents a value of the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is
specified, the argument is treated as a signed integer and the bits are converted.
NOTE
The result values of DBLE are defined by references to the intrinsic function REAL with the
same arguments. Therefore, the padding and truncation of binary, octal, and hexadecimal
literal constant arguments to DBLE is the same as for the intrinsic function REAL.
Example
DBLE (4) has the value 4.0.
DBLE ((3.4, 2.0)) has the value 3.4.
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
FLOAT
SNGL
REAL
CMPLX
DCLOCK
Portability Function: Returns the elapsed time in
seconds since the start of the current process.
Module
USE IFPORT
Syntax
result = DCLOCK( )
Results
The result type is REAL(8). This routine provides accurate timing to the nearest millisecond (Windows*) or to
the nearest microsecond (Linux* and macOS), taking into account the frequency of the processor where the
current process is running.
Note that the first call to DCLOCK performs calibration.
Example
USE IFPORT
DOUBLE PRECISION START_TIME, STOP_TIME
START_TIME = DCLOCK()
1364
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CALL FOO()
STOP_TIME = DCLOCK()
PRINT *, 'foo took:', STOP_TIME - START_TIME, 'seconds.'
See Also
DATE_AND_TIME
CPU_TIME
DCMPLX
Elemental Intrinsic Function (Specific): Converts
the argument to double complex type. This function
cannot be passed as an actual argument.
Syntax
result = DCMPLX (x[,y])
Results
The result type is double complex (COMPLEX(8) or COMPLEX*16).
If only one noncomplex argument appears, it is converted into the real part of the result value and zero is
assigned to the imaginary part. If y is not specified and x is complex, the result value is CMPLX(REAL( x),
AIMAG( x)).
If two noncomplex arguments appear, the complex value is produced by converting the first argument into
the real part of the value, and converting the second argument into the imaginary part.
DCMPLX( x, y) has the complex value whose real part is REAL( x, KIND=8) and whose imaginary part is
REAL( y, KIND=8).
Example
DCMPLX (-3) has the value (-3.0, 0.0).
DCMPLX (4.1, 2.3) has the value (4.1, 2.3).
See Also
CMPLX
FLOAT
INT
IFIX
REAL
SNGL
DEALLOCATE
Statement: Frees the storage allocated for allocatable
variables and nonprocedure pointer targets (and
causes the pointers to become disassociated).
Syntax
DEALLOCATE (object[,object]...[, dealloc-opt])
1365
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a STAT= variable or ERRMSG= variable is specified, it must not be deallocated in the DEALLOCATE
statement in which it appears. If the deallocation is successful, the STAT= variable is set to zero and the
ERRMSG= variable is unchanged. If the deallocation is not successful, an error condition occurs, the STAT=
variable is set to a positive integer value (representing the run-time error), and the ERRMSG= variable is
defined with a descriptive message about the error condition. If no STAT= variable is specified and an error
condition occurs, error termination is initiated.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images has initiated termination of execution, the STAT= variable becomes defined with the processor-
dependent positive integer value of the constant STAT_STOPPED_IMAGE from the intrinsic module
ISO_FORTRAN_ENV. Otherwise, if an allocatable object is a coarray and one or more images of the current
team has failed, the STAT= variable becomes defined with the processor-dependent positive integer value of
the constant STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV.
If any other error condition occurs during execution of the ALLOCATE or DEALLOCATE statement, the STAT=
variable becomes defined with a processor-dependent positive integer value different from
STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE.
If an ALLOCATE or DEALLOCATE statement with a coarray allocatable object is executed when one or more
images of the current team has failed, each allocatable object is successfully allocated or deallocated on the
active images of the current team. If any other error occurs, the allocation status of each allocatable object is
processor dependent:
• Successfully allocated allocatable objects have the allocation status of allocated, or associated if the
allocate object is has the POINTER attribute.
• Successfully deallocated allocatable objects have the allocation status of deallocated, or disassociated if
the allocatable object has the POINTER attribute.
• An allocatable object that was not successfully allocated or deallocated has its previous allocation status,
or its previous association status if it has the POINTER attribute.
It is recommended that all explicitly allocated storage be explicitly deallocated when it is no longer needed.
To disassociate a pointer that was not associated with the ALLOCATE statement, use the NULLIFY statement.
For a list of run-time errors, see Error Handling in the Compiler Reference.
Example
The following example shows deallocation of an allocatable array:
INTEGER ALLOC_ERR
REAL, ALLOCATABLE :: A(:), B(:,:)
...
ALLOCATE (A(10), B(-2:8,1:5))
...
DEALLOCATE(A, B, STAT = ALLOC_ERR)
1366
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ALLOCATE
NULLIFY
Arrays
Dynamic Allocation
ISO_FORTRAN_ENV Module
Syntax
!DIR$ DECLARE
!DIR$ NODECLARE
The DECLARE directive is primarily a debugging tool that locates variables that have not been properly
initialized, or that have been defined but never used.
See Also
IMPLICIT
General Compiler Directives
Syntax Rules for Compiler Directives
Equivalent Compiler Options
DECLARE MAPPER
OpenMP* Fortran Compiler Directive: Declares a
user-defined mapper for a specified type. It also lets
you optionally declare a map-identifier that can be
used in a MAP clause in other directives or in a
motion-clause of a TARGET UPDATE directive. This
feature is only available for ifx.
Syntax
!$OMP DECLARE MAPPER ([mapper-identifier:] type::var) [clause [[,] clause]...]
type Is an accessible type name within the scope where the directive
appears. It cannot be an intrinsic or an abstract type.
1367
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The DECLARE MAPPER directive is a declarative directive that appears in the specification part of a program.
type and mapper-identifier, if present, uniquely identify the mapper.
If a DECLARE MAPPER directive is not specified for a type DT, a predefined mapper exists for type DT as if the
type DT had appeared in the directive as follows:
1368
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a set of DECLARE MAPPER directives result in a cyclic definition of mappers, it causes unspecified behavior.
Example
The following example contains a DECLARE MAPPER directive that maps derived types of type my_type. The
variable var has the type my_type and is used in the MAP clause to reference the derived type and its
components.
The MAP clause in the DECLARE MAPPER directive specifies that all components of my_type are mapped, as
well as the dynamic storage in the array section var%values(1:NUM_ELEMENTS). No map-type is specified,
so the map type TOFROM is assumed.
Variables used in TARGET regions that are of type my_type will be implicitly mapped as prescribed in the
DECLARE MAPPER directive’s MAP clause.
program main
integer,parameter :: nvals = 250
type my_type
integer :: num_vals
integer, allocatable :: values(:)
end type
type (my_type) :: t
!$omp declare mapper (my_type :: var) map (var, var%values (1:var%num_vals))
t%num_vals = nvals
allocate (t%values(t%num_vals))
!$omp target
call initial_vals (t)
!$omp end target
...
contains
subroutine initial_vals (v)
type (my_type) :: v
v%values = 0
end subroutine initial_vals
end program
The following example maps the type my_type as seen in the previous example.
Type my_type is nested within another derived type, my_type2. my_type2 is mapped by a second DECLARE
MAPPER directive.
The array component unmapped is not mapped and is available on the host only. The component temp is
allocated on the target and used as temporary storage on the target device. The component arr is mapped
with the default map type TOFROM. The two mappers are combined when mapping variables of type
my_type2.
1369
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The second DECLARE MAPPER directive uses a mapper-identifier, and maps the variable x and the array y as
well as the type my_type2.
program main
integer,parameter :: nvals = 250
type my_type
integer :: num_vals
integer, allocatable :: values(:)
end type
!$omp declare mapper (my_type :: var) map (var, var%values (1:var%num_vals))
type my_type2
type (my_type) :: my_type_var
type (my_type) :: temp
real,dimension(nvals) :: unmapped
real,dimension(nvals) :: arr
end type
type (my_type2) :: t
real :: x, y(num_vals)
!$omp declare mapper (my_mapper : my_type2 :: v) map (v%arr, x, y(:)) &
!$omp& map (alloc : v%temp)
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET UPDATE
MAP clause
DECLARE REDUCTION
OpenMP* Fortran Compiler Directive: Declares
user-defined reductions which are identified by a
reduction-identifier that can be used in a reduction
clause of other directives.
Syntax
!$OMP DECLARE REDUCTION (reduction-identifier : type-list : combiner) [initializer-
clause]
1370
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• omp_out
This identifier refers to the storage that holds the resulting
combined value following execution of the combiner.
• omp_in
The above identifiers refer to variables that are the type of the
reduction variables specified in type-list for the reduction-identifier.
They denote values to be combined by executing the combiner.
No other identifiers are permitted in the combiner. Any number of
literal or named constants can appear in the combiner.
If combiner is a subroutine name followed by an argument list, it is
evaluated by calling the subroutine with the specified argument list. If
combiner is an assignment statement, combiner is evaluated by
executing the assignment statement.
The number of times the combiner is executed, and the order of these
executions, is unspecified.
• omp_priv = expression
This identifier refers to the storage to be initialized.
• subroutine-name (argument-list)
If initializer-expression is a subroutine name and an argument list, the
initializer is evaluated by executing a call to the subroutine with
the specified argument list. If initializer is an assignment
statement, it is evaluated by executing the assignment.
If initializer-expression is a subroutine name and an argument list,
one of the arguments must be omp_priv, and it must be associated
with an INTENT(OUT) dummy argument of the subroutine.
The number of times initializer-expression is evaluated and the order
of the evaluations is unspecified.
The DECLARE REDUCTION directive is a specification directive. It can appear in a specification part of a
subroutine, function, main program, module, or block construct.
1371
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
User-defined (custom) reductions can be defined using the DECLARE REDUCTION directive. The reduction is
identified by the reduction-identifier and the associated type from type-list. The reduction-identifier can be
used in a REDUCTION clause in another OpenMP* directive anywhere it is accessible by use or host
association.
A DECLARE REDUCTION directive cannot redefine a predefined reduction-identifier (see the table of implicitly
defined reduction identifiers in the REDUCTION clause section).
If a type in type-list has deferred or assumed-length type parameters, the reduction-identifier can be used in
a REDUCTION clause with a variable of the same type and kind type parameter as type, regardless of the
length parameter with which the variable is declared. The length parameter of a character type must be a
constant, colon, or asterisk. An accessible reduction-identifier defined with a deferred or assumed-length
character type cannot appear in another DECLARE REDUCTION directive with a type-list item of type
character with the same kind type parameter.
The accessibility of a reduction-identifier is determined by the same rules as for other Fortran entities; it can
be declared PUBLIC or PRIVATE, be made accessible or blocked by a USE or IMPORT statement, and it can be
renamed. If the reduction-identifier is the same as a generic name that is also the name of a derived type,
the accessibility of the reduction-identifier is the same as that of the generic name.
If a subroutine or function used in initializer-expression or combiner is not an intrinsic procedure, it must
have an accessible interface. Defined operators and defined assignments used in initializer or combiner
must have accessible interfaces. All subroutines, functions, defined operators and defined assignments used
in initializer or combiner must have accessible interfaces in the subprogram in which the corresponding
REDUCTION clause appears. Procedures referenced in combiner and initializer cannot be alternate return
subprograms.
The initial value of a user-defined reduction is not known before it is specified. The initializer-clause can be
used to specify an initial value for the reduction variable. The initializer-clause will be executed to establish
initial values for the private copies of reduction list items indicated in a REDUCTION clause that specifies the
reduction-identifier.
If initializer is not specified, private reduction variables are initialized as follows:
• If the reduction variable is type COMPLEX, REAL, or INTEGER, the default initializer is the value zero.
• If the reduction variable specified in list of the REDUCTION clause is LOGICAL, the default initializer is the
value .FALSE..
• If the reduction variable is of a default initialized derived type, the default initializer value is used.
• Otherwise, the initial value is unspecified.
If initializer is used in a target region, then a DECLARE TARGET construct (Linux* only) must be
specified for any procedures that are executed during the execution of combiner or initializer.
Example
Consider that a DECLARE REDUCTION directive is used to declare a sum reduction for an integer component
of a type my_type that is identified by the reduction-identifier '+'. It is then used in a REDUCTION clause of a
parallel region to produce the sum of the thread numbers (numbered 1 thru 4) of the region:
module types
type my_type
integer :: component
end type
interface operator(+)
module procedure :: my_add
end interface
1372
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
contains
function my_add (a1, a2)
type(my_type),intent(in) :: a1, a2
type(my_type) :: my_add
my_add%component = a1%component + a2%component
return
end function my_add
end module types
program main
use types
use omp_lib
type(my_type) :: my_var
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE TARGET
REDUCTION clause
DECLARE SIMD
OpenMP* Fortran Compiler Directive: Creates a
version of a function that can process multiple
arguments using Single Instruction Multiple Data
(SIMD) instructions from a single invocation from a
SIMD loop.
Syntax
!$OMP DECLARE SIMD(routine-name) [clause[[,] clause]... ]
1373
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The DECLARE SIMD construct enables the creation of SIMD versions of the specified subroutine or function.
You can use multiple DECLARE SIMD constructs in a single procedure to produce more than one SIMD
version of a procedure. These versions can be used to process multiple arguments from a single invocation
from a SIMD loop concurrently.
When routine-name is executed, it cannot have any side-effects that would change its execution for
concurrent iterations of a SIMD chunk. When the routine is called from a SIMD loop, it cannot cause the
execution of any OpenMP* Fortran construct.
If a DECLARE SIMD directive is specified for a routine name with explicit interface and for the definition of
the routine, they must match. Otherwise, the result is unspecified.
You cannot use procedure pointers to access routines created by the DECLARE SIMD directive.
You can only specify a particular variable in at most one instance of a UNIFORM or LINEAR clause.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE TARGET
OpenMP* Fortran Compiler Directive: Specifies
that named variables, common blocks, functions, and
subroutines are mapped to a device. This feature is
only available for ifx.
Syntax
!$OMP DECLARE TARGET [(extended-list)]
1374
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
-or-
!$OMP DECLARE TARGET[clause]
• A THREADPRIVATE variable
• A variable that is part of another variable (for example, an element
in an array or a field of a structure)
• A variable that is an element of a common block
• A variable that appears in an EQUIVALENCE statement
If the extended-list item is a common block:
• TO (extended-list)
Is a comma-separated collection of one or more list items or
procedures.
If a list item is a routine then a device-specific version of the
routine is created that can be called from a target region.
If a list item is a variable then the original variable is mapped to a
corresponding variable in the device data environment as if it had
appeared in a MAP clause with the map-type TO on the implicit
TARGET DATA construct for each device.
The list item is never removed from those device data
environments.
1375
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you specify list, this directive can only appear in a specification part of a subroutine, function, program, or
module.
If you do not specify list, the directive must appear in the specification part of the relevant subroutine,
function, or interface block.
If a DECLARE TARGET directive is specified in an interface block for a procedure, it must match a DECLARE
TARGET directive in the definition of the procedure.
If a procedure is declared in a procedure declaration statement, any DECLARE TARGET directive containing
the procedure name must appear in the same specification part.
The following additional rules apply to variables and common blocks:
• The DECLARE TARGET directive must appear in the declaration section of a scoping unit in which the
common block or variable is declared.
• If a variable or common block is declared with the BIND attribute, the corresponding C entities must also
be specified in a DECLARE TARGET directive in the C program.
Variables with static storage and procedures used in an OMP TARGET region are implicitly treated as OMP
DECLARE TARGET:
MODULE VARS
INTEGER X
END MODULE
!$OMP TARGET
X = FOO() ! X and FOO are implicitly DECLARE TARGET
!$OMP END TARGET
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT
OpenMP* Fortran Compiler Directive: Identifies a
variant of a base procedure and specifies the context
in which this variant is used. This feature is only
available for ifx.
Syntax
!$OMP DECLARE VARIANT ([base-proc-name:]variant-proc-name) clause[[[,] clause]... ]
variant-proc-name Is the name of the variant procedure that is to be called instead of the
base procedure if the base procedure is called from an OpenMP*
context that matches the context specified by the MATCH clause.
1376
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The DECLARE VARIANT directive is a declarative directive and must appear in the specification part of a
subroutine or function, or in an interface in an interface block. It identifies the name of a variant procedure
that is to be called instead of the base procedure when the call appears in a context that matches the
context-selector-specification in the MATCH clause.
If base-proc-name is not specified, the name of the procedure containing the directive is the base-proc-
name. base-proc-name must not be a dummy procedure name, a statement function name, a generic name,
a procedure pointer, or an alternate entry name.
If a DECLARE VARIANT directive appears in an interface body for a procedure, it must match a DECLARE
VARIANT directive in the definition of that procedure. If a DECLARE VARIANT directive appears for a
procedure with an explicit interface, and the definition of that procedure also contains a DECLARE VARIANT
directive for that procedure, the two directives must match.
1377
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Multiple DECLARE VARIANT directives can associate different variant-proc-names with the same base-proc-
name. If more than one DECLARE VARIANT associates the same variant-proc-name with the same base-
proc-name, then the context-selector-specification must be the same for all such directives.
A variant procedure must have the same interface characteristics as the base procedure, except that a
variant procedure must have one additional final argument declared in its dummy argument list, which must
be of type C_PTR from the intrinsic module ISO_C_BINDING. When a call to the base procedure is replaced
by a call to the variant, the compiler adds the additional argument into the actual argument list.
When the ADJUST_ARGS clause is specified, an argument with the is-device-ptr property in its
interoperability requirement set will be passed as is. Otherwise, the argument will be converted in the same
way that a USE_DEVICE_PTR clause on a TARGET DATA construct converts a pointer list item into a device
pointer.
When the APPEND_ARGS clause appears, the following occurs:
• For each modifier specified, an additional argument of type omp_interop_kind from the interoperability
requirement set of the encountering task is added to the end of the argument list of the base procedure.
The ordering of the appended arguments is the same as the order of the modifiers that are specified in
modifier-list in parentheses following the INTEROP keyword in the APPEND_ARGS clause.
• Each argument is constructed as if an INTEROP construct specifying an INIT clause with the corresponding
modifier was present.
• If the interoperability requirement set contains properties that could be used as INTEROP construct
clauses, it is as if the INTEROP construct also contained those clauses, and the properties will be removed
from the interoperability requirement set.
• Each appended argument is destroyed after the selected variant completes executions as if the INTEROP
construct contained a DESTROY clause.
If the variant is invoked by a DISPATCH construct that contains an INTEROP clause with n variables specified,
the first n modifiers specified in the APPEND_ARGS clause are ignored and replaced by the n variables
specified in the INTEROP clause of the DISPATCH directive. The order of these n variables appearing in the
argument list is the same order that they are specified in the INTEROP clause of the DISPATCH directive.
If there are m modifiers specified in the APPEND_ARG clause, and m > n, an argument for each of the
remaining m - n modifiers in the APPEND_ARGS clause is constructed and appended to the end of the
argument list in the same order in which they appear in the APPEND_ARGS clause.
Calling a procedure variant directly by variant-proc-name within an OpenMP* context that is different than
the context specified in the MATCH clause is non-conforming.
Example
The DECLARE VARIANT directive in the module procedure vecadd_base identifies the procedure
vecadd_gpu_offload as a variant that is to replace references to vecadd_base when called from a
DISPATCH construct and a GEN device is available for offloading. Notice that vecadd_base does not have
any dummy arguments, while vecadd_gpu_offload has a single C_PTR dummy argument.
MODULE vecadd
INTEGER,PARAMETER :: n = 1024
CONTAINS
FUNCTION vecadd_gpu_offload (ptr) RESULT (res)
USE,INTRINSIC :: ISO_C_BINDING, ONLY : c_ptr
!$DEC ATTRIBUTES NOINLINE :: vecadd_gpu_offload
TYPE (c_ptr) :: ptr
REAL :: res
REAL,DIMENSION(n) :: a, b
INTEGER :: k
1378
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
a(k) = k
b(k) = k + 1
res = a(k) + b(k)
END DO
!$omp END TARGET PARALLEL DO
PRINT *, "GPU version of vecadd called"
END FUNCTION vecadd_gpu_offload
PROGRAM main
USE vecadd
REAL :: result = 0.0
!$OMP DISPATCH
result = vecadd_base ()
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
INTEROP
DISPATCH
TARGET DATA
DECODE
Statement: Translates data from character to internal
form. It is comparable to using internal files in
formatted sequential READ statements.
Syntax
DECODE (c,f,b[, IOSTAT=i-var] [, ERR=label]) [io-list]
1379
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-list Is an I/O list. An I/O list is either an implied-DO list or a simple list of
variables (except for assumed-size arrays). The list receives the data
after translation to internal form.
The interaction between the format specifier and the I/O list is the
same as for a formatted I/O statement.
The number of characters that the DECODE statement can translate depends on the data type of b. For
example, an INTEGER(2) array can contain two characters per element, so that the maximum number of
characters is twice the number of elements in that array.
The maximum number of characters a character variable or character array element can contain is the length
of the character variable or character array element.
The maximum number of characters a character array can contain is the length of each element multiplied by
the number of elements.
Example
In the following example, the DECODE statement translates the 12 characters in A to integer form (as
specified by the FORMAT statement):
DIMENSION K(3)
CHARACTER*12 A,B
DATA A/'123456789012'/
DECODE(12,100,A) K
100 FORMAT(3I4)
The 12 characters are stored in array K:
K(1) = 1234
K(2) = 5678
K(3) = 9012
See Also
READ
WRITE
ENCODE
DEFAULT Clause
Parallel Directive Clause: Lets you specify a scope
for all variables in the lexical extent of a parallel
region.
1380
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE )
The specifications have the following effects:
• PRIVATE - Makes all named objects in the lexical extent of the parallel region, including common block
variables but excluding THREADPRIVATE variables, private to a thread as if you explicitly listed each
variable in a PRIVATE clause.
• FIRSTPRIVATE - Makes all variables in the construct that have implicitly determined data-sharing
attributes firstprivate as if you explicitly listed each variable in a FIRSTPRIVATE clause.
• SHARED - Makes all named objects in the lexical extent of the parallel region shared among the threads in
a team, as if you explicitly listed each variable in a SHARED clause. If you do not specify a DEFAULT
clause, this is the default.
• NONE - Specifies that there is no implicit default as to whether variables are PRIVATE or SHARED. In this
case, you must specify the PRIVATE, SHARED, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION property of
each variable you use in the lexical extent of the parallel region.
You can specify only one DEFAULT clause in a PARALLEL directive. You can exclude variables from a defined
default by using the PRIVATE, SHARED, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION clauses.
Variables in THREADPRIVATE common blocks are not affected by this clause.
Syntax
!DIR$ DEFINE name[ = val]
!DIR$ UNDEFINE 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
1381
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
IF Directive Construct
General Compiler Directives
Syntax Rules for Compiler Directives
D compiler option
Equivalent Compiler Options
DEFINE FILE
Statement: Establishes the size and structure of files
with relative organization and associates them with a
logical unit number.
Syntax
DEFINE FILE u(m,n,U,asv) [,u(m,n,U,asv)] ...
asv Is a scalar integer variable, called the associated variable of the file.
At the end of each direct access I/O operation, the record number of
the next higher numbered record in the file is assigned to asv; asv
must not be a dummy argument.
The DEFINE FILE statement is comparable to the OPEN statement. In situations where you can use the OPEN
statement, OPEN is the preferable mechanism for creating and opening files.
The DEFINE FILE statement specifies that a file containing m fixed-length records, each composed of n16-bit
words, exists (or will exist) on the specified logical unit. The records in the file are numbered sequentially
from 1 through m.
A DEFINE FILE statement does not itself open a file. However, the statement must be executed before the
first direct access I/O statement referring to the specified file. The file is opened when the I/O statement is
executed.
If this I/O statement is a WRITE statement, a direct access sequential file is opened, or created if necessary.
If the I/O statement is a READ or FIND statement, an existing file is opened, unless the specified file does
not exist. If a file does not exist, an error occurs.
The DEFINE FILE statement establishes the variable asv as the associated variable of a file. At the end of
each direct access I/O operation, the Fortran I/O system places in asv the record number of the record
immediately following the one just read or written.
1382
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The associated variable always points to the next sequential record in the file (unless the associated variable
is redefined by an assignment, input, or FIND statement). So, direct access I/O statements can perform
sequential processing on the file by using the associated variable of the file as the record number specifier.
Example
DEFINE FILE 3(1000,48,U,NREC)
In this example, the DEFINE FILE statement specifies that the logical unit 3 is to be connected to a file of
1000 fixed-length records; each record is forty-eight 16-bit words long. The records are numbered
sequentially from 1 through 1000 and are unformatted.
After each direct access I/O operation on this file, the integer variable NREC will contain the record number
of the record immediately following the record just processed.
See Also
OPEN
DELDIRQQ
Portability Function: Deletes a specified directory.
Module
USE IFPORT
Syntax
result = DELDIRQQ (dir)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The directory to be deleted must be empty. It cannot be the current directory, the root directory, or a
directory currently in use by another process.
Example
See the example for GETDRIVEDIRQQ.
See Also
GETDRIVEDIRQQ
GETDRIVEDIRQQ
MAKEDIRQQ
CHANGEDIRQQ
CHANGEDRIVEQQ
UNLINK
DELETE
Statement: Deletes a record from a relative file.
Syntax
DELETE ([UNIT=] io-unit[, REC=r][, ERR=label] [, IOSTAT=i-var])
1383
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
label Is the label of the branch target statement that receives control if an
error occurs.
In a relative file, the DELETE statement deletes the direct access record specified by r. If REC= r is omitted,
the current record is deleted. When the direct access record is deleted, any associated variable is set to the
next record number.
The DELETE statement logically removes the appropriate record from the specified file by locating the record
and marking it as a deleted record. It then frees the position formerly occupied by the deleted record so that
a new record can be written at that position.
NOTE
You must use compiler option vms for READs to detect that a record has been deleted.
Example
The following statement deletes the fifth record in the file connected to I/O unit 10:
See Also
Data Transfer I/O Statements
Branch Specifiers
vms compiler option
DELFILESQQ
Portability Function: Deletes all files matching the
name specification, which can contain wildcards (*
and ?).
Module
USE IFPORT
Syntax
result = DELFILESQQ (files)
Results
The result type is INTEGER(2). The result is the number of files deleted.
1384
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can use wildcards to delete more than one file at a time. DELFILESQQ does not delete directories or
system, hidden, or read-only files. Use this function with caution because it can delete many files at once. If
a file is in use by another process (for example, if it is open in another process), it cannot be deleted.
Example
USE IFPORT
USE IFCORE
INTEGER(4) len, count
CHARACTER(80) file
CHARACTER(1) ch
WRITE(*,*) "Enter names of files to delete: "
len = GETSTRQQ(file)
IF (file(1:len) .EQ. '*.*') THEN
WRITE(*,*) "Are you sure (Y/N)?"
ch = GETCHARQQ()
IF ((ch .NE. 'Y') .AND. (ch .NE. 'y')) STOP
END IF
count = DELFILESQQ(file)
WRITE(*,*) "Deleted ", count, " files."
END
See Also
FINDFILEQQ
DEPEND Clause
Parallel Directive Clause: Enforces additional
constraints on the scheduling of a task or loop
iterations by enabling dependences between sibling
tasks in the task region.
Syntax
It takes one of the following forms:
In Synchronization Directive !$OMP ORDERED
DEPEND (SOURCE) -or-
DEPEND (SINK:vec)
In all other directives:
DEPEND (dependence-type : locator-list)
dependence-type Can be any one of the following clauses: IN, OUT, or INOUT,
MUTEXINOUTSET, INOUTSET, or DEPOBJ. Clauses MUTEXINOUTSET,
INOUTSET, and DEPOBJ are only supported for ifx.
1385
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1386
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
DEPOBJ
DEPOBJ
OpenMP* Fortran Compiler Directive: Initializes,
updates, or uninitializes an OpenMP depend object.
This feature is only available for ifx.
Syntax
!$OMP DEPOBJ(depend-object) clause
Description
A depend object allows dynamic user-computed dependencies to be used in DEPEND clauses.
Depend objects must only be modified in a DEPOBJ construct, and referenced in a DEPEND clause. Any other
use of a variable that is a depend object makes the program a non-conforming OpenMP program. Depend
objects have two states, uninitialized and initialized. Depend objects have an initial state of uninitialized.
1387
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The DEPOBJ directive is a standalone construct; it does not affect any loop-nest or structured-block following
it. The binding thread set for a DEPOBJ regions is the thread that encounters it.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DEVICE Clause
Parallel Directive Clause: Specifies the target
device for a processor control directive like TARGET.
Syntax
DEVICE (scalar-integer-expression)
At most one DEVICE clause can appear in a directive that allows the clause.
If DEVICE is not specified, the default device is determined by the internal control variable (ICV) named
device-num-var.
DFLOAT
Elemental Intrinsic Function (Generic): Converts
an integer to double-precision real type.
Syntax
result = DFLOAT (a)
Results
The result type is double-precision real (by default, REAL(8) or REAL*8). Functions that cause conversion of
one data type to another type have the same effect as the implied conversion in assignment statements.
INTEGER(1) REAL(8)
Example
DFLOAT (-4) has the value -4.0.
See Also
REAL
1388
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = DFLOATI (i)
result = DFLOATJ (j)
result = DFLOATK (k)
Results
The result type is double-precision real (REAL(8) or REAL*8).
See Also
DFLOAT
DIGITS
Inquiry Intrinsic Function (Generic): Returns the
number of significant digits for numbers of the same
type and kind parameters as the argument.
Syntax
result = DIGITS (x)
Results
The result is a scalar of type default integer.
The result has the value q if x is of type integer; it has the value p if x is of type real. Integer parameter q is
defined in Model for Integer Data; real parameter p is defined in Model for Real Data.
Example
If x is of type REAL(4), DIGITS(x) has the value 24.
See Also
EXPONENT
RADIX
FRACTION
Data Representation Models
1389
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DIM
Elemental Intrinsic Function (Generic): Returns
the difference between two numbers (if the difference
is positive).
Syntax
result = DIM (x, y)
Results
The result type and kind are the same as x. The value of the result is x- y if x is greater than y; otherwise,
the value of the result is zero.
The setting of compiler options specifying integer size can affect this function.
Example
DIM (6, 2) has the value 4.
DIM (-4.0, 3.0) has the value 0.0.
The following shows another example:
INTEGER i
REAL r
REAL(8) d
i = IDIM(10, 5) ! returns 5
r = DIM (-5.1, 3.7) ! returns 0.0
d = DDIM (10.0D0, -5.0D0) ! returns 15.0D0
See Also
Argument Keywords in Intrinsic Procedures
DIMENSION
Statement and Attribute: Specifies that an object is
an array, and defines the shape of the array.
1390
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
The DIMENSION attribute can be specified in a type declaration statement or a DIMENSION statement, and
takes one of the following forms:
Type Declaration Statement:
type,[att-ls,] DIMENSION (a-spec) [, att-ls] :: a[(a-spec)][ , a[(a-spec)] ] ...
Statement:
DIMENSION [::]a(a-spec) [, a(a-spec) ] ...
Description
The DIMENSION attribute allocates a number of storage elements to each array named, one storage element
to each array element in each dimension. The size of each storage element is determined by the data type of
the array.
The total number of storage elements assigned to an array is equal to the number produced by multiplying
together the number of elements in each dimension in the array specification. For example, the following
statement defines ARRAY as having 16 real elements of 4 bytes each and defines MATRIX as having 125
integer elements of 4 bytes each:
Example
The following examples show type declaration statements specifying the DIMENSION attribute:
DIMENSION BOTTOM(12,24,10)
DIMENSION X(5,5,5), Y(4,85), Z(100)
DIMENSION MARK(4,4,4,4)
SUBROUTINE APROC(A1,A2,N1,N2,N3)
1391
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER A(2,0:2)
COMPLEX F
ALLOCATABLE F(:,:)
REAL(8), ALLOCATABLE, DIMENSION( :, :, : ) :: E
You can declare an implicit-shape constant array by using a type statement and a PARAMETER attribute, for
example:
INTEGER A(2,0:2)
COMPLEX F
ALLOCATABLE F(:,:)
REAL(8), ALLOCATABLE, DIMENSION( :, :, : ) :: E
You can specify both the upper and lower dimension bounds. If, for example, one array contains data from
experiments numbered 28 through 112, you could dimension the array as follows:
DIMENSION experiment(28:112)
Then, to refer to the data from experiment 72, you would reference experiment(72).
Array elements are stored in column-major order: the leftmost subscript is incremented first when the array
is mapped into contiguous memory addresses. For example, consider the following statements:
INTEGER(2) a
DIMENSION a(2, 0:2)
DATA a /1, 2, 3, 4, 5, 6/
If a is placed at location decimal 1000 in memory, the preceding DATA statement produces the following
mapping.
a(1,0) 1000 1
a(2,0) 1002 2
a(1,1) 1004 3
a(2,1) 1006 4
a(1,2) 1008 5
a(2,2) 100A 6
1392
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
...
SUBROUTINE Subr (matrix, rows, vector)
REAL MATRIX, VECTOR
INTEGER ROWS
DIMENSION MATRIX (ROWS,*), VECTOR (10),
+ LOCAL (2,4,8)
MATRIX (1,1) = VECTOR (5)
...
See Also
ALLOCATE
Declaration Statements for Arrays
Arrays
DISPATCH
OpenMP* Fortran Compiler Directive: Determines
whether a variant of a procedure is called for a given
function or subroutine call. This feature is only
available for ifx.
Syntax
!$OMP DISPATCH [clause[[,] clause]... ]
statement
1393
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the INTEROP directive appears with only one list item and the
DEVICE clause does not appear, it is as if DEVICE was specified
with the device number property of the listed interop-var.
The DEVICE clause is required if there is more than one list item
specified in the INTEROP clause.
• IS_DEVICE_PTR (list)
Identifies its list items as device pointers. The IS_DEVICE_PTR
property for each list item is added to the interoperability
requirement set.
Each IS_DEVICE_PTR list item must be of type C_PTR from the
intrinsic module ISO_C_BINDING
• NOCONTEXT (scalar-logical-expression)
If a NOCONTEXT clause appears and the scalar-logical-expression
evaluates to .TRUE., the DISPATCH construct is not added to the
construct set of the OpenMP context.
If the NOCONTEXT expression evaluates to .FALSE., the DISPATCH
directive is added to the OpenMP* context.
• NOVARIANTS (scalar-logical-expression)
If a NOVARIANTS clause appears, and the scalar-logical-expression
evaluates to .TRUE., no function variant is selected for execution as
the target-call, even if one would otherwise have been selected.
If the NOVARIANTS expression evaluates to .FALSE., and a variant
exists that specified an OpenMP* context in the MATCH clause that
matches the current context, the variant is called
• NOWAIT
Adds the NOWAIT property to the interoperability requirement set.
The DISPATCH directive creates an explicit task around the associated code as if a TASK construct was
present. Properties added to the interoperability requirement set can be removed by other directives. The
task will be an included task if the interoperability requirement set does not contain a NOWAIT property.
If the interoperability requirements set contains DEPEND properties, it is as if the TASK construct contained
the corresponding DEPEND clauses.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT
INTEROP
1394
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DISTRIBUTE
OpenMP* Fortran Compiler Directive: Specifies
that loop iterations will be distributed among the
primary threads of all thread teams in a league
created by a teams construct.
Syntax
!$OMP DISTRIBUTE [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE]
1395
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The binding thread set for a DISTRIBUTE construct is the set of primary threads created by a TEAMS
construct. A DISTRIBUTE region binds to the innermost enclosing team's parallel region. Only the threads
that execute the binding team's parallel region participate in the execution of the loop iterations. A
DISTRIBUTE construct must be closely nested in a team's region.
If used, the END DISTRIBUTE directive must appear immediately after the end of the loop. If you do not
specify an END DISTRIBUTE directive, an END DISTRIBUTE directive is assumed at the end of the do-loop.
The DISTRIBUTE construct is associated with loop iterations that follow the directive. The iterations are
distributed across the primary threads of all teams that execute the team's parallel region to which the
DISTRIBUTE region binds.
A list item may appear in a FIRSTPRIVATE or LASTPRIVATE clause but not both.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DO Directive
TEAMS
Parallel Processing Model for information about Binding Sets
DISTRIBUTE PARALLEL DO
OpenMP* Fortran Compiler Directive: Specifies a
loop that can be executed in parallel by multiple
threads that are members of multiple teams.
Syntax
!$OMP DISTRIBUTE PARALLEL DO [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE PARALLEL DO]
If the END DISTRIBUTE PARALLEL DO directive is not specified, an END DISTRIBUTE PARALLEL DO directive
is assumed at the end of do-loop.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
1396
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP DISTRIBUTE PARALLEL DO SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE PARALLEL DO SIMD]
If the END DISTRIBUTE PARALLEL DO SIMD directive is not specified, an END DISTRIBUTE PARALLEL DO
SIMD directive is assumed at the end of do-loop.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DISTRIBUTE POINT
General Compiler Directive: Specifies loop
distribution. It suggests a location at which a DO loop
can be split.
Syntax
!DIR$ DISTRIBUTE POINT
Loop distribution causes large loops to be distributed (split) into smaller ones. The resulting loops contain a
subset of the instructions from the initial loop. Loop distribution can enable software pipelining to be applied
to more loops. It can also reduce register pressure and improve both instruction and data cache use.
If the directive is placed before a loop, the compiler will determine where to distribute; data dependencies
are observed.
If the directive is placed inside a loop, the distribution is performed after the directive and any loop-carried
dependencies are ignored. Currently only one distribute directive is supported if the directive is placed inside
the loop.
1397
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
See Also
General Compiler Directives
DISTRIBUTE SIMD
OpenMP* Fortran Compiler Directive: Specifies a
loop that will be distributed across the primary
threads of the teams region. It will be executed
concurrently using SIMD instructions.
Syntax
!$OMP DISTRIBUTE SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END DISTRIBUTE SIMD]
1398
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The iterations of the DO loop are distributed across the existing team
of threads. The values of the loop control parameters of the DO loop
associated with a DO directive must be the same for all the threads in
the team.
If the END DISTRIBUTE SIMD directive is not specified, an END DISTRIBUTE SIMD directive is assumed at
the end of do-loop.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DNUM
Elemental Intrinsic Function (Specific): Converts
a character string to a REAL(8) value. This function
cannot be passed as an actual argument.
Syntax
result = DNUM (i)
Results
The result type is REAL(8). The result value is the double-precision real value represented by the character
string i.
Example
DNUM ("3.14159") has the value 3.14159 of type REAL(8).
The following sets x to 311.0:
CHARACTER(3) i
DOUBLE PRECISION x
i = "311"
x = DNUM(i)
DO Directive
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of the immediately following DO
loop must be executed in parallel.
Syntax
!$OMP DO [clause[[,] clause] ... ]
do_loop
[!$OMP END DO [NOWAIT]]
1399
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Kinds Effect
1400
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Kinds Effect
Modifier Effect
1401
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Modifier Effect
The binding thread set for a DO construct is the current team. A DO loop region binds to the innermost
enclosing parallel region.
If used, the END DO directive must appear immediately after the end of the loop. If you do not specify an
END DO directive, an END DO directive is assumed at the end of the DO loop.
If you specify NOWAIT in the END DO directive, threads do not synchronize at the end of the parallel loop.
Threads that finish early proceed straight to the instruction following the loop without waiting for the other
members of the team to finish the DO directive.
1402
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Parallel DO loop control variables are block-level entities within the DO loop. If the loop control variable also
appears in the LASTPRIVATE list of the parallel DO, it is copied out to a variable of the same name in the
enclosing PARALLEL region. The variable in the enclosing PARALLEL region must be SHARED if it is specified
in the LASTPRIVATE list of a DO directive.
Only a single SCHEDULE, COLLAPSE, or ORDERED clause can appear in a DO directive.
ORDERED (n) specifies how many loops are associated with the DO directive and it specifies that those
associated loops form a doacross loop nest. n does not affect how the logical iteration space is divided.
If you specify COLLAPSE (M) ORDERED (N) for loops nested K deep, the following rules apply:
• If either M > K or N > K, the behavior is unspecified.
• N must be greater than M
A LINEAR clause or an ORDERED (n) clause can be specified on a DO directive but not both.
DO directives must be encountered by all threads in a team or by none at all. It must also be encountered in
the same order by all threads in a team.
Example
In the following example, the loop iteration variable is private by default, and it is not necessary to explicitly
declare it. The END DO directive is optional:
!$OMP PARALLEL
!$OMP DO
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END DO
!$OMP END PARALLEL
If there are multiple independent loops within a parallel region, you can use the NOWAIT option to avoid the
implied BARRIER at the end of the DO directive, as follows:
!$OMP PARALLEL
!$OMP DO
DO I=2,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END DO NOWAIT
!$OMP DO
DO I=1,M
Y(I) = SQRT(Z(I))
END DO
!$OMP END DO NOWAIT
!$OMP END PARALLEL
Correct execution sometimes depends on the value that the last iteration of a loop assigns to a variable.
Such programs must list all such variables as arguments to a LASTPRIVATE clause so that the values of the
variables are the same as when the loop is executed sequentially, as follows:
!$OMP PARALLEL
!$OMP DO LASTPRIVATE(I)
DO I=1,N
A(I) = B(I) + C(I)
END DO
!$OMP END PARALLEL
CALL REVERSE(I)
In this case, the value of I at the end of the parallel region equals N+1, as in the sequential case.
1403
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Ordered sections are useful for sequentially ordering the output from work that is done in parallel. Assuming
that a reentrant I/O library exists, the following program prints out the indexes in sequential order:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Parallel Processing Model for information about Binding Sets
DO Statement
Statement: Marks the beginning of a DO construct.
The DO construct controls the repeated execution of a
block of statements or constructs. This repeated
execution is called a loop.
Syntax
A DO construct takes one of the following forms:
Block Form:
[name:] DO [label[, ] ] [loop-control]
block
[label] term-stmt
Non-block Form:
DO label [,] [loop-control]
block
[label] ex-term-stmt
1404
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
term-stmt Is the terminal statement for the block form of the construct.
ex-term-stmt Is the terminal statement for the non-block form of the construct.
Description
The terminal statement (term-stmt) for a block DO construct is an END DO or CONTINUE statement. If the
block DO statement contains a label, the terminal statement must be identified with the same label. If no
label appears, the terminal statement must be an END DO statement.
If a construct name is specified in a block DO statement, the same name must appear in the terminal END
DO statement. If no construct name is specified in the block DO statement, no name can appear in the
terminal END DO statement.
The terminal statement (ex-term-stmt) for a non-block DO construct is an executable statement (or
construct) that is identified by the label specified in the non-block DO statement. A non-block DO construct
can share a terminal statement with another non-block DO construct. A block DO construct cannot share a
terminal statement.
The following cannot be terminal statements for non-block DO constructs:
• CONTINUE (allowed if it is a shared terminal statement)
• CYCLE
• END (for a program or subprogram)
• EXIT
• GO TO (unconditional or assigned)
• Arithmetic IF
• RETURN
• STOP
The non-block DO construct is a deleted feature in the Fortran Standard. Intel® Fortran fully supports
features deleted in the Fortran Standard.
The labeled form of a DO loop is an obsolescent feature in the Fortran Standard.
Example
The following example shows a simple block DO construct (contains no iteration count or DO WHILE
statement):
DO
READ *, N
IF (N == 0) STOP
CALL SUBN
END DO
The DO block executes repeatedly until the value of zero is read. Then the DO construct terminates.
The following example shows a named block DO construct:
LOOP_1: DO I = 1, N
A(I) = C * B(I)
END DO LOOP_1
1405
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example shows a nonblock DO construct with a shared terminal statement:
DO 20 I = 1, N
DO 20 J = 1 + I, N
20 RESULT(I,J) = 1.0 / REAL(I + J)
The following two program fragments are also examples of DO statements:
DO j = 1, 10
WRITE (*, '(I5)') j
END DO
WRITE (*, '(I5)') j
See Also
CONTINUE
CYCLE
EXIT
DO WHILE
DO CONCURRENT
Execution Control
DO CONCURRENT
Statement: Specifies that there are no data
dependencies between the iterations of a DO loop.
Syntax
The DO CONCURRENT statement takes the following form:
[name:] DO [label [,]] CONCURRENT concurrent-header [locality-spec]
block
[END DO [name]]
1406
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1407
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1408
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that
iteration of the construct.
A branch within a DO CONCURRENT construct must not have a branch target that is outside the construct.
The following cannot appear in a DO CONCURRENT construct:
• A RETURN statement
• An image control statement
• A branch to a target outside the construct block
• A statement that may result in the deallocation of a polymorphic variable
• An input/output statement with an ADVANCE= specifier
• A reference to a nonpure procedure
• A reference to module IEEE_EXCEPTIONS procedure IEEE_GET_FLAG, IEEE_SET_HALTING_MODE, or
IEEE_GET_HALTING_MODE
An EXIT statement must not appear within a DO CONCURRENT construct if it belongs to that construct or an
outer construct.
A construct or statement entity with the SAVE attribute and with unspecified locality in a DO CONCURRENT
construct has SHARED locality. If it does not have the SAVE attribute, it is a different entity in each iteration
of the construct.
The construct entity does not have the BIND, SAVE, VALUE, PROTECTED, or INTENT attribute, even if the
variable with the same name outside the construct has the attribute. The construct entity does have the
VOLATILE, CONTIGUOUS, POINTER, TARGET or ASYCHRONOUS attribute if the variable outside the construct
with the same name has the attribute. If it is a non-pointer, it has the same bounds as the variable outside
the construct.
The following are rules for variables with unspecified locality in DO CONCURRENT constructs:
• A variable that is referenced in an iteration must be previously defined during that iteration, or it must not
be defined or become undefined during any other iteration.
A variable that is defined or becomes undefined by more than one iteration becomes undefined when the
loop terminates.
• An allocatable object that is allocated in more than one iteration must be subsequently deallocated during
the same iteration in which it was allocated.
An object that is allocated or deallocated in only one iteration must not be referenced, allocated,
deallocated, defined, or become undefined in a different iteration.
• A pointer that is referenced in an iteration must have been pointer associated previously during that
iteration, or it must not have its pointer association changed during any iteration.
A pointer that has its pointer association changed in more than one iteration has an association status of
undefined when the construct terminates.
• An input/output statement must not write data to a file record or position in one iteration and read from
the same record or position in a different iteration.
• Records written by output statements in the range of the loop to a sequential-access file appear in the file
in an indeterminate order.
The restrictions on referencing variables defined in an iteration of a DO CONCURRENT construct also apply to
any procedure invoked within the loop. These restrictions ensure no interdependencies occur that might
affect code optimizations.
NOTE
If compiler option -qopenmp (Linux* and macOS) or /Qopenmp (Windows*) is specified, the compiler
will attempt to parallelize the construct.
See the DO statement for the semantics of labeled and block forms of DO loops.
1409
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The labeled form of a DO CONCURRENT loop is an obsolescent feature in the Fortran Standard.
Example
The following shows a DO CONCURRENT construct with a mask-expr and locality specified for variables:
INTEGER,DIMENSION(N) :: J, K
INTEGER :: I, M
M = 10
I = 15
DO CONCURRENT (I = 1:N, J(I)> 0)LOCAL (M) SHARED (J, K)
M = MOD (K(I), J(I))
K(I) = K(I) – M
END DO
PRINT *, I, M ! Prints 15 10
DO SIMD
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of the loop will be distributed across
threads in the team. Iterations executed by each
thread can also be executed concurrently using SIMD
instructions.
Syntax
!$OMP DO SIMD [clause[[,] clause] ... ]
do-loop
[!$OMP END DO SIMD[NOWAIT]]
If the END DO SIMD directive is not specified, an END DO SIMD directive is assumed at the end of do-loop.
You can specify the NOWAIT clause to avoid the implied barrier at the end of a loop construct.
The DO SIMD construct converts the associated DO loop to a SIMD loop in a way that is consistent with any
clauses that apply to the SIMD construct. The resulting SIMD chunks and any remaining iterations will be
distributed across the implicit tasks of the parallel region in a way that is consistent with any clauses that
apply to the DO construct.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
1410
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DO WHILE
Statement: Executes the range of a DO construct
while a specified condition remains true.
Syntax
[name:] DO [label[, ]] WHILE (expr)
block
[END DO [name]]
Description
If a construct name is specified in a DO WHILE statement, the same name must appear in a terminal END
DO statement. If no construct name is specified in the DO WHILE statement, no name can appear in the
terminal END DO statement, if one is specified.
Before each execution of the DO range, the logical expression is evaluated. If it is true, the statements in the
body of the loop are executed. If it is false, the DO construct terminates and control transfers to the
statement following the loop.
If END DO is specified, it terminates the construct. If END DO is not specified, when all of the iterations have
completed execution, the loop terminates, and the DO construct becomes inactive.
If no label appears in a DO WHILE statement, the DO WHILE loop must be terminated with an END DO
statement. See the description of the DO statement for the semantics of labeled and block forms of DO
loops.
You can transfer control out of a DO WHILE loop but not into a loop from elsewhere in the program.
Terminating a DO WHILE loop with an executable statement other than a DO WHILE or a CONTINUE
statement is a deleted feature in the Fortran Standard. Intel® Fortran fully supports features deleted in the
Fortran Standard.
The labeled form of a DO WHILE loop is an obsolescent feature in the Fortran Standard.
Example
The following example shows a DO WHILE statement:
CHARACTER*132 LINE
...
I = 1
DO WHILE (LINE(I:I) .EQ. ' ')
I = I + 1
END DO
1411
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RequiredOptional
DO WHILE (I .GT. J) DO 10 WHILE (I .GT. J)
ARRAY(I,J) = 1.0 ARRAY(I,J) = 1.0
I = I - 1 I = I - 1
END DO 10 END DO
The following shows another example:
CHARACTER(1) input
input = ' '
DO WHILE ((input .NE. 'n') .AND. (input .NE. 'y'))
WRITE (*, '(A)') 'Enter y or n: '
READ (*, '(A)') input
END DO
See Also
CONTINUE
CYCLE
EXIT
DO statement
Execution Control
DOT_PRODUCT
Transformational Intrinsic Function (Generic):
Performs dot-product multiplication of numeric or
logical vectors (rank-one arrays).
Syntax
result = DOT_PRODUCT (vector_a,vector_b)
Results
The result is a scalar whose type depends on the types of vector_a and vector_b.
If vector_a is of type integer or real, the result value is SUM ( vector_a* vector_b).
If vector_a is of type complex, the result value is SUM (CONJG ( vector_a)* vector_b).
If vector_a is of type logical, the result has the value ANY ( vector_a.AND. vector_b).
If either rank-one array has size zero, the result is zero if the array is of numeric type, and false if the array
is of logical type.
Example
DOT_PRODUCT ((/1, 2, 3/), (/3, 4, 5/)) has the value 26, calculated as follows:
((1 x 3) + (2 x 4) + (3 x 5)) = 26
DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0), (1.0, 4.0) /)) has the value (17.0, 4.0).
DOT_PRODUCT ((/ .TRUE., .FALSE. /), (/ .FALSE., .TRUE. /)) has the value false.
1412
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PRODUCT
MATMUL
TRANSPOSE
DOUBLE COMPLEX
Statement: Specifies the DOUBLE COMPLEX data
type.
Syntax
DOUBLE COMPLEX
A COMPLEX(8) or DOUBLE COMPLEX constant is a pair of constants that represents a complex number. One
of the pair must be a double-precision real constant, the other can be an integer, single-precision real, or
double-precision real constant.
A COMPLEX(8) or DOUBLE COMPLEX constant occupies 16 bytes of memory and is interpreted as a complex
number.
The rules for DOUBLE PRECISION (REAL(8)) constants also apply to the double precision portion of
COMPLEX(KIND=8) or DOUBLE COMPLEX constants. (For more information, see REAL and DOUBLE
PRECISION.)
The DOUBLE PRECISION constants in a COMPLEX(8) or DOUBLE COMPLEX constant have IEEE* binary64
format.
Example
DOUBLE COMPLEX vector, arrays(7,29)
DOUBLE COMPLEX pi, pi2 /3.141592654,6.283185308/
Valid COMPLEX(8) or DOUBLE COMPLEX constants
(547.3E0_8,-1.44_8)
(1.7039E0,-1.7039D0)
(+12739D3,0.D0)
See Also
General Rules for Complex Constants
COMPLEX Statement
Complex Data Types
DOUBLE PRECISION
REAL
1413
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DOUBLE PRECISION
Statement: Specifies the DOUBLE PRECISION data
type.
Syntax
DOUBLE PRECISION
A REAL(8) or DOUBLE PRECISION constant has more than twice the accuracy of a REAL(4) number, and
greater range.
A REAL(8) or DOUBLE PRECISION constant occupies eight bytes of memory. The number of digits that
precede the exponent is unlimited, but typically only the leftmost 15 digits are significant.
IEEE* binary64 format is used.
For more information, see General Rules for Real Constants.
Example
DOUBLE PRECISION varnam
DOUBLE PRECISION,PRIVATE :: zz
Valid REAL(8) or DOUBLE PRECISION constants
123456789D+5
123456789E+5_8
+2.7843D00
-.522D-12
2E200_8
2.3_8
3.4E7_8
See Also
REAL Statement
REAL(8) or DOUBLE PRECISION Constants
Data Types, Constants, and Variables
Real Data Types
DPROD
Elemental Intrinsic Function (Specific): Produces
a higher precision product. This is a specific function
that has no generic function associated with it.
Syntax
result = DPROD (x, y)
1414
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
If x and y are of type REAL(4), the result type is double-precision real (REAL(8) or REAL*8). If x and y are of
type REAL(8), the result type is REAL(16). The result value is equal to x* y.
The setting of compiler options specifying real size can affect this function.
Example
DPROD (2.0, -4.0) has the value -8.00D0.
DPROD (5.0D0, 3.0D0) has the value 15.00Q0.
The following shows another example:
REAL(4) e
REAL(8) d
e = 123456.7
d = 123456.7D0
! DPROD (e,e) returns 15241557546.4944
DRAND, DRANDM
Portability Functions: Return double-precision
random numbers in the range 0.0 to 1.0, not including
the end points.
Module
USE IFPORT
Syntax
result = DRAND (iflag)
result = DRANDM (iflag)
iflag (Input) INTEGER(4). Controls the way the random number is selected.
Results
The result type is REAL(8). DRAND and DRANDM return random numbers in the range 0.0 to 1.0, not
including the end points.
There is no difference between DRAND and DRANDM. Both functions are included to insure portability of
existing code that references one or both of them.
1415
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The intrinsic subroutines RANDOM_INIT, RANDOM_NUMBER, and RANDOM_SEED provide the same
functionality and they are the recommended functions to use when writing programs to generate random
numbers.
Example
USE IFPORT
REAL(8) num
INTEGER(4) f
f=1
CALL print_rand
f=0
CALL print_rand
f=22
CALL print_rand
CONTAINS
SUBROUTINE print_rand
num = drand(f)
print *, 'f= ',f,':',num
END SUBROUTINE
END
See Also
RANDOM_INIT
RANDOM_NUMBER
RANDOM_SEED
DRANSET
Portability Subroutine: Sets the seed for the
random number generator.
Module
USE IFPORT
Syntax
CALL DRANSET (seed)
See Also
RANGET
DREAL
Elemental Intrinsic Function (Specific): Converts
the real part of a double complex argument to double-
precision type. This is a specific function that has no
generic function associated with it. It cannot be
passed as an actual argument.
Syntax
result = DREAL (a)
1416
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is double precision real (REAL(8) or REAL*8).
Example
DREAL ((2.0d0, 3.0d0)) has the value 2.0d0.
See Also
REAL
DSHIFTL
Elemental Intrinsic Function (Specific): Selects
the left 64 bits after shifting a 128-bit integer value to
the left. This function cannot be passed as an actual
argument.
Syntax
result = DSHIFTL (i,j,shift)
shift (Input) Integer. Must be nonnegative and less than or equal to 64.
This is the shift count.
Results
The result type is integer. The result value is the 64-bit value starting at bit 128 - shift of the 128-bit
concatenation of the values of i and j.
If either i or j is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic
function INT to type integer with the kind type parameter of the other. The rightmost shift bits of the result
value are the same as the leftmost bits of i, and the remaining bits of the result value are the same as the
rightmost bits of j. This is equal to IOR (SHIFTL (I, SHIFT), SHIFTR (J, BIT SIZE (J) - SHIFT)).
Example
Consider the following:
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
1417
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DSHIFTR
Elemental Intrinsic Function (Specific): Selects
the left 64 bits after shifting a 128-bit integer value to
the right. This function cannot be passed as an actual
argument.
Syntax
result = DSHIFTR (i,j,shift)
shift (Input) Integer. Must be nonnegative and less than or equal to 64.
This is the shift count.
Results
The result type is integer. The result value is the 64-bit value starting at bit 64 + shift of the 128-bit
concatenation of the values of i and j.
If either i or j is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic
function INT to type integer with the kind type parameter of the other. The leftmost shift bits of the result
value are the same as the rightmost bits of i, and the remaining bits of the result value are the same as the
leftmost bits of j. This is equal to IOR (SHIFTL (I, BIT SIZE (I) - SHIFT), SHIFTR (J, SHIFT)).
Example
Consider the following:
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
DTIME
Portability Function: Returns the elapsed CPU time
since the start of program execution when first called,
and the elapsed execution time since the last call to
DTIME thereafter.
Module
USE IFPORT
Syntax
result = DTIME (tarray)
1418
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is REAL(4). The result is the total CPU time, which is the sum of tarray(1) and tarray(2). If an
error occurs, -1 is returned.
Example
USE IFPORT
REAL(4) I, TA(2)
I = DTIME(TA)
write(*,*) 'Program has been running for', I, 'seconds.'
write(*,*) ' This includes', TA(1), 'seconds of user time and', &
& TA(2), 'seconds of system time.'
See Also
DATE_AND_TIME
CPU_TIME
E to F
This section describes language features that start with E or F.
E to F
ELEMENTAL
Keyword: Asserts that a user-defined procedure is
defined on scalar arguments that may be called with
array arguments. An elemental procedure may be a
pure procedure or an impure procedure. An elemental
procedure is an elemental intrinsic procedure, an
intrinsic module procedure that is specified to be
elemental, a user-defined procedure that is specified
to be elemental, or a type-bound procedure that is
bound to an elemental procedure. A procedure pointer
or a dummy procedure can not be specified to be
elemental.
Description
To specify an elemental procedure, use this keyword in a FUNCTION or SUBROUTINE statement.
An explicit interface must be visible to the caller of an ELEMENTAL procedure.
An elemental procedure can be passed an array, which is acted upon one element at a time.
For functions, the result must be scalar; it cannot have the POINTER or ALLOCATABLE attribute.
Dummy arguments in ELEMENTAL procedures may appear in specification expressions in the procedure.
Dummy arguments have the following restrictions:
• They must be scalar.
• They cannot have the POINTER or ALLOCATABLE attribute.
• They cannot be an alternate return specifier (*).
• They cannot be dummy procedures.
If the actual arguments are all scalar, the result is scalar. If the actual arguments are array valued, the
values of the elements (if any) of the result are the same as if the function or subroutine had been applied
separately, in any order, to corresponding elements of each array actual argument.
1419
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Elemental procedures are pure procedures and all rules that apply to pure procedures also apply to elemental
procedures, unless you specify that the elemental procedure is IMPURE. In that case, the rules for pure
procedures do not apply.
Example
Consider the following:
See Also
FUNCTION
SUBROUTINE
Determining When Procedures Require Explicit Interfaces
Optional Arguments
ELSE Directive
Statement: Marks an optional branch in an IF
Directive Construct.
See Also
See IF Directive Construct.
ELSE Statement
Statement: Marks an optional branch in an IF
Construct.
See Also
See IF Construct.
ELSEIF Directive
Statement: Marks an optional branch in an IF
Directive Construct.
See Also
See IF Directive Construct.
ELSE IF
Statement: Marks an optional branch in an IF
Construct.
See Also
See IF Construct.
1420
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ELSE WHERE
Statement: Marks the beginning of an ELSE WHERE
block within a WHERE construct.
Syntax
[name:]WHERE (mask-expr1)
[where-body-stmt]...
[ELSE WHERE(mask-expr2) [name]
[where-body-stmt]...]
[ELSE WHERE[name]
[where-body-stmt]...]
END WHERE [name]
Description
Every assignment statement following the ELSE WHERE is executed as if it were a WHERE statement with
".NOT. mask-expr1". If ELSE WHERE specifies "mask-expr2", it is executed as "(.NOT. mask-expr1) .AND.
mask-expr2" during the processing of the ELSE WHERE statement.
Example
WHERE (pressure <= 1.0)
pressure = pressure + inc_pressure
temp = temp - 5.0
ELSEWHERE
raining = .TRUE.
END WHERE
The variables temp, pressure, and raining are all arrays.
See Also
WHERE
ENCODE
Statement: Translates data from internal (binary)
form to character form. It is comparable to using
internal files in formatted sequential WRITE
statements.
Syntax
ENCODE (c,f,b[, IOSTAT=i-var] [, ERR=label]) [io-list]
1421
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
io-list Is an I/O list. An I/O list is either an implied-DO list or a simple list of
variables (except for assumed-size arrays). The list contains the data
to be translated to character form.
The interaction between the format specifier and the I/O list is the
same as for a formatted I/O statement.
The number of characters that the ENCODE statement can translate depends on the data type of b. For
example, an INTEGER(2) array can contain two characters per element, so that the maximum number of
characters is twice the number of elements in that array.
The maximum number of characters a character variable or character array element can contain is the length
of the character variable or character array element.
The maximum number of characters a character array can contain is the length of each element multiplied by
the number of elements.
Example
Consider the following:
DIMENSION K(3)
CHARACTER*12 A,B
DATA A/'123456789012'/
DECODE(12,100,A) K
100 FORMAT(3I4)
ENCODE(12,100,B) K(3), K(2), K(1)
The DECODE statement stores the 12 characters into array K:
K(1) = 1234
K(2) = 5678
K(3) = 9012
The ENCODE statement translates the values K(3), K(2), and K(1) to character form and stores the
characters in the character variable B.:
B = '901256781234'
See Also
READ
WRITE
DECODE
1422
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END
Statement: Marks the end of a program unit. It takes
one of the following forms:
Syntax
END [PROGRAM [program-name]]
END [FUNCTION [function-name]]
END [SUBROUTINE [subroutine-name]]
END [MODULE [module-name]]
END [SUBMODULE [module-name]]
END [BLOCK DATA [block-data-name]]
In main programs, function subprograms, and subroutine subprograms, END statements are executable and
can be branch target statements. If control reaches the END statement in these program units, the following
occurs:
• In a main program, execution of the END statement initiates normal termination of the image that
executes it.
• In a function or subroutine subprogram, a RETURN statement is implicitly executed.
The END statement cannot be continued in a program unit, and no other statement in the program unit can
have an initial line that appears to be the program unit END statement.
The END statements in a module or block data program unit are nonexecutable.
Example
C An END statement must be the last statement in a program
C unit:
PROGRAM MyProg
WRITE (*, '("Hello, world!")')
END
C
C An example of a named subroutine
C
SUBROUTINE EXT1 (X,Y,Z)
Real, Dimension (100,100) :: X, Y, Z
END SUBROUTINE EXT1
See Also
Program Units and Procedures
Branch Statements
Program Termination
END DO
Statement: Marks the end of a DO or DO WHILE
loop.
Syntax
END DO
Description
There must be a matching END DO statement for every DO or DO WHILE statement that does not contain a
label reference.
1423
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An END DO statement can terminate only one DO or DO WHILE statement. If you name the DO or DO WHILE
statement, the END DO statement can specify the same name.
Example
The following examples both produce the same output:
DO ivar = 1, 10
PRINT ivar
END DO
ivar = 0
do2: DO WHILE (ivar .LT. 10)
ivar = ivar + 1
PRINT ivar
END DO do2
See Also
DO
DO WHILE
CONTINUE
ENDIF Directive
Statement: Marks the end of an IF Directive
Construct.
See Also
See IF Directive Construct.
END IF
Statement: Marks the end of an IF Construct.
See Also
See IF Construct.
ENDFILE
Statement: For sequential files, writes an end-of-file
record to the file and positions the file after this record
(the terminal point). For direct access files, truncates
the file after the current record.
Syntax
It can have either of the following forms:
ENDFILE ([UNIT=] io-unit[, ERR=label] [, IOMSG=msg-var] [, IOSTAT=i-var])
ENDFILE io-unit
label Is the label of the branch target statement that receives control if an
error occurs.
1424
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If the unit specified in the ENDFILE statement is not open, the default file is opened for unformatted output.
An end-of-file record can be written only to files with sequential organization that are accessed as formatted-
sequential or unformatted-segmented sequential files. An ENDFILE performed on a direct access file always
truncates the file.
End-of-file records should not be written in files that are read by programs written in a language other than
Fortran.
NOTE
If you use compiler option vms and an ENDFILE is performed on a sequential unit, an actual
one byte record containing a CTRL+Zis written to the file. If this option is not specified, an
internal ENDFILE flag is set and the file is truncated. The option does not affect ENDFILE on
relative files; such files are truncated.
If a parameter of the ENDFILE statement is an expression that calls a function, that function must not cause
an I/O statement or the EOF intrinsic functionto be executed, because unpredictable results can occur.
Example
The following statement writes an end-of-file record to I/O unit 2:
ENDFILE 2
Suppose the following statement is specified:
WRITE (6, *) x
ENDFILE 6
REWIND 6
READ (6, *) y
See Also
BACKSPACE
REWIND
Data Transfer I/O Statements
Branch Specifiers
END FORALL
Statement: Marks the end of a FORALL construct.
The FORALL construct is an obsolescent language
feature in Fortran 2018.
See Also
See FORALL.
END INTERFACE
Statement: Marks the end of an INTERFACE block.
See Also
See INTERFACE.
1425
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END TYPE
Statement: Specifies the end of a derived type TYPE
statement.
See Also
See TYPE Statement (Derived Types).
END WHERE
Statement: Marks the end of a WHERE construct.
Example
WHERE (pressure <= 1.0)
pressure = pressure + inc_pressure
temp = temp - 5.0
ELSEWHERE
raining = .TRUE.
END WHERE
Note that the variables temp, pressure, and raining are all arrays.
See Also
See WHERE.
ENTRY
Statement: Provides one or more entry points within
a subprogram. It is not executable and must precede
any CONTAINS statement (if any) within the
subprogram.
Syntax
ENTRY name[ ( [d-arg[,d-arg]...] ) [RESULT (r-name)] ]
name Is the name of an entry point. If RESULT is specified, this entry name
must not appear in any specification statement in the scoping unit of
the function subprogram.
r-name (Optional) Is the name of a function result. This name must not be the
same as the name of the entry point, or the name of any other
function or function result. This parameter can only be specified for
function subprograms.
Description
ENTRY statements can only appear in external procedures or module procedures.
An ENTRY statement must not appear in an executable construct.
When the ENTRY statement appears in a subroutine subprogram, it is referenced by a CALL statement. When
the ENTRY statement appears in a function subprogram, it is referenced by a function reference.
An entry name within a function subprogram can appear in a type declaration statement.
1426
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Within the subprogram containing the ENTRY statement, the entry name must not appear as a dummy
argument in the FUNCTION or SUBROUTINE statement, and it must not appear in an EXTERNAL or
INTRINSIC statement. For example, neither of the following are valid:
Example
C This fragment writes a message indicating
C whether num is positive or negative
IF (num .GE. 0) THEN
CALL Sign
ELSE
CALL Negative
END IF
...
END
SUBROUTINE Sign
WRITE (*, *) 'It''s positive.'
RETURN
ENTRY Negative
WRITE (*, *) 'It''s negative.'
RETURN
END SUBROUTINE
See Also
Program Units and Procedures
ENTRY Statements in Function Subprograms
ENTRY Statements in Subroutine Subprograms
EOF
Inquiry Intrinsic Function (Generic): Checks
whether a file is at or beyond the end-of-file record.
Syntax
result = EOF (unit)
1427
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default logical. The value of the result is .TRUE. if the file connected to unit is at or beyond
the end-of-file record; otherwise, .FALSE..
Example
! Creates a file of random numbers, reads them back
REAL x, total
INTEGER count
OPEN (1, FILE = 'TEST.DAT')
DO I = 1, 20
CALL RANDOM_NUMBER(x)
WRITE (1, '(F6.3)') x * 100.0
END DO
CLOSE(1)
OPEN (1, FILE = 'TEST.DAT')
count = 0
total = 0.0
DO WHILE (.NOT. EOF(1))
count = count + 1
READ (1, *) value
total = total + value
END DO
100 IF ( count .GT. 0) THEN
WRITE (*,*) 'Average is: ', total / count
ELSE
WRITE (*,*) 'Input file is empty '
END IF
STOP
END
See Also
ENDFILE
READ Statement for details on an END specifier in a READ statement
BACKSPACE
REWIND
EOSHIFT
Transformational Intrinsic Function (Generic):
Performs an end-off shift on a rank-one array, or
performs end-off shifts on all the complete rank-one
sections along a given dimension of an array of rank
two or greater. Elements are shifted off at one end of
a section and copies of a boundary value are filled in
at the other end. Different sections can have different
boundary values and can be shifted by different
amounts and in different directions.
Syntax
result = EOSHIFT (array,shift [,boundary][,dim])
1428
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
shift (Input) Must be a scalar integer or an array with a rank that is one
less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
boundary (Input; optional) Must have the same type and kind parameters as
array. It must be a scalar or an array with a rank that is one less than
array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn). The boundary
specifies a value to replace spaces left by the shifting procedure.
If boundary is not specified, it is assumed to have the following
default values (depending on the data type of array):
Integer 0
Real 0.0
Logical false
dim (Input; optional) Must be a scalar integer with a value in the range 1
to n, where n is the rank of array. If dim is omitted, it is assumed to
be 1.
Results
The result is an array with the same type and kind parameters, and shape as array.
If array has rank one, the same shift is applied to each element. If an element is shifted off one end of the
array, the boundary value is placed at the other end the array.
If array has rank greater than one, each section (s1, s2, ..., sdim-1, :, sdim+1, ..., sn) of the result is shifted as
follows:
• By the value of shift, if shift is scalar
• According to the corresponding value in shift(s1, s2, ..., sdim-1, sdim+1, ..., sn), if shift is an array
If an element is shifted off one end of a section, the boundary value is placed at the other end of the section.
The value of shift determines the amount and direction of the end- off shift. A positive shift value causes a
shift to the left (in rows) or up (in columns). A negative shift value causes a shift to the right (in rows) or
down (in columns).
Example
V is the integer array (1, 2, 3, 4, 5, 6).
EOSHIFT (V, SHIFT=2) shifts the elements in V to the left by 2 positions, producing the value (3, 4, 5, 6, 0,
0). 1 and 2 are shifted off the beginning and two elements with the default BOUNDARY value are placed at
the end.
EOSHIFT (V, SHIFT= -3, BOUNDARY= 99) shifts the elements in V to the right by 3 positions, producing the
value (99, 99, 99, 1, 2, 3). 4, 5, and 6 are shifted off the end and three elements with BOUNDARY value 99
are placed at the beginning.
1429
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ].
EOSHIFT (M, SHIFT = 1, BOUNDARY = '*', DIM = 2) produces the result
[ 2 3 * ]
[ 5 6 * ]
[ 8 9 * ].
Each element in rows 1, 2, and 3 is shifted to the left by 1 position. This causes the first element in each row
to be shifted off the beginning, and the BOUNDARY value to be placed at the end.
EOSHIFT (M, SHIFT = -1, DIM = 1) produces the result
[ ^ ^ ^ ]
[ 1 2 3 ]
[ 4 5 6 ].
Each element in columns 1, 2, and 3 is shifted down by 1 position. This causes the last element in each
column to be shifted off the end and the BOUNDARY value (the default character boundary value <space>,
represented by "^") to be placed at the beginning.
EOSHIFT (M, SHIFT = (/1, -1, 0/), BOUNDARY = (/ '*', '?', '/' /), DIM = 2) produces the result
[ 2 3 * ]
[ ? 4 5 ]
[ 7 8 9 ].
Each element in row 1 is shifted to the left by 1 position, causing the first element to be shifted off the
beginning and the BOUNDARY value * to be placed at the end. Each element in row 2 is shifted to the right
by 1 position, causing the last element to be shifted off the end and the BOUNDARY value ? to be placed at
the beginning. No element in row 3 is shifted at all, so the specified BOUNDARY value is not used.
The following shows another example:
INTEGER shift(3)
CHARACTER(1) array(3, 3), AR1(3, 3)
array = RESHAPE ((/'A', 'D', 'G', 'B', 'E', 'H', &
'C', 'F', 'I'/), (/3,3/))
! array is A B C
! D E F
! G H I
shift = (/-1, 1, 0/)
AR1 = EOSHIFT (array, shift, BOUNDARY = (/'*','?','#'/), DIM= 2)
! returns * A B
! E F ?
! G H I
See Also
CSHIFT
ISHFT
ISHFTC
TRANSPOSE
1430
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
EPSILON
Inquiry Intrinsic Function (Generic): Returns a
positive model number that is almost negligible
compared to unity in the model representing real
numbers.
Syntax
result = EPSILON (x)
Results
The result is a scalar of the same type and kind parameters as x. The result has the value b 1-p. Parameters b
and p are defined in Model for Real Data.
EPSILON makes it easy to select a delta for algorithms (such as root locators) that search until the
calculation is within delta of an estimate. If delta is too small (smaller than the decimal resolution of the data
type), the algorithm might never halt. By scaling the value returned by EPSILON to the estimate, you obtain
a delta that ensures search termination.
Example
If x is of type REAL(4), EPSILON (X) has the value 2 -23.
See Also
PRECISION
TINY
Data Representation Models
EQUIVALENCE
Statement: Specifies that a storage area is shared by
two or more objects in a program unit. This causes
total or partial storage association of the objects that
share the storage area. EQUIVALENCE is an
obsolescent language feature in Standard Fortran.
Syntax
EQUIVALENCE (equiv-list) [,(equiv-list)]...
Description
The following objects cannot be specified in EQUIVALENCE statements:
• A dummy argument
• An allocatable variable
• An automatic object
• A pointer
• An object of nonsequence derived type
1431
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Any other intrinsic type Must have the same type and kind parameters
So, objects can be associated if they are of different numeric type. For example, the following is valid:
INTEGER A(20)
REAL Y(20)
EQUIVALENCE(A, Y)
Objects of default character do not need to have the same length. The following example associates
character variable D with the last 4 (of the 6) characters of character array F:
CHARACTER(LEN=4) D
CHARACTER(LEN=3) F(2)
EQUIVALENCE(D, F(1)(3:))
Entities having different data types can be associated because multiple components of one data type can
share storage with a single component of a higher-ranked data type. For example, if you make an integer
variable equivalent to a complex variable, the integer variable shares storage with the real part of the
complex variable.
The same storage unit cannot occur more than once in a storage sequence, and consecutive storage units
cannot be specified in a way that would make them nonconsecutive.
Intel® Fortran lets you associate character and noncharacter entities, for example:
CHARACTER*1 char1(10)
REAL reala, realb
EQUIVALENCE (reala, char1(1))
EQUIVALENCE (realb, char1(2))
1432
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
EQUIVALENCE statements require only the first subscript of a multidimensional array (unless the STRICT
compiler directive is in effect). For example, the array declaration var(3,3), var(4) could appear in an
EQUIVALENCE statement. The reference is to the fourth element of the array (var(1,2)), not to the beginning
of the fourth row or column.
If you use the STRICT directive, the following rules apply to the kinds of variables and arrays that you can
associate:
• If an EQUIVALENCE object is default integer, default real, double-precision real, default complex, default
logical, or a sequenced derived type of all numeric or logical components, all objects in the EQUIVALENCE
statement must be one of these types, though it is not necessary that they be the same type.
• If an EQUIVALENCE object is default character or a sequenced derived type of all character components,
all objects in the EQUIVALENCE statement must be one of these types. The lengths do not need to be the
same.
• If an EQUIVALENCE object is a sequenced derived type that is not purely numeric or purely character, all
objects in the EQUIVALENCE statement must be the same derived type.
• If an EQUIVALENCE object is an intrinsic type other than the default (for example, INTEGER(1)), all
objects in the EQUIVALENCE statement must be the same type and kind.
Example
The following EQUIVALENCE statement is invalid because it specifies the same storage unit for X(1) and
X(2):
REAL, DIMENSION(2) :: X
REAL :: Y
EQUIVALENCE(X(1), Y), (X(2), Y)
The following EQUIVALENCE statement is invalid because A(1) and A(2) will not be consecutive:
REAL A(2)
DOUBLE PRECISION D(2)
EQUIVALENCE(A(1), D(1)), (A(2), D(2))
In the following example, the EQUIVALENCE statement causes the four elements of the integer array IARR to
share the same storage as that of the double-precision variable DVAR:
CHARACTER (LEN = 4) :: a, b
CHARACTER (LEN = 3) :: c(2)
EQUIVALENCE (a, c(1)), (b, c(2))
1433
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 2 3 4 5 6 7
a(1:1) a(2:2) a(3:3) a(4:4)
b(1:1) b(2:2) b(3:3) b(4:4)
c(1)(1:1) c(1)(2:2) c(1)(3:3) c(2)(1:1) c(2)(2:2) c(2)(3:3)
Note that the fourth element of a, the first element of b, and the first element of c(2) share the same storage
unit.
See Also
Initialization Expressions
Derived Data Types
Storage Association
STRICT Directive
Obsolescent Language Features in the Fortran Standard
ERF
Elemental Intrinsic Function (Generic): Returns
the error function of an argument.
Syntax
result = ERF (x)
Results
The result type and kind are the same as x. The result is in the range -1 to 1.
ERF returns the error function of x defined as follows:
Example
ERF (1.0) has the value 0.842700794.
See Also
ERFC
ERFC
Elemental Intrinsic Function (Generic): Returns
the complementary error function of an argument.
Syntax
result = ERFC (x)
1434
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x. The result is in the range 0 to 2.
ERFC returns 1 - ERF(x) and is defined as follows:
ERFC is provided because of the extreme loss of relative accuracy if ERF(x) is called for large x and the result
is subtracted from 1.
Example
ERFC (1.0) has the value 0.1572992057.
See Also
ERF
ERFC_SCALED
Elemental Intrinsic Function (Generic): Returns
the scaled complementary error function of an
argument.
Syntax
result = ERFC_SCALED (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the exponentially-scaled
complementary error function of
1435
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Example
ERFC_SCALED (20.0) has the approximate value 0.02817434874.
See Also
ERFC
ERRSNS
Intrinsic Subroutine (Generic): Returns
information about the most recently detected I/O
system error condition. Intrinsic subroutines cannot be
passed as actual arguments.
Syntax
CALL ERRSNS ([io_err] [,sys_err] [,stat] [,unit] [,cond])
If you specify INTEGER(2) arguments, only the low-order 16 bits of information are returned or adjacent
data can be overwritten. Because of this, it is best to use INTEGER(4) arguments.
1436
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The saved error information is set to zero after each call to ERRSNS.
Example
Any of the arguments can be omitted. For example, the following is valid:
ESTABLISHQQ
Portability Function: Lets you specify a function to
handle errors detected by the Run-Time Library (RTL).
It lets you take appropriate steps in addition to the
RTL's error-handling behavior, or it lets you replace
that behavior.
Module
USE IFESTABLISH
Syntax
result = ESTABLISHQQ (handler_routine,context,prev_handler,prev_context)
Results
The result type for ESTABLISHQQ is LOGICAL(4). It indicates whether the handler was successfully
established. .TRUE. means it was established successfully; .FALSE. means it was not.
The handler function is called when an error occurs. The result for the handler is set by your code in the
handler. .TRUE. means that the error has been handled and the application should not issue an error
message. .FALSE. means that the application should issue an error message and continue as if there had
never been a handler.
After you use ESTABLISHQQ to specify an error handler function and an error occurs, the handler function is
called with the following input arguments. They are set up by the RTL when it calls the handler function:
Handler Function Syntax:
result = Handler_Function (error_code, continuable, message_string, context)
Handler_Function is a function you supply that has a compatible interface. It must use the Intel® Fortran
compiler defaults for calling mechanism and argument passing. When the Intel Fortran Run-Time Library
detects an error, it first calls your handler function with the following arguments:
error_code
(Input) INTEGER(4). This is the number of the error
that occurred and it is the value that will be set in
an IOSTAT= or STAT= specifier variable.
1437
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The function result of the handler function is type LOGICAL(4). The handler function should return .TRUE. if it
successfully handled the error; otherwise, .FALSE..
If the handler function returns .TRUE. and the error is continuable, execution of the program continues. If the
handler function returns .FALSE., normal error processing is performed, such as message output to the user
and possible program termination.
The handler function can be written in any language, but it must follow the Intel Fortran conventions. Note
that for argument message_string, an address-sized length is passed by value after argument context.
If you want to handle errors using a C/C++ handler, use the ISO_C_BINDINGS module features to call the
C/C++ routine.
Example
logical :: ret
integer(INT_PTR_KIND()) :: old_context, my_context = 0
real, volatile :: x,y,z
integer, volatile :: i, eleven, a(10)
my_context = 1
eleven = 11
1438
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
if (associated(old_handler_1)) then
print *, "** Unexpected old handler on first ESTABLISH **"
ret = old_handler_1(100, .true., "call number one", 1 )
print *, "back from call of old handler with", ret
else
print *,"== Got expected NULL old handler"
end if
if (associated(old_handler_2)) then
print *, "== Expect first handler as old handler"
ret = old_handler_2(100, .true., "call number one", 1 )
else
print *,"** Unexpectedly didn't get first handler as old handler **"
end if
if (associated(old_handler_3)) then
print *, "== Expect second handler as old handler"
ret = old_handler_3(100, .true., "call number one", 1 )
!print *, "back from call of old handler with", ret
else
print *,"** Unexpectedly didn't get second handler as old handler **"
end if
1439
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! Arguments
!
integer, intent(in) :: error_code ! RTL error code from IOSTAT table
logical, intent(in) :: continuable ! True if condition is continuable
character(*), intent(in) :: message_string ! Formatted message string a la ERRMSG/IOMSG
integer(INT_PTR_KIND()), intent(in) :: context ! Address-sized integer passed in to call
! ESTABLISHQQ, for whatever purpose
! the programmer desires
if (context == 1) then
print *, " Handler 1, continue"
else
print *, " ** Error -- wrong context value"
end if
return
! Arguments
!
1440
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
return
end function my_handler_2
! Arguments
!
logical :: my_handler_3
integer, intent(in) :: error_code ! RTL error code from IOSTAT table
logical, intent(in) :: continuable ! True if condition is continuable
character(*), intent(in) :: message_string ! Formatted message string a la ERRMSG/IOMSG
integer(INT_PTR_KIND()), intent(in) :: context ! Address-sized integer passed in to call
! ESTABLISHQQ, for whatever purpose
! the programmer desires
if (context == 1) then
print *," Handler 3, continue"
else if (context == 2) then
print *, " Handler 3, error is ", error_code, message_string
end if
See Also
Understanding Run-Time Errors
List of Run-Time Error Messages
ETIME
Portability Function: On single processor systems,
returns the elapsed CPU time, in seconds, of the
process that calls it. On multi-core or multi-processor
systems, returns the elapsed wall-clock time, in
seconds.
Module
USE IFPORT
1441
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = ETIME (array)
array (Output) REAL(4). Must be a rank one array with two elements:
• array(1) − Elapsed user time, which is time spent executing user
code. This value includes time running protected Windows
subsystem code. On single processors, ETIME returns the elapsed
CPU time, in seconds, of the process that calls it. On multiple
processors, ETIME returns the elapsed wall-clock time, in seconds.
• array(2) − Elapsed system time, which is time spent executing
privileged code (code in the Windows Executive) on single
processors; on multiple processors, this value is zero.
Results
The result type is REAL(4). The result is the total CPU time, which is the sum of array(1) and array(2).
Example
USE IFPORT
REAL(4) I, TA(2)
I = ETIME(TA)
write(*,*) 'Program has used', I, 'seconds of CPU time.'
write(*,*) ' This includes', TA(1), 'seconds of user time and', &
& TA(2), 'seconds of system time.'
See Also
DATE_AND_TIME
Syntax
EVENT POST (event-var [, sync-stat-list])
EVENT WAIT (event-var [, wait-spec-list])
sync-stat-list Is STAT=stat-var
or ERRMSG=err-var
1442
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
wait-spec-list Is until-spec
or sync-stat-list
Each specifier is optional and may appear at most once in a sync-stat-list or in a wait-spec-list.
Description
An EVENT POST statement atomically increments the value of event-var by one. Its value is processor
dependent if an error condition occurs during the execution of an EVENT POST statement. The completion of
an EVENT POST statement does not in any way depend on execution of a corresponding EVEN WAIT
statement.
The following actions occur during the execution of an EVENT WAIT statement:
• If UNTIL_COUNT is not specified, the threshold value is one; otherwise, it is the maximum value of one
and the specified scalar-integer-expression.
• The image executing the EVENT WAIT statement waits until the value of event-var is equal to or greater
than the threshold value; otherwise, an error condition occurs.
• If no error condition has occurred, event-var is atomically decremented by the threshold value.
The value of event-var is processor dependent if an error condition occurs during the execution of an EVENT
WAIT statement.
An EVEN POST statement execution is initially unsatisfied. The successful execution of an EVENT WAIT
statement with a threshold value of n satisfies the first n unsatisfied EVENT POST statement executions for
the specified event-var. The EVENT WAIT statement delays execution of the segment following the EVENT
WAIT statement to execute after the segments which precede the first n EVENT POST statement executions
for the specified event-var.
Example
The following example shows the use of EVENT POST and EVENT WAIT statements to synchronize each
image with its left and right neighbor. Image 1 and image NUM_IMAGES() treat each other as left and right
neighbors, conceptually laying the images out in a circle.
1443
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Using Coarrays
EVENT_QUERY
Intrinsic Subroutine (Generic): Queries the event
count of an event variable.
Syntax
CALL EVENT_QUERY (event, count [, stat])
event (Input) Must be an event variable of type EVENT_TYPE, and must not
be coindexed. The event variable is accessed atomically with respect
to the execution of EVENT POST statements in unordered segments, in
exact analogy to atomic subroutines.
Example
Consider the following example:
See Also
EVENT POST and EVENT WAIT
EXECUTE_COMMAND_LINE
Intrinsic Subroutine: Executes a command line.
Syntax
CALL EXECUTE_COMMAND_LINE (command [,wait,exitstat,cmdstat,cmdmsg])
1444
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
When command is executed synchronously, EXECUTE_COMMAND_LINE returns after the command line has
completed execution. Otherwise, EXECUTE_COMMAND_LINE returns without waiting.
If a condition occurs that would assign a nonzero value to cmdstat but cmdstat is not present, execution is
terminated.
NOTE
If the application has a standard console window, command output will appear in that
window. On Windows* systems, if the application does not have a console window, including
QuickWin applications, command output will not be shown.
Example
INTEGER :: CSTAT, ESTAT
CHARACTER(100) :: CMSG
CALL EXECUTE_COMMAND_LINE (“dir > dir.txt”, EXITSTAT=ESTAT, &
CMDSTAT=CSTAT, CMDMSG=CMSG)
IF (CSTAT > 0) THEN
PRINT *, “Command execution failed with error “, TRIM(CMSG)
ELSE IF (CSTAT < 0) THEN
PRINT *, “Command execution not supported”
ELSE
PRINT *, “Command completed with status “, ESTAT
END IF
END
In the above example, EXECUTE_COMMAND_LINE is called to execute a "dir" command with output
redirected to a file. Since the WAIT argument was omitted, the call waits for the command to complete and
the command's exit status is returned in ESTAT. If the command cannot be executed, the error message
returned in CMSG is displayed, but note that this is not based on the success or failure of the command itself.
EXIT Statement
Statement: Terminates execution of a DO loop or a
named construct.
Syntax
EXIT [name]
1445
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The EXIT statement causes execution of a DO loop or a named construct to be terminated.
If name is specified, the EXIT statement must be within the range of that named construct. Otherwise, the
EXIT statement must be within a DO loop and it exits the innermost DO within which it appears.
If a DO loop is terminated, any inner DO loops are also terminated and the DO control variables retain their
last value. If a non-DO construct is terminated, any DO loops inside that construct are also terminated.
An EXIT statement must not appear within a DO CONCURRENT construct if it belongs to that construct or an
outer construct.
An EXIT statement must not appear in a CHANGE TEAM or CRITICAL construct if it belongs to an outer
construct.
An EXIT statement can appear in any of the following constructs:
• ASSOCIATE
• BLOCK
• CHANGE TEAM
• CRITICAL
• DO
• IF
• SELECT CASE
• SELECT RANK
• SELECT TYPE
Example
The following examples demonstrate EXIT statements.
Example 1:
LOOP_A : DO I = 1, 15
N = N + 1
IF (N > I) EXIT LOOP_A
END DO LOOP_A
Example 2:
DO I=1,N
MyBlock: BLOCK
REAL :: T
T = A(I) + B(I)
IF (T == 0.0) EXIT MyBlock
C(I) = T + SQRT(T)
END BLOCK
END DO
1446
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example 4:
DO CONCURRENT (I = 1:N)
MyBlock: BLOCK
REAL :: T
T = A(I) + B(I)
IF (T == 0.0) EXIT MyBlock
C(I) = T + SQRT(T)
END BLOCK
END DO
The following example shows illegal EXIT statements in DO CONCURRENT and CRITICAL:
LOOP_2 : DO I = 1, 15
CRITICAL
N = N + 1
IF (N > I) EXIT LOOP_2 ! can’t EXIT outer construct from inside
END CRITICAL ! CHANGE TEAM, DO CONCURRENT, or CRITICAL
END DO LOOP_2
See Also
DO
DO WHILE
EXIT Subroutine
Intrinsic Subroutine (Generic): Terminates
program execution, closes all files, and returns control
to the operating system. Intrinsic subroutines cannot
be passed as actual arguments.
Syntax
CALL EXIT [( [status] )]
status (Output; optional) Is an integer argument you can use to specify the
image exit-status value.
The exit-status value may not be accessible after program termination in some application environments.
Example
INTEGER(4) exvalue
! all is well, exit with 1
exvalue = 1
CALL EXIT(exvalue)
! all is not well, exit with diagnostic -4
exvalue = -4
CALL EXIT(exvalue)
! give no diagnostic, just exit
CALL EXIT ( )
See Also
END
ABORT
1447
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
EXP
Elemental Intrinsic Function (Generic): Computes
an exponential value.
Syntax
result = EXP (x)
Results
The result type and kind are the same as x. The value of the result is e x. If x is of type complex, its
imaginary part is regarded as a value in radians.
Example
EXP (2.0) has the value 7.389056.
EXP (1.3) has the value 3.669297.
The following shows another example:
See Also
EXP10
LOG
EXP10
Elemental Intrinsic Function (Generic): Computes
a base 10 exponential value.
Syntax
result = EXP10 (x)
1448
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x. The value is 10 raised to the power of x. If x is of type complex,
its imaginary part is regarded as a value in radians.
Example
EXP10 (2.0) has the value 100.00.
EXP10 (1.3) has the value 19.95262.
See Also
LOG10
EXP
EXPONENT
Elemental Intrinsic Function (Generic): Returns
the exponent part of the argument when represented
as a model number.
Syntax
result = EXPONENT (x)
Results
The result type is default integer. If x is not equal to zero, the result value is the exponent part of x. The
exponent must be within default integer range; otherwise, the result is undefined.
If x is zero, the exponent of x is zero. For more information on the exponent part ( e) in the real model, see
Model for Real Data.
Example
EXPONENT (2.0) has the value 2.
If 4.1 is a REAL(4) value, EXPONENT (4.1) has the value 3.
The following shows another example:
REAL(4) r1, r2
REAL(8) r3, r4
r1 = 1.0
1449
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
r2 = 123456.7
r3 = 1.0D0
r4 = 123456789123456.7
write(*,*) EXPONENT(r1) ! prints 1
write(*,*) EXPONENT(r2) ! prints 17
write(*,*) EXPONENT(r3) ! prints 1
write(*,*) EXPONENT(r4) ! prints 47
END
See Also
DIGITS
RADIX
FRACTION
MAXEXPONENT
MINEXPONENT
Data Representation Models
EXTENDS_TYPE_OF
Inquiry Intrinsic Function (Generic): Inquires
whether the dynamic type of an object is an extension
type of the dynamic type of another object.
Syntax
result = EXTENDS_TYPE_OF (a , mold)
Results
The result type is default logical scalar.
The following determines the result value:
• If mold is unlimited polymorphic and is a disassociated pointer or an unallocated allocatable, the result
is .TRUE..
• If a is unlimited polymorphic and is a disassociated pointer or an unallocated allocatable, the result
is .FALSE..
• If the dynamic type of a or mold is extensible, the result is true only if the dynamic type of a is an
extension type of the dynamic type of mold.
Otherwise, the result is processor dependent.
EXTERNAL
Statement and Attribute: Allows an external
procedure, a dummy procedure, a procedure pointer,
or a block data subprogram to be used as an actual
argument. (To specify intrinsic procedures as actual
arguments, use the INTRINSIC attribute.)
Syntax
The EXTERNAL attribute can be specified in a type declaration statement or an EXTERNAL statement, and
takes one of the following forms:
1450
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
In a type declaration statement, only functions can be declared EXTERNAL. However, you can use the
EXTERNAL statement to declare subroutines and block data program units, as well as functions, to be
external.
The name declared EXTERNAL is assumed to be the name of an external procedure, even if the name is the
same as that of an intrinsic procedure. For example, if SIN is declared with the EXTERNAL attribute, all
subsequent references to SIN are to a user-supplied function named SIN, not to the intrinsic function of the
same name.
You can include the name of a block data program unit in the EXTERNAL statement to force a search of the
object module libraries for the block data program unit at link time. However, the name of the block data
program unit must not be used in a type declaration statement.
If you want to describe a routine with greater detail, use the INTERFACE statement. This statement
automatically declares a routine as EXTERNAL, and provides information on result types and argument types.
A procedure that has both the EXTERNAL and POINTER attributes is a procedure pointer.
Example
The following example shows type declaration statements specifying the EXTERNAL attribute:
PROGRAM TEST
...
INTEGER, EXTERNAL :: BETA
LOGICAL, EXTERNAL :: COS
...
CALL SUB(BETA) ! External function BETA is an actual argument
You can use a name specified in an EXTERNAL statement as an actual argument to a subprogram, and the
subprogram can then use the corresponding dummy argument in a function reference or a CALL statement;
for example:
EXTERNAL FACET
CALL BAR(FACET)
SUBROUTINE BAR(F)
EXTERNAL F
CALL F(2)
Used as an argument, a complete function reference represents a value, not a subprogram; for example,
FUNC(B) represents a value in the following statement:
1451
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INTRINSIC
Program Units and Procedures
Type Declarations
INTRINSIC
Compatible attributes
FORTRAN 66 Interpretation of the External Statement
FAIL IMAGE
Statement: Causes the image that executes it to stop
participating in program execution, without initiating
termination.
Syntax
FAIL IMAGE
This statement allows you to simulate image failure and to test and debug image failure recovery in a
program, without requiring an actual image failure.
After execution of a FAIL IMAGE statement, no additional statements are executed by the image.
A FAIL IMAGE statement is not an image control statement.
The detection of a failed image may happen at different times in the execution of other images; for more
information, see FAILED_IMAGES.
NOTE
If you use a FAIL IMAGE statement to make an image fail, you should use a STAT= specifier or a STAT
argument in all coarray operations that might encounter that failed image if the statement or
operation permits, or you should specify either the assume failed_images or standard-semantics
compiler option. If you do not use a STAT= specifier, a STAT argument, or specify one of the compiler
options, those operations will not check for failed images. They may then try to coordinate with the
failed image, waiting for a response from it. The response would never happen and so the application
would hang.
Examples
The following example demonstrates using the STAT= specifier to prevent an application hang (see Note
above):
1452
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END IF
SYNC ALL (STAT=MY_STAT) ! Would hang without STAT=
END SUBROUTINE FAIL_AND_SYNC
If an image calls the following procedure at regular time intervals, it has a one in ten thousand chance of
failure in each time step:
SUBROUTINE RANDOM_FAILURE ()
REAL RANDOM
CALL RANDOM_NUMBER (RANDOM)
IF (RANDOM > 0.9999) FAIL IMAGE
RETURN
END SUBROUTINE RANDOM_FAILURE
See Also
FAILED_IMAGES
IMAGE_STATUS
standard-semantics compiler option
assume [no]failed_images compiler option
FAILED_IMAGES
Transformational Intrinsic Function (Generic):
Returns an array of index images that have failed.
Syntax
result = FAILED_IMAGES ([team, kind])
kind (Input; optional) Must be a scalar integer expression with a value that
is a valid INTEGER kind type parameter.
Results
The result is a rank-one integer array with the same type kind parameters as kind if present; otherwise,
default integer. The size of the array is equal to the number of images in the specified team that are known
to have failed.
The result array elements are the image index values of images on the current team that are known to have
failed. The indices are arranged in increasing numeric order.
If the image executing the FAILED_IMAGES reference previously executed a collective subroutine whose
STAT argument returned the value STAT_FAILED_IMAGES defined in the intrinsic module ISO_FORTRAN_ENV,
or if the image executed an image control statement whose STAT= specifier returned the value
STAT_FAILED_IMAGE, at least one image in the team executing the collective or image control statement is
known to have failed.
Failed images may lead to unavoidable hangs
Coarray programs are parallel programs, so between synchronization points the relative ordering of events in
different images is unknown and undefined. The failure of an image or the execution of the FAIL IMAGE
statement is such an event. It happens at a definite time in the image that fails, but the other images will
discover the failure at different points in their execution. Also, because a failed image does not participate in
synchronization points, it is possible for the discovery to happen before a synchronization point in one image
and after it in another.
1453
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This means that when other images synchronize (such as with a SYNC ALL), it is possible that some will
know that that image has failed and some will not. In this case, the images that don't know will attempt to
synchronize with the failed image and the application will hang, making no progress.
There is no certain way to prevent a hang when an image fails. However, if you structure your program so
that synchronizations points are infrequent, the chance of a failure happening just before a synchronization
point is lower. If images frequently do coarray loads and stores, or check image status, they are more likely
to discover a failed image sooner. The FAILED_IMAGES intrinsic will check for failed images, but other images
might not get the same result from that call.
Example
If image 5 and 12 of the current team are known to have failed, the result of FAILED_IMAGES ( ) is an array
of default integer type with size 2 defined with the value [5, 12]. If no images in the current team are known
to have failed, the result of FAILED_IMAGES ( ) is a zero-sized array.
See Also
IMAGE_STATUS
STOPPED_IMAGES
ISO_FORTRAN_ENV Module
FDATE
Portability Function and Subroutine: Returns the
current date and time as an ASCII string.
Module
USE IFPORT
Syntax
Function Syntax
result = FDATE()
Subroutine Syntax:
CALL FDATE ( [string] )
Results
The result of the function FDATE and the value of string returned by the subroutine FDATE( string) are
identical. Newline and NULL are not included in the string.
When you use FDATE as a function, declare it as:
CHARACTER*24 FDATE
Example
USE IFPORT
CHARACTER*24 today
!
CALL FDATE(today)
write (*,*), 'Today is ', today
!
write (*,*), 'Today is ', fdate()
1454
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
DATE_AND_TIME
FGETC
Portability Function: Reads the next available
character from a file specified by a Fortran unit
number.
Module
USE IFPORT
Syntax
result = FGETC (lunit,char)
Results
The result type is INTEGER(4). The result is zero if the read is successful, or -1 if an end-of-file is detected. A
positive value is either a system error code or a Fortran I/O error code, such as:
EINVAL: The specified unit is invalid (either not already open, or an invalid unit number).
If you use WRITE, READ, or any other Fortran I/O statements with lunit, be sure to read Portability Routines.
Example
USE IFPORT
CHARACTER inchar
INTEGER istatus
istatus = FGETC(5,inchar)
PRINT *, inchar
END
See Also
GETCHARQQ
READ
FINAL Clause
Parallel Directive Clause: Specifies that the
generated task will be a final task.
Syntax
FINAL (scalar-logical-expression)
All task constructs encountered during execution of a final task will generate included tasks.
Note that if a variable is used in a FINAL clause expression of a directive construct, it causes an implicit
reference to the variable in all enclosing constructs.
Only a single FINAL clause can appear in the directive.
1455
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FINAL Statement
Statement: Denotes a finalization procedure that
defines one or more final subroutines that are bound
to a derived type.
Syntax
The FINAL statement takes the following form:
FINAL [::] sub1 [, sub2 ]...
sub1, sub2, ... Is a final subroutine, which is a module procedure with exactly one
dummy argument of the derived type. The dummy argument cannot
be INTENT(OUT), it cannot have the VALUE attribute, it cannot be
optional, and it cannot be a pointer, allocatable, or a coarray. All array
shape and length type parameters are assumed.
Description
A final subroutine must not have a dummy argument with the same kind type parameters and rank as the
dummy argument of another final subroutine of the type.
You cannot specify a subroutine that was previously specified as a final subroutine for the derived type.
If a final subroutine has an assumed-rank dummy argument, no other final subroutine of that type can have
a dummy argument with the same kind type parameters.
This statement is used in derived-type type-bound procedures.
A derived type is finalizable only if it has a final subroutine or a nonpointer, nonallocatable component of
finalizable type. A nonpointer data entity is finalizable only if it is of finalizable type.
When an entity is finalized, the following actions occur in this order:
1. If the dynamic type of the entity has a final subroutine whose dummy argument has the same kind
type parameters and rank as the entity being finalized, it is called with the entity as an actual
argument.
Otherwise, if there is an elemental final subroutine whose dummy argument has the same kind type
parameters as the entity being finalized, or a final subroutine whose dummy argument is assumed-rank
with the same kind type parameters as the entity being finalized, it is called with the entity as an actual
argument. Otherwise, no subroutine is called.
2. Finalizable components in the type are finalized. If the entity is an array, each finalizable component of
each element is finalized. The order of finalization is processor dependent.
3. If the entity is of an extended type with a finalizable parent type, the parent component is finalized.
Effects of Finalization
If the variable of an intrinsic assignment is not an unallocated allocatable array when the statement is
executed, the variable is finalized after the expression on the right-hand side (RHS) is evaluated and before
the variable is defined. If the variable is an allocated allocatable variable or has an allocated allocatable
subobject that would be deallocated by intrinsic assignment, finalization occurs before deallocation.
When a pointer is deallocated, its target is finalized. When an allocatable entity is deallocated, it is finalized
unless it is the variable on the left-hand side (LHS) of the intrinsic assignment or a subobject of the variable.
A nonpointer, nonallocatable object that is not a dummy argument or function result is finalized immediately
before it would become undefined due to execution of a RETURN or END statement.
If the entity is of extended type and the parent type is finalizable, the parent component is finalized.
A nonpointer, nonallocatable local variable of a BLOCK construct is finalized immediately before it would
become undefined due to termination of the BLOCK construct.
1456
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If an executable construct references a nonpointer function, the result is finalized after execution of the
innermost executable construct containing the reference.
• If a specification expression in a scoping unit references a function, the result is finalized before execution
of the executable constructs in the scoping unit.
• A nonpointer, nonallocatable, INTENT(OUT) dummy argument of a procedure is finalized when the
procedure is invoked before the dummy argument becomes undefined. Finalization of INTENT(OUT)
dummy arguments occurs in the invoked procedure; for elemental procedures, an INTENT(OUT) argument
will be finalized only if a scalar or elemental final subroutine is available, regardless of the rank of the
argument.
• If image execution is terminated, either by an error or by execution of a ERROR STOP, STOP, or END
PROGRAM statement, any entities that exist immediately before termination are not finalized.
Example
The following example declares two module subroutines to be final:
TYPE MY_TYPE
... ! Component declarations
CONTAINS
FINAL :: CLEAN1, CLEAN2
END TYPE MY_TYPE
See Also
Type-Bound Procedures
FIND
Statement: Positions a direct access file at a
particular record and sets the associated variable of
the file to that record number. It is comparable to a
direct access READ statement with no I/O list, and it
can open an existing file. No data transfer takes place.
Syntax
FIND ([UNIT=] io-unit, REC= r[, ERR= label] [, IOSTAT= i-var])
FIND (io-unit 'r [, ERR=label] [, IOSTAT=i-var])
Example
In the following example, the FIND statement positions logical unit 1 at the first record in the file. The file's
associated variable is set to one:
FIND(1, REC=1)
1457
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, the FIND statement positions the file at the record identified by the content of
INDX. The file's associated variable is set to the value of INDX:
FIND(4, REC=INDX)
See Also
Forms for Direct-Access READ Statements
I/O Control List
FINDLOC
Transformational Intrinsic Function (Generic):
Finds the location of a specified value in an array.
Syntax
result = FINDLOC (array, value, dim [, mask, kind, back])
result = FINDLOC (array, value[, mask, kind, back])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
If both array and value are of type logical, the comparison is performed with the .EQV. operator; otherwise,
the comparison is performed with the == operator. If the value of the comparison is true, that element of
array matches value.
Results
The result is integer. If kind is present, the kind type parameter is that specified by the value of kind.
Otherwise, the kind type parameter is that of default integer type.
If dim does not appear, the result is an array of rank one and of size equal to the rank of array; otherwise,
the result is of rank n - 1 and shape (d1, d2,...ddim-1, ddim+1,...dn), where (d1, d2,...dn) is the shape of array.
The result of FINDLOC (array, valuevalue) is a rank-one array whose element values are the values of the
subscripts of an element of array whose value matches value. If there is such a value, the ith subscript
returned is in the range 1 to ei, where ei is the extent of the ith dimension of array. If no elements match
value or if array has size zero, all elements of the result are zero.
The result of FINDLOC (array, value, MASK = mask) is a rank-one array whose element values are the values
of the subscripts of an element of array, corresponding to a true element of mask, whose value matches
value. If there is such a value, the ith subscript returned is in the range 1 to ei, where ei is the extent of the
ith dimension of array. If no elements match value, or array has size zero, or every element of mask has the
value .FALSE., all elements of the result are zero.
1458
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If array has rank one, the result of FINDLOC (array, value, DIM = dim [, MASK = mask]) is a scalar whose
value is equal to that of the first element of FINDLOC (array, value [, MASK = mask]). Otherwise, the value
of element (s1, s2,...sdim-1, sdim+1,...sn) of the result is equal to FINDLOC (array (s1, s2,...sdim-1, :, sdim
+1,...sn), value, DIM = 1 [, MASK = mask (s1, s2,...sdim-1, :, sdim+1,...sn)]).
The setting of compiler options specifying integer size can affect this function.
Examples
The value of FINDLOC ([2, 6, 4, 6], VALUE = 6) is [2].
The value of FINDLOC ([2, 6, 4, 6], VALUE = 6, BACK = .TRUE.) is [4].
If A has the value
[ 0 −5 7 7 ]
[ 3 4 −1 2 ]
[ 1 5 6 7 ]
and M has the value
[ T T F T ]
[ T T F T ]
[ T T F T ]
then FINDLOC (A, 7, MASK = M) is [1, 4] and FINDLOC (A, 7, MASK = M, BACK = .TRUE.) is [3, 4].
This is independent of the declared lower bounds for A.
The value of FINDLOC ([2, 6, 4], VALUE = 6, DIM = 1) is 2.
If B has the value
[ 1 2 -9 ]
[ 2 3 6 ]
then FINDLOC (B, VALUE = 2, DIM = 1) is [2, 1, 0] and FINDLOC (B, VALUE = 2, DIM = 2) is [2, 1].
This is independent of the declared lower bounds for B.
See Also
MAXLOC
MINLOC
FINDFILEQQ
Portability Function: Searches for a specified file in
the directories listed in the path contained in the
environment variable.
Module
USE IFPORT
Syntax
result = FINDFILEQQ (filename,varname,pathbuf)
1459
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pathbuf (Output) Character*(*). Buffer to receive the full path of the file
found.
Results
The result type is INTEGER(4). The result is the length of the string containing the full path of the found file
returned in pathbuf, or 0 if no file is found.
Example
USE IFPORT
CHARACTER(256) pathname
INTEGER(4) pathlen
pathlen = FINDFILEQQ("libfmt.lib", "LIB", pathname)
WRITE (*,*) pathname
END
See Also
FULLPATHQQ
GETFILEINFOQQ
SPLITPATHQQ
FIRSTPRIVATE
Parallel Directive Clause: Provides a superset of the
functionality provided by the PRIVATE clause. It
declares one or more variables to be private to each
thread in a team, and initializes each of them with the
value of the corresponding original variable.
Syntax
FIRSTPRIVATE (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
Variables that appear in a FIRSTPRIVATE list are subject to PRIVATE clause semantics. In addition, private
(local) copies of each variable in the different threads are initialized to the value the variable had upon
entering the parallel region.
To avoid race conditions, which are caused by unintended sharing of data, concurrent updates of the original
variable must be synchronized with the read of the original variable that occurs as a result of the
FIRSTPRIVATE clause.
If the original variable has the POINTER attribute, the new variable receives the same association status of
the original variable as if by pointer assignment.
If the original variable does not have the POINTER attribute, initialization of the new variable occurs as if by
intrinsic assignment, unless the original variable has the allocation status of "not currently allocated". In this
case, the new variable also has the status of " not currently un allocated".
The following are restrictions for the FIRSTPRIVATE clause:
• A variable that is part of another variable (as an array or structure element) must not appear in a
FIRSTPRIVATE clause.
• A variable that is private within a parallel region must not appear in a FIRSTPRIVATE clause in a
worksharing construct if any of the worksharing regions arising from the worksharing construct ever bind
to any of the parallel regions arising from the parallel construct.
1460
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• A variable that appears in a REDUCTION clause of a PARALLEL construct must not appear in a
FIRSTPRIVATE clause in a worksharing or task construct if any of the worksharing or task regions arising
from the worksharing or task construct ever bind to any of the parallel regions arising from the parallel
construct.
• A variable that appears in a REDUCTION clause in a WORKSHARE construct must not appear in a
FIRSTPRIVATE clause in a task construct encountered during execution of any of the worksharing regions
arising from the worksharing construct.
• Assumed-size arrays must not appear in a PRIVATE clause.
• Variables that appear in NAMELIST statements, in variable format expressions, and in expressions for
statement function definitions, must not appear in a PRIVATE clause.
• If a list item appears in both the FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all of the initializations for FIRSTPRIVATE.
NOTE
If a variable appears in both FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all initializations for FIRSTPRIVATE..
Example
Consider the following:
A = 3
B = 4
!$OMP PARALLEL PRIVATE(A) FIRSTPRIVATE(B)
In this case, variable A has an undefined value at the beginning of the parallel region. However, variable B
has the value 4, which was specified in the serial region preceding the parallel region.
See Also
PRIVATE clause
LASTPRIVATE clause
FIXEDFORMLINESIZE
General Compiler Directive: Sets the line length for
fixed-form Fortran source code.
Syntax
!DIR$ FIXEDFORMLINESIZE:{72 | 80 | 132}
You can set FIXEDFORMLINESIZE to 72 (the default), 80, or 132 characters. The FIXEDFORMLINESIZE
setting remains in effect until the end of the file, or until it is reset.
The FIXEDFORMLINESIZE directive sets the source-code line length in include files, but not in USE modules,
which are compiled separately. If an include file resets the line length, the change does not affect the host
file.
This directive has no effect on free-form source code.
Example
!DIR$ NOFREEFORM
!DIR$ FIXEDFORMLINESIZE:132
WRITE (*,*) 'Sentence that goes beyond the 72nd column without continuation.'
See Also
FREEFORM and NOFREEFORM
Source Forms
1461
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FLOAT
Elemental Intrinsic Function (Generic): Converts
an integer to REAL(4).
See Also
REAL
FLOOR
Elemental Intrinsic Function (Generic): Returns
the greatest integer less than or equal to its
argument.
Syntax
result = FLOOR (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The value of the result is equal to the greatest integer less than or equal to a.
The setting of compiler options specifying integer size can affect this function.
Example
FLOOR (4.8) has the value 4.
FLOOR (-5.6) has the value -6.
The following shows another example:
I = FLOOR(3.1) ! returns 3
I = FLOOR(-3.1) ! returns -4
See Also
CEILING
FLUSH Directive
OpenMP* Fortran Compiler Directive: Identifies
synchronization points at which the threads in a team
must provide a consistent view of memory.
Syntax
!$OMP FLUSH [(list)]
The binding thread set for a FLUSH construct is the encountering thread.
1462
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The FLUSH directive must appear at the precise point in the code at which the synchronization is required. To
avoid flushing all variables, specify a list.
Thread-visible variables are written back to memory at the point at which this directive appears.
Modifications to thread-visible variables are visible to all threads after this point. Subsequent reads of thread-
visible variables fetch the latest copy of the data.
Thread-visible variables include the following data items:
• Globally visible variables (common blocks and modules)
• Local variables that do not have the SAVE attribute but have had their address taken and saved or have
had their address passed to another subprogram
• Local variables that do not have the SAVE attribute that are declared shared in a parallel region within the
subprogram
• Dummy arguments
• All pointer dereferences
The FLUSH directive is implied for the following directives (unless the NOWAIT keyword is used):
• ATOMIC and END ATOMIC
• BARRIER
• CRITICAL and END CRITICAL
• END DO
• END PARALLEL
• END SECTIONS
• END SINGLE
• END WORKSHARE
• ORDERED and END ORDERED
• PARALLEL and END PARALLEL
• PARALLEL DO and END PARALLEL DO
• PARALLEL SECTIONS and END PARALLEL SECTIONS
• TARGET
• TARGET DATA
• TARGET ENTER DATA on entry
• TARGET EXIT DATA on exit
• TARGET UPDATE on entry if TO is present and on exit if FROM is present
These directives are only available on Linux* systems: TARGET, TARGET DATA, TARGET ENTER DATA, TARGET
EXIT DATA, TARGET UPDATE.
Example
The following example uses the FLUSH directive for point-to-point synchronization between pairs of threads:
See Also
OpenMP Fortran Compiler Directives
1463
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FLUSH Statement
Statement: Causes data written to a file to become
available to other processes or causes data written to
a file outside of Fortran to be accessible to a READ
statement. It takes one of the following forms:
Syntax
FLUSH([UNIT=]io-unit [, ERR=label] [, IOMSG=msg-var] [IOSTAT=i-var])
FLUSH io-unit
label (Input) Is the label of the branch target statement that receives
control if an error occurs.
The FLUSH statement specifiers can appear in any order. An I/O unit must be specified, but the UNIT=
keyword is optional if the unit specifier is the first item in the I/O control list.
This statement has no effect on file position.
FLUSH Subroutine
Portability Subroutine: Flushes the contents of an
external unit buffer into its associated file.
Module
USE IFPORT
Syntax
CALL FLUSH (lunit)
NOTE
The flush is performed in a non-blocking mode. In this mode, the command may return before the
physical write is completed. If you want to use a blocking mode of FLUSH use COMMITQQ.
See Also
COMMITQQ
1464
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ FMA
!DIR$ NOFMA
These directives affect the current program unit but they also apply to subsequent program units in the
source file, unless and until a program unit containing another FMA or NOFMA directive is encountered.
Once a NOFMA directive has been specified, it is in effect from that point forward. The setting impacts later
routines in the source file. For example, consider that the following are in the same source file:
!dir$ nofma
fms_mul2 = a*b - c*d ! no fma generation here
end function fms_mul2
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
fma, Qfma compiler option
fp-model strict, fp:strict compiler option
FOR__SET_FTN_ALLOC
Run-Time Function: Lets you specify your own
routine to dynamically allocate common blocks. This
function is especially useful when you are sharing
libraries.
Syntax
result = FOR__SET_FTN_ALLOC(alloc_routine)
1465
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result has the same type as the type of the argument. The return value is a pointer to the previous
allocation routine you specified for allocation of COMMONs, or to a null pointer if you did not specify a
previous allocation routine.
The caller of FOR__SET_FTN_ALLOC must include a USE IFCOMMONALLOC statement. The allocation routine
should include ISO_C_BINDING so it can correctly declare the arguments.
This function takes precedence over _FTN_ALLOC.
Example
The following shows an example of a user-defined routine that can be used with FOR__SET_FTN_ALLOC.
Note that you must compile the program using option [Q]dyncom to name the commons you want to be
dynamically allocated.
! Users would put their allocation code here. This example text
! does not contain code to allocate memory.
logical for_old
! Do the swap
!
print *, "my_Fortran_alloc_routine"
if (for_old) then
saved_alloc_routine = set_ftn_alloc( C_FUNLOC(my_Fortran_alloc_routine) )
else
saved_alloc_routine = set_ftn_alloc( saved_alloc_routine )
end if
1466
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! Dynamic commons in routines first called in this region will use the
! default allocation method.
swap_alloc_routines( .true. )
swap_alloc_routines( .false. )
! Dynamic commons in routines first called in this region will use the
! default allocation method.
See Also
Allocating Common Blocks
dyncom, Qdyncom compiler option
ISO_C_BINDING
FOR_DESCRIPTOR_ASSIGN
Run-Time Subroutine: Creates an array descriptor
in memory. This routine is only available for Windows.
Module
USE IFCORE
Syntax
CALL FOR_DESCRIPTOR_ASSIGN (dp,base,size,reserved,rank,dims_info)
Note that a Fortran pointer describes both the location and type of the
data item.
size (Input) INTEGER(4). The size of the data type; for example, 4 for
INTEGER(4).
1467
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE FOR_DIMS_INFO
INTEGER(4) LOWERBOUND !Lower bound for the dimension
INTEGER(4) UPPERBOUND !Upper bound for the dimension
INTEGER(4) STRIDE !Stride for the dimension
END TYPE FOR_DIMS_INFO
The FOR_DESCRIPTOR_ASSIGN routine is similar to a Fortran pointer assignment, but gives you more control
over the assignment, allowing, for example, assignment to any location in memory.
You can also use this routine to create an array that can be used from both Fortran or C.
Example
use IFCORE
common/c_array/ array
real(8) array(5,5)
external init_array
external c_print_array
real(8),pointer :: p_array(:,:)
type(FOR_DIMS_INFO) dims_info(2)
call init_array()
do i=1,5
do j=1,5
print *,i,j, array(i,j)
end do
end do
dims_info(1)%LOWERBOUND = 11
dims_info(1)%UPPERBOUND = 15
dims_info(1)%STRIDE = 1
dims_info(2)%LOWERBOUND = -5
1468
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
dims_info(2)%UPPERBOUND = -1
dims_info(2)%STRIDE = 1
p_array = p_array + 1
call c_print_array()
end
The following shows the C program containing init_array and c_print_array:
#include <stdio.h>
#if !defined(_WIN32) && !defined(_WIN64)
#define C_ARRAY c_array_
#define INIT_ARRAY init_array_
#define C_PRINT_ARRAY c_print_array_
#endif
double C_ARRAY[5][5];
void INIT_ARRAY(void);
void C_PRINT_ARRAY(void);
void INIT_ARRAY(void)
{
int i,j;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
C_ARRAY[i][j] = j + 10*i;
}
void C_PRINT_ARRAY(void)
{
int i,j;
for(i=0;i<5;i++){
for(j=0;j<5;j++)
printf("%f ", C_ARRAY[i][j]);
printf("\n");
}
}
See Also
POINTER - Fortran
FOR_GET_FPE
Run-Time Function: Returns the current settings of
floating-point exception flags. This routine can be
called from a C or Fortran program.
Module
USE IFCORE
1469
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = FOR_GET_FPE( )
Results
The result type is INTEGER(4). The return value represents the settings of the current floating-point
exception flags. The meanings of the bits are defined in the IFPORT module file.
To set floating-point exception flags after program initialization, use FOR_SET_FPE.
Example
USE IFCORE
INTEGER*4 FPE_FLAGS
FPE_FLAGS = FOR_GET_FPE ( )
See Also
FOR_SET_FPE
FOR_IFCORE_VERSION
Portability Function: Returns the version of the
Fortran run-time library (ifcore).
Module
USE IFPORT
Syntax
result = FOR_IFCORE_VERSION (string)
string (Output) Character*(*). The version information for the Fortran run-
time library (ifcore).
Results
The result type is INTEGER(4). The result is non-zero if successful; otherwise, zero.
If string is not long enough to contain the version information, the result is truncated on the right. If string is
longer than the version information, the result is blank-padded on the right. The result may contain multiple
blank or ASCII tab characters.
Example
Consider the following:
program what_ifcore
use ifport
integer :: res
character*56 :: str
1470
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
FOR_IFCORE_VERSION
FOR_IFPORT_VERSION
Portability Function: Returns the version of the
Fortran portability library (ifport).
Module
USE IFPORT
Syntax
result = FOR_IFPORT_VERSION (string)
Results
The result type is INTEGER(4). The result is non-zero if successful; otherwise, zero.
If string is not long enough to contain the version information, the result is truncated on the right. If string is
longer than the version information, the result is blank-padded on the right. The result may contain multiple
blank or ASCII tab characters.
Example
Consider the following:
program what_ifport
use ifport
integer :: res
character*56 :: str
1471
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
FOR_IFPORT_VERSION
FOR_LFENCE
Run-Time Subroutine: Inserts a memory load fence
instruction that ensures completion of preceding load
instructions.
Module
USE IFCORE
Syntax
CALL FOR_LFENCE ()
Using this subroutine guarantees that in program order, every load instruction that precedes the load fence
instruction is globally visible before any load instruction that follows the load fence.
FOR_MFENCE
Run-Time Subroutine: Inserts a memory fence
instruction that ensures completion of all preceding
load and store instructions.
Module
USE IFCORE
Syntax
CALL FOR_MFENCE ()
Using this subroutine guarantees that in program order, every load and store instruction that precedes the
memory fence instruction is globally visible before any load or store instruction that follows the memory
fence can proceed.
for_rtl_finish_
Run-Time Function: Cleans up the Fortran run-time
environment; for example, flushing buffers and closing
files. It also issues messages about floating-point
exceptions, if any occur.
Syntax
This routine should be called from a C main program; it is invoked by default from a Fortran main program.
result = for_rtl_finish_ ( )
Results
The result is an I/O status value. For information on these status values, see Error Handling: Using the
IOSTAT Value and Fortran Exit Codes.
1472
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following C code:
int io_status;
int for_rtl_finish_ ( );
io_status = for_rtl_finish_ ( );
See Also
for_rtl_init_
for_rtl_init_
Run-Time Subroutine: Initializes the Fortran run-
time environment and causes Fortran procedures and
subroutines to behave the same as when called from a
Fortran main program. On Linux* and macOS, it also
establishes handlers and floating-point exception
handling.
Syntax
This routine should be called from a C main program; it is invoked by default from a Fortran main program.
CALL for_rtl_init_ (argcount,actarg)
Example
Consider the following C code:
int argc;
char **argv;
void for_rtl_init_ (int *, char **);
for_rtl_init_ (&argc, argv);
See Also
for_rtl_finish_
FOR_SET_FPE
Run-Time Function: Sets the floating-point
exception flags. This routine can be called from a C or
Fortran program.
Module
USE IFCORE
Syntax
result = FOR_SET_FPE (a)
1473
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The return value represents the previous settings of the floating-point
exception flags. The meanings of the bits are defined in the IFCORE module file.
To get the current settings of the floating-point exception flags, use FOR_GET_FPE.
Example
USE IFCORE
INTEGER*4 OLD_FPE_FLAGS, NEW_FPE_FLAGS
OLD_FPE_FLAGS = FOR_SET_FPE (NEW_FPE_FLAGS)
The following example program is compiled without any fpe options. However, it uses calls to for_set_fpe
to enable the same flags as when compiling with option fpe:0. The new flags can be verified by compiling
the program with option -fpe:0.
program samplefpe
use ifcore
implicit none
end
subroutine PRINT_FPE_FLAGS(fpe_flags)
use ifcore
implicit none
integer(4) :: fpe_flags
character(3) :: toggle
1474
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
endif
write(*,*) " FPE_TRAP_OVF :", toggle
>ifort set_fpe_sample01.f90
>set_fpe_sample01.exe
The original FPE FLAGS were:
1475
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
if (ieee_support_subnormal()) then
print *, "Subnormals already supported"
else
orig_flags = for_get_fpe()
if (ieee_support_subnormal()) then
print *, "Subnormals are now supported"
else
print *, "Error: Subnormals still not supported after FOR_SET_FPE call"
end if
1476
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
end if
x = 0.0
y = tiny(x)
if (ieee_support_subnormal()) then
print *, "Subnormals already supported; turn off"
orig_flags = for_get_fpe()
if (ieee_support_subnormal()) then
print *, "Error: Subnormals still supported after FOR_SET_FPE call"
else
print *, "Subnormals are now NOT supported, should flush to zero"
end if
else
print *, "Subnormals already not supported"
end if
1477
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 FORMAT(1X,Z)
2 FORMAT("Flush to zero",1X,E40.25)
x = 0.0
y = tiny(x)
! Expect zeros
!
do i = 1, 20
y = y / 2.0
print 1,y
enddo
FOR_SET_REENTRANCY
Run-Time Function: Controls the type of reentrancy
protection that the Fortran Run-Time Library (RTL)
exhibits. This routine can be called from a C or Fortran
program.
Module
USE IFCORE
Syntax
result = FOR_SET_REENTRANCY (mode)
mode Must be of type INTEGER(4) and contain one of the following options:
1478
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The return value represents the previous setting of the Fortran Run-Time
Library reentrancy mode, unless the argument is FOR_K_REENTRANCY_INFO, in which case the return value
represents the current setting.
You must be using an RTL that supports the level of reentrancy you desire. For example,
FOR_SET_REENTRANCY ignores a request for thread protection (FOR_K_REENTRANCY_THREADED) if you do
not build your program with the thread-safe RTL.
Example
PROGRAM SETREENT
USE IFCORE
INTEGER*4 MODE
CHARACTER*10 REENT_TXT(3) /'NONE ','ASYNCH ','THREADED'/
PRINT*,'Setting Reentrancy mode to ',REENT_TXT(MODE+1)
MODE = FOR_SET_REENTRANCY(FOR_K_REENTRANCY_NONE)
PRINT*,'Previous Reentrancy mode was ',REENT_TXT(MODE+1)
MODE = FOR_SET_REENTRANCY(FOR_K_REENTRANCY_INFO)
PRINT*,'Current Reentrancy mode is ',REENT_TXT(MODE+1)
END
FOR_SFENCE
Run-Time Subroutine: Inserts a memory store fence
instruction that ensures completion of preceding store
instructions.
Module
USE IFCORE
Syntax
CALL FOR_SFENCE ()
Using this subroutine guarantees that in program order, every store instruction that precedes the store fence
instruction is globally visible before any store instruction that follows the store fence.
1479
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FORALL
Statement and Construct: The FORALL statement
and construct is an element-by-element generalization
of the masked array assignment in the WHERE
statement and construct. It allows more general array
shapes to be assigned, especially in construct form.
The FORALL construct is an obsolescent language
feature in Fortran 2018.
Syntax
Statement:
FORALL (triplet-spec[, triplet-spec] ...[, mask-expr]) assign-stmt
Construct:
[name:] FORALL (triplet-spec[, triplet-spec] ...[, mask-expr])
forall-body-stmt
[forall-body-stmt]...
END FORALL [name]
Description
If a construct name is specified in the FORALL statement, the same name must appear in the corresponding
END FORALL statement.
1480
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A FORALL statement is executed by first evaluating all bounds and stride expressions in the triplet
specifications, giving a set of values for each subscript name. The FORALL assignment statement is executed
for all combinations of subscript name values for which the mask expression is true.
The FORALL assignment statement is executed as if all expressions (on both sides of the assignment) are
completely evaluated before any part of the left side is changed. Valid values are assigned to corresponding
elements of the array being assigned to. No element of an array can be assigned a value more than once.
A FORALL construct is executed as if it were multiple FORALL statements, with the same triplet specifications
and mask expressions. Each statement in the FORALL body is executed completely before execution begins
on the next FORALL body statement.
Any procedure referenced in the mask expression or FORALL assignment statement must be pure.
Pure functions can be used in the mask expression or called directly in a FORALL statement. Pure subroutines
cannot be called directly in a FORALL statement, but can be called from other pure procedures.
Starting with Fortran 2018, the FORALL statement and construct are obsolescent features.
Example
The following example, which is not expressible using array syntax, sets diagonal elements of an array to 1:
REAL, DIMENSION(N, N) :: A
FORALL (I=1:N) A(I, I) = 1
Consider the following:
TYPE MONARCH
INTEGER, POINTER :: P
END TYPE MONARCH
TYPE(MONARCH), DIMENSION(8) :: PATTERN
INTEGER, DIMENSION(8), TARGET :: OBJECT
FORALL(J=1:8) PATTERN(J)%P => OBJECT(1+IEOR(J-1,2))
This FORALL statement causes elements 1 through 8 of array PATTERN to point to elements 3, 4, 1, 2, 7, 8,
5, and 6, respectively, of OBJECT. IEOR can be referenced here because it is pure.
The following example shows a FORALL construct:
1481
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The assignment to array D uses the values of C computed in the first statement in the construct, not the
values before the construct began execution.
See Also
WHERE
FORMAT
Statement: Specifies the form of data being
transferred and the data conversion (editing) required
to achieve that form.
Syntax
FORMAT (format-list)
Description
A FORMAT statement must be labeled.
Named constants are not permitted in format specifications.
If the associated I/O statement contains an I/O list, the format specification must contain at least one data
edit descriptor or the control edit descriptor Q.
Blank characters can precede the initial left parenthesis, and additional blanks can appear anywhere within
the format specification. These blanks have no meaning unless they are within a character string edit
descriptor.
When a formatted input statement is executed, the setting of the BLANK specifier (for the relevant logical
unit) determines the interpretation of blanks within the specification. If the BN or BZ edit descriptors are
specified for a formatted input statement, they supersede the default interpretation of blanks. (For more
information on BLANK defaults, see the OPEN statement.
For formatted input, you can use the comma as an external field separator. The comma terminates the input
of fields (for noncharacter data types) that are shorter than the number of characters expected. It can also
designate null (zero-length) fields.
1482
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The first character of a record transmitted to a line printer or terminal is typically used for carriage control; it
is not printed. The first character of such a record should be a blank, 0, 1, $,+, or ASCII NUL. Any other
character is treated as a blank.
A format specification cannot specify more output characters than the external record can contain. For
example, a line printer record cannot contain more than 133 characters, including the carriage control
character.
Whenever an edit descriptor requires an integer constant, you can specify an expression enclosed in angle
brackets (< and >). For more information, see Variable Format Expressions.
The integer expression can be any valid Fortran expression, including function calls and references to dummy
arguments, with the following restrictions:
• Expressions cannot be used with the H edit descriptor.
• Expressions cannot contain graphical relational operators (such as > and <).
The value of the expression is reevaluated each time an input/output item is processed during the execution
of the READ, WRITE, or PRINT statement.
The following tables summarize the different kinds of edit descriptors:
1483
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1484
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
INTEGER width, value
width = 2
read (*,1) width, value
! if the input is 3123, prints 123, not 12
1 format ( i1, i<width>)
print *, value
END
See Also
I/O Formatting
Format Specifications
Variable Format Expressions
Data Edit Descriptors
FORM TEAM
Statement: Defines team variables; creates one or
more teams of images from the images on the current
team.
Syntax
The FORM TEAM statement takes the following form:
FORM TEAM(team-number, team-variable [, form-team-spec-list])
team-number Is a scalar-integer-expression.
stat-var Is a scalar integer variable in which the status of the FORM TEAM
operation is stored.
The form-team-spec items can appear in any order. Each specifier in a FORM TEAM statement can appear at
most once. stat-var and err-var cannot be coindexed variables.
1485
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
A FORM TEAM statement creates a new team for each unique team-number specified by the active images of
the current team. The teams are identified by their team numbers, which are positive integers. An image
becomes a member of the team-number specified on the FORM TEAM statement the image executes. The
team-variable becomes defined with values that describe the team.
An image index must be positive and less than or equal to n, the number of images on the team. If
NEW_INDEX= is specified, the value of the scalar-integer-expression is the image index the image executing
the FORM TEAM statement will have on its new team. Its value must be different from any value specified for
every other image that is assigned to the same new team. If NEW_IMAGE= is not specified, the image is
given a processor-dependent unique image index in the range 1, 2, … n on the new team.
All active images of the current team must execute the same FORM TEAM statement. An implicit SYNC ALL
occurs at the FORM TEAM statement. Execution of the segment following the FORM TEAM statement is
delayed until other images of the current team have executed the same FORM TEAM statement the same
number of times. FORM TEAM is an image control statement; all segments executed before the FORM TEAM
statement precede all segments that execute after the FORM TEAM statement.
If STAT= appears and no error occurs, stat-var becomes defined with the value 0. If an image on the current
team has executed a STOP statement, stat-var is assigned the value STAT_STOPPED_IMAGE from the
intrinsic module ISO_FORTRAN_ENV. If there is a failed image on the current team and no other error occurs,
stat-var is assigned the value STAT_FAILED_IMAGE from ISO_FORTRAN_ENV. Otherwise, stat-var is assigned
a positive integer value different from STAT_FAILED_IMAGE and STAT_STOPPED_IMAGE.
team-variable becomes undefined if an error condition occurs.
Examples
Example 1:
USE ISO_FORTRAN
TYPE (TEAM_TYPE) :: one_or_two
IF (THIS_IMAGE() .LE. NUM_IMAGES() / 2) THEN
new_team = 1
ELSE
new_team = 2
END IF
FORM TEAM (new_team, one_or_two)
If the initial team has seven images, and the initial team executes the above FORM TEAM statement, two
teams are formed. The new image indices are assigned by the runtime system in a processor-dependent
manner.
Team number 1 has three images, images [1, 2, 3] of the initial team with new image indices [1, 2, 3]. Team
number 2 has four images, images [4, 5, 6, 7] from the initial team, with new image indices [1, 2, 3, 4]. The
team variable one_or_two on initial team images [1, 2, 3] collectively describe team number 1, while the
team variable one_or_two on the initial team images [4, 5, 6, 7] collectively describe team number 2.
Example 2:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: odd_even
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
If a team with 10 images executes the above code, two teams are formed. Team number 1 contains the odd
numbered images [1, 3, 5, 7, 9] of the parent team, and team number 2 contains the even numbered
images [2, 4, 6, 8, 10] of the parent. New image indices on each team are assigned by the processor. The
team variable odd_even across the odd numbered images on the parent team collectively describe team
number 1, and the team variable odd_even across the even numbered images on the parent team
collectively describe team number 2.
1486
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example 3:
USE ISO_FORTRAN_ENV
INTEGER, PARAMETER :: n = 4
TYPE (TEAM_TYPE) :: column
REAL,CODIMENSION[n, *] :: co_array
INTEGER,DIMENSION(2) :: my_cosubscripts
my_cosubscripts (:) = THIS_IMAGE(co_array)
FORM TEAM (my_cosubscripts(2), column, NEW_INDEX = my_cosubscripts(1))
If there are 16 images on the initial team, the scalar coarray co_array will be distributed across a 4x4 grid
of processors. The image indices of the 4x4 grid are:
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
THIS_IMAGE (co_array) will return a two element array of integer cosubscripts of co_array on the image
that executes the reference to THIS_IMAGE. The cosubscripts of each image are:
Execution of the FORM TEAM statement divides the initial team into four teams of four images. Each team
contains the images of one column of the grid of processors. The team number of each team is the column
number in the processor grid, and the image indices on each new team are the row indices of the processor
grid. The new image numbers on each team are shown below:
Team 1 2 3 4
Number
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
Example 4:
This example divides a 4x4 grid of images into 4 2x2 grids of images. Team numbers are assigned in the
FORM TEAM statement that reflect the position of each team in the grid of subteams. The example also
shows the use of NEW_INDEX to assign image indices to the images of the new teams.
The image indices of the 4x4 grid are:
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
The 2x2 grids are laid out and identified symbolically and with team numbers as:
top_lef top_rig
t (1,1) ht (1,2)
bot_lef bot_rig
t (2,1) ht (2,2)
The image numbers on each of the teams in the 2x2 grids become:
1487
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 3 1 3
2 4 2 4
1 3 1 3
2 4 2 4
PROGRAM MAIN
USE ISO_FORTRAN_ENV
INTEGER,PARAMETER :: top_left=11, bot_left=21, top_right=12, bot_right=22
INTEGER,DIMENSION(16) :: quads = [top_left, top_left, bot_left, bot_left, &
top_left, top_left, bot_left_ bot_left, &
top_right, top_right, bot_right, bot_right, &
top_right, top_right, bot_right, bot_right]
INTEGER,DIMENSION(16) :: images = [1,2,1,2,3,4,3,4,1,2,1,2,3,4,3,4]
TYPE(TEAM_TYPE) :: quadrants
INTEGER :: me
me = THIS_IMAGE()
FORM TEAM (quads(me), quadrants, NEW_INDEX=images(me))
. . .
END PROGRAM
Example 5:
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: original
FORM TEAM (1, original, NEW_INDEX = THIS_IMAGE())
This example forms a single subteam described by the team variable original. The subteam has the same
number of images as the initial team, and each image has the same image number on the initial team as on
the subteam. However, original describes a team that is different but functionally the same as the initial
team. It has a parent team, while the initial team does not.
See Also
Image Control Statements
Coarrays
Using Coarrays
FP_CLASS
Elemental Intrinsic Function (Generic): Returns
the class of an IEEE* real (binary32, binary64, and
binary128) argument. This function cannot be passed
as an actual argument.
Syntax
result = FP_CLASS (x)
Results
The result type is INTEGER(4). The return value is one of the following:
1488
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
FP_CLASS (4.0_8) has the value 4 (FOR_K_FP_POS_NORM).
FPUTC
Portability Function: Writes a character to the file
specified by a Fortran external unit, bypassing normal
Fortran input/output.
Module
USE IFPORT
Syntax
result = FPUTC (lunit,char)
Results
The result type is INTEGER(4). The result is zero if the write was successful; otherwise, an error code, such
as:
EINVAL - The specified unit is invalid (either not already open, or an invalid unit number)
If you use WRITE, READ, or any other Fortran I/O statements with lunit, be sure to read Input and Output
Routines in Overview of Portability Routines.
Example
use IFPORT
integer*4 lunit, i4
character*26 string
character*1 char1
lunit = 1
open (lunit,file = 'fputc.dat')
do i = 1,26
char1 = char(123-i)
1489
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
I/O Formatting
FRACTION
Elemental Intrinsic Function (Generic): Returns
the fractional part of the model representation of the
argument value.
Syntax
result = FRACTION (x)
Results
The result type and kind are the same as x.
The result has the value x* b e. Parameters b and e are defined in Model for Real Data.
If x has the value zero, the result has the value zero.
Example
If 3.0 is a REAL(4) value, FRACTION (3.0) has the value 0.75.
The following shows another example:
REAL result
result = FRACTION(3.0) ! returns 0.75
result = FRACTION(1024.0) ! returns 0.5
See Also
DIGITS
RADIX
EXPONENT
Data Representation Models
FREE
Intrinsic Subroutine (Specific): Frees a block of
memory that is currently allocated. Intrinsic
subroutines cannot be passed as actual arguments.
Syntax
CALL FREE (addr)
If the freed address was not previously allocated by MALLOC, or if an address is freed more than once,
results are unpredictable.
1490
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
INTEGER(4) SIZE
REAL(4) STORAGE(*)
POINTER (ADDR, STORAGE) ! ADDR will point to STORAGE
SIZE = 1024 ! Size in bytes
ADDR = MALLOC(SIZE) ! Allocate the memory
CALL FREE(ADDR) ! Free it
Syntax
!DIR$ FREEFORM
!DIR$ NOFREEFORM
When the FREEFORM or NOFREEFORM directives are used, they remain in effect for the remainder of the
source or include file in which the directive appears, or until the opposite directive is used. When in effect,
they apply to include files, but do not affect USE modules, which are compiled separately.
source or include file in which the directive appears
Example
Consider the following:
See Also
Source Forms
General Compiler Directives
Syntax Rules for Compiler Directives
free compiler option
Equivalent Compiler Options
FSEEK
Portability Function: Repositions a file specified by a
Fortran external unit.
1491
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = FSEEK (lunit,offset,from)
Results
The result type is INTEGER(4). The result is zero if the repositioning was successful; otherwise, an error
code, such as:
EINVAL: The specified unit is invalid because either the unit is not already open, an invalid unit number was
specified, or the from parameter is invalid.
The file specified in lunit must be open.
Example
USE IFPORT
integer(4) istat, offset, ipos
character ichar
OPEN (unit=1,file='datfile.dat')
offset = 5
ipos = 0
istat=fseek(1,offset,ipos)
if (.NOT. stat) then
istat=fgetc(1,ichar)
print *, 'data is ',ichar
end if
FSTAT
Portability Function: Returns detailed information
about a file specified by a external unit number.
Module
USE IFPORT
1492
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = FSTAT (lunit,statb)
1493
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, returns an error code equal to
EINVAL (lunit is not a valid unit number, or is not open).
The access mode (the third element of statb) is a bitmap consisting of an IOR of the following constants:
1494
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT returns the same information as FSTAT, but accesses files by name instead of external unit number.
Example
USE IFPORT
integer(4) statarray(12), istat
OPEN (unit=1,file='datfile.dat')
ISTAT = FSTAT (1, statarray)
if (.NOT. istat) then
print *, statarray
end if
See Also
INQUIRE
STAT
FTELL, FTELLI8
Portability Functions: Return the current position of
a file.
Module
USE IFPORT
Syntax
result = FTELL (lunit)
result = FTELLI8 (lunit)
1495
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4) for FTELL; INTEGER(8) for FTELLI8. The result is the offset, in bytes, from the
beginning of the file. A negative value indicates an error, which is the negation of the IERRNO error code. The
following is an example of an error code:
EINVAL: lunit is not a valid unit number, or is not open.
FULLPATHQQ
Portability Function: Returns the full path for a
specified file or directory.
Module
USE IFPORT
Syntax
result = FULLPATHQQ (name,pathbuf)
name (Input) Character*(*). Item for which you want the full path. Can be
the name of a file in the current directory, a relative directory or file
name, or a network uniform naming convention (UNC) path.
Results
The result type is INTEGER(4). The result is the length of the full path in bytes, or 0 if the function fails. This
function does not verify that the resulting path and file name are valid nor that they exist.
The length of the full path depends upon how deeply the directories are nested on the drive you are using. If
the full path is longer than the character buffer provided to return it ( pathbuf), FULLPATHQQ returns only
that portion of the path that fits into the buffer.
Check the length of the path before using the string returned in pathbuf. If the longest full path you are likely
to encounter does not fit into the buffer you are using, allocate a larger character buffer. You can allocate the
largest possible path buffer with the following statements:
USE IFPORT
CHARACTER($MAXPATH) pathbuf
$MAXPATH is a symbolic constant defined in IFPORT.F90 as 260.
Example
USE IFPORT
USE IFCORE
CHARACTER($MAXPATH) buf
CHARACTER(3) drive
CHARACTER(256) dir
CHARACTER(256) name
CHARACTER(256) ext
CHARACTER(256) file
INTEGER(4) len
DO WHILE (.TRUE.)
WRITE (*,*)
WRITE (*,'(A, \)') ' Enter filename (Hit &
RETURN to exit): '
len = GETSTRQQ(file)
IF (len .EQ. 0) EXIT
1496
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SPLITPATHQQ
FUNCTION
Statement: The initial statement of a function
subprogram. A function subprogram is invoked in an
expression and returns a single value (a function
result) that is used to evaluate the expression.
Syntax
[prefix [prefix]] FUNCTION name [([d-arg-list])] [suffix]
[specification-part]
[execution-part]
[CONTAINS
[internal-subprogram-part]]
END [FUNCTION [name]]
1497
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
name Is the name of the function. If RESULT is specified, the function name
must not appear in any specification statement in the scoping unit of
the function subprogram.
The function name can be followed by the length of the data type. The
length is specified by an asterisk (*) followed by any unsigned,
nonzero integer that is a valid length for the function's type. For
example, REAL FUNCTION LGFUNC*8 (Y, Z) specifies the function
result as REAL(8) (or REAL*8).
This optional length specification is not permitted if the length has
already been specified following the keyword CHARACTER.
FUNCTION F
1498
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The type and kind parameters (if any) of the function's result can be defined in the FUNCTION statement or
in a type declaration statement within the function subprogram, but not both. If no type is specified, the type
is determined by implicit typing rules in effect for the function subprogram.
Execution begins with the first executable construct or statement following the FUNCTION statement. Control
returns to the calling program unit once the END statement (or a RETURN statement) is executed.
If you specify CHARACTER(LEN=*) as the type of the function, the function assumes the length declared for
it in the program unit that invokes it. This type of the resulting character function can have different lengths
when it is invoked by different program units. An assumed-length character function cannot be directly
recursive.
If the character length is specified as an integer constant, the value must agree with the length of the
function specified in the program unit that invokes the function. If no length is specified, a length of 1 is
assumed.
If the function is array-valued or a pointer, the declarations within the function must state these attributes for
the function result name. The specification of the function result attributes, dummy argument attributes, and
the information in the procedure heading collectively define the interface of the function.
The value of the result variable is returned by the function when it completes execution. Certain rules apply
depending on whether the result is a pointer, as follows:
• If the result is a pointer, its allocation status must be determined before the function completes execution.
The function must associate a target with the pointer, or cause the pointer to be explicitly disassociated
from a target.
If the pointer result points to a TARGET with the INTENT(IN) attribute, the function can give the result a
value but the caller is not allowed to change the value pointed to.
• The shape of the value returned by the function is determined by the shape of the result variable when
the function completes execution.
• If the result is not a pointer, its value must be defined before the function completes execution. If the
result is an array, all the elements must be defined. If the result is a derived-type structure, all the
components must be defined.
A function subprogram cannot contain a BLOCK DATA statement, a PROGRAM statement, a MODULE
statement, or a SUBMODULE statement. A function can contain SUBROUTINE and FUNCTION statements to
define internal procedures. ENTRY statements can be included to provide multiple entry points to the
subprogram.
Example
The following example uses the Newton-Raphson iteration method (F(X) = cosh(X) + cos(X) - A = 0)
to get the root of the function:
FUNCTION ROOT(A)
IF (A >= 2.0) THEN
X = 1.0
DO
EX = EXP(X)
EMINX = 1./EX
ROOT = X - ((EX+EMINX)*.5+COS(X)-A)/((EX-EMINX)*.5-SIN(X))
IF (ABS((X-ROOT)/ROOT) .LT. 1E-6) RETURN
X = ROOT
1499
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END DO
ELSE
STOP 'in FUNCTION ROOT, A must be >= 2.0'
ENDIF
END
In the preceding example, the following formula is calculated repeatedly until the difference between Xi and
Xi+1 is less than 1.0E-6:
INTEGER Divby2
10 PRINT *, 'Enter a number'
READ *, i
Print *, Divby2(i)
GOTO 10
END
C
C This is the function definition
C
INTEGER FUNCTION Divby2 (num)
Divby2=num / 2
END FUNCTION
1500
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE AP
CONTAINS
FUNCTION ADD_VEC(P1,P2)
! Function to add two allocatable arrays of possibly differing lengths.
! The arrays may be thought of as polynomials (coefficients)
REAL, ALLOCATABLE :: ADD_VEC(:), P1(:), P2(:)
PROGRAM TEST
USE AP
REAL, ALLOCATABLE :: P(:), Q(:), R(:), S(:)
ALLOCATE(P(3))
ALLOCATE(Q(2))
ALLOCATE(R(3))
ALLOCATE(S(3))
P = (/1,1,1/) ! P = X**2 + X + 1
R = (/2,2,2/) ! R = 2X**2 + 2X + 2
S = (/3,3,3/) ! S = 3X**2 + 3X + 3
PRINT *,' Result should be: 6.000000 6.000000 6.000000'
PRINT *,' Coefficients are: ', ADD_VEC(ADD_VEC(P,R), S)
END
Consider the following example:
module mymodule
type :: vec
integer :: x(3)
contains
procedure :: at
end type vec
contains
function at( this, i ) result( p )
implicit none
class(vec), intent(in), target :: this
integer, intent(in) :: i
1501
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
integer, pointer :: p
p => this%x(i)
end function at
end module mymodule
program test
use mymodule
implicit none
type(vec) :: myvec
myvec%x = [1,2,3]
See Also
ENTRY
SUBROUTINE
PURE
ELEMENTAL
RESULT keyword
Function References
Program Units and Procedures
General Rules for Function and Subroutine Subprograms
G
This section describes language features that start with G.
G
GAMMA
Elemental Intrinsic Function (Generic): Returns
the gamma value of its argument.
Syntax
result = GAMMA (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the gamma function of x,
1502
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
GAMMA (1.0) has the approximate value 1.000.
GENERIC
Statement: Declares a generic interface that is bound
to a derived type-bound procedure, or specifies a
generic identifier for one or more specific procedures.
Syntax
The GENERIC statement takes the following form:
GENERIC [, access-spec]:: generic-spec => binding-name1 [, binding-name2]...
Examples
Consider the following:
1503
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE MY_TYPE2
...
CONTAINS
PROCEDURE :: MYPROC => MYPROC1
PROCEDURE,PASS(C) :: UPROC => UPROC1
GENERIC :: OPERATOR(+) => MYPROC, UPROC
END TYPE MY_TYPE2
...
TYPE,EXTENDS(MY_TYPE2) :: MY_TYPE3
...
CONTAINS
PROCEDURE :: MYPROC => MYPROC2
PROCEDURE,PASS(C) :: UPROC => UPROC2
END TYPE MY_TYPE3
The type MY_TYPE3 inherits the generic operator '+'. Invoking the generic (+) invokes the specific type-
bound procedure. For entities of type MY_TYPE3, that invokes the overriding actual procedure (MYPROC2 or
UPROC2).
See Also
Type-Bound Procedures
Defining Generic Names for Procedures
GERROR
Run-Time Subroutine: Returns a message for the
last error detected by a Fortran run-time routine.
Module
USE IFCORE
Syntax
CALL GERROR (string)
The last detected error does not necessarily correspond to the most recent function call. The compiler resets
string only when another error occurs.
Example
USE IFCORE
character*40 errtext
character char1
integer*4 iflag, i4
. . .!Open unit 1 here
i4=fgetc(1,char1)
if (i4) then
iflag = 1
Call GERROR (errtext)
print *, errtext
end if
See Also
PERROR
1504
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IERRNO
GETARG
Intrinsic Subroutine: Returns the specified
command-line argument (where the command itself is
argument number zero). Intrinsic subroutines cannot
be passed as actual arguments.
Syntax
CALL GETARG (n,buffer[,status])
buffer (Output) Must be a scalar of type default character. Its value is the
returned command-line argument.
GETARG returns the nth command-line argument. If n is zero, the name of the executing program file is
returned.
GETARG returns command-line arguments as they were entered. There is no case conversion.
If the command-line argument is shorter than buffer, GETARG pads buffer on the right with blanks. If the
argument is longer than buffer, GETARG truncates the argument on the right. If there is an error, GETARG
fills buffer with blanks.
Example
Assume a command-line invocation of PROG1 -g -c -a, and that buffer is at least five characters long. The
following calls to GETARG return the corresponding arguments in buffer and status:
See Also
NARGS
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND
1505
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GET_COMMAND_ARGUMENT
GETC
Portability Function: Reads the next available
character from external unit 5, which is normally
connected to the console.
Module
USE IFPORT
Syntax
result = GETC (char)
Results
The result type is INTEGER(4). The result is zero if successful, or -1 if an end-of-file was detected.
Example
use IFPORT
character ans,errtxt*40
print *, 'Enter a character: '
ISTAT = GETC (ans)
if (istat) then
call gerror(errtxt)
end if
See Also
GETCHARQQ
GETSTRQQ
GETCHARQQ
Run-Time Function: Returns the next keystroke.
Module
USE IFCORE
Syntax
result = GETCHARQQ( )
Results
The result type is character with length 1. The result is the character representing the key that was pressed.
The value can be any ASCII character.
If the key pressed is represented by a single ASCII character, GETCHARQQ returns the character. If the key
pressed is a function or direction key, a hex Z'00' or Z'E0' is returned. If you need to know which function or
direction was pressed, call GETCHARQQ a second time to get the extended code for the key.
If there is no keystroke waiting in the keyboard buffer, GETCHARQQ waits until there is one, and then returns
it. Compare this to the function PEEKCHARQQ, which returns .TRUE. if there is a character waiting in the
keyboard buffer, and .FALSE. if not. You can use PEEKCHARQQ to determine if GETCHARQQ should be called.
This can prevent a program from hanging while GETCHARQQ waits for a keystroke that isn't there. Note that
PEEKCHARQQ is only supported in console applications.
1506
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If your application is a QuickWin or Standard Graphics application, you may want to put a call to
PASSDIRKEYSQQ in your program. This will enable the program to get characters that would otherwise be
trapped. These extra characters are described in PASSDIRKEYSQQ.
Note that the GETCHARQQ routine used in a console application is a different routine than the one used in a
QuickWin or Standard Graphics application. The GETCHARQQ used with a console application does not trap
characters that are used in QuickWin for a special purpose, such as scrolling. Console applications do not
need, and cannot use PASSDIRKEYSQQ.
Example
! Program to demonstrate GETCHARQQ
USE IFCORE
CHARACTER(1) key / 'A' /
PARAMETER (ESC = 27)
PARAMETER (NOREP = 0)
WRITE (*,*) ' Type a key: (or q to quit)'
! Read keys until ESC or q is pressed
DO WHILE (ICHAR (key) .NE. ESC)
key = GETCHARQQ()
! Some extended keys have no ASCII representation
IF(ICHAR(key) .EQ. NOREP) THEN
key = GETCHARQQ()
WRITE (*, 900) 'Not ASCII. Char = NA'
WRITE (*,*)
! Otherwise, there is only one key
ELSE
WRITE (*,900) 'ASCII. Char = '
WRITE (*,901) key
END IF
IF (key .EQ. 'q' ) THEN
EXIT
END IF
END DO
900 FORMAT (1X, A, \)
901 FORMAT (A)
END
See Also
PEEKCHARQQ
GETSTRQQ
INCHARQQ
MBINCHARQQ
GETC
FGETC
PASSDIRKEYSQQ
GET_COMMAND
Intrinsic Subroutine: Returns the entire command
that was used to invoke the program.
Syntax
CALL GET_COMMAND ([command, length, status, errmsg])
1507
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
See the example in COMMAND_ARGUMENT_COUNT.
See Also
GETARG
NARGS
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND_ARGUMENT
GET_COMMAND_ARGUMENT
Intrinsic Subroutine: Returns a command line
argument of the command that invoked the program.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL GET_COMMAND_ARGUMENT (number [, value, length, status, errmsg])
1508
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
See the example in COMMAND_ARGUMENT_COUNT.
See Also
GETARG
NARGS
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND
GETCONTROLFPQQ
Portability Subroutine: Returns the floating-point
processor control word.
Module
USE IFPORT
Syntax
CALL GETCONTROLFPQQ (controlword)
1509
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0.
Exceptions can be disabled by setting the control bits to 1 with SETCONTROLFPQQ.
If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes
generate an appropriate special value (NaN or signed infinity), but the program continues.
You can find out which exceptions (if any) occurred by calling GETSTATUSFPQQ. If errors on floating-point
exceptions are enabled (by clearing the control bits to 0 with SETCONTROLFPQQ), the operating system
generates an interrupt when the exception occurs. By default, these interrupts cause run-time errors, but
you can capture the interrupts with SIGNALQQ and branch to your own error-handling routines.
You can use GETCONTROLFPQQ to retrieve the current control word and SETCONTROLFPQQ to change the
control word. Most users do not need to change the default settings.
1510
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
INTEGER(2) control
CALL GETCONTROLFPQQ (control)
! if not rounding down
IF (IAND(control, FPCW$DOWN) .NE. FPCW$DOWN) THEN
control = IAND(control, NOT(FPCW$MCW_RC)) ! clear all
! rounding
control = IOR(control, FPCW$DOWN) ! set to
! round down
CALL SETCONTROLFPQQ(control)
END IF
END
See Also
SETCONTROLFPQQ
GETSTATUSFPQQ
SIGNALQQ
CLEARSTATUSFPQQ
GETCWD
Portability Function: Returns the path of the current
working directory.
Module
USE IFPORT
Syntax
result = GETCWD (dirname)
dirname (Output) Character *(*). Name of the current working directory path,
including drive letter.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code.
Example
USE IFPORT
character*30 dirname
! variable dirname must be long enough to hold entire string
integer(4) istat
ISTAT = GETCWD (dirname)
IF (ISTAT == 0) write *, 'Current directory is ',dirname
See Also
GETDRIVEDIRQQ
GETDAT
Portability Subroutine: Returns the date.
Module
USE IFPORT
1511
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL GETDAT (iyr, imon, iday)
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
Example
! Program to demonstrate GETDAT and GETTIM
USE IFPORT
INTEGER(4) tmpday, tmpmonth, tmpyear
INTEGER(4) tmphour, tmpminute, tmpsecond, tmphund
CHARACTER(1) mer
CALL GETDAT(tmpyear, tmpmonth, tmpday)
CALL GETTIM(tmphour, tmpminute, tmpsecond, tmphund)
IF (tmphour .GT. 12) THEN
mer = 'p'
tmphour = tmphour - 12
ELSE
mer = 'a'
END IF
WRITE (*, 900) tmpmonth, tmpday, tmpyear
900 FORMAT(I2, '/', I2.2, '/', I4.4)
WRITE (*, 901) tmphour, tmpminute, tmpsecond, tmphund, mer
901 FORMAT(I2, ':', I2.2, ':', I2.2, ':', I2.2, ' ',&
A, 'm')
END
See Also
GETTIM
SETDAT
SETTIM
FDATE
JDATE
GETDRIVEDIRQQ
Portability Function: Returns the path of the current
working directory on a specified drive.
1512
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = GETDRIVEDIRQQ (drivedir)
Results
The result type is INTEGER(4). The result is the length (in bytes) of the full path of the directory on the
specified drive. Zero is returned if the path is longer than the size of the character buffer drivedir.
You specify the drive from which to return the current working directory by putting the drive letter into
drivedir before calling GETDRIVEDIRQQ. To make sure you get information about the current drive, put the
symbolic constant FILE$CURDRIVE (defined in IFPORT.F90) into drivedir.
Because drives are identified by a single alphabetic character, GETDRIVEDIRQQ examines only the first letter
of drivedir. For instance, if drivedir contains the path c:\fps90\bin, GETDRIVEDIRQQ ( drivedir) returns the
current working directory on drive C and disregards the rest of the path. The drive letter can be uppercase or
lowercase.
The length of the path returned depends on how deeply the directories are nested on the drive specified in
drivedir. If the full path is longer than the length of drivedir, GETDRIVEDIRQQ returns only the portion of the
path that fits into drivedir. If you are likely to encounter a long path, allocate a buffer of size $MAXPATH
($MAXPATH = 260).
On Linux* and macOS systems, the function gets a path only when symbolic constant FILE$CURDRIVE has
been applied to drivedir.
Example
! Program to demonstrate GETDRIVEDIRQQ
USE IFPORT
CHARACTER($MAXPATH) dir
INTEGER(4) length
! Get current directory
dir = FILE$CURDRIVE
length = GETDRIVEDIRQQ(dir)
IF (length .GT. 0) THEN
WRITE (*,*) 'Current directory is: '
WRITE (*,*) dir
ELSE
WRITE (*,*) 'Failed to get current directory'
END IF
END
See Also
CHANGEDRIVEQQ
CHANGEDIRQQ
GETDRIVESIZEQQ
GETDRIVESQQ
GETLASTERRORQQ
SPLITPATHQQ
1513
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETDRIVESIZEQQ
Portability Function: Returns the total size of the
specified drive and space available on it.
Module
USE IFPORT
Syntax
result = GETDRIVESIZEQQ (drive,total,avail)
drive (Input) Character*(*). String containing the letter of the drive to get
information about.
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The data types and dimension (if any) specified for the total and avail arguments must be the same.
Specifying an array of two INTEGER(4) elements, or an INTEGER(8) argument, allows drive sizes larger than
2147483647 to be returned.
If an array of two INTEGER(4) elements is specified, the least-significant 32 bits are returned in the first
element, the most-significant 32 bits in the second element. If an INTEGER(4) scalar is specified, the least-
significant 32 bits are returned.
Because drives are identified by a single alphabetic character, GETDRIVESIZEQQ examines only the first
letter of drive. The drive letter can be uppercase or lowercase. You can use the constant FILE$CURDRIVE
(defined in IFPORT.F90) to get the size of the current drive.
Example
! Program to demonstrate GETDRIVESQQ and GETDRIVESIZEQQ
USE IFPORT
CHARACTER(26) drives
CHARACTER(1) adrive
LOGICAL(4) status
INTEGER(4) total, avail
INTEGER(2) i
! Get the list of drives
drives = GETDRIVESQQ()
WRITE (*,'(A, A)') ' Drives available: ', drives
!
!Cycle through them for free space and write to console
DO i = 1, 26
adrive = drives(i:i)
status = .FALSE.
WRITE (*,'(A, A, A, \)') ' Drive ', CHAR(i + 64), ':'
IF (adrive .NE. ' ') THEN
status = GETDRIVESIZEQQ(adrive, total, avail)
END IF
IF (status) THEN
WRITE (*,*) avail, ' of ', total, ' bytes free.'
1514
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ELSE
WRITE (*,*) 'Not available'
END IF
END DO
END
See Also
GETLASTERRORQQ
GETDRIVESQQ
GETDRIVEDIRQQ
CHANGEDRIVEQQ
CHANGEDIRQQ
GETDRIVESQQ
Portability Function: Reports which drives are
available to the system.
Module
USE IFPORT
Syntax
result = GETDRIVESQQ( )
Results
The result type is character with length 26. It is the positional character string containing the letters of the
drives available in the system.
The returned string contains letters for drives that are available, and blanks for drives that are not available.
For example, on a system with A, C, and D drives, the string 'A CD' is returned.
On Linux* and macOS systems, the function returns a string filled with spaces.
Example
See the example for GETDRIVESIZEQQ.
See Also
GETDRIVEDIRQQ
GETDRIVESIZEQQ
CHANGEDRIVEQQ
GETENV
Portability Subroutine: Returns the value of an
environment variable.
Module
USE IFPORT
Syntax
CALL GETENV (ename,evalue)
1515
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
evalue (Output) Character*(*). Value found for ename. Blank if ename is not
found.
Example
use IFPORT
character*40 libname
CALL GETENV ("LIB",libname)
TYPE *, "The LIB variable points to ",libname
See Also
GETENVQQ
GET_ENVIRONMENT_VARIABLE
Intrinsic Subroutine: Gets the value of an
environment variable.
Syntax
CALL GET_ENVIRONMENT_VARIABLE (name [, value, length, status, trim_name, errmsg])
Example
The following program asks for the name of an environment variable. If the environment variable exists in
the program's environment, it prints out its value:
program print_env_var
character name*20, val*40
1516
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETENVQQ
Portability Function: Returns the value of an
environment variable.
Module
USE IFPORT
Syntax
result = GETENVQQ (varname,value)
1517
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is the length of the string returned in value. Zero is returned if the
given variable is not defined.
GETENVQQ searches the list of environment variables for an entry corresponding to varname. Environment
variables define the environment in which a process executes. For example, the LIB environment variable
defines the default search path for libraries to be linked with a program.
Note that some environment variables may exist only on a per-process basis and may not be present at the
command-line level.
GETENVQQ uses the C runtime routine getenv and SETENVQQ uses the C runtime routine _putenv. From the
C documentation:
getenv and _putenv use the copy of the environment pointed to by the global variable _environ to access the
environment. getenv operates only on the data structures accessible to the run-time library and not on the
environment segment created for the process by the operating system.
In a program that uses the main function, _environ is initialized at program startup to settings taken from
the operating system's environment.
Changes made outside the program by the console SET command, for example, SET MY_VAR=ABCDE, will be
reflected by GETENVQQ.
GETENVQQ and SETENVQQ will not work properly with the Windows* APIs GetEnvironmentVariable and
SetEnvironmentVariable.
Example
1518
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END IF
900 FORMAT (A, \)
END
See Also
SETENVQQ
GETLASTERRORQQ
GETEXCEPTIONPTRSQQ
Run-Time Function: Returns a pointer to C run-time
exception information pointers appropriate for use in
signal handlers established with SIGNALQQ or direct
calls to the C rtl signal( ) routine. This routine is only
available for Windows.
Module
USE IFCORE
Syntax
result = GETEXCEPTIONPTRSQQ( )
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The return value
is the address of a data structure whose members are pointers to exception information captured by the C
runtime at the time of an exception. This result value can then be used as the eptr argument to routine
TRACEBACKQQ to generate a stack trace from a user-defined handler or to inspect the exception context
record directly.
Calling GETEXCEPTIONPTRSQQ is only valid within a user-defined handler that was established with
SIGNALQQ or a direct call to the C rtl signal( ) function.
For a full description of exceptions and error handling, see Compiler Reference: Error Handling.
Example
PROGRAM SIGTEST
USE IFCORE
...
R3 = 0.0E0
STS = SIGNALQQ(MY_HANDLER)
! Cause a divide by zero exception
R1 = 3.0E0/R3
...
END
INTEGER(4) FUNCTION MY_HANDLER(SIGNUM,EXCNUM)
USE IFCORE
...
EPTRS = GETEXCEPTIONPTRSQQ()
...
CALL TRACEBACKQQ("Application SIGFPE error!",USER_EXIT_CODE=-1,EPTR=EPTRS)
...
MY_HANDLER = 1
END
See Also
TRACEBACKQQ
GETSTATUSFPQQ
1519
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CLEARSTATUSFPQQ
SETCONTROLFPQQ
GETCONTROLFPQQ
SIGNALQQ
GETFILEINFOQQ
Portability Function: Returns information about the
specified file. File names can contain wildcards (*
and ?).
Module
USE IFPORT
Syntax
result = GETFILEINFOQQ (files,buffer,handle)
files (Input) Character*(*). Name or pattern of files you are searching for.
Can include a full path and wildcards (* and ?).
TYPE FILE$INFO
INTEGER(4) CREATION ! CREATION TIME (-1 on FAT)
INTEGER(4) LASTWRITE ! LAST WRITE TO FILE
INTEGER(4) LASTACCESS ! LAST ACCESS (-1 on FAT)
INTEGER(4) LENGTH ! LENGTH OF FILE
INTEGER(4) PERMIT ! FILE ACCESS MODE
CHARACTER(255) NAME ! FILE NAME
END TYPE FILE$INFO
The derived type FILE$INFOI8 is defined in IFPORT.F90 as follows:
TYPE FILE$INFOI8
INTEGER(4) CREATION ! CREATION TIME (-1 on FAT)
INTEGER(4) LASTWRITE ! LAST WRITE TO FILE
INTEGER(4) LASTACCESS ! LAST ACCESS (-1 on FAT)
INTEGER(8) LENGTH ! LENGTH OF FILE
INTEGER(4) PERMIT ! FILE ACCESS MODE
CHARACTER(255) NAME ! FILE NAME
END TYPE FILE$INFOI8
Results
The result type is INTEGER(4). The result is the nonblank length of the file name if a match was found, or 0 if
no matching files were found.
1520
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To get information about one or more files, set the handle to FILE$FIRST and call GETFILEINFOQQ. This will
return information about the first file which matches the name and return a handle. If the program wants
more files, it should call GETFILEINFOQQ with the handle. GETFILEINFOQQ must be called with the handle
until GETFILEINFOQQ sets handle to FILE$LAST, or system resources may be lost.
The derived-type element variables FILE$INFO%CREATION, FILE$INFO%LASTWRITE, and FILE$INFO
%LASTACCESS contain packed date and time information that indicates when the file was created, last
written to, and last accessed, respectively.
To break the time and date into component parts, call UNPACKTIMEQQ. FILE$INFO%LENGTH contains the
length of the file in bytes. FILE$INFO%PERMIT contains a set of bit flags describing access information about
the file as follows:
You can use the constant FILE$NORMAL to check that all bit flags are set to 0. If the derived-type element
variable FILE$INFO%PERMIT is equal to FILE$NORMAL, the file has no special attributes. The variable FILE
$INFO%NAME contains the short name of the file, not the full path of the file.
If an error occurs, call GETLASTERRORQQ to retrieve the error message, such as:
• ERR$NOENT: The file or path specified was not found.
• ERR$NOMEM: Not enough memory is available to execute the command, the available memory has been
corrupted, or an invalid block exists, indicating that the process making the call was not allocated
properly.
Example
USE IFPORT
USE IFCORE
CALL SHOWPERMISSION( )
END
1521
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(KIND=INT_PTR_KIND( )) handle
INTEGER(4) length
CHARACTER(5) permit
TYPE (FILE$INFO) info
WRITE (*, 900) ' Enter wildcard of files to view: '
900 FORMAT (A, \)
length = GETSTRQQ(files)
handle = FILE$FIRST
DO WHILE (.TRUE.)
length = GETFILEINFOQQ(files, info, handle)
IF ((handle .EQ. FILE$LAST) .OR. &
(handle .EQ. FILE$ERROR)) THEN
SELECT CASE (GETLASTERRORQQ( ))
CASE (ERR$NOMEM)
WRITE (*,*) 'Out of memory'
CASE (ERR$NOENT)
EXIT
CASE DEFAULT
WRITE (*,*) 'Invalid file or path name'
END SELECT
END IF
See Also
SETFILEACCESSQQ
SETFILETIMEQQ
UNPACKTIMEQQ
GETGID
Portability Function: Returns the group ID of the
user of a process.
Module
USE IFPORT
Syntax
result = GETGID( )
1522
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result corresponds to the primary group of the user under whose identity
the program is running. The result is returned as follows:
• Linux and macOS
This function returns the group identity for the current process.
• Windows
This function returns the last subauthority of the security identifier for the process. This is unique on a
local machine and unique within a domain for domain accounts.
Note that on Windows systems, domain accounts and local accounts can overlap.
Example
USE IFPORT
ISTAT = GETGID( )
GETLASTERROR
Portability Function: Returns the last error set.
Module
USE IFPORT
Syntax
result = GETLASTERROR( )
Results
The result type is INTEGER(4). The result is the integer corresponding to the last run-time error value that
was set.
For example, if you use an ERR= specifier in an I/O statement, your program will not abort if an error occurs.
GETLASTERROR provides a way to determine what the error condition was, with a better degree of certainty
than just examining errno. Your application can then take appropriate action based upon the error number.
GETLASTERRORQQ
Portability Function: Returns the last error set by a
run-time procedure.
Module
USE IFPORT
Syntax
result = GETLASTERRORQQ( )
Results
The result type is INTEGER(4). The result is the most recent error code generated by a run-time procedure.
Library functions that return a logical or integer value sometimes also provide an error code that identifies
the cause of errors. GETLASTERRORQQ retrieves the most recent error message. The error constants are
defined in IFPORT.F90. The following table shows some library routines and the errors each routine
produces:
1523
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
BEEPQQ no error
BSEARCHQQ ERR$INVAL
COMMITQQ ERR$BADF
GETCHARQQ no error
GETDRIVESQQ no error
GETLASTERRORQQ no error
GETSTRQQ no error
PACKTIMEQQ no error
PEEKCHARQQ no error
SETERRORMODEQQ no error
SLEEPQQ no error
SORTQQ ERR$INVAL
1524
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
UNPACKTIMEQQ no error
GETLOG
Portability Subroutine: Returns the user's login
name.
Module
USE IFPORT
Syntax
CALL GETLOG (name)
The login name must be less than or equal to 64 characters. If the login name is longer than 64 characters, it
is truncated. The actual parameter corresponding to name should be long enough to hold the login name. If
the supplied actual parameter is too short to hold the login name, the login name is truncated.
If the login name is shorter than the actual parameter corresponding to name, the login name is padded with
blanks at the end, until it reaches the length of the actual parameter.
If the login name cannot be determined, all blanks are returned.
Example
use IFPORT
character*20 username
CALL GETLOG (username)
print *, "You logged in as ",username
GETPID
Portability Function: Returns the process ID of the
current process.
Module
USE IFPORT
Syntax
result = GETPID( )
Results
The result type is INTEGER(4). The result is the process ID number of the current process.
Example
USE IFPORT
INTEGER(4) istat
istat = GETPID()
1525
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETPOS, GETPOSI8
Portability Functions: Return the current position of
a file.
Module
USE IFPORT
Syntax
result = GETPOS (lunit)
result = GETPOSI8 (lunit)
lunit (Input) INTEGER(4). External unit number of a file. The value must be
in the range 0 to 100 and the file must be connected.
Results
The result type is INTEGER(4) for GETPOS; INTEGER(8) for GETPOSI8. The result is the offset, in bytes, from
the beginning of the file. If an error occurs, the result value is -1 and the following error code is returned in
errno:
EINVAL: lunit is not a valid unit number, or is not open.
These functions are equivalent to FTELL, FTELLI8.
GETSTATUSFPQQ
Portability Subroutine: Returns the floating-point
processor status word. This routine is only available
for Windows.
Module
USE IFPORT
Syntax
CALL GETSTATUSFPQQ (status)
The floating-point status word shows whether various floating-point exception conditions have occurred. The
compiler initially clears (sets to 0) all status flags, but after an exception occurs it does not reset the flags
before performing additional floating-point operations. A status flag with a value of one thus shows there has
been at least one occurrence of the corresponding exception. The following table lists the status flags and
their values:
1526
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can use a logical comparison on the status word returned by GETSTATUSFPQQ to determine which of the
six floating-point exceptions listed in the table has occurred.
An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0.
By default, all exception traps are disabled. Exceptions can be enabled and disabled by clearing and setting
the flags with SETCONTROLFPQQ. You can use GETCONTROLFPQQ to determine which exceptions are
currently enabled and disabled.
If an exception is disabled, it does not cause an interrupt when it occurs. Instead, floating-point processes
generate an appropriate special value (NaN or signed infinity), but the program continues. You can find out
which exceptions (if any) occurred by calling GETSTATUSFPQQ.
If errors on floating-point exceptions are enabled (by clearing the flags to 0 with SETCONTROLFPQQ), the
operating system generates an interrupt when the exception occurs. By default, these interrupts cause run-
time errors, but you can capture the interrupts with SIGNALQQ and branch to your own error-handling
routines.
Example
! Program to demonstrate GETSTATUSFPQQ
USE IFPORT
INTEGER(2) status
CALL GETSTATUSFPQQ(status)
! check for divide by zero
IF (IAND(status, FPSW$ZERODIVIDE) .NE. 0) THEN
WRITE (*,*) 'Divide by zero occurred. Look &
for NaN or signed infinity in resultant data.'
END IF
END
See Also
SETCONTROLFPQQ
GETCONTROLFPQQ
SIGNALQQ
CLEARSTATUSFPQQ
GETSTRQQ
Run-Time Function: Reads a character string from
the keyboard using buffered input.
Module
USE IFCORE
Syntax
result = GETSTRQQ (buffer)
1527
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4). The result is the number of characters placed in buffer.
The function does not complete until you press Return or Enter.
Example
! Program to demonstrate GETSTRQQ
USE IFCORE
USE IFPORT
INTEGER(4) length, result
CHARACTER(80) prog, args
WRITE (*, '(A, \)') ' Enter program to run: '
length = GETSTRQQ (prog)
WRITE (*, '(A, \)') ' Enter arguments: '
length = GETSTRQQ (args)
result = RUNQQ (prog, args)
IF (result .EQ. -1) THEN
WRITE (*,*) 'Couldn''t run program'
ELSE
WRITE (*, '(A, Z4, A)') 'Return code : ', result, 'h'
END IF
END
See Also
READ
GETCHARQQ
PEEKCHARQQ
GET_TEAM
Transformational Intrinsic Function (Generic):
Returns a copy of a team variable.
Syntax
result = GET_TEAM ([ level ])
level (Optional, Input) Must be a scalar integer whose value is equal to one
of the named constants INITIAL_TEAM, CURRENT_TEAM, or
PARENT_TEAM defined in the ISO_FORTRAN_ENV intrinsic module.
Results
The result is type TEAM_TYPE from the ISO_FORTRAN_ENV intrinsic module. If level is not present, or if
CURRENT_TEAM is specified, the result is a team variable describing the current team. If level has the value
PARENT_TEAM, the result is a team variable describing the parent team of the current team. If level has the
value INITIAL_TEAM, the result is a team variable describing the initial team.
Example
Consider the following program fragment:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: original
original = GET_TEAM (INITIAL_TEAM)
After execution of the GET_TEAM function, original is defined with a team value describing the initial team.
1528
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETTIM
Portability Subroutine: Returns the time.
Module
USE IFPORT
Syntax
CALL GETTIM (ihr, imin, isec, i100th)
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
Example
See the example in GETDAT.
See Also
GETDAT
SETDAT
SETTIM
CLOCK
CTIME
DTIME
ETIME
GMTIME
ITIME
LTIME
RTC
TIMEF
1529
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETTIMEOFDAY
Portability Subroutine: Returns seconds and
microseconds since 00:00 Jan 1, 1970.
Module
USE IFPORT
Syntax
CALL GETTIMEOFDAY (ret, err)
Element Value
ret(1) Seconds
ret(2) Microseconds
If an error occurs, err contains a value equal to -1 and array ret contains zeros.
On Windows* systems, this subroutine has millisecond precision, and the last three digits of the returned
value are not significant.
GETUID
Portability Function: Returns the user ID of the
calling process.
Module
USE IFPORT
Syntax
result = GETUID( )
Results
The result type is INTEGER(4). The result corresponds to the user identity under which the program is
running. The result is returned as follows:
• Linux and macOS
This function returns the user identity for the current process.
• Windows
This function returns the last subauthority of the security identifier for the process. This is unique on a
local machine and unique within a domain for domain accounts.
Note that on Windows systems, domain accounts and local accounts can overlap.
Example
USE IFPORT
integer(4) istat
istat = GETUID( )
1530
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GMTIME
Portability Subroutine: Returns the Greenwich
mean time in an array of time elements.
Module
USE IFPORT
Syntax
CALL GMTIME (stime,tarray)
Element Value
Caution
This subroutine may cause problems with the year 2000. Use DATE_AND_TIME instead.
Example
use IFPORT
integer(4) stime, timearray(9)
! initialize stime to number of seconds since
! 00:00:00 GMT January 1, 1970
stime = time()
CALL GMTIME (stime, timearray)
print *, timearray
end
See Also
DATE_AND_TIME
1531
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GOTO - Assigned
Statement: Transfers control to the statement whose
label was most recently assigned to a variable. This
feature has been deleted in the Fortran Standard.
Intel® Fortran fully supports features deleted in the
Fortran Standard.
Syntax
GOTO var[[ ,] ( label-list)]
The variable must have a statement label value assigned to it by an ASSIGN statement (not an arithmetic
assignment statement) before the GO TO statement is executed.
If a list of labels appears, the statement label assigned to the variable is not checked against the labels in the
list.
Both the assigned GO TO statement and its associated ASSIGN statement must be in the same scoping unit.
Example
The following example is equivalent to GO TO 200:
ASSIGN 10 TO I
J = I
GO TO J
In this case, variable J is not the variable assigned to, so it cannot be used in the assigned GO TO statement.
The following shows another example:
ASSIGN 10 TO N
GOTO N
10 CONTINUE
The following example uses an assigned GOTO statement with a label-list but it is not checked against the
value of VIEW:
See Also
Obsolescent Language Features in the Fortran Standard
GOTO - Computed GOTO
GOTO - Unconditional GOTO
Execution Control
1532
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GOTO - Computed
Statement: Transfers control to one of a set of
labeled branch target statements based on the value
of an expression. It is an obsolescent feature in
Fortran 95.
Syntax
GOTO (label-list) [ ,] expr
When the computed GO TO statement is executed, the expression is evaluated first. The value of the
expression represents the ordinal position of a label in the associated list of labels. Control is transferred to
the statement identified by the label. For example, if the list contains (30,20,30,40) and the value of the
expression is 2, control is transferred to the statement identified with label 20.
If the value of the expression is less than 1 or greater than the number of labels in the list, control is
transferred to the next executable statement or construct following the computed GO TO statement.
Example
The following example shows valid computed GO TO statements:
GO TO (12,24,36), INDEX
GO TO (320,330,340,350,360), SITU(J,K) + 1
The following shows another example:
next = 1
C
C The following statement transfers control to statement 10:
C
GOTO (10, 20) next
...
10 CONTINUE
...
20 CONTINUE
See Also
Obsolescent Language Features in the Fortran Standard
GOTO - Unconditional GOTO
Execution Control
GOTO - Unconditional
Statement: Transfers control to the same branch
target statement every time it executes.
Syntax
GO TO label
1533
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
label Is the label of a valid branch target statement in the same scoping
unit as the GO TO statement.
The unconditional GO TO statement transfers control to the branch target statement identified by the
specified label.
Example
The following are examples of GO TO statements:
GO TO 7734
GO TO 99999
The following shows another example:
integer(2) in
10 print *, 'enter a number from one to ten: '
read *, in
select case (in)
case (1:10)
exit
case default
print *, 'wrong entry, try again'
goto 10
end select
See Also
GOTO - Computed GOTO
Execution Control
H to I
This section describes language features that start with H or I.
H to I
HOSTNAM
Portability Function: Returns the current host
computer name. This function can also be specified as
HOSTNM.
Module
USE IFPORT
Syntax
result = HOSTNAM (name)
Results
The result type is INTEGER(4). The result is zero if successful. If name is not long enough to contain all of
the host name, the function truncates the host name and returns -1.
1534
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
use IFPORT
character(MAX_HOSTNAM_LENGTH + 1) hostname
integer(4) istat
ISTAT = HOSTNAM (hostname)
HUGE
Inquiry Intrinsic Function (Generic): Returns the
largest number in the model representing the same
type and kind parameters as the argument.
Syntax
result = HUGE (x)
Results
The result is a scalar of the same type and kind parameters as x. If x is of type integer, the result has the
value r q - 1. If x is of type real, the result has the value (1 - b -p)b emax.
Integer parameters r and q are defined in Model for Integer Data; real parameters b, p, and e maxare defined
in Model for Real Data.
Example
If X is of type REAL(4), HUGE (X) has the value (1 - 2 -24) x2 128.
See Also
TINY
Data Representation Models
HYPOT
Elemental Intrinsic Function (Generic): Returns
the value of the Euclidean distance of the arguments.
Syntax
result = HYPOT (x,y)
y (Input) Must be of type real. It must be the same type and kind as x.
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the Euclidean distance, ,
without undue overflow or underflow.
Example
HYPOT (3.0, 4.0) has the approximate value 5.0.
1535
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IACHAR
Elemental Intrinsic Function (Generic): Returns
the position of a character in the ASCII character set,
even if the processor's default character set is
different. In Intel® Fortran, IACHAR is equivalent to
the ICHAR function.
Syntax
result = IACHAR (c [, kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If c is in the ASCII collating sequence,
the result is the position of c in that sequence and satisfies the inequality (0 .le. IACHAR(c) .le. 127).
The results must be consistent with the LGE, LGT, LLE, and LLT lexical comparison functions. For example, if
LLE(C, D) is true, IACHAR(C) .LE. IACHAR(D) is also true.
Example
IACHAR ( 'Y' ) has the value 89.
IACHAR ( '%' ) has the value 37.
See Also
ASCII and Key Code Charts
ACHAR
CHAR
ICHAR
LGE
LGT
LLE
LLT
IALL
Transformational Intrinsic Function (Generic):
Reduces an array with a bitwise AND operation.
Syntax
result = IALL (array, dim [, mask])
result = IALL (array [, mask])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
1536
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result has the same type and kind parameters as array. It is scalar if dim does not appear or if array has
rank one; otherwise, the result is an array of rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where
[d1, d2,..., dn] is the shape of array.
If array has size zero the result value is equal to NOT (INT (0, KIND (array))). Otherwise, the result of IALL
(array) has a value equal to the bitwise AND of all the elements of array.
The result of IALL (array, MASK=mask) has a value equal to IALL (PACK (array, mask)).
The result of IALL (array, DIM=dim [ , MASK=mask]) has a value equal to that of IALL (array [ ,
MASK=mask]) if array has rank one. Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of the
result is equal to IALL (array (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn) [, MASK = mask (s1, s2, ..., sdim-1 , :, sdim
+1 , ..., sn)]).
Example
IALL ([14, 13, 11]) has the value 8. IALL ([14, 13, 11], MASK=[.true., .false., .true]) has the value 10.
See Also
IANY
IPARITY
IAND
Elemental Intrinsic Function (Generic): Performs
a logical AND on corresponding bits. This function can
also be specified as AND.
Syntax
result = IAND (i,j)
Results
If both i and j are of type integer or logical, the result type and kind are the same as i. If either i or j is a
binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to type
integer with the kind type parameter of the other.
The result value is derived by combining i and j bit-by-bit according to the following truth table:
i j IAND (i, j)
1 1 1
1 0 0
0 1 0
0 0 0
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1537
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IAND (2, 3) has the value 2.
IAND (4, 6) has the value 4.
The following shows another example:
INTEGER(1) i, m
INTEGER result
INTEGER(2) result2
i = 1
m = 3
result = IAND(i,m) ! returns an integer of default type
! (INTEGER(4) unless reset by user) whose
! value = 1
result2 = IAND(i,m) ! returns an INTEGER(2) with value = 1
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
IEOR
IOR
NOT
IALL
IANY
IPARITY
IANY
Transformational Intrinsic Function (Generic):
Reduces an array with a bitwise OR operation.
Syntax
result = IANY (array, dim [, mask])
result = IANY (array [, mask])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
1538
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result has the same type and kind parameters as array. It is scalar if dim does not appear; otherwise,
the result is an array of rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the
shape of array.
The result of IANY (array) is the bitwise OR of all the elements of array. If array has size zero, the result
value is equal to zero.
The result of IANY (array, MASK=mask) has a value equal to IANY (PACK (array, mask)).
The result of IANY (array, DIM=dim [ , MASK=mask]) has a value equal to that of IANY (array [ ,
MASK=mask]) if array has rank one. Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of the
result is equal to IANY (array (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn) [, MASK = mask (s1, s2, ..., sdim-1 , :, sdim
+1 , ..., sn)]).
Example
IANY ([14, 13, 8]) has the value 15. IANY ([14, 13, 8], MASK=[.true., .false., .true]) has the value 14.
See Also
IALL
IPARITY
IARGC
Inquiry Intrinsic Function (Specific): Returns the
index of the last command-line argument. It cannot
be passed as an actual argument. This function can
also be specified as IARG or NUMARG.
Syntax
result = IARGC( )
Results
The result type is INTEGER(4). The result is the index of the last command-line argument, which is also the
number of arguments on the command line. The command is not included in the count. For example, IARGC
returns 3 for the command-line invocation of PROG1 -g -c -a.
Example
integer(4) no_of_arguments
no_of_arguments = IARGC ()
print *, 'total command line arguments are ', no_of_arguments
For a command-line invocation of PROG1 -g -c -a, the program above prints:
See Also
GETARG
NARGS
COMMAND_ARGUMENT_COUNT
GET_COMMAND
GET_COMMAND_ARGUMENT
1539
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IBCHNG
Elemental Intrinsic Function (Generic): Reverses
the value of a specified bit in an integer.
Syntax
result = IBCHNG (i,pos)
pos (Input) Must be of type integer. This argument is the position of the
bit to be changed.
The rightmost (least significant) bit of i is in position 0.
Results
The result type and kind are the same as i. The result is equal to i with the bit in position pos reversed.
For more information, see Bit Functions.
Example
INTEGER J, K
J = IBCHNG(10, 2) ! returns 14 = 1110
K = IBCHNG(10, 1) ! returns 8 = 1000
See Also
BTEST
IAND
IBCLR
IBSET
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
NOT
IBCLR
Elemental Intrinsic Function (Generic): Clears one
bit to zero.
Syntax
result = IBCLR (i,pos)
pos (Input) Must be of type integer. It must not be negative and it must
be less than BIT_SIZE(i).
1540
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as i. The result has the value of the sequence of bits of i, except that
bit pos of i is set to zero.
For more information, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
IBCLR (18, 1) has the value 16.
If V has the value (1, 2, 3, 4), the value of IBCLR (POS = V, I = 15) is (13, 11, 7, 15).
The following shows another example:
INTEGER J, K
J = IBCLR(7, 1) ! returns 5 = 0101
K = IBCLR(5, 1) ! returns 5 = 0101
See Also
BTEST
IAND
IBCHNG
IBSET
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
NOT
IBITS
Elemental Intrinsic Function (Generic): Extracts a
sequence of bits (a bit field).
Syntax
result = IBITS (i,pos,len)
pos (Input) Must be of type integer. It must not be negative and pos+ len
must be less than or equal to BIT_SIZE(i).
1541
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as i. The result has the value of the sequence of len bits in i,
beginning at pos, right-adjusted and with all other bits zero.
For more information, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
IBITS (12, 1, 4) has the value 6.
IBITS (10, 1, 7) has the value 5.
See Also
BTEST
BIT_SIZE
IBCLR
IBSET
ISHFT
ISHFTC
MVBITS
IBSET
Elemental Intrinsic Function (Generic): Sets one
bit to 1.
Syntax
result = IBSET (i,pos)
pos (Input) Must be of type integer. It must not be negative and it must
be less than BIT_SIZE( i).
Results
The result type and kind are the same as i. The result has the value of the sequence of bits of i, except that
bit pos of i is set to 1.
For more information, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1542
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IBSET (8, 1) has the value 10.
If V has the value (1, 2, 3, 4), the value of IBSET (POS = V, I = 2) is (2, 6, 10, 18).
The following shows another example:
INTEGER I
I = IBSET(8, 2) ! returns 12 = 1100
See Also
BTEST
IAND
IBCHNG
IBCLR
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
NOT
ICHAR
Elemental Intrinsic Function (Generic): Returns
the position of a character in the processor's character
set.
Syntax
result = ICHAR (c [, kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer.
The result value is the position of c in the processor's character set. c is in the range zero to n - 1, where n is
the number of characters in the character set.
For any characters C and D (capable of representation in the processor), C .LE. D is true only if
ICHAR(C) .LE. ICHAR(D) is true, and C .EQ. D is true only if ICHAR(C) .EQ. ICHAR(D) is true.
1543
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CHARACTER INTEGER(2)
CHARACTER INTEGER(8)
1This specific function cannot be passed as an actual argument.
Example
ICHAR ( 'W' ) has the value 87.
ICHAR ( '#' ) has the value 35.
See Also
IACHAR
CHAR
ASCII and Key Code Charts
Syntax
CALL IDATE (i, j, k)
j (Output) Must be of type integer with the same kind type parameter
as i. It is the current day.
k (Output) Must be of type integer with the same kind type parameter
as i. It is the current year.
The current month is returned in i; the current day in j. The last two digits of the current year are returned
in k.
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
If the current date is September 16, 1999, the values of the integer variables upon return are: I = 9, J = 16,
and K = 99.
See Also
DATE intrinsic procedure
DATE_AND_TIME
1544
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
GETDAT
Module
USE IFPORT
Syntax
CALL IDATE (i, j, k)
-or-
CALL IDATE (iarray)
Caution
The two-digit year return value may cause problems with the year 2000. Use DATE_AND_TIME
instead.
Example
Consider the following:
use IFPORT
integer(4) imonth, iday, iyear, datarray(3)
! If the date is July 11, 1999:
CALL IDATE(IMONTH, IDAY, IYEAR)
! sets IMONTH to 7, IDAY to 11 and IYEAR to 99.
CALL IDATE (DATARRAY)
! datarray is (/11,7,99/)
See Also
DATE portability routine
DATE_AND_TIME
GETDAT
1545
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IDATE4
Portability Subroutine: Returns the month, day,
and year of the current system.
Module
USE IFPORT
Syntax
CALL IDATE4 (i,j,k)
-or-
CALL IDATE4 (iarray)
IDENT
General Compiler Directive: Specifies a string that
identifies an object module. The compiler places the
string in the identification field of an object module
when it generates the module for each source
program unit.
Syntax
!DIR$ IDENT string
Only the first IDENT directive is effective; the compiler ignores any additional IDENT directives in a program
unit or module.
See Also
General Compiler Directives
IDFLOAT
Portability Function: Converts an INTEGER(4)
argument to double-precision real type.
1546
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPORT
Syntax
result = IDFLOAT (i)
Results
The result type is double-precision real (REAL(8) or REAL*8).
See Also
DFLOAT
IEEE_CLASS
Elemental Module Intrinsic Function (Generic):
Returns the IEEE class.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_CLASS (x)
Results
The result is of type TYPE(IEEE_CLASS_TYPE). The result value is one of the following:
IEEE_SIGNALING_NAN IEEE_NEGATIVE_NORMAL
IEEE_QUIET_NAN IEEE_POSITIVE_DENORMAL
IEEE_POSITIVE_INF IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_INF IEEE_POSITIVE_ZERO
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_ZERO
Example
IEEE_CLASS(1.0) has the value IEEE_POSITIVE_NORMAL.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_COPY_SIGN
Elemental Module Intrinsic Function (Generic):
Returns an argument with a copied sign. This is
equivalent to the IEEE copysign function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
1547
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = IEEE_COPY_SIGN (x,y)
Results
The result type and kind are the same as x. The result has the value x with the sign of y. This is true even for
IEEE special values, such as NaN or infinity.
The flags information is returned as a set of 1-bit flags.
Example
The value of IEEE_COPY_SIGN (X,3.0) is ABS (X), even when X is NaN.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_FLAGS
Portability Function: Gets, sets or clears IEEE flags
for rounding direction and precision as well as queries
or controls exception status. This function provides
easy access to the modes and status required to use
the features of ISO/IEC/IEEE 60559:2011 arithmetic
in a Fortran program.
Module
USE IFPORT
Syntax
result = IEEE_FLAGS (action,mode,in,out)
action (Input) Character*(*). One of the following literal values: 'GET', 'SET',
'CLEAR', or 'CLEARALL'.
Value Description
1548
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Value Description
'negative'
'positive'
The values for in and out depend on the action and mode they are
used with. The interaction of the parameters can be summarized as
follows:
1549
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CLEAR 'direction' Null (' ') Null (' ') Clears the
mode. Sets
rounding to
'nearest'.
Returns 0 if
successful.
1550
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CLEARALL Null (' ') Null (' ') Null (' ') Clears all
flags. Sets
rounding to
'nearest',
sets
precision to
'double'
(W*S) or
'extended'
(L*X,
M*X), and
sets all
exception
flags to 0.
Returns 0 if
successful.
Results
IEEE_FLAGS is an elemental, integer-valued function that sets IEEE flags for GET, SET, CLEAR, or CLEARALL
procedures. It lets you control rounding direction and rounding precision, query exception status, and control
exception enabling or disabling by using the SET or CLEAR procedures, respectively.
The flags information is returned as a set of 1-bit flags.
Example
The following example gets the highest priority exception that has a flag raised. It passes the input argument
in as a null string:
USE IFPORT
INTEGER*4 iflag
CHARACTER*9 out
iflag = ieee_flags('get', 'exception', '', out)
PRINT *, out, ' flag raised'
1551
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example sets the rounding direction to round toward zero, unless the hardware does not
support directed rounding modes:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 mode, out, in
iflag = ieee_flags('set', 'direction', 'tozero', out)
The following example sets the rounding direction to the default ('nearest'):
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 out, in
iflag = ieee_flags('clear','direction', '', '' )
The following example clears all exceptions:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 out
iflag = ieee_flags('clear','exception', 'all', '' )
The following example restores default direction and precision settings, and sets all exception flags to 0:
USE IFPORT
INTEGER*4 iflag
CHARACTER*10 mode, out, in
iflag = ieee_flags('clearall', '', '', '')
The following example detects an underflow exception:
USE IFPORT
CHARACTER*20 out, in
excep_detect = ieee_flags('get', 'exception', 'underflow', out)
if (out .eq.'underflow') stop 'underflow'
IEEE_FMA
Elemental Module Intrinsic Function (Generic):
Returns the result of a fused multiply-add operation.
This is equivalent to the IEEE fusedMultiplyAdd
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_FMA (a,b,c)
b (Input) Must be of type REAL with the same kind type parameter as a.
c (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is REAL with the same kind type parameter as a. When the result is in range, the value of the
result is the mathematical value of (a * b) + c rounded according to the rounding mode of the representation
method of a. Only the final step in the calculation may cause IEEE_INEXACT, IEEE_OVERFLOW, or
IEEE_UNDERFLOW to signal; intermediate calculations do not.
This is the fusedMultiplyAdd operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
1552
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The result value of IEEE_FMA (TINY(0.0), TINY(0.0) 1.0) is equal to 1.0 when the rounding mode is set to
NEAREST. The exception IEEE_INEXACT is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_FLAG
Elemental Module Intrinsic Subroutine
(Generic): Returns whether an exception flag is
signaling.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_FLAG (flag, flag_value)
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_HALTING_MODE
Elemental Module Intrinsic Subroutine
(Generic): Stores the halting mode for an exception.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_HALTING_MODE (flag, halting)
1553
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_MODES
Intrinsic Module Subroutine (Generic): Stores the
current IEEE floating-point modes. This is an impure
subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_MODES (modes)
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_ROUNDING_MODE
Intrinsic Module Subroutine (Generic): Stores the
current IEEE rounding mode. This is an impure
subroutine.
1554
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_GET_ROUNDING_MODE (round_value [, radix])
radix (Input; optional) Must be an integer scalar with a value of two or ten.
The rounding mode queried is the binary rounding mode, unless radix
is present with the value ten, in which case it is the decimal rounding
mode queried.
Example
Consider the following:
IEEE_GET_STATUS
Intrinsic Module Subroutine (Generic): Stores the
current state of the floating-point environment. This is
an impure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_GET_STATUS (status_value)
Example
Consider the following:
1555
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_GET_UNDERFLOW_MODE
Intrinsic Module Subroutine (Generic): Stores the
current underflow mode. This is an impure subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_GET_UNDERFLOW_MODE (gradual)
Example
Consider the following:
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_HANDLER
Portability Function: Establishes a handler for IEEE
exceptions.
Module
USE IFPORT
Syntax
result = IEEE_HANDLER (action, exception, handler)
action (Input) Character*(*). One of the following literal IEEE actions: 'GET',
'SET', or 'CLEAR'. For more details on these actions, see IEEE_FLAGS.
1556
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is 0 if
successful; otherwise, 1.
IEEE_HANDLER calls a signal-handling routine to establish a handler for IEEE exceptions. It also enables an
FPU trap corresponding to the required exception.
The state of the FPU is not defined in the handler routine. When the FPU trap occurs, the program invokes
the handler routine. After the handler routine is executed, the program terminates.
The handler routine gets the exception code in the SIGINFO argument. SIGNO is the number of the system
signal. The meaning of the SIGINFO constants appear in the following table (defined in the IFPORT module):
FPE$ZERODIVIDE Divide-by-zero
'GET' actions return the location of the current handler routine for exception cast to an INTEGER.
Example
The following example creates a handler routine and sets it to trap divide-by-zero:
PROGRAM TEST_IEEE
REAL :: X, Y, Z
CALL FPE_SETUP
X = 0.
Y = 1.
Z = Y / X
END PROGRAM
SUBROUTINE FPE_SETUP
USE IFPORT
IMPLICIT NONE
INTERFACE
SUBROUTINE FPE_HANDLER(SIGNO, SIGINFO)
INTEGER(4), INTENT(IN) :: SIGNO, SIGINFO
END SUBROUTINE
END INTERFACE
INTEGER IR
IR = IEEE_HANDLER('set','division',FPE_HANDLER)
END SUBROUTINE FPE_SETUP
SUBROUTINE FPE_HANDLER(SIG, CODE)
USE IFPORT
IMPLICIT NONE
INTEGER SIG, CODE
1557
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
IEEE_FLAGS
IEEE_INT
Elemental Module Intrinsic Function (Generic):
Enables conversion to INTEGER type.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_INT (a, round [, kind])
Results
The result type is INTEGER. If kind is present, the kind type parameter is that specified by kind; otherwise,
the kind type parameter is default integer.
The result is the value of a converted to integer according to the rounding mode specified by round if the
values can be represented in the representation method of the result type kind; otherwise, the result is
processor dependent and IEEE_INVALID is signaled.
The result must be consistent with the ISO/IEC/IEEE 60559:2011 operation convertToInteger{round} or
convertToIntegerExact{round}. The processor consistently chooses which operation is performed.
Example
The result value of IEEE_INT (63.5, IEEE_DOWN) is 63. If converToIntegerExact{round} is used,
IEEE_INEXACT will signal.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_IS_FINITE
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is finite.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_FINITE (x)
1558
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default logical. The result has the value true if the value of x is finite; otherwise, false.
An IEEE value is finite if IEEE_CLASS(x) has one of the following values:
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_NORMAL IEEE_POSITIVE_ZERO
IEEE_POSITIVE_DENORMAL IEEE_NEGATIVE_ZERO
Example
IEEE_IS_FINITE (-2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_IS_NAN
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is Not-a-Number
(NaN).
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_NAN (x)
Results
The result type is default logical. The result has the value true if the value of x is NaN; otherwise, false.
Example
IEEE_IS_NAN (SQRT(-2.0)) has the value true if IEEE_SUPPORT_SQRT (2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_IS_NEGATIVE
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is negative.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_NEGATIVE (x)
1559
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default logical. The result has the value true if the value of x is negative; otherwise, false.
An IEEE value is negative if IEEE_CLASS(x) has one of the following values::
IEEE_NEGATIVE_NORMAL IEEE_NEGATIVE_ZERO
IEEE_NEGATIVE_DENORMAL IEEE_NEGATIVE_INF
Example
IEEE_IS_NEGATIVE (2.0) has the value false.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_IS_NORMAL
Elemental Module Intrinsic Function (Generic):
Returns whether an IEEE value is normal.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_IS_NORMAL (x)
Results
The result type is default logical. The result has the value true if the value of x is normal; otherwise, false.
An IEEE value is normal if IEEE_CLASS(x) has one of the following values:
IEEE_POSITIVE_NORMAL IEEE_POSITIVE_ZERO
IEEE_NEGATIVE_NORMAL IEEE_NEGATIVE_ZERO
Example
IEEE_IS_NORMAL (SQRT(-2.0)) has the value false if IEEE_SUPPORT_SQRT (-2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_LOGB
Elemental Module Intrinsic Function (Generic):
Returns a floating-point value equal to the unbiased
exponent of the argument. This is equivalent to the
IEEE logb function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
1560
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = IEEE_LOGB (x)
Results
The result type and kind are the same as x. The result has the value of the unbiased exponent of x if the
value of x is not zero, infinity, or NaN. The value of the result is equal to EXPONENT(x) - 1.
If x is equal to 0, the result is -infinity if IEEE_SUPPORT_INF(x) is true; otherwise, -HUGE(x). In either case,
the IEEE_DIVIDE_BY_ZERO exception is signaled.
Example
IEEE_LOGB (3.4) has the value 1.0; IEEE_LOGB (4.0) has the value 2.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MAX_NUM
Inquiry Module Intrinsic Function (Generic):
Returns the maximum of two values. This is
equivalent to the IEEE maxNum operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MAX_NUM (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is x if y < x. The result is y if x <
y.
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet NaN. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the maxNum operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_MAX_NUM (3.7, IEEE_VALUE (0.0, IEEE_SIGNALING_NAN)) is a NaN. The exception
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1561
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_MAX_NUM_MAG
Inquiry Module Intrinsic Function (Generic):
Returns the maximum magnitude of two values. This
is equivalent to the IEEE maxNumMag operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MAX_NUM_MAG (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is x if ABS(y) < ABS(x). The
result is the value of y if ABS(x) < ABS(y).
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet Nan. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the maxNumMag operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_MAX_NUM_MAG (3.7, -7.5) is -7.5.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MIN_NUM
Inquiry Module Intrinsic Function (Generic):
Returns the minimum of two values. This is equivalent
to the IEEE minNum operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MIN_NUM (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is x if x < y. The result is y if y <
x.
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet NaN. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
1562
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The result value of IEEE_MIN_NUM (3.7, IEEE_VALUE (0.0, IEEE_QUIET _NAN)) is 3.7. No exceptions are
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_MIN_NUM_MAG
Inquiry Module Intrinsic Function (Generic):
Returns the minimum magnitude of two values. This is
equivalent to the IEEE minNumMag operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_MIN_NUM_MAG (x,y)
y (Input) Must be of type REAL with the same kind type parameter as x.
Results
The result type is REAL with the same kind type parameter as x. The result is y if ABS(y) < ABS(x). The
result is the value of x if ABS(x) < ABS(y).
If one of the arguments is a quiet NaN, the result is the value of the argument which is not a quiet NaN. If
either or both of the arguments is a signaling NaN, the result is a NaN and IEEE_INVALID signals. Otherwise,
the result value is that of either x or y (processor dependent). No exceptions are signaled unless x or y is a
signaling NaN.
This is the minNumMag operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_MIN_NUM_MAG (3.7, -7.5) is 3.7.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_NEXT_AFTER
Elemental Module Intrinsic Function (Generic):
Returns the next representable value after X toward Y.
This is equivalent to the IEEE nextafter function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_NEXT_AFTER (x,y)
1563
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x. If x is equal to y, the result is x; no exception is signaled. If x is
not equal to y, the result has the value of the next representable neighbor of x toward y. The neighbors of
zero (of either sign) are both nonzero.
The following exceptions are signaled under certain cases:
Exception Signaled
Example
The value of IEEE_NEXT_AFTER (2.0,3.0) is 2.0 + EPSILON (X).
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_NEXT_DOWN
Elemental Module Intrinsic Function (Generic):
Returns the next lower adjacent machine number.
This is equivalent to the IEEE nextDown operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_NEXT_DOWN (x)
Results
The result type and kind are the same as x. The value of the result is the greatest value that compares less
than x - except when x has the value NaN, the result is NaN, and when x has the value - ∞ , the result is -
∞ . If x is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
This is the nextDown operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The value of IEEE_NEXT_DOWN(+0.0) is the negative subnormal number with the least magnitude if the
value if IEEE_SUPPORT_SUBNORMAL (0.0) is .TRUE..
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1564
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_NEXT_UP
Elemental Module Intrinsic Function (Generic):
Returns the next higher adjacent machine number.
This is equivalent to the IEEE nextUp operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_NEXT_UP (x)
Results
The result type and kind are the same as x. The value of the result is the least value that compares greater
than x - except when x has the value NaN, the result is NaN, and when x has the value + ∞, the result is +
∞. If x is a signaling NaN, IEEE_INVALID signals; otherwise, no exception is signaled.
This is the nextUp operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The value of IEEE_NEXT_UP (HUGE (x)) is + ∞ if the value of IEEE_SUPPORT_INF (x) is .true..
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_EQ
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for equality. This
is equivalent to the IEEE compareQuietEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_EQ (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares equal to b. If a or b is a NaN, the
result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_EQ (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
1565
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_QUIET_GE
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for greater than
or equal. This is equivalent to the IEEE
compareQuietGreaterEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_GE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than or equal to b. If a or b is
a NaN, the result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is
signaled.
This is the compareQuietGreaterEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_GE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_GT
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for greater than.
This is equivalent to the IEEE compareQuietGreater
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_GT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than b. If a or b is a NaN, the
result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietGreater operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
1566
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The result value of IEEE_QUIET_GT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_LE
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for less than or
equal. This is equivalent to the IEEE
compareQuietLessEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_LE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares less than or equal to b. If a or b is a
NaN, the result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is
signaled.
This is the compareQuietLessEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_LE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_LT
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for less than.
This is equivalent to the IEEE compareQuietLess
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_LT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
1567
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default LOGICAL. It has the value true if a compares less than b. If a or b is a NaN, the
result is false. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietLess operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_LT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_QUIET_NE
Elemental Module Intrinsic Function (Generic):
Performs a non-signaling comparison for inequality.
This is equivalent to the IEEE compareQuietNotEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_QUIET_NE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares not equal to b. If a or b is a NaN, the
result is true. IEEE_INVALID signals if either a or b is a signaling NaN, otherwise no exception is signaled.
This is the compareQuietNotEqual operation specified as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_QUIET_NE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is true and no exception is
signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_REAL
Elemental Module Intrinsic Function (Generic):
Enables conversion to REAL type.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_REAL (a [, kind])
1568
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is REAL. If kind is present, the kind type parameter is that specified by kind; otherwise, the
kind type parameter is default real.
The result has the same value as a if that value is representable in the representation method of the result
type kind; otherwise, it is rounded according to the current rounding mode.
The result must be consistent with the ISO/IEC/IEEE 60559:2011 operation convertFromInt if a is an integer,
and with operation convertFormat if a is real.
Example
The result value of IEEE_REAL (987) is 987.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_REM
Elemental Module Intrinsic Function (Generic):
Returns the result of an exact remainder operation.
This is equivalent to the IEEE remainder function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_REM (x,y)
y (Input) Must be of type REAL with a radix that is the same as that of
x.
Results
The result type is real with the kind type parameter of whichever argument has greater precision.
Regardless of the rounding mode, the result value is x - y*N, where N is the integer nearest to the value x /
y. If |N – x / y | = 1/2, N is even. If the result value is zero, the sign is the same as x.
Example
The value of IEEE_REM (5.0,4.0) is 1.0; the value of IEEE_REM (2.0,1.0) is 0.0; the value of IEEE_REM
(3.0,2.0) is -1.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1569
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_RINT
Elemental Module Intrinsic Function (Generic):
Returns an integer value rounded according to the
current rounding mode.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_RINT (x [, round])
Results
The result type and kind are the same as x.
The value of the result is x rounded to an integer according to the current rounding mode if round is not
present. If round is present, the value of the result is x rounded to an integer according to the mode
specified by round; this is the operation roundToInteger (rounding) as specified by ISO/IEC/IEEE
60559:2011.
If the result value is zero, the sign is the same as x.
The rounding mode specified by round, if present, is used to perform the conversion. The rounding mode
before and after the call remains unchanged.
Example
If the current rounding mode is IEEE_UP, the value of IEEE_RINT (2.2) is 3.0.
If the current rounding mode is IEEE_NEAREST, the value of IEEE_RINT (2.2) is 2.0.
The value of IEEE_RINT (7.4, IEEE_DOWN) is 7.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SCALB
Elemental Module Intrinsic Function (Generic):
Returns the exponent of a radix-independent floating-
point number. This is equivalent to the IEEE scalb
function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SCALB (x,i)
1570
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type and kind are the same as x. The result is x multiplied by 2**i, if the value can be represented
as a normal number.
If x (2**i) is too small and there is a loss of accuracy, the exception IEEE_UNDERFLOW is signaled. The
result value is the nearest number that can be represented with the same sign as x.
If x is finite and x (2**i) is too large, an IEEE_OVERFLOW exception occurs. If IEEE_SUPPORT_INF (x) is
true, the result value is infinity with the same sign as x; otherwise, the result value is SIGN (HUGE(x), x).
If x is infinite, the result is the same as x; no exception is signaled.
Example
The value of IEEE_SCALB (2.0,3) is 16.0.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SELECTED_REAL_KIND
Transformational Module Intrinsic Function
(Generic): Returns the value of the kind parameter of
an IEEE REAL data type.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SELECTED_REAL_KIND ([p][,r][,radix])
Results
If p or r is absent, the result is as if the argument was present with the value zero. If radix is absent, there
is no requirement on the radix of the selected kind.
The result is a scalar of type default integer. The result has a value equal to a value of the kind parameter of
an IEEE real data type with decimal precision, as returned by the function PRECISION, of at least p digits, a
decimal exponent range, as returned by the function RANGE, of at least r, and a radix, as returned by the
function RADIX, of radix.
If no such kind type parameter is available on the processor, the result is as follows:
If more than one kind type parameter value meets the criteria, the value returned is the one with the
smallest decimal precision.
1571
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IEEE_SELECTED_REAL_KIND (6, 70, 2) = 8.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
SELECTED_REAL_KIND
Model for Real Data
for information on the real model.
IEEE_SET_FLAG
Elemental Module Intrinsic Function (Generic):
Assigns a value to an exception flag. This is a pure
subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_FLAG (flag,flag_value)
flag_value (Output) Must be of type logical. If it has the value true, the exception
in flag is set to signal; otherwise, the exception is set to be quiet.
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SET_HALTING_MODE
Elemental Module Intrinsic Function (Generic):
Controls halting or continuation after an exception.
This is a pure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_HALTING_MODE (flag, halting)
1572
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
halting (Input) Must be scalar and of type logical. If the value is true, the
exception specified in flag will cause halting; otherwise, execution will
continue after this exception.
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SET_MODES
Intrinsic Module Subroutine (Generic): Restores
the current IEEE floating-point modes. This is an
impure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_MODES (modes)
Example
Consider the following:
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1573
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SET_ROUNDING_MODE
Intrinsic Module Subroutine (Generic): Sets the
IEEE rounding mode. This is an impure subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_SET_ROUNDING_MODE (round_value [, radix])
radix (Input; optional) Must be an integer scalar with a value of ten or two.
The rounding mode set is the binary rounding mode unless radix is
present with the value of ten, in which case it is the decimal rounding
mode set.
Example
Consider the following:
IEEE_SET_STATUS
Intrinsic Module Subroutine (Generic): Restores
the state of the floating-point environment. This is an
impure subroutine.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
CALL IEEE_SET_STATUS (status_value)
Example
Consider the following:
1574
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SET_UNDERFLOW_MODE
Intrinsic Module Subroutine (Generic): Sets the
current underflow mode. This is an impure subroutine.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
CALL IEEE_SET_UNDERFLOW_MODE (gradual)
gradual (Input) Must be scalar and of type logical. If it is true, the current
underflow mode is set to gradual underflow (subnormals may be
produced on underflow). If it is false, the current underflow mode is
set to abrupt (underflowed results are set to zero).
Example
Consider the following:
IEEE_SIGNALING_EQ
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for equality. This is
equivalent to the IEEE compareSignalingEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_EQ (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares equal to b. If a or b is a NaN, the
result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_EQ (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
1575
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SIGNALING_GE
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for greater than or
equal. This is equivalent to the IEEE
compareSignalingGreaterEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_GE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than or equal to b. If a or b is
a NaN, the result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingGreaterEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_GE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_GT
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for greater than. This
is equivalent to the IEEE compareSignalingGreater
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_GT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares greater than b. If a or b is a NaN, the
result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingGreater operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
1576
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The result value of IEEE_SIGNALING_GT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_LE
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for less than or
equal. This is equivalent to the IEEE
compareSignalingLessEqual operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_LE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares less than or equal to b. If a or b is a
NaN, the result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingLessEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_LE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_LT
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for less than. This is
equivalent to the IEEE compareSignalingLess
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_LT (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
1577
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default LOGICAL. It has the value true if a compares less than b. If a or b is a NaN, the
result is false and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingLess operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_LT (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is false and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNALING_NE
Elemental Module Intrinsic Function (Generic):
Performs a signaling comparison for inequality. This is
equivalent to the IEEE compareSignalingNotEqual
operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNALING_NE (a,b)
b (Input) Must be of type REAL with the same kind type parameter as a.
Results
The result type is default LOGICAL. It has the value true if a compares not equal to b. If a or b is a NaN, the
result is true and IEEE_INVALID signals, otherwise no exception is signaled.
This is the compareSignalingNotEqual operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result value of IEEE_SIGNALING_NE (3.7, IEEE_VALUE (0.0, IEEE_QUIET_NAN)) is true and
IEEE_INVALID is signaled.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SIGNBIT
Elemental Module Intrinsic Function (Generic):
Tests to determine if the argument's sign bit is set.
This is equivalent to the IEEE SignMinus operation.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SIGNBIT (x)
1578
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default logical. The result has the value .true. if the sign bit of x is set
(nonzero); otherwise, it has the value .false.. No exception is signaled even if x has the value of a signaling
NaN.
This is the SignMinus operation as specified in the ISO/IEC/IEEE 60559:2011 standard.
Example
The result of IEEE_SIGNBIT (-3.14) is .true..
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_DATATYPE
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
arithmetic.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_DATATYPE ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports IEEE arithmetic for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports IEEE arithmetic for real variables of
the same kind type parameter as x; otherwise, false.
If real values are implemented according to the IEEE standard except that underflowed values flush to zero
(abrupt) instead of being subnormal.
Example
IEEE_SUPPORT_DATATYPE (3.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_DENORMAL
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
subnormal numbers.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
1579
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = IEEE_SUPPORT_DENORMAL ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports arithmetic operations and assignments with subnormal numbers for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports arithmetic operations and assignments
with subnormal numbers for real variables of the same kind type parameter as x; otherwise, false.
IEEE_SUPPORT_DENORMAL() and IEEE_SUPPORT_DENORMAL(0.0_16) return .TRUE. even though Intel®
Fortran’s implementation does not signal when an underflow results in a REAL(16) denormal value. Intel®
Fortran’s implementation does signal when an underflow results in a REAL(16) zero.
Example
IEEE_SUPPORT_DENORMAL () has the value true if IEEE subnormal numbers are supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_DIVIDE
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE divide.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_DIVIDE ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports divide with the accuracy specified by the IEEE standard for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports divide with the accuracy specified by
the IEEE standard for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_DIVIDE ( ) has the value true if IEEE divide is supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1580
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_SUPPORT_FLAG
Transformational Module Intrinsic Function
(Generic): Returns whether the processor supports
IEEE exceptions.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
result = IEEE_SUPPORT_FLAG (flag [, x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports detection of the exception specified by flag for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports detection of the exception specified by
flag for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_FLAG (IEEE_UNDERFLOW) has the value true if the IEEE_UNDERFLOW exception is
supported for all real types.
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_HALTING
Transformational Module Intrinsic Function
(Generic): Returns whether the processor supports
IEEE halting.
Module
USE, INTRINSIC :: IEEE_EXCEPTIONS
Syntax
result = IEEE_SUPPORT_HALTING(flag)
Results
The result is a scalar of type default logical. The result has the value true if the processor supports the ability
to control halting after the exception specified by flag; otherwise, false.
1581
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
IEEE_SUPPORT_HALTING (IEEE_UNDERFLOW) has the value true if halting is supported after an
IEEE_UNDERFLOW exception
See Also
IEEE_EXCEPTIONS Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_INF
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
infinities.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_INF ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports IEEE infinities (positive and negative) for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports IEEE infinities for real variables of the
same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_INF( ) has the value true if IEEE infinities are supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_IO
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE base
conversion rounding during formatted I/O.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_IO ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports base conversion rounding during formatted input and output for all real values; otherwise, false.
1582
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If x is specified, the result has the value true if the processor supports base conversion rounding during
formatted input and output for real variables of the same kind type parameter as x; otherwise, false.
The base conversion rounding applies to modes IEEE_UP, IEEE_DOWN, IEEE_TO_ZERO, and IEEE_NEAREST.
Example
IEEE_SUPPORT_IO ( ) has the value true if base conversion rounding is supported for all real types during
formatted I/O.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_NAN
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE Not-a-
Number feature.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_NAN ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports NaNs for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports NaNs for real variables of the same
kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_NAN () has the value true if IEEE NaNs are supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_ROUNDING
Transformational Module Intrinsic Function
(Generic): Returns whether the processor supports
IEEE rounding mode.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_ROUNDING (round_value [, x])
1583
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports the rounding mode specified by round_value for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports the rounding mode specified by
round_value for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_ROUNDING (IEEE_DOWN) has the value true if rounding mode IEEE_DOWN is supported for
all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_SQRT
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE SQRT
(square root).
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_SQRT ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
implements SQRT in accord with the IEEE standard for all real values; otherwise, false.
If x is specified, the result has the value true if the processor implements SQRT in accord with the IEEE
standard for real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_SQRT ( ) has the value true if IEEE SQRT is supported for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_STANDARD
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE features
defined in the standard.
1584
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_STANDARD ([x])
Results
The result is a scalar of type default logical. The result has the value true if the results of all the following
functions are true (x can be omitted):
IEEE_SUPPORT_DATATYPE([x])
IEEE_SUPPORT_DENORMAL([x])
IEEE_SUPPORT_DIVIDE([x])
IEEE_SUPPORT_FLAG(flag [, x])1
IEEE_SUPPORT_HALTING(flag)1
IEEE_SUPPORT_INF([x])
IEEE_SUPPORT_NAN([x])
IEEE_SUPPORT_ROUNDING(round_value [, x])2
IEEE_SUPPORT_SQRT([x])
1 "flag" must be a valid value
2 "round_value" must be a valid value
Example
IEEE_SUPPORT_STANDARD () has the value false if both IEEE and non-IEEE real kinds are supported.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_SUBNORMAL
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports IEEE
subnormal numbers.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_SUBNORMAL ([x])
1585
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports arithmetic operations and assignments with subnormal numbers for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports arithmetic operations and assignments
with subnormal numbers for real variables of the same kind type parameter as x; otherwise, false.
IEEE_SUPPORT_SUBNORMAL () and IEEE_SUPPORT_SUBNORMAL (0.0_16) return .TRUE. even though Intel®
Fortran’s implementation does not signal when an underflow results in a REAL (16) subnormal value. Intel®
Fortran’s implementation does signal when an underflow results in a REAL (16) zero.
Example
IEEE_SUPPORT_SUBNORMAL () has the value true if IEEE subnormal numbers are supported for all real
types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_SUPPORT_UNDERFLOW_CONTROL
Inquiry Module Intrinsic Function (Generic):
Returns whether the processor supports the ability to
control the underflow mode.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_SUPPORT_UNDERFLOW_CONTROL ([x])
Results
The result is a scalar of type default logical. If x is omitted, the result has the value true if the processor
supports controlling the underflow mode for all real values; otherwise, false.
If x is specified, the result has the value true if the processor supports controlling the underflow mode for
real variables of the same kind type parameter as x; otherwise, false.
Example
IEEE_SUPPORT_UNDERFLOW _CONTROL () has the value true if controlling the underflow mode is supported
for all real types.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
1586
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IEEE_UNORDERED
Elemental Module Intrinsic Function (Generic):
Returns whether one or more of the arguments is Not-
a-Number (NaN). This is equivalent to the IEEE
unordered function.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_UNORDERED (x,y)
Results
The result type is default logical. The result has the value true if x or y is a NaN, or both are NaNs;
otherwise, false.
Example
IEEE_UNORDERED (0.0, SQRT(-2.0)) has the value true if IEEE_SUPPORT_SQRT (2.0) has the value true.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEEE_VALUE
Elemental Module Intrinsic Function (Generic):
Creates an IEEE value.
Module
USE, INTRINSIC :: IEEE_ARITHMETIC
Syntax
result = IEEE_VALUE (x, class)
IEEE_SIGNALING_NAN IEEE_NEGATIVE_NORMAL
IEEE_QUIET_NAN IEEE_POSITIVE_DENORMAL
IEEE_POSITIVE_INF IEEE_NEGATIVE_DENORMAL
IEEE_NEGATIVE_INF IEEE_POSITIVE_ZERO
IEEE_POSITIVE_NORMAL IEEE_NEGATIVE_ZERO
Results
The result type and kind are the same as x. The result value is an IEEE value as specified by "class".
1587
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When IEEE_VALUE returns a signaling NaN, it is processor dependent whether or not invalid is signaled and
processor dependent whether or not the signaling NaN is converted to a quiet NaN.
Example
IEEE_VALUE (1.0,IEEE_POSITIVE_INF) has the value +infinity.
See Also
IEEE_ARITHMETIC Intrinsic Module
IEEE Intrinsic Modules Quick Reference Tables
IEOR
Elemental Intrinsic Function (Generic): Performs
an exclusive OR on corresponding bits. This function
can also be specified as XOR or IXOR.
Syntax
result = IEOR (i,j)
Results
The result is the same as i if i is of type integer or logical; otherwise, the result is the same as j. If either i or
j is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to
type integer with the kind type parameter of the other.
The result value is derived by combining i and j bit-by-bit according to the following truth table:
i j IEOR (i, j)
1 1 0
1 0 1
0 1 1
0 0 0
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
1588
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
3Or JIXOR
Example
IEOR (12, 7) has the value 11; binary 1100 exclusive OR with binary 0111 is binary 1011.
The following shows another example:
INTEGER I
I = IEOR(240, 90) ! returns 170
! IEOR (B'11110000', B'1011010') == B'10101010'
The following shows an example using alternate option XOR:
INTEGER i, j, k
i = 3 ! B'011'
j = 5 ! B'101'
k = XOR(i, j) ! returns 6 = B'110'
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
IAND
IOR
NOT
IALL
IANY
IPARITY
IERRNO
Portability Function: Returns the number of the last
detected error from any routines in the IFPORT
module that return error codes.
Module
USE IFPORT
Syntax
result = IERRNO( )
Results
The result type is INTEGER(4). The result value is the last error code from any portability routines that return
error codes. These error codes are analogous to errno on a Linux* or macOS system. The module
IFPORT.F90 provides parameter definitions for the following errno names (typically found in errno.h on
Linux systems):
1589
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The value returned by IERRNO is updated only when an error occurs. For example, if an error occurs on a
GETLOG call and then two CHMOD calls succeed, a subsequent call to IERRNO returns the error for the
GETLOG call.
Examine IERRNO immediately after returning from a portability routine. IERRNO is set on a per thread basis.
Example
USE IFPORT
CHARACTER*20 username
INTEGER(4) ierrval
ierrval=0 !initialize return value
CALL GETLOG(username)
IF (IERRNO( ) == ierrval) then
print *, 'User name is ',username
exit
ELSE
ierrval = ierrno()
print *, 'Error is ',ierrval
END IF
IF - Arithmetic
Statement: Conditionally transfers control to one of
three statements, based on the value of an arithmetic
expression. The arithmetic IF statement is a deleted
feature in the Fortran Standard. Intel® Fortran fully
supports features deleted in the Fortran Standard.
Syntax
IF (expr) label1,label2,label3
label1, label2, label3 Are the labels of valid branch target statements that are in the same
scoping unit as the arithmetic IF statement.
Description
All three labels are required, but they do not need to refer to three different statements. The same label can
appear more than once in the same arithmetic IF statement.
1590
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
During execution, the expression is evaluated first. Depending on the value of the expression, control is then
transferred as follows:
Example
The following example transfers control to statement 50 if the real variable THETA is less than or equal to the
real variable CHI. Control passes to statement 100 only if THETA is greater than CHI.
IF (THETA-CHI) 50,50,100
The following example transfers control to statement 40 if the value of the integer variable NUMBERis even. It
transfers control to statement 20 if the value is odd.
See Also
SELECT CASE...END SELECT
Execution Control
Deleted Language Features in the Fortran Standard
IF - Logical
Statement: Conditionally executes one statement
based on the value of a logical expression. (This
statement was called a logical IF statement in
FORTRAN 77.)
Syntax
IF (expr) stmt
When an IF statement is executed, the logical expression is evaluated first. If the value is true, the
statement is executed. If the value is false, the statement is not executed and control transfers to the next
statement in the program.
1591
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following examples show valid IF statements:
USE IFPORT
INTEGER(4) istat, errget
character(inchar)
real x
istat = getc(inchar)
IF (istat) errget = -1
...
! IF (x .GT. 2.3) call new_subr(x)
...
See Also
IF Construct
Execution Control
IF Clause
Parallel Directive Clause: Specifies a conditional
expression. If the expression evaluates to .FALSE., the
construct is not executed.
Syntax
IF ([directive-name-modifier:] scalar-logical-expression)
directive-name-modifier Names the associated construct that the IF clause applies to.
Currently, you can specify one of the following associated constructs
(directives): PARALLEL, SIMD, TARGET DATA, TARGET, TARGET
UPDATE, TARGET ENTER DATA, TARGET EXIT DATA, TASK, or
TASKLOOP.
These directives are only available on Linux* systems: TARGET DATA,
TARGET, TARGET UPDATE, TARGET ENTER DATA, TARGET EXIT DATA.
At most one IF clause can appear in a non-combined directive. In combined directives, IF clauses with
different directive-name-modifiers can occur, at most one for each constituent directive making up the
combined directive where IF is allowed.
Description
The effect of the IF clause depends on the construct to which it is applied:
• For combined or composite constructs, the IF clause only applies to the semantics of the construct named
in the directive-name-modifier if one is specified.
• If no directive-name-modifier is specified for a combined or composite construct then the IF clause applies
to all constructs to which an IF clause can apply.
The following are additional rules that apply to specific OpenMP Fortran directives:
1592
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• For the CANCEL OpenMP* Fortran directive, if scalar-logical-expression evaluates to false, the construct
does not request cancellation. Note that directive-name-modifier cannot specify CANCEL.
• For the PARALLEL OpenMP Fortran directive:
• The enclosed code section is executed in parallel only if scalar-logical-expression evaluates to .TRUE..
Otherwise, the parallel region is serialized. If this clause is not used, the region is executed as if an
IF(.TRUE.) clause were specified.
• This clause is evaluated in the context outside of this construct.
• For the SIMD OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the number of
iterations to be executed concurrently is one.
• For the TARGET OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the target
region is not executed by the device. It is executed by the encountering task.
• For the TARGET DATA OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the new
device data environment is not created.
• For the TARGET UPDATE OpenMP Fortran directive, if scalar-logical-expression evaluates to .FALSE., the
TARGET UPDATE directive is ignored.
• For the TASK OpenMP Fortran directive:
• If scalar-logical-expression evaluates to .FALSE., the encountering thread must suspend the current
task region and begin execution of the generated task immediately. The suspended task region will not
be resumed until the generated task is completed.
• This clause is evaluated in the context outside of this construct.
IF Construct
Statement: Conditionally executes one block of
constructs or statements depending on the evaluation
of a logical expression. (This construct was called a
block IF statement in FORTRAN 77.)
Syntax
[name:] IF (expr) THEN
block
[ELSE IF (expr) THEN [name]
block]
[ELSE [name]
block]
END IF [name]
Description
If a construct name is specified at the beginning of an IF THEN statement, the same name must appear in
the corresponding END IF statement. If a construct name is specified on an ELSE IF or ELSE statement, the
same name must appear in the corresponding IF THEN and END IF statements.
The same construct name must not be used for different named constructs in the same scoping unit.
Depending on the evaluation of the logical expression, one block or no block is executed. The logical
expressions are evaluated in the order in which they appear, until a true value is found or an ELSE or END IF
statement is encountered.
1593
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Once a true value is found or an ELSE statement is encountered, the block immediately following it is
executed and the construct execution terminates.
If none of the logical expressions evaluate to true and no ELSE statement appears in the construct, no block
in the construct is executed and the construct execution terminates.
NOTE
No additional statement can be placed after the IF THEN statement in a block IF construct.
For example, the following statement is invalid in the block IF construct:
IF (e) THEN I = J
This statement is translated as the following logical IF statement:
IF (e) THENI = J
You cannot use branching statements to transfer control to an ELSE IF statement or ELSE statement.
However, you can branch to an END IF statement from within the IF construct.
The following figure shows the flow of control in IF constructs:
1594
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You can include an IF construct in the statement block of another IF construct, if the nested IF construct is
completely contained within a statement block. It cannot overlap statement blocks.
1595
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows the simplest form of an IF construct:
Form Example
IF (expr) THEN IF (ABS(ADJU) .GE. 1.0E-6) THEN
block TOTERR = TOTERR + ABS(ADJU)
QUEST = ADJU/FNDVAL
END IF END IF
This construct conditionally executes the block of statements between the IF THEN and the END IF
statements.
The following shows another example:
Form Example
IF (expr) THEN IF (NAME .LT. 'N') THEN
block1 IFRONT = IFRONT + 1
FRLET(IFRONT) = NAME(1:2)
ELSE ELSE
block2 IBACK = IBACK + 1
END IF END IF
Block1 consists of all the statements between the IF THEN and ELSE statements. Block2 consists of all the
statements between the ELSE and the END IF statements.
If the value of the character variable NAME is less than 'N ', block1 is executed. If the value of NAME is
greater than or equal to 'N ', block2 is executed.
Form Example
IF (expr) THEN IF (A .GT. B) THEN
block1 D = B
F = A - B
ELSE IF (expr) THEN ELSE IF (A .GT. B/2.) THEN
block2 D = B/2.
F = A - B/2.
END IF END IF
If A is greater than B, block1 is executed. If A is not greater than B, but A is greater than B/2, block2 is
executed. If A is not greater than B and A is not greater than B/2, neither block1 nor block2 is executed.
Control transfers directly to the next executable statement after the END IF statement.
1596
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Form Example
IF (expr) THEN IF (A .GT. B) THEN
block1 D = B
F = A - B
ELSE IF (expr) THEN ELSE IF (A .GT. C) THEN
block2 D = C
F = A - C
ELSE IF (expr) THEN ELSE IF (A .GT. Z) THEN
block3 D = Z
F = A - Z
ELSE ELSE
block4 D = 0.0
F = A
END IF END IF
If A is greater than B, block1 is executed. If A is not greater than B but is greater than C, block2 is executed.
If A is not greater than B or C but is greater than Z, block3 is executed. If A is not greater than B, C, or Z,
block4 is executed.
The following example shows a nested IF construct:
Form Example
IF (expr) THEN IF (A .LT. 100) THEN
block1 INRAN = INRAN + 1
IF (expr2) THEN IF (ABS(A-AVG) .LE. 5.) THEN
block1a INAVG = INAVG + 1
ELSE ELSE
block1b OUTAVG = OUTAVG + 1
END IF END IF
ELSE ELSE
block2 OUTRAN = OUTRAN + 1
END IF END IF
If A is less than 100, the code immediately following the IF is executed. This code contains a nested IF
construct. If the absolute value of A minus AVG is less than or equal to 5, block1a is executed. If the
absolute value of A minus AVG is greater than 5, block1b is executed.
If A is greater than or equal to 100, block2 is executed, and the nested IF construct (in block1) is not
executed.
The following shows another example:
1597
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IF Directive Construct
General Compiler Directive: A conditional
compilation construct that begins with an IF or IF
DEFINED directive. IF tests whether a logical
expression is .TRUE. or .FALSE.. IF DEFINED tests
whether a symbol has been defined.
Syntax
!DIR$ IF (expr) -or- !DIR$ IF DEFINED (name)
block
[!DIR$ ELSEIF (expr)
block] ...
[!DIR$ ELSE
block]
!DIR$ ENDIF
block Are executable statements that are compiled (or not) depending on
the value of logical expressions in the IF directive construct.
The IF and IF DEFINED directive constructs end with an ENDIF directive and can contain one or more ELSEIF
directives and at most one ELSE directive. If the logical condition within a directive evaluates to .TRUE. at
compilation, and all preceding conditions in the IF construct evaluate to .FALSE., then the statements
contained in the directive block are compiled.
A name can be defined with a DEFINE directive, and can optionally be assigned an integer value. If the
symbol has been defined, with or without being assigned a value, IF DEFINED (name) evaluates to .TRUE.;
otherwise, it evaluates to .FALSE..
If the logical condition in the IF or IF DEFINED directive is .TRUE., statements within the IF or IF DEFINED
block are compiled. If the condition is .FALSE., control transfers to the next ELSEIF or ELSE directive, if any.
If the logical expression in an ELSEIF directive is .TRUE., statements within the ELSEIF block are compiled. If
the expression is .FALSE., control transfers to the next ELSEIF or ELSE directive, if any.
1598
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If control reaches an ELSE directive because all previous logical conditions in the IF construct evaluated
to .FALSE., the statements in an ELSE block are compiled unconditionally.
You can use any Fortran logical or relational operator or symbol in the logical expression of the directive,
including: .LT., <, .GT., >, .EQ., ==, .LE., <=, .GE., >=, .NE., /=, .EQV., .NEQV., .NOT., .AND., .OR.,
and .XOR.. The logical expression can be as complex as you like, but the whole directive must fit on one line.
Example
! When the following code is compiled and run,
! the output is:
! Or this compiled if all preceding conditions .FALSE.
!
!DIR$ DEFINE flag=3
!DIR$ IF (flag .LT. 2)
WRITE (*,*) "This is compiled if flag less than 2."
!DIR$ ELSEIF (flag >= 8)
WRITE (*,*) "Or this compiled if flag greater than &
or equal to 8."
!DIR$ ELSE
WRITE (*,*) "Or this compiled if all preceding &
conditions .FALSE."
!DIR$ ENDIF
END
See Also
DEFINE and UNDEFINE
IF Construct
General Compiler Directives
Syntax Rules for Compiler Directives
IF DEFINED Directive
Statement: Marks the start of an IF Directive
Construct.
See Also
See IF Directive Construct.
IFIX
Elemental Intrinsic Function (Generic): Converts
a single-precision real argument to an integer by
truncating.
See Also
See INT.
IFLOATI, IFLOATJ
Portability Functions: Convert an integer to single-
precision real type.
Module
USE IFPORT
Syntax
result = IFLOATI (i)
result = IFLOATJ (j)
1599
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is single-precision real (REAL(4) or REAL*4).
See Also
DFLOAT
ILEN
Inquiry Intrinsic Function (Generic): Returns the
length (in bits) of the two's complement
representation of an integer.
Syntax
result = ILEN (i)
Results
The result type and kind are the same as i. The result value is (LOG2( i+ 1 )) if i is not negative; otherwise,
the result value is (LOG2( - i)).
Example
ILEN (4) has the value 3.
ILEN (-4) has the value 2.
IMAGE_INDEX
Transformational Intrinsic Function (Generic):
Converts cosubscripts to an image index.
Syntax
result = IMAGE_INDEX (coarray, sub)
result = IMAGE_INDEX (coarray, sub, team)
result = IMAGE_INDEX (coarray, sub, team_number)
sub (Input) Must be a rank-one integer array of size equal to the corank of
coarray.
team_number (Input) Must be an integer scalar. It must identify the initial team (-1)
or a team formed by the same execution of the FORM TEAM statement
that created the current team (a sibling team of the current team).
1600
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is default integer scalar. The result is the index of the corresponding image if the value of sub is a
valid sequence of cosubscripts for coarray on the team specified by team or team_number, or for the current
team if neither team nor team_number is specified. Otherwise, the result is zero.
Examples
If coarray D is declared as D [0:*] and coarray C is declared as C(5,10) [10, 0:9, 0:*], IMAGE_INDEX (D,
[0]) has the value 1 and IMAGE_INDEX (C, [3, 1, 2]) has the value 213 (on any image).
Consider the following program:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: initial, odd_even
REAL :: ca1[4:*], ca2[2, *]
INTEGER :: i, j, k, l
initial = GET_TEAM (CURRENT_TEAM)
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
PRINT *, THIS_IMAGE()
PRINT *, THIS_IMAGE (coarray1)
PRINT *, THIS_IMAGE (coarray2, 2)
CHANGE TEAM (odd_even)
. . .
i = IMAGE_INDEX(ca1, [6], 2)
j = IMAGE_INDEX(ca1, [6], 1)
k = IMAGE_INDEX(ca2, [2, 4], initial)
l = IMAGE_INDEX(ca1, [12], -1)
. . .
END TEAM
. . .
END PROGRAM
If there are 10 images on the initial team, ca1[4] will be on image 1, ca1[5] on image 2, and ca1[13] will be
on image 10. Similarly, ca2[1, 1] will be on image 1, ca[2, 1] on image 2, ending with ca2[2, 5] will be on
image 10. The FORM TEAM statement divides the images into two teams, with team 1 having images [1, 3,
5, 7, 9] with image numbers [1, 2, 3, 4, 5] respectively, and team 2 having images [2, 4, 6, 8, 10] with
image numbers [1, 2, 3, 4, 5] respectively.
After the 4 calls to IMAGE_INDEX, the value of i will be zero (ca1[6] is not on an image in team 2), j will
have the value 2, k will have the value 8, and l will have the value 9. Note that the team number -1 always
refers to the initial team. Note also that if the FORM TEAM does not specify NEW_INDEX, the image numbers
on the new teams formed by the FORM TEAM are assigned in a processor-dependent manner.
See Also
FORM TEAM
IMAGE_STATUS
Elemental Intrinsic Function (Generic): Returns
the execution status value of the specified image.
Syntax
result = IMAGE_STATUS (image [, team])
image (Input) Must be a positive integer with a value equal to or less than
the number of executing images on the specified team.
1601
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default integer. If image on the specified team has initiated normal termination, the result
is the value STAT_STOPPED_IMAGE defined in the intrinsic module ISO_FORTRAN_ENV. If image on the
specified team has failed, the result is the value STAT_FAILED_IMAGE defined in the intrinsic module
ISO_FORTRAN_ENV. Otherwise, the result value is zero.
Example
If image 5 on the specified team has initiated normal termination, and image 12 on the specified team is
known to have failed, then IMAGE_STATUS (5) returns the value STAT_STOPPED_IMAGE and IMAGE_STATUS
(12) returns the value STAT_FAILED_IMAGE. If image 3 on the specified team has neither initiated normal
termination nor failed, IMAGE_STATUS (3) returns the value zero.
See Also
FAILED_IMAGES
STOPPED_IMAGES
ISO_FORTRAN_ENV Module
IMPLICIT
Statement: Overrides the default implicit typing rules
for names. (The default data type is default INTEGER
kind for names beginning with the letters I through N,
and default REAL kind for names beginning with any
other letter.) An IMPLICIT NONE statement overrides
all implicit typing in a scoping unit, or it indicates that
all dummy procedures and externals must explicitly be
given the external attribute.
Syntax
The IMPLICIT statement takes one of the following forms:
IMPLICIT type(a[,a]...)[,type(a[,a]...)]...
IMPLICIT NONE [(spec-list])
The dollar sign can be used at the end of a range of letters, since IMPLICIT interprets the dollar sign to
alphabetically follow the letter Z. For example, a range of X-$ would apply to identifiers beginning with the
letters X, Y, Z, or $.
In Intel® Fortran, the parentheses around the list of letters are optional.
1602
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The IMPLICIT statement assigns the specified data type (and kind parameter) to all names that have no
explicit data type and begin with the specified letter or range of letters. It has no effect on the default types
of intrinsic procedures.
When the data type is CHARACTER*len, len is the length for character type. The len is an unsigned integer
constant or an integer specification expression enclosed in parentheses. The range for len is 1 to 2**31-1 on
IA-32 architecture; 1 to 2**63-1 on Intel® 64 architecture.
Names beginning with a dollar sign ($) are implicitly INTEGER.
The IMPLICIT NONE statement disables all implicit typing defaults. When IMPLICIT NONE is used, all names
in a program unit must be explicitly declared. An IMPLICIT NONE statement must precede any PARAMETER
statements, and there must be no other IMPLICIT statements in the scoping unit. An IMPLICIT NONE (TYPE)
statement is the same as an IMPLICIT NONE statement. If an IMPLICIT NONE (EXTERNAL) statement
appears in a scoping unit, all dummy procedures and external procedures in that scope or a contained scope
of BLOCK must have an accessible explicit interface or be declared EXTERNAL.
NOTE
To receive diagnostic messages when variables are used but not declared, you can specify
compiler option warn declarations instead of using IMPLICIT NONE or IMPLICIT NONE
(TYPE). To receive diagnostic messages when external and dummy procedures have not
explicitly been given the EXTERNAL attribute, you can specify compiler option
warn externals instead of using IMPLICIT NONE (EXTERNAL).
The following IMPLICIT statement represents the default typing as specified by the Fortran Standard for
names when they are not explicitly typed:
Example
The following are examples of the IMPLICIT statement:
SUBROUTINE FF (J)
IMPLICIT INTEGER (a-b), CHARACTER*(J+1) (n), TYPE(fried) (c-d)
TYPE fried
INTEGER e, f
REAL g, h
END TYPE
age = 10 ! integer
name = 'Paul' ! character
c%e = 1 ! type fried, integer component
See Also
Data Types, Constants, and Variables
warn declarations compiler option
warn externals compiler option
1603
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IMPORT
Statement: Controls accessibility of host entities in a
submodule, module procedure, a contained procedure,
a block construct, or in the interface body of an
interface block.
Syntax
The IMPORT statement takes the following form:
IMPORT [[::] import-name-list]
IMPORT,ONLY: import-name-list
IMPORT,NONE
IMPORT,ALL
import-name-list (Input) Is the name of one or more entities accessible in the host
scoping unit.
An IMPORT statement can appear in a submodule, module procedure, a contained procedure, the
specification part of a BLOCK construct, or in an interface body. It can not appear in the specification part of
a main program, external procedure, module, or block data except in an interface body.
An IMPORT statement must appear after any USE statements, and before any other specification statements.
Each of the named entities must be an accessible entity in the host scoping unit. Within an interface body
each named entity must be explicitly declared before the interface body, or accessible by use or host
association in the host containing the IMPORT statement.
If IMPORT, ONLY appears within a scoping unit, all other IMPORT statements in that scoping unit must be
IMPORT, ONLY statements. An entity is host associated in a scoping unit which contains an IMPORT, ONLY
statement if it appears in an import-name-list in that scoping unit.
If IMPORT, NONE is specified, no entities in the host are accessible by host association in that scoping unit.
This is the default behavior for interface bodies for a dummy or external procedure. IMPORT, NONE must not
appear in the specification part of a submodule.
If an IMPORT, ALL or an IMPORT, NONE statement appears in a scoping unit, it must be the only IMPORT
statement in that scoping unit.
If import-name-list is not specified, and if ALL, ONLY, or NONE are not specified, all of the accessible named
entities in the host scoping unit are imported unless they are made inaccessible by an entity of the same
name in the local scope. This is the default behavior for a nested scoping unit, other than an interface body,
for a dummy or external procedure.
If IMPORT, ALL is specified, all entities in the host are accessible by host association. If an entity is made
accessible by an IMPORT, ALL statement or by its name appearing in an import-name-list, it cannot be made
inaccessible by declaring another entity with the same name in the local scope.
If an IMPORT statement with an import-name-list appears, only the named entities are available by host
association.
Examples
The following examples show how the IMPORT statement can be applied.
module mymod
type mytype
integer comp
end type mytype
interface
subroutine sub (arg)
import
1604
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
type(mytype) :: arg
end subroutine sub
end interface
end module mymod
module host
integer :: i, j, k
contains
subroutine sub1 ()
import :: i, j
k = i + j ! only i and j are host associated, k is local to sub1
end subroutine
subroutine sub2 ()
import, none
k = i + j ! i, j, and k are local to sub2
end subroutine
subroutine sub3 ()
import all
k = i + j ! i, j, and k are all host associated
end subroutine
subroutine sub4 ()
import, only : i
import, only : j
k = i + j ! i and j are host associated, k is local
end subroutine
end module
IMPURE
Keyword: Asserts that a user-defined procedure has
side effects.
Description
This kind of procedure is specified by using the prefix IMPURE in a FUNCTION or SUBROUTINE statement. By
default all user-defined procedures are impure, that is, they are allowed to have side effects, except for
elemental procedures.
An IMPURE elemental procedure has the restrictions that apply to elemental procedures, but it does not have
any of the restrictions of PURE elemental procedures.
An impure elemental procedure can have side effects and it can contain the following:
• Any external I/O statement (including a READ or WRITE statement whose I/O unit is an external file unit
number or *)
• A PAUSE statement
• A STOP statement or an ERROR STOP statement
• An image control statement
An impure elemental procedure cannot be referenced in a context that requires a procedure to be pure; for
example:
• It cannot be called directly in a FORALL statement or be used in the mask expression of a FORALL
statement.
• It cannot be called from a pure procedure. Pure procedures can only call other pure procedures, including
one referenced by means of a defined operator, defined assignment, or finalization.
• It cannot be passed as an actual argument to a pure procedure.
1605
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
module my_rand_mod
integer, save :: my_rand_seed (8)
contains
impure elemental subroutine my_rand (r)
real, intent(out) :: r
See Also
FUNCTION
SUBROUTINE
IN_REDUCTION
Parallel Directive Clause: Specifies that a task
participates in a reduction. The IN_REDUCTION clause
is a reduction participating clause.
Syntax
IN_REDUCTION (reduction-identifier : list)
reduction identifier and list These are defined in the REDUCTION clause description. All the
common restrictions for the REDUCTION clause apply to the
IN_REDUCTION clause.
A list item that appears in an IN_REDUCTION clause must appear in a TASK_REDUCTION clause or a
REDUCTION clause with the TASK reduction modifier. The construct associated with the innermost region that
meets this condition must specify the same reduction-identifier as the IN_REDUCTION clause.
If the IN_REDUCTION clause appears in a TARGET construct, the target task becomes the task participating
in the reduction. A private copy of each list item is created in the data environment of the target task. The
copy is implicitly mapped into the data environment of the target device if the target device is not the parent
device.
If the IN_REDUCTION clause is associated with a TASK construct, the generated task is the participating
task, and a private copy of each list item may be created.
At the end of the region, the value of private copies of list items are combined with the value of a private
copy created by a reduction scoping clause, and finally with the original list item.
The list items specified in an IN_REDUCTION clause must match the list items that appear in a
TASK_REDUCTION clause or in a REDUCTION clause with the TASK reduction modifier. The construct
specifying the TASK_REDUCTION or REDUCTION clause corresponds to a region in which the participating
task’s region is closely nested. The innermost enclosing construct that meets this condition must also specify
the same reduction-identifier specified in the IN_REDUCTION clause.
1606
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, the IN_REDUCTION clause at (3) must name the same operator (+) and variable
(a) as in the TASK_REDUCTION clause in (2). The IN_REDUCTION clause at (4) must name the same
operator (*) and variable (a) as in the TASK_REDUCTION clause in (1).
See Also
REDUCTION
DECLARE REDUCTION
TASK_REDUCTION
TARGET
TASK
TASKLOOP
INCLUDE
Statement: Directs the compiler to stop reading
statements from the current file and read statements
in an included file or text module.
Syntax
The INCLUDE line takes the following form:
INCLUDE 'filename[/[NO]LIST]'
Description
An INCLUDE line can appear anywhere within a scoping unit. The line can span more than one source line,
but no other statement can appear on the same line. The source line cannot be labeled.
An included file or text module cannot begin with a continuation line, and each Fortran statement must be
completely contained within a single file.
1607
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An included file or text module can contain any source text, but it cannot begin or end with an incomplete
Fortran statement.
The included statements, when combined with the other statements in the compilation, must satisfy the
statement-ordering restrictions shown in Statements.
Included files or text modules can contain additional INCLUDE lines, but they must not be recursive.
INCLUDE lines can be nested until system resources are exhausted.
When the included file or text module completes execution, compilation resumes with the statement
following the INCLUDE line.
You can use modules instead of include files to achieve encapsulation of related data types and procedures.
For example, one module can contain derived type definitions as well as special operators and procedures
that apply to those types. For information on how to use modules, see Program Units and Procedures.
Example
In the following example, a file named COMMON.FOR (in the current working directory) is included and read
as input.
PROGRAM
INCLUDE 'COMMON.FOR' INTEGER, PARAMETER :: M=100
REAL, DIMENSION(M) :: Z REAL, DIMENSION(M) :: X, Y
CALL CUBE COMMON X, Y
DO I = 1, M
Z(I) = X(I) + SQRT(Y(I))
...
END DO
END
SUBROUTINE CUBE
INCLUDE 'COMMON.FOR'
DO I=1,M
X(I) = Y(I)**3
END DO
RETURN
END
The file COMMON.FOR defines a named constant M, and defines arrays X and Y as part of blank common.
The following example program declares its common data in an include file. The contents of the file
INCLUDE.INC are inserted in the source code in place of every INCLUDE 'INCLUDE.INC' line. This guarantees
that all references to common storage variables are consistent.
INTEGER i
REAL x
INCLUDE 'INCLUDE.INC'
DO i = 1, 5
READ (*, '(F10.5)') x
CALL Push (x)
END DO
See Also
MODULE
1608
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
USE
INDEX
Elemental Intrinsic Function (Generic): Returns
the starting position of a substring within a string.
Syntax
result = INDEX (string, substring [,back] [, kind])
Results
The result is of type integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
If back does not appear (or appears with the value false), the value returned is the minimum value of I such
that string(I : I + LEN (substring) - 1) = substring(or zero if there is no such value). If LEN (string) < LEN
(substring), zero is returned. If LEN (substring) = zero, 1 is returned.
If back appears with the value true, the value returned is the maximum value of I such that string(I : I +
LEN (substring) - 1) = substring (or zero if there is no such value). If LEN(string) < LEN (substring), zero is
returned. If LEN (substring) = zero, LEN (string) + 1 is returned.
CHARACTER INTEGER(1)
CHARACTER INTEGER(2)
CHARACTER INTEGER(8)
1The setting of compiler options specifying integer size can affect this function.
Example
INDEX ('FORTRAN', 'O', BACK = .TRUE.) has the value 2.
INDEX ('XXXX', " ", BACK = .TRUE.) has the value 5.
The following shows another example:
See Also
SCAN
1609
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ INLINE [RECURSIVE]
!DIR$ FORCEINLINE [RECURSIVE]
!DIR$ NOINLINE
The INLINE directive specifies that the routines can be inlined.
The FORCEINLINE directive specifies that a routine should be inlined whenever the compiler can do so. This
condition can also be specified by using compiler option [Q]inline-forceinline.
Caution
When you use directive FORCEINLINE, the compiler may do so much additional inlining that it runs out
of memory and terminates with an "out of memory" message.
Example
Consider the following:
!DIR$ INLINE
A = F(B) + G(C) ! inline the call to function F and inline the call to function G
!DIR$ INLINE
DO I = 1, N
CALL F1 ( G1(A), G2(A)) ! inline the call to F1 and the function executions of G1 and G2
!DIR$ NOINLINE
DO J = 1, M
M(J) = F (M(J)) ! do not inline this call to F {M is a data array}
END DO
M(I) = F2 (X) ! F2 gets inlined from the directive before DO I
See Also
General Compiler Directives
1610
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INMAX
Portability Function: Returns the maximum positive
value for an integer.
Module
USE IFPORT
Syntax
result = INMAX (i)
i (Input) INTEGER(4).
Results
The result type is INTEGER(4). The result is the maximum 4-byte signed integer value for the argument.
INQUIRE
Statement: Returns information on the status of
specified properties of a file, logical unit, or directory.
It takes one of the following forms:
Syntax
Inquiring by File:
INQUIRE (FILE=name[, ERR=label] [, ID=id-var] [, IOMSG=msg-var] [, SIZE=sz] [, IOSTAT=i-
var] [, DEFAULTFILE=def] slist)
Inquiring by Unit:
INQUIRE ([UNIT=]io-unit [, ERR=label] [, ID=id-var] [, IOMSG=msg-var] [, SIZE=sz] [,
IOSTAT=i-var] slist)
Inquiring by Directory:
INQUIRE (DIRECTORY=dir, EXIST=ex [, DIRSPEC=dirspec] [, ERR=label] [, ID=id-var] [,
IOMSG=msg-var] [, SIZE=sz] [, IOSTAT=i-var])
Inquiring by Output List:
INQUIRE (IOLENGTH=len) out-item-list
name Is a scalar default character expression specifying the name of the file
for inquiry. For more information, see FILE Specifier and STATUS
Specifier.
label Is the label of the branch target statement that receives control if an
error occurs. For more information, see Branch Specifiers.
sz Is a scalar integer variable that is assigned the size of the file in file
storage units. For more information, see Size Specifier.
1611
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
slist Is one or more of the following inquiry specifiers (each specifier can
appear only once):
dirspec Is a scalar default character variable that is assigned the value of the
full directory specification of dir if ex is assigned the value .TRUE..
This specifier can only be used when inquiring by directory.
1612
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
out-item-list (Output) Is a list of one or more output items (see I/O Lists).
Description
The control specifiers ([UNIT=] io-unit, ERR= label, and IOSTAT= i-var) and inquiry specifiers can appear
anywhere within the parentheses following INQUIRE. However, if the UNIT keyword is omitted, the io-unit
must appear first in the list.
An INQUIRE statement can be executed before, during, or after a file is connected to a unit. The specifier
values returned are those that are current when the INQUIRE statement executes.
To get file characteristics, specify the INQUIRE statement after opening the file.
Examples
The following shows examples of INQUIRE statements.
In the last statement, you can use the length returned in LEN as the value for the RECL specifier in an OPEN
statement that connects a file for unformatted direct access. If you have already specified a value for RECL,
you can check LEN to verify that A and B are less than or equal to the record length you specified.
CHARACTER*12 fname
LOGICAL exists
See Also
OPEN statement
UNIT control specifier
ERR control specifier
ID control specifier
IOMSG control specifier
IOSTAT control specifier
RECL specifier in OPEN statements
FILE specifier in OPEN statements
DEFAULTFILE specifier in OPEN statements
assume:byterecl compiler option
1613
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INT
Elemental Intrinsic Function (Generic): Converts
a value to integer type.
Syntax
result = INT (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
Functions that cause conversion of one data type to another type have the same effect as the implied
conversion in assignment statements.
The result value depends on the type and absolute value of a as follows:
1614
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1615
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX(4), COMPLEX(8),
COMPLEX(16)
If the argument is a binary, octal, or hexadecimal constant, the result is affected by the assume old-boz
option. The default option setting, noold-boz, treats the argument as a bit string that represents a value of
the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is specified, the
argument is treated as a signed integer and the bits are converted.
Example
INT (-4.2) has the value -4.
INT (7.8) has the value 7.
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
NINT
AINT
ANINT
REAL
DBLE
SNGL
INTC
Portability Function: Converts an INTEGER(4)
argument to INTEGER(2) type.
Module
USE IFPORT
1616
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = INTC (i)
Results
The result type is INTEGER(2). The result is the value of i with type INTEGER(2). Overflow is ignored.
INT_PTR_KIND
Inquiry Intrinsic Function (Specific): Returns the
INTEGER KIND that will hold an address. This is a
specific function that has no generic function
associated with it. It cannot be passed as an actual
argument.
Syntax
result = INT_PTR_KIND( )
Results
The result type is default integer. The result is a scalar with the value equal to the value of the kind
parameter of the integer data type that can represent an address on the targeted platform.
The result value is 4 on IA-32 target architecture; 8 on Intel® 64 architecture.
Example
REAL A(100)
POINTER (P, A)
INTEGER (KIND=INT_PTR_KIND()) SAVE_P
P = MALLOC (400)
SAVE_P = P
INTEGER Statement
Statement: Specifies the INTEGER data type.
Syntax
INTEGER
INTEGER([KIND=] n)
INTEGER*n
n Is kind 1, 2, 4, or 8.
If a kind parameter is specified, the integer has the kind specified. If a kind parameter is not specified,
integer constants are interpreted as follows:
• If the integer constant is within the default integer kind range, the kind is default integer.
• If the integer constant is outside the default integer kind range, the kind of the integer constant is the
smallest integer kind which holds the constant.
The default kind can also be changed by using the INTEGER directive or compiler options specifying integer
size.
1617
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Entity-oriented declarations:
INTEGER, DIMENSION(:), POINTER :: days, hours
INTEGER (2) :: k=4
INTEGER (2), PARAMETER :: limit=12
! Attribute-oriented declarations:
INTEGER days, hours
INTEGER (2):: k=4, limit
DIMENSION days(:), hours(:)
POINTER days, hours
PARAMETER (limit=12)
See Also
INTEGER Directive
Integer Data Types
Integer Constants
INTEGER Directive
General Compiler Directive: Specifies the default
integer kind.
Syntax
!DIR$ INTEGER:{ 2 | 4 | 8 }
The INTEGER directive specifies a size of 2 (KIND=2), 4 (KIND=4), or 8 (KIND=8) bytes for default integer
numbers.
When the INTEGER directive is in effect, all default integer variables are of the kind specified. Only numbers
specified or implied as INTEGER without KIND are affected.
The INTEGER directive can only appear at the top of a program unit. A program unit is a main program, an
external subroutine or function, a module or a block data program unit. INTEGER cannot appear at the
beginning of internal subprograms. It does not affect modules invoked with the USE statement in the
program unit that contains it.
The default logical kind is the same as the default integer kind. So, when you change the default integer kind
you also change the default logical kind.
Example
INTEGER i ! a 4-byte integer
WRITE(*,*) KIND(i)
CALL INTEGER2( )
WRITE(*,*) KIND(i) ! still a 4-byte integer
! not affected by setting in subroutine
END
SUBROUTINE INTEGER2( )
!DIR$ INTEGER:2
INTEGER j ! a 2-byte integer
WRITE(*,*) KIND(j)
END SUBROUTINE
See Also
INTEGER
REAL Directive
General Compiler Directives
1618
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTENT
Statement and Attribute: Specifies the intended use
of one or more dummy arguments.
Syntax
The INTENT attribute can be specified in a type declaration statement or an INTENT statement, and takes
one of the following forms:
Type Declaration Statement:
type,[att-ls,] INTENT (intent-spec) [, att-ls] :: d-arg[, d-arg]...
Statement:
INTENT (intent-spec) [::] d-arg[, d-arg] ...
Description
The INTENT statement can only appear in the specification part of a subprogram or interface body.
If no INTENT attribute is specified for a dummy argument, its use is subject to the limitations of the
associated actual argument.
If a function specifies a defined operator, the dummy arguments must have intent IN.
1619
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a subroutine specifies defined assignment, the first argument must have intent OUT or INOUT, and the
second argument must have intent IN or the VALUE attribute, or both IN and the VALUE attribute.
An entity with the INTENT (OUT) attribute must not be an allocatable coarray or have a subobject that is an
allocatable coarray. It must not be of, or have a subcomponent of, type EVENT_TYPE or type LOCK_TYPE
from the ISO_FORTRAN_ENV module.
A non-pointer dummy argument with intent IN (or a subobject of such a dummy argument) must not appear
as any of the following:
• A DO variable
• The variable of an assignment statement
• The pointer-object of a pointer assignment statement
• An object or STAT variable in an ALLOCATE or DEALLOCATE statement
• An input item in a READ statement
• A variable name in a NAMELIST statement if the namelist group name appears in a NML specifier in a
READ statement
• An internal file unit in a WRITE statement
• A definable variable in an INQUIRE statement
• An IOSTAT or SIZE specifier in an I/O statement
• An actual argument in a reference to a procedure with an explicit interface if the associated dummy
argument has intent OUT or INOUT
INTENT on a pointer dummy argument refers to the pointer association status of the pointer and has no
effect on the value of the target of the pointer.
A pointer dummy argument with intent IN (or a subobject of such a pointer argument) must not appear as
any of the following:
• A pointer-object in a NULLIFY statement
• A pointer-object in a pointer assignment statement
• An object in an ALLOCATE or DEALLOCATE statement
• An actual argument in a reference to a procedure if the associated dummy argument is a pointer with the
INTENT(OUT) or INTENT(INOUT) attribute.
A pointer dummy argument with INTENT(IN) can be argument associated with a non-pointer actual
argument with the TARGET attribute. During the execution of the procedure, it is pointer associated with the
actual argument.
If an actual argument is an array section with a vector subscript, it cannot be associated with a dummy array
that is defined or redefined (has intent OUT or INOUT).
On entry to a routine, given an INTENT(OUT) dummy argument:
Example
The following example shows type declaration statements specifying the INTENT attribute:
SUBROUTINE TEST(I, J)
INTEGER, INTENT(IN) :: I
INTEGER, INTENT(OUT), DIMENSION(I) :: J
1620
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SUBROUTINE TEST(A, B, X)
INTENT(INOUT) :: A, B
...
SUBROUTINE CHANGE(FROM, TO)
USE EMPLOYEE_MODULE
TYPE(EMPLOYEE) FROM, TO
INTENT(IN) FROM
INTENT(OUT) TO
...
The following shows another example:
See Also
Argument Association
Type Declarations
ISO_FORTRAN_ENV
Compatible attributes
INTERFACE
Statement: Defines an explicit interface for an
external or dummy procedure. It can also be used to
define a generic name for procedures, a new operator
for functions, and a new form of assignment for
subroutines.
Syntax
INTERFACE [generic-spec]
[interface-body]...
[[MODULE]PROCEDURE [::]name-list]...
END INTERFACE [generic-spec]
1621
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
name-list Is the name of one or more nonintrinsic procedures that are accessible
in the host. The MODULE keyword is only allowed if the interface block
specifies a generic-spec and has a host that is a module, or
accesses a module by use association.
The characteristics of module procedures or internal procedures are
not given in interface blocks, but are assumed from the module
subprogram definitions or the USE associated interfaces.
Description
Interface blocks can appear in the specification part of the program unit that invokes the external or dummy
procedure.
A generic-spec can only appear in the END INTERFACE statement if one appears in the INTERFACE
statement; they must be identical.
The characteristics specified for the external or dummy procedure must be consistent with those specified in
the procedure's definition.
An interface block must not appear in a block data program unit.
An interface block comprises its own scoping unit, and does not inherit anything from its host through host
association.
Internal, module, and intrinsic procedures are all considered to have explicit interfaces. External procedures
have implicit interfaces by default; when you specify an interface block for them, their interface becomes
explicit. A procedure must not have more than one explicit interface in a given scoping unit. This means that
you cannot include internal, module, or intrinsic procedures in an interface block, unless you want to define a
generic name for them.
The function or subroutine named in the interface-body cannot have the same name as a keyword that
specifies an intrinsic type.
A interface block containing generic-spec specifies a generic interface for the following procedures:
• The procedures within the interface block
1622
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Any generic name, defined operator, or equals symbol that appears is a generic identifier for all the
procedures in the interface block. For the rules on how any two procedures with the same generic
identifier must differ, see Unambiguous Generic Procedure References.
• The module procedures listed in the MODULE PROCEDURE statement
The module procedures must be accessible by a USE statement.
To make an interface block available to multiple program units (through a USE statement), place the
interface block in a module.
The following rules apply to interface blocks containing pure procedures:
• The interface specification of a pure procedure must declare the INTENT of all dummy arguments except
pointer and procedure arguments.
• A procedure that is declared pure in its definition can also be declared pure in an interface block. However,
if it is not declared pure in its definition, it must not be declared pure in an interface block.
Example
The following example shows a simple procedure interface block with no generic specification:
See Also
ABSTRACT INTERFACE
CALL
PROCEDURE
FUNCTION
MODULE
SUBMODULE
MODULE PROCEDURE
SUBROUTINE
PURE
Procedure Interfaces
Procedures that Require Explicit Interfaces
Use and Host Association
1623
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTERFACE TO
Statement: Identifies a subprogram and its actual
arguments before it is referenced or called.
Syntax
INTERFACE TO subprogram-stmt
[formal-declarations]
END
The INTERFACE TO block defines an explicit interface, but it contains specifications for only the procedure
declared in the INTERFACE TO statement. The explicit interface is defined only in the program unit that
contains the INTERFACE TO statement.
The recommended method for defining explicit interfaces is to use an INTERFACE block.
Example
Consider that a C function that has the following prototype:
See Also
INTERFACE
INTEROP
OpenMP* Fortran Compiler Directive: Identifies a
foreign runtime context and identifies runtime
characteristics of that context, enabling
interoperability with it. This feature is only available
for ifx.
Syntax
!$OMP INTEROP clause[[[,] clause]... ]
1624
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• TARGET
Provides the following properties:
• device - the foreign device handle
• device_context - the foreign device context handle
• platform - the handle to the foreign platform of the device
• TARGETSYNC
Enables synchronization between foreign tasks executing in the
foreign execution context and OpenMP* tasks.
1625
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
OpenMP* may interoperate with one or more foreign runtime environments using the INTEROP directive, the
INTEROP clause on a DECLARE VARIANT directive, or the interoperability functions in the OpenMP* runtime
API.
A task has an interoperability requirement set, which is a logical set of properties. Properties can be added to
or removed from the set by different directives. The properties can be queried by other constructs that have
interoperability semantics. The following properties can be added by a construct:
• DEPEND - requires the construct enforce the synchronization relationship specified by the DEPEND clause
• IS_DEVICE_PTR (list-item) - indicates that the list-item is a device pointer within the construct
• NOWAIT - indicates that the construct is asynchronous
The DISPATCH directive can add properties to the interoperability requirement set.
The DECLARE VARIANT directive can remove properties from the interoperability requirement set.
If the interop-var is initialized with TARGETSYNC, an empty mergeable task is generated. DEPEND clauses
apply to the generated task. If NOWAIT is omitted, the generated task is also an included task. The INTEROP
construct guarantees ordered execution of the generated task with respect to foreign tasks executing in
foreign contexts through the foreign synchronization object accessible through the TARGETSYNC property of
the interop-var.
If a foreign task is created prior to encountering an INTEROP construct, the foreign task must complete
execution before the generated task executes. If the creation of a foreign task occurs after an INTEROP
construct is encountered, the foreign task cannot begin execution until the generated task finishes execution.
The INTEROP construct imposes no ordering between the thread that encounters it and foreign tasks or
OpenMP* tasks.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT directive
DISPATCH directive
INTRINSIC
Statement and Attribute: Allows the specific name
of an intrinsic procedure to be used as an actual
argument.
Syntax
The INTRINSIC attribute can be specified in a type declaration statement or an INTRINSIC statement, and
takes one of the following forms:
1626
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
In a type declaration statement, only functions can be declared INTRINSIC. However, you can use the
INTRINSIC statement to declare subroutines, as well as functions, to be intrinsic.
The name declared INTRINSIC is assumed to be the name of an intrinsic procedure. If a generic intrinsic
function name is given the INTRINSIC attribute, the name retains its generic properties.
Some specific intrinsic function names cannot be used as actual arguments. For more information, see table
Specific Functions Not Allowed as Actual Arguments in Intrinsic Procedures.
Example
The following example shows a type declaration statement specifying the INTRINSIC attribute:
PROGRAM EXAMPLE
...
REAL(8), INTRINSIC :: DACOS
...
CALL TEST(X, DACOS) ! Intrinsic function DACOS is an actual argument
The following example shows an INTRINSIC statement:
... RETURN
END
CALL TRIG(ANGLE,SIN,SINE)
CTN = COS(X)/SIN(X)
... END
CALL TRIG(ANGLE,CTN,COTANGENT)
Note that when TRIG is called with a second argument of SIN or COS, the function reference F(X) references
the Standard Fortran library functions SIN and COS; but when TRIG is called with a second argument of CTN,
F(X) references the user function CTN.
1627
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
References to Generic Procedures
Type Declarations
Compatible attributes
INUM
Elemental Intrinsic Function (Specific): Converts
a character string to an INTEGER(2) value. This
function cannot be passed as an actual argument.
Syntax
result = INUM (i)
Results
The result type is INTEGER(2). The result value is the INTEGER(2) value represented by the character string
i.
If the argument contains characters that are illegal in an integer value, an error is signaled and execution
stops.
Example
INUM ("451") has the value 451 of type INTEGER(2).
IOR
Elemental Intrinsic Function (Generic): Performs
an inclusive OR on corresponding bits. This function
can also be specified as OR.
Syntax
result = IOR (i,j)
Results
The result is the same as i if i is of type integer; otherwise, the result is the same as j. If either i or j is a
binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic function INT to type
integer with the kind type parameter of the other.
1628
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The result value is derived by combining i and j bit-by-bit according to the following truth table:
i j IOR (i, j)
1 1 1
1 0 1
0 1 1
0 0 0
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
IOR (1, 4) has the value 5.
IOR (1, 2) has the value 3.
The following shows another example:
INTEGER result
result = IOR(240, 90) ! returns 250
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
IAND
IEOR
NOT
IALL
IANY
IPARITY
IPARITY
Transformational Intrinsic Function (Generic):
Returns the result of a bitwise exclusive OR operation.
Syntax
result = IPARITY (array, dim [, mask])
result = IPARITY (array [, mask])
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
1629
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result has the same type and kind parameters as array. It is scalar if dim does not appear; otherwise,
the result has rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the shape of
array.
The result of IPARITY (array) has a value equal to the bitwise exclusive OR of all the elements of array. If
array has size zero, the result value is equal to zero.
The result of IPARITY (array, MASK=mask) has a value equal to IPARITY (PACK (array, mask)).
The result of IPARITY (array, DIM=dim [ , MASK=mask]) has a value equal to that of IPARITY (array [ ,
MASK=mask]) if array has rank one. Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1 , ..., sn) of the
result is equal to IPARITY (array (s1, s2, ..., sdim-1 , :, sdim+1 , ..., sn) [, MASK = mask (s1, s2, ..., sdim-1 , :,
sdim+1 , ..., sn)]).
Example
IPARITY ([14, 13, 8]) has the value 11. IPARITY ([14, 13, 8], MASK=[.true., .false., .true]) has the value 6.
See Also
IANY
IALL
IRAND, IRANDM
Portability Functions: Return random numbers in
the range 0 through (2**31)-1, or 0 through
(2**15)-1 if called without an argument.
Module
USE IFPORT
Syntax
result = IRAND ([iflag])
result = IRANDM ([iflag])
iflag (Input) INTEGER(4). Optional for IRAND. Controls the way the
returned random number is chosen. If iflag is omitted, it is assumed
to be 0, and the return range is 0 through (2**15)-1 (inclusive).
Results
The result type is INTEGER(4). If iflag is 1, the generator is restarted and the first random value is returned.
If iflag is 0, the next random number in the sequence is returned. If iflag is neither zero nor 1, it is used as a
new seed for the random number generator, and the functions return the first new random value.
IRAND and IRANDM are equivalent and return the same random numbers. Both functions are included to
ensure portability of existing code that references one or both of them.
You can use SRAND to restart the pseudorandom number generator used by these functions.
Example
USE IFPORT
INTEGER(4) istat, flag_value, r_nums(20)
flag_value=1
r_nums(1) = IRAND (flag_value)
flag_value=0
1630
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
do istat=2,20
r_nums(istat) = irand(flag_value)
end do
See Also
RANDOM_INIT
RANDOM_NUMBER
RANDOM_SEED
SRAND
IRANGET
Portability Subroutine: Returns the current seed.
Module
USE IFPORT
Syntax
CALL IRANGET (seed)
See Also
IRANSET
IRANSET
Portability Subroutine: Sets the seed for the
random number generator.
Module
USE IFPORT
Syntax
CALL IRANSET (seed)
See Also
IRANGET
IS_CONTIGUOUS
Inquiry Intrinsic Function (Generic): Tests the
contiguity of an array.
Syntax
result = IS_CONTIGUOUS (array)
Results
The result is default logical scalar. The result has the value .TRUE. if array is contiguous; otherwise, .FALSE..
1631
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
After the pointer assignment MY_P => TARGET (2:20:4), IS_CONTIGUOUS (MY_P) has the value .FALSE..
See Also
CONTIGUOUS
IS_DEVICE_PTR Clause
Parallel Directive Clause: Indicates that a list item
is a device pointer currently in the device data
environment and that it should be used directly.
Syntax
IS_DEVICE_PTR (list)
list Is a list of one or more variables that are of type C_PTR from the
intrinsic module ISO_C_BINDING, or that do not have the POINTER,
ALLOCATABLE, or VALUE attribute1. Each list item is a device pointer
currently in the device data environment and that it should be used
directly.
1 List items not of type C_PTR have been deprecated in the OpenMP* specification.
If a list item in a MAP clause is an array section, and the array section is derived from a variable with a
POINTER or ALLOCATABLE attribute, then the behavior is unspecified if the corresponding list item's variable
is modified in the region.
A list item may be a device address returned as the result of a call to the OpenMP* run-time library memory
management function omp_target_alloc function.
IS_IOSTAT_END
Elemental Intrinsic Function (Generic): Tests for
an end-of-file condition.
Syntax
result=IS_IOSTAT_END(i)
Results
The result type is default logical. The value of the result is true only if i is a value that could be assigned to
the scalar integer variable in an IOSTAT= specifier to indicate an end-of-file condition.
Example
INTEGER IO_STATUS
…
READ (20, IOSTAT=IO_STATUS) A, B, C
IF (IS_IOSTAT_END (IO_STATUS)) THEN
… ! process end of file
ENDIF
… ! process data read
IS_IOSTAT_EOR
Elemental Intrinsic Function (Generic): Tests for
an end-of-record condition.
1632
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result=IS_IOSTAT_EOR(i)
Results
The result type is default logical. The value of the result is true only if i is a value that could be assigned to
the scalar integer variable in an IOSTAT= specifier to indicate an end-of-record condition.
Example
INTEGER IO_STATUS
…
READ (30, ADVANCE='YES', IOSTAT=IO_STATUS) A, B, C
IF (IS_IOSTAT_EOR (IO_STATUS)) THEN
… ! process end of record
ENDIF
… ! process data read
ISATTY
Portability Function: Checks whether a logical unit
number is a terminal.
Module
USE IFPORT
Syntax
result = ISATTY (lunit)
Results
The result type is LOGICAL(4). The result is .TRUE. if the specified logical unit is connected to a terminal
device; otherwise, .FALSE..
If lunit is out of range or is not connected, zero is returned.
ISHA
Elemental Intrinsic Function (Generic):
Arithmetically shifts an integer left or right by a
specified number of bits.
Syntax
result = ISHA (i,shift)
shift (Input) Must be of type integer. This argument is the direction and
distance of shift.
1633
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Positive shifts are left (toward the most significant bit); negative shifts
are right (toward the least significant bit).
Results
The result type and kind are the same as i. The result is equal to i shifted arithmetically by shift bits.
If shift is positive, the shift is to the left; if shift is negative, the shift is to the right. If shift is zero, no shift is
performed.
Bits shifted out from the left or from the right, as appropriate, are lost. If the shift is to the left, zeros are
shifted in on the right. If the shift is to the right, copies of the sign bit (0 for non-negative i; 1 for negative i)
are shifted in on the left.
The kind of integer is important in arithmetic shifting because sign varies among integer representations (see
the following example). If you want to shift a one-byte or two-byte argument, you must declare it as
INTEGER(1) or INTEGER(2).
Example
INTEGER(1) i, res1
INTEGER(2) j, res2
i = -128 ! equal to 10000000
j = -32768 ! equal to 10000000 00000000
res1 = ISHA (i, -4) ! returns 11111000 = -8
res2 = ISHA (j, -4) ! returns 11111000 10100000 = -2048
See Also
ISHC
ISHL
ISHFT
ISHFTC
ISHC
Elemental Intrinsic Function (Generic): Rotates
an integer left or right by specified number of bits.
Bits shifted out one end are shifted in the other end.
No bits are lost.
Syntax
result = ISHC (i,shift)
shift (Input) Must be of type integer. This argument is the direction and
distance of rotation.
Positive rotations are left (toward the most significant bit); negative
rotations are right (toward the least significant bit).
Results
The result type and kind are the same as i. The result is equal to i circularly rotated by shift bits.
If shift is positive, i is rotated left shift bits. If shift is negative, i is rotated right shift bits. Bits shifted out one
end are shifted in the other. No bits are lost.
The kind of integer is important in circular shifting. With an INTEGER(4) argument, all 32 bits are shifted. If
you want to rotate a one-byte or two-byte argument, you must declare it as INTEGER(1) or INTEGER(2).
1634
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHC (i, -3) ! returns 01000001 = 65
res2 = ISHC (j, -3) ! returns 01000000 00000001 =
! 16385
See Also
ISHA
ISHL
ISHFT
ISHFTC
ISHFT
Elemental Intrinsic Function (Generic): Performs
a logical shift.
Syntax
result = ISHFT (i,shift)
shift (Input) Must be of type integer. The absolute value for shift must be
less than or equal to BIT_SIZE( i).
Results
The result type and kind are the same as i. The result has the value obtained by shifting the bits of i by shift
positions. If shift is positive, the shift is to the left; if shift is negative, the shift is to the right. If shift is zero,
no shift is performed.
Bits shifted out from the left or from the right, as appropriate, are lost. Zeros are shifted in from the opposite
end.
ISHFT with a positive shift can also be specified as LSHIFT (or LSHFT). ISHFT with a negative shift can also
be specified as RSHIFT (or RSHFT) with | shift |.
For more information on bit functions, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
ISHFT (2, 1) has the value 4.
ISHFT (2, -1) has the value 1.
1635
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(1) i, res1
INTEGER(2) j, k(3), res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHFT (i, 5) ! returns 01000000 = 64
res2 = ISHFT (j, 5) ! returns 00000001 01000000 =
! 320
k = ISHFT((/3, 5, 1/), (/1, -1, 0/)) ! returns array
! /6, 2, 1/
See Also
BIT_SIZE
ISHFTC
ISHA
ISHC
ISHFTC
Elemental Intrinsic Function (Generic): Performs
a circular shift of the rightmost bits.
Syntax
result = ISHFTC (i,shift[,size])
shift (Input) Must be of type integer. The absolute value of shift must be
less than or equal to size.
Results
The result type and kind are the same as i. The result value is obtained by circular shifting the size rightmost
bits of i by shift positions. If shift is positive, the shift is to the left; if shift is negative, the shift is to the
right. If shift is zero, no shift is performed.
No bits are lost. Bits in i beyond the value specified by size are unaffected.
For more information on bit functions, see Bit Functions.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
ISHFTC (4, 2, 4) has the value 1.
1636
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHFTC (i, 2, 3) ! rotates the 3 rightmost
! bits by 2 (left) and
! returns 00001001 = 9
res1 = ISHFTC (i, -2, 3) ! rotates the 3 rightmost
! bits by -2 (right) and
! returns 00001100 = 12
res2 = ISHFTC (j, 2, 3) ! rotates the 3 rightmost
! bits by 2 and returns
! 00000000 00001001 = 9
See Also
BIT_SIZE
ISHFT
MVBITS
ISHL
Elemental Intrinsic Function (Generic): Logically
shifts an integer left or right by the specified bits.
Zeros are shifted in from the opposite end.
Syntax
result = ISHL (i,shift)
shift (Input) Must be of type integer. This argument is the direction and
distance of shift.
If positive, i is shifted left (toward the most significant bit). If
negative, i is shifted right (toward the least significant bit).
Results
The result type and kind are the same as i. The result is equal to i logically shifted by shift bits. Zeros are
shifted in from the opposite end.
Unlike circular or arithmetic shifts, which can shift ones into the number being shifted, logical shifts shift in
zeros only, regardless of the direction or size of the shift. The integer kind, however, still determines the end
that bits are shifted out of, which can make a difference in the result (see the following example).
Example
INTEGER(1) i, res1
INTEGER(2) j, res2
i = 10 ! equal to 00001010
j = 10 ! equal to 00000000 00001010
res1 = ISHL (i, 5) ! returns 01000000 = 64
res2 = ISHL (j, 5) ! returns 00000001 01000000 = 320
See Also
ISHA
1637
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ISHC
ISHFT
ISHFTC
ISNAN
Elemental Intrinsic Function (Generic): Tests
whether IEEE* real (binary32, binary64, and
binary128) numbers are Not-a-Number (NaN) values.
Syntax
result = ISNAN (x)
Results
The result type is default logical. The result is .TRUE. if x is an IEEE NaN; otherwise, the result is .FALSE..
Example
LOGICAL A
DOUBLE PRECISION B
...
A = ISNAN(B)
A is assigned the value .TRUE. if B is an IEEE NaN; otherwise, the value assigned is .FALSE..
ITIME
Portability Subroutine: Returns the time in numeric
form.
Module
USE IFPORT
Syntax
CALL ITIME (array)
array (Output) INTEGER(4). A rank one array with three elements used to
store numeric time data:
• array(1) - the hour
• array(2) - the minute
• array(3) - the second
Example
USE IFPORT
INTEGER(4) time_array(3)
CALL ITIME (time_array)
write(*,10) time_array
10 format (1X,I2,':',I2,':',I2)
END
See Also
DATE_AND_TIME
1638
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IVDEP
General Compiler Directive: Assists the compiler's
dependence analysis of iterative DO loops.
Syntax
!DIR$ IVDEP [: option]
The IVDEP directive is an assertion to the compiler's optimizer about the order of memory references inside a
DO loop.
IVDEP:LOOP implies no loop-carried dependencies. IVDEP:BACK implies no backward dependencies.
When no option is specified, the following occurs:
• The compiler begins dependence analysis by assuming all dependences occur in the same forward
direction as their appearance in the normal scalar execution order. This contrasts with normal compiler
behavior, which is for the dependence analysis to make no initial assumptions about the direction of a
dependence.
!DIR$ IVDEP with no option can also be spelled !DIR$ INIT_DEP_FWD (INITialize DEPendences ForWarD).
The IVDEP directive is applied to a DO loop in which the user knows that dependences are in lexical order.
For example, if two memory references in the loop touch the same memory location and one of them
modifies the memory location, then the first reference to touch the location has to be the one that appears
earlier lexically in the program source code. This assumes that the right-hand side of an assignment
statement is "earlier" than the left-hand side.
The IVDEP directive informs the compiler that the program would behave correctly if the statements were
executed in certain orders other than the sequential execution order, such as executing the first statement or
block to completion for all iterations, then the next statement or block for all iterations, and so forth. The
optimizer can use this information, along with whatever else it can prove about the dependences, to choose
other execution orders.
Example
In the following example, the IVDEP directive provides more information about the dependences within the
loop, which may enable loop transformations to occur:
!DIR$ IVDEP
DO I=1, N
A(INDARR(I)) = A(INDARR(I)) + B(I)
END DO
In this case, the scalar execution order follows:
1. Retrieve INDARR(I).
2. Use the result from step 1 to retrieve A(INDARR(I)).
3. Retrieve B(I).
4. Add the results from steps 2 and 3.
5. Store the results from step 4 into the location indicated by A(INDARR(I)) from step 1.
IVDEP directs the compiler to initially assume that when steps 1 and 5 access a common memory location,
step 1 always accesses the location first because step 1 occurs earlier in the execution sequence. This
approach lets the compiler reorder instructions, as long as it chooses an instruction schedule that maintains
the relative order of the array references.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
1639
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
J to L
This section describes language features that start with J, K, or L.
J to L
JABS
Portability Function: Returns an absolute value.
Module
USE IFPORT
Syntax
result = JABS (i)
Results
The result type is INTEGER(4). The value of the result is | i |.
JDATE
Portability Function: Returns an 8-character string
with the Julian date in the form "yyddd". Three spaces
terminate this string.
Module
USE IFPORT
Syntax
result = JDATE( )
Results
The result type is character with length 8. The result is the Julian date, in the form YYDDD, followed by three
spaces.
The Julian date is a five-digit number whose first two digits are the last two digits of the year, and whose
final three digits represent the day of the year (1 for January 1, 366 for December 31 of a leap year, and so
on). For example, the Julian date for February 1, 1999 is 99032.
Caution
The two-digit year return value may cause problems with the year 2000. Use
DATE_AND_TIME instead.
Example
! Sets julian to today's julian date
USE IFPORT
CHARACTER*8 julian
julian = JDATE( )
1640
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
DATE_AND_TIME
JDATE4
Portability Function: Returns a 10-character string
with the Julian date in the form "yyyyddd". Three
spaces terminate this string.
Module
USE IFPORT
Syntax
result = JDATE4( )
Results
The result type is character with length 10. The result is the Julian date, in the form YYYYDDD, followed by
three spaces.
The Julian date is a seven-digit number whose first four digits are the year, and whose final three represent
the day of the year (1 for January 1, 366 for December 31 of a leap year, and so on). For example, the Julian
date for February 1, 1999 is 1999032.
See Also
DATE_AND_TIME
JNUM
Elemental Intrinsic Function (Specific): Converts
a character string to an INTEGER(4) value. This
function cannot be passed as an actual argument.
Syntax
result = JNUM (i)
Results
The result type is INTEGER(4). The result value is the integer value represented by the character string i.
If the argument contains characters that are illegal in an integer value, an error is signaled and execution
stops.
Example
JNUM ("46616") has the value 46616 of type INTEGER(4).
KILL
Portability Function: Sends a signal to the process
given by ID.
Module
USE IFPORT
Syntax
result = KILL (pid,signum)
1641
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
signum (Input) INTEGER(4). A signal value. For the definition of signal values,
see the SIGNALfunction.
Results
The result type is INTEGER(4). The result is zero if the call was successful; otherwise, an error code. Possible
error codes are:
• EINVAL: The signum is not a valid signal number, or PID is not the same as getpid( ) and signum does not
equal SIGKILL.
• ESRCH: The given PID could not be found.
• EPERM: The current process does not have permission to send a signal to the process given by PID.
On Windows* systems, arbitrary signals can be sent only to the calling process (where pid= getpid( )). Other
processes can send only the SIGKILL signal ( signum= 9), and only if the calling process has permission.
Example
USE IFPORT
integer(4) id_number, sig_val, istat
id_number=getpid( )
ISTAT = KILL (id_number, sig_val)
See Also
SIGNAL
RAISEQQ
SIGNALQQ
KIND
Inquiry Intrinsic Function (Generic): Returns the
kind parameter of the argument.
Syntax
result = KIND (x)
Results
The result is a scalar of type default integer. The result has a value equal to the kind type parameter value of
x.
Example
KIND (0.0) has the kind value of default real type.
KIND (12) has the kind value of default integer type.
The following shows another example:
1642
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SELECTED_INT_KIND
SELECTED_REAL_KIND
CMPLX
INT
REAL
LOGICAL
CHAR
Intrinsic Data Types
Argument Keywords in Intrinsic Procedures
KNUM
Elemental Intrinsic Function (Specific): Converts
a character string to an INTEGER(8) value.
Syntax
result = KNUM (i)
Results
The result type is INTEGER(8). The result value is the integer value represented by the character string i.
If the argument contains characters that are illegal in an integer value, an error is signaled and execution
stops.
Example
KNUM ("46616") has the value 46616 of type INTEGER(8).
LASTPRIVATE
Parallel Directive Clause: Provides a superset of the
functionality provided by the PRIVATE clause. It
declares one or more variables to be private to an
implicit task, and causes the corresponding original
variable to be updated after the end of the region.
Syntax
LASTPRIVATE ([CONDITIONAL:] list)
CONDITIONAL Is an optional modifier specifying that the last value assigned to a list
item can be from the sequentially last iteration of the associated loops
or the lexically last section construct.
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
1643
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Variables that appear in a LASTPRIVATE list are subject to PRIVATE clause semantics. In addition, once the
parallel region is exited, each variable has the value provided by the sequentially last section or loop
iteration.
Multiple LASTPRIVATE clauses are allowed on all of the directives that accept them. A list item may not
appear in more than one LASTPRIVATE clause. LASTPRIVATE (CONDITIONAL:A,B) is equivalent to
LASTPRIVATE(CONDITIONAL:A) LASTPRIVATE(CONDITIONAL:B).
LASTPRIVATE (CONDITIONAL:list) can appear in the following directives:
• OMP DISTRIBUTE
• OMP DO
• OMP SECTIONS
• OMP SIMD
• OMP TASKLOOP
• Any and all of the combination directives of the above directives
The OMP PARALLEL directive does not allow the LASTPRIVATE clause.
If the original variable has the POINTER attribute, its update occurs as if by pointer assignment.
If the original variable does not have the POINTER attribute, its update occurs as if by intrinsic assignment.
When a LASTPRIVATE clause without the CONDITIONAL modifier appears in a worksharing or a SIMD
directive, the value of each new list item from the sequentially last iteration of the associated loops, or the
lexically last section, is assigned to the original list item.
When the CONDITIONAL modifier is specified, the final value written by the sequentially last iteration or
lexically last section that writes to a list item, if any, is assigned to the original list item.
When the CONDITIONAL modifier is not specified, list items that are not assigned a value by the sequentially
last iteration of the loops, or by the lexically last section, have unspecified values after the construct.
Therefore, variables specified in the list of a LASTPRIVATE clause that contains a CONDITIONAL modifier
should be variables that are conditionally assigned to in the loop/region/sections. The variables in the list of a
LASTPRIVATE clause that does not contain a CONDITIONAL modifier should be variables that are
unconditionally assigned to in the loop or sections.
Subobjects that are not assigned a value by the last iteration of the DO or the lexically last SECTION of the
SECTIONS directive are undefined after the construct.
The original variable becomes defined at the end of the construct if there is an implicit barrier at that point.
To avoid race conditions, concurrent reads or updates of the original variable must be synchronized with the
update of the original variable that occurs as a result of the LASTPRIVATE clause.
If the LASTPRIVATE clause is used in a construct for which NOWAIT is specified, accesses to the original
variable may create a data race. To avoid this, synchronization must be inserted to ensure that the
sequentially last iteration or lexically last section construct has stored and flushed that variable.
The following are restrictions for the LASTPRIVATE clause:
• A variable that is part of another variable (as an array or structure element) must not appear in a
PRIVATE clause.
• A variable that is private within a parallel region, or that appears in the REDUCTION clause of a PARALLEL
construct, must not appear in a LASTPRIVATE clause on a worksharing construct if any of the
corresponding worksharing regions ever binds to any of the corresponding parallel regions.
• A variable that appears in a LASTPRIVATE clause must be definable.
1644
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• An original variable with the ALLOCATABLE attribute must be in the allocated state at entry to the
construct containing the LASTPRIVATE clause. The variable in the sequentially last iteration or lexically last
section must be in the allocated state upon exit from that iteration or section with the same bounds as the
corresponding original variable.
• Assumed-size arrays must not appear in a PRIVATE clause.
• Variables that appear in NAMELIST statements, in variable format expressions, and in expressions for
statement function definitions, must not appear in a PRIVATE clause.
• If a list item appears in both the FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all of the initializations for FIRSTPRIVATE.
NOTE
If a variable appears in both FIRSTPRIVATE and LASTPRIVATE clauses, the update required for
LASTPRIVATE occurs after all initializations for FIRSTPRIVATE.
NOTE
If a variable appears in a LASTPRIVATE clause on a combined construct for which the first construct is
TARGET, it is treated as if it had appeared in a MAP clause with a map-type of FROM.
Example
Consider the following:
P = 0
!$OMP DO PRIVATE(I), FIRSTPRIVATE(P), LASTPRIVATE(CONDITIONAL:P)
DO I = 1, 1000
IF (A(I) .EQ. B) THEN
P = I
EXIT
END IF
ENDDO
!$OMP END DO
1645
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
After the loop, P will be the index of the first element of A to match B; if no match is found, P will be zero.
See Also
PRIVATE Clause
FIRSTPRIVATE clause
LBOUND
Inquiry Intrinsic Function (Generic): Returns the
lower bounds for all dimensions of an array, or the
lower bound for a specified dimension.
Syntax
result = LBOUND (array [, dim] [, kind])
dim (Input; optional) Must be a scalar integer with a value in the range 1
to n, where n is the rank array.
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
If dim is present, the result is a scalar. Otherwise, the result is a rank-one array with one element for each
dimension of array. Each element in the result corresponds to a dimension of array.
If array is an array section or an array expression that is not a whole array or array structure component,
each element of the result has the value 1.
If array is a whole array or array structure component, LBOUND ( array, dim) has a value equal to the lower
bound for subscript dim of array(if dim is nonzero or array is an assumed-size array of rank dim). Otherwise,
the corresponding element of the result has the value 1.
If LBOUND is invoked for an assumed-rank object that is associated with a scalar and dim is absent, the
result is a zero-sized array. LBOUND cannot be invoked for an assumed-rank object that is associated with a
scalar if dim is present because the rank of a scalar is zero and dim must be >= 1.
The setting of compiler options specifying integer size can affect this function.
Example
Consider the following:
1646
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
UBOUND
LCOBOUND
Inquiry Intrinsic Function (Generic): Returns the
lower cobounds of a coarray.
Syntax
result = LCOBOUND (coarray [,dim [, kind])
dim (Input; optional) Must be an integer scalar with a value in the range 1
<= dim <= n, where n is the corank of coarray. The corresponding
actual argument must not be an optional dummy argument.
Results
The result type is integer. If kind is present, the kind parameter is that specified by kind; otherwise, the kind
parameter is that of default integer type. The result is scalar if dim is present; otherwise, the result is an
array of rank one and size n, wheren is the corank of coarray.
The result depends on whether dim is specified:
• If dim is specified, LCOBOUND (COARRAY, DIM) has a value equal to the lower cobound for cosubscript
dim of coarray.
• If dim is not specified, LCOBOUND (COARRAY) has a value whose ith element is equal to LCOBOUND
(COARRAY, i), for i = 1, 2,. . . , n, where n is the corank of coarray.
Example
If B is allocated by the statement ALLOCATE (B [2:3, 8:*]), then LCOBOUND (B) is [2, 8] and LCOBOUND (B,
DIM=2) is 8.
LCWRQQ
Portability Subroutine: Sets the value of the
floating-point processor control word.
Module
USE IFPORT
Syntax
CALL LCWRQQ (controlword)
LCWRQQ performs the same function as the run-time subroutine SETCONTROLFPQQ and is provided for
compatibility.
1647
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
INTEGER(2) control
CALL SCWRQQ(control) ! get control word
! Set control word to make processor round up
control = control .AND. (.NOT. FPCW$MCW_RC) ! Clear
! control word with inverse
! of rounding control mask
control = control .OR. FPCW$UP ! Set control word
! to round up
CALL LCWRQQ(control)
WRITE (*, 9000) 'Control word: ', control
9000 FORMAT (1X, A, Z4)
END
See Also
SETCONTROLFPQQ
LEADZ
Elemental Intrinsic Function (Specific): Returns
the number of leading zero bits in an integer.
Syntax
result = LEADZ (i)
Results
The result type is default integer. The result value is the number of leading zeros in the binary representation
of the integer i.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
Consider the following:
INTEGER*8 J, TWO
PARAMETER (TWO=2)
DO J= -1, 40
TYPE *, LEADZ(TWO**J) ! Prints 64 down to 23 (leading zeros)
ENDDO
END
LEN
Inquiry Intrinsic Function (Generic): Returns the
length of a character expression.
Syntax
result = LEN (string [, kind])
string (Input) Must be of type character; it can be scalar or array valued. (It
can be an array of strings.)
1648
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The result has a value equal to the number of characters in string(if it is scalar) or in an element of string(if
it is array valued).
CHARACTER INTEGER(8)
1The setting of compiler options specifying integer size can affect this function.
Example
Consider the following example:
CHARACTER(11) STR(100)
INTEGER I
I = LEN (STR) ! returns 11
I = LEN('A phrase with 5 trailing blanks.^^^^^')
! returns 37
See Also
LEN_TRIM
Declaration Statements for Character Types
Character Data Type
LEN_TRIM
Elemental Intrinsic Function (Generic): Returns
the length of the character argument without counting
trailing blank characters.
Syntax
result = LEN_TRIM (string [, kind])
Results
The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The result has a value equal to the number of characters remaining after any trailing blanks in string are
removed. If the argument contains only blank characters, the result is zero.
The setting of compiler options specifying integer size can affect this function.
1649
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
LEN_TRIM (' C D ') has the value 4.
LEN_TRIM (' ') has the value 0.
The following shows another example:
INTEGER LEN1
LEN1 = LEN_TRIM (' GOOD DAY ') ! returns 9
LEN1 = LEN_TRIM (' ') ! returns 0
See Also
LEN
LNBLNK
LGE
Elemental Intrinsic Function (Generic):
Determines if a string is lexically greater than or equal
to another string, based on the ASCII collating
sequence, even if the processor's default collating
sequence is different. In Intel® Fortran, LGE is
equivalent to the (.GE.) operator.
Syntax
result = LGE (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if the strings are equal, both strings are of zero length, or if string_a follows string_b in the
ASCII collating sequence; otherwise, the result is false.
Example
LGE ( 'ONE', 'SIX' ) has the value false.
LGE ( 'TWO', 'THREE' ) has the value true.
The following shows another example:
LOGICAL L
L = LGE('ABC','ABD') ! returns .FALSE.
L = LGE ('AB', 'AAAAAAAB') ! returns .TRUE.
See Also
LGT
LLE
1650
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LLT
ASCII and Key Code Charts
LGT
Elemental Intrinsic Function (Generic):
Determines whether a string is lexically greater than
another string, based on the ASCII collating sequence,
even if the processor's default collating sequence is
different. In Intel® Fortran, LGT is equivalent to the >
(.GT.) operator.
Syntax
result = LGT (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if string_a follows string_b in the ASCII collating sequence; otherwise, the result is false. If
both strings are of zero length, the result is also false.
Example
LGT ( 'TWO', 'THREE' ) has the value true.
LGT ( 'ONE', 'FOUR' ) has the value true.
The following shows another example:
LOGICAL L
L = LGT('ABC', 'ABC') ! returns .FALSE.
L = LGT('ABC', 'AABC') ! returns .TRUE.
See Also
LGE
LLE
LLT
ASCII and Key Code Charts
LINEAR Clause
Parallel Directive Clause: Specifies that all variables
in a list are private to a SIMD lane and that they have
a linear relationship within the iteration space of a
loop.
Syntax
It takes one of the following forms:
1651
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• list
• modifier (list)
• REF
Specifies that the storage location of each list item on each lane
corresponds to an array at the storage location upon entry to the
function indexed by the logical number of the lane times linear-
step.
The referenced values passed into the routine (which forms a
vector for calculations) are located sequentially, like in an array,
with the distance between elements equal to step.
This modifier can be used only for dummy arguments passed by
reference.
• VAL
Specifies that the value of each list item on each lane corresponds
to the value of the list item upon entry to the function plus the
logical number of the lane times linear-step.
On each iteration of the loop from which the routine is called, the
value of the parameter can be calculated as
(value_on_previous_iteration + step).
• UVAL
Similar to VAL but each invocation uses the same storage location
for each SIMD lane. This storage location is updated with the final
value of the logically last lane. It differs from VAL as follows:
1652
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If more than one linear-step is specified for a var, a compile-time error occurs. Multiple LINEAR clauses can
be used to specify different values for linear-step. The linear-step expression must be invariant (must not be
changed) during the execution of the associated construct. Multiple LINEAR clauses are merged as a union.
The value corresponding to the sequentially last iteration of the associated loops is assigned to the original
list item.
A list item in a LINEAR clause cannot appear in any other data scope attribute clause, in another LINEAR
clause, or more than once in list. For a list of data scope attribute clauses, see the first table in Clauses Used
in Multiple OpenMP* Fortran Directives.
In the sequentially last iteration, any list item with the ALLOCATABLE attribute must have an allocation status
of allocated upon exit from that iteration.
If a list item is a dummy argument without the Fortran Standard VALUE attribute and the REF modifier is not
specified, then a read of the list item must be executed before any writes to the list item.
If a LINEAR clause appears in a directive that also contains a REDUCTION clause with the INSCAN modifier,
only a loop iteration variable of a loop associated with the construct can appear as a list item in the LINEAR
clause.
The following cannot appear in a LINEAR clause:
• Variables that have the POINTER attribute
• Cray* pointers
The LINEAR (REF) clause is very important because Fortran passes dummy arguments by reference. By
default, the compiler places consecutive addresses in a vector register, which leads to an inefficient gather of
the addresses.
In the following example, LINEAR (REF (X)) tells the compiler that the 4 addresses for the dummy argument
X are consecutive, so the code only needs to dereference X once and then copy consecutive values to a
vector register.
subroutine test_linear(x, y)
!$omp declare simd (test_linear) linear(ref(x, y)) ! arguments by reference
real(8),intent(in) :: x
real(8),intent(out) :: y
y = 1. + sin(x)**3
end subroutine test_linear
… ! procedure that calls test_linear
interface ! test_linear needs an explicit interface
…
do j = 1,n
call test_linear(a(j), b(j)) ! loop vectorized via qopenmp-simd
enddo
…
1653
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
! universal but slowest definition; it matches the use of func in loops 1, 2, and 3:
!$OMP DECLARE SIMD
!
! matches the use of func in loop 1:
!$OMP DECLARE SIMD LINEAR(in1) LINEAR(REF(in2)) UNIFORM(mul)
!
! matches the use of func in loops 2 and 3:
!$OMP DECLARE SIMD LINEAR(REF(in2))
!
! matches the use of func in loop 2:
!$OMP DECLARE SIMD LINEAR(REF(in2)) LINEAR(mul)
!
! matches the use of func in loop 3:
!$OMP DECLARE SIMD LINEAR(VAL(in2:2))
!loop 1
!$OMP SIMD
DO i=1,100
c(i) = func(a + i, b(i), mul) ! the value of the 1st parameter is changed linearly,
! the 2nd parameter reference is changed linearly,
! the 3rd parameter is not changed
END DO
!loop 2
!$OMP SIMD
DO i=1,100
c(i) = func(b(ndx(i)), b(i), i + 1 ! the value of the 1st parameter is unpredictable,
! the 2nd reference is changed linearly,
! the 3rd parameter is changed linearly
END DO
!loop 3
!$OMP SIMD
DO i=1,100
k = i * 2 ! during vectorization, private variables are
c(i) = func(b(ndx(i)), k, b(i)) ! transformed into arrays: k -> k_vec(simdlen)
! the value of the 1st parameter is unpredictable,
! for the 2nd parameter both value and reference
! to its location can be considered linear,
! the value for the 3rd parameter is unpredictable
!
! the !$OMP DECLARE SIMD LINEAR(VAL(in2:2))) will
END DO ! be chosen from the two matching variants)
1654
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
VALUE statement and attribute
SIMD Directive (OpenMP* API)
DECLARE SIMD
LLE
Elemental Intrinsic Function (Generic):
Determines whether a string is lexically less than or
equal to another string, based on the ASCII collating
sequence, even if the processor's default collating
sequence is different. In Intel® Fortran, LLE is
equivalent to the (.LE.) operator.
Syntax
result = LLE (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if the strings are equal, both strings are of zero length, or if string_a precedes string_b in
the ASCII collating sequence; otherwise, the result is false.
Example
LLE ( 'TWO', 'THREE' ) has the value false.
LLE ( 'ONE', 'FOUR' ) has the value false.
The following shows another example:
LOGICAL L
L = LLE('ABC', 'ABC') ! returns .TRUE.
L = LLE('ABC', 'AABCD') ! returns .FALSE.
See Also
LGE
LGT
LLT
ASCII and Key Code Charts
LLT
Elemental Intrinsic Function (Generic):
Determines whether a string is lexically less than
another string, based on the ASCII collating sequence,
1655
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = LLT (string_a,string_b)
Results
The result type is default logical. If the strings are of unequal length, the comparison is made as if the
shorter string were extended on the right with blanks, to the length of the longer string.
The result is true if string_a precedes string_b in the ASCII collating sequence; otherwise, the result is false.
If both strings are of zero length, the result is also false.
Example
LLT ( 'ONE', 'SIX' ) has the value true.
LLT ( 'ONE', 'FOUR' ) has the value false.
The following shows another example:
LOGICAL L
L = LLT ('ABC', 'ABC') ! returns .FALSE.
L = LLT ('AAXYZ', 'ABCDE') ! returns .TRUE.
See Also
LGE
LGT
LLE
ASCII and Key Code Charts
LNBLNK
Portability Function: Locates the position of the last
nonblank character in a string.
Module
USE IFPORT
Syntax
result = LNBLNK (string)
Results
The result type is INTEGER(4). The result is the index of the last nonblank character in string.
1656
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LNBLNK is very similar to the intrinsic function LEN_TRIM, except that string cannot be an array.
Example
USE IFPORT
integer(4) p
p = LNBLNK(' GOOD DAY ') ! returns 9
p = LNBLNK(' ') ! returns 0
See Also
LEN_TRIM
LOC
Inquiry Intrinsic Function (Generic): Returns the
internal address of a storage item. This function
cannot be passed as an actual argument.
Syntax
result = LOC (x)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the
result represents the address of the data object or, in the case of pointers, the address of its associated
target. If the argument is not valid, the result is undefined.
This function performs the same function as the %LOC built-in function.
Example
The Fortran standard provides the C_LOC intrinsic module function as an alternative to the non-standard
LOC. For more information, see the descriptions of C_LOC, C_FUNLOC, C_F_POINTER and
C_F_PROCPOINTER.
%LOC
Built-in Function: Computes the internal address of
a storage item.
Syntax
result = %LOC (a)
1657
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The value of the
result represents the address of the data object or, in the case of pointers, the address of its associated
target. If the argument is not valid, the result is undefined.
This function performs the same function as the LOC intrinsic function.
Syntax
LOCK (lock-var [, ACQUIRED_LOCK=log-var] [, STAT=stat-var] [, ERRMSG=err-var])
UNLOCK (lock-var [, STAT=stat-var] [, ERRMSG=err-var])
ACQUIRED_LOCK=, STAT=, and ERRMSG= can appear in any order, but only once in a LOCK statement.
STAT= and ERRMSG= can appear in either order, but only once in an UNLOCK statement.
Description
A lock variable is unlocked if its value is equal to that of the structure constructor LOCK_TYPE ( ). If it has
any other value, it is locked.
A lock variable is locked by an image if it was locked by execution of a LOCK statement on that image and
has not been subsequently unlocked by execution of an UNLOCK statement on the same image.
When a LOCK statement is specified without an ACQUIRED_LOCK= specifier, it causes the lock variable to
become locked by that image. If the lock variable is already locked by another image, that LOCK statement
causes the lock variable to become defined after the other image causes the lock variable to become
unlocked.
If the lock variable is unlocked, successful execution of a LOCK statement with an ACQUIRED LOCK=
specifier causes the lock variable to become locked by that image and the log-var to become defined with the
value TRUE. If the lock variable is already locked by a different image, successful execution of a LOCK
statement with an ACQUIRED LOCK= specifier leaves the lock variable unchanged and causes the log-var to
become defined with the value FALSE.
During the execution of the program, the value of a lock variable changes through a sequence of locked and
unlocked states when LOCK and UNLOCK statements are executed. If a lock variable becomes unlocked by
execution of an UNLOCK statement on image M and next becomes locked by execution of a LOCK statement
1658
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
on image T, the segments preceding the UNLOCK statement on image M precede the segments following the
LOCK statement on image T. Execution of a LOCK statement that does not cause the lock variable to become
locked does not affect segment ordering.
An error condition occurs in the following cases:
• If the lock variable in a LOCK statement is already locked by the executing image
• If the lock variable in an UNLOCK statement is not already locked by the executing image
If an error condition occurs during execution of a LOCK or UNLOCK statement, the value of the lock variable
is not changed and the value of the ACQUIRED_LOCK variable, if any, is not changed.
Example
The following example shows the use of LOCK and UNLOCK statements to manage a work queue:
TYPE(Task) :: current_task
INTEGER :: my_image
my_image = THIS_IMAGE()
DO
! Process the next task in the work queue
LOCK (work_queue_lock) ! Start of new segment A
! Segment A is ordered with respect to segment B
! executed by image my_image-1 below because of lock exclusion
IF (work_queue_size>0) THEN
! Get the next job from the queue
current_task = work_queue(work_queue_size)
work_queue_size = work_queue_size-1
END IF
UNLOCK (work_queue_lock) ! Segment ends
...
! Process the task
See Also
Image Control Statements
Coarrays
Using Coarrays
1659
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOG
Elemental Intrinsic Function (Generic): Returns
the natural logarithm of the argument.
Syntax
result = LOG (x)
Results
The result type and kind are the same as x. The result value is approximately equal to logex.
If the arguments are complex, the result is the principal value with imaginary part omega in the range -pi <=
omega <= pi.
If the real part of x < 0 and the imaginary part of x is a positive real zero, the imaginary part of the result is
pi.
If the real part of x < 0 and the imaginary part of x is a negative real zero, the imaginary part of the result is
-pi.
Example
LOG (8.0) has the value 2.079442.
LOG (25.0) has the value 3.218876.
The following shows another example:
REAL r
r = LOG(10.0) ! returns 2.302585
See Also
EXP
LOG10
1660
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOG_GAMMA
Elemental Intrinsic Function (Generic): Returns
the logarithm of the absolute value of the gamma
function of the argument.
Syntax
result = LOG_GAMMA (x)
Results
The result type and kind are the same as x.
The result has a value equal to a processor-dependent approximation to the natural logarithm of the absolute
value of the gamma function of x.
Example
LOG_GAMMA (3.0) has the approximate value 0.693.
LOG10
Elemental Intrinsic Function (Generic): Returns
the common logarithm of the argument.
Syntax
result = LOG10 (x)
Results
The result type and kind are the same as x. The result value is approximately equal to log10x.
Example
LOG10 (8.0) has the value 0.9030900.
LOG10 (15.0) has the value 1.176091.
1661
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL r
r = LOG10(10.0) ! returns 1.0
See Also
LOG
LOGICAL Function
Elemental Intrinsic Function (Generic): Converts
the logical value of the argument to a logical value
with different kind parameters.
Syntax
result = LOGICAL (l[,kind])
Results
The result is of type logical. If kind is present, the kind parameter is that specified by kind; otherwise, the
kind parameter is that of default logical. The result value is that of l.
The setting of compiler options specifying integer size can affect this function.
Example
LOGICAL (L .OR. .NOT. L) has the value true and is of type default logical regardless of the kind parameter of
logical variable L.
LOGICAL (.FALSE., 2) has the value false, with the parameter of kind 2.
See Also
CMPLX
INT
REAL
Logical Data Types
LOGICAL Statement
Statement: Specifies the LOGICAL data type.
Syntax
LOGICAL
LOGICAL([KIND=] n)
LOGICAL*n
n Is kind 1, 2, 4, or 8.
If a kind parameter is specified, the logical constant has the kind specified. If no kind parameter is specified,
the kind of the constant is default logical.
Example
LOGICAL, ALLOCATABLE :: flag1, flag2
LOGICAL (2), SAVE :: doit, dont=.FALSE.
LOGICAL switch
1662
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
Logical Data Types
Logical Constants
Data Types, Constants, and Variables
LONG
Portability Function: Converts an INTEGER(2)
argument to INTEGER(4) type.
Module
USE IFPORT
Syntax
result = LONG (int2)
Results
The result type is INTEGER(4). The result is the value of int2 with type INTEGER(4). The upper 16 bits of the
result are zeros and the lower 16 are equal to int2.
See Also
INT
KIND
LOOP
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of the associated loops can execute
concurrently. This feature is only available for ifx.
Syntax
!$OMP LOOP [clause[[,] clause]... ]
do-loop
[!$OMP END LOOP]
• BIND (binding)
Determines the binding region of the construct. binding is teams,
parallel, or thread.
1663
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical loop form.
The LOOP construct tells the compiler that all iterations of the associated loops can execute concurrently or in
any order.
If used, the END LOOP directive must appear immediately after the end of the loop. If you do not specify an
END LOOP directive, an END LOOP directive is assumed at the end of the outermost associated do-loop.
A LOOP construct can not contain calls to procedures containing other OpenMP* constructs or calls to the
OpenMP* runtime library functions.
The only OpenMP* constructs permitted inside a LOOP construct are another LOOP, PARALLEL, or SIMD
construct or a combined construct whose leftmost construct is a PARALLEL construct.
A LOOP construct that appears in a procedure and is not nested inside another OpenMP* construct must
contain a BIND clause.
1664
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If more than one loop is associated with the construct, any intervening code between two associated loops
executes at least once per iteration of the loop containing the intervening code, and at most once per
execution of the innermost loop associated with the construct. If an associated loop has a trip count of zero
and that loop does not contain the intervening code, the behavior is undefined.
The set of threads that may execute iterations of the LOOP construct is the binding thread set. Each iteration
is executed by one of these threads.
If a loop region is bound to a teams region, the threads in the binding set can continue execution at the end
of the loop region without waiting for all iterations of the region to complete execution. All iterations of the
loop region must complete execution before the end of the teams region. If the binding region is not a teams
region, all iterations of the associated loops must complete execution before the loop region is exited.
If a loop region is bound to a teams or parallel region, it must be encountered by all or none of the
binding threads.
A LOOP construct with a BIND clause that specifies a value of teams must be strictly nested inside a teams
region. The behavior of a LOOP construct with a BIND clause specifying a value of parallel is undefined if
the loop construct is nested inside a SIMD construct.
Referencing a THREADPRIVATE variable in a LOOP construct results in undefined behavior.
If a reduction-modifier is present in a reduction clause, the only permitted value is DEFAULT.
Example
In the following example, the loop iteration variable is private by default, and it is not necessary to explicitly
declare it. The END LOOP directive is optional. Iterations of the do loop can execute in any order, or
concurrently.
!$OMP PARALLEL
!$OMP LOOP
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END LOOP
!$OMP END PARALLEL
In the next example, the loops over J1 and J2 are collapsed and their iteration space is executed by all
threads of the current team. The subroutine BAR referenced in the innermost loop cannot contain OpenMP*
constructs or calls to procedures that do, and it cannot contain calls to the OpenMP* runtime library. The
END LOOP directive is optional:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Parallel Processing Model for information about Binding Sets
1665
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOOP COUNT
General Compiler Directive: Specifies the iterations
(typical trip count) for a DO loop.
Syntax
!DIR$ LOOP COUNT (n1[, n2]...)
!DIR$ LOOP COUNT= n1[, n2]...
!DIR$ LOOP COUNT qualifier(n)[, qualifier(n)]...
!DIR$ LOOP COUNT qualifier=n[, qualifier=n]...
The value of the loop count affects heuristics used in software pipelining, vectorization, and loop-
transformations.
There is no check at runtime to determine if the MAX or MIN values are exceeded.
Example
Consider the following:
See Also
General Compiler Directives
LSHIFT
Elemental Intrinsic Function (Generic): Shifts the
bits in an integer left by a specified number of
positions. This is the same as specifying ISHFT with a
positive shift.
See Also
See ISHFT.
1666
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LSTAT
Portability Function: Returns detailed information
about a file.
Module
USE IFPORT
Syntax
result = LSTAT (name,statb)
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code (see IERRNO).
LSTAT returns detailed information about the file named in name.
On Linux* and macOS systems, if the file denoted by name is a link, LSTAT provides information on the link,
while STAT provides information on the file at the destination of the link.
On Windows* systems, LSTAT returns exactly the same information as STAT (because there are no symbolic
links on these systems). STAT is the preferred function.
INQUIRE also provides information about file properties.
Example
USE IFPORT
INTEGER(4) info_array(12), istatus
character*20 file_name
print *, "Enter name of file to examime: "
read *, file_name
ISTATUS = LSTAT (file_name, info_array)
if (.NOT. ISTATUS) then
print *, info_array
else
print *, 'Error ',istatus
end if
See Also
INQUIRE
GETFILEINFOQQ
STAT
FSTAT
LTIME
Portability Subroutine: Returns the components of
the local time zone time in a nine-element array.
Module
USE IFPORT
1667
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL LTIME (time,array)
Element Value
Caution
This subroutine is not year-2000 compliant, use DATE_AND_TIME instead.
On Linux* and macOS, time can be a negative number returning the time before 00:00:00 Greenwich mean
time, January 1, 1970. On Windows*, time can not be negative, in which case all 9 elements of array are set
to -1. On all operating systems, if there is a system error in getting the local time, all 9 elements of array are
set to -1.
Example
USE IFPORT
INTEGER(4) input_time, time_array(9)
! find number of seconds since 1/1/70
input_time=TIME()
! convert number of seconds to time array
CALL LTIME (input_time, time_array)
PRINT *, time_array
See Also
DATE_AND_TIME
M to N
This section describes language features that start with M or N.
1668
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
M to N
MAKEDIRQQ
Portability Function: Creates a new directory with a
specified name.
Module
USE IFPORT
Syntax
result = MAKEDIRQQ (dirname)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
MAKEDIRQQ can create only one directory at a time. You cannot create a new directory and a subdirectory
below it in a single command. MAKEDIRQQ does not translate path delimiters. You can use either slash (/) or
backslash (\) as valid delimiters.
If an error occurs, call GETLASTERRORQQ to retrieve the error message. Possible errors include:
• ERR$ACCES - Permission denied. The file's (or directory's) permission setting does not allow the specified
access.
• ERR$EXIST - The directory already exists.
• ERR$NOENT - The file or path specified was not found.
Example
USE IFPORT
LOGICAL(4) result
result = MAKEDIRQQ('mynewdir')
IF (result) THEN
WRITE (*,*) 'New subdirectory successfully created'
ELSE
WRITE (*,*) 'Failed to create subdirectory'
END IF
END
See Also
DELDIRQQ
CHANGEDIRQQ
GETLASTERRORQQ
MALLOC
Elemental Intrinsic Function (Generic): Allocates
a block of memory. This is a generic function that has
no specific function associated with it. It must not be
passed as an actual argument.
Syntax
result = MALLOC (size)
size (Input) Must be of type integer. This value is the size (in bytes) of
memory to be allocated.
1669
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is the
starting address of the allocated memory. The memory allocated can be freed by using the FREE intrinsic
function.
Example
INTEGER(4) SIZE
REAL(4) STORAGE(*)
POINTER (ADDR, STORAGE) ! ADDR will point to STORAGE
SIZE = 1024 ! Size in bytes
ADDR = MALLOC(SIZE) ! Allocate the memory
CALL FREE(ADDR) ! Free it
MAP Clause
Clause for TARGET Directives: Maps a variable
from the data environment of the current task to the
data environment of the device associated with the
construct. This clause only applies to certain TARGET
directives. This feature is only available for ifx.
Syntax
MAP ([[map-type-modifier[,]] map-type :] list)
1670
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1671
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
On entry to an outermost target region where this clause is used, for each original list item, a new
corresponding list item is created on the device. On exit from the outermost target region, if the
corresponding list item is present on the device, it is then deleted from the device.
At least one MAP clause must appear in a directive that allows the clause.
THREADPRIVATE variables cannot appear in a MAP clause.
For the TARGET ENTER DATA directive, map-type must be either TO or ALLOC.
For the TARGET EXIT DATA directive, map-type must be FROM, RELEASE, or DELETE.
For the TARGET and TARGET DATA directives, map-type must be TO, FROM, TOFROM, or ALLOC.
For the TARGET UPDATE directive, map-type must be TO or FROM.
If original and corresponding list items share storage, data races can result when intervening synchronization
between tasks does not occur. If variables that share storage are mapped, it causes unspecified behavior.
Any variables within a TARGET MAP region that are not specified in a MAP clause are treated as shared
variables within the region.
A list item must not contain any components that have the ALLOCATABLE attribute.
If the allocation status of a list item with the ALLOCATABLE attribute is unallocated upon entry to a target
region, the list item must be unallocated upon exit from the region.
If the allocation status of a list item with the ALLOCATABLE attribute is allocated upon entry to a target
region, the allocation status of the corresponding list item must not be changed and must not be reshaped in
the region.
If an array section of an allocatable array is mapped and the size of the section is smaller than that of the
whole array, the target region must not have any reference to the whole array.
A list item that is an array or an array section that has a type for which a user-defined mapper exists, is
mapped as if the final map type is ALLOC, RELEASE, or DELETE. Then each element is mapped with the
original map type, as if by a separate construct according to the user-defined mapper.
If a MAPPER map-type-modifier appears in the MAP clause, the type specified in the user-defined mapper
must match the type of the list items in the MAP clause.
See Also
TARGET directive clause DEFAULTMAP
DECLARE MAPPER Directive
Example
UNION
MAP
CHARACTER*20 string
END MAP
MAP
INTEGER*2 number(10)
END MAP
END UNION
UNION
MAP
RECORD /Cartesian/ xcoord, ycoord
END MAP
1672
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MAP
RECORD /Polar/ length, angle
END MAP
END UNION
See Also
See STRUCTURE.
MASKED
OpenMP* Fortran Compiler Directive: Specifies a
structured block to be executed by a subset of the
threads of the current team. This feature is only
available for ifx.
Syntax
!$OMP MASKED [clause]
loosely-structured-block
!$OMP END MASKED
-or-
!$OMP MASKED [clause]
strictly-structured-block
!$OMP END MASKED
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding thread set for a MASKED construct is the current team. A master region binds to the innermost
enclosing parallel region.
There is no implied barrier, either on entry to or exit from the masked section.
Examples
The following example forces the primary thread to execute the routines OUTPUT and INPUT:
1673
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CALL OUTPUT(X)
CALL INPUT(Y)
!$OMP END MASKED
CALL WORK(Y)
!$OMP END PARALLEL
In the following example, only the even numbered threads execute INPUT and OUTPUT:
!$OMP PARALLEL
BLOCK
INTEGER :: me = omp_get_thread_num
CALL WORK(X)
!$OMP MASKED FILTER (me + mod (me,2))
CALL OUTPUT(X)
CALL INPUT(Y)
!$OMP END MASKED
CALL WORK(Y)
END BLOCK
!$OMP END PARALLEL
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
MASKED TASKLOOP
OpenMP* Fortran Compiler Directive: Creates a
MASKED construct containing a TASKLOOP construct,
with no Fortran statements in the MASKED construct
that are not also in the TASKLOOP construct. This
feature is only available for ifx.
Syntax
!$OMP MASKED TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END MASKED TASKLOOP]
This combined directive provides a shortcut for specifying a MASKED construct with a TASKLOOP construct
nested inside of it. The semantics are identical to a TASKLOOP construct specified immediately after a
MASKED construct.
All restrictions for MASKED and TASKLOOP constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASKED directive
TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification.
1674
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP MASKED TASKLOOP SIMD [clause[[,] clause]... ]
loop-nest
[!$OMP END MASKED TASKLOOP SIMD]
This combined directive provides a shortcut for specifying a MASKED construct with a TASKLOOP SIMD
construct nested inside of it. The semantics are identical to a TASKLOOP SIMD construct specified
immediately after a MASKED construct.
All restrictions for MASKED and TASKLOOP SIMD constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASKED directive
TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification.
MASKL
Elemental Intrinsic Function (Generic): Returns a
left-justified mask.
Syntax
result = MASKL (i[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The result value has its leftmost I bits set to 1 and the remaining bits set to 0.
The model for the interpretation of an integer value as a sequence of bits is in Model for Bit Data.
Example
MASKL (3) has the value SHIFTL (7, BIT_SIZE (0) - 3).
1675
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
MASKR
MASKR
Elemental Intrinsic Function (Generic): Returns a
right-justified mask.
Syntax
result = MASKR (i[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The result value has its rightmost I bits set to 1 and the remaining bits set to 0.
The model for the interpretation of an integer value as a sequence of bits is in Model for Bit Data.
Example
MASKR (3) has the value 7.
See Also
MASKL
MASTER
OpenMP* Fortran Compiler Directive:
(Deprecated; see MASKED) Specifies a block of code
to be executed by the master thread of the team.
Syntax
!$OMP MASTER
loosely-structured-block
!$OMP END MASTER
-or-
!$OMP MASTER
strictly-structured-block
!$OMP END MASTER
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding thread set for a MASTER construct is the current team. A master region binds to the innermost
enclosing parallel region.
1676
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When the MASTER directive is specified, the other threads in the team skip the enclosed block (section) of
code and continue execution. There is no implied barrier, either on entry to or exit from the master section.
The MASTER directive is deprecated; you should use the MASKED directive.
Example
The following example forces the master thread to execute the routines OUTPUT and INPUT:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
MASTER TASKLOOP
OpenMP* Fortran Compiler Directive:
(Deprecated; replaced by MASKED TASKLOOP)
Creates a MASTER construct containing a TASKLOOP
construct, with no Fortran statements in the MASTER
construct that are not also in the TASKLOOP construct.
This feature is only available for ifx.
Syntax
!$OMP MASTER TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END MASTER TASKLOOP]
This combined directive provides a shortcut for specifying a MASTER construct with a TASKLOOP construct
nested inside of it. The semantics are identical to a TASKLOOP construct specified immediately after a
MASTER construct.
All restrictions for MASTER and TASKLOOP constructs apply to this combined construct.
The MASTER TASKLOOP directive is deprecated; you should use the MASKED TASKLOOP directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASTER directive
TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification.
1677
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP MASTER TASKLOOP SIMD [clause[[,] clause]... ]
loop-nest
[!$OMP END MASTER TASKLOOP SIMD]
This combined directive provides a shortcut for specifying a MASTER construct with a TASKLOOP SIMD
construct nested inside of it. The semantics are identical to a TASKLOOP SIMD construct specified
immediately after a MASTER construct; the only Fortran statements in the construct are inside the block.
All restrictions for MASTER and TASKLOOP SIMD constructs apply to this combined construct.
The MASTER TASKLOOP SIMD directive is deprecated; you should use the MASKED TASKLOOP SIMD
directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
MASTER directive
TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification.
MATMUL
Transformational Intrinsic Function (Generic):
Performs matrix multiplication of numeric or logical
matrices.
Syntax
result = MATMUL (matrix_a,matrix_b)
1678
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is an array whose type depends on the data type of the arguments, according to the rules
described in Data Type of Numeric Expressions. The rank and shape of the result depends on the rank and
shapes of the arguments, as follows:
• If matrix_a has shape (n, m) and matrix_b has shape (m, k), the result is a rank-two array with shape (n,
k).
• If matrix_a has shape (m) and matrix_b has shape (m, k), the result is a rank-one array with shape (k).
• If matrix_a has shape (n, m) and matrix_b has shape (m), the result is a rank-one array with shape (n).
If the arguments are of numeric type, element (i, j) of the result has the value SUM((row i of matrix_a) *
(column j of matrix_b)). If the arguments are of logical type, element (i, j) of the result has the value
ANY((row i of matrix_a) .AND. (column j of matrix_b)).
Example
A is matrix
[ 2 3 4 ]
[ 3 4 5 ],
B is matrix
[ 2 3 ]
[ 3 4 ]
[ 4 5 ],
X is vector (1, 2), and Y is vector (1, 2, 3).
The result of MATMUL (A, B) is the matrix-matrix product AB with the value
[ 29 38 ]
[ 38 50 ].
The result of MATMUL (X, A) is the vector-matrix product XA with the value (8, 11, 14).
The result of MATMUL (A, Y) is the matrix-vector product AY with the value (20, 26).
The following shows another example:
e = MATMUL(a, b) ! returns 22 49
! 28 64
See Also
TRANSPOSE
PRODUCT
1679
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MAX
Elemental Intrinsic Function (Generic): Returns
the maximum value of the arguments.
Syntax
result = MAX (a1,a2[,a3]...)
a1, a2, a3 (Input) All must have the same type (integer, real, or character) and
kind parameters.
Results
For arguments of character type, the result type is character, and the length of the result is the length of the
longest argument. For MAX0, AMAX1, DMAX1, QMAX1, IMAX0, JMAX0, and KMAX0, the result type is the
same as the arguments. For MAX1, IMAX1, JMAX1, and KMAX1, the result type is integer. For AMAX0,
AIMAX0, AJMAX0, and AKMAX0, the result type is real. The value of the result is that of the largest
argument. For character arguments, the comparison is done using the ASCII collating sequence. If the
selected argument is shorter than the longest argument, the result is extended to the length of the longest
argument by inserting blank characters on the right.
INTEGER(1) INTEGER(1)
older versions of Fortran, these functions can also be specified as generic functions.
5Or JMAX1. MAX1 is the same as INT(MAX).
6The setting of compiler options specifying integer size can affect MAX1.
7The setting of compiler options specifying real size can affect AMAX1.
1680
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
MAX (2.0, -8.0, 6.0) has the value 6.0.
MAX (14, 32, -50) has the value 32.
The following shows another example:
INTEGER m1, m2
REAL r1, r2
m1 = MAX(5, 6, 7) ! returns 7
m2 = MAX1(5.7, 3.2, -8.3) ! returns 5
r1 = AMAX0(5, 6, 7) ! returns 7.0
r2 = AMAX1(6.4, -12.2, 4.9) ! returns 6.4
See Also
MAXLOC
MAXVAL
MIN
MAXEXPONENT
Inquiry Intrinsic Function (Generic): Returns the
maximum exponent in the model representing the
same type and kind parameters as the argument.
Syntax
result = MAXEXPONENT (x)
Results
The result is a scalar of type default integer. The result has the value emax, as defined in Model for Real Data.
Example
REAL(4) x
INTEGER i
i = MAXEXPONENT(x) ! returns 128.
See Also
MINEXPONENT
MAXLOC
Transformational Intrinsic Function (Generic):
Returns the location of the maximum value of all
elements in an array, a set of elements in an array, or
elements in a specified dimension of an array.
Syntax
result = MAXLOC (array, dim [, mask, kind, back])
result = MAXLOC (array [, mask, kind, back])
1681
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is an array of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The following rules apply if dim is not specified:
• The array result has rank one and a size equal to the rank of array.
• If MAXLOC(array) is specified, the elements in the array result form the subscript of the location of the
element with the maximum value in array.
The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of array.
• If MAXLOC( array, MASK= mask) is specified, the elements in the array result form the subscript of the
location of the element with the maximum value corresponding to the condition specified by mask.
The following rules apply if dim is specified:
• The array result has a rank that is one less than array, and shape (d1, d2,...ddim-1, ddim+1,...dn), where
(d1, d2,...dn) is the shape of array.
• If array has rank one, MAXLOC( array, dim [, mask]) is a scalar and has a value equal to the first element
of MAXLOC( array [, MASK = mask]). Otherwise, the value of element (s1, s2,...sdim-1, sdim+1,...sn) of
MAXLOC( array, dim [, mask]) is equal to MAXLOC( array(s1, s2,...sdim-1, :, sdim+1,...sn) [, MASK =
mask(s1, s2,...sdim-1, :, sdim+1,...sn)]).
If only one element has the maximum value, that element’s subscripts are returned. Otherwise, if more than
one element has the maximum value and back is absent or present with the value .FALSE., the element
whose subscripts are returned is the first such element, taken in array element order. If back is present with
the value .TRUE., the element whose subscripts are returned is the last such element, taken in array element
order.
If array has size zero, or every element of mask has the value .FALSE., the value of the result is controlled by
compiler option assume [no]old_maxminloc, which can set the value of the result to either 1 or 0.
If array is of type character, the comparison is done using the ASCII collating sequence.
The setting of compiler options specifying integer size can affect this function.
Example
The value of MAXLOC((/3, 7, 4, 7/)) is (2), which is the subscript of the location of the first occurrence of the
maximum value in the rank-one array.
A is the array
[ 4 0 4 2 ]
[ 3 1 -2 6 ]
[ -1 -4 5 5 ].
MAXLOC (A, MASK=A .LT. 5) has the value (1, 1) because these are the subscripts of the location of the first
maximum value (4) that is less than 5.
MAXLOC (A, DIM=1) has the value (1, 2, 3, 2). 1 is the subscript of the location of the first maximum value
(4) in column 1; 2 is the subscript of the location of the first maximum value (1) in column 2; and so forth.
1682
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MAXLOC (A, DIM=2) has the value (1, 4, 3). 1 is the subscript of the location of the first maximum value in
row 1; 4 is the subscript of the location of the first maximum value in row 2; and so forth.
MAXLOC (A, DIM=2, BACK=.TRUE.) has the value (3, 4, 4). 3 is the subscript of the location of the last
maximum value in row 1; 4 is the subscript of the location of the last maximum value in row 2; and so forth.
The following shows another example:
See Also
MAXVAL
MINLOC
MINVAL
FINDLOC
MAXVAL
Transformational Intrinsic Function (Generic):
Returns the maximum value of all elements in an
array, a set of elements in an array, or elements in a
specified dimension of an array.
Syntax
result = MAXVAL (array [, mask])
1683
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
dim (Input) Must be a scalar integer expression with a value in the range 1
to n, where n is the rank of array.
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is not specified or array has rank one.
The following rules apply if dim is not specified:
• If MAXVAL( array) is specified, the result has a value equal to the maximum value of all the elements in
array.
• If MAXVAL( array, MASK= mask) is specified, the result has a value equal to the maximum value of the
elements in array corresponding to the condition specified by mask.
The following rules apply if dim is specified:
• An array result has a rank that is one less than array, and shape (d1, d2,...,ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
• If array has rank one, MAXVAL( array, dim[, mask]) has a value equal to that of MAXVAL( array[,MASK =
mask]). Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of MAXVAL( array, dim, [,
mask]) is equal to MAXVAL( array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK = mask(s1, s2, ..., sdim-1, :,
sdim+1, ..., sn)]).
If array has size zero or if there are no true elements in mask, the result (if dim is omitted), or each element
in the result array (if dim is specified), has the value of the negative number of the largest magnitude
supported by the processor for numbers of the type and kind parameters of array.
If array is of type character, the comparison is done using the ASCII collating sequence.
Example
The value of MAXVAL ((/2, 3, 4/)) is 4 because that is the maximum value in the rank-one array.
MAXVAL (B, MASK=B .LT. 0.0) finds the maximum value of the negative elements of B.
C is the array
[ 2 3 4 ]
[ 5 6 7 ].
MAXVAL (C, DIM=1) has the value (5, 6, 7). 5 is the maximum value in column 1; 6 is the maximum value in
column 2; and so forth.
MAXVAL (C, DIM=2) has the value (4, 7). 4 is the maximum value in row 1 and 7 is the maximum value in
row 2.
The following shows another example:
1684
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! (a column) of array
ALLOCATE (AR2(i(1))) ! dimension AR2 to the number of
! elements in dimension 1
! (a row) of array
max = MAXVAL(array, MASK = array .LT. 4) ! returns 3
AR1 = MAXVAL(array, DIM = 1) ! returns [ 4 5 6 ]
AR2 = MAXVAL(array, DIM = 2) ! returns [ 5 6 ]
END
See Also
MAXLOC
MINVAL
MINLOC
MCLOCK
Inquiry Intrinsic Function (Specific): Returns time
accounting for a program.
Syntax
result = MCLOCK( )
Results
The result type is INTEGER(4). The result is the sum (in units of milliseconds) of the current process's user
time and the user and system time of all its child processes.
MERGE
Elemental Intrinsic Function (Generic): Selects
between two values or between corresponding
elements in two arrays, according to the condition
specified by a logical mask.
Syntax
result = MERGE (tsource,fsource,mask)
fsource (Input) Must be of the same type and type parameters as tsource.
Results
The result type and kind are the same as tsource. The value of mask determines whether the result value is
taken from tsource (if mask is true) or fsource (if mask is false).
Example
For MERGE (1.0, 0.0, R < 0), R = -3 has the value 1.0, and R = 7 has the value 0.0.
TSOURCE is the array
[ 1 3 5 ]
[ 2 4 6 ],
FSOURCE is the array
[ 8 9 0 ]
[ 1 2 3 ],
1685
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[ F T T]
[ T T F].
MERGE (TSOURCE, FSOURCE, MASK) produces the result:
[ 8 3 5 ]
[ 2 4 3 ].
The following shows another example:
MERGE_BITS
Elemental Intrinsic Function (Generic): Merges
bits by using a mask.
Syntax
result = MERGE_BITS (i,j,mask)
If both i and j are of type integer they must have the same kind type parameter. They cannot both be binary,
octal, or hexadecimal literal constants.
If mask is of type integer, it must have the same kind type parameter as each other argument of type
integer.
Results
The result type and kind are the same as i if i is of type integer; otherwise, the result type and kind are the
same as j.
If any argument is a binary, octal, or hexadecimal literal constant, it is first converted as if by the intrinsic
function INT to the type and kind parameter of the result. The result has the value of IOR (IAND (i, mask),
IAND (j, NOT (mask))).
Example
MERGE_BITS (13, 18, 22) has the value 4.
1686
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MERGEABLE Clause
Parallel Directive Clause: Specifies that the
implementation may generate a merged task.
Syntax
MERGEABLE
When the generated task is an undeferred task or an included task, it specifies that the implementation may
instead generate a merged task.
When the MERGEABLE clause is present on a TASKLOOP construct, each generated task is a mergeable task.
MESSAGE
General Compiler Directive: Specifies a character
string to be sent to the standard output device during
the first compiler pass; this aids debugging.
Syntax
!DIR$ MESSAGE:string
Example
!DIR$ MESSAGE:'Compiling Sound Speed Equations'
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
MIN
Elemental Intrinsic Function (Generic): Returns
the minimum value of the arguments.
Syntax
result = MIN (a1,a2[,a3...])
a1, a2, a3 (Input) All must have the same type (integer, real, or character) and
kind parameters.
Results
For arguments of character type, the result type is character, and the length of the result is the length of the
longest argument. For MIN0, AMIN1, DMIN1, QMIN1, IMIN0, JMIN0, and KMIN0, the result type is the same
as the arguments. For MIN1, IMIN1, JMIN1, and KMIN1, the result type is integer. For AMIN0, AIMIN0,
AJMIN0, and AKMIN0, the result type is real. The value of the result is that of the smallest argument. For
character arguments, the comparison is done using the ASCII collating sequence. If the selected argument is
shorter than the longest argument, the result is extended to the length of the longest argument by inserting
blank characters on the right.
INTEGER(1) INTEGER(1)
1687
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
MIN (2.0, -8.0, 6.0) has the value -8.0.
MIN (14, 32, -50) has the value -50.
The following shows another example:
INTEGER m1, m2
REAL r1, r2
m1 = MIN (5, 6, 7) ! returns 5
m2 = MIN1 (-5.7, 1.23, -3.8) ! returns -5
r1 = AMIN0 (-5, -6, -7) ! returns -7.0
r2 = AMIN1(-5.7, 1.23, -3.8) ! returns -5.7
See Also
MINLOC
MINVAL
MAX
MINEXPONENT
Inquiry Intrinsic Function (Generic): Returns the
minimum exponent in the model representing the
same type and kind parameters as the argument.
1688
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = MINEXPONENT (x)
Results
The result is a scalar of type default integer. The result has the value emin, as defined in Model for Real Data.
Example
If X is of type REAL(4), MINEXPONENT (X) has the value -125.
The following shows another example:
See Also
MAXEXPONENT
MINLOC
Transformational Intrinsic Function (Generic):
Returns the location of the minimum value of all
elements in an array, a set of elements in an array, or
elements in a specified dimension of an array.
Syntax
result = MINLOC (array, dim [, mask, kind, back])
result = MINLOC (array [, mask, kind, back])
Results
The result is an array of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The following rules apply if dim is not specified:
• The array result has rank one and a size equal to the rank of array.
• If MINLOC(array) is specified, the elements in the array result form the subscript of the location of the
element with the minimum value in array.
The ith subscript returned lies in the range 1 to ei, where ei is the extent of the ith dimension of array.
• If MINLOC(array, MASK= mask) is specified, the elements in the array result form the subscript of the
location of the element with the minimum value corresponding to the condition specified by mask.
The following rules apply if dim is specified:
1689
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• The array result has a rank that is one less than array, and shape (d1, d2,...ddim-1, ddim+1,...dn), where
(d1, d2,...dn) is the shape of array.
• If array has rank one, MINLOC( array, dim [, mask]) is a scalar and has a value equal to the first element
of MINLOC( array [,MASK = mask]). Otherwise, the value of element (s1, s2,...sdim-1, sdim+1,...sn) of
MINLOC( array, dim [, mask]) is equal to MINLOC( array(s1, s2,...sdim-1, :, sdim+1,...sn) [, MASK =
mask(s1, s2,...sdim-1, :, sdim+1,...sn)]).
If only one element has the minimum value, that element’s subscripts are returned. Otherwise, if more than
one element has the minimum value and back is absent or present with the value .FALSE., the element
whose subscripts are returned is the first such element, taken in array element order. If back is present with
the value .TRUE., the element whose subscripts are returned is the last such element, taken in array element
order.
If array has size zero, or every element of mask has the value .FALSE., the value of the result is controlled by
compiler option assume [no]old_maxminloc, which can set the value of the result to either 1 or 0.
If array is of type character, the comparison is done using the ASCII collating sequence.
The setting of compiler options specifying integer size can affect this function.
Example
The value of MINLOC ((/3, 1, 4, 1/)) is (2), which is the subscript of the location of the first occurrence of the
minimum value in the rank-one array.
A is the array
[ 4 0 0 2 ]
[ 3 -6 -2 6 ]
[ -1 -4 5 -4 ].
MINLOC (A, MASK=A .GT. -5) has the value (3, 2) because these are the subscripts of the location of the first
minimum value (-4) that is greater than -5.
MINLOC (A, DIM=1) has the value (3, 2, 2, 3). 3 is the subscript of the location of the first minimum value
(-1) in column 1; 3 is the subscript of the location of the first minimum value (-6) in column 2; and so forth.
MINLOC (A, DIM=2) has the value (2, 2, 2). 2 is the subscript of the location of the first minimum value (0)
in row 1; 2 is the subscript of the location of the first minimum value (-6) in row 2; and so forth.
MINLOC (A, DIM=2, BACK=.TRUE.) has the value (3, 2, 4). 3 is the subscript of the location of the last
minimum value (0) in row 1; 2 is the subscript of the location of the last minimum value (-6) in row 2; and
so forth.
The following shows another example:
INTEGER i, minl(1)
INTEGER array(2, 3)
INTEGER, ALLOCATABLE :: AR1(:)
! put values in array
array = RESHAPE((/-7, 1, -2, -9, 5, 0/),(/2, 3/))
! array is -7 -2 5
! 1 -9 0
i = SIZE(SHAPE(array)) ! Get the number of dimensions
! in array
ALLOCATE (AR1 (i)) ! Allocate AR1 to number
! of dimensions in array
AR1 = MINLOC (array, MASK = array .GT. -5) ! Get the
! location (subscripts) of
! smallest element greater
! than -5 in array
1690
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!
! MASK = array .GT. -5 creates a mask array the same
! size and shape as array whose elements are .TRUE. if
! the corresponding element in array is greater than
! -5, and .FALSE. if it is not. This mask causes MINLOC
! to return the index of the element in array with the
! smallest value greater than -5.
!
!array is -7 -2 5 and MASK= array .GT. -5 is F T T
! 1 -9 0 T F T
! and AR1 = MINLOC(array, MASK = array .GT. -5) returns
! (1, 2), the location of the element with value -2
See Also
MAXLOC
MINVAL
MAXVAL
FINDLOC
MINVAL
Transformational Intrinsic Function (Generic):
Returns the minimum value of all elements in an
array, a set of elements in an array, or elements in a
specified dimension of an array.
Syntax
result = MINVAL (array [, mask])
result = MINVAL (array, dim [, mask])
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is omitted or array has rank one.
The following rules apply if dim is not specified:
• If MINVAL( array) is specified, the result has a value equal to the minimum value of all the elements in
array.
• If MINVAL( array, MASK= mask) is specified, the result has a value equal to the minimum value of the
elements in array corresponding to the condition specified by mask.
The following rules apply if dim is specified:
• An array result has a rank that is one less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
1691
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If array has rank one, MINVAL( array, dim[, mask]) has a value equal to that of MINVAL( array[,MASK =
mask]). Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of MINVAL( array, dim, [,
mask]) is equal to MINVAL( array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK = mask(s1, s2, ..., sdim-1, :,
sdim+1, ..., sn)]).
If array has size zero or if there are no true elements in mask, the result (if dim is omitted), or each element
in the result array (if dim is specified), has the value of the positive number of the largest magnitude
supported by the processor for numbers of the type and kind parameters of array.
If array is of type character, the comparison is done using the ASCII collating sequence.
Example
The value of MINVAL ((/2, 3, 4/)) is 2 because that is the minimum value in the rank-one array.
The value of MINVAL (B, MASK=B .GT. 0.0) finds the minimum value of the positive elements of B.
C is the array
[ 2 3 4 ]
[ 5 6 7 ].
MINVAL (C, DIM=1) has the value (2, 3, 4). 2 is the minimum value in column 1; 3 is the minimum value in
column 2; and so forth.
MINVAL (C, DIM=2) has the value (2, 5). 2 is the minimum value in row 1 and 5 is the minimum value in row
2.
The following shows another example:
See Also
MAXVAL
MINLOC
MAXLOC
MM_PREFETCH
Intrinsic Subroutine (Generic): Prefetches data
from the specified address on one memory cache line.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL MM_PREFETCH (address[,hint] [,fault] [,exclusive])
1692
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
address (Input) Is the name of a scalar or array; it can be of any type or rank.
It specifies the address of the data on the cache line to prefetch.
1693
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
subroutine spread_lf (a, b)
PARAMETER (n = 1025)
stop
end
MOD
Elemental Intrinsic Function (Generic): Returns
the remainder when the first argument is divided by
the second argument.
Syntax
result = MOD (a, p)
Results
The result type and kind are the same as a. If p is not equal to zero, the value of the result is a - INT( a/ p) *
p. If p is equal to zero, the result is undefined.
1694
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1 Or HMOD.
2 Or JMOD.
3 The setting of compiler options specifying real size can affect AMOD and DMOD.
4 The setting of compiler options specifying double size can affect DMOD.
Example
MOD (7, 3) has the value 1.
MOD (9, -6) has the value 3.
MOD (-9, 6) has the value -3.
The following shows more examples:
INTEGER I
REAL R
R = MOD(9.0, 2.0) ! returns 1.0
I = MOD(18, 5) ! returns 3
I = MOD(-18, 5) ! returns -3
I = MOD( 8, 5) ! returns 3
I = MOD(-8, 5) ! returns -3
I = MOD( 8,-5) ! returns 3
I = MOD(-8,-5) ! returns -3
See Also
MODULO
MODULE
Statement: Marks the beginning of a module
program unit, which contains specifications and
definitions that can be used by one or more program
units.
Syntax
MODULE name
[specification-part]
[CONTAINS
[module-subprogram
[module-subprogram]...] ]
END[ MODULE [name]]
1695
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a name follows the END statement, it must be the same as the name specified in the MODULE statement.
The module name is considered global and must be unique. It cannot be the same as any local name in the
main program or the name of any other program unit, external procedure, or common block in the
executable program.
A module is host to any module procedures it contains, and entities in the module are accessible to the
module procedures through host association.
A module must not reference itself (either directly or indirectly).
You can use the PRIVATE attribute to restrict access to procedures or variables within a module.
Although ENTRY statements, FORMAT statements, and statement functions are not allowed in the
specification part of a module, they are allowed in the specification part of a module subprogram.
The following rules also apply to modules:
• The specification part of a module must not contain IMPORT, ENTRY, FORMAT, executable, or statement
function statements.
• A variable, common block, or procedure pointer declared in a submodule implicitly has the SAVE attribute,
which may be confirmed by explicit specification.
• If a specification or constant expression in the specification-part of a module includes a reference to a
generic entity, there must be no specific procedures of the generic entity defined in the submodule
subsequent to the specification or constant expression.
Example
The following example shows a simple module that can be used to provide global data:
MODULE MOD_A
INTEGER :: B, C
REAL E(25,5)
END MODULE MOD_A
...
SUBROUTINE SUB_Z
USE MOD_A ! Makes scalar variables B and C, and array
... ! E available to this subroutine
END SUBROUTINE SUB_Z
The following example shows a module procedure:
MODULE RESULTS
...
CONTAINS
FUNCTION MOD_RESULTS(X,Y) ! A module procedure
1696
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
...
END FUNCTION MOD_RESULTS
END MODULE RESULTS
The following example shows a module containing a derived type:
MODULE EMPLOYEE_DATA
TYPE EMPLOYEE
INTEGER ID
CHARACTER(LEN=40) NAME
END TYPE EMPLOYEE
END MODULE
The following example shows a module containing an interface block:
MODULE ARRAY_CALCULATOR
INTERFACE
FUNCTION CALC_AVERAGE(D)
REAL :: CALC_AVERAGE
REAL, INTENT(IN) :: D(:)
END FUNCTION
END INTERFACE
END MODULE ARRAY_CALCULATOR
The following example shows a derived-type definition that is public with components that are private:
MODULE MATTER
TYPE ELEMENTS
PRIVATE
INTEGER C, D
END TYPE
...
END MODULE MATTER
In this case, components C and D are private to type ELEMENTS, but type ELEMENTS is not private to
MODULE MATTER. Any program unit that uses the module MATTER can declare variables of type ELEMENTS,
and pass as arguments values of type ELEMENTS.
This design allows you to change components of a type without affecting other program units that use the
module.
If a derived type is needed in more than one program unit, the definition should be placed in a module and
accessed by a USE statement whenever it is needed, as follows:
MODULE STUDENTS
TYPE STUDENT_RECORD
...
END TYPE
CONTAINS
SUBROUTINE COURSE_GRADE(...)
TYPE(STUDENT_RECORD) NAME
...
END SUBROUTINE
END MODULE STUDENTS
...
PROGRAM SENIOR_CLASS
USE STUDENTS
TYPE(STUDENT_RECORD) ID
...
END PROGRAM
1697
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Program SENIOR_CLASS has access to type STUDENT_RECORD, because it uses module STUDENTS. Module
procedure COURSE_GRADE also has access to type STUDENT_RECORD, because the derived-type definition
appears in its host.
See Also
SUBMODULE
PUBLIC
PRIVATE
USE
Procedure Interfaces
Program Units and Procedures
PROTECTED Attribute and Statement
MODULE FUNCTION
Statement: Indicates a separate module procedure.
Example
submodule (M) A
contains
real module function foo (arg) result(res)
type(tt), intent(in) :: arg
res = arg%r
end function foo
end submodule A
See Also
Separate Module Procedures
MODULE PROCEDURE
Statement: Identifies module procedures in an
interface block that specifies a generic name.
Example
!A program that changes non-default integers and reals
! into default integers and reals
PROGRAM CHANGE_KIND
USE Module1
integer(2) in
integer indef
indef = DEFAULT(in)
END PROGRAM
1698
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
sub2 = INT(z)
END FUNCTION
END MODULE
See Also
INTERFACE
MODULE
Modules and Module Procedures
PROCEDURE
MODULE SUBROUTINE
Statement: Indicates a separate module procedure.
Example
submodule (M) A
contains
real module subroutine FOO (arg)
type(tt), intent(in) :: arg
arg%r =1
end subroutine FOO
end submodule A
See Also
Separate Module Procedures
MODULO
Elemental Intrinsic Function (Generic): Returns
the modulo of the arguments.
Syntax
result = MODULO (a,p)
p (Input) Must have the same type and kind parameters as a. It must
not have a value of zero.
Results
The result type is the same a. The result value depends on the type of a, as follows:
• If a is of type integer and p is not equal to zero, the value of the result is a - FLOOR(REAL( a) / REAL( p))
* p, that is, the result has a value such that a = q * p + result where q is an integer. The following also
applies:
• If p > 0, then 0 <= result < p
• If p < 0, then p < result <= 0
• If a is of type real and p is not equal to zero, the value of the result is a - FLOOR( a/ p) * p.
If p is equal to zero (regardless of the type of a), the result is undefined.
Example
MODULO (7, 3) has the value 1.
MODULO (9, -6) has the value -3.
MODULO (-9, 6) has the value 3.
1699
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER I
REAL R
I= MODULO(8, 5) ! returns 3 Note: q=1
I= MODULO(-8, 5) ! returns 2 Note: q=-2
I= MODULO(8, -5) ! returns -2 Note: q=-2
I= MODULO(-8,-5) ! returns -3 Note: q=1
R= MODULO(7.285, 2.35) ! returns 0.2350001 Note: q=3
R= MODULO(7.285, -2.35) ! returns -2.115 Note: q=-4
See Also
MOD
MOVE_ALLOC
Intrinsic Subroutine (Generic): Moves an allocation
from one allocatable object to another. Intrinsic
subroutines cannot be passed as actual arguments.
Syntax
CALL MOVE_ALLOC (from,to [, stat, errmsg])
from (Input; output) Can be of any type, type parameters, corank, and
rank; it must be allocatable.
to (Output) Must be type compatible with from and have the same rank
and corank; it must be allocatable. It must be polymorphic if from is
polymorphic. Each nondeferred type parameter of the declared type of
to must have the same value as the corresponding type parameter of
the declared type of from. For more information about type
compatibility, see the description in CLASS.
When the execution of MOVE_ALLOC is successful, or if STAT is assigned the value STAT_FAILED_IMAGE, the
following occurs:
• If to is currently allocated, it is deallocated.
• If from is allocated, to becomes allocated with the same type, type parameters, array bounds, and values
as from.
• from is deallocated.
If to has the TARGET attribute, any pointer associated with from at the time of the call to MOVE_ALLOC
becomes correspondingly associated with to. If to does not have the TARGET attribute, the pointer
association status of any pointer associated with from on entry becomes undefined.
During execution of MOVE_ALLOC, the internal descriptor contents are copied from from to to, so that the
storage pointed to by to is the storage that from used to point to.
Typically, MOVE_ALLOC is used to provide an efficient way to reallocate a variable to a larger size without
copying the data twice.
A reference to MOVE_ALLOC that has a coarray from argument has an implicit synchronization of all active
images of the current team. No image proceeds until all active images of the current team have completed
execution of the reference. If the current team contains any images that have stopped or failed, an error
condition occurs.
1700
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the procedure reference is successful, stat becomes defined with the value zero.
If an error condition occurs and stat is not specified, error termination is initiated. If stat is present and the
current team contains an image that has stopped, stat becomes defined with the value
STAT_STOPPED_IMAGE from the intrinsic module ISO_FORTRAN_ENV. Otherwise, if stat is present, the
current team contains a failed image, and no other error condition occurs, stat becomes defined with the
value STAT_FAILED_IMAGE from the intrinsic module ISO_FORTRAN_ENV. Otherwise, stat becomes defined
with a positive integer value different from STAT_STOPPED_IMAGE and STAT_FAILED_IMAGE.
The definition status of errmsg, if present, remains unchanged if the execution of the reference is successful.
If errmsg is present and an error condition occurs, errmsg becomes defined with an explanatory message
describing the error.
Example
The following shows an example of how to increase the allocated size of X and keep the old values with only
one copy of the old values. Using only assignment, a temporary variable named Y will be allocated and X
assigned to Y. Then X will be deallocated and reallocated to be twice the size; then Y will be assigned to the
first half of X. Finally, the temporary Y is deallocated.
allocated of X is T
allocated of Y is T
old X is 1.000000 2.000000
old Y is -1.000000 -1.000000 -1.000000 -1.000000
new Y is 1.000000 2.000000 -1.000000 -1.000000
allocated of X is T
allocated of Y is F
new X is 1.000000 2.000000 -1.000000 -1.000000
See Also
ISO_FORTRAN_ENV Module
1701
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MVBITS
Elemental Intrinsic Subroutine (Generic): Copies
a sequence of bits (a bit field) from one location to
another. Intrinsic subroutines cannot be passed as
actual arguments.
Syntax
CALL MVBITS (from,frompos,len,to,topos)
from (Input) Integer. Can be of any integer type. It represents the location
from which a bit field is transferred.
to (Input; output) Can be of any integer type, but must have the same
kind parameter as from. It represents the location to which a bit field
is transferred. to is set by copying the sequence of bits of length len,
starting at position frompos of from to position topos of to. No other
bits of to are altered.
Example
If TO has the initial value of 6, its value after a call to MVBITS(7, 2, 2, TO, 0) is 5.
The following shows another example:
See Also
BIT_SIZE
IBCLR
IBSET
1702
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ISHFT
ISHFTC
NAMELIST
Statement: Associates a name with a list of
variables. This group name can be referenced in some
input/output operations.
Syntax
NAMELIST /group/ var-list[[,] /group/ var-list]...
Description
The namelist group name is used by namelist I/O statements instead of an I/O list. The unique group name
identifies a list whose entities can be modified or transferred.
A variable can appear in more than one namelist group.
Each variable in var-list must be accessed by use or host association, or it must have its type, type
parameters, and shape explicitly or implicitly specified in the same scoping unit. If the variable is implicitly
typed, it can appear in a subsequent type declaration only if that declaration confirms the implicit typing.
You cannot specify an assumed-size array in a namelist group.
Only the variables specified in the namelist can be read or written in namelist I/O. It is not necessary for the
input records in a namelist input statement to define every variable in the associated namelist.
The order of variables in the namelist controls the order in which the values appear on namelist output. Input
of namelist values can be in any order.
If the group name has the PUBLIC attribute, no item in the variable list can have the PRIVATE attribute.
The group name can be specified in more than one NAMELIST statement in a scoping unit. The variable list
following each successive appearance of the group name is treated as a continuation of the list for that group
name.
Example
In the following example, D and E are added to the variables A, B, and C for group name LIST:
NAMELIST /LIST/ A, B, C
NAMELIST /LIST/ D, E
In the following example, two group names are defined:
CHARACTER*30 NAME(25)
NAMELIST /INPUT/ NAME, GRADE, DATE /OUTPUT/ TOTAL, NAME
Group name INPUT contains variables NAME, GRADE, and DATE. Group name OUTPUT contains variables
TOTAL and NAME.
The following shows another example:
NAMELIST /example/ i1, l1, r4, r8, z8, z16, c1, c10, iarray
! The corresponding input statements could be:
&example
1703
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
i1 = 11
l1 = .TRUE.
r4 = 24.0
r8 = 28.0d0
z8 = (38.0, 0.0)
z16 = (316.0d0, 0.0d0)
c1 = 'A'
c10 = 'abcdefghij'
iarray(8) = 41, 42, 43
/
A sample program, NAMELIST.F90, is included in the <install-dir>/samples subdirectory.
See Also
READ
WRITE
Namelist Specifier
Namelist Input
Namelist Output
NARGS
Inquiry Intrinsic Function (Specific): Returns the
total number of command-line arguments, including
the command. This function cannot be passed as an
actual argument.
Syntax
result = NARGS( )
Results
The result type is INTEGER(4). The result is the number of command-line arguments, including the
command. For example, NARGS returns 4 for the command-line invocation of PROG1 -g -c -a.
Example
INTEGER(2) result
result = RUNQQ('myprog', '-c -r')
END
num = 5
count = NARGS()
DO i = 1, count-1
CALL GETARG(i, buf, status)
IF (status .lt. 0) THEN
WRITE (*,*) 'GETARG error - exiting'
EXIT
END IF
IF (buf(2:status) .EQ.'r') THEN
1704
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
r1 = REAL(num)
WRITE (*,*) 'r1 = ',r1
ELSE IF (buf(2:status) .EQ.'c') THEN
c1 = CMPLX(num)
WRITE (*,*) 'c1 = ', c1
ELSE IF (buf(2:status) .EQ.'d') THEN
d1 = DBLE(num)
WRITE (*,*) 'd1 = ', d1
ELSE
WRITE(*,*) 'Invalid command switch: ', buf (1:status)
END IF
END DO
END
See Also
GETARG
IARGC
COMMAND_ARGUMENT_COUNT
GET_COMMAND
GET_COMMAND_ARGUMENT
NEAREST
Elemental Intrinsic Function (Generic): Returns
the nearest different number (representable on the
processor) in a given direction.
Syntax
result = NEAREST (x, s)
Results
The result type and kind are the same as x. The result has a value equal to the machine representable
number that is different from and nearest to x, in the direction of the infinity with the same sign as s.
Example
If 3.0 and 2.0 are REAL(4) values, NEAREST (3.0, 2.0) has the value 3 + 2 -22, which equals approximately
3.0000002. (For more information on the model for REAL(4), see Model for Real Data.
The following shows another example:
REAL(4) r1
REAL(8) r2, result
r1 = 3.0
result = NEAREST (r1, -2.0)
WRITE(*,*) result ! writes 2.999999761581421
1705
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
EPSILON
NEW_LINE
Inquiry Intrinsic Function (Generic): Returns a
new line character.
Syntax
result = NEW_LINE(a)
Results
The result is a character scalar of length one with the same kind type parameter as a.
The result value is the ASCII newline character ACHAR(10).
NINT
Elemental Intrinsic Function (Generic): Returns
the nearest integer to the argument.
Syntax
result = NINT (a[,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is shown in the following table. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
If a is greater than zero, NINT(a) has the value INT(a+ 0.5); if a is less than or equal to zero, NINT(a) has
the value INT(a- 0.5).
1706
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
NINT (3.879) has the value 4.
NINT (-2.789) has the value -3.
The following shows another example:
INTEGER(4) i1, i2
i1 = NINT(2.783) ! returns 3
i2 = IDNINT(-2.783D0) ! returns -3
See Also
ANINT
INT
NOFREEFORM
Statement: Specifies that source code is in fixed-
form format.
For more information, see FREEFORM and NOFREEFORM.
NOFUSION
General Compiler Directive: Prevents a loop from
fusing with adjacent loops.
Syntax
!DIR$ NOFUSION
The NOFUSION directive lets you fine tune your program on a loop-by-loop basis.
This directive should be placed immediately before the DO statement of the loop that should not be fused.
Example
Consider the following example that demonstrates use of the NOFUSION directive:
1707
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
a(i) = a(i) + 1
enddo
end
The following shows the same example, but it uses Standard Fortran array assignments, which allow implicit
arrays:
See Also
General Compiler Directives
NON_RECURSIVE
Keyword: Specifies that a subroutine or function does
not call itself directly or indirectly.
For more information, see RECURSIVE and NON_RECURSIVE.
NOOPTIMIZE
Statement: Disables optimizations.
For more information, see OPTIMIZE and NOOPTIMIZE.
NOPREFETCH
Statement: Disables data prefetching.
For more information, see PREFETCH and NOPREFETCH.
NORM2
Transformational Intrinsic Function (Generic):
Returns the L2 norm of an array.
Syntax
result = NORM2 (x)
result = NORM2 (x, dim)
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of x.
Results
The result is of the same type and kind parameters as x.
The result is a scalar if dim is not specified; otherwise, the result has rank n - 1 and shape [d1, d2, ..., ddim-1,
ddim+1, ..., dn], where n is the rank of x and [d1, d2, ..., dn] is the shape of x.
1708
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The result of NORM2 (x) has a value equal to a processor-dependent approximation to the generalized L2
norm of x, which is the square root of the sum of the squares of the elements of x.
The result of NORM2 (x, DIM=dim) has a value equal to that of NORM2 (x) if x has rank one.
Otherwise, the value of element (s1, s2, .., sdim-1, sdim+1, ... sn) of the result is equal to NORM2 (x (s1, s2, ..,
sdim-1, :, sdim+1, ... sn)).
It is recommended that the processor compute the result without undue overflow or underflow.
Example
The value of NORM2 ([3.0, 4.0]) is 5.0 (approximately).
If X has the value:
[ 1.0 2.0 ]
[ 3.0 4.0 ]
then the value of NORM2 (X, DIM=1) is approximately [3.162, 4.472] and the value of NORM2 (X, DIM=2) is
approximately [2.236,5.0].
NOSTRICT
Statement: Enables language features not found in
the language standard specified on the command line.
For more information, see STRICT and NOSTRICT.
NOT
Elemental Intrinsic Function (Generic): Returns
the logical complement of the argument.
Syntax
result = NOT (i)
Results
The result type and kind are the same as i. The result value is obtained by complementing i bit-by-bit
according to the following truth table:
INOT (I)
1 0
0 1
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If I has a value equal to 10101010 (base 2), NOT (I) has the value 01010101 (base 2).
1709
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
BTEST
IAND
IBCHNG
IBCLR
IBSET
IEOR
IOR
ISHA
ISHC
ISHL
ISHFT
ISHFTC
NOUNROLL
Statement: Disables the unrolling of a DO loop.
For more information, see UNROLL and NOUNROLL.
NOUNROLL_AND_JAM
Statement: Hints to the compiler to disable loop
unrolling and jamming.
For more information, see UNROLL_AND_JAM and NOUNROLL_AND_JAM.
NOVECTOR
Statement: Disables vectorization of a DO loop.
For more information, see VECTOR and NOVECTOR.
NOWAIT Clause
Parallel Directive Clause: Specifies that threads
may resume execution before the execution of the
region completes.
Syntax
NOWAIT
When you specify this clause, it removes the synchronization barrier implied at the end of the region.
Note that NOWAIT can also be specified as a keyword in several directives.
At most one NOWAIT clause or keyword can appear in a directive that allows the clause or keyword.
1710
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NULL
Transformational Intrinsic Function (Generic):
Initializes a pointer as disassociated when it is
declared.
Syntax
result = NULL ([ mold])
Results
The result type and kind are the same as mold, if present; otherwise, it is determined as follows:
On the right side of pointer assignment The pointer on the left side
Caution
If you use module IFWIN or IFWINTY, you will have a name conflict if you use the NULL
intrinsic. To avoid this problem, rename the integer parameter constant NULL to something
else; for example:
USE IFWIN, NULL0 => NULL
This example lets you use both NULL0 and NULL( ) in the same program unit with no conflict.
Example
Consider the following:
NULLIFY
Statement: Disassociates a pointer from a target.
Syntax
NULLIFY (pointer-object[,pointer-object]...)
1711
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
The initial association status of a pointer is undefined. You can use NULLIFY to initialize an undefined pointer,
giving it disassociated status. Then the pointer can be tested using the intrinsic function ASSOCIATED.
Example
The following is an example of the NULLIFY statement:
NULLIFY (arrow2)
IF (.NOT.ASSOCIATED(arrow2)) WRITE (*,'(/a/)') ' ARROW2 is not pointed.'
WRITE (*,'( 1x,a,7f8.0)') 'pointer',arrow1
WRITE (*,'(/1x,a,7f8.0)') 'target ',bullseye
END
See Also
ALLOCATE
ASSOCIATED
DEALLOCATE
POINTER
TARGET
NULL
Pointer Assignments
Dynamic Allocation
1712
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NUM_IMAGES
Transformational Intrinsic Function (Generic):
Returns the number of images on the current or
specified team.
Syntax
result = NUM_IMAGES()
result = NUM_IMAGES (team)result = NUM_IMAGES (team_number)
team_number (Input) Must be an integer scalar. It must identify the initial team (-1),
or a vaild team number of a team created by the same execution of
the FORM TEAM statement that created the current team executing
the function reference (a sibling of the current team).
Results
The result type is default integer. The result is the number of images on the current or specified team.
If neither team nor team_number are specified, the team is the current team. team and team_number may
not both be specified.
You can specify a compiler option or environment variable to modify the number of images. If both are
specified, the environment variable setting overrides the compiler option setting.
A compiler option must be specified to enable coarrays. If it is not specified and you use this intrinsic
function, an error occurs.
Example
In the following example, image 1 is used to read data. The other images then copy the data:
REAL :: R[*]
IF (THIS_IMAGE()==1) THEN
READ (7,*) R
DO I = 2, NUM_IMAGES()
R[I] = R
END DO
END IF
SYNC ALL
See Also
FORM TEAM
O to P
This section describes language features that start with O or P.
1713
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
O to P
OBJCOMMENT
General Compiler Directive: Specifies a library
search path in an object file.
Syntax
!DIR$ OBJCOMMENT LIB: library
The linker searches for the library named in OBJCOMMENT as if you named it on the command line, that is,
before default library searches. You can place multiple library search directives in the same source file. Each
search directive appears in the object file in the order it is encountered in the source file.
If the OBJCOMMENT directive appears in the scope of a module, any program unit that uses the module also
contains the directive, just as if the OBJCOMMENT directive appeared in the source file using the module.
If you want to have the OBJCOMMENT directive in a module, but do not want it in the program units that use
the module, place the directive outside the module that is used.
Example
! MOD1.F90
MODULE a
!DIR$ OBJCOMMENT LIB: "opengl32.lib"
END MODULE a
! MOD2.F90
!DIR$ OBJCOMMENT LIB: "graftools.lib"
MODULE b
!
END MODULE b
! USER.F90
PROGRAM go
USE a ! library search contained in MODULE a
! included here
USE b ! library search not included
END
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Equivalent Compiler Options
OPEN
Statement: Connects an external file to a unit,
creates a new file and connects it to a unit, creates a
preconnected file, or changes certain properties of a
connection.
Syntax
OPEN ([UNIT=] io-unit[, FILE= name] [, ERR= label] [, IOMSG=msg-var] [, IOSTAT=i-
var],slist)
1714
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
label Is the label of the branch target statement that receives control if an
error occurs. For more information, see Branch Specifiers.
slist Is one or more of the following OPEN specifiers in the form specifier=
value or specifier (each specifier can appear only once):
Description
The control specifiers ([UNIT=] io-unit, ERR= label, and IOSTAT= i-var) and OPEN specifiers can appear
anywhere within the parentheses following OPEN. However, if the UNIT specifier is omitted, the io-unit must
appear first in the list.
If you specify BLANK=, DECIMAL=, PAD=, ROUND=, or SIGN=, you must also specify FMT= or NML=.
If you specify ID=, you must also specify ASYNCHRONOUS='YES'.
Specifier values that are scalar numeric expressions can be any integer or real expression. The value of the
expression is converted to integer data type before it is used in the OPEN statement.
If the NEWUNIT= specifier does not appear, an io-unit must be specified. If the keyword UNIT= is omitted,
the io-unit must be first in the control list.
1715
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
You can specify character values at run time by substituting a character expression for a specifier value in the
OPEN statement. The character value can contain trailing blanks but not leading or embedded blanks; for
example:
1716
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
OPTIONAL
Statement and Attribute: Permits dummy
arguments to be omitted in a procedure reference.
Syntax
The OPTIONAL attribute can be specified in a type declaration statement or an OPTIONAL statement, and
takes one of the following forms:
Type Declaration Statement:
type,[att-ls,] OPTIONAL [, att-ls] :: d-arg[, d-arg]...
Statement:
OPTIONAL [::] d-arg[, d-arg] ...
Description
The OPTIONAL attribute can only appear in the scoping unit of a subprogram or an interface body, and can
only be specified for dummy arguments. It cannot be specified for arguments that are passed by value.
A dummy argument is "present" if it associated with an actual argument that is itself present. A dummy
argument that is not optional must be present. You can use the PRESENT intrinsic function to determine
whether an optional dummy argument is associated with an actual argument.
To call a procedure that has an optional argument, you must use an explicit interface.
If argument keywords are not used, argument association is positional. The first dummy argument becomes
associated with the first actual argument, and so on. If argument keywords are used, arguments are
associated by the keyword name, so actual arguments can be in a different order than dummy arguments. A
keyword is required for an argument only if a preceding optional argument is omitted or if the argument
sequence is changed.
Example
The following example shows a type declaration statement specifying the OPTIONAL attribute:
SUBROUTINE TEST(A)
REAL, OPTIONAL, DIMENSION(-10:2) :: A
END SUBROUTINE
The following is an example of the OPTIONAL statement:
SUBROUTINE TEST(A, B, L, X)
OPTIONAL :: B
INTEGER A, B, L, X
IF (PRESENT(B)) THEN ! Printing of B is conditional
PRINT *, A, B, L, X ! on its presence
ELSE
PRINT *, A, L, X
ENDIF
END SUBROUTINE
INTERFACE
SUBROUTINE TEST(ONE, TWO, THREE, FOUR)
1717
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER I, J, K, L
I = 1
J = 2
K = 3
L = 4
SUBROUTINE EX (a, b, c)
REAL, OPTIONAL :: b,c
This subroutine can be called with any of the following statements:
See Also
PRESENT
Argument Keywords in Intrinsic Procedures
Optional Arguments
Argument Association
Type Declarations
Compatible attributes
1718
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ OPTIMIZE[: n]
!DIR$ NOOPTIMIZE
The OPTIMIZE and NOOPTIMIZE directives can only appear once at the top of a procedure program unit. A
procedure program unit is a main program, an external subroutine or function, or a module. OPTIMIZE and
NOOPTIMIZE cannot appear between program units or in a block data program unit. They do not affect any
modules invoked with the USE statement in the program unit that contains them. They do affect CONTAINed
procedures that do not include an explicit OPTIMIZE or NOOPTIMIZE directive.
NOOPTIMIZE is the same as OPTIMIZE:0. They are both equivalent to −O0 (Linux* and macOS) and /Od
(Windows*).
The procedure is compiled with an optimization level equal to the smaller of n and the optimization level
specified by the O compiler option on the command line. For example, if the procedure contains the directive
NOOPTIMIZE and the program is compiled with compiler option O3, this procedure is compiled at O0 while the
rest of the program is compiled at O3.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
O compiler option
OPTIONS Directive
General Compiler Directive: Affects data alignment
and warnings about data alignment. Also controls
whether a target attribute is assigned to a section of
program declarations.
Syntax
!DIR$ OPTIONS option[option]
...
!DIR$ END OPTIONS
1719
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[class=]rule
(class= rule,...)
ALL
NONE
PAC Packs
KED fields in
records
or data
items in
common
blocks on
arbitrary
byte
boundarie
s.
NAT Naturally
URA aligns
L fields in
records
and data
items in
common
blocks on
up to 64-
bit
boundarie
s
(inconsist
ent with
the
Standard
Fortran).
1720
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This
keyword
causes
the
compiler
to
naturally
align all
data in a
common
block,
including
INTEGER(
KIND=8),
REAL(KIN
D=8),
and all
COMPLEX
data.
STA Naturally
NDA aligns
RD data
items in
common
blocks on
up to 32-
bit
boundarie
s
(consiste
nt with
the
Standard
Fortran).
This
keyword
only
applies to
common
blocks;
so, you
can
specify /
ALIGN=C
OMMONS
=STANDA
RD, but
you
cannot
specify /
1721
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ALIGN=S
TANDARD
.
The OPTIONS (and accompanying END OPTIONS) directives must come after OPTIONS, SUBROUTINE,
FUNCTION, and BLOCK DATA statements (if any) in the program unit, and before the executable part of the
program unit.
The OPTIONS directive supersedes the compiler option align.
For performance reasons, Intel® Fortran aligns local data items on natural boundaries. However,
EQUIVALENCE, COMMON, RECORD, and STRUCTURE data declaration statements can force misaligned data.
If /WARN=NOALIGNMENT is specified, warnings will not be issued if misaligned data is encountered.
NOTE
Misaligned data significantly increases the time it takes to execute a program. As the number of
misaligned fields encountered increases, so does the time needed to complete program execution.
Specifying /ALIGN (or compiler option align) minimizes misaligned data.
1722
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
align compiler option
OPTIONS Statement
Statement: Overrides or confirms the compiler
options in effect for a program unit.
Syntax
OPTIONS option[option...]
/ASSUME = [NO]UNDERSCORE
/CHECK = ALL
[NO]BOUNDS
NONE
/NOCHECK
/CONVERT = BIG_ENDIAN
CRAY
FDX
FGX
IBM
LITTLE_ENDIAN
NATIVE
VAXD
VAXG
/[NO]EXTEND_SOURCE
/[NO]F77
1723
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
/[NO]I4
/[NO]RECURSIVE
The OPTIONS statement must be the first statement in a program unit, preceding the PROGRAM,
SUBROUTINE, FUNCTION, MODULE, and BLOCK DATA statements.
OPTIONS statement options override compiler options, but only until the end of the program unit for which
they are defined. If you want to override compiler options in another program unit, you must specify the
OPTIONS statement before that program unit.
Example
The following are valid OPTIONS statements:
OPTIONS /CHECK=ALL/F77
OPTIONS /I4
See Also
OPEN Statement CONVERT Method
OPTIONS Statement Method
For details on compiler options, see your Compiler Options reference
OR
Elemental Intrinsic Function (Generic): Performs
a bitwise inclusive OR on its arguments.
See IOR.
Example
INTEGER i
i = OR(3, 10) ! returns 11
ORDERED
OpenMP* Fortran Compiler Directive: Specifies a
block of code that the threads in a team must execute
in the natural order of the loop iterations, or, as a
stand-alone directive, it specifies cross-iteration
dependences in a doacross loop nest.
Syntax
It takes one of the following forms:
Form 1:
!$OMP ORDERED [clause [[,] clause ]]
loosely-structured-block
!$OMP END ORDERED
-or-
!$OMP ORDERED [clause [[,] clause ]]
strictly-structured-block
!$OMP END ORDERED
1724
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Form 2:
!$OMP ORDERED clause [[[,] clause ]...]
• DEPEND (SOURCE)
• DEPEND (SINK : vec)
At most one DEPEND (SOURCE) clause can appear on an ORDERED
construct.
Either DEPEND (SINK : vec) clauses or DEPEND (SOURCE) clauses
can appear in an ORDERED construct, but not both.
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding thread set for an ORDERED construct is the current team. An ordered region binds to the
innermost enclosing loop region or the innermost enclosing SIMD region if the SIMD clause is present.
1725
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A doacross loop nest is a loop nest that has cross-iteration dependences. An iteration is dependent on one or
more lexicographically earlier iterations. The ORDERED clause parameter on a loop directive identifies the
loops associated with the doacross loop nest.
An ORDERED directive with no clause or with the THREADS clause specified can appear only in the dynamic
extent of a DO or PARALLEL DO directive. The DO directive to which the ordered section binds must have the
ORDERED clause specified.
An iteration of a loop using a DO directive must not execute the same ORDERED directive more than once,
and it must not execute more than one ORDERED directive.
One thread is allowed in an ordered section at a time. Threads are allowed to enter in the order of the loop
iterations. No thread can enter an ordered section until it can be guaranteed that all previous iterations have
completed or will never execute an ordered section. This sequentializes and orders code within ordered
sections while allowing code outside the section to run in parallel.
Ordered sections that bind to different DO directives are independent of each other.
If the SIMD clause is specified, the ordered regions encountered by any thread will use only a single SIMD
lane to execute the ordered regions in the order of the loop iterations.
You can only specify the SIMD clause (!$OMP ORDERED SIMD) within an !$OMP SIMD loop or an !$OMP
DECLARE SIMD procedure.
When a thread executing any subsequent iteration encounters an ORDERED construct with one or more
DEPEND (SINK : vec) clauses, it waits until its dependences on all valid iterations specified by the DEPEND
clauses are satisfied before it completes execution of the ORDERED region. A specific dependence is satisfied
when a thread executing the corresponding iteration encounters an ORDERED construct with a DEPEND
(SOURCE) clause.
For MONOTONIC (list : linear-step), the following rules apply:
• The value of the new list item on each iteration of the associated SIMD loop corresponds to the value of
the original list item before entering the associated loop, plus the number of the iterations for which the
conditional update happens prior to the current iteration, times linear-step.
• The value corresponding to the sequentially last iteration of the associated loop is assigned to the original
list item.
• A list item must not be used in statements that lexically precede the ORDERED SIMD to which it is bound,
that is, in the region from the OMP SIMD to the OMP ORDERED SIMD. A list item must not be modified
outside the ORDERED SIMD to which it is bound, that is, in the region from the OMP END ORDERED to the
OMP END SIMD.
NOTE
This construct is not supported within a TARGET or a DECLARE TARGET region if the target hardware is
spir64.
Examples
Ordered sections are useful for sequentially ordering the output from work that is done in parallel. Assuming
that a reentrant I/O library exists, the following program prints out the indexes in sequential order:
1726
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!$OMP ORDERED
WRITE(*,*) K
!$OMP END ORDERED
Ordered SIMD sections are useful for resolving cross-iteration data dependencies in otherwise data-parallel
computations. For example, it may handle histogram updates such the following:
!$OMP SIMD
DO I=0,N
AMOUNT = COMPUTE_AMOUNT(I)
CLUSTER = COMPUTE_CLUSTER(I) ! Multiple I’s may belong to the
! same cluster within SIMD chunk
!$OMP ORDERED SIMD
TOTALS(CLUSTER) = TOTALS(CLUSTER) + AMOUNT ! Requires ordering to
! process multiple updates
! to the same cluster
!$OMP END ORDERED
END DO
!$OMP END SIMD
The MONOTONIC keyword on the OMP ORDERED SIMD directive specifies that the body of a loop must be
executed in the natural order of the loop iterations. In the following example, the block of code in the OMP
ORDERED SIMD is executed in the ascending, monotonic order of the loop index I:
COUNT = 0
!$OMP SIMD
DO I = 1, N
IF (COND(I)) THEN
!$OMP ORDERED SIMD MONOTONIC (COUNT:1)
A(COUNT) = A(COUNT) + B(I)
COUNT = COUNT + 1
B(I) = C(COUNT)
!$OMP END ORDERED
END IF
END DO
!$OMP END SIMD
In the following example, the OVERLAP keyword specifies that the block of code after the OMP ORDERED
SIMD directive may contain overlap between the loop iterations:
!$OMP SIMD
DO I = 1, N
INX = INDEX(I)
!$OMP ORDERED SIMD OVERLAP (INX)
A(INX) = A(INX) + B(I)
!$OMP END ORDERED
END DO
!$OMP END SIMD
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
OUT_OF_RANGE
Elemental Intrinsic Function (Generic): Indicates
if a value can be safely converted to a specified type.
1727
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = OUT_OF_RANGE (value, mold [, round])
mold (Input) Must be a scalar of type real or integer. It need not be defined
if it is a variable.
round (Input; optional) Must be a scalar logical. round can only be present if
value is type real and mold is type integer.
Results
The result type is default logical.
If round is not present or has the value .false., and mold is an integer type, the result is .true. if value is a
NaN or an IEEE infinity, or if the integer with the largest magnitude between zero and value (inclusively) is
not representable by an object with the type and kind of mold.
If round has the value .true. and mold is an integer type, the result is .true. if value is a NaN or an IEEE
infinity, or if the integer value nearest value, or the integer of greater magnitude if the two integers are
equally near value, is not representable by an object with the type and kind of mold.
Otherwise, the result is .true. if value is a NaN or IEEE infinity that is not supported by an object of type and
kind of mold, or X is a finite number and the result of rounding value to the extended model for the kind of
mold has a magnitude larger than that of the largest finite number with the same size as value that can be
represented by objects with the type and kind of mold.
Example
If J8 is a variable with type INTEGER (KIND=1), OUT_OF_RANGE (-128.5, J8) will have the result .false. and
OUT_OF_RANGE (-128.5, J8, .TRUE.) will have the value .true..
PACK Directive
General Compiler Directive: Specifies the memory
alignment of derived-type items (and record structure
items).
Syntax
!DIR$ PACK[: {1 | 2 | 4 | 8} ]
Items of derived types, unions, and structures are aligned in memory on the smaller of two sizes: the size of
the type of the item, or the current alignment setting. The current alignment setting can be 1, 2, 4, or 8
bytes. The default initial setting is 8 bytes (unless compiler option vms or align rec n bytes is specified). By
reducing the alignment setting, you can pack variables closer together in memory.
The PACK directive lets you control the packing of derived-type or record structure items inside your program
by overriding the current memory alignment setting.
For example, if PACK:1 is specified, all variables begin at the next available byte, whether odd or even.
Although this slightly increases access time, no memory space is wasted. If PACK:4 is specified, INTEGER(1),
LOGICAL(1), and all character variables begin at the next available byte, whether odd or even. INTEGER(2)
and LOGICAL(2) begin on the next even byte; all other variables begin on 4-byte boundaries.
If the PACK directive is specified without a number, packing reverts to the compiler option setting (if any), or
the default setting of 8.
The directive can appear anywhere in a program before the derived-type definition or record structure
definition. It cannot appear inside a derived-type or record structure definition.
1728
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Use 4-byte packing for this derived type
! Note PACK is used outside of the derived type definition
!DIR$ PACK:4
TYPE pair
INTEGER a, b
END TYPE
! revert to default or compiler option
!DIR$ PACK
See Also
TYPE
STRUCTURE...END STRUCTURE
UNION...END UNION
General Compiler Directives
Syntax Rules for Compiler Directives
align:recnbytes compiler option
vms compiler option
Equivalent Compiler Options
PACK Function
Transformational Intrinsic Function (Generic):
Takes elements from an array and packs them into a
rank-one array under the control of a mask.
Syntax
result = PACK (array,mask[,vector])
vector (Input; optional) Must be a rank-one array with the same type and
type parameters as array. Its size must be at least t, where t is the
number of true elements in mask. If mask is a scalar with value true,
vector must have at least as many elements as there are in array.
Elements in vector are used to fill out the result array if there are not
enough elements selected by mask.
Results
The result is a rank-one array with the same type and kind parameters as array. If vector is present, the size
of the result is that of vector. Otherwise, the size of the result is the number of true elements in mask, or the
number of elements in array (if mask is a scalar with value true).
Elements in array are processed in array element order to form the result array. Element i of the result is the
element of array that corresponds to the ith true element of mask. If vector is present and has more
elements than there are true values in mask, any result elements that are empty (because they were not
true according to mask) are set to the corresponding values in vector.
1729
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
N is the array
[ 0 8 0 ]
[ 0 0 0 ]
[ 7 0 0 ].
PACK (N, MASK=N .NE. 0, VECTOR=(/1, 3, 5, 9, 11, 13/)) produces the result (7, 8, 5, 9, 11, 13).
PACK (N, MASK=N .NE. 0) produces the result (7, 8).
The following shows another example:
See Also
UNPACK
PACKTIMEQQ
Portability Subroutine: Packs time and date values.
Module
USE IFPORT
Syntax
CALL PACKTIMEQQ (timedate,iyr,imon,iday,ihr,imin,isec)
The input values are interpreted as being in the time zone set on the local computer and following the
daylight savings rules for that time zone.
The packed time is the number of seconds since 00:00:00 Greenwich mean time, January 1, 1970. Because
packed time values can be numerically compared, you can use PACKTIMEQQ to work with relative date and
time values. Use UNPACKTIMEQQ to unpack time information. SETFILETIMEQQ uses packed time.
Example
USE IFPORT
INTEGER(2) year, month, day, hour, minute, second, &
hund
1730
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(4) timedate
CALL GETDAT (year, month, day)
CALL GETTIM (hour, minute, second, hund)
CALL PACKTIMEQQ (timedate, year, month, day, hour, &
minute, second)
END
See Also
UNPACKTIMEQQ
SETFILETIMEQQ
GETFILEINFOQQ
TIME portability routine
Syntax
!$OMP PARALLEL [clause[[,] clause] ... ]
loosely-structured-block
!$OMP END PARALLEL
-or-
!$OMP PARALLEL [clause[[,] clause] ... ]
strictly-structured-block
!$OMP END PARALLEL
1731
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The PARALLEL and END PARALLEL directive pair must appear in the same routine in the executable section of
the code.
The END PARALLEL directive denotes the end of the parallel region. There is an implied barrier at this point.
Only the primary thread of the team continues execution at the end of a parallel region.
The number of threads in the team can be controlled by the NUM_THREADS clause, the environment variable
OMP_NUM_THREADS, or by calling the run-time library routine OMP_SET_NUM_THREADS from a serial
portion of the program.
NUM_THREADS supersedes the OMP_SET_NUM_THREADS routine, which supersedes the
OMP_NUM_THREADS environment variable. Subsequent parallel regions, however, are not affected unless
they have their own NUM_THREADS clauses.
Once specified, the number of threads in the team remains constant for the duration of that parallel region.
If the dynamic threads mechanism is enabled by an environment variable or a library routine, then the
number of threads requested by the NUM_THREADS clause is the maximum number to use in the parallel
region.
The code contained within the dynamic extent of the parallel region is executed on each thread, and the code
path can be different for different threads.
If a thread executing a parallel region encounters another parallel region, it creates a new team and becomes
the primary thread of that new team. By default, nested parallel regions are always serialized and executed
by a team of one thread.
Example
You can use the PARALLEL directive in coarse-grain parallel programs. In the following example, each thread
in the parallel region decides what part of the global array X upon which to work based on the thread
number:
1732
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Assuming you previously used the environment variable OMP_NUM_THREADS to set the number of threads
to six, you can change the number of threads between parallel regions as follows:
CALL OMP_SET_NUM_THREADS(3)
!$OMP PARALLEL
...
!$OMP END PARALLEL
CALL OMP_SET_NUM_THREADS(4)
!$OMP PARALLEL DO
...
!$OMP END PARALLEL DO
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
OpenMP* Run-time Library Routines for Fortran
PARALLEL DO
SHARED Clause
Parallel Processing Model for information about Binding Sets
Syntax
!DIR$ PARALLEL [clause[[,] clause] ... ]
!DIR$ NOPARALLEL
• ALWAYS [ASSERT]
• FIRSTPRIVATE (list)
Provides a superset of the functionality provided by the PRIVATE
clause. Variables that appear in a FIRSTPRIVATE list are subject to
PRIVATE clause semantics. In addition, private (local) copies of
each variable in the different iterations are initialized to the value
the variable had upon entering the parallel loop.
• LASTPRIVATE (list)
Provides a superset of the functionality provided by the PRIVATE
clause. Variables that appear in a LASTPRIVATE list are subject to
PRIVATE clause semantics. In addition, once the parallel loop is
exited, each variable has the value that resulted from the
sequentially last iteration of the parallel loop.
• NUM_THREADS (scalar_integer_expression)
Specifies the number of threads to be used to parallelize the
immediately following DO loop. The scalar_integer_expression
must evaluate to a positive scalar integer value. Only a single
NUM_THREADS clause can appear in the directive. Once specified,
the number of threads used remains constant for the duration of
that parallelized DO loop.
1733
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• PRIVATE (list)
Declares specified variables to be private to each thread in a team.
The declared variables become private to a task.
list Is one or more items in the form: var [:expr]…. Each list item must be
separated by a comma.
• If var is an array, then only its first expr elements are privatized.
If expr is omitted, the entire array is privatized.
• If var is a pointer, then the first expr elements are privatized
(element size is provided by the pointer's target type). If expr is
omitted, only the pointer variable itself is privatized.
• Program behavior is undefined if expr evaluates to a non-positive
value, or if it exceeds the array size.
PARALLEL helps the compiler to resolve dependencies, facilitating auto-parallelization of the immediately
following DO loop. It instructs the compiler to ignore dependencies that it assumes may exist and which
would prevent correct parallelization in the loop. However, if dependencies are proven, they are not ignored.
In addition, PARALLEL ALWAYS overrides the compiler heuristics that estimate the likelihood that
parallelization of a loop will increase performance. It allows a loop to be parallelized even if the compiler
thinks parallelization may not improve performance. If the ASSERT keyword is added, the compiler will
generate an error-level assertion message saying that the compiler analysis and cost model indicate that the
loop cannot be parallelized.
NOPARALLEL prevents auto-parallelization of the immediately following DO loop.
These directives take effect only if you specify the compiler option that enables auto-parallelization.
Caution
The directive PARALLEL ALWAYS should be used with care. Overriding the heuristics of the compiler
should only be done if you are absolutely sure the parallelization will improve performance.
Example
program main
parameter (n=100)
integer x(n), a(n), k
!DIR$ NOPARALLEL
do i=1,n
1734
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
x(i) = i
enddo
!DIR$ PARALLEL LASTPRIVATE (k)
do i=1,n
a( x(i) ) = i
k = x(i)
enddo
print *, k ! print 100, the value of x(n)
end
See Also
General Compiler Directives
PARALLEL DO
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a parallel region containing
a single DO directive.
Syntax
!$OMP PARALLEL DO [clause[[,] clause] ... ]
do-loop
[!$OMP END PARALLEL DO]
If the END PARALLEL DO directive is not specified, the PARALLEL DO is assumed to end with the DO loop that
immediately follows the PARALLEL DO directive. If used, the END PARALLEL DO directive must appear
immediately after the end of the DO loop.
The semantics are identical to explicitly specifying a PARALLEL directive immediately followed by a DO
directive.
Example
In the following example, the loop iteration variable is private by default and it is not necessary to explicitly
declare it. The END PARALLEL DO directive is optional:
!$OMP PARALLEL DO
DO I=1,N
B(I) = (A(I) + A(I-1)) / 2.0
END DO
!$OMP END PARALLEL DO
The following example shows how to use the REDUCTION clause in a PARALLEL DO directive:
1735
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A = A + ALOCAL
B = B + BLOCAL
END DO
!$OMP END PARALLEL DO
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL DO SIMD
OpenMP* Fortran Compiler Directive: Specifies a
PARALLEL construct that contains one DO SIMD
construct and no other statement.
Syntax
!$OMP PARALLEL DO SIMD [clause[[,] clause] ... ]
do-loop
[!$OMP END PARALLEL DO SIMD]
clause Can be any of the clauses accepted by the PARALLEL, DO, or SIMD
directives.
If the END PARALLEL DO SIMD directive is not specified, an END PARALLEL DO SIMD directive is assumed at
the end of do-loop.
You cannot specify NOWAIT in a PARALLEL DO SIMD directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL LOOP
OpenMP* Fortran Compiler Directive: Specifies a
shortcut for indicating that a loop or loop nest can
execute concurrently across multiple threads. This
feature is only available for ifx.
Syntax
!$OMP PARALLEL LOOP [clause[[,] clause]... ]
do-loop
1736
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical form. The DO loop iteration variable must be
of type integer.
This combined directive is semantically equivalent to a LOOP construct that immediately follows a PARALLEL
directive. All restrictions for PARALLEL and LOOP constructs apply to this combined construct.
If used, the END PARALLEL LOOP directive must appear immediately after the end of the loop. If you do not
specify an END PARALLEL LOOP directive, an END PARALLEL LOOP directive is assumed at the end of the do-
loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL construct
LOOP construct
PARALLEL MASKED
OpenMP* Fortran Compiler Directive: Creates a
PARALLEL construct containing a MASKED construct,
with no Fortran statements in the PARALLEL construct
which are not also in the MASKED construct. This
feature is only available for ifx.
Syntax
!$OMP PARALLEL MASKED [clause[[,] clause]... ]
loosely-structured-block
!$OMP END PARALLEL MASKED
-or-
!$OMP PARALLEL MASKED [clause[[,] clause]... ]
strictly-structured-block
!$OMP END PARALLEL MASKED
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASKED construct
nested inside of it. The semantics are identical to a MASKED construct specified immediately after a
PARALLEL construct; the only Fortran statements in the construct are inside the block.
All restrictions for PARALLEL and MASKED constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
1737
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP PARALLEL MASKED TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASKED TASKLOOP]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASKED TASKLOOP
construct nested inside of it. The semantics are identical to a MASKED TASKLOOP construct specified
immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASKED TASKLOOP constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASKED TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification.
Syntax
!$OMP PARALLEL MASKED TASKLOOP SIMD [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASKED TASKLOOP SIMD]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASKED TASKLOOP
SIMD construct nested inside of it. The semantics are identical to a MASKED TASKLOOP SIMD construct
specified immediately after a PARALLEL construct.
1738
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
All restrictions for PARALLEL and MASKED TASKLOOP SIMD constructs apply to this combined construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASKED TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification.
PARALLEL MASTER
OpenMP* Fortran Compiler Directive:
(Deprecated; see PARALLEL MASKED) Creates a
PARALLEL construct containing a MASTER construct,
with no Fortran statements in the PARALLEL construct
that are not also in the MASTER construct. This
feature is only available for ifx.
Syntax
!$OMP PARALLEL MASTER [clause[[,] clause]... ]
loosely-structured-block
!$OMP END PARALLEL MASTER
-or-
!$OMP PARALLEL MASTER [clause[[,] clause]... ]
strictly-structured-block
!$OMP END PARALLEL MASTER
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASTER construct
nested inside of it. The semantics are identical to a MASTER construct specified immediately after a
PARALLEL construct; the only Fortran statements in the construct are inside block.
All restrictions for PARALLEL and MASTER constructs apply to this combined construct.
The PARALLEL MASTER directive is deprecated; you should use the PARALLEL MASKED directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASTER directive
1739
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP PARALLEL MASTER TASKLOOP [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASTER TASKLOOP]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASTER TASKLOOP
construct nested inside of it. The semantics are identical to a MASTER TASKLOOP construct specified
immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASTER TASKLOOP constructs apply to this combined construct.
The PARALLEL MASTER TASKLOOP directive is deprecated; you should use the PARALLEL MASKED TASKLOOP
directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASTER TASKLOOP directive
To learn more about canonical form loops, see the OpenMP* specification.
Syntax
!$OMP PARALLEL MASTER TASKLOOP SIMD [clause[[,] clause]... ]
loop-nest
[!$OMP END PARALLEL MASTER TASKLOOP SIMD]
This combined directive provides a shortcut for specifying a PARALLEL construct with a MASTER TASKLOOP
SIMD construct nested inside of it. The semantics are identical to a MASTER TASKLOOP SIMD construct
specified immediately after a PARALLEL construct.
All restrictions for PARALLEL and MASTER TASKLOOP SIMD constructs apply to this combined construct.
1740
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PARALLEL MASTER TASKLOOP SIMD directive is deprecated; you should use the PARALLEL MASKED
TASKLOOP SIMD directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL directive
MASTER TASKLOOP SIMD directive
To learn more about canonical form loops, see the OpenMP* specification.
PARALLEL SECTIONS
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a parallel region containing
a single SECTIONS directive. The semantics are
identical to explicitly specifying a PARALLEL directive
immediately followed by a SECTIONS directive.
Syntax
!$OMP PARALLEL SECTIONS [clause[[,] clause] ...]
[!$OMP SECTION]
block
[!$OMP SECTION
block]...
!$OMP END PARALLEL SECTIONS
Example
In the following example, subroutines XAXIS, YAXIS, and ZAXIS can be executed concurrently:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL WORKSHARE
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a parallel region containing
a single WORKSHARE directive.
1741
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP PARALLEL WORKSHARE [clause[[,] clause] ... ]
loosely-structured-block
!$OMP END PARALLEL WORKSHARE
-or-
!$OMP PARALLEL WORKSHARE [clause[[,] clause] ... ]
strictly-structured-block
!$OMP END PARALLEL WORKSHARE
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARAMETER
Statement and Attribute: Defines a named
constant.
Syntax
The PARAMETER attribute can be specified in a type declaration statement or a PARAMETER statement, and
takes one of the following forms:
Type Declaration Statement:
type, [att-ls,] PARAMETER [, att-ls] :: c =expr[, c = expr] ...
Statement:
PARAMETER [( ]c= expr[, c= expr] ... [) ]
Description
The type, type parameters, and shape of the named constant are determined in one of the following ways:
• By an explicit type declaration statement in the same scoping unit.
• By the implicit typing rules in effect for the scoping unit. If the named constant is implicitly typed, it can
appear in a subsequent type declaration only if that declaration confirms the implicit typing.
For example, consider the following statement:
PARAMETER (MU=1.23)
1742
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
According to implicit typing, MU is of integer type, so MU=1. For MU to equal 1.23, it should previously be
declared REAL in a type declaration or be declared in an IMPLICIT statement.
A named array constant defined by a PARAMETER statement must have its rank specified in a previous
specification statement.
A named constant must not appear in a format specification or as the character count for Hollerith constants.
For compilation purposes, writing the name is the same as writing the value.
If the named constant is used as the length specifier in a CHARACTER declaration, it must be enclosed in
parentheses.
The name of a constant cannot appear as part of another constant, although it can appear as either the real
or imaginary part of a complex constant.
You can only use the named constant within the scoping unit containing the defining PARAMETER statement.
Any named constant that appears in the constant expression must have been defined previously in the same
type declaration statement (or in a previous type declaration statement or PARAMETER statement), or made
accessible by use or host association.
An entity with the PARAMETER attribute must not be a variable, a coarray, or a procedure.
Omission of the parentheses in a PARAMETER statement is an extension controlled by compiler option
altparam. In this form, the type of the name is taken from the form of the constant rather than from implicit
or explicit typing of the name.
Example
The following example shows a type declaration statement specifying the PARAMETER attribute:
1743
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!
! PARAMETER in attribute syntax
REAL, PARAMETER :: mass=47.3, pi=3.14159, loads=10.0, mass=32.2
See Also
DATA
Type Declarations
Compatible attributes
Constant Expressions
IMPLICIT
Alternative syntax for the PARAMETER statement
altparam compiler option
PARITY
Transformational Intrinsic Function (Generic):
Reduces an array by using an exclusive OR (.NEQV.)
operation.
Syntax
result = PARITY (mask)
result = PARITY (mask, dim)
dim (Input) Must be a scalar integer with a value in the range 1 <= dim
<= n, where n is the rank of mask.
Results
The result has the same type and kind parameters as mask. It is scalar if dim is not specified; otherwise, the
result has rank n - 1 and shape [d1, d2, ..., ddim-1, ddim+1 , ..., dn] where [d1, d2,..., dn] is the shape of mask.
The result of PARITY(mask) has the value .TRUE. if an odd number of the elements of mask are true;
otherwise, .FALSE..
If mask has rank one, PARITY(mask, dim) is equal to PARITY(mask). Otherwise, the value of element (s1,
s2, ..., sdim-1, sdim+1 , ..., sn) of PARITY(mask, dim) is equal to PARITY (mask (s1, s2, ..., sdim-1 , :, sdim+1 , ...,
sn)).
Example
If A is the array
[ T F T ]
[ T T F ]
and T has the value .TRUE. and F has the value .FALSE., then
PARITY (A, DIM=1) has the value [F, T, T] and PARITY (A, DIM=2) has the value [F, F].
PAUSE
Statement: Temporarily suspends program execution
and lets you execute operating system commands
during the suspension. The PAUSE statement is a
deleted feature in the Fortran Standard. Intel® Fortran
fully supports features deleted in the Fortran
Standard.
1744
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
PAUSE [pause-code]
If you specify pause-code, the PAUSE statement displays the specified message and then displays the default
prompt.
If you do not specify pause-code, the system displays the following default message:
FORTRAN PAUSE
The following prompt is then displayed:
• On Windows* systems:
PAUSE prompt>
For alternate methods of pausing while reading from and writing to a device, see READ and WRITE.
Effect on Windows* Systems
The program waits for input on stdin. If you enter a blank line, execution resumes at the next executable
statement.
Anything else is treated as a DOS command and is executed by a system( ) call. The program loops, letting
you execute multiple DOS commands, until a blank line is entered. Execution then resumes at the next
executable statement.
Effect on Linux* and macOS Systems
The effect of PAUSE differs depending on whether the program is a foreground or background process, as
follows:
• If a program is a foreground process, the program is suspended until you enter the CONTINUE command.
Execution then resumes at the next executable statement.
Any other command terminates execution.
• If a program is a background process, the behavior depends on stdin, as follows:
• If stdinis redirected from a file, the system displays the following (after the pause code and prompt):
Example
The following examples show valid PAUSE statements:
PAUSE 701
PAUSE 'ERRONEOUS RESULT DETECTED'
1745
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CHARACTER*24 filename
PAUSE 'Enter DIR to see available files or press RETURN' &
&' if you already know filename.'
READ(*,'(A\)') filename
OPEN(1, FILE=filename)
. . .
See Also
STOP
SYSTEM
Deleted and Obsolescent Language Features
PEEKCHARQQ
Run-Time Function: Checks the keystroke buffer for
a recent console keystroke and returns .TRUE. if there
is a character in the buffer or .FALSE. if there is not.
Module
USE IFCORE
Syntax
result = PEEKCHARQQ( )
Results
The result type is LOGICAL(4). The result is .TRUE. if there is a character waiting in the keyboard buffer;
otherwise, .FALSE..
To find out the value of the key in the buffer, call GETCHARQQ. If there is no character waiting in the buffer
when you call GETCHARQQ, GETCHARQQ waits until there is a character in the buffer. If you call
PEEKCHARQQ first, you prevent GETCHARQQ from halting your process while it waits for a keystroke. If there
is a keystroke, GETCHARQQ returns it and resets PEEKCHARQQ to .FALSE..
Example
USE IFCORE
LOGICAL(4) pressed / .FALSE. /
DO WHILE (.NOT. pressed)
WRITE(*,*) ' Press any key'
pressed = PEEKCHARQQ ( )
END DO
END
See Also
GETCHARQQ
GETSTRQQ
FGETC
GETC
PERROR
Run-Time Subroutine: Sends a message to the
standard error stream, preceded by a specified string,
for the last detected error.
1746
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFCORE
Syntax
CALL PERROR (string)
Example
USE IFCORE
character*24 errtext
errtext = 'In my opinion, '
. . .
! any error message generated by errtext is
! preceded by 'In my opinion, '
Call PERROR (errtext)
See Also
GERROR
IERRNO
POINTER - Fortran
Statement and Attribute: Specifies that an object or
a procedure is a pointer (a dynamic variable). A
pointer does not contain data, but points to a scalar or
array variable where data is stored. A pointer has no
initial storage set aside for it; memory storage is
created for the pointer as a program runs.
Syntax
The POINTER attribute can be specified in a type declaration statement or a POINTER statement, and takes
one of the following forms:
Type Declaration Statement:
type,[att-ls,] POINTER [, att-ls] :: ptr[(d-spec)][ , ptr[(d-spec)]]...
Statement:
POINTER [::]ptr[(d-spec)][ , ptr[(d-spec)]] ...
ptr Is the name of the pointer. The pointer cannot be declared with the
INTENT or PARAMETER attributes.
Description
No storage space is created for a data pointer until it is allocated with an ALLOCATE statement or until it is
assigned to a allocated target.
1747
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each pointer has an association status, which tells whether the pointer is currently associated with a target
object. When a pointer is initially declared, its status is undefined. You can use the ASSOCIATED intrinsic
function to find the association status of a pointer if the pointer's association status is defined.
Entities with the POINTER attribute can be associated with different data objects or procedures during
execution of a program.
A data pointer must not be referenced or defined unless it is pointer associated with a target object that can
be referenced or defined. A procedure pointer must not be referenced unless it is pointer associated with a
target procedure.
If the data pointer is an array, and it is given the DIMENSION attribute elsewhere in the program, it must be
declared as a deferred-shape array.
A pointer cannot be specified in an EQUIVALENCE or NAMELIST statement. A pointer in a DATA statement
can only be associated with NULL().
A procedure that has both the EXTERNAL and POINTER attributes is a procedure pointer.
An entity with the POINTER attribute must not have the ALLOCATABLE, INTRINSIC, or TARGET attribute, and
it must not be a coarray.
Fortran pointers are not the same as integer pointers. For more information, see the POINTER - Integer
statement.
Example
The following example shows type declaration statements specifying the POINTER attribute:
TYPE(SYSTEM) :: TODAYS
POINTER :: TODAYS, A(:,:)
The following shows another example:
1748
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
WRITE (*,'(/1x,a)') 'ARROW is repointed & resized, all the 5s are lost'
WRITE (*,'(1x,8f8.0)') arrow
NULLIFY (arrow)
IF (.NOT.ASSOCIATED(arrow)) WRITE (*,'(/a/)') ' ARROW is not pointed'
See Also
ALLOCATE
ASSOCIATED
DEALLOCATE
NULLIFY
TARGET
Deferred-Shape Arrays
Pointer Assignments
Pointer Association
Pointer Arguments
NULL
Integer POINTER statement
Type Declarations
Compatible attributes
POINTER - Integer
Statement: Establishes pairs of objects and pointers,
in which each pointer contains the address of its
paired object. This statement is different from the
Fortran POINTER statement.
Syntax
POINTER (pointer,pointee) [,(pointer,pointee)] . . .
1749
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTENT POINTER
• A pointee cannot be:
• A dummy argument
• A function return value
• A record field or an array element
• Zero-sized
• An automatic object
• The name of a generic interface block
• If a pointee is of derived type, it must be of sequence type.
Example
POINTER (p, k)
INTEGER j(2)
See Also
POINTER - Fortran
LOC
MALLOC
1750
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
FREE
POPCNT
Elemental Intrinsic Function (Generic): Returns
the number of 1 bits in the integer argument.
Syntax
result = POPCNT (i)
Results
The result type and kind are the same as i. The result value is the number of 1 bits in the binary
representation of the integer i.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If the value of I is B'0...00011010110', the value of POPCNT(I) is 5.
POPPAR
Elemental Intrinsic Function (Generic): Returns
the parity of the integer argument.
Syntax
result = POPPAR (i)
Results
The result type and kind are the same as i. The result value is 1 if there are an odd number of 1 bits in the
binary representation of the integer I. The result value is zero if there are an even number.
POPPAR( i) is the same as 1 .AND. POPCNT( i).
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
If the value of I is B'0...00011010110', the value of POPPAR(I) is 1.
PRECISION
Inquiry Intrinsic Function (Generic): Returns the
decimal precision in the model representing real
numbers with the same kind parameter as the
argument.
Syntax
result = PRECISION (x)
1751
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default integer. The result has the value INT((DIGITS( x) - 1) *
LOG10(RADIX( x))). If RADIX( x) is an integral power of 10, 1 is added to the result.
Example
If X is a REAL(4) value, PRECISION(X) has the value 6. The value 6 is derived from INT ((24-1) * LOG10
(2.)) = INT (6.92...). For more information on the model for REAL(4), see Model for Real Data.
Syntax
!DIR$ PREFETCH [var1[: hint1[: distance1]] [,var2[: hint2[: distance2]]]...]
!DIR$ PREFETCH *: hint[: distance]
!DIR$ NOPREFETCH [var1[,var2]...]
To use these directives, compiler option [q or Q]opt-prefetch must be set. Note that this option is turned
on by default if the compiler general optimization level is O2 or higher.
This directive affects the DO loop it precedes.
If you specify PREFETCH *, the hint and optional distance are used to prefetch all array accesses in the DO
loop.
If you specify NOPREFETCH with no arguments, the following occurs:
• All arrays accessed in the DO loop will NOT be prefetched.
• It negates all other PREFETCH directives for the following DO loop.
If a loop includes expression A(j), placing !DIR$ PREFETCH A:0:d in front of the loop instructs the compiler to
insert a vprefetch0 instruction for A within the loop that is d iterations ahead.
The PREFETCH directive takes precedence over the [q or Q]opt-prefetch-distance options.
1752
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! Issue no prefetches for A1
! Issue vector prefetch from L2 and higher caches for B with a distance
! of 16 vectorized iterations ahead
! Issue vector prefetch from L1 and higher caches for B with a distance
! of 4 vectorized iterations ahead
!DIR$ NOPREFETCH A1
!DIR$ PREFETCH B:1:16
!DIR$ PREFETCH B:0:4
DO J = 1,N
A1(J) = B(J-1) + B(J+1)
END DO
In the following example, array A will be prefetched with hint 0 and distance 5, arrays B and C will be
prefetched with hint 1 and distance 10, and array D will not be prefetched:
See Also
General Compiler Directives
Syntax
!$OMP PREFETCH ([prefetch-hint-modifier:] array-section [, array-section] ...) [clause]
• 0: no-op
• 1: L1 uncached and L3 uncached
• 2: L1 uncached and L3 chached
• 3: l1 cached and L3 uncached
• 4: L1 cached and L3 cached
• 5: L1 streaming load and L3 uncached
• 6: L1 streaming load and L3 cached
• 7: L1 invalidate-after-read and L3 cached
1753
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IF (scalar-logical-expression)
Description
The PREFETCH directive issues a prefetch to preload the data specified by array-section. If the IF clause is
present, the prefetch is done only when the scalar-logical-expression evaluates to .TRUE..
Example
The following code prefetches and caches elements 17 thru 1024 of the arrays y and z to L1 and L3 cache.
Each element is prefetched 16 iterations prior to its use in the computation y(i) + z(i).
SUBROUTINE sub ()
IMPLICIT NONE
REAL,DIMENSION(1024) :: y, x, z
INTEGER :: i
. . .
DO m = 1, 1024
!$omp PREFETCH DATA (4: y(i+16), z(i+16)) &
!$omp& IF ((MOD(i, 16) .eq. 1) .and. ((i+15 .le. 1024))
x(i) = y(i) + z(i)
END DO
. . .
END SUBROUTINE
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PRESENT
Inquiry Intrinsic Function (Generic): Returns
whether or not an optional dummy argument is
present, that is, whether it has an associated actual
argument.
Syntax
result = PRESENT (a)
Results
The result is a scalar of type default logical. The result is .TRUE. if a is present; otherwise, the result
is .FALSE..
Example
Consider the following:
MODULE MYMOD
CONTAINS
SUBROUTINE CHECK (X, Y)
REAL X, Z
REAL, OPTIONAL :: Y
...
IF (PRESENT (Y)) THEN
1754
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Z = Y
ELSE
Z = X * 2
END IF
END SUBROUTINE CHECK
END MODULE MYMOD
...
USE MYMOD
CALL CHECK (15.0, 12.0) ! Causes Z to be set to 12.0
CALL CHECK (15.0) ! Causes Z to be set to 30.0
The following shows another example:
See Also
OPTIONAL
Optional Arguments
PRINT
Statement: Displays output on the screen. TYPE is a
synonym for PRINT. All forms and rules for the PRINT
statement also apply to the TYPE statement.
Syntax
The PRINT statement is the same as a formatted, sequential WRITE statement, except that the PRINT
statement must never transfer data to user-specified I/O units. You can override this restriction by using
environment variable FOR_PRINT.
A PRINT statement takes one of the following forms:
Formatted:
PRINT form[, io-list]
Formatted - List-Directed:
PRINT *[, io-list]
Formatted - Namelist:
PRINT nml
1755
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
In the following example, one record (containing four fields of data) is printed to the implicit output device:
See Also
PUTC
READ
WRITE
FORMAT
Data Transfer I/O Statements
File Operation I/O Statements
PRINT as a value in CLOSE
PRIORITY
Parallel Directive Clause: Specifies that the
generated tasks have the indicated priority for
execution.
Syntax
PRIORITY (priority-value)
priority-value Provides a hint for the priority of task execution order. priority-value
must evaluate to a non-negative scalar integer value.
Among all tasks ready to be executed, higher priority tasks (those with a higher numerical value of priority-
value) are recommended to execute before lower priority tasks. A program that relies on task execution
order being determined by this priority-value may have unspecified behavior.
At most one PRIORITY clause can appear in the directive.
If this clause is not specified, tasks generated by the construct have a task priority of zero (the default).
PRIVATE Clause
Parallel Directive Clause: Declares one or more
variables to be private to each thread in a team.
Syntax
PRIVATE (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
This clause allows each thread to have its own copy of the variable and makes it a local variable to the
thread.
1756
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• Variables that appear in a PRIVATE, FIRSTPRIVATE, or REDUCTION clause in a parallel construct can also
appear in a PRIVATE clause in an enclosed parallel, task, or worksharing construct.
• Variables that appear in a PRIVATE or FIRSTPRIVATE clause in a task construct can also appear in a
PRIVATE clause in an enclosed parallel or task construct.
• Variables that appear in a PRIVATE, FIRSTPRIVATE, LASTPRIVATE, or REDUCTION clause in a worksharing
construct can also appear in a PRIVATE clause in an enclosed parallel or task construct.
1757
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
Variables that are used as counters for explicit or implicit DO loops or FORALL commands, or common
blocks that are specified to be THREADPRIVATE become automatically private to each thread, even
though they are not explicitly included inside a PRIVATE clause at the beginning of the scope of the
parallel region.
Example
Consider the following:
See Also
FIRSTPRIVATE clause
LASTPRIVATE clause
PRIVATE Statement
Statement and Attribute: Specifies that entities in a
module can be accessed only within the module itself.
Syntax
The PRIVATE attribute can be specified in a type declaration statement or a PRIVATE statement, and takes
one of the following forms:
Type Declaration Statement:
type,[att-ls,] PRIVATE [, att-ls] :: entity[, entity]...
Statement:
PRIVATE [[::] entity[, entity] ...]
Description
The PRIVATE attribute can only appear in the scoping unit of a module.
1758
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Only one PRIVATE statement without an entity list is permitted in the scoping unit of a module; it sets the
default accessibility of all entities in the module and any entities accessed from a module by USE association
whose names do not appear in a PUBLIC statement.
A module name can appear at most once in all the PUBLIC or PRIVATE statements in a scoping unit. If a
module name is specified in a PRIVATE statement, the module name must have appeared in a USE statement
within the same scoping unit.
A PRIVATE attribute can be specified on the TYPE statement of a derived-type definition in a module. This
specifies the derived-type definition is not accessible outside the module or the module's descendants.
A PRIVATE statement without an entity-list can appear in the component-definition part of a derived-type
definition, specifying the default accessibility of all components as PRIVATE. A PRIVATE statement with no
entity-list can appear in the type-bound-procedure-part of a derived-type definition specifying the default
accessibility of all type-bound procedures of that type as PRIVATE. In such cases, the default accessibility of
components and type-bound procedures can be overridden by explicitly declaring a component or type-
bound procedure PUBLIC.
A PRIVATE attribute can be specified in the statement declaring a component or a type-bound procedure of a
derived type. This specifies that the component or type-bound procedure is not accessible outside the
module or its descendants.
If no PRIVATE statements are specified in a module, the default is PUBLIC accessibility. Entities with PUBLIC
accessibility can be accessed from outside the module by means of a USE statement.
If a derived type is declared PRIVATE in a module, its components are also PRIVATE. The derived type and its
components are accessible to any subprograms within the defining module and the module's descendants
through host association, but they are not accessible from outside the module.
If the derived type is declared PUBLIC in a module, but its components are declared PRIVATE, any scoping
unit accessing the module though use association (or host association) can access the derived-type
definition, but not its components.
If a module procedure has a dummy argument or a function result of a type that has PRIVATE accessibility,
the module procedure must have PRIVATE accessibility. If the module has a generic identifier, it must also be
declared PRIVATE.
If a procedure has a generic identifier, the accessibility of the procedure's specific name is independent of the
accessibility of its generic identifier. One can be declared PRIVATE and the other PUBLIC.
The accessibility of the components of a type is independent of the accessibility of the type name. The
following combinations are possible:
The accessibility of a type does not affect, and is not affected by, the accessibility of its components and
type-bound procedures. If a type definition is private, then the type name, and thus the structure constructor
for the type, are accessible only within the module containing the definition.
Example
The following examples show type declaration statements specifying the PUBLIC and PRIVATE attributes:
REAL, PRIVATE :: A, B, C
INTEGER, PUBLIC :: LOCAL_SUMS
1759
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE SOME_DATA
REAL ALL_B
PUBLIC ALL_B
TYPE RESTRICTED_DATA
REAL LOCAL_C(50)
END TYPE RESTRICTED_DATA
PRIVATE RESTRICTED_DATA
END MODULE
The following derived-type declaration statement indicates that the type is restricted to the module:
MODULE MATTER
TYPE ELEMENTS
PRIVATE
INTEGER C, D
END TYPE
...
END MODULE MATTER
In this case, components C and D are private to type ELEMENTS, but type ELEMENTS is not private to
MODULE MATTER. Any program unit that uses the module MATTER, can declare variables of type ELEMENTS,
and pass as arguments values of type ELEMENTS.
The following shows another example:
1760
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Type Declarations
Compatible attributes
PROCEDURE
Statement: Declares procedure pointers, dummy
procedures, and external procedures.
Syntax
PROCEDURE ([proc-interface]) [[, proc-attr-spec]... :: ] proc-decl-list
Description
A PROCEDURE statement declares nonintrinsic procedures (procedure pointers, dummy procedures, internal
procedures, and external procedures). If the procedure is not a procedure pointer, a module procedure, or an
internal procedure, it specifies the EXTERNAL attribute for the procedure.
1761
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
You cannot use the PROCEDURE statement to identify a BLOCK DATA subprogram.
If => null-init appears, it specifies that the initial association status of the corresponding procedure entity is
disassociated. It also implies the SAVE attribute.
You can also declare procedures by using an EXTERNAL statement or a procedure component definition
statement.
If the BIND attribute is specified for a procedure, each dummy argument must be:
If the BIND attribute is specified for a function, the function result must be an interoperable scalar variable.
A Fortran procedure is interoperable if it has the BIND attribute; that is, if its interface is specified with a
language-binding-spec.
The ALLOCATABLE or POINTER attribute must not be specified for a default-initialized dummy argument of a
procedure that has a BIND attribute.
A dummy argument of a procedure that has a BIND attribute must not have both the OPTIONAL and VALUE
attributes.
A variable that is a dummy argument of a procedure that has a BIND attribute must be of interoperable type
or assumed type.
When a procedure whose interface has the BIND attribute is called, any actual argument corresponding to a
dummy argument with the ALLOCATABLE or POINTER attribute is passed by C descriptor. Similarly, if a
Fortran procedure with a BIND attribute has such dummy arguments, they are received by C descriptor.
Example
Consider the following:
PROCEDURE (INTEGER) X
INTEGER, EXTERNAL :: X
Consider the following:
ABSTRACT INTERFACE
FUNCTION SIM_FUNC (X)
REAL, INTENT (IN) :: X
REAL :: SIM_FUNC
END FUNCTION SIM_FUNC
END INTERFACE
INTERFACE
SUBROUTINE SUB2 (X)
REAL, INTENT (IN) :: X
END SUBROUTINE SUB2
END INTERFACE
1762
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following shows external and dummy procedures with explicit interfaces:
TYPE MEMO_TYPE
PROCEDURE (SIM_FUNC), POINTER :: COMPONENT
END TYPE MEMO_TYPE
The following shows a variable of the above type:
See Also
Procedure Interfaces
Type-Bound Procedures
ABSTRACT INTERFACE
INTERFACE
EXTERNAL attribute
PROCESSOR Clause
Parallel Directive Clause: Tells the compiler to
create a vector version of the routine for the specified
processor. When running on a processor that does not
match "cpuid", a scalar version will be invoked
multiple times based on vector length.
Syntax
PROCESSOR (cpuid)
se4
_2
ato Intel Atom® processors with Intel® Streaming
m_s SIMD Extensions 4.2 (Intel SSE4.2) with
®
1763
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
o_s
se4
_1
cor Intel® Core™2 Duo processors with Intel®
e_2 Supplemental Streaming SIMD Extensions 3
_du (SSSE3)
o_s
sse
3
cor 2nd generation Intel® Core™ processor family
e_2 with support for Intel Advanced Vector
®
gen
_av
x
cor 3rd generation Intel® Core™ processor family
e_3 with support for Intel® Advanced Vector
rd_ Extensions (Intel® AVX) including the RDRND
gen instruction
_av
x
cor 4th generation Intel® Core™ processor family
e_4 with support for Intel® Advanced Vector
th_ Extensions 2 (Intel® AVX2) including the RDRND
gen instruction
_av
x
cor 4th generation Intel® Core™ processor family
e_4 with support for Intel® Advanced Vector
th_ Extensions 2 (Intel® AVX2) including the RDRND
gen instruction, and support for Intel® Transactional
Synchronization Extensions (Intel® TSX)
_av
x_t
sx
cor 5th generation Intel® Core™ processor family
e_5 with support for Intel® Advanced Vector
th_ Extensions 2 (Intel® AVX2) including the
gen RDSEED and Multi-Precision Add-Carry
Instruction Extensions (ADX) instructions
_av
x
1764
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
7_s instructions
se4
_2
gen Other Intel processors for IA-32 or Intel® 64
eri architecture or compatible processors not
c provided by Intel Corporation
1765
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ii_
no_
xmm
_re
gs
pen Intel® Pentium® M processors
tiu
m_m
pen Intel® Pentium® processors with MMX™
tiu technology
m_m
mx
pen Intel® Pentium® Pro processors
tiu
m_p
ro
sky Intel® microarchitecture code name Skylake.
lak This keyword targets the Client CPU without
e support for Intel® AVX-512 instructions.
vx5
12
The vector version of the routine that is created by the compiler is not affected by processor options specified
on the command line.
Multiple PROCESSOR clauses cause a syntax error.
See Also
DECLARE SIMD
ATTRIBUTES VECTOR
PRODUCT
Transformational Intrinsic Function (Generic):
Returns the product of all the elements in an entire
array or in a specified dimension of an array.
Syntax
result = PRODUCT (array [, mask])
result = PRODUCT (array, dim [, mask])
mask (Input; optional) Must be of type logical and conformable with array.
1766
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is not specified or array has rank one.
The following rules apply if dim is not specified:
• If PRODUCT(array) is specified, the result is the product of all elements of array. If array has size zero,
the result is 1.
• If PRODUCT(array, MASK= mask) is specified, the result is the product of all elements of array
corresponding to true elements of mask. If array has size zero, or every element of mask has the
value .FALSE., the result is 1.
The following rules apply if dim is specified:
• If array has rank one, the value is the same as PRODUCT(array[,MASK= mask]).
• An array result has a rank that is one less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
• The value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of PRODUCT(array, dim[, mask]) is equal to
PRODUCT(array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK= mask(s1, s2, ..., sdim-1, :, sdim+1, ..., sn)]).
Example
PRODUCT ((/2, 3, 4/)) returns the value 24 (the product of 2 * 3 * 4). PRODUCT ((/2, 3, 4/), DIM=1)
returns the same result.
PRODUCT (C, MASK=C .LT. 0.0) returns the product of the negative elements of C.
A is the array
[ 1 4 7 ]
[ 2 3 5 ].
PRODUCT (A, DIM=1) returns the value (2, 12, 35), which is the product of all elements in each column. 2 is
the product of 1 * 2 in column 1. 12 is the product of 4 * 3 in column 2, and so forth.
PRODUCT (A, DIM=2) returns the value (28, 30), which is the product of all elements in each row. 28 is the
product of 1 * 4 * 7 in row 1. 30 is the product of 2 * 3 * 5 in row 2.
If array has shape (2, 2, 2), mask is omitted, and dim is 1, the result is an array result with shape (2, 2)
whose elements have the following values.
1767
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SUM
PROGRAM
Statement: Identifies the program unit as a main
program and gives it a name.
Syntax
[PROGRAM name]
[specification-part]
[execution-part]
[CONTAINS
internal-subprogram-part]
END[PROGRAM [name]]
Description
The PROGRAM statement is optional. Within a program unit, a PROGRAM statement can be preceded only by
comment lines or an OPTIONS statement.
The END statement is the only required part of a program. If a name follows the END statement, it must be
the same as the name specified in the PROGRAM statement.
The program name is considered global and must be unique. It cannot be the same as any local name in the
main program or the name of any other program unit, external procedure, or common block in the
executable program.
A main program must not reference itself (either directly or indirectly).
Example
The following is an example of a main program:
PROGRAM TEST
INTEGER C, D, E(20,20) ! Specification part
CALL SUB_1 ! Executable part
...
CONTAINS
SUBROUTINE SUB_1 ! Internal subprogram
1768
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
...
END SUBROUTINE SUB_1
END PROGRAM TEST
The following shows another example:
PROGRAM MyProg
PRINT *, 'hello world'
END
PROTECTED
Statement and Attribute: Specifies limitations on
the use of module entities.
Syntax
The PROTECTED attribute can be specified in a type declaration statement or a PROTECTED statement, and
takes one of the following forms:
Type Declaration Statement:
type, [att-ls, ] PROTECTED [, att-ls] :: entity[, entity] ...
Statement:
PROTECTED [::]entity[, entity] ...
The PROTECTED attribute can only appear in the specification part of a module.
The PROTECTED attribute can only be specified for a procedure pointer or named variable that is not in a
common block.
A non-pointer object that has the PROTECTED attribute and is accessed by use association can not appear in
a variable definition or as the target in a pointer assignment statement.
A pointer object that has the PROTECTED attribute and is accessed by use association must not appear as
any of the following:
• A pointer-object in a NULLIFY statement
• A pointer-object in a pointer assignment statement
• An object in an ALLOCATE or DEALLOCATE statement
• An actual argument in a reference to a procedure if the associated dummy argument is a pointer with the
INTENT(OUT) or INTENT(INOUT) attribute.
The following restrictions apply outside of the module in which the entity has been given the PROTECTED
attribute:
• A non-pointer entity may not be defined or redefined.
• A pointer entity may not have its association status changed through the pointer.
• A data entity with the TARGET and the PROTECTED attribute that is USE associated may not appear in a
pointer initialization expression or a constructor if it corresponds to a pointer component.
Example
The following example shows a type declaration statement specifying the PROTECTED attribute:
INTEGER, PROTECTED :: D, E
1769
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE counter_mod
INTEGER, PROTECTED :: current = 0
CONTAINS
PROGRAM test_counter
USE counter_mod
PRINT *, next( ) ! Prints 1
current = 42 ! Error: variable is protected
END PROGRAM test_counter
See Also
Modules and Module Procedures
Type Declarations
Compatible attributes
Pointer Assignments
PSECT
General Compiler Directive: Modifies characteristics
of a common block.
Syntax
!DIR$ PSECT /common-name/ a[,a] ...
common-name Is the name of the common block. The slashes ( / ) are required.
BYTE 0
WORD 1
LONG 2
QUAD 3
OCTA 4
1770
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If one program unit changes one or more characteristics of a common block, all other units that reference
that common block must also change those characteristics in the same way.
The defaults are ALIGN=OCTA and WRT.
See Also
General Compiler Directives
PUBLIC
Statement and Attribute: Specifies that entities in a
module can be accessed from outside the module by
specifying a USE statement.
Syntax
The PUBLIC attribute can be specified in a type declaration statement or a PUBLIC statement, and takes one
of the following forms:
Type Declaration Statement:
type,[att-ls,] PUBLIC [, att-ls] :: entity [, entity]...
Statement:
PUBLIC [[::] entity [, entity] ...]
Description
The PUBLIC attribute can only appear in the scoping unit of a module.
1771
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Only one PUBLIC statement without an entity list is permitted in the scoping unit of a module; it sets the
default accessibility of all entities in the module and any entities accessed from a module by use association.
If no PRIVATE statements are specified in a module, the default is PUBLIC accessibility for all entities in the
module and entities accessible from other modules by use association.
A module name can appear at most once in all the PUBLIC or PRIVATE statements in a scoping unit. If a
module name is specified in a PUBLIC statement, the module name must have appeared in a USE statement
within the same scoping unit.
A PUBLIC attribute can be specified on the TYPE statement of a derived-type definition in a module. This
specifies that the derived-type definition is accessible by USE association where the module is used.
A PUBLIC attribute can be specified in the statement declaring a component or a type-bound procedure of a
derived type. This specifies that the component or type-bound procedure is accessible by USE association
where the module is used, even if the default accessibility of the components and type-bound procedures of
the derived type has been set to PRIVATE in the definition of the derived type.
If a derived type is declared PUBLIC in a module, but its components are declared PRIVATE, any scoping unit
accessing the module though use association (or host association) can access the derived-type definition, but
not its components.
If a module procedure has a dummy argument or a function result of a type that has PRIVATE accessibility,
the module procedure must have PRIVATE accessibility. If the module procedure has a generic identifier, it
must also be declared PRIVATE.
If a procedure has a generic identifier, the accessibility of the procedure's specific name is independent of the
accessibility of its generic identifier. One can be declared PRIVATE and the other PUBLIC.
The accessibility of the components of a type is independent of the accessibility of the type name. The
following combinations are possible:
The accessibility of a type does not affect, and is not affected by, the accessibility of its components and
type-bound procedures. If a type definition is private, then the type name, and thus the structure constructor
for the type, are accessible only within the module containing the derived-type definition or in the module's
descendants.
Example
The following examples show type declaration statements specifying the PUBLIC and PRIVATE attributes:
REAL, PRIVATE :: A, B, C
INTEGER, PUBLIC :: LOCAL_SUMS
The following is an example of the PUBLIC and PRIVATE statements:
MODULE SOME_DATA
REAL ALL_B
PUBLIC ALL_B
TYPE RESTRICTED_DATA
REAL LOCAL_C(50)
END TYPE RESTRICTED_DATA
PRIVATE RESTRICTED_DATA
END MODULE
1772
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
MODULE MATTER
TYPE ELEMENTS
PRIVATE
INTEGER C, D
END TYPE
...
END MODULE MATTER
In this case, components C and D are private to type ELEMENTS, but type ELEMENTS is not private to
MODULE MATTER. Any program unit that uses the module MATTER, can declare variables of type ELEMENTS,
and pass as arguments values of type ELEMENTS.
The following shows another example:
See Also
PRIVATE
MODULE
TYPE
Defining Generic Names for Procedures
USE
Use and Host Association
Type Declarations
Compatible attributes
PURE
Keyword: Asserts that a user-defined procedure has
no side effects.
Description
This kind of procedure is specified by using the prefix PURE or the prefix ELEMENTAL without the prefix
IMPURE in a FUNCTION or SUBROUTINE statement.
A pure procedure has no side effects. It has no effect on the state of the program, except for the following:
• For functions: It returns a value.
1773
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1774
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
K = 0
XTMP = -X
DO WHILE (ABS(XTMP) < 2.0 .AND. K < ITOL)
XTMP = XTMP**2 - X
K = K + 1
END DO
MANDELBROT = K
END FUNCTION
The following shows the preceding function used in an interface block:
INTERFACE
PURE INTEGER FUNCTION MANDELBROT(X)
COMPLEX, INTENT(IN) :: X
END FUNCTION MANDELBROT
END INTERFACE
The following shows a FORALL construct calling the MANDELBROT function to update all the elements of an
array:
See Also
FUNCTION
SUBROUTINE
FORALL
ELEMENTAL prefix
1775
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
PUTC
Portability Function: Writes a character to Fortran
external unit number 6.
Module
USE IFPORT
Syntax
result = PUTC (char)
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code.
Example
use IFPORT
integer(4) i4
character*1 char1
do i = 1,26
char1 = char(123-i)
i4 = putc(char1)
if (i4.ne.0) iflag = 1
enddo
See Also
GETC
WRITE
PRINT
FPUTC
Q to R
This section describes language features that start with Q or R.
Q to R
QCMPLX
Elemental Intrinsic Function (Specific): Converts
an argument to COMPLEX(16) type. This function
cannot be passed as an actual argument.
Syntax
result = QCMPLX (x[,y])
Results
The result type is COMPLEX(16) (or COMPLEX*32).
If only one noncomplex argument appears, it is converted into the real part of the result value and zero is
assigned to the imaginary part. If y is not specified and x is complex, the result value is CMPLX(REAL( x),
AIMAG( x)).
1776
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If two noncomplex arguments appear, the complex value is produced by converting the first argument into
the real part of the value, and converting the second argument into the imaginary part.
QCMPLX( x, y) has the complex value whose real part is REAL( x, kind=16) and whose imaginary part is
REAL( y, kind=16).
Example
QCMPLX (-3) has the value (-3.0Q0, 0.0Q0).
QCMPLX (4.1, 2.3) has the value (4.1Q0, 2.3Q0).
See Also
CMPLX
DCMPLX
FLOAT
INT
IFIX
REAL
SNGL
QEXT
Elemental Intrinsic Function (Generic): Converts
a number to quad precision (REAL(16)) type.
Syntax
result = QEXT (a)
Results
The result type is REAL(16) (REAL*16). Functions that cause conversion of one data type to another type
have the same effect as the implied conversion in assignment statements.
If a is of type REAL(16), the result is the value of the a with no conversion (QEXT(a) = a).
If a is of type integer or real, the result has as much precision of the significant part of a as a REAL(16) value
can contain.
If a is of type complex, the result has as much precision of the significant part of the real part of a as a
REAL(16) value can contain.
INTEGER(1) REAL(16)
INTEGER(2) REAL(16)
INTEGER(4) REAL(16)
INTEGER(8) REAL(16)
REAL(16) REAL(16)
COMPLEX(4) REAL(16)
1777
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
COMPLEX(8) REAL(16)
COMPLEX(16) REAL(16)
1These specific functions cannot be passed as actual arguments.
Example
QEXT (4) has the value 4.0 (rounded; there are 32 places to the right of the decimal point).
QEXT ((3.4, 2.0)) has the value 3.4 (rounded; there are 32 places to the right of the decimal point).
QFLOAT
Elemental Intrinsic Function (Generic): Converts
an integer to quad precision (REAL(16)) type.
Syntax
result = QFLOAT (a)
Results
The result type is REAL(16) (REAL*16).
Functions that cause conversion of one data type to another type have the same affect as the implied
conversion in assignment statements.
Example
QFLOAT (-4) has the value -4.0 (rounded; there are 32 places to the right of the decimal point).
QNUM
Elemental Intrinsic Function (Specific): Converts
a character string to a REAL(16) value. This function
cannot be passed as an actual argument.
Syntax
result = QNUM (i)
Results
The result type is REAL(16). The result value is the real value represented by the character string i.
Example
QNUM ("-174.23") has the value -174.23 of type REAL(16).
QRANSET
Portability Subroutine: Sets the seed for a
sequence of pseudo-random numbers.
Module
USE IFPORT
1778
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL QRANSET (rseed)
QREAL
Elemental Intrinsic Function (Specific): Converts
the real part of a COMPLEX(16) argument to REAL(16)
type. This is a specific function that has no generic
function associated with it. It cannot be passed as an
actual argument.
Syntax
result = QREAL (a)
Results
The result type is quad-precision real (REAL(16) or REAL*16).
Example
QREAL ((2.0q0, 3.0q0)) has the value 2.0q0.
See Also
REAL
DREAL
QSORT
Portability Subroutine: Performs a quick sort on an
array of rank one.
Module
USE IFPORT
Syntax
CALL QSORT (array,len,isize,compar)
1779
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
If you use QSORT with different data types, your program must have a USE IFPORT statement so that
all the calls work correctly. In addition, if you wish to use QSORT with a derived type or a type that is
not in the predefined interfaces, you must include an overload for the generic subroutine QSORT.
Examples of how to do this are in the portability module's source file, IFPORT.F90.
Example
1780
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
type(element_type) array(len)
integer(C_SIZE_T) len, isize
integer(2), external :: comp
!
! Hook the overload to the real thing but be careful
! to connect to the correct qsort: the Fortran one, not
! the C one!
!
! We need to call the _Fortran_ qsort, not the _C_ one, or
! there will be errors from the 1-origin vs. 0-origin indexing
! and the row-major vs. column-major ordering.
!
! The symptom is that "OrderCharCI" is called with pointer values
! which are outside the bounds of the array to be sorted.
!
!DIR$ IF DEFINED(_WIN64)
!DIR$ ATTRIBUTES ALIAS:'QSORT' :: QSORT_element_types
!DIR$ ELSE
!DIR$ ATTRIBUTES ALIAS: '_QSORT' :: QSORT_element_types
!DIR$ ENDIF
end subroutine QSORT_element_types
end interface
type(element_type) :: c(7)
size_of_array = size(c) ! 7
size_of_element = sizeof(c(1)) ! 16
1781
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
implicit none
! Function result:
!
integer(2) :: OrderCharCI
! Locals:
!
character(10) :: c1L !} Local copies of c1 and c2.
character(10) :: c2L !}
write(*,*)'OrderCharCI, parameter C1 is "', c1%key, '" ', c1%data, ', len is ', len(c1%key)
write(*,*)' len_trim is ', len_trim(c1%key)
write(*,*) ' '
! SEGV on access to C2
!
write(*,*)'OrderCharCI, parameter C2 is "', c2%key, '" ', c2%data, ', len is ', len(c2%key)
write(*,*)' len_trim is ', len_trim(c2%key)
write(*,*) ' '
c1L = c1%key
c2L = c2%key
1782
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
do i = 1, len_trim(C1L)
if ('a' <= C1L(i:i) .and. c1L(i:i) <= 'z') c1L(i:i) = char(ichar(c1L(i:i)) - ichar('a')
+ ichar('A'))
end do
do i = 1, len_trim(C2L)
if ('a' <= c2L(i:i) .and. c2L(i:i) <= 'z') c2L(i:i) = char(ichar(c2L(i:i)) - ichar('a')
+ ichar('A'))
end do
if (c1L == c2L) Then
OrderCharCI = 0
write(*,*) ' - equal'
else if (c1L < c2L) Then
OrderCharCI = -1
write(*,*) ' - c1 is less'
else
OrderCharCI = 1
write(*,*) ' - c1 is more'
end if
end function OrderCharCI
The following shows another example:
PROGRAM SORTQ
use, intrinsic :: iso_c_binding, only: c_size_t
use IFPORT
integer(2), external :: cmp_function
integer(2) insort(26), i
integer (C_SIZE_T) array_len, array_size
array_len = 26
array_size = 2
do i=90,65,-1
insort(i-64)=91 - i
end do
print *, "Before: "
print *,insort
CALL qsort(insort,array_len,array_size,cmp_function)
print *, 'After: '
print *, insort
END
!
integer(2) function cmp_function(a1, a2)
integer(2) a1, a2
cmp_function=a1-a2
end function
RADIX
Inquiry Intrinsic Function (Generic): Returns the
base of the model representing numbers of the same
type and kind as the argument.
Syntax
result = RADIX (x)
1783
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default integer. For an integer argument, the result has the value r (as defined
in Model for Integer Data). For a real argument, the result has the value b (as defined in Model for Real
Data).
Example
If X is a REAL(4) value, RADIX (X) has the value 2.
See Also
DIGITS
EXPONENT
FRACTION
Data Representation Models
RAISEQQ
Portability Function: Sends a signal to the executing
program.
Module
USE IFPORT
Syntax
result = RAISEQQ (sig)
If you do not install a signal handler (with SIGNALQQ, for example), when a signal occurs the system by
default terminates the program with exit code 3.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, nonzero.
If a signal-handling routine for sig has been installed by a prior call to SIGNALQQ, RAISEQQ causes that
routine to be executed. If no handler routine has been installed, the system terminates the program (the
default action).
See Also
SIGNALQQ
SIGNAL
KILL
RAN
Nonelemental Intrinsic Function (Specific):
Returns the next number from a sequence of
pseudorandom numbers of uniform distribution over
1784
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = RAN (i)
Results
The result type is REAL(4). The result is a floating-point number that is uniformly distributed in the range
between 0.0 inclusive and 1.0 exclusive. The result is set equal to the value associated with the argument i.
RAN is not a pure function.
Example
In RAN (I), if variable I has the value 3, RAN has the value 4.8220158E-05.
See Also
RANDOM
RANDOM_NUMBER
RAND, RANDOM
Portability Functions: Return real random numbers
in the range 0.0 to 1.0, not including the end points.
Module
USE IFPORT
Syntax
result = RAND ([ iflag ])
result = RANDOM (iflag)
iflag (Input) INTEGER(4). Optional for RAND. Controls the way the random
number is selected.
Results
The result type is REAL(4). RAND and RANDOM return random numbers in the range 0.0 to 1.0, not including
the end points.
1785
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
RANDOM is available as a function or subroutine.
Example
The following example shows how to use both the RANDOM function and the RANDOM subroutine:
use ifport
real(4) ranval
call seed(1995) ! initialize
call random(ranval) ! get next random number
print *,ranval
print *,ranval
end
See Also
RANDOM_INIT
RANDOM_NUMBER
RANDOM_SEED
SRAND
RANDOM Subroutine
Portability Subroutine: Returns a pseudorandom
number greater than or equal to zero and less than
one from the uniform distribution.
Module
USE IFPORT
Syntax
CALL RANDOM (ranval)
1786
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A given seed always produces the same sequence of values from RANDOM.
If SEED is not called before the first call to RANDOM, RANDOM begins with a seed value of one. If a program
must have a different pseudorandom sequence each time it runs, pass the constant RND$TIMESEED (defined
in IFCORE.F90) to SEED before the first call to RANDOM.
The portability routines DRAND, DRANDM, IRAND, IRANDM, RAN, RAND, and the RANDOM portability
function and subroutine use the same algorithms and thus return the same answers. They are all compatible
and can be used interchangeably. The algorithm used is a "Prime Modulus M Multiplicative Linear
Congruential Generator," a modified version of the random number generator by Park and Miller in "Random
Number Generators: Good Ones Are Hard to Find," CACM, October 1988, Vol. 31, No. 10.
Example
USE IFPORT
REAL(4) ran
CALL SEED(1995)
CALL RANDOM(ran)
The following example shows how to use both the RANDOM subroutine and the RANDOM function:
use ifport
real(4) ranval
! from libifcore.lib
call seed(1995) ! initialize
! also from for_m_irand.c in libfor
call random(ranval) ! get next random number
print *,ranval
! from libifport.lib
ranval = random(1) ! initialize
! same
ranval = random(0) ! get next random number
print *,ranval
end
See Also
RANDOM_NUMBER
SEED
DRAND and DRANDM
IRAND and IRANDM
RAN
RAND
RANDOM_INIT
Intrinsic Subroutine: Initializes the pseudorandom
number generator used by RANDOM_NUMBER.
Syntax
CALL RANDOM_INIT (repeatable, image_distinct)
1787
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If repeatable has the value .true. and image_distinct has the value .true., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with a different processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is the same each time the program is executed.
If repeatable has the value .true. and image_distinct has the value .false., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with the same processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is the same each time the program is executed.
If repeatable has the value .false. and image_distinct has the value .true., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with a different processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is different each time the program is executed.
If repeatable has the value .false. and image_distinct has the value .false., the effect of a call to
RANDOM_INIT is equivalent to calling RANDOM_SEED with the same processor-dependent value of PUT on
each image that executes the call. If the invoking image index on the initial team is the same, the value of
PUT is the different each time the program is executed.
NOTE
This routine is thread safe.
Example
Consider the following:
PROGRAM main
REAL,DIMENSION(1000) :: y
CALL RANDOM_INIT (REPEATABLE=.TRUE., IMAGE_DISTINCT=.TRUE.)
CALL RANDOM_NUMBER (y)
. . .
END
After executing the above code, the array y contains a different sequence of pseudorandom numbers on each
image that executes the code. If the program is executed multiple times, for an image that has the same
image index in the initial team, the value of y is the same each time the program is run.
Consider another example:
PROGRAM main
REAL,DIMENSION(1000) :: y
CALL RANDOM_INIT (REPEATABLE=.FALSE., IMAGE_DISTINCT=.FALSE.)
CALL RANDOM_NUMBER (y)
. . .
END
After executing the above code, the array y contains the same sequence of pseudorandom numbers on each
image that executes the code. If the program is executed multiple times, the value of y is different each time
the program is run.
See Also
RANDOM_NUMBER
RANDOM_SEED
1788
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RANDOM
SEED
DRAND and DRANDM
IRAND and IRANDM
RAN
RAND and RANDOM
RANDOM_NUMBER
Intrinsic Subroutine: Returns one pseudorandom
number or an array of such numbers.
Syntax
CALL RANDOM_NUMBER (harvest)
The seed for the pseudorandom number generator used by RANDOM_NUMBER can be set or queried with
RANDOM_SEED. If RANDOM_SEED is not used, the processor sets the seed for RANDOM_NUMBER to a
processor-dependent value.
The RANDOM_NUMBER generator uses two separate congruential generators together to produce a period of
approximately 10**18, and produces real pseudorandom results with a uniform distribution in [0, 1). It
accepts two integer seeds, the first of which is reduced to the range [1, 2147483562]. The second seed is
reduced to the range [1, 2147483398]. This means that the generator effectively uses two 31-bit seeds.
The RANDOM_NUMBER generator does not produce subnormal numbers.
For more information on the algorithm, see the following:
• Communications of the ACM vol 31 num 6 June 1988, titled: Efficient and Portable Combined Random
Number Generators by Pierre L'ecuyer.
• Springer-Verlag New York, N. Y. 2nd ed. 1987, titled: A Guide to Simulation by Bratley, P., Fox, B. L., and
Schrage, L. E.
NOTE
This routine is thread safe.
Example
Consider the following:
REAL Y, Z (5, 5)
! Initialize Y with a pseudorandom number
CALL RANDOM_NUMBER (HARVEST = Y)
CALL RANDOM_NUMBER (Z)
Y and Z contain uniformly distributed random numbers.
The following shows another example:
1789
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
program testrand
intrinsic random_seed, random_number
integer size
integer, allocatable :: seed(:), gseed(:), hiseed(:), zseed(:)
real harvest(10)
call random_seed(SIZE=size)
print *,"size ",size
allocate(seed(size),gseed(size),hiseed(size),zseed(size))
hiseed = -1
zseed = 0
seed = 123456789
seed(size) = 987654321
call random_seed(PUT=hiseed(1:size))
call random_seed(GET=gseed(1:size))
print *,"hiseed gseed", hiseed, gseed
call random_seed(PUT=zseed(1:size))
call random_seed(GET=gseed(1:size))
print *,"zseed gseed ", zseed, gseed
call random_seed(PUT=seed(1:size))
call random_seed(GET=gseed(1:size))
call random_number(HARVEST=harvest)
print *, "seed gseed ", seed, gseed
print *, "harvest"
print *, harvest
call random_seed(GET=gseed(1:size))
print *,"gseed after harvest ", gseed
end program testrand
See Also
RANF Intrinsic Procedure
RANDOM_INIT
RANDOM_SEED
RANDOM
SEED
DRAND and DRANDM
IRAND and IRANDM
RAN
RAND and RANDOM
RANDOM_SEED
Intrinsic Subroutine (Generic): Changes or queries
the seed (starting point) for the pseudorandom
number generator used by intrinsic subroutine
RANDOM_NUMBER. Intrinsic subroutines cannot be
passed as actual arguments.
Syntax
CALL RANDOM_SEED ([size] [,put] [,get])
1790
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
size (Output; optional) Must be scalar and of type integer. Set to the
number of integers (N) that the processor uses to hold the value of
the seed.
put (Input; optional) Must be an integer array of rank one and size greater
than or equal to N. It is used to reset the value of the seed.
get (Output; optional) Must be an integer array of rank one and size
greater than or equal to N. It is set to the current value of the seed.
No more than one argument can be specified. If no argument is specified, a random number based on the
date and time is assigned to the seed.
You can determine the size of the array the processor uses to store the seed by calling RANDOM_SEED with
the size argument (see the second example below).
If RANDOM_SEED is called with no arguments, the seed is set to a different, unpredictable value on each call.
NOTE
This routine is thread safe.
Example
Consider the following:
INTEGER I
INTEGER, ALLOCATABLE :: new (:), old(:)
CALL RANDOM_SEED ( ) ! Processor reinitializes the seed
! randomly from the date and time
CALL RANDOM_SEED (SIZE = I) ! I is set to the size of
! the seed array
ALLOCATE (new(I))
ALLOCATE (old(I))
CALL RANDOM_SEED (GET=old(1:I)) ! Gets the current seed
WRITE(*,*) old
new = 5
CALL RANDOM_SEED (PUT=new(1:I)) ! Sets seed from array
! new
END
See Also
RANDOM_INIT
RANDOM_NUMBER
SEED
SRAND
1791
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RANDU
Intrinsic Subroutine (Generic): Computes a
pseudorandom number as a single-precision value.
Intrinsic subroutines cannot be passed as actual
arguments.
Syntax
CALL RANDU (i1,i2,x)
The result is returned in x, which must be of type REAL(4). The result value is a pseudorandom number in
the range 0.0 to 1.0. The algorithm for computing the random number value is based on the values for i1
and i2.
The result value is a pseudorandom number in the range 0.0 to 1.0. The algorithm for computing the random
number value is based on the values for i1 and i2.
If i1 = 0 and i2 = 0, the generator base is set as follows:
x(n + 1) = 2**16 + 3
Otherwise, it is set as follows:
Example
Consider the following:
REAL X
INTEGER(2) I, J
...
CALL RANDU (I, J, X)
If I and J are values 4 and 6, X has the value 5.4932479E-04.
Syntax
result = RANF ()
Results
The result type is REAL(4). The result value is a single-precision pseudo-random number between 0.0 and
(2**31) - 1.
1792
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
CALL SRAND(ISEED)
where ISEED is type INTEGER(4).
The intrinsic function RANF generates a different sequence of random numbers than the RANF portability
function generates for the same seed. The intrinsic function RANF used inside a loop can be vectorized into
one call that returns four results, but the portability function RANF cannot be so optimized.
See Also
RANDOM_NUMBER
SRAND
Module
USE IFPORT
Syntax
result = RANF ( )
Results
The result type is REAL(4). The result value is a single-precision pseudo-random number between 0.0 and
(2**31) - 1.
The initial seed is set by the following:
CALL SRAND(ISEED)
where ISEED is type INTEGER(4).
See Also
RANDOM_NUMBER
SRAND
RANGE
Inquiry Intrinsic Function (Generic): Returns the
decimal exponent range in the model representing
numbers with the same kind parameter as the
argument.
Syntax
result = RANGE (x)
1793
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type default integer.
For an integer argument, the result has the value INT(LOG10( HUGE( x) )). For information on the integer
model, see Model for Integer Data.
For a real or complex argument, the result has the value INT(MIN (LOG10( HUGE( x) ), -
LOG10( TINY( x) ))). For information on the real model, see Model for Real Data.
Example
If X is a REAL(4) value, RANGE (X) has the value 37. (HUGE(X) = (1 - 2 -24) x2 128and TINY(X) = 2 -126)
See Also
HUGE
TINY
RANGET
Portability Subroutine: Returns the current seed.
Module
USE IFPORT
Syntax
CALL RANGET (seed)
RANK
Inquiry Intrinsic Function (Generic): Returns the
rank of a data object.
Syntax
result = RANK (a)
Results
The result type is default integer scalar. The result value is the rank of a.
Example
If object C is an assumed-rank dummy argument and its associated argument is an array of rank 5, RANK(C)
returns the value 5.
If D is an array declared DIMENSION (2, 3, 4), RANK(D) returned the value 3.
See Also
Assumed-Rank Specifications
1794
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RANSET
Portability Subroutine: Sets the seed for the
random number generator.
Module
USE IFPORT
Syntax
CALL RANSET (seed)
READ Statement
Statement: Transfers input data from external
sequential, direct-access, or internal records.
Syntax
Sequential
Formatted:
READ (eunit, format [, advance] [, asynchronous] [, blank] [, decimal] [, id] [, pad] [,
pos] [, round] [, size] [, iostat] [, err] [, end] [, eor] [, iomsg]) [io-list]
READ form[, io-list]
Formatted - List-Directed:
READ (eunit, *[, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [, round] [,
size] [, iostat] [, err] [, end] [, iomsg]) [io-list]
READ *[, io-list]
Formatted - Namelist:
READ (eunit, nml-group[, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [,
round] [, size] [, iostat] [, err] [, end] [, iomsg])
READ nml
Unformatted:
READ (eunit [, asynchronous] [, id] [, pos] [, iostat] [, err][, end] [, iomsg]) [io-
list]
Direct-Access
Formatted:
READ (eunit, format, rec [, asynchronous] [, blank] [, decimal] [, id] [, pad] [, pos] [,
round] [, size] [, iostat] [, err] [, iomsg]) [io-list]
Unformatted:
READ (eunit, rec [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg]) [io-list]
Internal
READ (iunit, format [, nml-group] [, iostat] [, err] [, end] [, iomsg]) [io-list]
Internal Namelist
READ (iunit, nml-group [, iostat] [, err] [, end] [, iomsg]) [io-list]
1795
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pad Is a blank pading specifier (PAD = pd). If the value of pad is 'YES', the
record will be padded with blanks when necessary. If the value is 'NO',
the record will not be padded with blanks. The default value is 'YES'.
pos Is a pos specifier (POS=p) that indicates a file position in file storage
units in a stream file (ACCESS='STREAM'). It can only be specified on
a file opened for stream access. If omitted, the stream I/O occurs
starting at the next file position after the current file position.
iostat Is the name of a variable to contain the completion status of the I/O
operation. Optionally prefaced by IOSTAT=.
err, end, eor Are branch specifiers if an error (ERR=label), end-of-file (END=label),
or end-of-record (EOR=label) condition occurs.
EOR can only be specified for nonadvancing READ statements.
io-list Is an I/O list: the names of the variables, arrays, array elements, or
character substrings from which or to which data will be transferred.
Optionally an implied-DO list.
1796
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
The READ statement can disrupt the results of certain graphics text functions (such as
SETTEXTWINDOW) that alter the location of the cursor. You can avoid the problem by getting keyboard
input with the GETCHARQQ function and echoing the keystrokes to the screen using OUTTEXT.
Alternatively, you can use SETTEXTPOSITION to control cursor location.
Example
DIMENSION ia(10,20)
! Read in the bounds for the array.
! Then read in the array in nested implied-DO lists
! with input format of 8 columns of width 5 each.
READ (6, 990) il, jl, ((ia(i,j), j = 1, jl), i =1, il)
990 FORMAT (2I5, /, (8I5))
1797
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL x, y
INTEGER i, j
READ (*,*) x, y, i, j
See Also
I/O Lists
I/O Control List
Forms for Sequential READ Statements
Forms for Direct-Access READ Statements
Forms and Rules for Internal READ Statements
PRINT
WRITE
I/O Formatting
REAL Directive
General Compiler Directive: Specifies the default
real kind.
Syntax
!DIR$ REAL:{ 4 | 8 | 16 }
The REAL directive selects a size of 4 (KIND=4), 8 (KIND=8), or 16 (KIND=16) bytes for default real
numbers. When the directive is in effect, all default real and complex variables are of the kind specified in the
directive. Only numbers specified or implied as REAL without KIND are affected.
The REAL directive can appear only at the top of a program unit. A program unit is a main program, an
external subroutine or function, a module, or a block data program unit. REAL cannot appear at the
beginning of internal subprograms. It does not affect modules invoked with the USE statement in the
program unit that contains it.
Example
REAL r ! a 4-byte REAL
WRITE(*,*) KIND(r)
CALL REAL8( )
WRITE(*,*) KIND(r) ! still a 4-byte REAL
! not affected by setting in subroutine
END
SUBROUTINE REAL8( )
!DIR$ REAL:8
REAL s ! an 8-byte REAL
WRITE(*,*) KIND(s)
END SUBROUTINE
See Also
REAL
COMPLEX
General Compiler Directives
Syntax Rules for Compiler Directives
REAL Function
Elemental Intrinsic Function (Generic): Converts
a value to real type.
1798
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = REAL (a[,kind])
Results
The result type is real. If kind is present, the kind parameter is that specified by kind; otherwise, the kind
parameter of the result is shown in the following table. If the processor cannot represent the result value in
the kind of the result, the result is undefined.
Functions that cause conversion of one data type to another type have the same effect as the implied
conversion in assignment statements.
The result value depends on the type and absolute value of a as follows:
• If a is integer or real, the result is equal to an approximation of a. If a is complex, the result is equal to an
approximation of the real part of a.
• If a is a binary, octal, or hexadecimal literal constant, the value of the result is the value whose bit
sequence according to the model in Bit Model is the same as that of a as modified by padding or
truncation according to the following:
• If the length of the sequence of bits specified by a is less than the size in bits of a scalar variable of the
same type and kind type parameter as the result, the binary, octal, or hexadecimal literal constant is
treated as if it were extended to a length equal to the size in bits of the result by padding on the left
with zero bits.
• If the length of the sequence of bits specified by a is greater than the size in bits of a scalar variable of
the same type and kind type parameter as the result, the binary, octal, or hexadecimal literal constant
is treated as if it were truncated from the left to a length equal to the size in bits of the result.
• If a binary, octal, or hexadecimal literal constant is truncated as an argument to intrinsic function
REAL, the discarded bits must all be zero.
INTEGER(1) REAL(4)
REAL(4) REAL(4)
COMPLEX(4) REAL(4)
COMPLEX(8) REAL(8)
1 These specific functions cannot be passed as actual arguments.
2The setting of compiler options specifying real size can affect FLOAT, REAL, and SNGL.
1799
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
3 Or FLOATJ. For compatibility with older versions of Fortran, FLOAT is generic, allowing any kind of
INTEGER argument, and returning a default real result.
4For compatibility with older versions of Fortran, SNGL is generic, allowing any kind of REAL argument,
and returning a default real result.
If the argument is a a binary, octal, or hexadecimal constant, the result is affected by the assume old-boz
option. The default option setting, noold-boz, treats the argument as a bit string that represents a value of
the data type of the intrinsic, that is, the bits are not converted. If setting old-boz is specified, the
argument is treated as a signed integer and the bits are converted.
Example
REAL (-4) has the value -4.0.
REAL (Y) has the same kind parameter and value as the real part of complex variable Y.
If C is complex, C%RE is the same as REAL (C).
See Also
Binary, Octal, Hexadecimal, and Hollerith Constants
Model for Bit Data
DFLOAT
DREAL
DBLE
assume compiler option
REAL Statement
Statement: Specifies the REAL data type.
Syntax
REAL
REAL([KIND=] n)
REAL* n
DOUBLE PRECISION
Description
If a kind parameter is specified, the real constant has the kind specified. If a kind parameter is not specified,
the kind is default real.
Default real is affected by compiler options specifying real size and by the REAL directive.
The default KIND for DOUBLE PRECISION is affected by compiler option double-size. If this compiler option is
not specified, default DOUBLE PRECISION is REAL(8).
No kind parameter is permitted for data declared with type DOUBLE PRECISION.
REAL(4) and REAL*4 (single precision) are the same data type. REAL(8), REAL*8, and DOUBLE PRECISION
are the same data type.
1800
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! type declarations with attribute specifiers
REAL (8), PARAMETER :: testval=50.d0
REAL, SAVE :: a(10), b(20,30)
REAL, PARAMETER :: x = 100.
See Also
DOUBLE PRECISION
REAL directive
Real Data Types
General Rules for Real Constants
REAL(4) Constants
REAL(8) or DOUBLE PRECISION Constants
Real and Complex Editing
Model for Real Data
RECORD
Statement: Declares a record structure as an entity
with a name.
Syntax
RECORD /structure-name/record-namelist [, /structure-name/record-namelist]...
You can use record names in COMMON and DIMENSION statements, but not in DATA or NAMELIST
statements.
Records initially have undefined values unless you have defined their values in structure declarations.
STRUCTURE and RECORD constructs have been replaced by derived types, which should be used in writing
new code. See Derived Data Types.
Example
STRUCTURE /address/
LOGICAL*2 house_or_apt
INTEGER*2 apt
INTEGER*2 housenumber
CHARACTER*30 street
CHARACTER*20 city
CHARACTER*2 state
INTEGER*4 zip
END STRUCTURE
1801
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
TYPE
MAP...END MAP
STRUCTURE...END STRUCTURE
UNION...END UNION
Record Structures
Description
RECURSIVE or NON_RECURSIVE can be specified once in a FUNCTION or SUBROUTINE statement. They
cannot both appear in the same statement.
Procedures not specified as RECURSIVE or NON_RECURSIVE are currently compiled as NON_RECURSIVE.
The default behavior can be changed by using the -assume [no]recursion option, or in an OPTIONS
statement.
NOTE
The Fortran 2018 Standard specifies that the default mode is recursion; previous standards
specified the default was no recursion. The default compilation mode will change to
recursion in a future release.
If a function is directly recursive and array valued, and if the keyword RESULT is not specified in the
FUNCTION statement, the result variable is the function name, and all occurrences of the function name in
the executable part of the function are references to the function result variable.
A directly recursive function cannot have a declared type of CHARACTER if the character length is declared as
*.
A procedure interface is always explicit within the subprogram that defines the procedure.
The keyword RECURSIVE must be specified if the compilation mode is set to non-recursive by a compiler
option and if any of the following applies (directly or indirectly):
The keyword NON_RECURSIVE must be specified if the compilation mode is set to recursion by a compiler
option and the procedure is not to be compiled for recursion.
Example
! RECURS.F90
!
i = 0
1802
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ENTRY
FUNCTION
SUBROUTINE
OPTIONS
Program Units and Procedures
recursive compiler option
REDUCE
Transformational Intrinsic Function (Generic):
Performs general array reduction.
Syntax
result = REDUCE (array, operation [, mask] [, identity] [, ordered])
result = REDUCE (array, operation, dim [, mask] [, identity] [, ordered])
dim (Input) Must be a scalar integer whose value is greater than or equal
to 1 and less than or equal to the rank of array.
mask (Input; optional) Must be of type logical and conformable with array.
identity (Input; optional) Must be scalar with the same declared type and type
parameters as array.
Results
The result has the same declared type and type parameters as array. If dim does not appear the result is
scalar; otherwise if n=RANK (array) the result has shape [d1, d2,...ddim-1, ddim+1,...dn] and rank n–1.
The result value is calculated differently depending on the form of the call:
1803
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1. The result of REDUCE (array, operation [, identity, ordered]) is calculated iteratively over the values of
array. The initial order of the sequence is array element order. While there is more than one element in
the sequence, each iteration calculates r = operation (a, b) replacing a and b with r.
If ordered is present with the value .true., a and b must be the first two elements of the sequence. The
process continues until the sequence has one value, and that is the value of the reduction. If array is a
zero-sized array and identity is present, the result is the value of identity; otherwise error termination
is initiated.
2. The result of REDUCE(array, operation, mask [, identity, ordered] is calculated as for case 1, but the
sequence of values consists only of those values of array for which the corresponding element of mask
has the value .true..
3. If array is a rank 1 array, REDUCE (array, operation, dim [, mask, identity, ordered) is equivalent to
REDUCE (array, operation [, mask, identity, ordered]); otherwise, the value of element (s1, s2,...,
sdim-1,sdim+1,..., sn) of REDUCE (array, operation, dim [, mask, identity, ordered] is equal to REDUCE
(array (s1, s2,..., sdim-1, :, sdim+1,..., sn), operation, dim = 1 [, mask(s1, s2,..., sdim-1, :, sdim+1,..., sn),
identity, ordered]).
Example
The following examples all use the function my_add, which returns the sum of its two real arguments.
REDUCTION
Parallel Directive Clause: Performs a reduction
operation on the specified variables.
Syntax
REDUCTION ([reduction-modifier, ]reduction-identifier : list)
list Is the name of one or more variables that are accessible to the
scoping unit. Each list item must be definable. Each name must be
separated by a comma. The type of each variable must be compatible
with a type for which the reduction-identifier has an accessible
definition.
Assumed-size arrays, procedure pointers, and dummy arguments that
are pointers with the INTENT (IN) attribute are not allowed. Array
sections are allowed.
For each list item, the number of copies is unspecified.
The same list item cannot appear in both a REDUCTION and an
IN_REDUCTION clause in the same directive.
1804
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a reduction-modifier is not present or if DEFAULT is specified for PARALLEL, LOOP, and worksharing
constructs, one or more copies of each reduction list item is created for each implicit task in the region as if
the list item had been specified in a PRIVATE clause.
If the REDUCTION clause appears in a SIMD statement, one or more private copies of each reduction list
item is created for each SIMD lane. If the REDUCTION clause is in a TASKLOOP directive, private copies of
reduction list items are created as if a PRIVATE clause had been specified containing the list item. For a
REDUCTION clause in a TEAMS construct, one or more private copies of each reduction list item are created
for the initial task of each team in the league.
The TASK reduction-modifier can only appear in a REDUCTION clause of a PARALLEL or worksharing
construct or in a combined construct for which one of these constructs is a constituent member and the SIMD
and LOOP construct are not constituent members. If the TASK reduction-modifier is specified for a PARALLEL
or worksharing construct, it is as if each reduction list item appeared in a PRIVATE clause in the directive,
and any number of additional private copies can be created to support task reductions. If the TASK
reduction-modifier appears in a REDUCTION clause, a NOWAIT clause cannot appear for the same construct.
List items in a REDUCTION clause of the inner most enclosing worksharing or PARALLEL construct must not
be accessed in an explicit task generated by a construct unless that construct contains an IN_REDUCTION
clause that contains the same list items.
The INSCAN reduction-modifier is allowed only in a worksharing construct, a SIMD construct, or a composite
construct for which these constructs are a constituent construct, and the DISTRIBUTE is not a constituent
construct. It indicates that in each iteration of the loop, a scan computation is performed over the updates to
each list item. Each list item is made PRIVATE in the construct. Upon completion of the region, the value of
the private copy of a list item from the last logical iteration of the loops of the construct is assigned to the
original list item.
Each list item of a REDUCTION clause with the INSCAN reduction-modifier must appear as a list item in an
INCLUSIVE or EXCLUSIVE clause in a SCAN directive contained in the loop (nest) enclosed in the construct. If
INSCAN appears in one REDUCTION clause of a construct, all REDUCTION clauses of that construct must
contain an INSCAN reduction-modifier. If an INSCAN reduction-modifier is applied to a construct that is
combined with a TARGET construct, it is as if each list item also appears in a MAP clause with a map-type of
TOFROM.
Variables that appear in a REDUCTION clause must be SHARED in the enclosing context. A private copy of
each variable in list is created for each thread as if the PRIVATE clause had been used. The private copy is
initialized according to the initializer-clause of the reduction-identifier. A dummy argument that is a pointer
with the INTENT (IN) attribute must not appear in a REDUCTION clause.
At the end of the REDUCTION, the shared variable is updated to reflect the result of combining the original
value of the shared reduction variable with the final value of each of the private copies using the combiner
specified for the reduction-identifier. Reduction operations should all be associative (except for subtraction),
and the compiler can freely reassociate the computation of the final value; the partial results of a subtraction
reduction are added to form the final value.
The value of the shared variable becomes undefined when the first thread reaches the clause containing the
reduction, and it remains undefined until the reduction computation is complete. Normally, the computation
is complete at the end of the construct containing the REDUCTION clause.
However, if the REDUCTION clause is used in a construct to which NOWAIT is also applied, the shared
variable remains undefined until a barrier synchronization has been performed. This ensures that all the
threads complete the REDUCTION clause.
Any list item copies associated with the reduction must be initialized before they are accessed by the tasks
participating in the reduction. After the end of the region, the original list item contains the result of the
reduction.
1805
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An original list item with the POINTER attribute, or any pointer component of an original list item that is
referenced, must be associated at entry to the construct that contains the REDUCTION clause. Also, the list
item, or the pointer component of the list item, must not be deallocated, allocated, or pointer assigned within
the region.
An original list item with the ALLOCATABLE attribute, or any allocatable component of an original list item
that is referenced, must be in the allocated state at entry to the construct that contains the REDUCTION
clause. Also, the list item, or the allocatable component of the list item, must be neither deallocated nor
allocated within the region.
Any number of REDUCTION clauses can be specified on the directive, but a list item can appear only once in
REDUCTION clauses for that directive.
If a list item is an array section, the following applies:
• The array section must specify contiguous storage and it cannot be a zero-length array section.
• Accesses to the elements of the array outside the specified array section result in unspecified behavior.
• The reduction clause will be applied to each separate element of the array section.
• Access to the elements of the array outside the specified array section result in unspecified behavior.
The following table lists predefined reduction-identifiers. These reduction-identifiers are implicitly defined and
cannot be redefined in a DECLARE REDUCTION directive for the types shown here. The actual initialization
value will be consistent with the data type of the reduction variable.
Predefined reduction-identifiers
reduction-identifier Type Combiner Initializer
1806
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If a directive allows REDUCTION clauses, the number you can specify is not limited. However, each variable
name can appear only once in only one of the clauses.
NOTE
If a variable appears in a REDUCTION clause on a combined construct for which the first construct is
TARGET, it is treated as if it had appeared in a MAP clause with a map-type of TOFROM.
Example
In the following program fragment, time will be the sum of the time spent in the do loop across all threads:
use omp_lib
integer i
double precision t1, time
call omp_set_num_threads(4)
...
!$omp do reduction(+:time)
do i = 1, omp_get_num_threads()
t1 = omp_get_wtime()
...
time = omp_get_wtime() – t1
end do
!here time is equal to the total time across all threads
...
See Also
DECLARE REDUCTION
IN_REDUCTION
PRIVATE clause
SCAN
TASK_REDUCTION
%REF
Built-in Function: Changes the form of an actual
argument. Passes the argument by reference. In
Intel® Fortran, passing by reference is the default.
Syntax
%REF (a)
You must specify %REF in the actual argument list of a CALL statement or function reference. You cannot use
it in any other context.
The following table lists the Intel® Fortran defaults for argument passing, and the allowed uses of %REF:
1807
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Expressions:
Hollerith REF No
Array Name:
Procedure Name:
The %REF and %VAL functions override related !DIR$ ATTRIBUTE settings.
Example
CHARACTER(LEN=10) A, B
CALL SUB(A, %REF(B))
Variable A is passed by address and hidden length. Variable B is passed by reference.
Note that on Windows* systems, compiler option iface determines how the character argument for variable
B is passed.
See Also
CALL
%VAL
1808
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
%LOC
/iface compiler option
RENAME
Portability Function: Renames a file.
Module
USE IFPORT
Syntax
result = RENAME (from,to)
to (Input) Character*(*). The new path for the file (see Caution note
below).
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code, such as:
• EACCES - The file or directory specified by to could not be created (invalid path). This error is also
returned if the drive specified is not currently connected to a device.
• ENOENT - The file or path specified by from could not be found.
• EXDEV - Attempt to move a file to a different device.
Caution
This routine can cause data to be lost. If the file specified in to already exists, RENAME
deletes the pre-existing file.
It is possible to rename a file to itself without error.
The paths can use forward (/) or backward (\) slashes as path separators and can include drive letters
(if permitted by your operating system).
Example
use IFPORT
integer(4) istatus
character*12 old_name, new_name
print *, "Enter file to rename: "
read *, old_name
print *, "Enter new name: "
read *, new_name
ISTATUS = RENAME (old_name, new_name)
See Also
RENAMEFILEQQ
RENAMEFILEQQ
Portability Function: Renames a file or directory.
Module
USE IFPORT
1809
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = RENAMEFILEQQ (oldname,newname)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
You can use RENAMEFILEQQ to move a file from one directory to another on the same drive by giving a
different path in the newname parameter.
If the function fails, call GETLASTERRORQQ to determine the reason. One of the following errors can be
returned:
• ERR$ACCES - Permission denied. The file's or directory's permission setting does not allow the specified
access.
• ERR$EXIST - The file or directory already exists.
• ERR$NOENT - File or directory or path specified by oldname not found.
• ERR$XDEV - Attempt to move a file or directory to a different device.
Example
USE IFPORT
USE IFCORE
INTEGER(4) len
CHARACTER(80) oldname, newname
LOGICAL(4) result
See Also
FINDFILEQQ
RENAME
GETLASTERRORQQ
REPEAT
Transformational Intrinsic Function (Generic):
Concatenates several copies of a string.
Syntax
result = REPEAT (string,ncopies)
ncopies (Input) Must be scalar and of type integer. It must not be negative.
Results
The result is a scalar of type character and length ncopies x LEN( string). The kind parameter is the same as
string. The value of the result is the concatenation of ncopies copies of string.
1810
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
REPEAT ('S', 3) has the value SSS.
REPEAT ('ABC', 0) has the value of a zero-length string.
The following shows another example:
CHARACTER(6) str
str = REPEAT('HO', 3) ! returns HOHOHO
See Also
SPREAD
REQUIRES
OpenMP* Fortran Compiler Directive: Lists the
features that an implementation must support so that
the program compiles and runs correctly. This feature
is only available for ifx.
Syntax
!$OMP REQUIRES [clause[[,] clause]... ]
1811
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The REQUIRES directive identifies the requirements needed for execution of the code in the compilation unit
in which the directive appears.
The REQUIRES directive must appear in the specification part of the program unit, lexically following all USE,
IMPORT, and IMPLICIT statements.
The clauses specified in the REQUIRES directive are added to the requires trait in the OpenMP* context for all
points in the compilation unit.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
RESHAPE
Transformational Intrinsic Function (Generic):
Constructs an array with a different shape from the
argument array.
1812
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = RESHAPE (source,shape[,pad] [,order])
source (Input) Must be an array. It may be of any data type. It supplies the
elements for the result array. Its size must be greater than or equal to
PRODUCT(shape) if pad is omitted or has size zero.
pad (Input; optional) Must be an array with the same type and kind
parameters as source. It is used to fill in extra values if the result
array is larger than source.
order (Input; optional) Must be an integer array with the same shape as
shape. Its elements must be a permutation of (1,2,...,n), where n is
the size of shape. If order is omitted, it is assumed to be (1,2,...,n).
Results
The result is an array of shape shape with the same type and kind parameters as source. The size of the
result is the product of the values of the elements of shape.
In the result array, the array elements of source are placed in the order of dimensions specified by order. If
order is omitted, the array elements are placed in normal array element order.
The array elements of source are followed (if necessary) by the array elements of pad in array element order.
If necessary, additional copies of pad follow until all the elements of the result array have values.
NOTE
In standard Fortran array element order, the first dimension varies fastest. For example,
element order in a two-dimensional array would be (1,1), (2,1), (3,1) and so on. In a three-
dimensional array, each dimension having two elements, the array element order would be
(1,1,1), (2, 1, 1), (1, 2, 1), (2, 2, 1), (1, 1, 2), (2, 1, 2), (1, 2, 2), (2, 2, 2).
RESHAPE can be used to reorder a Fortran array to match C array ordering before the array is passed
from a Fortran to a C procedure.
Example
RESHAPE ((/3, 4, 5, 6, 7, 8/), (/2, 3/)) has the value
[ 3 5 7 ]
[ 4 6 8 ].
RESHAPE ((/3, 4, 5, 6, 7, 8/), (/2, 4/), (/1, 1/), (/2, 1/)) has the value
[ 3 4 5 6 ]
[ 7 8 1 1 ].
The following shows another example:
INTEGER AR1( 2, 5)
REAL F(5,3,8)
REAL C(8,3,5)
AR1 = RESHAPE((/1,2,3,4,5,6/),(/2,5/),(/0,0/),(/2,1/))
! returns 1 2 3 4 5
! 6 0 0 0 0
1813
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
!
! Change Fortran array order to C array order
C = RESHAPE(F, (/8,3,5/), ORDER = (/3, 2, 1/))
END
See Also
PACK
SHAPE
TRANSPOSE
Array Assignment Statements
RESULT
Keyword: Specifies a name for a function result.
Description
Normally, a function result is returned in the function's name, and all references to the function name are
references to the function result.
However, if you use the RESULT keyword in a FUNCTION statement, you can specify a local variable name for
the function result. In this case, all references to the function name are recursive calls, and the function
name must not appear in specification statements.
The RESULT name must be different from the name of the function.
Example
The following shows an example of a recursive function specifying a RESULT variable:
See Also
FUNCTION
ENTRY
RECURSIVE
Program Units and Procedures
1814
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RETURN
Statement: Transfers control from a subprogram to
the calling program unit.
Syntax
RETURN [expr]
Description
When a RETURN statement is executed in a function subprogram, control is transferred to the referencing
statement in the calling program unit.
When a RETURN statement is executed in a subroutine subprogram, control is transferred to the first
executable statement following the CALL statement that invoked the subroutine, or to the alternate return (if
one is specified).
Example
The following shows how alternate returns can be used in a subroutine:
SUBROUTINE Loop
CHARACTER in
10 READ (*, '(A)') in
IF (in .EQ. 'Y') RETURN
GOTO 10
! RETURN implied by the following statement:
END
1815
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
CALL
CASE
REWIND
Statement: Positions a sequential or direct access file
at the beginning of the file (the initial point). It takes
one of the following forms:
Syntax
REWIND ([UNIT=] io-unit[, ERR= label] [, IOMSG=msg-var] [, IOSTAT=i-var])
REWIND io-unit
label Is the label of the branch target statement that receives control if an
error occurs.
Description
The unit number must refer to a file on disk or magnetic tape, and the file must be open for sequential,
direct, or append access.
If a REWIND is done on a direct access file, the NEXTREC specifier is assigned a value of 1.
If a file is already positioned at the initial point, a REWIND statement has no effect.
If a REWIND statement is specified for a unit that is not open, it has no effect.
1816
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following statement repositions the file connected to I/O unit 3 to the beginning of the file:
REWIND 3
Consider the following statement:
See Also
OPEN
READ
WRITE
Data Transfer I/O Statements
Branch Specifiers
REWRITE
Statement: Rewrites the current record.
Syntax
Formatted:
REWRITE (eunit, format[, iostat] [, err]) [io-list]
Unformatted:
REWRITE (eunit[, iostat][ , err]) [io-list]
Description
In the REWRITE statement, data (translated if formatted; untranslated if unformatted) is written to the
current (existing) record in a file with direct access.
The current record is the last record accessed by a preceding, successful sequential or direct-access READ
statement.
Between a READ and REWRITE statement, you should not specify any other I/O statement (except INQUIRE)
on that logical unit. Execution of any other I/O statement on the logical unit destroys the current-record
context and causes the current record to become undefined.
Only one record can be rewritten in a single REWRITE statement operation.
The output list (and format specification, if any) must not specify more characters for a record than the
record size. (Record size is specified by RECLin an OPEN statement.)
1817
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the number of characters specified by the I/O list (and format, if any) do not fill a record, blank characters
are added to fill the record.
Example
In the following example, the current record (contained in the relative organization file connected to logical
unit 3) is updated with the values represented by NAME, AGE, and BIRTH:
RINDEX
Portability Function: Locates the index of the last
occurrence of a substring within a string.
Module
USE IFPORT
Syntax
result = RINDEX (string,substr)
Results
The result type is INTEGER(4). The result is the starting position of the final occurrence of substrg in string.
The result is zero if substring does not occur in string.
Example
USE IFPORT
character*80 mainstring
character*4 shortstr
integer(4) where
mainstring="Hello Hello Hello Hello There There There"
shortstr="Hello"
where=rindex(mainstring,shortstr)
! where is 19
See Also
INDEX
RNUM
Elemental Intrinsic Function (Specific): Converts
a character string to a REAL(4) value. This function
cannot be passed as an actual argument.
Syntax
result = RNUM (i)
Results
The result type is REAL(4). The result value is the real value represented by the character string i.
1818
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
RNUM ("821.003") has the value 821.003 of type REAL(4).
RRSPACING
Elemental Intrinsic Function (Generic): Returns
the reciprocal of the relative spacing of model
numbers near the argument value.
Syntax
result = RRSPACING (x)
Results
The result type and kind are the same as x. The result has the value | x* b -e| x b p. Parameters b, e, p are
defined in Model for Real Data.
Example
If -3.0 is a REAL(4) value, RRSPACING (-3.0) has the value 0.75 x 2 24.
REAL(4) res4
REAL(8) res8, r2
res4 = RRSPACING(3.0) ! returns 1.258291E+07
res4 = RRSPACING(-3.0) ! returns 1.258291E+07
r2 = 487923.3
res8 = RRSPACING(r2) ! returns 8.382458680573952E+015
END
See Also
SPACING
Data Representation Models
RSHIFT
Elemental Intrinsic Function (Generic): Shifts the
bits in an integer right by a specified number of
positions. This is the same as specifying ISHFT with a
negative shift.
See Also
See ISHFT.
RTC
Portability Function: Returns the number of seconds
elapsed since a specific Greenwich mean time.
Module
USE IFPORT
Syntax
result = RTC( )
1819
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is REAL(8). The result is the number of seconds elapsed since 00:00:00 Greenwich mean
time, January 1, 1970.
Example
USE IFPORT
real(8) s, s1, time_spent
INTEGER(4) i, j
s = RTC( )
call sleep(4)
s1 = RTC( )
time_spent = s1 - s
PRINT *, 'It took ',time_spent, 'seconds to run.'
See Also
DATE_AND_TIME
RUNQQ
Portability Function: Executes another program and
waits for it to complete.
Module
USE IFPORT
Syntax
result = RUNQQ (filename,commandline)
Results
The result type is INTEGER(2). If the program executed with RUNQQ terminates normally, the exit code of
that program is returned to the program that launched it. If the program fails, -1 is returned.
The RUNQQ function executes a new process for the operating system using the same path, environment,
and resources as the process that launched it. The launching process is suspended until execution of the
launched process is complete.
Example
USE IFPORT
INTEGER(2) result
result = RUNQQ('myprog', '-c -r')
END
See also the example in NARGS.
See Also
NARGS
SYSTEM
NARGS
1820
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
S
This section describes language features that start with S.
S
SAME_TYPE_AS
Inquiry Intrinsic Function (Generic): Inquires
whether the dynamic type of one object is the same
as the dynamic type of another object.
Syntax
result = SAME_TYPE_AS (a , b)
Results
The result type is default logical scalar. The result is true only if the dynamic type of a is the same as the
dynamic type of b.
SAVE
Statement and Attribute: Causes the values and
definition of objects to be retained after execution of a
RETURN or END statement in a subprogram.
Syntax
The SAVE attribute can be specified in a type declaration statement or a SAVE statement, and takes one of
the following forms:
Type Declaration Statement:
type,[att-ls,] SAVE [, att-ls] :: entity[, entity ] ...
Statement:
SAVE [[::]entity [, entity ] ...]
Description
In Intel® Fortran, certain variables are given the SAVE attribute, or not, by default. Variables are implicitly
given the SAVE attribute depending on whether a program unit is compiled for recursion.
1821
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
In the following lists, "initialized" means that the variable has been given an initial value in a
DATA statement, it has been initialized in a type declaration statement, it is of a derived
type that is default initialized, or it has a component that is default initialized.
• Scalar variables that are local to a recursive procedure and are not initialized (see above Note)
• Arrays of any type that are local to a recursive procedure and are not initialized (see above Note)
• Variables that are declared AUTOMATIC
• Local variables with the ALLOCATABLE attribute
The following variables are saved by default:
Local variables that are not described in the preceding two lists are saved by default.
NOTE
Certain compiler options (such as options [Q]save, assume norecursion, and auto) and the
use of OpenMP* features can change the defaults.
NOTE
Coarrays that do not have the ALLOCATABLE attribute and are local to the main program
unit or to a procedure are not statically allocated, but are allocated at program startup. They
are not deallocated until the program terminates.
To enhance portability and avoid possible compiler warning messages, Intel recommends that you use the
SAVE statement to name variables whose values you want to preserve between subprogram invocations.
When a SAVE statement does not explicitly contain a list, all allowable items in the scoping unit are saved.
A SAVE statement cannot specify the following (their values cannot be saved):
• A blank common
• An object in a common block
• A procedure
• A dummy argument
• A function result
• An automatic object
• A PARAMETER (named) constant
Even though a common block can be included in a SAVE statement, individual variables within the common
block can become undefined (or redefined) in another scoping unit.
If a common block is saved in any scoping unit of a program (other than the main program), it must be
saved in every scoping unit in which the common block appears.
A SAVE statement has no effect in a main program.
1822
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows a type declaration statement specifying the SAVE attribute:
SUBROUTINE TEST()
REAL, SAVE :: X, Y
The following is an example of the SAVE statement:
SUBROUTINE MySub
COMMON /z/ da, in, a, idum(10)
real(8) x,y
...
SAVE x, y, /z/
! alternate declaration
REAL(8), SAVE :: x, y
SAVE /z/
See Also
COMMON
DATA
RECURSIVE and NON_RECURSIVE
MODULE
MODULE PROCEDURE
Type Declarations
Compatible attributes
SAVE value in CLOSE
SCALE
Elemental Intrinsic Function (Generic): Returns
the value of the exponent part (of the model for the
argument) changed by a specified value.
Syntax
result = SCALE (x,i)
Results
The result type and kind are the same as x. The result has the value x x b i. Parameter b is defined in Model
for Real Data.
Example
If 3.0 is a REAL(4) value, SCALE (3.0, 2) has the value 12.0 and SCALE (3.0, 3) has the value 24.0.
The following shows another example:
REAL r
r = SCALE(5.2, 2) ! returns 20.8
1823
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
LSHIFT
Data Representation Models
SCAN Directive
OpenMP* Fortran Compiler Directive: Specifies a
scan computation that updates each list item in each
iteration of the loop.
Syntax
loop-associated-directive
do-loop-headers
block
!$OMP SCAN clause
block
do-termination-statements
[end-loop-associated-directive]
• INCLUSIVE (list)
• EXCLUSIVE (list)
If an INCLUSIVE clause appears, an inclusive scan computation is
performed for each list item in the clause. If an EXCLUSIVE clause
appears, an exclusive scan computation is performed for each list item
in the clause.
do-termination-statements Is one or more Fortran DO-loop terminal statements, such as END DO,
CONTINUE, or a terminal statement for a nonblock DO construct.
The SCAN directive can appear in the body of a loop or loop nest that is in a worksharing construct, a
worksharing-loop SIMD, or a SIMD construct.
There are two phases for each iteration of a SCAN loop, as follows:
• The input phase
For each iteration of an INCLUSIVE scan loop, the statements that appear lexically prior to the SCAN
directive constitute the input phase.
For each iteration, except the last iteration of an EXCLUSIVE scan loop, the statements that lexically
precede the directive constitute the input phase.
• The scan phase
For each iteration of an INCLUSIVE scan loop, the statements that follow the directive constitute the scan
phase.
For each iteration, except the last iteration of an EXCLUSIVE scan loop, the statements that lexically
follow the directive constitute the scan phase.
1824
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The last loop iteration does not have an input phase. For this iteration, all statements lexically preceding and
following the directive constitute the scan phase. All computations that update a list item during an iteration
are contained in the input phase. A statement that references a list item in the scan phase uses the result of
the scan operation for that iteration.
For a given iteration, the result of a scan operation is calculated according to the last generalized prefixed
sum (PRESUMlast) applied to the sequence of values given by the original value of the list item upon entry of
the loop construct, and updated values given the list item in each of the iterations of the loop. The
PRESUMlast (op, a1, . . . an) is defined for a binary operation op and a sequence of N values a1, . . . an as
follows:
• If N = 1, a1
• If N > 1, op (PRESUMlast (op, a1, . . . ak), PRESUMlast (op, ak+1, . . . an)) where 1 <= K <= N
At the beginning of the input phase for each iteration, the list item is initialized with the initializer value of
the reduction-identifier specified by the REDUCTION clause on the innermost enclosing OpenMP* construct.
For a given iteration, the update value of a list item is the value of the list item upon completion of the
iteration’s input phase.
If orig_value is the initial value of a list item upon entry to a worksharing-loop, worksharing SIMD, or SIMD
construct, if combiner is the combiner for the reduction-identifier specified in the REDUCTION clause on the
construct, and update-valuei is the value for the list item for iteration i, then at the beginning of the scan
phase of the first iteration, a list item of an INCLUSIVE clause on a SCAN directive is assigned the result of
the operation PRESUMlast (combiner, orig_value, update-value1 . . . update-valuei). At the beginning of the
scan phase of the first iteration, a list item of an EXCLUSIVE clause on a SCAN directive is assigned the value
orig_value. At the beginning of the scan phase of each subsequent iteration, i > 1, a list item of an
EXCLUSIVE clause on a SCAN directive is the result of the operation PRESUMlast (combiner, orig_value,
update-value1 . . . update-valuei-1).
A worksharing-loop, worksharing-loop SIMD, or a SIMD construct that has a REDUCTION clause with the
INSCAN modifier must contain exactly one SCAN directive in the loop body of the construct, and a list item in
an INCLUSIVE or EXCLUSIVE clause must be a list item in the REDUCTION clause of the construct.
With the exception of dependencies for list items in the INCLUSIVE or EXCLUSIVE clause, cross-iteration
dependencies across loop iterations are not permitted. Except for INCLUSIVE or EXCLUSIVE clause list-item
dependencies, intra-iteration dependencies between a statement lexically preceding the SCAN directive and a
statement lexically following a SCAN directive are not permitted.
NOTE
Currently, ifort only supports SCAN directives on SIMD and TARGET SIMD construct directives.
Example
The following contains an inclusive and an exclusive scan SIMD loop:
real,dimension(10) :: a, b
real :: s
integer :: i
...
do i = 1, 10
a(i) = real (i)
end do
s = 0.0
! Inclusive scan
!$omp simd reduction (inscan, +:s)
do i = 1, 10
1825
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
s = s + a(i)
!$omp scan inclusive (s)
b(i) = s
end do
print *, b
s = 0.0
! Exclusive scan
!$omp simd reduction (inscan, +:s)
do i = 1, 10
b(i) = s
!$omp scan exclusive (s)
s = s + a(i)
end do
print *, b
The first print statement prints the sequence 1.0 3.0 6.0 10.0 15.0 21.0 28.0 36.0 45.0 55.0. The second
print statement prints the sequence 0.0 1.0 3.0 6.0 10.0 15.0 21.0 28.0 36.0 45.0.
See Also
REDUCTION clause
SIMD OpenMP* Fortran directive
TARGET SIMD
DO statement
SCAN Function
Elemental Intrinsic Function (Generic): Scans a
string for any character in a set of characters.
Syntax
result = SCAN (string, set [, back] [, kind])
set (Input) Must be of type character with the same kind parameter as
string.
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
If back is omitted (or is present with the value false) and string has at least one character that is in set, the
value of the result is the position of the leftmost character of string that is in set.
If back is present with the value true and string has at least one character that is in set, the value of the
result is the position of the rightmost character of string that is in set.
If no character of string is in set or the length of string or set is zero, the value of the result is zero.
The setting of compiler options specifying integer size can affect this function.
Example
SCAN ('ASTRING', 'ST') has the value 2.
1826
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER i
INTEGER array(2)
i = SCAN ('FORTRAN', 'TR') ! returns 3
i = SCAN ('FORTRAN', 'TR', BACK = .TRUE.) ! returns 5
i = SCAN ('FORTRAN', 'GHA') ! returns 6
i = SCAN ('FORTRAN', 'ora') ! returns 0
array = SCAN ((/'FORTRAN','VISUALC'/),(/'A', 'A'/))
! returns (6, 5)
See Also
VERIFY
SCANENV
Portability Subroutine: Scans the environment for
the value of an environment variable.
Module
USE IFPORT
Syntax
CALL SCANENV (envname,envtext,envvalue)
SCOPE
OpenMP* Fortran Compiler Directive: Specifies a
block of code to be executed by all threads in a team;
it may contain additional OpenMP constructs. This
feature is only available for ifx.
Syntax
!$OMP SCOPE [clause[[,] clause]... ]
loosely-structured-block
1827
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
Description
The binding thread set for the SCOPE region is the current team.
The SCOPE region binds to the innermost parallel region in which it is enclosed. All threads of a team that
execute the binding parallel region, and only those threads, execute the statements of the block. The block
may contain additional OpenMP constructs.
If NOWAIT is not specified, the participating threads execute an implicit barrier at the end of the SCOPE
block.
Example
The following code performs a reduction on the array arr. Each thread produces a sum of the elements
dispatched to it. The SCOPE directive is used to perform a reduction of each partial sum. The sum of the
array, and the number of threads that participate, is printed.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
1828
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SCWRQQ
Portability Subroutine: Returns the floating-point
processor control word.
Module
USE IFPORT
Syntax
CALL SCWRQQ (control)
SCRWQQ performs the same function as the run-time subroutine GETCONTROLFPQQ, and is provided for
compatibility.
Example
See the example in LCWRQQ.
See Also
GETCONTROLFPQQ
LCWRQQ
Syntax
This function must not be passed as an actual argument. It is not a pure function, so it cannot be referenced
inside a FORALL construct.
result = SECNDS (x)
Results
The result type and kind are the same as x.
If x is zero, the result value is the time in seconds since the most recent midnight (in local time).
If x is not zero, it is compared to now: the value that would be returned if x had been zero. If x is less than
now, then the result value is now - x. If x is more than now, the function assumes that x is the result of a
call to SECONDS made the previous day and returns the value between that time and now.
This function cannot detect a delay of more than one day between calls. For timing intervals longer than 24
hours, use DCLOCK.
This function does not account for daylight savings changes in either direction.
The value of SECNDS is accurate to 0.01 second, which is the resolution of the system clock.
The 24 bits of precision provide accuracy to the resolution of the system clock for about one day. However,
loss of significance can occur if you attempt to compute very small elapsed times late in the day.
1829
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following shows how to use SECNDS to perform elapsed-time computations:
C CODE TO BE TIMED
...
DELTA = SECNDS(T1) ! DELTA gives the elapsed time
See Also
DATE_AND_TIME
RTC
SYSTEM_CLOCK
DCLOCK
Module
USE IFPORT
Syntax
result = SECNDS (time)
Results
The result type is REAL(4). The result value is the number of seconds that have elapsed since midnight,
minus time, with a precision of a hundredth of a second (0.01).
To start the timing clock, call SECNDS with 0.0, and save the result in a local variable. To get the elapsed
time since the last call to SECNDS, pass the local variable to SECNDS on the next call.
Example
USE IFPORT
REAL(4) s
INTEGER(4) i, j
s = SECNDS(0.0)
DO I = 1, 100000
J = J + 1
1830
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END DO
s = SECNDS(s)
PRINT *, 'It took ',s, 'seconds to run.'
See Also
DATE_AND_TIME
RTC
SYSTEM_CLOCK
SECTIONS
OpenMP* Fortran Compiler Directive: Specifies
that the enclosed SECTION directives define blocks of
code to be divided among threads in a team. Each
section is executed once by a thread in the team.
Syntax
!$OMP SECTIONS [clause[[,] clause] ... ]
[!$OMP SECTION]
block
[!$OMP SECTION
block]...
!$OMP END SECTIONS[NOWAIT]
The binding thread set for a SECTIONS construct is the current team. A SECTIONS region binds to the
innermost enclosing parallel region.
Each section of code is preceded by a SECTION directive, although the directive is optional for the first
section. The SECTION directives must appear within the lexical extent of the SECTIONS and END SECTIONS
directive pair.
The last section ends at the END SECTIONS directive. Threads that complete execution of their SECTIONs
encounter an implied barrier at the END SECTIONS directive unless NOWAIT is specified.
SECTIONS directives must be encountered by all threads in a team or by none at all.
1831
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
In the following example, subroutines XAXIS, YAXIS, and ZAXIS can be executed concurrently:
!$OMP PARALLEL
!$OMP SECTIONS
!$OMP SECTION
CALL XAXIS
!$OMP SECTION
CALL YAXIS
!$OMP SECTION
CALL ZAXIS
!$OMP END SECTIONS
!$OMP END PARALLEL
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
SEED
Portability Subroutine: Changes the starting point
of the pseudorandom number generator.
Module
USE IFPORT
Syntax
CALL SEED (iseed)
SEED uses iseed to establish the starting point of the pseudorandom number generator. A given seed always
produces the same sequence of values from RANDOM.
If SEED is not called before the first call to RANDOM, RANDOM always begins with a seed value of one. If a
program must have a different pseudorandom sequence each time it runs, pass the constant RND$TIMESEED
(defined in IFPORT.F90) to the SEED routine before the first call to RANDOM.
Example
USE IFPORT
REAL myrand
CALL SEED(7531)
CALL RANDOM(myrand)
See Also
RANDOM
RANDOM_INIT
RANDOM_SEED
RANDOM_NUMBER
1832
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
CHARACTER*1 cmdchar
. . .
Files: SELECT CASE (cmdchar)
CASE ('0')
WRITE (*, *) "Must retrieve one to nine files"
CASE ('1':'9')
CALL RetrieveNumFiles (cmdchar)
CASE ('A', 'a')
CALL AddEntry
CASE ('D', 'd')
CALL DeleteEntry
CASE ('H', 'h')
CALL Help
CASE DEFAULT
WRITE (*, *) "Command not recognized; please re-enter"
END SELECT Files
See Also
See CASE.
SELECT RANK
Statement: Marks the beginning of a SELECT RANK
construct. The construct selects for execution at most
one of its constituent blocks. The selection is based on
the rank of an assumed-rank variable.
Syntax
[name:] SELECT RANK ([ assoc-name => ] selector)
[rank-case-stmt
block]...
END SELECT [name]
1833
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a construct name is specified at the beginning of a SELECT RANK statement, the same name must appear
in the corresponding END SELECT statement. If a rank-case-stmt specifies a construct name, the
corresponding SELECT RANK statement must specify the same name. The same construct name must not be
used for different named constructs in the same scoping unit. If no name is specified at the beginning of a
SELECT RANK statement, you cannot specify one following the END SELECT statement or any corresponding
rank-case-stmt.
If no other rank-case-stmt of the construct matches the selector, a RANK DEFAULT statement, if present,
identifies the block of code to be executed.
A SELECT RANK construct selects at most one block to be executed. During execution of that block, the
associate name identifies an entity that is associated with the selector.
The following steps determine which block is selected for execution:
1. If the selector is argument associated with an assumed-size array, a RANK (*) statement identifies the
block to be executed.
2. If the selector is not argument associated with an assumed-size array, a RANK (scalar-int-const-exp)
statement identifies the block to be executed if the selector has that rank.
3. Otherwise, if there is a RANK DEFAULT statement, the block following that statement is executed.
A branch is allowed from within a block of a SELECT RANK construct to the END SELECT statement. Branches
to the END SELECT from outside the construct are not allowed.
The associating entity in the block following a RANK DEFAULT statement is assumed rank and has the same
attributes as the selector; it can used only in contexts that an assumed-rank entity can be used. The
associating entity in the block following a RANK (*) statement is an assumed-size one dimensional array and
lower bound 1, as if declared DIMENSION(1:*).
The associating entity in the block following a RANK (scalar-int-const-exp) statement has the rank specified.
The lower bound is the lower bound of the selector for each corresponding dimension, and the upper bound
is the upper bound of the selector for each corresponding dimension of the selector. The associating entity in
a RANK(*) or a RANK (scalar-int-const-exp) block is a variable and may appear in variable definition
contexts.
If the selector has the POINTER, TARGET or ALLOCATABLE attribute, the associating entity has the same
attributes.
Example
The following example shows a SELECT RANK construct that initializes scalars, rank 1, and rank 2 arrays to
zero. If the dummy argument rank is greater than 2, an error message is printed.
1834
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
RANK DEFAULT
PRINT *, "Subroutine initialize called with unexpected rank argument"
END SELECT
RETURN
END SUBROUTINE
The following example shows how to use a select rank to initialize assumed-size arrays of any rank to zero:
See Also
Construct Association
SELECT TYPE
Statement: Marks the beginning of a SELECT TYPE
construct. The construct selects for execution at most
one of its constituent blocks. The selection is based on
the dynamic type of a specified expression.
Syntax
[name:] SELECT TYPE ([ assoc-name => ] selector)
[type-guard-stmt
block]...
END SELECT [name]
1835
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a construct name is specified at the beginning of a SELECT TYPE statement, the same name must appear
in the corresponding END SELECT statement. The same construct name must not be used for different
named constructs in the same scoping unit. If no name is specified at the beginning of a SELECT TYPE
statement, you cannot specify one following the END SELECT statement or any type-guard-stmt. If a type-
guard-stmt specifies a construct name, it must match the construct name on the corresponding SELECT TYPE
statement.
A branch to the END SELECT statement is allowed from within the SELECT TYPE construct, but it is not
allowed from anywhere outside the construct.
Execution of a SELECT TYPE construct whose selector is not a variable causes the selector expression to be
evaluated.
A SELECT TYPE construct selects at most one block to be executed. During execution of that block, the
associate name identifies an entity that is associated with the selector. The entity associated with the
associate name has the declared type and type parameters of the selector. The entity is polymorphic only if
the selector is polymorphic.
The following steps determine which block is selected for execution:
1. If a TYPE IS statement matches the selector, the block following that statement is executed. A TYPE IS
statement matches the selector if the dynamic type and type parameter values of the selector are the
same as those specified by the statement.
2. Otherwise, if exactly one CLASS IS statement matches the selector, the block following that statement
is executed. A CLASS IS statement matches the selector if the dynamic type of the selector is an
extension of the type specified by the statement and the kind type parameters specified by the
statement are the same as the corresponding type parameters of the dynamic type of the selector.
3. Otherwise, if several CLASS IS statements match the selector, one of these statements must specify a
type that is an extension of all the types specified in the others. In this case, the block following that
statement is executed.
4. Otherwise, if there is a CLASS DEFAULT statement, the block following that statement is executed.
Within the block following a TYPE IS statement, the associating entity is not polymorphic, it has the type
named in the TYPE IS statement, and has the type parameters of the selector.
Within the block following a CLASS IS statement, the associating entity is polymorphic and has the declared
type named in the CLASS IS statement. The type parameters of the associating entity are the corresponding
type parameters of the selector.
Within the block following a CLASS DEFAULT statement, the associating entity is polymorphic and has the
same declared type as the selector. The type parameters of the associating entity are those of the declared
type of the selector.
If the declared type of the selector is M, specifying CLASS DEFAULT has the same effect as specifying CLASS
IS (M).
A type-guard-stmt cannot be a branch target statement. You can branch to an END SELECT statement only
from within its SELECT TYPE construct.
1836
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows a SELECT TYPE construct:
TYPE POINT
REAL :: X, Y
END TYPE POINT
TYPE, EXTENDS(POINT) :: POINT_3D
REAL :: Z
END TYPE POINT_3D
TYPE, EXTENDS(POINT) :: COLOR_POINT
INTEGER :: COLOR
END TYPE COLOR_POINT
TYPE(POINT), TARGET :: P
TYPE(POINT_3D), TARGET :: P3D
TYPE(COLOR_POINT), TARGET :: CP
CLASS(POINT), POINTER :: P_OR_CP
P_OR_CP=> CP
SELECT TYPE ( AN => P_OR_CP )
CLASS IS ( POINT )
! "CLASS ( POINT ) :: AN" is implied here
PRINT *, AN%X, AN%Y ! This block gets executed
TYPE IS ( POINT_3D )
! "TYPE ( POINT_3D ) :: AN" is implied here
PRINT *, AN%X, AN%Y, AN%Z
END SELECT
The following example uses declarations from the above example, but it omits the associate name AN:
See Also
Construct Association
Additional Attributes Of Associate Names
SELECTED_CHAR_KIND
Transformational Intrinsic Function (Generic):
Returns the value of the kind type parameter of the
character set named by the argument.
Syntax
result = SELECTED_CHAR_KIND(name)
name (Input) Must be scalar and of type default character. Its value must be
'DEFAULT' or 'ASCII'.
Results
The result is a scalar of type default integer.
1837
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The result is a scalar of type default integer. The result value is 1 if NAME has the value 'DEFAULT' or 'ASCII';
otherwise, the result value is -1.
SELECTED_INT_KIND
Transformational Intrinsic Function (Generic):
Returns the value of the kind parameter of an integer
data type.
Syntax
result = SELECTED_INT_KIND (r)
Results
The result is a scalar of type default integer. The result has a value equal to the value of the kind parameter
of the integer data type that represents all values n in the range of values n with -10 r< n < 10 r.
If no such kind type parameter is available on the processor, the result is -1. If more than one kind type
parameter meets the criteria, the value returned is the one with the smallest decimal exponent range. For
more information, see Model for Integer Data.
Example
SELECTED_INT_KIND (6) = 4
The following shows another example:
i = SELECTED_INT_KIND(8) ! returns 4
i = SELECTED_INT_KIND(3) ! returns 2
i = SELECTED_INT_KIND(10) ! returns 8
i = SELECTED_INT_KIND(20) ! returns -1 because 10**20
! is bigger than 2**63
See Also
SELECTED_REAL_KIND
SELECTED_REAL_KIND
Transformational Intrinsic Function (Generic):
Returns the value of the kind parameter of a real data
type.
Syntax
result = SELECTED_REAL_KIND ([p] [,r] [,radix])
Results
If p or r is absent, the result is as if the argument was present with the value zero. If radix is absent, there
is no requirement on the radix of the selected kind.
1838
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The result is a scalar of type default integer. If both arguments are absent, the result is zero. Otherwise, the
result has a value equal to a value of the kind parameter of a real data type with decimal precision, as
returned by the function PRECISION, of at least p digits, a decimal exponent range, as returned by the
function RANGE, of at least r, and a radix, as returned by the function RADIX, of radix.
If no such kind type parameter is available on the processor, the result is as follows:
Example
SELECTED_REAL_KIND (6, 70) = 8
The following shows another example:
i = SELECTED_REAL_KIND ()
See Also
SELECTED_INT_KIND
IEEE_SELECTED_REAL_KIND
SEQUENCE
Statement: Preserves the storage order of a derived-
type definition.
Syntax
SEQUENCE
Description
The SEQUENCE statement allows derived types to be used in common blocks and to be equivalenced.
The SEQUENCE statement appears only as part of derived-type definitions. It causes the components of the
derived type to be stored in the same sequence they are listed in the type definition. If you do not specify
SEQUENCE, the physical storage order is not necessarily the same as the order of components in the type
definition.
If a derived type is a sequence derived type, then any other derived type that includes it must also be a
sequence type.
Example
!DIR$ PACK:1
TYPE NUM1_SEQ
SEQUENCE
1839
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(2)::int_val
REAL(4)::real_val
LOGICAL(2)::log_val
END TYPE NUM1_SEQ
TYPE num2_seq
SEQUENCE
logical(2)::log_val
integer(2)::int_val
real(4)::real_val
end type num2_seq
type (num1_seq) num1
type (num2_seq) num2
character*8 t, t1
equivalence (num1,t)
equivalence (num2,t1)
num1%int_val=2
num1%real_val=3.5
num1%log_val=.TRUE.
t1(1:2)=t(7:8)
t1(3:4)=t(1:2)
t1(5:8)=t(3:6)
print *, num2%int_val, num2%real_val, num2%log_val
end
See Also
Derived Data Types
Data Types, Constants, and Variables
SETCONTROLFPQQ
Portability Subroutine: Sets the value of the
floating-point processor control word.
Module
USE IFPORT
Syntax
CALL SETCONTROLFPQQ (controlword)
The floating-point control word specifies how various exception conditions are handled by the floating-point
math processor, sets the floating-point precision, and specifies the floating-point rounding mechanism used.
The control word can be any of the following constants (defined in IFPORT.F90):
1840
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
An exception is disabled if its control bit is set to 1. An exception is enabled if its control bit is cleared to 0.
Setting the floating-point precision and rounding mechanism can be useful if you are reusing old code that is
sensitive to the floating-point precision standard used and you want to get the same results as on the old
machine.
You can use GETCONTROLFPQQ to retrieve the current control word and SETCONTROLFPQQ to change the
control word. Most users do not need to change the default settings. If you need to change the control word,
always use SETCONTROLFPQQ to make sure that special routines handling floating-point stack exceptions
and abnormal propagation work correctly.
NOTE
The Intel® Fortran exception handler allows for software masking of invalid operations, but does not
allow the math chip to mask them. If you choose to use the software masking, be aware that this can
affect program performance if you compile code written for Intel Fortran with another compiler.
Example
USE IFPORT
INTEGER(2) status, control, controlo
CALL GETCONTROLFPQQ(control)
WRITE (*, 9000) 'Control word: ', control
! Save old control word
controlo = control
! Clear all flags
control = control .AND. Z'0000'
! Set new control to round up
1841
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
GETCONTROLFPQQ
GETSTATUSFPQQ
LCWRQQ
SCWRQQ
CLEARSTATUSFPQQ
SETDAT
Portability Function: Sets the system date. This
function is only available on Windows* and Linux*
systems.
Module
USE IFPORT
Syntax
result = SETDAT (iyr, imon, iday)
Results
The result type is LOGICAL(4). The result is .TRUE. if the system date is changed; .FALSE. if no change is
made.
Actual arguments of the function SETDAT can be any valid INTEGER(2) or INTEGER(4) expression.
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
Refer to your operating system documentation for the range of permitted dates.
NOTE
On Linux systems, you must have root privileges to execute this function.
Example
USE IFPORT
LOGICAL(4) success
success = SETDAT(INT2(1997+1), INT2(2*3), INT2(30))
END
See Also
GETDAT
GETTIM
1842
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SETTIM
SETENVQQ
Portability Function: Sets the value of an existing
environment variable, or adds and sets a new
environment variable.
Module
USE IFPORT
Syntax
result = SETENVQQ (varname=value)
varname=value (Input) Character*(*). String containing both the name and the value
of the variable to be added or modified. Must be in the form: varname
= value, where varname is the name of an environment variable and
value is the value being assigned to it.
Results
The result is of type LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
Environment variables define the environment in which a program executes. For example, the LIB
environment variable defines the default search path for libraries to be linked with a program.
SETENVQQ deletes any terminating blanks in the string. Although the equal sign (=) is an illegal character
within an environment value, you can use it to terminate value so that trailing blanks are preserved. For
example, the string PATH= =sets value to ''.
You can use SETENVQQ to remove an existing variable by giving a variable name followed by an equal sign
with no value. For example, LIB= removes the variable LIB from the list of environment variables. If you
specify a value for a variable that already exists, its value is changed. If the variable does not exist, it is
created.
SETENVQQ affects only the environment that is local to the current process. You cannot use it to modify the
command-level environment. When the current process terminates, the environment reverts to the level of
the parent process. In most cases, this is the operating system level. However, you can pass the
environment modified by SETENVQQ to any child process created by RUNQQ. These child processes get new
variables and/or values added by SETENVQQ.
SETENVQQ uses the C runtime routine _putenv and GETENVQQ uses the C runtime routine getenv. From the
C documentation:
getenv and _putenv use the copy of the environment pointed to by the global variable _environ to access the
environment. getenv operates only on the data structures accessible to the run-time library and not on the
environment segment created for the process by the operating system.
SETENVQQ and GETENVQQ will not work properly with the Windows* APIs SetEnvironmentVariable and
GetEnvironmentVariable.
Example
USE IFPORT
LOGICAL(4) success
success = SETENVQQ("PATH=c:\mydir\tmp")
success = &
SETENVQQ("LIB=c:\mylib\bessel.lib;c:\math\difq.lib")
END
1843
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
GETENVQQ
RUNQQ
SETERRORMODEQQ
Portability Subroutine: Sets the prompt mode for
critical errors that by default generate system
prompts.
Module
USE IFPORT
Syntax
CALL SETERRORMODEQQ (pmode)
Certain I/O errors cause the system to display an error prompt. For example, attempting to write to a disk
drive with the drive door open generates an "Abort, Retry, Ignore" message. When the system starts up,
system error prompting is enabled by default (pmode= .TRUE.). You can also enable system error prompts by
calling SETERRORMODEQQ with pmode set to ERR$HARDPROMPT (defined in IFPORT.F90).
If prompt mode is turned off, critical errors that normally cause a system prompt are silent. Errors in I/O
statements such as OPEN, READ, and WRITE fail immediately instead of being interrupted with prompts. This
gives you more direct control over what happens when an error occurs. For example, you can use the ERR=
specifier to designate an executable statement to branch to for error handling. You can also take a different
action than that requested by the system prompt, such as opening a temporary file, giving a more
informative error message, or exiting.
You can turn off prompt mode by setting pmode to .FALSE. or to the constant ERR$HARDFAIL (defined in
IFPORT.F90).
Note that SETERRORMODEQQ affects only errors that generate a system prompt. It does not affect other I/O
errors, such as writing to a nonexistent file or attempting to open a nonexistent file with STATUS='OLD'.
Example
!PROGRAM 1
! DRIVE B door open
OPEN (10, FILE = 'B:\NOFILE.DAT', ERR = 100)
! Generates a system prompt error here and waits for the user
! to respond to the prompt before continuing
100 WRITE(*,*) ' Continuing'
END
! PROGRAM 2
! DRIVE B door open
USE IFPORT
CALL SETERRORMODEQQ(.FALSE.)
OPEN (10, FILE = 'B:\NOFILE.DAT', ERR = 100)
! Causes the statement at label 100 to execute
! without system prompt
100 WRITE(*,*) ' Drive B: not available, opening &
&alternative drive.'
OPEN (10, FILE = 'C:\NOFILE.DAT')
END
1844
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SET_EXPONENT
Elemental Intrinsic Function (Generic): Returns
the value of the exponent part (of the model for the
argument) set to a specified value.
Syntax
result = SET_EXPONENT (x,i)
Results
The result type and kind are the same as x. The result has the value x x b i-e. Parameters b and e are defined
in Model for Real Data. If x has the value zero, the result is zero.
Example
If 3.0 is a REAL(4) value, SET_EXPONENT (3.0, 1) has the value 1.5.
See Also
EXPONENT
Data Representation Models
SETFILEACCESSQQ
Portability Function: Sets the file access mode for a
specified file.
Module
USE IFPORT
Syntax
result = SETFILEACCESSQQ (filename,access)
access (Input) INTEGER(4). Constant that sets the access. Can be any
combination of the following flags, combined by an inclusive OR (such
asIOR or OR):
• FILE$ARCHIVE - Marked as having been copied to a backup device.
• FILE$HIDDEN - Hidden. The file does not appear in the directory
list that you can request from the command console.
• FILE$NORMAL - No special attributes (default).
• FILE$READONLY - Write-protected. You can read the file, but you
cannot make changes to it.
• FILE$SYSTEM - Used by the operating system.
The flags are defined in module IFPORT.F90.
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
To set the access value for a file, add the constants representing the appropriate access.
1845
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
USE IFPORT
INTEGER(4) permit
LOGICAL(4) result
See Also
GETFILEINFOQQ
SETFILETIMEQQ
Portability Function: Sets the modification time for
a specified file.
Module
USE IFPORT
Syntax
result = SETFILETIMEQQ (filename,timedate)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The modification time is the time the file was last modified and is useful for keeping track of different
versions of the file. The process that calls SETFILETIMEQQ must have write access to the file; otherwise, the
time cannot be changed. If you set timedate to FILE$CURTIME (defined in IFPORT.F90), SETFILETIMEQQ
sets the modification time to the current system time.
If the function fails, call GETLASTERRORQQ to determine the reason. It can be one of the following:
• ERR$ACCES - Permission denied. The file's (or directory's) permission setting does not allow the specified
access.
• ERR$INVAL - Invalid argument; the timedate argument is invalid.
• ERR$MFILE - Too many open files (the file must be opened to change its modification time).
• ERR$NOENT - File or path not found.
• ERR$NOMEM - Not enough memory is available to execute the command; or the available memory has
been corrupted; or an invalid block exists, indicating that the process making the call was not allocated
properly.
Example
USE IFPORT
INTEGER(2) day, month, year
INTEGER(2) hour, minute, second, hund
INTEGER(4) timedate
LOGICAL(4) result
1846
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PACKTIMEQQ
UNPACKTIMEQQ
GETLASTERRORQQ
SETTIM
Portability Function: Sets the system time in your
programs. This function is only available on Windows*
and Linux* systems.
Module
USE IFPORT
Syntax
result = SETTIM (ihr, imin, isec, i100th)
Results
The result type is LOGICAL(4). The result is .TRUE. if the system time is changed; .FALSE. if no change is
made.
All arguments must be of the same integer kind, that is, all must be INTEGER(2) or all must be INTEGER(4).
If INTEGER(2) arguments are passed, you must specify USE IFPORT.
NOTE
On Linux systems, you must have root privileges to execute this function.
Example
USE IFPORT
LOGICAL(4) success
success = SETTIM(INT2(21),INT2(53+3),&
INT2(14*2),INT2(88))
END
See Also
GETDAT
GETTIM
SETDAT
1847
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SHAPE
Inquiry Intrinsic Function (Generic): Returns the
shape of an array or scalar argument.
Syntax
result = SHAPE (source [, kind])
source (Input) Is a scalar or array. It may be of any data type. It must not be
an assumed-size array, a disassociated pointer, or an allocatable array
that is not allocated. It cannot be an assumed-size array.
Results
The result is a rank-one integer array whose size is equal to the rank of source. If kind is present, the kind
parameter of the result is that specified by kind; otherwise, the kind parameter of the result is that of default
integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.
The value of the result is the shape of source, unless source is assumed-rank and is associated with an
assumed-size array. In that case, the last element of the value returned by SHAPE is -1.
The setting of compiler options specifying integer size can affect this function.
Example
SHAPE (2) has the value of a rank-one array of size zero.
If B is declared as B(2:4, -3:1), then SHAPE (B) has the value (3, 5).
The following shows another example:
INTEGER VEC(2)
REAL array(3:10, -1:3)
VEC = SHAPE(array)
WRITE(*,*) VEC ! prints 8 5
END
!
! Check if a mask is conformal with an array
REAL, ALLOCATABLE :: A(:,:,:)
LOGICAL, ALLOCATABLE :: MASK(:,:,:)
INTEGER B(3), C(3)
LOGICAL conform
ALLOCATE (A(5, 4, 3))
ALLOCATE (MASK(3, 4, 5))
! Check if MASK and A allocated. If they are, check
! that they have the same shape (conform).
IF(ALLOCATED(A) .AND. ALLOCATED(MASK)) THEN
B = SHAPE(A); C = SHAPE(MASK)
IF ((B(1) .EQ. C(1)) .AND. (B(2) .EQ. C(2)) &
.AND. (B(3) .EQ. C(3))) THEN
conform = .TRUE.
ELSE
conform = .FALSE.
END IF
END IF
WRITE(*,*) conform ! prints F
END
See Also
SIZE
1848
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SHARED Clause
Parallel Directive Clause: Specifies variables that
will be shared by all the threads in a team.
Syntax
SHARED (list)
list Is the name of one or more variables or common blocks that are
accessible to the scoping unit. Subobjects cannot be specified. Each
name must be separated by a comma, and a named common block
must appear between slashes (/ /).
All threads within a team access the same storage area for SHARED data.
SHIFTA
Elemental Intrinsic Function (Specific): Performs
a right shift with fill. This function cannot be passed as
an actual argument.
Syntax
result = SHIFTA (i,shift)
Results
The result type and kind are the same as i.
The result has the value obtained by shifting the bits of i to the right shift bits and replicating the leftmost bit
of i in the left shift bits.
If shift is zero the result is i. Bits shifted off the right end are lost.
The model for the interpretation of an integer value as a sequence of bits is in Model for Bit Data.
Example
SHIFTA (IBSET (0, BIT_SIZE (0) - 1), 2) is equal to SHIFTL (7, BIT_SIZE (0) - 3).
SHIFTL
Elemental Intrinsic Function (Specific): Logically
shifts an integer left by a specified number of bits.
This function cannot be passed as an actual argument.
Syntax
result = SHIFTL (i,shift)
shift (Input) Must be of type integer. The value must be nonnegative and
<= BIT_SIZE(i). This value is the number of positions to shift.
Results
The result type and kind are the same as i. The result is the value of i shifted left by shift bit positions. Bits
shifted off the left end are lost; zeros are shifted in from the opposite end.
1849
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ISHFT
SHIFTR
Elemental Intrinsic Function (Specific): Logically
shifts an integer right by a specified number of bits.
This function cannot be passed as an actual argument.
Syntax
result = SHIFTR (i,shift)
shift (Input) Must be of type integer. The value must be nonnegative and
<= BIT_SIZE(i). This value is the number of positions to shift.
Results
The result type and kind are the same as i. The result is the value of i shifted right by shift bit positions. Bits
shifted off the right end are lost; zeros are shifted in from the opposite end.
SHIFTR (i, j) is the same as ISHFT (i, -j).
See Also
ISHFT
SHORT
Portability Function: Converts an INTEGER(4)
argument to INTEGER(2) type.
Module
USE IFPORT
Syntax
result = SHORT (int4)
Results
The result type is INTEGER(2). The result is equal to the lower 16 bits of int4. If the int4 value is greater
than 32,767, the converted INTEGER(2) value is not equal to the original.
Example
USE IFPORT
INTEGER(4) this_one
INTEGER(2) that_one
READ(*,*) this_one
THAT_ONE = SHORT(THIS_ONE)
WRITE(*,10) THIS_ONE, THAT_ONE
10 FORMAT (X," Long integer: ", I16, " Short integer: ", I16)
END
1850
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INT
Type Declarations
SIGN
Elemental Intrinsic Function (Generic): Returns
the absolute value of the first argument times the sign
of the second argument.
Syntax
result = SIGN (a, b)
Results
The result type and kind are the same as a. The value of the result is as follows:
• | a | if b > zero and -| a | if b < zero.
• | a | if b is of type integer and is zero.
• If b is of type real and zero and compiler option assume minus0 is not specified, the value of the result is
| a |.
• If b is of type real and zero and compiler option assume minus0 is specified, the processor can
distinguish between positive and negative real zero and the following occurs:
• If b is positive real zero, the value of the result is | a |.
• If b is negative real zero, the value of the result is -| a |.
The specific named versions of the function require that the arguments have the same kind parameters. The
generic form of the function permits the kind types of the arguments to differ.
Example
SIGN (4.0, -6.0) has the value -4.0.
SIGN (-5.0, 2.0) has the value 5.0.
1851
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
ABS
assume minus0 compiler option
SIGNAL
Portability Function: Controls interrupt signal
handling and changes the action for a specified signal.
Module
USE IFPORT
Syntax
result = SIGNAL (signum, proc, flag)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is the
previous value of proc associated with the specified signal. For example, if the previous value of proc was
SIG_IGN, the return value is also SIG_IGN. You can use this return value in subsequent calls to SIGNAL if
the signal number supplied is invalid, if the flag value is greater than 1, or to restore a previous action
definition.
A return value of SIG_ERR indicates an error, in which case a call to IERRNO returns EINVAL. If the signal
number supplied is invalid, or if the flag value is greater than 1, SIGNAL returns -(EINVAL) and a call to
IERRNO returns EINVAL.
An initial signal handler is in place at startup for SIGFPE (signal 8); its address is returned the first time
SIGNAL is called for SIGFPE. No other signals have initial signal handlers.
Be careful when you use SIGNALQQ or the C signal function to set a handler, and then use the Portability
SIGNAL function to retrieve its value. If SIGNAL returns an address that was not previously set by a call to
SIGNAL, you cannot use that address with either SIGNALQQ or C's signal function, nor can you call it directly.
You can, however, use the return value from SIGNAL in a subsequent call to SIGNAL. This allows you to
restore a signal handler, no matter how the original signal handler was set.
The signal-handler argument proc accepts a single INTEGER(4) argument, which is the number of the signal
to be handled. The function must use the compiler's default calling conventions. If you have used compiler
options, such as option iface, to change the default conventions, add the following directive to the signal
handler function to reset the calling conventions:
!DIR$ ATTRIBUTES DEFAULT :: the-routine-specified-in-proc
1852
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The signal-handler function returns an INTEGER(4) value. If the function has handled the signal, the value
returned is an integer, but the value is not used.
Because signal-handler routines are usually called asynchronously when an interrupt occurs, it is possible
that your signal-handler function will get control when a run-time operation is incomplete and in an unknown
state. You cannot use the following kinds of signal-handler routines:
• Routines that perform low-level (such as FGETC) or high-level (such as READ) I/O.
• Heap routines or any routine that uses the heap routines (such as MALLOC and ALLOCATE).
• Functions that generate a system call (such as TIME).
The following table lists signals, their names and values:
The default action for all signals is to terminate the program with exit code.
ABORT does not assert the SIGABRT signal. The only way to assert SIGABRT or SIGTERM is to use KILL.
SIGNAL can be used to catch SIGFPE exceptions, but it cannot be used to access the error code that caused
the SIGFPE. To do this, use SIGNALQQ instead.
Example
USE IFPORT
EXTERNAL h_abort
INTEGER(4) :: h_abort
INTEGER(4) iret1, iret2, procnum
iret1 = SIGNAL(SIGABRT, h_abort, -1)
WRITE(*,*) 'Set signal handler #1. Return = ', iret1
procnum = getpid( )
iret2 = KILL(procnum, SIGABRT)
WRITE(*,*) 'Raised signal. Return = ', iret2
END
!
! Signal-handler routine
!
INTEGER(4) FUNCTION h_abort (sig_num)
INTEGER(4) sig_num
!DIR$ ATTRIBUTES DEFAULT :: h_abort
WRITE(*,*) 'In signal handler function h_abort for SIG$ABORT'
WRITE(*,*) 'signum = ', sig_num
h_abort = 1
END
1853
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
SIGNALQQ
SIGNALQQ
Portability Function: Registers the function to be
called if an interrupt signal occurs.
Module
USE IFPORT
Syntax
result = SIGNALQQ (sig,func)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result is a
positive integer if successful; otherwise, -1 (SIG$ERR).
SIGNALQQ installs the function func as the handler for a signal of the type specified by sig. If you do not
install a handler, the system by default terminates the program with exit code 3 when an interrupt signal
occurs.
The argument func is the name of a function and must be declared with either the EXTERNAL or IMPLICIT
statements, or have an explicit interface. A function described in an INTERFACE block is EXTERNAL by
default, and does not need to be declared EXTERNAL.
NOTE
All signal-handler functions must be declared with the directive !DIR$ ATTRIBUTES C.
When an interrupt occurs, except a SIG$FPE interrupt, the sig argument SIG$INT is passed to func, and then
func is executed.
When a SIG$FPE interrupt occurs, the function func is passed two arguments: SIG$FPE and the floating-point
error code (for example, FPE$ZERODIVIDE or FPE$OVERFLOW) which identifies the type of floating-point
exception that occurred. The floating-point error codes begin with the prefix FPE$ and are defined in
IFPORT.F90.
If func returns, the calling process resumes execution immediately after the point at which it received the
interrupt signal. This is true regardless of the type of interrupt or operating mode.
Because signal-handler routines are normally called asynchronously when an interrupt occurs, it is possible
that your signal-handler function will get control when a run-time operation is incomplete and in an unknown
state. Therefore, do not call heap routines or any routine that uses the heap routines (for example, I/O
routines, ALLOCATE, and DEALLOCATE).
1854
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To test your signal handler routine you can generate interrupt signals by calling RAISEQQ, which causes your
program either to branch to the signal handlers set with SIGNALQQ, or to perform the system default
behavior if SIGNALQQ has set no signal handler.
The example below shows a signal handler for SIG$ABORT.
Example
INTEGER(2) i2ret
INTEGER(4) i4ret
i2ret = RAISEQQ(SIG$ABORT)
WRITE(*,*) 'Raised signal. Return = ', i2ret
END
!
! Signal handler routine
!
INTEGER(4) FUNCTION h_abort (signum)
!DIR$ ATTRIBUTES C :: h_abort
INTEGER(2) signum
WRITE(*,*) 'In signal handler for SIG$ABORT'
WRITE(*,*) 'signum = ', signum
h_abort = 1
END
See Also
RAISEQQ
SIGNAL
KILL
GETEXCEPTIONPTRSQQ
Syntax
!$OMP SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END SIMD]
1855
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1856
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A SIMD construct binds to the current task region. The binding thread set of the SIMD region is the current
team.
If used, the END SIMD directive must appear immediately after the end of the loop. If you do not specify an
END SIMD directive, an END SIMD directive is assumed at the end of do-loop.
The SIMD construct enables the execution of multiple iterations of the associated loops concurrently by
means of SIMD instructions. No other OpenMP* Fortran construct can appear in a SIMD directive.
A SIMD region binds to the current task region. The binding thread set of the SIMD region is the current
team.
When any thread encounters a SIMD construct, the iterations of the loop associated with the construct may
be executed concurrently using the SIMD lanes that are available to the thread.
If an ORDERED directive with the SIMD clause is specified inside the SIMD region, the ordered regions
encountered by any thread will use only a single SIMD lane to execute the ordered regions in the order of the
loop iterations.
1857
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following is an example using the SIMD directive:
subroutine subr(a, b, c, n)
implicit none
real(kind=kind(0.0d0)),dimension(*) :: a, b, c
integer :: n, i
!$omp simd
do i = 1, n
a(i) = a(i) * b(i) + c(i)
end do
end subroutine
The following example demonstrates the EARLY_EXIT clause:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
qsimd-honor-fp-model, Qsimd-honor-fp-model compiler option
qsimd-serialize-fp-reduction, Qsimd-serialize-fp-reduction compiler option
fp-model, fp compiler option
Nested DO Constructs
Parallel Processing Model for information about Binding Sets
Syntax
!DIR$ SIMD [clause[[,] clause]...]
1858
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1859
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(1) INTEGER
(KIND=1)
INTEGER(2) INTEGER
(KIND=2)
INTEGER(4) INTEGER
(KIND=4)
1860
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER(8) INTEGER
(KIND=8)
COMPLEX(4) COMPLEX
(KIND=4)
COMPLEX(8) COMPLEX
(KIND=8)
If you specify the SIMD directive with no clause, default rules are in effect for variable attributes, vector
length, and so forth.
If you do not explicitly specify a VECTORLENGTH clause, the compiler will choose a VECTORLENGTH using its
own cost model. Misclassification of variables into PRIVATE, FIRSTPRIVATE, LASTPRIVATE, LINEAR, and
REDUCTION, or the lack of appropriate classification of variables, may lead to unintended consequences such
as runtime failures and/or incorrect results.
You can only specify a particular variable in at most one instance of a PRIVATE, LINEAR, or REDUCTION
clause.
If the compiler is unable to vectorize a loop, a warning occurs by default. However, if ASSERT is specified, an
error occurs instead.
1861
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the vectorizer has to stop vectorizing a loop for some reason, the fast floating-point model is used for the
SIMD loop.
A SIMD loop may contain one or more nested loops or be contained in a loop nest. Only the loop preceded by
the SIMD directive is processed for SIMD vectorization.
The vectorization performed on this loop by the SIMD directive overrides any setting you may specify for
options -fp-model (Linux* and macOS) and /fp (Windows*) for this loop.
Note that the SIMD directive may not affect all auto-vectorizable loops. Some of these loops do not have a
way to describe the SIMD vector semantics.
The following restrictions apply to the SIMD directive:
• The countable loop for the SIMD directive has to conform to the DO-loop style of an OpenMP worksharing
loop construct. Additionally, the loop control variable must be a signed integer type.
• The vector values must be signed 8-, 16-, 32-, or 64-bit integers, single or double-precision floating-point
numbers, or single- or double-precision complex numbers.
• A SIMD directive loop performs memory references unconditionally. Therefore, all address computations
must result in valid memory addresses, even though such locations may not be accessed if the loop is
executed sequentially.
To disable the SIMD transformations for vectorization, specify option -no-simd (Linux* and macOS)
or /Qsimd- (Windows*).
To disable transformations that enable more vectorization, specify options -no-vec-no-simd (Linux and
macOS) or /Qvec-/Qsimd- (Windows).
Example
Consider the following:
...
subroutine add(A, N, X)
integer N, X
real A(N)
cDIR$ SIMD
DO I=X+1, N
A(I) = A(I) + A(I-X)
ENDDO
end
...
When the program containing this subroutine is compiled, the DO loop will be vectorized.
Because no optional clause was specified for the directive, default rules will apply for variable attributes,
vector length, and so forth.
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
simd, Qsimd compiler option
qsimd-honor-fp-model, Qsimd-honor-fp-model compiler option
qsimd-serialize-fp-reduction, Qsimd-serialize-fp-reduction compiler option
fp-model, fp compiler option
vec, Qvec compiler option
SIN
Elemental Intrinsic Function (Generic): Produces
the sine of an argument.
1862
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = SIN (x)
Results
The result type and kind are the same as x.
If x is of type real, the result is a value in radians.
If x is of type complex, the real part of the result is a value in radians.
Example
SIN (2.0) has the value 0.9092974.
SIN (0.8) has the value 0.7173561.
SIND
Elemental Intrinsic Function (Generic): Produces
the sine of an argument.
Syntax
result = SIND (x)
Results
The result type and kind are the same as x.
1863
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
SIND (2.0) has the value 3.4899496E-02.
SIND (0.8) has the value 1.3962180E-02.
SINGLE
OpenMP* Fortran Compiler Directive: Specifies
that a block of code is to be executed by only one
thread in the team at a time.
Syntax
!$OMP SINGLE [clause[[,] clause] ... ]
loosely-structured-block
!$OMP END SINGLE [modifier]
-or-
!$OMP SINGLE [clause[[,] clause] ... ]
strictly-structured-block
!$OMP END SINGLE [modifier]
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
• COPYPRIVATE (list)
• NOWAIT
The binding thread set for a SINGLE construct is the current team. A SINGLE region binds to the innermost
enclosing parallel region.
Threads in the team that are not executing this directive wait at the END SINGLE directive unless NOWAIT is
specified.
SINGLE directives must be encountered by all threads in a team or by none at all. It must also be
encountered in the same order by all threads in a team.
Example
In the following example, the first thread that encounters the SINGLE directive executes subroutines OUTPUT
and INPUT:
1864
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
SINH
Elemental Intrinsic Function (Generic): Produces
a hyperbolic sine.
Syntax
result = SINH (x)
Results
The result type and kind are the same as x.
If x is of type complex, the imaginary part of the result is in radians.
Example
SINH (2.0) has the value 3.626860.
SINH (0.8) has the value 0.8881060.
SIZE Function
Inquiry Intrinsic Function (Generic): Returns the
total number of elements in an array, or the extent of
an array along a specified dimension.
Syntax
result = SIZE (array [, dim] [, kind])
dim (Input; optional) Must be a scalar integer with a value in the range 1
to n, where n is the rank of array.
1865
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
In general, if dim is present, the result is the extent of dimension dim in array; otherwise, the result is the
total number of elements in array. However, the following exceptions apply:
• If array is assumed-rank and associated with an assumed-size array and dim is present with a value equal
to the rank of ARRAY, the result has a value of -1.
• If dim is absent and array is assumed-rank, the result has a value equal to PRODUCT(SHAPE(ARRAY,
KIND)).
The setting of compiler options specifying integer size can affect this function.
Example
If B is declared as B(2:4, -3:1), then SIZE (B, DIM=2) has the value 5 and SIZE (B) has the value 15.
The following shows another example:
SIZEOF
Inquiry Intrinsic Function (Generic): Returns the
number of bytes of storage used by the argument. It
cannot be passed as an actual argument.
Syntax
result = SIZEOF (x)
Results
The result type is INTEGER(4) on IA-32 architecture; INTEGER(8) on Intel® 64 architecture. The result value
is the number of bytes of storage used by x.
If x is of derived type, the result includes storage used by padding and descriptors for pointer or allocatable
components, if any, but not the storage used for the data of pointer or allocatable components. If x is an
assumed-rank array associated with an assumed-size array, the result is undefined.
Example
1866
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
C_SIZEOF
SLEEP
Portability Subroutine: Suspends the execution of a
process for a specified interval.
Module
USE IFPORT
Syntax
CALL SLEEP (time)
Example
USE IFPORT
integer(4) hold_time
hold_time = 1 ! lets the loop execute
DO WHILE (hold_time .NE. 0)
write(*,'(A)') "Enter the number of seconds to suspend"
read(*,*) hold_time
CALL SLEEP (hold_time)
END DO
END
See Also
SLEEPQQ
SLEEPQQ
Portability Subroutine: Delays execution of the
program for a specified duration.
Module
USE IFPORT
Syntax
CALL SLEEPQQ (duration)
Example
USE IFPORT
INTEGER(4) delay, freq, duration
delay = 2000
freq = 4000
duration = 1000
CALL SLEEPQQ(delay)
CALL BEEPQQ(freq, duration)
END
1867
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SNGL
Converts a REAL value to a default REAL result.
See Also
See REAL function.
SORTQQ
Portability Subroutine: Sorts a one-dimensional
array. The array elements cannot be derived types or
record structures.
Module
USE IFPORT
Syntax
CALL SORTQQ (adrarray,count,size)
size (Input) INTEGER(4). Positive constant less than 32,767 that specifies
the kind of array to be sorted. The following constants, defined in
IFPORT.F90, specify type and kind for numeric arrays:
SRT$INTEGER1 INTEGER(1)
If the value provided in size is not a symbolic constant and is less than 32,767, the array is assumed to be a
character array with size characters per element.
1868
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Caution
The location of the array must be passed by address using the LOC function. This defeats Fortran type-
checking, so you must make certain that the count and size arguments are correct.
If you pass invalid arguments, SORTQQ attempts to sort random parts of memory. If the memory it
attempts to sort is allocated to the current process, that memory is sorted; otherwise, the operating
system intervenes, the program is halted, and you get a General Protection Violation message.
Example
See Also
BSEARCHQQ
LOC
SPACING
Elemental Intrinsic Function (Generic): Returns
the absolute spacing of model numbers near the
argument value.
Syntax
result = SPACING (x)
Results
The result type and kind are the same as x. The result has the value b e-p. Parameters b, e, and p are defined
in Model for Real Data. If the result value is outside of the real model range, the result is TINY( x).
Example
If 3.0 is a REAL(4) value, SPACING (3.0) has the value 2 -22.
REAL(4) res4
REAL(8) res8, r2
res4 = SPACING(3.0) ! returns 2.384186E-07
res4 = SPACING(-3.0) ! returns 2.384186E-07
r2 = 487923.3
res8 = SPACING(r2) ! returns 5.820766091346741E-011
See Also
TINY
RRSPACING
1869
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SPLITPATHQQ
Portability Function: Breaks a file path or directory
path into its components.
Module
USE IFPORT
Syntax
result = SPLITPATHQQ (path,drive,dir,name,ext)
Results
The result type is INTEGER(4). The result is the length of dir.
The path parameter can be a complete or partial file specification.
$MAXPATH is a symbolic constant defined in module IFPORT.F90 as 260.
Example
USE IFPORT
CHARACTER($MAXPATH) buf
CHARACTER(3) drive
CHARACTER(256) dir
CHARACTER(256) name
CHARACTER(256) ext
CHARACTER(256) file
INTEGER(4) length
buf = 'b:\fortran\test\runtime\tsplit.for'
length = SPLITPATHQQ(buf, drive, dir, name, ext)
WRITE(*,*) drive, dir, name, ext
file = 'partial.f90'
length = SPLITPATHQQ(file, drive, dir, name, ext)
WRITE(*,*) drive, dir, name, ext
END
See Also
FULLPATHQQ
1870
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SPREAD
Transformational Intrinsic Function (Generic):
Creates a replicated array with an added dimension by
making copies of existing elements along a specified
dimension.
Syntax
result = SPREAD (source,dim,ncopies)
source (Input) Must be a scalar or array. It may be of any data type. The
rank must be less than 31.
dim (Input) Must be scalar and of type integer. It must have a value in the
range 1 to n + 1 (inclusive), where n is the rank of source.
ncopies Must be scalar and of type integer. It becomes the extent of the
additional dimension in the result.
Results
The result is an array of the same type as source and of rank that is one greater than source.
If source is an array, each array element in dimension dim of the result is equal to the corresponding array
element in source.
If source is a scalar, the result is a rank-one array with ncopies elements, each with the value source.
If ncopies less than or equal to zero, the result is an array of size zero.
Example
SPREAD ("B", 1, 4) is the character array (/"B", "B", "B", "B"/).
B is the array [3, 4, 5] and NC has the value 4.
SPREAD (B, DIM=1, NCOPIES=NC) produces the array
[ 3 4 5 ]
[ 3 4 5 ]
[ 3 4 5 ]
[ 3 4 5 ].
SPREAD (B, DIM=2, NCOPIES=NC) produces the array
[3 3 3 3 ]
[4 4 4 4 ]
[5 5 5 5 ].
The following shows another example:
See Also
PACK
RESHAPE
1871
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SQRT
Elemental Intrinsic Function (Generic): Produces
the square root of its argument.
Syntax
result = SQRT (x)
Results
The result type and kind are the same as x. The result has a value equal to the square root of x.
A result of type complex is the principal value, with the real part greater than or equal to zero.
When the real part of the result is zero, the imaginary part of the result has the same sign as the imaginary
part of x , even if the imaginary part of x is a negative real zero.
Example
SQRT (16.0) has the value 4.0.
SQRT (3.0) has the value 1.732051.
The following shows another example:
SRAND
Portability Subroutine: Seeds the random number
generator used with IRAND and RAND.
Module
USE IFPORT
1872
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
CALL SRAND (iseed)
SRAND seeds the random number generator used with IRAND and RAND. Calling SRAND is equivalent to
calling IRAND or RAND with a new seed.
The same value for iseed generates the same sequence of random numbers. To vary the sequence, call
SRAND with a different iseed value each time the program is executed.
Example
! How many random numbers out of 100 will be between .5 and .6?
USE IFPORT
ICOUNT = 0
CALL SRAND(123)
DO I = 1, 100
X = RAND(0)
IF ((X>.5).AND.(x<.6)) ICOUNT = ICOUNT + 1
END DO
WRITE(*,*) ICOUNT, "numbers between .5 and .6!"
END
See Also
RAND
IRAND
RANDOM_NUMBER
RANDOM_SEED
SSWRQQ
Portability Subroutine: Returns the floating-point
processor status word.
Module
USE IFPORT
Syntax
CALL SSWRQQ (status)
SSWRQQ performs the same function as the run-time subroutine GETSTATUSFPQQ and is provided for
compatibility.
Example
USE IFPORT
INTEGER(2) status
CALL SSWRQQ (status)
See Also
LCWRQQ
GETSTATUSFPQQ
1873
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT
Portability Function: Returns detailed information
about a file.
Module
USE IFPORT
Syntax
result = STAT (name,statb)
1874
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is INTEGER(4).
On Windows* systems, the result is zero if the inquiry was successful; otherwise, the error code ENOENT
(the specified file could not be found). On Linux* and macOS systems, the file inquired about must be
currently connected to a logical unit and must already exist when STAT is called; if STAT fails, errnois set.
1875
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT returns the same information as FSTAT, but accesses files by name instead of external unit number.
On Windows* systems, LSTAT returns exactly the same information as STAT. On Linux and macOS systems,
if the file denoted by name is a link, LSTAT provides information on the link, while STAT provides information
on the file at the destination of the link.
You can also use the INQUIRE statement to get information about file properties.
Example
USE IFPORT
CHARACTER*12 file_name
INTEGER(4) info_array(12)
print *, 'Enter file to examine: '
read *, file_name
ISTATUS = STAT (file_name, info_array)
if (.not. istatus) then
print *, info_array else
print *, 'Error = ',istatus
end if
end
1876
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
INQUIRE
GETFILEINFOQQ
FSTAT
Statement Function
Statement: Defines a function in a single statement
in the same program unit in which the procedure is
referenced.
Syntax
fun([d-arg [,d-arg]...]) = expr
Description
When a statement function reference appears in an expression, the values of the actual arguments are
associated with the dummy arguments in the statement function definition. The expression in the definition is
then evaluated. The resulting value is used to complete the evaluation of the expression containing the
function reference.
The data type of a statement function can be explicitly defined in a type declaration statement. If no type is
specified, the type is determined by implicit typing rules in effect for the program unit.
Actual arguments must agree in number, order, and data type with their corresponding dummy arguments.
Except for the data type, declarative information associated with an entity is not associated with dummy
arguments in the statement function; for example, declaring an entity to be an array or to be in a common
block does not affect a dummy argument with the same name.
The name of the statement function cannot be the same as the name of any other entity within the same
program unit.
Any reference to a statement function must appear in the same program unit as the definition of that
function.
A statement function reference must appear as (or be part of) an expression. The reference cannot appear
on the left side of an assignment statement.
1877
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following are examples of statement functions:
CHARACTER*10 CSF,A,B
CSF(A,B) = A(6:10)//B(1:5)
The following example shows a statement function and some references to it:
AVG(A,B,C) = (A+B+C)/3.
...
GRADE = AVG(TEST1,TEST2,XLAB)
IF (AVG(P,D,Q) .LT. AVG(X,Y,Z)) STOP
FINAL = AVG(TEST3,TEST4,LAB2) ! Invalid reference; implicit
... ! type of third argument does not
... ! match implicit type of dummy argument
Implicit typing problems can be avoided if all arguments are explicitly typed.
The following statement function definition is invalid because it contains a constant, which cannot be used as
a dummy argument:
REAL COMP, C, D, E
COMP(C,D,E,3.) = (C + D - E)/3.
The following shows another example:
Add (a, b) = a + b
REAL(4) y, x(6)
. . .
DO n = 2, 6
x(n) = Add (y, x(n-1))
END DO
See Also
FUNCTION
Argument Association
Use and Host Association
STATIC
Statement and Attribute: Controls the storage
allocation of variables in subprograms (as does
AUTOMATIC). Variables declared as STATIC and
allocated in memory reside in the static storage area,
rather than in the stack storage area.
Syntax
The STATIC attribute can be specified in a type declaration statement or a STATIC statement, and takes one
of the following forms:
Type Declaration Statement:
type, [att-ls,] STATIC [, att-ls] :: v[, v] ...
1878
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Statement:
STATIC[::] v[, v] ...
NOTE
Variables that are data-initialized, and variables in COMMON and SAVE statements are always static.
This is regardless of whether a compiler option specifies recursion.
A variable cannot be specified as STATIC more than once in the same scoping unit.
If the variable is a pointer, STATIC applies only to the pointer itself, not to any associated target.
Some variables cannot be specified as STATIC. The following table shows these restrictions:
Variable STATIC
Dummy argument No
Automatic object No
Use-associated item No
Function result No
A variable can be specified with both the STATIC and SAVE attributes.
If a variable is in a module's outer scope, it can be specified as STATIC.
1879
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows a type declaration statement specifying the STATIC attribute:
...
CONTAINS
INTEGER FUNCTION REDO_FUNC
INTEGER I, J(10), K
REAL C, D, E(30)
AUTOMATIC I, J, K(20)
STATIC C, D, E
...
END FUNCTION
...
INTEGER N1, N2
N1 = -1
DO WHILE (N1)
N2 = N1*2
call sub1(N1, N2)
read *, N1
END DO
CONTAINS
SUBROUTINE sub1 (iold, inew)
INTEGER, intent(INOUT):: iold
integer, STATIC ::N3
integer, intent(IN) :: inew
if (iold .eq. -1) then
N3 = iold
end if
print *, 'New: ', inew, 'N3: ',N3
END subroutine
!
END
See Also
AUTOMATIC
SAVE
Type Declarations
Compatible attributes
RECURSIVE
OPTIONS
POINTER
Modules and Module Procedures
recursive compiler option
1880
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
STOP [stop-code] [, QUIET = scalar-logical-expr]
ERROR STOP [stop-code] [, QUIET = scalar-logical-expr]
An ERROR STOP statement can appear in a PURE procedure, a STOP statement cannot appear.
If QUIET= is not specified, or if scalar-logical-expr is false, the STOP or ERROR STOP statement does the
following:
• If stop-code is specified, writes the specified message to the standard error device.
• Writes one or more of the following messages to the standard error device indicating which IEEE floating-
point exceptions are signaling if assume fpe-summary is specified:
IEEE_DIVIDE_BY_ZERO is signaling
IEEE_INVALID is signaling
IEEE_OVERFLOW is signaling
IEEE_UNDERFLOW is signaling
• STOP initiates normal termination on the image that executes it. ERROR STOP initiates error termination.
If stop-code is a character expression, STOP returns a status of zero and ERROR STOP returns a status of
non-zero. If stop-code is an integer, a status equal to stop-code is returned for both STOP and
ERROR_STOP.
If stop-code is not specified, or if QUIET= is specified and scalar-logical-expr has the value .TRUE., the
executing image initiates normal or error termination, and no message is printed; for STOP, a status of zero
is returned; for ERROR STOP, a positive status value of 128 is returned
When a program is running on multiple images, a STOP statement on one image does not affect the other
images; they can continue to reference and define the coarrays located on the stopped image. An ERROR
STOP initiates execution termination on all images, which may include flushing of I/O buffers, closing of I/O
files, and reporting error status on one or more images.
Effect on Windows* Systems
In QuickWin programs, the following is displayed in a message box:
STOP 99999
In this case, the program returns a status equal to 159 because integer 99999 = Z'1869F', and the lowest
byte is equal to Z'9F', which equals 159.
Example
The following examples show valid STOP statements:
STOP 98
STOP 'END OF RUN', QUIET=(J.EQ.K)
DO
1881
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
READ *, X, Y
IF (X > Y) STOP 5555
END DO
The following shows another example:
See Also
assume compiler option
EXIT
Program Termination
STOPPED_IMAGES
Transformational Intrinsic Function (Generic):
Returns an array of index images that have initiated
normal termination.
Syntax
result = STOPPED_IMAGES ([team, kind])
kind (Input; optional) Must be a scalar integer expression with a value that
is a valid INTEGER kind type parameter.
Results
The result is a rank-one integer array with the same type kind parameters as kind if present; otherwise,
default integer. The size of the array is equal to the number of images in the specified team that have
initiated normal termination.
The result array elements are the image index values of images on the specified team that have initiated
normal termination. The indices are arranged in increasing numeric order.
Example
If image 5 and 12 of the current team have initiated normal termination, the result of STOPPED_IMAGES ( )
is an array of default integer type with size 2 defined with the value [5, 12]. If no images in the current team
are known to have failed, the result of STOPPED_IMAGES ( ) is a zero-sized array.
See Also
FAILED_IMAGES
IMAGE_STATUS
STORAGE_SIZE
Inquiry Intrinsic Function (Generic): Returns the
storage size in bits.
Syntax
result = STORAGE_SIZE (a [, kind])
1882
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a scalar of type integer. If kind is present, the kind parameter of the result is that specified by
kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent
the result value in the kind of the result, the result is undefined.
The result value is the size expressed in bits for an element of an array that has the dynamic type and kind
parameters of a.
If the type and kind parameters are such that storage association applies, the result is consistent with the
named constants defined in the intrinsic module ISO_FORTRAN_ENV.
An array element may take more bits to store than a scalar, since any hardware-imposed alignment
requirements for array elements may not apply to a scalar variable.
NOTE
The result is intended to be the size in memory that an object takes when it is stored. This
size may differ from the size it takes during expression handling (which may be the native
register size) or when stored in a file. If an object is never stored in memory but only in a
register, this function returns the size it would take if it were stored in memory.
Example
STORAGE_SIZE (1.0) has the same value as the named constant NUMERIC_STORAGE_SIZE in the intrinsic
module ISO_FORTRAN_ENV.
See Also
Storage Association
ISO_FORTRAN_ENV Module
Syntax
!DIR$ STRICT
!DIR$ NOSTRICT
If STRICT is specified and no language standard is specified on the command line, the default is to disable
features not found in Fortran 2018.
The STRICT and NOSTRICT directives can appear only appear at the top of a program unit. A program unit is
a main program, an external subroutine or function, a module, or a block data program unit. STRICT and
NOSTRICT cannot appear between program units, or at the beginning of internal subprograms. They do not
affect any modules invoked with the USE statement in the program unit that contains them.
1883
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! NOSTRICT by default
TYPE stuff
INTEGER(4) k
INTEGER(4) m
CHARACTER(4) name
END TYPE stuff
TYPE (stuff) examp
DOUBLE COMPLEX cd ! non-standard data type, no error
cd =(3.0D0, 4.0D0)
examp.k = 4 ! non-standard component designation,
! no error
END
SUBROUTINE STRICTDEMO( )
!DIR$ STRICT
TYPE stuff
INTEGER(4) k
INTEGER(4) m
CHARACTER(4) name
END TYPE stuff
TYPE (stuff) samp
DOUBLE COMPLEX cd ! ERROR
cd =(3.0D0, 4.0D0)
samp.k = 4 ! ERROR
END SUBROUTINE
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
stand compiler option
Equivalent Compiler Options
Syntax
STRUCTURE [/structure-name/] [field-namelist]
field-declaration
[field-declaration]
. . .
[field-declaration]
END STRUCTURE
1884
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
INTEGER*4 P
STRUCTURE /ABC/
PARAMETER (P=4)
REAL*4 F
END STRUCTURE
REAL*4 A(P)
The Standard Fortran derived type replaces STRUCTURE and RECORD constructs, and should be used in
writing new code. See Derived Data Types.
Unlike type declaration statements, structure declarations do not create variables. Structured variables
(records) are created when you use a RECORD statement containing the name of a previously declared
structure. The RECORD statement can be considered as a kind of type declaration statement. The difference
is that aggregate items, not single items, are being defined.
Within a structure declaration, the ordering of both the statements and the field names within the statements
is important, because this ordering determines the order of the fields in records.
In a structure declaration, each field offset is the sum of the lengths of the previous fields, so the length of
the structure is the sum of the lengths of its fields. The structure is packed; you must explicitly provide any
alignment that is needed by including, for example, unnamed fields of the appropriate length.
1885
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
By default, fields are aligned on natural boundaries; misaligned fields are padded as necessary. To avoid
padding of records, you should lay out structures so that all fields are naturally aligned.
To pack fields on arbitrary byte boundaries, you must specify a compiler option. You can also specify
alignment for fields by using the OPTIONS or PACK general directive.
A field name must not be the same as any intrinsic or user-defined operator (for example, EQ cannot be used
as a field name).
Example
An item can be a RECORD statement that references a previously defined structure type:
STRUCTURE /full_address/
RECORD /full_name/ personsname
RECORD /address/ ship_to
INTEGER*1 age
INTEGER*4 phone
END STRUCTURE
You can specify a particular item by listing the sequence of items required to reach it, separated by a period
(.). Suppose you declare a structure variable, shippingaddress, using the full_addressstructure defined
in the previous example:
In the following example, the declaration defines a structure named APPOINTMENT. APPOINTMENT contains
the structure DATE(field APP_DATE) as a substructure. It also contains a substructure named TIME(field
APP_TIME, an array), a CHARACTER*20 array named APP_MEMO, and a LOGICAL*1 field named APP_FLAG.
STRUCTURE /DATE/
INTEGER*1 DAY, MONTH
INTEGER*2 YEAR
END STRUCTURE
STRUCTURE /APPOINTMENT/
RECORD /DATE/ APP_DATE
STRUCTURE /TIME/ APP_TIME (2)
INTEGER*1 HOUR, MINUTE
END STRUCTURE
CHARACTER*20 APP_MEMO (4)
LOGICAL*1 APP_FLAG
END STRUCTURE
The length of any instance of structure APPOINTMENT is 89 bytes.
1886
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following figure shows the memory mapping of any record or record array element with the structure
APPOINTMENT.
See Also
TYPE
MAP...END MAP
RECORD
UNION...END UNION
PACK Directive
OPTIONS Directive
Data Types, Constants, and Variables
1887
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Record Structures
SUBDEVICE
Parallel Directive Clause: Specifies which tiles or
compute slices (c-slices) of the offload device the
offloaded code will run on. This feature is only
available for ifx.
Syntax
SUBDEVICE ( [level,] start [:length [:stride]] )
The SUBDEVICE clause specifies which sub-devices the offloaded code is to execute on. A GPU device may be
made up of multiple tiles, and each tile may be made up of multiple compute slices (also called c-slices).
Specifying level 0 selects tiles, specifying level 1 selects c-slices. The tiles and c-slices are numbered 0 to n.
start, length, and stride act like an array section subscript to select the indices of the tiles or c-slices the
offloaded code will execute on.
At most one SUBDEVICE clause can appear in a directive that allows the clause.
Example
subdevice (0, 2:5) runs on tiles 2, 3, 4, and 5.
subdevice (1, 2:6:2) runs on compute slices 2, 4 and 6.
SUBMODULE
Statement: Marks the beginning of a submodule
program unit, which contains specifications and
definitions that can be used by one or more program
units.
Syntax
SUBMODULE (ancestor-module-name [:parent-submodule-name]) name
[specification-part]
[module-subprogram
[module-subprogram]...]
END [SUBMODULE [name]]
parent-submodule-name (Optional) Is the name of the parent submodule, if any. The parent
submodule must be a descendant of ancestor-module-name.
1888
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a name follows the END statement, it must be the same as the name specified in the SUBMODULE
statement.
Each submodule has exactly one ancestor module and exactly one parent module or submodule. If the
parent is a module then it must be the ancestor module. The relationship is tree-like, with the parent module
or submodule at the root of the tree, and its descendant submodules as the branches of the tree.
A module or submodule may have one or more descendent submodules.
A submodule can access the entities from its parent module or submodule by host association. Unlike a
module, a submodule cannot be referenced in other program units by use association. Entities declared in a
submodule are only accessible from the submodule and its descendent submodules. Furthermore, a module
procedure can have its interface declared in a module or submodule and its implementation contained in a
descendent submodule in a separate file.
Submodules help the modularization of a large module in several ways:
• Internal data can be shared among submodules without being exposed to users of the module. Without
the submodule feature, when a large module is split into smaller modules, internal data may be forced to
become public in order to be shared among the modules.
• Even if a module procedure implementation in a submodule is changed, as long as the module procedure
interface declared in the ancestor module remains the same, a recompilation would not be needed for the
user of the module. This could reduce the rebuilding time for a complex system.
• Separate concepts with circular dependencies can now be implemented in different submodules. It cannot
be done with just modules.
• The specification part of a submodule must not contain IMPORT, ENTRY, FORMAT, executable, or statement
function statements.
• A variable, common block, or procedure pointer declared in a submodule implicitly has the SAVE attribute,
which may be confirmed by explicit specification.
• If a specification or constant expression in the specification-part of a submodule includes a reference to a
generic entity, there must be no specific procedures of the generic entity defined in the submodule
subsequent to the specification or constant expression.
Unlike a module, the specification part of a submodule must not contain PUBLIC and PRIVATE specifications.
1889
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Any executable statements in a module or submodule can only be specified in a module or submodule
subprogram.
A submodule can contain one or more procedure interface blocks, which let you specify an explicit interface
for an external subprogram or dummy subprogram.
Example
Consider the following example of a multilevel submodule system:
Module M
In the above example, module M is extended by submodules up to two levels. Module M is the ancestor
module of all the submodules. Entities declared in module M can be shared among all the submodules. A is
the parent submodule of X, Y, and Z. Entities declared in submodule A can be shared among submodules X,
Y, and Z, but not by B or C.
Only public entities declared in M can be available to other program units by use association.
The SUBMODULE declarations for A and X are:
SUBMODULE (M) A
…
END SUBMODULE A
SUBMODULE (M : A) X
…
END SUBMODULE X
The following example shows modules and submodules, separate module procedures, and how circular
dependency can be avoided with submodules. There are five parts in the example:
1. module color_points
2. level-1 submodule color_points_a
3. level-2 submodule color_points_b
4. module palette_stuff
5. program main
! part 1
module color_points ! This is the ancestor module
type color_point
private
real :: x, y
integer :: color
end type color_point
1890
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! part 2
submodule ( color_points ) color_points_a ! submodule of color_points
integer :: instance_count = 0
contains
! Here are the implementations of three of the four separate module
! procedures declared in module color_point.
module subroutine color_point_del ( p )
type(color_point), allocatable :: p
instance_count = instance_count - 1
deallocate ( p )
end subroutine color_point_del
! part 3
submodule ( color_points:color_points_a ) color_points_b
! submodule of color_point_a
contains
! Implementation of a module procedure declared in the ancestor module
1891
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! part 4
module palette_stuff
type :: palette ; ... ; end type palette
contains
subroutine test_palette ( p )
use color_points
! This does not cause a circular dependency because the
! "use palette_stuff" that is logically within color_points
! is in the color_points_a submodule.
type(palette), intent(in) :: p
...
end subroutine test_palette
end module palette_stuff
! part 5
program main
use color_points
! Only public entities in color_points can be accessed here, not the
! entities from its submodules.
1892
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
! color_points
...
call color_point_del (c_1) ! body in color_points_a, interface in
! color_points
...
end program main
See Also
MODULE
FUNCTION
SUBROUTINE
References to Generic Procedures
SUBROUTINE
Statement: The initial statement of a subroutine
subprogram. A subroutine subprogram is invoked in a
CALL statement or by a defined assignment or
operator, and does not return a particular value.
Syntax
[prefix [prefix]] SUBROUTINE name [([d-arg-list]) [lang-binding]]
[specification-part]
[execution-part]
[CONTAINS
[internal-subprogram-part] ]
END [SUBROUTINE [name]]
1893
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
A subroutine is invoked by a CALL statement or defined assignment. When a subroutine is invoked, dummy
arguments (if present) become associated with the corresponding actual arguments specified in the call.
Execution begins with the first executable construct or statement following the SUBROUTINE statement.
Control returns to the calling program unit once the END statement (or a RETURN statement) is executed.
A subroutine subprogram cannot contain a BLOCK DATA statement, a PROGRAM statement, a MODULE
statement, or a SUBMODULE statement. A subroutine can contain SUBROUTINE and FUNCTION statements
to define internal procedures. ENTRY statements can be included to provide multiple entry points to the
subprogram.
You need an interface block for a subroutine when:
• Calling arguments use argument keywords.
• Some arguments are optional.
• A dummy argument is an assumed-shape array, a pointer, or a target.
• The subroutine extends intrinsic assignment.
• The subroutine can be referenced by a generic name.
• The subroutine is in a dynamic-link library.
If the subroutine is in a DLL and is called from your program, use the option DLLEXPORT or DLLIMPORT,
which you can specify with the ATTRIBUTES directive.
Note that if you specify lang-binding, you have to use the parentheses even if there are no arguments. For
example, without lang-binding you can specify SUBROUTINE F but with lang-binding you have to specify
SUBROUTINE F( ) BIND (C).
Example
The following example shows a subroutine:
Main ProgramSubroutine
CALL HELLO_WORLD SUBROUTINE HELLO_WORLD
... PRINT *, "Hello World"
END END SUBROUTINE
1894
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example uses alternate return specifiers to determine where control transfers on completion of
the subroutine:
Main ProgramSubroutine
CALL CHECK(A,B,*10,*20,C) SUBROUTINE CHECK(X,Y,*,*,Q)
TYPE *, 'VALUE LESS THAN ZERO' ...
GO TO 30 50 IF (Z) 60,70,80
10 TYPE*, 'VALUE EQUALS ZERO' 60 RETURN
GO TO 30 70 RETURN 1
20 TYPE*, 'VALUE MORE THAN ZERO' 80 RETURN 2
30 CONTINUE END
...
The SUBROUTINE statement argument list contains two dummy alternate return arguments corresponding to
the actual arguments *10 and *20 in the CALL statement argument list.
The value of Z determines the return, as follows:
• If Z < zero, a normal return occurs and control is transferred to the first executable statement following
CALL CHECK in the main program.
• If Z = = zero, the return is to statement label 10 in the main program.
• If Z > zero, the return is to statement label 20 in the main program.
Note that an alternate return is an obsolescent feature in the Fortran Standard.
The following shows another example:
See Also
FUNCTION
INTERFACE
PURE
ELEMENTAL
CALL
RETURN
ENTRY
Argument Association
Program Units and Procedures
General Rules for Function and Subroutine Subprograms
Deleted and Obsolescent Language Features
SUM
Transformational Intrinsic Function (Generic):
Returns the sum of all the elements in an entire array
or in a specified dimension of an array.
Syntax
result = SUM (array [, mask])
result = SUM (array, dim [, mask])
1895
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
mask (Input; optional) Must be of type logical and conformable with array.
Results
The result is an array or a scalar of the same data type as array.
The result is a scalar if dim is not specified or array has rank one.
The following rules apply if dim is not specified:
• If SUM( array) is specified, the result is the sum of all elements of array. If array has size zero, the result
is zero.
• If SUM( array, MASK= mask) is specified, the result is the sum of all elements of array corresponding to
true elements of mask. If array has size zero, or every element of mask has the value .FALSE., the result
is zero.
The following rules apply if dim is specified:
• If array has rank one, the value is the same as SUM( array[,MASK= mask]).
• An array result has a rank that is one less than array, and shape (d1, d2, ..., ddim-1, ddim+1, ..., dn), where
(d1, d2, ..., dn) is the shape of array.
• The value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn) of SUM( array, dim[, mask]) is equal to
SUM( array(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) [,MASK = mask(s1, s2, ..., sdim-1, :, sdim+1, ..., sn)].
Example
SUM ((/2, 3, 4/)) returns the value 9 (sum of 2 + 3 + 4). SUM ((/2, 3, 4/), DIM=1) returns the same result.
SUM (B, MASK=B .LT. 0.0) returns the arithmetic sum of the negative elements of B.
C is the array
[ 1 2 3 ]
[ 4 5 6 ].
SUM (C, DIM=1) returns the value (5, 7, 9), which is the sum of all elements in each column. 5 is the sum of
1 + 4 in column 1. 7 is the sum of 2 + 5 in column 2, and so forth.
SUM (C, DIM=2) returns the value (6, 15), which is the sum of all elements in each row. 6 is the sum of 1 +
2 + 3 in row 1. 15 is the sum of 4 + 5 + 6 in row 2.
The following shows another example:
See Also
PRODUCT
SYNC ALL
Statement: Performs a synchronization of all images
on the current team.
1896
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
The SYNC ALL statement takes the following form:
SYNC ALL[([STAT=stat-var][, ERRMSG=err-var])]
STAT= and ERRMSG= can appear in either order, but only once in a SYNC ALL statement.
Description
Execution on an image, for example, C, of the segment following the SYNC ALL statement is delayed until
each other image has executed a SYNC ALL statement as many times as has image C.
The segments that executed before the SYNC ALL statement on an image, precede the segments that
execute after the SYNC ALL statement on another image.
Example
In the following example, image 5 reads data and transmits the data to other images:
REAL :: W[*]
SYNC ALL
IF (THIS_IMAGE()==5) THEN
READ (*,*) W
DO I = 6, NUM_IMAGES()
W[I] = W
END DO
END IF
...
SYNC ALL
See Also
Image Control Statements
Coarrays
Using Coarrays
SYNC IMAGES
Statement: Performs a synchronization of the image
with each of the other images in the image set.
Syntax
The SYNC IMAGES statement takes the following form:
SYNC IMAGES (image-set[, STAT=stat-var][, ERRMSG=err-var])
1897
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
STAT= and ERRMSG= can appear in either order, but only once in a SYNC IMAGES statement.
Description
When SYNC IMAGES statements are executed on images C and G, they correspond if the number of times
image C has executed a SYNC IMAGES statement in the current team with G in its image set is the same as
the number of times image G has executed a SYNC IMAGES statement with C in its image set in this team.
The segments that executed before the SYNC IMAGES statement on either image, precede the segments that
execute after the corresponding SYNC IMAGES statement on the other image.
In a program that uses SYNC ALL as its only synchronization mechanism, every SYNC ALL statement can be
replaced by a SYNC IMAGES (*) statement. However, SYNC ALL may provide better performance. SYNC
IMAGES statements are not required to specify the entire image set, or even the same image set, on all
images that participate in the synchronization.
Example
In the following example, image 5 waits for each of the other images to complete using the data. The other
images wait for image 5 to set up the data, but do not wait for any other image:
IF (THIS_IMAGE() == 5) then
SYNC IMAGES(*) ! Sets up coarray data for other images
ELSE
SYNC IMAGES(5) ! Other images use the data set up by image 5
END IF
In the following example, each image synchronizes with its neighbor:
DO THIS_STEP = 1, TOTAL_STEPS
IF (MY_IMAGE > 1) SYNC IMAGES (MY_IMAGE - 1)
! Do the calculations
IF (MY_IMAGE < TOTAL_IMAGES) SYNC IMAGES (MY_IMAGE + 1)
END DO
SYNC ALL
The calculation starts on image 1 since all the others will be waiting on SYNC IMAGES (TOTAL_IMAGES-1).
When this is done, image 2 starts and image 1 performs its second calculation. This continues until they are
all executing different steps at the same time. Eventually, image 1 finishes and then the others finish one by
one.
See Also
Image Control Statements
Coarrays
Using Coarrays
1898
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SYNC MEMORY
Statement: Ends one image segment and begins
another. Each segment can then be ordered in some
way with respect to segments on other images.
Syntax
The SYNC MEMORY statement takes the following form:
SYNC MEMORY [([STAT=stat-var][, ERRMSG=err-var])]
STAT= and ERRMSG= can appear in either order, but only once in a SYNC IMAGES statement.
Description
Unlike the other image control statements, this statement does not have any built-in synchronization effect.
The action regarding X on image Q precedes the action regarding Y on image Q if, by execution of statements
on image P, the following is true:
• A variable X on image Q is defined, referenced, becomes undefined, or has its allocation status, pointer
association status, array bounds, dynamic type, or type parameters changed or inquired about by
execution of a statement
• That statement precedes a successful execution of a SYNC MEMORY statement
• A variable Y on image Q is defined, referenced, becomes undefined, or has its allocation status, pointer
association status, array bounds, dynamic type, or type parameters changed or inquired about by
execution of a statement that succeeds execution of that SYNC MEMORY statement,
User-defined ordering of segment Pi on image P to precede segment Qj on image Q occurs when the
following happens:
• Image P executes an image control statement that ends segment Pi, and then executes statements that
initiate a cooperative synchronization between images P and Q
• Image Q executes statements that complete the cooperative synchronization between images P and Q
and then executes an image control statement that begins segment Qj
Execution of the cooperative synchronization between images P and Q must include a dependency that forces
execution on image P of the statements that initiate the synchronization to precede the execution on image
Q of the statements that complete the synchronization. The mechanisms available for creating such a
dependency are processor dependent.
NOTE
SYNC MEMORY usually suppresses compiler optimizations that may reorder memory
operations across the segment boundary defined by the SYNC MEMORY statement. It
ensures that all memory operations initiated in the preceding segments in its image
complete before any memory operations in the subsequent segment in its image are
started.
1899
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example should be run on two images:
iam = this_image()
if (iam == 1) then
sync memory
call atomic_define(locked[2], .false.)
else if (iam == 2) then
val = .true.
do while (val)
call atomic_ref(val, locked)
end do
sync memory
end if
print *, 'success'
end
See Also
Image Control Statements
Coarrays
Using Coarrays
SYNC TEAM
Statement: Performs a synchronization of all images
on the specified team.
Syntax
The SYNC TEAM statement takes the following form:
SYNC TEAM(team-value [, STAT = stat-var] [, ERRMSG = err-var])
STAT= and ERR= can appear in any order, but each can appear at most once in a SYNC TEAM statement.
Description
A SYNC TEAM statement performs a synchronization of all images on the specified team. The team specified
must be the current team or an ancestor team, or a team whose parent is the current team. The executing
image must be a member of the specified team.
Execution of the segment following the SYNC TEAM statement is delayed on all images of the specified team
until all images of the specified team have executed the same SYNC TEAM statement the same number of
times.
1900
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A SYNC TEAM statement synchronizes a specific team, while a SYNC ALL statement synchronizes the current
team.
Example
In the following example, two teams are created by the FORM TEAM statement. Team number 1 consists of
the odd numbered images of the initial team; team number 2 consists of the even numbered images of the
initial team.
The SYNC TEAM statement when executed by an odd numbered image on the initial team prevents all other
odd numbered images of the initial team from proceeding to segment 2 until all odd images of the initial
team have executed the SYNC TEAM statement. Similarly, all even numbered images of the initial team are
prevented from executing segment 2 until all the even numbered images on the initial team have executed
the SYNC TEAM statement.
Using a SYNC ALL statement would prevent all images of the initial team from executing segment 2 until all
images had executed the SYNC ALL statement.
PROGRAM MAIN
USE ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) odd_even
FORM TEAM (2-MOD (THIS_IMAGE(), 2), odd_even)
! Segment 1
SYNC TEAM (odd_even)
! Segment 2
END PROGRAM
See Also
Image Control Statements
Coarrays
Using Coarrays
SYSTEM
Portability Function: Sends a command to the shell
as if it had been typed at the command line.
Module
USE IFPORT
Syntax
result = SYSTEM (string)
Results
The result type is INTEGER(4). The result is the exit status of the shell command. If -1, use IERRNO to
retrieve the error. Errors can be one of the following:
• E2BIG: The argument list is too long.
• ENOENT: The command interpreter cannot be found.
• ENOEXEC: The command interpreter file has an invalid format and is not executable.
• ENOMEM: Not enough system resources are available to execute the command.
On Windows* systems, the calling process waits until the command terminates. To insure compatibility and
consistent behavior, an image can be invoked directly by using the Windows API CreateProcess( ) in your
Fortran code.
1901
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Commands run with the SYSTEM routine are run in a separate shell. Defaults set with the SYSTEM function,
such as current working directory or environment variables, do not affect the environment the calling
program runs in.
The command line character limit for the SYSTEM function is the same limit that your operating system
command interpreter accepts.
Example
USE IFPORT
INTEGER(4) I, errnum
I = SYSTEM("dir > file.lst")
If (I .eq. -1) then
errnum = ierrno( )
print *, 'Error ', errnum
end if
END
See Also
SYSTEMQQ
SYSTEM_CLOCK
Intrinsic Subroutine: Returns data from a real-time
clock. SYSTEM_CLOCK returns the number of seconds
from 00:00 Coordinated Universal Time (CUT) on 1
JAN 1970. The number is returned with no bias. To
get the elapsed time, you must call SYSTEM_CLOCK
twice, and subtract the starting time value from the
ending time value.
Syntax
CALL SYSTEM_CLOCK ([count] [, count_rate] [, count_max])
count (Output; optional) Must be scalar and of type integer with a kind type
parameter greater than 1. It is set to a value based on the current
value of the processor clock. The value is increased by one for each
clock count until the value count_max is reached, and is reset to zero
at the next count. count lies in the range 0 to count_max.
count_rate (Output; optional) Must be scalar and of type integer or real. It is set
to the number of processor clock counts per second.
If the type is INTEGER(1), count_rate is 0. If the type is INTEGER(2),
count_rate is 1000. If the type is INTEGER(4) or REAL(4), count_rate
is 10000. If the type is INTEGER(8), REAL(8), or REAL(16), count_rate
is 1000000.
If the count argument is also supplied, the value returned for
count_rate is determined by the integer kind of count, not count_rate.
count_max (Output; optional) Must be scalar and of type integer. It is set to the
value HUGE(INT(0,KIND(count))).
If the type of count_rate or count_max is INTEGER(1), count_rate and count_max are zero, indicating that
there is no clock available to Intel® Fortran with an 8-bit range. If count is INTEGER(1), a compile time
message is issued indicating that the kind type is too small.
The values of count_rate and count_max are valid only for calls to SYSTEM_CLOCK where count is the same-
sized integer (or INTEGER(8) for the case where count_rate is REAL(16)).
1902
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
Consider the following:
See Also
DATE_AND_TIME
HUGE
GETTIM
SYSTEMQQ
Portability Function: Executes a system command
by passing a command string to the operating
system's command interpreter.
Module
USE IFPORT
Syntax
result = SYSTEMQQ (commandline)
Results
The result type is LOGICAL(4). The result is .TRUE. if successful; otherwise, .FALSE..
The SYSTEMQQ function lets you pass operating-system commands as well as programs. SYSTEMQQ refers
to the COMSPEC and PATH environment variables that locate the command interpreter file (usually named
COMMAND.COM).
On Windows* systems, the calling process waits until the command terminates. To insure compatibility and
consistent behavior, an image can be invoked directly by using the Windows API CreateProcess( ) in your
Fortran code.
If the function fails, call GETLASTERRORQQ to determine the reason. One of the following errors can be
returned:
• ERR$2BIG - The argument list exceeds 128 bytes, or the space required for the environment formation
exceeds 32K.
• ERR$NOINT - The command interpreter cannot be found.
• ERR$NOEXEC - The command interpreter file has an invalid format and is not executable.
• ERR$NOMEM - Not enough memory is available to execute the command; or the available memory has
been corrupted; or an invalid block exists, indicating that the process making the call was not allocated
properly.
1903
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The command line character limit for the SYSTEMQQ function is the same limit that your operating system
command interpreter accepts.
Example
USE IFPORT
LOGICAL(4) result
result = SYSTEMQQ('copy c:\bin\fmath.dat &
c:\dat\fmath2.dat')
See Also
SYSTEM
T to Z
This section describes language features that start with T, U, V, W, X, Y, or Z.
T to Z
TAN
Elemental Intrinsic Function (Generic): Produces
the tangent of an argument.
Syntax
result = TAN (x)
Results
The result type and kind are the same as x.
If x is of type real, the result is a value in radians.
If x is of type complex, the real part of the result is a value in radians.
Example
TAN (2.0) has the value -2.185040.
TAN (0.8) has the value 1.029639.
1904
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TAND
Elemental Intrinsic Function (Generic): Produces
the tangent of an argument.
Syntax
result = TAND (x)
Results
The result type and kind are the same as x.
Example
TAND (2.0) has the value 3.4920771E-02.
TAND (0.8) has the value 1.3963542E-02.
TANH
Elemental Intrinsic Function (Generic): Produces
a hyperbolic tangent.
Syntax
result = TANH (x)
Results
The result type and kind are the same as x.
If x is of type complex, the imaginary part of the result is in radians.
Example
TANH (2.0) has the value 0.9640276.
TANH (0.8) has the value 0.6640368.
1905
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TARGET
OpenMP* Fortran Compiler Directive: Creates a
device data environment and executes the construct
on that device. This feature is only available for ifx.
Syntax
!$OMP TARGET [clause[[,] clause]... ]
loosely-structured-block
!$OMP END TARGET
-or-
!$OMP TARGET [clause[[,] clause]... ]
strictly-structured-block
!$OMP END TARGET
1906
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding task for a TARGET construct is the encountering task. The target region binds to the enclosing
parallel or task region.
This construct provides a superset of the functionality provided by the TARGET DATA construct, except for the
clauses USE_DEVICE_PTR and USE_DEVICE_ADDR.
A list item in an IS_DEVICE_PTR clause that has a type other than C_PTR is the same as if it was a list item
in a HAS_DEVICE_ADDR clause. List items specified in a IS_DEVICE_PTR or HAS_DEVICE_ADDR clause
cannot appear in a data sharing attribute clause in the same TARGET directive. Note that the OpenMP*
Specification has deprecated non-C_PTR type list items in an IS_DEVICE_PTR clause.
The TARGET construct also specifies that the region is executed by a device. The encountering task waits for
the device to complete the target region at the end of the construct.
If a TARGET, TARGET DATA, or TARGET UPDATE construct appears within an OMP TARGET region, the
construct is ignored.
Execution of the target task may be deferred if the NOWAIT clause is specified; if it is not specified, the
target task is an included task.
If a variable or part of a variable does not appear in an IN_REDUCTION clause and is mapped by the TARGET
construct, the variable's default data-sharing attribute is shared in the data environment of the target task.
A variable that appears as a list item in an IN_REDUCTION clause is implicitly mapped as if it appears in a
MAP clause with a map-type of TOFROM, and a map-type-modifier of ALWAYS.
A variable that is fully or partially mapped by the TARGET construct and that is not a list item in an
IN_REDUCTION clause within the construct has a default data-sharing attribute of SHARED in the target
tasks data environment.
If a variable appears in a REDUCTION or LASTPRIVATE clause in a combined TARGET construct, it is treated
as if it had appeared in a MAP clause with a map-type of TOFROM for REDUCTION and a map-type of FROM
for LASTPRIVATE:
1907
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A non-scalar variable referenced in a TARGET region and not explicitly mapped is implicitly treated as MAP
(TOFROM):
INTEGER A(10)
!$OMP TARGET
A(5) = 5 ! A is treated as MAP (TOFROM)
!$OMP END TARGET
If only a subsection of a non-scalar variable has been mapped in an outer target region, and that variable is
then mapped implicitly inside a nested target region, that variable should not access memory outside of the
mapped subsection of the variable.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET DATA
TARGET UPDATE
DECLARE TARGET
Parallel Processing Model for information about Binding Sets
TARGET DATA
OpenMP* Fortran Compiler Directive: Maps
variables to a device data environment for the extent
of the region. This feature is only available for ifx.
Syntax
!$OMP TARGET DATA [clause[[,] clause]... ]
loosely-structured-block
!$OMP END TARGET DATA
-or-
!$OMP TARGET DATA [clause[[,] clause]... ]
strictly-structured-block
!$OMP END TARGET DATA
• DEVICE (integer-expression)
• IF ([TARGET DATA:] scalar-logical-expression)
• MAP ([[map-type-modifier[,]] map-type: ] list)
• SUBDEVICE ([integer-constant ,] integer-expression [ : integer-
expression [ : integer-expression] ] )
• USE_DEVICE_ADDR (list)
• USE_DEVICE_PTR (ptr-list)
At most one DEVICE clause and one IF clause can appear for the
construct.
At least one USE_DEVICE_PTR, USE_DEVICE_ADDR, or MAP clause
must appear for the construct.
The map-type in a MAP clause must be TO, FROM, TOFROM, or ALLOC.
1908
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding task region for a TARGET DATA construct is the encountering task. The target region binds to the
enclosing parallel or task region.
When a TARGET DATA construct is encountered, a new device data environment is created, and the
encountering task executes the target data region.
Occurrences of a list item appearing in a USE_DEVICE_ADDR clause in the structured block of the construct
are references to the device address of the item if the item has corresponding storage in the device data
environment. If the list item is not mapped, it is assumed to be accessible on the target device. The host
storage of a list item that has a device address may not be accessible from within the structured block. List
items can include array sections.
If a list item in a USE_DEVICE_PTR clause is not of type C_PTR from the intrinsic module ISO_C_BINDING, it
is treated as if it appeared in a USE_DEVICE_ADDR clause. The use of non-C_PTR types in a
USE_DEVICE_PTR clause has been deprecated.
A program must not depend on any ordering of the evaluations of the clauses of the TARGET DATA directive,
or on any side effects of the evaluations of the clauses, except that list items in any MAP clause are data
mapped prior to the conversion of any list items in a USE_DEVICE_PTR or USE_DEVICE_ADDR clause to their
device storage locations within the structured block.
List items in USE_DEVICE_PTR and USE_DEVICE_ADDR clauses can not be specified more than once in the
same or any other USE_DEVICE_PTR or USE_DEVICE_ADDR clause for the construct.
A list item in a USE_DEVICE_PTR or a USE_DEVICE_ADDR clause must not be a component of a derived
type.
List items in a USE_DEVICE_ADDR clause must have been mapped to the device, or be accessible on the
device from the host data environment. Similarly, the value of a list item in a USE_DEVICE_PTR that is of
type C_PTR must be the address of an entity that has storage in the device data environment or that is
accessible on the device from the host data environment.
If a list item in a USE_DEVICE_ADDR is an array section, the designator of the base expression cannot
contain any construct association selectors.
The same variable can be used in both the MAP clause and the USE_DEVICE_PTR clause or a
USE_DEVICE_ADDR clause:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
TARGET UPDATE directive
Parallel Processing Model for information about Binding Sets
TARGET Statement
Statement and Attribute: Specifies that an object
can become the target of a pointer (it can be pointed
to).
Syntax
The TARGET attribute can be specified in a type declaration statement or a TARGET statement, and takes one
of the following forms:
1909
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
object Is the name of the object. The object must not be declared with the
PARAMETER attribute.
Description
A pointer is associated with a target by pointer assignment or by an ALLOCATE statement.
If an object does not have the TARGET attribute or has not been allocated (using an ALLOCATE statement),
no part of it can be accessed by a pointer.
Example
The following example shows type declaration statements specifying the TARGET attribute:
See Also
ALLOCATE
ASSOCIATED
POINTER
Pointer Assignments
Pointer Association
Type Declarations
1910
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Compatible attributes
Syntax
!$OMP TARGET ENTER DATA [clause[[,] clause]... ]
The binding task for the TARGET ENTER DATA construct is the encountering task. TARGET ENTER DATA is a
stand-alone directive.
When a TARGET ENTER DATA construct is encountered, the list items in the MAP clauses are mapped to the
device data environment according to map-type. A map-type must be specified in all MAP clauses and must
be either TO or ALLOC.
The TARGET ENTER DATA construct executes as if it was enclosed in a TASK construct.
When a DEPEND clause is present, it acts as if it appeared on the implicit TASK construct that encloses the
TARGET ENTER DATA construct.
If there is no DEVICE clause, the default device is determined by the internal control variable (ICV) named
default-device-var.
When an IF clause is present and the IF clause scalar-logical-expression evaluates to .FALSE., the device is
the host.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET EXIT DATA
Parallel Processing Model for information about Binding Sets
Syntax
!$OMP TARGET EXIT DATA [clause[[,] clause]... ]
1911
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• NOWAIT
• SUBDEVICE ([integer-constant ,] integer-expression [ : integer-
expression [ : integer-expression] ] )
The binding task for the TARGET EXIT DATA construct is the encountering task. TARGET EXIT DATA is a
stand-alone directive.
When a TARGET EXIT DATA construct is encountered, the list items in the MAP clauses are unmapped from
the device data environment according to map-type. A map-type must be specified in all MAP clauses and
must be FROM, RELEASE, or DELETE.
The TARGET EXIT DATA construct executes as if it was enclosed in a task construct.
When a DEPEND clause is present, it acts as if it appeared on the implicit task construct that encloses the
TARGET EXIT DATA construct.
If there is no DEVICE clause, the default device is determined by the internal control variable (ICV) named
default-device-var.
When an IF clause is present and the IF clause scalar-logical-expression evaluates to .FALSE., the device is
the host.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET ENTER DATA
Parallel Processing Model for information about Binding Sets
TARGET PARALLEL
OpenMP* Fortran Compiler Directive: Creates a
device data environment in a parallel region and
executes the construct on that device.
Syntax
!$OMP TARGET PARALLEL [clause[[,] clause] ... ]
loosely-structured-block
!$OMP END TARGET PARALLEL
-or-
!$OMP TARGET PARALLEL [clause[[,] clause] ... ]
strictly-structured-block
!$OMP END TARGET PARALLEL
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
This directive provides a shortcut for specifying a TARGET construct immediately followed by a PARALLEL
construct. The effect of any clause that applies to both constructs is as if it were applied to both constructs
separately. The only exceptions are the following:
1912
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If any IF clause in the directive includes a directive-name-modifier then all IF clauses in the directive must
include a directive-name-modifier.
• At most one IF clause with no directive-name-modifier can appear on the directive.
• At most one IF clause with the PARALLEL directive-name-modifier can appear on the directive.
• At most one IF clause with the TARGET directive-name-modifier can appear on the directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
IF Clause
TARGET Directive
PARALLEL Directive
TARGET PARALLEL DO
OpenMP* Fortran Compiler Directive: Provides an
abbreviated way to specify a TARGET directive
containing a PARALLEL DO directive and no other
statements.
Syntax
!$OMP TARGET PARALLEL DO [clause[[,] clause] ... ]
do-loop
[!$OMP END TARGET PARALLEL DO]
If the END TARGET PARALLEL DO directive is not specified, the TARGET PARALLEL DO is assumed at the end
of do-loop. If used, the END TARGET PARALLEL DO directive must appear immediately after the end of do-
loop.
The semantics are identical to explicitly specifying a TARGET directive immediately followed by a PARALLEL
DO directive.
The restrictions for the TARGET and PARALLEL DO constructs apply to this directive except for the following:
• If any IF clause in the directive includes a directive-name-modifier then all IF clauses in the directive must
include a directive-name-modifier.
• At most one IF clause with no directive-name-modifier can appear on the directive.
• At most one IF clause with the PARALLEL directive-name-modifier can appear on the directive.
• At most one IF clause with the TARGET directive-name-modifier can appear on the directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
IF Clause
TARGET Directive
PARALLEL DO
1913
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP TARGET PARALLEL DO SIMD [clause[[,] clause] ... ]
do-loop
[!$OMP END TARGET PARALLEL DO SIMD]
If the END TARGET PARALLEL DO SIMD directive is not specified, an END TARGET PARALLEL DO SIMD
directive is assumed at the end of do-loop.
The restrictions for the TARGET and PARALLEL DO SIMD constructs apply to this directive except for the
following:
• If any IF clause in the directive includes a directive-name-modifier then all IF clauses in the directive must
include a directive-name-modifier.
• At most one IF clause with no directive-name-modifier can appear on the directive.
• At most one IF clause with the PARALLEL directive-name-modifier can appear on the directive.
• At most one IF clause with the TARGET directive-name-modifier can appear on the directive.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
IF Clause
TARGET Directive
PARALLEL DO SIMD
Syntax
!$OMP TARGET PARALLEL LOOP [clause[[,] clause]... ]
do-loop
1914
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
clause Can be any of the clauses accepted by the TARGET or PARALLEL LOOP
constructs with identical meanings and restrictions.
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical form. The DO loop iteration variable must be
of type integer.
This combined directive is semantically equivalent to a TARGET directive followed immediately by a PARALLEL
LOOP construct. The restrictions for TARGET and PARALLEL LOOP constructs apply to this combined
construct.
If used, the END TARGET PARALLEL LOOP directive must appear immediately after the end of the loop. If you
do not specify an END TARGET PARALLEL LOOP directive, an END TARGET PARALLEL LOOP directive is
assumed at the end of the do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET directive
PARALLEL LOOP directive
TARGET SIMD
OpenMP* Fortran Compiler Directive: Specifies a
TARGET construct that contains a SIMD construct and
no other statement.
Syntax
!$OMP TARGET SIMD [clause[[,] clause] ... ]
do-loop
[!$OMP END TARGET SIMD]
clause Can be any of the clauses accepted by the TARGET or SIMD directive,
with identical meanings and restrictions
If the END TARGET SIMD directive is not specified, an END TARGET SIMD directive is assumed at the end of
do-loop.
The restrictions for the TARGET and SIMD constructs apply to this directive.
1915
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
SIMD Directive (OpenMP* API)
TARGET TEAMS
OpenMP* Fortran Compiler Directive: Creates a
device data environment and executes the construct
on the same device. It also creates a league of thread
teams with the primary thread in each team executing
the structured block.
Syntax
!$OMP TARGET TEAMS [clause[[,] clause]... ]
loosely-structured-block
!$OMP END TARGET TEAMS
-or-
!$OMP TARGET TEAMS [clause[[,] clause]... ]
strictly-structured-block
!$OMP END TARGET TEAMS
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
This directive provides a shortcut for specifying a TARGET construct immediately followed by a TEAMS
construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
TEAMS
Syntax
!$OMP TARGET TEAMS DISTRIBUTE [clause[[,] clause]... ]
do-loop
[!$OMP END TARGET TEAMS DISTRIBUTE]
1916
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This directive provides a shortcut for specifying a TARGET construct followed immediately by a TEAMS
DISTRIBUTE construct.
If the END TARGET TEAMS DISTRIBUTE directive is not specified, an END TARGET TEAMS DISTRIBUTE
directive is assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
TEAMS DISTRIBUTE
Syntax
!$OMP TARGET TEAMS DISTRIBUTE PARALLEL DO [clause[[,] clause]... ]
do-loop
[!$OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO]
1917
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This directive provides a shortcut for specifying a TARGET construct followed immediately by a TEAMS
DISTRIBUTE PARALLEL DO construct.
If the END TARGET TEAMS DISTRIBUTE PARALLEL DO directive is not specified, an END TARGET TEAMS
DISTRIBUTE PARALLEL DO directive is assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
TEAMS DISTRIBUTE PARALLEL DO
Syntax
!$OMP TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD]
This directive provides a shortcut for specifying a TARGET construct followed immediately by a TEAMS
DISTRIBUTE PARALLEL DO SIMD construct.
If the END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD directive is not specified, an END TARGET TEAMS
DISTRIBUTE PARALLEL DO SIMD directive is assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
TEAMS DISTRIBUTE PARALLEL DO SIMD
1918
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP TARGET TEAMS DISTRIBUTE SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END TARGET TEAMS DISTRIBUTE SIMD]
This directive provides a shortcut for specifying a TARGET construct containing a TEAMS DISTRIBUTE SIMD
construct.
If the END TARGET TEAMS DISTRIBUTE SIMD directive is not specified, an END TARGET TEAMS DISTRIBUTE
SIMD directive is assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET Directive
TEAMS DISTRIBUTE SIMD
Syntax
!$OMP TARGET TEAMS LOOP [clause[[,] clause]... ]
do-loop
[!$OMP END TARGET TEAMS LOOP]
clause Can be any of the clauses accepted by the TARGET or TEAMS LOOP
directives with identical meanings and restrictions.
1919
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical form. The DO loop iteration variable must be
of type integer.
This combined directive is semantically equivalent to a TEAMS LOOP construct that immediately follows a
TARGET directive. All restrictions for TARGET and TEAMS LOOP constructs apply to this combined construct.
If used, the END TARGET TEAMS LOOP directive must appear immediately after the end of the loop. If you do
not specify an END TARGET TEAMS LOOP directive, an END TARGET TEAMS LOOP directive is assumed at the
end of the do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TARGET directive
TEAMS LOOP directive
TARGET UPDATE
OpenMP* Fortran Compiler Directive: Makes the
list items in the device data environment consistent
with their corresponding original list items. This
feature is only available for ifx.
Syntax
!$OMP TARGET UPDATE motion-clause [, clause[[,] clause]... ]
1920
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
For each list item in a FROM clause, the value of the corresponding list
item is assigned to the original list item.
A list item or subobject of a list item that has the ALLOCATABLE
attribute is updated only if it is allocated. A list item that has the
POINTER attribute whose association status is associated, the update
is performed with respect to the pointer target
A list item can only appear in a TO or FROM clause, but not both.
The binding task for a TARGET UPDATE construct is the encountering task. The TARGET UPDATE directive is a
stand-alone directive.
A TARGET UPDATE construct must not appear inside of a target region.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE MAPPER Directive
TARGET Directive
TARGET DATA
Parallel Processing Model for information about Binding Sets
Syntax
!$OMP TARGET VARIANT DISPATCH [clause[[,] clause]]
CALL subr (...)
-or-
!$OMP TARGET VARIANT DISPATCH [clause[[,] clause]]
var = func (...)
1921
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This directive causes the compiler to emit conditional dispatch code around the associated subroutine or
function call that follows the directive. If the default device is available, the variant version is called. If
DEVICE (integer-expression) is specified, the variant is called only if device integer-expression is available. If
SUBDEVICE is specified, the variant is called only if the specified tiles or compute slices are available. If both
DEVICE(n) and SUBDEVICE are specified, the variant is called only if the specified tiles or compute slices are
available on device n. Otherwise, the base version of the procedure is called on the host.
The NOWAIT clause, if present, indicates calls to the procedure can occur asynchronously. If NOWAIT is not
present, calls occur synchronously.
The name of the subroutine or function associated with the TARGET VARIANT DISPATCH directive must have
appeared in a DECLARE VARIANT directive in the specification part of the calling scope. The interface of the
variant procedure must be accessible in the base procedure where the DECLARE VARIANT directive appears.
The procedure called in the statement following the TARGET VARIANT DISPATCH directive must have an
explicit interface accessible at the call site.
The variant version of the procedure has an identical interface as the base function, except the variant has
an additional argument in the last position which is of type C_PTR. This final argument does not appear in
the TARGET VARIANT DISPATCH call, rather, the compiler inserts it if the variant is called.
Example
MODULE vecadd
INTEGER,PARAMETER :: n = 1024
CONTAINS
FUNCTION vecadd_gpu_offload (ptr)RESULT (res)
USE,INTRINSIC :: ISO_C_BINDING, ONLY : c_ptr
!$DEC ATTRIBUTES NOINLINE :: vecadd_gpu_offload
REAL :: res
REAL,DIMENSION(n) :: a, b
INTEGER :: k
PROGRAM main
USE vecadd
REAL :: result = 0.0
1922
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
ELSE
PRINT *, "FAILED: incorrect results"
ENDIF
END PROGRAM
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
DECLARE VARIANT
TASK
OpenMP* Fortran Compiler Directive: Defines a
task region.
Syntax
!$OMP TASK [clause[[,] clause] ... ]
block
!$OMP END TASK
The binding thread set of a TASK construct is the current team. A task region binds to the innermost
enclosing parallel region.
The TASK and END TASK directive pair must appear in the same routine in the executable section of the
code.
The END TASK directive denotes the end of the task.
When a thread encounters a task construct, a task is generated from the code for the associated structured
block. The encountering thread may immediately execute the task, or defer its execution. In the latter case,
any thread in the team may be assigned the task.
A thread that encounters a task scheduling point within the task region may temporarily suspend the task
region. By default, a task is then tied and its suspended task region can only be resumed by the thread that
started its execution. However, if the untied clause is specified in a TASK construct, any thread in the team
can resume the task region after a suspension. The untied clause is ignored in these cases:
• If a final clause has been specified in the same TASK construct and the final clause expression evaluates
to .TRUE..
1923
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
This construct is not supported within a TARGET or a DECLARE TARGET region if the target hardware is
spir64.
Examples
The following example calculates a Fibonacci number. The Fibonacci sequence is 1,1,2,3,5,8,13, etc., where
the current number is the sum of the previous two numbers. If a call to function fib is encountered by a
single thread in a parallel region, a nested task region will be spawned to carry out the computation in
parallel.
real*8 item(10000000)
integer i
!$omp parallel
!$omp single ! loop iteration variable i is private
do i=1,10000000
!$omp task
! i is firstprivate, item is shared
1924
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
call process(item(i))
!$omp end task
end do
!$omp end single
!$omp end parallel
end
The following example modifies the previous one to use an untied task to generate the unassigned tasks. If
the implementation reaches the limit generating unassigned tasks and the generating loop is suspended, any
other thread that becomes available can resume the task generation loop.
real*8 item(10000000)
!$omp parallel
!$omp single!
$omp task untied
! loop iteration variable i is private
do i=1,10000000
!$omp task ! i is firstprivate, item is shared
call process(item(i))
!$omp end task
end do
!$omp end task
!$omp end single
!$omp end parallel
The following example demonstrates four tasks with dependences:
integer :: a
1925
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The following example shows a set of sibling tasks that have dependences between them:
INTEGER :: A(0:N*B-1)
DO I=0,N-1
!$OMP TASK DEPEND(OUT:A(I*B:(I+1)*B-1))
CALL FILL(A(I*B:(I+1)*B-1))
!$OMP END TASK
END DO
DO I=1,N-1
IB = (I-1)*B+1
BB = I*B+1
!$OMP TASK DEPEND(INOUT:A(I*B:(I+1)*B-1)) DEPEND(IN:A((I+1)*B:(I+2)*B-1))
CALL PROCESS(A(I*B:(I+1)*B-1), A((I+1)*B:(I+2)*B-1))
!$OMP END TASK
END DO
DO I=1,N
IB = (I-1)*B+1
!$OMP TASK DEPEND(IN:A(I*B:(I+1)*B-1))
CALL OUTPUT(A(I*B:(I+1)*B-1))
!$OMP END TASK
END DO
1926
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the above example, the tasks of the first loop will be independent of any other tasks since there is no
previous task that expresses a dependence on the same list items. Tasks of the second loop will depend on
two tasks from the first loop. Also, because dependences are constructed in a sequential order, the IN
dependences force the tasks of the second loop to be dependent on the task from the previous iteration to be
processed. Finally, tasks of the third loop can be executed when the corresponding Process task from the
second loop has been executed. For example, if N was 4, the following shows the dependency graph:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
OpenMP* Run-time Library Routines for Fortran
PARALLEL DO
TASKWAIT
TASKYIELD
SHARED Clause
Parallel Processing Model for information about Binding Sets
1927
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TASK_REDUCTION
Specifies a reduction among tasks. The
TASK_REDUCTION clause is a reduction scoping
clause.
Syntax
TASK_REDUCTION (reduction-identifier : list)
Arguments reduction-identifier and list are defined in REDUCTION clause. All the common restrictions for the
REDUCTION clause apply to this clause.
See Also
IN_REDUCTION
DECLARE REDUCTION
REDUCTION
TASKGROUP
TASKGROUP
OpenMP* Fortran Compiler Directive: Specifies a
wait for the completion of all child tasks of the current
task and all of their descendant tasks.
Syntax
!$OMP TASKGROUP [clause[[,] clause] ... ]
loosely-structured-block
!$OMP END TASKGROUP
-or-
!$OMP TASKGROUP [clause[[,] clause] ... ]
strictly-structured-block
!$OMP END TASKGROUP
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
A TASKGROUP construct binds to the current task region. The binding thread set of the taskgroup region is
the current team.
When a thread encounters a TASKGROUP construct, it starts executing the region. There is an implicit task
scheduling point at the end of the TASKGROUP region. The current task is suspended at the task scheduling
point until all child tasks that it generated in the TASKGROUP region and all of their descendant tasks
complete execution.
Any number of reduction clauses can be specified in the TASKGROUP directive, but a list item can appear
only once in reduction clauses for that directive.
1928
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TASK
TASKWAIT
TASKYIELD
Parallel Processing Model for information about Binding Sets
TASKLOOP
OpenMP* Fortran Compiler Directive: Specifies
that the iterations of one or more associated DO loops
should be executed in parallel using OpenMP* tasks.
The iterations are distributed across tasks that are
created by the construct and scheduled to be
executed.
Syntax
!$OMP TASKLOOP [clause[[,] clause]... ]
do-loop
[!$OMP END TASKLOOP]
1929
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If you do not specify GRAINSIZE or NUM_TASKS, the number of loop tasks created and the number of logical
loop iterations assigned to these tasks is implementation defined. The GRAINSIZE clause and NUM_TASKS
clauses are mutually exclusive; they cannot appear in the same TASKLOOP directive.
The binding thread set of the TASKLOOP region is the current team. A TASKLOOP region binds to the
innermost enclosing parallel region.
When a thread encounters a TASKLOOP construct, the construct partitions the associated loops into tasks for
parallel execution of the loop iterations. The data environment of the created tasks is created according to
the clauses specified in the TASKLOOP construct, any data environment ICVs, and any defaults that apply.
The order of the creation of the loop tasks is unspecified. Programs that rely on any execution order of the
logical loop iterations are non-conforming.
If used, the END TASKLOOP directive must appear immediately after the end of the loop. If you do not
specify an END TASKLOOP directive, an END TASKLOOP directive is assumed at the end of the do-loop.
By default, the TASKLOOP construct executes as if it was enclosed in a TASKGROUP construct with no
statements or directives outside of the TASKLOOP construct. Therefore, the TASKLOOP construct creates an
implicit TASKGROUP region.
When a REDUCTION clause appears in a TASKLOOP construct, it behaves as if a TASK_REDUCTION clause
was applied to the implicit TASKGROUP construct enclosing the TASKLOOP construct. For each task that is
generated by the TASKLOOP construct, an IN_REDUCTION clause with the same reduction-identifier and the
same list items that appear in the REDUCTION clause is applied to the task. Each generated task participates
in the reduction defined by the IN_REDUCTION clause applied to the implicit TASKGROUP construct.
1930
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
When an IN_REDUCTION clause appears in a TASKLOOP construct, an IN_REDUCTION clause with the same
reduction-identifier and the same list items of the IN_REDUCTION clause is applied to the generated tasks.
The behavior is the same as if each generated task was defined by a TASK construct that contains an
IN_REDUCTION clause with the same reduction-identifier and list items. The generated tasks participate in a
reduction defined by a previous reduction scoping clause.
A list item must not appear in both a REDUCTION and IN_REDUCTION clause in the same TASKLOOP
directive.
The following restrictions also apply:
• A program that branches into or out of a TASKLOOP region is non-conforming.
• All loops associated with the TASKLOOP construct must be perfectly nested. There must be no intervening
code nor any other OpenMP* directive between any two loops.
NOTE
This construct is not supported within a TARGET or a DECLARE TARGET region if the target hardware is
spir64.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TASK_REDUCTION
TASKLOOP SIMD
OpenMP* Fortran Compiler Directive: Specifies a
loop that can be executed concurrently using SIMD
instructions and that those iterations will also be
executed in parallel using OpenMP* tasks.
Syntax
!$OMP TASKLOOP SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END TASKLOOP SIMD]
clause Can be almost all of the clauses accepted by the TASKLOOP or SIMD
directives with identical meanings and restrictions.
If the END TASKLOOP SIMD directive is not specified, an END TASKLOOP SIMD directive is assumed at the
end of do-loop.
1931
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The binding thread set of the TASKLOOP SIMD region is the current team. A TASKLOOP SIMD region binds to
the innermost enclosing parallel region.
The TASKLOOP SIMD construct first distributes the iterations of the associated loops across tasks in a
manner consistent with any clauses that apply to the TASKLOOP construct. The resulting tasks are then
converted to SIMD loops in a manner consistent with any clauses that apply to the SIMD construct.
The effect of any clause that applies to both constructs is as if it were applied to both constructs separately,
except for the COLLAPSE clause. For the purpose of converting each task to a SIMD loop, the COLLAPSE
directive is ignored, and an IN_REDUCTION clause behaves as if a REDUCTION clause, with the same
reduction-identifier and list items, is applied to the SIMD construct.
This directive specifies a composite construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TASKWAIT
OpenMP* Fortran Compiler Directive: Specifies a
wait on the completion of child tasks generated since
the beginning of the current task.
Syntax
!$OMP TASKWAIT [clause[[,] clause]...]
A TASKWAIT construct binds to the current task region. The binding thread set of the taskwait region is the
current team.
When the DEPEND clause is not specified, the current task region is suspended at an implicit scheduling point
in the construct until the child tasks that the current task generated prior to the TASKWAIT have completed
execution.
A TASKWAIT construct with one or more DEPEND clauses and a NOWAIT clause behaves as if the clauses
were applied to a TASK construct with an empty structured block that generates a task whose execution is
deferred until all preceding tasks of the current task complete execution before subsequently generated tasks
that depend on this task begin execution.
A TASKWAIT construct with one or more DEPEND clauses and no NOWAIT clause behaves as if the DEPEND
clauses were applied to a TASK construct with an empty structured block that generates an included and
mergeable task. The current task is suspended until the preceding tasks of the current task complete
execution.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
1932
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TASK directive
TASKYIELD directive
Parallel Processing Model for information about Binding Sets
TASKYIELD
OpenMP* Fortran Compiler Directive: Specifies
that the current task can be suspended at this point in
favor of execution of a different task.
Syntax
!$OMP TASKYIELD
A taskyield region binds to the current task region. The binding thread set of the taskyield region is the
current team.
Because the TASKYIELD construct is a stand-alone directive, there are some restrictions on its placement
within a program:
• The TASKYIELD directive can only be placed at a point where a Fortran executable statement is allowed.
• The TASKYIELD directive cannot be used as the action statement in an IF statement or as the executable
statement following a label if the label is referenced in the program.
The TASKYIELD construct includes an explicit task scheduling point in the current task region.
Example
The following example shows use of the TASKYIELD directive. It is non-conforming, because the FLUSH,
BARRIER, TASKWAIT, and TASKYIELD directives are stand-alone directives and cannot be the action
statement of an IF statement or a labeled branch target.
SUBROUTINE NONCONFORMING_STANDALONE()
INTEGER A
A = 1
! the FLUSH directive must not be the action statement in an IF statement
!
IF (A .NE. 0) !$OMP FLUSH(A)
GOTO 100
1933
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SUBROUTINE CONFORMING_STANDALONE ()
INTEGER N
N = 1
IF (N .NE. 0) THEN
!$OMP FLUSH(N)
ENDIF
IF (N .NE. 0) THEN
!$OMP BARRIER
ENDIF
IF (N .NE. 0) THEN
!$OMP TASKWAIT
ENDIF
IF (N .NE. 0) THEN
!$OMP TASKYIELD
ENDIF
GOTO 100
100 CONTINUE
!$OMP FLUSH(N)
GOTO 200
200 CONTINUE
!$OMP BARRIER
GOTO 300
300 CONTINUE
!$OMP TASKWAIT
GOTO 400
400 CONTINUE
!$OMP TASKYIELD
END SUBROUTINE
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TASK directive
TASKWAIT directive
Parallel Processing Model for information about Binding Sets
TEAM_NUMBER
Transformational Intrinsic Function (Generic):
Returns the team number of the specified team.
Syntax
result = TEAM_NUMBER ([ team ])
1934
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is an integer scalar whose value is -1 if the specified team is the initial team; otherwise, it is the
positive integer value that identifies the team of the executing image in the set of teams described by the
team.
Example
Consider the following program:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: original, odd_even
original = GET_TEAM (CURRENT_TEAM)
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
CHANGE TEAM (odd_even)
. . .
IF((THIS_IMAGE()==1).AND. (TEAM_NUMBER()==2) THEN
PRINT *, TEAM_NUMBER(original)
PRINT *, TEAM_NUMBER()
END IF
. . .
END TEAM
END PROGRAM
See Also
CHANGE TEAM
TEAMS
OpenMP* Fortran Compiler Directive: Creates a
league of thread teams to execute a structured block
in the primary thread of each team. This feature is
only available for ifx.
Syntax
!$OMP TEAMS [clause[[,] clause]... ]
loosely-structured-block
!$OMP END TEAMS
-or-
!$OMP TEAMS [clause[[,] clause]... ]
strictly-structured-block
!$OMP END TEAMS
1935
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
The binding thread set for a TEAMS construct is the encountering thread.
If a TEAMS construct appears within a TARGET construct, the enclosing TARGET construct must contain no
other statements or directives outside of the TEAMS construct. The following are the only OpenMP*
constructs that can be nested in the team's region:
• DISTRIBUTE
• PARALLEL
• PARALLEL SECTIONS
• PARALLEL WORKSHARE
• PARALLEL DO
• PARALLEL DO SIMD
The thread that encounters this directive constructs a league of thread teams that execute the block in the
primary thread of each team. After the teams are created, the number of teams remains constant for the
duration of the team's parallel region.
The region following the TEAMS construct is executed by the primary thread of each team. Other threads do
not begin execution until the primary thread encounters a parallel region. After the teams complete
execution of the TEAMS construct region, the encountering thread resumes execution of the enclosing target
region.
If NUM_TEAMS is not specified, the default number of teams is one. If THREAD_LIMIT is not specified, the
default number of threads is the-number-of-available-hardware-threads / NUM_TEAMS.
A program must not depend on any side effects or any ordering of the evaluation of clauses in the TEAMS
directive.
Each team has a unique team number. You can use the OpenMP* run-time library routine
OMP_GET_TEAM_NUM to get the team number of the calling thread.
1936
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Each thread within the team has a unique thread identifier returned by the OpenMP run-time library routine
OMP_GET_THREAD_NUM. As in any thread team, the thread identifier starts at zero for the primary thread
up to THREAD_LIMIT - 1 for the remaining threads.
Immediately after this directive, only the primary threads in each team are executing, the other team
members will only start to execute at the next (nested) parallel region. Therefore, there are only
NUM_TEAMS threads executing, and each of them has OMP_GET_THREAD_NUM() == 0.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Parallel Processing Model for information about Binding Sets
TEAMS DISTRIBUTE
OpenMP* Fortran Compiler Directive: Creates a
league of thread teams to execute a structured block
in the primary thread of each team. It also specifies
that loop iterations will be distributed among the
primary threads of all thread teams in a league
created by a TEAMS construct.
Syntax
!$OMP TEAMS DISTRIBUTE [clause[[,] clause]... ]
do-loop
[!$OMP END TEAMS DISTRIBUTE]
This directive provides a shortcut for specifying a TEAMS construct containing a DISTRIBUTE construct.
If the END TEAMS DISTRIBUTE directive is not specified, an END TEAMS DISTRIBUTE directive is assumed at
the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
1937
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP TEAMS DISTRIBUTE PARALLEL DO [clause[[,] clause]... ]
do-loop
[!$OMP END TEAMS DISTRIBUTE PARALLEL DO]
This directive provides a shortcut for specifying a TEAMS construct immediately followed by a DISTRIBUTE
PARALLEL DO construct. Some clauses are permitted on both constructs.
If the END TEAMS DISTRIBUTE PARALLEL DO directive is not specified, an END TEAMS DISTRIBUTE
PARALLEL DO directive is assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Syntax
!$OMP TEAMS DISTRIBUTE PARALLEL DO SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END TEAMS DISTRIBUTE PARALLEL DO SIMD]
1938
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This directive provides a shortcut for specifying a TEAMS construct immediately followed by a DISTRIBUTE
PARALLEL DO SIMD construct. The effect of any clause that applies to both constructs is as if it were applied
to both constructs separately.
If the END TEAMS DISTRIBUTE PARALLEL DO SIMD directive is not specified, an END TEAMS DISTRIBUTE
PARALLEL DO SIMD directive is assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Syntax
!$OMP TEAMS DISTRIBUTE SIMD [clause[[,] clause]... ]
do-loop
[!$OMP END TEAMS DISTRIBUTE SIMD]
This directive provides a shortcut for specifying a TEAMS construct immediately followed by a DISTRIBUTE
SIMD construct. The effect of any clause that applies to both constructs is as if it were applied to both
constructs separately.
If the END TEAMS DISTRIBUTE SIMD directive is not specified, an END TEAMS DISTRIBUTE SIMD directive is
assumed at the end of do-loop.
See Also
OpenMP Fortran Compiler Directives
1939
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TEAMS LOOP
OpenMP* Fortran Compiler Directive: Specifies a
shortcut for specifying a LOOP construct inside a
TEAMS construct. This feature is only available for ifx.
Syntax
!$OMP TEAMS LOOP [clause[[,] clause]... ]
do-loop
[!$OMP END TEAMS LOOP]
clause Can be any of the clauses accepted by the TEAMS or LOOP directives
with identical meanings and restrictions.
do-loop Is a DO loop that may contain other nested DO loops. The DO loops
must all be in canonical form. The DO loop iteration variable must be
of type integer.
This combined directive is semantically equivalent to a LOOP construct that immediately follows a TEAMS
directive. All restrictions for TEAMS and LOOP constructs apply to this combined construct.
If used, the END TEAMS LOOP directive must appear immediately after the end of the loop. If you do not
specify an END TEAMS LOOP directive, an END TEAMS LOOP directive is assumed at the end of the do-loop.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
TEAMS directive
LOOP directive
THIS_IMAGE
Transformational Intrinsic Function (Generic):
Returns the image index of the invoking image on the
current or specified team, or the cosubscripts for the
executing image on the current or specified team.
Syntax
result = THIS_IMAGE ([ team ])
result = THIS_IMAGE (coarray [, team])
result = THIS_IMAGE (coarray, dim [, team])
1940
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result type is default integer. It is scalar if coarray is not specified or dim is specified; otherwise, the
result has rank one and its size is equal to the corank of coarray.
The result depends on which arguments are specified:
• If no argument is specified, as in THIS_IMAGE ( ), the result is a scalar with a value equal to the index of
the invoking image on the current team.
• If only the team argument is specified, the result is a scalar with a value equal to the index of the
invoking image on the specified team.
• If coarray is specified and dim is not, the result is the sequence of cosubscript values for coarray that
would specify the invoking image on the specified team, or the current team if team is not specified.
• If coarray and dim are specified, the result is the value of cosubscript dim in the sequence of cosubscript
values for coarray that would specify the invoking image on the specified team, or the current team if
team is not specified.
Examples
Consider that coarray C is declared by the following statement:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: initial, odd_even
INTEGER coarray1[0:9, 10, *], coarray2 [10, 10, *]
initial = GET_TEAM (CURRENT_TEAM)
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
PRINT *, THIS_IMAGE()
PRINT *, THIS_IMAGE (coarray1)
PRINT *, THIS_IMAGE (coarray2, 2)
CHANGE TEAM (odd_even)
. . .
PRINT *, THIS_IMAGE(), THIS_IMAGE(initial)
PRINT *, THIS_IMAGE(coarray1)
PRINT *, THIS_IMAGE(coarry2,TEAM = initial)
PRINT *, THIS_IMAGE(coarray2, 2)
PRINT *, THIS_IMAGE(coarray2, 2, initial)
. . .
END TEAM
. . .
END PROGRAM
1941
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If there are 1024 images on the initial team, on image 8 of the initial team, the first print statement will print
8, the second print statement will print the value of the array [7, 1, 1], and the third print statement will
print 1. On that same image, the first print statement inside the CHANGE TEAM construct prints 4, 8, the
second prints the value of the array [7, 1, 1], the third prints the value of the array [8, 1, 1], and the fourth
and fifth both print 1.
On image 512 of the original team, the first print statement will print 512, the second print statement will
print the value of the array [1, 2, 6], and the third will print 2. On the same image inside the CHANGE team
construct, the first print statement will print 256 and 512, the second prints the value of the array [1,2,6],
the third prints the value of the array [2,2,6], and the fourth and fifth both print 2.
THREADPRIVATE
OpenMP* Fortran Compiler Directive: Specifies
named common blocks and certain variables to be
private (local) to each thread; they are global within
the thread.
Syntax
!$OMP THREADPRIVATE (list)
Each thread gets its own copy of the common block or variable, so data written to this object by one thread
is not directly visible to other threads.
During serial portions and MASKED sections of the program, accesses are to the primary thread copy of the
common block or variable. On entry to the first parallel region, data in the THREADPRIVATE common blocks
or variables should be assumed to be undefined unless a COPYIN clause is specified in the PARALLEL
directive.
The THREADPRIVATE directive must appear in the section of a scoping unit in which the common block or
variable is declared. Although variables in common blocks can be accessed by use association or host
association, common block names cannot. This means that a common block name specified in a
THREADPRIVATE directive must be declared to be a common block in the same scoping unit in which the
THREADPRIVATE directive appears.
When a common block (which is initialized using DATA statements) appears in a THREADPRIVATE directive,
each thread copy is initialized once prior to its first use. For subsequent parallel regions, data in
THREADPRIVATE common blocks are guaranteed to persist only if the dynamic threads mechanism has been
disabled and if the number of threads are the same for all the parallel regions.
A THREADPRIVATE common block or its constituent variables can appear only in a COPYIN clause. They are
not permitted in a PRIVATE, FIRSTPRIVATE, LASTPRIVATE, SHARED, or REDUCTION clause. They are not
affected by the DEFAULT clause.
If a THREADPRIVATE directive specifying a common block name appears in one program unit, then the
directive must also appear in every other program unit that contains a COMMON statement specifying the
same common block name. It must appear after the last COMMON statement in the program unit.
If a THREADPRIVATE variable or a THREADPRIVATE common block is declared with the BIND attribute, the
corresponding C entities must also be specified in a threadprivate directive in the C program.
1942
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
On Windows* systems, if you specify option /Qopenmp-threadprivate:compat, the compiler does
not generate threadsafe code for common blocks in an !$OMP THREADPRIVATE directive unless at
least one element in the common block is explicitly initialized.
Example
In the following example, the common blocks BLK1 and FIELDS are specified as thread private:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
Syntax
CALL TIME (buf)
The date is returned as a 8-byte ASCII character string taking the form hh:mm:ss, where:
If buf is of numeric type and smaller than 8 bytes, data corruption can occur.
If buf is of character type, its associated length is passed to the subroutine. If buf is smaller than 8 bytes,
the subroutine truncates the date to fit in the specified length. If an array of type character is passed, the
subroutine stores the date in the first array element, using the element length, not the length of the entire
array.
1943
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
CHARACTER*1 HOUR(8)
...
CALL TIME (HOUR)
The length of the first array element in CHARACTER array HOUR is passed to the TIME subroutine. The
subroutine then truncates the time to fit into the 1-character element, producing an incorrect result.
See Also
DATE_AND_TIME
Module
USE IFPORT
Syntax
Function Syntax:
result = TIME( )
Subroutine Syntax:
CALL TIME (timestr)
Results
The result type is INTEGER(4). The result value is the number of seconds that have elapsed since 00:00:00
Greenwich mean time, January 1, 1970.
The subroutine fills a parameter with the current time as a string in the format hh:mm:ss.
The value returned by this routine can be used as input to other portability date and time functions.
Example
USE IFPORT
INTEGER(4) int_time
character*8 char_time
int_time = TIME( )
call TIME(char_time)
print *, 'Integer: ', int_time, 'time: ', char_time
END
See Also
DATE_AND_TIME
1944
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TIMEF
Portability Function: Returns the number of seconds
since the first time it is called, or zero.
Module
USE IFPORT
Syntax
result = TIMEF( )
Results
The result type is REAL(8). The result value is the number of seconds that have elapsed since the first time
TIMEF was called.
The first time it is called, TIMEF returns 0.
Example
USE IFPORT
INTEGER i, j
REAL(8) elapsed_time
elapsed_time = TIMEF( )
DO i = 1, 100000
j = j + 1
END DO
elapsed_time = TIMEF( )
PRINT *, elapsed_time
END
See Also
Date and Time Procedures
TINY
Inquiry Intrinsic Function (Generic): Returns the
smallest number in the model representing the same
type and kind parameters as the argument.
Syntax
result = TINY (x)
Results
The result is a scalar with the same type and kind parameters as x. The result has the value b emin - 1.
Parameters b and emin are defined in Model for Real Data.
Example
If X is of type REAL(4), TINY (X) has the value 2 -126.
1945
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL(8) r, result
r = 487923.3D0
result = TINY(r) ! returns 2.225073858507201E-308
See Also
HUGE
Data Representation Models
TRACEBACKQQ
Run-Time Subroutine: Provides traceback
information. Uses the Intel® Fortran run-time library
traceback facility to generate a stack trace showing
the program call stack as it appeared at the time of
the call to TRACEBACKQQ( ).
Module
USE IFCORE
Syntax
CALL TRACEBACKQQ ([string] [,user_exit_code] [,status] [,eptr])
1946
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The TRACEBACKQQ routine provides a standard way for an application to initiate a stack trace. It can be
used to report application detected errors, debugging, and so forth. It uses the stack trace support in the
Intel Fortran run-time library, and produces the same output that the run-time library produces for
unhandled errors and exceptions.
The error message string normally included by the run-time system is replaced with the user-supplied
message text, or omitted if no string is specified. Traceback output is directed to the target destination
appropriate for the application type, just as it is when traceback is initiated internally by the run-time
system.
Example
In the most simple case, you can generate a stack trace by coding the call to TRACEBACKQQ with no
arguments:
CALL TRACEBACKQQ()
This call causes the run-time library to generate a traceback report with no leading header message, from
wherever the call site is, and terminate execution.
The following example generates a traceback report with no leading header message, from wherever the call
site is, and aborts execution:
USE IFCORE
CALL TRACEBACKQQ( )
The following example generates a traceback report with the user-supplied string as the header, and aborts
execution:
USE IFCORE
CALL TRACEBACKQQ("My application message string")
The following example generates a traceback report with the user-supplied string as the header, and aborts
execution, returning a status code of 123 to the operating system:
USE IFCORE
CALL TRACEBACKQQ(STRING="Bad value for TEMP",USER_EXIT_CODE=123)
Consider the following:
...
USE IFCORE
INTEGER(4) RTN_STS
INCLUDE 'IOSDEF.FOR'
...
CALL TRACEBACKQQ(USER_EXIT_CODE=-1,STATUS=RTN_STS)
IF (RTN_STS .EQ. FOR$IOS_SUCCESS) THEN
PRINT *,'TRACEBACK WAS SUCCESSFUL'
END IF
...
1947
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This example generates a traceback report with no header string, and returns to the caller to continue
execution of the application. If the traceback process succeeds, a status will be returned in variable
RTN_STS.
You can specify arguments that generate a stack trace with the user-supplied string as the header and
instead of terminating execution, return control to the caller to continue execution of the application. For
example:
1948
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
.
.
.
CHECK_EXCEPTION_INFO = 1
END
To return a pointer to C run-time exception information pointers within a user-defined handler that was
established with SIGNALQQ (or directly with the C signal function), you can call the GETEXCEPTIONPTRSQQ
routine.
See Also
GETEXCEPTIONPTRSQQ
TRAILZ
Elemental Intrinsic Function (Specific): Returns
the number of trailing zero bits in an integer.
Syntax
result = TRAILZ (i)
Results
The result type is default integer. The result value is the number of trailing zeros in the binary representation
of the integer i.
The model for the interpretation of an integer value as a sequence of bits is shown in Model for Bit Data.
Example
Consider the following:
INTEGER*8 J, TWO
PARAMETER (TWO=2)
DO J= -1, 40
TYPE *, TRAILZ(TWO**J) ! Prints 64, then 0 up to
ENDDO ! 40 (trailing zeros)
END
TRANSFER
Transformational Intrinsic Function (Generic):
Converts the bit pattern of the first argument
according to the type and kind parameters of the
second argument.
Syntax
result = TRANSFER (source,mold[,size])
mold (Input) Must be a scalar or array (of any data type). It provides the
type characteristics (not a value) for the result.
size (Input; optional) Must be scalar and of type integer. It provides the
number of elements for the output result.
1949
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result has the same type and type parameters as mold.
If mold is a scalar and size is omitted, the result is a scalar.
If mold is an array and size is omitted, the result is a rank-one array. Its size is the smallest that is possible
to hold all of source.
If size is present, the result is a rank-one array of size size.
When the size of source is greater than zero, mold must not be an array with elements of size zero.
If the internal representation of the result occupies m bits, and the internal representation of source occupies
n bits, then if m > n, the right-most src bits of result contain the bit pattern contained in source, and the m
minus n left-most bits of result are undefined. If m < n, then result contains the bit pattern of the right-most
m bits of source, and the left-most n minus m bits of source are ignored. Otherwise, the result contains the bit
pattern contained in source.
Example
TRANSFER (1082130432, 0.0) has the value 4.0 (on processors that represent the values 4.0 and
1082130432 as the string of binary digits 0100 0000 1000 0000 0000 0000 0000 0000).
TRANSFER ((/2.2, 3.3, 4.4/), ((0.0, 0.0))) results in a scalar whose value is (2.2, 3.3).
TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/)) results in a complex rank-one array of length 2. Its first element
is (2.2,3.3) and its second element has a real part with the value 4.4 and an undefined imaginary part.
TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/), 1) results in a complex rank-one array having one element with
the value (2.2, 3.3).
The following shows another example:
TRANSPOSE
Transformational Intrinsic Function (Generic):
Transposes an array of rank two.
Syntax
result = TRANSPOSE (matrix)
1950
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Results
The result is a rank-two array with the same type and kind parameters as matrix. Its shape is (n, m), where
(m, n) is the shape of matrix. For example, if the shape of matrix is (4,6), the shape of the result is (6,4).
Element (i, j) of the result has the value matrix(j, i), where i is in the range 1 to n, and j is in the range 1 to
m.
Example
B is the array
[ 2 3 4 ]
[ 5 6 7 ]
[ 8 9 1 ].
TRANSPOSE (B) has the value
[ 2 5 8 ]
[ 3 6 9 ]
[ 4 7 1 ].
The following shows another example:
See Also
RESHAPE
PRODUCT
TRIM
Transformational Intrinsic Function (Generic):
Returns the argument with trailing blanks removed.
Syntax
result = TRIM (string)
Results
The result is of type character with the same kind parameter as string. Its length is the length of string
minus the number of trailing blanks in string.
The value of the result is the same as string, except any trailing blanks are removed. If string contains only
blank characters, the result has zero length.
Example
TRIM (' NAME ') has the value ' NAME'.
TRIM (' C D ') has the value ' C D'.
1951
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
LEN_TRIM
TTYNAM
Portability Subroutine: Specifies a terminal device
name.
Module
USE IFPORT
Syntax
CALL TTYNAM (string,lunit)
Type Declarations
Statement: Explicitly specifies the properties of data
objects or functions.
Syntax
A type declaration has the general form:
type-spec[ [, att] ... :: ] v[/c-list/][, v[/c-list/]] ...
TYPE (derived-type-name)
For information about parameterized derived types, see
Parameterized Derived-Type Declarations.
TYPE (*)
This defines the entity as an assumed-type object.
CLASS (derived-type-name)
CLASS (*)
1952
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
DOUBLE PRECISION
COMPLEX[([KIND=]k)]
DOUBLE COMPLEX
CHARACTER[([KIND=]k)]
LOGICAL[([KIND=]k)]
In the optional kind selector "([KIND=]k)", k is the kind parameter. It
must be an acceptable kind parameter for that data type. If the kind
selector is not present, entities declared are of default type.
When type-spec is intrin-type, kind parameters for intrinsic
numeric and logical data types can also be specified using the *n
format, where n is the length (in bytes) of the entity; for example,
INTEGER*4. The *n format cannot be used when type-spec is TYPE
(intrin-type).
1953
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The c-list cannot specify more than one value unless it initializes an
array. When initializing an array, the c-list must contain a value for
every element in the array.
Description
Type declaration statements must precede all executable statements.
In most cases, a type declaration statement overrides (or confirms) the implicit type of an entity. However, a
variable that appears in a DATA statement and is typed implicitly can appear in a subsequent type declaration
only if that declaration confirms the implicit typing.
The double colon separator (::) is required only if the declaration contains an attribute specifier or
initialization; otherwise it is optional.
If att or a double colon (::) appears, c-list cannot be specified; for example:
1954
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The PROTECTED attribute is only allowed for a procedure pointer or named variable that is not in a common
block. A pointer object that has the PROTECTED attribute and is accessed by use association must not appear
as:
A derived-type-name cannot be the same as the name of any standard intrinsic type. The type names BYTE
and DOUBLECOMPLEX are not standard type names; they are Intel Fortran extensions. If BYTE or
DOUBLECOMPLEX is declared to be a derived-type-name, it overrides the intrinsic name BYTE or
DOUBLECOMPLEX. For example:
• The entity has no declared type and its dynamic type and type parameters are assumed from its effective
argument. An assumed-type object is unlimited polymorphic.
• An assumed-type object must be a dummy variable that does not have the ALLOCATABLE,
CODIMENSION, INTENT(OUT), POINTER, or VALUE attribute and is not an explicit-shape array.
1955
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• An assumed-type object that is not assumed-shape and not assumed-rank is intended to be passed as the
C address of the object. A TYPE(*) explicit-shape array is not permitted because there is insufficient
information passed for an assumed-type explicit-shape array that is an actual argument corresponding to
an assumed-shape dummy argument to compute element offsets.
• An assumed-type variable name must not appear in a designator or expression except as an actual
argument corresponding to a dummy argument that is assumed-type, or as the first argument to any of
the following intrinsic or intrinsic module functions: IS_CONTIGUOUS, LBOUND, PRESENT, RANK, SHAPE,
SIZE, UBOUND, and C_LOC.
• An assumed-type actual argument that corresponds to an assumed-rank dummy argument must be
assumed-shape or assumed-rank.
An object can have more than one attribute. The following table lists the compatible attributes:
Compatible Attributes
Attribute Compatible with:
1956
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following show valid type declaration statements:
1957
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
REAL a (10)
LOGICAL, DIMENSION (5, 5) :: mask1, mask2
TYPE (COMPLEX) :: cube_root = (-0.5, 0.867)
INTEGER, PARAMETER :: short = SELECTED_INT_KIND (4)
REAL (KIND (0.0D0)) a1
TYPE (REAL (KIND = 4)) b
COMPLEX (KIND = KIND (0.0D0)) :: c
INTEGER (short) k ! Range at least -9999 to 9999
TYPE (member) :: george
The following shows an example of pointer initialization:
See Also
TYPE Declaration for Derived Types
CLASS Declaration
CHARACTER
COMPLEX
Default Initialization
DOUBLE COMPLEX
DOUBLE PRECISION
INTEGER
LOGICAL
REAL
IMPLICIT
RECORD
STRUCTURE
Syntax
TYPE [[,attr-list] :: ] name [(type-param-name-list)]
[type-param-def-stmts]
[PRIVATE statement or SEQUENCE statement]. . .
[component-definition]. . .
1958
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
[type-bound-procedure-part]
END TYPE [name]
name Is the name of the derived data type. It must not be the same as the
name of any intrinsic type, or the same as the name of a derived type
that can be accessed from a module.
1959
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1960
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a name is specified following the END TYPE statement, it must be the same name that follows TYPE in the
derived type statement.
A derived type can be defined only once in a scoping unit. If the same derived-type name appears in a
derived-type definition in another scoping unit, it is treated independently.
A component name has the scope of the derived-type definition only. Therefore, the same name can be used
in another derived-type definition in the same scoping unit.
The default accessibility attribute for a module is PUBLIC unless it has been changed by a PRIVATE statement
with no entity-list.
A PUBLIC or PRIVATE keyword can only appear on the TYPE statement of a derived-type definition, or on a
component or type-bound procedure declaration of the type if the derived-type definition is in the
specification part of a module.
The PRIVATE statement can only be specified in the component-definition or type-bound-procedure-part if
the derived-type definition is in the specification part of a module. A PRIVATE statement inside a component-
definition part specifies that the default accessibility of all components of the derived type are PRIVATE.
Similarly, a PRIVATE statement inside a type-bound-procedure-part specifies that the default accessibility of
the type bound procedures of the derived type are PRIVATE. If the default accessibility of components or
type-bound procedures is PRIVATE, individual components or type-bound procedures can be declared
PUBLIC, overriding the default accessibility attribute.
If a type definition is PRIVATE, the type name and the structure constructor for the type are accessible only
within the module containing the definition and in the descendants of that module.
Two data entities have the same type if they are both declared to be of the same derived type; the derived-
type definition can be accessed from a module or a host scoping unit.
If EXTENDS appears and the type being defined has a coarray ultimate component, its parent type must
have a coarray ultimate component.
Data entities in different scoping units also have the same type if the following is true:
• They are declared with reference to different derived-type definitions that specify the same type name.
• All have the SEQUENCE property.
• All have the BIND attribute.
• They have no components with PRIVATE accessibility.
• They have type parameters and components that agree in order, name, and attributes.
Otherwise, they are of different derived types.
A data component is a coarray if the component declaration contains a coarray specification. If the
component declaration contains a coarray specification, it specifies the corank.
1961
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
! DERIVED.F90
! Define a derived-type structure,
! type variables, and assign values
TYPE member
INTEGER age
CHARACTER (LEN = 20) name
END TYPE member
TYPE mem_name
SEQUENCE
CHARACTER (LEN = 20) lastn
CHARACTER (LEN = 20) firstn
CHARACTER (len = 3) cos ! this works because COS is a component name
END TYPE mem_name
TYPE member
SEQUENCE
TYPE (mem_name) :: name
INTEGER age
CHARACTER (LEN = 20) specialty
END TYPE member
In the following example, a and b are both variable arrays of derived type pair:
TYPE employee_name
CHARACTER(25) last_name
CHARACTER(15) first_name
END TYPE
1962
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
TYPE employee_addr
CHARACTER(20) street_name
INTEGER(2) street_number
INTEGER(2) apt_number
CHARACTER(20) city
CHARACTER(2) state
INTEGER(4) zip
END TYPE
Objects of these derived types can then be used within a third derived-type specification, such as:
TYPE employee_data
TYPE (employee_name) :: name
TYPE (employee_addr) :: addr
INTEGER(4) telephone
INTEGER(2) date_of_birth
INTEGER(2) date_of_hire
INTEGER(2) social_security(3)
LOGICAL(2) married
INTEGER(2) dependents
END TYPE
The following program shows how you initialize components of a derived-type object:
TYPE list_node
CHARACTER(20) :: street_name = “ “
INTEGER(2) :: street_number = 0
INTEGER(2) :: apt_number = -1
CHARACTER(20) :: city = “ “
CHARACTER(2) :: state = “NH”
INTEGER(4) :: zip = 0
TYPE (list_node), POINTER :: next => NULL()
END TYPE
NH 3054
Coarrays are a Fortran 2008 feature. The following example shows a derived-type definition with a coarray
component:
TYPE NEW_TYPE
REAL,ALLOCATABLE,CODIMENSION[:,:,:] :: NEW(:,:,:)
END TYPE NEW_TYPE
An object of type NEW_TYPE must be a scalar and it cannot be a pointer, allocatable, or a coarray.
The following example shows a derived-type definition containing a coarray-spec:
type t
integer :: k
real, allocatable :: x (:,:)[:,:]
end type t
1963
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, when the assignment to DEST occurs, DEST%TA is unallocated: it is first allocated
with the size of SOURCE%TA and then the value of SOURCE%TA is assigned into DEST%TA:
TYPE T
INTEGER I
END TYPE T
TYPE T2
TYPE (T), ALLOCATABLE :: TA
END TYPE T2
ALLOCATE(SOURCE%TA)
DEST = SOURCE
The use of allocatable components of recursive type can involve direct recursion, in which the type has a
component that is the same type as its parent. The following example creates a five-element linked list using
allocatable components of recursive type:
TYPE T
INTEGER I
TYPE(T), ALLOCATABLE :: NEXT
END TYPE
ALLOCATE(ORIG)
TA => ORIG
DO I=1,5
TA%I = I
ALLOCATE(TA%NEXT)
TA => TA%NEXT
END DO
By using allocatable components rather than pointer components, there is no need to explicitly nullify
component NEXT - it is set to an unallocated state automatically by the compiler. Because the semantics of
ALLOCATE(SOURCE=) require the allocation and copying of all allocated allocatable components from ORIG
into COPY, we can create a complete, unique copy of the entire linked list in one easy statement:
ALLOCATE(COPY, SOURCE=ORIG)
In addition to direct recursion, indirect recursion or forward referencing can also be used. In the following
example, component A of type T is of type T2, a forward reference to a type not yet defined, while
component B of type T2 is of type T:
TYPE T
TYPE(T2), ALLOCATABLE :: A
END TYPE
TYPE T2
TYPE(T), ALLOCATABLE :: B
END TYPE
TYPE(T2) TY
See Also
Type Declarations
Procedure Pointers
1964
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Type-Bound Procedures
Passed-Object Dummy Arguments
Type Extension
Procedure Pointers as Derived-Type Components
DIMENSION
PRIVATE
PUBLIC
RECORD
SEQUENCE
STRUCTURE...END STRUCTURE
Derived Data Types
Default Initialization
Structure Components
Structure Constructors
UBOUND
Inquiry Intrinsic Function (Generic): Returns the
upper bounds for all dimensions of an array, or the
upper bound for a specified dimension.
Syntax
result = UBOUND (array [, dim] [, kind])
dim (Input; optional) Must be a scalar integer with a value in the range 1
to n, where n is the rank of array.
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The following rule applies if array is not assumed-rank:
• If dim is present, the result is a scalar. Otherwise, the result is a rank-one array with one element for each
dimension of array. Each element in the result corresponds to a dimension of array.
• If dim is present and array is assumed-rank, the value of the result is as if array were a whole array, with
the extent of the final dimension of array when array is associated with an assumed-size array being
considered to be −1.
• If UBOUND is invoked for an assumed-rank object that is associated with a scalar and dim is absent, the
result is a zero-sized array. UBOUND cannot be invoked for an assumed-rank object that is associated
with a scalar if dim is present because the rank of a scalar is zero and dim must be >= 1.
If array is an array section or an array expression that is not a whole array or array structure component,
UBOUND(array, dim) has a value equal to the number of elements in the given dimension.
1965
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If array is a whole array or array structure component, UBOUND(array, dim) has a value equal to the upper
bound for subscript dim of array (if dim is nonzero). If dim has size zero, the corresponding element of the
result has the value zero.
The setting of compiler options specifying integer size can affect this function.
Example
Consider the following:
See Also
LBOUND
UCOBOUND
Inquiry Intrinsic Function (Generic): Returns the
upper cobounds of a coarray.
Syntax
result = UCOBOUND (coarray [,dim [, kind])
dim (Input; optional) Must be an integer scalar with a value in the range 1
<= dim <= n, where n is the corank of coarray. The corresponding
actual argument must not be an optional dummy argument.
Results
The result type is integer. If kind is present, the kind parameter is that specified by kind; otherwise, the kind
parameter is that of default integer type. The result is scalar if dim is present; otherwise, the result is an
array of rank one and size n, wheren is the corank of coarray.
The final upper cobound is the final cosubscript in the cosubscript list for the coarray that selects the image
whose index is equal to the number of images in the current team. The result depends on whether dim is
specified:
• If dim is specified, UCOBOUND (COARRAY, DIM) has a value equal to the upper cobound for cosubscript
dim of coarray.
• If dim is not specified, UCOBOUND (COARRAY) has a value whose ith element is equal to UCOBOUND
(COARRAY, i), for i = 1, 2,. . . , n, where n is the corank of coarray.
1966
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Examples
If A is allocated by the statement ALLOCATE (A [2:3, 7:*]), then LCOBOUND (A) is [2, 7] and LCOBOUND (A,
DIM=2) is 7.
If NUM_IMAGES( ) has the value 30, and coarray B is allocated by the statement ALLOCATE (B[2:3, 0:7, *]),
then UCOBOUND (B) is [3, 7, 2] and UCOBOUND (B, DIM=2) is 7. Note that the cosubscripts [3, 7, 2] do not
correspond to an actual image.
UNDEFINE
Statement: Removes a defined symbol.
See Also
See DEFINE and UNDEFINE.
Syntax
Each unique field or group of fields is defined by a separate map declaration.
UNION
map-declaration
map-declaration
[map-declaration]
. . .
[map-declaration]
END UNION
1967
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
As with normal Fortran type declarations, data can be initialized in field declaration statements in union
declarations. However, if fields within multiple map declarations in a single union are initialized, the data
declarations are initialized in the order in which the statements appear. As a result, only the final initialization
takes effect and all of the preceding initializations are overwritten.
The size of the shared area established for a union declaration is the size of the largest map defined for that
union. The size of a map is the sum of the sizes of the fields declared within it.
Manipulating data by using union declarations is similar to using EQUIVALENCE statements. The difference is
that data entities specified within EQUIVALENCE statements are concurrently associated with a common
storage location and the data residing there; with union declarations you can use one discrete storage
location to alternately contain a variety of fields (arrays or variables).
With union declarations, only one map declaration within a union declaration can be associated at any point
in time with the storage location that they share. Whenever a field within another map declaration in the
same union declaration is referenced in your program, the fields in the prior map declaration become
undefined and are succeeded by the fields in the map declaration containing the newly referenced field.
Example
In the following example, the structure WORDS_LONG is defined. This structure contains a union declaration
defining two map fields. The first map field consists of three INTEGER*2 variables (WORD_0, WORD_1, and
WORD_2), and the second, an INTEGER*4 variable, LONG:
STRUCTURE /WORDS_LONG/
UNION
MAP
INTEGER*2 WORD_0, WORD_1, WORD_2
END MAP
MAP
INTEGER*4 LONG
END MAP
END UNION
END STRUCTURE
The length of any record with the structure WORDS_LONG is 6 bytes. The following figure shows the memory
mapping of any record with the structure WORDS_LONG:
Memory Map of Structure WORDS_LONG
In the following example, note how the first 40 characters in the string2 array are overlayed on 4-byte
integers, while the remaining 20 are overlayed on 2-byte integers:
UNION
MAP
CHARACTER*20 string1, CHARACTER*10 string2(6)
1968
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
END MAP
MAP
INTEGER*2 number(10), INTEGER*4 var(10), INTEGER*2
+ datum(10)
END MAP
END UNION
See Also
STRUCTURE and END STRUCTURE
Record Structures
UNLINK
Portability Function: Deletes the file given by path.
Module
USE IFPORT
Syntax
result = UNLINK (name)
name (Input) Character*(*). Path of the file to delete. The path can use
forward (/) or backward (\) slashes as path separators and can
contain drive letters.
Results
The result type is INTEGER(4). The result is zero if successful; otherwise, an error code. Errors can be one of
the following:
• ENOENT: The specified file could not be found.
• EACCES: The specified file is read-only.
You must have adequate permission to delete the specified file.
On Windows systems, you will get the EACCES error if the file has been opened by any process.
Example
USE IFPORT
INTEGER(4) ISTATUS
CHARACTER*20 dirname
READ *, dirname
ISTATUS = UNLINK (dirname)
IF (ISTATUS) then
print *, 'Error ', ISTATUS
END IF
END
See Also
SYSTEM
DELDIRQQ
UNPACK
Transformational Intrinsic Function (Generic):
Takes elements from a rank-one array and unpacks
them into another (possibly larger) array under the
control of a mask.
1969
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = UNPACK (vector,mask,field)
vector (Input) Must be a rank-one array. It may be of any data type. Its size
must be at least t, where t is the number of true elements in mask.
field (Input) Must be of the same type and type parameters as vector and
conformable with mask. Elements in field are inserted into the result
array when the corresponding mask element has the value false.
Results
The result is an array with the same shape as mask, and the same type and type parameters as vector.
Elements in the result array are filled in array element order. If element i of mask is true, the corresponding
element of the result is filled by the next element in vector. Otherwise, it is filled by field (if field is scalar) or
the ith element of field (if field is an array).
Example
N is the array
[ 0 0 1 ]
[ 1 0 1 ]
[ 1 0 0 ],
P is the array (2, 3, 4, 5), and Q is the array
[ T F F ]
[ F T F ]
[ T T F ].
UNPACK (P, MASK=Q, FIELD=N) produces the result
[ 2 0 1 ]
[ 1 4 1 ]
[ 3 5 0 ].
UNPACK (P, MASK=Q, FIELD=1) produces the result
[ 2 1 1 ]
[ 1 4 1 ]
[ 3 5 1 ].
The following shows another example:
See Also
PACK
RESHAPE
1970
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
SHAPE
UNPACKTIMEQQ
Portability Subroutine: Unpacks a packed time and
date value into its component parts.
Module
USE IFPORT
Syntax
CALL UNPACKTIMEQQ (timedate,iyr,imon,iday,ihr,imin,isec)
GETFILEINFOQQ returns time and date in a packed format. You can use UNPACKTIMEQQ to unpack these
values.
The output values reflect the time zone set on the local computer and the daylight savings rules for that time
zone.
Use PACKTIMEQQ to repack times for passing to SETFILETIMEQQ. Packed times can be compared using
relational operators.
Example
USE IFPORT
CHARACTER(80) file
TYPE (FILE$INFO) info
INTEGER(4) handle, result
INTEGER(2) iyr, imon, iday, ihr, imin, isec
file = 'd:\f90ps\bin\t???.*'
handle = FILE$FIRST
result = GETFILEINFOQQ(file, info, handle)
CALL UNPACKTIMEQQ(info%lastwrite, iyr, imon,&
iday, ihr, imin, isec)
WRITE(*,*) iyr, imon, iday
WRITE(*,*) ihr, imin, isec
END
See Also
PACKTIMEQQ
GETFILEINFOQQ
1971
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!$OMP UNROLL [clause]
loop-nest
[!$OMP END UNROLL]
Description
The UNROLL construct applies to the outermost loop of the loop nest.
The transformed loop will be in canonical form only when PARTIAL is specified.
The iteration count of the outermost DO loop must be constant if FULL is specified.
Examples
In the following example, the FULL clause is specified in the UNROLL directive, so the loop iteration count
must be a compile-time constant. In this case, a worksharing loop construct cannot be used because there is
no loop to apply it to after the loop is unrolled.
1972
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, the loop is partially unrolled. The trip count is a multiple of count specified in the
PARTIAL clause:
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
To learn more about canonical form loops, see the OpenMP* specification.
1973
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
!DIR$ UNROLL [(n)] -or- !DIR$ UNROLL [=n]
!DIR$ NOUNROLL
If n is specified, the optimizer unrolls the loop n times. If n is omitted, or if it is outside the allowed range,
the optimizer picks the number of times to unroll the loop.
The UNROLL directive overrides any setting of loop unrolling from the command line.
To use these directives, compiler option O2 or O3 must be set.
Example
!DIR$ UNROLL
do i =1, m
b(i) = a(i) + 1
d(i) = c(i) + 1
enddo
The following shows another example:
!DIR$ UNROLL= 4
do i =1, m
b(i) = a(c(i)) + 1
enddo
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Rules for Loop Directives that Affect Array Assignment Statements
O compiler option
Syntax
!DIR$ UNROLL_AND_JAM [(n)] -or- !DIR$ UNROLL_AND_JAM [=n]
!DIR$ NOUNROLL_AND_JAM
The UNROLL_AND_JAM directive partially unrolls one or more loops higher in the nest than the innermost
loop and fuses (jams) the resulting loops back together. This transformation allows more reuses in the loop.
This directive is not effective on innermost loops. You must ensure that the immediately following loop is not
the innermost loop after compiler-initiated interchanges are completed.
Specifying this directive is a hint to the compiler that the unroll and jam sequence is legal and profitable. The
compiler will enable this transformation whenever possible.
1974
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The UNROLL_AND_JAM directive must precede the DO statement for each DO loop it affects. If n is specified,
the optimizer unrolls the loop n times. If n is omitted or if it is outside the allowed range, the optimizer
chooses the number of times to unroll the loop. The compiler generates correct code by comparing n and the
loop count.
This directive is supported only when compiler option O3 is set. The UNROLL_AND_JAM directive overrides
any setting of loop unrolling from the command line.
When unrolling a loop increases register pressure and code size, it may be necessary to prevent unrolling of
a nested or imperfect nested loop. In such cases, use the NOUNROLL_AND_JAM directive, which hints to the
compiler not to unroll a specified loop.
Example
integer a(10,10), b(10,10), c(10,10), d(10,10)
integer i, j, k
!dir$ unroll_and_jam = 6
do i=1,10
!dir$ unroll_and_jam (6)
do j=1,10
do k=1,10
a (j, i) = a (j, i) + b (k, i) *c (k, j)
end do ! k
end do ! j
end do ! i
end
See Also
General Compiler Directives
Syntax Rules for Compiler Directives
Rules for General Directives that Affect DO Loops
Rules for Loop Directives that Affect Array Assignment Statements
O compiler option
UNTIED Clause
Parallel Directive Clause: Specifies that the task is
never tied to the thread that started its execution.
Syntax
UNTIED
Any thread in the team can resume the task region after a suspension. For example, during runtime, the
execution of a given task can start on thread A, break execution, and later resume on thread B.
USE
Statement: Gives a program unit accessibility to
public entities in a module.
Syntax
USE [[, mod-nature] ::] name [, rename-list]
USE [[, mod-nature] ::] name, ONLY : [ only-list]
1975
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
only-list Is one or more items, separated by commas, where each item is the
name of a public entity in the module or a generic identifier (a generic
name, a defined operator specified as "OPERATOR (op-name)", or
defined assignment).
An entity in the only-list can also take the form:
Description
If the USE statement is specified without the ONLY option, the program unit has access to all public entities
in the named module.
If the USE statement is specified with the ONLY option, the program unit has access to only those entities
following the option.
If more than one USE statement for a given module appears in a scoping unit, the following rules apply:
• If one USE statement does not have the ONLY option, all public entities in the module are accessible, and
any rename-lists and only-lists are interpreted as a single, concatenated rename-list.
• If all the USE statements have ONLY options, all the only-lists are interpreted as a single, concatenated
only-list. Only those entities named in one or more of the only-lists are accessible.
If two or more generic interfaces that are accessible in a scoping unit have the same name, the same
operator, or are both assignments, they are interpreted as a single generic interface. Otherwise, multiple
accessible entities can have the same name only if no reference to the name is made in the scoping unit.
The local names of entities made accessible by a USE statement must not be declared locally other than in a
PUBLIC, PRIVATE, VOLATILE, or ASYNCHRONOUS statement. Within a module, if a use-associated entity is
declared VOLATILE or ASYNCHRONOUS, it has the default accessibility of a locally declared identifier.
The local names of use-associated entities can appear in namelist group lists, but not in a COMMON or
EQUIVALENCE statement.
1976
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If the name of every module from which a use-associated entity is accessed appears in an accessibility
statement, the default accessibility of the entity is PRIVATE if every such accessibility statement is PRIVATE,
and PUBLIC if any such accessibility statement is PUBLIC.
The accessibility of a use associated entity within a module can be determined by applying the following rules
in the specified order:
1. It is PUBLIC if the entity is specified in the entity-list of a PUBLIC statement. It is PRIVATE if the entity
is specified in the entity-list of a PRIVATE statement.
2. If the entity is declared locally in an ASYNCHRONOUS or VOLATILE statement, go to 5.
3. It is PUBLIC if any module through which the entity is accessible appears in a PUBLIC statement.
4. It is PRIVATE if every module thru which the entity is accessible appears in a PRIVATE statement.
5. It is PUBLIC if there is a PUBLIC statement with no entity-list specified in the module. It is PRIVATE if
there is a PRIVATE statement with no entity-list specified in the module.
6. It is PUBLIC.
Examples
The following shows examples of the USE statement:
MODULE MOD_A
INTEGER :: B, C
REAL E(25,5), D(100)
END MODULE MOD_A
...
SUBROUTINE SUB_Y
USE MOD_A, DX => D, EX => E ! Array D has been renamed DX and array E
... ! has been renamed EX. Scalar variables B
END SUBROUTINE SUB_Y ! and C are also available to this
... ! subroutine (using their module names).
SUBROUTINE SUB_Z
USE MOD_A, ONLY: B, C ! Only scalar variables B and C are
... ! available to this subroutine
END SUBROUTINE SUB_Z
...
You must not specify a user module and an intrinsic module of the same name in the same program unit. For
example, if you specify a user module named ISO_FORTRAN_ENV, then it is illegal to specify the following in
the same program unit:
USE :: ISO_FORTRAN_ENV
USE, INTRINSIC :: ISO_FORTRAN_ENV
The following example shows a module containing common blocks:
MODULE COLORS
COMMON /BLOCKA/ C, D(15)
COMMON /BLOCKB/ E, F
...
END MODULE COLORS
...
FUNCTION HUE(A, B)
USE COLORS
...
END FUNCTION HUE
The USE statement makes all of the variables in the common blocks in module COLORS available to the
function HUE.
1977
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
To provide data abstraction, a user-defined data type and operations to be performed on values of this type
can be packaged together in a module. The following example shows such a module:
MODULE CALCULATION
TYPE ITEM
REAL :: X, Y
END TYPE ITEM
CONTAINS
FUNCTION ITEM_CALC (A1, A2)
TYPE(ITEM) A1, A2, ITEM_CALC
...
END FUNCTION ITEM_CALC
...
END MODULE CALCULATION
PROGRAM TOTALS
USE CALCULATION
TYPE(ITEM) X, Y, Z
...
X = Y + Z
...
END
The USE statement allows program TOTALS access to both the type ITEM and the extended intrinsic operator
+ to perform calculations.
The following shows another example:
1978
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
This statement accesses the routine called CROSSTABS in MODULE_LIB by the name XTABS. This way, if two
modules have routines called CROSSTABS, one program can use them both simultaneously by assigning a
local name in its USE statement.
When a program or subprogram renames a module entity, the local name (XTABS, in the preceding example)
is accessible throughout the scope of the program unit that names it.
The ONLY option also allows public variables to be renamed. Consider the following:
MODULE FOO
integer foos_integer
PRIVATE
integer foos_my_integer
END MODULE FOO
PRIVATE, in this case, makes the PRIVATE attribute the default for the entire module FOO. To make
foos_integer accessible to other program units, add the line:
PUBLIC :: foos_integer
Alternatively, to make only foos_my_integer inaccessible outside the module, rewrite the module as
follows:
MODULE FOO
integer foos_integer
integer, private::foos_my_integer
END MODULE FOO
Given the following module declarations:
MODULE mod1
INTEGER x1
END MODULE
MODULE mod2
USE mod1
INTEGER x2
END MODULE
Then in module mod3 below, x1 has default accessibility of PRIVATE:
MODULE mod3
USE mod2
PUBLIC x2 ! x2 is PUBLIC
PRIVATE ! x1 is PRIVATE
END MODULE
In mod4 below, even though x1 is declared in mod1, and mod1 is declared PRIVATE in mod4, x1 is PUBLIC
since it is declared VOLATILE and it assumes the default accessibility of PUBLIC of a locally declared identifier
in mod4:
MODULE mod4
USE mod1
PRIVATE mod1
VOLATILE x1 ! x1 is PUBLIC
END MODULE
1979
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In mod5 below, x1 and x2 are both PRIVATE since all modules from which they are accessed appear in
PRVATE statements:
MODULE mod5
USE mod1
USE mod2
PRIVATE mod1
PRIVATE mod2 ! x1 and x2 are PRIVATE
END MODULE
However, in mod6 below, both x1 and x2 are PUBLIC since they are accessible thru the use of mod2 which is
declared PUBLIC:
MODULE mod6
USE mod1
USE mod2
PRIVATE mod1
PUBLIC mod2 ! x1 and x2 are PUBLIC
END MODULE
See Also
Program Units and Procedures
USE_DEVICE_PTR Clause
Parallel Directive Clause: Tells the construct to use
a device pointer currently in the device data
environment.
Syntax
USE_DEVICE_PTR (ptr-list)
ptr-list Is a list of one or more variables of type C_PTR from the intrinsic
module ISO_C_BINDING1. The pointers are converted into device
pointers to the corresponding list item in the device data environment.
1 List items not of type C_PTR have been deprecated in the OpenMP* specification.
The pointers listed in ptr-list become private pointers in the device data environment. The device pointers to
the corresponding list items in the device data environment are assigned to the private pointers.
References in the construct to a ptr-list item that appears in this clause must be to the address of the ptr-list
item.
%VAL
Built-in Function: Changes the form of an actual
argument. Passes the argument as an immediate
value.
Syntax
%VAL (a)
Description
The argument is passed as follows:
1980
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• On IA-32 architecture, as a 32-bit immediate value. If the argument is integer (or logical) and shorter
than 32 bits, it is sign-extended to a 32-bit value. For complex data types, %VAL passes two 32-bit
arguments.
• On Intel® 64 architecture, as a 64-bit immediate value. If the argument is integer (or logical) and shorter
than 64 bits, it is sign-extended to a 64-bit value. For complex data types, %VAL passes two 64-bit
arguments.
You must specify %VAL in the actual argument list of a CALL statement or function reference. You cannot use
it in any other context.
The following tables list the Intel® Fortran defaults for argument passing, and the allowed uses of %VAL:
Expressions
Actual Argument Data Type Default %VAL
REAL(8) REF No
REAL(16) REF No
COMPLEX(16) REF No
Hollerith REF No
Aggregate3 REF No
Derived REF No
Array Name
Actual Argument Data Type Default %VAL
Numeric REF No
Aggregate3 REF No
Derived REF No
Procedure Name
Actual Argument Data Type Default %VAL
Numeric REF No
1981
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
CALL SUB(2, %VAL(2))
Constant 2 is passed by reference. The second constant 2 is passed by immediate value.
See Also
CALL
%REF
%LOC
VALUE
Statement and Attribute: Specifies a type of
argument association for a dummy argument.
Syntax
The VALUE attribute can be specified in a type declaration statement or a VALUE statement, and takes one of
the following forms:
Type Declaration Statement:
type, [att-ls, ] VALUE [, att-ls] :: arg [, arg] ...
Statement:
VALUE [::] arg [, arg]...
Description
The VALUE attribute can be used in INTERFACE body or in a procedure. It can only be specified for dummy
arguments. It cannot be specified for a dummy procedure.
An entity with the VALUE attribute must be a dummy data object that is not an assumed-size array or a
coarray, and does not have a coarray ultimate component.
When this attribute is specified for a present dummy argument, the dummy argument becomes associated
with a temporary, definable data object whose initial value is that of the corresponding actual argument. The
actual mechanism by which this happens is determined by the compiler. If the procedure also has the
BIND(C) attribute, the dummy argument is interoperable with the corresponding formal parameter of the C
language prototype, causing the argument to be passed or received by value if C would do so.
When the VALUE attribute is used in a type declaration statement, any length type parameter values must be
omitted or they must be specified by initialization expressions.
If the VALUE attribute is specified, you cannot specify a PARAMETER, EXTERNAL, POINTER, ALLOCATABLE,
VOLATILE, or INTENT (INOUT or OUT) attribute in the same scoping unit.
You can use option assume nostd_value to tell the compiler to use non-standard semantics for VALUE so that
the value of the actual argument is passed to the called procedure, not the address of the actual argument
nor the address of a copy of the actual argument.
1982
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Example
The following example shows how the VALUE attribute can be applied in a type declaration statement.
j = 3
call sub (j)
write (*,*) j ! Writes 3
contains
subroutine sub (i)
integer, value :: I
i = 4
write (*,*) i ! Writes 4
end subroutine sub
end
See Also
Type Declarations
Compatible attributes
VECREMAINDER Clause
General Directive Clause: Allows the compiler to
vectorize (or not to vectorize) any peel or remainder
loops when the original loop is vectorized.
Syntax
[NO]VECREMAINDER
If !DIR$ VECTOR ALWAYS is specified, the following occurs:
• If VECREMAINDER is specified, the compiler vectorizes peel and remainder loops when the original main
loop is vectorized.
• If NOVECREMAINDER is specified, the compiler does not vectorize peel or remainder loops when the
original main loop is vectorized.
• If neither the VECREMAINDER or NOVECREMAINDER clause is specified, the compiler overrides efficiency
heuristics of the vectorizer and it determines whether the loop can be vectorized.
See Also
VECTOR and NOVECTOR
SIMD Loop Directive
Syntax
!DIR$ VECTOR [clause[[,] clause]...]
!DIR$ NOVECTOR
1983
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
1984
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The VECTOR and NOVECTOR directives control vectorization of the DO loop that directly follows the directive.
If the MASK_READWRITE clause is specified, the compiler generates masked loads and stores within all
conditional branches in the loop. If the NOMASK_READWRITE clause is specified, the compiler generates
unmasked loads and stores for increased performance.
Caution
The VECTOR directive should be used with care. Overriding the efficiency heuristics of the compiler
should only be done if you are absolutely sure the vectorization will improve performance.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/
PerformanceIndex.
Notice revision #20201201
Example
The compiler normally does not vectorize DO loops that have a large number of non-unit stride references
(compared to the number of unit stride references).
1985
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
In the following example, vectorization would be disabled by default, but the directive overrides this
behavior:
!DIR$ NOVECTOR
do i = 1, 100
a(i) = b(i) + c(i)
enddo
See Also
General Compiler Directives
VERIFY
Elemental Intrinsic Function (Generic): Verifies
that a set of characters contains all the characters in a
string by identifying the first character in the string
that is not in the set.
Syntax
result = VERIFY (string, set [, back] [, kind])
set (Input) Must be of type character with the same kind parameter as
string.
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
If back is omitted (or is present with the value false) and string has at least one character that is not in set,
the value of the result is the position of the leftmost character of string that is not in set.
If back is present with the value true and string has at least one character that is not in set, the value of the
result is the position of the rightmost character of string that is not in set.
1986
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If each character of string is in set or the length of string is zero, the value of the result is zero.
The setting of compiler options specifying integer size can affect this function.
Example
VERIFY ('CDDDC', 'C') has the value 2.
VERIFY ('CDDDC', 'C', BACK=.TRUE.) has the value 4.
VERIFY ('CDDDC', 'CD') has the value zero.
The following shows another example:
INTEGER(4) position
See Also
SCAN
VIRTUAL
Statement: Has the same form and effect as the
DIMENSION statement. It is included for compatibility
with PDP-11 FORTRAN.
See Also
DIMENSION
VOLATILE
Statement and Attribute: Specifies that the value of
an object is entirely unpredictable, based on
information local to the current program unit. It
prevents objects from being optimized during
compilation.
Syntax
The VOLATILE attribute can be specified in a type declaration statement or a VOLATILE statement, and takes
one of the following forms:
Type Declaration Statement:
type, [att-ls, ] VOLATILE [, att-ls] :: object[, object] ...
Statement:
VOLATILE [::] object[, object] ...
A variable or COMMON block must be declared VOLATILE if it can be read or written in a way that is not
visible to the compiler. For example:
• If an operating system feature is used to place a variable in shared memory (so that it can be accessed by
other programs), the variable must be declared VOLATILE.
1987
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
• If a variable is accessed or modified by a routine called by the operating system when an asynchronous
event occurs, the variable must be declared VOLATILE.
If an array is declared VOLATILE, each element in the array becomes volatile. If a common block is declared
VOLATILE, each variable in the common block becomes volatile.
If an object of derived type is declared VOLATILE, its components become volatile.
If a pointer is declared VOLATILE, the pointer itself becomes volatile.
A VOLATILE statement cannot specify the following:
• A procedure
• A namelist group
The VOLATILE attribute must not be specified for a coarray that is accessed by use or host association. A
noncoarray object that has the VOLATILE attribute can be associated with an object that does not have the
VOLATILE attribute, including by use or host association. A data object with the VOLATILE attribute may not
be declared in a PURE procedure or referenced by a PURE statement function.
Example
The following example shows a type declaration statement specifying the VOLATILE attribute:
INTEGER, VOLATILE :: D, E
The following example shows a VOLATILE statement:
PROGRAM TEST
LOGICAL(KIND=1) IPI(4)
INTEGER(KIND=4) A, B, C, D, E, ILOOK
INTEGER(KIND=4) P1, P2, P3, P4
COMMON /BLK1/A, B, C
VOLATILE /BLK1/, D, E
EQUIVALENCE(ILOOK, IPI)
EQUIVALENCE(A, P1)
EQUIVALENCE(P1, P4)
The named common block, BLK1, and the variables D and E are volatile. Variables P1 and P4 become volatile
because of the direct equivalence of P1 and the indirect equivalence of P4.
See Also
Type Declarations
Compatible attributes
WAIT
Statement: Performs a wait operation for a specified
pending asynchronous data transfer operation. It
takes one of the following forms:
Syntax
WAIT([UNIT=]io-unit [, END=label] [, EOR=label] [, ERR=label] [, ID=id-var] [, IOMSG=msg-
var] [, IOSTAT=i-var])
WAIT io-unit
label (Input) Is the label of the branch target statement that receives
control if an error occurs.
1988
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
A wait operation completes the processing of a pending data transfer operation. Each wait operation
completes only a single data transfer operation, although a single statement may perform multiple wait
operations.
The WAIT statement specifiers can appear in any order. An I/O unit must be specified, but the UNIT=
keyword is optional if the unit specifier is the first item in the I/O control list.
The EOR= specifier only has effect if the pending data transfer operation is a nonadvancing read. The END=
specifier only has effect if the pending data transfer operation is a READ.
Example
The following example shows how the WAIT statement can be applied.
program test
integer, asynchronous, dimension(100) :: array
open (unit=1,file='asynch.dat',asynchronous='YES',&
form='unformatted')
write (1) (i,i=1,100)
rewind (1)
read (1,asynchronous='YES') array
wait(1)
write (*,*) array(1:10)
end
WHERE
Statement and Construct: Lets you use masked
array assignment, which performs an array operation
on selected elements. This kind of assignment applies
a logical test to an array on an element-by-element
basis.
Syntax
Statement:
WHERE (mask-expr1) assign-stmt
Construct:
[name:]WHERE (mask-expr1)
[where-body-stmt] ...
[ELSE WHERE(mask-expr2) [name]
[where-body-stmt] ...]
[ELSE WHERE[name]
[where-body-stmt] ...]
END WHERE [name]
1989
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Description
If a construct name is specified in a WHERE statement, the same name must appear in the corresponding
END WHERE statement. The same construct name can optionally appear in any ELSE WHERE statement in
the construct. (ELSE WHERE cannot specify a different name.)
In each assignment statement, the mask expression, the variable being assigned to, and the expression on
the right side, must all be conformable. Also, the assignment statement cannot be a defined assignment.
Only the WHERE statement (or the first line of the WHERE construct) can be labeled as a branch target
statement.
The following shows an example using a WHERE statement:
INTEGER A, B, C
DIMENSION A(5), B(5), C(5)
DATA A /0,1,1,1,0/
DATA B /10,11,12,13,14/
C = -1
WHERE(A .NE. 0) C = B / A
The resulting array C contains: -1,11,12,13, and -1.
The assignment statement is only executed for those elements where the mask is true. Think of the mask
expression as being evaluated first into a logical array that has the value true for those elements where A is
positive. This array of trues and falses is applied to the arrays A, B and C in the assignment statement. The
right side is only evaluated for elements for which the mask is true; assignment on the left side is only
performed for those elements for which the mask is true. The elements for which the mask is false do not get
assigned a value.
In a WHERE construct, the mask expression is evaluated first and only once. Every assignment statement
following the WHERE is executed as if it were a WHERE statement with " mask-expr1" and every assignment
statement following the ELSE WHERE is executed as if it were a WHERE statement with ".NOT. mask-expr1".
If ELSE WHERE specifies "mask-expr2", it is executed as "(.NOT. mask-expr1) .AND. mask-expr2" during the
processing of the ELSE WHERE statement.
You should be careful if the statements have side effects, or modify each other or the mask expression.
The following is an example of the WHERE construct:
1990
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
The mask is applied to the arguments of functions on the right side of the assignment if they are considered
to be elemental functions. Only elemental intrinsics are considered elemental functions. Transformational
intrinsics, inquiry intrinsics, and functions or operations defined in the subprogram are considered to be
nonelemental functions.
Consider the following example using LOG, an elemental function:
REAL A, B
DIMENSION A(10,10), B(10)
WHERE(B .GT. 0.0) B = SUM(A, DIM=1)
Since SUM is nonelemental, it is evaluated fully for all of A. Then, the assignment only happens for those
elements for which the mask evaluated to true.
Consider the following example:
REAL A, B, C
DIMENSION A(10,10), B(10), C(10)
WHERE(C .GT. 0.0) B = SUM(LOG(A), DIM=1)/C
Because SUM is nonelemental, all of its arguments are evaluated fully regardless of whether they are
elemental or not. In this example, LOG(A) is fully evaluated for all elements in A even though LOG is
elemental. Notice that the mask is applied to the result of the SUM and to C to determine the right side. One
way of thinking about this is that everything inside the argument list of a nonelemental function does not use
the mask, everything outside does.
Example
REAL(4) a(20)
. . .
WHERE (a > 0.0)
a = LOG (a)
!LOG is invoked only for positive elements
END WHERE
See Also
FORALL
Arrays
WORKSHARE
OpenMP* Fortran Compiler Directive: Divides the
work of executing a block of statements or constructs
into separate units. It also distributes the work of
executing the units to threads of the team so each
unit is only executed once.
Syntax
!$OMP WORKSHARE
loosely-structured-block
!$OMP END WORKSHARE [NOWAIT]
-or-
!$OMP WORKSHARE
1991
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
strictly-structured-block
!$OMP END WORKSHARE [NOWAIT]
strictly-structured-block Is a Fortran BLOCK construct. You cannot branch into or out of the
BLOCK construct.
See Also
OpenMP Fortran Compiler Directives
Syntax Rules for Compiler Directives
PARALLEL WORKSHARE
Parallel Processing Model for information about Binding Sets
WRITE Statement
Statement: Transfers output data to external
sequential, direct-access, or internal records.
Syntax
Sequential
Formatted:
WRITE (eunit, format [, advance] [, asynchronous] [, decimal] [, id] [, pos] [, round] [,
sign] [, iostat] [ , err] [, [iomsg])[io-list]
1992
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Formatted - List-Directed:
WRITE (eunit, * [, asynchronous] [, decimal] [, delim] [, id] [, pos] [, round] [, sign]
[, iostat] [, err] [, iomsg])[io-list]
Formatted - Namelist:
WRITE (eunit, nml-group [, asynchronous] [, decimal] [, delim] [, id] [, pos] [, round]
[, sign] [, iostat] [, err] [, iomsg])
Unformatted:
WRITE (eunit [, asynchronous] [, id] [, pos] [, iostat] [, err] [, iomsg])[io-list]
Direct-Access
Formatted:
WRITE (eunit, format, rec [, asynchronous] [, decimal] [, delim] [, id] [, pos] [, round]
[, sign] [, iostat] [, err] [, iomsg])[io-list]
Unformatted:
WRITE (eunit, rec [, asynchronous] [, id] [, pos] [, iostat] [ , err] [, iomsg])[io-list]
Internal
WRITE (iunit, format [, nml-group] [, iostat] [ , err] [, iomsg])[io-list]
Internal Namelist
WRITE (iunit, nml-group [, iostat] [ , err] [, iomsg])[io-list]
1993
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
pos Is a pos specifier (POS=p) that indicates a file position in file storage
units in a stream file (ACCESS='STREAM'). It can only be specified on
a file opened for stream access. If omitted, the stream I/O occurs
starting at the next file position after the current file position.
sign Is a plus sign specifier (SIGN=sn). This controls whether optional plus
characters appear in formatted numeric output.
iostat Is the name of a variable to contain the completion status of the I/O
operation. Optionally prefaced by IOSTAT=.
io-list Is an I/O list: the names of the variables, arrays, array elements, or
character substrings from which or to which data will be transferred.
Optionally an implied-DO list.
If you specify DECIMAL=, ROUND=, or SIGN= you must also specify FMT= or NML=.
If you specify ID=, you must also specify ASYNCHRONOUS='YES'.
Example
! write to file
open(1,FILE='test.dat')
write (1, '(A20)') namedef
! write with FORMAT statement
WRITE (*, 10) (n, SQRT(FLOAT(n)), FLOAT(n)**(1.0/3.0), n = 1, 100)
10 FORMAT (I5, F8.4, F8.5)
1994
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
I/O Lists
I/O Control List
Forms for Sequential WRITE Statements
Forms for Direct-Access WRITE Statements
Forms and Rules for Internal WRITE Statements
READ
PRINT
OPEN
I/O Formatting
XOR
Elemental Intrinsic Function (Generic): An
alternative name for intrinsic function IEOR.
See Also
See IEOR.
ZEXT
Elemental Intrinsic Function (Generic): Extends
an argument with zeros. This function is used
primarily for bit-oriented operations. It cannot be
passed as an actual argument.
Syntax
result = ZEXT (x [,kind])
Results
The result type is integer. If kind is present, the kind parameter of the result is that specified by kind;
otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the
result value in the kind of the result, the result is undefined.
The result value is x extended with zeros and treated as an unsigned value.
The storage requirements for integer constants are never less than two bytes. Integer constants within the
range of constants that can be represented by a single byte still require two bytes of storage.
The setting of compiler options specifying integer size can affect this function.
LOGICAL(2) INTEGER(2)
INTEGER(1) INTEGER(2)
INTEGER(2) INTEGER(2)
1995
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
LOGICAL(2) INTEGER(4)
LOGICAL(4) INTEGER(4)
INTEGER(1) INTEGER(4)
INTEGER(2) INTEGER(4)
INTEGER(4) INTEGER(4)
LOGICAL(2) INTEGER(8)
LOGICAL(4) INTEGER(8)
LOGICAL(8) INTEGER(8)
INTEGER(1) INTEGER(8)
INTEGER(2) INTEGER(8)
INTEGER(4) INTEGER(8)
INTEGER(8) INTEGER(8)
1These specific functions cannot be passed as actual arguments.
Example
Consider the following example:
IPXFARGC
POSIX Function: Returns the index of the last
command-line argument.
Module
USE IFPOSIX
1996
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Syntax
result = IPXFARGC( )
Results
The result type is INTEGER(4). The result value is the number of command-line arguments, excluding the
command name, in the command used to invoke the executing program. A return value of zero indicates
there are no command-line arguments other than the command name itself.
See Also
PXFGETARG
IPXFCONST
POSIX Function: Returns the value associated with a
constant defined in the C POSIX standard.
Module
USE IFPOSIX
Syntax
result = IPXFCONST (constname)
Results
The result type is INTEGER(4). If constname corresponds to a defined constant in the C POSIX standard, the
result value is the integer that is associated with the constant. Otherwise, the result value is -1.
See Also
PXFGETARG
PXFCONST
IPXFLENTRIM
POSIX Function: Returns the index of the last non-
blank character in an input string.
Module
USE IFPOSIX
Syntax
result = IPXFLENTRIM (string)
Results
The result type is INTEGER(4). The result value is the index of the last non-blank character in the input
argument string, or zero if all characters in string are blank characters.
IPXFWEXITSTATUS
POSIX Function: Returns the exit code of a child
process. This routine is only available for Linux and
macOS.
1997
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPOSIX
Syntax
result = IPXFWEXITSTATUS (istat)
Results
The result type is INTEGER(4). The result is the low-order eight bits of the output argument of PXFWAIT or
PXFWAITPID.
The IPXFWEXITSTATUS function should only be used if PXFWIFEXITED returns TRUE.
Example
program t1
use ifposix
integer(4) ipid, istat, ierror, ipid_ret, istat_ret
print *," the child process will be born"
call PXFFORK(IPID, IERROR)
call PXFGETPID(IPID_RET,IERROR)
if(IPID.EQ.0) then
print *," I am a child process"
print *," My child's pid is", IPID_RET
call PXFGETPPID(IPID_RET,IERROR)
print *," The pid of my parent is",IPID_RET
print *," Now I have exited with code 0xABCD"
call PXFEXIT(Z'ABCD')
else
print *," I am a parent process"
print *," My parent pid is ", IPID_RET
print *," I am creating the process with pid", IPID
print *," Now I am waiting for the end of the child process"
call PXFWAIT(ISTAT, IPID_RET, IERROR)
print *," The child with pid ", IPID_RET," has exited"
if( PXFWIFEXITED(ISTAT) ) then
print *, " The child exited normally"
istat_ret = IPXFWEXITSTATUS(ISTAT)
print 10," The low byte of the child exit code is", istat_ret
end if
end if
10 FORMAT (A,Z)
end program
See Also
PXFWAIT
PXFWAITPID
PXFWIFEXITED
IPXFWSTOPSIG
POSIX Function: Returns the number of the signal
that caused a child process to stop. This routine is
only available for Linux and macOS.
1998
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
Module
USE IFPOSIX
Syntax
result = IPXFWSTOPSIG (istat)
Results
The result type is INTEGER(4). The result is the number of the signal that caused the child process to stop.
The IPXFWSTOPSIG function should only be used if PXFWIFSTOPPED returns TRUE.
See Also
PXFWAIT
PXFWAITPID
PXFWIFSTOPPED
IPXFWTERMSIG
POSIX Function: Returns the number of the signal
that caused a child process to terminate. This routine
is only available for Linux and macOS.
Module
USE IFPOSIX
Syntax
result = IPXFWTERMSIG (istat)
Results
The result type is INTEGER(4). The result is the number of the signal that caused the child process to
terminate.
The IPXFWTERMSIG function should only be used if PXFWIFSIGNALED returns TRUE.
See Also
PXFWAIT
PXFWAITPID
PXFWIFSIGNALED
PXFGET
POSIX Subroutine: Gets the value stored in a
component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXF(type)GET (jhandle,compname,value,ierror)
1999
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compname (Input) Character. The name of the component (or field) of the
structure to retrieve data from.
value (Output) A variable, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type is INTEGER(4). Stores the
value of the component (or field).
ilen (Output) INTEGER(4). This argument can only be used when (type)
is STR (PXFSTRGET). Stores the length of the returned string.
The PXF(type)GET subroutines retrieve the value from component (or field) compname of the structure
associated with handle jhandle into variable value.
Example
See the example in PXFTIMES (which shows PXFINTGET and PXFINT8GET)
See Also
PXF(type)SET
PXFSET
POSIX Subroutine: Sets the value of a component
(or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXF(type)SET (jhandle,compname,value,ierror)
CALL PXF(type)SET (jhandle,compname,value,ilen,ierror) ! syntax when (type) is STR
2000
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compname (Input) Character. The name of the component (or field) of the
structure to write data to.
value (Input) A variable, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type is INTEGER(4). The value
for the component (or field).
ilen (Input) INTEGER(4). This argument can only be used when (type) is
STR (PXFSTRSET). The length of the string in value.
Example
See the example in PXFSTRUCTCREATE (which shows PXFSTRSET)
See Also
PXF(type)GET
PXFAGET
POSIX Subroutine: Gets the array values stored in a
component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXFA(type)GET (jhandle,compname,value,ialen,ierror)
CALL PXFA(type)GET (jhandle,compname,value,ialen,ilen,ierror) ! syntax when (type) is
STR
2001
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compname (Input) Character. The name of the component (or field) of the
structure to retrieve data from.
value (Output) An array, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type of the array is INTEGER(4).
Stores the value of the component (or field).
ilen (Output) INTEGER(4). This argument can only be used when (type)
is STR (PXFASTRGET). An array that stores the lengths of elements of
array value.
The PXFA(type)GET subroutines are similar to the PXF(type)GET subroutines, but they should be used when
the component (or field) of the structure is an array.
When the PXFA(type)GET subroutines are used, the entire array is accessed (read from the component or
field) as a unit.
See Also
PXFA(type)SET
PXF(type)GET
PXFASET
POSIX Subroutine: Sets the value of an array
component (or field) of a structure.
Module
USE IFPOSIX
Syntax
CALL PXFA(type)SET (jhandle, compname,value,ialen,ierror)
CALL PXFA(type)SET (jhandle,compname,value,ialen,ilen,ierror) ! syntax when (type) is
STR
2002
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
compname (Input) Character. The name of the component (or field) of the
structure to write data to.
value (Input) An array, whose data type depends on the value of (type).
See the table above for the data types for each value; for example, if
the value for (type) is INT, the data type of the array is INTEGER(4).
The value for the component (or field).
ilen (Input) INTEGER(4). This argument can only be used when (type) is
STR (PXFASTRSET). An array that specifies the lengths of elements of
array value.
The PXFA(type)GET subroutines are similar to the PXF(type)GET subroutines, but they should be used when
the component (or field) of the structure is an array.
When the PXFA(type)GET subroutines are used, the entire array is accessed (read from the component or
field) as a unit.
See Also
PXFA(type)GET
PXF(type)SET
PXFACCESS
POSIX Subroutine: Determines the accessibility of a
file.
Module
USE IFPOSIX
Syntax
CALL PXFACCESS (path,ilen,iamode,ierror)
2003
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
If access is permitted, the result value is zero; otherwise, an error code. Possible error codes are:
• -1: A bad parameter was passed.
• ENOENT: The named directory does not exist.
• EACCES: Access requested was denied.
On Windows* systems, if the name given is a directory name, the function only checks for existence. All
directories have read/write access on Windows* systems.
PXFALARM
POSIX Subroutine: Schedules an alarm.
Module
USE IFPOSIX
Syntax
CALL PXFALARM (iseconds,isecleft,ierror)
iseconds (Input) INTEGER(4). The number of seconds before the alarm signal
should be delivered.
The PXFALARM subroutine arranges for a SIGALRM signal to be delivered to the process in seconds
iseconds.
On Linux* and macOS systems, SIGALRM is a reserved defined constant that is equal to 14. You can use any
other routine to install the signal handler. You can get SIGALRM and other signal values by using PXFCONST
or IPXFCONST.
On Windows* systems, the SIGALRM feature is not supported, but the POSIX library has an implementation
you can use. You can provide a signal handler for SIGALRM by using PXFSIGACTION.
See Also
PXFCONST
2004
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
IPXFCONST
PXFSIGACTION
PXFCALLSUBHANDLE
POSIX Subroutine: Calls the associated subroutine.
Module
USE IFPOSIX
Syntax
CALL PXFCALLSUBHANDLE (jhandle2,ival,ierror)
The PXFCALLSUBHANDLE subroutine, when given a subroutine handle, calls the associated subroutine.
PXFGETSUBHANDLE should be used to obtain a subroutine handle.
NOTE
The subroutine cannot be a function, an intrinsic, or an entry point, and must be defined with exactly
one integer argument.
See Also
PXFGETSUBHANDLE
PXFCFGETISPEED
POSIX Subroutine: Returns the input baud rate from
a termios structure. This routine is only available for
Linux and macOS.
Module
USE IFPOSIX
Syntax
CALL PXFCFGETISPEED (jtermios,iospeed,ierror)
iospeed (Output) INTEGER(4). The returned value of the input baud rate from
the structure associated with handle jtermios.
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
2005
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
See Also
PXFSTRUCTCREATE
PXFCFSETISPEED
PXFCFGETOSPEED
POSIX Subroutine: Returns the output baud rate
from a termios structure. This routine is only available
for Linux and macOS.
Module
USE IFPOSIX
Syntax
CALL PXFCFGETOSPEED (jtermios,iospeed,ierror)
iospeed (Output) INTEGER(4). The returned value of the output baud rate
from the structure associated with handle jtermios.
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFCFSETOSPEED
PXFCFSETISPEED
POSIX Subroutine: Sets the input baud rate in a
termios structure. This routine is only available for
Linux and macOS.
Module
USE IFPOSIX
Syntax
CALL PXFCFSETISPEED (jtermios,ispeed,ierror)
ispeed (Input) INTEGER(4). The value of the input baud rate for the structure
associated with handle jtermios.
2006
Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFCFGETISPEED
PXFCFSETOSPEED
POSIX Subroutine: Sets the output baud rate in a
termios structure. This routine is only available for
Linux and macOS.
Module
USE IFPOSIX
Syntax
CALL PXFCFSETOSPEED (jtermios,ispeed,ierror)
ispeed (Input) INTEGER(4). The value of the output baud rate for the
structure associated with handle jtermios.
NOTE
To get a handle for an instance of the termios structure, use PXFSTRUCTCREATE with the string
'termios' for the structure name.
See Also
PXFSTRUCTCREATE
PXFCFGETOSPEED
PXFCHDIR
POSIX Subroutine: Changes the current working
directory.
Module
USE IFPOSIX
Syntax
CALL PXFCHDIR (path,ilen,ierror)
2007
Intel® Fortran Compiler Classic and I