Blame confdb/aclocal_mpi.m4

Packit 0848f5
dnl
Packit 0848f5
dnl/*D 
Packit 0848f5
dnl PAC_LIB_MPI - Check for MPI library
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_LIB_MPI([action if found],[action if not found])
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl Currently, only checks for lib mpi and mpi.h.  Later, we will add
Packit 0848f5
dnl MPI_Pcontrol prototype (const int or not?).  
Packit 0848f5
dnl
Packit 0848f5
dnl Prerequisites:
Packit 0848f5
dnl autoconf version 2.13 (for AC_SEARCH_LIBS)
Packit 0848f5
dnl D*/
Packit 0848f5
dnl Other tests to add:
Packit 0848f5
dnl Version of MPI
Packit 0848f5
dnl MPI-2 I/O?
Packit 0848f5
dnl MPI-2 Spawn?
Packit 0848f5
dnl MPI-2 RMA?
Packit 0848f5
dnl PAC_LIB_MPI([found text],[not found text])
Packit 0848f5
AC_DEFUN([PAC_LIB_MPI],[
Packit 0848f5
dnl Set the prereq to 2.50 to avoid having 
Packit 0848f5
AC_PREREQ(2.50)
Packit 0848f5
if test "X$pac_lib_mpi_is_building" != "Xyes" ; then
Packit 0848f5
  # Use CC if TESTCC is defined
Packit 0848f5
  if test "X$pac_save_level" != "X" ; then
Packit 0848f5
     pac_save_TESTCC="${TESTCC}"
Packit 0848f5
     pac_save_TESTCPP="${TESTCPP}"
Packit 0848f5
     CC="$pac_save_CC"
Packit 0848f5
     if test "X$pac_save_CPP" != "X" ; then
Packit 0848f5
         CPP="$pac_save_CPP"
Packit 0848f5
     fi
Packit 0848f5
  fi
Packit 0848f5
  # Look for MPILIB first if it is defined
Packit 0848f5
  AC_SEARCH_LIBS(MPI_Init,$MPILIB mpi mpich)
Packit 0848f5
  if test "$ac_cv_search_MPI_Init" = "no" ; then
Packit 0848f5
    ifelse($2,,
Packit 0848f5
    AC_MSG_ERROR([Could not find MPI library]),[$2])
Packit 0848f5
  fi
Packit 0848f5
  AC_CHECK_HEADER(mpi.h,pac_have_mpi_h="yes",pac_have_mpi_h="no")
Packit 0848f5
  if test $pac_have_mpi_h = "no" ; then
Packit 0848f5
    ifelse($2,,
Packit 0848f5
    AC_MSG_ERROR([Could not find mpi.h include file]),[$2])
Packit 0848f5
  fi
Packit 0848f5
  if test "X$pac_save_level" != "X" ; then
Packit 0848f5
     CC="$pac_save_TESTCC"
Packit 0848f5
     CPP="$pac_save_TESTCPP"
Packit 0848f5
  fi
Packit 0848f5
fi
Packit 0848f5
ifelse($1,,,[$1])
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl This should also set MPIRUN.
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_ARG_MPI_TYPES - Add command-line switches for different MPI 
Packit 0848f5
dnl environments
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis:
Packit 0848f5
dnl PAC_ARG_MPI_TYPES([default])
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effects:
Packit 0848f5
dnl Adds the following command line options to configure
Packit 0848f5
dnl+ \-\-with\-mpich[=path] - MPICH.  'path' is the location of MPICH commands
Packit 0848f5
dnl. \-\-with\-ibmmpi - IBM MPI
Packit 0848f5
dnl. \-\-with\-lammpi[=path] - LAM/MPI
Packit 0848f5
dnl. \-\-with\-mpichnt - MPICH NT
Packit 0848f5
dnl- \-\-with\-sgimpi - SGI MPI
Packit 0848f5
dnl If no type is selected, and a default ("mpich", "ibmmpi", or "sgimpi")
Packit 0848f5
dnl is given, that type is used as if '--with-<default>' was given.
Packit 0848f5
dnl
Packit 0848f5
dnl Sets 'CC', 'F77', 'TESTCC', 'TESTF77', and 'MPILIBNAME'.  Does `not`
Packit 0848f5
dnl perform an AC_SUBST for these values.
Packit 0848f5
dnl Also sets 'MPIBOOT' and 'MPIUNBOOT'.  These are used to specify 
Packit 0848f5
dnl programs that may need to be run before and after running MPI programs.
Packit 0848f5
dnl For example, 'MPIBOOT' may start demons necessary to run MPI programs and
Packit 0848f5
dnl 'MPIUNBOOT' will stop those demons.
Packit 0848f5
dnl 
Packit 0848f5
dnl The two forms of the compilers are to allow for tests of the compiler
Packit 0848f5
dnl when the MPI version of the compiler creates executables that cannot
Packit 0848f5
dnl be run on the local system (for example, the IBM SP, where executables
Packit 0848f5
dnl created with mpcc will not run locally, but executables created
Packit 0848f5
dnl with xlc may be used to discover properties of the compiler, such as
Packit 0848f5
dnl the size of data types).
Packit 0848f5
dnl
Packit 0848f5
dnl Historical note:
Packit 0848f5
dnl Some common autoconf tests, such as AC_CHECK_SIZEOF, used to require
Packit 0848f5
dnl running a program.  But some MPI compilers (often really compilation 
Packit 0848f5
dnl scripts) produced programs that could only be run with special commands,
Packit 0848f5
dnl such as a batch submission system.  To allow these test programs to be
Packit 0848f5
dnl run, a separate set of compiler variables, TESTCC, TESTF77, etc., 
Packit 0848f5
dnl were defined.  However, in later versions of autoconf, it both became
Packit 0848f5
dnl unnecessary to run programs for tests such as AC_CHECK_SIZEOF and 
Packit 0848f5
dnl it became necessary to define CC etc. before invoking AC_PROG_CC (and
Packit 0848f5
dnl the othe language compilers), because those commands now do much, much
Packit 0848f5
dnl more than just determining the compiler.
Packit 0848f5
dnl
Packit 0848f5
dnl To address the change, we still define the TESTCC etc. compilers where
Packit 0848f5
dnl possible to allow the use of AC_TRY_RUN when required, but we define
Packit 0848f5
dnl the CC etc variables and do not define ac_cv_prog_CC etc., as these 
Packit 0848f5
dnl cause autoconf to skip all of the other initialization code that 
Packit 0848f5
dnl AC_PROG_CC etc. runs.  Note also that this command must occur before 
Packit 0848f5
dnl AC_PROG_CC (or anything that might cause AC_PROG_CC to be invoked).
Packit 0848f5
dnl
Packit 0848f5
dnl See also:
Packit 0848f5
dnl PAC_LANG_PUSH_COMPILERS, PAC_LIB_MPI
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_ARG_MPI_TYPES],[
Packit 0848f5
# known types
Packit 0848f5
PAC_ARG_MPI_KNOWN_TYPES
Packit 0848f5
# find compilers
Packit 0848f5
PAC_MPI_FIND_COMPILER_SCRIPTS
Packit 0848f5
PAC_MPI_FIND_COMPILERS
Packit 0848f5
# check for MPI library
Packit 0848f5
PAC_MPI_CHECK_MPI_LIB
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl To keep autoconf from prematurely invoking the compiler check scripts,
Packit 0848f5
dnl we need a command that first sets the compilers and a separate one
Packit 0848f5
dnl that makes any necessary checks for libraries
Packit 0848f5
dnl
Packit 0848f5
AC_DEFUN([PAC_ARG_MPI_KNOWN_TYPES],[
Packit 0848f5
AC_ARG_WITH(mpich,
Packit 0848f5
[--with-mpich=path  - Assume that we are building with MPICH],
Packit 0848f5
ac_mpi_type=mpich)
Packit 0848f5
# Allow MPICH as well as MPICH
Packit 0848f5
AC_ARG_WITH(mpich,
Packit 0848f5
[--with-mpich=path  - Assume that we are building with MPICH],
Packit 0848f5
ac_mpi_type=mpich)
Packit 0848f5
AC_ARG_WITH(lammpi,
Packit 0848f5
[--with-lammpi=path  - Assume that we are building with LAM/MPI],
Packit 0848f5
ac_mpi_type=lammpi)
Packit 0848f5
AC_ARG_WITH(ibmmpi,
Packit 0848f5
[--with-ibmmpi    - Use the IBM SP implementation of MPI],
Packit 0848f5
ac_mpi_type=ibmmpi)
Packit 0848f5
AC_ARG_WITH(sgimpi,
Packit 0848f5
[--with-sgimpi    - Use the SGI implementation of MPI],
Packit 0848f5
ac_mpi_type=sgimpi)
Packit 0848f5
AC_ARG_WITH(mpichnt,
Packit 0848f5
[--with-mpichnt - Use MPICH for Windows NT ],
Packit 0848f5
ac_mpi_type=mpichnt)
Packit 0848f5
AC_ARG_WITH(mpi,
Packit 0848f5
[--with-mpi=path    - Use an MPI implementation with compile scripts mpicc
Packit 0848f5
                     and mpif77 in path/bin],ac_mpi_type=generic)
Packit 0848f5
Packit 0848f5
if test "X$ac_mpi_type" = "X" ; then
Packit 0848f5
    if test "X$1" != "X" ; then
Packit 0848f5
        ac_mpi_type=$1
Packit 0848f5
    else
Packit 0848f5
        ac_mpi_type=unknown
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
if test "$ac_mpi_type" = "unknown" -a "$pac_lib_mpi_is_building" = "yes" ; then
Packit 0848f5
    ac_mpi_type="mpich"
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl Because autoconf insists on moving code to the beginning of
Packit 0848f5
dnl certain definitions, it is *not possible* to define a single command
Packit 0848f5
dnl that selects compilation scripts and also check for other options.
Packit 0848f5
dnl Thus, this needs to be divided into 
Packit 0848f5
dnl   MPI_FIND_COMPILER_SCRIPTS
Packit 0848f5
dnl which can fail (i.e., not find a script), and
Packit 0848f5
dnl   MPI_FIND_COMPILERS
Packit 0848f5
dnl which runs the various PROC_xx for the compilers.
Packit 0848f5
dnl WARNING: this function ignores --program-suffix and --program-prefix.
Packit 0848f5
dnl However, this function is not currently used at all.
Packit 0848f5
AC_DEFUN([PAC_MPI_FIND_COMPILER_SCRIPTS],[
Packit 0848f5
# Set defaults
Packit 0848f5
MPIRUN_NP="-np "
Packit 0848f5
MPIEXEC_N="-n "
Packit 0848f5
AC_SUBST(MPIRUN_NP)
Packit 0848f5
AC_SUBST(MPIEXEC_N)
Packit 0848f5
dnl
Packit 0848f5
AC_ARG_VAR([MPIEXEC],[Name and path of mpiexec program])
Packit 0848f5
AC_ARG_VAR([MPIRUN],[Name and path of mpirun program])
Packit 0848f5
AC_ARG_VAR([MPIBOOT],[Name and path of program to run before mpirun])
Packit 0848f5
AC_ARG_VAR([MPIUNBOOT],[Name and path of program to run after all mpirun])
Packit 0848f5
AC_ARG_VAR([MPICC],[Name and absolute path of program used to compile MPI programs in C])
Packit 0848f5
AC_ARG_VAR([MPIF77],[Name and absolute path of program used to compile MPI programs in F77])
Packit 0848f5
AC_ARG_VAR([MPICXX],[Name and absolute path of program used to compile MPI programs in C++])
Packit 0848f5
AC_ARG_VAR([MPIF90],[Name and absolute path of program used to compile MPI programs in F90])
Packit 0848f5
#
Packit 0848f5
# Check for things that will cause trouble.  For example, 
Packit 0848f5
# if MPICC is defined but does not contain a / or \, then PATH_PROG will
Packit 0848f5
# ignore the value
Packit 0848f5
if test -n "$MPICC" ; then
Packit 0848f5
   case $MPICC in
Packit 0848f5
changequote(<<,>>)
Packit 0848f5
    [\\/]* | ?:[\\/]*)
Packit 0848f5
changequote([,])
Packit 0848f5
    # Ok, PATH_PROG will figure it out
Packit 0848f5
    ;;  
Packit 0848f5
  *)
Packit 0848f5
    AC_MSG_ERROR([MPICC must be set to an absolute path if it is set])
Packit 0848f5
  esac
Packit 0848f5
fi
Packit 0848f5
if test -n "$MPICXX" ; then
Packit 0848f5
   case $MPICXX in
Packit 0848f5
changequote(<<,>>)
Packit 0848f5
    [\\/]* | ?:[\\/]*)
Packit 0848f5
changequote([,])
Packit 0848f5
    # Ok, PATH_PROG will figure it out
Packit 0848f5
    ;;  
Packit 0848f5
  *)
Packit 0848f5
    AC_MSG_ERROR([MPICXX must be set to an absolute path if it is set])
Packit 0848f5
  esac
Packit 0848f5
fi
Packit 0848f5
if test -n "$MPIF77" ; then
Packit 0848f5
   case $MPIF77 in
Packit 0848f5
changequote(<<,>>)
Packit 0848f5
    [\\/]* | ?:[\\/]*)
Packit 0848f5
changequote([,])
Packit 0848f5
    # Ok, PATH_PROG will figure it out
Packit 0848f5
    ;;  
Packit 0848f5
  *)
