From 124fe280d6e1e8d33b768bae0ebf95dd74890a04 Mon Sep 17 00:00:00 2001 From: buncic Date: Fri, 23 Feb 2001 17:33:40 +0000 Subject: [PATCH] Added alifs wrapper for CASTOR and alirun modified accordingly. --- share/alifs | 166 +++++++++++++++++++++++++++++++++++++++++++++++ share/alirun | 179 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 289 insertions(+), 56 deletions(-) create mode 100755 share/alifs diff --git a/share/alifs b/share/alifs new file mode 100755 index 00000000000..700623448ac --- /dev/null +++ b/share/alifs @@ -0,0 +1,166 @@ +#!/bin/sh +############################################################################# +# alifs - a front-end shell for CASTOR and SHIFT +############################################################################# +# +# modification history +# $Log$ +# +# SYNOPSIS +# alifs +# +# DESCRIPTION +# This is an interface script to underlying mass storage manager. At present it supports CASTOR on RH6.1 and offers some basic Unix like commands: +# +# o) list directory +# alifs ls [-cdilRTu] [--class] [--comment] path +# +# o) move (rename) file or directory +# alifs mv oldname newname... +# +# o) remove file or directory +# alifs rm [-f] [-i] [-r] dirname... +# +# o) create directory +# alifs mkdir [-m absolute_mode] [-p] dirname... +# +# CASTOR file system is accessible via RFIO (root must be configured configured with --enable-rfio switch and linked with appropriate libshift.a library). It provides experiment topl level directory (/castor/cern.ch/alice) and user directories following the AFS naming scheeme (like /castor/cern.ch/user/b/buncic). +#For more info on CASTOR commands, see related man pages (nsls, nsrename, nsrm, nsmkdir). +# +# +# AUTHOR: +# Predrag Buncic, e-mail: Predrag.Buncic@cern.ch +# +# CREATION DATE: +# 15-Feb-2001 +#C< +########################################################################### +Configure() +{ + if [ "$CASTOR_USER_POOL" = "" ] + then + CASTOR_USER_POOL=$STAGE_POOL + fi + + if [ "$CASTOR_BIN" = "" ] + then + case `uname` in + Linux) + CASTOR_BIN=/afs/cern.ch/asis/packages/CASTOR/castor-1.3.1.1/i386_redhat61/usr.local/bin + EXEC_SHELL=/bin/sh + ;; + *) + ;; + esac + fi + + if [ ! -d $CASTOR_BIN ] + then + printf "CASTOR is not supported on this platform.\n" + exit 255 + fi + + if [ "$EXEC_SHELL" = "" ] + then + EXEC_SHELL=bin/sh + for shell in bash zsh ksh + do + for dir in /bin /usr/bin /usr/local/bin + do + if [ -x $dir/$shell ] + then + EXEC_SHELL=$dir/$shell + break 2 + fi + done + done + export EXEC_SHELL + exec $EXEC_SHELL -norc -noprofile $0 $* + fi +} +########################################################################### +ALIFS::Usage() +{ + printf "Usage: alifs \n" + exit +} +########################################################################### +ALIFS::Makeman() +########################################################################### +{ + mandir=../man/man4 + ./mangen -n tool $0 + if [ $? -eq 0 ] + then + [ ! -d $mandir ] && mkdir -p $mandir + mv `basename $0`.? $mandir + exit + fi +} +########################################################################### +ALIFS::ls() +{ + $CASTOR_BIN/nsls $* +} +########################################################################### +ALIFS::mkdir() +{ + $CASTOR_BIN/nsmkdir $* +} +########################################################################### +ALIFS::mv() +{ + $CASTOR_BIN/nsrename $* +} +########################################################################### +ALIFS::rm() +{ + $CASTOR_BIN/nsrm $* +} +########################################################################### +Configure $* +########################################################################### +ALIFS() +{ + cmd=$1; shift 1 + + case `type -t ALIFS::$cmd` in + function) + ALIFS::$cmd $* + ;; + *) + ALIFS::Usage; + ;; + esac + + exit +} +########################################################################### +########################################################################### + +for param in $* +do + case $param in + -trace) + shift 1 + set -vx + ;; + -echo) + shift 1 + ECHO="echo " + ;; + -makeman) + shift 1 + ALIFS::Makeman + ;; + -p) + shift 1 + POOL=$1; shift 1 + ;; + *) + ALIFS $* + ;; + esac +done + + diff --git a/share/alirun b/share/alirun index 89297ebcb8e..fd5dbdd626f 100755 --- a/share/alirun +++ b/share/alirun @@ -5,6 +5,9 @@ # # modification history # $Log$ +# Revision 1.4 2001/02/08 18:55:43 buncic +# Support for writing to remote file systems (shift/castor). +# # Revision 1.3 2001/02/01 18:00:23 buncic # Use bash in place of sh for compatibility # @@ -14,7 +17,6 @@ # Revision 1.1 2001/01/26 21:22:02 hristov # Major upgrade of AliRoot code # -############################################################################# # # SYNOPSIS # alirun [[-d |-all]] @@ -40,6 +42,7 @@ # - Digits .............. digitisation # - SDigits ............. creation of sumable digits # - SDigits2Digits ...... conversion SDigits->Digits +# - Reco ................ reconstruction # # -d | -d all | -all # Selects detector for which will be run. If none of these options was specified, an internal loop in AliRoot over all active detectors is assumed. Otherwise, for each detector, input file(s) are re-opened in update mode, command (or macro) is executed and the file is closed. Option -all is equivalent to MUON+RICH+TOF+ITS+TPC+PHOS+PMD+CASTOR+TRD. Detectors are processed in order as they appear on the command line. @@ -48,7 +51,11 @@ # Name of the top level Root file where Root trees will be stored (branches may reside in the same file or be diverted to separate files (see -split option). By default, file is named galice.root. # # -o -# A directory where output file(s) will be stored. If does not exist, it will be created. If not specified, current directory is used. +# A directory where output file(s) will be stored. If does not exist, it will be created. If not specified, current directory is used. One can prefix the directory name with a string indicting file transport protocols (as supported by ROOT). In addition, some file transport protocols are selected by name signatures. At present the following methods are available: +# +# o) if file name begins with rfio:, shift:, castor:, hpss:, /shift, /castor, /hpss => rfio (remote file i/o) protocol (requires rfiod on server side) +# o) if file name begins with root:, roots: => root and secure root protocol (requires rootd on server side) +# o) if file name begins with http: => HTTP protocol (requires modified apache server on server side) # # -split # If specified, this option will tell AliRoot to divert branches of Root trees into separate files. @@ -96,6 +103,9 @@ # -debug # Execute AliRoot under gdb. # +# -debugger +# Execute AliRoot under debugger other than gdb. +# # -break # Execute AliRoot under gdb and set . # @@ -103,21 +113,21 @@ # Create man page for alirun. # # EXAMPLES -# Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.1 directory: +# Run sumulation for 1 event, 100 particles and store output in file galice.root in /tmp/event.1 directory: # -# alirun -o /tmp/event.1 -f test.root -p 100 -verbose -c Hits +# alirun -o /tmp/event.1 -p 100 -c Hits # -# Run sumulation for 1 event, 100 particles and store output in default file galice.root in /tmp/event.1 directory. In adition, divert branches of TreeD,TreeR and TreeK into separate files: +# Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.2 directory. In adition, divert branches of TreeD,TreeR and TreeK into separate files: # -# alirun -o /tmp/event.2 -split -p 100 -verbose -c Hits +# alirun -o /tmp/event.2 -f test.root -split -p 100 -c Hits # # Use output from first step and create TOF and RICH digits. Output is in the same direcory and in file test.root # -# alirun -d TOF+RICH -o /tmp/event.1 -f test.root -verbose -c Digits +# alirun -d TOF+RICH -o /tmp/event.1 -c Digits # # Use output from second step and create digits for all detectors. Output is in the same direcory and branches are diverted to separate files: # -# alirun -d all -o /tmp/event.2 -split -verbose -c Digits +# alirun -d all -o /tmp/event.2 -f test.root -split -c Digits # # AUTHOR: # Predrag Buncic, e-mail: Predrag.Buncic@cern.ch @@ -127,6 +137,7 @@ # #C< ########################################################################### + if [ "$ALIRUN_SHELL" = "" ] then ALIRUN_SHELL=bin/sh @@ -143,6 +154,7 @@ then done exec $ALIRUN_SHELL -norc -noprofile $0 $* fi + ########################################################################### AliRun() ########################################################################### @@ -168,29 +180,44 @@ Mktemp() } ########################################################################### -Configure() +ConfigureIO() ########################################################################### { - if [ -x /usr/local/bin/rfmkdir ] - then - MKDIR="/usr/local/bin/rfmkdir" - else - MKDIR="mkdir" - fi - if [ -x /usr/local/bin/rfrm ] + if [ "$1" != "" ] then - RMDIR="echo y | /usr/local/bin/rfrm -r" - else - RMDIR="rm -rf" - fi - if [ -x /usr/local/bin/rfstat ] - then - STAT="/usr/local/bin/rfstat" - else - STAT="test -d" + case $1 in + CASTOR) + MKDIR="alifs mkdir" + RMDIR="alifs rm -r" + STAT="/usr/local/bin/rfstat" + if [ "$STAGE_HOST" = "" ] + then + unset STAGE_HOST + fi + if [ "$STAGE_POOL" = "" ] + then + unset STAGE_POOL + fi + ;; + RFIO) + MKDIR="/usr/local/bin/rfmkdir" + RMDIR="echo y | /usr/local/bin/rfrm -r" + STAT="/usr/local/bin/rfstat" + ;; + LOCAL) + MKDIR="mkdir" + RMDIR="rm -rf" + STAT="test -d" + ;; + *) + printf "%s I/O not yet supported by alirun.\n" $1 + exit 255 + ;; + esac fi } + ########################################################################### Cleanup() ########################################################################### @@ -211,13 +238,16 @@ AliRoot() macro=`HitsMacro` ;; Digits) - macro=`DigitsMacro Hits2Digits` + macro=`GenericMacro Hits2Digits` ;; SDigits) - macro=`DigitsMacro Hits2SDigits` + macro=`GenericMacro Hits2SDigits` ;; SDigits2Digits) - macro=`DigitsMacro SDigits2Digits` + macro=`GenericMacro SDigits2Digits` + ;; + Reco) + macro=`GenericMacro RunReco` ;; *.C|*.C\(*\)) macro=$1 @@ -254,11 +284,15 @@ b $BREAK c where EOF - $ECHO gdb -q -x $ALIRUN_TMPDIR/gdb aliroot + $ECHO $ALIRUN_DEBUGGER -q -x $ALIRUN_TMPDIR/gdb aliroot else if [ "$VERBOSE" = "TRUE" ] then $ECHO aliroot -q -b $macro + if [ $? -ne 0 ] + then + exit $? + fi else $ECHO aliroot -q -b $macro > $stdout 2>&1 if [ $? -ne 0 ] @@ -288,7 +322,7 @@ void Simulate() { TFile *file = TFile::Open(gSystem->Getenv("CONFIG_FILE"),"recreate"); - //file->UseCache(); + $USE_CACHE; file->SetCompressionLevel(2); @@ -305,17 +339,17 @@ EOF } ########################################################################### -DigitsMacro() +GenericMacro() ########################################################################### { mode=$1 - macro=$ALIRUN_TMPDIR/Digitize.C + macro=$ALIRUN_TMPDIR/$mode.C cat < $macro //////////////////////////////////////////////////////////////////////////// -void Digitize() +void $mode() { TFile *file = TFile::Open(gSystem->Getenv("CONFIG_FILE"),"update"); if (! file ) { @@ -324,7 +358,7 @@ void Digitize() } file->SetCompressionLevel(2); - //file->UseCache(); + $USE_CACHE; if (gAlice) delete gAlice; @@ -393,20 +427,19 @@ AliRunDigits() fi } - -########################################################################### -Configure; ########################################################################### -ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; # export ALL -DETECTORS=""; # export DETECTORS +ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; +DETECTORS=""; FILE="galice.root"; CONFIG=$ALICE_ROOT/macros/Config.C; export CONFIG CONFIG_NPARTICLES=50; export CONFIG_NPARTICLES CONFIG_PATH=`pwd`; export CONFIG_PATH +CONFIG_BATCH="TRUE"; export CONFIG_BATCH ALIRUN_TMPDIR=`Mktemp`; export ALIRUN_TMPDIR +ALIRUN_DEBUGGER=gdb DEBUG="FALSE" BREAK="" @@ -416,6 +449,7 @@ CMDLIST="Usage" FORK="FALSE" FORK_LSF="FALSE" ECHO="" +USE_CACHE="file->UseCache()" if [ -x /usr/local/lsf/bin/lsrun ] then @@ -438,6 +472,10 @@ do shift 1 DEBUG="TRUE" ;; + -debugger) + shift 1 + ALIRUN_DEBUGGER=$1 + ;; -break) shift 1 DEBUG="TRUE" @@ -507,6 +545,10 @@ do shift 1 CONFIG_SEED=$1; export CONFIG_SEED ;; + -nocache) + shift 1 + USE_CACHE="" + ;; -c) shift 1 CMDLIST=$* @@ -514,7 +556,12 @@ do ;; -C) shift 1 - CONFIG=$1; export CONFIG + CONFIG=$1; + if [ `dirname $CONFIG` = "." ] + then + CONFIG=`pwd`/$CONFIG + fi + export CONFIG ;; *) shift 1 @@ -530,36 +577,56 @@ else fi case $CONFIG_OUTDIR in - rfio:*|/shift/*|shift:*|/castor/*|castor:*) - ROOT_FILE_TYPE="rfio:" + rfio:*|/shift/*|shift:*) + CONFIG_FILE_PREFIX="rfio:" + ConfigureIO RFIO + ;; + /castor/*|castor:*|hpss:*) + CONFIG_FILE_PREFIX="rfio:" + ConfigureIO CASTOR + ;; + hpss:*) + CONFIG_FILE_PREFIX="rfio:" + ConfigureIO RFIO ;; root:*) - ROOT_FILE_TYPE="root:" + CONFIG_FILE_PREFIX="root:" + ConfigureIO ROOT + ;; + roots:*) + CONFIG_FILE_PREFIX="roots:" + ConfigureIO ROOT ;; http:*) - ROOT_FILE_TYPE="http:" + CONFIG_FILE_PREFIX="http:" + ConfigureIO HTTP ;; file:*) - ROOT_FILE_TYPE="" + CONFIG_FILE_PREFIX="" + ConfigureIO LOCAL ;; + /*) + CONFIG_FILE_PREFIX="" + ConfigureIO LOCAL + ;; *) - ROOT_FILE_TYPE="" + CONFIG_FILE_PREFIX=`pwd`/ + ConfigureIO LOCAL ;; esac export CONFIG_OUTDIR -export CONFIG_ROOT_FILE_TYPE +export CONFIG_FILE_PREFIX -for dir in $CONFIG_OUTDIR $ALIRUN_TMPDIR -do - $STAT $dir > /dev/null 2>&1 - if [ $? -ne 0 ] - then - $MKDIR -p $dir - fi -done +$STAT $CONFIG_OUTDIR > /dev/null 2>&1 +if [ $? -ne 0 ] +then + $MKDIR -p $CONFIG_OUTDIR +fi + +mkdir -p $ALIRUN_TMPDIR -CONFIG_FILE=$ROOT_FILE_TYPE$CONFIG_OUTDIR/$FILE; export CONFIG_FILE +CONFIG_FILE=$CONFIG_FILE_PREFIX$CONFIG_OUTDIR/$FILE; export CONFIG_FILE trap Cleanup 2 -- 2.39.3