Intel® Fortran Compiler 16.0 User and Reference Guide

Compiling and Linking Multithreaded Programs

To build a multithreaded application that uses the Fortran run-time libraries, specify the threads compiler option from the command line. The Visual Studio* integrated development environment (IDE), described later in this topic, can also be used on Windows*.

You must also link with the correct library files. Some libraries, such as those for OpenMP* or coarrays, are always linked dynamically.

Linux* and OS X*

To create statically-linked, multithreaded programs, link with the static library named libifcoremt.a.

To use shared libraries, link your application with libifcoremd.so (Linux*) or libifcoremd.dylib (OS X*).

To compile and link your multithreaded program from the command line:

  1. Make sure the IA32ROOT environment variable points to the directory containing your library files.

  2. Compile and link the program with the -threads option. For example:

    ifort -threads mythread.f90 

    Note

    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.

Windows*

To create statically linked multithreaded programs, link with the re-entrant support library LIBIFCOREMT.LIB.

To use shared libraries, use the shared LIBIFCOREMD.DLL library, which is also re-entrant, and is referenced by linking your application with the LIBIFCOREMD.LIB import library.

Programs built with LIBIFCOREMT.LIB do not share Fortran run-time library code or data with any dynamic-link libraries they call. You must link with LIBIFCOREMD.LIB if you plan to call a DLL.

Additional Notes:

To compile and link your multithreaded program using Visual Studio*

  1. Create a new project by clicking File > New > Project.

  2. Select the Intel® Visual Fortran project type from Intel® Visual Fortran Projects in the left pane.

  3. Add the file containing the source code to the project.

    From the Project menu, select Properties. The Property Pages dialog box appears.

  4. Choose the Fortran folder, Libraries category, and set the Runtime Library to Multithreaded or Multithread DLL (or their debug equivalents).

  5. Create the executable file by choosing Build Solution from the Build menu.

To compile and link your multithreaded program from the command line:

  1. Make sure your LIB environment variable points to the directory containing your library files.

  2. Compile and link the program with the /threads option. For example:

    ifort /threads mythread.f90

    Note

    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.