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 single mpifort command 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 paths mpifort is using. detective mode. πŸ”
  • -link_info β€” Show the steps for linking a program. use this to see what options and libraries mpifort is 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, -c causes files to be compiled, -g selects compilation with debugging on most systems, and -o name causes 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 library
  • PROFILE_POSTLIB β€” Libraries to include after the MPI library
  • PROFILE_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