Feature-request : use --download-mpich on Ubuntu

Dear FreeFEM developpers

After most struggle to compile FreeFEM on Ubuntu 20.04, I found that many problems can be avoided if PETSc is compiled beforehand as suggested by Compiling with your own PETSc and SLEPc builds and by http://jolivet.perso.enseeiht.fr/FreeFem-tutorial/#pfc0.

It seems that the mpich or openmpi available from the ubuntu public repositories are somehow broken or hard to configure properly for the compilation. I also attempted to install from the provided .deb but I have an issue with the version of gfortran.

However everything seems to run fine if we follow these steps:

  • Install and compile PETSc first with
PREFIX="/usr/local/ff-petsc/r/"
sudo ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran \
    --download-mumps --download-parmetis --download-mpich --download-fblaslapack \
    --download-metis --download-hypre --download-slepc \
    --download-hpddm --download-ptscotch \
    --download-suitesparse \
    --download-scalapack \
    --with-fortran-bindings=no \
    --with-scalar-type=real \
    --with-debugging=no \
    --prefix=$PREFIX

This automatically install a working mpich. Note that on my environment “–download-fblaslapack” is needed because the MUMPS of the ubuntu repository is too old and its libraries will create conflict when compiling FreeFEM.

  • One should need to do the same for PETSc complex and adapting to use the mpich of PETSc real
  • Then set the mpi compilers to be those of PETSc:
export MPIPREFIX="/usr/local/ff-petsc/r/bin"
export MPICC="$MPIPREFIX/mpicc"
export MPICXX="$MPIPREFIX/mpicxx"
export MPIF77="$MPIPREFIX/mpif77"
export MPIFC="$MPIPREFIX/mpif90"
export MPIRUN="$MPIPREFIX/mpirun"
  • Finally run configure and compile:
./configure --enable-download --enable-optim -with-mpi=mpich
./3rdparty/getall -a
make
sudo make install

I made a script which attempts to do all this (verified on kubuntu 20.04) which is maintained here:

I suspect it could help many ubuntu users if there would be an option to use --download-mpich of PETSc on the FreeFEM configure which would reproduce my suggestion, or if these instructions would be clearly suggested on the FreeFEM doc page.

Many thanks for all the work you are doing

Best

Dear Florian,
I’ve just pushed a new commit in the develop branch so that if no MPI implementation is detected during ./configure, the flag --download-mpich will automatically be added for you when running make petsc-slepc. Then, during ./reconfigure, FreeFEM will pick up the PETSc-generated wrappers mpirun, mpic++, mpic, and mpif90 if you have Fortran installed. Having MPI installed is not a requirement anymore for using PETSc/SLEPc.

Thank you for the feature request :slight_smile:

PS: I still do prefer and recommend to power users to have their PETSc installation on the side, like you are doing in your post, since it’s easier to update and adapt, e.g., specific downloaded libraries and such.

Hi prj,

Thanks for the update!

By the way in the mean time I passed to Fedora and I noticed that the recent version 10 of gcc and gfortran create some retrocompatibility problems at the compilation, see e.g. https://gcc.gnu.org/gcc-10/porting_to.html#argument-mismatch.

One should use the c/cpp flag -fcommon and the gfortran flag -fallow-argument-mismatch: e.g. using these exports before running ./configure:

export FCFLAGS="-fallow-argument-mismatch"
export FFLAGS="-fallow-argument-mismatch"
export CFLAGS="-fcommon"
export CXXFLAGS="-fcommon"

So I updated my recipe here (on fedora ow but it works also for ubuntu):

Best

I usually recommend people to just --disable-fortran. What are those CFLAGS and CXXFLAGS for, please?

Hi Pierre,

If we do --disable-fortran, then it is still possible to compile all third party packages ?
The -fcommon flag is needed now for the compilation of mmg with gcc10 (otherwise there are linker errors). The reason for this is explained here https://gcc.gnu.org/gcc-10/porting_to.html.

Best
Florian

OK, I guess the Mmg error should be reported upstream, and I don’t think it would be too difficult to fix?
If you do:

$ ./configure --enable-download --prefix=~/FreeFem-install
$ cd 3rdparty/ff-petsc && make petsc-slepc
$ ./reconfigure --disable-fortran 

Then, you’ll get most (not all) third party packages. The missing ones will be ARPACK (but you’ll have SLEPc), Ipopt, MUMPS_seq.

With the upcoming release of PETSc 3.14.0 (scheduled September 29), you’ll also get ARPACK with these steps (may be tested using the branch petsc-3.14.0).

The -fcommon flag is needed now for the compilation of mmg with gcc10

Hasn’t this been fixed for a while? https://github.com/MmgTools/mmg/issues/72