Packit 0848f5
    AC_MSG_ERROR([MPIF77 must be set to an absolute path if it is set])
Packit 0848f5
  esac
Packit 0848f5
fi
Packit 0848f5
if test -n "$MPIF90" ; then
Packit 0848f5
   case $MPIF90 in
Packit 0848f5
changequote(<<,>>)
Packit 0848f5
    [\\/]* | ?:[\\/]*)
Packit 0848f5
changequote([,])
Packit 0848f5
    # Ok, PATH_PROG will figure it out
Packit 0848f5
    ;;  
Packit 0848f5
  *)
Packit 0848f5
    AC_MSG_ERROR([MPIF90 must be set to an absolute path if it is set])
Packit 0848f5
  esac
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
case $ac_mpi_type in
Packit 0848f5
	mpich)
Packit 0848f5
        dnl 
Packit 0848f5
        dnl This isn't correct.  It should try to get the underlying compiler
Packit 0848f5
        dnl from the mpicc and mpif77 scripts or mpireconfig
Packit 0848f5
        if test "X$pac_lib_mpi_is_building" != "Xyes" ; then
Packit 0848f5
	    PAC_PUSH_FLAG([PATH])
Packit 0848f5
            if test "$with_mpich" != "yes" -a "$with_mpich" != "no" ; then 
