#! /bin/sh
 
#    Feb 15/05 - F.Majaess (Revised for LL setup in Victoria)
#    Dec 03/03 - F.Majaess
 
#id  rmllfls - Handles the removal of LL temporary files.
 
#    AUTHOR  - F.Majaess
 
#hd  PURPOSE - "rmllfls" script handles the removal of LoadLeveller
#hd            temporary files created by "qsub" as part of the 
#hd            submission process. The list of files is extracted
#hd            from "LOADL_STEP_COMMAND" and "CCCMA_LL_RMFILES"
#hd            (if defined).
 
#ex  EXAMPLE: 
#ex
#ex    rmllfls 
#ex
#ex  The above will result in removing the list of files supplied
#ex  in "LOADL_STEP_COMMAND" and "CCCMA_LL_RMFILES".
#ex  

# Check and possibly adjust for parameters specified on the 
# script call ...

if [ $# -gt 0 ] ; then
  for arg in $@
  do
    case $arg in
      -*) set $arg            ;;
     *=*) eval $arg           ;;
     *  ) skip="$skip $arg" ;;
    esac
  done
fi

#   ****   Task of the script...   ****
 
# if [ "$OS" = 'AIX' ] ; then
if [ \( \( "$SITE_ID" = 'Dorval' -o "$SITE_ID" = 'Victoria' \)  -a "$OS" = 'AIX' \) -o "$SITE_ID" = 'DrvlSC' ] ; then

 # Ensure the removal of the associated LoadLeveler's "executable"

 if [ -n "$LOADL_STEP_COMMAND" -a -f "$LOADL_STEP_COMMAND" ] ; then
  (\rm -f $LOADL_STEP_COMMAND || : )
 fi
 
 # Remove the files if supplied in CCCMA_LL_RMFILES 

 if [ -n "$CCCMA_LL_RMFILES" ] ; then
  for SCfl in $CCCMA_LL_RMFILES
  do
#  SCfl=`echo $SCfl | sed -e "s/'//g"`
   if [ -f $SCfl ] ; then
    (\rm -f $SCfl || : )
   fi
  done
 fi
fi
