From 29af092fd634d26202e151fbe858cc39d107849a Mon Sep 17 00:00:00 2001 From: sfilippone Date: Thu, 20 Nov 2025 14:58:21 +0100 Subject: [PATCH] Require SUBMODULES and bump minimum GNU version to 6.0 --- config/pac.m4 | 51 +++++++++++++++++++++++++++++++++++ configure | 73 ++++++++++++++++++++++++++++++++++++++++++++------- configure.ac | 24 ++++++++++------- 3 files changed, 130 insertions(+), 18 deletions(-) diff --git a/config/pac.m4 b/config/pac.m4 index 90340c8d..9cb55647 100644 --- a/config/pac.m4 +++ b/config/pac.m4 @@ -956,6 +956,57 @@ end program xtt], AC_LANG_POP([Fortran]) ]) +dnl @synopsis PAC_FORTRAN_TEST_SUBMODULES( [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl +dnl Will try to compile a program checking the SUBMODULES Fortran support. +dnl +dnl Will use MPIFC, otherwise '$FC'. +dnl +dnl If the test passes, will execute ACTION-IF-FOUND. Otherwise, ACTION-IF-NOT-FOUND. +dnl Note : This file will be likely to induce the compiler to create a module file +dnl (for a module called conftest). +dnl Depending on the compiler flags, this could cause a conftest.mod file to appear +dnl in the present directory, or in another, or with another name. So be warned! +dnl +dnl @author Salvatore Filippone +AC_DEFUN(PAC_FORTRAN_TEST_SUBMODULES, +dnl Warning : square brackets are EVIL! +[AC_MSG_CHECKING([support for Fortran SUBMODULES]) +AC_LANG_PUSH([Fortran]) + ac_exeext='' + ac_ext='F90' + dnl ac_link='${MPIFC-$FC} -o conftest${ac_exeext} $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' + ac_fc=${MPIFC-$FC}; + AC_COMPILE_IFELSE([ +module conftest + + interface + module subroutine foo(v) + integer, intent(inout) :: v(:) + end subroutine foo + end interface +end module conftest +submodule (conftest) conftest_impl + +contains + module subroutine foo(v) + integer, intent(inout) :: v(:) + integer :: i + do i=1,size(v) + v(i)=i + end do + end subroutine foo +end submodule ], + [ AC_MSG_RESULT([yes]) + ifelse([$1], , :, [ $1])], + [ AC_MSG_RESULT([no]) + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD + ifelse([$2], , , [ $2])]) +AC_LANG_POP([Fortran]) +]) + + dnl @synopsis PAC_CHECK_BLACS dnl dnl Will try to find the BLACS diff --git a/configure b/configure index d13f8146..e6b1d36f 100755 --- a/configure +++ b/configure @@ -8110,7 +8110,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for TR15581. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8159,7 +8159,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for EXTENDS. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8224,7 +8224,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for CLASS and type bound procedures. - Please get a Fortran compiler that supports them, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports them, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8275,7 +8275,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for SOURCE= allocation. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8316,7 +8316,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for MOVE_ALLOC. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8356,7 +8356,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for ISO_C_BINDING. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8407,7 +8407,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for SAME_TYPE_AS. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8456,7 +8456,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for EXTENDS_TYPE_OF. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8507,7 +8507,7 @@ printf "%s\n" "no" >&6; } echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 as_fn_error $? "Sorry, cannot build PSBLAS without support for MOLD= allocation. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8." "$LINENO" 5 + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; esac fi @@ -8520,6 +8520,61 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking support for Fortran SUBMODULES" >&5 +printf %s "checking support for Fortran SUBMODULES... " >&6; } +ac_ext=${ac_fc_srcext-f} +ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' +ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_fc_compiler_gnu + + ac_exeext='' + ac_ext='F90' + ac_fc=${MPIFC-$FC}; + cat > conftest.$ac_ext <<_ACEOF + +module conftest + + interface + module subroutine foo(v) + integer, intent(inout) :: v(:) + end subroutine foo + end interface +end module conftest +submodule (conftest) conftest_impl + +contains + module subroutine foo(v) + integer, intent(inout) :: v(:) + integer :: i + do i=1,size(v) + v(i)=i + end do + end subroutine foo +end submodule +_ACEOF +if ac_fn_fc_try_compile "$LINENO" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + : +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + as_fn_error $? "Sorry, cannot build without support for SUBMODULES. + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0." "$LINENO" 5 ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking support for Fortran VOLATILE" >&5 printf %s "checking support for Fortran VOLATILE... " >&6; } ac_ext=${ac_fc_srcext-f} diff --git a/configure.ac b/configure.ac index 38360bf2..eb645bdb 100644 --- a/configure.ac +++ b/configure.ac @@ -599,55 +599,61 @@ fi PAC_FORTRAN_TEST_TR15581( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for TR15581. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_EXTENDS( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for EXTENDS. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_CLASS_TBP( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for CLASS and type bound procedures. - Please get a Fortran compiler that supports them, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports them, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_SOURCE( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for SOURCE= allocation. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_HAVE_MOVE_ALLOC( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for MOVE_ALLOC. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_ISO_C_BIND( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for ISO_C_BINDING. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_SAME_TYPE( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for SAME_TYPE_AS. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_EXTENDS_TYPE( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for EXTENDS_TYPE_OF. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] ) PAC_FORTRAN_TEST_MOLD( [], [AC_MSG_ERROR([Sorry, cannot build PSBLAS without support for MOLD= allocation. - Please get a Fortran compiler that supports it, e.g. GNU Fortran 4.8.])] + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])] +) + +PAC_FORTRAN_TEST_SUBMODULES( + [], + [AC_MSG_ERROR([Sorry, cannot build without support for SUBMODULES. + Please get a Fortran compiler that supports it, e.g. GNU Fortran 6.0.])], ) PAC_FORTRAN_TEST_VOLATILE(