diff --git a/.gitignore b/.gitignore index 9ee19103b5d..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 @@ -403,50 +393,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 @@ -460,24 +406,16 @@ 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 +/src/include/mpi_mpich.h /src/include/mpif.h #/src/include/mpe_thread.h /src/include/mpimod.pcl @@ -509,7 +447,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/Makefile.am b/Makefile.am index 44fc74d15d1..6bc50080240 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 ## @@ -101,8 +86,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 @@ -112,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 = @@ -124,10 +106,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 +127,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,55 +138,48 @@ 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 -# 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 +# -------- mpi-abi: libpmpi + libmpi ------------------ +# +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) +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 = $(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) $(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 -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 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 @@ -225,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' \ @@ -243,60 +222,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 \ - cd ${DESTDIR}${bindir} && ln -f -s @MPIFORT_NAME@ @MPIF90_NAME@ ; \ - 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 \ - cd ${DESTDIR}${bindir} && ln -f -s @MPIFORT_NAME@ @MPIF77_NAME@ ; \ - fi ; \ - 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@ ; \ - 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 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_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/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/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/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/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 988cd33c22b..a42bc3bc92f 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) @@ -285,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]) @@ -313,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 @@ -472,15 +450,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) @@ -496,6 +465,16 @@ 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) + +# 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, @@ -503,11 +482,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) @@ -586,25 +567,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_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], @@ -665,12 +627,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 @@ -764,30 +735,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]) - # compute canonical system types AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -808,7 +755,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 @@ -867,10 +814,6 @@ export CFLAGS export CPPFLAGS export CXX export CXXFLAGS -export F77 -export FC -export FCFLAGS -export FFLAGS export LDFLAGS export LIBS @@ -906,35 +849,31 @@ 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. # 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) - -# We'll set FORTRAN_BINDING to 1 if we support Fortran -FORTRAN_BINDING=0 # enable-fast # strip off multiple options, separated by commas @@ -1050,13 +989,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 @@ -1064,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 @@ -1326,34 +1262,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 @@ -1422,7 +1346,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 @@ -1806,442 +1730,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]) - # 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 -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 - bindingsubsystems="$bindingsubsystems src/binding/fortran/use_mpi" - 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], @@ -2255,8 +1745,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]) @@ -2362,13 +1852,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, @@ -2436,42 +1919,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 @@ -2951,248 +2404,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)]) - - 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 - - # 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. Support for this case is experimental; use at your own risk]) - 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 @@ -3253,12 +2464,6 @@ else ac_cv_sizeof_LongDoubleComplex=0 fi -# ------------ -# MPI_FINT -# ------------ -# MPI_FINT is already set -AC_SUBST(MPI_FINT) - # ------------ # MPI_AINT # ------------ @@ -3348,7 +2553,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. @@ -3364,8 +2568,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], @@ -3383,36 +2587,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 @@ -3426,17 +2600,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]) @@ -3480,66 +2652,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]) @@ -3602,19 +2714,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]) @@ -3809,15 +2908,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}" @@ -3826,6 +2921,9 @@ else fi AC_SUBST(LMPICXXLIBNAME) +# export to src/binding/fortran/configure +export MPILIBNAME LPMPILIBNAME + # ---------------------------------------------------------------------------- # with MPI_AINT defined, now we can @@ -3993,7 +3091,7 @@ 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 +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 @@ -4001,35 +3099,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]) - -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 @@ -4066,13 +3135,8 @@ 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"]) -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 @@ -4090,17 +3154,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 @@ -4140,10 +3198,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 @@ -4165,99 +3219,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 @@ -4273,60 +3234,33 @@ 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 +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 + 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 \ @@ -4342,38 +3276,33 @@ 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.h \ + src/include/mpi_mpich.h \ 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 -# 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 < 0) THEN") @@ -241,42 +240,46 @@ 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" - else: - arg_1 = p['name'] - arg_2 = "%s_c" % 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" - 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, p['name'])) 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" % (p['name'], arg_c)) + return arg_c + else: + 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)) - return (arg, 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): arg = "%s_c" % p['name'] @@ -288,7 +291,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'] @@ -301,7 +304,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'] @@ -332,51 +335,48 @@ 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": @@ -387,7 +387,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): @@ -403,33 +402,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") @@ -437,8 +437,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": @@ -446,65 +446,63 @@ 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'] - else: - arg_1 = "%s%%MPI_VAL" % p['name'] - arg_2 = "%s_c" % p['name'] + arg_c = "%s_c" % p['name'] + c_decl_list.append("INTEGER :: i") + (f2c, c2f) = get_f2c_name(p) if RE.match(r'in|inout', p['param_direction']): - convert_list_1.append("%s = %s" % (arg_2, arg_1)) + 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']): - convert_list_2.append("%s = %s" % (arg_1, arg_2)) + 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_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 - else: - use_list = convert_list_1 - 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): @@ -514,55 +512,59 @@ 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") - 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)") + 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") - # 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: + (f2c, c2f) = get_f2c_name(p) + uses[f2c] = 1 + 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: - 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 @@ -581,13 +583,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']: @@ -603,40 +604,41 @@ 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']) + 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_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) - elif p['kind'] == 'FILE': - (arg_1, arg_2) = process_mpi_file(p) + arg = process_procedure(p) + elif RE.match(r'TYPE\(MPIX?_\w+\)', f08_mapping[p['kind']], re.IGNORECASE): + arg = process_mpi_handle(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 @@ -657,30 +659,18 @@ 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 - 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_call(s, check_int_kind): + 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 if p['length'] is None: @@ -691,40 +681,53 @@ 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: 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' else: ret = 'res' - 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 not ('skip' in func and RE.search(r'initcheck', func['skip'], re.IGNORECASE)): + G.out.append("call MPIR_Init_fortran()") + if is_alltoallvw: + 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() G.out.append("") @@ -759,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): @@ -769,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 @@ -793,6 +797,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']: @@ -920,7 +931,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) @@ -936,22 +947,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) @@ -1159,7 +1181,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) @@ -1296,6 +1321,12 @@ 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 '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): @@ -1319,6 +1350,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 @@ -1647,13 +1697,30 @@ def dump_compile_constants_f90(f): print("end module mpi_f08_compile_constants", file=Out) -def load_mpi_h_in(f): +"""load_mpi_h - loads mpi.h or MPICH's mpi_mpich.h.in + use regex, it only works with - + * mpi.h from https://github.com/mpi-forum/mpi-abi-stubs + * mpi.h from mpich +""" +def load_mpi_h(f): def hex_to_signed_int(s): val = int(s, 16) if val >= 0x80000000: val = val - 0x100000000 return val + def translate_autoconf(name): + if name == 'MPI_MAX_PROCESSOR_NAME': + return G.opts['max-processor-name'] + elif name == 'MPI_MAX_LIBRARY_VERSION_STRING': + return G.opts['max-version-string'] + elif name == 'MPI_MAX_ERROR_STRING': + return G.opts['max-error-string'] + elif name == 'BSEND_OVERHEAD': + return G.opts['bsend-overhead'] + else: + raise Exception("Unexpected autoconf macro " + name) + # load constants into G.mpih_defines with open(f, "r") as In: for line in In: @@ -1662,34 +1729,33 @@ def hex_to_signed_int(s): if RE.match(r'#define\s+(MPI_\w+)\s+(.+)', line): # direct macros (name, val) = RE.m.group(1, 2) - if re.match(r'MPI_FILE_NULL', name): - val = "MPI_File(0)" - elif re.match(r'MPI_(LONG_LONG|C_FLOAT_COMPLEX)', val): - # datatype aliases - val = G.mpih_defines[val] - elif re.match(r'\(?\(MPI_Datatype\)\@(MPIR?_\w+)\@\)?', val): - val = "DATATYPE" + 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 + # handle constants - hex (T, V) = RE.m.group(1, 2) val = hex_to_signed_int(V) val = "%s(%d) ! 0x%s" % (T, hex_to_signed_int(V), V) - elif RE.match(r'0x([0-9a-fA-F]+)', val): - # direct hex constants (KEYVAL constants) - val = int(RE.m.group(1), 16) - val = str(val) + (" ! 0x%08x" % val) - elif RE.match(r'MPI_MAX_', name): - # Fortran string buffer limit need be 1-less - if re.match(r'@\w+@', val): - val += "-1" - else: - val = int(val) - 1 - elif RE.match(r'\(([-\d]+)\)', val): - # take off the extra parentheses + elif RE.match(r'\(+(MPI_\w+)\)(\d+)', val): + # handle constants - decimal + (T, V) = RE.m.group(1, 2) + val = "%s(%s)" % (T, V) + elif RE.match(r'@(\w+)@', val): + # MPICH autoconf macros + val = translate_autoconf(RE.m.group(1)) + elif re.match(r'MPI_(LONG_LONG|C_FLOAT_COMPLEX)', val): + # datatype aliases + val = G.mpih_defines[val] + elif RE.match(r'\(+MPI_Offset\)\s*(-?\d+)', val): val = RE.m.group(1) - + elif RE.match(r'0x([0-9a-fA-F]+)\s*$', val): + val = hex_to_signed_int(RE.m.group(1)) + elif re.match(r'^(\d+)\s*$', val): + if re.match(r'MPI_MAX_', name): + # Fortran string buffer limit need be 1-less + val = int(val) - 1 G.mpih_defines[name] = val - elif RE.match(r'\s+(MPI_\w+)\s*=\s*(\d+)', line): + elif RE.match(r'\s+(MPI_\w+)\s*=\s*(-?\d+)', line): # enum values (name, val) = RE.m.group(1, 2) G.mpih_defines[name] = val diff --git a/maint/local_python/binding_f77.py b/maint/local_python/binding_f77.py index 4b30e22a717..ac595860cbe 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,33 +831,47 @@ 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() 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") @@ -911,9 +931,10 @@ 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: - # FIXME: need check name mangling before call mpirinitf_() - G.out.append("if (MPIR_F_NeedInit) {mpirinitf_(); MPIR_F_NeedInit = 0;}") - G.out.append("") + # 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("") for l in code_list_common: G.out.append(l) @@ -942,6 +963,12 @@ def process_func_parameters(): for l in end_list_common: 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("if (MPIR_F_NeedInit) {mpirinitf_();}") + dump_mpi_decl_end() def dump_f77_c_file(f, lines): @@ -973,8 +1000,11 @@ def dump_mpif_h(f): for l in G.copyright_f77: print(l, file=Out) + # declare KIND parameters first since they may be used for later parameters for a in ['INTEGER', 'ADDRESS', 'COUNT', 'OFFSET']: - G.mpih_defines['MPI_%s_KIND' % a] = '@%s_KIND@' % a + print(" INTEGER MPI_%s_KIND" % a, file=Out) + print(" PARAMETER (MPI_%s_KIND=%s)" % (a, G.opts[a.lower() + '-kind']), file=Out) + G.mpih_defines['MPI_STATUS_SIZE'] = G.mpih_defines['MPI_F_STATUS_SIZE'] for a in ['SOURCE', 'TAG', 'ERROR']: G.mpih_defines['MPI_%s' % a] = int(G.mpih_defines['MPI_F_%s' % a]) + 1 @@ -991,7 +1021,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=MPI_OFFSET_KIND)' print(" %s %s" % (T, name), file=Out) print(" PARAMETER (%s=%s)" % (name, G.mpih_defines[name]), file=Out) @@ -1025,7 +1055,8 @@ def dump_mpif_h(f): print(" INTEGER MPI_ERRCODES_IGNORE(1)", file=Out) print(" CHARACTER*1 MPI_ARGVS_NULL(1,1)", file=Out) print(" CHARACTER*1 MPI_ARGV_NULL(1)", file=Out) - print("@DLLIMPORT@", file=Out) + if "DLLIMPORT" in G.opts: + print(G.opts["DLLIMPORT"], file=Out) print(" COMMON /MPIFCMB5/ MPI_UNWEIGHTED", file=Out) print(" COMMON /MPIFCMB9/ MPI_WEIGHTS_EMPTY", file=Out) print(" COMMON /MPIFCMBa/ MPI_BUFFER_AUTOMATIC", file=Out) @@ -1035,13 +1066,30 @@ 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): +"""load_mpi_h - loads mpi.h or MPICH's mpi_mpich.h.in + use regex, it only works with - + * mpi.h from https://github.com/mpi-forum/mpi-abi-stubs + * mpi.h from mpich +""" +def load_mpi_h(f): def hex_to_signed_int(s): val = int(s, 16) if val >= 0x80000000: val = val - 0x100000000 return val + def translate_autoconf(name): + if name == 'MPI_MAX_PROCESSOR_NAME': + return G.opts['max-processor-name'] + elif name == 'MPI_MAX_LIBRARY_VERSION_STRING': + return G.opts['max-version-string'] + elif name == 'MPI_MAX_ERROR_STRING': + return G.opts['max-error-string'] + elif name == 'BSEND_OVERHEAD': + return G.opts['bsend-overhead'] + else: + raise Exception("Unexpected autoconf macro " + name) + # load constants into G.mpih_defines with open(f, "r") as In: for line in In: @@ -1050,37 +1098,30 @@ def hex_to_signed_int(s): if RE.match(r'#define\s+(MPI_\w+)\s+(.+)', line): # direct macros (name, val) = RE.m.group(1, 2) - if re.match(r'MPI_FILE_NULL', name): - val = 0 - elif re.match(r'MPI_(LONG_LONG|C_FLOAT_COMPLEX)', val): - # datatype aliases - val = G.mpih_defines[val] - elif re.match(r'\(?\(MPI_Datatype\)\@(MPIR?_\w+)\@\)?', val): - # datatypes - if re.match(r'MPI_(AINT|OFFSET|COUNT)', name): - val = "@F77_%s_DATATYPE@" % name - elif RE.match(r'MPI_CXX_(\w+)', name): - val = "@F77_MPIR_CXX_%s@" % RE.m.group(1) - else: - val = "@F77_%s@" % name + + 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): + # type-cast constants (MPICH does this for MPI_FILE_NULL and MPI_DISPLACEMENT_CURRENT) + val = RE.m.group(1) elif RE.match(r'0x([0-9a-fA-F]+)', val): - # direct hex constants (KEYVAL constants) - val = int(RE.m.group(1), 16) - elif RE.match(r'MPI_MAX_', name): - # Fortran string buffer limit need be 1-less - if re.match(r'@\w+@', val): - val += "-1" - else: + # direct hex constants (MPICH's mpi.h use e.g. #define MPI_TAG_UB 0x64400001) + val = hex_to_signed_int(RE.m.group(1)) + elif RE.match(r'@(\w+)@', val): + # MPICH autoconf macros + val = translate_autoconf(RE.m.group(1)) + elif re.match(r'MPI_(LONG_LONG|C_FLOAT_COMPLEX)', val): + # datatype aliases + val = G.mpih_defines[val] + elif re.match(r'^(\d+)\s*$', val): + if re.match(r'MPI_MAX_', name): + # Fortran string buffer limit need be 1-less val = int(val) - 1 - elif RE.match(r'\(([-\d]+)\)', val): - # take off the extra parentheses - val = RE.m.group(1) - G.mpih_defines[name] = val - elif RE.match(r'\s+(MPI_\w+)\s*=\s*(\d+)', line): + elif RE.match(r'\s+(MPI_\w+)\s*=\s*(-?\d+)', line): # enum values (name, val) = RE.m.group(1, 2) G.mpih_defines[name] = val @@ -1272,8 +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/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): diff --git a/maint/release.pl b/maint/release.pl index f4934dfa9ea..19f7b9f8fdc 100755 --- a/maint/release.pl +++ b/maint/release.pl @@ -314,6 +314,16 @@ sub run_cmd run_cmd("cp -a libpmi-${version}.tar.gz ${root}/"); print("done\n"); +# Create the libfortran tarball +print("===> 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/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) 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/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/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/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..48007da9303 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', ); @@ -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 ); @@ -1857,7 +1856,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 +1866,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 +1880,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, @@ -2061,8 +2055,8 @@ 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 \"mpi.h\"\n"; + print $OUTFD "#include \"mpichconf.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/binding/fortran/.gitignore b/src/binding/fortran/.gitignore new file mode 100644 index 00000000000..4e89800ce85 --- /dev/null +++ b/src/binding/fortran/.gitignore @@ -0,0 +1,55 @@ +# 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/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 +# 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 + +/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 new file mode 100644 index 00000000000..6145bd69714 --- /dev/null +++ b/src/binding/fortran/Makefile.am @@ -0,0 +1,141 @@ +## +## 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 = +bin_SCRIPTS = +include_HEADERS = +noinst_LTLIBRARIES = +noinst_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 = $(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 + +# ---- 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 new file mode 100755 index 00000000000..981645971d4 --- /dev/null +++ b/src/binding/fortran/autogen.sh @@ -0,0 +1,50 @@ +#! /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 + cp -v $MPICH_CONFDB/config.rpath 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..0a88c7c4ce2 --- /dev/null +++ b/src/binding/fortran/configure.ac @@ -0,0 +1,1149 @@ +## +## 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/]) + +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]) +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 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) +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")]) +if test -z "$MPIFCLIBNAME" ; then + MPIFCLIBNAME="mpifort" ; +fi +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 + mpi_h="$main_top_srcdir/src/include/mpi_mpich.h.in" + has_mpix=yes + elif test "$WITH_MPI" = "abi" ; then + 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 + 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 + 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 + 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 + +# 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 + +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_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 +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 + +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 +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=""} + +# 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 + +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 + 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 + +# 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) + +# 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 +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]) + 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 + 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 + 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" + 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 + 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 "$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 + 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_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 \ + mpif_h/mpi_fortran.h \ + mpif_h/setbotf.f \ + mpif_h/cmblk.c \ + env/mpifort.sh \ + env/mpifort.bash \ + localdefs]) + +if test "$enable_f08" = "yes" ; then + AC_CONFIG_FILES([use_mpi_f08/mpi_c_interface_types.f90]) +fi +AC_OUTPUT 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/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 8dad755eae0..21d69cf5e22 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,11 +11,13 @@ 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/setbotf.f + mpif_h/fortran_binding.c \ + mpif_h/f2c_impl.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) @@ -23,7 +25,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 @@ -33,15 +35,13 @@ 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 +include_HEADERS += \ + mpif_h/mpif.h \ + mpif_h/mpi_fortran.h endif BUILD_F77_BINDING diff --git a/src/binding/fortran/mpif_h/setbot.c.in b/src/binding/fortran/mpif_h/cmblk.c.in similarity index 74% rename from src/binding/fortran/mpif_h/setbot.c.in rename to src/binding/fortran/mpif_h/cmblk.c.in index e3803dd4594..3958cf467cd 100644 --- a/src/binding/fortran/mpif_h/setbot.c.in +++ b/src/binding/fortran/mpif_h/cmblk.c.in @@ -5,63 +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; - -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; -} +#if defined(HAVE_C_MULTI_ATTR_ALIAS) /* Enable all known common block symbols mangling to be alias to each other, @@ -70,8 +14,6 @@ FORT_DLL_SPEC void FORT_CALL mpirinitc_(void *si, void *ssi, 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/f2c_impl.c b/src/binding/fortran/mpif_h/f2c_impl.c new file mode 100644 index 00000000000..0896457792b --- /dev/null +++ b/src/binding/fortran/mpif_h/f2c_impl.c @@ -0,0 +1,340 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +#include "mpi_fortimpl.h" + +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 MPI_ERR_ARG; + } +#ifdef HAVE_FINT_IS_INT + *c_status = *(MPI_Status *) f_status; +#else + /* 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; +} + +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 MPI_ERR_ARG; + } +#ifdef HAVE_FINT_IS_INT + *(MPI_Status *) f_status = *c_status; +#else + /* 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; +} + +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 MPI_ERR_ARG; + } + /* f_status and f08_status are always byte-equivalent */ + *f08_status = *(MPI_F08_status *) f_status; + return MPI_SUCCESS; +} + +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 MPI_ERR_ARG; + } + /* f_status and f08_status are always byte-equivalent */ + *(MPI_F08_status *) f_status = *f08_status; + return MPI_SUCCESS; +} + +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 MPI_ERR_ARG; + } +#ifdef HAVE_FINT_IS_INT + *c_status = *(MPI_Status *) f08_status; +#else + /* 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; +} + +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 MPI_ERR_ARG; + } +#ifdef HAVE_FINT_IS_INT + *(MPI_Status *) f08_status = *c_status; +#else + /* 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; +} + +/* 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); +} + +#ifdef MPICH_HAS_MPIX +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); +} +#endif diff --git a/src/binding/fortran/mpif_h/mpi_fortimpl.h b/src/binding/fortran/mpif_h/mpi_fortimpl.h index 7a882fc1ee7..a2108b5cc26 100644 --- a/src/binding/fortran/mpif_h/mpi_fortimpl.h +++ b/src/binding/fortran/mpif_h/mpi_fortimpl.h @@ -6,13 +6,23 @@ #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 #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 @@ -52,6 +62,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 +296,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; @@ -288,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; @@ -366,14 +376,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, @@ -388,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 *); diff --git a/src/binding/fortran/mpif_h/mpi_fortran.h.in b/src/binding/fortran/mpif_h/mpi_fortran.h.in new file mode 100644 index 00000000000..eb91da8ab2b --- /dev/null +++ b/src/binding/fortran/mpif_h/mpi_fortran.h.in @@ -0,0 +1,97 @@ +/* + * Copyright (C) by Argonne National Laboratory + * 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 + 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. + */ +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; + +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); + +#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/setbot.c b/src/binding/fortran/mpif_h/setbot.c new file mode 100644 index 00000000000..23ee4f4e6ce --- /dev/null +++ b/src/binding/fortran/mpif_h/setbot.c @@ -0,0 +1,178 @@ +/* + * Copyright (C) by Argonne National Laboratory + * See COPYRIGHT in top-level directory + */ + +#include "mpi_fortimpl.h" +#include + + +#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_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; +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; +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; + + 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 */ +#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..a495742644a 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 { @@ -51,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) @@ -104,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, @@ -123,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; @@ -153,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; }; @@ -162,7 +190,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); } @@ -172,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_c2f(op_i); + *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; }; @@ -196,7 +234,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); @@ -205,7 +243,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); @@ -214,7 +252,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); @@ -223,7 +261,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); @@ -234,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, @@ -261,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_c2f(errhandler_i); + *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/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/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 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/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[]). diff --git a/src/env/Makefile.mk b/src/env/Makefile.mk index 8a79083b0f0..27a296ebd30 100644 --- a/src/env/Makefile.mk +++ b/src/env/Makefile.mk @@ -15,10 +15,6 @@ 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 endif INSTALL_MPICXX @@ -34,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 3c2e2ca0723..5ee62f481d3 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 #---------------------------------------- @@ -211,7 +213,7 @@ subcode: parse_args $call parse_arg_cases $(if:cc=cc or cc=cxx) $call parse_delay_libs - $call parse_mpi_abi + $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) @@ -367,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 @@ -379,12 +387,6 @@ subcode: parse_args fi fi - subcode: parse_mpi_abi - $(block:parse_args_init) - mpi_abi=no - &call case, -mpi-abi|-mpi_abi - mpi_abi=yes - subcode: parse_fc_args $(set:addarg=1) $(if:sh=sh) @@ -486,21 +488,17 @@ subcode: set_final_vars final_libs="${final_libs} __LIBS_TO_BE_FILLED_AT_INSTALL_TIME__" fi + mpi_libs_shared="-l@MPILIBNAME@ @LPMPILIBNAME@" + mpi_libs_static="$libdir/lib@MPILIBNAME@.a @LPMPILIBNAME@" $(if:cc=cc or cc=cxx) - if [ "${0%_abi}" != "$0" ] ; then - mpi_abi=yes - fi - if [ "$mpi_abi" = no ] ; then - mpi_libs_shared="-l@MPILIBNAME@ @LPMPILIBNAME@" - mpi_libs_static="$libdir/lib@MPILIBNAME@.a @LPMPILIBNAME@" - else - final_cppflags="-DMPI_ABI ${final_cppflags}" - mpi_libs_shared="-l@MPIABILIBNAME@ @LPMPIABILIBNAME@" - mpi_libs_static="$libdir/lib@MPIABILIBNAME@.a @LPMPIABILIBNAME@" + 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 - $(else) - mpi_libs_shared="-l@MPILIBNAME@ @LPMPILIBNAME@" - mpi_libs_static="$libdir/lib@MPILIBNAME@.a @LPMPILIBNAME@" $(if:cc=fc) $call patch_final_fcflags diff --git a/src/include/Makefile.mk b/src/include/Makefile.mk index 181d8150418..b8594d8a35f 100644 --- a/src/include/Makefile.mk +++ b/src/include/Makefile.mk @@ -6,7 +6,12 @@ # nodist_ b/c these are created by config.status and should not be distributed nodist_include_HEADERS += src/include/mpi.h -include_HEADERS += src/include/mpi_proto.h src/include/mpix.h +if !BUILD_ABI_LIB +include_HEADERS += src/include/mpi_proto.h +endif !BUILD_ABI_LIB + +# need mpix.h for either ABIs +include_HEADERS += src/include/mpix.h ## Internal headers that are created by config.status from a corresponding ## ".h.in" file. This ensures that these files are _not_ distributed, which is diff --git a/src/include/mpi.h.in b/src/include/mpi_mpich.h.in similarity index 97% rename from src/include/mpi.h.in rename to src/include/mpi_mpich.h.in index 49b73d4fba4..6e888efcafc 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 @@ -149,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) @@ -369,7 +362,6 @@ typedef int MPI_Info; #ifndef MPICH_BUILD_MPI_ABI /* Definitions that are determined by configure. */ typedef @MPI_AINT@ MPI_Aint; -typedef @MPI_FINT@ MPI_Fint; typedef @MPI_COUNT@ MPI_Count; /* Let ROMIO know that MPI_Offset is already defined */ @@ -389,35 +381,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 @@ -1021,6 +990,9 @@ int QMPI_Get_calling_address(QMPI_Context context, void **address) MPICH_API_PUB #include #include +/* 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. */ @@ -1070,6 +1042,8 @@ int QMPI_Get_calling_address(QMPI_Context context, void **address) MPICH_API_PUB #define PMPI_Session_f2c(session) (MPI_Session)(session) #endif +#endif + #endif /* MPICH_BUILD_MPI_ABI */ #if defined(__cplusplus) @@ -1091,4 +1065,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_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_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/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; 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/mpi/datatype/typeutil.c b/src/mpi/datatype/typeutil.c index 990fb4f2113..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,33 +558,40 @@ 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 { \ 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); - 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); 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/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/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 diff --git a/src/mpi/misc/f2c_impl.c b/src/mpi/misc/f2c_impl.c deleted file mode 100644 index 067568337be..00000000000 --- a/src/mpi/misc/f2c_impl.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) by Argonne National Laboratory - * See COPYRIGHT in top-level directory - */ - -#include "mpiimpl.h" - -#ifndef MPICH_BUILD_MPI_ABI - -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); - } -#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]; -#endif - return MPI_SUCCESS; -} - -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); - } -#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; -#endif - return MPI_SUCCESS; -} - -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); - } - /* f_status and f08_status are always byte-equivalent */ - *f08_status = *(MPI_F08_status *) f_status; - return MPI_SUCCESS; -} - -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); - } - /* f_status and f08_status are always byte-equivalent */ - *(MPI_F08_status *) f_status = *f08_status; - return MPI_SUCCESS; -} - -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); - } -#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; -#endif - return MPI_SUCCESS; -} - -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); - } -#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; -#endif - return MPI_SUCCESS; -} - -#endif /* MPICH_BUILD_MPI_ABI */ diff --git a/src/mpi/romio/Makefile.am b/src/mpi/romio/Makefile.am index 45cd2cf15e9..dda5b2d1429 100644 --- a/src/mpi/romio/Makefile.am +++ b/src/mpi/romio/Makefile.am @@ -13,6 +13,7 @@ ACLOCAL_AMFLAGS = -I confdb # empty variable initializations so that later code can append (+=) +noinst_LTLIBRARIES = include_HEADERS = nodist_include_HEADERS = noinst_HEADERS = @@ -64,9 +65,25 @@ include mpi-io/Makefile.mk include adio/Makefile.mk if BUILD_ROMIO_EMBEDDED +if BUILD_ABI_LIB +noinst_LTLIBRARIES += libromio_abi.la +libromio_abi_la_SOURCES = $(romio_mpi_sources) $(romio_other_sources) $(glue_sources) +libromio_abi_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPICH_BUILD_MPI_ABI + +if BUILD_PROFILING_LIB +noinst_LTLIBRARIES += libpromio_abi.la +libpromio_abi_la_SOURCES = $(romio_mpi_sources) +libpromio_abi_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPIO_BUILD_PROFILING -DMPICH_BUILD_MPI_ABI +libpromio_abi_la_LDFLAGS = $(external_ldflags) +libpromio_abi_la_LIBADD = $(external_libs) +endif BUILD_PROFILING_LIB +libromio_abi_la_LDFLAGS = $(external_ldflags) +libromio_abi_la_LIBADD = $(external_libs) + +else !BUILD_ABI_LIB # Build a libtool convenience library that the enclosing MPI implementation can # use by adding it to the right _LIBADD variable. -noinst_LTLIBRARIES = libromio.la +noinst_LTLIBRARIES += libromio.la libromio_la_SOURCES = $(romio_mpi_sources) $(romio_other_sources) $(glue_sources) ## NOTE: ROMIO's old build system builds a bunch of _foo.o objects that contain @@ -93,21 +110,7 @@ libromio_la_LDFLAGS = $(external_ldflags) libromio_la_LIBADD = $(external_libs) endif !BUILD_PROFILING_LIB -if BUILD_ABI_LIB -noinst_LTLIBRARIES += libromio_abi.la -libromio_abi_la_SOURCES = $(romio_mpi_sources) $(romio_other_sources) $(glue_sources) -libromio_abi_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPICH_BUILD_MPI_ABI - -if BUILD_PROFILING_LIB -noinst_LTLIBRARIES += libpromio_abi.la -libpromio_abi_la_SOURCES = $(romio_mpi_sources) -libpromio_abi_la_CPPFLAGS = $(AM_CPPFLAGS) -DMPIO_BUILD_PROFILING -DMPICH_BUILD_MPI_ABI -libpromio_abi_la_LDFLAGS = $(external_ldflags) -libpromio_abi_la_LIBADD = $(external_libs) -endif BUILD_PROFILING_LIB -libromio_abi_la_LDFLAGS = $(external_ldflags) -libromio_abi_la_LIBADD = $(external_libs) -endif BUILD_ABI_LIB +endif !BUILD_ABI_LIB # --------------------------- else !BUILD_ROMIO_EMBEDDED 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/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 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@" 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/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 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" 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 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