~maddevelopers/mg5amcnlo/3.0.2-alpha0

« back to all changes in this revision

Viewing changes to Template/bin/survey

Added Template and HELAS into bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
#  This runs a quick survey over all of the processes to determine
 
4
#  which channels in each process are important. This must be run
 
5
#  before you call integrate since it sets up important information
 
6
#  about each process. Must be run from main directory or bin directory
 
7
#
 
8
#  Usage: survey compression parallel [name]
 
9
#
 
10
#  parallel is 0 for serial, 1 for PBS, 2 for multicore
 
11
#  name is queue name for PBS or number of cores for multicore
 
12
#  
 
13
#   First we need to get into the main directory
 
14
#
 
15
if [[  ! -d ./bin  ]]; then
 
16
    cd ../
 
17
    if [[ ! -d ./bin ]]; then
 
18
        echo "Error: survey must be executed from the main, or bin directory"
 
19
        exit
 
20
    fi
 
21
fi
 
22
#
 
23
#  Now let shell know where to find important executables
 
24
#
 
25
main=`pwd`
 
26
dirbin=$main/bin
 
27
# Begin Local versions
 
28
# set dirbin = /home/tstelzer/bin/MG_ME
 
29
# End Local versions 
 
30
qsub=qsub
 
31
 
 
32
if [[  "$1" == ""  ]]; then
 
33
    echo 'Enter 2 for multi-core, 1 for parallel, 0 for serial run' 
 
34
    read mode
 
35
else
 
36
    mode=$1
 
37
fi
 
38
if [[  $mode -gt 0 ]]; then
 
39
   if [[  "$2" == ""  ]]; then
 
40
     if [[  $mode -eq 1 ]]; then
 
41
       echo 'Enter name for jobs on pbs queue'
 
42
     elif [[  $mode -eq 2 ]]; then
 
43
       echo 'Enter number of cores'
 
44
     fi
 
45
     read n
 
46
   else
 
47
       n=$2
 
48
   fi
 
49
fi
 
50
 
 
51
# check makefile version
 
52
c=`awk '/^[^#].*=.*pdlabel/{print $1}' Cards/run_card.dat`
 
53
if [[ $c == "'lhapdf'" ]]; then
 
54
    echo Using LHAPDF interface!
 
55
    if [[ -e $main/Source/makefile_default ]]; then
 
56
        echo already loaded
 
57
    else
 
58
        cp $main/Source/makefile $main/Source/makefile_default
 
59
        cp $main/Source/PDF/makefile $main/Source/PDF/makefile_default
 
60
        cp $main/Source/DHELAS/Makefile $main/Source/DHELAS/Makefile_default
 
61
        cp $main/Source/MODEL/makefile $main/Source/MODEL/makefile_default
 
62
        cp $main/Source/CERNLIB/makefile $main/Source/CERNLIB/makefile_default
 
63
        cp $main/SubProcesses/makefile $main/SubProcesses/makefile_default
 
64
        cp $main/SubProcesses/makefile_mo $main/SubProcesses/makefile_mo_default
 
65
        cp $main/Source/makefile_lhapdf $main/Source/makefile
 
66
        cp $main/Source/PDF/makefile_lhapdf $main/Source/PDF/makefile    
 
67
        cp $main/SubProcesses/makefile_lhapdf $main/SubProcesses/makefile    
 
68
        cp $main/SubProcesses/makefile_mo_lhapdf $main/SubProcesses/makefile_mo  
 
69
        sed -i.bak "s|f77|gfortran|g" $main/Source/DHELAS/Makefile
 
70
        sed -i.bak "s|f77|gfortran|g" $main/Source/MODEL/makefile
 
71
        sed -i.bak "s|f77|gfortran|g" $main/Source/CERNLIB/makefile
 
72
        #    cp $lhadir/lib/libLHAPDF.a $main/lib/.
 
73
    fi
 
74
else
 
75
    if [[ -e $main/Source/makefile_default ]]; then
 
76
            mv Source/makefile_default Source/makefile
 
77
            mv Source/PDF/makefile_default Source/PDF/makefile
 
78
            mv Source/DHELAS/Makefile_default Source/DHELAS/Makefile
 
79
            mv Source/MODEL/makefile_default Source/MODEL/makefile
 
80
            mv Source/CERNLIB/makefile_default Source/CERNLIB/makefile
 
81
            mv SubProcesses/makefile_default SubProcesses/makefile
 
82
    fi
 
83
fi
 
84
 
 
85
echo "Compiling libraries"
 
86
if [[ -d Source ]]; then
 
87
    echo "Compiling Libraries" >& status
 
88
    cd Source
 
89
    make ../bin/sum_html >/dev/null
 
90
    make all >& /dev/null
 
91
    cd ..
 
92
else
 
93
    echo 'Error Source directory not found'
 
94
    exit
 
95
fi
 
96
if [[ -d SubProcesses ]]; then
 
97
    if [[  $mode -gt 0 ]]; then    
 
98
        echo "Creating Jobs" >& status
 
99
    else
 
100
        echo " " >& status
 
101
    fi
 
102
    cd SubProcesses
 
103
    r=0
 
104
    if [[ -e randinit ]]; then
 
105
        source ./randinit
 
106
    fi
 
107
    for i in `cat subproc.mg` ; do
 
108
        r=`expr $r + 1`
 
109
    done
 
110
#    echo "Using random number seed offset = " $r
 
111
    echo "r=$r" >& randinit
 
112
    echo "Working on subprocess:"
 
113
    for i in `cat subproc.mg` ; do
 
114
        cd $i
 
115
        echo -n "   " $i "   "
 
116
        rm -f ajob* >& /dev/null
 
117
        rm -f wait.ajob* >& /dev/null
 
118
        rm -f run.ajob* >& /dev/null
 
119
        rm -f done.ajob* >& /dev/null
 
120
        make gensym > /dev/null
 
121
        ./gensym >& gensym.log
 
122
        chmod +x ajob*
 
123
        make madevent > /dev/null
 
124
        for job in ajob*  ; do
 
125
            touch wait.$job
 
126
            if [[ $mode == 1 ]]; then
 
127
                $qsub -N $n $job >> ../../running_jobs
 
128
            elif [[ $mode == 2 ]]; then
 
129
                ../../bin/multicore $n $job
 
130
                sleep 1
 
131
            else
 
132
                time nice ./$job >/dev/null
 
133
                ../../bin/sum_html >/dev/null
 
134
            fi
 
135
        done
 
136
        cd ..
 
137
        if [[ $mode == 0  ]]; then 
 
138
            ../bin/sum_html 
 
139
        fi
 
140
    done
 
141
    if [[ $mode -ge 1 ]]; then
 
142
        $dirbin/monitor $3
 
143
        ../bin/sumall
 
144
    fi
 
145
    cd ../
 
146
else
 
147
    echo "Error could not find SubProcesses"
 
148
    exit
 
149
fi
 
150
$dirbin/gen_crossxhtml-pl $3