Commit 75a61508 authored by Kevin Harms's avatar Kevin Harms

Previous file was for mpif77. Updated to correct mpif90 script.


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@206 3b7491f3-a168-0410-bf4b-c445ed680a29
parent d571c34a
......@@ -3,20 +3,19 @@
# (C) 2006 by Argonne National Laboratory.
# See COPYRIGHT in top-level directory.
#
# mpif77
# mpif90
# Simple script to compile and/or link MPI programs.
# This script knows the default flags and libraries, and can handle
# alternative C compilers and the associated flags and libraries.
# The important terms are:
# includedir, libdir - Directories containing an *installed* mpich2
# prefix, execprefix - Often used to define includedir and libdir
# FC - Fortran 77 compiler
# WRAPPER_FFLAGS - Any special flags needed to compile
# F90 - Fortran 90 compiler
# WRAPPER_F90FLAGS - Any special flags needed to compile
# WRAPPER_LDFLAGS - Any special flags needed to link
# MPILIBNAME - Name of the MPI library
# MPI_OTHERLIBS - Other libraries needed in order to link
# F77_OTHER_LIBS - Yet more libraries, needed just with F77
#
# F90_OTHER_LIBS - Yet more libraries, needed just with F90
#
# We assume that (a) the C compiler can both compile and link programs
#
......@@ -34,6 +33,7 @@ prefix=/bgsys/drivers/ppcfloor/comm/fast
exec_prefix=${prefix}
sysconfdir=${prefix}/etc
includedir=${prefix}/include
modincdir=${prefix}/include
libdir=${exec_prefix}/lib
opalibdir=${exec_prefix}/lib
......@@ -45,19 +45,32 @@ CP_ZLIB_LINK_FLAGS=@__CP_ZLIB_LINK_FLAGS@
# Default settings for compiler, flags, and libraries
# Determined by a combination of environment variables and tests within
# configure (e.g., determining whehter -lsocket is needee)
FC=`which bgxlf90_r`
FC_LINKPATH_SHL=""
F77CPP=""
WRAPPER_FFLAGS="-I/bgsys/drivers/ppcfloor/comm/sys/include"
F90=`which bgxlf90_r`
F90_LINKPATH_SHL=""
F90CPP=""
#
# Fortran 90 Compiler characteristics
F90INC="-I"
# f90modinc specifies how to add a directory to the search path for modules.
# Some compilers (Intel ifc version 5) do not support this concept, and
# instead need
# a specific list of files that contain module names and directories.
# The F90MODINCSPEC is a more general approach that uses <dir> and <file>
# for the directory and file respectively.
F90MODINC="-I"
F90MODINCSPEC=""
F90EXT="f90"
#
WRAPPER_F90FLAGS="-I/bgsys/drivers/ppcfloor/comm/sys/include"
WRAPPER_LDFLAGS=" "
MPILIBNAME="mpich.cnk"
PMPILIBNAME="pmpich.cnk"
MPI_OTHERLIBS=" -L/bgsys/drivers/ppcfloor/comm/sys/lib -Wl,-rpath,/bgsys/drivers/ppcfloor/comm/sys/lib -ldcmf-fast.cnk -ldcmfcoll-fast.cnk -lpthread -L/bgsys/drivers/ppcfloor/runtime/SPI -Wl,-rpath,/bgsys/drivers/ppcfloor/runtime/SPI -lSPI-fast.cna -lrt "
MPI_OTHERLIBS=" -L/bgsys/drivers/ppcfloor/comm/sys/lib -Wl,-rpath,/bgsys/drivers/ppcfloor/comm/sys/lib -ldcmf-fast.cnk -ldcmfcoll-fast.cnk -lpthread -L/bgsys/drivers/ppcfloor/runtime/SPI -Wl,-rpath,/bgsys/drivers/ppcfloor/runtime/SPI -lSPI-fast.cna -lrt "
NEEDSPLIB="yes"
#
# MPIVERSION is the version of the MPICH2 library for which mpif77 is intended
# MPIVERSION is the version of the MPICH2 library for which mpif90 is intended
MPIVERSION="1.1"
#
#
# Internal variables
# Show is set to echo to cause the compilation command to be echoed instead
# of executed.
......@@ -66,23 +79,23 @@ Show=
# End of initialization of variables
#---------------------------------------------------------------------
# Environment Variables.
# The environment variables MPICH_F77 may be used to override the
# The environment variables MPICH_F90 may be used to override the
# default choices.
# In addition, if there is a file $sysconfdir/mpif77-$F77name.conf,
# where F77name is the name of the compiler with all spaces replaced by hyphens
# (e.g., "f77 -64" becomes "f77--64", that file is sources, allowing other
# In addition, if there is a file $sysconfdir/mpif90-$F90name.conf,
# where F90name is the name of the compiler with all spaces replaced by hyphens
# (e.g., "f90 -64" becomes "f90--64", that file is sources, allowing other
# changes to the compilation environment. See the variables used by the
# script (defined above)
if [ -n "$MPICH_F77" ] ; then
FC="$MPICH_F77"
F77name=`echo $FC | sed 's/ /-/g'`
if [ -s $sysconfdir/mpif77-$F77name.conf ] ; then
. $sysconfdir/mpif77-$F77name.conf
if [ -n "$MPICH_F90" ] ; then
F90="$MPICH_F90"
F90name=`echo $F90 | sed 's/ /-/g'`
if [ -s $sysconfdir/mpif90-$F90name.conf ] ; then
. $sysconfdir/mpif90-$F90name.conf
fi
fi
# Allow a profiling option to be selected through an environment variable
if [ -n "$MPIF77_PROFILE" ] ; then
profConf=$MPIF77_PROFILE
if [ -n "$MPIF90_PROFILE" ] ; then
profConf=$MPIF90_PROFILE
fi
#
# ------------------------------------------------------------------------
......@@ -111,33 +124,27 @@ for arg in "$@" ; do
linking=no
;;
# ----------------------------------------------------------------
# Options that control how we use mpif77 (e.g., -show,
# -f77=* -config=*
# Options that control how we use mpif90 (e.g., -show,
# -f90=* -config=*
-echo)
addarg=no
set -x
;;
-f77=*)
FC=`echo A$arg | sed -e 's/A-f77=//g'`
-f90=*)
F90=`echo A$arg | sed -e 's/A-f90=//g'`
addarg=no
;;
-fc=*)
FC=`echo A$arg | sed -e 's/A-fc=//g'`
addarg=no
;;
-show)
addarg=no
Show=echo
;;
-config=*)
addarg=no
F77name=`echo A$arg | sed -e 's/A-config=//g'`
if [ -s "$sysconfdir/mpif77-$F77name.conf" ] ; then
. "$sysconfdir/mpif77-$F77name.conf"
F90name=`echo A$arg | sed -e 's/A-config=//g'`
if [ -s "$sysconfdir/mpif90-$F90name.conf" ] ; then
. "$sysconfdir/mpif90-$F90name.conf"
else
echo "Configuration file mpif77-$F77name.conf not found"
echo "Configuration file mpif90-$F90name.conf not found"
fi
;;
-compile-info|-compile_info)
......@@ -152,7 +159,7 @@ for arg in "$@" ; do
;;
-v)
# Pass this argument to the compiler as well.
echo "mpif77 for $MPIVERSION"
echo "mpif90 for $MPIVERSION"
# if there is only 1 argument, it must be -v.
if [ "$#" -eq "1" ] ; then
linking=no
......@@ -175,16 +182,14 @@ for arg in "$@" ; do
# Loading the profConf file is handled below
;;
-help)
NC=`echo "$FC" | sed 's%\/% %g' | awk '{print $NF}' -`
NC=`echo "$F90" | sed 's%\/% %g' | awk '{print $NF}' -`
if [ -f "$sysconfdir/mpixxx_opts.conf" ] ; then
. $sysconfdir/mpixxx_opts.conf
echo " -f77=xxx - Reset the native compiler to xxx."
echo " -fc=xxx - Reset the native compiler to xxx."
echo " -f90=xxx - Reset the native compiler to xxx."
else
if [ -f "./mpixxx_opts.conf" ] ; then
. ./mpixxx_opts.conf
echo " -f77=xxx - Reset the native compiler to xxx."
echo " -fc=xxx - Reset the native compiler to xxx."
echo " -f90=xxx - Reset the native compiler to xxx."
fi
fi
exit 0
......@@ -197,18 +202,18 @@ for arg in "$@" ; do
-D*)
cppflags[${#cppflags}]="$arg"
;;
*.F|*.F90|*.fpp|*.FPP)
# If F77CPP is not empty, then we need to do the following:
*.F|*.F90|.fpp|.FPP)
# If F90CPP is not empty, then we need to do the following:
# If any input files have the .F or .F90 extension, then
# If F77CPP = false, then
# If F90CPP = false, then
# generate an error message and exit
# Use F77CPP to convert the file from .F to .f, using
# Use F90CPP to convert the file from .F to .f, using
# $TMPDIR/f$$-$count.f as the output file name
# Replace the input file with this name in the args
# This is needed only for very broken systems
#
if [ -n "$F77CPP" ] ; then
if [ "$F77CPP" = "false" ] ; then
if [ -n "$F90CPP" ] ; then
if [ "$F90CPP" = "false" ] ; then
echo "This Fortran compiler does not accept .F or .F90 files"
exit 1
fi
......@@ -218,8 +223,9 @@ for arg in "$@" ; do
bfile=`basename $arg $ext`
#
TMPDIR=${TMPDIR:-/tmp}
tmpfile=$TMPDIR/f$$-$bfile.f
if $F77CPP "${cppflags[@]}" $arg > $tmpfile ; then
# Make sure that we use a valid extension for the temp file.
tmpfile=$TMPDIR/f$$-$bfile.$F90EXT
if $F90CPP "${cppflags[@]}" $arg > $tmpfile ; then
# Add this file to the commandline list
count=`expr $count + 1`
allargs[${#allargs}]="$tmpfile"
......@@ -233,7 +239,7 @@ for arg in "$@" ; do
# Otherwise, just accept the argument
;;
# - end of special handling for .F files
esac
if [ $addarg = no ] ; then
unset allargs[$argno]
......@@ -252,14 +258,19 @@ fi
# Derived variables. These are assembled from variables set from the
# default, environment, configuration file (if any) and command-line
# options (if any)
#
# The library lib${MPILIBNAME}f90 contains the f90-specific features,
# such as the module objects and the routines defined by them
# (MPI_SIZEOF is handled in lib${MPILIBNAME)f90, for example).
if [ "$NEEDSPLIB" = yes ] ; then
mpilibs="-l$PMPILIBNAME -l$MPILIBNAME -lopa"
mpilibs="-l${MPILIBNAME}f90 -l$PMPILIBNAME -l$MPILIBNAME -lopa"
else
mpilibs="-l$MPILIBNAME -lopa"
mpilibs="-l${MPILIBNAME}f90 -l$MPILIBNAME -lopa"
fi
#
# Init with the ones needed by MPI
FFLAGS="$WRAPPER_FFLAGS"
F90FLAGS="$WRAPPER_F90FLAGS"
LDFLAGS="$WRAPPER_LDFLAGS"
#
# Handle the case of a profile switch
......@@ -277,26 +288,62 @@ if [ -n "$profConf" ] ; then
if [ -n "$profConffile" -a -s "$profConffile" ] ; then
. $profConffile
if [ -n "$PROFILE_INCPATHS" ] ; then
FFLAGS="$PROFILE_INCPATHS $FFLAGS"
F90FLAGS="$PROFILE_INCPATHS $F90FLAGS"
fi
if [ -n "$PROFILE_PRELIB" ] ; then
mpilibs="$PROFILE_PRELIB $mpilibs -lopa"
mpilibs="$PROFILE_PRELIB $mpilibs"
fi
if [ -n "$PROFILE_POSTLIB" ] ; then
mpilibs="$mpilibs $PROFILE_POSTLIB -lopa"
mpilibs="$mpilibs $PROFILE_POSTLIB"
fi
fi
fi
# Construct the line to add the include directory (not all compilers
# use -I, unfortunately)
if [ -z "${F90INC}" ] ; then
# If there is no path, add a link to the mpif.h file.
# There *must* be a way to provide the path the any modules (there
# may be too many to link)
if [ ! -r mpif.h ] ; then
#echo "Adding a symbolic link for mpif.h"
trap "$Show rm -f mpif.h" 0
# This should really be the (related) f77includedir (see mpif77).
$Show ln -s ${includedir}/mpif.h mpif.h
# Remember to remove this file
rmfiles="$rmfiles mpif.h"
fi
F90INCDIRS=
else
# Normally, F90INC is just -I, but some compilers have used different
# command line arguments
F90INCDIRS=${F90INC}${includedir}
fi
# Handle the specification of the directory containing the modules
# For now, these are in the includedir (no choice argument supported)
moduledir=$modincdir
modulelib=${MPILIBNAME}f90
if [ -n "$F90MODINCSPEC" ] ; then
newarg=`echo A"$F90MODINCSPEC" | \
sed -e 's/^A//' -e 's%<dir>%'"$moduledir%g" -e 's/<file>/mpi/g'`
F90MODDIRS="$newarg"
F90MODLIBS="-l$modulelib"
elif [ -n "$F90MODINC" ] ; then
F90MODDIRS="${F90MODINC}$moduledir"
F90MODLIBS="-l$modulelib"
fi
#
# A temporary statement to invoke the compiler
# Place the -L before any args incase there are any mpi libraries in there.
# Eventually, we'll want to move this after any non-MPI implementation
# libraries
#
if [ "$linking" = yes ] ; then
if [ -n "$FC_LINKPATH_SHL" ] ; then
if [ -n "$F90_LINKPATH_SHL" ] ; then
# Prepend the path for the shared libraries to the library list
mpilibs="$FC_LINKPATH_SHL$libdir $mpilibs"
mpilibs="$F90_LINKPATH_SHL$libdir $mpilibs"
fi
# Trial run to generate a symbol listing. We only enable Darshan if:
......@@ -307,9 +354,9 @@ if [ "$linking" = yes ] ; then
# test in configure (in which case MPI objects break the executable) or
# if the user is using another PMPI based tool
stock_link_cmd="$FC ${allargs[@]} -I$includedir $FFLAGS $LDFLAGS -L$libdir -L$opalibdir $mpilibs $MPI_OTHERLIBS"
stock_link_cmd="$F90 ${allargs[@]} $F90INCDIRS $F90MODDIRS $F90FLAGS $LDFLAGS -L$libdir -L$opalibdir $F90MODLIBS $mpilibs $MPI_OTHERLIBS"
darshan_link_cmd="$FC ${CP_WRAPPERS} ${allargs[@]} -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -lfmpich.cnk -ldarshan-posix -ldarshan-mpi-io -I$includedir $FFLAGS $LDFLAGS -L$libdir -L$opalibdir $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix -ldarshan-mpi-io -lz"
darshan_link_cmd="$F90 ${CP_WRAPPERS} ${allargs[@]} -L${DARSHAN_LIB_PATH} ${CP_ZLIB_LINK_FLAGS} -lfmpich.cnk -ldarshan-posix -ldarshan-mpi-io $F90INCDIRS $F90MODDIRS $F90FLAGS $LDFLAGS -L$libdir -L$opalibdir $F90MODLIBS $mpilibs $MPI_OTHERLIBS -L${DARSHAN_LIB_PATH} -ldarshan-posix -ldarshan-mpi-io -lz"
used_darshan=0
......@@ -344,7 +391,7 @@ if [ "$linking" = yes ] ; then
fi
rc=$?
else
$Show $FC "${allargs[@]}" -I$includedir $FFLAGS
$Show $F90 "${allargs[@]}" $F90INCDIRS $F90MODDIRS $F90FLAGS
rc=$?
fi
if [ -n "$rmfiles" ] ; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment