925 |
|
AC_DEFUN([ACX_MPI], [ |
926 |
|
|
927 |
|
# Set variables... |
928 |
< |
AC_ARG_WITH(mpi, |
929 |
< |
[AC_HELP_STRING([--with-mpi=<prefix>], [use MPI libraries in <prefix>])]) |
930 |
< |
case $with_mpi in |
931 |
< |
yes | "") ;; |
932 |
< |
no) acx_mpi_ok=disable ;; |
933 |
< |
*) MPI="$with_mpi";; |
934 |
< |
esac |
935 |
< |
if test -z "$MPI"; then |
936 |
< |
MPI="/usr/local" |
937 |
< |
fi |
938 |
< |
|
939 |
< |
if "$acx_mpi_ok" != "disable"; then |
940 |
< |
MPI_LIBS_PATH="$MPI/lib" |
941 |
< |
MPI_INCLUDES_PATH="$MPI/include" |
928 |
> |
MPI_LIB_DIR="$MPI/lib" |
929 |
> |
MPI_INC_DIR="$MPI/include" |
930 |
> |
AC_SUBST([MPI_LIB_DIR]) |
931 |
> |
AC_SUBST([MPI_INC_DIR]) |
932 |
|
|
933 |
< |
# Check that the compiler uses the library we specified... |
934 |
< |
MPI_IMPL="mpi" |
935 |
< |
if test -e $MPI_LIBS_PATH/lib$MPI_IMPL.a || test -e $MPI_LIBS_PATH/lib$MPI_IMPL.so; then |
936 |
< |
echo "note: using $MPI_LIBS_PATH/lib$MPI_IMPL (.a/.so)" |
933 |
> |
AC_MSG_CHECKING([for mpi.h]) |
934 |
> |
have_mpi_h=0 |
935 |
> |
echo '#include <mpi.h>' > conftest.cc |
936 |
> |
if test -z "`${CXX} -I${MPI_INC_DIR} -c conftest.cc 2>&1`"; then |
937 |
> |
AC_MSG_RESULT(yes) |
938 |
> |
have_mpi_h=1 |
939 |
> |
else |
940 |
> |
AC_MSG_RESULT(no! Check MPI include paths) |
941 |
> |
USE_MPI="no" |
942 |
> |
fi |
943 |
> |
rm -f conftest* |
944 |
> |
if test "$have_mpi_h" = 1; then |
945 |
> |
AC_DEFINE(HAVE_MPI_H, 1, [have mpi.h]) |
946 |
> |
fi |
947 |
|
|
948 |
< |
# Ensure the comiler finds the library... |
949 |
< |
tmpLIBS=$LIBS |
950 |
< |
AC_LANG_SAVE |
951 |
< |
AC_LANG_C |
952 |
< |
LIBS="-L$MPI_LIBS_PATH $LIBS" |
953 |
< |
AC_CHECK_LIB( |
954 |
< |
[$MPI_IMPL], |
955 |
< |
[MPI_Init], |
956 |
< |
[], |
957 |
< |
[AC_MSG_ERROR( [Could not link in the MPI library... exiting] )] ) |
958 |
< |
MPI_LIBS="-l$MPI_IMPL" |
959 |
< |
MPI_LIBS_PATHS="-L$MPI_LIBS_PATH" |
960 |
< |
AC_LANG_RESTORE |
961 |
< |
LIBS=$tmpLIBS |
948 |
> |
AC_MSG_CHECKING([whether mpif.h is usable]) |
949 |
> |
have_mpif_h=0 |
950 |
> |
rm -f conftest* |
951 |
> |
cat >conftest.f90 <<EOF |
952 |
> |
program main |
953 |
> |
include 'mpif.h' |
954 |
> |
end |
955 |
> |
EOF |
956 |
> |
if $F90 -I$MPI_INC_DIR -c conftest.f90 > conftest.out 2>&1 ; then |
957 |
> |
AC_MSG_RESULT(yes) |
958 |
> |
MPI_F90_INC="$MPI_INC" |
959 |
> |
have_mpif_h=1 |
960 |
> |
else |
961 |
> |
if test -s conftest.out ; then |
962 |
> |
cat conftest.out >> config.log |
963 |
> |
fi |
964 |
> |
AC_MSG_RESULT([no! Check MPI include paths]) |
965 |
> |
USE_MPI="no" |
966 |
> |
fi |
967 |
> |
rm -f conftest* |
968 |
> |
AC_SUBST(MPI_F90_INC) |
969 |
> |
if test "$have_mpif_h" = 1; then |
970 |
> |
AC_DEFINE(HAVE_MPIF_H, 1, [have mpif.h]) |
971 |
> |
fi |
972 |
|
|
973 |
< |
# Ensure the comiler finds the header file... |
974 |
< |
if test -e $MPI_INCLUDES_PATH/mpi.h; then |
975 |
< |
echo "note: using $MPI_INCLUDES_PATH/mpi.h" |
976 |
< |
tmpCPPFLAGS=$CPPFLAGS |
977 |
< |
AC_LANG_SAVE |
978 |
< |
AC_LANG_C |
979 |
< |
CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" |
980 |
< |
AC_CHECK_HEADER( |
981 |
< |
[mpi.h], |
982 |
< |
[AC_DEFINE( |
983 |
< |
[HAVE_MPI_H],, |
984 |
< |
[Define to 1 if you have the <mpi.h> header file.])], |
985 |
< |
[AC_MSG_ERROR( [Could not compile in the MPI headers... exiting] )] ) |
986 |
< |
MPI_INCLUDES_PATHS="-I$MPI_INCLUDES_PATH" |
987 |
< |
AC_LANG_RESTORE |
988 |
< |
CPPFLAGS=$tmpCPPFLAGS |
989 |
< |
else |
990 |
< |
AC_MSG_ERROR( [Could not physically find MPI header file... exiting] ) |
991 |
< |
fi |
992 |
< |
else |
993 |
< |
# Try look for mpich |
994 |
< |
MPI_IMPL="mpich" |
995 |
< |
if test -e $MPI_LIBS_PATH/lib$MPI_IMPL.a || test -e $MPI_LIBS_PATH/lib$MPI_IMPL.so; then |
996 |
< |
echo "note: using $MPI_LIBS_PATH/lib$MPI_IMPL (.a/.so)" |
973 |
> |
AC_LANG_PUSH(C) |
974 |
> |
ac_save_LDFLAGS=$LDFLAGS |
975 |
> |
LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR} " |
976 |
> |
|
977 |
> |
if test x = x"$MPI_LIB"; then |
978 |
> |
AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi"]) |
979 |
> |
fi |
980 |
> |
if test x = x"$MPI_LIB"; then |
981 |
> |
AC_CHECK_LIB(mpich, MPI_Init, [MPI_LIB="-lmpich"]) |
982 |
> |
fi |
983 |
> |
$as_unset ac_cv_lib_mpi_MPI_Init |
984 |
> |
if test x = x"$MPI_LIB"; then |
985 |
> |
AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam"], [], |
986 |
> |
"-llam") |
987 |
> |
fi |
988 |
> |
|
989 |
> |
$as_unset ac_cv_lib_mpi_MPI_Init |
990 |
> |
if test x = x"$MPI_LIB"; then |
991 |
> |
AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam -lpthread"],[ |
992 |
> |
AC_MSG_ERROR([Didn't find liblam, libmpi, or libmpich; check path for MPI package first...]) |
993 |
> |
USE_MPI="no" |
994 |
> |
], |
995 |
> |
[-llam -lpthread]) |
996 |
> |
fi |
997 |
|
|
998 |
< |
# Ensure the comiler finds the library... |
989 |
< |
tmpLIBS=$LIBS |
990 |
< |
AC_LANG_SAVE |
991 |
< |
AC_LANG_C |
992 |
< |
LIBS="-L$MPI_LIBS_PATH $LIBS" |
993 |
< |
AC_CHECK_LIB( |
994 |
< |
[$MPI_IMPL], |
995 |
< |
[MPI_Init], |
996 |
< |
[], |
997 |
< |
[AC_MSG_ERROR( [Could not link in the MPI library... exiting] )] ) |
998 |
< |
MPI_LIBS="-l$MPI_IMPL" |
999 |
< |
MPI_LIBS_PATHS="-L$MPI_LIBS_PATH" |
1000 |
< |
AC_LANG_RESTORE |
1001 |
< |
LIBS=$tmpLIBS |
998 |
> |
AC_SUBST(MPI_LIB) |
999 |
|
|
1000 |
< |
# Ensure the comiler finds the header file... |
1001 |
< |
if test -e $MPI_INCLUDES_PATH/mpi.h; then |
1002 |
< |
echo "note: using $MPI_INCLUDES_PATH/mpi.h" |
1003 |
< |
tmpCPPFLAGS=$CPPFLAGS |
1004 |
< |
AC_LANG_SAVE |
1005 |
< |
AC_LANG_C |
1006 |
< |
CPPFLAGS="-I$MPI_INCLUDES_PATH $CPPFLAGS" |
1007 |
< |
AC_CHECK_HEADER( |
1008 |
< |
[mpi.h], |
1009 |
< |
[AC_DEFINE( |
1013 |
< |
[HAVE_MPI_H],, |
1014 |
< |
[Define to 1 if you have the <mpi.h> header file.])], |
1015 |
< |
[AC_MSG_ERROR( [Could not compile in the MPI headers... exiting] )] ) |
1016 |
< |
MPI_INCLUDES_PATHS="-I$MPI_INCLUDES_PATH" |
1017 |
< |
AC_LANG_RESTORE |
1018 |
< |
CPPFLAGS=$tmpCPPFLAGS |
1019 |
< |
else |
1020 |
< |
AC_MSG_ERROR( [Could not physically find MPI header file... exiting] ) |
1021 |
< |
fi |
1022 |
< |
else |
1023 |
< |
# Try let the compiler find eith mpi or mpich |
1024 |
< |
tmpLIBS=$LIBS |
1025 |
< |
tmpCPPFLAGS=$CPPFLAGS |
1026 |
< |
AC_LANG_SAVE |
1027 |
< |
AC_LANG_C |
1028 |
< |
AC_CHECK_LIB( |
1029 |
< |
[mpi], |
1030 |
< |
[MPI_Init], |
1031 |
< |
[MPI_IMPL="mpi";MPI="";MPI_LIBS_PATH="";echo "note: using mpi library found in default build path"], |
1032 |
< |
[AC_CHECK_LIB( |
1033 |
< |
[mpich], |
1034 |
< |
[MPI_Init], |
1035 |
< |
[MPI_IMPL="mpich";MPI="";MPI_LIBS_PATH="";echo "note: using mpich library found in default build path"], |
1036 |
< |
[AC_MSG_ERROR( [Could not find/link in the MPI library... exiting] )] )] ) |
1037 |
< |
AC_CHECK_HEADER( |
1038 |
< |
[mpi.h], |
1039 |
< |
[MPI_INCLUDES_PATH="";AC_DEFINE( |
1040 |
< |
[HAVE_MPI_H],, |
1041 |
< |
[Define to 1 if you have the <mpi.h> header file.])], |
1042 |
< |
[AC_MSG_ERROR( [Could not find/compile in the MPI headers... exiting] )] ) |
1043 |
< |
AC_LANG_RESTORE |
1044 |
< |
LIBS=$tmpLIBS |
1045 |
< |
CPPFLAGS=$tmpCPPFLAGS |
1046 |
< |
|
1047 |
< |
MPI_LIBS="-l$MPI_IMPL" |
1048 |
< |
MPI_LIBS_PATHS="" |
1049 |
< |
MPI_INCLUDES_PATHS="" |
1050 |
< |
fi |
1051 |
< |
fi |
1052 |
< |
|
1053 |
< |
# AlphaServer SCs MPI requires the elan library to be included too |
1054 |
< |
if nm $MPI_LIBS_PATH/lib$MPI_IMPL.a | grep elan > /dev/null; then |
1055 |
< |
echo "note: MPI found to use Quadrics switch, looking for elan library" |
1056 |
< |
AC_CHECK_LIB( |
1057 |
< |
[elan], |
1058 |
< |
[elan_init], |
1059 |
< |
[MPI_LIBS="$MPI_LIBS -lelan"], |
1060 |
< |
[AC_MSG_ERROR( |
1061 |
< |
[Could not find elan library... exiting] )] ) |
1062 |
< |
fi; |
1063 |
< |
|
1064 |
< |
# Save variables... |
1065 |
< |
AC_SUBST( MPI ) |
1066 |
< |
AC_SUBST( MPI_IMPL ) |
1067 |
< |
AC_SUBST( MPI_LIBS ) |
1068 |
< |
AC_SUBST( MPI_LIBS_PATH ) |
1069 |
< |
AC_SUBST( MPI_LIBS_PATHS ) |
1070 |
< |
AC_SUBST( MPI_INCLUDES_PATH ) |
1071 |
< |
AC_SUBST( MPI_INCLUDES_PATHS ) |
1000 |
> |
AC_MSG_CHECKING([for MPI Fortran library]) |
1001 |
> |
MPI_F90_LIB="" |
1002 |
> |
if test -f "$MPI_LIB_DIR/libfmpich.a" ; then |
1003 |
> |
MPI_F90_LIB="-lfmpich" |
1004 |
> |
elif test -f "$MPI_LIB_DIR/liblamf77mpi.a" ; then |
1005 |
> |
MPI_F90_LIB="-llamf77mpi" |
1006 |
> |
else |
1007 |
> |
dnl nothing special found, we'll assume that the C |
1008 |
> |
dnl library is all we need |
1009 |
> |
MPI_F90_LIB=" " |
1010 |
|
fi |
1011 |
+ |
AC_MSG_RESULT([found $MPI_F90_LIB]) |
1012 |
+ |
AC_SUBST(MPI_F90_LIB) |
1013 |
|
])dnl ACX_MPI |