From 85222a24be31277ce33e30863f9097aecbb8b9f3 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 17 Aug 2026 16:34:55 -0500 Subject: [PATCH 01/39] spellcheck: skip word indx We use indx instead of index because often index is a keyword. --- maint/spellcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maint/spellcheck.sh b/maint/spellcheck.sh index 92642685052..a379dce3e7d 100755 --- a/maint/spellcheck.sh +++ b/maint/spellcheck.sh @@ -4,7 +4,7 @@ ## See COPYRIGHT in top-level directory ## -skip_words="inout,improbe,nd,alse,ans,parm,parms,stange,faught,gord,sur,hellow,creat,outweights,configury,numer,thrid,offsetp,wronly" +skip_words="inout,improbe,nd,alse,ans,parm,parms,stange,faught,gord,sur,hellow,creat,outweights,configury,numer,thrid,offsetp,wronly,indx" skip_files=".git,*.tex,*.bib,*.sty,*.f,confdb/config.*" opts=(--ignore-words-list="$skip_words" --skip="$skip_files" --write-changes) From 3763ca3436989c0ceb24fe97837b13ef5582381d Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 13 May 2026 13:55:16 -0500 Subject: [PATCH 02/39] datatype: fix MPIR_Abi_set_fortran_info_impl We need set the last 8 bits of the internal type to the index of the original builtin type, or we will lose the original names. --- src/mpi/datatype/typeutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mpi/datatype/typeutil.c b/src/mpi/datatype/typeutil.c index 990fb4f2113..abc14dce781 100644 --- a/src/mpi/datatype/typeutil.c +++ b/src/mpi/datatype/typeutil.c @@ -576,7 +576,7 @@ int MPIR_Abi_set_fortran_info_impl(MPIR_Info * info) str_val = MPIR_Info_lookup(info, keyname); \ if (str_val && strcmp(str_val, "true") == 0) { \ int i = (mpi_type) & 0xff; \ - MPIR_Internal_types[i].internal_type = mpir_type; \ + MPIR_Internal_types[i].internal_type = mpir_type | i; \ } \ } while (0) SET_TYPE_SUPPORTED(MPI_LOGICAL1, "mpi_logical1_supported", MPIR_INT8); From d95efcdad7d8e597571318fcc4cea4ef7af49524 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Thu, 1 Jan 2026 12:35:34 -0600 Subject: [PATCH 03/39] romio: call AC_USE_SYSTEM_EXTENSIONS early Autoconf complains that we can't call AC_USE_SYSTEM_EXTENSIONS after PAC_CHECK_VISIBILITY. --- src/mpi/romio/configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mpi/romio/configure.ac b/src/mpi/romio/configure.ac index cdf838f6573..45f3eb2c67d 100644 --- a/src/mpi/romio/configure.ac +++ b/src/mpi/romio/configure.ac @@ -32,10 +32,11 @@ AM_MAINTAINER_MODE([enable]) dnl must come before LT_INIT, which AC_REQUIREs AC_PROG_CC AC_PROG_CC AM_PROG_CC_C_O +AC_USE_SYSTEM_EXTENSIONS + PAC_CHECK_VISIBILITY AC_SUBST(VISIBILITY_CFLAGS) -AC_USE_SYSTEM_EXTENSIONS PAC_C_NO_COMMON AM_PROG_AR From e46963e28d49bf34078cf76b8bc6d56371c1e50f Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 29 Dec 2025 11:07:36 -0600 Subject: [PATCH 04/39] abi: only build mpi abi with --enable-mpi-abi Instead of build both mpich abi and mpi abi, only build a single library with --enable-mpi-abi. If configured with --enable-mpi-abi, we only install libmpi_abi.so and mpi.h will be a link to mpi_abi.h. Compiler scripts such as mpicc no longer supports -mpi-abi option. It will either link to libmpi.so or libmpi_abi.so based on the configure option. --- Makefile.am | 72 +++++++++++++++++++-------------------- configure.ac | 30 ++++++++++------ src/env/mpicc.def | 24 ++----------- src/include/Makefile.mk | 7 +++- src/mpi/romio/Makefile.am | 35 ++++++++++--------- 5 files changed, 83 insertions(+), 85 deletions(-) diff --git a/Makefile.am b/Makefile.am index 44fc74d15d1..1e05a9b5f6f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -101,8 +101,7 @@ endif BUILD_F77_BINDING ## lib@PMPILIBNAME@ (which is the same as lib@MPILIBNAME@ on systems ## that support weak symbols). ## -## mpi_abi_sources: similar to mpi_sources, but used to compile -## lib@MPIABILIBNAME@. +## mpi_abi_sources: similar to mpi_sources, but used if BUILD_ABI_LIB. ## ## mpi_cxx_sources: When compiled with -DMPICH_MPI_FROM_PMPI, these ## files provide the "MPI" public functions for the C++ bindings and @@ -124,10 +123,14 @@ lib_LTLIBRARIES = include src/Makefile.mk include packaging/Makefile.mk +if ! BUILD_ABI_LIB if BUILD_PROFILING_LIB +# -------- mpich-abi: libpmpi + libmpi ------------------ +# lib_LTLIBRARIES += lib/lib@PMPILIBNAME@.la lib_lib@PMPILIBNAME@_la_SOURCES = $(mpi_sources) $(mpi_core_sources) lib_lib@PMPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABIVERSIONFLAGS) +lib_lib@PMPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) lib_lib@PMPILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(mpi_convenience_libs) EXTRA_lib_lib@PMPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(mpi_convenience_libs) @@ -141,7 +144,8 @@ lib_lib@MPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPICH_MPI_FROM_PMPI lib_lib@MPILIBNAME@_la_LIBADD = lib/lib@PMPILIBNAME@.la else !BUILD_PROFILING_LIB - +# -------- mpich-abi: libmpi ------------------ +# lib_LTLIBRARIES += lib/lib@MPILIBNAME@.la lib_lib@MPILIBNAME@_la_SOURCES = $(mpi_sources) $(mpi_core_sources) lib_lib@MPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABIVERSIONFLAGS) @@ -151,35 +155,38 @@ EXTRA_lib_lib@MPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(mpi_conve endif !BUILD_PROFILING_LIB -if BUILD_ABI_LIB +else BUILD_ABI_LIB abi_cppflags = -DMPICH_BUILD_MPI_ABI -I$(srcdir)/src/binding/abi if BUILD_PROFILING_LIB +# -------- mpi-abi: libpmpi + libmpi ------------------ +# # dropping mpi_fc_sources and mpi_cxx_sources from libmpmpi since they # don't contribute any PMPI symbols. -lib_LTLIBRARIES += lib/lib@PMPIABILIBNAME@.la -lib_lib@PMPIABILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_f77_sources) $(mpi_core_sources) $(mpi_abi_core_sources) -lib_lib@PMPIABILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABI_ABIVERSIONFLAGS) -lib_lib@PMPIABILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DF77_USE_PMPI $(abi_cppflags) -lib_lib@PMPIABILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(abi_convenience_libs) -EXTRA_lib_lib@PMPIABILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_convenience_libs) - -# lib@MPIABILIBNAME@.la might depend on lib@PMPIABILIBNAME@.la. We add them +lib_LTLIBRARIES += lib/lib@PMPILIBNAME@.la +lib_lib@PMPILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_f77_sources) $(mpi_core_sources) $(mpi_abi_core_sources) +lib_lib@PMPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABI_ABIVERSIONFLAGS) +lib_lib@PMPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DF77_USE_PMPI $(abi_cppflags) +lib_lib@PMPILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(abi_convenience_libs) +EXTRA_lib_lib@PMPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_convenience_libs) + +# lib@MPILIBNAME@.la might depend on lib@PMPILIBNAME@.la. We add them # in that order to lib_LTLIBRARIES so libtool doesn't get # confused. (see https://bugzilla.redhat.com/show_bug.cgi?id=91110) -lib_LTLIBRARIES += lib/lib@MPIABILIBNAME@.la -lib_lib@MPIABILIBNAME@_la_SOURCES = $(mpi_abi_sources) -lib_lib@MPIABILIBNAME@_la_LDFLAGS = $(ABI_ABIVERSIONFLAGS) -lib_lib@MPIABILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPICH_MPI_FROM_PMPI $(abi_cppflags) -lib_lib@MPIABILIBNAME@_la_LIBADD = lib/lib@PMPIABILIBNAME@.la +lib_LTLIBRARIES += lib/lib@MPILIBNAME@.la +lib_lib@MPILIBNAME@_la_SOURCES = $(mpi_abi_sources) +lib_lib@MPILIBNAME@_la_LDFLAGS = $(ABI_ABIVERSIONFLAGS) +lib_lib@MPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPICH_MPI_FROM_PMPI $(abi_cppflags) +lib_lib@MPILIBNAME@_la_LIBADD = lib/lib@PMPILIBNAME@.la else !BUILD_PROFILING_LIB - -lib_LTLIBRARIES += lib/lib@MPIABILIBNAME@.la -lib_lib@MPIABILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_core_sources) $(mpi_abi_core_sources) -lib_lib@MPIABILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABI_ABIVERSIONFLAGS) -lib_lib@MPIABILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) $(abi_cppflags) -lib_lib@MPIABILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(abi_convenience_libs) -EXTRA_lib_lib@MPIABILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_convenience_libs) +# -------- mpi-abi: libmpi ------------------ +# +lib_LTLIBRARIES += lib/lib@MPILIBNAME@.la +lib_lib@MPILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_core_sources) $(mpi_abi_core_sources) +lib_lib@MPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABI_ABIVERSIONFLAGS) +lib_lib@MPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) $(abi_cppflags) +lib_lib@MPILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(abi_convenience_libs) +EXTRA_lib_lib@MPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_convenience_libs) endif !BUILD_PROFILING_LIB endif BUILD_ABI_LIB @@ -194,12 +201,14 @@ lib_lib@MPIFCLIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS) @FCLIB_LDFLAGS@ lib_lib@MPIFCLIBNAME@_la_LIBADD = lib/lib@MPILIBNAME@.la $(mpifort_convenience_libs) endif BUILD_F77_BINDING +if ! BUILD_ABI_LIB if BUILD_CXX_BINDING lib_LTLIBRARIES += lib/lib@MPICXXLIBNAME@.la lib_lib@MPICXXLIBNAME@_la_SOURCES = $(mpi_cxx_sources) lib_lib@MPICXXLIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS) lib_lib@MPICXXLIBNAME@_la_LIBADD = lib/lib@MPILIBNAME@.la endif BUILD_CXX_BINDING +endif ! BUILD_ABI_LIB # build the current directory and then the examples directory after everything else SUBDIRS += . examples @@ -243,6 +252,9 @@ install-exec-hook: cd ${DESTDIR}${bindir} && ln -f -s @MPICXX_NAME@ @MPICPP_NAME@ ; \ fi ; \ fi ; +if BUILD_ABI_LIB + cd ${DESTDIR}${includedir} && ln -sf mpi_abi.h mpi.h ; +endif BUILD_ABI_LIB if BUILD_FC_BINDING if INSTALL_MPIF90 if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ @@ -261,18 +273,6 @@ if INSTALL_MPIF77 fi ; endif INSTALL_MPIF77 endif BUILD_F77_BINDING -if BUILD_ABI_LIB - if test -e ${DESTDIR}${bindir}/@MPICC_NAME@ ; then \ - if test "@MPICC_NAME@" != "@MPICC_ABI_NAME@" ; then \ - cd ${DESTDIR}${bindir} && ln -f -s @MPICC_NAME@ @MPICC_ABI_NAME@ ; \ - fi ; \ - fi ; \ - if test -e ${DESTDIR}${bindir}/@MPICXX_NAME@ ; then \ - if test "@MPICXX_NAME@" != "@MPICXX_ABI_NAME@" ; then \ - cd ${DESTDIR}${bindir} && ln -f -s @MPICXX_NAME@ @MPICXX_ABI_NAME@ ; \ - fi ; \ - fi ; -endif BUILD_ABI_LIB if test -e ${DESTDIR}${libdir}/lib@MPILIBNAME@@SHLIB_EXT@ ; then \ if test "@MPILIBNAME@" != "mpl" ; then \ cd ${DESTDIR}${libdir} && ln -f -s lib@MPILIBNAME@@SHLIB_EXT@ libmpl@SHLIB_EXT@ ; \ diff --git a/configure.ac b/configure.ac index 988cd33c22b..6d00d3963b9 100644 --- a/configure.ac +++ b/configure.ac @@ -496,6 +496,11 @@ AC_ARG_ENABLE(mpi-abi, AS_HELP_STRING([--enable-mpi-abi], [Enable building libmpi_abi.so]),, enable_mpi_abi=no) AM_CONDITIONAL([BUILD_ABI_LIB], [test "$enable_mpi_abi" = "yes"]) +AC_SUBST(enable_mpi_abi) + +if test "$enable_mpi_abi" = "yes" ; then + enable_cxx=no +fi ## Enable creation of libtool-style versioning or no versioning AC_ARG_ENABLE(versioning, @@ -906,21 +911,24 @@ m4_map([PAC_SUBCFG_DO_PREREQ], [PAC_SUBCFG_MODULE_LIST]) # Set default library names if names haven't already been provided AC_ARG_VAR([MPILIBNAME],[can be used to override the name of the MPI library (default: "mpi")]) AC_ARG_VAR([PMPILIBNAME],[can be used to override the name of the MPI profiling library (default: "p$MPILIBNAME")]) -AC_ARG_VAR([MPIABILIBNAME],[can be used to override the name of the MPI library (default: "mpi_abi")]) -AC_ARG_VAR([PMPIABILIBNAME],[can be used to override the name of the MPI profiling library (default: "p$MPIABILIBNAME")]) AC_ARG_VAR([MPICXXLIBNAME],[can be used to override the name of the MPI C++ library (default: "${MPILIBNAME}cxx")]) AC_ARG_VAR([MPIFCLIBNAME],[can be used to override the name of the MPI fortran library (default: "${MPILIBNAME}fort")]) -MPILIBNAME=${MPILIBNAME:-"mpi"} + +if test "$enable_mpi_abi" = "yes" ; then + MPILIBNAME=${MPILIBNAME:-"mpi_abi"} +else + MPILIBNAME=${MPILIBNAME:-"mpi"} +fi + # ROMIO is configured as a subdirectory and needs the resolved library name # when building its legacy tests against the top-level build tree. export MPILIBNAME + PMPILIBNAME_set=no if test -n "$PMPILIBNAME" ; then PMPILIBNAME_set=yes fi PMPILIBNAME=${PMPILIBNAME:-"p$MPILIBNAME"} -MPIABILIBNAME=${MPIABILIBNAME:-"mpi_abi"} -PMPIABILIBNAME=${PMPIABILIBNAME:-"p$MPIABILIBNAME"} # Note that the name for this library may be updated after we check for # enable_shmem # Fortran names are set later. @@ -3809,15 +3817,11 @@ fi # Setup other replaceable values AC_SUBST(MPILIBNAME) AC_SUBST(PMPILIBNAME) -AC_SUBST(MPIABILIBNAME) -AC_SUBST(PMPIABILIBNAME) if test "$NEEDSPLIB" = "yes" ; then LPMPILIBNAME="-l${PMPILIBNAME}" - LPMPIABILIBNAME="-l${PMPIABILIBNAME}" fi AC_SUBST(LPMPILIBNAME) -AC_SUBST(LPMPIABILIBNAME) if test "enable_cxx" = "yes" -a "$enable_mpi_abi" = "no" -a x"$MPICXXLIBNAME" != x"$MPILIBNAME" ; then LMPICXXLIBNAME="-l${MPICXXLIBNAME}" @@ -4363,12 +4367,18 @@ if test "$enable_f08" = "yes" ; then fi AC_OUTPUT -# TODO: add info about MPI ABI +if test "$enable_mpi_abi" = "yes" ; then + ABI_INFO="MPI ABI 1.0" +else + ABI_INFO="MPICH ABI" +fi cat < Date: Mon, 11 May 2026 16:50:50 -0500 Subject: [PATCH 05/39] configure: clean up setting of ABIVERSIONFLAGS Gather the code and remove leftovers from simplemake. Only define $ABIVERSIONFLAGS since now we only build one ABI. --- Makefile.am | 6 +++--- configure.ac | 18 +++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1e05a9b5f6f..3daae7612db 100644 --- a/Makefile.am +++ b/Makefile.am @@ -164,7 +164,7 @@ if BUILD_PROFILING_LIB # don't contribute any PMPI symbols. lib_LTLIBRARIES += lib/lib@PMPILIBNAME@.la lib_lib@PMPILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_f77_sources) $(mpi_core_sources) $(mpi_abi_core_sources) -lib_lib@PMPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABI_ABIVERSIONFLAGS) +lib_lib@PMPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABIVERSIONFLAGS) lib_lib@PMPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DF77_USE_PMPI $(abi_cppflags) lib_lib@PMPILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(abi_convenience_libs) EXTRA_lib_lib@PMPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_convenience_libs) @@ -174,7 +174,7 @@ EXTRA_lib_lib@PMPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_conv # confused. (see https://bugzilla.redhat.com/show_bug.cgi?id=91110) lib_LTLIBRARIES += lib/lib@MPILIBNAME@.la lib_lib@MPILIBNAME@_la_SOURCES = $(mpi_abi_sources) -lib_lib@MPILIBNAME@_la_LDFLAGS = $(ABI_ABIVERSIONFLAGS) +lib_lib@MPILIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS) lib_lib@MPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPICH_MPI_FROM_PMPI $(abi_cppflags) lib_lib@MPILIBNAME@_la_LIBADD = lib/lib@PMPILIBNAME@.la @@ -183,7 +183,7 @@ else !BUILD_PROFILING_LIB # lib_LTLIBRARIES += lib/lib@MPILIBNAME@.la lib_lib@MPILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_core_sources) $(mpi_abi_core_sources) -lib_lib@MPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABI_ABIVERSIONFLAGS) +lib_lib@MPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABIVERSIONFLAGS) lib_lib@MPILIBNAME@_la_CPPFLAGS = $(AM_CPPFLAGS) $(abi_cppflags) lib_lib@MPILIBNAME@_la_LIBADD = $(external_libs) $(pmpi_convenience_libs) $(abi_convenience_libs) EXTRA_lib_lib@MPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_convenience_libs) diff --git a/configure.ac b/configure.ac index 6d00d3963b9..7eef19aadf6 100644 --- a/configure.ac +++ b/configure.ac @@ -121,9 +121,6 @@ MPICH_VERSION=MPICH_VERSION_m4 AC_SUBST([MPICH_VERSION]) MPICH_RELEASE_DATE="MPICH_RELEASE_DATE_m4" AC_SUBST([MPICH_RELEASE_DATE]) -libmpi_so_version="libmpi_so_version_m4" -AC_SUBST([libmpi_so_version]) - if test -z "$MPICH_VERSION" ; then AC_MSG_ERROR([MPICH_VERSION is empty, check maint/version.m4 for errors]) @@ -183,13 +180,6 @@ AC_ARG_WITH(custom-version-string, MPICH_CUSTOM_STRING=$with_custom_version_string AC_SUBST(MPICH_CUSTOM_STRING) -# ABIVERSION is the name used by simplemake, so we reassign the -# libmpi_so_version number to it -ABIVERSION=${libmpi_so_version} -export ABIVERSION -export libmpi_so_version -AC_SUBST(ABIVERSION) - # Print out the configure options CONFIGURE_ARGUMENTS="$ac_configure_args" AC_SUBST(CONFIGURE_ARGUMENTS) @@ -508,11 +498,13 @@ AC_ARG_ENABLE(versioning, [enable_versioning=yes]) if test "$enable_versioning" = "yes" ; then - ABIVERSIONFLAGS="-version-info \$(ABIVERSION)" - ABI_ABIVERSIONFLAGS="-version-info libmpi_abi_so_version_m4" + if test "$enable_mpi_abi" = "yes" ; then + ABIVERSIONFLAGS="-version-info libmpi_abi_so_version_m4" + else + ABIVERSIONFLAGS="-version-info libmpi_so_version_m4" + fi else ABIVERSIONFLAGS="-avoid-version" - ABI_ABIVERSIONFLAGS="-avoid-version" fi export ABIVERSIONFLAGS AC_SUBST(ABIVERSIONFLAGS) From 1683f5d3a417e4811c6a895de19b50e4331f8881 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 31 Dec 2025 19:15:51 -0600 Subject: [PATCH 06/39] mpi.h: rename mpi.h.in to mpi_mpich.h.in Internally we will include mpi_mpich.h instead of mpi.h. On the other hand, mpi.h will be a copy from mpi_abi.h or mpi_mpich.h based on whether --enable-mpi-abi is configured. This allows examples as well as utilities (e.g. mpichversion and mpivars) to work when mpi-abi is enabled. --- .gitignore | 1 + Makefile.am | 3 --- configure.ac | 11 +++++++++-- maint/code-cleanup.bash | 1 + maint/extracterrmsgs | 2 +- maint/gen_binding_f08.py | 3 +-- maint/gen_binding_f77.py | 3 +-- src/binding/abi/Makefile.mk | 2 -- src/binding/cxx/Makefile.mk | 2 +- src/binding/cxx/buildiface | 4 ++-- src/include/Makefile.mk | 2 +- src/include/{mpi.h.in => mpi_mpich.h.in} | 6 ------ src/include/mpiimpl.h | 2 +- src/include/mpir_pointers.h | 2 +- src/include/mpir_refcount.h | 2 +- src/include/mpitimpl.h | 2 +- src/mpi/datatype/typerep/dataloop/dataloop.h | 3 --- src/mpid/ch3/channels/nemesis/include/mpid_nem_defs.h | 1 - src/mpid/ch4/netmod/ofi/ofi_pre.h | 1 - src/mpid/ch4/shm/posix/posix_pre.h | 1 - src/mpid/ch4/shm/src/shm_pre.h | 2 -- 21 files changed, 22 insertions(+), 34 deletions(-) rename src/include/{mpi.h.in => mpi_mpich.h.in} (99%) diff --git a/.gitignore b/.gitignore index 9ee19103b5d..6785b26f15e 100644 --- a/.gitignore +++ b/.gitignore @@ -478,6 +478,7 @@ Makefile.am-stamp # /src/include/ /src/include/mpi.h +/src/include/mpi_mpich.h /src/include/mpif.h #/src/include/mpe_thread.h /src/include/mpimod.pcl diff --git a/Makefile.am b/Makefile.am index 3daae7612db..7d756a270c4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -252,9 +252,6 @@ install-exec-hook: cd ${DESTDIR}${bindir} && ln -f -s @MPICXX_NAME@ @MPICPP_NAME@ ; \ fi ; \ fi ; -if BUILD_ABI_LIB - cd ${DESTDIR}${includedir} && ln -sf mpi_abi.h mpi.h ; -endif BUILD_ABI_LIB if BUILD_FC_BINDING if INSTALL_MPIF90 if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ diff --git a/configure.ac b/configure.ac index 7eef19aadf6..dac60b56aa4 100644 --- a/configure.ac +++ b/configure.ac @@ -805,7 +805,7 @@ PAC_C_CHECK_fPIE_OK # ----------------------------------------------------------------------------- # First check that we have a clean build if we are doing a VPATH build -PAC_VPATH_CHECK(src/include/mpi.h src/env/mpicc,lib) +PAC_VPATH_CHECK(src/include/mpi_mpich.h src/env/mpicc,lib) # ---------------------------------------------------------------------------- # This test is complicated by the fact that top_srcdir is not set until @@ -4323,6 +4323,13 @@ case "$host_os" in ;; esac +AC_CONFIG_COMMANDS([src/include/mpi.h],[ + if test "$enable_mpi_abi" = "yes" ; then + cp $srcdir/src/binding/abi/mpi_abi.h src/include/mpi.h + else + cp $srcdir/src/include/mpi_mpich.h src/include/mpi.h + fi], [enable_mpi_abi="$enable_mpi_abi"]) + dnl This includes an experimental pkgconfig file for ch3 in the src/pkgconfig dnl directory AC_CONFIG_FILES([Makefile \ @@ -4341,7 +4348,7 @@ AC_CONFIG_FILES([Makefile \ src/env/mpifort.sh \ src/env/mpifort.bash \ src/env/parkill \ - src/include/mpi.h \ + src/include/mpi_mpich.h \ doc/installguide/Makefile \ doc/refman/Makefile \ doc/userguide/Makefile \ diff --git a/maint/code-cleanup.bash b/maint/code-cleanup.bash index 51cd16fbb38..df7ec597c70 100755 --- a/maint/code-cleanup.bash +++ b/maint/code-cleanup.bash @@ -124,6 +124,7 @@ ignore_list="$ignore_list|test/mpi/f77/pt2pt/attr1aints.h.in" ignore_list="$ignore_list|test/mpi/f77/rma/addsize.h.in" ignore_list="$ignore_list|test/mpi/f77/spawn/type1aint.h.in" ignore_list="$ignore_list|src/include/mpi.h.in" +ignore_list="$ignore_list|src/include/mpi_mpich.h.in" ignore_list="$ignore_list|src/mpi/romio/include/mpio.h.in" ignore_list="$ignore_list|src/mpi/romio/adio/include/adioi_errmsg.h" ignore_list="$ignore_list|src/pmi/include/pmix.h" diff --git a/maint/extracterrmsgs b/maint/extracterrmsgs index b8906ced257..56cdc830c3f 100755 --- a/maint/extracterrmsgs +++ b/maint/extracterrmsgs @@ -46,7 +46,7 @@ foreach my $k ("envvarparse", "cvar_val"){ } # Check for special args -my $mpi_h = "src/include/mpi.h.in"; +my $mpi_h = "src/include/mpi_mpich.h.in"; my $mpi_abi_h = "src/binding/abi/mpi_abi.h"; my $baseerrnames_txt = "src/mpi/errhan/baseerrnames.txt"; my @files = (); diff --git a/maint/gen_binding_f08.py b/maint/gen_binding_f08.py index 4c91e5de28c..f19339a4787 100644 --- a/maint/gen_binding_f08.py +++ b/maint/gen_binding_f08.py @@ -155,8 +155,7 @@ def main(): if G.is_autogen(): # mpi_f08_compile_constants.f90.in G.mpih_defines = {} - load_mpi_h_in("src/include/mpi.h.in") - load_mpi_h_in("src/mpi/romio/include/mpio.h.in") + load_mpi_h_in("src/include/mpi_mpich.h.in") f = "%s/mpi_f08_compile_constants.f90.in" % f08_dir dump_compile_constants_f90(f) diff --git a/maint/gen_binding_f77.py b/maint/gen_binding_f77.py index 0aed977ac24..8b011359110 100644 --- a/maint/gen_binding_f77.py +++ b/maint/gen_binding_f77.py @@ -50,8 +50,7 @@ def has_cptr(func): # .in files has to be generated in the source tree if G.is_autogen(): G.mpih_defines = {} - load_mpi_h_in("src/include/mpi.h.in") - load_mpi_h_in("src/mpi/romio/include/mpio.h.in") + load_mpi_h_in("src/include/mpi_mpich.h.in") f = "%s/mpif.h.in" % f77_dir dump_mpif_h(f) diff --git a/src/binding/abi/Makefile.mk b/src/binding/abi/Makefile.mk index a6ffbbcefa3..f8d8a5f13ec 100644 --- a/src/binding/abi/Makefile.mk +++ b/src/binding/abi/Makefile.mk @@ -5,8 +5,6 @@ if BUILD_ABI_LIB -include_HEADERS += src/binding/abi/mpi_abi.h - mpi_abi_sources += \ src/binding/abi/c_binding_abi.c \ src/binding/abi/io_abi.c diff --git a/src/binding/cxx/Makefile.mk b/src/binding/cxx/Makefile.mk index bac59949f82..e8a7f5f2ee7 100644 --- a/src/binding/cxx/Makefile.mk +++ b/src/binding/cxx/Makefile.mk @@ -13,7 +13,7 @@ cxx_buildiface_out_files = $(top_srcdir)/src/binding/cxx/mpicxx.h.in \ $(top_srcdir)/src/binding/cxx/initcxx.cxx if MAINTAINER_MODE $(cxx_buildiface_out_files): src/binding/cxx/buildiface-stamp -src/binding/cxx/buildiface-stamp: $(top_srcdir)/src/binding/cxx/buildiface $(top_srcdir)/src/include/mpi.h.in +src/binding/cxx/buildiface-stamp: $(top_srcdir)/src/binding/cxx/buildiface $(top_srcdir)/src/include/mpi_mpich.h.in ( cd $(top_srcdir)/src/binding/cxx && ./buildiface -nosep -initfile=./cxx.vlist ) endif MAINTAINER_MODE diff --git a/src/binding/cxx/buildiface b/src/binding/cxx/buildiface index 27ea570976c..a064a460ca1 100755 --- a/src/binding/cxx/buildiface +++ b/src/binding/cxx/buildiface @@ -519,7 +519,7 @@ $specialReturnType{"intra-Dup"} = "Intracomm"; %class_mpi2intra = ( #'Alltoallw' => 0, 'Exscan' => 0, # Because Spawn and Spawn_multiple have two different - # signaturs, they are handled as special cases. + # signatures, they are handled as special cases. 'Accept' => 'MPI_Comm', 'Connect' => 'MPI_Comm', ); @@ -2062,7 +2062,7 @@ sub build_specials { $files[$#files+1] = "initcxx.cxx"; &print_header; print $OUTFD "#include \"mpichconf.h\"\n"; # Requires for HAVE_FORTRAN_BINDING - print $OUTFD "#include \"mpi.h\"\n"; + print $OUTFD "#include \"mpi_mpich.h\"\n"; print $OUTFD "#include \n"; # Required for pcontrol # Add exception for coding style checker diff --git a/src/include/Makefile.mk b/src/include/Makefile.mk index 00a70d01088..b8594d8a35f 100644 --- a/src/include/Makefile.mk +++ b/src/include/Makefile.mk @@ -3,10 +3,10 @@ ## See COPYRIGHT in top-level directory ## -if !BUILD_ABI_LIB # nodist_ b/c these are created by config.status and should not be distributed nodist_include_HEADERS += src/include/mpi.h +if !BUILD_ABI_LIB include_HEADERS += src/include/mpi_proto.h endif !BUILD_ABI_LIB diff --git a/src/include/mpi.h.in b/src/include/mpi_mpich.h.in similarity index 99% rename from src/include/mpi.h.in rename to src/include/mpi_mpich.h.in index 49b73d4fba4..c3fb5646e95 100644 --- a/src/include/mpi.h.in +++ b/src/include/mpi_mpich.h.in @@ -3,11 +3,6 @@ * See COPYRIGHT in top-level directory */ -#ifdef MPI_ABI -#include "mpi_abi.h" -#include "mpix.h" -#else - /* @configure_input@ */ #ifndef MPI_INCLUDED #define MPI_INCLUDED @@ -1091,4 +1086,3 @@ int QMPI_Get_calling_address(QMPI_Context context, void **address) MPICH_API_PUB #endif #endif /* MPI_INCLUDED */ -#endif /* MPI_ABI */ diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h index 146c7ed607d..c3e771f192d 100644 --- a/src/include/mpiimpl.h +++ b/src/include/mpiimpl.h @@ -51,7 +51,7 @@ #endif #include "mpl.h" -#include "mpi.h" +#include "mpi_mpich.h" #include #include diff --git a/src/include/mpir_pointers.h b/src/include/mpir_pointers.h index febb24b2b3f..b2223002d87 100644 --- a/src/include/mpir_pointers.h +++ b/src/include/mpir_pointers.h @@ -6,7 +6,7 @@ #ifndef MPIR_POINTERS_H_INCLUDED #define MPIR_POINTERS_H_INCLUDED -#include "mpi.h" +#include "mpi_mpich.h" #include "mpichconf.h" #include "mpichconfconst.h" #include "mpir_assert.h" diff --git a/src/include/mpir_refcount.h b/src/include/mpir_refcount.h index f5e92c5c987..f747b62455b 100644 --- a/src/include/mpir_refcount.h +++ b/src/include/mpir_refcount.h @@ -6,7 +6,7 @@ #ifndef MPIR_REFCOUNT_H_INCLUDED #define MPIR_REFCOUNT_H_INCLUDED -#include "mpi.h" +#include "mpi_mpich.h" #include "mpichconf.h" #if MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE diff --git a/src/include/mpitimpl.h b/src/include/mpitimpl.h index c0973548391..f6f01569b51 100644 --- a/src/include/mpitimpl.h +++ b/src/include/mpitimpl.h @@ -9,7 +9,7 @@ #ifndef MPITIMPL_H_INCLUDED #define MPITIMPL_H_INCLUDED -#include "mpi.h" +#include "mpi_mpich.h" #include "mpir_strerror.h" #include "mpir_type_defs.h" #include "mpir_assert.h" diff --git a/src/mpi/datatype/typerep/dataloop/dataloop.h b/src/mpi/datatype/typerep/dataloop/dataloop.h index f97403d51b0..3e003ceddff 100644 --- a/src/mpi/datatype/typerep/dataloop/dataloop.h +++ b/src/mpi/datatype/typerep/dataloop/dataloop.h @@ -6,9 +6,6 @@ #ifndef DATALOOP_H_INCLUDED #define DATALOOP_H_INCLUDED -#include -#include - struct MPIR_Datatype; #define MPIR_DATALOOP_GET_LOOPPTR(a,lptr_) do { \ diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_defs.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_defs.h index 29cf8248bdd..68a5b13bd7a 100644 --- a/src/mpid/ch3/channels/nemesis/include/mpid_nem_defs.h +++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_defs.h @@ -7,7 +7,6 @@ #define MPID_NEM_DEFS_H_INCLUDED #include "mpid_nem_datatypes.h" -#include "mpi.h" #include "mpiimpl.h" #include "mpidu_init_shm.h" diff --git a/src/mpid/ch4/netmod/ofi/ofi_pre.h b/src/mpid/ch4/netmod/ofi/ofi_pre.h index bf8c6d51d64..d2b98153f6b 100644 --- a/src/mpid/ch4/netmod/ofi/ofi_pre.h +++ b/src/mpid/ch4/netmod/ofi/ofi_pre.h @@ -6,7 +6,6 @@ #ifndef OFI_PRE_H_INCLUDED #define OFI_PRE_H_INCLUDED -#include #include #include #include diff --git a/src/mpid/ch4/shm/posix/posix_pre.h b/src/mpid/ch4/shm/posix/posix_pre.h index 5d66814a52c..5afa54607c0 100644 --- a/src/mpid/ch4/shm/posix/posix_pre.h +++ b/src/mpid/ch4/shm/posix/posix_pre.h @@ -6,7 +6,6 @@ #ifndef POSIX_PRE_H_INCLUDED #define POSIX_PRE_H_INCLUDED -#include #include "release_gather_types.h" #define MPIDI_POSIX_MAX_AM_HDR_SIZE 800 /* constrained by MPIDI_POSIX_AM_HDR_POOL_CELL_SIZE */ diff --git a/src/mpid/ch4/shm/src/shm_pre.h b/src/mpid/ch4/shm/src/shm_pre.h index 00d76554416..4acefd47de5 100644 --- a/src/mpid/ch4/shm/src/shm_pre.h +++ b/src/mpid/ch4/shm/src/shm_pre.h @@ -6,8 +6,6 @@ #ifndef SHM_PRE_H_INCLUDED #define SHM_PRE_H_INCLUDED -#include - #include "../posix/posix_pre.h" #include "../ipc/src/ipc_pre.h" From 50b4b39a6d1c5084670440035a30d04cff78d144 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 22 Dec 2025 11:46:10 -0600 Subject: [PATCH 07/39] makefile: remove the mpich-specific installation links Since these links, including libmpl.so, libopa.so, libmpich.so, etc. are not in use any more, let's remove them. --- Makefile.am | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7d756a270c4..92147fe7b46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -270,30 +270,7 @@ if INSTALL_MPIF77 fi ; endif INSTALL_MPIF77 endif BUILD_F77_BINDING - if test -e ${DESTDIR}${libdir}/lib@MPILIBNAME@@SHLIB_EXT@ ; then \ - if test "@MPILIBNAME@" != "mpl" ; then \ - cd ${DESTDIR}${libdir} && ln -f -s lib@MPILIBNAME@@SHLIB_EXT@ libmpl@SHLIB_EXT@ ; \ - fi ; \ - if test "@MPILIBNAME@" != "opa" ; then \ - cd ${DESTDIR}${libdir} && ln -f -s lib@MPILIBNAME@@SHLIB_EXT@ libopa@SHLIB_EXT@ ; \ - fi ; \ - if test "@MPILIBNAME@" != "mpich" ; then \ - cd ${DESTDIR}${libdir} && ln -f -s lib@MPILIBNAME@@SHLIB_EXT@ libmpich@SHLIB_EXT@ ; \ - fi ; \ - fi ; \ - if test -e ${DESTDIR}${libdir}/lib@MPIFCLIBNAME@@SHLIB_EXT@ ; then \ - if test "@MPIFCLIBNAME@" != "fmpich" ; then \ - cd ${DESTDIR}${libdir} && ln -f -s lib@MPIFCLIBNAME@@SHLIB_EXT@ libfmpich@SHLIB_EXT@ ; \ - fi ; \ - if test "@MPIFCLIBNAME@" != "mpichf90" ; then \ - cd ${DESTDIR}${libdir} && ln -f -s lib@MPIFCLIBNAME@@SHLIB_EXT@ libmpichf90@SHLIB_EXT@ ; \ - fi ; \ - fi ; \ - if test -e ${DESTDIR}${libdir}/lib@MPICXXLIBNAME@@SHLIB_EXT@ ; then \ - if test "@MPICXXLIBNAME@" != "mpichcxx" ; then \ - cd ${DESTDIR}${libdir} && ln -f -s lib@MPICXXLIBNAME@@SHLIB_EXT@ libmpichcxx@SHLIB_EXT@ ; \ - fi ; \ - fi + # the configure step checks for the 'lib' dir to decide whether a source # directory has been previously used for an in-path build before allowing a From 89745ebb443d78a30f551c6be46dbd8f3e6227c4 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 23 Dec 2025 11:28:25 -0600 Subject: [PATCH 08/39] configure: remove devsubsystems and bindingsubsystems Both are no longer in use. Just use subsystems to simplify the configure design. --- configure.ac | 12 +++--------- src/mpid/ch3/channels/sock/subconfigure.m4 | 11 ----------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index dac60b56aa4..d2717055f6e 100644 --- a/configure.ac +++ b/configure.ac @@ -1422,7 +1422,7 @@ elif test -f $devicedir/subconfigure.m4 ; then : else # Add the device to the configure list - devsubsystems="$devsubsystems $devicereldir" + subsystems="$subsystems $devicereldir" # Make device_name available to subdirs fi @@ -2073,7 +2073,6 @@ libbuild_dir=$libbuild_dir bashWorks=$bashWorks) if test "$enable_f90" = "yes" ; then - bindingsubsystems="$bindingsubsystems src/binding/fortran/use_mpi" bindings="$bindings f90" PAC_APPEND_CSV([use mpi], [fortran_bindings]) fi @@ -3987,9 +3986,8 @@ fi dnl "configure" the device here via subconfigure.m4 files m4_map([PAC_SUBCFG_CONFIGURE_SUBSYS], [PAC_SUBCFG_MODULE_LIST]) -# now configure any actual recursively configures subsystems, such as ROMIO and -# hydra, or older components that haven't been updated to a subconfigure.m4 yet -for subsys in $devsubsystems $subsystems ; do +# We explicitly configure most modules now. $subsystems only contains hydra and nameserv/* (if configured). +for subsys in $subsystems ; do PAC_CONFIG_SUBDIR_ARGS([$subsys],[$subsys_config_args],[],[AC_MSG_ERROR([$subsys configure failed])]) done if test "$DEBUG_SUBDIR_CACHE" = yes -a "$enable_echo" != yes ; then @@ -3997,10 +3995,6 @@ if test "$DEBUG_SUBDIR_CACHE" = yes -a "$enable_echo" != yes ; then fi dnl PAC_SUBDIR_CACHE_CLEANUP -# Make subsystems available to makefiles. -# FIXME does the makefile actually need this? -subsystems="$devsubsystems $subsystems $bindingsubsystems" - # MPI_STATUS_SIZE is hardcoded and need to be synchronized with mpi.h MPI_STATUS_SIZE=5 AC_SUBST([MPI_STATUS_SIZE]) diff --git a/src/mpid/ch3/channels/sock/subconfigure.m4 b/src/mpid/ch3/channels/sock/subconfigure.m4 index 126fb80f749..7c07fd74db7 100644 --- a/src/mpid/ch3/channels/sock/subconfigure.m4 +++ b/src/mpid/ch3/channels/sock/subconfigure.m4 @@ -26,17 +26,6 @@ AC_DEFUN([PAC_SUBCFG_PREREQ_]PAC_SUBCFG_AUTO_SUFFIX,[ # $ac_configure_args - all arguments passed to configure # - found_dir="no" - for sys in $devsubsystems ; do - if test "$sys" = "src/mpid/common/sock" ; then - found_dir="yes" - break - fi - done - if test "$found_dir" = "no" ; then - devsubsystems="$devsubsystems src/mpid/common/sock" - fi - # FIXME: The setup file has a weird requirement that it needs to be # run *before* the MPICH device (not the setup directory itself) is # configured, but the actual configuration of the associated directory From c4467558998fee20870b1835edeabcd8707c4765 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 22 Dec 2025 12:30:24 -0600 Subject: [PATCH 09/39] configure: remove define of FORTRAN_BINDING This is only used in mpicxx.h. We don't need it now that we always define standard MPI Fortran datatypes in mpi.h. --- configure.ac | 13 ------------- src/binding/cxx/buildiface | 9 ++------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index d2717055f6e..00dcfeee9ec 100644 --- a/configure.ac +++ b/configure.ac @@ -933,9 +933,6 @@ export MPIFCLIBNAME AC_SUBST(MPICXXLIBNAME) AC_SUBST(MPIFCLIBNAME) -# We'll set FORTRAN_BINDING to 1 if we support Fortran -FORTRAN_BINDING=0 - # enable-fast # strip off multiple options, separated by commas save_IFS="$IFS" @@ -2043,9 +2040,6 @@ if test "$enable_f77" = "yes" ; then bindings="$bindings f77" PAC_APPEND_CSV([mpif.h], [fortran_bindings]) AC_DEFINE(HAVE_FORTRAN_BINDING,1,[Define if Fortran is supported]) - # Also define the name FORTRAN_BINDING for use in #if @FORTRAN_BINDING@.. - FORTRAN_BINDING=1 - fi dnl By modifying mpif.h to use ! for comments, it can work with many f90 @@ -2361,13 +2355,6 @@ if test "$enable_cxx" = "yes" ; then AC_DEFINE(HAVE_CXX_BINDING,1,[Define if C++ is supported]) INCLUDE_MPICXX_H='#include "mpicxx.h"' AC_SUBST(INCLUDE_MPICXX_H) - - # In order to support the Fortran datatypes within C++, - # - # FORTRAN_BINDING always has a CPP-time value of either 0 or 1, - # so that it may be used in #if statements without adding to - # the CPP name space - AC_SUBST(FORTRAN_BINDING) fi # we install mpicxx as long as CXX is defined. In the case of enable_cxx=no, diff --git a/src/binding/cxx/buildiface b/src/binding/cxx/buildiface index a064a460ca1..3b2b8e55cc6 100755 --- a/src/binding/cxx/buildiface +++ b/src/binding/cxx/buildiface @@ -1857,7 +1857,6 @@ sub PrintConstants { # Fortran types if ($giveValue) { print $OUTFD " -#ifdef HAVE_FORTRAN_BINDING Datatype INTEGER(MPI_INTEGER); Datatype REAL(MPI_REAL); Datatype DOUBLE_PRECISION(MPI_DOUBLE_PRECISION); @@ -1868,14 +1867,10 @@ Datatype CHARACTER(MPI_CHARACTER); Datatype TWOREAL(MPI_2REAL); Datatype TWODOUBLE_PRECISION(MPI_2DOUBLE_PRECISION); Datatype TWOINTEGER(MPI_2INTEGER); -#endif\n"; +\n"; } else { - # This is for the mpicxx.h.in file, so instead of assuming that - # we have mpichconf.h (which we do not, so as to keep the user's - # CPP name space clean), we directly set this value print $OUTFD " -#if \@FORTRAN_BINDING\@ extern Datatype INTEGER; extern Datatype REAL; extern Datatype DOUBLE_PRECISION; @@ -1886,7 +1881,7 @@ extern Datatype CHARACTER; extern Datatype TWOREAL; extern Datatype TWODOUBLE_PRECISION; extern Datatype TWOINTEGER; -#endif\n"; +\n"; } # Still to do: Fortran optional types, integer1,2,4, real2,4,8, From a0da35f7dd94be37768d7642653404888d70e96d Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 22 Dec 2025 15:03:25 -0600 Subject: [PATCH 10/39] datatype: set Fortran datatypes in mpirinitc_ Add MPIX_Init_fortran to initialize fortran datatypes. This is called from mpirinitc_ so Fortran applications will have the datatype initialized upon entry. TODO: add a mechanism for MPI_Init in libmpi.so to call MPIX_Init_fortran for those *C* programs that require Fortran interop such as MPI_Fint, xxx_f2c, etc. TODO: Call MPIX_Init_fortran for mpi_f08 module. --- configure.ac | 157 ++++++++++++---------- maint/local_python/binding_f77.py | 13 +- src/binding/fortran/mpif_h/mpi_fortimpl.h | 2 + src/binding/fortran/mpif_h/setbot.c.in | 101 ++++++++++++++ src/mpi/datatype/typeutil.c | 86 ++++++------ 5 files changed, 245 insertions(+), 114 deletions(-) diff --git a/configure.ac b/configure.ac index 00dcfeee9ec..e0cf00213dd 100644 --- a/configure.ac +++ b/configure.ac @@ -3015,12 +3015,96 @@ if test "$enable_f77" = yes ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*16 a])], pac_cv_fort_real16=yes, pac_cv_fort_real16=no)]) + AC_CACHE_CHECK([whether complex*4 is supported],pac_cv_fort_complex4,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*4 a])], + pac_cv_fort_complex4=yes, + pac_cv_fort_complex4=no)]) + AC_CACHE_CHECK([whether complex*8 is supported],pac_cv_fort_complex8,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*8 a])], + pac_cv_fort_complex8=yes, + pac_cv_fort_complex8=no)]) + AC_CACHE_CHECK([whether complex*16 is supported],pac_cv_fort_complex16,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*16 a])], + pac_cv_fort_complex16=yes, + pac_cv_fort_complex16=no)]) + AC_CACHE_CHECK([whether complex*32 is supported],pac_cv_fort_complex32,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*32 a])], + pac_cv_fort_complex32=yes, + pac_cv_fort_complex32=no)]) + AC_CACHE_CHECK([whether double precision is supported],pac_cv_fort_double_precision,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ double precision a])], + pac_cv_fort_double_precision=yes, + pac_cv_fort_double_precision=no)]) if test -z "$pac_cv_f77_sizeof_integer" -o \ "X$pac_cv_f77_sizeof_integer" = "X0" ; then AC_MSG_ERROR([Unable to configure with Fortran support because configure could not determine the size of a Fortran INTEGER. Consider setting CROSS_F77_SIZEOF_INTEGER to the length in bytes of a Fortran INTEGER]) fi + AC_DEFINE_UNQUOTED([MPI_CHARACTER_SIZE], [$pac_cv_f77_sizeof_character], [Define the size of Fortran CHARACTER]) + AC_DEFINE_UNQUOTED([MPI_LOGICAL_SIZE], [$pac_cv_f77_sizeof_logical], [Define the size of Fortran LOGICAL]) + AC_DEFINE_UNQUOTED([MPI_INTEGER_SIZE], [$pac_cv_f77_sizeof_integer], [Define the size of Fortran INTEGER]) + AC_DEFINE_UNQUOTED([MPI_REAL_SIZE], [$pac_cv_f77_sizeof_real], [Define the size of Fortran REAL]) + AC_DEFINE_UNQUOTED([MPI_DOUBLE_PRECISION_SIZE], [$pac_cv_f77_sizeof_double_precision], [Define the size of Fortran DOUBLE PRECISION]) + + if test "$pac_cv_fort_double_precision" = "yes"; then + AC_DEFINE([MPI_DOUBLE_PRECISION_SUPPORTED], [1], [Define if Fortran DOUBLE PRECISION is supported]) + fi + if test "$pac_cv_fort_logical1" = "yes"; then + AC_DEFINE([MPI_LOGICAL1_SUPPORTED], [1], [Define if Fortran LOGICAL*1 is supported]) + fi + if test "$pac_cv_fort_logical2" = "yes"; then + AC_DEFINE([MPI_LOGICAL2_SUPPORTED], [1], [Define if Fortran LOGICAL*2 is supported]) + fi + if test "$pac_cv_fort_logical4" = "yes"; then + AC_DEFINE([MPI_LOGICAL4_SUPPORTED], [1], [Define if Fortran LOGICAL*4 is supported]) + fi + if test "$pac_cv_fort_logical8" = "yes"; then + AC_DEFINE([MPI_LOGICAL8_SUPPORTED], [1], [Define if Fortran LOGICAL*8 is supported]) + fi + if test "$pac_cv_fort_logical16" = "yes"; then + AC_DEFINE([MPI_LOGICAL16_SUPPORTED], [1], [Define if Fortran LOGICAL*16 is supported]) + fi + if test "$pac_cv_fort_integer1" = "yes"; then + AC_DEFINE([MPI_INTEGER1_SUPPORTED], [1], [Define if Fortran INTEGER*1 is supported]) + fi + if test "$pac_cv_fort_integer2" = "yes"; then + AC_DEFINE([MPI_INTEGER2_SUPPORTED], [1], [Define if Fortran INTEGER*2 is supported]) + fi + if test "$pac_cv_fort_integer4" = "yes"; then + AC_DEFINE([MPI_INTEGER4_SUPPORTED], [1], [Define if Fortran INTEGER*4 is supported]) + fi + if test "$pac_cv_fort_integer8" = "yes"; then + AC_DEFINE([MPI_INTEGER8_SUPPORTED], [1], [Define if Fortran INTEGER*8 is supported]) + fi + if test "$pac_cv_fort_integer16" = "yes"; then + AC_DEFINE([MPI_INTEGER16_SUPPORTED], [1], [Define if Fortran INTEGER*16 is supported]) + fi + if test "$pac_cv_fort_real2" = "yes"; then + AC_DEFINE([MPI_REAL2_SUPPORTED], [1], [Define if Fortran REAL*2 is supported]) + fi + if test "$pac_cv_fort_real4" = "yes"; then + AC_DEFINE([MPI_REAL4_SUPPORTED], [1], [Define if Fortran REAL*4 is supported]) + fi + if test "$pac_cv_fort_real8" = "yes"; then + AC_DEFINE([MPI_REAL8_SUPPORTED], [1], [Define if Fortran REAL*8 is supported]) + fi + if test "$pac_cv_fort_real16" = "yes"; then + AC_DEFINE([MPI_REAL16_SUPPORTED], [1], [Define if Fortran REAL*16 is supported]) + fi + if test "$pac_cv_fort_complex4" = "yes"; then + AC_DEFINE([MPI_COMPLEX4_SUPPORTED], [1], [Define if Fortran COMPLEX*4 is supported]) + fi + if test "$pac_cv_fort_complex8" = "yes"; then + AC_DEFINE([MPI_COMPLEX8_SUPPORTED], [1], [Define if Fortran COMPLEX*8 is supported]) + fi + if test "$pac_cv_fort_complex16" = "yes"; then + AC_DEFINE([MPI_COMPLEX16_SUPPORTED], [1], [Define if Fortran COMPLEX*16 is supported]) + fi + if test "$pac_cv_fort_complex32" = "yes"; then + AC_DEFINE([MPI_COMPLEX32_SUPPORTED], [1], [Define if Fortran COMPLEX*32 is supported]) + fi + # Provide the corresponding C types for MPI_INTEGER AC_MSG_CHECKING([for C type matching Fortran integer]) get_c_int_type $pac_cv_f77_sizeof_integer @@ -3466,66 +3550,6 @@ AC_DEFINE_UNQUOTED([MPIR_2INT_INTERNAL], [MPIR_2INT$len], [Internal typ AC_DEFINE_UNQUOTED([MPIR_SIGNED_CHAR_INTERNAL], [MPIR_INT8], [Internal type for MPI_SIGNED_CHAR]) len=`expr $ac_cv_sizeof_long_long \* 8` AC_DEFINE_UNQUOTED([MPIR_UNSIGNED_LONG_LONG_INTERNAL],[MPIR_UINT$len], [Internal type for MPI_UNSIGNED_LONG_LONG]) -if test "$enable_f77" = "yes" ; then - len=`expr $pac_cv_f77_sizeof_character \* 8` - AC_DEFINE_UNQUOTED([MPIR_CHARACTER_INTERNAL], [MPIR_INT$len], [Internal type for MPI_CHARACTER]) - len=`expr $pac_cv_f77_sizeof_integer \* 8` - AC_DEFINE_UNQUOTED([MPIR_INTEGER_INTERNAL], [MPIR_INT$len], [Internal type for MPI_INTEGER]) - len=`expr $pac_cv_f77_sizeof_real \* 8` - AC_DEFINE_UNQUOTED([MPIR_REAL_INTERNAL], [MPIR_FLOAT$len], [Internal type for MPI_REAL]) - len=`expr $pac_cv_f77_sizeof_logical \* 8` - AC_DEFINE_UNQUOTED([MPIR_LOGICAL_INTERNAL], [MPIR_FORTRAN_LOGICAL$len], [Internal type for MPI_LOGICAL]) - len=`expr $pac_cv_f77_sizeof_real \* 8` - AC_DEFINE_UNQUOTED([MPIR_COMPLEX_INTERNAL], [MPIR_COMPLEX$len], [Internal type for MPI_COMPLEX]) - len=`expr $pac_cv_f77_sizeof_double_precision \* 8` - AC_DEFINE_UNQUOTED([MPIR_DOUBLE_PRECISION_INTERNAL],[MPIR_FLOAT$len], [Internal type for MPI_DOUBLE_PRECISION]) - len=`expr $pac_cv_f77_sizeof_integer \* 8` - AC_DEFINE_UNQUOTED([MPIR_2INTEGER_INTERNAL], [MPIR_2INT$len], [Internal type for MPI_2INTEGER]) - len=`expr $pac_cv_f77_sizeof_real \* 8` - AC_DEFINE_UNQUOTED([MPIR_2REAL_INTERNAL], [MPIR_2FLOAT$len], [Internal type for MPI_2REAL]) - len=`expr $pac_cv_f77_sizeof_double_precision \* 8` - AC_DEFINE_UNQUOTED([MPIR_DOUBLE_COMPLEX_INTERNAL],[MPIR_COMPLEX$len], [Internal type for MPI_DOUBLE_COMPLEX]) - AC_DEFINE_UNQUOTED([MPIR_2DOUBLE_PRECISION_INTERNAL],[MPIR_2FLOAT$len], [Internal type for MPI_2DOUBLE_PRECISION]) - # skip MPI_2COMPLEX, MPI_2DOUBLE_COMPLEX - AC_DEFINE_UNQUOTED([MPIR_REAL2_INTERNAL], [MPIR_FLOAT16], [Internal type for MPI_REAL2]) - AC_DEFINE_UNQUOTED([MPIR_REAL4_INTERNAL], [MPIR_FLOAT32], [Internal type for MPI_REAL4]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX8_INTERNAL], [MPIR_COMPLEX32], [Internal type for MPI_COMPLEX8]) - AC_DEFINE_UNQUOTED([MPIR_REAL8_INTERNAL], [MPIR_FLOAT64], [Internal type for MPI_REAL8]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX16_INTERNAL], [MPIR_COMPLEX64], [Internal type for MPI_COMPLEX16]) - AC_DEFINE_UNQUOTED([MPIR_REAL16_INTERNAL], [MPIR_FLOAT128], [Internal type for MPI_REAL16]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX32_INTERNAL], [MPIR_COMPLEX128], [Internal type for MPI_COMPLEX32]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER1_INTERNAL], [MPIR_INT8], [Internal type for MPI_INTEGER1]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX4_INTERNAL], [MPIR_COMPLEX16], [Internal type for MPI_COMPLEX4]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER2_INTERNAL], [MPIR_INT16], [Internal type for MPI_INTEGER2]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER4_INTERNAL], [MPIR_INT32], [Internal type for MPI_INTEGER4]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER8_INTERNAL], [MPIR_INT64], [Internal type for MPI_INTEGER8]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER16_INTERNAL], [MPIR_INT128], [Internal type for MPI_INTEGER16]) -else - AC_DEFINE_UNQUOTED([MPIR_CHARACTER_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_CHARACTER]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_INTEGER]) - AC_DEFINE_UNQUOTED([MPIR_REAL_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_REAL]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_LOGICAL]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_COMPLEX]) - AC_DEFINE_UNQUOTED([MPIR_DOUBLE_PRECISION_INTERNAL],[MPI_DATATYPE_NULL], [Internal type for MPI_DOUBLE_PRECISION]) - AC_DEFINE_UNQUOTED([MPIR_2INTEGER_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_2INTEGER]) - AC_DEFINE_UNQUOTED([MPIR_2REAL_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_2REAL]) - AC_DEFINE_UNQUOTED([MPIR_DOUBLE_COMPLEX_INTERNAL],[MPI_DATATYPE_NULL], [Internal type for MPI_DOUBLE_COMPLEX]) - AC_DEFINE_UNQUOTED([MPIR_2DOUBLE_PRECISION_INTERNAL],[MPI_DATATYPE_NULL], [Internal type for MPI_2DOUBLE_PRECISION]) - # skip MPI_2COMPLEX, MPI_2DOUBLE_COMPLEX - AC_DEFINE_UNQUOTED([MPIR_REAL2_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_REAL2]) - AC_DEFINE_UNQUOTED([MPIR_REAL4_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_REAL4]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX8_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_COMPLEX8]) - AC_DEFINE_UNQUOTED([MPIR_REAL8_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_REAL8]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX16_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_COMPLEX16]) - AC_DEFINE_UNQUOTED([MPIR_REAL16_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_REAL16]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX32_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_COMPLEX32]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER1_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_INTEGER1]) - AC_DEFINE_UNQUOTED([MPIR_COMPLEX4_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_COMPLEX4]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER2_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_INTEGER2]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER4_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_INTEGER4]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER8_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_INTEGER8]) - AC_DEFINE_UNQUOTED([MPIR_INTEGER16_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_INTEGER16]) -fi if test -n "$CXX" ; then len=`expr $ac_cv_sizeof_bool \* 8` AC_DEFINE_UNQUOTED([MPIR_CXX_BOOL_INTERNAL], [MPIR_INT$len], [Internal type for MPI_CXX_BOOL]) @@ -3588,19 +3612,6 @@ AC_DEFINE_UNQUOTED([MPIR_OFFSET_INTERNAL],[MPIR_INT$len], [Internal type for MPI len=`expr $MPI_SIZEOF_COUNT \* 8` AC_DEFINE_UNQUOTED([MPIR_COUNT_INTERNAL], [MPIR_INT$len], [Internal type for MPI_COUNT_DATATYPE]) AC_DEFINE_UNQUOTED([MPIR_C_FLOAT16_INTERNAL], [MPIR_FLOAT16], [Internal type for MPIX_C_FLOAT16]) -if test "$enable_f77" = "yes" ; then - AC_DEFINE_UNQUOTED([MPIR_LOGICAL1_INTERNAL], [MPIR_FORTRAN_LOGICAL8], [Internal type for MPI_LOGICAL1]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL2_INTERNAL], [MPIR_FORTRAN_LOGICAL16], [Internal type for MPI_LOGICAL2]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL4_INTERNAL], [MPIR_FORTRAN_LOGICAL32], [Internal type for MPI_LOGICAL4]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL8_INTERNAL], [MPIR_FORTRAN_LOGICAL64], [Internal type for MPI_LOGICAL8]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL16_INTERNAL], [MPIR_FORTRAN_LOGICAL128],[Internal type for MPI_LOGICAL16]) -else - AC_DEFINE_UNQUOTED([MPIR_LOGICAL1_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_LOGICAL1]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL2_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_LOGICAL2]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL4_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_LOGICAL4]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL8_INTERNAL], [MPI_DATATYPE_NULL], [Internal type for MPI_LOGICAL8]) - AC_DEFINE_UNQUOTED([MPIR_LOGICAL16_INTERNAL], [MPI_DATATYPE_NULL],[Internal type for MPI_LOGICAL16]) -fi AC_DEFINE_UNQUOTED([MPIR_BFLOAT16_INTERNAL], [MPIR_BFLOAT16],[Internal type for MPIX_BFLOAT16]) AC_MSG_RESULT([done]) diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 4b30e22a717..375b37e2d65 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -911,9 +911,13 @@ def process_func_parameters(): # these are all special functions, e.g. MPI_Wtime, MPI_Wtick, MPI_Aint_add, MPI_Aint_diff G.out.append("return %s(%s);" % (c_func_name, ', '.join(c_arg_list_A))) else: + # If it's MPI_Init etc, run mpirinitf_ at the end so it can call MPI_Abi_set_fortran_info etc. + # Otherwise, call it first so common symbols can work. # FIXME: need check name mangling before call mpirinitf_() - G.out.append("if (MPIR_F_NeedInit) {mpirinitf_(); MPIR_F_NeedInit = 0;}") - G.out.append("") + is_init = re.match(r'(MPI_Init|MPI_Init_thread|MPI_Session_init)', func['name'], re.IGNORECASE) + if not is_init: + G.out.append("if (MPIR_F_NeedInit) {mpirinitf_();}") + G.out.append("") for l in code_list_common: G.out.append(l) @@ -942,6 +946,11 @@ def process_func_parameters(): for l in end_list_common: G.out.append(l) + # call mpirinitf_ after MPI_Init + if is_init: + G.out.append("") + G.out.append("mpirinitf_();") + dump_mpi_decl_end() def dump_f77_c_file(f, lines): diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index 7a882fc1ee7..397a4c51f3e 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -422,4 +422,6 @@ int MPII_greq_start(F77_greq_query_function query_fn, F77_greq_free_function fre extern FORT_DLL_SPEC void FORT_CALL mpi_alloc_mem_cptr_(MPI_Aint * size, MPI_Fint * info, void **baseptr, MPI_Fint * ierr); +void MPIX_Init_fortran(void) __attribute__ ((visibility("default"))); + #endif /* MPI_FORTIMPL_H_INCLUDED */ diff --git a/src/binding/fortran/mpif_h/setbot.c.in b/src/binding/fortran/mpif_h/setbot.c.in index e3803dd4594..264377de0ea 100644 --- a/src/binding/fortran/mpif_h/setbot.c.in +++ b/src/binding/fortran/mpif_h/setbot.c.in @@ -44,6 +44,13 @@ void *MPI_F_ARGV_NULL = 0; void *MPI_F_ARGVS_NULL = 0; void *MPIR_F_MPI_WEIGHTS_EMPTY = 0; +static void info_set_int(MPI_Info info, const char *key, int val) +{ + char str[20]; + snprintf(str, 20, "%d", val); + MPI_Info_set(info, key, str); +} + FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, void *bt, void *ip, void *c_ba, void *uw, void *ecsi, @@ -61,6 +68,100 @@ FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, MPI_F_ARGV_NULL = an; MPI_F_ARGVS_NULL = asn; MPIR_F_MPI_WEIGHTS_EMPTY = we; + + int mpi_is_initialized = 0; + MPI_Initialized(&mpi_is_initialized); + if (!mpi_is_initialized) { + return; + } + + MPIX_Init_fortran(); + + MPIR_F_NeedInit = 0; +} + +void MPIX_Init_fortran(void) +{ + + int mpi_errno; + MPI_Info info; + mpi_errno = MPI_Abi_get_fortran_info(&info); + assert(mpi_errno == MPI_SUCCESS); + + if (info == MPI_INFO_NULL) { + /* MPI_Abi_set_fortran_info */ + MPI_Info_create(&info); + info_set_int(info, "mpi_character_size", MPI_CHARACTER_SIZE); + info_set_int(info, "mpi_logical_size", MPI_LOGICAL_SIZE); + info_set_int(info, "mpi_integer_size", MPI_INTEGER_SIZE); + info_set_int(info, "mpi_real_size", MPI_REAL_SIZE); + info_set_int(info, "mpi_double_precision_size", MPI_DOUBLE_PRECISION_SIZE); +#ifdef MPI_LOGICAL1_SUPPORTED + MPI_Info_set(info, "mpi_logical1_supported", "true"); +#endif +#ifdef MPI_LOGICAL2_SUPPORTED + MPI_Info_set(info, "mpi_logical2_supported", "true"); +#endif +#ifdef MPI_LOGICAL4_SUPPORTED + MPI_Info_set(info, "mpi_logical4_supported", "true"); +#endif +#ifdef MPI_LOGICAL8_SUPPORTED + MPI_Info_set(info, "mpi_logical8_supported", "true"); +#endif +#ifdef MPI_LOGICAL16_SUPPORTED + MPI_Info_set(info, "mpi_logical16_supported", "true"); +#endif +#ifdef MPI_INTEGER1_SUPPORTED + MPI_Info_set(info, "mpi_integer1_supported", "true"); +#endif +#ifdef MPI_INTEGER2_SUPPORTED + MPI_Info_set(info, "mpi_integer2_supported", "true"); +#endif +#ifdef MPI_INTEGER4_SUPPORTED + MPI_Info_set(info, "mpi_integer4_supported", "true"); +#endif +#ifdef MPI_INTEGER8_SUPPORTED + MPI_Info_set(info, "mpi_integer8_supported", "true"); +#endif +#ifdef MPI_INTEGER16_SUPPORTED + MPI_Info_set(info, "mpi_integer16_supported", "true"); +#endif +#ifdef MPI_REAL2_SUPPORTED + MPI_Info_set(info, "mpi_real2_supported", "true"); +#endif +#ifdef MPI_REAL4_SUPPORTED + MPI_Info_set(info, "mpi_real4_supported", "true"); +#endif +#ifdef MPI_REAL8_SUPPORTED + MPI_Info_set(info, "mpi_real8_supported", "true"); +#endif +#ifdef MPI_REAL16_SUPPORTED + MPI_Info_set(info, "mpi_real16_supported", "true"); +#endif +#ifdef MPI_COMPLEX4_SUPPORTED + MPI_Info_set(info, "mpi_complex4_supported", "true"); +#endif +#ifdef MPI_COMPLEX8_SUPPORTED + MPI_Info_set(info, "mpi_complex8_supported", "true"); +#endif +#ifdef MPI_COMPLEX16_SUPPORTED + MPI_Info_set(info, "mpi_complex16_supported", "true"); +#endif +#ifdef MPI_COMPLEX32_SUPPORTED + MPI_Info_set(info, "mpi_complex32_supported", "true"); +#endif +#ifdef MPI_DOUBLE_PRECISION_SUPPORTED + MPI_Info_set(info, "mpi_double_precision_supported", "true"); +#endif + mpi_errno = MPI_Abi_set_fortran_info(info); + assert(mpi_errno == MPI_SUCCESS); + + MPI_Info_free(&info); + + /* MPI_Abi_set_fortran_boolean */ + mpi_errno = MPI_Abi_set_fortran_boolean(MPI_LOGICAL_SIZE, F77_TRUE_VALUE, F77_FALSE_VALUE); + assert(mpi_errno == MPI_SUCCESS); + } } /* diff --git a/src/mpi/datatype/typeutil.c b/src/mpi/datatype/typeutil.c index abc14dce781..8627ee5a2da 100644 --- a/src/mpi/datatype/typeutil.c +++ b/src/mpi/datatype/typeutil.c @@ -23,6 +23,7 @@ MPIR_Object_alloc_t MPIR_Datatype_mem = { 0, 0, 0, 0, 0, 0, 0, MPIR_DATATYPE, static int datatype_attr_finalize_cb(void *dummy); #define type_name_entry(x_, g_) { MPI_##x_, MPIR_##x_##_INTERNAL, MPIR_DT_GROUP_##g_, "MPI_" #x_ } +#define type_name_unset(x_, g_) { MPI_##x_, MPI_DATATYPE_NULL, MPIR_DT_GROUP_##g_, "MPI_" #x_ } #define type_name_x(x_, g_) { MPIX_##x_, MPIR_##x_##_INTERNAL, MPIR_DT_GROUP_##g_, "MPIX_" #x_ } #define type_name_null {MPI_DATATYPE_NULL, MPI_DATATYPE_NULL, MPIR_DT_GROUP_NULL, NULL} @@ -54,31 +55,31 @@ struct MPIR_Datatype_builtin_entry MPIR_Internal_types[] = { type_name_null, /* 0x17 */ type_name_entry(SIGNED_CHAR, C_INTEGER), /* 0x18 */ type_name_entry(UNSIGNED_LONG_LONG, C_INTEGER), /* 0x19 */ - type_name_entry(CHARACTER, NULL), /* 0x1a */ - type_name_entry(INTEGER, FORTRAN_INTEGER), /* 0x1b */ - type_name_entry(REAL, FLOATING_POINT), /* 0x1c */ - type_name_entry(LOGICAL, LOGICAL), /* 0x1d */ - type_name_entry(COMPLEX, COMPLEX), /* 0x1e */ - type_name_entry(DOUBLE_PRECISION, FLOATING_POINT), /* 0x1f */ - type_name_entry(2INTEGER, NULL), /* 0x20 */ - type_name_entry(2REAL, NULL), /* 0x21 */ - type_name_entry(DOUBLE_COMPLEX, COMPLEX), /* 0x22 */ - type_name_entry(2DOUBLE_PRECISION, NULL), /* 0x23 */ + type_name_unset(CHARACTER, NULL), /* 0x1a */ + type_name_unset(INTEGER, FORTRAN_INTEGER), /* 0x1b */ + type_name_unset(REAL, FLOATING_POINT), /* 0x1c */ + type_name_unset(LOGICAL, LOGICAL), /* 0x1d */ + type_name_unset(COMPLEX, COMPLEX), /* 0x1e */ + type_name_unset(DOUBLE_PRECISION, FLOATING_POINT), /* 0x1f */ + type_name_unset(2INTEGER, NULL), /* 0x20 */ + type_name_unset(2REAL, NULL), /* 0x21 */ + type_name_unset(DOUBLE_COMPLEX, COMPLEX), /* 0x22 */ + type_name_unset(2DOUBLE_PRECISION, NULL), /* 0x23 */ type_name_null, /* 0x24 */ type_name_null, /* 0x25 */ - type_name_entry(REAL2, FLOATING_POINT), /* 0x26 */ - type_name_entry(REAL4, FLOATING_POINT), /* 0x27 */ - type_name_entry(COMPLEX8, COMPLEX), /* 0x28 */ - type_name_entry(REAL8, FLOATING_POINT), /* 0x29 */ - type_name_entry(COMPLEX16, COMPLEX), /* 0x2a */ - type_name_entry(REAL16, FLOATING_POINT), /* 0x2b */ - type_name_entry(COMPLEX32, COMPLEX), /* 0x2c */ - type_name_entry(INTEGER1, FORTRAN_INTEGER), /* 0x2d */ - type_name_entry(COMPLEX4, COMPLEX), /* 0x2e */ - type_name_entry(INTEGER2, FORTRAN_INTEGER), /* 0x2f */ - type_name_entry(INTEGER4, FORTRAN_INTEGER), /* 0x30 */ - type_name_entry(INTEGER8, FORTRAN_INTEGER), /* 0x31 */ - type_name_entry(INTEGER16, FORTRAN_INTEGER), /* 0x32 */ + type_name_unset(REAL2, FLOATING_POINT), /* 0x26 */ + type_name_unset(REAL4, FLOATING_POINT), /* 0x27 */ + type_name_unset(COMPLEX8, COMPLEX), /* 0x28 */ + type_name_unset(REAL8, FLOATING_POINT), /* 0x29 */ + type_name_unset(COMPLEX16, COMPLEX), /* 0x2a */ + type_name_unset(REAL16, FLOATING_POINT), /* 0x2b */ + type_name_unset(COMPLEX32, COMPLEX), /* 0x2c */ + type_name_unset(INTEGER1, FORTRAN_INTEGER), /* 0x2d */ + type_name_unset(COMPLEX4, COMPLEX), /* 0x2e */ + type_name_unset(INTEGER2, FORTRAN_INTEGER), /* 0x2f */ + type_name_unset(INTEGER4, FORTRAN_INTEGER), /* 0x30 */ + type_name_unset(INTEGER8, FORTRAN_INTEGER), /* 0x31 */ + type_name_unset(INTEGER16, FORTRAN_INTEGER), /* 0x32 */ type_name_entry(CXX_BOOL, LOGICAL), /* 0x33 */ type_name_entry(CXX_FLOAT_COMPLEX, COMPLEX), /* 0x34 */ type_name_entry(CXX_DOUBLE_COMPLEX, COMPLEX), /* 0x35 */ @@ -99,11 +100,11 @@ struct MPIR_Datatype_builtin_entry MPIR_Internal_types[] = { type_name_entry(OFFSET, MULTI), /* 0x44 */ type_name_entry(COUNT, MULTI), /* 0x45 */ type_name_x(C_FLOAT16, FLOATING_POINT), /* 0x46 */ - type_name_entry(LOGICAL1, LOGICAL), /* 0x47 */ - type_name_entry(LOGICAL2, LOGICAL), /* 0x48 */ - type_name_entry(LOGICAL4, LOGICAL), /* 0x49 */ - type_name_entry(LOGICAL8, LOGICAL), /* 0x4a */ - type_name_entry(LOGICAL16, LOGICAL), /* 0x4b */ + type_name_unset(LOGICAL1, LOGICAL), /* 0x47 */ + type_name_unset(LOGICAL2, LOGICAL), /* 0x48 */ + type_name_unset(LOGICAL4, LOGICAL), /* 0x49 */ + type_name_unset(LOGICAL8, LOGICAL), /* 0x4a */ + type_name_unset(LOGICAL16, LOGICAL), /* 0x4b */ type_name_x(BFLOAT16, FLOATING_POINT), /* 0x4c */ /* *INDENT-ON* */ }; @@ -557,19 +558,26 @@ int MPIR_Abi_set_fortran_info_impl(MPIR_Info * info) } const char *str_val; -#define SET_TYPE_INFO(mpi_type, keyname, mpir_type) \ +#define SET_TYPE_INFO(mpi_type, keyname, mpir_type, multiple) \ do { \ str_val = MPIR_Info_lookup(info, keyname); \ MPIR_ERR_CHKANDJUMP1(!str_val, mpi_errno, MPI_ERR_ABI, "**abi_set_fortran", "**abi_set_fortran %s", (keyname)); \ int i = (mpi_type) & 0xff; \ - int typesize = atoi(str_val); \ + int typesize = atoi(str_val) * (multiple); \ /* FIXME: sanity check typesize */ \ MPIR_Internal_types[i].internal_type = MPIR_FIXED0 | (mpir_type) | (typesize << 8) | i; \ } while (0) - SET_TYPE_INFO(MPI_LOGICAL, "mpi_logical_size", MPIR_TYPE_SIGNED); - SET_TYPE_INFO(MPI_INTEGER, "mpi_integer_size", MPIR_TYPE_SIGNED); - SET_TYPE_INFO(MPI_REAL, "mpi_real_size", MPIR_TYPE_FLOAT); - SET_TYPE_INFO(MPI_DOUBLE_PRECISION, "mpi_double_precision_size", MPIR_TYPE_FLOAT); + SET_TYPE_INFO(MPI_CHARACTER, "mpi_character_size", MPIR_TYPE_FIXED, 1); + SET_TYPE_INFO(MPI_LOGICAL, "mpi_logical_size", MPIR_TYPE_SIGNED, 1); + SET_TYPE_INFO(MPI_INTEGER, "mpi_integer_size", MPIR_TYPE_SIGNED, 1); + SET_TYPE_INFO(MPI_REAL, "mpi_real_size", MPIR_TYPE_FLOAT, 1); + SET_TYPE_INFO(MPI_DOUBLE_PRECISION, "mpi_double_precision_size", MPIR_TYPE_FLOAT, 1); + + SET_TYPE_INFO(MPI_COMPLEX, "mpi_real_size", MPIR_TYPE_COMPLEX, 2); + SET_TYPE_INFO(MPI_DOUBLE_COMPLEX, "mpi_double_precision_size", MPIR_TYPE_COMPLEX, 2); + SET_TYPE_INFO(MPI_2INTEGER, "mpi_integer_size", MPIR_TYPE_FIXED, 2); + SET_TYPE_INFO(MPI_2REAL, "mpi_real_size", MPIR_TYPE_FIXED, 2); + SET_TYPE_INFO(MPI_2DOUBLE_PRECISION, "mpi_double_precision_size", MPIR_TYPE_FIXED, 2); #define SET_TYPE_SUPPORTED(mpi_type, keyname, mpir_type) \ do { \ @@ -579,11 +587,11 @@ int MPIR_Abi_set_fortran_info_impl(MPIR_Info * info) MPIR_Internal_types[i].internal_type = mpir_type | i; \ } \ } while (0) - SET_TYPE_SUPPORTED(MPI_LOGICAL1, "mpi_logical1_supported", MPIR_INT8); - SET_TYPE_SUPPORTED(MPI_LOGICAL2, "mpi_logical2_supported", MPIR_INT16); - SET_TYPE_SUPPORTED(MPI_LOGICAL4, "mpi_logical4_supported", MPIR_INT32); - SET_TYPE_SUPPORTED(MPI_LOGICAL8, "mpi_logical8_supported", MPIR_INT64); - SET_TYPE_SUPPORTED(MPI_LOGICAL16, "mpi_logical16_supported", MPIR_INT128); + SET_TYPE_SUPPORTED(MPI_LOGICAL1, "mpi_logical1_supported", MPIR_FORTRAN_LOGICAL8); + SET_TYPE_SUPPORTED(MPI_LOGICAL2, "mpi_logical2_supported", MPIR_FORTRAN_LOGICAL16); + SET_TYPE_SUPPORTED(MPI_LOGICAL4, "mpi_logical4_supported", MPIR_FORTRAN_LOGICAL32); + SET_TYPE_SUPPORTED(MPI_LOGICAL8, "mpi_logical8_supported", MPIR_FORTRAN_LOGICAL64); + SET_TYPE_SUPPORTED(MPI_LOGICAL16, "mpi_logical16_supported", MPIR_FORTRAN_LOGICAL128); SET_TYPE_SUPPORTED(MPI_INTEGER1, "mpi_integer1_supported", MPIR_INT8); SET_TYPE_SUPPORTED(MPI_INTEGER2, "mpi_integer2_supported", MPIR_INT16); SET_TYPE_SUPPORTED(MPI_INTEGER4, "mpi_integer4_supported", MPIR_INT32); From 301d2d758161bfca30163b681990e535c6d9f114 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 13 May 2026 16:17:22 -0500 Subject: [PATCH 11/39] binding/f77: always do handle conversions Always use MPI_{Comm,Type,...}_{from,to}int to convert handles between Fortran and C rather than assuming the C handle types are int. I don't think we are concerned with overhead of handle conversions. But if we ever do care, we may add a configure option and internally define the conversion functions into direct C casts. --- maint/local_python/__init__.py | 14 +++ maint/local_python/binding_f77.py | 109 +++++++++++++--------- src/binding/fortran/mpif_h/mpi_fortimpl.h | 8 -- 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/maint/local_python/__init__.py b/maint/local_python/__init__.py index 6a025b387da..a81778b6f95 100644 --- a/maint/local_python/__init__.py +++ b/maint/local_python/__init__.py @@ -85,6 +85,20 @@ def check_write_path(path): 'STREAM': "MPIR_Stream", } + # C types that have conversion apis, e.g. MPI_Comm_{from,to}int + handle_conversions = { + 'MPI_Comm': "MPI_Comm", + 'MPI_Group': "MPI_Group", + 'MPI_Datatype': "MPI_Type", + 'MPI_Errhandler': "MPI_Errhandler", + 'MPI_Op': "MPI_Op", + 'MPI_Info': "MPI_Info", + 'MPI_Win': "MPI_Win", + 'MPI_Request': "MPI_Request", + 'MPI_Session': "MPI_Session", + 'MPI_File': "MPI_File", + } + handle_error_codes = { 'COMMUNICATOR': "MPI_ERR_COMM", 'GROUP': "MPI_ERR_GROUP", diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 375b37e2d65..2853994cc19 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -65,8 +65,12 @@ def dump_p(p): raise Exception("Unhandled: %s - %s, length=%s" % (func['name'], p['name'], p['length'])) else: c_param_list.append("MPI_Fint *" + p['name']) - c_arg_list_A.append("(%s) (*%s)" % (c_type, p['name'])) - c_arg_list_B.append("(%s) (*%s)" % (c_type, p['name'])) + if c_type in G.handle_conversions: + c_arg_list_A.append("%s_fromint(*%s)" % (G.handle_conversions[c_type], p['name'])) + c_arg_list_B.append("%s_fromint(*%s)" % (G.handle_conversions[c_type], p['name'])) + else: + c_arg_list_A.append("(%s) (*%s)" % (c_type, p['name'])) + c_arg_list_B.append("(%s) (*%s)" % (c_type, p['name'])) def dump_scalar_out(v, f_type, c_type): c_param_list.append("%s *%s" % (f_type, v)) @@ -204,6 +208,14 @@ def copy_statuses_out(): def dump_int_out(v, c_type, is_inout): c_param_list.append("MPI_Fint *%s" % v) + def dump_handle_conversion(): + c_arg_list_A.append("&%s_i" % v) + c_arg_list_B.append("&%s_i" % v) + code_list_common.append("%s %s_i;" % (c_type, v)) + if is_inout: + code_list_common.append("%s_i = %s_fromint(*%s);" % (v, G.handle_conversions[c_type], v)) + end_list_common.append("*%s = %s_toint(%s_i);" % (v, G.handle_conversions[c_type], v)) + def dump_FINT_is_INT_pre(): c_arg_list_A.append("(%s *) %s" % (c_type, v)) @@ -215,9 +227,12 @@ def dump_FINT_not_INT_pre(): def dump_FINT_not_INT_post(): end_list_B.append("*%s = (MPI_Fint) %s_i;" % (v, v)) - dump_FINT_is_INT_pre() - dump_FINT_not_INT_pre() - dump_FINT_not_INT_post() + if c_type in G.handle_conversions: + dump_handle_conversion() + else: + dump_FINT_is_INT_pre() + dump_FINT_not_INT_pre() + dump_FINT_not_INT_post() # scalar integer input, but we assume Fortran use the same c_type def dump_c_type_in(v, c_type): @@ -255,6 +270,23 @@ def dump_array_special_out(v, c_type, count): def dump_array(v, c_type, incount, outcount, is_in=True, is_out=False, has_special=False): c_param_list.append("MPI_Fint *%s" % v) + def dump_handle_conversion(): + c_arg_list_A.append("%s_i" % v) + c_arg_list_B.append("%s_i" % v) + code_list_common.append("%s *%s_i;" % (c_type, v)) + + code_list_common.append("%s_i = malloc(sizeof(%s) * %s);" % (v, c_type, incount)) + if is_in: + code_list_common.append("for (int i = 0; i < %s; i++) {" % incount) + code_list_common.append(" %s_i[i] = %s_fromint(%s[i]);" % (v, G.handle_conversions[c_type], v)) + code_list_common.append("}") + + if is_out: + end_list_common.append("for (int i = 0; i < %s; i++) {" % outcount) + end_list_common.append(" %s[i] = %s_toint(%s_i[i]);" % (v, G.handle_conversions[c_type], v)) + end_list_common.append("}") + end_list_common.append("free(%s_i);" % v) + def dump_FINT_is_INT_pre(): c_arg_list_A.append("(int *) %s" % v) dump_check_special(True) @@ -330,9 +362,12 @@ def dump_check_special_end(code_list): code_list.append("DEDENT") code_list.append("}") - dump_FINT_is_INT_pre() - dump_FINT_not_INT_pre() - dump_FINT_not_INT_post() + if c_type in G.handle_conversions: + dump_handle_conversion() + else: + dump_FINT_is_INT_pre() + dump_FINT_not_INT_pre() + dump_FINT_not_INT_post() def dump_array_int_to_aint(v, count): c_param_list.append("MPI_Fint *%s" % v) @@ -406,21 +441,6 @@ def dump_string_2darray(v, count): end_list_common.append(" MPIR_fort_free_str_2d_array(%s_i, %s);" % (v, count)) end_list_common.append("}") - def dump_file_in(v): - c_param_list.append("MPI_Fint *%s" % v) - c_arg_list_A.append("MPI_File_f2c(*%s)" % v) - c_arg_list_B.append("MPI_File_f2c(*%s)" % v) - - def dump_file_out(v, is_inout): - c_param_list.append("MPI_Fint *%s" % v) - c_arg_list_A.append("&%s_i" % v) - c_arg_list_B.append("&%s_i" % v) - if is_inout: - code_list_common.append("MPI_File %s_i = MPI_File_f2c(*%s);" % (v, v)) - else: - code_list_common.append("MPI_File %s_i;" % v) - end_list_common.append("*%s = MPI_File_c2f(%s_i);" % (v, v)) - def dump_logical_in(v): c_param_list.append("MPI_Fint *%s" % v) c_arg_list_A.append("*%s" % v) @@ -521,14 +541,8 @@ def dump_sum(codelist, sum_v, sum_n, array): def dump_mpi_decl_begin(name, param_str, return_type): G.out.append("FORT_DLL_SPEC %s FORT_CALL %s(%s) {" % (return_type, name, param_str)) G.out.append("INDENT") - if re.match(r'MPI_File_|MPI_Register_datarep', func['name'], re.IGNORECASE): - G.out.append("#ifndef HAVE_ROMIO") - G.out.append("*ierr = MPI_ERR_INTERN;") - G.out.append("#else") def dump_mpi_decl_end(): - if re.match(r'MPI_File_|MPI_Register_datarep', func['name'], re.IGNORECASE): - G.out.append("#endif") G.out.append("DEDENT") G.out.append("}") @@ -670,15 +684,7 @@ def process_func_parameters(): else: raise Exception("Not handled: %s - %s" % (func['name'], p['name'])) - elif p['kind'] == "FILE": - if p['param_direction'] == 'out': - dump_file_out(p['name'], False) - elif p['param_direction'] == 'inout': - dump_file_out(p['name'], True) - else: - dump_file_in(p['name']) elif p['kind'] == "LOGICAL": - if re.match(r'MPI_Cart_sub$', func['name'], re.IGNORECASE): # remain_dims dump_array_in(p['name'], 'int', "maxdims") @@ -768,7 +774,7 @@ def process_func_parameters(): # use MPII_greq_start c_param_list.append("MPI_Fint *%s" % p['name']) c_arg_list_A.append(p['name']) - elif p['kind'] in G.handle_mpir_types or c_mapping[p['kind']] == "int": + elif p['kind'] in G.handle_mpir_types or p['kind'] == 'FILE' or c_mapping[p['kind']] == "int": c_type = c_mapping[p['kind']] if p['length'] is None: if p['param_direction'] == 'out': @@ -825,22 +831,33 @@ def process_func_parameters(): dump_sum(code_list_B, "total_procs", "count", "array_of_maxprocs") elif re.match(r'MPI_Cart_(rank|sub)$', func['name'], re.IGNORECASE): code_list_B.append("int maxdims;") - code_list_B.append("MPI_Cartdim_get((MPI_Comm) (*comm), &maxdims);") + code_list_B.append("MPI_Cartdim_get(MPI_Comm_fromint(*comm), &maxdims);") elif re.match(r'mpi_i?neighbor_(.*[vw])(_init)?$', func['name'], re.IGNORECASE): - code_list_B.append("int indegree, outdegree, weighted;") - code_list_B.append("MPI_Dist_graph_neighbors_count((MPI_Comm) (*comm), &indegree, &outdegree, &weighted);") + code_list_common.append("int indegree, outdegree, weighted;") + code_list_common.append("MPI_Dist_graph_neighbors_count(MPI_Comm_fromint(*comm), &indegree, &outdegree, &weighted);") elif re.match(r'mpi_.*(reduce_scatter)', func['name'], re.IGNORECASE): code_list_B.append("int comm_size;") - code_list_B.append("MPI_Comm_size((MPI_Comm) (*comm), &comm_size);") - elif re.match(r'mpi_.*(gatherv|scatterv|alltoall[vw])', func['name'], re.IGNORECASE): + code_list_B.append("MPI_Comm_size(MPI_Comm_fromint(*comm), &comm_size);") + elif re.match(r'mpi_.*(gatherv|scatterv|alltoallv)', func['name'], re.IGNORECASE): code_list_B.append("int is_inter;") code_list_B.append("int comm_size;") - code_list_B.append("MPI_Comm_test_inter((MPI_Comm) (*comm), &is_inter);") + code_list_B.append("MPI_Comm_test_inter(MPI_Comm_fromint(*comm), &is_inter);") code_list_B.append("if (is_inter) {") - code_list_B.append(" MPI_Comm_remote_size((MPI_Comm) (*comm), &comm_size);") + code_list_B.append(" MPI_Comm_remote_size(MPI_Comm_fromint(*comm), &comm_size);") code_list_B.append("} else {") - code_list_B.append(" MPI_Comm_size((MPI_Comm) (*comm), &comm_size);") + code_list_B.append(" MPI_Comm_size(MPI_Comm_fromint(*comm), &comm_size);") code_list_B.append("}") + elif re.match(r'mpi_.*(alltoallw)', func['name'], re.IGNORECASE): + # datatype array always require conversion + code_list_common.append("int is_inter;") + code_list_common.append("int comm_size;") + code_list_common.append("MPI_Comm_test_inter(MPI_Comm_fromint(*comm), &is_inter);") + code_list_common.append("if (is_inter) {") + code_list_common.append(" MPI_Comm_remote_size(MPI_Comm_fromint(*comm), &comm_size);") + code_list_common.append("} else {") + code_list_common.append(" MPI_Comm_size(MPI_Comm_fromint(*comm), &comm_size);") + code_list_common.append("}") + process_func_parameters() diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index 397a4c51f3e..fc1b59d7aad 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -366,14 +366,6 @@ typedef char *MPID_FCHAR_T; #undef MPI_CONVERSION_FN_NULL #endif /* MPI_DUP_FN */ -/* A special case to help out when ROMIO is disabled */ -#ifndef HAVE_ROMIO -#ifndef MPI_File_f2c -#define MPI_File_f2c(a) ((MPI_File)(MPI_Aint)(a)) -#define MPI_File_c2f(a) ((MPI_Fint)(MPI_Aint)(a)) -#endif -#endif /* HAVE_ROMIO */ - enum F77_handle_type { F77_COMM, F77_GROUP, From d033612e80542708853ba6a2ed3b60dda254e149 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sun, 28 Dec 2025 13:48:23 -0600 Subject: [PATCH 12/39] configure/fortran: remove variable FORTRAN_MPI_OFFSET Since now we only support the same Fortran compiler as FC and F77, we can directly use offset type as INTEGER(KIND=@OFFSET_KIND@). --- configure.ac | 30 ------------------------------ maint/local_python/binding_f77.py | 2 +- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index e0cf00213dd..62bc6787af9 100644 --- a/configure.ac +++ b/configure.ac @@ -3453,36 +3453,6 @@ AC_DEFINE_UNQUOTED([MPIR_OFFSET_MAX],[$MPIR_OFFSET_MAX],[limits.h _MAX constant # We may wish to use a different approach MPI_OFFSET_TYPEDEF="typedef $MPI_OFFSET MPI_Offset;" AC_SUBST(MPI_OFFSET_TYPEDEF) -# -# Fortran type for an Offset type (needed to define MPI_DISPLACEMENT_CURRENT) -# and is needed in mpif.h.in. -# First, we check that this works with both Fortran compilers (if -# they are defined) -# -if test "$enable_f77" = yes -a "$enable_f90" = yes ; then - FORTRAN_MPI_OFFSET="INTEGER(KIND=$OFFSET_KIND)" - - AC_LANG_PUSH([Fortran 77]) - AC_MSG_CHECKING([whether the Fortran Offset type works with Fortran 77]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([],[ $FORTRAN_MPI_OFFSET i]) - ],[has_f77_offsettype=yes],[has_f77_offsetype=no]) - AC_MSG_RESULT($has_f77_offsettype) - AC_LANG_POP([Fortran 77]) - - AC_LANG_PUSH([Fortran]) - AC_MSG_CHECKING([whether the Fortran Offset type works with Fortran 90]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([],[ $FORTRAN_MPI_OFFSET i]) - ],[has_fc_offsettype=yes],[has_fc_offsetype=no]) - AC_LANG_POP([Fortran]) - AC_MSG_RESULT($has_fc_offsettype) - - if test "$has_f77_offsettype" != yes -o "$has_fc_offsettype" != yes ; then - AC_MSG_WARN([mpif.h is not compatible with both $F77 $FFLAGS and $FC $FCFLAGS. We recommend that you set both F77 and FC to the same compiler and reconfigure.]) - fi -fi -AC_SUBST(FORTRAN_MPI_OFFSET) # ------------ # MPI_COUNT diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 2853994cc19..5007e9795c2 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -1017,7 +1017,7 @@ def dump_mpif_h(f): elif re.match(r'MPI_(UNWEIGHTED|WEIGHTS_EMPTY|BUFFER_AUTOMATIC|BOTTOM|IN_PLACE|STATUS_IGNORE|STATUSES_IGNORE|ERRCODES_IGNORE|ARGVS_NULL|ARGV_NULL)', name): continue elif re.match(r'MPI_DISPLACEMENT_CURRENT', name): - T = '@FORTRAN_MPI_OFFSET@' + T = 'INTEGER(KIND=@OFFSET_KIND@)' print(" %s %s" % (T, name), file=Out) print(" PARAMETER (%s=%s)" % (name, G.mpih_defines[name]), file=Out) From d3d474a99a669b8f5c4248f94493d244b5fed93c Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sun, 28 Dec 2025 14:17:57 -0600 Subject: [PATCH 13/39] romio: remove configure for Fortran We no longer support having romio define its own constants that are incompatible from MPICH or MPI ABI. Thus, we no longer need export ROMIO constants via mpiof.h. Remove all its support for mpiof.h. --- .gitignore | 2 +- confdb/aclocal_romio.m4 | 321 ------------------------------ maint/code-cleanup.bash | 1 - src/mpi/romio/README | 5 +- src/mpi/romio/doc/users-guide.tex | 5 +- src/mpi/romio/include/mpiof.h.in | 46 ----- src/mpi/romio/localdefs.in | 1 - 7 files changed, 5 insertions(+), 376 deletions(-) delete mode 100644 src/mpi/romio/include/mpiof.h.in diff --git a/.gitignore b/.gitignore index 6785b26f15e..dd595dc4e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -510,7 +510,7 @@ Makefile.am-stamp /src/mpi/romio/cscope.out # /src/mpi/romio/include/ -/src/mpi/romio/include/mpio.h mpiof.h +/src/mpi/romio/include/mpio.h # /src/mpi/romio/mpi-io/ diff --git a/confdb/aclocal_romio.m4 b/confdb/aclocal_romio.m4 index d63da521482..1cb359f82a0 100644 --- a/confdb/aclocal_romio.m4 +++ b/confdb/aclocal_romio.m4 @@ -4,68 +4,6 @@ dnl build configure scripts. dnl dnl Almost all of this file is taken from the aclocal.m4 of MPICH dnl -dnl Get the format of Fortran names. Uses F77, FFLAGS, and sets WDEF. -dnl If the test fails, sets NOF77 to 1, HAVE_FORTRAN to 0. -dnl -dnl -AC_DEFUN([PAC_GET_FORTNAMES],[ - rm -f confftest.f confftest.$OBJEXT - cat > confftest.f < /dev/null 2>&1 - if test ! -s confftest.$OBJEXT ; then - AC_MSG_WARN([Unable to test Fortran compiler. Compiling a test -program failed to produce an object file]) - NOF77=1 - elif test -z "$FORTRANNAMES" ; then - # MAC OS X (and probably FreeBSD need strings - (not strings -a) - # Cray doesn't accept -a ... - allstrings="-a" - if test $arch_CRAY ; then - allstrings="" - elif strings - confftest.$OBJEXT < /dev/null >/dev/null 2>&1 ; then - allstrings="-" - elif strings -a confftest.$OBJEXT < /dev/null >/dev/null 2>&1 ; then - allstrings="-a" - fi - - nameform1=`strings $allstrings confftest.$OBJEXT | grep mpir_init_fop_ | head -1` - nameform2=`strings $allstrings confftest.$OBJEXT | grep MPIR_INIT_FOP | head -1` - nameform3=`strings $allstrings confftest.$OBJEXT | grep mpir_init_fop | head -1` - nameform4=`strings $allstrings confftest.$OBJEXT | grep mpir_init_fop__ | head -1` - rm -f confftest.f confftest.$OBJEXT - if test -n "$nameform4" ; then - echo "Fortran externals are lower case and have two trailing underscores" - FORTRANNAMES="FORTRANDOUBLEUNDERSCORE" - elif test -n "$nameform1" ; then - # We don't set this in CFLAGS; it is a default case - echo "Fortran externals have a trailing underscore and are lowercase" - FORTRANNAMES="FORTRANUNDERSCORE" - elif test -n "$nameform2" ; then - echo "Fortran externals are uppercase" - FORTRANNAMES="FORTRANCAPS" - elif test -n "$nameform3" ; then - echo "Fortran externals are lower case" - FORTRANNAMES="FORTRANNOUNDERSCORE" - else - AC_MSG_WARN([Unable to determine the form of Fortran external names. -Make sure that the compiler $F77 can be run on this system. -Turning off Fortran (-nof77 being assumed)]) - NOF77=1 - fi - fi - if test -n "$FORTRANNAMES" ; then - WDEF="-D$FORTRANNAMES" - fi - # Delete confftest files with any extension. This catches the case - # where auxiliary files, such as coverage files, are removed. - rm -f confftest.* - ])dnl dnl define(PAC_GET_SPECIAL_SYSTEM_INFO,[ # @@ -242,79 +180,6 @@ EOF rm -f conftest$EXEEXT mpitest.c ])dnl dnl -dnl PAC_LONG_LONG_64: check if there is a 64-bit long long -dnl -define(PAC_LONG_LONG_64,[ -if test -n "$longlongsize" ; then - if test "$longlongsize" = 8 ; then - echo "defining MPI_Offset as long long in C and integer*8 in Fortran" - AC_DEFINE(HAVE_LONG_LONG_64,,[Define if long long is 64 bits]) - DEFINE_MPI_OFFSET="typedef long long MPI_Offset;" - FORTRAN_MPI_OFFSET="integer*8" - LL="\%lld" - elif test "$longlongsize" = "int" ; then # a hack to set MPI_Offset as int - echo "defining MPI_Offset as int in C and integer in Fortran" - DEFINE_MPI_OFFSET="typedef int MPI_Offset;" - FORTRAN_MPI_OFFSET="integer" - AC_DEFINE(MPI_OFFSET_IS_INT,,[Define if MPI_Offset is int]) - LL="\%d" - MPI_OFFSET_KIND1="!" - MPI_OFFSET_KIND2="!" - else - echo "defining MPI_Offset as long in C and integer in Fortran" - DEFINE_MPI_OFFSET="typedef long MPI_Offset;" - FORTRAN_MPI_OFFSET="integer" - LL="\%ld" - MPI_OFFSET_KIND1="!" - MPI_OFFSET_KIND2="!" - fi -else - PAC_GET_TYPE_SIZE(long long, longlongsize) - if test -n "$longlongsize" ; then - if test "$longlongsize" = 8 ; then - PAC_TEST_LONG_LONG() - else - echo "defining MPI_Offset as long in C and integer in Fortran" - DEFINE_MPI_OFFSET="typedef long MPI_Offset;" - FORTRAN_MPI_OFFSET="integer" - LL="\%ld" - MPI_OFFSET_KIND1="!" - MPI_OFFSET_KIND2="!" - fi - else -dnl check if longlong is not supported or only its size cannot be determined -dnl because the program cannot be run. - rm -f ltest.c - cat > ltest.c < /dev/null 2>&1 - if test -x conftest$EXEEXT ; then - echo "assuming size of long long is 8bytes; use '-longlongsize' to indicate otherwise" - rm -f conftest$EXEEXT ltest.c - echo "defining MPI_Offset as long long in C and integer*8 in Fortran" - AC_DEFINE(HAVE_LONG_LONG_64,,[Define if long long is 64 bits]) - DEFINE_MPI_OFFSET="typedef long long MPI_Offset;" - FORTRAN_MPI_OFFSET="integer*8" - LL="\%lld" - else - echo "assuming long long is not available; use '-longlongsize' to indicate otherwise" - echo "defining MPI_Offset as long in C and integer in Fortran" - DEFINE_MPI_OFFSET="typedef long MPI_Offset;" - FORTRAN_MPI_OFFSET="integer" - LL="\%ld" - MPI_OFFSET_KIND1="!" - MPI_OFFSET_KIND2="!" - fi - fi -fi -])dnl -dnl dnl define(PAC_MPI_INFO,[ AC_MSG_CHECKING(if MPI_Info functions are defined in the MPI implementation) @@ -335,17 +200,9 @@ EOF AC_MSG_RESULT(yes) AC_DEFINE(HAVE_MPI_INFO,1,[Define if MPI_Info available]) HAVE_MPI_INFO="#define HAVE_MPI_INFO" - MPI_FINFO1="!" - MPI_FINFO2="!" - MPI_FINFO3="!" - MPI_FINFO4="!" else AC_MSG_RESULT(no) BUILD_MPI_INFO=1 - MPI_FINFO1=" INTEGER MPI_MAX_INFO_KEY, MPI_MAX_INFO_VAL" - MPI_FINFO2=" PARAMETER (MPI_MAX_INFO_KEY=255, MPI_MAX_INFO_VAL=1024)" - MPI_FINFO3=" INTEGER MPI_INFO_NULL" - MPI_FINFO4=" PARAMETER (MPI_INFO_NULL=0)" fi rm -f conftest$EXEEXT mpitest.c ])dnl @@ -372,23 +229,9 @@ EOF AC_MSG_RESULT(yes) AC_DEFINE(HAVE_MPI_DARRAY_SUBARRAY,,[Define if MPI Darray available]) HAVE_MPI_DARRAY_SUBARRAY="#define HAVE_MPI_DARRAY_SUBARRAY" - MPI_FARRAY1="!" - MPI_FARRAY2="!" - MPI_FARRAY3="!" - MPI_FARRAY4="!" - MPI_FARRAY5="!" - MPI_FARRAY6="!" - MPI_FARRAY7="!" else AC_MSG_RESULT(no) BUILD_MPI_ARRAY=1 - MPI_FARRAY1=" INTEGER MPI_ORDER_C, MPI_ORDER_FORTRAN" - MPI_FARRAY2=" PARAMETER (MPI_ORDER_C=56, MPI_ORDER_FORTRAN=57)" - MPI_FARRAY3=" INTEGER MPI_DISTRIBUTE_BLOCK, MPI_DISTRIBUTE_CYCLIC" - MPI_FARRAY4=" INTEGER MPI_DISTRIBUTE_NONE, MPI_DISTRIBUTE_DFLT_DARG" - MPI_FARRAY5=" PARAMETER (MPI_DISTRIBUTE_BLOCK=121, MPI_DISTRIBUTE_CYCLIC=122)" - MPI_FARRAY6=" PARAMETER (MPI_DISTRIBUTE_NONE=123)" - MPI_FARRAY7=" PARAMETER (MPI_DISTRIBUTE_DFLT_DARG=-49767)" fi rm -f conftest$EXEEXT mpitest.c ])dnl @@ -417,31 +260,6 @@ EOF ])dnl dnl dnl -dnl -define(PAC_CHECK_MPIOF_H,[ - AC_MSG_CHECKING(if mpiof.h is included in mpif.h) - rm -f mpitest.f - cat > mpitest.f < /dev/null 2>&1 - if test -x conftest$EXEEXT ; then - AC_MSG_RESULT(yes) - MPIOF_H_INCLUDED=1 - else - AC_MSG_RESULT(no) - fi - rm -f conftest$EXEEXT mpitest.f -])dnl -dnl -dnl dnl check if pread64 is defined in IRIX. needed on IRIX 6.5 dnl define(PAC_HAVE_PREAD64,[ @@ -522,107 +340,6 @@ EOF ])dnl dnl dnl -dnl PAC_MPI_OFFSET_KIND() -dnl -dnl tries to determine the Fortran 90 kind parameter for 8-byte integers -dnl -define(PAC_MPI_OFFSET_KIND, -[ -# This is needed for Mac OSX 10.5 -rm -rf conftest.dSYM -rm -f conftest* -# Determine the extension for Fortran 90 files (not all compilers accept -# .f and not all accept .f90) -if test -z "$ac_f90ext" ; then - if test -z "$FC" ; then - # This list should correspond to the list in aclocal_fc.m4 - AC_CHECK_PROGS(FC,ifort pgf90 pathf90 pathf95 xlf90 xlf95 f90 epcf90 \ - f95 fort lf95 gfortran g95 ifc efc) - fi - AC_MSG_CHECKING([for extension for Fortran 90 programs]) - ac_f90ext="f90" - ac_f90compile='${FC-f90} -c $FCFLAGS conftest.$ac_f90ext 1>&AS_MESSAGE_LOG_FD' - cat > conftest.$ac_f90ext < conftest.$ac_f90ext < conftest.$ac_f90ext - program main - integer i - i = selected_int_kind(16) - open(8, file="conftest.out", form="formatted") - write (8,*) i - close(8) - stop - end -EOF -if test -z "$FC" ; then - FC=f90 -fi -KINDVAL="" -if $FC -o conftest$EXEEXT conftest.$ac_f90ext $FCFLAGS >/dev/null 2>&1 ; then - ./conftest$EXEEXT >/dev/null 2>&1 - if test -s conftest.out ; then - KINDVAL=`cat conftest.out` - fi -fi -# This is needed for Mac OSX 10.5 -rm -rf conftest.dSYM -rm -f conftest* -if test -n "$KINDVAL" -a "$KINDVAL" != "-1" ; then - AC_MSG_RESULT($KINDVAL) - MPI_OFFSET_KIND1=" INTEGER MPI_OFFSET_KIND" - MPI_OFFSET_KIND2=" PARAMETER (MPI_OFFSET_KIND=$KINDVAL)" -else - AC_MSG_RESULT(unavailable) -fi -])dnl -dnl -dnl -define(PAC_TEST_MPI_HAVE_OFFSET_KIND,[ - AC_MSG_CHECKING(if MPI_OFFSET_KIND is defined in mpif.h) - rm -f mpitest.f - cat > mpitest.f < /dev/null 2>&1 - if test -x conftest$EXEEXT ; then - AC_MSG_RESULT(yes) - MPI_OFFSET_KIND1="!" - MPI_OFFSET_KIND2="!" - else - AC_MSG_RESULT(no) - fi - rm -f conftest$EXEEXT mpitest.f -])dnl -dnl -dnl dnl PAC_GET_XFS_MEMALIGN dnl dnl @@ -681,44 +398,6 @@ EOF ])dnl dnl dnl -dnl PAC_MPI_OFFSET_KIND_4BYTE() -dnl -dnl tries to determine the Fortran 90 kind parameter for 4-byte integers -dnl -define(PAC_MPI_OFFSET_KIND_4BYTE, -[AC_MSG_CHECKING([for Fortran 90 KIND parameter for 4-byte integers]) -rm -f kind.f kind.$OBJEXT kind$EXEEXT -cat < kind.f - program main - integer i - i = selected_int_kind(8) - open(8, file="k.out", form="formatted") - write (8,*) i - close(8) - stop - end -EOF -if test -z "$FC" ; then - FC=f90 -fi -KINDVAL="" -if $FC -o kind$EXEEXT kind.f $FCFLAGS >/dev/null 2>&1 ; then - ./kind >/dev/null 2>&1 - if test -s k.out ; then - KINDVAL=`cat k.out` - fi -fi -rm -f kind$EXEEXT k.out kind.f kind.$OBJEXT -if test -n "$KINDVAL" -a "$KINDVAL" != "-1" ; then - AC_MSG_RESULT($KINDVAL) - MPI_OFFSET_KIND1=" INTEGER MPI_OFFSET_KIND" - MPI_OFFSET_KIND2=" PARAMETER (MPI_OFFSET_KIND=$KINDVAL)" -else - AC_MSG_RESULT(unavailable) -fi -])dnl -dnl -dnl define(PAC_FUNC_STRERROR,[ AC_MSG_CHECKING([for strerror()]) rm -f conftest.c diff --git a/maint/code-cleanup.bash b/maint/code-cleanup.bash index df7ec597c70..f9f659af642 100755 --- a/maint/code-cleanup.bash +++ b/maint/code-cleanup.bash @@ -111,7 +111,6 @@ ignore_list="$ignore_list|src/mpid/ch3/util" ignore_list="$ignore_list|src/mpid/ch3/channels/nemesis/include" ignore_list="$ignore_list|src/mpid/ch3/channels/nemesis/src" ignore_list="$ignore_list|src/mpid/ch3/channels/nemesis/utils" -ignore_list="$ignore_list|src/mpi/romio/include/mpiof.h.in" ignore_list="$ignore_list|test/mpi/errors/f77/io/addsize.h.in" ignore_list="$ignore_list|test/mpi/errors/f77/io/iooffset.h.in" ignore_list="$ignore_list|test/mpi/f77/attr/attraints.h.in" diff --git a/src/mpi/romio/README b/src/mpi/romio/README index bbdc18cb6ea..77619e8ffaf 100644 --- a/src/mpi/romio/README +++ b/src/mpi/romio/README @@ -488,8 +488,7 @@ Compiling and Running MPI-IO Programs ------------------------------------- If ROMIO is not already included in the MPI implementation, you need -to include the file mpio.h for C or mpiof.h for Fortran in your MPI-IO -program. +to include the file mpio.h for C in your MPI-IO program. Note that on HP machines running HPUX and on NEC SX-4, you need to compile Fortran programs with mpifort, because the f77 compilers on @@ -519,7 +518,7 @@ or If you have built ROMIO with some other MPI implementation, you can compile MPI-IO programs by explicitly giving the path to the include -file mpio.h or mpiof.h and explicitly specifying the path to the +file mpio.h and explicitly specifying the path to the library libmpio.a, which is located in $(ROMIO_HOME)/lib/$(ARCH)/libmpio.a . diff --git a/src/mpi/romio/doc/users-guide.tex b/src/mpi/romio/doc/users-guide.tex index 925d6fe809c..be954ccaaab 100644 --- a/src/mpi/romio/doc/users-guide.tex +++ b/src/mpi/romio/doc/users-guide.tex @@ -780,8 +780,7 @@ \section{Testing ROMIO} % \section{Compiling and Running MPI-IO Programs} If ROMIO is not already included in the MPI implementation, you need -to include the file {\tt mpio.h} for C or {\tt mpiof.h} for Fortran in -your MPI-IO program. +to include the file {\tt mpio.h} for C in your MPI-IO program. Note that on HP machines running HPUX and on NEC SX-4, you need to compile Fortran programs with {\tt mpifort}. @@ -805,7 +804,7 @@ \section{Compiling and Running MPI-IO Programs} If you have built ROMIO with some other MPI implementation, you can compile MPI-IO programs by explicitly giving the path to the include -file mpio.h or mpiof.h and explicitly specifying the path to the +file mpio.h and explicitly specifying the path to the library libmpio.a, which is located in {\tt \$(ROMIO\_HOME)/lib/\$(ARCH)/libmpio.a}. Run the program as you would run any MPI program on the machine. diff --git a/src/mpi/romio/include/mpiof.h.in b/src/mpi/romio/include/mpiof.h.in deleted file mode 100644 index 6b84d9d98f3..00000000000 --- a/src/mpi/romio/include/mpiof.h.in +++ /dev/null @@ -1,46 +0,0 @@ -! -! Copyright (C) by Argonne National Laboratory -! See COPYRIGHT in top-level directory -! - -! user include file for Fortran MPI-IO programs -! - INTEGER MPI_MODE_RDONLY, MPI_MODE_RDWR, MPI_MODE_WRONLY - INTEGER MPI_MODE_DELETE_ON_CLOSE, MPI_MODE_UNIQUE_OPEN - INTEGER MPI_MODE_CREATE, MPI_MODE_EXCL - INTEGER MPI_MODE_APPEND, MPI_MODE_SEQUENTIAL - PARAMETER (MPI_MODE_RDONLY=2, MPI_MODE_RDWR=8, MPI_MODE_WRONLY=4) - PARAMETER (MPI_MODE_CREATE=1, MPI_MODE_DELETE_ON_CLOSE=16) - PARAMETER (MPI_MODE_UNIQUE_OPEN=32, MPI_MODE_EXCL=64) - PARAMETER (MPI_MODE_APPEND=128, MPI_MODE_SEQUENTIAL=256) -! - INTEGER MPI_FILE_NULL - PARAMETER (MPI_FILE_NULL=0) -! - INTEGER MPI_MAX_DATAREP_STRING - PARAMETER (MPI_MAX_DATAREP_STRING=128) -! - INTEGER MPI_SEEK_SET, MPI_SEEK_CUR, MPI_SEEK_END - PARAMETER (MPI_SEEK_SET=600, MPI_SEEK_CUR=602, MPI_SEEK_END=604) -! - INTEGER MPIO_REQUEST_NULL - PARAMETER (MPIO_REQUEST_NULL=0) -! - @FORTRAN_MPI_OFFSET@ MPI_DISPLACEMENT_CURRENT - PARAMETER (MPI_DISPLACEMENT_CURRENT=-54278278) -! -@MPI_OFFSET_KIND1@ -@MPI_OFFSET_KIND2@ -! -@MPI_FARRAY1@ -@MPI_FARRAY2@ -@MPI_FARRAY3@ -@MPI_FARRAY4@ -@MPI_FARRAY5@ -@MPI_FARRAY6@ -@MPI_FARRAY7@ -! -@MPI_FINFO1@ -@MPI_FINFO2@ -@MPI_FINFO3@ -@MPI_FINFO4@ diff --git a/src/mpi/romio/localdefs.in b/src/mpi/romio/localdefs.in index 0a03bedfede..787cb6d29ce 100644 --- a/src/mpi/romio/localdefs.in +++ b/src/mpi/romio/localdefs.in @@ -8,4 +8,3 @@ WRAPPER_LIBS="$WRAPPER_LIBS @LIBS@" MPI_OFFSET_TYPE="@MPI_OFFSET_TYPE@" -FORTRAN_MPI_OFFSET="@FORTRAN_MPI_OFFSET@" From d8c3b9cdaea2b58380f8a4b1f403fbed45d1c0f6 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 22 Dec 2025 16:23:20 -0600 Subject: [PATCH 14/39] mpi.h: only support MPI_Fint as int in mpi.h With MPI 5.0, C programs should not need to use MPI_Fint directly. We hard code MPI_Fint as int in mpi.h, which is the common case, so legacy code should continue to work. If the Fortran compiler uses a different INTEGER size than C int, users can add `-DMPI_FINT_CTYPE=[ctype]` work around the issue. The proper solution is to avoid direct access of MPI_Fint altogether. --- configure.ac | 2 +- src/include/mpi_mpich.h.in | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 62bc6787af9..0f986b528b6 100644 --- a/configure.ac +++ b/configure.ac @@ -3127,7 +3127,7 @@ if test "$enable_f77" = yes ; then if test "$pac_cv_f77_sizeof_integer" = "$ac_cv_sizeof_int" ; then AC_DEFINE(HAVE_FINT_IS_INT,1,[Define if Fortran integer are the same size as C ints]) else - AC_MSG_WARN([Fortran integers and C ints are not the same size. Support for this case is experimental; use at your own risk]) + AC_MSG_WARN([Fortran integers and C ints are not the same size. C programs that directly use MPI_Fint may be incorrect.]) fi # Try and compute the values of .true. and .false. in Fortran diff --git a/src/include/mpi_mpich.h.in b/src/include/mpi_mpich.h.in index c3fb5646e95..eea449f60de 100644 --- a/src/include/mpi_mpich.h.in +++ b/src/include/mpi_mpich.h.in @@ -363,8 +363,12 @@ typedef int MPI_Info; #ifndef MPICH_BUILD_MPI_ABI /* Definitions that are determined by configure. */ +#ifdef MPI_FINT_CTYPE +typedef MPI_FINT_CTYPE MPI_Fint; +#else +typedef int MPI_Fint; +#endif typedef @MPI_AINT@ MPI_Aint; -typedef @MPI_FINT@ MPI_Fint; typedef @MPI_COUNT@ MPI_Count; /* Let ROMIO know that MPI_Offset is already defined */ From 5b65ed2bcbb306b48ea08d9b72e97aadee82be60 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 12 May 2026 11:03:37 -0500 Subject: [PATCH 15/39] configure: refactor wrapper-related macros Move AC_ARG_WITH([wrapper-dl-type],...) into PAC_COMPILER_SHLIB_FLAGS since both need be set together. --- confdb/aclocal_shl.m4 | 9 +++++++++ configure.ac | 15 --------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/confdb/aclocal_shl.m4 b/confdb/aclocal_shl.m4 index e0960d0d5c7..2bd2003db71 100644 --- a/confdb/aclocal_shl.m4 +++ b/confdb/aclocal_shl.m4 @@ -432,6 +432,15 @@ AC_DEFUN([PAC_COMPILER_SHLIB_FLAGS],[ AC_REQUIRE_AUX_FILE([config.rpath]) AC_REQUIRE([AC_CANONICAL_HOST]) +AC_ARG_WITH([wrapper-dl-type],[AS_HELP_STRING([--with-wrapper-dl-type], + [Dynamic loading model for alternate MPI libraries, used when programs are linked + by mpicc compiler wrappers. This only applies when shared libraries are built. + The default is "runpath"; use --with-wrapper-dl-type=rpath to force + rpath; use --with-wrapper-dl-type=none to find shared libraries according to the + rules for your system (e.g., in LD_LIBRARY_PATH)])], + [],[with_wrapper_dl_type=runpath]) +AC_SUBST([with_wrapper_dl_type]) + # It appears that the libtool dynamic linking strategy on Darwin is this: # 1. Link all shared libs with "-install_name /full/path/to/libfoo.dylib" # 2. Don't do anything special when linking programs, since it seems that the diff --git a/configure.ac b/configure.ac index 0f986b528b6..5ad94191c47 100644 --- a/configure.ac +++ b/configure.ac @@ -588,21 +588,6 @@ AC_ARG_ENABLE(multi-aliases, [Multiple aliasing to support multiple fortran compilers (default)]),, enable_multi_aliases=yes) -AC_ARG_WITH([wrapper-dl-type], - [AS_HELP_STRING([--with-wrapper-dl-type], - [Dynamic loading model for alternate MPI - libraries, used when programs are linked - by mpicc compiler wrappers. This only - applies when shared libraries are built. - The default is "runpath"; use - --with-wrapper-dl-type=rpath to force - rpath; use --with-wrapper-dl-type=none to - find shared libraries according to the - rules for your system (e.g., in - LD_LIBRARY_PATH)])], - [],[with_wrapper_dl_type=runpath]) -AC_SUBST([with_wrapper_dl_type]) - AC_ARG_ENABLE([long-double], [AS_HELP_STRING([--disable-long-double], [Pass --disable-long-double to prevent the MPI From 325a8d32082918ac3ba7e0dae2f633bcbd001ad6 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Thu, 7 May 2026 12:36:42 -0500 Subject: [PATCH 16/39] binding/fortran: split mpif_h/cmblk.c and .gitignore Split the part of code from mpif_h/setbot.c that require autoconf substitutions so when we modify mpirinitc_ etc. we don't have to rerun autoconf. Split .gitignore as well since now the fortran binding is treated as separate. --- .gitignore | 44 ----- src/binding/fortran/.gitignore | 44 +++++ src/binding/fortran/mpif_h/Makefile.mk | 1 + .../mpif_h/{setbot.c.in => cmblk.c.in} | 161 +----------------- src/binding/fortran/mpif_h/setbot.c | 157 +++++++++++++++++ 5 files changed, 203 insertions(+), 204 deletions(-) create mode 100644 src/binding/fortran/.gitignore rename src/binding/fortran/mpif_h/{setbot.c.in => cmblk.c.in} (54%) create mode 100644 src/binding/fortran/mpif_h/setbot.c diff --git a/.gitignore b/.gitignore index dd595dc4e7f..40d7fe793e8 100644 --- a/.gitignore +++ b/.gitignore @@ -403,50 +403,6 @@ Makefile.am-stamp /src/binding/cxx/cov2html /src/binding/cxx/*.h -# /src/binding/fortran/mpif_h/ -/src/binding/fortran/mpif_h/include -/src/binding/fortran/mpif_h/Makefile.sm -/src/binding/fortran/mpif_h/mpif_bottom.h -/src/binding/fortran/mpif_h/setbotf.f -/src/binding/fortran/mpif_h/setbot.c -/src/binding/fortran/mpif_h/mpif77.conf -/src/binding/fortran/mpif_h/mpif77 -/src/binding/fortran/mpif_h/fproto.h -/src/binding/fortran/mpif_h/mpif.h -/src/binding/fortran/mpif_h/mpif.h.in -/src/binding/fortran/mpif_h/fortran_profile.h -/src/binding/fortran/mpif_h/fortran_binding.c - -# /src/binding/fortran/use_mpi/ -/src/binding/fortran/use_mpi/mpi_base.f90.orig -/src/binding/fortran/use_mpi/mpi_base.f90.new -/src/binding/fortran/use_mpi/mpif.h -/src/binding/fortran/use_mpi/Makefile.sm -/src/binding/fortran/use_mpi/mpi_t1.f90 -/src/binding/fortran/use_mpi/mpimod.pcl -/src/binding/fortran/use_mpi/mpi_sizeofs.f90 -/src/binding/fortran/use_mpi/mpi_base.f90 -/src/binding/fortran/use_mpi/pmpi_base.f90 -/src/binding/fortran/use_mpi/mpif90type.h -/src/binding/fortran/use_mpi/mpi_constants.f90 -/src/binding/fortran/use_mpi/mpifnoext.h - -# generated by src/binding/fortran/use_mpi_f08/buildiface -/src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90 -/src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90.in -# translated by configure -/src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90 -# generated by gen_binding_f08.py -/src/binding/fortran/use_mpi_f08/mpi_f08.f90 -/src/binding/fortran/use_mpi_f08/pmpi_f08.f90 -/src/binding/fortran/use_mpi_f08/mpi_f08_types.f90 -/src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.f90 -/src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.f90 -/src/binding/fortran/use_mpi_f08/wrappers_f/f08ts.f90 -/src/binding/fortran/use_mpi_f08/wrappers_f/pf08ts.f90 -/src/binding/fortran/use_mpi_f08/wrappers_c/f08_cdesc.c -/src/binding/fortran/use_mpi_f08/wrappers_c/cdesc_proto.h - # generated by maint/gen_coll.py /src/mpi/coll/mpir_coll.c /src/mpi/coll/include/coll_algos.h diff --git a/src/binding/fortran/.gitignore b/src/binding/fortran/.gitignore new file mode 100644 index 00000000000..07c063cacb2 --- /dev/null +++ b/src/binding/fortran/.gitignore @@ -0,0 +1,44 @@ +# mpif_h/ +/mpif_h/include +/mpif_h/Makefile.sm +/mpif_h/mpif_bottom.h +/mpif_h/setbotf.f +/mpif_h/cmblk.c +/mpif_h/mpif77.conf +/mpif_h/mpif77 +/mpif_h/fproto.h +/mpif_h/mpif.h +/mpif_h/mpif.h.in +/mpif_h/fortran_profile.h +/mpif_h/fortran_binding.c + +# use_mpi/ +/use_mpi/mpi_base.f90.orig +/use_mpi/mpi_base.f90.new +/use_mpi/mpif.h +/use_mpi/Makefile.sm +/use_mpi/mpi_t1.f90 +/use_mpi/mpimod.pcl +/use_mpi/mpi_sizeofs.f90 +/use_mpi/mpi_base.f90 +/use_mpi/pmpi_base.f90 +/use_mpi/mpif90type.h +/use_mpi/mpi_constants.f90 +/use_mpi/mpifnoext.h + +# use_mpi_f08/ +/use_mpi_f08/mpi_f08_compile_constants.f90 +/use_mpi_f08/mpi_f08_compile_constants.f90.in +# translated by configure +/use_mpi_f08/mpi_c_interface_types.f90 +# generated by gen_binding_f08.py +/use_mpi_f08/mpi_f08.f90 +/use_mpi_f08/pmpi_f08.f90 +/use_mpi_f08/mpi_f08_types.f90 +/use_mpi_f08/mpi_c_interface_cdesc.f90 +/use_mpi_f08/mpi_c_interface_nobuf.f90 +/use_mpi_f08/wrappers_f/f08ts.f90 +/use_mpi_f08/wrappers_f/pf08ts.f90 +/use_mpi_f08/wrappers_c/f08_cdesc.c +/use_mpi_f08/wrappers_c/cdesc_proto.h + diff --git a/src/binding/fortran/mpif_h/Makefile.mk b/src/binding/fortran/mpif_h/Makefile.mk index 8dad755eae0..c8bda784834 100644 --- a/src/binding/fortran/mpif_h/Makefile.mk +++ b/src/binding/fortran/mpif_h/Makefile.mk @@ -15,6 +15,7 @@ lib_libf77_mpi_la_SOURCES = \ src/binding/fortran/mpif_h/user_proxy.c \ src/binding/fortran/mpif_h/fdebug.c \ src/binding/fortran/mpif_h/setbot.c \ + src/binding/fortran/mpif_h/cmblk.c \ src/binding/fortran/mpif_h/setbotf.f lib_libf77_mpi_la_CPPFLAGS = $(f77_cppflags) diff --git a/src/binding/fortran/mpif_h/setbot.c.in b/src/binding/fortran/mpif_h/cmblk.c.in similarity index 54% rename from src/binding/fortran/mpif_h/setbot.c.in rename to src/binding/fortran/mpif_h/cmblk.c.in index 264377de0ea..3958cf467cd 100644 --- a/src/binding/fortran/mpif_h/setbot.c.in +++ b/src/binding/fortran/mpif_h/cmblk.c.in @@ -5,164 +5,7 @@ #include "mpi_fortimpl.h" - -#ifdef F77_NAME_UPPER -#define mpirinitc_ MPIRINITC -#elif defined(F77_NAME_LOWER_2USCORE) || defined(F77_NAME_LOWER_USCORE) -/* leave name alone */ -#else -#define mpirinitc_ mpirinitc -#endif -/* These functions are called from Fortran so only need prototypes in - this file. Note that the second-to-last argument is a character array, so - we need to include the elements of the Fortran character "dope vector". -*/ -FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, - void *bt, void *ip, void *c_ba, - void *uw, void *ecsi, - void *an FORT_MIXED_LEN(d1), - void *asn FORT_MIXED_LEN(d1), - void *we FORT_END_LEN(d1) FORT_END_LEN(d2)); - -/* - # MPI-2, section 4.12.5, on the declaration of MPI_F_STATUS_IGNORE - # MPI_F_STATUSES_IGNORE as global variables in mpi.h (!) -*/ -int MPIR_F_NeedInit = 1; -void *MPIR_F_MPI_BOTTOM = 0; -void *MPIR_F_MPI_IN_PLACE = 0; -void *MPIR_F_MPI_BUFFER_AUTOMATIC = 0; -void *MPIR_F_MPI_UNWEIGHTED = 0; -/* MPI_F_STATUS_IGNORE etc must be declared within mpi.h (MPI-2 standard - requires this) */ -/* -void *MPI_F_STATUS_IGNORE = 0; -void *MPI_F_STATUSES_IGNORE = 0; -*/ -MPI_Fint *MPI_F_ERRCODES_IGNORE = 0; -void *MPI_F_ARGV_NULL = 0; -void *MPI_F_ARGVS_NULL = 0; -void *MPIR_F_MPI_WEIGHTS_EMPTY = 0; - -static void info_set_int(MPI_Info info, const char *key, int val) -{ - char str[20]; - snprintf(str, 20, "%d", val); - MPI_Info_set(info, key, str); -} - -FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, - void *bt, void *ip, void *c_ba, - void *uw, void *ecsi, - void *an FORT_MIXED_LEN(d1), - void *asn FORT_MIXED_LEN(d1), - void *we FORT_END_LEN(d1) FORT_END_LEN(d2)) -{ - MPI_F_STATUS_IGNORE = (MPI_Fint *) si; - MPI_F_STATUSES_IGNORE = (MPI_Fint *) ssi; - MPIR_F_MPI_BOTTOM = bt; - MPIR_F_MPI_IN_PLACE = ip; - MPIR_F_MPI_BUFFER_AUTOMATIC = c_ba; - MPIR_F_MPI_UNWEIGHTED = uw; - MPI_F_ERRCODES_IGNORE = (MPI_Fint *) ecsi; - MPI_F_ARGV_NULL = an; - MPI_F_ARGVS_NULL = asn; - MPIR_F_MPI_WEIGHTS_EMPTY = we; - - int mpi_is_initialized = 0; - MPI_Initialized(&mpi_is_initialized); - if (!mpi_is_initialized) { - return; - } - - MPIX_Init_fortran(); - - MPIR_F_NeedInit = 0; -} - -void MPIX_Init_fortran(void) -{ - - int mpi_errno; - MPI_Info info; - mpi_errno = MPI_Abi_get_fortran_info(&info); - assert(mpi_errno == MPI_SUCCESS); - - if (info == MPI_INFO_NULL) { - /* MPI_Abi_set_fortran_info */ - MPI_Info_create(&info); - info_set_int(info, "mpi_character_size", MPI_CHARACTER_SIZE); - info_set_int(info, "mpi_logical_size", MPI_LOGICAL_SIZE); - info_set_int(info, "mpi_integer_size", MPI_INTEGER_SIZE); - info_set_int(info, "mpi_real_size", MPI_REAL_SIZE); - info_set_int(info, "mpi_double_precision_size", MPI_DOUBLE_PRECISION_SIZE); -#ifdef MPI_LOGICAL1_SUPPORTED - MPI_Info_set(info, "mpi_logical1_supported", "true"); -#endif -#ifdef MPI_LOGICAL2_SUPPORTED - MPI_Info_set(info, "mpi_logical2_supported", "true"); -#endif -#ifdef MPI_LOGICAL4_SUPPORTED - MPI_Info_set(info, "mpi_logical4_supported", "true"); -#endif -#ifdef MPI_LOGICAL8_SUPPORTED - MPI_Info_set(info, "mpi_logical8_supported", "true"); -#endif -#ifdef MPI_LOGICAL16_SUPPORTED - MPI_Info_set(info, "mpi_logical16_supported", "true"); -#endif -#ifdef MPI_INTEGER1_SUPPORTED - MPI_Info_set(info, "mpi_integer1_supported", "true"); -#endif -#ifdef MPI_INTEGER2_SUPPORTED - MPI_Info_set(info, "mpi_integer2_supported", "true"); -#endif -#ifdef MPI_INTEGER4_SUPPORTED - MPI_Info_set(info, "mpi_integer4_supported", "true"); -#endif -#ifdef MPI_INTEGER8_SUPPORTED - MPI_Info_set(info, "mpi_integer8_supported", "true"); -#endif -#ifdef MPI_INTEGER16_SUPPORTED - MPI_Info_set(info, "mpi_integer16_supported", "true"); -#endif -#ifdef MPI_REAL2_SUPPORTED - MPI_Info_set(info, "mpi_real2_supported", "true"); -#endif -#ifdef MPI_REAL4_SUPPORTED - MPI_Info_set(info, "mpi_real4_supported", "true"); -#endif -#ifdef MPI_REAL8_SUPPORTED - MPI_Info_set(info, "mpi_real8_supported", "true"); -#endif -#ifdef MPI_REAL16_SUPPORTED - MPI_Info_set(info, "mpi_real16_supported", "true"); -#endif -#ifdef MPI_COMPLEX4_SUPPORTED - MPI_Info_set(info, "mpi_complex4_supported", "true"); -#endif -#ifdef MPI_COMPLEX8_SUPPORTED - MPI_Info_set(info, "mpi_complex8_supported", "true"); -#endif -#ifdef MPI_COMPLEX16_SUPPORTED - MPI_Info_set(info, "mpi_complex16_supported", "true"); -#endif -#ifdef MPI_COMPLEX32_SUPPORTED - MPI_Info_set(info, "mpi_complex32_supported", "true"); -#endif -#ifdef MPI_DOUBLE_PRECISION_SUPPORTED - MPI_Info_set(info, "mpi_double_precision_supported", "true"); -#endif - mpi_errno = MPI_Abi_set_fortran_info(info); - assert(mpi_errno == MPI_SUCCESS); - - MPI_Info_free(&info); - - /* MPI_Abi_set_fortran_boolean */ - mpi_errno = MPI_Abi_set_fortran_boolean(MPI_LOGICAL_SIZE, F77_TRUE_VALUE, F77_FALSE_VALUE); - assert(mpi_errno == MPI_SUCCESS); - } -} +#if defined(HAVE_C_MULTI_ATTR_ALIAS) /* Enable all known common block symbols mangling to be alias to each other, @@ -171,8 +14,6 @@ void MPIX_Init_fortran(void) This is done to avoid alignment problem. */ -#if defined(HAVE_C_MULTI_ATTR_ALIAS) - struct mpif_cmblk1_t_ { MPI_Fint MPIF_STATUS_IGNORE[MPI_F_STATUS_SIZE]; }; diff --git a/src/binding/fortran/mpif_h/setbot.c b/src/binding/fortran/mpif_h/setbot.c new file mode 100644 index 00000000000..750abc6625d --- /dev/null +++ b/src/binding/fortran/mpif_h/setbot.c @@ -0,0 +1,157 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +#include "mpi_fortimpl.h" + + +#ifdef F77_NAME_UPPER +#define mpirinitc_ MPIRINITC +#elif defined(F77_NAME_LOWER_2USCORE) || defined(F77_NAME_LOWER_USCORE) +/* leave name alone */ +#else +#define mpirinitc_ mpirinitc +#endif +/* These functions are called from Fortran so only need prototypes in + this file. Note that the second-to-last argument is a character array, so + we need to include the elements of the Fortran character "dope vector". +*/ +FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, + void *bt, void *ip, void *c_ba, + void *uw, void *ecsi, + void *an FORT_MIXED_LEN(d1), + void *asn FORT_MIXED_LEN(d1), + void *we FORT_END_LEN(d1) FORT_END_LEN(d2)); + +/* + # MPI-2, section 4.12.5, on the declaration of MPI_F_STATUS_IGNORE + # MPI_F_STATUSES_IGNORE as global variables in mpi.h (!) +*/ +int MPIR_F_NeedInit = 1; +void *MPIR_F_MPI_BOTTOM = 0; +void *MPIR_F_MPI_IN_PLACE = 0; +void *MPIR_F_MPI_BUFFER_AUTOMATIC = 0; +void *MPIR_F_MPI_UNWEIGHTED = 0; +/* MPI_F_STATUS_IGNORE etc must be declared within mpi.h (MPI-2 standard + requires this) */ +/* +void *MPI_F_STATUS_IGNORE = 0; +void *MPI_F_STATUSES_IGNORE = 0; +*/ +MPI_Fint *MPI_F_ERRCODES_IGNORE = 0; +void *MPI_F_ARGV_NULL = 0; +void *MPI_F_ARGVS_NULL = 0; +void *MPIR_F_MPI_WEIGHTS_EMPTY = 0; + +FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, + void *bt, void *ip, void *c_ba, + void *uw, void *ecsi, + void *an FORT_MIXED_LEN(d1), + void *asn FORT_MIXED_LEN(d1), + void *we FORT_END_LEN(d1) FORT_END_LEN(d2)) +{ + MPI_F_STATUS_IGNORE = (MPI_Fint *) si; + MPI_F_STATUSES_IGNORE = (MPI_Fint *) ssi; + MPIR_F_MPI_BOTTOM = bt; + MPIR_F_MPI_IN_PLACE = ip; + MPIR_F_MPI_BUFFER_AUTOMATIC = c_ba; + MPIR_F_MPI_UNWEIGHTED = uw; + MPI_F_ERRCODES_IGNORE = (MPI_Fint *) ecsi; + MPI_F_ARGV_NULL = an; + MPI_F_ARGVS_NULL = asn; + MPIR_F_MPI_WEIGHTS_EMPTY = we; + + int mpi_is_initialized = 0; + MPI_Initialized(&mpi_is_initialized); + if (!mpi_is_initialized) { + return; + } + + MPIX_Init_fortran(); + + MPIR_F_NeedInit = 0; +} + +void MPIX_Init_fortran(void) +{ + int mpi_errno; + MPI_Info info; + mpi_errno = MPI_Abi_get_fortran_info(&info); + assert(mpi_errno == MPI_SUCCESS); + + if (info == MPI_INFO_NULL) { + /* MPI_Abi_set_fortran_info */ + MPI_Info_create(&info); + MPI_Info_set(info, "mpi_character_size", MPI_CHARACTER_SIZE); + MPI_Info_set(info, "mpi_logical_size", MPI_LOGICAL_SIZE); + MPI_Info_set(info, "mpi_integer_size", MPI_INTEGER_SIZE); + MPI_Info_set(info, "mpi_real_size", MPI_REAL_SIZE); + MPI_Info_set(info, "mpi_double_precision_size", MPI_DOUBLE_PRECISION_SIZE); +#ifdef MPI_LOGICAL1_SUPPORTED + MPI_Info_set(info, "mpi_logical1_supported", "true"); +#endif +#ifdef MPI_LOGICAL2_SUPPORTED + MPI_Info_set(info, "mpi_logical2_supported", "true"); +#endif +#ifdef MPI_LOGICAL4_SUPPORTED + MPI_Info_set(info, "mpi_logical4_supported", "true"); +#endif +#ifdef MPI_LOGICAL8_SUPPORTED + MPI_Info_set(info, "mpi_logical8_supported", "true"); +#endif +#ifdef MPI_LOGICAL16_SUPPORTED + MPI_Info_set(info, "mpi_logical16_supported", "true"); +#endif +#ifdef MPI_INTEGER1_SUPPORTED + MPI_Info_set(info, "mpi_integer1_supported", "true"); +#endif +#ifdef MPI_INTEGER2_SUPPORTED + MPI_Info_set(info, "mpi_integer2_supported", "true"); +#endif +#ifdef MPI_INTEGER4_SUPPORTED + MPI_Info_set(info, "mpi_integer4_supported", "true"); +#endif +#ifdef MPI_INTEGER8_SUPPORTED + MPI_Info_set(info, "mpi_integer8_supported", "true"); +#endif +#ifdef MPI_INTEGER16_SUPPORTED + MPI_Info_set(info, "mpi_integer16_supported", "true"); +#endif +#ifdef MPI_REAL2_SUPPORTED + MPI_Info_set(info, "mpi_real2_supported", "true"); +#endif +#ifdef MPI_REAL4_SUPPORTED + MPI_Info_set(info, "mpi_real4_supported", "true"); +#endif +#ifdef MPI_REAL8_SUPPORTED + MPI_Info_set(info, "mpi_real8_supported", "true"); +#endif +#ifdef MPI_REAL16_SUPPORTED + MPI_Info_set(info, "mpi_real16_supported", "true"); +#endif +#ifdef MPI_COMPLEX4_SUPPORTED + MPI_Info_set(info, "mpi_complex4_supported", "true"); +#endif +#ifdef MPI_COMPLEX8_SUPPORTED + MPI_Info_set(info, "mpi_complex8_supported", "true"); +#endif +#ifdef MPI_COMPLEX16_SUPPORTED + MPI_Info_set(info, "mpi_complex16_supported", "true"); +#endif +#ifdef MPI_COMPLEX32_SUPPORTED + MPI_Info_set(info, "mpi_complex32_supported", "true"); +#endif +#ifdef MPI_DOUBLE_PRECISION_SUPPORTED + MPI_Info_set(info, "mpi_double_precision_supported", "true"); +#endif + mpi_errno = MPI_Abi_set_fortran_info(info); + assert(mpi_errno == MPI_SUCCESS); + + MPI_Info_free(&info); + + /* MPI_Abi_set_fortran_boolean */ + mpi_errno = MPI_Abi_set_fortran_boolean(MPI_LOGICAL_SIZE, F77_TRUE_VALUE, F77_FALSE_VALUE); + assert(mpi_errno == MPI_SUCCESS); + } +} From 9325709545fc7157f7fc4ab0a1382c63f15eabf9 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Thu, 1 Jan 2026 18:35:47 -0600 Subject: [PATCH 17/39] binding/fortran: running python gen scripts from subdir The binding generation scripts can be run - 1. autogen from mpich main_top_srcdir. 2. src/binding/fortran/configure within the mpich source tree. 3. fortran binding tarball, i.e. src/binding/fortran without mpich source tree. This commit makes all 3 ways work. Option 2 and 3 of course depends on next commits. Set default option for "-mpi-h", which will be used for standalone libmpifort build. Remove the autogen check. In the coming commits, the python script will directly generate files without autoconf macros. --- maint/gen_binding_c.py | 19 +++++++--------- maint/gen_binding_f08.py | 38 ++++++++++++++----------------- maint/gen_binding_f77.py | 20 +++++++--------- maint/gen_binding_f90.py | 14 +++++------- maint/local_python/__init__.py | 26 ++++++++++++++++++--- maint/local_python/binding_f08.py | 2 +- maint/local_python/binding_f77.py | 2 +- 7 files changed, 64 insertions(+), 57 deletions(-) diff --git a/maint/gen_binding_c.py b/maint/gen_binding_c.py index 7538da501ad..c2e4a04087a 100644 --- a/maint/gen_binding_c.py +++ b/maint/gen_binding_c.py @@ -14,10 +14,7 @@ def main(): # currently support: -single-source G.parse_cmdline() - binding_dir = G.get_srcdir_path("src/binding") - c_dir = "src/binding/c" - abi_dir = "src/binding/abi" - func_list = load_C_func_list(binding_dir) + func_list = load_C_func_list(G.binding_dir) # -- Loading extra api prototypes (needed until other `buildiface` scripts are updated) G.mpi_declares = [] @@ -117,14 +114,14 @@ def dump_c_binding(): if 'single-source' not in G.opts: # dump individual functions in separate source files - dump_out(get_func_file_path(func, c_dir)) + dump_out(get_func_file_path(func, G.c_dir)) G.out = [] G.out.append("#include \"mpiimpl.h\"") G.out.append("") if 'single-source' in G.opts: # otherwise, dump all functions in binding.c - dump_out(c_dir + "/c_binding.c") + dump_out(G.c_dir + "/c_binding.c") def dump_c_binding_abi(): G.out = [] @@ -150,7 +147,7 @@ def dump_c_binding_abi(): for t_func in func['_replaces']: dump_func_abi(t_func) - abi_file_path = abi_dir + "/c_binding_abi.c" + abi_file_path = G.abi_dir + "/c_binding_abi.c" G.check_write_path(abi_file_path) dump_c_file(abi_file_path, G.out) @@ -163,7 +160,7 @@ def dump_io_funcs(): for func in io_func_list: dump_func(func, do_doc) - dump_out(c_dir + "/io.c") + dump_out(G.c_dir + "/io.c") def dump_io_funcs_abi(): G.out = [] @@ -178,7 +175,7 @@ def dump_io_funcs_abi(): continue dump_func_abi(func) - abi_file_path = abi_dir + "/io_abi.c" + abi_file_path = G.abi_dir + "/io_abi.c" G.check_write_path(abi_file_path) dump_c_file(abi_file_path, G.out) @@ -198,10 +195,10 @@ def dump_io_funcs_abi(): G.check_write_path("src/include") G.check_write_path("src/mpi_t") G.check_write_path("src/include/mpi_proto.h") - dump_Makefile_mk("%s/Makefile.mk" % c_dir) + dump_Makefile_mk("%s/Makefile.mk" % G.c_dir) dump_mpir_impl_h("src/include/mpir_impl.h") dump_mpir_io_impl_h("src/include/mpir_io_impl.h") - dump_errnames_txt("%s/errnames.txt" % c_dir) + dump_errnames_txt("%s/errnames.txt" % G.c_dir) dump_qmpi_register_h("src/mpi_t/qmpi_register.h") dump_mpi_proto_h("src/include/mpi_proto.h") dump_mtest_mpix_h("test/mpi/include/mtest_mpix.h") diff --git a/maint/gen_binding_f08.py b/maint/gen_binding_f08.py index f19339a4787..23c98eac72c 100644 --- a/maint/gen_binding_f08.py +++ b/maint/gen_binding_f08.py @@ -14,11 +14,9 @@ def main(): # currently support -no-real128, -fint-size, -aint-size, -count-size, -cint-size G.parse_cmdline() - binding_dir = G.get_srcdir_path("src/binding") - f08_dir = "src/binding/fortran/use_mpi_f08" - G.check_write_path("%s/wrappers_f/" % f08_dir) - G.check_write_path("%s/wrappers_c/" % f08_dir) - func_list = load_C_func_list(binding_dir, True) # suppress noise + G.check_write_path("%s/wrappers_f/" % G.f08_dir) + G.check_write_path("%s/wrappers_c/" % G.f08_dir) + func_list = load_C_func_list(G.binding_dir, True) # suppress noise # preprocess get_real_POLY_kinds() @@ -47,9 +45,9 @@ def main(): if func['_need_large']: G.out.append("") dump_f08_wrappers_c(func, True) - f = "%s/wrappers_c/f08_cdesc.c" % f08_dir + f = "%s/wrappers_c/f08_cdesc.c" % G.f08_dir dump_cdesc_c(f, G.out) - f = "%s/wrappers_c/cdesc_proto.h" % f08_dir + f = "%s/wrappers_c/cdesc_proto.h" % G.f08_dir dump_cdesc_proto_h(f, G.decls) # f08ts.f90 @@ -58,7 +56,7 @@ def main(): dump_f08_wrappers_f(func, False) if func['_need_large']: dump_f08_wrappers_f(func, True) - f = "%s/wrappers_f/f08ts.f90" % f08_dir + f = "%s/wrappers_f/f08ts.f90" % G.f08_dir dump_f90_file(f, G.out) do_profiling = True @@ -66,7 +64,7 @@ def main(): temp_out = [] for l in G.out: temp_out.append(re.sub(r'(subroutine|function)\s+(MPIX?)_', r'\1 P\2R_', l, flags=re.IGNORECASE)) - f = "%s/wrappers_f/pf08ts.f90" % f08_dir + f = "%s/wrappers_f/pf08ts.f90" % G.f08_dir dump_f90_file(f, temp_out) temp_out = None @@ -79,7 +77,7 @@ def main(): if func['_need_large']: dump_mpi_c_interface_cdesc(func, True) dump_interface_module_close("mpi_c_interface_cdesc") - f = "%s/mpi_c_interface_cdesc.f90" % f08_dir + f = "%s/mpi_c_interface_cdesc.f90" % G.f08_dir dump_f90_file(f, G.out) G.out = [] @@ -90,7 +88,7 @@ def main(): if func['_need_large']: dump_mpi_c_interface_nobuf(func, True) dump_interface_module_close("mpi_c_interface_nobuf") - f = "%s/mpi_c_interface_nobuf.f90" % f08_dir + f = "%s/mpi_c_interface_nobuf.f90" % G.f08_dir dump_f90_file(f, G.out) # mpi_f08.f90 and pmpi_f08.f90 @@ -127,7 +125,7 @@ def main(): G.out.append("") dump_F_module_close("mpi_f08") - f = "%s/mpi_f08.f90" % f08_dir + f = "%s/mpi_f08.f90" % G.f08_dir dump_f90_file(f, G.out) if do_profiling: @@ -141,23 +139,21 @@ def main(): temp_out.append(RE.m.group(1) + ' P' + RE.m.group(2)) else: temp_out.append(re.sub(r'(subroutine|function)\s+(MPIX?)_', r'\1 P\2R_', l, flags=re.IGNORECASE)) - f = "%s/pmpi_f08.f90" % f08_dir + f = "%s/pmpi_f08.f90" % G.f08_dir dump_f90_file(f, temp_out) temp_out = None # mpi_f08_types.f90 G.out = [] dump_mpi_f08_types() - f = "%s/mpi_f08_types.f90" % f08_dir + f = "%s/mpi_f08_types.f90" % G.f08_dir dump_f90_file(f, G.out) - # .in files has to be generated in the source tree - if G.is_autogen(): - # mpi_f08_compile_constants.f90.in - G.mpih_defines = {} - load_mpi_h_in("src/include/mpi_mpich.h.in") - f = "%s/mpi_f08_compile_constants.f90.in" % f08_dir - dump_compile_constants_f90(f) + # mpi_f08_compile_constants.f90 + G.mpih_defines = {} + load_mpi_h(G.opts['mpi-h']) + f = "%s/mpi_f08_compile_constants.f90.in" % G.f08_dir + dump_compile_constants_f90(f) # --------------------------------------------------------- if __name__ == "__main__": diff --git a/maint/gen_binding_f77.py b/maint/gen_binding_f77.py index 8b011359110..4f41518a475 100644 --- a/maint/gen_binding_f77.py +++ b/maint/gen_binding_f77.py @@ -14,10 +14,7 @@ def main(): # currently support -no-real128, -aint-is-int G.parse_cmdline() - binding_dir = G.get_srcdir_path("src/binding") - f77_dir = "src/binding/fortran/mpif_h" - - func_list = load_C_func_list(binding_dir, True) # suppress noise + func_list = load_C_func_list(G.binding_dir, True) # suppress noise func_list.extend(get_f77_dummy_func_list()) @@ -41,18 +38,17 @@ def has_cptr(func): if has_cptr(func): dump_f77_c_func(func, True) - f = "%s/fortran_binding.c" % f77_dir + f = "%s/fortran_binding.c" % G.f77_dir dump_f77_c_file(f, G.out) - f = "%s/fortran_profile.h" % f77_dir + f = "%s/fortran_profile.h" % G.f77_dir dump_f77_c_file(f, G.profile_out) - # .in files has to be generated in the source tree - if G.is_autogen(): - G.mpih_defines = {} - load_mpi_h_in("src/include/mpi_mpich.h.in") - f = "%s/mpif.h.in" % f77_dir - dump_mpif_h(f) + # mpif.h + G.mpih_defines = {} + load_mpi_h(G.opts['mpi-h']) + f = "%s/mpif.h.in" % G.f77_dir + dump_mpif_h(f) # --------------------------------------------------------- if __name__ == "__main__": diff --git a/maint/gen_binding_f90.py b/maint/gen_binding_f90.py index 2aa95c9defa..daa8c55fa0e 100644 --- a/maint/gen_binding_f90.py +++ b/maint/gen_binding_f90.py @@ -13,10 +13,8 @@ def main(): G.parse_cmdline() - binding_dir = G.get_srcdir_path("src/binding") - f90_dir = "src/binding/fortran/use_mpi" - G.check_write_path("%s/" % f90_dir) - func_list = load_C_func_list(binding_dir, True) # suppress noise + G.check_write_path("%s/" % G.f90_dir) + func_list = load_C_func_list(G.binding_dir, True) # suppress noise func_list.extend(get_f77_dummy_func_list()) def has_cptr(func): @@ -45,7 +43,7 @@ def has_cptr(func): G.out.append("") dump_F_module_close("mpi_base") - f = "%s/mpi_base.f90" % f90_dir + f = "%s/mpi_base.f90" % G.f90_dir dump_f90_file(f, G.out) # pmpi_base.f90 @@ -67,7 +65,7 @@ def has_cptr(func): G.out.append("") dump_F_module_close("pmpi_base") - f = "%s/pmpi_base.f90" % f90_dir + f = "%s/pmpi_base.f90" % G.f90_dir dump_f90_file(f, G.out) # mpi_constants.f90 @@ -76,7 +74,7 @@ def has_cptr(func): dump_f90_constants() dump_F_module_close("mpi_constants") - f = "%s/mpi_constants.f90" % f90_dir + f = "%s/mpi_constants.f90" % G.f90_dir dump_f90_file(f, G.out) # mpi_sizeofs.f90 @@ -85,7 +83,7 @@ def has_cptr(func): dump_f90_sizeofs() dump_F_module_close("mpi_sizeofs") - f = "%s/mpi_sizeofs.f90" % f90_dir + f = "%s/mpi_sizeofs.f90" % G.f90_dir dump_f90_file(f, G.out) # --------------------------------------------------------- diff --git a/maint/local_python/__init__.py b/maint/local_python/__init__.py index a81778b6f95..d11475939e1 100644 --- a/maint/local_python/__init__.py +++ b/maint/local_python/__init__.py @@ -8,9 +8,6 @@ import sys def get_srcdir(): - if os.path.exists("maint/local_python/__init__.py"): - return "." - m = re.match(r'(.*)\/maint\/local_python', __file__) if m: return m.group(1) @@ -19,6 +16,14 @@ def get_srcdir(): else: raise Exception("Can't determine srcdir from __file__") +def get_binding_dir(srcdir): + if os.path.exists(srcdir + "/src/binding/mpi_standard_api.txt"): + return srcdir + "/src/binding" + elif os.path.exists(srcdir + "/maint/mpi_standard_api.txt"): + return srcdir + "/src/maint" + else: + raise Exception("Can't find mpi_standard_api.txt") + # RE class allows convenience of using regex capture in a condition class RE: m = None @@ -32,6 +37,20 @@ def search(pat, str, flags=0): # Global data used across modules class MPI_API_Global: srcdir = get_srcdir() + binding_dir = get_binding_dir(srcdir) + if os.path.exists("mpif_h"): + # stand-alone fortran binding + f77_dir = "mpif_h" + f90_dir = "use_mpi" + f08_dir = "use_mpi_f08" + elif os.path.exists("src/binding/c"): + c_dir = "src/binding/c" + abi_dir = "src/binding/abi" + f77_dir = "src/binding/fortran/mpif_h" + f90_dir = "src/binding/fortran/use_mpi" + f08_dir = "src/binding/fortran/use_mpi_f08" + else: + raise Exception("Can't determine output directories") def is_autogen(): return MPI_API_Global.srcdir == "." @@ -48,6 +67,7 @@ def check_write_path(path): # The F08 bindings use the sizes to detect duplicate large interfaces # The F90 bindings use the sizes to implement MPI_SIZEOF (although deprecated in MPI-4) opts = {'fint-size':4, 'aint-size':8, 'count-size':8, 'cint-size':4, 'f-logical-size':4, + 'mpi-h':'src/include/mpi_mpich.h.in', 'iso-c-binding':'yes'} args = [] diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index f372f638610..9f37d9c8585 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -1647,7 +1647,7 @@ def dump_compile_constants_f90(f): print("end module mpi_f08_compile_constants", file=Out) -def load_mpi_h_in(f): +def load_mpi_h(f): def hex_to_signed_int(s): val = int(s, 16) if val >= 0x80000000: diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 5007e9795c2..39460a04df3 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -1061,7 +1061,7 @@ def dump_mpif_h(f): print(" SAVE /MPIFCMB5/, /MPIFCMB9/, /MPIFCMBa/", file=Out) print(" SAVE /MPIPRIV1/, /MPIPRIV2/, /MPIPRIVC/", file=Out) -def load_mpi_h_in(f): +def load_mpi_h(f): def hex_to_signed_int(s): val = int(s, 16) if val >= 0x80000000: From ebaa50fddb6150db8193e8a14d548b0a65cd72e9 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sun, 21 Dec 2025 15:26:33 -0600 Subject: [PATCH 18/39] fortran: fortran binding as a separate package Configure and build the fortran binding separately from MPICH. --- Makefile.am | 35 +- autogen.sh | 23 + confdb/aclocal_fc.m4 | 13 + confdb/aclocal_util.m4 | 2 +- configure.ac | 1046 +---------------- maint/gen_binding_f08.py | 2 +- maint/gen_binding_f77.py | 2 +- maint/local_python/__init__.py | 4 +- maint/local_python/binding_f08.py | 60 +- maint/local_python/binding_f77.py | 70 +- maint/release.pl | 10 + src/binding/Makefile.mk | 3 - src/binding/fortran/Makefile.am | 45 + src/binding/fortran/autogen.sh | 49 + src/binding/fortran/configure.ac | 1030 ++++++++++++++++ src/binding/fortran/localdefs.in | 6 + src/binding/fortran/mpif_h/Makefile.mk | 30 +- src/binding/fortran/mpif_h/mpi_fortimpl.h | 21 +- src/binding/fortran/mpif_h/setbot.c | 36 +- src/binding/fortran/mpif_h/user_proxy.c | 5 + src/binding/fortran/use_mpi/Makefile.mk | 198 ++-- src/binding/fortran/use_mpi_f08/Makefile.mk | 466 ++++---- .../fortran/use_mpi_f08/wrappers_c/cdesc.h | 2 +- src/env/Makefile.mk | 2 - 24 files changed, 1700 insertions(+), 1460 deletions(-) create mode 100644 src/binding/fortran/Makefile.am create mode 100755 src/binding/fortran/autogen.sh create mode 100644 src/binding/fortran/configure.ac create mode 100644 src/binding/fortran/localdefs.in diff --git a/Makefile.am b/Makefile.am index 92147fe7b46..84d2bd21d50 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,8 +9,6 @@ ACLOCAL_AMFLAGS = -I confdb # before appending to them with "+=" AM_CFLAGS = @VISIBILITY_CFLAGS@ AM_CPPFLAGS = -AM_FFLAGS = -AM_FCFLAGS = include_HEADERS = nodist_include_HEADERS = nodist_noinst_HEADERS = @@ -47,7 +45,7 @@ pkgconfigdir = @pkgconfigdir@ # to build src/mpi/errhan/defmsg.h errnames_txt_files = -external_subdirs = @mpl_srcdir@ @hwloc_srcdir@ @json_srcdir@ @yaksa_srcdir@ @pmi_srcdir@ +external_subdirs = @mpl_srcdir@ @hwloc_srcdir@ @json_srcdir@ @yaksa_srcdir@ @pmi_srcdir@ @fortrandir@ external_ldflags = @RPATHS@ external_libs = @WRAPPER_LIBS@ @@ -77,19 +75,6 @@ lib_lib@PMPILIBNAME@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(lib_lib@PMPILIBNAME@_la_CFLAGS) $(CFLAGS) \ $(lib_lib@PMPILIBNAME@_la_LDFLAGS) $(LDFLAGS) -o $@ -if BUILD_F77_BINDING -if BUILD_FC_BINDING -lib_lib@MPIFCLIBNAME@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=FC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(FCLD) \ - $(AM_FCFLAGS) $(FCFLAGS) $(lib_lib@MPIFCLIBNAME@_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -else !BUILD_FC_BINDING -lib_lib@MPIFCLIBNAME@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=F77 \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(F77LD) \ - $(AM_FFLAGS) $(FFLAGS) $(lib_lib@MPIFCLIBNAME@_la_LDFLAGS) \ - $(LDFLAGS) -o $@ -endif !BUILD_FC_BINDING -endif BUILD_F77_BINDING ## Create lists of files for different libraries ## @@ -111,11 +96,9 @@ endif BUILD_F77_BINDING ## that are used by all bindings. mpi_sources = mpi_abi_sources = -mpi_fc_modules = mpi_cxx_sources = mpi_core_sources = mpi_abi_core_sources = -mpifort_convenience_libs = @mpl_lib@ lib_LTLIBRARIES = @@ -160,8 +143,6 @@ abi_cppflags = -DMPICH_BUILD_MPI_ABI -I$(srcdir)/src/binding/abi if BUILD_PROFILING_LIB # -------- mpi-abi: libpmpi + libmpi ------------------ # -# dropping mpi_fc_sources and mpi_cxx_sources from libmpmpi since they -# don't contribute any PMPI symbols. lib_LTLIBRARIES += lib/lib@PMPILIBNAME@.la lib_lib@PMPILIBNAME@_la_SOURCES = $(mpi_abi_sources) $(mpi_f77_sources) $(mpi_core_sources) $(mpi_abi_core_sources) lib_lib@PMPILIBNAME@_la_LDFLAGS = $(external_ldflags) $(ABIVERSIONFLAGS) @@ -191,16 +172,6 @@ EXTRA_lib_lib@MPILIBNAME@_la_DEPENDENCIES = $(pmpi_convenience_libs) $(abi_conve endif !BUILD_PROFILING_LIB endif BUILD_ABI_LIB -if BUILD_F77_BINDING -lib_LTLIBRARIES += lib/lib@MPIFCLIBNAME@.la -lib_lib@MPIFCLIBNAME@_la_SOURCES = -if BUILD_FC_BINDING -modinc_HEADERS = $(mpi_fc_modules) -endif BUILD_FC_BINDING -lib_lib@MPIFCLIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS) @FCLIB_LDFLAGS@ -lib_lib@MPIFCLIBNAME@_la_LIBADD = lib/lib@MPILIBNAME@.la $(mpifort_convenience_libs) -endif BUILD_F77_BINDING - if ! BUILD_ABI_LIB if BUILD_CXX_BINDING lib_LTLIBRARIES += lib/lib@MPICXXLIBNAME@.la @@ -252,7 +223,6 @@ install-exec-hook: cd ${DESTDIR}${bindir} && ln -f -s @MPICXX_NAME@ @MPICPP_NAME@ ; \ fi ; \ fi ; -if BUILD_FC_BINDING if INSTALL_MPIF90 if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ if test "@MPIFORT_NAME@" != "@MPIF90_NAME@" ; then \ @@ -260,8 +230,6 @@ if INSTALL_MPIF90 fi ; \ fi ; endif INSTALL_MPIF90 -endif BUILD_FC_BINDING -if BUILD_F77_BINDING if INSTALL_MPIF77 if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ if test "@MPIFORT_NAME@" != "@MPIF77_NAME@" ; then \ @@ -269,7 +237,6 @@ if INSTALL_MPIF77 fi ; \ fi ; endif INSTALL_MPIF77 -endif BUILD_F77_BINDING # the configure step checks for the 'lib' dir to decide whether a source diff --git a/autogen.sh b/autogen.sh index ce7fb2957a8..14a0c87f0ed 100755 --- a/autogen.sh +++ b/autogen.sh @@ -172,6 +172,10 @@ set_externals() { # external packages that require autogen.sh to be run for each of them externals="src/mpl test/mpi" + if [ "yes" = "$do_fortran" ] ; then + externals="${externals} src/binding/fortran" + fi + if [ "yes" = "$do_hydra" ] ; then externals="${externals} src/pm/hydra" fi @@ -297,6 +301,24 @@ fn_pmi() { (cd src/pmi && ./autogen.sh) } +# ./autogen.sh -do=fortran if *only* build libfortran +fn_fortran() { + dir=src/binding/fortran + echo "####################################" + echo "## Prepareing src/binding/fortran ##" + echo "####################################" + cp -pPR maint/version.m4 $dir/version.m4 + sync_external confdb $dir/confdb + + rm -rf "$dir/maint" + mkdir -p "$dir/maint" + cp -pPR maint/local_python $dir/maint/ + cp maint/gen_{f77,f90,f08}.py $dir/maint/ + cp src/binding/*.txt $dir/maint/ + + (cd $dir && ./autogen.sh) +} + # ./autogen.sh -do=test if *only* build testsuite fn_test() { echo "####################################" @@ -320,6 +342,7 @@ fn_copy_confdb_etc() { # a couple of other random files if [ -f maint/version.m4 ] ; then + cp -pPR maint/version.m4 src/binding/fortran/version.m4 cp -pPR maint/version.m4 src/pm/hydra/version.m4 cp -pPR maint/version.m4 src/mpi/romio/version.m4 cp -pPR maint/version.m4 src/pmi/version.m4 diff --git a/confdb/aclocal_fc.m4 b/confdb/aclocal_fc.m4 index 8eb4998b4f0..697c3334eef 100644 --- a/confdb/aclocal_fc.m4 +++ b/confdb/aclocal_fc.m4 @@ -120,6 +120,19 @@ else AC_LANG_POP(Fortran) fi # is not cross compiling ])dnl + +dnl determine the ISO_C_BINDING integer types +AC_DEFUN([PAC_PROG_FC_C_INT_TYPE],[ + AC_MSG_CHECKING([for $2]) + AS_CASE("$1", + [$ac_cv_sizeof_short], [$2="c_short"], + [$ac_cv_sizeof_int], [$2="c_int"], + [$ac_cv_sizeof_long], [$2="c_long"], + [$ac_cv_sizeof_long_long], [$2="c_long_long"], + [AC_MSG_ERROR([unable to determine C type for $2 in Fortran 2008])]) + AC_MSG_RESULT([$$2]) +]) + dnl dnl ------------------------------------------------------------------------ dnl Special characteristics that have no autoconf counterpart but that diff --git a/confdb/aclocal_util.m4 b/confdb/aclocal_util.m4 index 5cb0fe0b59d..bc2ea9096f0 100644 --- a/confdb/aclocal_util.m4 +++ b/confdb/aclocal_util.m4 @@ -3,7 +3,7 @@ dnl Usage: PAC_APPEND_CSV([foo], [bar]) AC_DEFUN([PAC_APPEND_CSV],[ AS_IF([test -n "$$2"], [$2="$$2, $1"], - [$2=$1]) + [$2="$1"]) ]) dnl Nesting safe macros for saving variables diff --git a/configure.ac b/configure.ac index 5ad94191c47..6f54b77bcbf 100644 --- a/configure.ac +++ b/configure.ac @@ -462,15 +462,6 @@ dnl interfaces including mpif.h, use mpi, and use_mpi_f08. AC_ARG_ENABLE(fortran, AS_HELP_STRING([--disable-fortran], [Whether to disable Fortran bindings]),,[enable_fortran=yes]) -AC_ARG_ENABLE(f77, - AS_HELP_STRING([--disable-f77], [Whether to disable "include 'mpif.h'" interface]),,[enable_f77=yes]) - -AC_ARG_ENABLE(f90, - AS_HELP_STRING([--disable-f90], [Whether to disable "use mpi" interface]),,[enable_f90=yes]) - -AC_ARG_ENABLE(f08, - AS_HELP_STRING([--disable-f08], [Whether to disable "use mpi_f08" interface]),,[enable_f08=yes]) - AC_ARG_ENABLE(cxx, AS_HELP_STRING([--enable-cxx], [Enable C++ bindings]),,enable_cxx=yes) @@ -488,9 +479,14 @@ AC_ARG_ENABLE(mpi-abi, AM_CONDITIONAL([BUILD_ABI_LIB], [test "$enable_mpi_abi" = "yes"]) AC_SUBST(enable_mpi_abi) +# export $WITH_MPI for libmpifort if test "$enable_mpi_abi" = "yes" ; then enable_cxx=no + WITH_MPI=abi +else + WITH_MPI=mpich fi +export WITH_MPI ## Enable creation of libtool-style versioning or no versioning AC_ARG_ENABLE(versioning, @@ -583,10 +579,6 @@ else fi AC_SUBST(ENABLE_QMPI) -AC_ARG_ENABLE(multi-aliases, - AS_HELP_STRING([--enable-multi-aliases], - [Multiple aliasing to support multiple fortran compilers (default)]),, - enable_multi_aliases=yes) AC_ARG_ENABLE([long-double], [AS_HELP_STRING([--disable-long-double], @@ -647,12 +639,21 @@ AC_ARG_ENABLE([nvml], [AS_HELP_STRING([--disable-nvml], [passed to hwloc])]) AC_ARG_ENABLE([opencl], [AS_HELP_STRING([--disable-opencl], [passed to hwloc])]) AC_ARG_ENABLE([rsmi], [AS_HELP_STRING([--disable-rsmi], [passed to hwloc])]) +# options passed to libmpifort configure +AC_ARG_ENABLE([two-level-namespace], + [AS_HELP_STRING([--enable-two-level-namespace], + [(Darwin only) Do not use `-Wl,-flat_namespace` to + link libmpifort.dylib. MacOS uses two-level namespace + to compile dylibs by default. This may cause issues + not resolving MPI constants, such as MPI_IN_PLACE. + Thus, we use flat_namespace by default. Enable this + option to use two-level-namespace instead. ])], + [], + [enable_two_level_namespace=no]) + AC_CANONICAL_TARGET -# Find a C compiler. -# We also need to do this before the F77 and FC test to ensure that we -# find the C preprocessor reliably. AC_PROG_CC # Modern autoconf aggressively probe gnu std support and will append (e.g.) -std=gnu23 to $CC @@ -746,27 +747,6 @@ if test "$pac_cv_cxx_builds_exe" = "no" ; then CXX= fi -if test "$enable_fortran" = "no" ; then - enable_f77=no - enable_f90=no - enable_f08=no -fi - -# Python 3 is needed to generate Fortran bindings -PAC_CHECK_PYTHON - -if test "$enable_fortran" != "no" ; then - # suppress default "-g -O2" from AC_PROG_FC - : ${FCFLAGS=""} - AC_PROG_FC - - F77=$FC - - FFLAGS=$FCFLAGS - AC_PROG_F77 - -fi - AM_CONDITIONAL([INSTALL_MPIF90],[true]) AM_CONDITIONAL([INSTALL_MPIF77],[true]) @@ -849,10 +829,6 @@ export CFLAGS export CPPFLAGS export CXX export CXXFLAGS -export F77 -export FC -export FCFLAGS -export FFLAGS export LDFLAGS export LIBS @@ -889,7 +865,6 @@ m4_map([PAC_SUBCFG_DO_PREREQ], [PAC_SUBCFG_MODULE_LIST]) AC_ARG_VAR([MPILIBNAME],[can be used to override the name of the MPI library (default: "mpi")]) AC_ARG_VAR([PMPILIBNAME],[can be used to override the name of the MPI profiling library (default: "p$MPILIBNAME")]) AC_ARG_VAR([MPICXXLIBNAME],[can be used to override the name of the MPI C++ library (default: "${MPILIBNAME}cxx")]) -AC_ARG_VAR([MPIFCLIBNAME],[can be used to override the name of the MPI fortran library (default: "${MPILIBNAME}fort")]) if test "$enable_mpi_abi" = "yes" ; then MPILIBNAME=${MPILIBNAME:-"mpi_abi"} @@ -912,11 +887,8 @@ PMPILIBNAME=${PMPILIBNAME:-"p$MPILIBNAME"} # We use a different library for the C++ wrappers to avoid problems when # creating shared libraries if test -z "$MPICXXLIBNAME" ; then MPICXXLIBNAME="${MPILIBNAME}cxx" ; fi -if test -z "$MPIFCLIBNAME" ; then MPIFCLIBNAME="${MPILIBNAME}fort" ; fi export MPICXXLIBNAME -export MPIFCLIBNAME AC_SUBST(MPICXXLIBNAME) -AC_SUBST(MPIFCLIBNAME) # enable-fast # strip off multiple options, separated by commas @@ -1032,13 +1004,6 @@ if test $enable_weak_symbols = "yes" ; then fi AM_CONDITIONAL([BUILD_PROFILING_LIB],[test "$NEEDSPLIB" = "yes"]) -NEEDS_F77_PLIB=yes -if test "$pac_cv_prog_c_weak_symbols" = "pragma weak alias" -o "$pac_cv_prog_c_weak_symbols" = "attr weak alias" ; then - AC_DEFINE(USE_WEAK_SYMBOLS,1,[Define if weak symbols should be used]) - NEEDS_F77_PLIB=no -fi -AM_CONDITIONAL([BUILD_LIBF77_PMPI], [test "$NEEDS_F77_PLIB" = "yes"]) - PAC_CHECK_VISIBILITY AC_SUBST(VISIBILITY_CFLAGS) # disable visibility if building profiling library @@ -1788,438 +1753,8 @@ fi AC_DEFINE_UNQUOTED(ENABLE_PVAR_MULTINIC,$status_multinic_pvars, [Define to 1 to enable message count transmitted through multiple NICs MPI_T performance variables]) -# --------------------------------------------------------------------------- -# Support for the language bindings: Fortran 77, Fortran 90, and C++ -# -# First, we handle the case of no explicit enable/disable option. In that -# case, we look for a usable compiler. We cannot use the ac macros for this -# because they abort the configure step if they fail to find a compiler -# (earlier versions of autoconf did not have this behavior!). -# -# Second, we perform the langugage-specific tests, if necessary. This may -# be relatively simple (C++) or complex (Fortran 77, including formation of -# the encoded MPI handles). -# -# Note that the bindings support needs to know some of the properties of -# the C compiler, so those tests (particularly for weak symbols) -# must come first. -# ---------------------------------------------------------------------------- - -# -# First, determine whether we are/can support the language bindings -# -# Handle default choices for the Fortran compilers -# Note that these have already been set above - -if test "$enable_f90" = "yes" -o "$enable_f08" = "yes"; then - if test "$FC" = "" -o "$FC" = "no"; then - # No Fortran compiler found; abort - AC_MSG_ERROR([No Fortran compiler found. If you don't need to - build any Fortran programs, you can disable Fortran support using - --disable-fortran. If you do want to build Fortran - programs, you need to install a Fortran compiler such as gfortran - or ifort before you can proceed.]) - fi - - # Determine the extension for Fortran 90 files (it isn't always .f90) - PAC_FC_EXT - FCEXT=$ac_fc_srcext - AC_SUBST(FCEXT) -fi - -if test "$enable_f77" = yes ; then - # Check if $MPI_DEFAULT_FOPTS is valid with $F77 - if test -n "$MPI_DEFAULT_FOPTS" ; then - if test "$enable_check_compiler_flags" = "yes" ; then - PAC_F77_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_FOPTS], [ - FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS" - ] ) - else - FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS" - fi - fi -fi - -# -# We need to know the name mangling for Fortran before testing for FC -# compatibility (we need this because of the way we decide to generate -# the Fortran 77 bindings) -if test "$enable_f77" = yes ; then - FLIBS_save="$FLIBS" - FLIBS="" - AC_F77_LIBRARY_LDFLAGS - # The autoconf macro for finding FLIBS sometimes makes mistakes - # (particularly with the Fujitsu frt compiler). This next step - # first sees if the FLIBS is valid with the Fortran compiler - PAC_PROG_F77_FLIBS_VALID - # Now see if FLIBS works with the C compiler - PAC_PROG_F77_CHECK_FLIBS - - # Check F77+FLAGS is compatible with CC+CFLAGS before using F77+CC. - PAC_PROG_F77_OBJ_LINKS_WITH_C - - PAC_PROG_F77_LINKER_WITH_C - # For name mangle, we need the library flags - PAC_PROG_F77_NAME_MANGLE - # Check whether additional libraries are needed when linking with C - PAC_PROG_F77_AND_C_STDIO_LIBS - AC_SUBST(F77_OTHER_LIBS) - - # Warn about mixed name mangling, since many of the tests will fail - if test "$pac_cv_prog_f77_name_mangle" = "mixed" ; then - AC_MSG_WARN([The compiler $F77 uses mixed case names. Fortran is monocase -and many Fortran programs may use either upper or lower case names for MPI -calls. Consider specifying a particular parameter to your Fortran compiler -to select either upper or lower case names. For the Absoft compiler, --f selects lower case and -N109 selects upper case (if you use -f, also use --B108 to enable the iargc and getarg routines, which are needed for some -tests and by many user programs). Specify new command -line options by setting the environment variable FFLAGS to include -the options (e.g., setenv FFLAGS "-f -B108"). In addition, make sure that your -Fortran 90 compiler uses a compatible naming choice. For the -Absoft Fortran 90, -YALL_NAMES=LCS selects lower case names and -B108 -adds underscores to names, as required for iargc and getarg. Pass this -information to configure with the FCFLAGS environment variable.]) - # If Fortran implicitly enabled, disable it now. Otherwise, - # abort the configure since warning messages are often lost in - # the output. - AC_MSG_ERROR([Aborting configure because of mixed case names in Fortran. Either select --disable-fortran or set FCFLAGS to force the compiler to select monocase names]) - fi - - # The MPI standard requires that MPI_Init in any language initialize - # MPI in all languages. This can be a problem when objects produced - # by the Fortran compiler require symbols from the Fortran runtime - # (making linking C-only programs unnecessarily difficult). What we test - # here is whether the much more restricted needs of the Fortran - # initialize can be met with no special use of the Fortran runtime - PAC_F77_INIT_WORKS_WITH_C - if test "$pac_f_init_works_with_c" = "yes" ; then - AC_DEFINE(HAVE_MPI_F_INIT_WORKS_WITH_C,1,[Define if the Fortran init code for MPI works from C programs without special libraries]) - fi - - # - # Some Fortran compilers now pass CHARACTER length as a size_t instead - # of as an int. This is hard to test for, since the data is passed by - # value and for characters less than about 2GB long, the correct - # value will be used. In this case, we must use an approach similar to - # the one used by libtool for shared library options - look at the - # compiler name or vendor. - # Known compilers that use size_t instead of int: - # Intel Fortran - # gfortran - # Add others as they become known - AC_ARG_ENABLE(f77characterlen, - AS_HELP_STRING([--enable-f77characterlen], - [Select between int and size_t for the length of a Fortran CHARACTER, depending on the F77 compiler. If --enable-f77characterlen=size_t is given, force the use of size_t. This is used for passing Fortran CHARACTER data between C and Fortran, and is provided for experts. Note that the documentation provided by compiler vendors on the calling convention may not be accurate.]),,enable_f77characterlen=no) - - # Set the default - f77_uses_int_for_str=default - - case "$enable_f77characterlen" in - yes|no) - ;; - size_t) - f77_uses_int_for_str=no - enable_f77characterlen=yes - ;; - int) - f77_uses_int_for_str=yes - enable_f77characterlen=yes - ;; - *) - AC_MSG_ERROR([Invalid value provided for --enable-f77characterlen]) - ;; - esac - - # If we might change the size (enable) and we haven't set the choice, - # attempt to determine it from the compiler name. Risky, but we haven't - # found a reliable way to do this with test codes. - if test "$enable_f77characterlen" = "yes" -a \ - "$f77_uses_int_for_str" = "default" ; then - f77_uses_int_for_str=yes - f77Basename=`basename $F77` - case $f77Basename in - ifort*) - f77_uses_int_for_str=no - ;; - gfortran*) - f77_uses_int_for_str=no - ;; - esac - fi - # This test is disabled for now. Despite information in documentation - # on gfortran, it appears to pass lengths as int, at least in some - # builds (it used movl when tested in 2/2013). Tests that failed - # included infotestf.f, in a call to mpi_info_get. - # Leave this as a place holder until a proper test can be determined. - if test "$enable_f77characterlen" = "yes" -a \ - "$f77_uses_int_for_str" = "no" ; then - AC_DEFINE(USE_FORT_STR_LEN_SIZET,1,[Define if the length of a CHARACTER*(*) string in Fortran should be passed as size_t instead of int] ) - fi - -fi - -if test "$enable_f90" = "yes" -a "$enable_f77" != "yes" ; then - # Fortran 90 support requires compatible Fortran 77 support - AC_MSG_ERROR([ -Fortran 90 support requires compatible Fortran 77 support. -To force the use of the Fortran 90 compiler for Fortran 77, -do not use configure option --disable-fortran, and set the environment -variable F77 to the name of the Fortran 90 compiler, or \$FC. -If you do not want any Fortran support, use configure options ---disable-fortran.]) -fi - -# ---------------------------------------------------------------------------- -# Now test for Fortran compiler characteristics -# ---------------------------------------------------------------------------- -if test "$enable_f77" = "yes" ; then - # determine shared library flags for F77 - f77_shlib_conf=src/env/f77_shlib.conf - PAC_COMPILER_SHLIB_FLAGS([F77],[$f77_shlib_conf]) - AC_SUBST_FILE([f77_shlib_conf]) - - AC_LANG([Fortran 77]) - PAC_PROG_F77_EXCLAIM_COMMENTS(has_exclaim="yes",has_exclaim="no") - PAC_PROG_F77_HAS_INCDIR(src) - PAC_PROG_F77_LIBRARY_DIR_FLAG - - AC_SUBST(MPIFPMPI) - if test "$MPI_WITH_PMPI" = "no" ; then - # If the PMPI routines are not in the same library with the MPI - # routines, we may need to remove the pmpi declarations - PAC_PROG_F77_ALLOWS_UNUSED_EXTERNALS([MPIFPMPI=",PMPI_WTIME,PMPI_WTICK"],[ - MPIFPMPI=""; - AC_MSG_WARN([Removed PMPI_WTIME and PMPI_WTICK from mpif.h])]) - else - MPIFPMPI=",PMPI_WTIME,PMPI_WTICK" - fi - - # Once we have name mangle, we can try to limit the number of needed libs - dnl F77_IN_C_LIBS is not needed currently because mpirinitf_() in setbotf.f - dnl is called in initthread.c only when FLIBS is not needed to initialize - dnl Fortran constants from a C main, See PAC_F77_INIT_WORKS_WITH_C. - dnl PAC_PROG_F77_IN_C_LIBS - dnl AC_SUBST(F77_IN_C_LIBS) - - # Most systems allow the Fortran compiler to process .F and .F90 files - # using the C preprocessor. However, some systems either do not - # allow this or have serious bugs (OSF Fortran compilers have a bug - # that generates an error message from cpp). The following test - # checks to see if .F works, and if not, whether "cpp -P -C" can be used - # This is needed for Mac OSX 10.5 - PAC_F77_WORKS_WITH_CPP([F77CPP]) - AC_SUBST(F77CPP) - - # Check that the Fortran compiler will allow us to pass arguments - # of different types (e.g., for MPI_Send) - PAC_PROG_F77_MISMATCHED_ARGS(addarg,yes) - if test "X$addarg" != "X" ; then - # 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" - PAC_APPEND_CSV([mpif.h], [fortran_bindings]) - AC_DEFINE(HAVE_FORTRAN_BINDING,1,[Define if Fortran is supported]) -fi - -dnl By modifying mpif.h to use ! for comments, it can work with many f90 -dnl compilers without creating a separate version. -dnl Note that this is run AFTER the AC_OUTPUT actions -AC_CONFIG_COMMANDS([src/include/mpif.h],[if test "$enable_f77" = yes ; then -if test "$has_exclaim" = "yes" ; then - sed -e 's/^C/\!/g' src/binding/fortran/mpif_h/mpif.h > src/include/mpif.h - cp src/include/mpif.h src/binding/fortran/mpif_h/mpif.h -else - cp src/binding/fortran/mpif_h/mpif.h src/include -fi -if test "$has_fort_real8" = "yes" ; then - sed -e 's/DOUBLE PRECISION/REAL*8/g' src/include/mpif.h > src/include/mpif.h.new - mv src/include/mpif.h.new src/include/mpif.h - cp src/include/mpif.h src/binding/fortran/mpif_h/mpif.h -fi -fi], -main_top_srcdir=$main_top_srcdir -enable_f77=$enable_f77 -has_exclaim=$has_exclaim -has_fort_real8=$pac_cv_fort_real8 -includebuild_dir=$includebuild_dir -libbuild_dir=$libbuild_dir -bashWorks=$bashWorks) - -if test "$enable_f90" = "yes" ; then - bindings="$bindings f90" - PAC_APPEND_CSV([use mpi], [fortran_bindings]) -fi - -if test "$enable_f08" = "yes" ; then - PAC_FC_2008_SUPPORT([:],[enable_f08=no]) -fi -AM_CONDITIONAL([BUILD_F08_BINDING], [test "$enable_f08" = "yes"]) - -if test "$enable_f08" = "yes" ; then - bindings="$bindings f08" - PAC_APPEND_CSV([use mpi_f08], [fortran_bindings]) - AC_DEFINE(HAVE_F08_BINDING, 1, [Define to 1 if we have Fortran 2008 binding]) -fi - -# Set defaults for these values so that the Makefile in src/bindings/f90 -# is valid even if fc is not enabled (this is necessary for the -# distclean target) -MPIMODNAME=mpi -MPICONSTMODNAME=mpi_constants -MPISIZEOFMODNAME=mpi_sizeofs -MPIBASEMODNAME=mpi_base -PMPIBASEMODNAME=pmpi_base - -# F08 binding stuff -MPI_F08_LINK_CONSTANTS_NAME=mpi_f08_link_constants -PMPI_F08_NAME=pmpi_f08 -MPI_F08_CALLBACKS_NAME=mpi_f08_callbacks -MPI_C_INTERFACE_NAME=mpi_c_interface -MPI_C_INTERFACE_GLUE_NAME=mpi_c_interface_glue -MPI_F08_TYPES_NAME=mpi_f08_types -MPI_C_INTERFACE_NOBUF_NAME=mpi_c_interface_nobuf -MPI_F08_COMPILE_CONSTANTS_NAME=mpi_f08_compile_constants -MPI_F08_NAME=mpi_f08 -MPI_C_INTERFACE_TYPES_NAME=mpi_c_interface_types -MPI_C_INTERFACE_CDESC_NAME=mpi_c_interface_cdesc - -if test "$enable_f90" = "yes" -o "$enable_f08" = "yes"; then - # determine shared library flags for FC - fc_shlib_conf=src/env/fc_shlib.conf - PAC_COMPILER_SHLIB_FLAGS([FC],[$fc_shlib_conf]) - AC_SUBST_FILE([fc_shlib_conf]) - - # Determine characteristics of the Fortran 90 compiler - # Find a Fortran 90 compiler. Sets FC - # Work around bug in autoconf that adds -g to FCFLAGS - saveFCFLAGS="$FCFLAGS" - dnl FIXME XXX DJG this needs to be reconciled with our separate use of - dnl AC_PROG_FC earlier - dnl PAC_PROG_FC - PAC_PROG_FC_WORKS - FCFLAGS=$saveFCFLAGS - if test "$pac_cv_prog_fc_works" = no ; then - # Reject this compiler - if test "$FC" != "no" ; then - fc_rejected=yes - oldFC="$FC" - FC="no" - fi - fi - - if test "$FC" = "no" ; then - if test "$fc_rejected" = "yes" ; then - AC_MSG_ERROR([Could not find a usable Fortran 90 compiler. The compiler $oldFC may be incompatible with the Fortran 77 compiler $F77; check the output of configure and consult the installation manuals]) - else - AC_MSG_ERROR([Could not find a usable Fortran 90 compiler.]) - fi - fi - - # Find the extension that this compiler uses for modules. - # Sets FCMODEXT (and adds it to the list substed) - # Sets FCMODINCFLAG (and adds it to the list substed) - PAC_FC_MODULE - AC_SUBST(FCMODINCSPEC) - if test -z "$FCMODOUTFLAG" ; then - AC_MSG_ERROR([FCMODOUTFLAG could not be determined but is critical for the current Fortran build system]) - fi - - if test "$pac_cv_fc_module_case" = "upper" ; then - MPIMODNAME=MPI - MPICONSTMODNAME=MPI_CONSTANTS - MPISIZEOFMODNAME=MPI_SIZEOFS - MPIBASEMODNAME=MPI_BASE - PMPIBASEMODNAME=PMPI_BASE - MPI_F08_NAME=MPI_F08 - MPI_F08_LINK_CONSTANTS_NAME=MPI_F08_LINK_CONSTANTS - MPI_F08_CALLBACKS_NAME=MPI_F08_CALLBACKS - MPI_F08_TYPES_NAME=MPI_F08_TYPES - MPI_F08_COMPILE_CONSTANTS_NAME=MPI_F08_COMPILE_CONSTANTS - PMPI_F08_NAME=PMPI_F08 - MPI_C_INTERFACE_NAME=MPI_C_INTERFACE - MPI_C_INTERFACE_NOBUF_NAME=MPI_C_INTERFACE_NOBUF - MPI_C_INTERFACE_GLUE_NAME=MPI_C_INTERFACE_GLUE - MPI_C_INTERFACE_TYPES_NAME=MPI_C_INTERFACE_TYPES - MPI_C_INTERFACE_CDESC_NAME=MPI_C_INTERFACE_CDESC - else - MPIMODNAME=mpi - MPICONSTMODNAME=mpi_constants - MPISIZEOFMODNAME=mpi_sizeofs - MPIBASEMODNAME=mpi_base - PMPIBASEMODNAME=pmpi_base - MPI_F08_NAME=mpi_f08 - MPI_F08_LINK_CONSTANTS_NAME=mpi_f08_link_constants - MPI_F08_CALLBACKS_NAME=mpi_f08_callbacks - MPI_F08_TYPES_NAME=mpi_f08_types - MPI_F08_COMPILE_CONSTANTS_NAME=mpi_f08_compile_constants - PMPI_F08_NAME=pmpi_f08 - MPI_C_INTERFACE_NAME=mpi_c_interface - MPI_C_INTERFACE_NOBUF_NAME=mpi_c_interface_nobuf - MPI_C_INTERFACE_GLUE_NAME=mpi_c_interface_glue - MPI_C_INTERFACE_TYPES_NAME=mpi_c_interface_types - MPI_C_INTERFACE_CDESC_NAME=mpi_c_interface_cdesc - fi - AC_SUBST(MPIMODNAME) - AC_SUBST(MPICONSTMODNAME) - AC_SUBST(MPISIZEOFMODNAME) - AC_SUBST(MPIBASEMODNAME) - AC_SUBST(PMPIBASEMODNAME) - - AC_SUBST(MPI_F08_NAME) - AC_SUBST(MPI_F08_LINK_CONSTANTS_NAME) - AC_SUBST(MPI_F08_CALLBACKS_NAME) - AC_SUBST(MPI_F08_TYPES_NAME) - AC_SUBST(MPI_F08_COMPILE_CONSTANTS_NAME) - AC_SUBST(PMPI_F08_NAME) - AC_SUBST(MPI_C_INTERFACE_NAME) - AC_SUBST(MPI_C_INTERFACE_NOBUF_NAME) - AC_SUBST(MPI_C_INTERFACE_GLUE_NAME) - AC_SUBST(MPI_C_INTERFACE_TYPES_NAME) - AC_SUBST(MPI_C_INTERFACE_CDESC_NAME) - - # Assume that all Fortran 90 compilers accept -I for include directories - FCINC=-I - AC_SUBST(FCINC) - FCINCFLAG=-I - AC_SUBST(FCINCFLAG) - - # Check if $MPI_DEFAULT_FCOPTS is valid with $F90 - if test -n "$MPI_DEFAULT_FCOPTS" ; then - if test "$enable_check_compiler_flags" = "yes" ; then - PAC_FC_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_FCOPTS], [ - FCFLAGS="$FCFLAGS $MPI_DEFAULT_FCOPTS" - ] ) - else - FCFLAGS="$FCFLAGS $MPI_DEFAULT_FCOPTS" - fi - fi - - # Most systems allow the Fortran compiler to process .F and .F90 files - # using the C preprocessor. However, some systems either do not - # allow this or have serious bugs (OSF Fortran compilers have a bug - # that generates an error message from cpp). The following test - # checks to see if .F works, and if not, whether "cpp -P -C" can be used - PAC_FC_WORKS_WITH_CPP([FCCPP]) - AC_SUBST(FCCPP) - - # Check whether additional libraries are needed when linking with C - PAC_PROG_FC_AND_C_STDIO_LIBS - AC_SUBST(FC_OTHER_LIBS) -fi - -if test "X$modincdir" = "X" ; then - modincdir=$includedir -fi -export modincdir -AC_SUBST(modincdir) - AC_LANG_PUSH([C]) + AC_MSG_CHECKING([whether TRUE has been defined]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[return TRUE;])], [has_true_upper_case=yes], @@ -2233,8 +1768,8 @@ AC_LANG_POP([C]) # ---------------------------------------------------------------------------- # We previously allowed "default" as a valid value for $enable_cxx. Now we -# assume its available by default and error out if it doesn't work (just like -# F77 & FC). The user must pass "--disable-cxx" in order to successfully +# assume its available by default and error out if it doesn't work. +# The user must pass "--disable-cxx" in order to successfully # complete configure in this case. if test "$enable_cxx" = "default" ; then AC_MSG_ERROR([aborting because "--enable-cxx=default" is no longer a supported value]) @@ -2922,332 +2457,6 @@ AH_TEMPLATE([MPIR_ALT_FLOAT128_ALIGN], [The alignment for MPIR_ALT_FLOAT128]) AH_TEMPLATE([MPIR_ALT_COMPLEX96_CTYPE], [The C type for MPIR_ALT_COMPLEX96]) AH_TEMPLATE([MPIR_ALT_COMPLEX128_CTYPE], [The C type for MPIR_ALT_COMPLEX128]) -# ---------------------------------------------------------------------------- -# We can now create the Fortran versions of the datatype values, along with -# some of the other datatype-dependent sizes - -# There are two parts to handling the datatypes: -# Convert the C datatype values to their Fortran equivalent. This -# involves converting the hex values for the C version into decimal -# since standard Fortran does not have hex constants -# -# Determine the existence of the Fortran 'sized' types and set those -# values. -# -# In addition, we need to look at a few additional constants that depend -# on how the compiler sizes some datatypes. These are: -# INTEGER_KIND, ADDRESS_KIND, and OFFSET_KIND -# -# ---------------------------------------------------------------------------- -if test "$enable_f77" = yes ; then - pac_cv_f77_sizeof_character=1 - - # Up to size checking code in main configure.ac (where it tries to - # find the matching C sizes) as part of defining mpi_integer8 etc. - # The results are available in pac_cv_sizeof_f77_ - # Size is 0 if unknown or unavailable (or cross-compiling) - # Due to limitations in autoconf, we cannot put these into a loop. - # We also check integer to find the type of MPI_Fint - # - # Cross-compilation results can be included with the --with-cross=file - # option. - CROSS_F77_SIZEOF_INTEGER=${CROSS_F77_SIZEOF_INTEGER:-0} - CROSS_F77_SIZEOF_REAL=${CROSS_F77_SIZEOF_REAL:-0} - CROSS_F77_SIZEOF_DOUBLE_PRECISION=${CROSS_F77_SIZEOF_DOUBLE_PRECISION:-0} - CROSS_F77_SIZEOF_LOGICAL=${CROSS_F77_SIZEOF_LOGICAL:-0} - PAC_PROG_F77_CHECK_SIZEOF_EXT(integer,$CROSS_F77_SIZEOF_INTEGER) - PAC_PROG_F77_CHECK_SIZEOF_EXT(real,$CROSS_F77_SIZEOF_REAL) - PAC_PROG_F77_CHECK_SIZEOF_EXT(double precision,$CROSS_F77_SIZEOF_DOUBLE_PRECISION) - PAC_PROG_F77_CHECK_SIZEOF_EXT(logical,$CROSS_F77_SIZEOF_LOGICAL) - AC_LANG([Fortran 77]) - # If we have sizes for real and double, we do not need to call - # mpir_get_fsize at run time. - # For the size-defined types (e.g., integer*2), we assume that if the - # compiler allows it, it has the stated size. - AC_CACHE_CHECK([whether integer*1 is supported],pac_cv_fort_integer1,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*1 i])], - pac_cv_fort_integer1=yes, - pac_cv_fort_integer1=no)]) - AC_CACHE_CHECK([whether integer*2 is supported],pac_cv_fort_integer2,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*2 i])], - pac_cv_fort_integer2=yes, - pac_cv_fort_integer2=no)]) - AC_CACHE_CHECK([whether integer*4 is supported],pac_cv_fort_integer4,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*4 i])], - pac_cv_fort_integer4=yes, - pac_cv_fort_integer4=no)]) - AC_CACHE_CHECK([whether integer*8 is supported],pac_cv_fort_integer8,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*8 i])], - pac_cv_fort_integer8=yes, - pac_cv_fort_integer8=no)]) - AC_CACHE_CHECK([whether integer*16 is supported],pac_cv_fort_integer16,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*16 i])], - pac_cv_fort_integer16=yes, - pac_cv_fort_integer16=no)]) - AC_CACHE_CHECK([whether real*2 is supported],pac_cv_fort_real2,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*2 a])], - pac_cv_fort_real2=yes, - pac_cv_fort_real2=no)]) - AC_CACHE_CHECK([whether real*4 is supported],pac_cv_fort_real4,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*4 a])], - pac_cv_fort_real4=yes, - pac_cv_fort_real4=no)]) - AC_CACHE_CHECK([whether real*8 is supported],pac_cv_fort_real8,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*8 a])], - pac_cv_fort_real8=yes, - pac_cv_fort_real8=no)]) - AC_CACHE_CHECK([whether real*16 is supported],pac_cv_fort_real16,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*16 a])], - pac_cv_fort_real16=yes, - pac_cv_fort_real16=no)]) - AC_CACHE_CHECK([whether complex*4 is supported],pac_cv_fort_complex4,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*4 a])], - pac_cv_fort_complex4=yes, - pac_cv_fort_complex4=no)]) - AC_CACHE_CHECK([whether complex*8 is supported],pac_cv_fort_complex8,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*8 a])], - pac_cv_fort_complex8=yes, - pac_cv_fort_complex8=no)]) - AC_CACHE_CHECK([whether complex*16 is supported],pac_cv_fort_complex16,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*16 a])], - pac_cv_fort_complex16=yes, - pac_cv_fort_complex16=no)]) - AC_CACHE_CHECK([whether complex*32 is supported],pac_cv_fort_complex32,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*32 a])], - pac_cv_fort_complex32=yes, - pac_cv_fort_complex32=no)]) - AC_CACHE_CHECK([whether double precision is supported],pac_cv_fort_double_precision,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ double precision a])], - pac_cv_fort_double_precision=yes, - pac_cv_fort_double_precision=no)]) - - if test -z "$pac_cv_f77_sizeof_integer" -o \ - "X$pac_cv_f77_sizeof_integer" = "X0" ; then - AC_MSG_ERROR([Unable to configure with Fortran support because configure could not determine the size of a Fortran INTEGER. Consider setting CROSS_F77_SIZEOF_INTEGER to the length in bytes of a Fortran INTEGER]) - fi - - AC_DEFINE_UNQUOTED([MPI_CHARACTER_SIZE], [$pac_cv_f77_sizeof_character], [Define the size of Fortran CHARACTER]) - AC_DEFINE_UNQUOTED([MPI_LOGICAL_SIZE], [$pac_cv_f77_sizeof_logical], [Define the size of Fortran LOGICAL]) - AC_DEFINE_UNQUOTED([MPI_INTEGER_SIZE], [$pac_cv_f77_sizeof_integer], [Define the size of Fortran INTEGER]) - AC_DEFINE_UNQUOTED([MPI_REAL_SIZE], [$pac_cv_f77_sizeof_real], [Define the size of Fortran REAL]) - AC_DEFINE_UNQUOTED([MPI_DOUBLE_PRECISION_SIZE], [$pac_cv_f77_sizeof_double_precision], [Define the size of Fortran DOUBLE PRECISION]) - - if test "$pac_cv_fort_double_precision" = "yes"; then - AC_DEFINE([MPI_DOUBLE_PRECISION_SUPPORTED], [1], [Define if Fortran DOUBLE PRECISION is supported]) - fi - if test "$pac_cv_fort_logical1" = "yes"; then - AC_DEFINE([MPI_LOGICAL1_SUPPORTED], [1], [Define if Fortran LOGICAL*1 is supported]) - fi - if test "$pac_cv_fort_logical2" = "yes"; then - AC_DEFINE([MPI_LOGICAL2_SUPPORTED], [1], [Define if Fortran LOGICAL*2 is supported]) - fi - if test "$pac_cv_fort_logical4" = "yes"; then - AC_DEFINE([MPI_LOGICAL4_SUPPORTED], [1], [Define if Fortran LOGICAL*4 is supported]) - fi - if test "$pac_cv_fort_logical8" = "yes"; then - AC_DEFINE([MPI_LOGICAL8_SUPPORTED], [1], [Define if Fortran LOGICAL*8 is supported]) - fi - if test "$pac_cv_fort_logical16" = "yes"; then - AC_DEFINE([MPI_LOGICAL16_SUPPORTED], [1], [Define if Fortran LOGICAL*16 is supported]) - fi - if test "$pac_cv_fort_integer1" = "yes"; then - AC_DEFINE([MPI_INTEGER1_SUPPORTED], [1], [Define if Fortran INTEGER*1 is supported]) - fi - if test "$pac_cv_fort_integer2" = "yes"; then - AC_DEFINE([MPI_INTEGER2_SUPPORTED], [1], [Define if Fortran INTEGER*2 is supported]) - fi - if test "$pac_cv_fort_integer4" = "yes"; then - AC_DEFINE([MPI_INTEGER4_SUPPORTED], [1], [Define if Fortran INTEGER*4 is supported]) - fi - if test "$pac_cv_fort_integer8" = "yes"; then - AC_DEFINE([MPI_INTEGER8_SUPPORTED], [1], [Define if Fortran INTEGER*8 is supported]) - fi - if test "$pac_cv_fort_integer16" = "yes"; then - AC_DEFINE([MPI_INTEGER16_SUPPORTED], [1], [Define if Fortran INTEGER*16 is supported]) - fi - if test "$pac_cv_fort_real2" = "yes"; then - AC_DEFINE([MPI_REAL2_SUPPORTED], [1], [Define if Fortran REAL*2 is supported]) - fi - if test "$pac_cv_fort_real4" = "yes"; then - AC_DEFINE([MPI_REAL4_SUPPORTED], [1], [Define if Fortran REAL*4 is supported]) - fi - if test "$pac_cv_fort_real8" = "yes"; then - AC_DEFINE([MPI_REAL8_SUPPORTED], [1], [Define if Fortran REAL*8 is supported]) - fi - if test "$pac_cv_fort_real16" = "yes"; then - AC_DEFINE([MPI_REAL16_SUPPORTED], [1], [Define if Fortran REAL*16 is supported]) - fi - if test "$pac_cv_fort_complex4" = "yes"; then - AC_DEFINE([MPI_COMPLEX4_SUPPORTED], [1], [Define if Fortran COMPLEX*4 is supported]) - fi - if test "$pac_cv_fort_complex8" = "yes"; then - AC_DEFINE([MPI_COMPLEX8_SUPPORTED], [1], [Define if Fortran COMPLEX*8 is supported]) - fi - if test "$pac_cv_fort_complex16" = "yes"; then - AC_DEFINE([MPI_COMPLEX16_SUPPORTED], [1], [Define if Fortran COMPLEX*16 is supported]) - fi - if test "$pac_cv_fort_complex32" = "yes"; then - AC_DEFINE([MPI_COMPLEX32_SUPPORTED], [1], [Define if Fortran COMPLEX*32 is supported]) - fi - - # Provide the corresponding C types for MPI_INTEGER - AC_MSG_CHECKING([for C type matching Fortran integer]) - get_c_int_type $pac_cv_f77_sizeof_integer - MPI_FINT=$pac_retval - AC_MSG_RESULT($MPI_FINT) - - # We also need to check the size of MPI_Aint vs MPI_Fint, and - # define AINT_LARGER_THAN_FINT if aint is larger (this - # affects code in MPI_Address) - if test "$ac_cv_sizeof_void_p" != "0" -a \ - "$ac_cv_sizeof_void_p" -gt "$pac_cv_f77_sizeof_integer" ; then - AC_DEFINE(HAVE_AINT_LARGER_THAN_FINT,1,[Define if addresses are larger than Fortran integers]) - fi - if test "$ac_cv_sizeof_void_p" != 0 -a \ - "$ac_cv_sizeof_void_p" != "$pac_cv_f77_sizeof_integer" ; then - AC_DEFINE(HAVE_AINT_DIFFERENT_THAN_FINT,1,[Define if addresses are a different size than Fortran integers]) - fi - - # Include a defined value for Fint is int - if test "$pac_cv_f77_sizeof_integer" = "$ac_cv_sizeof_int" ; then - AC_DEFINE(HAVE_FINT_IS_INT,1,[Define if Fortran integer are the same size as C ints]) - else - AC_MSG_WARN([Fortran integers and C ints are not the same size. C programs that directly use MPI_Fint may be incorrect.]) - fi - - # Try and compute the values of .true. and .false. in Fortran - # This code has been removed because the Fortran binding code does - # not yet support it. - PAC_F77_LOGICALS_IN_C([$MPI_FINT]) - - # Get the INTEGER_KIND, ADDRESS_KIND and OFFSET_KIND if possible - # - # For Fortran 90, we'll also need MPI_ADDRESS_KIND and MPI_OFFSET_KIND - # Since our compiler might BE a Fortran 90 compiler, try and determine the - # values. - if test "$FC" = "no" ; then - PAC_F77_IS_FC([ - FC=$F77 - if test -z "$FCFLAGS" ; then - FCFLAGS="$FFLAGS" - fi - ]) - fi - if test "$FC" != "no" ; then - # Offset kind should be for 8 bytes if possible (Romio prefers that) - # address should be sizeof void * (unless --with-aint-size has - # been set) - # FIXME in the current configure implementation OFFSET_KIND and - # MPI_Offset won't always agree, but generally will. The MPI Standard - # implies that these types must have identical size, so this is a bug - # waiting to happen. - if test "$with_aint_size" -gt 0 -a \ - "$with_aint_size" -gt "$ac_cv_sizeof_void_p" ; then - testsize=$with_aint_size - else - testsize=$ac_cv_sizeof_void_p - fi - if test "$testsize" = 0 ; then - # Set a default - testsize=4 - fi - dnl Using the {} around testsize helps the comments work correctly - PAC_PROG_FC_INT_KIND(ADDRESS_KIND,${testsize},$CROSS_F90_ADDRESS_KIND) - if test "$testsize" = 8 ; then - OFFSET_KIND=$ADDRESS_KIND - else - PAC_PROG_FC_INT_KIND(OFFSET_KIND,8,$CROSS_F90_OFFSET_KIND) - fi - # - PAC_PROG_FC_INT_KIND(INTEGER_KIND,$pac_cv_f77_sizeof_integer,$CROSS_F90_INTEGER_KIND) - if test "$INTEGER_KIND" = "-1" ; then - # In our experience, this usually means that there is some - # problem building and/or running the f90 program. Fail - # in this case rather than attempt to continue - AC_MSG_ERROR([Unable to determine Fortran 90 KIND values for either address-sized integers or offset-sized integers.]) - fi - # - # Some compilers won't allow a -1 kind (e.g., absoft). In this case, - # use a fallback (sizeof(int) kind) - if test "$ADDRESS_KIND" = "-1" -o "$OFFSET_KIND" = "-1" ; then - if test "$ADDRESS_KIND" = "-1" ; then - ADDRESS_KIND=$INTEGER_KIND - fi - if test "$OFFSET_KIND" = "-1" ; then - OFFSET_KIND=$INTEGER_KIND - fi - fi - AC_LANG_PUSH([Fortran]) - AC_CACHE_CHECK([if real*8 is supported in Fortran 90], - [pac_cv_fort90_real8],[ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([],[ real*8 a]) - ],[ - pac_cv_fort90_real8=yes - ],[ - pac_cv_fort90_real8=no - ]) - ]) - AC_LANG_POP([Fortran]) - WTIME_DOUBLE_TYPE="DOUBLE PRECISION" - if test "$pac_cv_fort90_real8" = "yes" ; then - WTIME_DOUBLE_TYPE="REAL*8" - fi - # WTIME_DOUBLE_TYPE is substituted into mpi_base.f90 - AC_SUBST(WTIME_DOUBLE_TYPE) - fi - # Make sure that address kind and offset kind have values. - if test -z "$ADDRESS_KIND" ; then - ADDRESS_KIND=0 - fi - if test -z "$OFFSET_KIND" ; then - OFFSET_KIND=0 - fi - # Note, however, that zero value are (in all practical case) invalid - # for Fortran 90, and indicate a failure. Test and fail if Fortran 90 - # enabled. - if test "$enable_f90" = "yes" ; then - if test "$ADDRESS_KIND" -le 0 -o "$OFFSET_KIND" -le 0 ; then - AC_MSG_ERROR([Unable to determine Fortran 90 integer kinds for MPI types. If you do not need Fortran 90, add --disable-fc to the configure options.]) - fi - fi - AC_SUBST(ADDRESS_KIND) - AC_SUBST(OFFSET_KIND) - AC_SUBST(INTEGER_KIND) - - # Some compilers may require special directives to handle the common - # block in a library. In particular, directives are needed for Microsoft - # Windows to support dynamic library import. The following six - # directives may be needed: - # CMS\$ATTRIBUTES DLLIMPORT::/MPIPRIV1/ - # CMS\$ATTRIBUTES DLLIMPORT::/MPIPRIV2/ - # CMS\$ATTRIBUTES DLLIMPORT::/MPIPRIVC/ - # CDEC\$ATTRIBUTES DLLIMPORT::/MPIPRIV1/ - # CDEC\$ATTRIBUTES DLLIMPORT::/MPIPRIV2/ - # CDEC\$ATTRIBUTES DLLIMPORT::/MPIPRIVC/ - # CMS is for the Microsoft compiler, - # CDEC is (we believe) for the DEC Fortran compiler. - # We need to make this a configure-time variable because some compilers - # (in particular, a version of the Intel Fortran compiler for Linux) - # will read directives for other compilers and then flag as fatal - # errors directives that it does not support but does recognize. - - DLLIMPORT="" - AC_SUBST(DLLIMPORT) - - AC_LANG([C]) -else - MPI_FINT=int - - # set following sizes to 0 will disable the corresponding datatype - pac_cv_f77_sizeof_character=0 - pac_cv_f77_sizeof_integer=0 - pac_cv_f77_sizeof_real=0 - pac_cv_f77_sizeof_double_precision=0 - pac_cv_f77_sizeof_logical=0 - - AC_DEFINE(HAVE_NO_FORTRAN_MPI_TYPES_IN_C,1,[Define if the Fortran types are not available in C]) -fi # ---------------------------------------------------------------------------- # C++ types - we support CXX datatypes if there is a working CXX compiler @@ -3403,7 +2612,6 @@ if test -n "$MPI_OFFSET_TYPE" ; then MPI_SIZEOF_OFFSET=$ac_cv_sizeof_MPI_Offset fi fi - export MPI_SIZEOF_OFFSET else # Make a guess at the appropriate definition for offset. Try to # find a 64bit type. @@ -3419,8 +2627,8 @@ else MPI_OFFSET=long MPI_SIZEOF_OFFSET=$ac_cv_sizeof_long fi - export MPI_SIZEOF_OFFSET fi +export MPI_SIZEOF_OFFSET AC_SUBST(MPI_OFFSET) AS_CASE([$MPI_OFFSET], @@ -3451,17 +2659,15 @@ AS_IF([test -z "$MPI_SIZEOF_OFFSET"], AS_IF([test "$MPI_SIZEOF_AINT" -gt "$MPI_SIZEOF_OFFSET"], [# an unlikely case, but I suppose it's theoretically possible MPI_COUNT="$MPI_AINT" - COUNT_KIND="$ADDRESS_KIND" MPIR_COUNT_MAX="$MPIR_AINT_MAX" MPI_SIZEOF_COUNT="$MPI_SIZEOF_AINT"], [# don't bother checking whether Aint or Offset are larger than int, they # surely will be MPI_COUNT="$MPI_OFFSET" - COUNT_KIND="$OFFSET_KIND" MPIR_COUNT_MAX="$MPIR_OFFSET_MAX" MPI_SIZEOF_COUNT="$MPI_SIZEOF_OFFSET"]) +export MPI_SIZEOF_COUNT AC_SUBST([MPI_COUNT]) -AC_SUBST([COUNT_KIND]) AC_DEFINE_UNQUOTED([MPIR_COUNT_MAX],[$MPIR_COUNT_MAX],[limits.h _MAX constant for MPI_Count]) AC_DEFINE_UNQUOTED(MPIR_Ucount,unsigned $MPI_COUNT,[MPIR_Ucount is an unsigned MPI_Count-sized integer]) @@ -3939,7 +3145,8 @@ fi dnl "configure" the device here via subconfigure.m4 files m4_map([PAC_SUBCFG_CONFIGURE_SUBSYS], [PAC_SUBCFG_MODULE_LIST]) -# We explicitly configure most modules now. $subsystems only contains hydra and nameserv/* (if configured). +# now configure any actual recursively configures subsystems, such as ROMIO and +# hydra, or older components that haven't been updated to a subconfigure.m4 yet for subsys in $subsystems ; do PAC_CONFIG_SUBDIR_ARGS([$subsys],[$subsys_config_args],[],[AC_MSG_ERROR([$subsys configure failed])]) done @@ -3948,31 +3155,6 @@ if test "$DEBUG_SUBDIR_CACHE" = yes -a "$enable_echo" != yes ; then fi dnl PAC_SUBDIR_CACHE_CLEANUP -# MPI_STATUS_SIZE is hardcoded and need to be synchronized with mpi.h -MPI_STATUS_SIZE=5 -AC_SUBST([MPI_STATUS_SIZE]) - -if test "$enable_f77" = yes ; then - # Check if multiple __attribute__((alias)) is available - # This test requires MPI_STATUS_SIZE, and thus must be made after - # MPI_STATUS_SIZE is determined - if test "$enable_multi_aliases" = "yes" ; then - PAC_C_MULTI_ATTR_ALIAS - if test "$pac_c_multi_attr_alias" = "yes" ; then - PAC_F2C_ATTR_ALIGNED_SIZE([1],[CMB_1INT_ALIGNMENT]) - AC_SUBST(CMB_1INT_ALIGNMENT) - PAC_F2C_ATTR_ALIGNED_SIZE([$MPI_STATUS_SIZE],[CMB_STATUS_ALIGNMENT], - [32]) - AC_SUBST(CMB_STATUS_ALIGNMENT) - if test "X$CMB_1INT_ALIGNMENT" != "X" \ - -a "X$CMB_STATUS_ALIGNMENT" != "X" ; then - AC_DEFINE(HAVE_C_MULTI_ATTR_ALIAS, 1, - [Define if multiple __attribute__((alias)) are supported]) - fi - fi - fi -fi - # ----------------------------------------------------------------------------- # enable_nolocal option may get overwritten by device subconfigure, e.g. with "with_ch4_shmmods=none" if test "$enable_nolocal" = "yes" ; then @@ -4014,8 +3196,6 @@ MPIU_DLL_SPEC_DEF="#define MPIU_DLL_SPEC" AC_SUBST(MPIU_DLL_SPEC_DEF) AM_CONDITIONAL([BUILD_CXX_BINDING],[test "$enable_cxx" = "yes"]) -AM_CONDITIONAL([BUILD_F77_BINDING],[test "$enable_f77" = "yes"]) -AM_CONDITIONAL([BUILD_FC_BINDING],[test "$enable_f90" = "yes"]) # MPI_SRCDIR gives the test/mpi configure the location of the source # files for an MPI implementation if test -n "$ac_abs_srcdir" ; then @@ -4083,10 +3263,6 @@ fi if test -z "$libbuild_dir" ; then libbuild_dir=`pwd`/lib fi -if test -z "$modincbuild_dir" ; then - # The include files may be in a different directory from the mpif.h file - modincbuild_dir=`pwd`/src/binding/fortran/use_mpi -fi dnl dnl If we rerun configure, place a file in the lib directory with the @@ -4108,99 +3284,6 @@ AC_DEFINE(HAVE_MPICHCONF,1,[Define so that we can test whether the mpichconf.h f # linking issue on Darwin LT_OUTPUT -AC_ARG_ENABLE([two-level-namespace], - [AS_HELP_STRING([--enable-two-level-namespace], - [(Darwin only) Do not use `-Wl,-flat_namespace` to - link libmpifort.dylib. MacOS uses two-level namespace - to compile dylibs by default. This may cause issues - not resolving MPI constants, such as MPI_IN_PLACE. - Thus, we use flat_namespace by default. Enable this - option to use two-level-namespace instead. ])], - [], - [enable_two_level_namespace=no]) -FCLIB_LDFLAGS= -AC_SUBST([FCLIB_LDFLAGS]) - -if test "X$enable_shared" = "Xyes" ; then - # see ticket #1590 for some more background on these Darwin linking issues - AS_CASE([$host], - [*-*-darwin*], - [ - - # The linker on Darwin does not allow common symbols, thus libtool - # adds the -fno-common option by default for shared libraries. - # However, the common symbols defined in different shared libraries - # and object files still can not be treated as the same symbol. - # For example: - # with gfortran, the same common block in the shared libraries and - # the object files will have different memory locations separately; - # with ifort, the same common block in different shared libraries - # will get the same memory location but still get a different location - # in the object file. - - # On the other hand, the -flat-namespace option allows linker to - # unify the same common symbols in different dylibs. It needs to be - # added in linking stage for both the shared library and the final - # executable file. - - # In Fortran programs, we implement global definitions such as MPI_BOTTOM - # as common symbols. We check the address of the user input and translate it - # to the C global definition if it is equal to the internal pre-stored address - # in the Fortran binding layer. Without -flat-namespace, we may get different - # addresses and thus treat the predefined constant as a normal buffer. - - # sanity check that -Wl,-flat_namespace works on darwin, unless the user - # asked us not to add it - if test "X$enable_two_level_namespace" = "Xno"; then - # TODO, move this into a PAC macro with real autoconf caching - pac_cv_wl_flat_namespace_works=no - AC_MSG_CHECKING([if the C compiler accepts -Wl,-flat_namespace]) - PAC_PUSH_FLAG([LDFLAGS]) - PAC_APPEND_FLAG([-Wl,-flat_namespace],[LDFLAGS]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[int i;])], - [AC_MSG_RESULT([yes]) - pac_cv_wl_flat_namespace_works=yes], - [AC_MSG_RESULT([no])]) - PAC_POP_FLAG([LDFLAGS]) - - # Technically we may not be able to use the same form of the argument - # for all three compilers (CC/CXX/FC). But we only think this is - # necessary for Darwin for now, so this unconditional, single-var - # approximation will work for now. - if test "X$pac_cv_wl_flat_namespace_works" = "Xyes" ; then - FCLIB_LDFLAGS="-Wl,-flat_namespace" - fi - fi - ] - ) -fi - -if test "$enable_f08" = "yes"; then - AS_CASE([$MPI_AINT], - [short], [F08_C_AINT="c_short"], - [int], [F08_C_AINT="c_int"], - [long], [F08_C_AINT="c_long"], - ['long long'], [F08_C_AINT="c_long_long"], - [AC_MSG_ERROR([unable to determine C MPI_AINT type in Fortran 2008])]) - - AS_CASE([$MPI_COUNT], - [short], [F08_C_COUNT="c_short"], - [int], [F08_C_COUNT="c_int"], - [long], [F08_C_COUNT="c_long"], - ['long long'], [F08_C_COUNT="c_long_long"], - [AC_MSG_ERROR([unable to determine C MPI_COUNT type in Fortran 2008])]) - - AS_CASE([$MPI_OFFSET], - [short], [F08_C_OFFSET="c_short"], - [int], [F08_C_OFFSET="c_int"], - [long], [F08_C_OFFSET="c_long"], - ['long long'], [F08_C_OFFSET="c_long_long"], - [AC_MSG_ERROR([unable to determine C MPI_OFFSET type in Fortran 2008])]) - - AC_SUBST(F08_C_AINT) - AC_SUBST(F08_C_COUNT) - AC_SUBST(F08_C_OFFSET) -fi ######################################################################## # Some of the settings need to be applied at the end @@ -4216,60 +3299,30 @@ fi AC_SUBST(pkgconfigdir) export pkgconfigdir -if test "$enable_f90" = "yes" ; then - PAC_FC_CHECK_IGNORE_TKR - PAC_FC_ISO_C_BINDING - if test -z "$PYTHON" ; then - if test -f src/binding/fortran/use_mpi/mpi_base.f90 ; then - AC_MSG_NOTICE([Use pre-generated Fortran mpi binding. To prevent issues, install Python 3 and re-run configure.]) - else - AC_MSG_ERROR([Python 3 is required to generate F90 bindings but not found!]) - fi - else - cmd_f90="$PYTHON $srcdir/maint/gen_binding_f90.py" - # pass in type sizes for MPI_SIZEOF - cmd_f90="$cmd_f90 -f-logical-size=$pac_cv_f77_sizeof_logical" - if test "$pac_fc_ignore_tkr" != "no" ; then - cmd_f90="$cmd_f90 -ignore-tkr=$pac_fc_ignore_tkr" - fi - if test "$pac_fc_iso_c_binding" = "no" ; then - cmd_f90="$cmd_f90 -iso-c-binding=no" - fi - AC_CONFIG_COMMANDS([gen_binding_f90], [$cmd_gen_binding_f90], [cmd_gen_binding_f90="$cmd_f90"]) - fi -fi - -if test "$enable_f08" = "yes" ; then - PAC_FC_CHECK_REAL128 - PAC_FC_CHECK_IGNORE_TKR_D - if test -z "$PYTHON" ; then - if test -f src/binding/fortran/use_mpi_f08/mpi_f08.f90 ; then - AC_MSG_NOTICE([Using pre-generated Fortran mpi_f08 binding source. To prevent issues, install Python 3 and rerun configure.]) - else - AC_MSG_ERROR([Python 3 is required to generate F08 bindings but not found!]) - fi - else - cmd_f08="$PYTHON $srcdir/maint/gen_binding_f08.py" - if test "$pac_fc_has_real128" = "no" ; then - cmd_f08="$cmd_f08 -no-real128" - fi - if test "$pac_fc_ignore_tkr_d" != "no" ; then - cmd_f08="$cmd_f08 -ignore-tkr-d=$pac_fc_ignore_tkr_d" - fi - if test "$enable_romio" = "no" ; then - cmd_f08="$cmd_f08 -no-mpiio" - fi - cmd_f08="$cmd_f08 -fint-size=$pac_cv_f77_sizeof_integer -aint-size=$MPI_SIZEOF_AINT -count-size=$MPI_SIZEOF_COUNT -cint-size=$ac_cv_sizeof_int" - AC_CONFIG_COMMANDS([gen_binding_f08], [$cmd_gen_binding_f08], [cmd_gen_binding_f08="$cmd_f08"]) - fi -fi - case "$host_os" in freebsd*) AC_DEFINE(DELAY_SHM_MUTEX_DESTROY, 1, [Define to workaround interprocess mutex issue on FreeBSD]) ;; esac +fortrandir= +AC_SUBST(fortrandir) +if test "$enable_fortran" = "yes" ; then + fortrandir="src/binding/fortran" + PAC_CONFIG_SUBDIR_ARGS([src/binding/fortran],[$fortran_args],[],[AC_MSG_ERROR(Fortran binding configure failed)]) + + AC_MSG_NOTICE([sourcing $main_top_builddir/src/binding/fortran/localdefs]) + . $main_top_builddir/src/binding/fortran/localdefs + + # For now, we build/install mpifort in mpich + fc_shlib_conf="src/binding/fortran/fc_shlib.conf" + AC_SUBST([fc_shlib_conf]) +fi + +# FCEXT used in mpifort.bash.in +FCEXT="f90" +AC_SUBST([FCEXT]) + AC_CONFIG_COMMANDS([src/include/mpi.h],[ if test "$enable_mpi_abi" = "yes" ; then cp $srcdir/src/binding/abi/mpi_abi.h src/include/mpi.h @@ -4299,18 +3352,9 @@ AC_CONFIG_FILES([Makefile \ doc/installguide/Makefile \ doc/refman/Makefile \ doc/userguide/Makefile \ - test/commands/cmdtests \ packaging/pkgconfig/mpich.pc \ - packaging/envmods/mpich.module]) -if test "$enable_f77" = "yes" ; then - AC_CONFIG_FILES([src/binding/fortran/mpif_h/mpif.h \ - src/binding/fortran/mpif_h/setbotf.f \ - src/binding/fortran/mpif_h/setbot.c]) -fi -if test "$enable_f08" = "yes" ; then - AC_CONFIG_FILES([src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90 \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90]) -fi + packaging/envmods/mpich.module \ + test/commands/cmdtests]) AC_OUTPUT if test "$enable_mpi_abi" = "yes" ; then @@ -4329,7 +3373,7 @@ cat < Creating the final libfortran tarball... "); +chdir("${expdir}"); +run_cmd("./autogen.sh -do=fortran"); +chdir("${tdir}"); +run_cmd("cp -a ${expdir}/src/binding/fortran libfortran-${version}"); +run_cmd("tar -czvf libfortran-${version}.tar.gz libfortran-${version}"); +run_cmd("cp -a libfortran-${version}.tar.gz ${root}/"); +print("done\n"); + # Create the testsuite tarball print("===> Creating the final mpich-testsuite tarball... "); chdir("${expdir}"); diff --git a/src/binding/Makefile.mk b/src/binding/Makefile.mk index 27b1ce18663..c68e5e6bec2 100644 --- a/src/binding/Makefile.mk +++ b/src/binding/Makefile.mk @@ -6,6 +6,3 @@ include $(top_srcdir)/src/binding/c/Makefile.mk include $(top_srcdir)/src/binding/abi/Makefile.mk include $(top_srcdir)/src/binding/cxx/Makefile.mk -include $(top_srcdir)/src/binding/fortran/mpif_h/Makefile.mk -include $(top_srcdir)/src/binding/fortran/use_mpi/Makefile.mk -include $(top_srcdir)/src/binding/fortran/use_mpi_f08/Makefile.mk diff --git a/src/binding/fortran/Makefile.am b/src/binding/fortran/Makefile.am new file mode 100644 index 00000000000..671cfa1585a --- /dev/null +++ b/src/binding/fortran/Makefile.am @@ -0,0 +1,45 @@ +## +## Copyright (C) by Argonne National Laboratory +## See COPYRIGHT in top-level directory +## + +ACLOCAL_AMFLAGS = -I confdb +AM_CPPFLAGS = @VISIBILITY_CFLAGS@ -I$(top_srcdir) +AM_FFLAGS = +AM_FCFLAGS = + +mpi_fc_modules = +mpifort_convenience_libs = + +lib_LTLIBRARIES = +noinst_LTLIBRARIES = +noinst_HEADERS = +nodist_include_HEADERS = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = +BUILT_SOURCES = + +include $(srcdir)/mpif_h/Makefile.mk +include $(srcdir)/use_mpi/Makefile.mk +include $(srcdir)/use_mpi_f08/Makefile.mk + +lib_LTLIBRARIES += lib/lib@MPIFCLIBNAME@.la +lib_lib@MPIFCLIBNAME@_la_SOURCES = +modinc_HEADERS = $(mpi_fc_modules) +lib_lib@MPIFCLIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS) @FCLIB_LDFLAGS@ +lib_lib@MPIFCLIBNAME@_la_LIBADD = @mpi_libs@ $(mpifort_convenience_libs) + +if BUILD_F77_BINDING +if BUILD_FC_BINDING +lib_lib@MPIFCLIBNAME@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=FC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(FCLD) \ + $(AM_FCFLAGS) $(FCFLAGS) $(lib_lib@MPIFCLIBNAME@_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +else !BUILD_FC_BINDING +lib_lib@MPIFCLIBNAME@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=F77 \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(F77LD) \ + $(AM_FFLAGS) $(FFLAGS) $(lib_lib@MPIFCLIBNAME@_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +endif !BUILD_FC_BINDING +endif BUILD_F77_BINDING diff --git a/src/binding/fortran/autogen.sh b/src/binding/fortran/autogen.sh new file mode 100755 index 00000000000..b13b7fe605f --- /dev/null +++ b/src/binding/fortran/autogen.sh @@ -0,0 +1,49 @@ +#! /bin/sh +## +## Copyright (C) by Argonne National Laboratory +## See COPYRIGHT in top-level directory +## + +if test -z "$AUTORECONF" ; then + AUTORECONF="autoreconf" +fi + +if test -n "$MPICH_CONFDB" ; then + CONFARGS="-I $MPICH_CONFDB -vif" + mkdir -p confdb +else + if ! test -d confdb ; then + echo "Missing confdb!" + exit 1 + fi + + CONFARGS="-vif" +fi + + +$AUTORECONF $CONFARGS || exit 1 + +# need python3 to generate bindings + +check_python3() { + printf "Checking for python ..." + PYTHON= + if test 3 = `python -c 'import sys; print(sys.version_info[0])' 2> /dev/null || echo "0"`; then + PYTHON=python + fi + + if test -z "$PYTHON" -a 3 = `python3 -c 'import sys; print(sys.version_info[0])' 2> /dev/null || echo "0"`; then + PYTHON=python3 + fi + + if test -z "$PYTHON" ; then + echo "not found" + exit 1 + else + echo "$PYTHON" + fi +} + +if test -z "$PYTHON" ; then + check_python3 +fi diff --git a/src/binding/fortran/configure.ac b/src/binding/fortran/configure.ac new file mode 100644 index 00000000000..fea2cf0ebaa --- /dev/null +++ b/src/binding/fortran/configure.ac @@ -0,0 +1,1030 @@ +## +## Copyright (C) by Argonne National Laboratory +## See COPYRIGHT in top-level directory +## + +AC_PREREQ([2.69]) + +m4_include([version.m4]) + +AC_INIT([MPIFORT], MPICH_VERSION_m4, [discuss@mpich.org], [mpifort], [http://www.mpich.org/]) + +AC_CONFIG_AUX_DIR(confdb) +AC_CONFIG_MACRO_DIR(confdb) +AM_INIT_AUTOMAKE([-Wall -Wno-portability-recursive foreign 1.12.3 silent-rules subdir-objects no-dist no-maintainer-mode]) +AM_MAINTAINER_MODE([disable]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +AC_CONFIG_HEADERS([mpifort_config.h]) + +AC_ARG_VAR([MPIFCLIBNAME],[can be used to override the name of the MPI fortran library (default: "${MPILIBNAME}fort")]) +if test -z "$MPIFCLIBNAME" ; then + MPIFCLIBNAME="mpifort" ; +fi +export MPIFCLIBNAME +AC_SUBST(MPIFCLIBNAME) + +# When build from MPICH, --with-mpi=mpich to build native mpich ABI, --with-mpi=abi to build MPI ABI +# When build stand-alone, set --with-mpi to path. TODO: check for system mpi. +AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi=dir], + [Specify the path where MPI is installed.])],,with_mpi=mpich) + +mpi_h= +mpi_libs= +AC_SUBST(mpi_libs) +if test "$FROM_MPICH" = "yes" ; then + if test "$WITH_MPI" = "mpich" ; then + # We expect the following vars to be set from parent configure + # MPI_MAX_PROCESSOR_NAME, MPI_MAX_LIBRARY_VERSION_STRING, MPI_MAX_ERROR_STRING, BSEND_OVERHEAD + # MPI_SIZEOF_AINT, MPI_SIZEOF_OFFSET, MPI_SIZEOF_COUNT + PAC_APPEND_FLAG(-I${main_top_srcdir}/src/include, [CPPFLAGS]) + mpi_h="$main_top_srcdir/src/include/mpi_mpich.h.in" + elif test "$WITH_MPI" = "abi" ; then + PAC_APPEND_FLAG(-I${main_top_srcdir}/src/binding, [CPPFLAGS]) + mpi_h="$main_top_srcdir/src/binding/mpi_abi.h" + else + AC_MSG_ERROR([$FROM_MPICH is set but $WITH_MPI is not set!]) + fi +else + if ! test "$with_mpi/include/mpi.h" ; then + AC_MSG_ERROR([mpi.h not found in $with_mpi/include/]) + fi + PAC_APPEND_FLAG(-I${with_mpi}/include, [CPPFLAGS]) + mpi_h="$with_mpi/include/mpi.h" + + if test -e "$with_mpi/lib/libmpi.so" ; then + PAC_APPEND_FLAG(-L${with_mpi}/lib, [LDFLAGS]) + mpi_libs="-lmpi" + elif test -e "$with_mpi/lib/libmpi_abi.so" ; then + PAC_APPEND_FLAG(-L${with_mpi}/lib, [LDFLAGS]) + mpi_libs="-lmpi_abi" + fi +fi + +# Find a C compiler. +# We also need to do this before the F77 and FC test to ensure that we +# find the C preprocessor reliably. +AC_PROG_CC +AM_PROG_CC_C_O + +# check some constants from mpi.h +if test -z "$MPI_SIZEOF_AINT" -a -n "$mpi_h" ; then + AC_CHECK_SIZEOF(MPI_Aint, 0, [#include "mpi.h"]) + if test $ac_cv_sizeof_MPI_Aint -gt "0" ; then + MPI_SIZEOF_AINT=$ac_cv_sizeof_MPI_Aint + fi + + AC_CHECK_SIZEOF(MPI_Offset, 0, [#include "mpi.h"]) + if test $ac_cv_sizeof_MPI_Offset -gt "0" ; then + MPI_SIZEOF_OFFSET=$ac_cv_sizeof_MPI_Offset + fi + + AC_CHECK_SIZEOF(MPI_Count, 0, [#include "mpi.h"]) + if test $ac_cv_sizeof_MPI_Count -gt "0" ; then + MPI_SIZEOF_COUNT=$ac_cv_sizeof_MPI_Count + fi +fi + +if test -z "$MPI_SIZEOF_AINT" ; then + AC_MSG_ERROR([Can't determine the size of MPI_Aint]) +fi +if test -z "$MPI_SIZEOF_OFFSET" ; then + AC_MSG_ERROR([Can't determine the size of MPI_Offset]) +fi +if test -z "$MPI_SIZEOF_COUNT" ; then + AC_MSG_ERROR([Can't determine the size of MPI_Count]) +fi + + +dnl enable_fortran is assumed to be true + +# suppress default "-g -O2" from AC_PROG_FC +: ${FCFLAGS=""} + +# We only supports a single compiler for FC and F77 +AC_PROG_FC + +if test "$FC" = "" -o "$FC" = "no"; then + # No Fortran compiler found; abort + AC_MSG_ERROR([No Fortran compiler found. If you don't need to + build any Fortran programs, you can disable Fortran support using + --disable-fortran. If you do want to build Fortran + programs, you need to install a Fortran compiler such as gfortran + or ifort before you can proceed. Set FC to the path of Fortran compiler.]) +fi + +F77=$FC +FFLAGS=$FCFLAGS +AC_PROG_F77 + +AC_ARG_ENABLE([two-level-namespace], + [AS_HELP_STRING([--enable-two-level-namespace], + [(Darwin only) Do not use `-Wl,-flat_namespace` to + link libmpifort.dylib. MacOS uses two-level namespace + to compile dylibs by default. This may cause issues + not resolving MPI constants, such as MPI_IN_PLACE. + Thus, we use flat_namespace by default. Enable this + option to use two-level-namespace instead. ])], + [], + [enable_two_level_namespace=no]) + +FCLIB_LDFLAGS= +AC_SUBST([FCLIB_LDFLAGS]) + +if test "X$enable_shared" = "Xyes" ; then + # see ticket #1590 for some more background on these Darwin linking issues + AS_CASE([$host], + [*-*-darwin*], + [ + + # The linker on Darwin does not allow common symbols, thus libtool + # adds the -fno-common option by default for shared libraries. + # However, the common symbols defined in different shared libraries + # and object files still can not be treated as the same symbol. + # For example: + # with gfortran, the same common block in the shared libraries and + # the object files will have different memory locations separately; + # with ifort, the same common block in different shared libraries + # will get the same memory location but still get a different location + # in the object file. + + # On the other hand, the -flat-namespace option allows linker to + # unify the same common symbols in different dylibs. It needs to be + # added in linking stage for both the shared library and the final + # executable file. + + # In Fortran programs, we implement global definitions such as MPI_BOTTOM + # as common symbols. We check the address of the user input and translate it + # to the C global definition if it is equal to the internal pre-stored address + # in the Fortran binding layer. Without -flat-namespace, we may get different + # addresses and thus treat the predefined constant as a normal buffer. + + # sanity check that -Wl,-flat_namespace works on darwin, unless the user + # asked us not to add it + if test "X$enable_two_level_namespace" = "Xno"; then + # TODO, move this into a PAC macro with real autoconf caching + pac_cv_wl_flat_namespace_works=no + AC_MSG_CHECKING([if the C compiler accepts -Wl,-flat_namespace]) + PAC_PUSH_FLAG([LDFLAGS]) + PAC_APPEND_FLAG([-Wl,-flat_namespace],[LDFLAGS]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[int i;])], + [AC_MSG_RESULT([yes]) + pac_cv_wl_flat_namespace_works=yes], + [AC_MSG_RESULT([no])]) + PAC_POP_FLAG([LDFLAGS]) + + # Technically we may not be able to use the same form of the argument + # for all three compilers (CC/CXX/FC). But we only think this is + # necessary for Darwin for now, so this unconditional, single-var + # approximation will work for now. + if test "X$pac_cv_wl_flat_namespace_works" = "Xyes" ; then + FCLIB_LDFLAGS="-Wl,-flat_namespace" + fi + fi + ] + ) +fi + +# Determine characteristics of the Fortran 90 compiler +# Find a Fortran 90 compiler. Sets FC +# Work around bug in autoconf that adds -g to FCFLAGS +saveFCFLAGS="$FCFLAGS" +PAC_PROG_FC_WORKS +FCFLAGS=$saveFCFLAGS +if test "$pac_cv_prog_fc_works" = no ; then + AC_MSG_ERROR([Could not find a usable Fortran 90 compiler. Check the output of configure and consult the installation manuals]) +fi + +# assume requirement for f77 and f90 are always met at this point +enable_f77=yes +enable_f90=yes +AM_CONDITIONAL([BUILD_F77_BINDING], [test "$enable_f77" = "yes"]) +AM_CONDITIONAL([BUILD_FC_BINDING], [test "$enable_f90" = "yes"]) + +# check requirement for f08 +PAC_FC_2008_SUPPORT([enable_f08=yes],[enable_f08=no]) +AM_CONDITIONAL([BUILD_F08_BINDING], [test "$enable_f08" = "yes"]) + +fortran_bindings= +AC_SUBST([fortran_bindings]) + +if test "$enable_f77" = "yes" ; then + PAC_APPEND_CSV([mpif.h], [fortran_bindings]) +fi + +if test "$enable_f90" = "yes" ; then + PAC_APPEND_CSV([use mpi], [fortran_bindings]) +fi + +if test "$enable_f08" = "yes" ; then + PAC_APPEND_CSV([use mpi_f08], [fortran_bindings]) + AC_DEFINE(HAVE_F08_BINDING, 1, [Define to 1 if we have Fortran 2008 binding]) +fi + +AM_PROG_AR + +LT_PREREQ([2.2.6]) +LT_INIT() + +# generate fc_shlib.conf, needed by mpifort, used by MPICH +fc_shlib_conf=fc_shlib.conf +PAC_COMPILER_SHLIB_FLAGS([FC],[$fc_shlib_conf]) + +PAC_CHECK_VISIBILITY +AC_SUBST(VISIBILITY_CFLAGS) + +# check weak symbols, needed by f77 binding +# duplicated from mpich configure + +# If build with MPICH, if paraent configure set NEEDSPLIB to yes, skip weak symbol check +if test "$NEEDSPLIB" != "yes" ; then + PAC_PROG_C_WEAK_SYMBOLS(enable_weak_symbols=yes,enable_weak_symbols=no) + if test "$pac_cv_prog_c_weak_symbols" = "pragma weak alias" -o "$pac_cv_prog_c_weak_symbols" = "attr weak alias" ; then + AC_DEFINE(USE_WEAK_SYMBOLS,1,[Define if weak symbols should be used]) + NEEDSPLIB=no + else + NEEDSPLIB=yes + fi +fi +AM_CONDITIONAL([BUILD_LIBF77_PMPI],[test "$NEEDSPLIB" = "yes"]) + +AC_ARG_ENABLE(multi-aliases, + AS_HELP_STRING([--enable-multi-aliases], + [Multiple aliasing to support multiple fortran compilers (default)]),, + enable_multi_aliases=yes) + + +# MPI_STATUS_SIZE is hardcoded and need to be synchronized with mpi.h +# FIXME: check MPI_F_STATUS_SIZE from mpi.h +MPI_STATUS_SIZE=5 +AC_SUBST([MPI_STATUS_SIZE]) + +# Check if multiple __attribute__((alias)) is available +# This test requires MPI_STATUS_SIZE, and thus must be made after +# MPI_STATUS_SIZE is determined +if test "$enable_multi_aliases" = "yes" ; then + PAC_C_MULTI_ATTR_ALIAS + if test "$pac_c_multi_attr_alias" = "yes" ; then + PAC_F2C_ATTR_ALIGNED_SIZE([1],[CMB_1INT_ALIGNMENT]) + AC_SUBST(CMB_1INT_ALIGNMENT) + PAC_F2C_ATTR_ALIGNED_SIZE([$MPI_STATUS_SIZE],[CMB_STATUS_ALIGNMENT], + [32]) + AC_SUBST(CMB_STATUS_ALIGNMENT) + if test "X$CMB_1INT_ALIGNMENT" != "X" \ + -a "X$CMB_STATUS_ALIGNMENT" != "X" ; then + AC_DEFINE(HAVE_C_MULTI_ATTR_ALIAS, 1, + [Define if multiple __attribute__((alias)) are supported]) + fi + fi +fi + +# --------------------------------------------------------------------------- +# Support for the language bindings: Fortran 77, Fortran 90 +# +# First, we handle the case of no explicit enable/disable option. In that +# case, we look for a usable compiler. We cannot use the ac macros for this +# because they abort the configure step if they fail to find a compiler +# (earlier versions of autoconf did not have this behavior!). +# +# Second, we perform the langugage-specific tests, if necessary. This may +# be relatively simple (C++) or complex (Fortran 77, including formation of +# the encoded MPI handles). +# +# Note that the bindings support needs to know some of the properties of +# the C compiler, so those tests (particularly for weak symbols) +# must come first. +# ---------------------------------------------------------------------------- + +# +# First, determine whether we are/can support the language bindings +# +# Handle default choices for the Fortran compilers +# Note that these have already been set above + +# Determine the extension for Fortran 90 files (it isn't always .f90) +PAC_FC_EXT +FCEXT=$ac_fc_srcext +AC_SUBST(FCEXT) + +if test "$enable_f77" = yes ; then + # Check if $MPI_DEFAULT_FOPTS is valid with $F77 + if test -n "$MPI_DEFAULT_FOPTS" ; then + if test "$enable_check_compiler_flags" = "yes" ; then + PAC_F77_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_FOPTS], [ + FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS" + ] ) + else + FFLAGS="$FFLAGS $MPI_DEFAULT_FOPTS" + fi + fi +fi + +# +# We need to know the name mangling for Fortran before testing for FC +# compatibility (we need this because of the way we decide to generate +# the Fortran 77 bindings) +if test "$enable_f77" = yes ; then + FLIBS_save="$FLIBS" + FLIBS="" + AC_F77_LIBRARY_LDFLAGS + # The autoconf macro for finding FLIBS sometimes makes mistakes + # (particularly with the Fujitsu frt compiler). This next step + # first sees if the FLIBS is valid with the Fortran compiler + PAC_PROG_F77_FLIBS_VALID + # Now see if FLIBS works with the C compiler + PAC_PROG_F77_CHECK_FLIBS + + # Check F77+FLAGS is compatible with CC+CFLAGS before using F77+CC. + PAC_PROG_F77_OBJ_LINKS_WITH_C + + PAC_PROG_F77_LINKER_WITH_C + # For name mangle, we need the library flags + PAC_PROG_F77_NAME_MANGLE + # Check whether additional libraries are needed when linking with C + PAC_PROG_F77_AND_C_STDIO_LIBS + AC_SUBST(F77_OTHER_LIBS) + + # Warn about mixed name mangling, since many of the tests will fail + if test "$pac_cv_prog_f77_name_mangle" = "mixed" ; then + AC_MSG_WARN([The compiler $F77 uses mixed case names. Fortran is monocase +and many Fortran programs may use either upper or lower case names for MPI +calls. Consider specifying a particular parameter to your Fortran compiler +to select either upper or lower case names. For the Absoft compiler, +-f selects lower case and -N109 selects upper case (if you use -f, also use +-B108 to enable the iargc and getarg routines, which are needed for some +tests and by many user programs). Specify new command +line options by setting the environment variable FFLAGS to include +the options (e.g., setenv FFLAGS "-f -B108"). In addition, make sure that your +Fortran 90 compiler uses a compatible naming choice. For the +Absoft Fortran 90, -YALL_NAMES=LCS selects lower case names and -B108 +adds underscores to names, as required for iargc and getarg. Pass this +information to configure with the FCFLAGS environment variable.]) + # If Fortran implicitly enabled, disable it now. Otherwise, + # abort the configure since warning messages are often lost in + # the output. + AC_MSG_ERROR([Aborting configure because of mixed case names in Fortran. Either select --disable-fortran or set FCFLAGS to force the compiler to select monocase names]) + fi + + # The MPI standard requires that MPI_Init in any language initialize + # MPI in all languages. This can be a problem when objects produced + # by the Fortran compiler require symbols from the Fortran runtime + # (making linking C-only programs unnecessarily difficult). What we test + # here is whether the much more restricted needs of the Fortran + # initialize can be met with no special use of the Fortran runtime + PAC_F77_INIT_WORKS_WITH_C + if test "$pac_f_init_works_with_c" = "yes" ; then + AC_DEFINE(HAVE_MPI_F_INIT_WORKS_WITH_C,1,[Define if the Fortran init code for MPI works from C programs without special libraries]) + fi + + # + # Some Fortran compilers now pass CHARACTER length as a size_t instead + # of as an int. This is hard to test for, since the data is passed by + # value and for characters less than about 2GB long, the correct + # value will be used. In this case, we must use an approach similar to + # the one used by libtool for shared library options - look at the + # compiler name or vendor. + # Known compilers that use size_t instead of int: + # Intel Fortran + # gfortran + # Add others as they become known + AC_ARG_ENABLE(f77characterlen, + AS_HELP_STRING([--enable-f77characterlen], + [Select between int and size_t for the length of a Fortran CHARACTER, depending on the F77 compiler. If --enable-f77characterlen=size_t is given, force the use of size_t. This is used for passing Fortran CHARACTER data between C and Fortran, and is provided for experts. Note that the documentation provided by compiler vendors on the calling convention may not be accurate.]),,enable_f77characterlen=no) + + # Set the default + f77_uses_int_for_str=default + + case "$enable_f77characterlen" in + yes|no) + ;; + size_t) + f77_uses_int_for_str=no + enable_f77characterlen=yes + ;; + int) + f77_uses_int_for_str=yes + enable_f77characterlen=yes + ;; + *) + AC_MSG_ERROR([Invalid value provided for --enable-f77characterlen]) + ;; + esac + + # If we might change the size (enable) and we haven't set the choice, + # attempt to determine it from the compiler name. Risky, but we haven't + # found a reliable way to do this with test codes. + if test "$enable_f77characterlen" = "yes" -a \ + "$f77_uses_int_for_str" = "default" ; then + f77_uses_int_for_str=yes + f77Basename=`basename $F77` + case $f77Basename in + ifort*) + f77_uses_int_for_str=no + ;; + gfortran*) + f77_uses_int_for_str=no + ;; + esac + fi + # This test is disabled for now. Despite information in documentation + # on gfortran, it appears to pass lengths as int, at least in some + # builds (it used movl when tested in 2/2013). Tests that failed + # included infotestf.f, in a call to mpi_info_get. + # Leave this as a place holder until a proper test can be determined. + if test "$enable_f77characterlen" = "yes" -a \ + "$f77_uses_int_for_str" = "no" ; then + AC_DEFINE(USE_FORT_STR_LEN_SIZET,1,[Define if the length of a CHARACTER*(*) string in Fortran should be passed as size_t instead of int] ) + fi + +fi + +# ---------------------------------------------------------------------------- +# Now test for Fortran compiler characteristics +# ---------------------------------------------------------------------------- +if test "$enable_f77" = "yes" ; then + AC_LANG([Fortran 77]) + PAC_PROG_F77_EXCLAIM_COMMENTS(has_exclaim="yes",has_exclaim="no") + PAC_PROG_F77_HAS_INCDIR(src) + PAC_PROG_F77_LIBRARY_DIR_FLAG + + AC_SUBST(MPIFPMPI) + if test "$MPI_WITH_PMPI" = "no" ; then + # If the PMPI routines are not in the same library with the MPI + # routines, we may need to remove the pmpi declarations + PAC_PROG_F77_ALLOWS_UNUSED_EXTERNALS([MPIFPMPI=",PMPI_WTIME,PMPI_WTICK"],[ + MPIFPMPI=""; + AC_MSG_WARN([Removed PMPI_WTIME and PMPI_WTICK from mpif.h])]) + else + MPIFPMPI=",PMPI_WTIME,PMPI_WTICK" + fi + + # Once we have name mangle, we can try to limit the number of needed libs + dnl F77_IN_C_LIBS is not needed currently because mpirinitf_() in setbotf.f + dnl is called in initthread.c only when FLIBS is not needed to initialize + dnl Fortran constants from a C main, See PAC_F77_INIT_WORKS_WITH_C. + dnl PAC_PROG_F77_IN_C_LIBS + dnl AC_SUBST(F77_IN_C_LIBS) + + # Most systems allow the Fortran compiler to process .F and .F90 files + # using the C preprocessor. However, some systems either do not + # allow this or have serious bugs (OSF Fortran compilers have a bug + # that generates an error message from cpp). The following test + # checks to see if .F works, and if not, whether "cpp -P -C" can be used + # This is needed for Mac OSX 10.5 + PAC_F77_WORKS_WITH_CPP([F77CPP]) + AC_SUBST(F77CPP) + + # Check that the Fortran compiler will allow us to pass arguments + # of different types (e.g., for MPI_Send) + PAC_PROG_F77_MISMATCHED_ARGS(addarg,yes) + if test "X$addarg" != "X" ; then + # 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) +fi + +dnl By modifying mpif.h to use ! for comments, it can work with many f90 +dnl compilers without creating a separate version. +dnl Note that this is run AFTER the AC_OUTPUT actions +AC_CONFIG_COMMANDS([src/include/mpif.h],[if test "$enable_f77" = yes ; then + if test "$has_exclaim" = "yes" ; then + sed -e 's/^C/\!/g' mpif_h/mpif.h > mpif.h.tmp + mv mpif.h.tmp mpif_h/mpif.h + fi + if test "$has_fort_real8" = "yes" ; then + sed -e 's/DOUBLE PRECISION/REAL*8/g' mpif_h/mpif.h > mpif.h.tmp + mv mpif.h.tmp mpif_h/mpif.h + fi +fi], +enable_f77=$enable_f77 +has_exclaim=$has_exclaim +has_fort_real8=$pac_cv_fort_real8) + +# ---------------------------------------------------------------------------- +# We can now create the Fortran versions of the datatype values, along with +# some of the other datatype-dependent sizes + +# There are two parts to handling the datatypes: +# Convert the C datatype values to their Fortran equivalent. This +# involves converting the hex values for the C version into decimal +# since standard Fortran does not have hex constants +# +# Determine the existence of the Fortran 'sized' types and set those +# values. +# +# In addition, we need to look at a few additional constants that depend +# on how the compiler sizes some datatypes. These are: +# INTEGER_KIND, ADDRESS_KIND, and OFFSET_KIND +# +# ---------------------------------------------------------------------------- +pac_cv_f77_sizeof_character=1 + +# Up to size checking code in main configure.ac (where it tries to +# find the matching C sizes) as part of defining mpi_integer8 etc. +# The results are available in pac_cv_sizeof_f77_ +# Size is 0 if unknown or unavailable (or cross-compiling) +# Due to limitations in autoconf, we cannot put these into a loop. +# We also check integer to find the type of MPI_Fint +# +# Cross-compilation results can be included with the --with-cross=file +# option. +CROSS_F77_SIZEOF_INTEGER=${CROSS_F77_SIZEOF_INTEGER:-0} +CROSS_F77_SIZEOF_REAL=${CROSS_F77_SIZEOF_REAL:-0} +CROSS_F77_SIZEOF_DOUBLE_PRECISION=${CROSS_F77_SIZEOF_DOUBLE_PRECISION:-0} +CROSS_F77_SIZEOF_LOGICAL=${CROSS_F77_SIZEOF_LOGICAL:-0} +PAC_PROG_F77_CHECK_SIZEOF_EXT(integer,$CROSS_F77_SIZEOF_INTEGER) +PAC_PROG_F77_CHECK_SIZEOF_EXT(real,$CROSS_F77_SIZEOF_REAL) +PAC_PROG_F77_CHECK_SIZEOF_EXT(double precision,$CROSS_F77_SIZEOF_DOUBLE_PRECISION) +PAC_PROG_F77_CHECK_SIZEOF_EXT(logical,$CROSS_F77_SIZEOF_LOGICAL) +AC_LANG([Fortran 77]) +# If we have sizes for real and double, we do not need to call +# mpir_get_fsize at run time. +# For the size-defined types (e.g., integer*2), we assume that if the +# compiler allows it, it has the stated size. +AC_CACHE_CHECK([whether integer*1 is supported],pac_cv_fort_integer1,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*1 i])], + pac_cv_fort_integer1=yes, + pac_cv_fort_integer1=no)]) +AC_CACHE_CHECK([whether integer*2 is supported],pac_cv_fort_integer2,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*2 i])], + pac_cv_fort_integer2=yes, + pac_cv_fort_integer2=no)]) +AC_CACHE_CHECK([whether integer*4 is supported],pac_cv_fort_integer4,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*4 i])], + pac_cv_fort_integer4=yes, + pac_cv_fort_integer4=no)]) +AC_CACHE_CHECK([whether integer*8 is supported],pac_cv_fort_integer8,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*8 i])], + pac_cv_fort_integer8=yes, + pac_cv_fort_integer8=no)]) +AC_CACHE_CHECK([whether integer*16 is supported],pac_cv_fort_integer16,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ integer*16 i])], + pac_cv_fort_integer16=yes, + pac_cv_fort_integer16=no)]) +AC_CACHE_CHECK([whether real*2 is supported],pac_cv_fort_real2,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*2 a])], + pac_cv_fort_real2=yes, + pac_cv_fort_real2=no)]) +AC_CACHE_CHECK([whether real*4 is supported],pac_cv_fort_real4,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*4 a])], + pac_cv_fort_real4=yes, + pac_cv_fort_real4=no)]) +AC_CACHE_CHECK([whether real*8 is supported],pac_cv_fort_real8,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*8 a])], + pac_cv_fort_real8=yes, + pac_cv_fort_real8=no)]) +AC_CACHE_CHECK([whether real*16 is supported],pac_cv_fort_real16,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ real*16 a])], + pac_cv_fort_real16=yes, + pac_cv_fort_real16=no)]) +AC_CACHE_CHECK([whether complex*4 is supported],pac_cv_fort_complex4,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*4 a])], + pac_cv_fort_complex4=yes, + pac_cv_fort_complex4=no)]) +AC_CACHE_CHECK([whether complex*8 is supported],pac_cv_fort_complex8,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*8 a])], + pac_cv_fort_complex8=yes, + pac_cv_fort_complex8=no)]) +AC_CACHE_CHECK([whether complex*16 is supported],pac_cv_fort_complex16,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*16 a])], + pac_cv_fort_complex16=yes, + pac_cv_fort_complex16=no)]) +AC_CACHE_CHECK([whether complex*32 is supported],pac_cv_fort_complex32,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ complex*32 a])], + pac_cv_fort_complex32=yes, + pac_cv_fort_complex32=no)]) +AC_CACHE_CHECK([whether double precision is supported],pac_cv_fort_double_precision,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ double precision a])], + pac_cv_fort_double_precision=yes, + pac_cv_fort_double_precision=no)]) + +if test -z "$pac_cv_f77_sizeof_integer" -o \ + "X$pac_cv_f77_sizeof_integer" = "X0" ; then + AC_MSG_ERROR([Unable to configure with Fortran support because configure could not determine the size of a Fortran INTEGER. Consider setting CROSS_F77_SIZEOF_INTEGER to the length in bytes of a Fortran INTEGER]) +fi + +AC_DEFINE_UNQUOTED([MPI_CHARACTER_SIZE], [$pac_cv_f77_sizeof_character], [Define the size of Fortran CHARACTER]) +AC_DEFINE_UNQUOTED([MPI_LOGICAL_SIZE], [$pac_cv_f77_sizeof_logical], [Define the size of Fortran LOGICAL]) +AC_DEFINE_UNQUOTED([MPI_INTEGER_SIZE], [$pac_cv_f77_sizeof_integer], [Define the size of Fortran INTEGER]) +AC_DEFINE_UNQUOTED([MPI_REAL_SIZE], [$pac_cv_f77_sizeof_real], [Define the size of Fortran REAL]) +AC_DEFINE_UNQUOTED([MPI_DOUBLE_PRECISION_SIZE], [$pac_cv_f77_sizeof_double_precision], [Define the size of Fortran DOUBLE PRECISION]) + +if test "$pac_cv_fort_double_precision" = "yes"; then + AC_DEFINE([MPI_DOUBLE_PRECISION_SUPPORTED], [1], [Define if Fortran DOUBLE PRECISION is supported]) +fi +if test "$pac_cv_fort_logical1" = "yes"; then + AC_DEFINE([MPI_LOGICAL1_SUPPORTED], [1], [Define if Fortran LOGICAL*1 is supported]) +fi +if test "$pac_cv_fort_logical2" = "yes"; then + AC_DEFINE([MPI_LOGICAL2_SUPPORTED], [1], [Define if Fortran LOGICAL*2 is supported]) +fi +if test "$pac_cv_fort_logical4" = "yes"; then + AC_DEFINE([MPI_LOGICAL4_SUPPORTED], [1], [Define if Fortran LOGICAL*4 is supported]) +fi +if test "$pac_cv_fort_logical8" = "yes"; then + AC_DEFINE([MPI_LOGICAL8_SUPPORTED], [1], [Define if Fortran LOGICAL*8 is supported]) +fi +if test "$pac_cv_fort_logical16" = "yes"; then + AC_DEFINE([MPI_LOGICAL16_SUPPORTED], [1], [Define if Fortran LOGICAL*16 is supported]) +fi +if test "$pac_cv_fort_integer1" = "yes"; then + AC_DEFINE([MPI_INTEGER1_SUPPORTED], [1], [Define if Fortran INTEGER*1 is supported]) +fi +if test "$pac_cv_fort_integer2" = "yes"; then + AC_DEFINE([MPI_INTEGER2_SUPPORTED], [1], [Define if Fortran INTEGER*2 is supported]) +fi +if test "$pac_cv_fort_integer4" = "yes"; then + AC_DEFINE([MPI_INTEGER4_SUPPORTED], [1], [Define if Fortran INTEGER*4 is supported]) +fi +if test "$pac_cv_fort_integer8" = "yes"; then + AC_DEFINE([MPI_INTEGER8_SUPPORTED], [1], [Define if Fortran INTEGER*8 is supported]) +fi +if test "$pac_cv_fort_integer16" = "yes"; then + AC_DEFINE([MPI_INTEGER16_SUPPORTED], [1], [Define if Fortran INTEGER*16 is supported]) +fi +if test "$pac_cv_fort_real2" = "yes"; then + AC_DEFINE([MPI_REAL2_SUPPORTED], [1], [Define if Fortran REAL*2 is supported]) +fi +if test "$pac_cv_fort_real4" = "yes"; then + AC_DEFINE([MPI_REAL4_SUPPORTED], [1], [Define if Fortran REAL*4 is supported]) +fi +if test "$pac_cv_fort_real8" = "yes"; then + AC_DEFINE([MPI_REAL8_SUPPORTED], [1], [Define if Fortran REAL*8 is supported]) +fi +if test "$pac_cv_fort_real16" = "yes"; then + AC_DEFINE([MPI_REAL16_SUPPORTED], [1], [Define if Fortran REAL*16 is supported]) +fi +if test "$pac_cv_fort_complex4" = "yes"; then + AC_DEFINE([MPI_COMPLEX4_SUPPORTED], [1], [Define if Fortran COMPLEX*4 is supported]) +fi +if test "$pac_cv_fort_complex8" = "yes"; then + AC_DEFINE([MPI_COMPLEX8_SUPPORTED], [1], [Define if Fortran COMPLEX*8 is supported]) +fi +if test "$pac_cv_fort_complex16" = "yes"; then + AC_DEFINE([MPI_COMPLEX16_SUPPORTED], [1], [Define if Fortran COMPLEX*16 is supported]) +fi +if test "$pac_cv_fort_complex32" = "yes"; then + AC_DEFINE([MPI_COMPLEX32_SUPPORTED], [1], [Define if Fortran COMPLEX*32 is supported]) +fi + +AC_LANG_PUSH([C]) +AC_CHECK_SIZEOF(int) +# for matching C types for F08 ISO_C_BINDING +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) +AC_LANG_POP([C]) + +# Provide the corresponding C types for MPI_INTEGER +AC_MSG_CHECKING([for C type matching Fortran integer]) +if test "$pac_cv_f77_sizeof_integer" == "$ac_cv_sizeof_int" ; then + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_FINT_IS_INT,1,[Define if Fortran integer are the same size as C ints]) + MPI_FINT=int +else + AC_MSG_RESULT([no]) + AC_MSG_WARN([Fortran integers and C ints are not the same size. C programs that directly use MPI_Fint may be incorrect.]) + if test "$pac_cv_f77_sizeof_integer" == "$ac_cv_sizeof_short" ; then + MPI_FINT=short + elif test "$pac_cv_f77_sizeof_integer" == "$ac_cv_sizeof_long" ; then + MPI_FINT=long + elif test "$pac_cv_f77_sizeof_integer" == "$ac_cv_sizeof_long_long" ; then + MPI_FINT="long long" + else + AC_MSG_ERROR([Failed to determine C type for Fortran Integer.]) + fi +fi + +# Try and compute the values of .true. and .false. in Fortran +# This code has been removed because the Fortran binding code does +# not yet support it. +PAC_F77_LOGICALS_IN_C([$MPI_FINT]) + +# Get the INTEGER_KIND, ADDRESS_KIND and OFFSET_KIND if possible +# We also need to check the size of MPI_Aint vs MPI_Fint, and +# define AINT_LARGER_THAN_FINT if aint is larger (this +# affects code in MPI_Address) +if test "$MPI_SIZEOF_AINT" != "0" -a \ + "$MPI_SIZEOF_AINT" -gt "$pac_cv_f77_sizeof_integer" ; then + AC_DEFINE(HAVE_AINT_LARGER_THAN_FINT,1,[Define if addresses are larger than Fortran integers]) +fi +if test "$MPI_SIZEOF_AINT" != 0 -a \ + "$MPI_SIZEOF_AINT" != "$pac_cv_f77_sizeof_integer" ; then + AC_DEFINE(HAVE_AINT_DIFFERENT_THAN_FINT,1,[Define if addresses are a different size than Fortran integers]) +fi + +dnl Using the {} around testsize helps the comments work correctly +PAC_PROG_FC_INT_KIND(INTEGER_KIND,${pac_cv_f77_sizeof_integer},$CROSS_F90_INTEGER_KIND) +PAC_PROG_FC_INT_KIND(ADDRESS_KIND,${MPI_SIZEOF_AINT},$CROSS_F90_ADDRESS_KIND) +PAC_PROG_FC_INT_KIND(OFFSET_KIND,${MPI_SIZEOF_OFFSET},$CROSS_F90_OFFSET_KIND) + +if test "$INTEGER_KIND" = "-1" ; then + # In our experience, this usually means that there is some + # problem building and/or running the f90 program. Fail + # in this case rather than attempt to continue + AC_MSG_ERROR([Unable to determine Fortran 90 KIND values for either address-sized integers or offset-sized integers.]) +fi +# +# Some compilers won't allow a -1 kind (e.g., absoft). In this case, +# use a fallback (sizeof(int) kind) +if test "$ADDRESS_KIND" = "-1" ; then + ADDRESS_KIND=$INTEGER_KIND +fi +if test "$OFFSET_KIND" = "-1" ; then + OFFSET_KIND=$INTEGER_KIND +fi + +# assuming MPI_SIZEOF_COUNT is the max of MPI_SIZEOF_AINT and MPI_SIZEOF_OFFSET +if test $MPI_SIZEOF_COUNT = $MPI_SIZEOF_AINT; then + COUNT_KIND=$ADDRESS_KIND +else + COUNT_KIND=$OFFSET_KIND +fi + +if test "$enable_f08" = "yes"; then + PAC_PROG_FC_C_INT_TYPE([$MPI_SIZEOF_AINT], [F08_C_AINT]) + PAC_PROG_FC_C_INT_TYPE([$MPI_SIZEOF_OFFSET], [F08_C_OFFSET]) + PAC_PROG_FC_C_INT_TYPE([$MPI_SIZEOF_COUNT], [F08_C_COUNT]) + AC_SUBST(F08_C_AINT) + AC_SUBST(F08_C_COUNT) + AC_SUBST(F08_C_OFFSET) +fi + +AC_LANG_PUSH([Fortran]) +AC_CACHE_CHECK([if real*8 is supported in Fortran 90], + [pac_cv_fort90_real8],[ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([],[ real*8 a]) + ],[ + pac_cv_fort90_real8=yes + ],[ + pac_cv_fort90_real8=no + ]) +]) +AC_LANG_POP([Fortran]) +WTIME_DOUBLE_TYPE="DOUBLE PRECISION" +if test "$pac_cv_fort90_real8" = "yes" ; then + WTIME_DOUBLE_TYPE="REAL*8" +fi +# WTIME_DOUBLE_TYPE is substituted into mpi_base.f90 +AC_SUBST(WTIME_DOUBLE_TYPE) + +# Make sure that address kind and offset kind have values. +if test -z "$ADDRESS_KIND" ; then + ADDRESS_KIND=0 +fi +if test -z "$OFFSET_KIND" ; then + OFFSET_KIND=0 +fi +# Note, however, that zero value are (in all practical case) invalid +# for Fortran 90, and indicate a failure. Test and fail if Fortran 90 +# enabled. +if test "$enable_f90" = "yes" ; then + if test "$ADDRESS_KIND" -le 0 -o "$OFFSET_KIND" -le 0 ; then + AC_MSG_ERROR([Unable to determine Fortran 90 integer kinds for MPI types. If you do not need Fortran 90, add --disable-fc to the configure options.]) + fi +fi +AC_SUBST(ADDRESS_KIND) +AC_SUBST(OFFSET_KIND) +AC_SUBST(INTEGER_KIND) +AC_SUBST(COUNT_KIND) + +# Some compilers may require special directives to handle the common +# block in a library. In particular, directives are needed for Microsoft +# Windows to support dynamic library import. The following six +# directives may be needed: +# CMS\$ATTRIBUTES DLLIMPORT::/MPIPRIV1/ +# CMS\$ATTRIBUTES DLLIMPORT::/MPIPRIV2/ +# CMS\$ATTRIBUTES DLLIMPORT::/MPIPRIVC/ +# CDEC\$ATTRIBUTES DLLIMPORT::/MPIPRIV1/ +# CDEC\$ATTRIBUTES DLLIMPORT::/MPIPRIV2/ +# CDEC\$ATTRIBUTES DLLIMPORT::/MPIPRIVC/ +# CMS is for the Microsoft compiler, +# CDEC is (we believe) for the DEC Fortran compiler. +# We need to make this a configure-time variable because some compilers +# (in particular, a version of the Intel Fortran compiler for Linux) +# will read directives for other compilers and then flag as fatal +# errors directives that it does not support but does recognize. + +# TODO: add check, and if needed, add to cmd_f77 the option "-DLLIMPORT type" + + +# Set defaults for these values so that the Makefile in src/bindings/f90 +# is valid even if fc is not enabled (this is necessary for the +# distclean target) +MPIMODNAME=mpi +MPICONSTMODNAME=mpi_constants +MPISIZEOFMODNAME=mpi_sizeofs +MPIBASEMODNAME=mpi_base +PMPIBASEMODNAME=pmpi_base + +# F08 binding stuff +MPI_F08_LINK_CONSTANTS_NAME=mpi_f08_link_constants +PMPI_F08_NAME=pmpi_f08 +MPI_F08_CALLBACKS_NAME=mpi_f08_callbacks +MPI_C_INTERFACE_NAME=mpi_c_interface +MPI_C_INTERFACE_GLUE_NAME=mpi_c_interface_glue +MPI_F08_TYPES_NAME=mpi_f08_types +MPI_C_INTERFACE_NOBUF_NAME=mpi_c_interface_nobuf +MPI_F08_COMPILE_CONSTANTS_NAME=mpi_f08_compile_constants +MPI_F08_NAME=mpi_f08 +MPI_C_INTERFACE_TYPES_NAME=mpi_c_interface_types +MPI_C_INTERFACE_CDESC_NAME=mpi_c_interface_cdesc + +# Find the extension that this compiler uses for modules. +# Sets FCMODEXT (and adds it to the list substed) +# Sets FCMODINCFLAG (and adds it to the list substed) +PAC_FC_MODULE +AC_SUBST(FCMODINCSPEC) +if test -z "$FCMODOUTFLAG" ; then + AC_MSG_ERROR([FCMODOUTFLAG could not be determined but is critical for the current Fortran build system]) +fi + +if test "$pac_cv_fc_module_case" = "upper" ; then + MPIMODNAME=MPI + MPICONSTMODNAME=MPI_CONSTANTS + MPISIZEOFMODNAME=MPI_SIZEOFS + MPIBASEMODNAME=MPI_BASE + PMPIBASEMODNAME=PMPI_BASE + MPI_F08_NAME=MPI_F08 + MPI_F08_LINK_CONSTANTS_NAME=MPI_F08_LINK_CONSTANTS + MPI_F08_CALLBACKS_NAME=MPI_F08_CALLBACKS + MPI_F08_TYPES_NAME=MPI_F08_TYPES + MPI_F08_COMPILE_CONSTANTS_NAME=MPI_F08_COMPILE_CONSTANTS + PMPI_F08_NAME=PMPI_F08 + MPI_C_INTERFACE_NAME=MPI_C_INTERFACE + MPI_C_INTERFACE_NOBUF_NAME=MPI_C_INTERFACE_NOBUF + MPI_C_INTERFACE_GLUE_NAME=MPI_C_INTERFACE_GLUE + MPI_C_INTERFACE_TYPES_NAME=MPI_C_INTERFACE_TYPES + MPI_C_INTERFACE_CDESC_NAME=MPI_C_INTERFACE_CDESC +else + MPIMODNAME=mpi + MPICONSTMODNAME=mpi_constants + MPISIZEOFMODNAME=mpi_sizeofs + MPIBASEMODNAME=mpi_base + PMPIBASEMODNAME=pmpi_base + MPI_F08_NAME=mpi_f08 + MPI_F08_LINK_CONSTANTS_NAME=mpi_f08_link_constants + MPI_F08_CALLBACKS_NAME=mpi_f08_callbacks + MPI_F08_TYPES_NAME=mpi_f08_types + MPI_F08_COMPILE_CONSTANTS_NAME=mpi_f08_compile_constants + PMPI_F08_NAME=pmpi_f08 + MPI_C_INTERFACE_NAME=mpi_c_interface + MPI_C_INTERFACE_NOBUF_NAME=mpi_c_interface_nobuf + MPI_C_INTERFACE_GLUE_NAME=mpi_c_interface_glue + MPI_C_INTERFACE_TYPES_NAME=mpi_c_interface_types + MPI_C_INTERFACE_CDESC_NAME=mpi_c_interface_cdesc +fi +AC_SUBST(MPIMODNAME) +AC_SUBST(MPICONSTMODNAME) +AC_SUBST(MPISIZEOFMODNAME) +AC_SUBST(MPIBASEMODNAME) +AC_SUBST(PMPIBASEMODNAME) + +AC_SUBST(MPI_F08_NAME) +AC_SUBST(MPI_F08_LINK_CONSTANTS_NAME) +AC_SUBST(MPI_F08_CALLBACKS_NAME) +AC_SUBST(MPI_F08_TYPES_NAME) +AC_SUBST(MPI_F08_COMPILE_CONSTANTS_NAME) +AC_SUBST(PMPI_F08_NAME) +AC_SUBST(MPI_C_INTERFACE_NAME) +AC_SUBST(MPI_C_INTERFACE_NOBUF_NAME) +AC_SUBST(MPI_C_INTERFACE_GLUE_NAME) +AC_SUBST(MPI_C_INTERFACE_TYPES_NAME) +AC_SUBST(MPI_C_INTERFACE_CDESC_NAME) + +# Assume that all Fortran 90 compilers accept -I for include directories +FCINC=-I +AC_SUBST(FCINC) +FCINCFLAG=-I +AC_SUBST(FCINCFLAG) + +# Check if $MPI_DEFAULT_FCOPTS is valid with $F90 +if test -n "$MPI_DEFAULT_FCOPTS" ; then + if test "$enable_check_compiler_flags" = "yes" ; then + PAC_FC_CHECK_COMPILER_OPTION( [$MPI_DEFAULT_FCOPTS], [ + FCFLAGS="$FCFLAGS $MPI_DEFAULT_FCOPTS" + ] ) + else + FCFLAGS="$FCFLAGS $MPI_DEFAULT_FCOPTS" + fi +fi + +# Most systems allow the Fortran compiler to process .F and .F90 files +# using the C preprocessor. However, some systems either do not +# allow this or have serious bugs (OSF Fortran compilers have a bug +# that generates an error message from cpp). The following test +# checks to see if .F works, and if not, whether "cpp -P -C" can be used +PAC_FC_WORKS_WITH_CPP([FCCPP]) +AC_SUBST(FCCPP) + +# Check whether additional libraries are needed when linking with C +PAC_PROG_FC_AND_C_STDIO_LIBS +AC_SUBST(FC_OTHER_LIBS) + +if test "X$modincdir" = "X" ; then + modincdir=$includedir +fi +export modincdir +AC_SUBST(modincdir) + +# Python 3 is needed to generate Fortran bindings +PAC_CHECK_PYTHON + +# we can optionally skip python generation if the bindings are pre-generated +skip_gen_bindings=no +if test -z "$PYTHON" ; then + skip_gen_bindings=yes + if test "$enable_f77" = "yes" && ! test -f mpif_h/mpif.h.in ; then + skip_gen_bindings=no + fi + if test "$enable_f90" = "yes" && ! test -f use_mpi/mpi_base.f90 ; then + skip_gen_bindings=no + fi + if test "$enable_f08" = "yes" && ! test -f use_mpi_f08/mpi_f08.f90 ; then + skip_gen_bindings=no + fi + if test "$skip_gen_bindings" = "yes" ; then + AC_MSG_NOTICE([Use pre-generated Fortran mpi binding. To prevent issues, install Python 3 and re-run configure.]) + else + AC_MSG_ERROR([Python 3 is required to generate F90 bindings but not found!]) + fi +fi + + +if test "$skip_gen_bindings" = no ; then + # locate the python scripts + if test -e "$main_top_srcdir/maint/gen_binding_f77.py" ; then + # when build FROM_MPICH, we don't require local copy of maint folder + maintdir="$main_top_srcdir/maint" + elif test -e "../../../maint/gen_binding_f77.py" ; then + maintdir="../../../maint" + elif test -e "maint/gen_binding_f77.py" ; then + maintdir="maint" + else + AC_MSG_ERROR([Can't find gen_binding_f77.py]) + fi + + if test "$enable_f77" = "yes" ; then + cmd_f77="$PYTHON $maintdir/gen_binding_f77.py" + if test -n "$mpi_h" ; then + cmd_f77="$cmd_f77 -mpi-h=$mpi_h" + fi + cmd_f77="$cmd_f77 -integer-kind=$INTEGER_KIND -address-kind=$ADDRESS_KIND -count-kind=$COUNT_KIND -offset-kind=$OFFSET_KIND" + # if mpi_h is mpi_mpich.in, pass in those autoconf macro values + if test -n "$MPI_MAX_PROCESSOR_NAME" ; then + cmd_f77="$cmd_f77 -max-processor-name=$MPI_MAX_PROCESSOR_NAME -max-version-string=$MPI_MAX_LIBRARY_VERSION_STRING -max-error-string=$MPI_MAX_ERROR_STRING -bsend-overhead=$BSEND_OVERHEAD" + fi + AC_CONFIG_COMMANDS([gen_binding_f77], [$cmd_gen_binding_f77], [cmd_gen_binding_f77="$cmd_f77"]) + fi + + if test "$enable_f90" = "yes" ; then + PAC_FC_CHECK_IGNORE_TKR + PAC_FC_ISO_C_BINDING + cmd_f90="$PYTHON $maintdir/gen_binding_f90.py" +# pass in type sizes for MPI_SIZEOF + cmd_f90="$cmd_f90 -f-logical-size=$pac_cv_f77_sizeof_logical" + if test "$pac_fc_ignore_tkr" != "no" ; then + cmd_f90="$cmd_f90 -ignore-tkr=$pac_fc_ignore_tkr" + fi + if test "$pac_fc_iso_c_binding" = "no" ; then + cmd_f90="$cmd_f90 -iso-c-binding=no" + fi + AC_CONFIG_COMMANDS([gen_binding_f90], [$cmd_gen_binding_f90], [cmd_gen_binding_f90="$cmd_f90"]) + fi + + if test "$enable_f08" = "yes" ; then + PAC_FC_CHECK_REAL128 + PAC_FC_CHECK_IGNORE_TKR_D + cmd_f08="$PYTHON $maintdir/gen_binding_f08.py" + if test -n "$mpi_h" ; then + cmd_f08="$cmd_f08 -mpi-h=$mpi_h" + fi + if test "$pac_fc_has_real128" = "no" ; then + cmd_f08="$cmd_f08 -no-real128" + fi + if test "$pac_fc_ignore_tkr_d" != "no" ; then + cmd_f08="$cmd_f08 -ignore-tkr-d=$pac_fc_ignore_tkr_d" + fi + if test "$enable_romio" = "no" ; then + cmd_f08="$cmd_f08 -no-mpiio" + fi + cmd_f08="$cmd_f08 -fint-size=$pac_cv_f77_sizeof_integer -aint-size=$MPI_SIZEOF_AINT -count-size=$MPI_SIZEOF_COUNT -cint-size=$ac_cv_sizeof_int" + AC_CONFIG_COMMANDS([gen_binding_f08], [$cmd_gen_binding_f08], [cmd_gen_binding_f08="$cmd_f08"]) + fi +fi + +AC_CONFIG_FILES([Makefile \ + localdefs]) + +if test "$enable_f77" = "yes" ; then + AC_CONFIG_FILES([mpif_h/setbotf.f \ + mpif_h/cmblk.c]) +fi +if test "$enable_f08" = "yes" ; then + AC_CONFIG_FILES([use_mpi_f08/mpi_c_interface_types.f90]) +fi +AC_OUTPUT diff --git a/src/binding/fortran/localdefs.in b/src/binding/fortran/localdefs.in new file mode 100644 index 00000000000..8b93eacd9ef --- /dev/null +++ b/src/binding/fortran/localdefs.in @@ -0,0 +1,6 @@ +## +## Copyright (C) by Argonne National Laboratory +## See COPYRIGHT in top-level directory +## + +FORTRAN_BINDINGS="@fortran_bindings@" diff --git a/src/binding/fortran/mpif_h/Makefile.mk b/src/binding/fortran/mpif_h/Makefile.mk index c8bda784834..1dc0eb8fb07 100644 --- a/src/binding/fortran/mpif_h/Makefile.mk +++ b/src/binding/fortran/mpif_h/Makefile.mk @@ -3,7 +3,7 @@ ## See COPYRIGHT in top-level directory ## -f77_cppflags = $(AM_CPPFLAGS) -I${main_top_srcdir}/src/binding/fortran/mpif_h +f77_cppflags = $(AM_CPPFLAGS) -I${srcdir}/mpif_h if BUILD_F77_BINDING @@ -11,12 +11,12 @@ mpifort_convenience_libs += lib/libf77_mpi.la noinst_LTLIBRARIES += lib/libf77_mpi.la lib_libf77_mpi_la_SOURCES = \ - src/binding/fortran/mpif_h/fortran_binding.c \ - src/binding/fortran/mpif_h/user_proxy.c \ - src/binding/fortran/mpif_h/fdebug.c \ - src/binding/fortran/mpif_h/setbot.c \ - src/binding/fortran/mpif_h/cmblk.c \ - src/binding/fortran/mpif_h/setbotf.f + mpif_h/fortran_binding.c \ + mpif_h/user_proxy.c \ + mpif_h/fdebug.c \ + mpif_h/setbot.c \ + mpif_h/cmblk.c \ + mpif_h/setbotf.f lib_libf77_mpi_la_CPPFLAGS = $(f77_cppflags) @@ -24,7 +24,7 @@ if BUILD_LIBF77_PMPI mpifort_convenience_libs += lib/libf77_pmpi.la noinst_LTLIBRARIES += lib/libf77_pmpi.la -lib_libf77_pmpi_la_SOURCES = src/binding/fortran/mpif_h/fortran_binding.c +lib_libf77_pmpi_la_SOURCES = mpif_h/fortran_binding.c # build "pmpi_xxx_" f77 public functions lib_libf77_pmpi_la_CPPFLAGS = $(f77_cppflags) -DF77_USE_PMPI @@ -34,15 +34,11 @@ lib_libf77_mpi_la_CPPFLAGS += -DMPICH_MPI_FROM_PMPI -DUSE_ONLY_MPI_NAMES endif BUILD_LIBF77_PMPI noinst_HEADERS += \ - src/binding/fortran/mpif_h/fortran_profile.h \ - src/binding/fortran/mpif_h/mpi_fortimpl.h - -# config.status copies src/binding/fortran/mpif_h/mpif.h to src/include (see the relevant -# AC_CONFIG_COMMANDS in configure.ac), so we need to delete it at distclean time -# too. More work is needed in this Makefile.mk to keep src/include/mpif.h up to -# date w.r.t. the src/binding/fortran/mpif_h version. -DISTCLEANFILES += src/binding/fortran/mpif_h/mpif.h src/include/mpif.h -nodist_include_HEADERS += src/binding/fortran/mpif_h/mpif.h + mpif_h/fortran_profile.h \ + mpif_h/mpi_fortimpl.h + +DISTCLEANFILES += mpif_h/mpif.h +nodist_include_HEADERS += mpif_h/mpif.h endif BUILD_F77_BINDING diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index fc1b59d7aad..64fcc8295a0 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -6,7 +6,7 @@ #ifndef MPI_FORTIMPL_H_INCLUDED #define MPI_FORTIMPL_H_INCLUDED -#include "mpichconf.h" +#include "mpifort_config.h" #include "mpi.h" #include /* for ssize_t */ #include @@ -52,6 +52,18 @@ #define FORT_END_LEN(a) , FORT_SIZE_INT a #endif +/* configure defines F77_TRUE_VALUE and F77_FALSE_VALUE */ +#define MPII_TO_FLOG(a) ((a) ? F77_TRUE_VALUE : F77_FALSE_VALUE) +#define MPII_FROM_FLOG(a) ((a) == F77_FALSE_VALUE ? 0 : 1) + +/* define internal MPI usage to PMPI */ +#define MPI_Abi_get_fortran_info PMPI_Abi_get_fortran_info +#define MPI_Abi_set_fortran_info PMPI_Abi_set_fortran_info +#define MPI_Abi_set_fortran_boolean PMPI_Abi_set_fortran_boolean +#define MPI_Info_create PMPI_Info_create +#define MPI_Info_set PMPI_Info_set +#define MPI_Info_free PMPI_Info_free + /* NOTE: both leading and trailing spaces are not counted */ static inline int get_fort_str_len(char *s, int len) { @@ -274,13 +286,6 @@ typedef MPI_Aint MPI_FAint; /* Define the internal values needed for Fortran support */ -/* Fortran logicals */ -/* The definitions for the Fortran logical values are also needed - by the reduction operations in mpi/coll/opland, oplor, and oplxor, - so they are defined in src/include/mpii_fortlogical.h */ -#include "mpii_fortlogical.h" - - /* MPIR_F_MPI_BOTTOM is the address of the Fortran MPI_BOTTOM value */ extern FORT_DLL_SPEC int MPIR_F_NeedInit; extern FORT_DLL_SPEC void *MPIR_F_MPI_BOTTOM; diff --git a/src/binding/fortran/mpif_h/setbot.c b/src/binding/fortran/mpif_h/setbot.c index 750abc6625d..a6be14db5f1 100644 --- a/src/binding/fortran/mpif_h/setbot.c +++ b/src/binding/fortran/mpif_h/setbot.c @@ -4,6 +4,7 @@ */ #include "mpi_fortimpl.h" +#include #ifdef F77_NAME_UPPER @@ -44,6 +45,13 @@ void *MPI_F_ARGV_NULL = 0; void *MPI_F_ARGVS_NULL = 0; void *MPIR_F_MPI_WEIGHTS_EMPTY = 0; +static void info_set_int(MPI_Info info, const char *key, int val) +{ + char str[20]; + snprintf(str, 20, "%d", val); + MPI_Info_set(info, key, str); +} + FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, void *bt, void *ip, void *c_ba, void *uw, void *ecsi, @@ -83,11 +91,11 @@ void MPIX_Init_fortran(void) if (info == MPI_INFO_NULL) { /* MPI_Abi_set_fortran_info */ MPI_Info_create(&info); - MPI_Info_set(info, "mpi_character_size", MPI_CHARACTER_SIZE); - MPI_Info_set(info, "mpi_logical_size", MPI_LOGICAL_SIZE); - MPI_Info_set(info, "mpi_integer_size", MPI_INTEGER_SIZE); - MPI_Info_set(info, "mpi_real_size", MPI_REAL_SIZE); - MPI_Info_set(info, "mpi_double_precision_size", MPI_DOUBLE_PRECISION_SIZE); + info_set_int(info, "mpi_character_size", MPI_CHARACTER_SIZE); + info_set_int(info, "mpi_logical_size", MPI_LOGICAL_SIZE); + info_set_int(info, "mpi_integer_size", MPI_INTEGER_SIZE); + info_set_int(info, "mpi_real_size", MPI_REAL_SIZE); + info_set_int(info, "mpi_double_precision_size", MPI_DOUBLE_PRECISION_SIZE); #ifdef MPI_LOGICAL1_SUPPORTED MPI_Info_set(info, "mpi_logical1_supported", "true"); #endif @@ -151,7 +159,23 @@ void MPIX_Init_fortran(void) MPI_Info_free(&info); /* MPI_Abi_set_fortran_boolean */ - mpi_errno = MPI_Abi_set_fortran_boolean(MPI_LOGICAL_SIZE, F77_TRUE_VALUE, F77_FALSE_VALUE); +#if MPI_LOGICAL_SIZE == 1 + int8_t true_val = F77_TRUE_VALUE; + int8_t false_val = F77_FALSE_VALUE; +#elif MPI_LOGICAL_SIZE == 2 + int16_t true_val = F77_TRUE_VALUE; + int16_t false_val = F77_FALSE_VALUE; +#elif MPI_LOGICAL_SIZE == 4 + int32_t true_val = F77_TRUE_VALUE; + int32_t false_val = F77_FALSE_VALUE; +#elif MPI_LOGICAL_SIZE == 8 + int64_t true_val = F77_TRUE_VALUE; + int64_t false_val = F77_FALSE_VALUE; +#else +#error Configure did not define a good MPI_LOGICAL_SIZE! +#endif + mpi_errno = + MPI_Abi_set_fortran_booleans(MPI_LOGICAL_SIZE, (void *) &true_val, (void *) &false_val); assert(mpi_errno == MPI_SUCCESS); } } diff --git a/src/binding/fortran/mpif_h/user_proxy.c b/src/binding/fortran/mpif_h/user_proxy.c index 7c5274d92dd..0c6834f9a0e 100644 --- a/src/binding/fortran/mpif_h/user_proxy.c +++ b/src/binding/fortran/mpif_h/user_proxy.c @@ -7,7 +7,12 @@ #include #include +#ifdef HAS_LIB_MPL #include "mpl.h" +#else +#define MPL_malloc(size, class) malloc(size) +#define MPL_free(p) free(p) +#endif /* ---- attr -----*/ struct F77_attr_state { diff --git a/src/binding/fortran/use_mpi/Makefile.mk b/src/binding/fortran/use_mpi/Makefile.mk index d0284960f56..df954b28e88 100644 --- a/src/binding/fortran/use_mpi/Makefile.mk +++ b/src/binding/fortran/use_mpi/Makefile.mk @@ -21,25 +21,25 @@ if BUILD_FC_BINDING # We need to tell some compilers (e.g., Solaris f90) to look for modules in the # current directory when the source file is not in the working directory (i.e., # in a VPATH build) -AM_FCFLAGS += @FCINCFLAG@src/binding/fortran/use_mpi +AM_FCFLAGS += @FCINCFLAG@use_mpi -AM_CPPFLAGS += -Isrc/binding/fortran/use_mpi +AM_CPPFLAGS += -Iuse_mpi noinst_HEADERS += \ - src/binding/fortran/use_mpi/mpifnoext.h + use_mpi/mpifnoext.h # cause any .$(MOD) files to be output in the f90 bindings directory instead of # the current directory -FC_COMPILE_MODS += $(FCMODOUTFLAG)src/binding/fortran/use_mpi +FC_COMPILE_MODS += $(FCMODOUTFLAG)use_mpi mpifort_convenience_libs += lib/libf90_mpi.la noinst_LTLIBRARIES += lib/libf90_mpi.la lib_libf90_mpi_la_SOURCES = \ - src/binding/fortran/use_mpi/mpi.f90 \ - src/binding/fortran/use_mpi/mpi_constants.f90 \ - src/binding/fortran/use_mpi/mpi_sizeofs.f90 \ - src/binding/fortran/use_mpi/mpi_base.f90 \ - src/binding/fortran/use_mpi/pmpi_base.f90 + use_mpi/mpi.f90 \ + use_mpi/mpi_constants.f90 \ + use_mpi/mpi_sizeofs.f90 \ + use_mpi/mpi_base.f90 \ + use_mpi/pmpi_base.f90 # FIXME: We may want to edit the mpif.h to convert Fortran77-specific # items (such as an integer*8 used for file offsets) into the @@ -49,202 +49,202 @@ lib_libf90_mpi_la_SOURCES = \ # We need the MPI constants in a separate module for some of the # interface definitions (the ones that need MPI_ADDRESS_KIND or # MPI_OFFSET_KIND) -src/binding/fortran/use_mpi/mpi.$(MOD)-stamp: src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) src/binding/fortran/use_mpi/$(MPISIZEOFMOD).$(MOD) src/binding/fortran/use_mpi/$(MPIBASEMOD).$(MOD) src/binding/fortran/use_mpi/$(PMPIBASEMOD).$(MOD) $(srcdir)/src/binding/fortran/use_mpi/mpi.f90 src/binding/fortran/use_mpi/mpifnoext.h - @rm -f src/binding/fortran/use_mpi/mpi-tmp - @touch src/binding/fortran/use_mpi/mpi-tmp - @( cd src/binding/fortran/use_mpi && \ +use_mpi/mpi.$(MOD)-stamp: use_mpi/$(MPICONSTMOD).$(MOD) use_mpi/$(MPISIZEOFMOD).$(MOD) use_mpi/$(MPIBASEMOD).$(MOD) use_mpi/$(PMPIBASEMOD).$(MOD) $(srcdir)/use_mpi/mpi.f90 use_mpi/mpifnoext.h + @rm -f use_mpi/mpi-tmp + @touch use_mpi/mpi-tmp + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] || [ ! -f mpi.$(FCEXT) ] ; then \ rm -f mpi.$(FCEXT) ; \ - $(LN_S) $(abs_top_srcdir)/src/binding/fortran/use_mpi/mpi.f90 mpi.$(FCEXT) ; \ + $(LN_S) $(abs_srcdir)/use_mpi/mpi.f90 mpi.$(FCEXT) ; \ fi ) - $(mod_verbose)$(FC_COMPILE_MODS) -c src/binding/fortran/use_mpi/mpi.$(FCEXT) -o src/binding/fortran/use_mpi/mpi.lo - @( cd src/binding/fortran/use_mpi && \ + $(mod_verbose)$(FC_COMPILE_MODS) -c use_mpi/mpi.$(FCEXT) -o use_mpi/mpi.lo + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] || [ ! -f mpi.$(FCEXT) ] ; then \ rm -f mpi.$(FCEXT) ; \ fi ) - @mv src/binding/fortran/use_mpi/mpi-tmp src/binding/fortran/use_mpi/mpi.$(MOD)-stamp + @mv use_mpi/mpi-tmp use_mpi/mpi.$(MOD)-stamp -src/binding/fortran/use_mpi/mpi.lo src/binding/fortran/use_mpi/$(MPIMOD).$(MOD): src/binding/fortran/use_mpi/mpi.$(MOD)-stamp +use_mpi/mpi.lo use_mpi/$(MPIMOD).$(MOD): use_mpi/mpi.$(MOD)-stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi/mpi-lock src/binding/fortran/use_mpi/mpi.$(MOD)-stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi/mpi-lock 2>/dev/null; then \ + trap 'rm -rf use_mpi/mpi-lock use_mpi/mpi.$(MOD)-stamp' 1 2 13 15; \ + if mkdir use_mpi/mpi-lock 2>/dev/null; then \ ## This code is being executed by the first process. - rm -f src/binding/fortran/use_mpi/mpi.$(MOD)-stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi/mpi.$(MOD)-stamp; \ - rmdir src/binding/fortran/use_mpi/mpi-lock; \ + rm -f use_mpi/mpi.$(MOD)-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi/mpi.$(MOD)-stamp; \ + rmdir use_mpi/mpi-lock; \ else \ ## This code is being executed by the follower processes. ## Wait until the first process is done. - while test -d src/binding/fortran/use_mpi/mpi-lock; do sleep 1; done; \ + while test -d use_mpi/mpi-lock; do sleep 1; done; \ ## Succeed if and only if the first process succeeded. - test -f src/binding/fortran/use_mpi/mpi.$(MOD)-stamp; exit $$?; \ + test -f use_mpi/mpi.$(MOD)-stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi/mpi.$(MOD)-stamp src/binding/fortran/use_mpi/$(MPIMOD).$(MOD) src/binding/fortran/use_mpi/mpi.lo src/binding/fortran/use_mpi/mpi-tmp +CLEANFILES += use_mpi/mpi.$(MOD)-stamp use_mpi/$(MPIMOD).$(MOD) use_mpi/mpi.lo use_mpi/mpi-tmp -src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp: src/binding/fortran/use_mpi/mpi_constants.f90 src/binding/fortran/use_mpi/mpifnoext.h - @rm -f src/binding/fortran/use_mpi/mpi_constants-tmp - @touch src/binding/fortran/use_mpi/mpi_constants-tmp - @( cd src/binding/fortran/use_mpi && \ +use_mpi/mpi_constants.$(MOD)-stamp: use_mpi/mpi_constants.f90 use_mpi/mpifnoext.h + @rm -f use_mpi/mpi_constants-tmp + @touch use_mpi/mpi_constants-tmp + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] || [ ! -f mpi_constants.$(FCEXT) ] ; then \ rm -f mpi_constants.$(FCEXT) ; \ - $(LN_S) $(abs_top_srcdir)/src/binding/fortran/use_mpi/mpi_constants.f90 mpi_constants.$(FCEXT) ; \ + $(LN_S) $(abs_srcdir)/use_mpi/mpi_constants.f90 mpi_constants.$(FCEXT) ; \ fi ) - $(mod_verbose)$(FC_COMPILE_MODS) -c src/binding/fortran/use_mpi/mpi_constants.$(FCEXT) -o src/binding/fortran/use_mpi/mpi_constants.lo - @( cd src/binding/fortran/use_mpi && \ + $(mod_verbose)$(FC_COMPILE_MODS) -c use_mpi/mpi_constants.$(FCEXT) -o use_mpi/mpi_constants.lo + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] || [ ! -f mpi_constants.$(FCEXT) ] ; then \ rm -f mpi_constants.$(FCEXT) ; \ fi ) - @mv src/binding/fortran/use_mpi/mpi_constants-tmp src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp + @mv use_mpi/mpi_constants-tmp use_mpi/mpi_constants.$(MOD)-stamp -src/binding/fortran/use_mpi/mpi_constants.lo src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD): src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp +use_mpi/mpi_constants.lo use_mpi/$(MPICONSTMOD).$(MOD): use_mpi/mpi_constants.$(MOD)-stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi/mpi_constants-lock src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi/mpi_constants-lock 2>/dev/null; then \ + trap 'rm -rf use_mpi/mpi_constants-lock use_mpi/mpi_constants.$(MOD)-stamp' 1 2 13 15; \ + if mkdir use_mpi/mpi_constants-lock 2>/dev/null; then \ ## This code is being executed by the first process. - rm -f src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp; \ - rmdir src/binding/fortran/use_mpi/mpi_constants-lock; \ + rm -f use_mpi/mpi_constants.$(MOD)-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi/mpi_constants.$(MOD)-stamp; \ + rmdir use_mpi/mpi_constants-lock; \ else \ ## This code is being executed by the follower processes. ## Wait until the first process is done. - while test -d src/binding/fortran/use_mpi/mpi_constants-lock; do sleep 1; done; \ + while test -d use_mpi/mpi_constants-lock; do sleep 1; done; \ ## Succeed if and only if the first process succeeded. - test -f src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp; exit $$?; \ + test -f use_mpi/mpi_constants.$(MOD)-stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi/mpi_constants.$(MOD)-stamp src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) src/binding/fortran/use_mpi/mpi_constants.lo src/binding/fortran/use_mpi/mpi_constants-tmp +CLEANFILES += use_mpi/mpi_constants.$(MOD)-stamp use_mpi/$(MPICONSTMOD).$(MOD) use_mpi/mpi_constants.lo use_mpi/mpi_constants-tmp -src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp: src/binding/fortran/use_mpi/mpi_sizeofs.f90 src/binding/fortran/use_mpi/mpifnoext.h - @rm -f src/binding/fortran/use_mpi/mpi_sizeofs-tmp - @touch src/binding/fortran/use_mpi/mpi_sizeofs-tmp - @( cd src/binding/fortran/use_mpi && \ +use_mpi/mpi_sizeofs.$(MOD)-stamp: use_mpi/mpi_sizeofs.f90 use_mpi/mpifnoext.h + @rm -f use_mpi/mpi_sizeofs-tmp + @touch use_mpi/mpi_sizeofs-tmp + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] ; then \ rm -f mpi_sizeofs.$(FCEXT) ; \ $(LN_S) mpi_sizeofs.f90 mpi_sizeofs.$(FCEXT) ; \ fi ) - $(mod_verbose)$(FC_COMPILE_MODS) -c src/binding/fortran/use_mpi/mpi_sizeofs.$(FCEXT) -o src/binding/fortran/use_mpi/mpi_sizeofs.lo - @( cd src/binding/fortran/use_mpi && \ + $(mod_verbose)$(FC_COMPILE_MODS) -c use_mpi/mpi_sizeofs.$(FCEXT) -o use_mpi/mpi_sizeofs.lo + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] ; then \ rm -f mpi_sizeofs.$(FCEXT) ; \ fi ) - @mv src/binding/fortran/use_mpi/mpi_sizeofs-tmp src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp + @mv use_mpi/mpi_sizeofs-tmp use_mpi/mpi_sizeofs.$(MOD)-stamp -src/binding/fortran/use_mpi/mpi_sizeofs.lo src/binding/fortran/use_mpi/$(MPISIZEOFMOD).$(MOD): src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp +use_mpi/mpi_sizeofs.lo use_mpi/$(MPISIZEOFMOD).$(MOD): use_mpi/mpi_sizeofs.$(MOD)-stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi/mpi_sizeofs-lock src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi/mpi_sizeofs-lock 2>/dev/null; then \ + trap 'rm -rf use_mpi/mpi_sizeofs-lock use_mpi/mpi_sizeofs.$(MOD)-stamp' 1 2 13 15; \ + if mkdir use_mpi/mpi_sizeofs-lock 2>/dev/null; then \ ## This code is being executed by the first process. - rm -f src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp; \ - rmdir src/binding/fortran/use_mpi/mpi_sizeofs-lock; \ + rm -f use_mpi/mpi_sizeofs.$(MOD)-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi/mpi_sizeofs.$(MOD)-stamp; \ + rmdir use_mpi/mpi_sizeofs-lock; \ else \ ## This code is being executed by the follower processes. ## Wait until the first process is done. - while test -d src/binding/fortran/use_mpi/mpi_sizeofs-lock; do sleep 1; done; \ + while test -d use_mpi/mpi_sizeofs-lock; do sleep 1; done; \ ## Succeed if and only if the first process succeeded. - test -f src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp; exit $$?; \ + test -f use_mpi/mpi_sizeofs.$(MOD)-stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi/mpi_sizeofs.$(MOD)-stamp src/binding/fortran/use_mpi/$(MPISIZEOFMOD).$(MOD) src/binding/fortran/use_mpi/mpi_sizeofs.lo src/binding/fortran/use_mpi/mpi_sizeofs-tmp +CLEANFILES += use_mpi/mpi_sizeofs.$(MOD)-stamp use_mpi/$(MPISIZEOFMOD).$(MOD) use_mpi/mpi_sizeofs.lo use_mpi/mpi_sizeofs-tmp -src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp: src/binding/fortran/use_mpi/mpi_base.f90 src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) - @rm -f src/binding/fortran/use_mpi/mpi_base-tmp - @touch src/binding/fortran/use_mpi/mpi_base-tmp - @( cd src/binding/fortran/use_mpi && \ +use_mpi/mpi_base.$(MOD)-stamp: use_mpi/mpi_base.f90 use_mpi/$(MPICONSTMOD).$(MOD) + @rm -f use_mpi/mpi_base-tmp + @touch use_mpi/mpi_base-tmp + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] ; then \ rm -f mpi_base.$(FCEXT) ; \ $(LN_S) mpi_base.f90 mpi_base.$(FCEXT) ; \ fi ) - $(mod_verbose)$(FC_COMPILE_MODS) -c src/binding/fortran/use_mpi/mpi_base.$(FCEXT) -o src/binding/fortran/use_mpi/mpi_base.lo - @( cd src/binding/fortran/use_mpi && \ + $(mod_verbose)$(FC_COMPILE_MODS) -c use_mpi/mpi_base.$(FCEXT) -o use_mpi/mpi_base.lo + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] ; then \ rm -f mpi_base.$(FCEXT) ; \ fi ) - @mv src/binding/fortran/use_mpi/mpi_base-tmp src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp + @mv use_mpi/mpi_base-tmp use_mpi/mpi_base.$(MOD)-stamp -src/binding/fortran/use_mpi/mpi_base.lo src/binding/fortran/use_mpi/$(MPIBASEMOD).$(MOD): src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp +use_mpi/mpi_base.lo use_mpi/$(MPIBASEMOD).$(MOD): use_mpi/mpi_base.$(MOD)-stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi/mpi_base-lock src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi/mpi_base-lock 2>/dev/null; then \ + trap 'rm -rf use_mpi/mpi_base-lock use_mpi/mpi_base.$(MOD)-stamp' 1 2 13 15; \ + if mkdir use_mpi/mpi_base-lock 2>/dev/null; then \ ## This code is being executed by the first process. - rm -f src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp; \ - rmdir src/binding/fortran/use_mpi/mpi_base-lock; \ + rm -f use_mpi/mpi_base.$(MOD)-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi/mpi_base.$(MOD)-stamp; \ + rmdir use_mpi/mpi_base-lock; \ else \ ## This code is being executed by the follower processes. ## Wait until the first process is done. - while test -d src/binding/fortran/use_mpi/mpi_base-lock; do sleep 1; done; \ + while test -d use_mpi/mpi_base-lock; do sleep 1; done; \ ## Succeed if and only if the first process succeeded. - test -f src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp; exit $$?; \ + test -f use_mpi/mpi_base.$(MOD)-stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi/mpi_base.$(MOD)-stamp src/binding/fortran/use_mpi/$(MPIBASEMOD).$(MOD) src/binding/fortran/use_mpi/mpi_base.lo src/binding/fortran/use_mpi/mpi_base-tmp +CLEANFILES += use_mpi/mpi_base.$(MOD)-stamp use_mpi/$(MPIBASEMOD).$(MOD) use_mpi/mpi_base.lo use_mpi/mpi_base-tmp -src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp: src/binding/fortran/use_mpi/pmpi_base.f90 src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) - @rm -f src/binding/fortran/use_mpi/pmpi_base-tmp - @touch src/binding/fortran/use_mpi/pmpi_base-tmp - @( cd src/binding/fortran/use_mpi && \ +use_mpi/pmpi_base.$(MOD)-stamp: use_mpi/pmpi_base.f90 use_mpi/$(MPICONSTMOD).$(MOD) + @rm -f use_mpi/pmpi_base-tmp + @touch use_mpi/pmpi_base-tmp + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] ; then \ rm -f pmpi_base.$(FCEXT) ; \ $(LN_S) pmpi_base.f90 pmpi_base.$(FCEXT) ; \ fi ) - $(mod_verbose)$(FC_COMPILE_MODS) -c src/binding/fortran/use_mpi/pmpi_base.$(FCEXT) -o src/binding/fortran/use_mpi/pmpi_base.lo - @( cd src/binding/fortran/use_mpi && \ + $(mod_verbose)$(FC_COMPILE_MODS) -c use_mpi/pmpi_base.$(FCEXT) -o use_mpi/pmpi_base.lo + @( cd use_mpi && \ if [ "$(FCEXT)" != "f90" ] ; then \ rm -f pmpi_base.$(FCEXT) ; \ fi ) - @mv src/binding/fortran/use_mpi/pmpi_base-tmp src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp + @mv use_mpi/pmpi_base-tmp use_mpi/pmpi_base.$(MOD)-stamp -src/binding/fortran/use_mpi/pmpi_base.lo src/binding/fortran/use_mpi/$(PMPIBASEMOD).$(MOD): src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp +use_mpi/pmpi_base.lo use_mpi/$(PMPIBASEMOD).$(MOD): use_mpi/pmpi_base.$(MOD)-stamp ## Recover from the removal of $@ @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi/pmpi_base-lock src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi/pmpi_base-lock 2>/dev/null; then \ + trap 'rm -rf use_mpi/pmpi_base-lock use_mpi/pmpi_base.$(MOD)-stamp' 1 2 13 15; \ + if mkdir use_mpi/pmpi_base-lock 2>/dev/null; then \ ## This code is being executed by the first process. - rm -f src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp; \ - rmdir src/binding/fortran/use_mpi/pmpi_base-lock; \ + rm -f use_mpi/pmpi_base.$(MOD)-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi/pmpi_base.$(MOD)-stamp; \ + rmdir use_mpi/pmpi_base-lock; \ else \ ## This code is being executed by the follower processes. ## Wait until the first process is done. - while test -d src/binding/fortran/use_mpi/pmpi_base-lock; do sleep 1; done; \ + while test -d use_mpi/pmpi_base-lock; do sleep 1; done; \ ## Succeed if and only if the first process succeeded. - test -f src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp; exit $$?; \ + test -f use_mpi/pmpi_base.$(MOD)-stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi/pmpi_base.$(MOD)-stamp src/binding/fortran/use_mpi/$(PMPIBASEMOD).$(MOD) src/binding/fortran/use_mpi/pmpi_base.lo src/binding/fortran/use_mpi/pmpi_base-tmp +CLEANFILES += use_mpi/pmpi_base.$(MOD)-stamp use_mpi/$(PMPIBASEMOD).$(MOD) use_mpi/pmpi_base.lo use_mpi/pmpi_base-tmp mpi_fc_modules += \ - src/binding/fortran/use_mpi/$(MPIMOD).$(MOD) \ - src/binding/fortran/use_mpi/$(MPISIZEOFMOD).$(MOD) \ - src/binding/fortran/use_mpi/$(MPICONSTMOD).$(MOD) \ - src/binding/fortran/use_mpi/$(MPIBASEMOD).$(MOD) \ - src/binding/fortran/use_mpi/$(PMPIBASEMOD).$(MOD) + use_mpi/$(MPIMOD).$(MOD) \ + use_mpi/$(MPISIZEOFMOD).$(MOD) \ + use_mpi/$(MPICONSTMOD).$(MOD) \ + use_mpi/$(MPIBASEMOD).$(MOD) \ + use_mpi/$(PMPIBASEMOD).$(MOD) # We need a free-format version of mpif.h with no external commands, # including declarations such as `REAL*8 MPI_WTIME, PMPI_WTIME`. # Filtering on `PMPI_` covers those lines. # NOTE: do not use extended regex to allow posix sed. -src/binding/fortran/use_mpi/mpifnoext.h: src/binding/fortran/mpif_h/mpif.h +use_mpi/mpifnoext.h: mpif_h/mpif.h rm -f $@ sed -e 's/^C/\!/g' -e '/EXTERNAL/d' \ - -e '/PMPI_/d' src/binding/fortran/mpif_h/mpif.h > $@ + -e '/PMPI_/d' mpif_h/mpif.h > $@ -CLEANFILES += src/binding/fortran/use_mpi/mpifnoext.h +CLEANFILES += use_mpi/mpifnoext.h MAINTAINERCLEANFILES += $(mpi_sources) fproto.h CLEANFILES += $(mpi_fc_modules) diff --git a/src/binding/fortran/use_mpi_f08/Makefile.mk b/src/binding/fortran/use_mpi_f08/Makefile.mk index 8ff957ef7e8..0a43727343d 100644 --- a/src/binding/fortran/use_mpi_f08/Makefile.mk +++ b/src/binding/fortran/use_mpi_f08/Makefile.mk @@ -5,329 +5,329 @@ if BUILD_F08_BINDING -AM_FCFLAGS += @FCINCFLAG@src/binding/fortran/use_mpi_f08 +AM_FCFLAGS += @FCINCFLAG@use_mpi_f08 mpifort_convenience_libs += lib/libf08_mpi.la noinst_LTLIBRARIES += lib/libf08_mpi.la lib_libf08_mpi_la_SOURCES = \ - src/binding/fortran/use_mpi_f08/pmpi_f08.f90 \ - src/binding/fortran/use_mpi_f08/mpi_f08.f90 \ - src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.f90 \ - src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90 \ - src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.f90 \ - src/binding/fortran/use_mpi_f08/mpi_f08_types.f90 \ - src/binding/fortran/use_mpi_f08/mpi_c_interface.f90 \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.f90 \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.f90 \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90 \ - src/binding/fortran/use_mpi_f08/wrappers_f/f08ts.f90 \ - src/binding/fortran/use_mpi_f08/wrappers_f/pf08ts.f90 \ - src/binding/fortran/use_mpi_f08/wrappers_c/f08_cdesc.c \ - src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.c \ - src/binding/fortran/use_mpi_f08/wrappers_c/comm_spawn_c.c \ - src/binding/fortran/use_mpi_f08/wrappers_c/comm_spawn_multiple_c.c \ - src/binding/fortran/use_mpi_f08/wrappers_c/utils.c - -lib_libf08_mpi_la_CPPFLAGS = $(AM_CPPFLAGS) -I${main_top_srcdir}/src/binding/fortran/use_mpi_f08/wrappers_c -Isrc/binding/fortran/use_mpi_f08/wrappers_c - -noinst_HEADERS += src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.h + use_mpi_f08/pmpi_f08.f90 \ + use_mpi_f08/mpi_f08.f90 \ + use_mpi_f08/mpi_f08_callbacks.f90 \ + use_mpi_f08/mpi_f08_compile_constants.f90 \ + use_mpi_f08/mpi_f08_link_constants.f90 \ + use_mpi_f08/mpi_f08_types.f90 \ + use_mpi_f08/mpi_c_interface.f90 \ + use_mpi_f08/mpi_c_interface_cdesc.f90 \ + use_mpi_f08/mpi_c_interface_glue.f90 \ + use_mpi_f08/mpi_c_interface_nobuf.f90 \ + use_mpi_f08/mpi_c_interface_types.f90 \ + use_mpi_f08/wrappers_f/f08ts.f90 \ + use_mpi_f08/wrappers_f/pf08ts.f90 \ + use_mpi_f08/wrappers_c/f08_cdesc.c \ + use_mpi_f08/wrappers_c/cdesc.c \ + use_mpi_f08/wrappers_c/comm_spawn_c.c \ + use_mpi_f08/wrappers_c/comm_spawn_multiple_c.c \ + use_mpi_f08/wrappers_c/utils.c + +lib_libf08_mpi_la_CPPFLAGS = $(AM_CPPFLAGS) -I${srcdir}/use_mpi_f08/wrappers_c -Iuse_mpi_f08/wrappers_c + +noinst_HEADERS += use_mpi_f08/wrappers_c/cdesc.h mpi_fc_modules += \ - src/binding/fortran/use_mpi_f08/$(PMPI_F08_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) + use_mpi_f08/$(PMPI_F08_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) f08_module_files = \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(PMPI_F08_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) + use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) \ + use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) \ + use_mpi_f08/$(PMPI_F08_NAME).$(MOD) \ + use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) BUILT_SOURCES += $(f08_module_files) CLEANFILES += $(f08_module_files) F08_COMPILE_MODS = $(LTFCCOMPILE) -F08_COMPILE_MODS += $(FCMODOUTFLAG)src/binding/fortran/use_mpi_f08 +F08_COMPILE_MODS += $(FCMODOUTFLAG)use_mpi_f08 -src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp: src/binding/fortran/use_mpi_f08/mpi_f08_types.f90 src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_f08_types.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_f08_types.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_f08_types.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_f08_types.f90 -o src/binding/fortran/use_mpi_f08/mpi_f08_types.lo - @mv src/binding/fortran/use_mpi_f08/mpi_f08_types.tmp src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp +use_mpi_f08/mpi_f08_types.stamp: use_mpi_f08/mpi_f08_types.f90 use_mpi_f08/mpi_c_interface_types.stamp + @rm -f use_mpi_f08/mpi_f08_types.tmp + @touch use_mpi_f08/mpi_f08_types.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_f08_types.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_f08_types.f90 -o use_mpi_f08/mpi_f08_types.lo + @mv use_mpi_f08/mpi_f08_types.tmp use_mpi_f08/mpi_f08_types.stamp -src/binding/fortran/use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_f08_types.lo : src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp +use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) use_mpi_f08/mpi_f08_types.lo : use_mpi_f08/mpi_f08_types.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_f08_types-lock src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_f08_types-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_f08_types-lock; \ + trap 'rm -rf use_mpi_f08/mpi_f08_types-lock use_mpi_f08/mpi_f08_types.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_f08_types-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_f08_types.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_f08_types.stamp; \ + rmdir use_mpi_f08/mpi_f08_types-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_f08_types-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_f08_types-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_f08_types.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_f08_types.lo \ - src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp \ - src/binding/fortran/use_mpi_f08/mpi_f08_types.tmp +CLEANFILES += use_mpi_f08/$(MPI_F08_TYPES_NAME).$(MOD) \ + use_mpi_f08/mpi_f08_types.lo \ + use_mpi_f08/mpi_f08_types.stamp \ + use_mpi_f08/mpi_f08_types.tmp -src/binding/fortran/use_mpi_f08/mpi_f08.stamp: src/binding/fortran/use_mpi_f08/mpi_f08.f90 src/binding/fortran/use_mpi_f08/pmpi_f08.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_f08.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_f08.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_f08.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_f08.f90 -o src/binding/fortran/use_mpi_f08/mpi_f08.lo - @mv src/binding/fortran/use_mpi_f08/mpi_f08.tmp src/binding/fortran/use_mpi_f08/mpi_f08.stamp +use_mpi_f08/mpi_f08.stamp: use_mpi_f08/mpi_f08.f90 use_mpi_f08/pmpi_f08.stamp + @rm -f use_mpi_f08/mpi_f08.tmp + @touch use_mpi_f08/mpi_f08.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_f08.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_f08.f90 -o use_mpi_f08/mpi_f08.lo + @mv use_mpi_f08/mpi_f08.tmp use_mpi_f08/mpi_f08.stamp -src/binding/fortran/use_mpi_f08/$(MPI_F08_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_f08.lo : src/binding/fortran/use_mpi_f08/mpi_f08.stamp +use_mpi_f08/$(MPI_F08_NAME).$(MOD) use_mpi_f08/mpi_f08.lo : use_mpi_f08/mpi_f08.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_f08-lock src/binding/fortran/use_mpi_f08/mpi_f08.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_f08-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_f08.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_f08.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_f08-lock; \ + trap 'rm -rf use_mpi_f08/mpi_f08-lock use_mpi_f08/mpi_f08.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_f08-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_f08.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_f08.stamp; \ + rmdir use_mpi_f08/mpi_f08-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_f08-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_f08.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_f08-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_f08.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_F08_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_f08.lo \ - src/binding/fortran/use_mpi_f08/mpi_f08.stamp \ - src/binding/fortran/use_mpi_f08/mpi_f08.tmp +CLEANFILES += use_mpi_f08/$(MPI_F08_NAME).$(MOD) \ + use_mpi_f08/mpi_f08.lo \ + use_mpi_f08/mpi_f08.stamp \ + use_mpi_f08/mpi_f08.tmp -src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp: src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 src/binding/fortran/use_mpi_f08/mpi_f08.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 -o src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.lo - @mv src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.tmp src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp +use_mpi_f08/mpi_c_interface_glue.stamp: use_mpi_f08/mpi_c_interface_glue.f90 use_mpi_f08/mpi_f08.stamp + @rm -f use_mpi_f08/mpi_c_interface_glue.tmp + @touch use_mpi_f08/mpi_c_interface_glue.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_c_interface_glue.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_c_interface_glue.f90 -o use_mpi_f08/mpi_c_interface_glue.lo + @mv use_mpi_f08/mpi_c_interface_glue.tmp use_mpi_f08/mpi_c_interface_glue.stamp -src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.lo : src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp +use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) use_mpi_f08/mpi_c_interface_glue.lo : use_mpi_f08/mpi_c_interface_glue.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_c_interface_glue-lock src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_c_interface_glue-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_c_interface_glue-lock; \ + trap 'rm -rf use_mpi_f08/mpi_c_interface_glue-lock use_mpi_f08/mpi_c_interface_glue.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_c_interface_glue-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_c_interface_glue.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_c_interface_glue.stamp; \ + rmdir use_mpi_f08/mpi_c_interface_glue-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_c_interface_glue-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_c_interface_glue-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_c_interface_glue.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.lo \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.tmp +CLEANFILES += use_mpi_f08/$(MPI_C_INTERFACE_GLUE_NAME).$(MOD) \ + use_mpi_f08/mpi_c_interface_glue.lo \ + use_mpi_f08/mpi_c_interface_glue.stamp \ + use_mpi_f08/mpi_c_interface_glue.tmp -src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp: src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90 - @rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_types.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_c_interface_types.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_c_interface_types.f90 -o src/binding/fortran/use_mpi_f08/mpi_c_interface_types.lo - @mv src/binding/fortran/use_mpi_f08/mpi_c_interface_types.tmp src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp +use_mpi_f08/mpi_c_interface_types.stamp: use_mpi_f08/mpi_c_interface_types.f90 + @rm -f use_mpi_f08/mpi_c_interface_types.tmp + @touch use_mpi_f08/mpi_c_interface_types.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_c_interface_types.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_c_interface_types.f90 -o use_mpi_f08/mpi_c_interface_types.lo + @mv use_mpi_f08/mpi_c_interface_types.tmp use_mpi_f08/mpi_c_interface_types.stamp -src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_c_interface_types.lo : src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp +use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) use_mpi_f08/mpi_c_interface_types.lo : use_mpi_f08/mpi_c_interface_types.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_c_interface_types-lock src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_c_interface_types-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_c_interface_types-lock; \ + trap 'rm -rf use_mpi_f08/mpi_c_interface_types-lock use_mpi_f08/mpi_c_interface_types.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_c_interface_types-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_c_interface_types.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_c_interface_types.stamp; \ + rmdir use_mpi_f08/mpi_c_interface_types-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_c_interface_types-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_c_interface_types-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_c_interface_types.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_types.lo \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_types.stamp \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_types.tmp +CLEANFILES += use_mpi_f08/$(MPI_C_INTERFACE_TYPES_NAME).$(MOD) \ + use_mpi_f08/mpi_c_interface_types.lo \ + use_mpi_f08/mpi_c_interface_types.stamp \ + use_mpi_f08/mpi_c_interface_types.tmp -src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp: src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90 src/binding/fortran/use_mpi_f08/mpi_f08_types.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.f90 -o src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.lo - @mv src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.tmp src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp +use_mpi_f08/mpi_f08_compile_constants.stamp: use_mpi_f08/mpi_f08_compile_constants.f90 use_mpi_f08/mpi_f08_types.stamp + @rm -f use_mpi_f08/mpi_f08_compile_constants.tmp + @touch use_mpi_f08/mpi_f08_compile_constants.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_f08_compile_constants.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_f08_compile_constants.f90 -o use_mpi_f08/mpi_f08_compile_constants.lo + @mv use_mpi_f08/mpi_f08_compile_constants.tmp use_mpi_f08/mpi_f08_compile_constants.stamp -src/binding/fortran/use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.lo : src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp +use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) use_mpi_f08/mpi_f08_compile_constants.lo : use_mpi_f08/mpi_f08_compile_constants.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants-lock src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants-lock; \ + trap 'rm -rf use_mpi_f08/mpi_f08_compile_constants-lock use_mpi_f08/mpi_f08_compile_constants.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_f08_compile_constants-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_f08_compile_constants.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_f08_compile_constants.stamp; \ + rmdir use_mpi_f08/mpi_f08_compile_constants-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_f08_compile_constants-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_f08_compile_constants.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.lo \ - src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp \ - src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.tmp +CLEANFILES += use_mpi_f08/$(MPI_F08_COMPILE_CONSTANTS_NAME).$(MOD) \ + use_mpi_f08/mpi_f08_compile_constants.lo \ + use_mpi_f08/mpi_f08_compile_constants.stamp \ + use_mpi_f08/mpi_f08_compile_constants.tmp -src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp: src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.f90 src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.f90 -o src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.lo - @mv src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.tmp src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp +use_mpi_f08/mpi_c_interface_cdesc.stamp: use_mpi_f08/mpi_c_interface_cdesc.f90 use_mpi_f08/mpi_c_interface_nobuf.stamp + @rm -f use_mpi_f08/mpi_c_interface_cdesc.tmp + @touch use_mpi_f08/mpi_c_interface_cdesc.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_c_interface_cdesc.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_c_interface_cdesc.f90 -o use_mpi_f08/mpi_c_interface_cdesc.lo + @mv use_mpi_f08/mpi_c_interface_cdesc.tmp use_mpi_f08/mpi_c_interface_cdesc.stamp -src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.lo : src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp +use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) use_mpi_f08/mpi_c_interface_cdesc.lo : use_mpi_f08/mpi_c_interface_cdesc.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc-lock src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc-lock; \ + trap 'rm -rf use_mpi_f08/mpi_c_interface_cdesc-lock use_mpi_f08/mpi_c_interface_cdesc.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_c_interface_cdesc-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_c_interface_cdesc.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_c_interface_cdesc.stamp; \ + rmdir use_mpi_f08/mpi_c_interface_cdesc-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_c_interface_cdesc-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_c_interface_cdesc.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.lo \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.tmp +CLEANFILES += use_mpi_f08/$(MPI_C_INTERFACE_CDESC_NAME).$(MOD) \ + use_mpi_f08/mpi_c_interface_cdesc.lo \ + use_mpi_f08/mpi_c_interface_cdesc.stamp \ + use_mpi_f08/mpi_c_interface_cdesc.tmp -src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp: src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.f90 src/binding/fortran/use_mpi_f08/mpi_f08_compile_constants.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.f90 -o src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.lo - @mv src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.tmp src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp +use_mpi_f08/mpi_f08_callbacks.stamp: use_mpi_f08/mpi_f08_callbacks.f90 use_mpi_f08/mpi_f08_compile_constants.stamp + @rm -f use_mpi_f08/mpi_f08_callbacks.tmp + @touch use_mpi_f08/mpi_f08_callbacks.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_f08_callbacks.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_f08_callbacks.f90 -o use_mpi_f08/mpi_f08_callbacks.lo + @mv use_mpi_f08/mpi_f08_callbacks.tmp use_mpi_f08/mpi_f08_callbacks.stamp -src/binding/fortran/use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.lo : src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp +use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) use_mpi_f08/mpi_f08_callbacks.lo : use_mpi_f08/mpi_f08_callbacks.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_f08_callbacks-lock src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_f08_callbacks-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_f08_callbacks-lock; \ + trap 'rm -rf use_mpi_f08/mpi_f08_callbacks-lock use_mpi_f08/mpi_f08_callbacks.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_f08_callbacks-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_f08_callbacks.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_f08_callbacks.stamp; \ + rmdir use_mpi_f08/mpi_f08_callbacks-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_f08_callbacks-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_f08_callbacks-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_f08_callbacks.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.lo \ - src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp \ - src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.tmp +CLEANFILES += use_mpi_f08/$(MPI_F08_CALLBACKS_NAME).$(MOD) \ + use_mpi_f08/mpi_f08_callbacks.lo \ + use_mpi_f08/mpi_f08_callbacks.stamp \ + use_mpi_f08/mpi_f08_callbacks.tmp -src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp: src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.f90 src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.f90 -o src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.lo - @mv src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.tmp src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp +use_mpi_f08/mpi_c_interface_nobuf.stamp: use_mpi_f08/mpi_c_interface_nobuf.f90 use_mpi_f08/mpi_c_interface_glue.stamp + @rm -f use_mpi_f08/mpi_c_interface_nobuf.tmp + @touch use_mpi_f08/mpi_c_interface_nobuf.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_c_interface_nobuf.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_c_interface_nobuf.f90 -o use_mpi_f08/mpi_c_interface_nobuf.lo + @mv use_mpi_f08/mpi_c_interface_nobuf.tmp use_mpi_f08/mpi_c_interface_nobuf.stamp -src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.lo : src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp +use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) use_mpi_f08/mpi_c_interface_nobuf.lo : use_mpi_f08/mpi_c_interface_nobuf.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf-lock src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf-lock; \ + trap 'rm -rf use_mpi_f08/mpi_c_interface_nobuf-lock use_mpi_f08/mpi_c_interface_nobuf.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_c_interface_nobuf-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_c_interface_nobuf.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_c_interface_nobuf.stamp; \ + rmdir use_mpi_f08/mpi_c_interface_nobuf-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_c_interface_nobuf-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_c_interface_nobuf.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.lo \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.stamp \ - src/binding/fortran/use_mpi_f08/mpi_c_interface_nobuf.tmp +CLEANFILES += use_mpi_f08/$(MPI_C_INTERFACE_NOBUF_NAME).$(MOD) \ + use_mpi_f08/mpi_c_interface_nobuf.lo \ + use_mpi_f08/mpi_c_interface_nobuf.stamp \ + use_mpi_f08/mpi_c_interface_nobuf.tmp -src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp: src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.f90 src/binding/fortran/use_mpi_f08/mpi_f08_callbacks.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.f90 -o src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.lo - @mv src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.tmp src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp +use_mpi_f08/mpi_f08_link_constants.stamp: use_mpi_f08/mpi_f08_link_constants.f90 use_mpi_f08/mpi_f08_callbacks.stamp + @rm -f use_mpi_f08/mpi_f08_link_constants.tmp + @touch use_mpi_f08/mpi_f08_link_constants.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_f08_link_constants.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_f08_link_constants.f90 -o use_mpi_f08/mpi_f08_link_constants.lo + @mv use_mpi_f08/mpi_f08_link_constants.tmp use_mpi_f08/mpi_f08_link_constants.stamp -src/binding/fortran/use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.lo : src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp +use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) use_mpi_f08/mpi_f08_link_constants.lo : use_mpi_f08/mpi_f08_link_constants.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_f08_link_constants-lock src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_f08_link_constants-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_f08_link_constants-lock; \ + trap 'rm -rf use_mpi_f08/mpi_f08_link_constants-lock use_mpi_f08/mpi_f08_link_constants.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_f08_link_constants-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_f08_link_constants.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_f08_link_constants.stamp; \ + rmdir use_mpi_f08/mpi_f08_link_constants-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_f08_link_constants-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_f08_link_constants-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_f08_link_constants.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.lo \ - src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp \ - src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.tmp +CLEANFILES += use_mpi_f08/$(MPI_F08_LINK_CONSTANTS_NAME).$(MOD) \ + use_mpi_f08/mpi_f08_link_constants.lo \ + use_mpi_f08/mpi_f08_link_constants.stamp \ + use_mpi_f08/mpi_f08_link_constants.tmp -src/binding/fortran/use_mpi_f08/pmpi_f08.stamp: src/binding/fortran/use_mpi_f08/pmpi_f08.f90 src/binding/fortran/use_mpi_f08/mpi_f08_link_constants.stamp - @rm -f src/binding/fortran/use_mpi_f08/pmpi_f08.tmp - @touch src/binding/fortran/use_mpi_f08/pmpi_f08.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/pmpi_f08.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/pmpi_f08.f90 -o src/binding/fortran/use_mpi_f08/pmpi_f08.lo - @mv src/binding/fortran/use_mpi_f08/pmpi_f08.tmp src/binding/fortran/use_mpi_f08/pmpi_f08.stamp +use_mpi_f08/pmpi_f08.stamp: use_mpi_f08/pmpi_f08.f90 use_mpi_f08/mpi_f08_link_constants.stamp + @rm -f use_mpi_f08/pmpi_f08.tmp + @touch use_mpi_f08/pmpi_f08.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/pmpi_f08.f90' || echo '$(srcdir)/'`use_mpi_f08/pmpi_f08.f90 -o use_mpi_f08/pmpi_f08.lo + @mv use_mpi_f08/pmpi_f08.tmp use_mpi_f08/pmpi_f08.stamp -src/binding/fortran/use_mpi_f08/$(PMPI_F08_NAME).$(MOD) src/binding/fortran/use_mpi_f08/pmpi_f08.lo : src/binding/fortran/use_mpi_f08/pmpi_f08.stamp +use_mpi_f08/$(PMPI_F08_NAME).$(MOD) use_mpi_f08/pmpi_f08.lo : use_mpi_f08/pmpi_f08.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/pmpi_f08-lock src/binding/fortran/use_mpi_f08/pmpi_f08.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/pmpi_f08-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/pmpi_f08.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/pmpi_f08.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/pmpi_f08-lock; \ + trap 'rm -rf use_mpi_f08/pmpi_f08-lock use_mpi_f08/pmpi_f08.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/pmpi_f08-lock 2>/dev/null; then \ + rm -f use_mpi_f08/pmpi_f08.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/pmpi_f08.stamp; \ + rmdir use_mpi_f08/pmpi_f08-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/pmpi_f08-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/pmpi_f08.stamp; exit $$?; \ + while test -d use_mpi_f08/pmpi_f08-lock; do sleep 1; done; \ + test -f use_mpi_f08/pmpi_f08.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(PMPI_F08_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/pmpi_f08.lo \ - src/binding/fortran/use_mpi_f08/pmpi_f08.stamp \ - src/binding/fortran/use_mpi_f08/pmpi_f08.tmp +CLEANFILES += use_mpi_f08/$(PMPI_F08_NAME).$(MOD) \ + use_mpi_f08/pmpi_f08.lo \ + use_mpi_f08/pmpi_f08.stamp \ + use_mpi_f08/pmpi_f08.tmp -src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp: src/binding/fortran/use_mpi_f08/mpi_c_interface.f90 src/binding/fortran/use_mpi_f08/mpi_c_interface_cdesc.stamp - @rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface.tmp - @touch src/binding/fortran/use_mpi_f08/mpi_c_interface.tmp - $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'src/binding/fortran/use_mpi_f08/mpi_c_interface.f90' || echo '$(srcdir)/'`src/binding/fortran/use_mpi_f08/mpi_c_interface.f90 -o src/binding/fortran/use_mpi_f08/mpi_c_interface.lo - @mv src/binding/fortran/use_mpi_f08/mpi_c_interface.tmp src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp +use_mpi_f08/mpi_c_interface.stamp: use_mpi_f08/mpi_c_interface.f90 use_mpi_f08/mpi_c_interface_cdesc.stamp + @rm -f use_mpi_f08/mpi_c_interface.tmp + @touch use_mpi_f08/mpi_c_interface.tmp + $(mod_verbose)$(F08_COMPILE_MODS) -c `test -f 'use_mpi_f08/mpi_c_interface.f90' || echo '$(srcdir)/'`use_mpi_f08/mpi_c_interface.f90 -o use_mpi_f08/mpi_c_interface.lo + @mv use_mpi_f08/mpi_c_interface.tmp use_mpi_f08/mpi_c_interface.stamp -src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) src/binding/fortran/use_mpi_f08/mpi_c_interface.lo : src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp +use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) use_mpi_f08/mpi_c_interface.lo : use_mpi_f08/mpi_c_interface.stamp @if test -f $@; then :; else \ - trap 'rm -rf src/binding/fortran/use_mpi_f08/mpi_c_interface-lock src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp' 1 2 13 15; \ - if mkdir src/binding/fortran/use_mpi_f08/mpi_c_interface-lock 2>/dev/null; then \ - rm -f src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp; \ - rmdir src/binding/fortran/use_mpi_f08/mpi_c_interface-lock; \ + trap 'rm -rf use_mpi_f08/mpi_c_interface-lock use_mpi_f08/mpi_c_interface.stamp' 1 2 13 15; \ + if mkdir use_mpi_f08/mpi_c_interface-lock 2>/dev/null; then \ + rm -f use_mpi_f08/mpi_c_interface.stamp; \ + $(MAKE) $(AM_MAKEFLAGS) use_mpi_f08/mpi_c_interface.stamp; \ + rmdir use_mpi_f08/mpi_c_interface-lock; \ else \ - while test -d src/binding/fortran/use_mpi_f08/mpi_c_interface-lock; do sleep 1; done; \ - test -f src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp; exit $$?; \ + while test -d use_mpi_f08/mpi_c_interface-lock; do sleep 1; done; \ + test -f use_mpi_f08/mpi_c_interface.stamp; exit $$?; \ fi; \ fi -CLEANFILES += src/binding/fortran/use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) \ - src/binding/fortran/use_mpi_f08/mpi_c_interface.lo \ - src/binding/fortran/use_mpi_f08/mpi_c_interface.stamp \ - src/binding/fortran/use_mpi_f08/mpi_c_interface.tmp +CLEANFILES += use_mpi_f08/$(MPI_C_INTERFACE_NAME).$(MOD) \ + use_mpi_f08/mpi_c_interface.lo \ + use_mpi_f08/mpi_c_interface.stamp \ + use_mpi_f08/mpi_c_interface.tmp endif BUILD_F08_BINDING diff --git a/src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.h b/src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.h index dedb8127280..35a17c5bef1 100644 --- a/src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.h +++ b/src/binding/fortran/use_mpi_f08/wrappers_c/cdesc.h @@ -6,7 +6,7 @@ #ifndef CDESC_H_INCLUDED #define CDESC_H_INCLUDED -#include "mpichconf.h" +#include "mpifort_config.h" #include #include #include diff --git a/src/env/Makefile.mk b/src/env/Makefile.mk index 8a79083b0f0..21858afbfe5 100644 --- a/src/env/Makefile.mk +++ b/src/env/Makefile.mk @@ -15,9 +15,7 @@ bin_PROGRAMS += src/env/mpichversion \ src_env_mpichversion_LDADD = lib/lib@MPILIBNAME@.la src_env_mpivars_LDADD = lib/lib@MPILIBNAME@.la -if BUILD_FC_BINDING bin_SCRIPTS += src/env/mpifort -endif BUILD_FC_BINDING if INSTALL_MPICXX bin_SCRIPTS += src/env/mpicxx From e55440d5b92e8080424ce14ba3f91f3817b231fd Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 11 May 2026 12:37:53 -0500 Subject: [PATCH 19/39] binding/fortran: move mpifort to standalone fortran Configure and install mpifort and libmpifort.so from src/binding/fortran as a sub-package.. temp: fix up fortran binding as a separate package --- .gitignore | 19 --- Makefile.am | 18 +-- confdb/aclocal_shell.m4 | 35 ++++++ configure.ac | 82 ++----------- src/binding/fortran/.gitignore | 11 ++ src/binding/fortran/Makefile.am | 98 +++++++++++++++- src/binding/fortran/autogen.sh | 1 + src/binding/fortran/configure.ac | 135 +++++++++++++++++++--- src/{ => binding/fortran}/env/mpifort.txt | 0 src/env/Makefile.mk | 10 +- src/env/mpicc.def | 2 + 11 files changed, 272 insertions(+), 139 deletions(-) create mode 100644 confdb/aclocal_shell.m4 rename src/{ => binding/fortran}/env/mpifort.txt (100%) diff --git a/.gitignore b/.gitignore index 40d7fe793e8..7fbf33523d3 100644 --- a/.gitignore +++ b/.gitignore @@ -169,8 +169,6 @@ Makefile.am-stamp # random additions /README.envvar /maint/extracterrmsgs -/src/binding/fortran/use_mpi/mpi_base.f90.in -/src/binding/fortran/use_mpi/mpi_constants.f90.in /src/mpi/romio/include/mpio.h /src/mpid/ch3/channels/nemesis/include/mpid_nem_net_module_defs.h /src/packaging/envmods/mpich2.module @@ -189,14 +187,6 @@ Makefile.am-stamp /src/packaging/pkgconfig/mpich.pc /src/mpi/coll/src/csel_json_autogen.c -# stamp "witness" files from the new build system -/src/binding/fortran/use_mpi/mpi.mod-stamp -/src/binding/fortran/use_mpi/mpi_base.mod-stamp -/src/binding/fortran/use_mpi/pmpi_base.mod-stamp -/src/binding/fortran/use_mpi/mpi_constants.mod-stamp -/src/binding/fortran/use_mpi/mpi_sizeofs.mod-stamp -/src/binding/fortran/use_mpi_f08/*.stamp - /src/mpe2/src/callstack/bin/bt2line # MPL build products @@ -416,21 +406,12 @@ Makefile.am-stamp /src/env/mpicxx.sh /src/env/mpicxx.bash /src/env/mpicxx.conf -/src/env/mpif77 -/src/env/mpif77.sh -/src/env/mpif77.bash -/src/env/mpif77.conf -/src/env/mpifort -/src/env/mpifort.sh -/src/env/mpifort.bash /src/env/mpichversion /src/env/parkill /src/env/mpivars /src/env/mpixxx_opts.conf /src/env/cc_shlib.conf /src/env/cxx_shlib.conf -/src/env/f77_shlib.conf -/src/env/fc_shlib.conf # /src/include/ /src/include/mpi.h diff --git a/Makefile.am b/Makefile.am index 84d2bd21d50..6bc50080240 100644 --- a/Makefile.am +++ b/Makefile.am @@ -205,8 +205,7 @@ install-exec-hook: . lib/lib@MPILIBNAME@.la ; \ fi ; \ for e in ${DESTDIR}${bindir}/@MPICC_NAME@ \ - ${DESTDIR}${bindir}/@MPICXX_NAME@ \ - ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; do \ + ${DESTDIR}${bindir}/@MPICXX_NAME@ ; do \ if test -e $${e} ; then \ sed -e 's|__PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__|${prefix}|g' \ -e 's|__EXEC_PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__|${exec_prefix}|g' \ @@ -223,21 +222,6 @@ install-exec-hook: cd ${DESTDIR}${bindir} && ln -f -s @MPICXX_NAME@ @MPICPP_NAME@ ; \ fi ; \ fi ; -if INSTALL_MPIF90 - if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ - if test "@MPIFORT_NAME@" != "@MPIF90_NAME@" ; then \ - cd ${DESTDIR}${bindir} && ln -f -s @MPIFORT_NAME@ @MPIF90_NAME@ ; \ - fi ; \ - fi ; -endif INSTALL_MPIF90 -if INSTALL_MPIF77 - if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ - if test "@MPIFORT_NAME@" != "@MPIF77_NAME@" ; then \ - cd ${DESTDIR}${bindir} && ln -f -s @MPIFORT_NAME@ @MPIF77_NAME@ ; \ - fi ; \ - fi ; -endif INSTALL_MPIF77 - # the configure step checks for the 'lib' dir to decide whether a source # directory has been previously used for an in-path build before allowing a diff --git a/confdb/aclocal_shell.m4 b/confdb/aclocal_shell.m4 new file mode 100644 index 00000000000..0da512fae73 --- /dev/null +++ b/confdb/aclocal_shell.m4 @@ -0,0 +1,35 @@ +dnl PAC_CHECK_BASH - check whether bash syntax, esp. arrays, can be used in mpicc etc. +dnl Sets $pac_cv_bash_works +AC_DEFUN([PAC_CHECK_BASH],[ + AC_ARG_ENABLE([bash],[AS_HELP_STRING([--disable-bash],[Do not use bash for wrapper scripts (mpicc etc)])], + [],[enable_bash=yes]) + AC_PATH_PROG(BASH_SHELL,bash) + pac_cv_bash_works=no + if test -z "$pac_cv_bash_works" -a "$enable_bash" = "yes" ; then + # Confirm that bash has working arrays. We can use this to + # build more robust versions of the scripts (particularly the + # compilation scripts) by taking advantage of the array features in + # bash. + if test -x "$BASH_SHELL" ; then + changequote(%%,::)dnl + cat >>conftest <&1 >/dev/null ; then + pac_cv_bash_works=yes + else + pac_cv_bash_works=no + fi + rm -f conftest* + AC_MSG_RESULT($pac_cv_bash_works) + fi + fi +]) diff --git a/configure.ac b/configure.ac index 6f54b77bcbf..8d2f432a600 100644 --- a/configure.ac +++ b/configure.ac @@ -275,16 +275,6 @@ AC_SUBST(MPICH_MPICXX_CXXFLAGS) AC_SUBST(MPICH_MPICXX_LDFLAGS) AC_SUBST(MPICH_MPICXX_LIBS) -AC_SUBST(MPICH_MPIF77_CPPFLAGS) -AC_SUBST(MPICH_MPIF77_FFLAGS) -AC_SUBST(MPICH_MPIF77_LDFLAGS) -AC_SUBST(MPICH_MPIF77_LIBS) - -AC_SUBST(MPICH_MPIFORT_CPPFLAGS) -AC_SUBST(MPICH_MPIFORT_FCFLAGS) -AC_SUBST(MPICH_MPIFORT_LDFLAGS) -AC_SUBST(MPICH_MPIFORT_LIBS) - # Add MPICHLIB_* to the appropriate flags AC_ARG_VAR(MPICHLIB_CFLAGS, [extra CFLAGS used in building MPICH libraries]) @@ -303,8 +293,6 @@ AC_ARG_VAR(MPICHLIB_LIBS, CFLAGS="$CFLAGS $MPICHLIB_CFLAGS" CPPFLAGS="$CPPFLAGS $MPICHLIB_CPPFLAGS" CXXFLAGS="$CXXFLAGS $MPICHLIB_CXXFLAGS" -FFLAGS="$FFLAGS $MPICHLIB_FFLAGS" -FCFLAGS="$FCFLAGS $MPICHLIB_FCFLAGS" # Save LDFLAGS before merging with MPICHLIB_LDFLAGS. The wrapper scripts # may need this in case interlibrary dependencies are not supported. WRAPPER_DEPENDENCY_LDFLAGS=$LDFLAGS @@ -747,9 +735,6 @@ if test "$pac_cv_cxx_builds_exe" = "no" ; then CXX= fi -AM_CONDITIONAL([INSTALL_MPIF90],[true]) -AM_CONDITIONAL([INSTALL_MPIF77],[true]) - # compute canonical system types AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -1273,34 +1258,22 @@ IFS="$save_IFS" if test "$enable_append_g" = "yes" ; then PAC_APPEND_FLAG([-g],[CFLAGS]) PAC_APPEND_FLAG([-g],[CXXFLAGS]) - PAC_APPEND_FLAG([-g],[FFLAGS]) - PAC_APPEND_FLAG([-g],[FCFLAGS]) PAC_APPEND_FLAG([-g],[WRAPPER_CFLAGS]) PAC_APPEND_FLAG([-g],[WRAPPER_CXXFLAGS]) - PAC_APPEND_FLAG([-g],[WRAPPER_FFLAGS]) - PAC_APPEND_FLAG([-g],[WRAPPER_FCFLAGS]) fi if test "$enable_asan" = "yes" ; then PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[CFLAGS]) PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[CXXFLAGS]) - PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[FFLAGS]) - PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[FCFLAGS]) PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[WRAPPER_CFLAGS]) PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[WRAPPER_CXXFLAGS]) - PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[WRAPPER_FFLAGS]) - PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[WRAPPER_FCFLAGS]) PAC_APPEND_FLAG([-fsanitize=address],[LDFLAGS]) fi if test "$enable_ubsan" = "yes" ; then PAC_APPEND_FLAG([-fsanitize=undefined],[CFLAGS]) PAC_APPEND_FLAG([-fsanitize=undefined],[CXXFLAGS]) - PAC_APPEND_FLAG([-fsanitize=undefined],[FFLAGS]) - PAC_APPEND_FLAG([-fsanitize=undefined],[FCFLAGS]) PAC_APPEND_FLAG([-fsanitize=undefined],[WRAPPER_CFLAGS]) PAC_APPEND_FLAG([-fsanitize=undefined],[WRAPPER_CXXFLAGS]) - PAC_APPEND_FLAG([-fsanitize=undefined],[WRAPPER_FFLAGS]) - PAC_APPEND_FLAG([-fsanitize=undefined],[WRAPPER_FCFLAGS]) PAC_APPEND_FLAG([-fsanitize=undefined],[LDFLAGS]) fi if test "$enable_tsan" = "yes" ; then @@ -1942,42 +1915,12 @@ PAC_PROG_CHECK_INSTALL_WORKS PAC_PROG_MKDIR_P PAC_PROG_MAKE -AC_ARG_ENABLE([bash],[AS_HELP_STRING([--disable-bash],[Do not use bash for wrapper scripts (mpicc etc)])], - [],[enable_bash=yes]) -AC_PATH_PROG(BASH_SHELL,bash) - -bashWorks=no -if test "$enable_bash" = "yes" ; then - # Check for bash to allow more robust shell scripts - # - # Confirm that bash has working arrays. We can use this to - # build more robust versions of the scripts (particularly the - # compilation scripts) by taking advantage of the array features in - # bash. - if test -x "$BASH_SHELL" ; then - changequote(%%,::)dnl - cat >>conftest <&1 >/dev/null ; then - bashWorks=yes - else - bashWorks=no - fi - rm -f conftest* - AC_MSG_RESULT($bashWorks) - fi -fi dnl BUILD_BASH_SCRIPTS used to be an AC_SUBST -AM_CONDITIONAL([BUILD_BASH_SCRIPTS], [test "x$bashWorks" = xyes]) +PAC_CHECK_BASH +AM_CONDITIONAL([BUILD_BASH_SCRIPTS], [test "x$pac_cv_bash_works" = xyes]) + +# export variables for subconfigure in mpifort +export BASH_SHELL pac_cv_bash_works # ---------------------------------------------------------------------------- # At this point, we've finally settled on the value of PMPILIBNAME. We @@ -2980,6 +2923,9 @@ else fi AC_SUBST(LMPICXXLIBNAME) +# export to src/binding/fortran/configure +export MPILIBNAME LPMPILIBNAME + # ---------------------------------------------------------------------------- # with MPI_AINT defined, now we can @@ -3213,17 +3159,11 @@ AC_SUBST(MPICC_ABI_NAME) AC_SUBST(MPICXX_NAME) AC_SUBST(MPICXX_ABI_NAME) AC_SUBST(MPICPP_NAME) -AC_SUBST(MPIFORT_NAME) -AC_SUBST(MPIF90_NAME) -AC_SUBST(MPIF77_NAME) PAC_GET_EXENAME("mpicc", MPICC_NAME) PAC_GET_EXENAME("mpicc_abi", MPICC_ABI_NAME) PAC_GET_EXENAME("mpicxx", MPICXX_NAME) PAC_GET_EXENAME("mpicxx_abi", MPICXX_ABI_NAME) PAC_GET_EXENAME("mpic++", MPICPP_NAME) -PAC_GET_EXENAME("mpifort", MPIFORT_NAME) -PAC_GET_EXENAME("mpif90", MPIF90_NAME) -PAC_GET_EXENAME("mpif77", MPIF77_NAME) dnl dnl Generate the Makefiles from Makefile.in @@ -3313,10 +3253,6 @@ if test "$enable_fortran" = "yes" ; then AC_MSG_NOTICE([sourcing $main_top_builddir/src/binding/fortran/localdefs]) . $main_top_builddir/src/binding/fortran/localdefs - - # For now, we build/install mpifort in mpich - fc_shlib_conf="src/binding/fortran/fc_shlib.conf" - AC_SUBST([fc_shlib_conf]) fi # FCEXT used in mpifort.bash.in @@ -3345,8 +3281,6 @@ AC_CONFIG_FILES([Makefile \ src/env/mpicc.bash \ src/env/mpicxx.sh \ src/env/mpicxx.bash \ - src/env/mpifort.sh \ - src/env/mpifort.bash \ src/env/parkill \ src/include/mpi_mpich.h \ doc/installguide/Makefile \ diff --git a/src/binding/fortran/.gitignore b/src/binding/fortran/.gitignore index 07c063cacb2..4e89800ce85 100644 --- a/src/binding/fortran/.gitignore +++ b/src/binding/fortran/.gitignore @@ -26,6 +26,13 @@ /use_mpi/mpi_constants.f90 /use_mpi/mpifnoext.h +/use_mpi/mpi.mod-stamp +/use_mpi/mpi_base.mod-stamp +/use_mpi/pmpi_base.mod-stamp +/use_mpi/mpi_constants.mod-stamp +/use_mpi/mpi_sizeofs.mod-stamp +/use_mpi_f08/*.stamp + # use_mpi_f08/ /use_mpi_f08/mpi_f08_compile_constants.f90 /use_mpi_f08/mpi_f08_compile_constants.f90.in @@ -42,3 +49,7 @@ /use_mpi_f08/wrappers_c/f08_cdesc.c /use_mpi_f08/wrappers_c/cdesc_proto.h +/env/mpifort +/env/mpifort.sh +/env/mpifort.bash +/env/fc_shlib.conf diff --git a/src/binding/fortran/Makefile.am b/src/binding/fortran/Makefile.am index 671cfa1585a..74ef237f25d 100644 --- a/src/binding/fortran/Makefile.am +++ b/src/binding/fortran/Makefile.am @@ -12,6 +12,7 @@ mpi_fc_modules = mpifort_convenience_libs = lib_LTLIBRARIES = +bin_SCRIPTS = noinst_LTLIBRARIES = noinst_HEADERS = nodist_include_HEADERS = @@ -28,7 +29,7 @@ lib_LTLIBRARIES += lib/lib@MPIFCLIBNAME@.la lib_lib@MPIFCLIBNAME@_la_SOURCES = modinc_HEADERS = $(mpi_fc_modules) lib_lib@MPIFCLIBNAME@_la_LDFLAGS = $(ABIVERSIONFLAGS) @FCLIB_LDFLAGS@ -lib_lib@MPIFCLIBNAME@_la_LIBADD = @mpi_libs@ $(mpifort_convenience_libs) +lib_lib@MPIFCLIBNAME@_la_LIBADD = $(mpifort_convenience_libs) if BUILD_F77_BINDING if BUILD_FC_BINDING @@ -43,3 +44,98 @@ lib_lib@MPIFCLIBNAME@_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=F77 \ $(LDFLAGS) -o $@ endif !BUILD_FC_BINDING endif BUILD_F77_BINDING + +# ---- install mpifort -------------------- + +bin_SCRIPTS += env/@MPIFORT_NAME@ + +if BUILD_BASH_SCRIPTS +shell = bash +else +shell = sh +endif + +env/@MPIFORT_NAME@: env/mpifort.$(shell) + cp -p env/mpifort.$(shell) env/@MPIFORT_NAME@ + +install-exec-hook: + for e in ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; do \ + if test -e $${e} ; then \ + sed -e 's|__PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__|${prefix}|g' \ + -e 's|__EXEC_PREFIX_TO_BE_FILLED_AT_INSTALL_TIME__|${exec_prefix}|g' \ + -e 's|__SYSCONFDIR_TO_BE_FILLED_AT_INSTALL_TIME__|${sysconfdir}|g' \ + -e 's|__INCLUDEDIR_TO_BE_FILLED_AT_INSTALL_TIME__|${includedir}|g' \ + -e 's|__LIBDIR_TO_BE_FILLED_AT_INSTALL_TIME__|${libdir}|g' \ + -e "s|__LIBS_TO_BE_FILLED_AT_INSTALL_TIME__|$$dependency_libs|g" \ + $${e} > $${e}.tmp ; \ + $(INSTALL_SCRIPT) $${e}.tmp $${e} ; \ + rm -f $${e}.tmp ; \ + fi ; \ + done ; +if INSTALL_MPIF90 + if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ + if test "@MPIFORT_NAME@" != "@MPIF90_NAME@" ; then \ + cd ${DESTDIR}${bindir} && ln -f -s @MPIFORT_NAME@ @MPIF90_NAME@ ; \ + fi; \ + fi; +endif INSTALL_MPIF90 +if INSTALL_MPIF77 + if test -e ${DESTDIR}${bindir}/@MPIFORT_NAME@ ; then \ + if test "@MPIFORT_NAME@" != "@MPIF77_NAME@" ; then \ + cd ${DESTDIR}${bindir} && ln -f -s @MPIFORT_NAME@ @MPIF77_NAME@ ; \ + fi; \ + fi; +endif INSTALL_MPIF77 + +# ---- install man pages -------------------- + +SUFFIXES = +doc1_src_txt = env/mpifort.txt + +#.PHONY: mandoc mandoc-local htmldoc htmldoc-local +SUFFIXES += .man-phony .html-phony .man1-phony .html1-phony .txt + +# "make V=1" support for our documentation recipes +doctextman_verbose = $(doctextman_verbose_$(V)) +doctextman_verbose_ = $(doctextman_verbose_$(AM_DEFAULT_VERBOSITY)) +doctextman_verbose_0 = @echo " DOCTEXTMAN " $@; +doctexthtml_verbose = $(doctexthtml_verbose_$(V)) +doctexthtml_verbose_ = $(doctexthtml_verbose_$(AM_DEFAULT_VERBOSITY)) +doctexthtml_verbose_0 = @echo " DOCTEXTHTML " $@; + +# Build dir paths where the man pages will be created. Will usually be +# overridden by MPICH make. +mandoc_path1=${DESTDIR}${sharedir}/man/man1 +mandoc_path3=${DESTDIR}${sharedir}/man/man3 +htmldoc_path1=${DESTDIR}${sharedir}/www/www1 +htmldoc_path3=${DESTDIR}${sharedir}/www/www3 +doctext_docnotes= + +.c.man-phony: + $(doctextman_verbose)$(DOCTEXT) -man -mpath $(mandoc_path3) -ext 3 \ + -heading HYDRA -quotefmt $(doctext_docnotes) $< +.c.html-phony: + $(doctexthtml_verbose)$(DOCTEXT) -html -mpath $(htmldoc_path3) \ + -heading HYDRA -quotefmt $(doctext_docnotes) $< + +.txt.man1-phony: + $(doctextman_verbose)$(DOCTEXT) -man -mpath $(mandoc_path1) -ext 1 \ + -heading HYDRA -quotefmt $(doctext_docnotes) $< +.txt.html1-phony: + $(doctexthtml_verbose)$(DOCTEXT) -html -mpath $(htmldoc_path1) \ + -heading HYDRA -quotefmt $(doctext_docnotes) $< + +# use mandoc-local target to force directory creation before running DOCTEXT +mandoc: + test -d $(mandoc_path1) || $(MKDIR_P) $(mandoc_path1) + test -d $(mandoc_path3) || $(MKDIR_P) $(mandoc_path3) + $(MAKE) $(AM_MAKEFLAGS) mandoc-local +mandoc-local: $(doc1_src_txt:.txt=.man1-phony) + +# use htmldoc-local target to force directory creation before running DOCTEXT +htmldoc: + test -d $(top_builddir)/www/www1 || $(MKDIR_P) $(top_builddir)/www/www1 + test -d $(top_builddir)/www/www3 || $(MKDIR_P) $(top_builddir)/www/www3 + $(MAKE) $(AM_MAKEFLAGS) htmldoc-local +htmldoc-local: $(doc1_src_txt:.txt=.html1-phony) + diff --git a/src/binding/fortran/autogen.sh b/src/binding/fortran/autogen.sh index b13b7fe605f..981645971d4 100755 --- a/src/binding/fortran/autogen.sh +++ b/src/binding/fortran/autogen.sh @@ -11,6 +11,7 @@ fi if test -n "$MPICH_CONFDB" ; then CONFARGS="-I $MPICH_CONFDB -vif" mkdir -p confdb + cp -v $MPICH_CONFDB/config.rpath confdb/ else if ! test -d confdb ; then echo "Missing confdb!" diff --git a/src/binding/fortran/configure.ac b/src/binding/fortran/configure.ac index fea2cf0ebaa..2a841c901a5 100644 --- a/src/binding/fortran/configure.ac +++ b/src/binding/fortran/configure.ac @@ -9,12 +9,40 @@ m4_include([version.m4]) AC_INIT([MPIFORT], MPICH_VERSION_m4, [discuss@mpich.org], [mpifort], [http://www.mpich.org/]) +MPICH_VERSION=MPICH_VERSION_m4 +AC_SUBST([MPICH_VERSION]) + +## Enable creation of libtool-style versioning or no versioning +AC_ARG_ENABLE(versioning, + [AS_HELP_STRING([--enable-versioning],[Enable library versioning])],, + [enable_versioning=yes]) + +if test "$enable_versioning" = "yes" ; then + ABIVERSIONFLAGS="-version-info libmpi_so_version_m4" +else + ABIVERSIONFLAGS="-avoid-version" +fi +AC_SUBST(ABIVERSIONFLAGS) + AC_CONFIG_AUX_DIR(confdb) AC_CONFIG_MACRO_DIR(confdb) -AM_INIT_AUTOMAKE([-Wall -Wno-portability-recursive foreign 1.12.3 silent-rules subdir-objects no-dist no-maintainer-mode]) +AM_INIT_AUTOMAKE([-Wall -Wno-portability-recursive foreign 1.12.3 silent-rules subdir-objects no-dist]) AM_MAINTAINER_MODE([disable]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +PAC_PREFIX_ALL_FLAGS(WRAPPER) + +# When build from MPICH, --with-mpi=mpich to build native mpich ABI, --with-mpi=abi to build MPI ABI +# When build stand-alone, set --with-mpi to path. TODO: check for system mpi. +AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi=dir], + [Specify the path where MPI is installed.])],,with_mpi=mpich) + +mpi_h= +AC_ARG_VAR([MPILIBNAME], [default: "mpi"]) +AC_ARG_VAR([LPMPILIBNAME], [default: ""]) +AC_SUBST(MPILIBNAME) +AC_SUBST(LPMPILIBNAME) + AC_CONFIG_HEADERS([mpifort_config.h]) AC_ARG_VAR([MPIFCLIBNAME],[can be used to override the name of the MPI fortran library (default: "${MPILIBNAME}fort")]) @@ -24,14 +52,6 @@ fi export MPIFCLIBNAME AC_SUBST(MPIFCLIBNAME) -# When build from MPICH, --with-mpi=mpich to build native mpich ABI, --with-mpi=abi to build MPI ABI -# When build stand-alone, set --with-mpi to path. TODO: check for system mpi. -AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi=dir], - [Specify the path where MPI is installed.])],,with_mpi=mpich) - -mpi_h= -mpi_libs= -AC_SUBST(mpi_libs) if test "$FROM_MPICH" = "yes" ; then if test "$WITH_MPI" = "mpich" ; then # We expect the following vars to be set from parent configure @@ -45,19 +65,35 @@ if test "$FROM_MPICH" = "yes" ; then else AC_MSG_ERROR([$FROM_MPICH is set but $WITH_MPI is not set!]) fi + if test -z "$MPILIBNAME" ; then + AC_MSG_ERROR([MPICH configure need export MPILIBNAME and LPMPILIBNAME]) + fi else if ! test "$with_mpi/include/mpi.h" ; then AC_MSG_ERROR([mpi.h not found in $with_mpi/include/]) fi PAC_APPEND_FLAG(-I${with_mpi}/include, [CPPFLAGS]) + PAC_APPEND_FLAG(-L${with_mpi}/lib, [LDFLAGS]) mpi_h="$with_mpi/include/mpi.h" if test -e "$with_mpi/lib/libmpi.so" ; then - PAC_APPEND_FLAG(-L${with_mpi}/lib, [LDFLAGS]) - mpi_libs="-lmpi" + if test -z "$MPILIBNAME" ; then + MPILIBNAME="mpi" + fi + if test -e "$with_mpi/lib/libpmpi.so" ; then + LPMPILIBNAME="-lpmpi" + fi elif test -e "$with_mpi/lib/libmpi_abi.so" ; then - PAC_APPEND_FLAG(-L${with_mpi}/lib, [LDFLAGS]) - mpi_libs="-lmpi_abi" + if test -z "$MPILIBNAME" ; then + MPILIBNAME="mpi_abi" + fi + if test -e "$with_mpi/lib/libpmpi_abi.so" ; then + LPMPILIBNAME="-lpmpi_abi" + fi + else + if test -z "$MPILIBNAME" ; then + AC_MSG_ERROR([Please export \$MPILIBNAME and \$LPMPILIBNAME]) + fi fi fi @@ -98,6 +134,12 @@ fi dnl enable_fortran is assumed to be true +# Add MPICHLIB_* to the appropriate flags +AC_ARG_VAR(MPICHLIB_FFLAGS, [extra FFLAGS used in building MPICH libraries]) +AC_ARG_VAR(MPICHLIB_FCFLAGS, [extra FCFLAGS used in building MPICH libraries]) +FFLAGS="$FFLAGS $MPICHLIB_FFLAGS" +FCFLAGS="$FCFLAGS $MPICHLIB_FCFLAGS" + # suppress default "-g -O2" from AC_PROG_FC : ${FCFLAGS=""} @@ -117,6 +159,38 @@ F77=$FC FFLAGS=$FCFLAGS AC_PROG_F77 +AM_PROG_AR + +LT_PREREQ([2.2.6]) +LT_INIT() + +dnl --enable-g will affect the flags +AC_ARG_ENABLE(g, +[ --enable-g=option - Control the level of debugging support. Accepted options: + none - No debugging + dbg - Add compiler flag -g + asan - Add compiler flag -fsanitize=address + ubsan - Add compiler flag -fsanitize=undefined + yes - same as "dbg" +],,enable_g=none) + +if test "$enable_g" = "yes"; then + enable_g=dbg +fi + +if test "$enable_g" = "dbg" ; then + PAC_APPEND_FLAG([-g],[FCFLAGS]) + PAC_APPEND_FLAG([-g],[WRAPPER_FCFLAGS]) +elif test "$enable_g" = "asan" ; then + PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[FCFLAGS]) + PAC_APPEND_FLAG([-O1 -g -fsanitize=address -fno-omit-frame-pointer],[WRAPPER_FCFLAGS]) + PAC_APPEND_FLAG([-fsanitize=address],[LDFLAGS]) +elif test "$enable_g" = "ubsan" ; then + PAC_APPEND_FLAG([-O1 -g -fsanitize=undefined -fno-omit-frame-pointer],[FCFLAGS]) + PAC_APPEND_FLAG([-O1 -g -fsanitize=undefined -fno-omit-frame-pointer],[WRAPPER_FCFLAGS]) + PAC_APPEND_FLAG([-fsanitize=undefined],[LDFLAGS]) +fi + AC_ARG_ENABLE([two-level-namespace], [AS_HELP_STRING([--enable-two-level-namespace], [(Darwin only) Do not use `-Wl,-flat_namespace` to @@ -221,14 +295,10 @@ if test "$enable_f08" = "yes" ; then AC_DEFINE(HAVE_F08_BINDING, 1, [Define to 1 if we have Fortran 2008 binding]) fi -AM_PROG_AR - -LT_PREREQ([2.2.6]) -LT_INIT() - -# generate fc_shlib.conf, needed by mpifort, used by MPICH +# generate rpath-related macros, needed by mpifort fc_shlib_conf=fc_shlib.conf PAC_COMPILER_SHLIB_FLAGS([FC],[$fc_shlib_conf]) +AC_SUBST_FILE([fc_shlib_conf]) PAC_CHECK_VISIBILITY AC_SUBST(VISIBILITY_CFLAGS) @@ -1017,7 +1087,34 @@ if test "$skip_gen_bindings" = no ; then fi fi +AC_SUBST(MPIFORT_NAME) +AC_SUBST(MPIF90_NAME) +AC_SUBST(MPIF77_NAME) +PAC_GET_EXENAME("mpifort", MPIFORT_NAME) +PAC_GET_EXENAME("mpif90", MPIF90_NAME) +PAC_GET_EXENAME("mpif77", MPIF77_NAME) + +# MPICH_MPIx_FLAGS are used by mpifort and friends. They are like +# WRAPPER flags, but these are provided by the user. +AC_SUBST(MPICH_MPIFORT_CPPFLAGS) +AC_SUBST(MPICH_MPIFORT_FCFLAGS) +AC_SUBST(MPICH_MPIFORT_LDFLAGS) +AC_SUBST(MPICH_MPIFORT_LIBS) + +AC_SUBST(MPICH_MPIF77_CPPFLAGS) +AC_SUBST(MPICH_MPIF77_FCFLAGS) +AC_SUBST(MPICH_MPIF77_LDFLAGS) +AC_SUBST(MPICH_MPIF77_LIBS) + +AM_CONDITIONAL([INSTALL_MPIF90],[true]) +AM_CONDITIONAL([INSTALL_MPIF77],[true]) + +PAC_CHECK_BASH +AM_CONDITIONAL([BUILD_BASH_SCRIPTS], [test "x$pac_cv_bash_works" = xyes]) + AC_CONFIG_FILES([Makefile \ + env/mpifort.sh \ + env/mpifort.bash \ localdefs]) if test "$enable_f77" = "yes" ; then diff --git a/src/env/mpifort.txt b/src/binding/fortran/env/mpifort.txt similarity index 100% rename from src/env/mpifort.txt rename to src/binding/fortran/env/mpifort.txt diff --git a/src/env/Makefile.mk b/src/env/Makefile.mk index 21858afbfe5..27a296ebd30 100644 --- a/src/env/Makefile.mk +++ b/src/env/Makefile.mk @@ -15,8 +15,6 @@ bin_PROGRAMS += src/env/mpichversion \ src_env_mpichversion_LDADD = lib/lib@MPILIBNAME@.la src_env_mpivars_LDADD = lib/lib@MPILIBNAME@.la -bin_SCRIPTS += src/env/mpifort - if INSTALL_MPICXX bin_SCRIPTS += src/env/mpicxx endif INSTALL_MPICXX @@ -32,18 +30,12 @@ src/env/mpicc: src/env/mpicc.$(shell) cp -p src/env/mpicc.$(shell) src/env/mpicc src/env/mpicxx: src/env/mpicxx.$(shell) cp -p src/env/mpicxx.$(shell) src/env/mpicxx -src/env/mpifort: src/env/mpifort.$(shell) - cp -p src/env/mpifort.$(shell) src/env/mpifort DISTCLEANFILES += $(top_builddir)/src/env/cc_shlib.conf \ $(top_builddir)/src/env/cxx_shlib.conf \ - $(top_builddir)/src/env/f77_shlib.conf \ - $(top_builddir)/src/env/fc_shlib.conf \ $(top_builddir)/src/env/mpicc \ - $(top_builddir)/src/env/mpicxx \ - $(top_builddir)/src/env/mpifort + $(top_builddir)/src/env/mpicxx wrapper_doc_src = src/env/mpicc.txt \ src/env/mpicxx.txt \ - src/env/mpifort.txt doc1_src += $(wrapper_doc_src) diff --git a/src/env/mpicc.def b/src/env/mpicc.def index 4755451c7aa..21ea72c74bb 100644 --- a/src/env/mpicc.def +++ b/src/env/mpicc.def @@ -22,9 +22,11 @@ page: mpicxx.bash.in $call mpicc_main, bash, cxx page: mpifort.sh.in + output_dir: ../binding/fortran/env $call mpicc_main, sh, fc page: mpifort.bash.in + output_dir: ../binding/fortran/env $call mpicc_main, bash, fc #---------------------------------------- From d71db5f8f0b91a241782e560235e2647b26bc8ea Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 12 May 2026 19:38:02 -0500 Subject: [PATCH 20/39] binding/fortran: add MPIX_Init_fortran Let MPI_Init initialize Fortran datatypes and inter-op functions. Both MPI_Abi_get_fortran_info and MPI_Abi_set_fortran_info will fail if MPI is not initialized. There are MPI functions can be called before MPI is initialized and there is no good way of testing it -- MPI_Initialized does not work with MPI_Session_init -- we simply return if MPI_Abi_get_fortran_info return an error assuming it is due to MPI uninitialized. --- confdb/config.rpath | 9 +++++++++ configure.ac | 4 ++++ maint/local_python/binding_f77.py | 10 ++++------ src/binding/cxx/buildiface | 2 +- src/binding/fortran/mpif_h/setbot.c | 6 ------ src/env/mpicc.def | 15 +++++++++++++++ src/mpi/init/mpir_init.c | 11 +++++++++++ test/mpi/cxx/datatype/Makefile.am | 3 +++ test/mpi/datatype/Makefile.am | 1 + 9 files changed, 48 insertions(+), 13 deletions(-) diff --git a/confdb/config.rpath b/confdb/config.rpath index 9a8d62e98be..680ecdb1680 100755 --- a/confdb/config.rpath +++ b/confdb/config.rpath @@ -229,9 +229,13 @@ if test "$with_gnu_ld" = yes; then if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then # use --enable-new-dtags for RUNPATH support, which is required for # switching between ABI compatible libraries at runtime. + + # use --no-as-needed for adding a library e.g. -lmpifort if test "$GCC" = yes; then enable_dtags_flag="${wl}--enable-new-dtags" disable_dtags_flag="${wl}--disable-new-dtags" + # note: the end space is important since we use it as "${no_as_needed}-lmpifort" + no_as_needed="${wl}--no-as-needed " else case $cc_basename in ifort* | ifx*) enable_dtags_flag="${wl}--enable-new-dtags" @@ -380,6 +384,8 @@ else ;; darwin* | rhapsody*) hardcode_direct=no + # note: the library must follow the flag without space, e.g. "-Wl,-needed-lmpifort" + no_as_needed="-Wl,-needed" if { case $cc_basename in ifort* | ifx*) true;; *) test "$GCC" = yes;; esac; }; then : else @@ -705,6 +711,9 @@ hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" enable_dtags_flag="$enable_dtags_flag" disable_dtags_flag="$disable_dtags_flag" +# Flag to add an extra library +no_as_needed="$no_as_needed" + # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator="$hardcode_libdir_separator" diff --git a/configure.ac b/configure.ac index 8d2f432a600..3d58b91d569 100644 --- a/configure.ac +++ b/configure.ac @@ -996,6 +996,10 @@ if test "$NEEDSPLIB" = "yes" ; then VISIBILITY_CFLAGS="" fi +# dlopen and dlsym +AC_SEARCH_LIBS([dlopen],[dl dld], + [AC_DEFINE(HAVE_DLOPEN,1,[Define if dlopen is available])]) + # MPL m4_define([mpl_embedded_dir],[src/mpl]) PAC_CONFIG_MPL diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 2a3c2634904..8edcddad63b 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -928,11 +928,8 @@ def process_func_parameters(): # these are all special functions, e.g. MPI_Wtime, MPI_Wtick, MPI_Aint_add, MPI_Aint_diff G.out.append("return %s(%s);" % (c_func_name, ', '.join(c_arg_list_A))) else: - # If it's MPI_Init etc, run mpirinitf_ at the end so it can call MPI_Abi_set_fortran_info etc. - # Otherwise, call it first so common symbols can work. - # FIXME: need check name mangling before call mpirinitf_() - is_init = re.match(r'(MPI_Init|MPI_Init_thread|MPI_Session_init)', func['name'], re.IGNORECASE) - if not is_init: + # functions that can be called before MPI_Init are also not depend on mpirinitf_. + if not ('skip' in func and RE.search(r'initcheck', func['skip'], re.IGNORECASE)): G.out.append("if (MPIR_F_NeedInit) {mpirinitf_();}") G.out.append("") @@ -964,9 +961,10 @@ def process_func_parameters(): G.out.append(l) # call mpirinitf_ after MPI_Init + is_init = re.match(r'(MPI_Init|MPI_Init_thread|MPI_Session_init)$', func['name'], re.IGNORECASE) if is_init: G.out.append("") - G.out.append("mpirinitf_();") + G.out.append("if (MPIR_F_NeedInit) {mpirinitf_();}") dump_mpi_decl_end() diff --git a/src/binding/cxx/buildiface b/src/binding/cxx/buildiface index 3b2b8e55cc6..4052fad8b0f 100755 --- a/src/binding/cxx/buildiface +++ b/src/binding/cxx/buildiface @@ -2056,7 +2056,7 @@ sub build_specials { open( $OUTFD, ">${filename}.new" ) || die "Cannot open ${filename}.new\n"; $files[$#files+1] = "initcxx.cxx"; &print_header; - print $OUTFD "#include \"mpichconf.h\"\n"; # Requires for HAVE_FORTRAN_BINDING + print $OUTFD "#include \"mpichconf.h\"\n"; print $OUTFD "#include \"mpi_mpich.h\"\n"; print $OUTFD "#include \n"; # Required for pcontrol diff --git a/src/binding/fortran/mpif_h/setbot.c b/src/binding/fortran/mpif_h/setbot.c index a6be14db5f1..e5c7e11a750 100644 --- a/src/binding/fortran/mpif_h/setbot.c +++ b/src/binding/fortran/mpif_h/setbot.c @@ -70,12 +70,6 @@ FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, MPI_F_ARGVS_NULL = asn; MPIR_F_MPI_WEIGHTS_EMPTY = we; - int mpi_is_initialized = 0; - MPI_Initialized(&mpi_is_initialized); - if (!mpi_is_initialized) { - return; - } - MPIX_Init_fortran(); MPIR_F_NeedInit = 0; diff --git a/src/env/mpicc.def b/src/env/mpicc.def index 21ea72c74bb..d5739ac71b6 100644 --- a/src/env/mpicc.def +++ b/src/env/mpicc.def @@ -213,6 +213,7 @@ subcode: parse_args $call parse_arg_cases $(if:cc=cc or cc=cxx) $call parse_delay_libs + $call parse_need_fortran $call parse_arg_help # fc args such as -I*, -D* need be in between the case for *'*|*"*) and *) &call parse_other_args_$(sh) @@ -368,6 +369,12 @@ subcode: parse_args &call case, -lcuda|-lcudart|-lze_loader delay_libs="$delay_libs $arg" + subcode: parse_need_fortran + $(block:parse_args_init) + need_fortran= + &call case, -fortran + need_fortran="yes" + subcode: show_help NC=`echo "$$(CC)" | sed 's%\/% %g' | awk '{print $NF}' -` if [ -f "$sysconfdir/mpixxx_opts.conf" ] ; then @@ -483,6 +490,14 @@ subcode: set_final_vars mpi_libs_shared="-l@MPILIBNAME@ @LPMPILIBNAME@" mpi_libs_static="$libdir/lib@MPILIBNAME@.a @LPMPILIBNAME@" + $(if:cc=cc or cc=cxx) + if test "$need_fortran" = "yes" ; then + mpi_libs_shared="$no_as_needed-lmpifort $mpi_libs_shared" + \x23 dlsym won't work with static linking but at least we make it available + if test -e "$libdir/libmpifort.a" ; then + mpi_libs_static="$libdir/libmpifort.a $mpi_libs_static" + fi + fi $(if:cc=fc) $call patch_final_fcflags diff --git a/src/mpi/init/mpir_init.c b/src/mpi/init/mpir_init.c index 4a2ce338c4c..096e1768c3b 100644 --- a/src/mpi/init/mpir_init.c +++ b/src/mpi/init/mpir_init.c @@ -7,6 +7,7 @@ #include "mpir_info.h" #include "mpi_init.h" #include +#include #include "mpir_async_things.h" /* @@ -105,6 +106,9 @@ === END_MPI_T_CVAR_INFO_BLOCK === */ +/* Used to dlsym MPIX_Init_fortran */ +typedef void (*init_func_t) (void); + /* MPIR_world_model_state tracks so we only init and finalize once in world model */ MPL_atomic_int_t MPIR_world_model_state = MPL_ATOMIC_INT_T_INITIALIZER(0); @@ -343,6 +347,13 @@ int MPII_Init_thread(int *argc, char ***argv, int user_required, int *provided, MPIR_ThreadInfo.isThreaded = (MPIR_ThreadInfo.thread_provided == MPI_THREAD_MULTIPLE); #endif +#ifdef HAVE_DLOPEN + init_func_t func = (init_func_t) dlsym(RTLD_DEFAULT, "MPIX_Init_fortran"); + if (func) { + func(); + } +#endif + fn_exit: if (is_world_model) { if (!MPIR_Process.comm_world) { diff --git a/test/mpi/cxx/datatype/Makefile.am b/test/mpi/cxx/datatype/Makefile.am index b540bdc704b..a3c6d97bec7 100644 --- a/test/mpi/cxx/datatype/Makefile.am +++ b/test/mpi/cxx/datatype/Makefile.am @@ -12,3 +12,6 @@ typecntsx_SOURCES = typecntsx.cxx typenamex_SOURCES = typenamex.cxx typemiscx_SOURCES = typemiscx.cxx packsizex_SOURCES = packsizex.cxx + +typenamex_LDFLAGS = -fortran +typemiscx_LDFLAGS = -fortran diff --git a/test/mpi/datatype/Makefile.am b/test/mpi/datatype/Makefile.am index 4fae95ac1a3..8584b7ae9f0 100644 --- a/test/mpi/datatype/Makefile.am +++ b/test/mpi/datatype/Makefile.am @@ -100,3 +100,4 @@ $(top_builddir)/util/libdtypes.la: sendrecvt2_LDADD = $(LDADD) $(LDADDDATA) sendrecvt4_LDADD = $(LDADD) $(LDADDDATA) +typename_LDFLAGS = -fortran From 0af37fb83755a793647ca329274e1d2e44858998 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 13 May 2026 21:39:17 -0500 Subject: [PATCH 21/39] fortran/f08: call MPIX_Init_fortran The mpi_f08 module also need call MPIX_Init_fortran to initialize the datatypes. --- maint/local_python/binding_f08.py | 7 ++++++- .../fortran/use_mpi_f08/mpi_c_interface_glue.f90 | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index 65f24986686..d8ca0429954 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -182,6 +182,8 @@ def dump_f08_wrappers_f(func, is_large): status_count = "" is_alltoallvw = False + uses['MPIR_Init_fortran'] = 1 + if need_cdesc(func): f08ts_name = get_f08ts_name(func, is_large) c_func_name = get_cdesc_name(func, is_large) @@ -710,6 +712,9 @@ def dump_call(s, check_int_kind): else: ret = 'res' + if not ('skip' in func and RE.search(r'initcheck', func['skip'], re.IGNORECASE)): + G.out.append("call MPIR_Init_fortran()") + if need_check_int_kind and G.opts['fint-size'] == G.opts['cint-size']: if is_alltoallvw: dump_F_if_open("c_associated(c_loc(sendbuf), c_loc(MPI_IN_PLACE))") @@ -920,7 +925,7 @@ def dump_F_uses(uses): for a in uses: if re.match(r'c_(int|char|ptr|loc|associated|null_ptr|null_funptr|funptr|funloc)', a, re.IGNORECASE): iso_c_binding_list.append(a) - elif re.match(r'MPIR_.*string_(f2c|c2f)', a): + elif re.match(r'MPIR_.*string_(f2c|c2f)|MPIR_Init_fortran', a): mpi_c_list_3.append(a) elif re.match(r'MPI_\w+_(function|FN|FN_NULL)(_c)?$', a, re.IGNORECASE): mpi_f08_list_4.append(a) diff --git a/src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 b/src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 index b6ce9a6b5da..27a08b1f162 100644 --- a/src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 +++ b/src/binding/fortran/use_mpi_f08/mpi_c_interface_glue.f90 @@ -9,11 +9,26 @@ module mpi_c_interface_glue implicit none +logical, save :: is_initialized = .false. +interface + subroutine MPIX_Init_fortran() bind(c, name="MPIX_Init_fortran") + implicit none + end subroutine +end interface + +public :: MPIR_Init_fortran public :: MPIR_Fortran_string_f2c public :: MPIR_Fortran_string_c2f contains +subroutine MPIR_Init_fortran() + implicit none + if (is_initialized) return + call MPIX_Init_fortran() + is_initialized = .true. +end subroutine MPIR_Init_fortran + ! Copy Fortran string to C character array, assuming the C array is one-char ! longer for the terminating null char. ! fstring : the Fortran input string From bee42595ea6d10e1c75a205d03bf99574f78c408 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 20 May 2026 14:05:01 -0500 Subject: [PATCH 22/39] fortran/f08: always enable file routines We handle ENABLE_ROMIO at the C binding layer. --- maint/local_python/binding_f08.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index d8ca0429954..8d2730e6ffb 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -130,15 +130,6 @@ def dump_p(p): tlist = split_line_with_break(s, "", 80) G.out.extend(tlist) G.out.append("{") - if re.match(r'MPI_File_', func['name']): - if is_large: - # File large functions are not there yet - G.out.append(" return MPI_ERR_INTERN;") - G.out.append("}") - return - G.out.append("#ifndef HAVE_ROMIO") - G.out.append(" return MPI_ERR_INTERN;") - G.out.append("#else") G.out.append("INDENT"); G.out.append("int err = MPI_SUCCESS;") if re.match(r'MPI_F_sync_reg', func['name'], re.IGNORECASE): @@ -156,8 +147,6 @@ def dump_p(p): G.out.append(l) G.out.append("return err;") G.out.append("DEDENT") - if re.match(r'MPI_File_', func['name']): - G.out.append("#endif") G.out.append("}") def dump_f08_wrappers_f(func, is_large): From 2177f3301d8856485042c8d1db6aa7fdda13cd3b Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 20 May 2026 17:22:26 -0500 Subject: [PATCH 23/39] test: fix f08/info/infocrenvf90.f90 Use mpi_f08 instead of mpif.h or it won't compile. --- test/mpi/f08/info/infocrenvf90.f90 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/mpi/f08/info/infocrenvf90.f90 b/test/mpi/f08/info/infocrenvf90.f90 index a3dbe84d1cf..145881264cf 100644 --- a/test/mpi/f08/info/infocrenvf90.f90 +++ b/test/mpi/f08/info/infocrenvf90.f90 @@ -7,9 +7,9 @@ ! Testing MPI_Info_create_env. ! subroutine test_info ( i1, i2, errs ) - implicit none - include 'mpif.h' - integer ierr, i, i1, i2, vl, errs + use mpi_f08 + Type(MPI_Info) i1, i2 + integer ierr, i, vl, errs character*(MPI_MAX_INFO_KEY) value1, value2 character*(MPI_MAX_INFO_KEY) keys(9) logical f1, f2 @@ -50,10 +50,9 @@ subroutine test_info ( i1, i2, errs ) end program main - implicit none - include 'mpif.h' - integer i1, i2 - integer ierr, errs + use mpi_f08 + Type(MPI_Info):: i1, i2 + integer:: ierr, errs ! errs = 0 From 2efc888aa7dc4ae16cd393dcfb2ca000952792e3 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Fri, 22 May 2026 21:57:12 -0500 Subject: [PATCH 24/39] python/f08: MPI_Info_create_env need argc and argv The C interface for MPI_Info_create_env has extra argc and argv parameter. This was uncaught due to previous test/f08/info/infocrenvf90 didn't use mpi_f08. --- maint/local_python/binding_f08.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index 8d2730e6ffb..99b433bd29c 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -187,6 +187,12 @@ def dump_f08_wrappers_f(func, is_large): arg_list_2.append("c_null_ptr") arg_list_2.append("c_null_ptr") uses['c_null_ptr'] = 1 + elif RE.match(r'MPI_Info_create_env$', func['name'], re.IGNORECASE): + arg_list_1.append("0") + arg_list_1.append("c_null_ptr") + arg_list_2.append("0") + arg_list_2.append("c_null_ptr") + uses['c_null_ptr'] = 1 elif RE.match(r'mpi_i?alltoall[vw]', func['name'], re.IGNORECASE): # Need check MPI_IN_PLACE in order to skip accessing sender arrays is_alltoallvw = True @@ -787,6 +793,13 @@ def dump_interface_function(func, name, c_name, is_large): decl_list.append("TYPE(c_ptr), VALUE, INTENT(in) :: argc") decl_list.append("TYPE(c_ptr), VALUE, INTENT(in) :: argv") uses['c_ptr'] = 1 + elif RE.match(r'MPI_Info_create_env$', func['name'], re.IGNORECASE): + f_param_list.append("argc") + f_param_list.append("argv") + decl_list.append("INTEGER(c_int), VALUE, INTENT(in) :: argc") + decl_list.append("TYPE(c_ptr), VALUE, INTENT(in) :: argv") + uses['c_int'] = 1 + uses['c_ptr'] = 1 # ---- for p in func['parameters']: From 551c5d166fc67da8b77d47dbab034d633d622dd3 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 25 May 2026 09:37:36 -0500 Subject: [PATCH 25/39] include: split mpi_fortran.h from mpi.h Separate all fortran inter-op related declarations to mpi_fortran.h. MPI_F_{STATUS_SIZE,SOURCE,TAG,ERROR} are still defined in mpi_mpich.h.in since they describes the C struct MPI_Status. --- src/env/mpicc.def | 13 +++--- src/include/Makefile.mk | 3 +- src/include/mpi_fortran.h | 82 ++++++++++++++++++++++++++++++++++++++ src/include/mpi_mpich.h.in | 78 ++---------------------------------- 4 files changed, 94 insertions(+), 82 deletions(-) create mode 100644 src/include/mpi_fortran.h diff --git a/src/env/mpicc.def b/src/env/mpicc.def index d5739ac71b6..5ee62f481d3 100644 --- a/src/env/mpicc.def +++ b/src/env/mpicc.def @@ -491,13 +491,14 @@ subcode: set_final_vars mpi_libs_shared="-l@MPILIBNAME@ @LPMPILIBNAME@" mpi_libs_static="$libdir/lib@MPILIBNAME@.a @LPMPILIBNAME@" $(if:cc=cc or cc=cxx) - if test "$need_fortran" = "yes" ; then - mpi_libs_shared="$no_as_needed-lmpifort $mpi_libs_shared" - \x23 dlsym won't work with static linking but at least we make it available - if test -e "$libdir/libmpifort.a" ; then - mpi_libs_static="$libdir/libmpifort.a $mpi_libs_static" + if test "$need_fortran" = "yes" ; then + final_cppflags="${final_cppflags} -DMPICH_ENABLE_FORTRAN" + mpi_libs_shared="$no_as_needed-lmpifort $mpi_libs_shared" + \x23 dlsym won't work with static linking but at least we make it available + if test -e "$libdir/libmpifort.a" ; then + mpi_libs_static="$libdir/libmpifort.a $mpi_libs_static" + fi fi - fi $(if:cc=fc) $call patch_final_fcflags diff --git a/src/include/Makefile.mk b/src/include/Makefile.mk index b8594d8a35f..619281dfce0 100644 --- a/src/include/Makefile.mk +++ b/src/include/Makefile.mk @@ -7,7 +7,8 @@ nodist_include_HEADERS += src/include/mpi.h if !BUILD_ABI_LIB -include_HEADERS += src/include/mpi_proto.h +include_HEADERS += src/include/mpi_proto.h \ + src/include/mpi_fortran.h endif !BUILD_ABI_LIB # need mpix.h for either ABIs diff --git a/src/include/mpi_fortran.h b/src/include/mpi_fortran.h new file mode 100644 index 00000000000..85c88310236 --- /dev/null +++ b/src/include/mpi_fortran.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +#ifdef MPI_FINT_CTYPE +typedef MPI_FINT_CTYPE MPI_Fint; +#else +typedef int MPI_Fint; +#endif + +/* See 4.12.5 for MPI_F_STATUS(ES)_IGNORE */ +extern MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUS_IGNORE MPICH_API_PUBLIC; +extern MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUSES_IGNORE MPICH_API_PUBLIC; +/* The annotation MPIU_DLL_SPEC to the extern statements is used + as a hook for systems that require C extensions to correctly construct + DLLs, and is defined as an empty string otherwise + */ + +/* C type for MPI_STATUS in F08. + The field order should match that in mpi_f08_types.f90, and mpi_c_interface_types.f90. + */ +typedef struct { + MPI_Fint count_lo; + MPI_Fint count_hi_and_cancelled; + MPI_Fint MPI_SOURCE; + MPI_Fint MPI_TAG; + MPI_Fint MPI_ERROR; +} MPI_F08_status; + +/* Provided in libmpifort.so */ +extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUS_IGNORE MPICH_API_PUBLIC; +extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUSES_IGNORE MPICH_API_PUBLIC; + +/* The f2c and c2f APIs exist as real functions, but these macros allows + * for backward MPICH ABI compatibility. + */ +/* exclude these macros from MPICH internal */ +#ifndef MPICHCONF_H_INCLUDED +#define MPI_Comm_c2f(comm) (MPI_Fint)(comm) +#define MPI_Comm_f2c(comm) (MPI_Comm)(comm) +#define MPI_Type_c2f(datatype) (MPI_Fint)(datatype) +#define MPI_Type_f2c(datatype) (MPI_Datatype)(datatype) +#define MPI_Group_c2f(group) (MPI_Fint)(group) +#define MPI_Group_f2c(group) (MPI_Group)(group) +#define MPI_Info_c2f(info) (MPI_Fint)(info) +#define MPI_Info_f2c(info) (MPI_Info)(info) +#define MPI_Request_f2c(request) (MPI_Request)(request) +#define MPI_Request_c2f(request) (MPI_Fint)(request) +#define MPI_Op_c2f(op) (MPI_Fint)(op) +#define MPI_Op_f2c(op) (MPI_Op)(op) +#define MPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) +#define MPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) +#define MPI_Win_c2f(win) (MPI_Fint)(win) +#define MPI_Win_f2c(win) (MPI_Win)(win) +#define MPI_Message_c2f(msg) ((MPI_Fint)(msg)) +#define MPI_Message_f2c(msg) ((MPI_Message)(msg)) +#define MPI_Session_c2f(session) (MPI_Fint)(session) +#define MPI_Session_f2c(session) (MPI_Session)(session) + +/* PMPI versions of the handle transfer functions. See section 4.17 */ +#define PMPI_Comm_c2f(comm) (MPI_Fint)(comm) +#define PMPI_Comm_f2c(comm) (MPI_Comm)(comm) +#define PMPI_Type_c2f(datatype) (MPI_Fint)(datatype) +#define PMPI_Type_f2c(datatype) (MPI_Datatype)(datatype) +#define PMPI_Group_c2f(group) (MPI_Fint)(group) +#define PMPI_Group_f2c(group) (MPI_Group)(group) +#define PMPI_Info_c2f(info) (MPI_Fint)(info) +#define PMPI_Info_f2c(info) (MPI_Info)(info) +#define PMPI_Request_f2c(request) (MPI_Request)(request) +#define PMPI_Request_c2f(request) (MPI_Fint)(request) +#define PMPI_Op_c2f(op) (MPI_Fint)(op) +#define PMPI_Op_f2c(op) (MPI_Op)(op) +#define PMPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) +#define PMPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) +#define PMPI_Win_c2f(win) (MPI_Fint)(win) +#define PMPI_Win_f2c(win) (MPI_Win)(win) +#define PMPI_Message_c2f(msg) ((MPI_Fint)(msg)) +#define PMPI_Message_f2c(msg) ((MPI_Message)(msg)) +#define PMPI_Session_c2f(session) (MPI_Fint)(session) +#define PMPI_Session_f2c(session) (MPI_Session)(session) +#endif diff --git a/src/include/mpi_mpich.h.in b/src/include/mpi_mpich.h.in index eea449f60de..c82b0d6dc96 100644 --- a/src/include/mpi_mpich.h.in +++ b/src/include/mpi_mpich.h.in @@ -363,11 +363,6 @@ typedef int MPI_Info; #ifndef MPICH_BUILD_MPI_ABI /* Definitions that are determined by configure. */ -#ifdef MPI_FINT_CTYPE -typedef MPI_FINT_CTYPE MPI_Fint; -#else -typedef int MPI_Fint; -#endif typedef @MPI_AINT@ MPI_Aint; typedef @MPI_COUNT@ MPI_Count; @@ -388,35 +383,12 @@ typedef struct MPI_Status { int MPI_ERROR; } MPI_Status; -/* See 4.12.5 for MPI_F_STATUS(ES)_IGNORE */ -extern MPIU_DLL_SPEC MPI_Fint * MPI_F_STATUS_IGNORE MPICH_API_PUBLIC; -extern MPIU_DLL_SPEC MPI_Fint * MPI_F_STATUSES_IGNORE MPICH_API_PUBLIC; -/* The annotation MPIU_DLL_SPEC to the extern statements is used - as a hook for systems that require C extensions to correctly construct - DLLs, and is defined as an empty string otherwise - */ - -/* C type for MPI_STATUS in F08. - The field order should match that in mpi_f08_types.f90, and mpi_c_interface_types.f90. - */ -typedef struct { - MPI_Fint count_lo; - MPI_Fint count_hi_and_cancelled; - MPI_Fint MPI_SOURCE; - MPI_Fint MPI_TAG; - MPI_Fint MPI_ERROR; -} MPI_F08_status; - /* MPI 4 added following constants to allow access F90 STATUS as an array of MPI_Fint */ #define MPI_F_STATUS_SIZE 5 #define MPI_F_SOURCE 2 #define MPI_F_TAG 3 #define MPI_F_ERROR 4 -/* Provided in libmpifort.so */ -extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUS_IGNORE MPICH_API_PUBLIC; -extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUSES_IGNORE MPICH_API_PUBLIC; - #endif /* MPICH_BUILD_MPI_ABI */ #ifdef MPICH_DEFINE_ATTR_TYPE_TYPES @@ -1020,53 +992,9 @@ int QMPI_Get_calling_address(QMPI_Context context, void **address) MPICH_API_PUB #include #include -/* The f2c and c2f APIs exist as real functions, but these macros allows - * for backward MPICH ABI compatibility. - */ -/* exclude these macros from MPICH internal */ -#ifndef MPICHCONF_H_INCLUDED -#define MPI_Comm_c2f(comm) (MPI_Fint)(comm) -#define MPI_Comm_f2c(comm) (MPI_Comm)(comm) -#define MPI_Type_c2f(datatype) (MPI_Fint)(datatype) -#define MPI_Type_f2c(datatype) (MPI_Datatype)(datatype) -#define MPI_Group_c2f(group) (MPI_Fint)(group) -#define MPI_Group_f2c(group) (MPI_Group)(group) -#define MPI_Info_c2f(info) (MPI_Fint)(info) -#define MPI_Info_f2c(info) (MPI_Info)(info) -#define MPI_Request_f2c(request) (MPI_Request)(request) -#define MPI_Request_c2f(request) (MPI_Fint)(request) -#define MPI_Op_c2f(op) (MPI_Fint)(op) -#define MPI_Op_f2c(op) (MPI_Op)(op) -#define MPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) -#define MPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) -#define MPI_Win_c2f(win) (MPI_Fint)(win) -#define MPI_Win_f2c(win) (MPI_Win)(win) -#define MPI_Message_c2f(msg) ((MPI_Fint)(msg)) -#define MPI_Message_f2c(msg) ((MPI_Message)(msg)) -#define MPI_Session_c2f(session) (MPI_Fint)(session) -#define MPI_Session_f2c(session) (MPI_Session)(session) - -/* PMPI versions of the handle transfer functions. See section 4.17 */ -#define PMPI_Comm_c2f(comm) (MPI_Fint)(comm) -#define PMPI_Comm_f2c(comm) (MPI_Comm)(comm) -#define PMPI_Type_c2f(datatype) (MPI_Fint)(datatype) -#define PMPI_Type_f2c(datatype) (MPI_Datatype)(datatype) -#define PMPI_Group_c2f(group) (MPI_Fint)(group) -#define PMPI_Group_f2c(group) (MPI_Group)(group) -#define PMPI_Info_c2f(info) (MPI_Fint)(info) -#define PMPI_Info_f2c(info) (MPI_Info)(info) -#define PMPI_Request_f2c(request) (MPI_Request)(request) -#define PMPI_Request_c2f(request) (MPI_Fint)(request) -#define PMPI_Op_c2f(op) (MPI_Fint)(op) -#define PMPI_Op_f2c(op) (MPI_Op)(op) -#define PMPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) -#define PMPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) -#define PMPI_Win_c2f(win) (MPI_Fint)(win) -#define PMPI_Win_f2c(win) (MPI_Win)(win) -#define PMPI_Message_c2f(msg) ((MPI_Fint)(msg)) -#define PMPI_Message_f2c(msg) ((MPI_Message)(msg)) -#define PMPI_Session_c2f(session) (MPI_Fint)(session) -#define PMPI_Session_f2c(session) (MPI_Session)(session) +/* include fortran inter-op header if needed */ +#ifdef MPICH_ENABLE_FORTRAN +#include #endif #endif /* MPICH_BUILD_MPI_ABI */ From 6437ff4839b66a76936e0ace161db47691f0164f Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 26 May 2026 12:17:35 -0500 Subject: [PATCH 26/39] mpir: remove prototypes for fortran callbacks The C library no longer handle Fortran callbacks directly. The MPI Fortran binding should provide proxy to handle the callbacks. --- src/include/mpir_attr.h | 8 -------- src/include/mpir_errhandler.h | 1 - src/include/mpir_op.h | 1 - src/include/mpir_request.h | 12 ------------ 4 files changed, 22 deletions(-) diff --git a/src/include/mpir_attr.h b/src/include/mpir_attr.h index d9bd1fb8eaf..6ef8fb4d0bc 100644 --- a/src/include/mpir_attr.h +++ b/src/include/mpir_attr.h @@ -35,11 +35,6 @@ MPII_Attr_copy_c_proxy(MPI_Comm_copy_attr_function * user_function, int keyval, void *extra_state, void *attrib, void **attrib_copy, int *flag); typedef struct copy_function { - int (*C_CopyFunction) (int, int, void *, void *, void *, int *); - void (*F77_CopyFunction) (MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, - MPI_Fint *, MPI_Fint *, MPI_Fint *); - void (*F90_CopyFunction) (MPI_Fint *, MPI_Fint *, MPI_Aint *, MPI_Aint *, - MPI_Aint *, MPI_Fint *, MPI_Fint *); /* The generic lang-independent user_function and proxy will * replace the lang dependent copy funcs above * Currently the lang-indpendent funcs are used only for keyvals @@ -73,9 +68,6 @@ MPII_Attr_delete_c_proxy(MPI_Comm_delete_attr_function * user_function, int handle, int keyval, void *attrib, void *extra_state); typedef struct delete_function { - int (*C_DeleteFunction) (int, int, void *, void *); - void (*F77_DeleteFunction) (MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *); - void (*F90_DeleteFunction) (MPI_Fint *, MPI_Fint *, MPI_Aint *, MPI_Aint *, MPI_Fint *); /* The generic lang-independent user_function and proxy will * replace the lang dependent copy funcs above * Currently the lang-indpendent funcs are used only for keyvals diff --git a/src/include/mpir_errhandler.h b/src/include/mpir_errhandler.h index e1f983e47d6..c8b8b4fb102 100644 --- a/src/include/mpir_errhandler.h +++ b/src/include/mpir_errhandler.h @@ -37,7 +37,6 @@ typedef union errhandler_fn { MPIX_File_errhandler_function_x *X_File_Handler_function; MPIX_Win_errhandler_function_x *X_Win_Handler_function; MPIX_Session_errhandler_function_x *X_Session_Handler_function; - void (*F77_Handler_function) (MPI_Fint *, MPI_Fint *); } errhandler_fn; /*S diff --git a/src/include/mpir_op.h b/src/include/mpir_op.h index d4f84c93c9c..9b22e91d2a1 100644 --- a/src/include/mpir_op.h +++ b/src/include/mpir_op.h @@ -87,7 +87,6 @@ typedef union MPIR_User_function { void (*c_large_function) (const void *, void *, const MPI_Count *, const ABI_Datatype *); void (*c_x_function) (void *, void *, MPI_Count, ABI_Datatype, void *); #endif - void (*f77_function) (const void *, void *, const MPI_Fint *, const MPI_Fint *); } MPIR_User_function; /* FIXME: Should there be "restrict" in the definitions above, e.g., (*c_function)(const void restrict * , void restrict *, ...)? */ diff --git a/src/include/mpir_request.h b/src/include/mpir_request.h index c88c212bfa5..6c8889e8433 100644 --- a/src/include/mpir_request.h +++ b/src/include/mpir_request.h @@ -73,13 +73,6 @@ typedef enum MPIR_Request_kind_t { #define MPIR_REQUEST_NULL_RECV (MPI_Request)0x6c000010 -/* This currently defines a single structure type for all requests. - Eventually, we may want a union type, as used in MPICH-1 */ -/* Typedefs for Fortran generalized requests */ -typedef void (MPIR_Grequest_f77_cancel_function) (void *, MPI_Fint *, MPI_Fint *); -typedef void (MPIR_Grequest_f77_free_function) (void *, MPI_Fint *); -typedef void (MPIR_Grequest_f77_query_function) (void *, MPI_Fint *, MPI_Fint *); - /* vtable-ish structure holding generalized request function pointers and other * state. Saves ~48 bytes in pt2pt requests on many platforms. */ struct MPIR_Grequest_fns { @@ -89,11 +82,6 @@ struct MPIR_Grequest_fns { MPI_Grequest_free_function *free_fn; MPI_Grequest_query_function *query_fn; } C; - struct { - MPIR_Grequest_f77_cancel_function *cancel_fn; - MPIR_Grequest_f77_free_function *free_fn; - MPIR_Grequest_f77_query_function *query_fn; - } F; } U; MPIX_Grequest_poll_function *poll_fn; MPIX_Grequest_wait_function *wait_fn; From 744f96ca664666108207d1e0023778247dbbc673 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 26 May 2026 10:44:28 -0500 Subject: [PATCH 27/39] binding/fortran: move interop interface to mpifort Move all the fortran inter-op C API to libmpifort.so and only installed by the mpifort package. --- configure.ac | 9 --------- maint/gen_binding_c.py | 4 ++++ src/binding/cxx/buildiface | 1 - src/binding/fortran/Makefile.am | 2 +- src/binding/fortran/configure.ac | 10 ++++++---- src/binding/fortran/mpif_h/Makefile.mk | 5 ++++- .../misc => binding/fortran/mpif_h}/f2c_impl.c | 6 +----- src/binding/fortran/mpif_h/mpi_fortimpl.h | 12 ++++++++++-- .../fortran/mpif_h/mpi_fortran.h.in} | 16 ++++++++-------- src/binding/fortran/mpif_h/setbot.c | 13 ++++++++----- src/include/Makefile.mk | 3 +-- src/include/mpi_mpich.h.in | 2 -- src/mpi/init/globals.c | 15 --------------- src/mpi/misc/Makefile.mk | 1 - 14 files changed, 43 insertions(+), 56 deletions(-) rename src/{mpi/misc => binding/fortran/mpif_h}/f2c_impl.c (97%) rename src/{include/mpi_fortran.h => binding/fortran/mpif_h/mpi_fortran.h.in} (96%) diff --git a/configure.ac b/configure.ac index 3d58b91d569..a42bc3bc92f 100644 --- a/configure.ac +++ b/configure.ac @@ -2464,12 +2464,6 @@ else ac_cv_sizeof_LongDoubleComplex=0 fi -# ------------ -# MPI_FINT -# ------------ -# MPI_FINT is already set -AC_SUBST(MPI_FINT) - # ------------ # MPI_AINT # ------------ @@ -3141,9 +3135,6 @@ else fi AC_SUBST(MPI_MAX_ERROR_STRING) -# Add a definition that is used to help support Windows DLLs (used in mpi.h.in) -MPIU_DLL_SPEC_DEF="#define MPIU_DLL_SPEC" -AC_SUBST(MPIU_DLL_SPEC_DEF) AM_CONDITIONAL([BUILD_CXX_BINDING],[test "$enable_cxx" = "yes"]) # MPI_SRCDIR gives the test/mpi configure the location of the source diff --git a/maint/gen_binding_c.py b/maint/gen_binding_c.py index c2e4a04087a..d61ceddba95 100644 --- a/maint/gen_binding_c.py +++ b/maint/gen_binding_c.py @@ -106,6 +106,8 @@ def dump_c_binding(): for func in func_list: if 'replace' in func and 'body' not in func: continue + elif re.match(r'.*_(f2c|c2f|c2f08|f082c|f2f08|f082f)', func['name']): + continue dump_func(func, do_doc) if '_replaces' in func: @@ -158,6 +160,8 @@ def dump_io_funcs(): G.out.append("") for func in io_func_list: + if re.match(r'.*_(f2c|c2f|c2f08|f082c|f2f08|f082f)', func['name']): + continue dump_func(func, do_doc) dump_out(G.c_dir + "/io.c") diff --git a/src/binding/cxx/buildiface b/src/binding/cxx/buildiface index 4052fad8b0f..48007da9303 100755 --- a/src/binding/cxx/buildiface +++ b/src/binding/cxx/buildiface @@ -1172,7 +1172,6 @@ print $OUTFD " // Typedefs for basic int types typedef MPI_Offset Offset; typedef MPI_Aint Aint; -typedef MPI_Fint Fint; // Special internal routine void MPIR_CXX_InitDatatypeNames( void ); diff --git a/src/binding/fortran/Makefile.am b/src/binding/fortran/Makefile.am index 74ef237f25d..6145bd69714 100644 --- a/src/binding/fortran/Makefile.am +++ b/src/binding/fortran/Makefile.am @@ -13,9 +13,9 @@ mpifort_convenience_libs = lib_LTLIBRARIES = bin_SCRIPTS = +include_HEADERS = noinst_LTLIBRARIES = noinst_HEADERS = -nodist_include_HEADERS = CLEANFILES = DISTCLEANFILES = MAINTAINERCLEANFILES = diff --git a/src/binding/fortran/configure.ac b/src/binding/fortran/configure.ac index 2a841c901a5..b7ee891d43c 100644 --- a/src/binding/fortran/configure.ac +++ b/src/binding/fortran/configure.ac @@ -749,6 +749,9 @@ AC_CHECK_SIZEOF(long long) AC_LANG_POP([C]) # Provide the corresponding C types for MPI_INTEGER +MPI_FINT= +AC_SUBST(MPI_FINT) + AC_MSG_CHECKING([for C type matching Fortran integer]) if test "$pac_cv_f77_sizeof_integer" == "$ac_cv_sizeof_int" ; then AC_MSG_RESULT([yes]) @@ -1113,14 +1116,13 @@ PAC_CHECK_BASH AM_CONDITIONAL([BUILD_BASH_SCRIPTS], [test "x$pac_cv_bash_works" = xyes]) AC_CONFIG_FILES([Makefile \ + mpif_h/mpi_fortran.h \ + mpif_h/setbotf.f \ + mpif_h/cmblk.c \ env/mpifort.sh \ env/mpifort.bash \ localdefs]) -if test "$enable_f77" = "yes" ; then - AC_CONFIG_FILES([mpif_h/setbotf.f \ - mpif_h/cmblk.c]) -fi if test "$enable_f08" = "yes" ; then AC_CONFIG_FILES([use_mpi_f08/mpi_c_interface_types.f90]) fi diff --git a/src/binding/fortran/mpif_h/Makefile.mk b/src/binding/fortran/mpif_h/Makefile.mk index 1dc0eb8fb07..21d69cf5e22 100644 --- a/src/binding/fortran/mpif_h/Makefile.mk +++ b/src/binding/fortran/mpif_h/Makefile.mk @@ -12,6 +12,7 @@ noinst_LTLIBRARIES += lib/libf77_mpi.la lib_libf77_mpi_la_SOURCES = \ mpif_h/fortran_binding.c \ + mpif_h/f2c_impl.c \ mpif_h/user_proxy.c \ mpif_h/fdebug.c \ mpif_h/setbot.c \ @@ -38,7 +39,9 @@ noinst_HEADERS += \ mpif_h/mpi_fortimpl.h DISTCLEANFILES += mpif_h/mpif.h -nodist_include_HEADERS += mpif_h/mpif.h +include_HEADERS += \ + mpif_h/mpif.h \ + mpif_h/mpi_fortran.h endif BUILD_F77_BINDING diff --git a/src/mpi/misc/f2c_impl.c b/src/binding/fortran/mpif_h/f2c_impl.c similarity index 97% rename from src/mpi/misc/f2c_impl.c rename to src/binding/fortran/mpif_h/f2c_impl.c index 067568337be..f9d9b6b8f27 100644 --- a/src/mpi/misc/f2c_impl.c +++ b/src/binding/fortran/mpif_h/f2c_impl.c @@ -3,9 +3,7 @@ * See COPYRIGHT in top-level directory */ -#include "mpiimpl.h" - -#ifndef MPICH_BUILD_MPI_ABI +#include "mpi_fortimpl.h" int MPIR_Status_f2c_impl(const MPI_Fint * f_status, MPI_Status * c_status) { @@ -100,5 +98,3 @@ int MPIR_Status_c2f08_impl(const MPI_Status * c_status, MPI_F08_status * f08_sta #endif return MPI_SUCCESS; } - -#endif /* MPICH_BUILD_MPI_ABI */ diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index 64fcc8295a0..aa210a23f0f 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -13,6 +13,16 @@ #include #include +#ifndef MPICH_API_PUBLIC +#if defined(HAVE_VISIBILITY) +#define MPICH_API_PUBLIC __attribute__((visibility ("default"))) +#else +#define MPICH_API_PUBLIC +#endif +#endif /* MPICH_API_PUBLIC */ + +#include "mpi_fortran.h" + /* Handle different mechanisms for passing Fortran CHARACTER to routines. * * In the case where MPI_Fint is a different size from int, it appears that @@ -419,6 +429,4 @@ int MPII_greq_start(F77_greq_query_function query_fn, F77_greq_free_function fre extern FORT_DLL_SPEC void FORT_CALL mpi_alloc_mem_cptr_(MPI_Aint * size, MPI_Fint * info, void **baseptr, MPI_Fint * ierr); -void MPIX_Init_fortran(void) __attribute__ ((visibility("default"))); - #endif /* MPI_FORTIMPL_H_INCLUDED */ diff --git a/src/include/mpi_fortran.h b/src/binding/fortran/mpif_h/mpi_fortran.h.in similarity index 96% rename from src/include/mpi_fortran.h rename to src/binding/fortran/mpif_h/mpi_fortran.h.in index 85c88310236..27930716e54 100644 --- a/src/include/mpi_fortran.h +++ b/src/binding/fortran/mpif_h/mpi_fortran.h.in @@ -3,19 +3,17 @@ * See COPYRIGHT in top-level directory */ -#ifdef MPI_FINT_CTYPE -typedef MPI_FINT_CTYPE MPI_Fint; -#else -typedef int MPI_Fint; -#endif +typedef @MPI_FINT@ MPI_Fint; -/* See 4.12.5 for MPI_F_STATUS(ES)_IGNORE */ -extern MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUS_IGNORE MPICH_API_PUBLIC; -extern MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUSES_IGNORE MPICH_API_PUBLIC; /* The annotation MPIU_DLL_SPEC to the extern statements is used as a hook for systems that require C extensions to correctly construct DLLs, and is defined as an empty string otherwise */ +#define MPIU_DLL_SPEC + +/* See 4.12.5 for MPI_F_STATUS(ES)_IGNORE */ +extern MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUS_IGNORE MPICH_API_PUBLIC; +extern MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUSES_IGNORE MPICH_API_PUBLIC; /* C type for MPI_STATUS in F08. The field order should match that in mpi_f08_types.f90, and mpi_c_interface_types.f90. @@ -80,3 +78,5 @@ extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUSES_IGNORE MPICH_API_PUBLIC; #define PMPI_Session_c2f(session) (MPI_Fint)(session) #define PMPI_Session_f2c(session) (MPI_Session)(session) #endif + +void MPIX_Init_fortran(void) MPICH_API_PUBLIC; diff --git a/src/binding/fortran/mpif_h/setbot.c b/src/binding/fortran/mpif_h/setbot.c index e5c7e11a750..859de14c919 100644 --- a/src/binding/fortran/mpif_h/setbot.c +++ b/src/binding/fortran/mpif_h/setbot.c @@ -34,12 +34,15 @@ void *MPIR_F_MPI_BOTTOM = 0; void *MPIR_F_MPI_IN_PLACE = 0; void *MPIR_F_MPI_BUFFER_AUTOMATIC = 0; void *MPIR_F_MPI_UNWEIGHTED = 0; -/* MPI_F_STATUS_IGNORE etc must be declared within mpi.h (MPI-2 standard - requires this) */ -/* -void *MPI_F_STATUS_IGNORE = 0; + +void *MPI_F_STATUS_IGNORE = 0; void *MPI_F_STATUSES_IGNORE = 0; -*/ +/* F08 objects can be defined in C and referenced via BIND(C) */ +MPI_F08_status MPIR_F08_MPI_STATUS_IGNORE_OBJ MPICH_API_PUBLIC; +MPI_F08_status MPIR_F08_MPI_STATUSES_IGNORE_OBJ[1] MPICH_API_PUBLIC; +MPI_F08_status *MPI_F08_STATUS_IGNORE = &MPIR_F08_MPI_STATUS_IGNORE_OBJ; +MPI_F08_status *MPI_F08_STATUSES_IGNORE = &MPIR_F08_MPI_STATUSES_IGNORE_OBJ[0]; + MPI_Fint *MPI_F_ERRCODES_IGNORE = 0; void *MPI_F_ARGV_NULL = 0; void *MPI_F_ARGVS_NULL = 0; diff --git a/src/include/Makefile.mk b/src/include/Makefile.mk index 619281dfce0..b8594d8a35f 100644 --- a/src/include/Makefile.mk +++ b/src/include/Makefile.mk @@ -7,8 +7,7 @@ nodist_include_HEADERS += src/include/mpi.h if !BUILD_ABI_LIB -include_HEADERS += src/include/mpi_proto.h \ - src/include/mpi_fortran.h +include_HEADERS += src/include/mpi_proto.h endif !BUILD_ABI_LIB # need mpix.h for either ABIs diff --git a/src/include/mpi_mpich.h.in b/src/include/mpi_mpich.h.in index c82b0d6dc96..04e882cf33a 100644 --- a/src/include/mpi_mpich.h.in +++ b/src/include/mpi_mpich.h.in @@ -144,8 +144,6 @@ extern "C" { # define MPICH_ATTR_TYPE_TAG_CXX(type) #endif -@MPIU_DLL_SPEC_DEF@ - /* Define some null objects */ #define MPI_COMM_NULL ((MPI_Comm)0x04000000) #define MPI_OP_NULL ((MPI_Op)0x18000000) diff --git a/src/mpi/init/globals.c b/src/mpi/init/globals.c index 898d441b5d5..37ec2c0aa86 100644 --- a/src/mpi/init/globals.c +++ b/src/mpi/init/globals.c @@ -15,18 +15,3 @@ MPIR_Process_t MPIR_Process = { }; MPIR_Thread_info_t MPIR_ThreadInfo; - -#ifndef MPICH_BUILD_MPI_ABI -/* These are initialized as null (avoids making these into common symbols). - If the Fortran binding is supported, these can be initialized to - their Fortran values (MPI only requires that they be valid between - MPI_Init and MPI_Finalize) */ -MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUS_IGNORE MPL_USED = 0; -MPIU_DLL_SPEC MPI_Fint *MPI_F_STATUSES_IGNORE MPL_USED = 0; - -MPI_F08_status MPIR_F08_MPI_STATUS_IGNORE_OBJ MPICH_API_PUBLIC; -MPI_F08_status MPIR_F08_MPI_STATUSES_IGNORE_OBJ[1] MPICH_API_PUBLIC; -MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUS_IGNORE MPL_USED = &MPIR_F08_MPI_STATUS_IGNORE_OBJ; -MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUSES_IGNORE MPL_USED = - &MPIR_F08_MPI_STATUSES_IGNORE_OBJ[0]; -#endif diff --git a/src/mpi/misc/Makefile.mk b/src/mpi/misc/Makefile.mk index 0477edf1291..adacd21810f 100644 --- a/src/mpi/misc/Makefile.mk +++ b/src/mpi/misc/Makefile.mk @@ -5,6 +5,5 @@ mpi_core_sources += \ src/mpi/misc/utils.c \ - src/mpi/misc/f2c_impl.c \ src/mpi/misc/memory_alloc_kinds.c \ src/mpi/misc/gpu_query.c From e94dfb0d0c842aa69361da6081b48d63ec69fd44 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 12 Aug 2026 14:30:46 -0500 Subject: [PATCH 28/39] warnings: conflicting types for MPI_F_STATUS_IGNORE Should use `MPI_Fint *` rather than `void *`. --- src/binding/fortran/mpif_h/mpi_fortimpl.h | 7 +------ src/binding/fortran/mpif_h/setbot.c | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index aa210a23f0f..8eb0f549199 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -303,12 +303,7 @@ extern FORT_DLL_SPEC void *MPIR_F_MPI_IN_PLACE; extern FORT_DLL_SPEC void *MPIR_F_MPI_BUFFER_AUTOMATIC; extern FORT_DLL_SPEC void *MPIR_F_MPI_UNWEIGHTED; extern FORT_DLL_SPEC void *MPIR_F_MPI_WEIGHTS_EMPTY; -/* MPI_F_STATUS(ES)_IGNORE are defined in mpi.h and are intended for C - programs. */ -/* -extern FORT_DLL_SPEC MPI_Fint *MPI_F_STATUS_IGNORE; -extern FORT_DLL_SPEC MPI_Fint *MPI_F_STATUSES_IGNORE; -*/ + /* MPI_F_ERRCODES_IGNORE is defined as a Fortran INTEGER type, so must be declared as MPI_Fint */ extern FORT_DLL_SPEC MPI_Fint *MPI_F_ERRCODES_IGNORE; diff --git a/src/binding/fortran/mpif_h/setbot.c b/src/binding/fortran/mpif_h/setbot.c index 859de14c919..23ee4f4e6ce 100644 --- a/src/binding/fortran/mpif_h/setbot.c +++ b/src/binding/fortran/mpif_h/setbot.c @@ -35,8 +35,8 @@ void *MPIR_F_MPI_IN_PLACE = 0; void *MPIR_F_MPI_BUFFER_AUTOMATIC = 0; void *MPIR_F_MPI_UNWEIGHTED = 0; -void *MPI_F_STATUS_IGNORE = 0; -void *MPI_F_STATUSES_IGNORE = 0; +MPI_Fint *MPI_F_STATUS_IGNORE = 0; +MPI_Fint *MPI_F_STATUSES_IGNORE = 0; /* F08 objects can be defined in C and referenced via BIND(C) */ MPI_F08_status MPIR_F08_MPI_STATUS_IGNORE_OBJ MPICH_API_PUBLIC; MPI_F08_status MPIR_F08_MPI_STATUSES_IGNORE_OBJ[1] MPICH_API_PUBLIC; From fd5e92b0ba8b1e27e653081b24a229928b55a2da Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Wed, 12 Aug 2026 14:37:55 -0500 Subject: [PATCH 29/39] fortran: return MPI_ERR_ARG in f2c_impl.c We can't use MPIR_Err_create_code now the fortran bindings are separate. --- src/binding/fortran/mpif_h/f2c_impl.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/binding/fortran/mpif_h/f2c_impl.c b/src/binding/fortran/mpif_h/f2c_impl.c index f9d9b6b8f27..32839c097fb 100644 --- a/src/binding/fortran/mpif_h/f2c_impl.c +++ b/src/binding/fortran/mpif_h/f2c_impl.c @@ -8,8 +8,7 @@ int MPIR_Status_f2c_impl(const MPI_Fint * f_status, MPI_Status * c_status) { if (f_status == MPI_F_STATUS_IGNORE || f_status == MPI_F_STATUSES_IGNORE) { - return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - __func__, __LINE__, MPI_ERR_OTHER, "**notfstatignore", 0); + return MPI_ERR_ARG; } #ifdef HAVE_FINT_IS_INT *c_status = *(MPI_Status *) f_status; @@ -26,8 +25,7 @@ int MPIR_Status_f2c_impl(const MPI_Fint * f_status, MPI_Status * c_status) int MPIR_Status_c2f_impl(const MPI_Status * c_status, MPI_Fint * f_status) { if (c_status == MPI_STATUS_IGNORE || c_status == MPI_STATUSES_IGNORE) { - return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - __func__, __LINE__, MPI_ERR_OTHER, "**notcstatignore", 0); + return MPI_ERR_ARG; } #ifdef HAVE_FINT_IS_INT *(MPI_Status *) f_status = *c_status; @@ -44,8 +42,7 @@ int MPIR_Status_c2f_impl(const MPI_Status * c_status, MPI_Fint * f_status) int MPIR_Status_f2f08_impl(const MPI_Fint * f_status, MPI_F08_status * f08_status) { if (f_status == MPI_F_STATUS_IGNORE || f_status == MPI_F_STATUSES_IGNORE) { - return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - __func__, __LINE__, MPI_ERR_OTHER, "**notfstatignore", 0); + return MPI_ERR_ARG; } /* f_status and f08_status are always byte-equivalent */ *f08_status = *(MPI_F08_status *) f_status; @@ -55,8 +52,7 @@ int MPIR_Status_f2f08_impl(const MPI_Fint * f_status, MPI_F08_status * f08_statu int MPIR_Status_f082f_impl(const MPI_F08_status * f08_status, MPI_Fint * f_status) { if (f08_status == MPI_F08_STATUS_IGNORE || f08_status == MPI_F08_STATUSES_IGNORE) { - return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - __func__, __LINE__, MPI_ERR_OTHER, "**notcstatignore", 0); + return MPI_ERR_ARG; } /* f_status and f08_status are always byte-equivalent */ *(MPI_F08_status *) f_status = *f08_status; @@ -66,8 +62,7 @@ int MPIR_Status_f082f_impl(const MPI_F08_status * f08_status, MPI_Fint * f_statu int MPIR_Status_f082c_impl(const MPI_F08_status * f08_status, MPI_Status * c_status) { if (f08_status == MPI_F08_STATUS_IGNORE || f08_status == MPI_F08_STATUSES_IGNORE) { - return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - __func__, __LINE__, MPI_ERR_OTHER, "**notfstatignore", 0); + return MPI_ERR_ARG; } #ifdef HAVE_FINT_IS_INT *c_status = *(MPI_Status *) f08_status; @@ -84,8 +79,7 @@ int MPIR_Status_f082c_impl(const MPI_F08_status * f08_status, MPI_Status * c_sta int MPIR_Status_c2f08_impl(const MPI_Status * c_status, MPI_F08_status * f08_status) { if (c_status == MPI_STATUS_IGNORE || c_status == MPI_STATUSES_IGNORE) { - return MPIR_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, - __func__, __LINE__, MPI_ERR_OTHER, "**notcstatignore", 0); + return MPI_ERR_ARG; } #ifdef HAVE_FINT_IS_INT *(MPI_Status *) f08_status = *c_status; From 664aa0b9fc2bbd48390b20816b101fc9a27d26cb Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Thu, 13 Aug 2026 14:21:18 -0500 Subject: [PATCH 30/39] fortran/mpif_h: use _toint instead of _c2f in user_proxy.c --- src/binding/fortran/mpif_h/user_proxy.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/binding/fortran/mpif_h/user_proxy.c b/src/binding/fortran/mpif_h/user_proxy.c index 0c6834f9a0e..019980f114c 100644 --- a/src/binding/fortran/mpif_h/user_proxy.c +++ b/src/binding/fortran/mpif_h/user_proxy.c @@ -167,7 +167,7 @@ static void F77_op_proxy(void *invec, void *inoutvec, MPI_Count len, MPI_Datatyp { struct F77_op_state *p = extra_state; MPI_Fint len_i = (MPI_Fint) len; - MPI_Fint datatype_i = MPI_Type_c2f(datatype); + MPI_Fint datatype_i = MPI_Type_toint(datatype); p->opfn(invec, inoutvec, &len_i, &datatype_i); } @@ -185,7 +185,7 @@ int MPII_op_create(F77_OpFunction * opfn, MPI_Fint commute, MPI_Fint * op) MPI_Op op_i; int ret = MPIX_Op_create_x(F77_op_proxy, F77_op_free, commute, p, &op_i); if (ret == MPI_SUCCESS) { - *op = MPI_Op_c2f(op_i); + *op = MPI_Op_toint(op_i); } else { MPL_free(p); } @@ -201,7 +201,7 @@ struct F77_errhan_state { static void F77_comm_errhan_proxy(MPI_Comm comm, int error_code, void *extra_state) { struct F77_errhan_state *p = extra_state; - MPI_Fint comm_i = MPI_Comm_c2f(comm); + MPI_Fint comm_i = MPI_Comm_toint(comm); MPI_Fint error_code_i = error_code; p->err_fn(&comm_i, &error_code_i); @@ -210,7 +210,7 @@ static void F77_comm_errhan_proxy(MPI_Comm comm, int error_code, void *extra_sta static void F77_win_errhan_proxy(MPI_Win win, int error_code, void *extra_state) { struct F77_errhan_state *p = extra_state; - MPI_Fint win_i = MPI_Win_c2f(win); + MPI_Fint win_i = MPI_Win_toint(win); MPI_Fint error_code_i = error_code; p->err_fn(&win_i, &error_code_i); @@ -219,7 +219,7 @@ static void F77_win_errhan_proxy(MPI_Win win, int error_code, void *extra_state) static void F77_file_errhan_proxy(MPI_File file, int error_code, void *extra_state) { struct F77_errhan_state *p = extra_state; - MPI_Fint file_i = MPI_File_c2f(file); + MPI_Fint file_i = MPI_File_toint(file); MPI_Fint error_code_i = error_code; p->err_fn(&file_i, &error_code_i); @@ -228,7 +228,7 @@ static void F77_file_errhan_proxy(MPI_File file, int error_code, void *extra_sta static void F77_session_errhan_proxy(MPI_Session session, int error_code, void *extra_state) { struct F77_errhan_state *p = extra_state; - MPI_Fint session_i = MPI_Session_c2f(session); + MPI_Fint session_i = MPI_Session_toint(session); MPI_Fint error_code_i = error_code; p->err_fn(&session_i, &error_code_i); @@ -267,7 +267,7 @@ int MPII_errhan_create(F77_ErrFunction * err_fn, MPI_Fint * errhandler, enum F77 assert(0); } if (ret == MPI_SUCCESS) { - *errhandler = MPI_Errhandler_c2f(errhandler_i); + *errhandler = MPI_Errhandler_toint(errhandler_i); } else { MPL_free(p); } From 60c0e65028901d2f9b7f0eb766dd497d34a88708 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sat, 15 Aug 2026 11:25:01 -0500 Subject: [PATCH 31/39] fortran: assume opaque MPI_Status Instead of assuming MPI_Status as defined by MPICH, assume struct MPI_Status is equivalent to an int array of size MPI_F_STATUS_SIZE. --- src/binding/fortran/mpif_h/f2c_impl.c | 42 ++++++++++++----------- src/binding/fortran/mpif_h/mpi_fortimpl.h | 7 ++++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/binding/fortran/mpif_h/f2c_impl.c b/src/binding/fortran/mpif_h/f2c_impl.c index 32839c097fb..2a053f06cf9 100644 --- a/src/binding/fortran/mpif_h/f2c_impl.c +++ b/src/binding/fortran/mpif_h/f2c_impl.c @@ -13,11 +13,11 @@ int MPIR_Status_f2c_impl(const MPI_Fint * f_status, MPI_Status * c_status) #ifdef HAVE_FINT_IS_INT *c_status = *(MPI_Status *) f_status; #else - c_status->count_lo = (int) f_status[0]; - c_status->count_hi_and_cancelled = (int) f_status[1]; - c_status->MPI_SOURCE = (int) f_status[2]; - c_status->MPI_TAG = (int) f_status[3]; - c_status->MPI_ERROR = (int) f_status[4]; + /* cast c_status as int array */ + int *p = (int *) c_status; + for (int i = 0; i < MPI_F_STATUS_SIZE; i++) { + p[i] = (int) f_status[i]; + } #endif return MPI_SUCCESS; } @@ -30,11 +30,11 @@ int MPIR_Status_c2f_impl(const MPI_Status * c_status, MPI_Fint * f_status) #ifdef HAVE_FINT_IS_INT *(MPI_Status *) f_status = *c_status; #else - f_status[0] = (MPI_Fint) c_status->count_lo; - f_status[1] = (MPI_Fint) c_status->count_hi_and_cancelled; - f_status[2] = (MPI_Fint) c_status->MPI_SOURCE; - f_status[3] = (MPI_Fint) c_status->MPI_TAG; - f_status[4] = (MPI_Fint) c_status->MPI_ERROR; + /* cast c_status as int array */ + int *p = (int *) c_status; + for (int i = 0; i < MPI_F_STATUS_SIZE; i++) { + f_status[i] = (MPI_Fint) p[i]; + } #endif return MPI_SUCCESS; } @@ -67,11 +67,12 @@ int MPIR_Status_f082c_impl(const MPI_F08_status * f08_status, MPI_Status * c_sta #ifdef HAVE_FINT_IS_INT *c_status = *(MPI_Status *) f08_status; #else - c_status->count_lo = (int) f08_status->count_lo; - c_status->count_hi_and_cancelled = (int) f08_status->count_hi_and_cancelled; - c_status->MPI_SOURCE = (int) f08_status->MPI_SOURCE; - c_status->MPI_TAG = (int) f08_status->MPI_TAG; - c_status->MPI_ERROR = (int) f08_status->MPI_ERROR; + /* cast c_status as int array, f08_status as MPI_Fint array */ + int *p = (int *) c_status; + int *q = (MPI_Fint *) f08_status; + for (int i = 0; i < MPI_F_STATUS_SIZE; i++) { + p[i] = (int) q[i]; + } #endif return MPI_SUCCESS; } @@ -84,11 +85,12 @@ int MPIR_Status_c2f08_impl(const MPI_Status * c_status, MPI_F08_status * f08_sta #ifdef HAVE_FINT_IS_INT *(MPI_Status *) f08_status = *c_status; #else - f08_status->count_lo = (MPI_Fint) c_status->count_lo; - f08_status->count_hi_and_cancelled = (MPI_Fint) c_status->count_hi_and_cancelled; - f08_status->MPI_SOURCE = (MPI_Fint) c_status->MPI_SOURCE; - f08_status->MPI_TAG = (MPI_Fint) c_status->MPI_TAG; - f08_status->MPI_ERROR = (MPI_Fint) c_status->MPI_ERROR; + /* cast c_status as int array, f08_status as MPI_Fint array */ + int *p = (int *) c_status; + int *q = (MPI_Fint *) f08_status; + for (int i = 0; i < MPI_F_STATUS_SIZE; i++) { + q[i] = (MPI_Fint) p[i]; + } #endif return MPI_SUCCESS; } diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index 8eb0f549199..a2108b5cc26 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -390,6 +390,13 @@ enum F77_handle_type { F77_SESSION, }; +int MPIR_Status_f2c_impl(const MPI_Fint * f_status, MPI_Status * c_status); +int MPIR_Status_c2f_impl(const MPI_Status * c_status, MPI_Fint * f_status); +int MPIR_Status_f2f08_impl(const MPI_Fint * f_status, MPI_F08_status * f08_status); +int MPIR_Status_f082f_impl(const MPI_F08_status * f08_status, MPI_Fint * f_status); +int MPIR_Status_f082c_impl(const MPI_F08_status * f08_status, MPI_Status * c_status); +int MPIR_Status_c2f08_impl(const MPI_Status * c_status, MPI_F08_status * f08_status); + /* The F90 attr copy/delete function prototype and calling convention */ typedef void (FORT_CALL F90_CopyFunction) (MPI_Fint *, MPI_Fint *, MPI_Aint *, MPI_Aint *, MPI_Aint *, MPI_Fint *, MPI_Fint *); From 09b1c571c08373b32aa36b77499ab6da12d0ed34 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 17 Aug 2026 11:00:57 -0500 Subject: [PATCH 32/39] fortran: check skip Fortran directive If the function is annotated in api file (e.g. src/binding/c/abi_api.txt), check its skip Fortran annotation. --- maint/local_python/binding_f08.py | 2 ++ maint/local_python/binding_f77.py | 2 ++ maint/local_python/binding_f90.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index 99b433bd29c..01cda41a894 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -1303,6 +1303,8 @@ def process_func_parameters(func): def check_func_directives(func): if 'dir' in func and func['dir'] == "mpit": func['_skip_fortran'] = 1 + elif 'skip' in func and RE.search(r'Fortran', func['skip'], re.IGNORECASE): + func['_skip_fortran'] = 1 elif RE.match(r'mpix_(grequest_|type_iov|async_)', func['name'], re.IGNORECASE): func['_skip_fortran'] = 1 elif RE.match(r'mpi_attr_', func['name'], re.IGNORECASE): diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 8edcddad63b..dad253cf110 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -1310,6 +1310,8 @@ def dump_fortran_line(s): def check_func_directives(func): if 'dir' in func and func['dir'] == "mpit": func['_skip_fortran'] = 1 + elif 'skip' in func and RE.search(r'Fortran', func['skip'], re.IGNORECASE): + func['_skip_fortran'] = 1 elif RE.match(r'mpix_(grequest_|type_iov|async_|(comm|file|win|session|type)_create_(errhandler|keyval)_x|op_create_x)', func['name'], re.IGNORECASE): func['_skip_fortran'] = 1 elif RE.match(r'mpi_\w+_((f|f08|c)2(f|f08|c)|fromint|toint)$', func['name'], re.IGNORECASE): diff --git a/maint/local_python/binding_f90.py b/maint/local_python/binding_f90.py index ba1d0032ebd..8d149f4000f 100644 --- a/maint/local_python/binding_f90.py +++ b/maint/local_python/binding_f90.py @@ -216,6 +216,8 @@ def dump_f90_sizeofs(): def check_func_directives(func): if 'dir' in func and func['dir'] == "mpit": func['_skip_fortran'] = 1 + elif 'skip' in func and RE.search(r'Fortran', func['skip'], re.IGNORECASE): + func['_skip_fortran'] = 1 elif RE.match(r'mpix_(grequest_|type_iov|async_|(comm|file|win|session|type)_create_(errhandler|keyval)_x|op_create_x)', func['name'], re.IGNORECASE): func['_skip_fortran'] = 1 elif RE.match(r'mpi_attr_', func['name'], re.IGNORECASE): From 4100e82686bc0c1c806ef1a4942bbbd659a32f89 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sat, 15 Aug 2026 17:30:53 -0500 Subject: [PATCH 33/39] fortran/mpif_h: add _f2c/c2f functions Define _f2c/c2f functions. These functions will be used internally in mpi_f08. TODO: export and properly set weak symbols. --- src/binding/c/stream_api.txt | 20 ++ src/binding/fortran/mpif_h/f2c_impl.c | 242 ++++++++++++++++++++ src/binding/fortran/mpif_h/mpi_fortran.h.in | 109 +++++---- src/include/mpi_mpich.h.in | 49 ++++ 4 files changed, 372 insertions(+), 48 deletions(-) diff --git a/src/binding/c/stream_api.txt b/src/binding/c/stream_api.txt index 5c482856217..8adc1d88dcf 100644 --- a/src/binding/c/stream_api.txt +++ b/src/binding/c/stream_api.txt @@ -236,3 +236,23 @@ MPIX_Allreduce_enqueue: datatype: DATATYPE, [data type of elements of send buffer] op: OPERATION, [operation] comm: COMMUNICATOR, [communicator] + +MPIX_Stream_toint: + .desc: converts MPIX_Stream to an integer handle + .return: INTEGER + stream: STREAM + .impl: direct + .skip: Fortran, Errors +{ + return (int) stream; +} + +MPIX_Stream_fromint: + .desc: converts an integer handle to MPIX_Stream + .return: STREAM + stream: INTEGER + .impl: direct + .skip: Fortran, Errors +{ + return (MPIX_Stream) stream; +} diff --git a/src/binding/fortran/mpif_h/f2c_impl.c b/src/binding/fortran/mpif_h/f2c_impl.c index 2a053f06cf9..b60662fb8c8 100644 --- a/src/binding/fortran/mpif_h/f2c_impl.c +++ b/src/binding/fortran/mpif_h/f2c_impl.c @@ -94,3 +94,245 @@ int MPIR_Status_c2f08_impl(const MPI_Status * c_status, MPI_F08_status * f08_sta #endif return MPI_SUCCESS; } + +/* provide all the _f2c/c2f functions */ +/* TODO: proper weak symbol support */ +MPI_Fint MPI_Comm_c2f(MPI_Comm comm) +{ + return (MPI_Fint) MPI_Comm_toint(comm); +} + +MPI_Comm MPI_Comm_f2c(MPI_Fint comm) +{ + return MPI_Comm_fromint(comm); +} + +MPI_Fint PMPI_Comm_c2f(MPI_Comm comm) +{ + return (MPI_Fint) MPI_Comm_toint(comm); +} + +MPI_Comm PMPI_Comm_f2c(MPI_Fint comm) +{ + return MPI_Comm_fromint(comm); +} + +MPI_Fint MPI_Errhandler_c2f(MPI_Errhandler errhandler) +{ + return (MPI_Fint) MPI_Errhandler_toint(errhandler); +} + +MPI_Errhandler MPI_Errhandler_f2c(MPI_Fint errhandler) +{ + return MPI_Errhandler_fromint(errhandler); +} + +MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhandler) +{ + return (MPI_Fint) MPI_Errhandler_toint(errhandler); +} + +MPI_Errhandler PMPI_Errhandler_f2c(MPI_Fint errhandler) +{ + return MPI_Errhandler_fromint(errhandler); +} + +MPI_Fint MPI_File_c2f(MPI_File file) +{ + return (MPI_Fint) MPI_File_toint(file); +} + +MPI_File MPI_File_f2c(MPI_Fint file) +{ + return MPI_File_fromint(file); +} + +MPI_Fint PMPI_File_c2f(MPI_File file) +{ + return (MPI_Fint) MPI_File_toint(file); +} + +MPI_File PMPI_File_f2c(MPI_Fint file) +{ + return MPI_File_fromint(file); +} + +MPI_Fint MPI_Group_c2f(MPI_Group group) +{ + return (MPI_Fint) MPI_Group_toint(group); +} + +MPI_Group MPI_Group_f2c(MPI_Fint group) +{ + return MPI_Group_fromint(group); +} + +MPI_Fint PMPI_Group_c2f(MPI_Group group) +{ + return (MPI_Fint) MPI_Group_toint(group); +} + +MPI_Group PMPI_Group_f2c(MPI_Fint group) +{ + return MPI_Group_fromint(group); +} + +MPI_Fint MPI_Info_c2f(MPI_Info info) +{ + return (MPI_Fint) MPI_Info_toint(info); +} + +MPI_Info MPI_Info_f2c(MPI_Fint info) +{ + return MPI_Info_fromint(info); +} + +MPI_Fint PMPI_Info_c2f(MPI_Info info) +{ + return (MPI_Fint) MPI_Info_toint(info); +} + +MPI_Info PMPI_Info_f2c(MPI_Fint info) +{ + return MPI_Info_fromint(info); +} + +MPI_Fint MPI_Message_c2f(MPI_Message message) +{ + return (MPI_Fint) MPI_Message_toint(message); +} + +MPI_Message MPI_Message_f2c(MPI_Fint message) +{ + return MPI_Message_fromint(message); +} + +MPI_Fint PMPI_Message_c2f(MPI_Message message) +{ + return (MPI_Fint) MPI_Message_toint(message); +} + +MPI_Message PMPI_Message_f2c(MPI_Fint message) +{ + return MPI_Message_fromint(message); +} + +MPI_Fint MPI_Op_c2f(MPI_Op op) +{ + return (MPI_Fint) MPI_Op_toint(op); +} + +MPI_Op MPI_Op_f2c(MPI_Fint op) +{ + return MPI_Op_fromint(op); +} + +MPI_Fint PMPI_Op_c2f(MPI_Op op) +{ + return (MPI_Fint) MPI_Op_toint(op); +} + +MPI_Op PMPI_Op_f2c(MPI_Fint op) +{ + return MPI_Op_fromint(op); +} + +MPI_Fint MPI_Request_c2f(MPI_Request request) +{ + return (MPI_Fint) MPI_Request_toint(request); +} + +MPI_Request MPI_Request_f2c(MPI_Fint request) +{ + return MPI_Request_fromint(request); +} + +MPI_Fint PMPI_Request_c2f(MPI_Request request) +{ + return (MPI_Fint) MPI_Request_toint(request); +} + +MPI_Request PMPI_Request_f2c(MPI_Fint request) +{ + return MPI_Request_fromint(request); +} + +MPI_Fint MPI_Session_c2f(MPI_Session session) +{ + return (MPI_Fint) MPI_Session_toint(session); +} + +MPI_Session MPI_Session_f2c(MPI_Fint session) +{ + return MPI_Session_fromint(session); +} + +MPI_Fint PMPI_Session_c2f(MPI_Session session) +{ + return (MPI_Fint) MPI_Session_toint(session); +} + +MPI_Session PMPI_Session_f2c(MPI_Fint session) +{ + return MPI_Session_fromint(session); +} + +MPI_Fint MPI_Type_c2f(MPI_Datatype datatype) +{ + return (MPI_Fint) MPI_Type_toint(datatype); +} + +MPI_Datatype MPI_Type_f2c(MPI_Fint datatype) +{ + return MPI_Type_fromint(datatype); +} + +MPI_Fint PMPI_Type_c2f(MPI_Datatype datatype) +{ + return (MPI_Fint) MPI_Type_toint(datatype); +} + +MPI_Datatype PMPI_Type_f2c(MPI_Fint datatype) +{ + return MPI_Type_fromint(datatype); +} + +MPI_Fint MPI_Win_c2f(MPI_Win win) +{ + return (MPI_Fint) MPI_Win_toint(win); +} + +MPI_Win MPI_Win_f2c(MPI_Fint win) +{ + return MPI_Win_fromint(win); +} + +MPI_Fint PMPI_Win_c2f(MPI_Win win) +{ + return (MPI_Fint) MPI_Win_toint(win); +} + +MPI_Win PMPI_Win_f2c(MPI_Fint win) +{ + return MPI_Win_fromint(win); +} + +MPI_Fint MPIX_Stream_c2f(MPIX_Stream stream) +{ + return (MPI_Fint) MPIX_Stream_toint(stream); +} + +MPIX_Stream MPIX_Stream_f2c(MPI_Fint stream) +{ + return MPIX_Stream_fromint(stream); +} + +MPI_Fint PMPIX_Stream_c2f(MPIX_Stream stream) +{ + return (MPI_Fint) MPIX_Stream_toint(stream); +} + +MPIX_Stream PMPIX_Stream_f2c(MPI_Fint stream) +{ + return MPIX_Stream_fromint(stream); +} diff --git a/src/binding/fortran/mpif_h/mpi_fortran.h.in b/src/binding/fortran/mpif_h/mpi_fortran.h.in index 27930716e54..972d0b7b474 100644 --- a/src/binding/fortran/mpif_h/mpi_fortran.h.in +++ b/src/binding/fortran/mpif_h/mpi_fortran.h.in @@ -3,7 +3,9 @@ * See COPYRIGHT in top-level directory */ +/* *INDENT-OFF* */ typedef @MPI_FINT@ MPI_Fint; +/* *INDENT-ON* */ /* The annotation MPIU_DLL_SPEC to the extern statements is used as a hook for systems that require C extensions to correctly construct @@ -30,53 +32,64 @@ typedef struct { extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUS_IGNORE MPICH_API_PUBLIC; extern MPIU_DLL_SPEC MPI_F08_status *MPI_F08_STATUSES_IGNORE MPICH_API_PUBLIC; -/* The f2c and c2f APIs exist as real functions, but these macros allows - * for backward MPICH ABI compatibility. - */ -/* exclude these macros from MPICH internal */ -#ifndef MPICHCONF_H_INCLUDED -#define MPI_Comm_c2f(comm) (MPI_Fint)(comm) -#define MPI_Comm_f2c(comm) (MPI_Comm)(comm) -#define MPI_Type_c2f(datatype) (MPI_Fint)(datatype) -#define MPI_Type_f2c(datatype) (MPI_Datatype)(datatype) -#define MPI_Group_c2f(group) (MPI_Fint)(group) -#define MPI_Group_f2c(group) (MPI_Group)(group) -#define MPI_Info_c2f(info) (MPI_Fint)(info) -#define MPI_Info_f2c(info) (MPI_Info)(info) -#define MPI_Request_f2c(request) (MPI_Request)(request) -#define MPI_Request_c2f(request) (MPI_Fint)(request) -#define MPI_Op_c2f(op) (MPI_Fint)(op) -#define MPI_Op_f2c(op) (MPI_Op)(op) -#define MPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) -#define MPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) -#define MPI_Win_c2f(win) (MPI_Fint)(win) -#define MPI_Win_f2c(win) (MPI_Win)(win) -#define MPI_Message_c2f(msg) ((MPI_Fint)(msg)) -#define MPI_Message_f2c(msg) ((MPI_Message)(msg)) -#define MPI_Session_c2f(session) (MPI_Fint)(session) -#define MPI_Session_f2c(session) (MPI_Session)(session) - -/* PMPI versions of the handle transfer functions. See section 4.17 */ -#define PMPI_Comm_c2f(comm) (MPI_Fint)(comm) -#define PMPI_Comm_f2c(comm) (MPI_Comm)(comm) -#define PMPI_Type_c2f(datatype) (MPI_Fint)(datatype) -#define PMPI_Type_f2c(datatype) (MPI_Datatype)(datatype) -#define PMPI_Group_c2f(group) (MPI_Fint)(group) -#define PMPI_Group_f2c(group) (MPI_Group)(group) -#define PMPI_Info_c2f(info) (MPI_Fint)(info) -#define PMPI_Info_f2c(info) (MPI_Info)(info) -#define PMPI_Request_f2c(request) (MPI_Request)(request) -#define PMPI_Request_c2f(request) (MPI_Fint)(request) -#define PMPI_Op_c2f(op) (MPI_Fint)(op) -#define PMPI_Op_f2c(op) (MPI_Op)(op) -#define PMPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) -#define PMPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) -#define PMPI_Win_c2f(win) (MPI_Fint)(win) -#define PMPI_Win_f2c(win) (MPI_Win)(win) -#define PMPI_Message_c2f(msg) ((MPI_Fint)(msg)) -#define PMPI_Message_f2c(msg) ((MPI_Message)(msg)) -#define PMPI_Session_c2f(session) (MPI_Fint)(session) -#define PMPI_Session_f2c(session) (MPI_Session)(session) -#endif +MPI_Fint MPI_Comm_c2f(MPI_Comm comm); +MPI_Comm MPI_Comm_f2c(MPI_Fint comm); +MPI_Fint PMPI_Comm_c2f(MPI_Comm comm); +MPI_Comm PMPI_Comm_f2c(MPI_Fint comm); + +MPI_Fint MPI_Errhandler_c2f(MPI_Errhandler errhandler); +MPI_Errhandler MPI_Errhandler_f2c(MPI_Fint errhandler); +MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhandler); +MPI_Errhandler PMPI_Errhandler_f2c(MPI_Fint errhandler); + +MPI_Fint MPI_File_c2f(MPI_File file); +MPI_File MPI_File_f2c(MPI_Fint file); +MPI_Fint PMPI_File_c2f(MPI_File file); +MPI_File PMPI_File_f2c(MPI_Fint file); + +MPI_Fint MPI_Group_c2f(MPI_Group group); +MPI_Group MPI_Group_f2c(MPI_Fint group); +MPI_Fint PMPI_Group_c2f(MPI_Group group); +MPI_Group PMPI_Group_f2c(MPI_Fint group); + +MPI_Fint MPI_Info_c2f(MPI_Info info); +MPI_Info MPI_Info_f2c(MPI_Fint info); +MPI_Fint PMPI_Info_c2f(MPI_Info info); +MPI_Info PMPI_Info_f2c(MPI_Fint info); + +MPI_Fint MPI_Message_c2f(MPI_Message message); +MPI_Message MPI_Message_f2c(MPI_Fint message); +MPI_Fint PMPI_Message_c2f(MPI_Message message); +MPI_Message PMPI_Message_f2c(MPI_Fint message); + +MPI_Fint MPI_Op_c2f(MPI_Op op); +MPI_Op MPI_Op_f2c(MPI_Fint op); +MPI_Fint PMPI_Op_c2f(MPI_Op op); +MPI_Op PMPI_Op_f2c(MPI_Fint op); + +MPI_Fint MPI_Request_c2f(MPI_Request request); +MPI_Request MPI_Request_f2c(MPI_Fint request); +MPI_Fint PMPI_Request_c2f(MPI_Request request); +MPI_Request PMPI_Request_f2c(MPI_Fint request); + +MPI_Fint MPI_Session_c2f(MPI_Session session); +MPI_Session MPI_Session_f2c(MPI_Fint session); +MPI_Fint PMPI_Session_c2f(MPI_Session session); +MPI_Session PMPI_Session_f2c(MPI_Fint session); + +MPI_Fint MPI_Type_c2f(MPI_Datatype datatype); +MPI_Datatype MPI_Type_f2c(MPI_Fint datatype); +MPI_Fint PMPI_Type_c2f(MPI_Datatype datatype); +MPI_Datatype PMPI_Type_f2c(MPI_Fint datatype); + +MPI_Fint MPI_Win_c2f(MPI_Win win); +MPI_Win MPI_Win_f2c(MPI_Fint win); +MPI_Fint PMPI_Win_c2f(MPI_Win win); +MPI_Win PMPI_Win_f2c(MPI_Fint win); + +MPI_Fint MPIX_Stream_c2f(MPIX_Stream stream); +MPIX_Stream MPIX_Stream_f2c(MPI_Fint stream); +MPI_Fint PMPIX_Stream_c2f(MPIX_Stream stream); +MPIX_Stream PMPIX_Stream_f2c(MPI_Fint stream); void MPIX_Init_fortran(void) MPICH_API_PUBLIC; diff --git a/src/include/mpi_mpich.h.in b/src/include/mpi_mpich.h.in index 04e882cf33a..6e888efcafc 100644 --- a/src/include/mpi_mpich.h.in +++ b/src/include/mpi_mpich.h.in @@ -993,6 +993,55 @@ int QMPI_Get_calling_address(QMPI_Context context, void **address) MPICH_API_PUB /* include fortran inter-op header if needed */ #ifdef MPICH_ENABLE_FORTRAN #include +/* The f2c and c2f APIs exist as real functions, but these macros allows + * for backward MPICH ABI compatibility. + */ +/* exclude these macros from MPICH internal */ +#ifndef MPICHCONF_H_INCLUDED +#define MPI_Comm_c2f(comm) (MPI_Fint)(comm) +#define MPI_Comm_f2c(comm) (MPI_Comm)(comm) +#define MPI_Type_c2f(datatype) (MPI_Fint)(datatype) +#define MPI_Type_f2c(datatype) (MPI_Datatype)(datatype) +#define MPI_Group_c2f(group) (MPI_Fint)(group) +#define MPI_Group_f2c(group) (MPI_Group)(group) +#define MPI_Info_c2f(info) (MPI_Fint)(info) +#define MPI_Info_f2c(info) (MPI_Info)(info) +#define MPI_Request_f2c(request) (MPI_Request)(request) +#define MPI_Request_c2f(request) (MPI_Fint)(request) +#define MPI_Op_c2f(op) (MPI_Fint)(op) +#define MPI_Op_f2c(op) (MPI_Op)(op) +#define MPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) +#define MPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) +#define MPI_Win_c2f(win) (MPI_Fint)(win) +#define MPI_Win_f2c(win) (MPI_Win)(win) +#define MPI_Message_c2f(msg) ((MPI_Fint)(msg)) +#define MPI_Message_f2c(msg) ((MPI_Message)(msg)) +#define MPI_Session_c2f(session) (MPI_Fint)(session) +#define MPI_Session_f2c(session) (MPI_Session)(session) + +/* PMPI versions of the handle transfer functions. See section 4.17 */ +#define PMPI_Comm_c2f(comm) (MPI_Fint)(comm) +#define PMPI_Comm_f2c(comm) (MPI_Comm)(comm) +#define PMPI_Type_c2f(datatype) (MPI_Fint)(datatype) +#define PMPI_Type_f2c(datatype) (MPI_Datatype)(datatype) +#define PMPI_Group_c2f(group) (MPI_Fint)(group) +#define PMPI_Group_f2c(group) (MPI_Group)(group) +#define PMPI_Info_c2f(info) (MPI_Fint)(info) +#define PMPI_Info_f2c(info) (MPI_Info)(info) +#define PMPI_Request_f2c(request) (MPI_Request)(request) +#define PMPI_Request_c2f(request) (MPI_Fint)(request) +#define PMPI_Op_c2f(op) (MPI_Fint)(op) +#define PMPI_Op_f2c(op) (MPI_Op)(op) +#define PMPI_Errhandler_c2f(errhandler) (MPI_Fint)(errhandler) +#define PMPI_Errhandler_f2c(errhandler) (MPI_Errhandler)(errhandler) +#define PMPI_Win_c2f(win) (MPI_Fint)(win) +#define PMPI_Win_f2c(win) (MPI_Win)(win) +#define PMPI_Message_c2f(msg) ((MPI_Fint)(msg)) +#define PMPI_Message_f2c(msg) ((MPI_Message)(msg)) +#define PMPI_Session_c2f(session) (MPI_Fint)(session) +#define PMPI_Session_f2c(session) (MPI_Session)(session) +#endif + #endif #endif /* MPICH_BUILD_MPI_ABI */ From 4931025b8fe61f30bf236162c86e4b8fa27d3f84 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sun, 16 Aug 2026 19:32:53 -0500 Subject: [PATCH 34/39] fortran/f08: refactor dump_f08_wrappers_f We used to generate both branches: the case fint is the same as c_int and the case require explicit conversions. Previously we changed that switch to the python layer. Consequently, we can need generate one version and we no longer need keep track of both branches in python. Merge arg_list_1/arg_list_2 into single arg_list. Fold convert_list_1/ convert_list_2 into convert_list_pre/convert_list_post. All process_* functions return a single arg instead of a tuple. Replace runtime need_check_int_kind with generation-time need_int_conversions. --- maint/local_python/binding_f08.py | 372 +++++++++++++++--------------- 1 file changed, 181 insertions(+), 191 deletions(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index 01cda41a894..301ba1d6ebc 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -153,18 +153,16 @@ def dump_f08_wrappers_f(func, is_large): c_mapping = get_kind_map('C', is_large) f08_mapping = get_kind_map('F08', is_large) + need_int_conversions = (G.opts['fint-size'] != G.opts['cint-size']) + f_param_list = [] uses = {} f_decl_list = [] c_decl_list = [] - arg_list_1 = [] # used if (c_int == kind(0)) - arg_list_2 = [] # used otherwise + arg_list = [] code_list = [] - convert_list_pre = [] # conversions always needed + convert_list_pre = [] convert_list_post = [] - convert_list_1 = [] # conversions only if c_int != kind(0) - convert_list_2 = [] - need_check_int_kind = False need_check_status_ignore = None # or p (the status parameter) has_comm_size = False # arrays of length = comm_size status_var = "" @@ -182,16 +180,12 @@ def dump_f08_wrappers_f(func, is_large): uses[c_func_name] = 1 if RE.match(r'MPI_(Init|Init_thread)$', func['name'], re.IGNORECASE): - arg_list_1.append("c_null_ptr") - arg_list_1.append("c_null_ptr") - arg_list_2.append("c_null_ptr") - arg_list_2.append("c_null_ptr") + arg_list.append("c_null_ptr") + arg_list.append("c_null_ptr") uses['c_null_ptr'] = 1 elif RE.match(r'MPI_Info_create_env$', func['name'], re.IGNORECASE): - arg_list_1.append("0") - arg_list_1.append("c_null_ptr") - arg_list_2.append("0") - arg_list_2.append("c_null_ptr") + arg_list.append("0") + arg_list.append("c_null_ptr") uses['c_null_ptr'] = 1 elif RE.match(r'mpi_i?alltoall[vw]', func['name'], re.IGNORECASE): # Need check MPI_IN_PLACE in order to skip accessing sender arrays @@ -201,18 +195,9 @@ def dump_f08_wrappers_f(func, is_large): uses['MPI_IN_PLACE'] = 1 # alltoallw inplace hack (since it is a corner case) - def dump_alltoallvw_inplace(arg_list_1, arg_list_2, convert_list_2): - # cannot use like sendcounts(1:length) - if G.opts['fint-size'] == G.opts['cint-size']: - if re.match(r'mpi_i?alltoallw', func['name'], re.IGNORECASE): - send_args = "sendbuf, sendcounts, sdispls, sendtypes(1:1)%MPI_VAL" - args1 = send_args + ", " + ', '.join(arg_list_1[4:]) - else: - # alltoallv is fine - args1 = ', '.join(arg_list_1) - dump_fortran_line("ierror_c = %s(%s)" % (c_func_name, args1)) - else: - args2 = ', '.join(arg_list_2) + def dump_alltoallvw_inplace(): + if need_int_conversions: + # cannot use like sendcounts(1:length) G.out.append("sendcounts_c = sendcounts(1:1)") G.out.append("sdispls_c = sdispls(1:1)") G.out.append("recvcounts_c = recvcounts(1:length)") @@ -223,12 +208,20 @@ def dump_alltoallvw_inplace(arg_list_1, arg_list_2, convert_list_2): else: G.out.append("sendtype_c = sendtype%MPI_VAL") G.out.append("recvtype_c = recvtype%MPI_VAL") - dump_fortran_line("ierror_c = %s(%s)" % (c_func_name, args2)) - G.out.extend(convert_list_2) + else: + if re.match(r'mpi_i?alltoallw', func['name'], re.IGNORECASE): + # For alltoallw inplace, sendtypes only has 1 element + send_args = "sendbuf, sendcounts, sdispls, sendtypes(1:1)%MPI_VAL" + args1 = send_args + ", " + ', '.join(arg_list[4:]) + else: + # alltoallv is fine + args1 = ', '.join(arg_list) + dump_fortran_line("ierror_c = %s(%s)" % (c_func_name, args1)) + return + dump_fortran_line("ierror_c = %s(%s)" % (c_func_name, ', '.join(arg_list))) # ---- def process_integer(p): - nonlocal need_check_int_kind def info_get_string_buflen(): convert_list_pre.append("IF (buflen > 0) THEN") @@ -238,32 +231,37 @@ def info_get_string_buflen(): convert_list_pre.append("END IF") def info_get_valuelen(): - convert_list_2.append("IF (flag_c /= 0) THEN") - convert_list_2.append(" valuelen = valuelen_c") - convert_list_2.append("END IF") + convert_list_post.append("IF (flag_c /= 0) THEN") + convert_list_post.append(" valuelen = valuelen_c") + convert_list_post.append("END IF") # ---- if RE.match(r'TYPE\(MPIX?_\w+\)', f08_mapping[p['kind']], re.IGNORECASE): - arg_1 = p['name'] + "%MPI_VAL" + arg_val = p['name'] + "%MPI_VAL" else: - arg_1 = p['name'] - arg_2 = "%s_c" % p['name'] + arg_val = p['name'] if p['name'] == 'comm' and (has_comm_size or RE.match(r'mpi_cart_(rank|sub)', func['name'], re.IGNORECASE)): # already processed pass elif p['name'] == 'buflen' and func['name'] == "MPI_Info_get_string": # always use "buflen_c" - arg_1 = arg_2 info_get_string_buflen() + return "%s_c" % p['name'] elif p['name'] == 'valuelen' and func['name'] == "MPI_Info_get_valuelen": - info_get_valuelen() - else: - need_check_int_kind = True + if need_int_conversions: + info_get_valuelen() + return "%s_c" % p['name'] + else: + return p['name'] + elif need_int_conversions: + arg_c = "%s_c" % p['name'] if p['param_direction'] == 'in' or p['param_direction'] == 'inout': - convert_list_1.append("%s = %s" % (arg_2, arg_1)) + convert_list_pre.append("%s = %s" % (arg_c, arg_val)) if p['param_direction'] == 'out' or p['param_direction'] == 'inout': - convert_list_2.append("%s = %s" % (arg_1, arg_2)) - return (arg_1, arg_2) + convert_list_post.append("%s = %s" % (arg_val, arg_c)) + return arg_c + else: + return arg_val def process_mpi_file(p): arg = "%s_c" % p['name'] @@ -273,7 +271,7 @@ def process_mpi_file(p): if p['param_direction'] == 'out' or p['param_direction'] == 'inout': uses['MPI_File_c2f'] = 1 convert_list_post.append("%s%%MPI_VAL = MPI_File_c2f(%s)" % (p['name'], arg)) - return (arg, arg) + return arg def process_logical(p): arg = "%s_c" % p['name'] @@ -285,7 +283,7 @@ def process_logical(p): convert_list_pre.append("END IF") if p['param_direction'] == 'out' or p['param_direction'] == 'inout': convert_list_post.append("%s = (%s /= 0)" % (p['name'], arg)) - return (arg, arg) + return arg def process_index(p): arg = "%s_c" % p['name'] @@ -298,7 +296,7 @@ def process_index(p): convert_list_post.append("ELSE") convert_list_post.append(" %s = %s + 1" % (p['name'], arg)) convert_list_post.append("END IF") - return (arg, arg) + return arg def process_string(p): arg = "%s_c" % p['name'] @@ -329,51 +327,47 @@ def info_get_post(): else: convert_list_post.append("call MPIR_Fortran_string_c2f(%s, %s)" % (arg, p['name'])) uses["MPIR_Fortran_string_c2f"] = 1 - return (arg, arg) + return arg def process_status(p): - nonlocal need_check_int_kind, need_check_status_ignore - need_check_int_kind = True + nonlocal need_check_status_ignore uses['c_loc'] = 1 uses['c_associated'] = 1 uses['assignment(=)'] = 1 - if p['length'] is not None: + if p['length'] is not None: # always output parameter uses['MPI_STATUSES_IGNORE'] = 1 uses['MPIR_F08_get_MPI_STATUSES_IGNORE_c'] = 1 need_check_status_ignore = p - arg_1 = ":STATUS:" - arg_2 = ":STATUS:" length = p['_array_length'] if RE.match(r'mpix?_(test|wait|request_get_status_)some', func['name'], re.IGNORECASE): length = "outcount_c" p['_status_convert'] = "%s(1:%s) = %s_c(1:%s)" % (p['name'], length, p['name'], length) + return ":STATUS:" else: - arg_1 = "c_loc(status)" - arg_2 = "c_loc(status_c)" if p['param_direction'] == 'out': need_check_status_ignore = p uses['MPI_STATUS_IGNORE'] = 1 uses['MPIR_F08_get_MPI_STATUS_IGNORE_c'] = 1 - arg_1 = ":STATUS:" - arg_2 = ":STATUS:" - # currently we preserve status%MPI_ERROR - p['_status_convert_in'] = "status_c = status" - p['_status_convert'] = "status = status_c" - elif p['param_direction'] == 'inout': - convert_list_1.append("status_c = status") - convert_list_2.append("status = status_c") + if need_int_conversions: + p['_status_convert_in'] = "status_c = status" + p['_status_convert'] = "status = status_c" + return ":STATUS:" + elif need_int_conversions: + if p['param_direction'] == 'inout': + convert_list_pre.append("status_c = status") + convert_list_post.append("status = status_c") + else: + convert_list_pre.append("status_c = status") + return "c_loc(status_c)" else: - convert_list_1.append("status_c = status") - return (arg_1, arg_2) + return "c_loc(status)" def process_array_check(p): - nonlocal need_check_int_kind uses['c_loc'] = 1 uses['c_ptr'] = 1 - arg_1 = "%s_cptr" % p['name'] - arg_2 = arg_1 - convert_list_pre.append("%s = c_loc(%s)" % (arg_1, p['name'])) + arg = "%s_cptr" % p['name'] + convert_list_pre.append("%s = c_loc(%s)" % (arg, p['name'])) check = None if p['name'] == "argv": @@ -384,7 +378,6 @@ def process_array_check(p): # weights are input int array c_decl_list.append("LOGICAL :: has_%s = .false." % p['name']) check = "MPI_UNWEIGHTED" - need_check_int_kind = True if RE.match(r'mpi_dist_graph_create$', func['name'], re.IGNORECASE): length = "sum(degrees)" elif RE.match(r'mpi_dist_graph_create_adjacent$', func['name'], re.IGNORECASE): @@ -400,33 +393,34 @@ def process_array_check(p): else: print("process_array_check: Unhandled %s" % p['name']) - c_decl_list.append("INTEGER(c_int), TARGET :: %s_c(%s)" % (p['name'], length)) - convert_list_1.append("IF (has_%s) THEN" % p['name']) - convert_list_1.append(" %s_c(1:%s) = %s(1:%s)" % (p['name'], length, p['name'], length)) - convert_list_1.append(" %s_cptr = c_loc(%s_c)" % (p['name'], p['name'])) - convert_list_1.append("END IF") - # output conversion for MPI_Dist_graph_neighbors - if p['param_direction'] == 'out': - convert_list_2.append("IF (has_%s) THEN" % p['name']) - convert_list_2.append(" %s(1:%s) = %s_c(1:%s)" % (p['name'], length, p['name'], length)) - convert_list_2.append("END IF") + if need_int_conversions: + c_decl_list.append("INTEGER(c_int), TARGET :: %s_c(%s)" % (p['name'], length)) + convert_list_pre.append("IF (has_%s) THEN" % p['name']) + convert_list_pre.append(" %s_c(1:%s) = %s(1:%s)" % (p['name'], length, p['name'], length)) + convert_list_pre.append(" %s_cptr = c_loc(%s_c)" % (p['name'], p['name'])) + convert_list_pre.append("END IF") + # output conversion for MPI_Dist_graph_neighbors + if p['param_direction'] == 'out': + convert_list_post.append("IF (has_%s) THEN" % p['name']) + convert_list_post.append(" %s(1:%s) = %s_c(1:%s)" % (p['name'], length, p['name'], length)) + convert_list_post.append("END IF") elif p['name'] == "array_of_errcodes": # errcodes are output int array c_decl_list.append("LOGICAL :: has_errcodes_ignore = .false.") check = "MPI_ERRCODES_IGNORE" - need_check_int_kind = True - if RE.match(r'mpi_comm_spawn_multiple', func['name'], re.IGNORECASE): - length = "sum(array_of_maxprocs(1:count))" - else: # mpi_comm_spawn - length = "maxprocs" - c_decl_list.append("INTEGER(c_int), TARGET :: %s_c(%s)" % (p['name'], length)) - convert_list_1.append("IF (.not. has_errcodes_ignore) THEN") - convert_list_1.append(" %s_cptr = c_loc(%s_c)" % (p['name'], p['name'])) - convert_list_1.append("END IF") - convert_list_2.append("IF (.not. has_errcodes_ignore) THEN") - convert_list_2.append(" %s(1:%s) = %s_c" % (p['name'], length, p['name'])) - convert_list_2.append("END IF") + if need_int_conversions: + if RE.match(r'mpi_comm_spawn_multiple', func['name'], re.IGNORECASE): + length = "sum(array_of_maxprocs(1:count))" + else: # mpi_comm_spawn + length = "maxprocs" + c_decl_list.append("INTEGER(c_int), TARGET :: %s_c(%s)" % (p['name'], length)) + convert_list_pre.append("IF (.not. has_errcodes_ignore) THEN") + convert_list_pre.append(" %s_cptr = c_loc(%s_c)" % (p['name'], p['name'])) + convert_list_pre.append("END IF") + convert_list_post.append("IF (.not. has_errcodes_ignore) THEN") + convert_list_post.append(" %s(1:%s) = %s_c" % (p['name'], length, p['name'])) + convert_list_post.append("END IF") else: print("Unhandled process_array_check") @@ -434,8 +428,8 @@ def process_array_check(p): uses['c_associated'] = 1 uses[check] = 1 uses['MPIR_F08_get_%s_c' % check] = 1 - convert_list_pre.append("IF (c_associated(%s, c_loc(%s))) THEN" % (arg_1, check)) - convert_list_pre.append(" %s = MPIR_F08_get_%s_c()" % (arg_1, check)) + convert_list_pre.append("IF (c_associated(%s, c_loc(%s))) THEN" % (arg, check)) + convert_list_pre.append(" %s = MPIR_F08_get_%s_c()" % (arg, check)) if check == "MPI_ERRCODES_IGNORE": convert_list_pre.append(" has_errcodes_ignore = .true.") elif check == "MPI_UNWEIGHTED": @@ -443,57 +437,61 @@ def process_array_check(p): check = "MPI_WEIGHTS_EMPTY" uses[check] = 1 uses['MPIR_F08_get_%s_c' % check] = 1 - convert_list_pre.append("ELSE IF (c_associated(%s, c_loc(%s))) THEN" % (arg_1, check)) - convert_list_pre.append(" %s = MPIR_F08_get_%s_c()" % (arg_1, check)) + convert_list_pre.append("ELSE IF (c_associated(%s, c_loc(%s))) THEN" % (arg, check)) + convert_list_pre.append(" %s = MPIR_F08_get_%s_c()" % (arg, check)) convert_list_pre.append("ELSE") - convert_list_pre.append(" %s = c_loc(%s)" % (arg_1, p['name'])) + convert_list_pre.append(" %s = c_loc(%s)" % (arg, p['name'])) convert_list_pre.append(" has_%s = .true." % p['name']) convert_list_pre.append("END IF") - return (arg_1, arg_2) + return arg def process_array(p): - nonlocal need_check_int_kind, has_comm_size + nonlocal has_comm_size if p['_array_convert'] == "MPI_VAL": - need_check_int_kind = True if p['kind'] == "DATATYPE" and has_comm_size: # alltoallw types array - arg_1 = "%s(1:length)%%MPI_VAL" % p['name'] + arg_val = "%s(1:length)%%MPI_VAL" % p['name'] else: - arg_1 = "%s%%MPI_VAL" % p['name'] - arg_2 = "%s_c" % p['name'] - if RE.match(r'in|inout', p['param_direction']): - convert_list_1.append("%s = %s" % (arg_2, arg_1)) - if RE.match(r'out|inout', p['param_direction']): - convert_list_2.append("%s = %s" % (arg_1, arg_2)) + arg_val = "%s%%MPI_VAL" % p['name'] + if need_int_conversions: + arg_c = "%s_c" % p['name'] + if RE.match(r'in|inout', p['param_direction']): + convert_list_pre.append("%s = %s" % (arg_c, arg_val)) + if RE.match(r'out|inout', p['param_direction']): + convert_list_post.append("%s = %s" % (arg_val, arg_c)) + return arg_c + else: + return arg_val elif p['_array_convert'] == "LOGICAL": - arg_1 = "%s_c" % p['name'] - arg_2 = "%s_c" % p['name'] + arg = "%s_c" % p['name'] if RE.match(r'in|inout', p['param_direction']): - convert_list_pre.append("%s = merge(1, 0, %s)" % (arg_2, p['name'])) + convert_list_pre.append("%s = merge(1, 0, %s)" % (arg, p['name'])) if RE.match(r'out|inout', p['param_direction']): - convert_list_post.append("%s = (%s /= 0)" % (p['name'], arg_2)) + convert_list_post.append("%s = (%s /= 0)" % (p['name'], arg)) + return arg elif p['_array_convert'] == "INDEX": - arg_1 = "%s_c" % p['name'] - arg_2 = "%s_c" % p['name'] + arg = "%s_c" % p['name'] if RE.match(r'MPI_(Wait|Test|Request_get_status_)some', func['name'], re.IGNORECASE): - convert_list_post.append("%s(1:outcount) = %s(1:outcount) + 1" % (p['name'], arg_2)) + convert_list_post.append("%s(1:outcount) = %s(1:outcount) + 1" % (p['name'], arg)) else: raise Exception("Unexpected function encountered in process_array: %s" % func['name']) + return arg elif RE.match(r'allocate:(.+)', p['_array_convert']): # The length variable name is_MPI_VAL = (RE.m.group(1) == 'MPI_VAL') length = "length" # get array length if p['_array_length'] == 'comm_size': - need_check_int_kind = True if not has_comm_size: if RE.search(r'alltoall[vw]', func['name'], re.IGNORECASE): # always need the length for types or counts array use_list = convert_list_pre + elif need_int_conversions: + use_list = convert_list_pre else: - use_list = convert_list_1 + use_list = convert_list_pre use_list.append("comm_c = comm%MPI_VAL") if RE.search(r'neighbor', func['name'], re.IGNORECASE): c_decl_list.append("INTEGER(c_int) :: err, indegree, outdegree, weighted") @@ -512,54 +510,57 @@ def process_array(p): elif p['_array_length'] == 'cart_dim': # MPI_Cart_rank, only 1 allocatable array c_decl_list.append("INTEGER(c_int) :: err, length") - use_list = convert_list_pre - if RE.match(r'mpi_cart_rank', func['name'], re.IGNORECASE): - use_list = convert_list_2 - use_list.append("comm_c = comm%MPI_VAL") - use_list.append("err = MPIR_Cartdim_get_c(comm_c, length)") + convert_list_pre.append("comm_c = comm%MPI_VAL") + convert_list_pre.append("err = MPIR_Cartdim_get_c(comm_c, length)") uses['MPIR_Cartdim_get_c'] = 1 else: print("process_array: Unhandled assumed array length") - # set args - if is_MPI_VAL: - if p['kind'] == "DATATYPE": - arg_1 = "%s(1:%s)%%MPI_VAL" % (p['name'], length) - else: - arg_1 = "%s%%MPI_VAL" % p['name'] - args_1 = "%s(1:%s)%%MPI_VAL" % (p['name'], length) - else: - arg_1 = p['name'] - args_1 = "%s(1:%s)" % (p['name'], length) - arg_2 = "%s_c" % p['name'] - + arg_c = "%s_c" % p['name'] # convert if p['kind'] == "LOGICAL": - convert_list_pre.append("%s = merge(1, 0, %s)" % (arg_2, args_1)) - arg_1 = arg_2 + args_1 = "%s(1:%s)" % (p['name'], length) + convert_list_pre.append("%s = merge(1, 0, %s)" % (arg_c, args_1)) + return arg_c + elif is_MPI_VAL: + if need_int_conversions: + args_1 = "%s(1:%s)%%MPI_VAL" % (p['name'], length) + convert_list_pre.append("%s = %s" % (arg_c, args_1)) + return arg_c + else: + if p['kind'] == "DATATYPE": + return "%s(1:%s)%%MPI_VAL" % (p['name'], length) + else: + return "%s%%MPI_VAL" % p['name'] else: - convert_list_1.append("%s = %s" % (arg_2, args_1)) + if need_int_conversions: + args_1 = "%s(1:%s)" % (p['name'], length) + convert_list_pre.append("%s = %s" % (arg_c, args_1)) + return arg_c + else: + return p['name'] elif p['_array_convert'] == "c_int": - need_check_int_kind = True - arg_1 = "%s" % p['name'] - arg_2 = "%s_c" % p['name'] - if p['_array_length']: - argv_1 = arg_1 + "(1:%s)" % p['_array_length'] - argv_2 = arg_2 + "(1:%s)" % p['_array_length'] + if need_int_conversions: + arg_c = "%s_c" % p['name'] + if p['_array_length']: + argv_1 = "%s(1:%s)" % (p['name'], p['_array_length']) + argv_2 = "%s_c(1:%s)" % (p['name'], p['_array_length']) + else: + argv_1 = p['name'] + argv_2 = arg_c + if RE.match(r'in|inout', p['param_direction']): + convert_list_pre.append("%s = %s" % (argv_2, argv_1)) + if RE.match(r'out|inout', p['param_direction']): + if RE.match(r'mpix?_(test|wait|request_get_status_)some', func['name'], re.IGNORECASE) and p['name'] == "array_of_indices": + argv_1 = "array_of_indices(1:outcount_c)" + argv_2 = "array_of_indices_c(1:outcount_c)" + convert_list_post.append("%s = %s" % (argv_1, argv_2)) + return arg_c else: - argv_1 = arg_1 - argv_2 = arg_2 - if RE.match(r'in|inout', p['param_direction']): - convert_list_1.append("%s = %s" % (argv_2, argv_1)) - if RE.match(r'out|inout', p['param_direction']): - if RE.match(r'mpix?_(test|wait|request_get_status_)some', func['name'], re.IGNORECASE) and p['name'] == "array_of_indices": - argv_1 = "array_of_indices(1:outcount_c)" - argv_2 = "array_of_indices_c(1:outcount_c)" - convert_list_2.append("%s = %s" % (argv_1, argv_2)) + return p['name'] else: print("Unhandled process_array") - - return (arg_1, arg_2) + return p['name'] def process_procedure(p): uses['c_funptr'] = 1 @@ -578,13 +579,12 @@ def process_procedure(p): uses['c_null_funptr'] = 1 uses[FN_NULL] = 1 arg = "%s_c" % p['name'] - return (arg, arg) + return arg def post_string_len(v): c_decl_list.append("INTEGER(c_int) :: %s_len" % v) convert_list_pre.append("%s_len = len(%s)" % (v, v)) - arg_list_1.append("%s_len" % v) - arg_list_2.append("%s_len" % v) + arg_list.append("%s_len" % v) # ---- for p in func['parameters']: @@ -600,40 +600,40 @@ def post_string_len(v): c_decl = get_F_c_decl(func, p, f08_mapping, c_mapping) if not c_decl: if p['kind'] == "STRING_ARRAY": - arg_1 = "c_loc(%s)" % p['name'] + arg = "c_loc(%s)" % p['name'] uses['c_loc'] = 1 elif p['kind'] == "INFO": - arg_1 = "%s(1:%s)%%MPI_VAL" % (p['name'], p['_array_length']) + arg = "%s(1:%s)%%MPI_VAL" % (p['name'], p['_array_length']) elif p['kind'] == 'ATTRIBUTE_VAL' and RE.match(r'MPI_(Comm|Win)_get_attr', f08ts_name): - arg_1 = p['name'] + arg = p['name'] else: # no conversion needed, e.g. choice buffer, MPI_Aint, etc. - arg_1 = p['name'] - arg_2 = arg_1 + arg = p['name'] else: - c_decl_list.append(c_decl) - check_decl_uses(c_decl, uses) if p['kind'] == "STRING": - (arg_1, arg_2) = process_string(p) + arg = process_string(p) elif p['kind'] == "STATUS": - (arg_1, arg_2) = process_status(p) + arg = process_status(p) elif '_array_length' in p: # set by get_F_c_decl(p) if p['_array_convert'] == 'c_ptr_check': - (arg_1, arg_2) = process_array_check(p) + arg = process_array_check(p) else: - (arg_1, arg_2) = process_array(p) + arg = process_array(p) elif p['kind'] == "LOGICAL" or p['kind'] == "LOGICAL_BOOLEAN": - (arg_1, arg_2) = process_logical(p) + arg = process_logical(p) elif p['kind'] == "INDEX" and re.match(r'MPI_(Test|Wait|Request_get_status_)any', func['name'], re.IGNORECASE): - (arg_1, arg_2) = process_index(p) + arg = process_index(p) elif f08_mapping[p['kind']] == "PROCEDURE": - (arg_1, arg_2) = process_procedure(p) + arg = process_procedure(p) elif p['kind'] == 'FILE': - (arg_1, arg_2) = process_mpi_file(p) + arg = process_mpi_file(p) else: - (arg_1, arg_2) = process_integer(p) - arg_list_1.append(arg_1) - arg_list_2.append(arg_2) + arg = process_integer(p) + if arg != p['name']: + c_decl_list.append(c_decl) + check_decl_uses(c_decl, uses) + + arg_list.append(arg) if isinstance(p['length'], str) and RE.match(r'(MPI_\w+)', p['length'], re.IGNORECASE): uses[RE.m.group(1)] = 1 @@ -654,7 +654,7 @@ def post_string_len(v): else: f_decl_list.append("%s :: res" % f08_mapping[func['return']]) - if need_check_int_kind: + if need_int_conversions: uses['c_int'] = 1 # -- dump to G.out @@ -677,7 +677,7 @@ def post_string_len(v): G.out.append("") # ---- - def dump_call(s, check_int_kind): + def dump_call(s): if need_check_status_ignore: p = need_check_status_ignore # the status parameter if p['length'] is None: @@ -688,14 +688,14 @@ def dump_call(s, check_int_kind): s2 = re.sub(r':STATUS:', "MPIR_F08_get_%s_c()" % ignore, s) dump_fortran_line(s2) dump_F_else() - if check_int_kind: + if need_int_conversions: s2 = re.sub(r':STATUS:', "c_loc(%s_c)" % p['name'], s) if '_status_convert_in' in p: G.out.append(p['_status_convert_in']) else: s2 = re.sub(r':STATUS:', "c_loc(%s)" % p['name'], s) dump_fortran_line(s2) - if check_int_kind: + if need_int_conversions: G.out.append(p['_status_convert']) dump_F_if_close() else: @@ -710,21 +710,11 @@ def dump_call(s, check_int_kind): if not ('skip' in func and RE.search(r'initcheck', func['skip'], re.IGNORECASE)): G.out.append("call MPIR_Init_fortran()") - if need_check_int_kind and G.opts['fint-size'] == G.opts['cint-size']: - if is_alltoallvw: - dump_F_if_open("c_associated(c_loc(sendbuf), c_loc(MPI_IN_PLACE))") - dump_alltoallvw_inplace(arg_list_1, arg_list_2, convert_list_2) - dump_F_else() - dump_call("%s = %s(%s)" % (ret, c_func_name, ', '.join(arg_list_1)), False) - else: - if is_alltoallvw: - dump_F_if_open("c_associated(c_loc(sendbuf), c_loc(MPI_IN_PLACE))") - dump_alltoallvw_inplace(arg_list_1, arg_list_2, convert_list_2) - dump_F_else() - G.out.extend(convert_list_1) - dump_call("%s = %s(%s)" % (ret, c_func_name, ', '.join(arg_list_2)), True) - G.out.extend(convert_list_2) - + if is_alltoallvw: + dump_F_if_open("c_associated(c_loc(sendbuf), c_loc(MPI_IN_PLACE))") + dump_alltoallvw_inplace() + dump_F_else() + dump_call("%s = %s(%s)" % (ret, c_func_name, ', '.join(arg_list))) if is_alltoallvw: dump_F_if_close() G.out.append("") From 4e677d87a73b550ca14f560edb90a2042607afa0 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sun, 16 Aug 2026 19:40:19 -0500 Subject: [PATCH 35/39] fortran/f08: fix long USE lines in dump_F_uses dump_fortran_line uses split_line_with_break which assumes a function-like line and tries to indent after the first '(', and it assumes the '(' (if found) comes before the line length. This may not be true when the line isn't a function, such as: USE :: mpi_f08_types, ONLY : MPI_Datatype, MPI_Type_f2c, MPI_Message, MPI_Message_f2c, MPI_Message_c2f, MPI_Status, assignment(=) Replace dump_fortran_line with dump_use_line that properly splits long USE statements at symbol boundaries. --- maint/local_python/binding_f08.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index 301ba1d6ebc..efddd62ec44 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -933,22 +933,33 @@ def dump_F_uses(uses): mpi_c_list_1.append(a) else: mpi_c_list_2.append(a) + + def dump_use_line(prefix, symbol_list): + line = prefix + symbol_list[0] + for sym in symbol_list[1:]: + if len(line) + 2 + len(sym) > 100: + G.out.append(line + ", &") + line = " " + sym + else: + line += ", " + sym + G.out.append(line) + if iso_c_binding_list: - dump_fortran_line("USE, intrinsic :: iso_c_binding, ONLY : %s" % ', '.join(iso_c_binding_list)) + dump_use_line("USE, intrinsic :: iso_c_binding, ONLY : ", iso_c_binding_list) if mpi_f08_list_1: - dump_fortran_line("USE :: mpi_f08_types, ONLY : %s" % ', '.join(mpi_f08_list_1)) + dump_use_line("USE :: mpi_f08_types, ONLY : ", mpi_f08_list_1) if mpi_f08_list_2: - dump_fortran_line("USE :: mpi_f08_compile_constants, ONLY : %s" % ', '.join(mpi_f08_list_2)) + dump_use_line("USE :: mpi_f08_compile_constants, ONLY : ", mpi_f08_list_2) if mpi_f08_list_3: - dump_fortran_line("USE :: mpi_f08_link_constants, ONLY : %s" % ', '.join(mpi_f08_list_3)) + dump_use_line("USE :: mpi_f08_link_constants, ONLY : ", mpi_f08_list_3) if mpi_f08_list_4: - dump_fortran_line("USE :: mpi_f08_callbacks, ONLY : %s" % ', '.join(mpi_f08_list_4)) + dump_use_line("USE :: mpi_f08_callbacks, ONLY : ", mpi_f08_list_4) if mpi_c_list_1: - dump_fortran_line("USE :: mpi_c_interface_types, ONLY : %s" % ', '.join(mpi_c_list_1)) + dump_use_line("USE :: mpi_c_interface_types, ONLY : ", mpi_c_list_1) if mpi_c_list_2: - dump_fortran_line("USE :: mpi_c_interface, ONLY : %s" % ', '.join(mpi_c_list_2)) + dump_use_line("USE :: mpi_c_interface, ONLY : ", mpi_c_list_2) if mpi_c_list_3: - dump_fortran_line("USE :: mpi_c_interface_glue, ONLY : %s" % ', '.join(mpi_c_list_3)) + dump_use_line("USE :: mpi_c_interface_glue, ONLY : ", mpi_c_list_3) def dump_F_if_open(cond): G.out.append("IF (%s) THEN" % cond) From bc1dc2cc9d61536dc3bfaa34189cfa673accb1fb Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Sun, 16 Aug 2026 19:40:24 -0500 Subject: [PATCH 36/39] fortran/f08: use f2c routines to convert MPI_VAL Do not assume we can pass MPI_VAL directly to C. Use _f2c conversions. --- maint/local_python/binding_f08.py | 184 +++++++++++++++++------------- 1 file changed, 107 insertions(+), 77 deletions(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index efddd62ec44..c00f5c3db4f 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -194,30 +194,39 @@ def dump_f08_wrappers_f(func, is_large): uses['c_associated'] = 1 uses['MPI_IN_PLACE'] = 1 - # alltoallw inplace hack (since it is a corner case) + # alltoallvw special case: handle types and inplace integer arrays + def dump_alltoallvw_types(): + is_alltoallw = re.match(r'mpi_i?alltoallw', func['name'], re.IGNORECASE) + if is_alltoallw: + uses['MPI_Type_f2c'] = 1 + G.out.append("allocate(sendtypes_c(1:length))") + G.out.append("allocate(recvtypes_c(1:length))") + G.out.append("do i = 1, length") + G.out.append(" sendtypes_c(i) = MPI_Type_f2c(sendtypes(i)%MPI_VAL)") + G.out.append("end do") + G.out.append("do i = 1, length") + G.out.append(" recvtypes_c(i) = MPI_Type_f2c(recvtypes(i)%MPI_VAL)") + G.out.append("end do") + def dump_alltoallvw_inplace(): + is_alltoallw = re.match(r'mpi_i?alltoallw', func['name'], re.IGNORECASE) + if is_alltoallw: + uses['MPI_Type_f2c'] = 1 + G.out.append("allocate(sendtypes_c(1:1))") + G.out.append("allocate(recvtypes_c(1:length))") + G.out.append("sendtypes_c(1) = MPI_Type_f2c(sendtypes(1)%MPI_VAL)") + G.out.append("do i = 1, length") + G.out.append(" recvtypes_c(i) = MPI_Type_f2c(recvtypes(i)%MPI_VAL)") + G.out.append("end do") + else: + G.out.append("sendtype_c = MPI_Type_f2c(sendtype%MPI_VAL)") + G.out.append("recvtype_c = MPI_Type_f2c(recvtype%MPI_VAL)") if need_int_conversions: # cannot use like sendcounts(1:length) G.out.append("sendcounts_c = sendcounts(1:1)") G.out.append("sdispls_c = sdispls(1:1)") G.out.append("recvcounts_c = recvcounts(1:length)") G.out.append("rdispls_c = rdispls(1:length)") - if re.match(r'mpi_i?alltoallw', func['name'], re.IGNORECASE): - G.out.append("sendtypes_c = sendtypes(1:1)%MPI_VAL") - G.out.append("recvtypes_c = recvtypes(1:length)%MPI_VAL") - else: - G.out.append("sendtype_c = sendtype%MPI_VAL") - G.out.append("recvtype_c = recvtype%MPI_VAL") - else: - if re.match(r'mpi_i?alltoallw', func['name'], re.IGNORECASE): - # For alltoallw inplace, sendtypes only has 1 element - send_args = "sendbuf, sendcounts, sdispls, sendtypes(1:1)%MPI_VAL" - args1 = send_args + ", " + ', '.join(arg_list[4:]) - else: - # alltoallv is fine - args1 = ', '.join(arg_list) - dump_fortran_line("ierror_c = %s(%s)" % (c_func_name, args1)) - return dump_fortran_line("ierror_c = %s(%s)" % (c_func_name, ', '.join(arg_list))) # ---- @@ -236,14 +245,7 @@ def info_get_valuelen(): convert_list_post.append("END IF") # ---- - if RE.match(r'TYPE\(MPIX?_\w+\)', f08_mapping[p['kind']], re.IGNORECASE): - arg_val = p['name'] + "%MPI_VAL" - else: - arg_val = p['name'] - if p['name'] == 'comm' and (has_comm_size or RE.match(r'mpi_cart_(rank|sub)', func['name'], re.IGNORECASE)): - # already processed - pass - elif p['name'] == 'buflen' and func['name'] == "MPI_Info_get_string": + if p['name'] == 'buflen' and func['name'] == "MPI_Info_get_string": # always use "buflen_c" info_get_string_buflen() return "%s_c" % p['name'] @@ -256,21 +258,27 @@ def info_get_valuelen(): elif need_int_conversions: arg_c = "%s_c" % p['name'] if p['param_direction'] == 'in' or p['param_direction'] == 'inout': - convert_list_pre.append("%s = %s" % (arg_c, arg_val)) + convert_list_pre.append("%s = %s" % (arg_c, p['name'])) if p['param_direction'] == 'out' or p['param_direction'] == 'inout': - convert_list_post.append("%s = %s" % (arg_val, arg_c)) + convert_list_post.append("%s = %s" % (p['name'], arg_c)) return arg_c else: - return arg_val + return p['name'] - def process_mpi_file(p): + def process_mpi_handle(p): + nonlocal has_comm_size arg = "%s_c" % p['name'] - if p['param_direction'] == 'in' or p['param_direction'] == 'inout': - uses['MPI_File_f2c'] = 1 - convert_list_pre.append("%s = MPI_File_f2c(%s%%MPI_VAL)" % (arg, p['name'])) - if p['param_direction'] == 'out' or p['param_direction'] == 'inout': - uses['MPI_File_c2f'] = 1 - convert_list_post.append("%s%%MPI_VAL = MPI_File_c2f(%s)" % (p['name'], arg)) + if p['name'] == 'comm' and (has_comm_size or RE.match(r'mpi_cart_(rank|sub)', func['name'], re.IGNORECASE)): + # already processed + pass + else: + (f2c, c2f) = get_f2c_name(p) + if p['param_direction'] == 'in' or p['param_direction'] == 'inout': + uses[f2c] = 1 + convert_list_pre.append("%s = %s(%s%%MPI_VAL)" % (arg, f2c, p['name'])) + if p['param_direction'] == 'out' or p['param_direction'] == 'inout': + uses[c2f] = 1 + convert_list_post.append("%s%%MPI_VAL = %s(%s)" % (p['name'], c2f, arg)) return arg def process_logical(p): @@ -349,6 +357,7 @@ def process_status(p): need_check_status_ignore = p uses['MPI_STATUS_IGNORE'] = 1 uses['MPIR_F08_get_MPI_STATUS_IGNORE_c'] = 1 + # currently we preserve status%MPI_ERROR if need_int_conversions: p['_status_convert_in'] = "status_c = status" p['_status_convert'] = "status = status_c" @@ -450,20 +459,21 @@ def process_array(p): nonlocal has_comm_size if p['_array_convert'] == "MPI_VAL": - if p['kind'] == "DATATYPE" and has_comm_size: - # alltoallw types array - arg_val = "%s(1:length)%%MPI_VAL" % p['name'] - else: - arg_val = "%s%%MPI_VAL" % p['name'] - if need_int_conversions: - arg_c = "%s_c" % p['name'] - if RE.match(r'in|inout', p['param_direction']): - convert_list_pre.append("%s = %s" % (arg_c, arg_val)) - if RE.match(r'out|inout', p['param_direction']): - convert_list_post.append("%s = %s" % (arg_val, arg_c)) - return arg_c - else: - return arg_val + arg_c = "%s_c" % p['name'] + if "INTEGER :: i" not in c_decl_list: + c_decl_list.append("INTEGER :: i") + (f2c, c2f) = get_f2c_name(p) + if RE.match(r'in|inout', p['param_direction']): + uses[f2c] = 1 + convert_list_pre.append("do i = 1, %s" % p['length']) + convert_list_pre.append(" %s(i) = %s(%s(i)%%MPI_VAL)" % (arg_c, f2c, p['name'])) + convert_list_pre.append("end do") + if RE.match(r'out|inout', p['param_direction']): + uses[c2f] = 1 + convert_list_post.append("do i = 1, %s" % p['length']) + convert_list_post.append(" %s(i)%%MPI_VAL = %s(%s(i))" % (p['name'], c2f, arg_c)) + convert_list_post.append("end do") + return arg_c elif p['_array_convert'] == "LOGICAL": arg = "%s_c" % p['name'] if RE.match(r'in|inout', p['param_direction']): @@ -485,21 +495,15 @@ def process_array(p): # get array length if p['_array_length'] == 'comm_size': if not has_comm_size: - if RE.search(r'alltoall[vw]', func['name'], re.IGNORECASE): - # always need the length for types or counts array - use_list = convert_list_pre - elif need_int_conversions: - use_list = convert_list_pre - else: - use_list = convert_list_pre - use_list.append("comm_c = comm%MPI_VAL") + uses['MPI_Comm_f2c'] = 1 + convert_list_pre.append("comm_c = MPI_Comm_f2c(comm%MPI_VAL)") if RE.search(r'neighbor', func['name'], re.IGNORECASE): - c_decl_list.append("INTEGER(c_int) :: err, indegree, outdegree, weighted") - use_list.append("err = MPIR_Dist_graph_neighbors_count_c(comm_c, indegree, outdegree, weighted)") + c_decl_list.append("INTEGER(c_int) :: indegree, outdegree, weighted") + convert_list_pre.append("ierror_c = MPIR_Dist_graph_neighbors_count_c(comm_c, indegree, outdegree, weighted)") uses['MPIR_Dist_graph_neighbors_count_c'] = 1 else: - c_decl_list.append("INTEGER(c_int) :: err, length") - use_list.append("err = MPIR_Comm_size_c(comm_c, length)") + c_decl_list.append("INTEGER(c_int) :: length") + convert_list_pre.append("ierror_c = MPIR_Comm_size_c(comm_c, length)") uses['MPIR_Comm_size_c'] = 1 has_comm_size = True if RE.search(r'neighbor', func['name'], re.IGNORECASE): @@ -509,9 +513,10 @@ def process_array(p): length = "indegree" elif p['_array_length'] == 'cart_dim': # MPI_Cart_rank, only 1 allocatable array - c_decl_list.append("INTEGER(c_int) :: err, length") - convert_list_pre.append("comm_c = comm%MPI_VAL") - convert_list_pre.append("err = MPIR_Cartdim_get_c(comm_c, length)") + c_decl_list.append("INTEGER(c_int) :: length") + uses['MPI_Comm_f2c'] = 1 + convert_list_pre.append("comm_c = MPI_Comm_f2c(comm%MPI_VAL)") + convert_list_pre.append("ierror_c = MPIR_Cartdim_get_c(comm_c, length)") uses['MPIR_Cartdim_get_c'] = 1 else: print("process_array: Unhandled assumed array length") @@ -523,15 +528,16 @@ def process_array(p): convert_list_pre.append("%s = merge(1, 0, %s)" % (arg_c, args_1)) return arg_c elif is_MPI_VAL: - if need_int_conversions: - args_1 = "%s(1:%s)%%MPI_VAL" % (p['name'], length) - convert_list_pre.append("%s = %s" % (arg_c, args_1)) - return arg_c - else: - if p['kind'] == "DATATYPE": - return "%s(1:%s)%%MPI_VAL" % (p['name'], length) - else: - return "%s%%MPI_VAL" % p['name'] + (f2c, c2f) = get_f2c_name(p) + uses[f2c] = 1 + if "INTEGER :: i" not in c_decl_list: + c_decl_list.append("INTEGER :: i") + if not is_alltoallvw: + # alltoallvw types are handled in dump_alltoallvw_inplace/normal + convert_list_pre.append("do i = 1, %s" % length) + convert_list_pre.append(" %s(i) = %s(%s(i)%%MPI_VAL)" % (arg_c, f2c, p['name'])) + convert_list_pre.append("end do") + return arg_c else: if need_int_conversions: args_1 = "%s(1:%s)" % (p['name'], length) @@ -603,7 +609,8 @@ def post_string_len(v): arg = "c_loc(%s)" % p['name'] uses['c_loc'] = 1 elif p['kind'] == "INFO": - arg = "%s(1:%s)%%MPI_VAL" % (p['name'], p['_array_length']) + uses['MPI_Info_f2c'] = 1 + arg = "MPI_Info_f2c(%s(1:%s)%%MPI_VAL)" % (p['name'], p['_array_length']) elif p['kind'] == 'ATTRIBUTE_VAL' and RE.match(r'MPI_(Comm|Win)_get_attr', f08ts_name): arg = p['name'] else: @@ -625,8 +632,8 @@ def post_string_len(v): arg = process_index(p) elif f08_mapping[p['kind']] == "PROCEDURE": arg = process_procedure(p) - elif p['kind'] == 'FILE': - arg = process_mpi_file(p) + elif RE.match(r'TYPE\(MPIX?_\w+\)', f08_mapping[p['kind']], re.IGNORECASE): + arg = process_mpi_handle(p) else: arg = process_integer(p) if arg != p['name']: @@ -714,6 +721,7 @@ def dump_call(s): dump_F_if_open("c_associated(c_loc(sendbuf), c_loc(MPI_IN_PLACE))") dump_alltoallvw_inplace() dump_F_else() + dump_alltoallvw_types() dump_call("%s = %s(%s)" % (ret, c_func_name, ', '.join(arg_list))) if is_alltoallvw: dump_F_if_close() @@ -1167,7 +1175,10 @@ def dump_handle_f2c(): if RE.match(r'MPIX?_(\w+)', a): c_name = "c_" + RE.m.group(1) for p in [("f", "c"), ("c", "f")]: - func_name = "%s_%s2%s" % (a, p[0], p[1]) + if a == 'MPI_Datatype': + func_name = "MPI_Type_%s2%s" % (p[0], p[1]) + else: + func_name = "%s_%s2%s" % (a, p[0], p[1]) G.out.append("") G.out.append("FUNCTION %s(x) bind(C, name=\"P%s\") result(res)" % (func_name, func_name)) G.out.append(" USE mpi_c_interface_types, ONLY: %s" % c_name) @@ -1329,6 +1340,25 @@ def check_func_directives(func): # c-only func['_skip_fortran'] = 1 +def get_f2c_name(p): + """Returns (f2c_func, c2f_func) names for MPI handle conversion.""" + kind_map = { + 'COMMUNICATOR': 'MPI_Comm', + 'DATATYPE': 'MPI_Type', + 'GROUP': 'MPI_Group', + 'REQUEST': 'MPI_Request', + 'WINDOW': 'MPI_Win', + 'OPERATION': 'MPI_Op', + 'INFO': 'MPI_Info', + 'FILE': 'MPI_File', + 'ERRHANDLER': 'MPI_Errhandler', + 'MESSAGE': 'MPI_Message', + 'SESSION': 'MPI_Session', + 'STREAM': 'MPIX_Stream', + } + prefix = kind_map[p['kind']] + return ("%s_f2c" % prefix, "%s_c2f" % prefix) + # ------------------------------- def need_ptr_check(p): # Array parameter that may have special constant values From 9e25b88f017720df3914a7faa8d5ae9992178c6f Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 17 Aug 2026 10:40:43 -0500 Subject: [PATCH 37/39] fortran/f08: add dump_decl_list to deduplicate c_decl_list --- maint/local_python/binding_f08.py | 51 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index c00f5c3db4f..0f3f6686d44 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -460,8 +460,7 @@ def process_array(p): if p['_array_convert'] == "MPI_VAL": arg_c = "%s_c" % p['name'] - if "INTEGER :: i" not in c_decl_list: - c_decl_list.append("INTEGER :: i") + c_decl_list.append("INTEGER :: i") (f2c, c2f) = get_f2c_name(p) if RE.match(r'in|inout', p['param_direction']): uses[f2c] = 1 @@ -530,8 +529,7 @@ def process_array(p): elif is_MPI_VAL: (f2c, c2f) = get_f2c_name(p) uses[f2c] = 1 - if "INTEGER :: i" not in c_decl_list: - c_decl_list.append("INTEGER :: i") + c_decl_list.append("INTEGER :: i") if not is_alltoallvw: # alltoallvw types are handled in dump_alltoallvw_inplace/normal convert_list_pre.append("do i = 1, %s" % length) @@ -664,26 +662,14 @@ def post_string_len(v): if need_int_conversions: uses['c_int'] = 1 - # -- dump to G.out - G.out.append("") - if 'return' not in func: - dump_fortran_line("SUBROUTINE %s(%s)" % (f08ts_name, ', '.join(f_param_list))) - else: - dump_fortran_line("FUNCTION %s(%s) result(res)" % (f08ts_name, ', '.join(f_param_list))) - G.out.append("INDENT") - dump_F_uses(uses) - G.out.append("") - G.out.append("IMPLICIT NONE") - G.out.append("") - G.out.extend(f_decl_list) - G.out.append("") - G.out.extend(c_decl_list) - G.out.append("") - if convert_list_pre: - G.out.extend(convert_list_pre) - G.out.append("") - # ---- + def dump_decl_list(c_decl_list): + seen = set() + for decl in c_decl_list: + if decl not in seen: + seen.add(decl) + G.out.append(decl) + def dump_call(s): if need_check_status_ignore: p = need_check_status_ignore # the status parameter @@ -708,6 +694,25 @@ def dump_call(s): else: dump_fortran_line(s) + # -- dump to G.out + G.out.append("") + if 'return' not in func: + dump_fortran_line("SUBROUTINE %s(%s)" % (f08ts_name, ', '.join(f_param_list))) + else: + dump_fortran_line("FUNCTION %s(%s) result(res)" % (f08ts_name, ', '.join(f_param_list))) + G.out.append("INDENT") + dump_F_uses(uses) + G.out.append("") + G.out.append("IMPLICIT NONE") + G.out.append("") + G.out.extend(f_decl_list) + G.out.append("") + dump_decl_list(c_decl_list) + G.out.append("") + if convert_list_pre: + G.out.extend(convert_list_pre) + G.out.append("") + # ---- if 'return' not in func: ret = 'ierror_c' From ca118a007f18805b003ae5e64b6d2c39b91e7cfd Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 17 Aug 2026 15:24:11 -0500 Subject: [PATCH 38/39] fortran: add configure check to build without MPIX If configure detect there is not necessary MPIX functions defined in the exposed mpi.h, skip exposing fortran interface for MPIX functions, and use fallback for registering callbacks. That may mean the callback won't parse some argument correctly without c2f conversions. --- maint/local_python/binding_f08.py | 11 ++- maint/local_python/binding_f77.py | 25 +++++-- src/binding/fortran/configure.ac | 17 ++++- src/binding/fortran/mpif_h/f2c_impl.c | 2 + src/binding/fortran/mpif_h/mpi_fortran.h.in | 2 + src/binding/fortran/mpif_h/user_proxy.c | 68 +++++++++++++++++-- .../fortran/use_mpi_f08/wrappers_c/utils.c | 4 +- 7 files changed, 114 insertions(+), 15 deletions(-) diff --git a/maint/local_python/binding_f08.py b/maint/local_python/binding_f08.py index 0f3f6686d44..fdba0f8ba25 100644 --- a/maint/local_python/binding_f08.py +++ b/maint/local_python/binding_f08.py @@ -762,6 +762,7 @@ def dump_mpi_c_interface_cdesc(func, is_large): def dump_mpi_c_interface_nobuf(func, is_large): name = get_f08_c_name(func, is_large) + has_mpix = ('skip-mpix' not in G.opts) if RE.match(r'mpi_(comm|type|win|file|session)_create_(errhandler|keyval)', func['name'], re.IGNORECASE): c_name = re.sub(r'MPI_', r'MPII_', func['name']) elif RE.match(r'mpi_comm_spawn(_multiple)?$', func['name'], re.IGNORECASE): @@ -772,7 +773,7 @@ def dump_mpi_c_interface_nobuf(func, is_large): c_name = "MPII_op_create" elif RE.match(r'mpi_grequest_start', func['name'], re.IGNORECASE) and not is_large: c_name = "MPII_greq_start" - elif RE.match(r'mpi_(comm|type|win)_(get|set)_attr', func['name'], re.IGNORECASE) and not is_large: + elif RE.match(r'mpi_(comm|type|win)_(get|set)_attr', func['name'], re.IGNORECASE) and not is_large and has_mpix: c_name = "PMPIX_%s_%s_attr_as_fortran" % RE.m.group(1, 2) else: # uses PMPI c binding directly @@ -1322,6 +1323,10 @@ def check_func_directives(func): func['_skip_fortran'] = 1 elif 'skip' in func and RE.search(r'Fortran', func['skip'], re.IGNORECASE): func['_skip_fortran'] = 1 + elif 'skip-mpix' in G.opts and RE.match(r'mpix_', func['name'], re.IGNORECASE): + func['_skip_fortran'] = 1 + elif 'skip-mpix' in G.opts and RE.match(r'mpix_', func['name'], re.IGNORECASE): + func['_skip_fortran'] = 1 elif RE.match(r'mpix_(grequest_|type_iov|async_)', func['name'], re.IGNORECASE): func['_skip_fortran'] = 1 elif RE.match(r'mpi_attr_', func['name'], re.IGNORECASE): @@ -1724,7 +1729,9 @@ def translate_autoconf(name): if RE.match(r'#define\s+(MPI_\w+)\s+(.+)', line): # direct macros (name, val) = RE.m.group(1, 2) - if RE.match(r'\(+(MPI_\w+)\)\(?0x([0-9a-fA-F]+)', val): + if RE.match(r'MPI_ABI_(Aint|Offset|Count)', name): + continue + elif RE.match(r'\(+(MPI_\w+)\)\(?0x([0-9a-fA-F]+)', val): # handle constants - hex (T, V) = RE.m.group(1, 2) val = hex_to_signed_int(V) diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index dad253cf110..ac595860cbe 100644 --- a/maint/local_python/binding_f77.py +++ b/maint/local_python/binding_f77.py @@ -862,13 +862,16 @@ def process_func_parameters(): process_func_parameters() c_func_name = func_name + has_mpix = ('skip-mpix' not in G.opts) if RE.match(r'MPI_Attr_(get|put)', func['name'], re.IGNORECASE): - if RE.m.group(1) == 'put': - c_func_name = "MPIX_Comm_set_attr_as_fortran" - else: - c_func_name = "MPIX_Comm_get_attr_as_fortran" + if has_mpix: + if RE.m.group(1) == 'put': + c_func_name = "MPIX_Comm_set_attr_as_fortran" + else: + c_func_name = "MPIX_Comm_get_attr_as_fortran" elif RE.match(r'MPI_(Comm|Type|Win)_(get|set)_attr$', func['name'], re.IGNORECASE): - c_func_name = "MPIX_%s_%s_attr_as_fortran" % RE.m.group(1, 2) + if has_mpix: + c_func_name = "MPIX_%s_%s_attr_as_fortran" % RE.m.group(1, 2) elif re.match(r'MPI_(Init|Init_thread|Info_create_env)$', func['name'], re.IGNORECASE): # argc, argv c_arg_list_A.insert(0, "0, 0") @@ -1096,7 +1099,9 @@ def translate_autoconf(name): # direct macros (name, val) = RE.m.group(1, 2) - if RE.match(r'\(+MPI_\w+\)\(?0x([0-9a-fA-F]+)', val): + if RE.match(r'MPI_ABI_(Aint|Offset|Count)', name): + continue + elif RE.match(r'\(+MPI_\w+\)\(?0x([0-9a-fA-F]+)', val): # handle constants val = hex_to_signed_int(RE.m.group(1)) elif RE.match(r'\(+MPI_\w+\)\s*([-0-9]+)', val): @@ -1308,10 +1313,18 @@ def dump_fortran_line(s): # ------------------------------- def check_func_directives(func): + none_standard = False + if RE.match(r'mpix_', func['name'], re.IGNORECASE): + none_standard = True + elif 'replace' in func: + none_standard = True + if 'dir' in func and func['dir'] == "mpit": func['_skip_fortran'] = 1 elif 'skip' in func and RE.search(r'Fortran', func['skip'], re.IGNORECASE): func['_skip_fortran'] = 1 + elif 'skip-mpix' in G.opts and none_standard: + func['_skip_fortran'] = 1 elif RE.match(r'mpix_(grequest_|type_iov|async_|(comm|file|win|session|type)_create_(errhandler|keyval)_x|op_create_x)', func['name'], re.IGNORECASE): func['_skip_fortran'] = 1 elif RE.match(r'mpi_\w+_((f|f08|c)2(f|f08|c)|fromint|toint)$', func['name'], re.IGNORECASE): diff --git a/src/binding/fortran/configure.ac b/src/binding/fortran/configure.ac index b7ee891d43c..9e536216545 100644 --- a/src/binding/fortran/configure.ac +++ b/src/binding/fortran/configure.ac @@ -61,7 +61,7 @@ if test "$FROM_MPICH" = "yes" ; then mpi_h="$main_top_srcdir/src/include/mpi_mpich.h.in" elif test "$WITH_MPI" = "abi" ; then PAC_APPEND_FLAG(-I${main_top_srcdir}/src/binding, [CPPFLAGS]) - mpi_h="$main_top_srcdir/src/binding/mpi_abi.h" + mpi_h="$main_top_srcdir/src/binding/abi/mpi_abi.h" else AC_MSG_ERROR([$FROM_MPICH is set but $WITH_MPI is not set!]) fi @@ -131,6 +131,12 @@ if test -z "$MPI_SIZEOF_COUNT" ; then AC_MSG_ERROR([Can't determine the size of MPI_Count]) fi +# TODO: check specific MPIX functions +has_mpix=no +AC_CHECK_DECL([MPIX_Comm_create_keyval_x], [has_mpix=yes], [], [#include "mpi.h"]) +if test "$has_mpix" = "yes" ; then + AC_DEFINE([MPICH_HAS_MPIX], 1, [Define HAS_MPIX if we are building against MPICH ABI]) +fi dnl enable_fortran is assumed to be true @@ -1046,6 +1052,9 @@ if test "$skip_gen_bindings" = no ; then if test -n "$mpi_h" ; then cmd_f77="$cmd_f77 -mpi-h=$mpi_h" fi + if test "$has_mpix" = "no" ; then + cmd_f77="$cmd_f77 -skip-mpix" + fi cmd_f77="$cmd_f77 -integer-kind=$INTEGER_KIND -address-kind=$ADDRESS_KIND -count-kind=$COUNT_KIND -offset-kind=$OFFSET_KIND" # if mpi_h is mpi_mpich.in, pass in those autoconf macro values if test -n "$MPI_MAX_PROCESSOR_NAME" ; then @@ -1058,6 +1067,9 @@ if test "$skip_gen_bindings" = no ; then PAC_FC_CHECK_IGNORE_TKR PAC_FC_ISO_C_BINDING cmd_f90="$PYTHON $maintdir/gen_binding_f90.py" + if test "$has_mpix" = "no" ; then + cmd_f90="$cmd_f90 -skip-mpix" + fi # pass in type sizes for MPI_SIZEOF cmd_f90="$cmd_f90 -f-logical-size=$pac_cv_f77_sizeof_logical" if test "$pac_fc_ignore_tkr" != "no" ; then @@ -1076,6 +1088,9 @@ if test "$skip_gen_bindings" = no ; then if test -n "$mpi_h" ; then cmd_f08="$cmd_f08 -mpi-h=$mpi_h" fi + if test "$has_mpix" = "no" ; then + cmd_f08="$cmd_f08 -skip-mpix" + fi if test "$pac_fc_has_real128" = "no" ; then cmd_f08="$cmd_f08 -no-real128" fi diff --git a/src/binding/fortran/mpif_h/f2c_impl.c b/src/binding/fortran/mpif_h/f2c_impl.c index b60662fb8c8..0896457792b 100644 --- a/src/binding/fortran/mpif_h/f2c_impl.c +++ b/src/binding/fortran/mpif_h/f2c_impl.c @@ -317,6 +317,7 @@ MPI_Win PMPI_Win_f2c(MPI_Fint win) return MPI_Win_fromint(win); } +#ifdef MPICH_HAS_MPIX MPI_Fint MPIX_Stream_c2f(MPIX_Stream stream) { return (MPI_Fint) MPIX_Stream_toint(stream); @@ -336,3 +337,4 @@ MPIX_Stream PMPIX_Stream_f2c(MPI_Fint stream) { return MPIX_Stream_fromint(stream); } +#endif diff --git a/src/binding/fortran/mpif_h/mpi_fortran.h.in b/src/binding/fortran/mpif_h/mpi_fortran.h.in index 972d0b7b474..eb91da8ab2b 100644 --- a/src/binding/fortran/mpif_h/mpi_fortran.h.in +++ b/src/binding/fortran/mpif_h/mpi_fortran.h.in @@ -87,9 +87,11 @@ MPI_Win MPI_Win_f2c(MPI_Fint win); MPI_Fint PMPI_Win_c2f(MPI_Win win); MPI_Win PMPI_Win_f2c(MPI_Fint win); +#ifdef MPICH_HAS_MPIX MPI_Fint MPIX_Stream_c2f(MPIX_Stream stream); MPIX_Stream MPIX_Stream_f2c(MPI_Fint stream); MPI_Fint PMPIX_Stream_c2f(MPIX_Stream stream); MPIX_Stream PMPIX_Stream_f2c(MPI_Fint stream); +#endif void MPIX_Init_fortran(void) MPICH_API_PUBLIC; diff --git a/src/binding/fortran/mpif_h/user_proxy.c b/src/binding/fortran/mpif_h/user_proxy.c index 019980f114c..a495742644a 100644 --- a/src/binding/fortran/mpif_h/user_proxy.c +++ b/src/binding/fortran/mpif_h/user_proxy.c @@ -56,10 +56,12 @@ static int F77_attr_delete_proxy(int handle, int keyval, void *value, void *cont return (int) ierr; } +#ifdef MPICH_HAS_MPIX static void F77_keyval_free(void *extra_state) { MPL_free(extra_state); } +#endif static int F77_Comm_attr_copy_proxy(MPI_Comm comm, int keyval, void *context, void *value_in, void *value_out, int *flag) @@ -109,6 +111,7 @@ int MPII_Keyval_create(F90_CopyFunction copy_fn, F90_DeleteFunction delete_fn, i p->extra_state = extra_state; int mpi_errno = MPI_SUCCESS; +#ifdef MPICH_HAS_MPIX switch (type) { case F77_COMM: mpi_errno = MPIX_Comm_create_keyval_x(F77_Comm_attr_copy_proxy, @@ -128,6 +131,25 @@ int MPII_Keyval_create(F90_CopyFunction copy_fn, F90_DeleteFunction delete_fn, i default: assert(0); } +#else + /* Without MPIX extension, we can't set F77_keyval_free, thus will leak F77_attr_state */ + switch (type) { + case F77_COMM: + mpi_errno = MPI_Comm_create_keyval(F77_Comm_attr_copy_proxy, + F77_Comm_attr_delete_proxy, keyval_out, p); + break; + case F77_WIN: + mpi_errno = MPI_Win_create_keyval(F77_Win_attr_copy_proxy, + F77_Win_attr_delete_proxy, keyval_out, p); + break; + case F77_DATATYPE: + mpi_errno = MPI_Type_create_keyval(F77_Type_attr_copy_proxy, + F77_Type_attr_delete_proxy, keyval_out, p); + break; + default: + assert(0); + } +#endif if (mpi_errno == MPI_SUCCESS) { p->keyval = *keyval_out; @@ -158,6 +180,7 @@ int MPII_Type_create_keyval(F90_CopyFunction copy_fn, F90_DeleteFunction delete_ } /* ---- user op ----------------- */ +#ifdef MPICH_HAS_MPIX struct F77_op_state { F77_OpFunction *opfn; }; @@ -177,23 +200,33 @@ static void F77_op_free(void *extra_state) MPL_free(extra_state); } +#endif + int MPII_op_create(F77_OpFunction * opfn, MPI_Fint commute, MPI_Fint * op) { + MPI_Op op_i; +#ifdef MPICH_HAS_MPIX struct F77_op_state *p = MPL_malloc(sizeof(struct F77_op_state), MPL_MEM_OTHER); p->opfn = opfn; - MPI_Op op_i; int ret = MPIX_Op_create_x(F77_op_proxy, F77_op_free, commute, p, &op_i); +#else + /* MPI will call opfn directly, the datatype argument likely won't work */ + int ret = MPI_Op_create((MPI_User_function *) opfn, commute, &op_i); +#endif if (ret == MPI_SUCCESS) { *op = MPI_Op_toint(op_i); } else { +#ifdef MPICH_HAS_MPIX MPL_free(p); +#endif } return ret; } /* ---- user errhandler ----------------- */ +#ifdef MPICH_HAS_MPIX struct F77_errhan_state { F77_ErrFunction *err_fn; }; @@ -239,13 +272,16 @@ static void F77_errhan_free(void *extra_state) MPL_free(extra_state); } +#endif + int MPII_errhan_create(F77_ErrFunction * err_fn, MPI_Fint * errhandler, enum F77_handle_type type) { - struct F77_errhan_state *p = MPL_malloc(sizeof(struct F77_errhan_state), MPL_MEM_OTHER); - p->err_fn = err_fn; - MPI_Errhandler errhandler_i; int ret = MPI_SUCCESS; + +#ifdef MPICH_HAS_MPIX + struct F77_errhan_state *p = MPL_malloc(sizeof(struct F77_errhan_state), MPL_MEM_OTHER); + p->err_fn = err_fn; switch (type) { case F77_COMM: ret = MPIX_Comm_create_errhandler_x(F77_comm_errhan_proxy, F77_errhan_free, @@ -266,10 +302,34 @@ int MPII_errhan_create(F77_ErrFunction * err_fn, MPI_Fint * errhandler, enum F77 default: assert(0); } +#else + /* MPI will call err_fn directly, the comm/win/file/sessioin argument likely won't work */ + switch (type) { + case F77_COMM: + ret = MPI_Comm_create_errhandler((MPI_Comm_errhandler_function *) err_fn, + &errhandler_i); + break; + case F77_WIN: + ret = MPI_Win_create_errhandler((MPI_Win_errhandler_function *) err_fn, &errhandler_i); + break; + case F77_FILE: + ret = MPI_File_create_errhandler((MPI_File_errhandler_function *) err_fn, + &errhandler_i); + break; + case F77_SESSION: + ret = MPI_Session_create_errhandler((MPI_Session_errhandler_function *) err_fn, + &errhandler_i); + break; + default: + assert(0); + } +#endif if (ret == MPI_SUCCESS) { *errhandler = MPI_Errhandler_toint(errhandler_i); } else { +#ifdef MPICH_HAS_MPIX MPL_free(p); +#endif } return ret; diff --git a/src/binding/fortran/use_mpi_f08/wrappers_c/utils.c b/src/binding/fortran/use_mpi_f08/wrappers_c/utils.c index c3060fb7709..ce74a143ac6 100644 --- a/src/binding/fortran/use_mpi_f08/wrappers_c/utils.c +++ b/src/binding/fortran/use_mpi_f08/wrappers_c/utils.c @@ -6,8 +6,8 @@ #include "cdesc.h" #include -int MPIR_F08_MPI_IN_PLACE MPICH_API_PUBLIC; -int MPIR_F08_MPI_BOTTOM MPICH_API_PUBLIC; +int MPIR_F08_MPI_IN_PLACE; +int MPIR_F08_MPI_BOTTOM; /* Convert an array of strings in Fortran Format to an array of strings in C format (i.e., char* a[]). From 5d72a191558411728d66c04b775a1dad643ef6b9 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 18 Aug 2026 11:38:15 -0500 Subject: [PATCH 39/39] temp: fixup fortran/configure dependency on mpi.h --- src/binding/fortran/configure.ac | 47 ++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/binding/fortran/configure.ac b/src/binding/fortran/configure.ac index 9e536216545..0a88c7c4ce2 100644 --- a/src/binding/fortran/configure.ac +++ b/src/binding/fortran/configure.ac @@ -37,7 +37,9 @@ PAC_PREFIX_ALL_FLAGS(WRAPPER) AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi=dir], [Specify the path where MPI is installed.])],,with_mpi=mpich) +# $mpi_h is needed for python scripts gen_binding_{f77,f90,f08}.py mpi_h= + AC_ARG_VAR([MPILIBNAME], [default: "mpi"]) AC_ARG_VAR([LPMPILIBNAME], [default: ""]) AC_SUBST(MPILIBNAME) @@ -53,15 +55,13 @@ export MPIFCLIBNAME AC_SUBST(MPIFCLIBNAME) if test "$FROM_MPICH" = "yes" ; then + PAC_APPEND_FLAG(-I${main_top_builddir}/src/include, [CPPFLAGS]) if test "$WITH_MPI" = "mpich" ; then - # We expect the following vars to be set from parent configure - # MPI_MAX_PROCESSOR_NAME, MPI_MAX_LIBRARY_VERSION_STRING, MPI_MAX_ERROR_STRING, BSEND_OVERHEAD - # MPI_SIZEOF_AINT, MPI_SIZEOF_OFFSET, MPI_SIZEOF_COUNT - PAC_APPEND_FLAG(-I${main_top_srcdir}/src/include, [CPPFLAGS]) mpi_h="$main_top_srcdir/src/include/mpi_mpich.h.in" + has_mpix=yes elif test "$WITH_MPI" = "abi" ; then - PAC_APPEND_FLAG(-I${main_top_srcdir}/src/binding, [CPPFLAGS]) mpi_h="$main_top_srcdir/src/binding/abi/mpi_abi.h" + has_mpix=no else AC_MSG_ERROR([$FROM_MPICH is set but $WITH_MPI is not set!]) fi @@ -103,24 +103,31 @@ fi AC_PROG_CC AM_PROG_CC_C_O -# check some constants from mpi.h -if test -z "$MPI_SIZEOF_AINT" -a -n "$mpi_h" ; then - AC_CHECK_SIZEOF(MPI_Aint, 0, [#include "mpi.h"]) - if test $ac_cv_sizeof_MPI_Aint -gt "0" ; then - MPI_SIZEOF_AINT=$ac_cv_sizeof_MPI_Aint - fi +if test "$FROM_MPICH" != "yes" ; then + # check mpi.h if we are not build with MPICH + if test -z "$MPI_SIZEOF_AINT" ; then + AC_CHECK_SIZEOF(MPI_Aint, 0, [#include "mpi.h"]) + if test $ac_cv_sizeof_MPI_Aint -gt "0" ; then + MPI_SIZEOF_AINT=$ac_cv_sizeof_MPI_Aint + fi - AC_CHECK_SIZEOF(MPI_Offset, 0, [#include "mpi.h"]) - if test $ac_cv_sizeof_MPI_Offset -gt "0" ; then - MPI_SIZEOF_OFFSET=$ac_cv_sizeof_MPI_Offset - fi + AC_CHECK_SIZEOF(MPI_Offset, 0, [#include "mpi.h"]) + if test $ac_cv_sizeof_MPI_Offset -gt "0" ; then + MPI_SIZEOF_OFFSET=$ac_cv_sizeof_MPI_Offset + fi - AC_CHECK_SIZEOF(MPI_Count, 0, [#include "mpi.h"]) - if test $ac_cv_sizeof_MPI_Count -gt "0" ; then - MPI_SIZEOF_COUNT=$ac_cv_sizeof_MPI_Count + AC_CHECK_SIZEOF(MPI_Count, 0, [#include "mpi.h"]) + if test $ac_cv_sizeof_MPI_Count -gt "0" ; then + MPI_SIZEOF_COUNT=$ac_cv_sizeof_MPI_Count + fi fi + + # TODO: check specific MPIX functions + has_mpix=no + AC_CHECK_DECL([MPIX_Comm_create_keyval_x], [has_mpix=yes], [], [#include "mpi.h"]) fi +# sanity check if test -z "$MPI_SIZEOF_AINT" ; then AC_MSG_ERROR([Can't determine the size of MPI_Aint]) fi @@ -131,13 +138,11 @@ if test -z "$MPI_SIZEOF_COUNT" ; then AC_MSG_ERROR([Can't determine the size of MPI_Count]) fi -# TODO: check specific MPIX functions -has_mpix=no -AC_CHECK_DECL([MPIX_Comm_create_keyval_x], [has_mpix=yes], [], [#include "mpi.h"]) if test "$has_mpix" = "yes" ; then AC_DEFINE([MPICH_HAS_MPIX], 1, [Define HAS_MPIX if we are building against MPICH ABI]) fi + dnl enable_fortran is assumed to be true # Add MPICHLIB_* to the appropriate flags