Skip to content

Commit f67e216

Browse files
authored
Merge pull request #13123 from devreal/deprecate-mpifh
Mark mpif.h as deprecated
2 parents bf59a30 + 0cb20b1 commit f67e216

File tree

6 files changed

+77
-1
lines changed

6 files changed

+77
-1
lines changed

config/ompi_configure_options.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,9 @@ else
252252
ompi_want_ompio=1
253253
fi
254254
AM_CONDITIONAL(OMPI_OMPIO_SUPPORT, test "$ompi_want_ompio" = "1")
255+
256+
AC_ARG_ENABLE([deprecate-mpif-h],
257+
[AS_HELP_STRING([--enable-deprecate-mpif-h],
258+
[Mark the mpif.h bindings as deprecated (default: enabled)])])
259+
255260
])dnl

config/ompi_fortran_check_warning.m4

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
dnl -*- shell-script -*-
2+
dnl
3+
dnl Copyright (c) 2025 Stony Brook University. All rights reserved.
4+
dnl $COPYRIGHT$
5+
dnl
6+
dnl Additional copyrights may follow
7+
dnl
8+
dnl $HEADER$
9+
dnl
10+
11+
# Check whether the fortran compiler produces a warning when
12+
# it encounters a #warning directive
13+
14+
# OMPI_FORTRAN_CHECK_WARNING([action if found],
15+
# [action if not found])
16+
# ----------------------------------------------------
17+
AC_DEFUN([OMPI_FORTRAN_CHECK_WARNING],[
18+
AS_VAR_PUSHDEF([warning_var], [ompi_cv_fortran_warning])
19+
20+
AC_CACHE_CHECK([if Fortran compiler supports preprocessor warnings], warning_var,
21+
[
22+
# check if the compiler provides a proper #warning
23+
# some compilers (gfortran) do not show the warning if the file is found
24+
# through an include path, so create a temporary directory and include file
25+
OAC_VAR_SCOPE_PUSH(msg, dir)
26+
dir="tmp_includedir_$$"
27+
msg="This is a deprecated file"
28+
AS_MKDIR_P($dir)
29+
echo "#warning $msg" > $dir/deprecated.h
30+
31+
echo "! -*- fortran -*-
32+
program main
33+
implicit none
34+
include 'deprecated.h'
35+
end program main
36+
" > conftest.f
37+
AS_IF([${FC} ${FCFLAGS} -c -I$dir conftest.f 2>conftest.err >conftest.out],
38+
[ # compilation succeeded, check the produced output for the warning
39+
AS_IF([grep "$msg" conftest.err conftest.out >/dev/null 2>/dev/null],
40+
[AS_VAR_SET(warning_var, "yes")],
41+
[AS_VAR_SET(warning_var, "no (missing warning)")],)],
42+
[AS_VAR_SET(warning_var, "no (compilation failed)")])
43+
OPAL_VAR_SCOPE_POP
44+
rm -rf conftest.f conftest.err conftest.out $dir 2>/dev/null >/dev/null
45+
])
46+
AS_VAR_IF(warning_var, [yes], [$1], [$2])
47+
AS_VAR_POPDEF([warning_var])dnl
48+
])
49+

config/ompi_setup_fc.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
1616
dnl Copyright (c) 2009-2020 Cisco Systems, Inc. All rights reserved.
1717
dnl Copyright (c) 2015-2020 Research Organization for Information Science
1818
dnl and Technology (RIST). All rights reserved.
19+
dnl Copyright (c) 2025 Stony Brook University. All rights reserved.
1920
dnl $COPYRIGHT$
2021
dnl
2122
dnl Additional copyrights may follow
@@ -43,7 +44,7 @@ AC_DEFUN_ONCE([_OMPI_SETUP_FC_COMPILER],[
4344
# Fortran compilers (excluding the f77 compiler names) from AC's
4445
# default list of compilers and use it here. This is the main
4546
# reason we have an OMPI-ized version of the PROG_FC macro.
46-
AC_PROG_FC([gfortran f95 fort xlf95 ifort ifc efc pgfortran pgf95 lf95 f90 xlf90 pgf90 epcf90 nagfor nvfortran])
47+
AC_PROG_FC([gfortran flang-new flang f95 fort xlf95 ifort ifc efc pgfortran pgf95 lf95 f90 xlf90 pgf90 epcf90 nagfor nvfortran])
4748
FCFLAGS="$ompi_fcflags_save"
4849
OPAL_VAR_SCOPE_POP
4950
])

config/ompi_setup_mpi_fortran.m4

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dnl Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
2121
dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2222
dnl Copyright (c) 2022 Triad National Security, LLC. All rights
2323
dnl reserved.
24+
dnl Copyright (c) 2025 Stony Brook University. All rights reserved.
2425
dnl $COPYRIGHT$
2526
dnl
2627
dnl Additional copyrights may follow
@@ -381,6 +382,20 @@ end program]])],
381382
[OMPI_FORTRAN_BUILD_SIZEOF=0])
382383
AC_SUBST(OMPI_FORTRAN_BUILD_SIZEOF)
383384

385+
OMPI_FORTRAN_SUPPORTS_WARNING="no"
386+
AS_IF([! test x"$enable_deprecate_mpif_h" = "xno"],
387+
[OMPI_FORTRAN_CHECK_WARNING([OMPI_FORTRAN_SUPPORTS_WARNING="yes"],
388+
[OMPI_FORTRAN_SUPPORTS_WARNING="no"])])
389+
AC_MSG_CHECKING([if we mark mpif.h bindings as deprecated])
390+
AS_IF([test "x$enable_deprecate_mpif_h" = "xyes" && test "$OMPI_FORTRAN_SUPPORTS_WARNING" = "no"],
391+
[AC_MSG_ERROR([Request to mark mpif.h as deprecated but Fortran compiler does not support warning preprocessor directive.])])
392+
AS_IF([test "x$enable_deprecate_mpif_h" != "xno" && test "$OMPI_FORTRAN_SUPPORTS_WARNING" = "yes"],
393+
[OMPI_FORTRAN_DEPRECATE_MPIF_H="#warning mpif.h has been deprecated since MPI 4.1. See MPI-4.1:19.1.4 for details."
394+
AC_MSG_RESULT([yes])],
395+
[OMPI_FORTRAN_DEPRECATE_MPIF_H=""
396+
AC_MSG_RESULT([no])])
397+
AC_SUBST(OMPI_FORTRAN_DEPRECATE_MPIF_H)
398+
384399
#--------------------------------------------
385400
# Fortran use mpi or use mpi_f08 MPI bindings
386401
#--------------------------------------------

docs/release-notes/changelog/v6.0.x.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ Open MPI version v6.0.0
3030
(which has been the default for quite a while, anyway).
3131

3232
- Added MPI-4.1 ``MPI_Status_*`` functions.
33+
34+
- MPI-4.1 has deprecated the use of the Fortran ``mpif.h`` include
35+
file. Open MPI will now issue a warning when the file is included
36+
and the Fortran compiler supports the ``#warning`` directive.

ompi/include/mpif.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
! WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
5454
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5555
56+
@OMPI_FORTRAN_DEPRECATE_MPIF_H@
57+
5658
include 'mpif-config.h'
5759
include 'mpif-constants.h'
5860
include 'mpif-handles.h'

0 commit comments

Comments
 (0)