#! /bin/sh # DoLink=1 DoCompile=0 show_compile=0 show_link=0 MPILOG= Show=eval allargs= compileargs= linkargs= linkobjs= gettinglinkarg=0 HasDashC=0 UsesPmpi=0 verbose=0 # Default compiler configuration # # Directory locations: Fixed for any MPI implementation prefix=/usr/src/mpich-1.2.5.2 exec_prefix=${prefix} sysconfdir=${exec_prefix}/etc includedir=${prefix}/include libdir=${exec_prefix}/lib # # Directory locations: Can change for each Fortran version f90includedir=${includedir} f90libdir=${libdir} # F90BASE="/opt/intel_fc_80/bin/ifort" #F90LINKERBASE="/usr/src/mpich-1.2.5.2/src/fortran/src/mpif90" F90LINKERBASE="/opt/intel_fc_80/bin/xild" LDFLAGSBASE="" BASE_FFLAGS=" " F90INC="/opt/intel_fc_80/include" # f90modinc specifies how to add a directory to the search path for modules. # Some compilers (Intel ifc) 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 and # for the directory and file respectively. F90MODINC="" F90MODINCSPEC="" USER_FFLAGS="" # # Linker flags F90_LDFLAGS="" BASE_LIB_LIST=" " FLIB_LIST="" F90LIB_PATH_LEADER="-L" F90LIB_PATH="${libdir}" MPILIBNAME="mpich" MPIVERSION="1.2.5 (release) of : 2003/01/13 16:21:53" FWRAPNAME="fmpich" FLIBNAME="mpich" # set to yes if the PMPI routines are in the same library with the MPI routines # (for example, they are built with weak symbols). MPI_WITH_PMPI="yes" proflib=-lp${MPILIBNAME} proflibfullname=${libdir}/libp${MPILIBNAME}.a # hasMPE="yes" # Shared library support SHAREDKIND="ignore" SHARED_LIB_SEARCH_PATH_LEADER='' SHARED_LIB_LOCALDIR="" sharedlibdir=${libdir}/shared # # Override the compilers using environment variables F90LINKER="${MPICH_F90LINKER-$F90LINKERBASE}" 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 else F90="$F90BASE" fi UseSharedLib=${MPICH_USE_SHLIB-no} choice=0 for arg in "$@" ; do # echo procssing arg $arg # Special processing for -o name if [ $gettinglinkarg = 1 ] ; then linkargs="$linkargs $arg" gettinglinkarg=0 outputfilename="$arg" continue fi case "$arg" in -c) # If -c is NOT specified, then we need to perform a link step. allargs="$allargs $arg" compileargs="$compileargs $arg" # If -o was set, then we need to move the output file option # to the compile line (note that this is non-standard, and should # not be used in portable codes) if [ $DoLink = 1 -a -n "$outputfilename" ] ; then compileargs="$compileargs -o $outputfilename" fi DoLink=0 HasDashC=1 ;; -o) # Need to link allargs="$allargs $arg" if [ $HasDashC = 1 ] ; then # Some BUT NOT ALL compilers support -o with -c. Allow # the user to make use of the feature, IF IT EXISTS. compileargs="$compileargs $arg" else linkargs="$linkargs $arg" compileargs="$compileargs -c" # Still need to add the target of the -o gettinglinkarg=1 DoLink=1 fi ;; -O*) allargs="$allargs $arg" compileargs="$compileargs $arg" linkargs="$linkargs $arg" if [ $choice = 0 ] ; then choice=2 ; fi ;; -choicemod) choice=1 ;; -nochoicemod) choice=2 ;; -mpilog) if [ $UsesPmpi = 1 ] ; then echo "Only one of -mpilog, -mpitrace, or -mpianim may be used." exit 1 else UsesPmpi=1 fi if [ "$hasMPE" = "yes" ] ; then MPILOG="-l${FWRAPNAME} -llmpe -lmpe" else echo "-mpilog requires the MPE libraries" fi ;; -mpitrace) if [ $UsesPmpi = 1 ] ; then echo "Only one of -mpilog, -mpitrace, or -mpianim may be used." exit 1 else UsesPmpi=1 fi if [ "$hasMPE" = "yes" ] ; then MPILOG="-l${FWRAPNAME} -ltmpe -lmpe" else echo "-mpitrace requires the MPE libraries" fi ;; -mpianim) if [ $UsesPmpi = 1 ] ; then echo "Only one of -mpilog, -mpitrace, or -mpianim may be used." exit 1 else UsesPmpi=1 fi if [ "$hasMPE" = "yes" ] ; then MPILOG="-l${FWRAPNAME} -lampe -lmpe" else echo "-mpianim requires the MPE libraries" fi ;; -echo) set -x ;; -show) Show=echo ;; -config=*) FCname=`echo A$arg | sed -e 's/A-config=//g'` if [ -s $sysconfdir/mpif90-$FCname.conf ] ; then . $sysconfdir/mpif90-$FCname.conf else echo "Configuration file mpif90-$FCname.conf not found" fi ;; -f90=*) F90=`echo A$arg | sed -e 's/A-f90=//g'` F90LINKER="$F90" ;; -compile_info) show_compile=1 DoLink=0 Show=echo ;; -link_info) show_link=1 Show=echo ;; -shlib) UseSharedLib=yes ;; -noshlib) UseSharedLib=no ;; -v) verbose=1 echo "mpif90 for $MPIVERSION" compileargs="$compileargs -v" linkargs="$linkargs -v" ;; -l*) # This SHOULD be the -l argument. Only for the linker linkargs="$linkargs $arg" allargs="$allargs $arg" ;; -help) cat <%'"$moduledir%g" -e 's//mpi/g'` compileargs="$compileargs $newarg" linkargs="$linkargs -l$modulelib" elif [ -n "$F90MODINC" ] ; then compileargs="$compileargs ${F90MODINC}$moduledir" linkargs="$linkargs -l$modulelib" fi # # Take care of mpif.h; try to add the link if necessary # We'll need to edit mpif.h to remove comments if we use mpif.h instead # of an MPI module # added_link=0 if [ -z "${F90INC}" ] ; then if [ ! -r mpif.h ] ; then #echo "Adding a symbolic link for mpif.h" trap "$Show /bin/rm mpif.h" 0 # This should really be the (related) f77includedir (see mpif77). $Show ln -s ${includedir}/mpif.h mpif.h added_link=1 fi else F90INC=${F90INC}${includedir} fi status=0 if [ $DoCompile = 1 -o $show_compile = 1 ] ; then if [ $HasDashC != 1 ] ; then compileargs="-c $compileargs" fi $Show $F90 $finc $BASE_FFLAGS $F90FLAGS $compileargs $F90INC status=$? if [ $status != 0 ] ; then exit $status fi fi if [ $DoLink = 1 -o $show_link = 1 ] ; then # If no LDFLAGS defined, use the ones that MPICH was built with if [ -z "$LDFLAGS" ] ; then LDFLAGS="$LDFLAGSBASE" fi # Figure out the library list. Because we want to support both a single # mpi library containing both C and Fortran interfaces, as well as # a library that allows multiple Fortran interfaces, we may need different # library link lines. With a unified C/Fortran library, we just # use -l${MPILIBNAME}. With separate Fortran libraries, we need # -l -l${MPILIBNAME} -l # We also handle the profiling library here, which may not be needed # for those systems that support weak symbols. # If the libraries are separate, the Fortran77 must work with the # Fortran 90 files. if [ "${MPILIBNAME}" = "${FLIBNAME}" ] ; then mpilibs="-l${MPILIBNAME}" else mpilibs="-l${FLIBNAME} -l${MPILIBNAME} -l${FLIBNAME}fsup" fi # If the profiling library doesn't exist, or MPICH_NO_PROF environment # variable is set, skip the profiling library. if [ -n "$MPICH_NO_PROF" -o ! -s "$proflibfullname" ] ; then proflib="" fi # IRIX complains if we include a library twice. In the case of a # library using weak symbols, we don't need the proflib. Just # in case we do, there is an enviroment variable that # can be used to override this test. if [ "$MPI_WITH_PMPI" = "yes" -a "$MPICH_INCLUDE_PROFLIB" != yes ] ; then proflib="" fi # If proflib is non-empty, then add it if [ -n "$proflib" ] ; then # We include the last "mpilibs" because the mpilibs contains the # ADI routines. There is a chance that a file in the first mpich.a # invokes a pmpi routine that needs an ADIO routine. mpilibs="$proflib $mpilibs $proflib $mpilibs" fi # See the comment in mpicc about UseSharedLib # Also, don't use if the shared libraries don't exist yet # (because -lmpichfarg.a won't exist yet) if [ "$SHAREDKIND" != "ignore" -a $UseSharedLib = "yes" -a \ -s ${libdir}/lib${FLIBNAME}farg.a ] ; then # We also add a library containing MPI_Init and the routines # that it uses to call getarg/iarg. flibpath="${F90LIB_PATH_LEADER}${sharedlibdir}" if [ -n "${SHARED_LIB_SEARCH_PATH_LEADER}" ] ; then flibpath="${SHARED_LIB_SEARCH_PATH_LEADER}${sharedlibdir} $flibpath" fi if [ -n "${SHAREDLIB_LOCALDIR}" ] ; then flibpath="${F90LIB_PATH_LEADER}${SHAREDLIB_LOCALDIR} $flibpath" if [ -n "${SHARED_LIB_SEARCH_PATH_LEADER}" ] ; then flibpath="${SHARED_LIB_SEARCH_PATH_LEADER}${SHAREDLIB_LOCALDIR} $flibpath" fi fi mpilibs="-l${FLIBNAME}farg $mpilibs" fi $Show $F90LINKER $F90_LDFLAGS $LDFLAGS $BASE_FFLAGS $flibpath ${F90LIB_PATH_LEADER}${F90LIB_PATH} $linkobjs $MPILOG $linkargs $mpilibs $BASE_LIB_LIST $FLIB_LIST status=$? fi # # If we added the link, remove it. if [ $added_link = 1 ] ; then $Show rm mpif.h trap 0 fi exit $status