Packit 0848f5
		# Look for commands; if not found, try adding bin to the
Packit 0848f5
		# path
Packit 0848f5
		if test ! -x $with_mpich/mpicc -a -x $with_mpich/bin/mpicc ; then
Packit 0848f5
			with_mpich="$with_mpich/bin"
Packit 0848f5
		fi
Packit 0848f5
                PATH=$with_mpich:${PATH}
Packit 0848f5
            fi
Packit 0848f5
            AC_PATH_PROG(MPICC,mpicc)
Packit 0848f5
	    if test -z "$TESTCC" ; then TESTCC=${CC-cc} ; fi
Packit 0848f5
            CC="$MPICC"
Packit 0848f5
	    # Note that autoconf may unconditionally change the value of 
Packit 0848f5
	    # CC (!) in some other command. Thus, we define CCMASTER
Packit 0848f5
	    CCMASTER=$CC
Packit 0848f5
	    # Force autoconf to respect this choice
Packit 0848f5
	    ac_ct_CC=$CC
Packit 0848f5
	    # to permit configure codes to recover the correct CC.  This
Packit 0848f5
	    # is an ugly not-quite-correct workaround for the fact that 
Packit 0848f5
	    # does not want you to change the C compiler once you have set it
Packit 0848f5
	    # (But since it does so unconditionally, it silently creates 
