#!/bin/tcsh
#######################################################################
#  run_athena.csh ==> Set up runtime version of Athena
#   This assumes that there is a requirements file in ~/cmthome
#
# Parameters:
#  $1 = Athena version (assumes directory /data08/diehl/athena/AthenaOffline-$1 exists)
#       12.0.2 assumed by default
#  $2 = Athena options file (optional)
#  $3 = "run" directory (if different than "run" - optional)
#
#  If $2 is supplied then Athena is run, otherwise only setup is done
#  For interactive work, source this file.
#  For batch work, supply a options file and optional run directory
#######################################################################
#  Environmental variables for Athena
#######################################################################
setenv POOL_CATALOG /data08/diehl/data/PoolFileCatalog.xml

#######################################################################
#  Set up CMT for a specific Athena version
#######################################################################
if ( $1 == "-h" || $1 == "--help" ) then
  echo ""
  echo "  run_athena.csh ==> Set up runtime version of Athena"
  echo "  Assumptions:"
  echo '     1. file "requirements" exists in ~/cmthome'
  echo "     2. directory /data08/diehl/athena/AthenaOffline-<AthenaVersion> exists"
  echo ""
  echo " Parameters:"
  echo '  $1 = Athena version (default = 12.0.2)'
  echo '  $2 = Athena options file (optional)'
  echo '  $3 = run directory (default = "run")'
  echo ""
  echo " If options files is supplied Athena is run, otherwise only do setup"
  echo " For interactive work, source this file"
  echo " For batch work, supply a options file and optional run directory"
  echo ""
  exit
else if ( $1 != "" ) then
  set version=$1
else
  set version=12.0.2
endif
cd /data08/diehl/athena/cmthome
echo ">>>>>>>>>>>>> source setup.csh -tag=$version"
source setup.csh -tag=$version
#######################################################################
#  Set up Athena run-time
#######################################################################
echo ">>>>>>>>>>>>> cd /data08/diehl/athena/AtlasOffline-$version"
cd /data08/diehl/athena/AtlasOffline-$version
echo ">>>>>>>>>>>>> Do Atlas runtime setup"
source /afs/atlas.umich.edu/atlas/software/kits/AtlasOffline/$version/AtlasOfflineRunTime/cmt/setup.csh
#######################################################################
#  Find "run" directory
#######################################################################
if ( $3 != "" ) then
  set run_dir=`find . -name $3`
else
  set run_dir=`find . -name run`
endif
echo ">>>>>>>>>>>>> cd $run_dir"
cd $run_dir
#######################################################################
#    Now run ATHENA!!!
#######################################################################
if ( $2 != "" ) then
 echo ">>>>>>>>>>>>> Now run ATHENA"
  athena $2
else
  echo ">>>>>>>>>>>>> Ready to run ATHENA"
endif
