From b48519e8210a1d130306e8565b8a4b16823026c4 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Mon, 11 Oct 2021 15:04:19 +0200 Subject: [PATCH] madgraph5amcatnlo: mackport changes from cc8 branch --- madgraph5amcatnlo-compile.patch | 266 -------------------------------- madgraph5amcatnlo.spec | 18 +-- 2 files changed, 1 insertion(+), 283 deletions(-) delete mode 100644 madgraph5amcatnlo-compile.patch diff --git a/madgraph5amcatnlo-compile.patch b/madgraph5amcatnlo-compile.patch deleted file mode 100644 index 743251285fe..00000000000 --- a/madgraph5amcatnlo-compile.patch +++ /dev/null @@ -1,266 +0,0 @@ -diff -Naur /dev/null MG5_aMC_v2_5_5/bin/compile.py ---- /dev/null 2016-01-21 22:33:58.638300539 +0100 -+++ MG5_aMC_v2_5_5/bin/compile.py 2016-01-21 22:33:58.638300539 +0100 -@@ -0,0 +1,262 @@ -+#! /usr/bin/env python3 -+################################################################################ -+# -+# Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors -+# -+# This file is a part of the MadGraph5_aMC@NLO project, an application which -+# automatically generates Feynman diagrams and matrix elements for arbitrary -+# high-energy processes in the Standard Model and beyond. -+# -+# It is subject to the MadGraph5_aMC@NLO license which should accompany this -+# distribution. -+# -+# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch -+# -+################################################################################ -+import os -+import sys -+import logging -+import time -+# Get the parent directory (mg root) of the script real path (bin) -+# and add it to the current PYTHONPATH -+root_path = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0] -+sys.path.append(root_path) -+ -+from madgraph import MG5DIR -+import madgraph.iolibs.import_v4 as import_v4 -+import madgraph.interface.master_interface as interface -+import models.import_ufo as import_ufo -+import aloha.create_aloha as create_aloha -+import madgraph.iolibs.files as files -+import madgraph.various.misc as misc -+import re -+ -+# Set logging level to error -+logging.basicConfig(level=vars(logging)['INFO'], -+ format="%(message)s") -+pjoin = os.path.join -+ -+class Compile_MG5: -+ -+ def __init__(self): -+ """ launch all the compilation """ -+ -+ self.make_UFO_pkl() -+ self.make_v4_pkl() -+ self.make_stdHep() -+ self.make_CutTools() -+ self.make_IREGI() -+ -+ #important for UCL cluster -+ files.cp(pjoin(MG5DIR,'input','.mg5_configuration_default.txt'), -+ pjoin(MG5DIR,'input','mg5_configuration.txt')) -+ self.cmd = interface.MasterCmd() -+ self.install_package() -+ -+ @staticmethod -+ def make_v4_pkl(): -+ """create the model.pkl for each directory""" -+ file_cond = lambda p : (os.path.exists(os.path.join(MG5DIR,'models',p,'particles.dat'))) -+ #1. find v4 model: -+ v4_model = [os.path.join(MG5DIR,'models',p) -+ for p in os.listdir(os.path.join(MG5DIR,'models')) -+ if file_cond(p)] -+ -+ for model_path in v4_model: -+ #remove old pkl -+ start = time.time() -+ print('make pkl for %s :' % os.path.basename(model_path)) -+ try: -+ os.remove(os.path.join(model_path,'model.pkl')) -+ except: -+ pass -+ import_v4.import_model(model_path) -+ print('%2fs' % (time.time() - start)) -+ -+ @staticmethod -+ def make_UFO_pkl(): -+ """ """ -+ file_cond = lambda p : os.path.exists(os.path.join(MG5DIR,'models',p,'particles.py')) -+ #1. find UFO model: -+ ufo_model = [os.path.join(MG5DIR,'models',p) -+ for p in os.listdir(os.path.join(MG5DIR,'models')) -+ if file_cond(p)] -+ # model.pkl -+ for model_path in ufo_model: -+ start = time.time() -+ print('make model.pkl for %s :' % os.path.basename(model_path)) -+ #remove old pkl -+ try: -+ os.remove(os.path.join(model_path,'model.pkl')) -+ except: -+ pass -+ import_ufo.import_full_model(model_path) -+ print('%2fs' % (time.time() - start)) -+ -+ return -+ # aloha routine -+ for model_path in ufo_model: -+ start = time.time() -+ print('make ALOHA for %s' % os.path.basename(model_path)) -+ #remove old pkl -+ try: -+ os.remove(os.path.join(model_path,'aloha.pkl')) -+ except: -+ pass -+ try: -+ os.system('rm -rf %s &> /dev/null' % os.path.join(model_path,'Fortran')) -+ except: -+ pass -+ -+ ufo_path, ufo_name =os.path.split(model_path) -+ sys.path.insert(0, ufo_path) -+ output_dir = os.path.join(model_path, 'Fortran') -+ create_aloha.AbstractALOHAModel(ufo_name, write_dir=output_dir, format='Fortran') -+ print('done in %2fs' % (time.time() - start)) -+ -+ @staticmethod -+ def make_stdHep(): -+ print("Compiling StdHEP in %s."%str(os.path.join(MG5DIR, 'vendor', 'StdHEP'))) -+ # this is for 64-bit systems -+ if sys.maxsize > 2**32: -+ path = os.path.join(MG5DIR, 'vendor', 'StdHEP', 'src', 'make_opts') -+ text = open(path).read() -+ text = text.replace('MBITS=32','MBITS=64') -+ open(path, 'w').writelines(text) -+ # Set the correct fortran compiler -+ if 'FC' not in os.environ or not os.environ['FC']: -+ if misc.which('gfortran'): -+ compiler = 'FC=gfortran' -+ elif misc.which('g77'): -+ compiler = 'FC=g77' -+ else: -+ raise self.InvalidCmd('Require g77 or Gfortran compiler') -+ else: -+ compiler = '#FC=gfortran' -+ -+ base_compiler= ['FC=g77','FC=gfortran','#FC=g77','#FC=gfortran'] -+ path = None -+ path = os.path.join(MG5DIR, 'vendor', 'StdHEP', 'src', 'make_opts') -+ text = open(path).read() -+ for base in base_compiler: -+ text = text.replace(base,compiler) -+ open(path, 'w').writelines(text) -+ -+ misc.compile(cwd = os.path.join(MG5DIR, 'vendor', 'StdHEP')) -+ -+ @staticmethod -+ def make_CutTools(): -+ print("Compiling CutTools in %s."%str(os.path.join(MG5DIR, 'vendor', 'CutTools'))) -+ # Set the correct fortran compiler -+ if 'FC' not in os.environ or not os.environ['FC']: -+ if misc.which('gfortran'): -+ compiler = 'FC=gfortran' -+ else: -+ raise self.InvalidCmd('Require gfortran compiler') -+ else: -+ compiler = '#FC=gfortran' -+ -+ base_compiler= ['FC=gfortran','#FC=gfortran'] -+ path = None -+ path = os.path.join(MG5DIR, 'vendor', 'CutTools', 'makefile') -+ text = open(path).read() -+ for base in base_compiler: -+ text = text.replace(base,compiler) -+ open(path, 'w').writelines(text) -+ -+ misc.compile(cwd = os.path.join(MG5DIR, 'vendor', 'CutTools')) -+ -+ @staticmethod -+ def make_IREGI(): -+ print("Compiling IREGI in %s."%str(os.path.join(MG5DIR, 'vendor', 'IREGI','src'))) -+ # Set the correct fortran compiler -+ if 'FC' not in os.environ or not os.environ['FC']: -+ if misc.which('gfortran'): -+ compiler = 'FC=gfortran' -+ else: -+ raise self.InvalidCmd('Require gfortran compiler') -+ else: -+ compiler = '#FC=gfortran' -+ -+ iregi_path = os.path.join(MG5DIR, 'vendor', 'IREGI') -+ # replace the current compiler to be gfortran -+ if compiler == 'FC=gfortran': -+ # in case there is #FC -> FC -+ #search file in src -+ file_to_change=misc.find_makefile_in_dir(os.path.join(iregi_path,'src')) -+ comp_re = re.compile('^(\s*)#FC\s*=\s*(.+)\s*$') -+ var = 'FC' -+ mod = False -+ for name in file_to_change: -+ lines = open(name,'r').read().split('\n') -+ for iline, line in enumerate(lines): -+ result = comp_re.match(line) -+ if result: -+ mod = True -+ lines[iline] = result.group(1) + var + "=" + result.group(2) -+ if mod: -+ open(name,'w').write('\n'.join(lines)) -+ mod = False -+ # search file in src/oneloop -+ file_to_change=misc.find_makefile_in_dir(os.path.join(iregi_path,'src','oneloop')) -+ mod = False -+ for name in file_to_change: -+ lines = open(name,'r').read().split('\n') -+ for iline, line in enumerate(lines): -+ result = comp_re.match(line) -+ if result: -+ mod = True -+ lines[iline] = result.group(1) + var + "=" + result.group(2) -+ if mod: -+ open(name,'w').write('\n'.join(lines)) -+ mod = False -+ # change FC = current to FC = new -+ current = misc.detect_current_compiler( -+ os.path.join(iregi_path,'src','makefile_ML5_lib')) -+ new = 'gfortran' -+ if current != new: -+ misc.mod_compilator(os.path.join(iregi_path,'src'), new,current) -+ misc.mod_compilator(os.path.join(iregi_path,'src','oneloop'), -+ new, current) -+ else: -+ #search file in src -+ file_to_change=misc.find_makefile_in_dir(os.path.join(iregi_path,'src')) -+ comp_re = re.compile('^(\s*)FC\s*=\s*(.+)\s*$') -+ var = 'FC' -+ mod = False -+ for name in file_to_change: -+ lines = open(name,'r').read().split('\n') -+ for iline, line in enumerate(lines): -+ result = comp_re.match(line) -+ if result: -+ mod = True -+ lines[iline] = '#'+result.group(1) + var + "=" + result.group(2) -+ if mod: -+ open(name,'w').write('\n'.join(lines)) -+ mod = False -+ # search file in src/oneloop -+ file_to_change=misc.find_makefile_in_dir(os.path.join(iregi_path,'src','oneloop')) -+ mod = False -+ for name in file_to_change: -+ lines = open(name,'r').read().split('\n') -+ for iline, line in enumerate(lines): -+ result = comp_re.match(line) -+ if result: -+ mod = True -+ lines[iline] = '#'+result.group(1) + var + "=" + result.group(2) -+ if mod: -+ open(name,'w').write('\n'.join(lines)) -+ mod = False -+ -+ misc.compile(cwd = os.path.join(iregi_path,'src')) -+ -+ def install_package(self): -+ print("do not install any external packages") -+ # self.cmd.exec_cmd('install pythia-pgs') -+ # self.cmd.exec_cmd('install Delphes') -+ # self.cmd.exec_cmd('install ExRootAnalysis') -+ # self.cmd.exec_cmd('install MadAnalysis') -+ # self.cmd.exec_cmd('install SysCalc') -+ -+if __name__ == '__main__': -+ Compile_MG5() diff --git a/madgraph5amcatnlo.spec b/madgraph5amcatnlo.spec index 0ee0fc704db..925eda11a20 100644 --- a/madgraph5amcatnlo.spec +++ b/madgraph5amcatnlo.spec @@ -4,10 +4,8 @@ Provides: perl(Compress::Zlib) Provides: perl(List::Util) Source: https://launchpad.net/mg5amcnlo/2.0/2.7.x/+download/MG5_aMC_v%{realversion}.py3.tar.gz Patch0: madgraph5amcatnlo-config -# Compile and install internal and external packages -Patch1: madgraph5amcatnlo-compile #Python 3.9, use of math.gcd instead of fractions.gcd -Patch2: madgraph5amcatnlo-py39 +Patch1: madgraph5amcatnlo-py39 Requires: python3 py3-six Requires: hepmc @@ -24,7 +22,6 @@ Requires: thepeg %setup -n MG5_aMC_v%{versiontag}_py3 %patch0 -p1 %patch1 -p1 -%patch2 -p1 sed -i -e "s|\${HEPMC_ROOT}|${HEPMC_ROOT}|g" input/mg5_configuration.txt sed -i -e "s|\${PYTHIA8_ROOT}|${PYTHIA8_ROOT}|g" input/mg5_configuration.txt @@ -37,18 +34,6 @@ sed -i -e "s|SHFLAG = \-fPIC|SHFLAG = \-fPIC \-fcommon|g" vendor/StdHEP/src/stdh %build export FC="$(which gfortran) -std=legacy" -# Save patched config -cp input/mg5_configuration.txt input/mg5_configuration_patched.txt - -# Compile in advance -chmod +x bin/compile.py -./bin/compile.py -# Remove compile script after compilation -rm bin/compile.py - -# Add back patched config after compilation since its get overwritten -# Save patched config -mv input/mg5_configuration_patched.txt input/mg5_configuration.txt # Start small NLO event generation to make sure that all additional packages are compiled cat < basiceventgeneration.txt @@ -63,7 +48,6 @@ EOF find . -type f -name '*.tgz' -delete %install -sed -i -e "s|@MADGRAPH5AMCATNLO_ROOT@|%{i}|g" input/mg5_configuration.txt rsync -avh %{_builddir}/MG5_aMC_v%{versiontag}_py3/ %{i}/ sed -ideleteme 's|#!.*/bin/python|#!/usr/bin/env python|' \ %{i}/Template/LO/bin/internal/addmasses_optional.py \