Packit 0848f5
	    # bogus output files.)
Packit 0848f5
            AC_PATH_PROG(MPIF77,mpif77)
Packit 0848f5
	    if test -z "$TESTF77" ; then TESTF77=${F77-f77} ; fi
Packit 0848f5
            F77="$MPIF77"
Packit 0848f5
            AC_PATH_PROG(MPIFC,mpif90)
Packit 0848f5
	    if test -z "$TESTFC" ; then TESTFC=${FC-f90} ; fi 
Packit 0848f5
            FC="$MPIFC"
Packit 0848f5
            AC_PATH_PROG(MPICXX,mpiCC)
Packit 0848f5
	    if test -z "$TESTCXX" ; then TESTCXX=${CXX-CC} ; fi
Packit 0848f5
            CXX="$MPICXX"
Packit 0848f5
	    # We may want to restrict this to the path containing mpirun
Packit 0848f5
	    AC_PATH_PROG(MPIEXEC,mpiexec)
Packit 0848f5
	    AC_PATH_PROG(MPIRUN,mpirun)
Packit 0848f5
	    AC_PATH_PROG(MPIBOOT,mpichboot)
Packit 0848f5
	    AC_PATH_PROG(MPIUNBOOT,mpichstop)
Packit 0848f5
	    PAC_POP_FLAG([PATH])
