Skip to content

mpif90 shows an invalid command on Ubuntu 22.04 + gcc #11636

Open
@perazz

Description

@perazz

System information

  • Ubuntu 22.04 (Docker image) + gcc 11.3.0 + gfortran + OpenMPI 4.1.2 via apt

Background information

Working on an MPI wrapper for the Fortran Package Manager

After installing OpenMPI via apt, mpif90 shows invalid library directory flags, which make them useless.

I'm using this very simple Dockerfile:

FROM ubuntu:22.04
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      git vim gcc gfortran wget openmpi-bin libopenmpi-dev

Issue

mpif90 -show reports a non-existent directory flag: -L/usr/lib/x86_64-linux-gnu/openmpi/lib/fortran/gfortran :

root@87c9773eedf2:~/fpm-dev# mpif90 -show
gfortran -I/usr/lib/x86_64-linux-gnu/openmpi/lib/../../fortran/gfortran-mod-15/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/lib -L/usr/lib/x86_64-linux-gnu/openmpi/lib/fortran/gfortran -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi -lopen-rte -lopen-pal -lhwloc -levent_core -levent_pthreads -lm -lz

That folder does not exist, nor as a symbolic link.

  • If I try to build a program with the command output by mpif90 -show, I get a bunch of undefined reference errors, because the MPI libraries can't be found
  • If I instead build using mpif90 as the compiler, the build succeeds.

The other wrappers i.e. mpicc report the correct directory:

root@87c9773eedf2:~/fpm-dev# mpicc -show
gcc -I/usr/lib/x86_64-linux-gnu/openmpi/include -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions