Skip to content

Mark mpif.h as deprecated #13123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/ompi_configure_options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,9 @@ else
fi
AM_CONDITIONAL(OMPI_OMPIO_SUPPORT, test "$ompi_want_ompio" = "1")

AC_ARG_ENABLE([deprecate-mpif-h],
[AS_HELP_STRING([--enable-deprecate-mpif-h],
[Mark the mpif.h bindings as deprecated (default: enabled)])])

])dnl

49 changes: 49 additions & 0 deletions config/ompi_fortran_check_warning.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2025 Stony Brook University. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

# Check whether the fortran compiler produces a warning when
# it encounters a #warning directive

# OMPI_FORTRAN_CHECK_WARNING([action if found],
# [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_WARNING],[
AS_VAR_PUSHDEF([warning_var], [ompi_cv_fortran_warning])

AC_CACHE_CHECK([if Fortran compiler supports preprocessor warnings], warning_var,
[
# check if the compiler provides a proper #warning
# some compilers (gfortran) do not show the warning if the file is found
# through an include path, so create a temporary directory and include file
OAC_VAR_SCOPE_PUSH(msg, dir)
dir="tmp_includedir_$$"
msg="This is a deprecated file"
AS_MKDIR_P($dir)
echo "#warning $msg" > $dir/deprecated.h

echo "! -*- fortran -*-
program main
implicit none
include 'deprecated.h'
end program main
" > conftest.f
AS_IF([${FC} ${FCFLAGS} -c -I$dir conftest.f 2>conftest.err >conftest.out],
[ # compilation succeeded, check the produced output for the warning
AS_IF([grep "$msg" conftest.err conftest.out >/dev/null 2>/dev/null],
[AS_VAR_SET(warning_var, "yes")],
[AS_VAR_SET(warning_var, "no (missing warning)")],)],
[AS_VAR_SET(warning_var, "no (compilation failed)")])
OPAL_VAR_SCOPE_POP
rm -rf conftest.f conftest.err conftest.out $dir 2>/dev/null >/dev/null
])
AS_VAR_IF(warning_var, [yes], [$1], [$2])
AS_VAR_POPDEF([warning_var])dnl
])

3 changes: 2 additions & 1 deletion config/ompi_setup_fc.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
dnl Copyright (c) 2009-2020 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2015-2020 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl Copyright (c) 2025 Stony Brook University. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
Expand Down Expand Up @@ -43,7 +44,7 @@ AC_DEFUN_ONCE([_OMPI_SETUP_FC_COMPILER],[
# Fortran compilers (excluding the f77 compiler names) from AC's
# default list of compilers and use it here. This is the main
# reason we have an OMPI-ized version of the PROG_FC macro.
AC_PROG_FC([gfortran f95 fort xlf95 ifort ifc efc pgfortran pgf95 lf95 f90 xlf90 pgf90 epcf90 nagfor nvfortran])
AC_PROG_FC([gfortran flang-new flang f95 fort xlf95 ifort ifc efc pgfortran pgf95 lf95 f90 xlf90 pgf90 epcf90 nagfor nvfortran])
FCFLAGS="$ompi_fcflags_save"
OPAL_VAR_SCOPE_POP
])
Expand Down
15 changes: 15 additions & 0 deletions config/ompi_setup_mpi_fortran.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dnl Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
dnl Copyright (c) 2022 Triad National Security, LLC. All rights
dnl reserved.
dnl Copyright (c) 2025 Stony Brook University. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
Expand Down Expand Up @@ -376,6 +377,20 @@ end program]])],
[OMPI_FORTRAN_BUILD_SIZEOF=0])
AC_SUBST(OMPI_FORTRAN_BUILD_SIZEOF)

OMPI_FORTRAN_SUPPORTS_WARNING="no"
AS_IF([! test x"$enable_deprecate_mpif_h" = "xno"],
[OMPI_FORTRAN_CHECK_WARNING([OMPI_FORTRAN_SUPPORTS_WARNING="yes"],
[OMPI_FORTRAN_SUPPORTS_WARNING="no"])])
AC_MSG_CHECKING([if we mark mpif.h bindings as deprecated])
AS_IF([test "x$enable_deprecate_mpif_h" = "xyes" && test "$OMPI_FORTRAN_SUPPORTS_WARNING" = "no"],
[AC_MSG_ERROR([Request to mark mpif.h as deprecated but Fortran compiler does not support warning preprocessor directive.])])
AS_IF([test "x$enable_deprecate_mpif_h" != "xno" && test "$OMPI_FORTRAN_SUPPORTS_WARNING" = "yes"],
[OMPI_FORTRAN_DEPRECATE_MPIF_H="#warning mpif.h has been deprecated since MPI 4.1. See MPI-4.1:19.1.4 for details."
AC_MSG_RESULT([yes])],
[OMPI_FORTRAN_DEPRECATE_MPIF_H=""
AC_MSG_RESULT([no])])
AC_SUBST(OMPI_FORTRAN_DEPRECATE_MPIF_H)

#--------------------------------------------
# Fortran use mpi or use mpi_f08 MPI bindings
#--------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes/changelog/v6.0.x.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ Open MPI version v6.0.0
:Date: ...fill me in...

- Open MPI now requires a C11-compliant compiler to build.
- MPI 4.1 has deprecated the use of the Fortran mpif.h include file.
Open MPI will now issue a warning when the file is included and the
Fortran compiler supports the #warning directive.
2 changes: 2 additions & 0 deletions ompi/include/mpif.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
! WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@OMPI_FORTRAN_DEPRECATE_MPIF_H@

include 'mpif-config.h'
include 'mpif-constants.h'
include 'mpif-handles.h'
Expand Down