Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:12

0001 
0002 #!/bin/bash
0003 #
0004 #  file:        install_sherpa.sh
0005 #  description: BASH script for the installation of the SHERPA MC generator,
0006 #               downloads and installs SHERPA, HepMC2, LHAPDF, BlackHat,
0007 #               OpenMPI, FastJet and qd (if required),
0008 #               can be used standalone or called from other scripts,
0009 #  uses:        install_hepmc2.sh
0010 #               install_lhapdf.sh
0011 #               install_blackhat.sh
0012 #               install_qd.sh
0013 #               install_openmpi.sh
0014 #               install_fastjet.sh
0015 #               SHERPA patches/fixes [see below]
0016 #
0017 #  author:      Markus Merschmeyer, Sebastian Thüer, RWTH Aachen University
0018 #  date:        2014/02/22
0019 #  version:     4.3
0020 #
0021 
0022 print_help() {
0023     echo "" && \
0024     echo "install_sherpa version 4.3" && echo && \
0025     echo "options: -v  version    define SHERPA version ( "${SHERPAVER}" )" && \
0026     echo "         -d  path       define (SHERPA) installation directory" && \
0027     echo "                         -> ( "${IDIR}" )" && \
0028     echo "         -p  path       apply official SHERPA patches ( "${PATCHES}" )" && \
0029     echo "                         from this path ( "${PDIR}" )" && \
0030     echo "         -m  version    request HepMC2 installation ( "${HEPMC}", "${HVER}" )" && \
0031     echo "         -M  options    special HepMC2 options ( "${OPTHEPMC}" )" && \
0032     echo "         -l  version    request LHAPDF installation ( "${LHAPDF}", "${LVER}" )" && \
0033     echo "         -L  options    special LHAPDF options ( "${OPTLHAPDF}" )" && \
0034     echo "         -P  name       automatically retrieve LHAPDF set ( "${PDFSET}" )" && \
0035     echo "         -f  version    request FastJet installation ( "${FJ}", "${FJVER}" )" && \
0036     echo "         -F  options    special FastJet options ( "${OPTFJ}" )" && \
0037 #    echo "         -S             link (softlink) LHAPDF sets ( "${LINKPDF}" )" && \
0038 #    echo "                         or do a hardcopy if not set" && \
0039     echo "         -q  version    request qd installation ( "${QD}", "${QDVER}" )" && \
0040     echo "         -Q  options    special qd options ( "${OPTQD}" )" && \
0041     echo "         -b  version    request BlackHat installation ( "${BH}", "${BHVER}" )" && \
0042     echo "         -B  options    special BlackHat options ( "${OPTBH}" )" && \
0043     echo "         -o  version    request openmpi installation ( "${OM}", "${OMVER}" )" && \
0044     echo "         -O  options    special openmpi options ( "${OPTOM}" )" && \
0045     echo "         -W  location   (web)location of SHERPA tarball ( "${SHERPAWEBLOCATION}" )" && \
0046     echo "         -Y  filename   file name of SHERPA tarball ( "${SHERPAFILE}" )" && \
0047     echo "         -C  level      cleaning level of SHERPA installation ("${LVLCLEAN}" )" && \
0048     echo "                         -> 0: nothing, 1: +objects, 2: +sourcecode" && \
0049     echo "         -c  option     add option for configure script ("${OPTCONFIG}" )" && \
0050     echo "         -T             enable multithreading"  && \
0051     echo "         -t             enable MPI" && \
0052     echo "         -A             enable analysis" && \
0053     echo "         -D             debug flag, compile with '-g' option ("${FLGDEBUG}" )" && \
0054     echo "         -X             create XML file for tool override in CMSSW ( "${FLGXMLFL}" )" && \
0055     echo "         -Z             use multiple CPU cores if available ( "${FLGMCORE}" )" && \
0056     echo "         -K             keep SHERPA source code tree after installation ( "${FLGKEEPT}" )" && \
0057     echo "         -h             display this help and exit" && echo
0058 }
0059 
0060 replace_tool() {
0061 # $1 : tool name (e.g. 'qd')
0062 # $2 : path to replacement XML file
0063 # $3 : name of replacement XML file
0064 # $4 : tool installation directory
0065 # $5 : output file name
0066     echo "#################################################################" >> $5
0067     echo "" >> $5
0068     echo "tmptool=$1" >> $5
0069     echo "tmpfil=\${tmptool}.xml" >> $5
0070     echo "tmpxml=\`find \$CMSSW_BASE/config/ -type f -name \${tmpfil}\`" >> $5
0071     echo "if [ \"\${tmpxml}\" = \"\" ]; then" >> $5
0072     echo "  tmpxml=\`find \$CMSSW_BASE/config/ -type d -name available\`" >> $5
0073     echo "  tmpxml=\${tmpxml}/\${tmpfil}" >> $5
0074     echo "else" >> $5
0075     echo "  scramv1 tool remove \${tmptool}" >> $5
0076     echo "fi" >> $5
0077     echo "cp $2/$3 \${tmpxml}" >> $5
0078     echo "scramv1 setup \${tmptool}" >> $5
0079     echo "newlibpath=\`find $4 -name \\*.\*a -printf %h\\\\\n | head -1\`" >> $5
0080     echo "export LD_LIBRARY_PATH=\${newlibpath}:\$LD_LIBRARY_PATH" >> $5
0081     echo "" >> $5
0082     echo "#################################################################" >> $5
0083 }
0084 
0085 
0086 
0087 
0088 # save current path
0089 HDIR=`pwd`
0090 
0091 
0092 # get absolute path of this script
0093 SCRIPT=$(readlink -f $0)
0094 #echo "XXX: "$SCRIPT
0095 SCRIPTPATH=`dirname $SCRIPT`
0096 #echo "YYY: "$SCRIPTPATH
0097 
0098 
0099 # dummy setup (if all options are missing)
0100 IDIR="/tmp"                # installation directory
0101 SHERPAVER="1.2.0"          # SHERPA version to be installed
0102 SHCFLAGS=""                # SHERPA compiler flags
0103 HEPMC="FALSE"              # install HepMC2
0104 HVER="2.05.00"             # HepMC2 version to be installed
0105 OPTHEPMC=""                # special HepMC2 installation options
0106 LHAPDF="FALSE"             # install LHAPDF
0107 OPTLHAPDF=""               # special LHAPDF installation options
0108 PDFSET=""                  # name of PDFset to download
0109 #LINKPDF="FALSE"            # link (softlink) LHAPDF sets
0110 LVER="5.6.0"               # LHAPDF version to be installed
0111 FJ="FALSE"                 # install FastJet
0112 FJVER="2.4.5"              # FastJet version to be installed
0113 OPTFJ=""                   # special FastJet installation options
0114 QD="FALSE"                 # install qd
0115 QDVER="2.3.13"             # qd version to be installed
0116 OPTQD=""                   # special qd installation options
0117 BH="FALSE"                 # install BlackHat
0118 BHVER="0.9.9"              # BlackHat version to be installed
0119 OPTBH=""                   # special BlackHat installation options
0120 OM="FALSE"                 # install openmpi
0121 OMVER="1.6.5"              # openmpi version to be installed
0122 OPTOM=""                   # special openmpi installation options
0123 PATCHES="FALSE"            # apply SHERPA patches
0124 PDIR="./"                  # path containing patches
0125 SHERPAWEBLOCATION=""       # (web)location of SHERPA tarball
0126 SHERPAFILE=""              # file name of SHERPA tarball
0127 LVLCLEAN=0                 # cleaning level (0-2)
0128 OPTCONFIG=""               # option(s) for configure script
0129 FLGDEBUG="FALSE"           # debug flag for compilation
0130 FLGXMLFL="FALSE"           # create XML tool definition file for SCRAM?
0131 FLGKEEPT="FALSE"           # keep the source code tree?
0132 FLGMCORE="FALSE"           # use multiple cores for compilation
0133 
0134 
0135 # get & evaluate options
0136 while getopts :v:d:m:l:f:q:b:o:p:W:P:Y:C:c:M:L:F:Q:B:O:STtADXZKh OPT
0137 do
0138   case $OPT in
0139   v) SHERPAVER=$OPTARG ;;
0140   d) IDIR=$OPTARG ;;
0141   m) HEPMC=TRUE && HVER=$OPTARG ;;
0142   M) OPTHEPMC=${OPTHEPMC}" "$OPTARG ;;
0143   l) LHAPDF=TRUE && LVER=$OPTARG ;;
0144   L) OPTLHAPDF=${OPTLHAPDF}" "$OPTARG ;;
0145   P) PDFSET=$PDFSET" "$OPTARG ;;
0146 #  S) LINKPDF=TRUE ;;
0147   f) FJ=TRUE && FJVER=$OPTARG ;;
0148   F) OPTFJ=${OPTFJ}" "$OPTARG ;;
0149   q) QD=TRUE && QDVER=$OPTARG ;;
0150   Q) OPTQD=${OPTQD}" "$OPTARG ;;
0151   b) BH=TRUE && BHVER=$OPTARG ;;
0152   B) OPTBH=${OPTBH}" "$OPTARG ;;
0153   o) OM=TRUE && OMVER=$OPTARG ;;
0154   O) OPTOM=${OPTOM}" "$OPTARG ;;
0155   p) PATCHES=TRUE && PDIR=$OPTARG ;;
0156   T) SHCFLAGS=${SHCFLAGS}" --enable-multithread" ;;
0157   t) SHCFLAGS=${SHCFLAGS}" --enable-mpi" ;;
0158   A) SHCFLAGS=${SHCFLAGS}" --enable-analysis" ;;
0159   W) SHERPAWEBLOCATION=$OPTARG ;;
0160   Y) SHERPAFILE=$OPTARG ;;
0161   C) LVLCLEAN=$OPTARG ;;
0162   c) SHCFLAGS=${SHCFLAGS}" "$OPTARG ;;
0163   D) FLGDEBUG=TRUE ;;
0164   X) FLGXMLFL=TRUE ;;
0165   Z) FLGMCORE=TRUE ;;
0166   K) FLGKEEPT=TRUE ;;
0167   h) print_help && exit 0 ;;
0168   \?)
0169     shift `expr $OPTIND - 1`
0170     if [ "$1" = "--help" ]; then print_help && exit 0;
0171     else 
0172       echo -n "install_sherpa: error: unrecognized option "
0173       if [ $OPTARG != "-" ]; then echo "'-$OPTARG'. try '-h'"
0174       else echo "'$1'. try '-h'"
0175       fi
0176       print_help && exit 1
0177     fi
0178   esac
0179 done
0180 
0181 
0182 # set up file names
0183 MSI=$HDIR                            # main installation directory
0184 MSI=$SCRIPTPATH
0185 shpatchfile="sherpa_patches_"${SHERPAVER}".tgz" # official patches for current SHERPA version
0186 shfixfile="sherpa_fixes_"${SHERPAVER}".tgz"     # fixes for current SHERPA version
0187 shshifile="install_sherpa.sh"        # this script
0188 shhmifile="install_hepmc2.sh"        # script for HepMC2 installation
0189 shlhifile="install_lhapdf.sh"        # script for LHAPDF installation
0190 shqdifile="install_qd.sh"            # script for qd installation
0191 shbhifile="install_blackhat.sh"      # script for BlackHat installation
0192 shomifile="install_openmpi.sh"       # script for openmpi installation
0193 shfjifile="install_fastjet.sh"       # script for FastJet installation
0194 
0195 
0196 # set SHERPA (HepMC2,LHAPDF) download location
0197 if [ "$SHERPAWEBLOCATION" = "" ]; then
0198   SHERPAWEBLOCATION="http://www.hepforge.org/archive/sherpa"
0199   FLOC=" "
0200 else
0201   if [ -e ${SHERPAWEBLOCATION} ]; then   # is the location a local subdirectory?
0202     if [ -d ${SHERPAWEBLOCATION} ]; then
0203       cd ${SHERPAWEBLOCATION}; SHERPAWEBLOCATION=`pwd`; cd ${HDIR}
0204     fi
0205   fi
0206   FLOC=" -W "${SHERPAWEBLOCATION}
0207 fi
0208 if [ "$SHERPAFILE" = "" ]; then
0209   SHERPAFILE="SHERPA-MC-"${SHERPAVER}".tar.gz"
0210 fi
0211 
0212 
0213 # make SHERPA version a global variable
0214 export SHERPAVER=${SHERPAVER}
0215 export HEPMC2VER=${HVER}
0216 export LHAPDFVER=${LVER}
0217 export BHVER=${BHVER}
0218 export QDVER=${QDVER}
0219 export OMVER=${OMVER}
0220 
0221 # always use absolute path names...
0222 cd ${IDIR}; IDIR=`pwd`; cd ${HDIR}
0223 cd ${PDIR}; PDIR=`pwd`; cd ${HDIR}
0224 cd ${FDIR}; FDIR=`pwd`; cd ${HDIR}
0225 
0226 # print basic setup information
0227 echo " SHERPA (HepMC2,LHAPDF) installation: "
0228 echo "  -> SHERPA version: '"${SHERPAVER}"'"
0229 echo "  -> installation directory: '"${IDIR}"'"
0230 echo "  -> SHERPA patches: '"${PATCHES}"' in '"${PDIR}"'"
0231 echo "  -> SHERPA location: '"${SHERPAWEBLOCATION}"'"
0232 echo "  -> SHERPA file name: '"${SHERPAFILE}"'"
0233 echo "  -> cleaning level: '"${LVLCLEAN}"'"
0234 echo "  -> configure options: '"${SHCFLAGS}"'"
0235 echo "  -> debugging mode: '"${FLGDEBUG}"'"
0236 echo "  -> CMSSW override: '"${FLGXMLFL}"'"
0237 echo "  -> keep sources:   '"${FLGKEEPT}"'"
0238 echo "  -> use multiple CPU cores: '"${FLGMCORE}"'"
0239 echo "  -> HepMC2: '"${HEPMC}"', version '"${HVER}"'"
0240 echo "  ->   options: "${OPTHEPMC}
0241 echo "  -> LHAPDF: '"${LHAPDF}"', version '"${LVER}"'"
0242 echo "  ->   options: "${OPTLHAPDF}
0243 echo "  ->   PDFsets: "${PDFSET}
0244 #echo "  -> link PDFsets: '"${LINKPDF}"'"
0245 echo "  -> qd: '"${QD}"', version '"${QDVER}"'"
0246 echo "  ->   options: "${OPTQD}
0247 echo "  -> BlackHat: '"${BH}"', version '"${BHVER}"'"
0248 echo "  ->   options: "${OPTBH}
0249 echo "  -> openmpi: '"${OM}"', version '"${OMVER}"'"
0250 echo "  ->   options: "${OPTOM}
0251 
0252 
0253 
0254 # set basic CXX, CXXFLAGS and LDFLAGS & other flags
0255 #tmpcxx=""
0256 ##tmpcxx="g++"
0257 #~ tmpcxx="g++44"
0258 #~ tmpcc="gcc44"
0259 #~ tmpfc="gfortran44"
0260 #~ tmpf77="gfortran44"
0261 ######tmpcxxflg="-O2 -m64 -I$MPI_INCLUDE"
0262 tmpcxxflg="-O2 -m64"
0263 tmpcflg="-O2 -m64"
0264 tmpfflg="-O2 -m64"
0265 tmpfcflg="-O2 -m64"
0266 
0267 
0268 ##tmpcxxflg="-O2 -m64 -std=c++0x -fuse-cxa-atexit"
0269 #tmpcxxflg="-O2 -m64"
0270 if [ "$FLGDEBUG" = "TRUE" ]; then
0271   tmpcxxflg=${tmpcxxflg}" -g"
0272 fi
0273 #######tmpldflg="-ldl -L$MPI_LIBDIR -lmpi -lmpi_cxx"
0274 tmpldflg="-ldl"
0275 ##tmpldflg="-ldl"
0276 tmpconfg=""
0277 ##tmpconfg="--disable-silent-rules"
0278 if [ "${tmpcxx}" != "" ]; then
0279   if [ "${CXX}" != "" ]; then
0280     export CXX=${tmpcxx}" "${CXX}
0281   else
0282     export CXX=${tmpcxx}
0283   fi
0284   echo " <I> basic CXX option(s): "${tmpcxx}
0285 fi
0286 if [ "${tmpcc}" != "" ]; then
0287   if [ "${CC}" != "" ]; then
0288     export CC=${tmpcc}" "${CC}
0289   else
0290     export CC=${tmpcc}
0291   fi
0292   echo " <I> basic CC option(s): "${tmpcc}
0293 fi
0294 
0295 if [ "${tmpfc}" != "" ]; then
0296   if [ "${FC}" != "" ]; then
0297     export FC=${tmpfc}" "${FC}
0298   else
0299     export FC=${tmpfc}
0300   fi
0301   echo " <I> basic FC option(s): "${tmpfc}
0302 fi
0303 
0304 if [ "${tmpf77}" != "" ]; then
0305   if [ "${F77}" != "" ]; then
0306     export F77=${tmpf77}" "${F77}
0307   else
0308     export F77=${tmpf77}
0309   fi
0310   echo " <I> basic F77 option(s): "${tmpf77}
0311 fi
0312 
0313 
0314 
0315 
0316 if [ "${tmpcxxflg}" != "" ]; then
0317   if [ "${CXXFLAGS}" != "" ]; then
0318     export CXXFLAGS=${tmpcxxflg}" "${CXXFLAGS}
0319   else
0320     export CXXFLAGS=${tmpcxxflg}
0321   fi
0322   echo " <I> basic CXXFLAGS: "${tmpcxxflg}
0323 fi
0324 
0325 
0326 if [ "${tmpcflg}" != "" ]; then
0327   if [ "${CFLAGS}" != "" ]; then
0328     export CFLAGS=${tmpcflg}" "${CFLAGS}
0329   else
0330     export CFLAGS=${tmpcflg}
0331   fi
0332   echo " <I> basic CFLAGS: "${tmpcflg}
0333 fi
0334 
0335 if [ "${tmpfflg}" != "" ]; then
0336   if [ "${FFLAGS}" != "" ]; then
0337     export FFLAGS=${tmpfflg}" "${FFLAGS}
0338   else
0339     export FFLAGS=${tmpfflg}
0340   fi
0341   echo " <I> basic FFLAGS: "${tmpfflg}
0342 fi
0343 
0344 if [ "${tmpfcflg}" != "" ]; then
0345   if [ "${FCFLAGS}" != "" ]; then
0346     export FCFLAGS=${tmpfcflg}" "${FCFLAGS}
0347   else
0348     export FCFLAGS=${tmpfcflg}
0349   fi
0350   echo " <I> basic FCFLAGS: "${tmpfcflg}
0351 fi
0352 
0353 
0354 
0355 
0356 if [ "${tmpldflg}" != "" ]; then
0357   if [ "${LDFLAGS}" != "" ]; then
0358     export LDFLAGS=${tmpldflg}" "${LDFLAGS}
0359   else
0360     export LDFLAGS=${tmpldflg}
0361   fi
0362   echo " <I> basic LDLFAGS: "${tmpldflg}
0363 fi
0364 echo " <I> basic ./configure option(s): "${tmpconfg}
0365 SHCFLAGS=${SHCFLAGS}" "${tmpconfg}
0366 # initialize custom flags
0367 M_CXXFLAGS=""
0368 M_CFLAGS=""
0369 M_FFLAGS=""
0370 M_FCFLAGS=""
0371 M_LDFLAGS=""
0372 
0373 
0374 
0375 # set path to local SHERPA installation
0376 export SHERPADIR=${IDIR}"/SHERPA-MC-"${SHERPAVER}
0377 export SHERPAIDIR=${IDIR}"/SHERPA_"${SHERPAVER}
0378 
0379 if [ "$HEPMC" = "TRUE" ]; then
0380  CTESTH=`echo ${HVER} | cut -c1`
0381  if [ "$HVER" = "CMSSW" ]; then
0382   if [ ! "$CMSSW_BASE" = "" ]; then
0383     newdir=""
0384     cd $CMSSW_BASE &&
0385     newdir=`scramv1 tool info hepmc | grep BASE | cut -f 2 -d "="`
0386     if [ "${newdir}" = "" ]; then
0387       echo " <E> no 'hepmc' tool defined in CMSSW, are you sure that"
0388       echo " <E>  1. the command 'scramv1' is available ?"
0389       echo " <E>  2. the path to your CMSSW is correct ?"
0390       echo " <E>  3. there exists a HEPMC2 package in your CMSSW ?"
0391       exit 0
0392     else
0393       HEPMC2DIR=${newdir}
0394     fi
0395     cd ${HDIR}
0396   else
0397     echo " <E> probably 'cmsenv' was not executed"
0398     exit 0
0399   fi
0400  elif [ "$CTESTH" = "." ] || [ "$CTESTH" = "/" ]; then
0401   cd ${HVER}
0402   HEPMC2DIR=`pwd`
0403   cd ${HDIR}
0404  fi
0405 fi
0406 
0407 if [ "$LHAPDF" = "TRUE" ]; then
0408  CTESTL=`echo ${LVER} | cut -c1`
0409  if [ "$LVER" = "CMSSW" ]; then
0410   if [ ! "$CMSSW_BASE" = "" ]; then
0411     newdir=""
0412     cd $CMSSW_BASE &&
0413     newdir=`scramv1 tool info lhapdf | grep BASE | cut -f 2 -d "="`
0414     if [ "${newdir}" = "" ]; then
0415       echo " <E> no 'lhapdf' tool defined in CMSSW, are you sure that"
0416       echo " <E>  1. the command 'scramv1' is available ?"
0417       echo " <E>  2. the path to your CMSSW is correct ?"
0418       echo " <E>  3. there exists a LHAPDF package in your CMSSW ?"
0419       exit 0
0420     else
0421       LHAPDFDIR=${newdir}
0422     fi
0423     cd ${HDIR}
0424   else
0425     echo " <E> probably 'cmsenv' was not executed"
0426     exit 0
0427   fi
0428  elif [ "$CTESTL" = "." ] || [ "$CTESTL" = "/" ]; then
0429   cd ${LVER}
0430   LHAPDFDIR=`pwd`
0431   cd ${HDIR}
0432  fi
0433 fi
0434 
0435 if [ "$FJ" = "TRUE" ]; then
0436  CTESTH=`echo ${FJVER} | cut -c1`
0437  if [ "$FJVER" = "CMSSW" ]; then
0438   if [ ! "$CMSSW_BASE" = "" ]; then
0439     newdir=""
0440     cd $CMSSW_BASE &&
0441     newdir=`scramv1 tool info fastjet | grep BASE | cut -f 2 -d "="`
0442     if [ "${newdir}" = "" ]; then
0443       echo " <E> no 'fastjet' tool defined in CMSSW, are you sure that"
0444       echo " <E>  1. the command 'scramv1' is available ?"
0445       echo " <E>  2. the path to your CMSSW is correct ?"
0446       echo " <E>  3. there exists a FastJet package in your CMSSW ?"
0447       exit 0
0448     else
0449       FJDIR=${newdir}
0450     fi
0451     cd ${HDIR}
0452   else
0453     echo " <E> probably 'cmsenv' was not executed"
0454     exit 0
0455   fi
0456  elif [ "$CTESTH" = "." ] || [ "$CTESTH" = "/" ]; then
0457   cd ${FJVER}
0458   FJDIR=`pwd`
0459   cd ${HDIR}
0460  fi
0461 fi
0462 
0463 if [ "$QD" = "TRUE" ]; then
0464  CTESTL=`echo ${QDVER} | cut -c1`
0465  if [ "$BHVER" = "CMSSW" ]; then QDVER="CMSSW"; fi
0466  if [ "$QDVER" = "CMSSW" ]; then
0467   if [ ! "$CMSSW_BASE" = "" ]; then
0468     newdir=""
0469     cd $CMSSW_BASE &&
0470     newdir=`scramv1 tool info qd | grep BASE | cut -f 2 -d "="`
0471     if [ "${newdir}" = "" ]; then
0472       echo " <E> no 'qd' tool defined in CMSSW, are you sure that"
0473       echo " <E>  1. the command 'scramv1' is available ?"
0474       echo " <E>  2. the path to your CMSSW is correct ?"
0475       echo " <E>  3. there exists a qd package in your CMSSW ?"
0476       exit 0
0477     else
0478       QDDIR=${newdir}
0479     fi
0480     cd ${HDIR}
0481   else
0482     echo " <E> probably 'cmsenv' was not executed"
0483     exit 0
0484   fi
0485  elif [ "$CTESTL" = "." ] || [ "$CTESTL" = "/" ]; then
0486   cd ${QDVER}
0487   QDDIR=`pwd`
0488   cd ${HDIR}
0489  fi
0490 fi
0491 
0492 if [ "$BH" = "TRUE" ]; then
0493  CTESTL=`echo ${BHVER} | cut -c1`
0494  if [ "$BHVER" = "CMSSW" ]; then
0495   if [ ! "$CMSSW_BASE" = "" ]; then
0496     newdir=""
0497     cd $CMSSW_BASE &&
0498     newdir=`scramv1 tool info blackhat | grep BASE | cut -f 2 -d "="`
0499     if [ "${newdir}" = "" ]; then
0500       echo " <E> no 'blackhat' tool defined in CMSSW, are you sure that"
0501       echo " <E>  1. the command 'scramv1' is available ?"
0502       echo " <E>  2. the path to your CMSSW is correct ?"
0503       echo " <E>  3. there exists a BlackHat package in your CMSSW ?"
0504       exit 0
0505     else
0506       BHDIR=${newdir}
0507     fi
0508     cd ${HDIR}
0509   else
0510     echo " <E> probably 'cmsenv' was not executed"
0511     exit 0
0512   fi
0513  elif [ "$CTESTL" = "." ] || [ "$CTESTL" = "/" ]; then
0514   cd ${BHVER}
0515   BHDIR=`pwd`
0516   cd ${HDIR}
0517  fi
0518 fi
0519 
0520 if [ "$OM" = "TRUE" ]; then
0521  CTESTL=`echo ${OMVER} | cut -c1`
0522  if [ "$OMVER" = "CMSSW" ]; then
0523   if [ ! "$CMSSW_BASE" = "" ]; then
0524     newdir=""
0525     cd $CMSSW_BASE &&
0526     newdir=`scramv1 tool info openmpi | grep BASE | cut -f 2 -d "="`
0527     if [ "${newdir}" = "" ]; then
0528       echo " <E> no 'openmpi' tool defined in CMSSW, are you sure that"
0529       echo " <E>  1. the command 'scramv1' is available ?"
0530       echo " <E>  2. the path to your CMSSW is correct ?"
0531       echo " <E>  3. there exists an openmpi package in your CMSSW ?"
0532       exit 0
0533     else
0534       OMDIR=${newdir}
0535     fi
0536     cd ${HDIR}
0537   else
0538     echo " <E> probably 'cmsenv' was not executed"
0539     exit 0
0540   fi
0541  elif [ "$CTESTL" = "." ] || [ "$CTESTL" = "/" ]; then
0542   cd ${OMVER}
0543   OMDIR=`pwd`
0544   cd ${HDIR}
0545  fi
0546 fi
0547 
0548 
0549 
0550 
0551 # check HepMC2 installation (if required)
0552 if [ "$HEPMC" = "TRUE" ]; then
0553   OPTHEPMC=${OPTHEPMC}" -v "${HVER}" -d "${IDIR}
0554   if [ "${FLGMCORE}" = "TRUE" ]; then OPTHEPMC=${OPTHEPMC}" -Z"; fi
0555   if [ "${FLGXMLFL}" = "TRUE" ]; then OPTHEPMC=${OPTHEPMC}" -X"; fi
0556   if [ "${FLGDEBUG}" = "TRUE" ]; then OPTHEPMC=${OPTHEPMC}" -D"; fi
0557   if [ "${FLGKEEPT}" = "TRUE" ]; then OPTHEPMC=${OPTHEPMC}" -K"; fi
0558   if [ ${LVLCLEAN} -gt 0 ]; then OPTHEPMC=${OPTHEPMC}" -C "${LVLCLEAN}; fi
0559   if [ ! "$HEPMC2DIR" = "" ]; then
0560     echo " -> HepMC2 directory is: "${HEPMC2DIR}
0561     if [ ! -e ${HEPMC2DIR} ]; then
0562       echo " -> ... and does not exist: installing HepMC2..."
0563       echo " -> ... with command "${MSI}/${shhmifile} ${FLOC} ${OPTHEPMC}
0564       ${MSI}/${shhmifile} ${FLOC} ${OPTHEPMC}
0565     else
0566       echo " -> ... and exists: Installation cancelled!"
0567     fi
0568   else
0569     export HEPMC2IDIR=${IDIR}"/HEPMC_"${HVER}
0570     echo " -> no HepMC2 directory specified, trying installation"
0571     echo "     into "${HEPMC2IDIR}
0572     echo "     with command "${MSI}/${shhmifile} ${FLOC} ${OPTHEPMC}
0573     ${MSI}/${shhmifile} ${FLOC} ${OPTHEPMC}
0574     export HEPMC2DIR=${HEPMC2IDIR}
0575   fi
0576   SHCFLAGS=${SHCFLAGS}" --enable-hepmc2="${HEPMC2DIR}
0577 fi
0578 
0579 
0580 # check LHAPDF installation (if required)
0581 if [ "$LHAPDF" = "TRUE" ]; then
0582   OPTLHAPDF=${OPTLHAPDF}" -v "${LVER}" -d "${IDIR}
0583   if [ "${FLGMCORE}" = "TRUE" ]; then OPTLHAPDF=${OPTLHAPDF}" -Z"; fi
0584   if [ "${FLGXMLFL}" = "TRUE" ]; then OPTLHAPDF=${OPTLHAPDF}" -X"; fi
0585   if [ "${FLGDEBUG}" = "TRUE" ]; then OPTLHAPDF=${OPTLHAPDF}" -D"; fi
0586   if [ "${FLGKEEPT}" = "TRUE" ]; then OPTLHAPDF=${OPTLHAPDF}" -K"; fi
0587   if [ ${LVLCLEAN} -gt 0 ]; then OPTLHAPDF=${OPTLHAPDF}" -C "${LVLCLEAN}; fi
0588   for pdfs in $PDFSET; do OPTLHAPDF=${OPTLHAPDF}" -P "${pdfs}; done
0589   if [ ! "$LHAPDFDIR" = "" ]; then
0590     echo " -> LHAPDF directory is: "${LHAPDFDIR}
0591     if [ ! -e ${LHAPDFDIR} ]; then
0592       echo " -> ... and does not exist: installing LHAPDF..."
0593       echo " -> ... with command "${MSI}/${shlhifile} ${FLOC} ${OPTLHAPDF}
0594       ${MSI}/${shlhifile} ${FLOC} ${OPTLHAPDF}
0595     else
0596       echo " -> ... and exists: Installation cancelled!"
0597     fi
0598   else
0599     export LHAPDFIDIR=${IDIR}"/LHAPDF_"${LVER}
0600     echo " -> no LHAPDF directory specified, trying installation"
0601     echo "     into "${LHAPDFIDIR}
0602     echo "     with command "${MSI}/${shlhifile} ${FLOC} ${OPTLHAPDF}
0603     ${MSI}/${shlhifile} ${FLOC} ${OPTLHAPDF}
0604     export LHAPDFDIR=${LHAPDFIDIR}
0605   fi
0606   SHCFLAGS=${SHCFLAGS}" --enable-lhapdf="${LHAPDFDIR}
0607 fi
0608 
0609 
0610 # check FastJet installation (if required)
0611 if [ "$FJ" = "TRUE" ]; then
0612   OPTFJ=${OPTFJ}" -v "${FJVER}" -d "${IDIR}
0613   if [ "${FLGMCORE}" = "TRUE" ]; then OPTFJ=${OPTFJ}" -Z"; fi
0614   if [ "${FLGXMLFL}" = "TRUE" ]; then OPTFJ=${OPTFJ}" -X"; fi
0615   if [ "${FLGDEBUG}" = "TRUE" ]; then OPTFJ=${OPTFJ}" -D"; fi
0616   if [ "${FLGKEEPT}" = "TRUE" ]; then OPTFJ=${OPTFJ}" -K"; fi
0617   if [ ${LVLCLEAN} -gt 0 ]; then OPTFJ=${OPTFJ}" -C "${LVLCLEAN}; fi
0618   if [ ! "$FJDIR" = "" ]; then
0619     echo " -> FastJet directory is: "${FJDIR}
0620     if [ ! -e ${FJDIR} ]; then
0621       echo " -> ... and does not exist: installing FastJet..."
0622       echo " -> ... with command "${MSI}/${shfjifile} ${FLOC} ${OPTFJ}
0623       ${MSI}/${shfjifile} ${FLOC} ${OPTFJ}
0624     else
0625       echo " -> ... and exists: Installation cancelled!"
0626     fi
0627   else
0628     export FJIDIR=${IDIR}"/FJ_"${FJVER}
0629     echo " -> no FastJet directory specified, trying installation"
0630     echo "     into "${FJIDIR}
0631     echo "     with command "${MSI}/${shfjifile} ${FLOC} ${OPTFJ}
0632     ${MSI}/${shfjifile} ${FLOC} ${OPTFJ}
0633     export FJDIR=${FJIDIR}
0634   fi
0635   SHCFLAGS=${SHCFLAGS}" --enable-fastjet="${FJDIR}
0636 fi
0637 
0638 
0639 # check qd installation (if required)
0640 if [ "$QD" = "TRUE" ]; then
0641   OPTQD=${OPTQD}" -v "${QDVER}" -d "${IDIR}
0642   if [ "${FLGMCORE}" = "TRUE" ]; then OPTQD=${OPTQD}" -Z"; fi
0643   if [ "${FLGXMLFL}" = "TRUE" ]; then OPTQD=${OPTQD}" -X"; fi
0644   if [ "${FLGDEBUG}" = "TRUE" ]; then OPTQD=${OPTQD}" -D"; fi
0645   if [ "${FLGKEEPT}" = "TRUE" ]; then OPTQD=${OPTQD}" -K"; fi
0646   if [ ${LVLCLEAN} -gt 0 ]; then OPTQD=${OPTQD}" -C "${LVLCLEAN}; fi
0647   if [ ! "$QDDIR" = "" ]; then
0648     echo " -> qd directory is: "${QDDIR}
0649     if [ ! -e ${QDDIR} ]; then
0650       echo " -> ... and does not exist: installing qd..."
0651       echo " -> ... with command "${MSI}/${shqdifile} ${FLOC} ${OPTQD}
0652       ${MSI}/${shqdifile} ${FLOC} ${OPTQD}
0653     else
0654       echo " -> ... and exists: Installation cancelled!"
0655     fi
0656   else
0657     export QDIDIR=${IDIR}"/QD_"${QDVER}
0658     echo " -> no qd directory specified, trying installation"
0659     echo "     into "${QDIDIR}
0660     echo "     with command "${MSI}/${shqdifile} ${FLOC} ${OPTQD}
0661     ${MSI}/${shqdifile} ${FLOC} ${OPTQD}
0662     export QDDIR=${QDIDIR}
0663   fi
0664   SHCFLAGS=${SHCFLAGS}
0665 # update compiler & linker flags
0666  M_CXXFLAGS=${M_CXXFLAGS}" -I"${QDDIR}"/include"
0667  M_CFLAGS=${M_CFLAGS}" -I"${QDDIR}"/include"
0668  M_FFLAGS=${M_FFLAGS}" -I"${QDDIR}"/include"
0669  M_FCFLAGS=${M_FCFLAGS}" -I"${QDDIR}"/include"
0670  M_LDFLAGS=${M_LDFLAGS}" -L"${QDDIR}"/lib"
0671 fi
0672 
0673 
0674 # check BlackHat installation (if required)
0675 if [ "$BH" = "TRUE" ]; then
0676 if [ ! "$QDDIR" = "" ] && [ -e ${QDDIR} ]; then
0677   OPTBH=${OPTBH}" -v "${BHVER}" -d "${IDIR}" -Q "${QDDIR}
0678   if [ "${FLGMCORE}" = "TRUE" ]; then OPTBH=${OPTBH}" -Z"; fi
0679   if [ "${FLGXMLFL}" = "TRUE" ]; then OPTBH=${OPTBH}" -X"; fi
0680   if [ "${FLGDEBUG}" = "TRUE" ]; then OPTBH=${OPTBH}" -D"; fi
0681   if [ "${FLGKEEPT}" = "TRUE" ]; then OPTBH=${OPTBH}" -K"; fi
0682   if [ "${PATCHES}" = "TRUE" ]; then OPTBH=${OPTBH}" -p ${PDIR}"; fi  
0683   
0684   if [ ${LVLCLEAN} -gt 0 ]; then OPTBH=${OPTBH}" -C "${LVLCLEAN}; fi
0685   if [ ! "$BHDIR" = "" ]; then
0686     echo " -> BlackHat directory is: "${BHDIR}
0687     if [ ! -e ${BHDIR} ]; then
0688       echo " -> ... and does not exist: installing BlackHat..."
0689       echo " -> ... with command "${MSI}/${shbhifile} ${FLOC} ${OPTBH}
0690       ${MSI}/${shbhifile} ${FLOC} ${OPTBH}
0691     else
0692       echo " -> ... and exists: Installation cancelled!"
0693     fi
0694   else
0695     export BHIDIR=${IDIR}"/BH_"${BHVER}
0696     echo " -> no BlackHat directory specified, trying installation"
0697     echo "     into "${BHIDIR}
0698     echo "     with command "${MSI}/${shbhifile} ${FLOC} ${OPTBH}
0699     ${MSI}/${shbhifile} ${FLOC} ${OPTBH}
0700     export BHDIR=${BHIDIR}
0701   fi
0702   SHCFLAGS=${SHCFLAGS}" --enable-blackhat="${BHDIR}
0703 # update compiler & linker flags
0704 #  CXXFLAGS=${CXXFLAGS}" -I"${BHDIR}"/include"
0705 #  M_LDFLAGS=${M_LDFLAGS}" -L"${BHDIR}"/lib/blackhat"
0706 else
0707   echo " <E> qd directory is empty, cannot install BlackHat"
0708   exit 0
0709 fi
0710 fi
0711 
0712 
0713 # check openmpi installation (if required)
0714 if [ "$OM" = "TRUE" ]; then
0715   OPTOM=${OPTOM}" -v "${OMVER}" -d "${IDIR}
0716   if [ "${FLGMCORE}" = "TRUE" ]; then OPTOM=${OPTOM}" -Z"; fi
0717   if [ "${FLGXMLFL}" = "TRUE" ]; then OPTOM=${OPTOM}" -X"; fi
0718   if [ "${FLGDEBUG}" = "TRUE" ]; then OPTOM=${OPTOM}" -D"; fi
0719   if [ "${FLGKEEPT}" = "TRUE" ]; then OPTOM=${OPTOM}" -K"; fi
0720   if [ ${LVLCLEAN} -gt 0 ]; then OPTOM=${OPTOM}" -C "${LVLCLEAN}; fi
0721   if [ ! "$OMDIR" = "" ]; then
0722     echo " -> openmpi directory is: "${OMDIR}
0723     if [ ! -e ${OMDIR} ]; then
0724       echo " -> ... and does not exist: installing openmpi..."
0725       echo " -> ... with command "${MSI}/${shomifile} ${FLOC} ${OPTOM}
0726       ${MSI}/${shomifile} ${FLOC} ${OPTOM}
0727     else
0728       echo " -> ... and exists: Installation cancelled!"
0729     fi
0730   else
0731     export OMIDIR=${IDIR}"/OM_"${OMVER}
0732     echo " -> no openmpi directory specified, trying installation"
0733     echo "     into "${OMIDIR}
0734     echo "     with command "${MSI}/${shomifile} ${FLOC} ${OPTOM}
0735     ${MSI}/${shomifile} ${FLOC} ${OPTOM}
0736     export OMDIR=${OMIDIR}
0737   fi
0738 # update compiler & linker flags
0739   export MPI_BINDIR=${OMDIR}/bin
0740   export MPI_LIBDIR=${OMDIR}/lib
0741   export MPI_INCLUDE=${OMDIR}/include
0742   M_CXXFLAGS="-I"${MPI_INCLUDE}" "${M_CXXFLAGS}
0743   M_CFLAGS="-I"${MPI_INCLUDE}" "${M_CFLAGS}
0744   M_FFLAGS="-I"${MPI_INCLUDE}" "${M_FFLAGS}
0745   M_FCFLAGS="-I"${MPI_INCLUDE}" "${M_FCFLAGS}
0746   M_LDFLAGS="-L"${MPI_LIBDIR}" -lmpi -lmpi_cxx "${M_LDFLAGS}
0747   export LD_LIBRARY_PATH=${MPI_LIBDIR}:$LD_LIBRARY_PATH
0748 fi
0749 
0750 
0751 
0752 
0753 # download and extract SHERPA
0754 cd ${IDIR}
0755 if [ ! -d ${SHERPADIR} ]; then
0756   if [ `echo ${SHERPAWEBLOCATION} | grep -c "http:"` -gt 0 ]; then
0757     echo " -> downloading SHERPA "${SHERPAVER}" from "${SHERPAWEBLOCATION}/${SHERPAFILE}
0758     wget ${SHERPAWEBLOCATION}/${SHERPAFILE}
0759   elif [ `echo ${SHERPAWEBLOCATION} | grep -c "srm:"` -gt 0 ]; then
0760     echo " -> srm-copying SHERPA "${SHERPAVER}" from "${SHERPAWEBLOCATION}/${SHERPAFILE}
0761     srmcp ${SHERPAWEBLOCATION}/${SHERPAFILE} file:////${SHERPAFILE}
0762   else
0763     echo " -> copying SHERPA "${SHERPAVER}" from "${SHERPAWEBLOCATION}/${SHERPAFILE}
0764     cp ${SHERPAWEBLOCATION}/${SHERPAFILE} ./
0765   fi
0766   tar -xzf ${SHERPAFILE}
0767   if [ ! "$FLGKEEPT" = "TRUE" ]; then
0768     rm ${SHERPAFILE}
0769   fi
0770 else
0771   echo " <W> path exists => using already installed SHERPA"
0772   echo " <W>  -> this might cause problems with some fixes and/or patches !!!"
0773 fi
0774 cd ${HDIR}
0775 
0776 
0777 # add compiler & linker flags
0778 MOPTS=""
0779 POPTS=""
0780 if [ "$FLGMCORE" = "TRUE" ]; then
0781     nprc=`cat /proc/cpuinfo | grep  -c processor`
0782     if [ $nprc -gt 1 ]; then
0783       echo " <I> multiple CPU cores detected: "$nprc
0784       POPTS=" -j"$nprc" "
0785     fi
0786 fi
0787 
0788 
0789 
0790 # apply the necessary patches
0791 cd ${SHERPADIR}
0792 if [ "$PATCHES" = "TRUE" ]; then
0793   echo " <I> applying patches to SHERPA..."
0794   if [ -e ${PDIR}/${shpatchfile} ]; then
0795     pfilelist=`tar -xzvf ${PDIR}/${shpatchfile}`
0796     for pfile in `echo ${pfilelist}`; do
0797       echo "  -> applying patch: "${pfile}
0798       patch -p1 < ${pfile}
0799       echo " <I> (patches) removing file "${pfile}
0800       rm ${pfile}
0801     done
0802   else
0803     echo " <W> file "${PDIR}/${shpatchfile}" does not exist,"
0804     echo " <W>  cannot apply Sherpa patches"
0805   fi
0806 fi
0807 cd ${HDIR}
0808 
0809 
0810 
0811 # compile and install SHERPA
0812 cd ${SHERPADIR}
0813 export SHERPA_INCLUDE_PATH=${SHERPAIDIR}"/include/SHERPA-MC"
0814 export SHERPA_SHARE_PATH=${SHERPAIDIR}"/share/SHERPA-MC"
0815 export SHERPA_INCLUDE_PATH=${SHERPAIDIR}"/lib/SHERPA-MC"
0816 if [ -e ${SHERPADIR}/bin/Sherpa ]; then
0817   echo " <E> installed SHERPA exists, clean up!"
0818   exit 0
0819 fi
0820 
0821   if [ "$PATCHES" = "TRUE" ]; then
0822     echo " <I> doing autoreconf"
0823     autoreconf -i --force -v
0824   fi
0825 #
0826   
0827   if [ "${M_CXXFLAGS}" != "" ]; then
0828     if [ "${CXXFLAGS}" != "" ]; then
0829       export CXXFLAGS=${M_CXXFLAGS}" "${CXXFLAGS}
0830     else
0831       export CXXFLAGS=${M_CXXFLAGS}
0832     fi
0833     echo " <I> CXXFLAGS variable content: "${CXXFLAGS}
0834   fi
0835 
0836 
0837  if [ "${M_CFLAGS}" != "" ]; then
0838     if [ "${CFLAGS}" != "" ]; then
0839       export CFLAGS=${M_CFLAGS}" "${CFLAGS}
0840     else
0841       export CFLAGS=${M_CFLAGS}
0842     fi
0843     echo " <I> CFLAGS variable content: "${CFLAGS}
0844   fi
0845 
0846 
0847  if [ "${M_FFLAGS}" != "" ]; then
0848     if [ "${FFLAGS}" != "" ]; then
0849       export FFLAGS=${M_FFLAGS}" "${FFLAGS}
0850     else
0851       export FFLAGS=${M_FFLAGS}
0852     fi
0853     echo " <I> FFLAGS variable content: "${FFLAGS}
0854   fi
0855 
0856 
0857  if [ "${M_FCFLAGS}" != "" ]; then
0858     if [ "${FCFLAGS}" != "" ]; then
0859       export FCFLAGS=${M_FCFLAGS}" "${FCFLAGS}
0860     else
0861       export FCFLAGS=${M_FCFLAGS}
0862     fi
0863     echo " <I> FCFLAGS variable content: "${FCFLAGS}
0864   fi
0865 
0866   if [ "${M_LDFLAGS}" != "" ]; then
0867     if [ "${LDFLAGS}" != "" ]; then
0868       export LDFLAGS=${M_LDFLAGS}" "${LDFLAGS}
0869     else
0870       export LDFLAGS=${M_LDFLAGS}
0871     fi
0872     echo " <I> LDFLAGS variable content: "${LDFLAGS}
0873   fi
0874 echo "CXX: "${CXXFLAGS}
0875 echo "MCXX: "${M_CXXFLAGS}
0876 echo "LDF: "${LDFLAGS}
0877 echo "MLDF: "${M_LDFLAGS}
0878 
0879 
0880   echo " <I> configuring with prefix: "${SHERPAIDIR} && \
0881   echo " <I> ... and options: "${SHCFLAGS} && \
0882 #  ./configure --prefix=${SHERPAIDIR} ${SHCFLAGS} > ../sherpa_install.log 2>&1
0883   ./configure --prefix=${SHERPAIDIR} ${SHCFLAGS}  && \
0884 #
0885   echo " <I> make Sherpa with options: "${POPTS} && \
0886 #  make ${POPTS} >> ../sherpa_install.log 2>&1
0887   make ${POPTS} && \
0888 #
0889   echo " <I> make install Sherpa" && \
0890 #  make install >> ../sherpa_install.log 2>&1
0891   make install
0892   cd ${HDIR}
0893   if [ "$FLGKEEPT" = "TRUE" ]; then
0894     echo " <I> keeping source code..."
0895   else
0896     rm -rf ${SHERPADIR}
0897   fi
0898 export SHERPADIR=${SHERPAIDIR}
0899 cd ${HDIR}
0900 
0901 
0902 ##FIXME???
0903 # get LHAPDFs into SHERPA... (now with symbolic links)
0904 if [ "$LHAPDF" = "TRUE" ]; then
0905   pdfdir=`find ${LHAPDFDIR} -type d -name PDFsets`
0906 #  if [ ! -e ${pdfdir} ]; then
0907 #    echo " <E> PDFsets of LHAPDF not found, stopping..."
0908 #    exit 1
0909 #  fi
0910 #  if [ "${LINKPDF}" = "TRUE" ] && [ ! "${pdfdir}" = "" ]; then
0911 #    ln -s ${pdfdir} ${SHERPADIR}/share/SHERPA-MC/PDFsets
0912 #  else
0913 #    cp -r ${pdfdir} ${SHERPADIR}/share/SHERPA-MC/
0914 #  fi
0915 fi
0916 #cd ${HDIR}
0917 
0918 
0919 # create XML file for SCRAM
0920 if [ "${FLGXMLFL}" = "TRUE" ]; then
0921 #  xmlfile=sherpa.xml
0922   xmlfile="sherpa_"${SHERPAVER}".xml"
0923   echo " <I> creating Sherpa tool definition XML file"
0924   if [ -e ${xmlfile} ]; then rm ${xmlfile}; fi; touch ${xmlfile}
0925   echo "  <tool name=\"Sherpa\" version=\""${SHERPAVER}"\">" >> ${xmlfile}
0926   tmppath=`find ${SHERPADIR} -type f -name libSherpaMain.so\*`
0927   tmpcnt=`echo ${tmppath} | grep -o "/" | grep -c "/"`
0928   tmppath=`echo ${tmppath} | cut -f 1-${tmpcnt} -d "/"`
0929   for LIB in `cd ${tmppath}; ls *.so | cut -f 1 -d "." | sed -e 's/lib//'; cd ${HDIR}`; do
0930     echo "    <lib name=\""${LIB}"\"/>" >> ${xmlfile}
0931   done
0932   echo "    <client>" >> ${xmlfile}
0933   echo "      <Environment name=\"SHERPA_BASE\" value=\""${SHERPADIR}"\"/>" >> ${xmlfile}
0934   echo "      <Environment name=\"BINDIR\" default=\"\$SHERPA_BASE/bin\"/>" >> ${xmlfile}
0935   echo "      <Environment name=\"LIBDIR\" default=\"\$SHERPA_BASE/lib/SHERPA-MC\"/>" >> ${xmlfile}
0936   echo "      <Environment name=\"INCLUDE\" default=\"\$SHERPA_BASE/include/SHERPA-MC\"/>" >> ${xmlfile}
0937   echo "    </client>" >> ${xmlfile}
0938   echo "    <runtime name=\"LD_LIBRARY_PATH\" value=\"\$SHERPA_BASE/lib/SHERPA-MC\" type=\"path\"/>" >> ${xmlfile}
0939   echo "    <runtime name=\"CMSSW_FWLITE_INCLUDE_PATH\" value=\"\$SHERPA_BASE/include\" type=\"path\"/>" >> ${xmlfile}
0940   echo "    <runtime name=\"SHERPA_SHARE_PATH\" value=\"\$SHERPA_BASE/share/SHERPA-MC\" type=\"path\"/>" >> ${xmlfile}
0941   echo "    <runtime name=\"SHERPA_INCLUDE_PATH\" value=\"\$SHERPA_BASE/include/SHERPA-MC\" type=\"path\"/>" >> ${xmlfile}
0942   echo "    <runtime name=\"SHERPA_LIBRARY_PATH\" value=\"\$SHERPA_BASE/lib/SHERPA-MC\" type=\"path\"/>" >> ${xmlfile}
0943   echo "    <use name=\"HepMC\"/>" >> ${xmlfile}
0944   echo "    <use name=\"lhapdf\"/>" >> ${xmlfile}
0945   echo "  </tool>" >> ${xmlfile}
0946   if [ ! "$PWD" = "${HDIR}" ]; then
0947     mv ${xmlfile} ${HDIR}/
0948   fi
0949 
0950   if [ ! "$CMSSW_BASE" = "" ]; then
0951     cd $CMSSW_BASE
0952     tmpsha=`scramv1 tool info sherpa | grep "SHERPA_BASE" | cut -f2 -d"="`
0953     tmpxml=`find $CMSSW_BASE/config/ -type f -name sherpa.xml -printf %h`
0954     echo " <I>"
0955     echo " <I> SHERPA version currently being used: "${tmpsha}
0956     echo " <I> ...defined in "${tmpxml}
0957     cd ${tmpxml}; tmpxml=$PWD; cd ${HDIR}
0958     echo " <I>"
0959     echo " <I> If you want to override this version with the freshly produced "${xmlfile}","
0960     echo " <I> ...please type (something like) the following commands:"
0961     echo " <I>"
0962     echo "       cd $CMSSW_BASE"
0963     echo "       scramv1 tool remove sherpa"
0964     echo "       cp ${HDIR}/${xmlfile} ${tmpxml}/"
0965     echo "       scramv1 setup sherpa"
0966     echo "       cd -"
0967     echo " <I>"
0968   fi
0969 
0970 fi
0971 cd ${HDIR}
0972 
0973 
0974 ### write these override commands into a script
0975 if [ "${FLGXMLFL}" = "TRUE" ]; then
0976   overrscr="Z_OVERRIDE.sh"
0977   shelltype="#!/bin/bash"
0978   if [ -e ${overrscr} ]; then
0979     rm ${overrscr}
0980   fi
0981   touch ${overrscr}
0982   echo ${shelltype} >> ${overrscr}
0983   echo "cd \$CMSSW_BASE" >> ${overrscr}
0984   lxmlfile="lhapdf_"${LVER}".xml"
0985   if [ "$LHAPDF" = "TRUE" ] && [ -e ${HDIR}/${lxmlfile} ]; then
0986     replace_tool lhapdf ${HDIR} ${lxmlfile} ${LHAPDFDIR} ${overrscr}
0987   fi
0988   hxmlfile="hepmc_"${HVER}".xml"
0989   if [ "$HEPMC" = "TRUE" ] && [ -e ${HDIR}/${hxmlfile} ]; then
0990     replace_tool hepmc ${HDIR} ${hxmlfile} ${HEPMC2DIR} ${overrscr}
0991   fi
0992   qxmlfile="qd_"${QDVER}".xml"
0993   if [ "$QD" = "TRUE" ] && [ -e ${HDIR}/${qxmlfile} ]; then
0994     replace_tool qd ${HDIR} ${qxmlfile} ${QDDIR} ${overrscr}
0995   fi
0996   bxmlfile="blackhat_"${BHVER}".xml"
0997   if [ "$BH" = "TRUE" ] && [ -e ${HDIR}/${bxmlfile} ]; then
0998     replace_tool blackhat ${HDIR} ${bxmlfile} ${BHDIR} ${overrscr}
0999   fi
1000   sxmlfile=${xmlfile}
1001   echo "scramv1 tool remove sherpa" >> ${overrscr}
1002   echo ${setvarcmd}"tmpfil=sherpa.xml" >> ${overrscr}
1003   echo ${setvarcmd}"tmpxml=\`find \$CMSSW_BASE/config/ -type f -name \${tmpfil}\`" >> ${overrscr}
1004   echo "if [ \"\${tmpxml}\" = \"\" ]; then" >> ${overrscr}
1005   echo "  ${setvarcmd}tmpxml=\`find \$CMSSW_BASE/config/ -type d -name selected\`" >> ${overrscr}
1006   echo "  ${setvarcmd}tmpxml=\${tmpxml}/\${tmpfil}" >> ${overrscr}
1007   echo "fi" >> ${overrscr}
1008   echo "cp ${HDIR}/${sxmlfile} \${tmpxml}" >> ${overrscr}
1009   echo "scramv1 setup sherpa" >> ${overrscr}
1010   echo ${setvarcmd}"newlibpath=\`find ${SHERPADIR}/ -name \\*.so -printf %h\\\\\n | head -1\`" >> ${overrscr}
1011   echo ${exportcmd}"LD_LIBRARY_PATH"${exporteqs}"\${newlibpath}:\$LD_LIBRARY_PATH" >> ${overrscr}
1012   echo "cd -" >> ${overrscr}
1013   chmod u+x ${overrscr}
1014 
1015   echo " <I> ===> you can find these override commands collected in the script "${overrscr}
1016   echo " <I> ===> just type 'source ./"${overrscr}"'"
1017 fi
1018 
1019 
1020 # summarize installation
1021 echo " <I> Summary of the SHERPA installation:"
1022 if [ "$HEPMC" = "TRUE" ]; then
1023   echo ""
1024   echo " <I> HepMC2 version "${HEPMC2VER}" installed in "${HEPMC2DIR}
1025   echo ""
1026 fi
1027 if [ "$LHAPDF" = "TRUE" ]; then
1028   echo ""
1029   echo " <I> LHAPDF version "${LHAPDFVER}" installed in "${LHAPDFDIR}
1030   echo " <I>  -> before using SHERPA please define"
1031   echo " <I>  -> export LHAPATH="${pdfdir}
1032   echo ""
1033 fi
1034 if [ "$FJ" = "TRUE" ]; then
1035   echo ""
1036   echo " <I> FastJet version "${FJVER}" installed in "${FJDIR}
1037   echo ""
1038 fi
1039 if [ "$QD" = "TRUE" ]; then
1040   echo ""
1041   echo " <I> qd version "${QDVER}" installed in "${QDDIR}
1042   echo ""
1043 fi
1044 if [ "$BH" = "TRUE" ]; then
1045   echo ""
1046   echo " <I> BlackHat version "${BHVER}" installed in "${BHDIR}
1047   echo ""
1048 fi
1049 if [ "$MPI" = "TRUE" ]; then
1050         echo " <I> MPI installed in "${MPIDIR}
1051         echo " <I> Please add "${MPI_LIBDIR}" to the LD_LIBRARY_PATH variable:"
1052         echo " <I> export LD_LIBRARY_PATH=${MPI_LIBDIR}:\$LD_LIBRARY_PATH"
1053         echo " <I> Please add "${MPI_BINDIR}" to the PATH variable:"
1054         echo " <I> export PATH=${MPI_BINDIR}:\$PATH"
1055 fi
1056 echo " <I> SHERPA version "${SHERPAVER}" installed in "${SHERPADIR}
1057 echo " <I>     export SHERPA_INCLUDE_PATH=${SHERPADIR}/include/SHERPA-MC/"
1058 echo " <I>     export SHERPA_SHARE_PATH=${SHERPADIR}/share/SHERPA-MC/"
1059 
1060 
1061 
1062