From 0c221c80fd418c70a70dc1e3e5d679b73788d8a4 Mon Sep 17 00:00:00 2001 From: Prabhanjan Kambadur Date: Fri, 16 Jan 2004 22:16:25 +0000 Subject: [PATCH] These files help in determining MPI_Fint (in terms of relevant C types). configure.ac #define's MPI_Fint to be of int32_t, int64_t or int depending on the configuration details This commit was SVN r454. --- acinclude.m4 | 1 + config/Makefile.am | 19 +++-- config/lam_get_sizeof_fortran_type.m4 | 118 ++++++++++++++++++++++++++ configure.ac | 47 ++++++++++ 4 files changed, 176 insertions(+), 9 deletions(-) create mode 100644 config/lam_get_sizeof_fortran_type.m4 diff --git a/acinclude.m4 b/acinclude.m4 index aa6c8a53e8..aac461c943 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -22,6 +22,7 @@ sinclude(config/lam_config_subdir.m4) sinclude(config/lam_config_subdir_args.m4) sinclude(config/lam_configure_options.m4) sinclude(config/lam_functions.m4) +sinclude(config/lam_get_sizeof_fortran_type.m4) sinclude(config/lam_get_version.m4) sinclude(config/lam_get_libtool_linker_flags.m4) sinclude(config/lam_mca.m4) diff --git a/config/Makefile.am b/config/Makefile.am index 12610324a1..271545c7bd 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -20,12 +20,13 @@ EXTRA_DIST = \ lam_config_pthreads.m4 \ lam_config_solaris_threads.m4 \ lam_config_threads.m4 \ - lam_configure_options.m4 \ - lam_functions.m4 \ - lam_get_version.m4 \ - lam_get_version.sh \ - lam_mca.m4 \ - lam_setup_cc.m4 \ - lam_setup_cxx.m4 \ - lam_setup_f77.m4 \ - lam_setup_f90.m4 + lam_configure_options.m4 \ + lam_functions.m4 \ + lam_get_sizeof_fortran_type.m4 \ + lam_get_version.m4 \ + lam_get_version.sh \ + lam_mca.m4 \ + lam_setup_cc.m4 \ + lam_setup_cxx.m4 \ + lam_setup_f77.m4 \ + lam_setup_f90.m4 diff --git a/config/lam_get_sizeof_fortran_type.m4 b/config/lam_get_sizeof_fortran_type.m4 new file mode 100644 index 0000000000..f074f5f41a --- /dev/null +++ b/config/lam_get_sizeof_fortran_type.m4 @@ -0,0 +1,118 @@ +dnl -*- shell-script -*- +dnl +dnl Copyright (c) 2001-2002 The Trustees of Indiana University. +dnl All rights reserved. +dnl Copyright (c) 1998-2001 University of Notre Dame. +dnl All rights reserved. +dnl Copyright (c) 1994-1998 The Ohio State University. +dnl All rights reserved. +dnl +dnl This file is part of the LAM/MPI software package. For license +dnl information, see the LICENSE file in the top level directory of the +dnl LAM/MPI source distribution. +dnl +dnl $Id: lam_get_sizeof_fortran_type.m4,v 1.1 2004/01/16 22:16:25 pkambadu Exp $ +dnl + +define(LAM_GET_SIZEOF_FORTRAN_TYPE,[ +# Determine FORTRAN datatype size. +# First arg is type, 2nd (optional) arg is config var to define. +AC_MSG_CHECKING([size of FORTRAN $1]) +lam_ac_size_fn= +if test "x$lam_ac_doubleunder" = xy || test "x$lam_ac_singleunder" = xy; then + lam_ac_size_fn=size_ +else + if test "x$lam_ac_nounder" = xy; then + lam_ac_size_fn=size + else + if test "x$lam_ac_caps" = xy; then + lam_ac_size_fn=SIZE + else + AC_MSG_WARN([*** FORTRAN external naming convention undefined]) + AC_MSG_ERROR([*** Cannot continue.]) + fi + fi +fi + +# +# Cannot use standard AC_TRY macros because we need two different .o +# files here, and link them together +# + +# +# Fortran module +# + +cat > conftestf.f < conftest.c < +#include +$lam_conftest_h + +#ifdef __cplusplus +extern "C" { +#endif +void $lam_ac_size_fn(char *a, char *b) +{ + int diff = (int) (b - a); + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", diff); +} +#ifdef __cplusplus +} +#endif +EOF + +# +# Try the compilation and run. Can't use AC_TRY_RUN because it's two +# module files. +# + +LAM_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c], + LAM_LOG_COMMAND([$F77 $FFLAGS conftestf.f conftest.o -o conftest], + LAM_LOG_COMMAND([./conftest],[HAPPY=1],[HAPPY=0]), + [HAPPY=0]), + [HAPPY=0]) + +if test "$HAPPY" = "1" -a -f conftestval; then + lam_ac_fortsize=`cat conftestval` + AC_MSG_RESULT([$lam_ac_fortsize]) + if test -n "$2"; then + eval "$2=$lam_ac_fortsize" + fi +else + AC_MSG_RESULT([unknown]) + + LAM_LOG_MSG([here is the C program:], 1) + LAM_LOG_FILE([conftest.c]) + if test -f conftest.h; then + LAM_LOG_MSG([here is contest.h:], 1) + LAM_LOG_FILE([conftest.h]) + fi + LAM_LOG_MSG([here is the fortran program:], 1) + LAM_LOG_FILE([conftestf.f]) + + AC_MSG_WARN([*** Problem running configure test!]) + AC_MSG_WARN([*** See config.log for details.]) + AC_MSG_ERROR([*** Cannot continue.]) +fi + +unset lam_ac_fortsize HAPPY lam_conftest_h +/bin/rm -f conftest*])dnl diff --git a/configure.ac b/configure.ac index 7541cd1d71..6fb3a2a649 100644 --- a/configure.ac +++ b/configure.ac @@ -224,6 +224,14 @@ if test -n "$F77"; then LAM_F77_FIND_EXT_SYMBOL_CONVENTION($F77) fi +# checking the sizeof fortran interger. This is needed to define +# MPI_Fint. This is needed for C bindings and hence there is no +# bearing of --enable-fortran flag on this test. +# +LAM_SIZEOF_FORTRAN_INT=0 +LAM_GET_SIZEOF_FORTRAN_TYPE(INTEGER, LAM_SIZEOF_FORTRAN_INT) +#AC_DEFINE_UNQUOTED(LAM_SIZEOF_FORTRAN_INT, $LAM_SIZEOF_FORTRAN_INT, +# [Size of fortran INTEGER]) LAM_SETUP_F90 @@ -279,6 +287,45 @@ AC_DEFINE_UNQUOTED(LAM_HAVE_UNDERSCORE_VA_COPY, $LAM_HAVE_UNDERSCORE_VA_COPY, ################################## lam_show_title "System-specific tests" +# +# Determine what MPI_Fint shout be defined as. If the size of +# fortran integer is 4 then it is defined to either +# int32_t or int. Similarly if the size of fortran integer +# is 8 bytes then it is defined to either int64_t or int. +# ac_cv_type_int32_t=yes implies that unint_32 was present. +# similary ac_cv_type_int64_t=yes. Similarly the values +# of ac_cv_sizeof_int will contain the size of int and later +# this will be #defined to SIZEOF_INT. +# +MPI_FINT_TYPE= +if test "$LAM_SIZEOF_FORTRAN_INT" = 4 ; then + if test "$ac_cv_type_int32_t" == "yes"; then + AC_MSG_CHECKING([Yahoo .... I think we have a winner int32_t]) + MPI_FINT_TYPE=int32_t + else + if test "$ac_cv_sizeof_int" = 4 ; then + AC_MSG_CHECKING([Yahoo .... I think we have a winner int]) + MPI_FINT_TYPE=int + fi + fi +fi +if test "$LAM_SIZEOF_FORTRAN_INT" = 8 ; then + if test "$ac_cv_type_int64_t" == "yes"; then + AC_MSG_CHECKING([Yahoo .... I think we have a winner int64_t]) + MPI_FINT_TYPE=int64_t + else + if test "$ac_cv_sizeof_int" = 8 ; then + AC_MSG_CHECKING([Yahoo .... I think we have a winner int]) + MPI_FINT_TYPE=int + fi + fi +fi +if test -z "$MPI_FINT_TYPE"; then + AC_MSG_WARN([*** WARNING: Unable to find the right definition for MPI_Fint]) + AC_MSG_ERROR([Cannot continue]) +fi +AC_DEFINE_UNQUOTED(MPI_Fint, $MPI_FINT_TYPE,[MPI_Fint is int32_t]) + # all: endian # all: SYSV semaphores