Packit 0848f5
  	    MPILIBNAME="mpich"
Packit 0848f5
        else 
Packit 0848f5
	    # All of the above should have been passed in the environment!
Packit 0848f5
	    :
Packit 0848f5
        fi
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
        mpichnt)
Packit 0848f5
        ;;
Packit 0848f5
Packit 0848f5
	lammpi)
Packit 0848f5
	dnl
Packit 0848f5
        dnl This isn't correct.  It should try to get the underlying compiler
Packit 0848f5
        dnl from the mpicc and mpif77 scripts or mpireconfig
Packit 0848f5
	PAC_PUSH_FLAG([PATH])
Packit 0848f5
        if test "$with_mpich" != "yes" -a "$with_mpich" != "no" ; then 
Packit 0848f5
	    # Look for commands; if not found, try adding bin to the path
Packit 0848f5
		if test ! -x $with_lammpi/mpicc -a -x $with_lammpi/bin/mpicc ; then
Packit 0848f5
			with_lammpi="$with_lammpi/bin"
Packit 0848f5
		fi
Packit 0848f5
                PATH=$with_lammpi:${PATH}
Packit 0848f5
        fi
Packit 0848f5
        AC_PATH_PROG(MPICC,mpicc)
Packit 0848f5
        if test -z "$TESTCC" ; then TESTCC=${CC-cc} ; fi
Packit 0848f5
        CC="$MPICC"
Packit 0848f5
        AC_PATH_PROG(MPIF77,mpif77)
Packit 0848f5
	if test -z "$TESTCC" ; then TESTF77=${F77-f77} ; fi
Packit 0848f5
        F77="$MPIF77"
Packit 0848f5
        AC_PATH_PROG(MPIFC,mpif90)
Packit 0848f5
        TESTFC=${FC-f90}
Packit 0848f5
	if test -z "$TESTFC" ; then TESTFC=${FC-f90} ; fi
