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

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 @@ ...@@ -3,20 +3,19 @@
# (C) 2006 by Argonne National Laboratory. # (C) 2006 by Argonne National Laboratory.
# See COPYRIGHT in top-level directory. # See COPYRIGHT in top-level directory.
# #
# mpif77 # mpif90
# Simple script to compile and/or link MPI programs. # Simple script to compile and/or link MPI programs.
# This script knows the default flags and libraries, and can handle # This script knows the default flags and libraries, and can handle
# alternative C compilers and the associated flags and libraries. # alternative C compilers and the associated flags and libraries.
# The important terms are: # The important terms are:
# includedir, libdir - Directories containing an *installed* mpich2 # includedir, libdir - Directories containing an *installed* mpich2
# prefix, execprefix - Often used to define includedir and libdir # prefix, execprefix - Often used to define includedir and libdir
# FC - Fortran 77 compiler # F90 - Fortran 90 compiler
# WRAPPER_FFLAGS - Any special flags needed to compile # WRAPPER_F90FLAGS - Any special flags needed to compile
# WRAPPER_LDFLAGS - Any special flags needed to link # WRAPPER_LDFLAGS - Any special flags needed to link
# MPILIBNAME - Name of the MPI library # MPILIBNAME - Name of the MPI library
# MPI_OTHERLIBS - Other libraries needed in order to link # 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 # We assume that (a) the C compiler can both compile and link programs
# #
...@@ -34,6 +33,7 @@ prefix=/bgsys/drivers/ppcfloor/comm/fast ...@@ -34,6 +33,7 @@ prefix=/bgsys/drivers/ppcfloor/comm/fast
exec_prefix=${prefix} exec_prefix=${prefix}
sysconfdir=${prefix}/etc sysconfdir=${prefix}/etc
includedir=${prefix}/include includedir=${prefix}/include
modincdir=${prefix}/include
libdir=${exec_prefix}/lib libdir=${exec_prefix}/lib
opalibdir=${exec_prefix}/lib opalibdir=${exec_prefix}/lib
...@@ -45,19 +45,32 @@ CP_ZLIB_LINK_FLAGS=@__CP_ZLIB_LINK_FLAGS@ ...@@ -45,19 +45,32 @@ CP_ZLIB_LINK_FLAGS=@__CP_ZLIB_LINK_FLAGS@
# Default settings for compiler, flags, and libraries # Default settings for compiler, flags, and libraries
# Determined by a combination of environment variables and tests within # Determined by a combination of environment variables and tests within
# configure (e.g., determining whehter -lsocket is needee) # configure (e.g., determining whehter -lsocket is needee)
FC=`which bgxlf90_r` F90=`which bgxlf90_r`
FC_LINKPATH_SHL="" F90_LINKPATH_SHL=""
F77CPP="" F90CPP=""
WRAPPER_FFLAGS="-I/bgsys/drivers/ppcfloor/comm/sys/include" #
# 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=" " WRAPPER_LDFLAGS=" "
MPILIBNAME="mpich.cnk" MPILIBNAME="mpich.cnk"
PMPILIBNAME="pmpich.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" NEEDSPLIB="yes"
# # MPIVERSION is the version of the MPICH2 library for which mpif90 is intended
# MPIVERSION is the version of the MPICH2 library for which mpif77 is intended
MPIVERSION="1.1" MPIVERSION="1.1"
# #
#
# Internal variables # Internal variables
# Show is set to echo to cause the compilation command to be echoed instead # Show is set to echo to cause the compilation command to be echoed instead
# of executed. # of executed.
...@@ -66,23 +79,23 @@ Show= ...@@ -66,23 +79,23 @@ Show=
# End of initialization of variables # End of initialization of variables
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Environment 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. # default choices.
# In addition, if there is a file $sysconfdir/mpif77-$F77name.conf, # In addition, if there is a file $sysconfdir/mpif90-$F90name.conf,
# where F77name is the name of the compiler with all spaces replaced by hyphens # where F90name 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 # (e.g., "f90 -64" becomes "f90--64", that file is sources, allowing other
# changes to the compilation environment. See the variables used by the # changes to the compilation environment. See the variables used by the
# script (defined above) # script (defined above)
if [ -n "$MPICH_F77" ] ; then if [ -n "$MPICH_F90" ] ; then
FC="$MPICH_F77" F90="$MPICH_F90"
F77name=`echo $FC | sed 's/ /-/g'` F90name=`echo $F90 | sed 's/ /-/g'`
if [ -s $sysconfdir/mpif77-$F77name.conf ] ; then if [ -s $sysconfdir/mpif90-$F90name.conf ] ; then
. $sysconfdir/mpif77-$F77name.conf . $sysconfdir/mpif90-$F90name.conf
fi fi
fi fi
# Allow a profiling option to be selected through an environment variable # Allow a profiling option to be selected through an environment variable
if [ -n "$MPIF77_PROFILE" ] ; then if [ -n "$MPIF90_PROFILE" ] ; then
profConf=$MPIF77_PROFILE profConf=$MPIF90_PROFILE
fi fi
# #
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
...@@ -111,33 +124,27 @@ for arg in "$@" ; do ...@@ -111,33 +124,27 @@ for arg in "$@" ; do
linking=no linking=no
;; ;;
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# Options that control how we use mpif77 (e.g., -show, # Options that control how we use mpif90 (e.g., -show,
# -f77=* -config=* # -f90=* -config=*
-echo) -echo)
addarg=no addarg=no
set -x set -x
;; ;;
-f90=*)
-f77=*) F90=`echo A$arg | sed -e 's/A-f90=//g'`
FC=`echo A$arg | sed -e 's/A-f77=//g'`
addarg=no addarg=no
;; ;;
-fc=*)
FC=`echo A$arg | sed -e 's/A-fc=//g'`
addarg=no
;;
-show) -show)
addarg=no addarg=no
Show=echo Show=echo
;; ;;
-config=*) -config=*)
addarg=no addarg=no
F77name=`echo A$arg | sed -e 's/A-config=//g'` F90name=`echo A$arg | sed -e 's/A-config=//g'`
if [ -s "$sysconfdir/mpif77-$F77name.conf" ] ; then if [ -s "$sysconfdir/mpif90-$F90name.conf" ] ; then
. "$sysconfdir/mpif77-$F77name.conf" . "$sysconfdir/mpif90-$F90name.conf"
else else
echo "Configuration file mpif77-$F77name.conf not found" echo "Configuration file mpif90-$F90name.conf not found"
fi fi
;; ;;
-compile-info|-compile_info) -compile-info|-compile_info)
...@@ -152,7 +159,7 @@ for arg in "$@" ; do ...@@ -152,7 +159,7 @@ for arg in "$@" ; do
;; ;;
-v) -v)
# Pass this argument to the compiler as well. # 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 there is only 1 argument, it must be -v.
if [ "$#" -eq "1" ] ; then if [ "$#" -eq "1" ] ; then
linking=no linking=no
...@@ -175,16 +182,14 @@ for arg in "$@" ; do ...@@ -175,16 +182,14 @@ for arg in "$@" ; do
# Loading the profConf file is handled below # Loading the profConf file is handled below
;; ;;
-help) -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 if [ -f "$sysconfdir/mpixxx_opts.conf" ] ; then
. $sysconfdir/mpixxx_opts.conf . $sysconfdir/mpixxx_opts.conf
echo " -f77=xxx - Reset the native compiler to xxx." echo " -f90=xxx - Reset the native compiler to xxx."
echo " -fc=xxx - Reset the native compiler to xxx."
else else
if [ -f "./mpixxx_opts.conf" ] ; then if [ -f "./mpixxx_opts.conf" ] ; then
. ./mpixxx_opts.conf . ./mpixxx_opts.conf
echo " -f77=xxx - Reset the native compiler to xxx." echo " -f90=xxx - Reset the native compiler to xxx."
echo " -fc=xxx - Reset the native compiler to xxx."
fi fi
fi fi
exit 0 exit 0
...@@ -197,18 +202,18 @@ for arg in "$@" ; do ...@@ -197,18 +202,18 @@ for arg in "$@" ; do
-D*) -D*)
cppflags[${#cppflags}]="$arg" cppflags[${#cppflags}]="$arg"
;; ;;
*.F|*.F90|*.fpp|*.FPP) *.F|*.F90|.fpp|.FPP)
# If F77CPP is not empty, then we need to do the following: # If F90CPP is not empty, then we need to do the following:
# If any input files have the .F or .F90 extension, then # 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 # 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 # $TMPDIR/f$$-$count.f as the output file name
# Replace the input file with this name in the args # Replace the input file with this name in the args
# This is needed only for very broken systems # This is needed only for very broken systems
# #
if [ -n "$F77CPP" ] ; then if [ -n "$F90CPP" ] ; then
if [ "$F77CPP" = "false" ] ; then if [ "$F90CPP" = "false" ] ; then
echo "This Fortran compiler does not accept .F or .F90 files" echo "This Fortran compiler does not accept .F or .F90 files"
exit 1 exit 1
fi fi
...@@ -218,8 +223,9 @@ for arg in "$@" ; do ...@@ -218,8 +223,9 @@ for arg in "$@" ; do
bfile=`basename $arg $ext` bfile=`basename $arg $ext`
# #
TMPDIR=${TMPDIR:-/tmp} TMPDIR=${TMPDIR:-/tmp}
tmpfile=$TMPDIR/f$$-$bfile.f # Make sure that we use a valid extension for the temp file.
if $F77CPP "${cppflags[@]}" $arg > $tmpfile ; then tmpfile=$TMPDIR/f$$-$bfile.$F90EXT
if $F90CPP "${cppflags[@]}" $arg > $tmpfile ; then
# Add this file to the commandline list # Add this file to the commandline list
count=`expr $count + 1` count=`expr $count + 1`
allargs[${#allargs}]="$tmpfile" allargs[${#allargs}]="$tmpfile"
...@@ -233,7 +239,7 @@ for arg in "$@" ; do ...@@ -233,7 +239,7 @@ for arg in "$@" ; do
# Otherwise, just accept the argument # Otherwise, just accept the argument
;; ;;
# - end of special handling for .F files # - end of special handling for .F files
esac esac
if [ $addarg = no ] ; then if [ $addarg = no ] ; then
unset allargs[$argno] unset allargs[$argno]
...@@ -252,14 +258,19 @@ fi ...@@ -252,14 +258,19 @@ fi
# Derived variables. These are assembled from variables set from the # Derived variables. These are assembled from variables set from the
# default, environment, configuration file (if any) and command-line # default, environment, configuration file (if any) and command-line
# options (if any) # 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 if [ "$NEEDSPLIB" = yes ] ; then
mpilibs="-l$PMPILIBNAME -l$MPILIBNAME -lopa" mpilibs="-l${MPILIBNAME}f90 -l$PMPILIBNAME -l$MPILIBNAME -lopa"
else else
mpilibs="-l$MPILIBNAME -lopa" mpilibs="-l${MPILIBNAME}f90 -l$MPILIBNAME -lopa"
fi fi
# #
# Init with the ones needed by MPI # Init with the ones needed by MPI
FFLAGS="$WRAPPER_FFLAGS" F90FLAGS="$WRAPPER_F90FLAGS"
LDFLAGS="$WRAPPER_LDFLAGS" LDFLAGS="$WRAPPER_LDFLAGS"
# #
# Handle the case of a profile switch # Handle the case of a profile switch
...@@ -277,26 +288,62 @@ if [ -n "$profConf" ] ; then ...@@ -277,26 +288,62 @@ if [ -n "$profConf" ] ; then
if [ -n "$profConffile" -a -s "$profConffile" ] ; then if [ -n "$profConffile" -a -s "$profConffile" ] ; then
. $profConffile . $profConffile
if [ -n "$PROFILE_INCPATHS" ] ; then if [ -n "$PROFILE_INCPATHS" ] ; then
FFLAGS="$PROFILE_INCPATHS $FFLAGS" F90FLAGS="$PROFILE_INCPATHS $F90FLAGS"
fi fi
if [ -n "$PROFILE_PRELIB" ] ; then if [ -n "$PROFILE_PRELIB" ] ; then
mpilibs="$PROFILE_PRELIB $mpilibs -lopa" mpilibs="$PROFILE_PRELIB $mpilibs"
fi fi
if [ -n "$PROFILE_POSTLIB" ] ; then if [ -n "$PROFILE_POSTLIB" ] ; then
mpilibs="$mpilibs $PROFILE_POSTLIB -lopa" mpilibs="$mpilibs $PROFILE_POSTLIB"
fi fi
fi 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 # A temporary statement to invoke the compiler
# Place the -L before any args incase there are any mpi libraries in there. # 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 # Eventually, we'll want to move this after any non-MPI implementation
# libraries # libraries
#
if [ "$linking" = yes ] ; then 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 # Prepend the path for the shared libraries to the library list
mpilibs="$FC_LINKPATH_SHL$libdir $mpilibs" mpilibs="$F90_LINKPATH_SHL$libdir $mpilibs"
fi fi
# Trial run to generate a symbol listing. We only enable Darshan if: # Trial run to generate a symbol listing. We only enable Darshan if:
...@@ -307,9 +354,9 @@ if [ "$linking" = yes ] ; then ...@@ -307,9 +354,9 @@ if [ "$linking" = yes ] ; then
# test in configure (in which case MPI objects break the executable) or # test in configure (in which case MPI objects break the executable) or
# if the user is using another PMPI based tool # 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 used_darshan=0
...@@ -344,7 +391,7 @@ if [ "$linking" = yes ] ; then ...@@ -344,7 +391,7 @@ if [ "$linking" = yes ] ; then
fi fi
rc=$? rc=$?
else else
$Show $FC "${allargs[@]}" -I$includedir $FFLAGS $Show $F90 "${allargs[@]}" $F90INCDIRS $F90MODDIRS $F90FLAGS
rc=$? rc=$?
fi fi
if [ -n "$rmfiles" ] ; then 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