PLUTO
make_problem.MakeProblem Class Reference
Inheritance diagram for make_problem.MakeProblem:
Collaboration diagram for make_problem.MakeProblem:

Public Member Functions

def __init__ (self, work_dir, pluto_dir, auto_update_def, auto_update_mkfl)
 
def SetArch (self)
 
def ChomboMakeVars (self)
 
def UpdateMkflTemplate (self)
 

Public Attributes

 work_dir
 
 pluto_dir
 
 auto_update
 
 mkfl_name
 
 additional_files
 
 additional_flags
 
 header_files
 
 pluto_path
 
 chomboflag
 
 row
 
 makefile_template
 
 arch
 
 arch_string
 

Detailed Description

Definition at line 8 of file make_problem.py.

Constructor & Destructor Documentation

def make_problem.MakeProblem.__init__ (   self,
  work_dir,
  pluto_dir,
  auto_update_def,
  auto_update_mkfl 
)
Create the makefile for the PLUTO code from the defintions header file.

This class creates a makefile with all necessary information
that would compile the code based on the problem defined by user
in defintions.h file.
In case the makefile is already present, this class will
read those default values to re-create the file.

**Inputs**:
  1. work_dir = Path to PLUTO code working directory
  2. pluto_dir = Path to PLUTO source directory
  3. auto-update_def  = Boolean that indicates auto-update of defintions.h.
  4. auto-update_mkfl = Boolean that indicates auto-update of makefile.

**Output**:
  It generates a makefile for compilation.

Definition at line 9 of file make_problem.py.

9  def __init__(self, work_dir, pluto_dir, auto_update_def, auto_update_mkfl):
10  """Create the makefile for the PLUTO code from the defintions header file.
11 
12  This class creates a makefile with all necessary information
13  that would compile the code based on the problem defined by user
14  in defintions.h file.
15  In case the makefile is already present, this class will
16  read those default values to re-create the file.
17 
18  **Inputs**:
19  1. work_dir = Path to PLUTO code working directory
20  2. pluto_dir = Path to PLUTO source directory
21  3. auto-update_def = Boolean that indicates auto-update of defintions.h.
22  4. auto-update_mkfl = Boolean that indicates auto-update of makefile.
23 
24  **Output**:
25  It generates a makefile for compilation.
26  """
27  self.work_dir = work_dir
28  self.pluto_dir = pluto_dir
29  self.auto_update = auto_update_mkfl
30  self.mkfl_name = self.work_dir+'/makefile'
31  Dp = DefineProblem(self.work_dir, self.pluto_dir, auto_update_def)
32  self.additional_files = Dp.additional_files
33  self.additional_flags = Dp.additional_flags
34  self.header_files = Dp.header_files
35  self.pluto_path = Dp.pluto_path
36  self.chomboflag = Dp.flag_dict['WITH-CHOMBO']
37 
38  self.SetArch()
39  self.row = 1
40  menu.Print ("> Generating makefile... ["+self.arch+"]", row=self.row,sleep=1)
41 
42  if self.chomboflag:
43  self.ChomboMakeVars()
44  self.makefile_template = '/Src/Templates/makefile.chombo'
45  else:
46  self.makefile_template = '/Src/Templates/makefile'
47 
48  self.UpdateMkflTemplate()
49 
50 
def __init__(self, work_dir, pluto_dir, auto_update_def, auto_update_mkfl)
Definition: make_problem.py:9

Member Function Documentation

def make_problem.MakeProblem.ChomboMakeVars (   self)
Adds CHOMBO specific vars in the Makefile.

This method of the MakeProblem class does necessary
modification to the makefile so as to accomodate
compilation of chombo (AMR) specific variables.

Definition at line 79 of file make_problem.py.

79  def ChomboMakeVars(self):
80  """Adds CHOMBO specific vars in the Makefile.
81 
82  This method of the MakeProblem class does necessary
83  modification to the makefile so as to accomodate
84  compilation of chombo (AMR) specific variables.
85  """
86  pf = pfIO.PlutoFiles(self.work_dir+'/definitions.h')
87  scrh = pf.LocateString('DIMENSIONS')
88  dims = scrh[0][1].split()[2]
89  chombo_config_string = 'DIM='+dims
90 
91  if '--with-chombo:' in sys.argv:
92  i = sys.argv.index('--with-chombo:') + 1
93  try:
94  sys.argv[1:]
95  except IndexError:
96  print "Additional Configration Details Required for '--with-chombo:' flag"
97  sys.exit()
98  else:
99  for y in sys.argv[i:]:
100  chombo_config_string += ' '+y
101 
102  self.row += 1
103  menu.Print(" - Chombo config string: "+chombo_config_string,row=self.row)
104  self.row += 1
105  menu.Print(" - creating make.vars...",row=self.row,sleep=0)
106  os.chdir(self.pluto_dir+"/Lib/Chombo-3.2/lib")
107  os.system("make "+chombo_config_string+" vars > make.vars\n")
108  os.system("cp make.vars "+self.work_dir+"\n")
109  os.chdir(self.work_dir)
110 
111 
def Print
Print a message on the screen.
Definition: menu.py:60