Packit 0848f5
        FC="$MPIFC"
Packit 0848f5
        AC_PATH_PROG(MPICXX,mpiCC)
Packit 0848f5
	if test -z "$TESTCXX" ; then TESTCXX=${CXX-CC} ; fi
Packit 0848f5
        CXX="$MPICXX"
Packit 0848f5
	PAC_POP_FLAG([PATH])
Packit 0848f5
  	MPILIBNAME="lammpi"
Packit 0848f5
	MPIBOOT="lamboot"
Packit 0848f5
	MPIUNBOOT="wipe"
Packit 0848f5
	MPIRUN="mpirun"
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
	ibmmpi)
Packit 0848f5
	AC_CHECK_PROGS(MPCC,mpcc)
Packit 0848f5
	AC_CHECK_PROGS(MPXLF,mpxlf mpfort)
Packit 0848f5
	if test -z "$MPCC" -o -z "$MPXLF" ; then
Packit 0848f5
	    AC_MSG_ERROR([Could not find IBM MPI compilation scripts.  Either mpcc or mpxlf/mpfort is missing])
Packit 0848f5
	fi
Packit 0848f5
	if test -z "$TESTCC" ; then TESTCC=${CC-xlC} ; fi
Packit 0848f5
	if test -z "$TESTF77" ; then TESTF77=${F77-xlf}; fi
Packit 0848f5
	CC=mpcc; F77=$MPXLF
Packit 0848f5
	# There is no mpxlf90, but the options langlvl and free can
Packit 0848f5
	# select the Fortran 90 version of xlf
Packit 0848f5
	if test "$enable_f90" != no ; then
Packit 0848f5
	    AC_CHECK_PROGS(MPIXLF90,mpxlf90 mpfort)
Packit 0848f5
	    if test -z "$TESTFC" ; then TESTFC=${FC-xlf90}; fi
Packit 0848f5
            if test "X$MPIXLF90" != "X" ; then 
Packit 0848f5
	        FC="$MPIXLF90"
Packit 0848f5
	    else
Packit 0848f5
	    	FC="$MPXLF -qlanglvl=90ext -qfree=f90"
Packit 0848f5
	    fi
Packit 0848f5
	fi
Packit 0848f5
	MPILIBNAME=""
Packit 0848f5
	cross_compiling=yes
Packit 0848f5
	# Turn off the autoconf version 3 warning message
Packit 0848f5
	ac_tool_warned=yes
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
	sgimpi)
Packit 0848f5
	if test -z "$TESTCC" ; then TESTCC=${CC:=cc} ; fi
Packit 0848f5
	if test -z "$TESTF77" ; then TESTF77=${F77:=f77} ; fi
Packit 0848f5
	if test -z "$TESTCXX" ; then TESTCXX=${CXX:=CC} ; fi
Packit 0848f5
	if test -z "$TESTFC" ; then TESTFC=${FC:=f90} ; fi
Packit 0848f5
	# Must check for the MPI library in a separate macro - adding
Packit 0848f5
	# a test here will cause autoconf to prematurely define the
Packit 0848f5
	# C compiler
Packit 0848f5
	MPIRUN=mpirun
Packit 0848f5
	MPIBOOT=""
Packit 0848f5
	MPIUNBOOT=""
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
	generic)
Packit 0848f5
	# in $with_mpi/bin or $with_mpi
Packit 0848f5
        if test "X$MPICC" = "X" ; then
Packit 0848f5
            if test -x "$with_mpi/bin/mpicc" ; then
Packit 0848f5
                MPICC=$with_mpi/bin/mpicc
Packit 0848f5
	    elif test -x "$with_mpi/mpicc" ; then
Packit 0848f5
	        MPICC=$with_mpi/mpicc
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
        if test "X$MPICXX" = "X" ; then
Packit 0848f5
            if test -x "$with_mpi/bin/mpicxx" ; then
