OpticalLibraryBuild_Grid.sh
Go to the documentation of this file.
1 #!/bin/bash
2 #
3 # Author: bjpjones@fnal.gov from echurch@fnal.gov from dbox@fnal.gov
4 #
5 # A script to run the optical library building job
6 #
7 #
8 # To run this job:
9 #
10 # jobsub -X509_USER_PROXY /scratch/[user]/grid/[user].uboone.proxy -N [NoOfJobs] -q OpticalLibraryBuild_Grid.sh `whoami` `pwd`
11 #
12 # You will get outputs in the area specified by the "outstage" variable
13 # which is specified below.
14 #
15 # The form of the output is one file for each few voxels. These then need
16 # stitching together, which is done after all jobs are done, with a
17 # dedicated stitching script.
18 #
19 
20 umask 0002
21 verbose=T
22 
23 # Copy arguments into meaningful names.
24 cluster=${CLUSTER}
25 process=${PROCESS}
26 user=$1
27 submitdir=$2
28 
29 
30 # Directory in which to put the output files.
31 outstage=/uboone/data/users/bjpjones/OpticalProduction
32 
33 
34 # Library building parameters
35 
36 # In each grid job, do this many voxels:
37 NVoxelsPerJob=240
38 
39 # In each voxel, run this many photons:
40 NPhotonsPerVoxel=30000
41 
42 NTopVoxel=2250000
43 
44 # This works out which voxels this job should focus on:
45 FirstVoxel=`echo "($NVoxelsPerJob * $PROCESS ) % $NTopVoxel" | bc`
46 LastVoxel=`echo "(($NVoxelsPerJob * $PROCESS ) + $NVoxelsPerJob - 1 ) % $NTopVoxel" | bc`
47 
48 
49 # And then tell the user about it:
50 echo "This job will run from voxel $FirstVoxel to $LastVoxel, generating $NPhotonsPerVoxel in each"
51 
52 
53 # Most of what comes next is from echurch's grid submission script.
54 
55 
56 echo "Input arguments:"
57 echo "Cluster: " $cluster
58 echo "Process: " $process
59 echo "User: " $user
60 echo "SubmitDir: " $submitdir
61 echo " "
62 
63 # Do not change this section.
64 ORIGDIR=`pwd`
65 TMP=`mktemp -d ${_CONDOR_SCRATCH_DIR:-/var/tmp}/working_dir.XXXXXXXXXX`
66 TMP=${TMP:-${_CONDOR_SCRATCH_DIR:-/var/tmp}/working_dir.$$}
67 
68 { [[ -n "$TMP" ]] && mkdir -p "$TMP"; } || \
69  { echo "ERROR: unable to create temporary directory!" 1>&2; exit 1; }
70 trap "[[ -n \"$TMP\" ]] && { cd ; rm -rf \"$TMP\"; }" 0
71 
72 echo "Temp directory : $TMP"
73 cd $TMP
74 
75 
76 cp -r $ORIGDIR/* .
77 # End of the section you should not change.
78 
79 
80 # Construct the run-time configuration file for this job;
81 # Make the random number seeds a function of the process number.
82 generatorSeed=$(( $process *23 + 31))
83 g4Seed=$(( $process *41 + 37))
84 
85 
86 # Copy fcl file and configure for this process
87 cp /uboone/app/users/bjpjones/GridReadyNew/prodsingle_buildopticallibrary.fcl thisjob.fcl
88 
89 echo "physics.producers.generator.FirstVoxel: $FirstVoxel" >> thisjob.fcl
90 echo "physics.producers.generator.LastVoxel: $LastVoxel" >> thisjob.fcl
91 echo "physics.producers.generator.N: $NPhotonsPerVoxel">> thisjob.fcl
92 
93 # No need to set random seeds - generated from machine state
94 #echo "physics.producers.generator.RandomSeed: $generatorSeed">> thisjob.fcl
95 #echo "physics.producers.largeant.RandomSeed: $g4Seed">> thisjob.fcl
96 
97 
98 unset LD_LIBRARY_PATH
99 
100 # Establish environment and run the job.
101 export GROUP=uboone
102 export EXPERIMENT=uboone
103 export EXTRA_PATH=lar
104 export HOME=/uboone/app/users/bjpjones/GridReadyNew
105 
106 ## This sets all the needed FW and SRT and LD_LIBRARY_PATH envt variables.
107 ## Then we cd back to our TMP area. EC, 23-Nov-2010.
108 
109 cd $TMP
110 
111 # Setup larsoft within the uboone frozen release
112 source /grid/fermiapp/lbne/lar/code/larsoft/releases/S2013.03.11/setup/setup_larsoft_fnal.sh -r S2013.03.11
113 srt_setup SRT_BASE_RELEASE=S2013.03.11
114 
115 
116 
117 
118 
119 # Run the job
120 echo "Starting job"
121 lar -c thisjob.fcl -n $NVoxelsPerJob >& thisjob.log
122 echo "Job completed"
123 
124 
125 # Make sure the user's output staging area exists.
126 test -e $outstage || mkdir $outstage
127 if [ ! -d $outstage ];then
128  echo "File exists but is not a directory."
129  outstage=/grid/data/lbne/outstage/nobody
130  echo "Changing outstage directory to: " $outstage
131  exit
132 fi
133 
134 # Make a directory in the outstage area to hold all files from this job.
135 echo "Trying to make directory : ${outstage}/${cluster}_${process} "
136 mkdir ${outstage}/${cluster}_${process}
137 
138 
139 # Copy all files from the working directory to the output staging area.
140 /grid/fermiapp/minos/scripts/cpn *.root ${outstage}/${cluster}_${process}
141 /grid/fermiapp/minos/scripts/cpn *.log ${outstage}/${cluster}_${process}
142 /grid/fermiapp/minos/scripts/cpn *.fcl ${outstage}/${cluster}_${process}
143 # Make sure EXPERIMENTana (under which name the jobs run on the grid)
144 # writes these as group rw, so you can rm 'em, etc.
145 #chmod -R g+rw $outstage
146 
147 exit 0