### Intel Fortran Compiler

IMPORTANT: Use the default installation directory to install the Intel Fortran Compiler (any version).

Intel Fortran Compiler versions 7.1 and 8.1 compile the `XBC` option tree and other X-Midas host primitives written in Fortran (see X-Midas Backwards Compatibility (XBC) for details on X-Midas host primitives in NeXtMidas).

Because of significant changes made between Intel Fortran Compiler versions 7.1 and 8.1, different configuration options are required. Refer to the appropriate section for instructions:

- Intel Fortran Compiler 7.1
- Intel Fortran Compiler for 32-bit applications 8.1
- Using OpenMP for the Intel Compiler

#### Intel Fortran Compiler 7.1

Intel Fortran Compiler 7.1 (`ifc`) is the default Fortran compiler for NeXtMidas 2.0.X (and earlier). To use this compiler with later versions of NeXtMidas, change the `native.lin.for.comp` and `native.lin.for.link` build properties in `$NMROOT/nxm/sys/cfg/build.props`:

Intel Fortran Compiler 7.1 | Intel Fortran Compiler 8.1
--- | ---
`native.lin.for.comp = ${ifc.comp} native.lin.for.link = ${ifc.link}` | `native.lin.for.comp = ${ifort.comp} native.lin.for.link = ${ifort.link}`

#### Intel Fortran Compiler for 32-bit applications 8.1

Intel Fortran Compiler for 32-bit applications 8.1 (`ifort`) is the default Fortran compiler for NeXtMidas 2.1.X (and later). To use this compiler with earlier versions of NeXtMidas, change the `native.lin.for.comp` and `native.lin.for.link` build properties in `$NMROOT/nxm/sys/cfg/build.props`:

Intel Fortran Compiler 7.1 | Intel Fortran Compiler 8.1
--- | ---
`native.lin.for.comp = ${ifc.comp} native.lin.for.link = ${ifc.link}` | `native.lin.for.comp = ${ifort.comp} native.lin.for.link = ${ifort.link}`

Some Linux installations cannot find the `ifort` shared libraries until they are manually added to the `/lib` directory. The following steps verify this particular system problem:

1. Start NeXtMidas.
2. Add `XBC` to the NeXtMidas path (use `PATH ADD XBC`).
3. Re-build all of the code in `XBC` (use `BLD ALL ALL XBC`).
4. Run the `SD360` primitive (use `SD360 1e20`). If the libraries are not found the primitive locks up and an error message similar to this appears:

       Shell.loadLibrary err: java.lang.UnsatisfiedLinkError:
       /home/smith/nxm210/nxm/xbc/lib/libHPrimitive_lin.so:
       libifcore.so.5 cannot open shared object file: No such
       file or directory

   (If this happens, use `Control-C` to kill the current Java session.)

The following steps add the `ifort` runtime libraries to `/lib` (where `/opt/intel_fc_80` is the installation directory for `ifort`):

    $ cd /lib
    $ ln -s /opt/intel_fc_80/lib/libcprts.so.5
    $ ln -s /opt/intel_fc_80/lib/libcxa.so.5
    $ ln -s /opt/intel_fc_80/lib/libcxaguard.so.5
    $ ln -s /opt/intel_fc_80/lib/libguide.so
    $ ln -s /opt/intel_fc_80/lib/libguide_stats.so
    $ ln -s /opt/intel_fc_80/lib/libifcore.so.5
    $ ln -s /opt/intel_fc_80/lib/libifcoremt.so.5
    $ ln -s /opt/intel_fc_80/lib/libifport.so.5
    $ ln -s /opt/intel_fc_80/lib/libimf.so
    $ ln -s /opt/intel_fc_80/lib/libsvml.so
    $ ln -s /opt/intel_fc_80/lib/libunwind.so.5

#### Using OpenMP for the Intel Compiler

OpenMP is an API that supports multi-platform shared memory multiprocessing programming. The following configuration is an example of using OpenMP with an X-Midas Fortran primitive.

- Update the SYS build.props ($NMROOT/nxm/sys/cfg/build.props)
  - Update and uncomment the location for the Intel compiler directory (e.g.):
    - ifort.libs.dir = /opt/intel/Compiler/11.1/075/lib/intel64/ (ifort version 11.1.x and prior)
    - ifort.libs.dir = /opt/intel/composerxe-2011.1.107/compiler/lib/intel64 (ifort version 12.x and later)
  - Update and uncomment the following line. The library reference adjusts as appropriate to the compiler version.
    - ifort.link.append = -L${fflags.fortlibs} -lguide -Wl,-rpath=${fflags.fortlibs} (ifort version 11.1.x and prior)
    - ifort.link.append = -L${fflags.fortlibs} -liomp5 -Wl,-rpath=${fflags.fortlibs} (ifort version 12.x and later)
- Add a line to your primitive to prior to running the M$CHECKIN

        call setenvqq("KMP_HANDLE_SIGNALS=false")

  OR In the OS shell prior to running nmstart

        setenv KMP_HANDLE_SIGNALS false

- Add a line to the cfg/primitives.cfg file in the option tree (PUT CREATE SOMETHING HERE). See the $NMROOT/nxm/sys/hlp/using_libraries.doc for a copy of X-Midas's docs for a detailed description, syntax, and examples usages of primitives.cfg or the primitives.cfg section of the BUILD explain file.

  Add the `-openmp` compile flag to enable to OpenMP directive(s) for the primitive.

        openmp_example:
          cflags + -openmp

        openmp_cpp_example:
          cflags + -openmp

- An example can be found in the XBCTESTOPT2 option tree at $NMROOT/nxm/xbc/test/nmopts/nxm/xbctestopt2