gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
standalone_facilitator Namespace Reference

Functions

def main (argv)
 

Variables

string toolsfile = "./Utils/scripts/harvesting_tools.py"
 

Function Documentation

◆ main()

def standalone_facilitator.main (   argv)

Definition at line 29 of file standalone_facilitator.py.

References harvesting_tools.neatsplit(), Gambit::ColliderBit.print(), and harvesting_tools.update_only_if_different().

29 def main(argv):
30 
31  # List of modules to include
32  modules=set([])
33 
34  # Handle command line options
35  verbose = False
36  try:
37  executablename = argv[0]
38  opts, args = getopt.getopt(argv[1:],"vm:",["verbose","use-modules="])
39  except getopt.GetoptError:
40  print('Usage: standalone_facilitator.py [flags]')
41  print(' flags:')
42  print(' -v : More verbose output')
43  print(' -m module1,module2,... : Link against module1, module2, etc.')
44  sys.exit(2)
45  for opt, arg in opts:
46  if opt in ('-v','--verbose'):
47  verbose = True
48  print('standalone_facilitator.py: verbose=True')
49  elif opt in ('-m','--use-modules'):
50  modules_list = neatsplit(",",arg)
51  modules.update(modules_list)
52 
53  # Retrieve the pickled module types.
54  try:
55  with open('./scratch/build_time/harvested_types.pickle', 'rb') as handle:
56  returned_types = pickle.load(handle)
57  except:
58  print("Could not open previously harvested module functor types.")
59  print("filename: ./scratch/build_time/harvested_types.pickle")
60  exit(2)
61 
62  # Generate the union of types.
63  all_types = set([])
64  for x in modules:
65  if x in returned_types:
66  all_types.update(returned_types[x])
67 
68  # Generate a c++ source file containing all the explicit functor template specialisations needed by the standalone program.
69  towrite = "\
70 // GAMBIT: Global and Modular BSM Inference Tool\n\
71 // *********************************************\n\
72 /// \\file \n\
73 /// \n\
74 /// Explicit functor template class \n\
75 /// instantiations needed by standalone program \n\
76 /// "+executablename+". \n\
77 /// \n\
78 /// This file was automatically generated by \n\
79 /// standalone_facilitator.py. Do not modify. \n\
80 /// The content is harvested from the rollcall \n\
81 /// headers registered in module_rollcall.hpp \n\
82 /// and the types registered in \n\
83 /// types_rollcall.hpp. \n\
84 /// \n\
85 /// *********************************************\n\
86 /// \n\
87 /// Authors: \n\
88 /// \n\
89 /// \\author The GAMBIT Collaboration \n\
90 /// \date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
91 /// \n\
92 /// *********************************************\n\
93  \n\
94 #include \"gambit/Elements/functor_definitions.hpp\"\n\
95 #include \"gambit/Elements/types_rollcall.hpp\" \n\
96 #include \"gambit/Backends/backend_functor_types.hpp\"\n\
97  \n\
98 namespace Gambit \n\
99 { \n\
100  // Non-module types \n\
101  template class module_functor<void>; \n"
102  for t in returned_types["non_module"]:
103  towrite += " template class module_functor<"+t+">;\n"
104  if all_types:
105  towrite += " // Module types\n"
106  for t in all_types: towrite += " template class module_functor<"+t+">;\n"
107  else:
108  towrite += " // No module-specific types required.\n"
109  towrite += "}\n\n\
110 // Define standalone versions of functor signal helpers (that do nothing)\n\
111 namespace Gambit \n\
112 { \n\
113  namespace FunctorHelp \n\
114  { \n\
115  void check_for_shutdown_signal(module_functor_common&) {} \n\
116  bool emergency_shutdown_begun() { return false; } \n\
117  void entering_multithreaded_region(module_functor_common&) {} \n\
118  void leaving_multithreaded_region(module_functor_common&) {} \n\
119  } \n\
120 }\n"
121 
122  # Don't touch any existing file unless it is actually different from what we will create
123  filename = "./"+modules_list[1]+"/examples/functors_for_"+executablename+".cpp"
124  candidate = "./scratch/build_time/functors_for_"+executablename+".cpp.candidate"
125  with open(candidate,"w") as f: f.write(towrite)
126  update_only_if_different(filename, candidate)
127 
128  if verbose:
129  print("Generated "+filename+".")
130 
131 
132 # Handle command line arguments (verbosity)
void print(MixMatrix A)
Helper function to print a matrix.
def update_only_if_different(existing, candidate, verbose=True)
def neatsplit(regex, string)
Here is the call graph for this function:

Variable Documentation

◆ toolsfile

string standalone_facilitator.toolsfile = "./Utils/scripts/harvesting_tools.py"

Definition at line 26 of file standalone_facilitator.py.