[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.0.2-15-g0a452a2

mysql vizuser noreply at mpich.org
Thu Feb 7 11:55:06 CST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  0a452a24cf55b8a648965ca1f5a504955880c354 (commit)
      from  5ffbf15451930ce35b5e08678d8b267ceb6a5fe4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/0a452a24cf55b8a648965ca1f5a504955880c354

commit 0a452a24cf55b8a648965ca1f5a504955880c354
Author: William Gropp <wgropp at illinois.edu>
Date:   Wed Feb 6 07:31:15 2013 -0600

    Added support for passing the length of a Fortran CHARACTER as size_t instead of int.  Added a configure option to set; note that despite documentation to the contrary, it looks like some compilers still pass the length as an int (the common practice for decades), so changing to size_t must be made with extreme caution

diff --git a/configure.ac b/configure.ac
index f17eb74..e3cd063 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1882,6 +1882,66 @@ information to configure with the FCFLAGS environment variable.])
        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,
+       AC_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
 
 # FC requires F77 as well.  If the user disabled f77, do not run the
diff --git a/src/binding/f77/mpi_fortimpl.h b/src/binding/f77/mpi_fortimpl.h
index f8eb11f..0adfa11 100644
--- a/src/binding/f77/mpi_fortimpl.h
+++ b/src/binding/f77/mpi_fortimpl.h
@@ -22,16 +22,35 @@
  * an MPI_Fint instead of an int.  In that case, we will need an additional
  * case.
  */
+/*
+ * Many Fortran compilers at some point changed from passing the length of
+ * a CHARACTER*(N) in an int to using a size_t.  This definition allows
+ * us to select either size_t or int.  Determining which one the compiler
+ * is using may require reading the documentation or examining the generated
+ * code.
+ *
+ * The default is left as "int" because that is the correct legacy choice.
+ * Configure may need to check the compiler vendor and version to decide
+ * whether to select size_t.  And despite documentation to the contrary,
+ * in our experiments, gfortran used int instead of size_t, which was
+ * verified by inspecting the assembly code.
+ */
+#ifdef USE_FORT_STR_LEN_SIZET
+#define FORT_SIZE_INT size_t
+#else
+#define FORT_SIZE_INT int
+#endif
+
 #ifdef USE_FORT_MIXED_STR_LEN
-#define FORT_MIXED_LEN_DECL   , int
+#define FORT_MIXED_LEN_DECL   , FORT_SIZE_INT
 #define FORT_END_LEN_DECL
-#define FORT_MIXED_LEN(a)     , int a
+#define FORT_MIXED_LEN(a)     , FORT_SIZE_INT a
 #define FORT_END_LEN(a)
 #else
 #define FORT_MIXED_LEN_DECL
-#define FORT_END_LEN_DECL     , int
+#define FORT_END_LEN_DECL     , FORT_SIZE_INT
 #define FORT_MIXED_LEN(a)
-#define FORT_END_LEN(a)       , int a
+#define FORT_END_LEN(a)       , FORT_SIZE_INT a
 #endif
 
 /* ------------------------------------------------------------------------- */

-----------------------------------------------------------------------

Summary of changes:
 configure.ac                   |   60 ++++++++++++++++++++++++++++++++++++++++
 src/binding/f77/mpi_fortimpl.h |   27 +++++++++++++++--
 2 files changed, 83 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list