~maddevelopers/mg5amcnlo/WWW5_caching

« back to all changes in this revision

Viewing changes to users/mardelcourt/PROC_242195/PROC_242195/bin/internal/Gridpack/gridrun

  • Committer: John Doe
  • Date: 2013-03-25 20:27:02 UTC
  • Revision ID: john.doe@gmail.com-20130325202702-5sk3t1r8h33ca4p4
first clean version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
################################################################################
 
4
#
 
5
# Copyright (c) 2009 The MadGraph Development team and Contributors
 
6
#
 
7
# This file is a part of the MadGraph 5 project, an application which 
 
8
# automatically generates Feynman diagrams and matrix elements for arbitrary
 
9
# high-energy processes in the Standard Model and beyond.
 
10
#
 
11
# It is subject to the MadGraph license which should accompany this 
 
12
# distribution.
 
13
#
 
14
# For more information, please visit: http://madgraph.phys.ucl.ac.be
 
15
#
 
16
################################################################################
 
17
 
 
18
"""This is the main executable, a simple frontend to set up the PYTHONPATH
 
19
and call immediately the command line interface scripts"""
 
20
 
 
21
import sys
 
22
if not sys.version_info[0] == 2 or sys.version_info[1] < 6:
 
23
    sys.exit('MadGraph/MadEvent 5 works only with python 2.6 or later (but not python 3.X).\n\
 
24
               Please upgrate your version of python.')
 
25
 
 
26
import os
 
27
import optparse
 
28
 
 
29
# Get the directory of the script real path (bin)
 
30
# and add it to the current PYTHONPATH
 
31
 
 
32
root_path = os.path.dirname(os.path.dirname(os.path.realpath( __file__ )))
 
33
sys.path.insert(0, root_path)
 
34
 
 
35
 
 
36
# Write out nice usage message if called with -h or --help
 
37
usage = "usage: %prog [options] [FILE] "
 
38
parser = optparse.OptionParser(usage=usage)
 
39
parser.add_option("-l", "--logging", default='INFO',
 
40
                  help="logging level (DEBUG|INFO|WARNING|ERROR|CRITICAL) [%default]")
 
41
parser.add_option("","--debug", action="store_true", default=False, dest='debug', \
 
42
                 help='force to launch debug mode')
 
43
(options, args) = parser.parse_args()
 
44
if len(args) == 0:
 
45
    args = ''
 
46
 
 
47
import subprocess
 
48
 
 
49
# Check if optimize mode is (and should be) activated
 
50
if __debug__ and not options.debug and \
 
51
    (not os.path.exists(os.path.join(root_path,'../..', 'bin','create_release.py'))):
 
52
        subprocess.call([sys.executable] + ['-O'] + sys.argv)
 
53
        sys.exit()
 
54
 
 
55
import logging
 
56
import logging.config
 
57
 
 
58
try:
 
59
   import psyco
 
60
   psyco.full()
 
61
except:
 
62
   pass
 
63
 
 
64
if __debug__:
 
65
        print 'Running MG5 in debug mode'
 
66
 
 
67
 
 
68
# Set logging level according to the logging level given by options
 
69
#logging.basicConfig(level=vars(logging)[options.logging])
 
70
try:
 
71
    if __debug__ and options.logging == 'INFO':
 
72
        options.logging = 'DEBUG'    
 
73
    logging.config.fileConfig(os.path.join(root_path, 'internal', 'me5_logging.conf'))
 
74
    logging.root.setLevel(eval('logging.' + options.logging))
 
75
    logging.getLogger('madgraph').setLevel(eval('logging.' + options.logging))
 
76
except:
 
77
    pass
 
78
 
 
79
import internal.madevent_interface as cmd_interface
 
80
 
 
81
# Call the cmd interface main loop
 
82
 
 
83
try:
 
84
    cmd_line = cmd_interface.GridPackCmd(me_dir=root_path, nb_event=args[0], seed=args[1])            
 
85
except KeyboardInterrupt:
 
86
    print 'Quit on KeyboardInterrupt' 
 
87
 
 
88
print 'DONE'
 
89
 
 
90
try:
 
91
    # Remove lock file
 
92
    os.remove(os.path.join(root_path, 'RunWeb'))
 
93
    if cmd_line.history[-1] not in ['EOF','quit','exit']:
 
94
        cmd_line.results.store_result()
 
95
except:
 
96
    pass