Packit 0848f5
                MPICXX=$with_mpi/bin/mpicxx
Packit 0848f5
	    elif test -x "$with_mpi/mpicxx" ; then
Packit 0848f5
	        MPICXX=$with_mpi/mpicxx
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
        if test "X$MPIF77" = "X" ; then
Packit 0848f5
            if test -x "$with_mpi/bin/mpif77" ; then
Packit 0848f5
                MPIF77=$with_mpi/bin/mpif77
Packit 0848f5
	    elif test -x "$with_mpi/mpif77" ; then
Packit 0848f5
	        MPIF77=$with_mpi/mpif77
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
        if test "X$MPIF90" = "X" ; then
Packit 0848f5
            if test -x "$with_mpi/bin/mpif90" ; then
Packit 0848f5
                MPIF90=$with_mpi/bin/mpif90
Packit 0848f5
	    elif test -x "$with_mpi/mpif90" ; then
Packit 0848f5
	        MPIF90=$with_mpi/mpif90
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
        if test "X$MPIEXEC" = "X" ; then
Packit 0848f5
            if test -x "$with_mpi/bin/mpiexec" ; then
Packit 0848f5
                MPIEXEC=$with_mpi/bin/mpiexec
Packit 0848f5
	    elif test -x "$with_mpi/mpiexec" ; then
Packit 0848f5
	        MPIEXEC=$with_mpi/mpiexec
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
        CC=$MPICC
Packit 0848f5
        F77=$MPIF77
Packit 0848f5
	if test "X$MPICXX" != "X" ; then CXX=$MPICXX ; fi
Packit 0848f5
	if test "X$MPIF90" != "X" ; then F90=$MPIF90 ; fi
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
	*)
Packit 0848f5
	# Use the default choices for the compilers
Packit 0848f5
	;;
Packit 0848f5
esac
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
AC_DEFUN([PAC_MPI_FIND_COMPILERS],[
Packit 0848f5
# Tell autoconf to determine properties of the compilers (these are the 
Packit 0848f5
# compilers for MPI programs)
Packit 0848f5
PAC_PROG_CC
Packit 0848f5
if test "$enable_f77" != no -a "$enable_fortran" != no ; then
Packit 0848f5
    AC_PROG_F77
Packit 0848f5
fi
Packit 0848f5
if test "$enable_cxx" != no ; then
Packit 0848f5
    AC_PROG_CXX
Packit 0848f5
fi
Packit 0848f5
if test "$enable_f90" != no ; then
Packit 0848f5
    PAC_PROG_FC
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl
Packit 0848f5
dnl This uses the selected CC etc to check for include paths and libraries
Packit 0848f5
AC_DEFUN([PAC_MPI_CHECK_MPI_LIB],[
Packit 0848f5
AC_REQUIRE([AC_PROG_CC])
Packit 0848f5
case $ac_mpi_type in
Packit 0848f5
    mpich)
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
    mpichnt)
Packit 0848f5
        dnl
Packit 0848f5
        dnl This isn't adequate, but it helps with using MPICH-NT/SDK.gcc
Packit 0848f5
	PAC_PUSH_FLAG([CFLAGS])
Packit 0848f5
        CFLAGS="$CFLAGS -I$with_mpichnt/include"
Packit 0848f5
	PAC_PUSH_FLAG([CPPFLAGS])
Packit 0848f5
        CPPFLAGS="$CPPFLAGS -I$with_mpichnt/include"
Packit 0848f5
	PAC_PUSH_FLAG([LDFLAGS])
Packit 0848f5
        LDFLAGS="$LDFLAGS -L$with_mpichnt/lib"
Packit 0848f5
        AC_CHECK_LIB(mpich,MPI_Init,found="yes",found="no")
Packit 0848f5
        if test "$found" = "no" ; then
Packit 0848f5
          AC_CHECK_LIB(mpich,MPI_Init,found="yes",found="no")
Packit 0848f5
        fi
Packit 0848f5
	if test "$enable_cxx" != no ; then
Packit 0848f5
	    AC_PROG_CXX
Packit 0848f5
	fi
Packit 0848f5
	if test "$enable_f90" != no ; then
Packit 0848f5
	    PAC_PROG_FC
Packit 0848f5
	fi
Packit 0848f5
	# Set defaults for the TEST versions if not already set
Packit 0848f5
	if test -z "$TESTCC" ; then TESTCC=${CC:=cc} ; fi
Packit 0848f5
	if test -z "$TESTF77" ; then TESTF77=${F77:=f77} ; fi
Packit 0848f5
	if test -z "$TESTCXX" ; then TESTCXX=${CXX:=CC} ; fi
Packit 0848f5
	if test -z "$TESTFC" ; then TESTFC=${FC:=f90} ; fi
Packit 0848f5
        if test "$found" = "no" ; then
Packit 0848f5
	  PAC_POP_FLAG([CFLAGS])
Packit 0848f5
	  PAC_POP_FLAG([CPPFLAGS])
Packit 0848f5
	  PAC_POP_FLAG([LDFLAGS])
Packit 0848f5
        fi
Packit 0848f5
        ;;
Packit 0848f5
Packit 0848f5
    lammpi)
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
    ibmmpi)
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
    sgimpi)
