140def getArgumentParser(legacy_args=False, **kwargs):
141 """Create default argument parser"""
142
143 parser = argparse.ArgumentParser(formatter_class=
144 lambda prog : argparse.HelpFormatter(
145 prog, max_help_position=40, width=100),
146 add_help=False, **kwargs)
147
148 parser.expert_groups = [] # List of expert option groups
149
150 # --------------------------------------------------------------------------
151 g = parser.add_argument_group('Main options')
152
153 if __athenaCLI and legacy_args:
154 g.add_argument('scripts', nargs='*', action=JobOptAction,
155 help='scripts or pickle file to run')
156
157 g.add_argument('-l', '--loglevel', metavar='LVL', type=str.upper, default='INFO',
158 choices=['ALL', 'VERBOSE', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'FATAL'],
159 help='logging level: %(choices)s')
160
161 g.add_argument('--filesInput', metavar='FILES',
162 help='set FilesInput property (comma-separated list with wildcards)')
163
164 g.add_argument('--evtMax', metavar='N', type=int,
165 help='max number of events to process')
166
167 g.add_argument('--skipEvents', metavar='N', type=int,
168 help='number of events to skip')
169
170 g.add_argument('--nprocs', metavar='N', type=int,
171 help='enable AthenaMP if %(metavar)s>=1 or %(metavar)s==-1')
172
173 g.add_argument('--threads', metavar='N', type=int,
174 help='number of threads for AthenaMT, threads per worker for athenaMP')
175
176 g.add_argument('--concurrent-events', metavar='N', type=int,
177 help='number of concurrent events for AthenaMT')
178
179 g.add_argument('--CA', action='store_true',
180 help='force ComponentAccumulator mode')
181
182 g.add_argument('--config-only', metavar='FILE', nargs='?', default=False, const=True,
183 help='run only configuration and optionally store in %(metavar)s')
184
185 g.add_argument('--mtes', action='store_true',
186 help='activate multi-threaded event service')
187
188 g.add_argument('--mtes-channel', metavar='NAME', default='EventService_EventRanges',
189 help='yampl channel name between pilot and AthenaMT in event service mode')
190
191 g.add_argument("--mpi", action="store_true", default=None, help="activate MPI mode")
192
193 g.add_argument('--version', action='version', version=get_version(),
194 help='print version number')
195
196 g.add_argument('-h', '--help', metavar='FLAGS', nargs='?', action=AthHelpFlags,
197 help='show help message (for FLAGS, "flags" for all categories)' if __athenaCLI
198 else 'show help message (for FLAGS category)')
199
200
201 # --------------------------------------------------------------------------
202 g = parser.add_argument_group('Monitoring and debugging')
203
204 g.add_argument('--perfmon', metavar='MODE', nargs='?', const='fastmonmt',
205 help='enable performance monitoring toolkit in MODE')
206
207 g.add_argument('-i', '--interactive', nargs='?', choices=['init', 'run'], const='init',
208 help='interactive mode with optional stage (default: init)')
209
210 g.add_argument('--profile-python', metavar='FILE',
211 help='profile python code, dump in %(metavar)s (.pkl or .txt)')
212
213 g.add_argument('-d', '--debug', metavar='STAGE', nargs='?', const='init',
214 choices=['conf', 'init', 'exec', 'fini'],
215 help='attach debugger at stage: %(choices)s [%(const)s] (gdb or $ATLAS_DEBUGGER if set)')
216
217 g.add_argument('--debugWorker', action='store_true', dest='debug_worker',
218 help='pause AthenaMP workers at bootstrap until SIGUSR1 signal received')
219
220 g.add_argument('--leak-check', metavar='STAGE', dest='do_leak_chk', action=MemCheckAction,
221 choices=['initialize', 'start', 'beginrun', 'execute', 'finalize',
222 'endrun', 'stop', 'full', 'full-athena', 'all'],
223 help='perform basic memory leak checking, disables the use of tcmalloc.')
224
225 g.add_argument('--delete-check', metavar='STAGE', dest='do_leak_chk', action=MemCheckAction,
226 choices=['initialize', 'start', 'beginrun', 'execute', 'finalize',
227 'endrun', 'stop', 'full', 'full-athena', 'all'],
228 help='perform double delete checking, disables the use of tcmalloc.')
229
230 g.add_argument('--tracelevel', metavar='LEVEL', nargs='?', type=int, choices=range(1,4), const=3,
231 help='trace level for python configuration (%(choices)s)')
232
233 # --------------------------------------------------------------------------
234 if legacy_args:
235 g = parser.add_argument_group('Legacy options')
236
237 g.add_argument('-c', '--command', metavar='CMD',
238 help='one-liner, runs before any scripts')
239
240 g.add_argument('--drop-and-reload', action='store_true', dest='drop_reload',
241 help='offload configuration and start new process')
242
243 g.add_argument('--dump-configuration', metavar='FILE', dest='config_dump_file',
244 help='dump an ASCII version of the configuration to %(metavar)s')
245
246 g.add_argument('-s', '--showincludes', action='store_true',
247 help='show printout of included files')
248
249 # --------------------------------------------------------------------------
250 if __athenaCLI:
251 g = parser.add_argument_group('System options')
252
253 g.add_argument('--tcmalloc', action='store_true', dest='tcmalloc', default=True,
254 help='use tcmalloc.so for memory allocation [DEFAULT]')
255
256 g.add_argument('--stdcmalloc', action='store_false', dest='tcmalloc',
257 help='use libc malloc for memory allocation')
258
259 g.add_argument('--stdcmath', action='store_true', default=True,
260 help='use libc malloc for memory allocation [DEFAULT]')
261
262 g.add_argument('--imf', action='store_true',
263 help='use Intel Math Function library')
264
265 g.add_argument('--exctrace', action='store_true',
266 help='preload exception trace collector')
267
268 g.add_argument('--no-excabort', action='store_true',
269 help='disable converting some exceptions to abort')
270
271 g.add_argument('--preloadlib', metavar='LIB',
272 help='localized preload of library %(metavar)s')
273
274 g.add_argument('--enable-ers-hdlr', metavar='y/n', default='n', choices=['y','n'],
275 help='enable or not the ERS handler [%(default)s]')
276
277 return parser
278
279