1
1
openmpi/config/ompi_fortran_check_max_array_rank.m4
Jeff Squyres d7eaca83fa Fortran: Fix MPI_SIZEOF. What a disaster. :-(
What started as a simple ticket ended up reaching the way up to the
MPI Forum.
    
It turns out that we are supposed to have MPI_SIZEOF for all Fortran
interfaces: mpif.h, the mpi module, and the mpi_f08 module.
    
It further turns out that to properly support MPI_SIZEOF, your Fortran
compiler *has* support the INTERFACE keyword and ISO_FORTRAN_ENV.  We
can't use "ignore TKR" functionality, because the whole point of
MPI_SIZEOF is that the implementation knows what type was passed to it
("ignore TKR" functionality, by definition, throws that information
away).  Hence, we have to have an MPI_SIZEOF interface+implementation
for all intrinsic types, kinds, and ranks.

This commit therefore adds a perl script that generates both the
interfaces and implementations for MPI_SIZEOF in each of mpif.h, the
mpi module, and mpi_f08 module (yay consolidation!).

The perl script uses the results of some new configure tests:

* check if the Fortran compiler supports the INTERFACE keyword
* check if the Fortran compiler supports ISO_FORTRAN_ENV
* find the max array rank (i.e., dimension) that the compiler supports

If the Fortran compiler supports both INTERFACE and ISO_FORTRAN_ENV,
then we'll build the MPI_SIZEOF interfaces.  If not, we'll skip
MPI_SIZEOF in mpif.h and the mpi module.  Note that we won't build the
mpi_f08 module -- to include the MPI_SIZEOF interfaces -- if the
Fortran compiler doesn't support INTERFACE, ISO_FORTRAN_ENV, and a
whole bunch of ther modern Fortran stuff.

Since MPI_SIZEOF interfaces are now generated by the perl script, this
commit also removes all the old MPI_SIZEOF implementations (which were
laden with a zillion #if blocks).

cmr=v1.8.3

This commit was SVN r32764.
2014-09-19 13:44:52 +00:00

70 строки
2.7 KiB
Bash

dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
# Check the max array rank that the Fortran compiler supports.
#
# OMPI_FORTRAN_CHECK_MAX_ARRAY_RANK
#
# Sets $OMPI_FORTRAN_MAX_ARRAY_RANK, AC_SUBSTs it, and AC_DEFINEs
# OMPI_FORTRAN_MAX_ARRAY_RANK.
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_MAX_ARRAY_RANK],[
AS_VAR_PUSHDEF([max_array_rank_var], [ompi_cv_fortran_max_array_rank])
OPAL_VAR_SCOPE_PUSH([f_max_rank f_fail f_rank f_i f_dim])
AC_CACHE_CHECK([max supported Fortran array rank], max_array_rank_var,
[AC_LANG_PUSH([Fortran])
f_max_rank=0
f_fail=0
# Realistically, this will only be 7 or 15. But what the heck
# -- try them all. Note that we don't test above 15, because
# that's the max value from the F2008 spec (and some compilers
# will let you go above rank=16, e.g., Intel ifort).
for f_rank in 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
if test $f_fail -eq 0; then
f_i=1
f_dim=2
while test `expr $f_i + 1` -le $f_rank; do
f_dim="$f_dim,2"
f_i=`expr $f_i + 1`
done
OPAL_LOG_MSG([testing Fortran dimension $f_rank / $f_dim])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[PROGRAM test_program
INTEGER, DIMENSION($f_dim) :: var
var($f_dim) = 3
END PROGRAM test_program]])],
[f_max_rank=$f_rank], [f_fail=1])
fi
done
AS_VAR_SET(max_array_rank_var, $f_max_rank)
AC_LANG_POP([Fortran])
])
AS_VAR_COPY([OMPI_FORTRAN_MAX_ARRAY_RANK], [max_array_rank_var])
AC_SUBST(OMPI_FORTRAN_MAX_ARRAY_RANK)
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_MAX_ARRAY_RANK],
[$OMPI_FORTRAN_MAX_ARRAY_RANK],
[Max dimension rank of Fortran arrays])
OPAL_VAR_SCOPE_POP
AS_VAR_POPDEF([max_array_rank_var])dnl
])