Packit 0848f5
	AC_CHECK_LIB(mpi,MPI_Init)
Packit 0848f5
	if test "$ac_cv_lib_mpi_MPI_Init" = "yes" ; then
Packit 0848f5
	    MPILIBNAME="mpi"
Packit 0848f5
	fi	
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
    generic)
Packit 0848f5
	AC_SEARCH_LIBS(MPI_Init,mpi mpich mpich)
Packit 0848f5
	if test "$ac_cv_lib_mpi_MPI_Init" = "yes" ; then
Packit 0848f5
	    MPILIBNAME="mpi"
Packit 0848f5
	fi	
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
    *)
Packit 0848f5
	;;
Packit 0848f5
esac
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_MPI_F2C - Determine if MPI has the MPI-2 functions MPI_xxx_f2c and
Packit 0848f5
dnl   MPI_xxx_c2f
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl Define 'HAVE_MPI_F2C' if the routines are found.
Packit 0848f5
dnl
Packit 0848f5
dnl Notes:
Packit 0848f5
dnl Looks only for 'MPI_Request_c2f'.
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_MPI_F2C],[
Packit 0848f5
AC_CACHE_CHECK([for MPI F2C and C2F routines],
Packit 0848f5
pac_cv_mpi_f2c,
Packit 0848f5
[
Packit 0848f5
AC_TRY_LINK([#include "mpi.h"],
Packit 0848f5
[MPI_Request request;MPI_Fint a;a = MPI_Request_c2f(request);],
Packit 0848f5
pac_cv_mpi_f2c="yes",pac_cv_mpi_f2c="no")
Packit 0848f5
])
Packit 0848f5
if test "$pac_cv_mpi_f2c" = "yes" ; then 
Packit 0848f5
    AC_DEFINE(HAVE_MPI_F2C,1,[Define if MPI has F2C]) 
Packit 0848f5
fi
Packit 0848f5
])
Packit 0848f5
dnl
Packit 0848f5
dnl/*D
Packit 0848f5
dnl PAC_HAVE_ROMIO - make mpi.h include mpio.h if romio enabled
Packit 0848f5
dnl
Packit 0848f5
dnl Output Effect:
Packit 0848f5
dnl expands @HAVE_ROMIO@ in mpi.h into #include "mpio.h"
Packit 0848f5
dnl D*/
Packit 0848f5
AC_DEFUN([PAC_HAVE_ROMIO],[
Packit 0848f5
if test "$enable_romio" = "yes" ; then HAVE_ROMIO='#include "mpio.h"'; fi
Packit 0848f5
AC_SUBST(HAVE_ROMIO)
Packit 0848f5
])