#!/bin/bash -x mkdir -p NA62mcJobRunDir if [ -f $1 ]; then echo "Input file $1 exists, OK" else echo "An input file  $1 does not exist, exiting ..." exit 1 fi cd NA62mcJobRunDir rm -rf * CWD=`pwd` echo " current working directory is  $CWD " # SD=$VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir_v4 # mv ../input_files.tgz . mv ../$1 . /bin/ls -l # LD_LIBRARY_PATH_ORIGINAL=$LD_LIBRARY_PATH # PATH=$VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir_v4/NA62MC/bin/Linux-g++:$PATH # NA62 internal libraies pre=$SD/NA62MC # first bit extra here, since the libNA62MC.so ends up in the temp directory: NA62_LIBS=$pre/tmp/Linux-g++/NA62MC:$pre/RICH/Persistency/lib:$pre/GigaTracker/Persistency/lib:$pre/CHOD/Persistency/lib:$pre/Spectrometer/Persistency/lib:$pre/MUV3/Persistency/lib:$pre/MUV2/Persistency/lib:$pre/MUV1/Persistency/lib:$pre/IRC/Persistency/lib:$pre/LAV/Persistency/lib:$pre/SAC/Persistency/lib:$pre/Cedar/Persistency/lib:$pre/Generator:$pre/Persistency/lib:$pre/LKr/Persistency/lib:$pre/Beam/src # LD_LIBRARY_PATH=$NA62_LIBS:$SD/sw/lcg/external/geant4/9.4/x86_64-slc5-gcc43/lib:$SD/sw/lcg/external/XercesC/3.1.0/x86_64-slc5-gcc43-opt/lib:$SD/sw/lcg/external/clhep/2.1.0.1/x86_64-slc5-gcc43-opt/lib:$SD/sw/lcg/contrib/gcc/4.3.2/x86_64-slc5-gcc34-opt/lib64:$SD/usr/lib64/root/:$SD/root/lib:$SD/sw/usr/lib64:$SD/usr/lib64:$SD/geant4.9.4.p01/lib/Linux-g++ # untar the input sandbox tar xzf input_files.tgz # move $1 to the tree mv $1 macros/ # echo " topdir " /bin/ls echo " macros/ " /bin/ls macros echo " macro file " /bin/ls ./macros/$1 echo " sed sybstitute ... " # sed -e "s,^\(/Detector/LAV/EfficiencyMatrix\)[[:space:]]\+\(.*\)\$,\1 $VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir_v4/NA62MC/\2,g"  -i ./macros/$1 echo " grep for the change ? " grep "/Detector/LAV/EfficiencyMatrix"  ./macros/$1 # sed -e "s,^\(/Detector/LAV/TimeMatrix\).*\$,\1 $VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir_v4/NA62MC/LAV/LAVDelay.txt,g" -i ./macros/$1 grep "/Detector/LAV/TimeMatrix"  ./macros/$1 echo " list root dir "  $VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir_v4/root/lib ls $VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir_v4/root/libCore* echo " find " find $VO_NA62_VO_GRIDPP_AC_UK_SW_DIR -name "libCore.so.*"  -print # launch the main script NA62MC macros/$1 exit_code=$? if [ $exit_code -ne 0 ] ; then echo "NA62MC exec failed" ; exit $exit_code; fi # echo " cwd file listing " /bin/ls # # pluto.root # --vo na62.vo.gridpp.ac.uk --checksum -l /grid/na62.vo.gridpp.ac.uk/users/Martyniak/test/pluto.root # echo "output file name below, correct ??? " OUTPUT_FILE=`sed -n '/^\/output\/fileName/p' ./macros/$1 | head -1 | awk '{print $2}'` echo $OUTPUT_FILE #SE_NAME="srm://svr018.gla.scotgrid.ac.uk/dpm/gla.scotgrid.ac.uk/home/na62.vo.gridpp.ac.uk" SE_PATH=`ldapsearch -x -LLL -H ldap://lcg-bdii.cern.ch:2170/ -b mds-vo-name=local,o=grid "(&(GlueChunkKey=GlueSEUniqueID=$VO_NA62_VO_GRIDPP_AC_UK_DEFAULT_SE)(GlueVOInfoAccessControlBaseRule=VO:na62.vo.gridpp.ac.uk))" GlueVOInfoPath | sed -n '/GlueVOInfoPath:/p' | head -1 | awk '{print $2}'` SE_NAME="srm://$VO_NA62_VO_GRIDPP_AC_UK_DEFAULT_SE$SE_PATH" FILE=$OUTPUT_FILE echo "lcg-cr uploading $FILE to $SE_NAME " LD_LIBRARY_PATH=$LD_LIBRARY_PATH_ORIGINAL export LFC_HOST=lfc00.grid.hep.ph.ic.ac.uk echo $LD_LIBRARY_PATH # LFC_ARCHIVE_GUID=`lcg-cr -v -d $SE_NAME/martynia/test/$OUTPUT_FILE --vo na62.vo.gridpp.ac.uk --checksum -l /grid/na62.vo.gridpp.ac.uk/users/Martyniak/test/$OUTPUT_FILE file:$FILE ||\                      echo \"lfc_upload failed from $FILE\"` exit_code=$? if [ $exit_code -ne 0 ] ; then echo "lcg-cr failed" ; echo "$LFC_ARCHIVE_GUID"; exit $exit_code; fi echo "The resulting $LFC_ARCHIVE_GUID" # run the Controller submit client # Axis libraries: SW_DIR=$VO_NA62_VO_GRIDPP_AC_UK_SW_DIR/na62mcrundir export AXIS_LIB=$SW_DIR/axis-1_4/lib export AXISCLASSPATH=.:$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery-0.2.jar:$AXIS_LIB/commons-logging-1.0.4.jar:$AXIS_LIB/jaxrpc.jar:$AXIS_LIB/saaj.jar:$AXIS_LIB/log4j-1.2.8.jar:$AXIS_LIB/wsdl4j-1.5.1.jar # logging cp $SW_DIR/simpleclient/log4j.properties . # params: proxy, fts service edpoint, source, dest # pass the lfn with -D !!! $SW_DIR/jdk1.6.0_29/bin/java -Dlfn=/grid/na62.vo.gridpp.ac.uk/users/Martyniak/test/$OUTPUT_FILE -Xms128m -Xmx256m -cp $AXISCLASSPATH:$SW_DIR/glite/share/java/glite-security-trustmanager.jar:$SW_DIR/glite/share/java/glite-security-util-java.jar:$SW_DIR/glite/share/glite-security-trustmanager/bcprov-1.37.jar:$SW_DIR/simpleclient/NA62Controller.jar org.na62.grid.controller.Client $X509_USER_PROXY https://lcgfts.gridpp.rl.ac.uk:8443/glite-data-transfer-fts/services/FileTransfer $SE_NAME/martynia/test/$OUTPUT_FILE  srm://srm-na62.gridpp.rl.ac.uk/castor/ads.rl.ac.uk/prod/na62.vo.gridpp.ac.uk/$OUTPUT_FILE $X509_CERT_DIR