~maddevelopers/mg5amcnlo/3.0.2-alpha0

« back to all changes in this revision

Viewing changes to Template/bin/newprocess_mg5

Added Template and HELAS into bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
#  First get to main level directory for this process
 
4
#
 
5
 
 
6
if [[  ! -d ./bin || ! -d ./SubProcesses ]]; then
 
7
    cd ../
 
8
    if [[ ! -d ./bin || ! -d ./SubProcesses  ]]; then
 
9
        echo "Error: store must be executed from the main, or bin directory"
 
10
        exit
 
11
    fi
 
12
fi
 
13
 
 
14
# Check that mg5 exists
 
15
main=`pwd`
 
16
mgdir=$main/../bin
 
17
if [[  ! -x $mgdir/mg5 ]]; then
 
18
    mgdir=$main/../madgraph5/bin
 
19
fi
 
20
if [[ ! -x $mgdir/mg5 ]]; then
 
21
   echo "Error no mg5 executable $mgdir/mg5 found"
 
22
   exit
 
23
fi
 
24
 
 
25
 
 
26
dirbin=$main/bin
 
27
 
 
28
# Local versions to work on the cluster
 
29
tag=''
 
30
while [[ "$1" != ""  ]]; do
 
31
    if [[ "$1" == "--web" ]]; then
 
32
    mgdir=$MADGRAPH_BASE/MG_ME/mg5
 
33
    dirbin=$MADGRAPH_BASE/MG_ME/WebBin
 
34
    tag="--web"
 
35
    fi
 
36
    shift 1
 
37
done
 
38
 
 
39
# some external executable
 
40
gen_card=$dirbin/gen_cardhtml-pl
 
41
gen_info=$dirbin/gen_infohtml-pl
 
42
 
 
43
# Check if we have to use MG4 proc_card.dat or MG5 proc_card.dat
 
44
if [[ -e ./Cards/proc_card_mg5.dat ]]; then 
 
45
   if [[ -e ./Cards/proc_card.dat ]]; then
 
46
      if [[ $tag != '--web' ]]; then
 
47
          echo "both mg4 and mg5 proc_card.dat are detected. Which one do you want to use? [4/5]"
 
48
          read card_use 
 
49
      else
 
50
           card_use='5'
 
51
      fi
 
52
   else
 
53
        card_use='5'
 
54
   fi
 
55
elif [[ -e ./Cards/proc_card.dat ]]; then
 
56
     card_use='4'
 
57
else
 
58
    echo "neither proc_card.dat or proc_card_mg5.dat" 
 
59
    echo "are present in directory Cards"
 
60
    echo "Prepare a card (see examples on the web) and"
 
61
    echo "copy it there."
 
62
    exit
 
63
fi
 
64
 
 
65
echo $$ > generating
 
66
rm proc_log.txt >& /dev/null
 
67
echo "Started `date`" >  ./proc_log.txt
 
68
echo "Running..."
 
69
 
 
70
$gen_card >& /dev/null
 
71
 
 
72
# launch the mg5 program
 
73
if [[ $card_use == '4' ]]; then
 
74
# Run ./mg5 with stderr going to both the file proc_log.txt and to terminal
 
75
# output. See http://acs.lbl.gov/~ksb/Scratch/sh_redir_pipe.html
 
76
    ((echo import proc_v4 ./Cards/proc_card.dat | $mgdir/mg5 3>&1 1>&2 2>&3) | tee /dev/tty) >> proc_log.txt 2>&1
 
77
    exit
 
78
elif [[ $card_use == '5' ]]; then
 
79
# Run ./mg5 with stderr going to both the file proc_log.txt and to terminal
 
80
# output. See http://acs.lbl.gov/~ksb/Scratch/sh_redir_pipe.html
 
81
     (($mgdir/mg5 ./Cards/proc_card_mg5.dat 3>&1 1>&2 2>&3) | tee /dev/tty) >> proc_log.txt 2>&1
 
82
else
 
83
    echo 'not recognized mode'
 
84
fi
 
85
 
 
86
echo "Finished `date` " >> ./proc_log.txt
 
87
echo "`date` " >& ./CREATED
 
88
cd SubProcesses
 
89
touch done
 
90
cd ..
 
91
 
 
92
if [[  $tag == "--web"  ]]; then
 
93
   touch Online
 
94
fi
 
95
rm generating
 
96
echo 'done'
 
97
$gen_card >& /dev/null