mpifort(1)
π mpifort β the Fortran MPI ride-or-die π
okay bestie, listen up. this is mpifort(1), a page from the MPI manual, and it is literally the tool you need to compile and link MPI programs written in Fortran 90. she's not complicated, she's just essential. π«Ά
β¨ NAME β¨
mpifort β Compiles and links MPI programs written in Fortran 90
πΈ DESCRIPTION πΈ
you can use this command to compile and link MPI programs written in Fortran. that's the whole job, and she does it flawlessly. she hands you all the options and the special libraries you need to actually get that compile and link to work. π
and like β use this command, okay? especially when you're linking programs, because that's where the necessary libraries come in. linking with plain old gfortran and hoping for the best? not the vibe. this is the vibe. β¨
π COMMAND LINE ARGUMENTS π
here's the lineup, no skips, all facts:
-showβ Show the commands that would be used without running them. it's giving "peek behind the curtain, don't touch anything." π-helpβ Give short help. a lil snack of guidance.-fc=nameβ Use compiler name instead of the default choice. β οΈ only do this if the compiler is compatible with the MPICH library (see below π).-config=nameβ Load a configuration file for a particular compiler. this lets a singlempifortcommand be used with multiple compilers. multitasking queen. π-compile_infoβ Show the steps for compiling a program. use this option to see exactly what options and include pathsmpifortis using. detective mode. π-link_infoβ Show the steps for linking a program. use this to see what options and librariesmpifortis using. same detective energy, different crime scene.-profile=nameβ Use the MPI profiling given by name. details are further down, keep reading bestie π-echoβ Show exactly what this program is doing. π normally this option should not be used. she said what she said.-staticβ mpi - Use a statically compile MPI library, but shared libraries for all of the other dependencies.- others β are passed to the compiler or linker. for example,
-ccauses files to be compiled,-gselects compilation with debugging on most systems, and-o namecauses linking with the output executable given the name name.
π ENVIRONMENT VARIABLES π
the environment variable MPICH_FC may be used to select a different Fortran compiler and linker.
β οΈ real talk though: since MPICH is built with a particular C and Fortran compiler, changing the compilers used can cause problems. only do this if you could intermix code compiled with the different compilers. no cap.
π§ COMPATIBLE COMPILERS π§
the MPI library may be used with any compiler that uses the same lengths for basic data objects (such as long double) and that uses compatible run-time libraries. on many systems the various compilers are compatible and may be used interchangeably. icon behaviour honestly.
but there are exceptions π. if you use the MPICH_FC environment variable or the -fc=name command-line argument to override the choice of compiler, and you encounter problems, try reconfiguring MPICH with the new compiler and installing MPICH in a separate location. see the installation manual for more details. π
β EXAMPLES β
to compile a single file foo.f, use:
mpifort -c foo.f
to link the output and make an executable, use:
mpifort -o foo foo.o
combining compilation and linking in a single command:
mpifort -o foo foo.f
is a convenient way to build simple programs. one command, whole program, main character energy. π
π SELECTING A PROFILING LIBRARY π
the -profile=name argument lets you specify an MPI profiling library to be used. name can have two forms:
- A library in the same directory as the MPI library
- The name of a profile configuration file
if name is a library, then this library is included before the MPI library. this allows the simple use of libraries that make use of the MPI profiling interface and that are installed in the same directory as the MPI library. easy peasy. π
if name.conf is the name of a file in the sysconfdir directory, then this is read and may define the following variables:
PROFILE_PRELIBβ Libraries (and paths) to include before the MPI libraryPROFILE_POSTLIBβ Libraries to include after the MPI libraryPROFILE_INCPATHSβ C preprocessor arguments for any include files
for example, to add /usr/local/myprof/include to the include path and the library libmyprof.a in /usr/local/myprof/lib to the link step, you could create the file myprof.conf with the lines:
PROFILE_PRELIB="-L/usr/local/myprof/lib -lmyprof"
PROFILE_INCPATHS="-I/usr/local/myprof/include"
and place it in the sysconfdir directory (this directory is set at configure time when MPICH is built). then using the command-line argument -profile=myprof will cause these definitions to be added to the relevant compile commands. slay. π₯
π SEE ALSO π
mpicc, mpicxx, mpifort, mpiexec
and that's the whole page bestie, you ate it π
this was mpifort(1) from the MPI manual, dated 4/10/2026 β go compile something iconic β¨π¦π
π¦ where this page comes from
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms