119def error_check(errors_a, return_code):
120 if not MADGRAPH_CATCH_ERRORS:
121 return
122 unmasked_error = False
123 my_debug_file = None
124 bad_variables = []
125
126 errors = errors_a
127 if type(errors)==bytes:
128 errors = errors.decode('utf-8')
129 if len(errors):
130 mglog.info('Some errors detected by MadGraphControl - checking for serious errors')
131 for err in errors.split('\n'):
132 if len(err.strip())==0:
133 continue
134
135 if 'Inappropriate ioctl for device' in err:
136 mglog.info(err)
137 continue
138 if 'stty: standard input: Invalid argument' in err:
139 mglog.info(err)
140 continue
141
142 if 'PDF already installed' in err:
143 mglog.info(err)
144 continue
145 if 'Read-only file system' in err:
146 mglog.info(err)
147 continue
148 if 'HTML' in err:
149
150 mglog.info(err)
151 continue
152 if 'impossible to set default multiparticles' in err:
153
154 mglog.info(err)
155 continue
156 if 'More information is found in' in err:
157 my_debug_file = err.split("'")[1]
158 if err.startswith('tar'):
159 mglog.info(err)
160 continue
161 if 'python2 support will be removed' in err:
162 mglog.info(err)
163 continue
164 if 'python3.12 support is still experimental' in err:
165 mglog.info(err)
166 continue
167
168 if 'required by /lib64/libfontconfig.so' in err or\
169 'required by /lib64/libgs.so' in err:
170 mglog.info(err)
171 continue
172 if 'Error: Symbol' in err and 'has no IMPLICIT type' in err:
173 bad_variables += [ err.split(
'Symbol ')[1].
split(
' at ')[0] ]
174
175 if 'it/s' in err:
176 mglog.info(err)
177 continue
178 mglog.error(err)
179 unmasked_error = True
180
181 if my_debug_file is None:
182 debug_files = glob.glob('*debug.log')+glob.glob('*/*debug.log')
183 for debug_file in debug_files:
184
185 has_subproc = os.access(os.path.join(os.path.dirname(debug_file),'SubProcesses'),os.R_OK)
186 if has_subproc:
187 my_debug_file = debug_file
188 break
189
190 if my_debug_file is not None:
191 if not unmasked_error:
192 mglog.warning('Found a debug file at '+my_debug_file+' but no apparent error. Will terminate.')
193 mglog.error('MadGraph5_aMC@NLO appears to have crashed. Debug file output follows.')
194 with open(my_debug_file,'r') as error_output:
195 for l in error_output:
196 mglog.error(l.replace('\n',''))
197 mglog.error('End of debug file output')
198
199 if bad_variables:
200 mglog.warning('Appeared to detect variables in your run card that MadGraph did not understand:')
201 mglog.warning(' Check your run card / JO settings for %s',bad_variables)
202
203
204 if return_code!=0:
205 mglog.error(f'Detected a bad return code: {return_code}')
206 unmasked_error = True
207
208
209 if unmasked_error or my_debug_file is not None:
210 write_test_script()
211 raise RuntimeError('Error detected in MadGraphControl process')
212 return
213
214
215
std::vector< std::string > split(const std::string &s, const std::string &t=":")