Make mpi error with gfortran10+

Hello everyone,

I’m trying building the mpi using MPI and Fortran 10+ , but I’ve faced the following compilation errors:
/usr/bin/ld: cannot find -lmpi_usempif08: Datei oder Verzeichnis nicht gefunden
/usr/bin/ld: cannot find -lmpi_usempi_ignore_tkr: Datei oder Verzeichnis nicht gefunden
/usr/bin/ld: cannot find -lmpi_mpifh: Datei oder Verzeichnis nicht gefunden
/usr/bin/ld: cannot find -lopen-rte: Datei oder Verzeichnis nicht gefunden
/usr/bin/ld: cannot find -lopen-pal: Datei oder Verzeichnis nicht gefunden
/usr/bin/ld: cannot find -levent_core: Datei oder Verzeichnis nicht gefunden
/usr/bin/ld: cannot find -levent_pthreads: Datei oder Verzeichnis nicht gefunden
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile.mkmf:5240: exciting] Fehler 1
make[3]: Verzeichnis „/temp_local/…/exciting/build/mpi“ wird verlassen
make[2]: *** […/Make.common:93: bin] Fehler 2
make[2]: Verzeichnis „/temp_local/…/exciting/build/mpi“ wird verlassen
make[1]: *** [Makefile:6: all] Fehler 2
make[1]: Verzeichnis „/temp_local/…/exciting/build/mpi“ wird verlassen
make: *** [Makefile:26: mpi] Fehler 2

I modified my Makefile as follows:

F90 = gfortran
F77 = $(F90)
FCCPP = cpp

F90_OPTS = -O3 -march=native -ffree-line-length-0 -fallow-argument-mismatch
F77_OPTS = -O3 -fallow-argument-mismatch

F90_DEBUGOPTS = -g -O0 -DUSE_ASSERT -fbounds-check -fbacktrace -Wall -Wextra -ffree-line-length-0 -fcheck=all -finit-integer=42 -frecord-gcc-switches -finit-character=42 -finit-logical=true -ffpe-trap=invalid,zero,overflow -fdump-core -fstack-protector
F77_DEBUGOPTS = $(F90_DEBUGOPTS)

CPP_ON_OPTS = -cpp -DXS -DISO -DLIBXC

export USE_SYS_LAPACK = true
LIB_LPK = -L./ -llapack -lblas
MPI_LIBS =
LIB_FFT = fftlib.a
LIB_BZINT = libbzint.a
LIBS = (LIB_LPK) (LIB_FFT) $(LIB_BZINT)

MPIF90 = mpif90
MPIF77 = mpif77

MPIF77_OPTS = $(MPIF90_OPTS)

MPIF90 = mpif90
MPIF90_OPTS = -fopenmp -DUSEOMP -DSCAL -DMPI -I/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15/mpich -I/usr/lib/x86_64-linux-gnu/openmpi/include -I/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi

SMPF90_OPTS = -fopenmp -DUSEOMP
SMPF77_OPTS = $(SMPF90_OPTS)
SMP_LIBS =

BUILDMPI = true
BUILDSMP = true
BUILDMPISMP = true

my steps to solve:

  • Ensured all the mentioned libraries (e.g., libevent_pthreads, libevent_core, etc.) are installed at /usr/lib/x86_64-linux-gnu/.
  • Updated the library paths in the bash environment variables.
  • Attempted to explicitly define MPI_LIBS in the Makefile, but no success.

Hi Sareh,

Your changes to the makefile don’t make sense, which is why you’re probably having problems.

The main problem is that you’re defining include paths for openMPI and mpich. This makes no sense, they’re two separate implementations of MPI. You only need one. And this should be whatever mpif90 is pointing to. For simplicity, I recommend uninstalling one of them

  • If all libs are installed in the default places (looks like you’re on linux, and probably using the package manager, so I assume yes), you don’t need to define the location of the headers/modules with -I.

  • Whilst you specify the include paths, yopu don’t give the library paths with -L. But again, if they’re installed in the correct places there should be no need. One can also check $LIBRARY_PATH

  • MPIF77 doesn’t exist, this won’t do anything.

  • You’ve redefined -fopenmp -DUSEOMP in MPIF90_OPTS which is redundant, they’re already in SMPF90_OPTS.

  • -DSCAL assumes you have scalapack installed. I’d remove this for the time-being.

make.inc.gfortran8-9 should be sufficient for defining the build, with the packages installed according to build/utilities/docker/Dockerfile_debian-GCC8:

apt-get update && \
apt-get install -y build-essential git xsltproc \
python2 libpython3.7 libpython3.7-dev python3-pip python3-venv python3-mysqldb python3-tk python3-mysqldb-dbg \
man tcllib environment-modules libfabric1 libfabric-dev gcc-8 libblas-dev liblapack-dev libopenmpi3

(maybe the -dev is required for libopenmpi3).

Hi Alex,

Thank you so much for your answer. I faced several errors even with the original makefile when trying to use gfortran also on different systems. Finally, I managed to create make_purempi using ifort instead of gfortran, and the orginal makefile worked correctly. Anyway, I will definitely use your tips in the future for other systems.
Best regards
Sareh