Skip to content

Commit 8016113

Browse files
committed
Clean-up of unused function and improvements
1 parent 012448e commit 8016113

2 files changed

Lines changed: 11 additions & 92 deletions

File tree

madmatrix/model_handling.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def write_combined_cc(self, lor_names, offshell=None, sym=True, mode=''):
846846
# self.declaration.discard
847847
text.write(self.get_declaration_txt(add_i=False, combined=True))
848848
text.write(routine.getvalue())
849-
text.write(self.get_foot_txt(combine=True))
849+
text.write(self.get_foot_txt(combined=True))
850850

851851
text = text.getvalue()
852852
return text
@@ -1897,13 +1897,6 @@ def edit_processConfig(self):
18971897
ff.write(template % replace_dict)
18981898
ff.close()
18991899

1900-
def generate_subprocess_directory_end(self, **opt):
1901-
""" opt contain all local variable of the fortran original function"""
1902-
#self.edit_coloramps() # AV new file (NB this is Sigma-specific, should not be a symlink to Subprocesses)
1903-
subproc_diagrams_for_config = opt['subproc_diagrams_for_config']
1904-
misc.sprint(len(subproc_diagrams_for_config))
1905-
self.edit_coloramps( subproc_diagrams_for_config)
1906-
19071900
# AV - new method
19081901
def edit_coloramps(self):
19091902
"""Generate coloramps.h"""
@@ -1970,17 +1963,6 @@ def edit_coloramps(self):
19701963
ff.write(template % replace_dict)
19711964
ff.close()
19721965

