Document number: 307058-001
Overview
Configuring the Intel
Before You Start
The Verification
Source File
Confirming Proper
Installation
Invoking the Compiler (Command Line)
Compiling with No
Optimization Options
Running/Verifying
the Compiled Program
Compiling with Optimization
Running/Comparing
Performance
Using the Compiler on Your
Own
Where from Here?
Disclaimer and Legal Information
The Intel® Fortran Compiler 9.0 for Linux* systems uses the command line on a Linux* host system to compile Fortran source files to run on Linux* platforms. Refer to the Intel(R) Software Development Products web site for more information about this product, and other Intel software development products.
Note: The default installation path for the Fortran compiler is
/opt/intel/fc/9.0. For the remainder of this guide,
the path /opt/intel/fc/9.0 will be indicated as <install-dir>.
(install.sh).
You need to also run the compiler environment script file
(ifortvars.sh)
that
sets the environment variables. It is strongly recommended that you add this script file
into your login script (.login
for C shell or
.profile
for other shells). Once the variables are set
in the login script, there is no need to run the environment script
files for each session. The installation program also creates compiler configuration files named
<install-dir>/bin/ifort.cfg
that contains
common settings for all compilations. You can edit this file to add additional default options.
Note: Once installed, you invoke the Fortran compiler using ifort on the command line.
Refer to the Installation Guide to confirm that the Intel Fortran Compiler 9.0 for Linux has been properly configured.
Once you complete installation of the Intel Fortran Compiler, it is useful to
perform a basic verification task that confirms proper installation,
configuration, and operation of the compiler. A verification source file
is provided at
<install-dir>/doc/samples/int_sin.f90
as part of the compiler installation.
The verification source file is a math program that integrates the absolute value of a sine curve for one cycle of 2 pi radians. The following figure shows the method used for calculation. This method successively adds the areas of rectangles with a height centered on the curve. As the number of rectangles increases (and the slice width decreases), the calculated area approaches four (4.0). The figure below shows what is being calculated for 24 interior points and the first eight slices of a 25 interior point calculation.
The timing function in the program returns the number of measured application clocks from the beginning to the end of program execution. This time measure is inexact and will vary somewhat depending on the processor and its workload.
You can confirm proper installation of the compiler by compiling the verification source, running the verification output file, and observe that the output of the file converges to the known correct value of 4. Perform the following steps to verify your installation:
<install-dir>/doc/samples
directory. Make sure you have
write permission to the /samples directory, then change to
the directory and run the compiler on the verification source file, as
follows:<install-dir>/doc/samples
directory with a file name
of a.out. The program requires no argument
. Execute the program as follows: Number of | Computed Integral|
Interior Points | |
--------------------------------------
4 | 3.1415927E+00 |
--------------------------------------
8 | 3.7922378E+00 |
--------------------------------------
16 | 3.9484632E+00 |
--------------------------------------
32 | 3.9871407E+00 |
--------------------------------------
64 | 3.9967867E+00 |
--------------------------------------
128 | 3.9991968E+00 |
--------------------------------------
256 | 3.9997992E+00 |
--------------------------------------
512 | 3.9999498E+00 |
--------------------------------------
1024 | 3.9999875E+00 |
--------------------------------------
2048 | 3.9999969E+00 |
--------------------------------------
4096 | 3.9999992E+00 |
--------------------------------------
8192 | 3.9999998E+00 |
--------------------------------------
16384 | 4.0000000E+00 |
--------------------------------------
32768 | 4.0000000E+00 |
--------------------------------------
65536 | 4.0000000E+00 |
--------------------------------------
131072 | 4.0000000E+00 |
--------------------------------------
262144 | 4.0000000E+00 |
--------------------------------------
524288 | 4.0000000E+00 |
--------------------------------------
1048576 | 4.0000000E+00 |
--------------------------------------
2097152 | 4.0000000E+00 |
--------------------------------------
4194304 | 4.0000000E+00 |
--------------------------------------
8388608 | 4.0000000E+00 |
--------------------------------------
16777216 | 4.0000000E+00 |
--------------------------------------
33554432 | 4.0000000E+00 |
--------------------------------------
67108864 | 4.0000000E+00 |
--------------------------------------
CPU Time = 5.875000 seconds
The Intel® Fortran Compiler 9.0 for Linux* can be invoked from the Linux command line using ifort for Fortran (f90) source files. We will use the int_sin.f90 verification source file in order to get started using the compiler and become familiar with some of its features and options.
The int_sin.f90 verification source file is
located in the
<install-dir>/doc/
samples directory. Before starting this section,
open a shell window and change directory as follows:
prompt> cd
<install-dir>/doc/samples
Note: You need to have write permission in the /samples directory.
We can establish a performance baseline by invoking the Intel Fortran compiler without any optimization options. Invoke the Intel Fortran compiler on the source as follows:
prompt> ifort int_sin.f90 -O0
Alternatively, you could use the -g debug option, because that changes the default optimization from -O2 to -O0.
The compiled program is in the same directory as the source, with a standard
file name of a.out. Execute the program as follows:
prompt> ./a.out
The computed integral value nears or equals 4.0 for each calculation as the execution time (number of processor clock cycles) consumed during each of the calculations generally increases with the number of interior points. The following example output is similar to the output you should see:
Number of | Computed Integral|
Interior Points | |
--------------------------------------
4 | 3.1415927E+00 |
--------------------------------------
8 | 3.7922378E+00 |
--------------------------------------
16 | 3.9484632E+00 |
--------------------------------------
32 | 3.9871407E+00 |
--------------------------------------
64 | 3.9967867E+00 |
--------------------------------------
128 | 3.9991968E+00 |
--------------------------------------
256 | 3.9997992E+00 |
--------------------------------------
512 | 3.9999498E+00 |
--------------------------------------
1024 | 3.9999875E+00 |
--------------------------------------
2048 | 3.9999969E+00 |
--------------------------------------
4096 | 3.9999992E+00 |
--------------------------------------
8192 | 3.9999998E+00 |
--------------------------------------
16384 | 4.0000000E+00 |
--------------------------------------
32768 | 4.0000000E+00 |
--------------------------------------
65536 | 4.0000000E+00 |
--------------------------------------
131072 | 4.0000000E+00 |
--------------------------------------
262144 | 4.0000000E+00 |
--------------------------------------
524288 | 4.0000000E+00 |
--------------------------------------
1048576 | 4.0000000E+00 |
--------------------------------------
2097152 | 4.0000000E+00 |
--------------------------------------
4194304 | 4.0000000E+00 |
--------------------------------------
8388608 | 4.0000000E+00 |
--------------------------------------
16777216 | 4.0000000E+00 |
--------------------------------------
33554432 | 4.0000000E+00 |
--------------------------------------
67108864 | 4.0000000E+00 |
--------------------------------------
CPU Time = 9.843750 seconds
The performance enhancement realized by using some of the optimization options of the Intel Fortran compiler can be quite significant. Other options allow you to enhance operation or performance in different areas. Invoke the compiler (with the default optimization) as follows:
prompt> ifort int_sin.f90
By default the compiler performs level 2 optimizations (-O2), which are intended to improve code execution speed.
Execute the optimized version of the compiled int_sin program as follows:
prompt> ./a.out
Compare the "CPU Time" with the value you noted for the unoptimized program. Although the actual time differences you see might depend on the architecture of your target system, the following output is typical for an Intel® IA-32 system.
Number of | Computed Integral|
Interior Points | |
--------------------------------------
4 | 3.1415927E+00 |
--------------------------------------
8 | 3.7922378E+00 |
--------------------------------------
16 | 3.9484632E+00 |
--------------------------------------
32 | 3.9871407E+00 |
--------------------------------------
64 | 3.9967867E+00 |
--------------------------------------
128 | 3.9991968E+00 |
--------------------------------------
256 | 3.9997992E+00 |
--------------------------------------
512 | 3.9999498E+00 |
--------------------------------------
1024 | 3.9999875E+00 |
--------------------------------------
2048 | 3.9999969E+00 |
--------------------------------------
4096 | 3.9999992E+00 |
--------------------------------------
8192 | 3.9999998E+00 |
--------------------------------------
16384 | 4.0000000E+00 |
--------------------------------------
32768 | 4.0000000E+00 |
--------------------------------------
65536 | 4.0000000E+00 |
--------------------------------------
131072 | 4.0000000E+00 |
--------------------------------------
262144 | 4.0000000E+00 |
--------------------------------------
524288 | 4.0000000E+00 |
--------------------------------------
1048576 | 4.0000000E+00 |
--------------------------------------
2097152 | 4.0000000E+00 |
--------------------------------------
4194304 | 4.0000000E+00 |
--------------------------------------
8388608 | 4.0000000E+00 |
--------------------------------------
16777216 | 4.0000000E+00 |
--------------------------------------
33554432 | 4.0000000E+00 |
--------------------------------------
67108864 | 4.0000000E+00 |
--------------------------------------
CPU Time = 5.875000 seconds
Note: While the large improvement in execution time (unoptimized to optimized program) in this example might not be typical for all programs, you should be able to improve the execution time for programs running on Intel processors by choosing to optimize your compiled output. Note also that the Intel Fortran compiler optimizes programs at an -O2 level by default.
The procedures in this Getting Started guide show you how to compile, apply/remove optimization, provide arguments, and monitor the output of the example program. If you have an existing source program, there should be no problem in substituting your source file for the example and running it.
The examples provided in this Getting Started guide are only an introduction to the capabilities of the Intel Fortran compiler.
A Documentation Index file is available that provides links to all of the documentation included with the product. Refer to the doc_index.htm file.
If you would like more in-depth training on Intel compilers, a Web-based
training tutorial on using Intel compilers for software development is
included with this product. Refer to Enhancing
Performance with Intel Compilers located at:
<install-dir>/doc/training/optimize/index.htm
Refer to the product Release Notes document for information about Technical Support and any Limitations that apply to the product.
You can find out about other Intel software development products through
the Intel web site at:
http://www.intel.com/software/products/.
The information in this document is subject to change without notice and Intel Corporation assumes no responsibility or liability for any errors or inaccuracies that may appear in this document or any software that may be provided in association with this document. This document and the software described in it are furnished under license and may only be used or copied in accordance with the terms of the license. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted by this document. The information in this document is provided in connection with Intel products and should not be construed as a commitment by Intel Corporation.
EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. Intel products are not intended for use in medical, life saving, life sustaining, critical control or safety systems, or in nuclear facility applications.
Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them.
The software described in this document may contain software defects which may cause the product to deviate from published specifications. Current characterized software defects are available on request.
Intel, the Intel logo, Intel SpeedStep, Intel NetBurst, Intel NetStructure, MMX, Intel386, Intel486, Celeron, Intel Centrino, Intel Xeon, Intel XScale, Itanium, Pentium, Pentium II Xeon, Pentium III Xeon, Pentium M, and VTune are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.
* Other names and brands may be claimed as the property of others.
Copyright © 2005, Intel Corporation.