72def error_check(errors_a, return_code):
73 if not MADGRAPH_CATCH_ERRORS:
74 return
75 if errors_a is None:
76
77
78 if return_code != 0:
79 mglog.error(f'Detected a bad return code: {return_code}')
80 write_test_script()
81 raise RuntimeError('Error detected in MadGraphControl process')
82 return
83 unmasked_error = False
84 my_debug_file = None
85 bad_variables = []
86
87 errors = errors_a
88 if type(errors)==bytes:
89 errors = errors.decode('utf-8')
90 if len(errors):
91 mglog.info('Some errors detected by MadGraphControl - checking for serious errors')
92 for err in errors.split('\n'):
93 if len(err.strip())==0:
94 continue
95
96 if 'Inappropriate ioctl for device' in err:
97 mglog.info(err)
98 continue
99 if 'stty: standard input: Invalid argument' in err:
100 mglog.info(err)
101 continue
102
103 if 'PDF already installed' in err:
104 mglog.info(err)
105 continue
106 if 'Read-only file system' in err:
107 mglog.info(err)
108 continue
109 if 'HTML' in err:
110
111 mglog.info(err)
112 continue
113 if 'impossible to set default multiparticles' in err:
114
115 mglog.info(err)
116 continue
117 if 'More information is found in' in err:
118 my_debug_file = err.split("'")[1]
119 if err.startswith('tar'):
120 mglog.info(err)
121 continue
122 if 'python2 support will be removed' in err:
123 mglog.info(err)
124 continue
125 if 'python3.12 support is still experimental' in err:
126 mglog.info(err)
127 continue
128
129 if 'python3.12+ support: For reweighting feature, please use 3.6.X release.' in err:
130 mglog.info(err)
131 continue
132
133 if 'required by /lib64/libfontconfig.so' in err or\
134 'required by /lib64/libgs.so' in err:
135 mglog.info(err)
136 continue
137 if 'Error: Symbol' in err and 'has no IMPLICIT type' in err:
138 bad_variables += [ err.split(
'Symbol ')[1].
split(
' at ')[0] ]
139
140 if 'it/s' in err:
141 mglog.info(err)
142 continue
143 mglog.error(err)
144 unmasked_error = True
145
146 if my_debug_file is None:
147 debug_files = glob.glob('*debug.log')+glob.glob('*/*debug.log')
148 for debug_file in debug_files:
149
150 has_subproc = os.access(os.path.join(os.path.dirname(debug_file),'SubProcesses'),os.R_OK)
151 if has_subproc:
152 my_debug_file = debug_file
153 break
154
155 if my_debug_file is not None:
156 if not unmasked_error:
157 mglog.warning('Found a debug file at '+my_debug_file+' but no apparent error. Will terminate.')
158 mglog.error('MadGraph5_aMC@NLO appears to have crashed. Debug file output follows.')
159 with open(my_debug_file,'r') as error_output:
160 for l in error_output:
161 mglog.error(l.replace('\n',''))
162 mglog.error('End of debug file output')
163
164 if bad_variables:
165 mglog.warning('Appeared to detect variables in your run card that MadGraph did not understand:')
166 mglog.warning(' Check your run card / JO settings for %s',bad_variables)
167
168
169 if return_code!=0:
170 mglog.error(f'Detected a bad return code: {return_code}')
171 unmasked_error = True
172
173
174 if unmasked_error or my_debug_file is not None:
175 write_test_script()
176 raise RuntimeError('Error detected in MadGraphControl process')
177 return
178
179
180
std::vector< std::string > split(const std::string &s, const std::string &t=":")