1973-
# AV - new method
1974-
def edit_testxxx(self):
1975-
"""Generate testxxx.cc"""
1976-
###misc.sprint('Entering OneProcessExporterMadMatrix.edit_testxxx')
1977-
template = open(pjoin(self.template_path,'madmatrix','testxxx.cc'),'r').read()
1978-
replace_dict = {}
1979-
replace_dict['model_name'] = self.model_name
1980-
ff = open(pjoin(self.path, '..', 'testxxx.cc'),'w')
1981-
ff.write(template % replace_dict)
1982-
ff.close()
1983-
19841966
# AV - new method
19851967
def edit_memorybuffers(self):
19861968
"""Generate MemoryBuffers.h"""
@@ -2046,14 +2028,15 @@ def get_color_matrix_lines(self, matrix_element):
20462028
denom_string = ' static constexpr fptype2 colorDenom[ncolor] = { %s }; // 1-D array[%i]' \
20472029
% ( ', '.join(['%i' % denom for denom in color_denominators]), len(color_denominators) )
20482030
matrix_strings = []
2049-
my_cs = color.ColorString()
20502031
for index, denominator in enumerate(color_denominators):
20512032
# Then write the numerators for the matrix elements
20522033
num_list = matrix_element.get('color_matrix').get_line_numerators(index, denominator)
20532034
matrix_strings.append('{ %s }' % ', '.join(['%d' % i for i in num_list]))
20542035
matrix_string = ' static constexpr fptype2 colorMatrix[ncolor][ncolor] = '
2055-
if len( matrix_strings ) > 1 : matrix_string += '{\n ' + ',\n '.join(matrix_strings) + ' };'
2056-
else: matrix_string += '{ ' + matrix_strings[0] + ' };'
2036+
if len( matrix_strings ) > 1:
2037+
matrix_string += '{\n ' + ',\n '.join(matrix_strings) + ' };'
2038+
else:
2039+
matrix_string += '{ ' + matrix_strings[0] + ' };'
20572040
matrix_string += ' // 2-D array[%i][%i]' % ( len(color_denominators), len(color_denominators) )
20582041
denom_comment = '\n // The color denominators (initialize all array elements, with ncolor=%i)\n // [NB do keep \'static\' for these constexpr arrays, see issue #283]\n' % len(color_denominators)
20592042
matrix_comment = '\n // The color matrix (initialize all array elements, with ncolor=%i)\n // [NB do keep \'static\' for these constexpr arrays, see issue #283]\n' % len(color_denominators)
@@ -2359,7 +2342,7 @@ def super_get_matrix_element_calls(self, matrix_element, color_amplitudes, multi
23592342
return res
23602343

23612344
# AV - overload helas_call_writers.GPUFOHelasCallWriter method (improve formatting)
2362-
def get_matrix_element_calls(self, matrix_element, color_amplitudes, multi_channel_map=False):
2345+
def get_matrix_element_calls(self, matrix_element, color_amplitudes, multi_channel_map):
23632346
"""Return a list of strings, corresponding to the Helas calls for the matrix element"""
23642347
res = self.super_get_matrix_element_calls(matrix_element, color_amplitudes, multi_channel_map)
23652348
for i, item in enumerate(res):

madmatrix/output.py

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ def copy_template(self, model):
130130
super().copy_template(model)
131131

132132
# AV - add debug printouts (in addition to the default one from OM's tutorial)
133-
def generate_subprocess_directory(self, subproc_group, fortran_model, me=None):
133+
def generate_subprocess_directory(self, matrix_element, cpp_helas_call_writer, proc_number=None):
134134
misc.sprint('Entering ProcessExporterMadMatrix.generate_subprocess_directory (create the directory)')
135-
misc.sprint(' type(subproc_group)=%s'%type(subproc_group)) # e.g. madgraph.core.helas_objects.HelasMatrixElement
136-
misc.sprint(' type(fortran_model)=%s'%type(fortran_model)) # e.g. madgraph.iolibs.helas_call_writers.GPUFOHelasCallWriter
137-
misc.sprint(' type(me)=%s me=%s'%(type(me) if me is not None else None, me)) # e.g. int
135+
misc.sprint(' type(matrix_element)=%s'%type(matrix_element)) # e.g. madgraph.core.helas_objects.HelasMatrixElement
136+
misc.sprint(' type(cpp_helas_call_writer)=%s'%type(cpp_helas_call_writer)) # e.g. madgraph.iolibs.helas_call_writers.GPUFOHelasCallWriter
137+
misc.sprint(' type(proc_number)=%s me=%s'%(type(proc_number) if proc_number is not None else None, proc_number)) # e.g. int
138138
misc.sprint("need to link", self.to_link_in_P)
139-
out = super().generate_subprocess_directory(subproc_group, fortran_model, me)
139+
out = super().generate_subprocess_directory(matrix_element, cpp_helas_call_writer, proc_number)
140140
return out
141141

142142
# AV (default from OM's tutorial) - add a debug printout
@@ -146,55 +146,6 @@ def convert_model(self, model, wanted_lorentz=[], wanted_couplings=[]):
146146
del model.cudacpp_wanted_ordered_couplings
147147
return super().convert_model(model, wanted_lorentz, wanted_couplings)
148148

149-
# AV (default from OM's tutorial) - add a debug printout
150-
def finalize(self, matrix_element, cmdhistory, MG5options, outputflag):
151-
"""Typically creating jpeg/HTML output/ compilation/...
152-
cmdhistory is the list of command used so far.
153-
MG5options are all the options of the main interface
154-
outputflags is a list of options provided when doing the output command"""
155-
###misc.sprint('Entering ProcessExporterMadMatrix.finalize', self.in_madevent_mode, type(self))
156-
if self.in_madevent_mode:
157-
# Modify makefiles and symlinks to avoid doing
158-
# make -f makefile -f cudacpp_overlay.mk to include the overlay
159-
# and instead just use `make`, see #1052
160-
subprocesses_dir = pjoin(self.dir_path, "SubProcesses")
161-
files.cp(pjoin(subprocesses_dir, "makefile"), pjoin(subprocesses_dir, "makefile_original.mk"))
162-
files.rm(pjoin(subprocesses_dir, "makefile"))
163-
files.ln(pjoin(subprocesses_dir, "makefile_wrapper.mk"), subprocesses_dir, 'makefile')
164-
165-
patch_coupl_write = r"""set -euo pipefail
166-
# Get last fields from lines starting with WRITE(*,2)
167-
gcs=$(awk '$1=="WRITE(*,2)" {print $NF}' coupl_write.inc)
168-
169-
for gc in $gcs; do
170-
if grep -q "$gc(VECSIZE_MEMMAX)" coupl.inc; then
171-
awk -v gc="$gc" '{
172-
if ($1=="WRITE(*,2)" && $NF==gc) print $0"(1)";
173-
else print
174-
}' coupl_write.inc > coupl_write.inc.new
175-
mv coupl_write.inc.new coupl_write.inc
176-
fi
177-
done"""
178-
try:
179-
result = subprocess.run(
180-
["bash", "-c", patch_coupl_write],
181-
cwd=pjoin(self.dir_path, "Source", "MODEL"),
182-
text=True,
183-
capture_output=True,
184-
check=True, # raise CalledProcessError on non-zero exit
185-
)
186-
misc.sprint(result.returncode)
187-
except subprocess.CalledProcessError as e:
188-
logger.debug("####### \n stdout is \n %s", e.stdout)
189-
logger.info("####### \n stderr is \n %s", e.stderr)
190-
logger.info("return code is %s\n", e.returncode)
191-
raise Exception("ERROR while patching coupl_write.inc") from e
192-
193-
# Additional patching (OM)
194-
self.add_madevent_plugin_fct() # Added by OM
195-
# do not call standard finalize since is this is already done...
196-
#return super().finalize(matrix_element, cmdhistory, MG5options, outputflag)
197-
198149
# AV (default from OM's tutorial) - overload settings and add a debug printout
199150
def modify_grouping(self, matrix_element):
200151
"""allow to modify the grouping (if grouping is in place)
@@ -204,18 +155,3 @@ def modify_grouping(self, matrix_element):
204155
# Irrelevant here since group_mode=False so this function is never called
205156
misc.sprint('Entering ProcessExporterMadMatrix.modify_grouping')
206157
return False, matrix_element
207-
208-
# OM adding a new way to "patch" python file such that the launch command of MG5aMC is working
209-
# this consist in a file plugin_interface.py
210-
# which contains a series of functions and one dictionary variable TO_OVERWRITE
211-
# that will be used to have temporary overwrite of all the key variable passed as string by their value.
212-
# all variable that are file related should be called as madgraph.dir.file.variable
213-
def add_madevent_plugin_fct(self):
214-
"""this consist in a file plugin_interface.py
215-
which contains a series of functions and one dictionary variable TO_OVERWRITE
216-
that will be used to have temporary overwrite of all the key variable passed as string by their value.
217-
all variable that are file related should be called as madgraph.dir.file.variable
218-
"""
219-
plugin_path = os.path.dirname(os.path.realpath( __file__ ))
220-
files.cp(pjoin(plugin_path, 'launch_plugin.py'), pjoin(self.dir_path, 'bin', 'internal'))
221-
files.ln(pjoin(self.dir_path, 'lib'), pjoin(self.dir_path, 'SubProcesses'))

0 commit comments

Comments
 (0)