Visible to Intel only — GUID: GUID-9BA75CEE-081C-4934-BB01-F80012989809
Visible to Intel only — GUID: GUID-9BA75CEE-081C-4934-BB01-F80012989809
Compile and Link Multithreaded Programs
When building a multithreaded application, be sure to link against the thread-safe version of the Fortran runtime libraries and to enable thread safety. This is specified by the threads and reentrancy:threaded compiler options.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 macOS
To create statically-linked, multithreaded programs, link with the static library named libifcoremt.a.
To use shared libraries, link your application with libifcoremt.so (Linux) or libifcoremt.dylib (macOS).
To compile and link your multithreaded program from the command line:
Compile and link the program with the -threads option. For example:
ifort -threads mythread.f90
To ensure that a threadsafe and/or reentrant runtime 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 runtime 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:
The /threads option is automatically set when a multithreaded application is specified in the IDE.
Specify the compiler options /libs=dll and /threads if you are using both multithreaded code and DLLs.
You can use the /libs=dll and /threads options only with Fortran Console projects, not QuickWin applications.
To compile and link your multithreaded program using Visual Studio*
Create a new project by clicking File > New > Project.
Select the Intel® Visual Fortran project type from Intel® Visual Fortran Projects in the left pane.
Add the file containing the source code to the project.
From the Project menu, select Properties. The Property Pages dialog box appears.
Choose the Fortran folder, Libraries category, and set the Runtime Library to Multithreaded or Multithread DLL (or their debug equivalents).
Create the executable file by choosing Build Solution from the Build menu.
To compile and link your multithreaded program from the command line:
Make sure your LIB environment variable points to the directory containing your library files.
Compile and link the program with the /threads option. For example:
ifort /threads mythread.f90
NOTE:To ensure that a threadsafe and/or reentrant runtime library is linked and correctly initialized, option threads should also be used for the link step and for the compilation of the main routine.