Skip to content

Commit 2fa4830

Browse files
committed
[oct23av] in CODEGEN move tmadmode steps (SDE config, runcard/paramcard generation, cleanup) from patchMad.sh to generateAndCompare.sh
This is meant to fix various code generation issues introduced in generateAndCompare.sh by PR madgraph5#764
1 parent a30fd57 commit 2fa4830

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

epochX/cudacpp/CODEGEN/PLUGIN/CUDACPP_SA_OUTPUT/patchMad.sh

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,9 @@ if [ ! -e ${dir} ]; then echo "ERROR! Directory $dir does not exist"; exit 1; fi
4242

4343
# AV Recover special 'tmad' mode used by generateAndCompare.sh, after OM's changes that commented this out in patchMad.sh
4444
tmadmode=0
45-
if [ "${MG5AMC_TMADMODE}" != "" ]; then
45+
if [ "${CUDACPP_CODEGEN_TMADMODE}" != "" ]; then
4646
tmadmode=1
47-
echo "DEBUG! Switching on tmad mode (MG5AMC_TMADMODE=${MG5AMC_TMADMODE})"
48-
fi
49-
50-
# These two steps are part of "cd Source; make" but they actually are code-generating steps
51-
if [ "${tmadmode}" != "0" ]; then
52-
${dir}/bin/madevent treatcards run # AV BUG! THIS MAY SILENTLY FAIL (should check if output contains "Please report this bug")
53-
###echo status=$?
54-
${dir}/bin/madevent treatcards param # AV BUG! THIS MAY SILENTLY FAIL (should check if output contains "Please report this bug")
55-
###echo status=$?
56-
fi
57-
58-
# Cleanup
59-
if [ "${tmadmode}" != "0" ]; then
60-
\rm -f ${dir}/crossx.html
61-
\rm -f ${dir}/index.html
62-
\rm -f ${dir}/madevent.tar.gz
63-
\rm -f ${dir}/Cards/delphes_trigger.dat
64-
\rm -f ${dir}/Cards/plot_card.dat
65-
\rm -f ${dir}/bin/internal/run_plot*
66-
\rm -f ${dir}/HTML/*
67-
\rm -rf ${dir}/bin/internal/__pycache__
68-
\rm -rf ${dir}/bin/internal/ufomodel/py3_model.pkl
69-
\rm -rf ${dir}/bin/internal/ufomodel/__pycache__
70-
touch ${dir}/HTML/.keep # new file
47+
echo "DEBUG! Switching on tmad mode (CUDACPP_CODEGEN_TMADMODE=${CUDACPP_CODEGEN_TMADMODE})"
7148
fi
7249

7350
# Exit here for patchlevel 0 (--upstream)
@@ -84,10 +61,6 @@ fi
8461
# (1) Process-independent patches
8562
touch ${dir}/Events/.keep # this file should already be present (mg5amcnlo copies it from Template/LO/Events/.keep)
8663
\cp -pr ${scrdir}/MG5aMC_patches/${dir_patches}/fbridge_common.inc ${dir}/SubProcesses # new file
87-
if [ "${tmadmode}" != "0" ]; then
88-
sed -i 's/2 = sde_strategy/1 = sde_strategy/' ${dir}/Cards/run_card.dat # use strategy SDE=1 in multichannel mode (see #419)
89-
sed -i 's/SDE_STRAT = 2/SDE_STRAT = 1/' ${dir}/Source/run_card.inc # use strategy SDE=1 in multichannel mode (see #419)
90-
fi
9164
if [ "${patchlevel}" == "2" ]; then
9265
cd ${dir}
9366
if [ "${tmadmode}" != "0" ]; then

epochX/cudacpp/CODEGEN/generateAndCompare.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
set -e # fail on error
88

99
# AV Recover special 'tmad' mode used by generateAndCompare.sh, after OM's changes that commented this out in patchMad.sh
10-
export MG5AMC_TMADMODE=1
10+
export CUDACPP_CODEGEN_TMADMODE=1
1111

1212
#--------------------------------------------------------------------------------------
1313

@@ -204,9 +204,31 @@ function codeGenAndDiff()
204204
cat ${outproc}_log.txt | egrep -v '(Crash Annotation)' > ${outproc}_log.txt.new # remove firefox 'glxtest: libEGL initialize failed' errors
205205
\mv ${outproc}_log.txt.new ${outproc}_log.txt
206206
fi
207+
# Patches moved here from patchMad.sh after Olivier's PR #764 (THIS IS ONLY NEEDED IN THE MADGRAPH4GPU GIT REPO)
208+
if [ "${OUTBCK}" == "mad" ]; then
209+
# Force the use of strategy SDE=1 in multichannel mode (see #419)
210+
sed -i 's/2 = sde_strategy/1 = sde_strategy/' ${outproc}/Cards/run_card.dat
211+
# Generate run_card.inc and param_card.inc (include stdout and stderr in the code generation log which is later checked for errors)
212+
# These two steps are part of "cd Source; make" but they actually are code-generating steps
213+
${outproc}/bin/madevent treatcards run >> ${outproc}_log.txt 2>&1 # AV BUG! THIS MAY SILENTLY FAIL (check if output contains "Please report this bug")
214+
${outproc}/bin/madevent treatcards param >> ${outproc}_log.txt 2>&1 # AV BUG! THIS MAY SILENTLY FAIL (check if output contains "Please report this bug")
215+
# Cleanup
216+
\rm -f ${outproc}/crossx.html
217+
\rm -f ${outproc}/index.html
218+
\rm -f ${outproc}/madevent.tar.gz
219+
\rm -f ${outproc}/Cards/delphes_trigger.dat
220+
\rm -f ${outproc}/Cards/plot_card.dat
221+
\rm -f ${outproc}/bin/internal/run_plot*
222+
\rm -f ${outproc}/HTML/*
223+
\rm -rf ${outproc}/bin/internal/__pycache__
224+
\rm -rf ${outproc}/bin/internal/ufomodel/py3_model.pkl
225+
\rm -rf ${outproc}/bin/internal/ufomodel/__pycache__
226+
touch ${outproc}/HTML/.keep # new file
227+
fi
228+
# Check the code generation log for errors
207229
if [ -d ${outproc} ] && ! grep -q "Please report this bug" ${outproc}_log.txt; then
208230
###cat ${outproc}_log.txt; exit 0 # FOR DEBUGGING
209-
cat ${MG5AMC_HOME}/${outproc}_log.txt | egrep 'INFO: (Try|Creat|Organiz|Process)'
231+
cat ${MG5AMC_HOME}/${outproc}_log.txt | { egrep 'INFO: (Try|Creat|Organiz|Process)' || true; }
210232
else
211233
echo "*** ERROR! Code generation failed"
212234
cat ${MG5AMC_HOME}/${outproc}_log.txt

0 commit comments

Comments
 (0)