Here is the call graph for this function:

def make_problem.MakeProblem.SetArch (   self)
Sets the Architecture for compilation of code.

This attribute of the MakeProblem class looks for the
'ARCH' keyword in makefile and if not defined will define it
based on user's choice of the Makefile configuration
from the Config/ folder. If already defined then will use
that architecture for compilation of Makefile.

Definition at line 51 of file make_problem.py.

51  def SetArch(self):
52  """Sets the Architecture for compilation of code.
53 
54  This attribute of the MakeProblem class looks for the
55  'ARCH' keyword in makefile and if not defined will define it
56  based on user's choice of the Makefile configuration
57  from the Config/ folder. If already defined then will use
58  that architecture for compilation of Makefile.
59  """
60  mkfl_exits = os.path.exists(self.mkfl_name)
61  if mkfl_exits:
62  pf = pfIO.PlutoFiles(self.mkfl_name)
63  scrh = pf.LocateString('ARCH')
64 
65  if self.auto_update == 0 or not mkfl_exits or len(scrh[0]) == 0:
66  def_list = []
67  entries = os.listdir(self.pluto_dir + '/Config')
68  for def_file in entries:
69  if (def_file.endswith('.defs')): def_list.append(def_file)
70 
71  def_list.sort()
72  menu.SetTitle("Change makefile")
73  self.arch = menu.Browse(def_list)
74  self.arch_string = 'ARCH = '+ self.arch + '\n'
75  else:
76  self.arch_string = scrh[0][1]
77  self.arch = self.arch_string.split()[2]
78 
def SetTitle
Definition: menu.py:50
def Browse
Browse a menu with entries (1st column) and default (2nd column, optional) Note: with Python > 2...
Definition: menu.py:181

Here is the call graph for this function:

def make_problem.MakeProblem.UpdateMkflTemplate (   self)
Updates Makefile with additional flags, files and modular makefile paths.

Definition at line 112 of file make_problem.py.

113  """
114  Updates Makefile with additional flags, files and modular makefile paths.
115  """
116  shutil.copy(self.pluto_dir + self.makefile_template, self.mkfl_name)
117  pf = pfIO.PlutoFiles(self.mkfl_name)
118  pf.ReplaceWord('PLUTO_DIR','PLUTO_DIR = '+self.pluto_dir+'\n',DelOld=True)
119  pf.ReplaceWord('ARCH',self.arch_string, DelOld=True)
120 
121  scrh = pf.LocateString('Additional_header_files_here')
122  ipos = scrh[0][0] + 3
123  for x in self.header_files:
124  pf.InsertLine('HEADERS += '+ x +'\n',ipos)
125  ipos = ipos + 1
126 
127  scrh = pf.LocateString('Additional_object_files_here')
128  ipos = scrh[0][0] + 3
129  for x in self.additional_files:
130  pf.InsertLine('OBJ += '+x + '\n', ipos)
131  ipos = ipos + 1
132 
133  for x in self.pluto_path:
134  pf.InsertLine('include $(SRC)/' + x + 'makefile' + '\n',ipos)
135  ipos = ipos + 1
136 
137  for x in self.additional_flags:
138  pf.InsertLine('CFLAGS += '+x+'\n', ipos)
139  ipos = ipos + 1
140 

Member Data Documentation

make_problem.MakeProblem.additional_files

Definition at line 32 of file make_problem.py.

make_problem.MakeProblem.additional_flags

Definition at line 33 of file make_problem.py.

make_problem.MakeProblem.arch

Definition at line 73 of file make_problem.py.

make_problem.MakeProblem.arch_string

Definition at line 74 of file make_problem.py.

make_problem.MakeProblem.auto_update

Definition at line 29 of file make_problem.py.

make_problem.MakeProblem.chomboflag

Definition at line 36 of file make_problem.py.

make_problem.MakeProblem.header_files

Definition at line 34 of file make_problem.py.

make_problem.MakeProblem.makefile_template

Definition at line 44 of file make_problem.py.

make_problem.MakeProblem.mkfl_name

Definition at line 30 of file make_problem.py.

make_problem.MakeProblem.pluto_dir

Definition at line 28 of file make_problem.py.

make_problem.MakeProblem.pluto_path

Definition at line 35 of file make_problem.py.

make_problem.MakeProblem.row

Definition at line 39 of file make_problem.py.

make_problem.MakeProblem.work_dir

Definition at line 27 of file make_problem.py.


The documentation for this class was generated from the following file: