Compiling and Building Fortran Examples
If possible, compile the Fortran examples with the Fortran 90 compiler, because some examples contain Fortran 90 specific features like the
ADVANCE
specifier in the
WRITE
statement.
An LAPACK binary defines the appropriate entry point for the LAPACK routine, which is called from the example according to the default Fortran naming convention. For example, to define the
dgesv
routine on IA-32 architecture, use
dgesv_
(lowercase, trailing underscore) on Linux* OS, or
_DGESV
(uppercase, leading underscore) on Windows* OS.
To compile and build an example:
- Run themklvarsscript to set the required environment variables.
- Build the application using a Fortran 90 compiler as follows:<f90> <compiler options> <example.f> <link line>whereis a Fortran 90 compiler,<f90>is any of the oneMKL LAPACK Fortran examples, and<example.f>contains linker options and arguments, including the LAPACK library files required for your application.<link line>See the following example lines for reference:
- with Intel® Fortran Compiler, you can useifort -mkl cgesv_ex.fon Linux* OS, orifort /Qmkl cgesv_ex.fon Windows* OS.See theLinking Your Application with the Intel oneAPI Math Kernel Librarysection of the oneMKL Developer Guide for more information on linking with the oneMKL.
- with third-party compilers, you can usegfortran -fopenmp -m64 -I${MKLROOT}/include cgesv_ex.f -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_gf_lp64 -lmkl_core -lmkl_gnu_thread -lpthread -lm -ldlto compile with the GNU* Fortran compiler on Linux* OS.The example above is linking dynamically against 64-bit oneMKL library files. To create a custom link line, use the oneMKL Link Line Advisor or refer to the oneMKL Developer Guide, sectionLinking Your Application with the Intel oneAPI Math Kernel Library.