diff --git a/configure b/configure index 8fd223c0..3bca6aca 100755 --- a/configure +++ b/configure @@ -2040,16 +2040,25 @@ then fi mpi_fc='h5pfc' -elif test "$parallel_compiler" == mpif90 +elif test "$parallel_compiler" == mpif90 || test "$parallel_compiler" == mpifort then - mpi_compiler=`basename $(mpif90 -show | awk {'print $1'})` - mpi_fc='HDF5_FLINKER=mpif90 HDF5_FC=mpif90 h5fc' + mpi_compiler=`basename $($parallel_compiler -show | awk {'print $1'})` + # The h5fc wrapper in HDF5 1.x lets HDF5_FC and HDF5_FLINKER replace the + # compiler it calls, so we can make it call the MPI wrapper. The h5fc in + # HDF5 2.x is a different, pkg-config based script that ignores these + # variables and always calls the serial compiler, so in that case we do the + # reverse and make the MPI wrapper call h5fc (MPICH_FC is read by MPICH and + # OMPI_FC by Open MPI). The HDF5 2.x wrapper also no longer adds the linker + # flags HDF5 was built with, so we pass on LDFLAGS ourselves. + h5fc_compiler=`HDF5_FLINKER=$parallel_compiler HDF5_FC=$parallel_compiler h5fc -show | awk {'print $1'}` + if test "$h5fc_compiler" == "$parallel_compiler" + then + mpi_fc="HDF5_FLINKER=$parallel_compiler HDF5_FC=$parallel_compiler h5fc" -elif test "$parallel_compiler" == mpifort -then - mpi_compiler=`basename $(mpifort -show | awk {'print $1'})` - mpi_fc='HDF5_FLINKER=mpifort HDF5_FC=mpifort h5fc' + else + mpi_fc="MPICH_FC=h5fc OMPI_FC=h5fc $parallel_compiler $LDFLAGS" + fi else as_fn_error $? "\"h5pfc or mpif90 need to be present\"" "$LINENO" 5 fi diff --git a/configure.ac b/configure.ac index 4c00ab88..d67cccdc 100644 --- a/configure.ac +++ b/configure.ac @@ -170,14 +170,23 @@ then mpi_compiler=`basename $(mpifort -show | awk {'print $1'})` fi AC_SUBST(mpi_fc, 'h5pfc') -elif test "$parallel_compiler" == mpif90 -then - mpi_compiler=`basename $(mpif90 -show | awk {'print $1'})` - AC_SUBST(mpi_fc, 'HDF5_FLINKER=mpif90 HDF5_FC=mpif90 h5fc') -elif test "$parallel_compiler" == mpifort -then - mpi_compiler=`basename $(mpifort -show | awk {'print $1'})` - AC_SUBST(mpi_fc, 'HDF5_FLINKER=mpifort HDF5_FC=mpifort h5fc') +elif test "$parallel_compiler" == mpif90 || test "$parallel_compiler" == mpifort +then + mpi_compiler=`basename $($parallel_compiler -show | awk {'print $1'})` + # The h5fc wrapper in HDF5 1.x lets HDF5_FC and HDF5_FLINKER replace the + # compiler it calls, so we can make it call the MPI wrapper. The h5fc in + # HDF5 2.x is a different, pkg-config based script that ignores these + # variables and always calls the serial compiler, so in that case we do the + # reverse and make the MPI wrapper call h5fc (MPICH_FC is read by MPICH and + # OMPI_FC by Open MPI). The HDF5 2.x wrapper also no longer adds the linker + # flags HDF5 was built with, so we pass on LDFLAGS ourselves. + h5fc_compiler=`HDF5_FLINKER=$parallel_compiler HDF5_FC=$parallel_compiler h5fc -show | awk {'print $1'}` + if test "$h5fc_compiler" == "$parallel_compiler" + then + AC_SUBST(mpi_fc, "HDF5_FLINKER=$parallel_compiler HDF5_FC=$parallel_compiler h5fc") + else + AC_SUBST(mpi_fc, "MPICH_FC=h5fc OMPI_FC=h5fc $parallel_compiler $LDFLAGS") + fi else AC_MSG_ERROR("h5pfc or mpif90 need to be present") fi