Skip to content

Commit

Permalink
fortran: add mismatch flags to mpif77 wrapper
Browse files Browse the repository at this point in the history
Remove the AC_MSG_ERROR on needing the Fortran mismatch flag and add the
flag to the mpif77 wrapper.

This will not affect users of modern Fortran MPI applications who are
likely to use `mpifort` or `mpif90` and uses the mpi module interface.

Users who use `mpif77` is likely to use `mpif.h` interface and will
require the ignore-mismatch compiler flags to compile their MPI
applications.

By adding the extra flags to mpif77 wrapper only, we hope to strike a
balance of convenience and impact.
  • Loading branch information
hzhou committed Feb 9, 2022
1 parent 710c808 commit 778933a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
13 changes: 5 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1970,15 +1970,12 @@ if test "$enable_f77" = "yes" ; then
# of different types (e.g., for MPI_Send)
PAC_PROG_F77_MISMATCHED_ARGS(addarg,yes)
if test "X$addarg" != "X" ; then
# We could add the names of all of the MPI routines that
# accept different types. Instead, we fail cleanly.
# Some Fortran compilers allow you to turn off checking for
# mismatched arguments for *all* routines. Adding an argument
# that turns off checking for *everything* is not something that
# configure should do - if the user wants this, they can follow
# the instructions in the following error message.
AC_MSG_ERROR([The Fortran compiler $FC does not accept programs that call the same routine with arguments of different types without the option $addarg. Rerun configure with FCFLAGS=$addarg])
# Code using mpif.h interface will likely need this flag to compile.
# Code with `use mpi` or `use mpi_f08` do not need this flag.
# Add the flag to mpif77 wrappers.
WRAPPER_EXTRA_F77_FLAGS="$addarg"
fi
AC_SUBST(WRAPPER_EXTRA_F77_FLAGS)

bindings="$bindings f77"
AC_DEFINE(HAVE_FORTRAN_BINDING,1,[Define if Fortran is supported])
Expand Down
5 changes: 5 additions & 0 deletions src/env/mpifort.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ if test "@INTERLIB_DEPS@" = "no" -o "${interlib_deps}" = "no" ; then
final_libs="${final_libs} @LIBS@ @WRAPPER_LIBS@"
fi

extra_f77_flags="@WRAPPER_EXTRA_F77_FLAGS@"
if test "mpif77" = ${0##*/} -a -n "$extra_f77_flags" ; then
final_fcflags="${final_fcflags} $extra_f77_flags"
fi

# A temporary statement to invoke the compiler
# Place the -L before any args in case there are any mpi libraries in there.
# Eventually, we'll want to move this after any non-MPI implementation
Expand Down
5 changes: 5 additions & 0 deletions src/env/mpifort.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ if test "@INTERLIB_DEPS@" = "no" -o "${interlib_deps}" = "no" ; then
final_libs="${final_libs} @LIBS@ @WRAPPER_LIBS@"
fi

extra_f77_flags="@WRAPPER_EXTRA_F77_FLAGS@"
if test "mpif77" = ${0##*/} -a -n "$extra_f77_flags" ; then
final_fcflags="${final_fcflags} $extra_f77_flags"
fi

# A temporary statement to invoke the compiler
# Place the -L before any args in case there are any mpi libraries in there.
# Eventually, we'll want to move this after any non-MPI implementation
Expand Down
20 changes: 0 additions & 20 deletions test/mpi/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1034,26 +1034,6 @@ EOF
AC_LANG_FORTRAN77
PAC_PROG_F77_NAME_MANGLE

# Check that the Fortran compiler will allow us to pass arguments
# of different types (e.g., for MPI_Send)
# Any strict Fortran compiler will require that the arguments be
# the same type - currently, the NAG Fortran compiler (nagfor) is known
# to enforce this.
# We could set the FFLAGS/FCFLAGS values with the option that disables
# this check (if we found one), but because that may affect other tests,
# instead we tell the user and exit.
PAC_PROG_F77_MISMATCHED_ARGS(addarg,yes)
if test "X$addarg" != "X" ; then
# We could add the names of all of the MPI routines that
# accept different types. Instead, we fail cleanly.
# Some Fortran compilers allow you to turn off checking for
# mismatched arguments for *all* routines. Adding an argument
# that turns off checking for *everything* is not something that
# configure should do - if the user wants this, they can follow
# the instructions in the following error message.
AC_MSG_ERROR([The Fortran compiler $F77 does not accept programs that call the same routine with arguments of different types without the option $addarg. Rerun configure with FFLAGS=$addarg])
fi

# Check whether we need -lU77 to get iargc and getarg, which
# are used for a few of the tests in spawn (U77 was needed with
# the native compilers on HPUX. See the aclocal_f77(old).m4 file,
Expand Down

0 comments on commit 778933a

Please sign in to comment.