Skip to content

Commit 40a6cd6

Browse files
committed
MPI_F08: error out if fortran FCFLAGs do not work with big count
Without this patch, one can successfully configure OMPI with fortran compiler flags that lead to compilation failures when building the mpi_f08 module. This can happen when the default integer size is the same as KIND=MPI_KIND_COUNT. Add a configure check to error out at that state with a hopefully useful error message: checking if Fortran compiler can compile interface containing MPI_KIND_COUNT arguments ... no configure: error: The MPI_F08 module cannot be compiled using configure Fortran commpiler options. Either change compiler options or use --enable-mpi-fortran=usempi Signed-off-by: Howard Pritchard <[email protected]> (cherry picked from commit 355d5ce)
1 parent 5635c6d commit 40a6cd6

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
dnl -*- shell-script -*-
2+
dnl
3+
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4+
dnl University Research and Technology
5+
dnl Corporation. All rights reserved.
6+
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
7+
dnl of Tennessee Research Foundation. All rights
8+
dnl reserved.
9+
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10+
dnl University of Stuttgart. All rights reserved.
11+
dnl Copyright (c) 2004-2005 The Regents of the University of California.
12+
dnl All rights reserved.
13+
dnl Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
14+
dnl Copyright (c) 2022-2025 Triad National Security, LLC. All rights
15+
dnl reserved.
16+
dnl $COPYRIGHT$
17+
dnl
18+
dnl Additional copyrights may follow
19+
dnl
20+
dnl $HEADER$
21+
dnl
22+
23+
# Check whether or not the Fortran compiler can build mpi_f08 using
24+
# the given compiler options. This test is intended to
25+
# trap cases where default INTEGER KIND is equivalent to MPI_COUNT_KIND.
26+
27+
# OMPI_FORTRAN_CHECK_BIG_COUNT([action if found],
28+
# [action if not found])
29+
# ----------------------------------------------------
30+
AC_DEFUN([OMPI_FORTRAN_CHECK_BIG_COUNT],[
31+
AS_VAR_PUSHDEF([big_count_var], [ompi_cv_big_count_var])
32+
33+
AC_CACHE_CHECK([if Fortran compiler can compile interface containing MPI_KIND_COUNT arguments ], big_count_var,
34+
[AC_LANG_PUSH([Fortran])
35+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[module sendit_interfaces
36+
INTERFACE SendIt
37+
subroutine SendIt_int(X)
38+
INTEGER :: X
39+
end subroutine SendIt_int
40+
subroutine SendIt_big(x)
41+
integer(KIND=$OMPI_MPI_COUNT_KIND)::X
42+
end subroutine SendIt_big
43+
end interface SendIt
44+
end module sendit_interfaces]])],
45+
[AS_VAR_SET(big_count_var, yes)],
46+
[AS_VAR_SET(big_count_var, no)])
47+
touch conftest_foo.mod
48+
rm -rf *.mod 2>/dev/null
49+
AC_LANG_POP([Fortran])
50+
])
51+
52+
AS_VAR_IF(big_count_var, [yes], [$1], [$2])
53+
AS_VAR_POPDEF([big_count_var])dnl
54+
])

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,14 @@ AC_CHECK_MEMBERS([struct timespec.tv_nsec],
896896
#
897897
m4_ifdef([project_ompi], [OMPI_FIND_MPI_AINT_COUNT_OFFSET])
898898

899+
#
900+
# now that we have MPI_COUNT_KIND set, try building
901+
# MPI F08 bindings if that level of fortran support is requested
902+
#
903+
m4_ifdef([project_ompi], [AS_IF([test $OMPI_BUILD_FORTRAN_BINDINGS -ge $OMPI_FORTRAN_USEMPIF08_BINDINGS],
904+
[OMPI_FORTRAN_CHECK_BIG_COUNT([],
905+
[AC_MSG_ERROR([The mpi_f08 module cannot be compiled using the current set of Fortran compiler options ($FCFLAGS). Either change compiler options or use --enable-mpi-fortran=usempi])])
906+
])])
899907
# checkpoint results
900908
AC_CACHE_SAVE
901909

0 commit comments

Comments
 (0)