10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-12-22 12:23:32 +01:00

Merge branch 'master' of ssh://irpf90.git.sourceforge.net/gitroot/irpf90/irpf90

This commit is contained in:
Anthony Scemama 2011-08-17 12:19:15 +02:00
commit b43edb99c5
6 changed files with 42 additions and 10 deletions

View File

@ -41,6 +41,8 @@ options['p'] = [ 'preprocess' , 'Preprocess file', 1 ]
options['t'] = [ 'touch' , 'Display which entities are touched', 1 ] options['t'] = [ 'touch' , 'Display which entities are touched', 1 ]
options['m'] = [ 'memory' , 'Debug memory info', 0 ] options['m'] = [ 'memory' , 'Debug memory info', 0 ]
options['z'] = [ 'openmp' , 'Automatic openMP tasks (may not work)', 0 ] options['z'] = [ 'openmp' , 'Automatic openMP tasks (may not work)', 0 ]
options['l'] = [ 'align' , 'Align arrays using compiler directives', 1 ]
options['r'] = [ 'no_directives', 'Ignore compiler directives !DEC$ and !DIR$', 0 ]
class CommandLine(object): class CommandLine(object):
@ -54,7 +56,7 @@ class CommandLine(object):
if '_defined' not in self.__dict__: if '_defined' not in self.__dict__:
self._defined = [] self._defined = []
for o,a in self.opts: for o,a in self.opts:
if o in [ "-D", options['D'][0] ]: if o in [ "-D", '--'+options['D'][0] ]:
self._defined.append(a) self._defined.append(a)
return self._defined return self._defined
defined = property(fget=defined) defined = property(fget=defined)
@ -63,7 +65,7 @@ class CommandLine(object):
if '_preprocessed' not in self.__dict__: if '_preprocessed' not in self.__dict__:
self._preprocessed = [] self._preprocessed = []
for o,a in self.opts: for o,a in self.opts:
if o in [ "-p", options['p'][0] ]: if o in [ "-p", '--'+options['p'][0] ]:
self._preprocessed.append(a) self._preprocessed.append(a)
return self._preprocessed return self._preprocessed
preprocessed = property(fget=preprocessed) preprocessed = property(fget=preprocessed)
@ -72,11 +74,29 @@ class CommandLine(object):
if '_touched' not in self.__dict__: if '_touched' not in self.__dict__:
self._touched = [] self._touched = []
for o,a in self.opts: for o,a in self.opts:
if o in [ "-t", options['t'][0] ]: if o in [ "-t", '--'+options['t'][0] ]:
self._touched.append(a.lower()) self._touched.append(a.lower())
return self._touched return self._touched
touched = property(fget=touched) touched = property(fget=touched)
def align(self):
if '_align' not in self.__dict__:
self._align = 0
for o,a in self.opts:
if o in [ "-l", '--'+options['l'][0] ]:
self._align = int(a)
return self._align
align = property(fget=align)
def directives(self):
if '_directives' not in self.__dict__:
self._directives = True
for o,a in self.opts:
if o in [ "-r", '--'+options['r'][0] ]:
self._directives = False
return self._directives
directives = property(fget=directives)
def usage(self): def usage(self):
t = """ t = """
$EXE - $DESCR $EXE - $DESCR

View File

@ -197,6 +197,12 @@ class Openmp(Line):
def __repr__(self): def __repr__(self):
return "%20s:%5d : %s"%("Openmp",self.i,self.text) return "%20s:%5d : %s"%("Openmp",self.i,self.text)
class Directive(Line):
def __init__(self,i,text,filename):
Line.__init__(self,i,text,filename)
def __repr__(self):
return "%20s:%5d : %s"%("Directive",self.i,self.text)
class Use(Line): class Use(Line):
def __init__(self,i,text,filename): def __init__(self,i,text,filename):
Line.__init__(self,i,text,filename) Line.__init__(self,i,text,filename)

View File

@ -134,6 +134,7 @@ def get_parsed_text():
Begin_shell, Begin_shell,
End_shell, End_shell,
Openmp, Openmp,
Directive,
Use, Use,
Enddo, Enddo,
End_select, End_select,

View File

@ -148,6 +148,8 @@ instead of
if lower_line0[1:5] == "$omp": if lower_line0[1:5] == "$omp":
return [ Openmp(i,line,filename) ], is_doc return [ Openmp(i,line,filename) ], is_doc
elif lower_line0[1:5] in ["dec$", "dir$"] and command_line.directives:
return [ Directive(i,line,filename) ], is_doc
if re_decl.match(lower_line) is not None: if re_decl.match(lower_line) is not None:
if "function" in buffer[1:3]: if "function" in buffer[1:3]:
@ -321,7 +323,7 @@ def form(text):
re2 = re.compile(r"^\s*[!#]") re2 = re.compile(r"^\s*[!#]")
re3 = re.compile(r"^\s*[^ 0-9]+") re3 = re.compile(r"^\s*[^ 0-9]+")
for line in text: for line in text:
if type(line) in [ Empty_line, Doc, Openmp ]: if type(line) in [ Empty_line, Doc, Openmp, Directive ]:
pass pass
else: else:
if len(line.text) > 5: if len(line.text) > 5:
@ -368,7 +370,7 @@ def remove_comments(text,form):
if form == Free_form: if form == Free_form:
for line in text: for line in text:
if type(line) in [ Openmp, Doc] : if type(line) in [ Openmp, Doc, Directive] :
result.append(line) result.append(line)
elif type(line) == Empty_line: elif type(line) == Empty_line:
pass pass
@ -382,7 +384,7 @@ def remove_comments(text,form):
return result return result
else: else:
for line in text: for line in text:
if type(line) in [ Openmp, Doc ]: if type(line) in [ Openmp, Doc, Directive ]:
result.append(line) result.append(line)
elif type(line) == Empty_line: elif type(line) == Empty_line:
pass pass

View File

@ -229,6 +229,8 @@ class Variable(object):
if '_header' not in self.__dict__: if '_header' not in self.__dict__:
name = self.name name = self.name
self._header = [ " %s :: %s %s"%(self.type, name, build_dim_colons(self) ) ] self._header = [ " %s :: %s %s"%(self.type, name, build_dim_colons(self) ) ]
if self.dim != [] and command_line.align > 0:
self._header += [" !DIR$ ATTRIBUTES ALIGN: %d :: %s"%(command_line.align,name)]
if self.is_main: if self.is_main:
self._header += [ " logical :: %s_is_built = .False."%(name) ] self._header += [ " logical :: %s_is_built = .False."%(name) ]
return self._header return self._header
@ -458,12 +460,13 @@ class Variable(object):
result = " allocate(%s(%s),stat=irp_err)" result = " allocate(%s(%s),stat=irp_err)"
result = result%(name,','.join(self.dim)) result = result%(name,','.join(self.dim))
if command_line.do_memory: if command_line.do_memory:
tmp = "\n print *, 'Allocating %s(%s), (',%s,')'" tmp = "\n print *, %s, 'Allocating %s(%s), (',%s,')'"
d = ','.join(self.dim) d = ','.join(self.dim)
d2 = '*'.join(self.dim)
if ":" in d: if ":" in d:
result += tmp%(name,d,"''") result += tmp%('-1',name,d,"''")
else: else:
result += tmp%(name,d,d) result += tmp%(d2,name,d,d)
return result return result
result = [ " if (allocated (%s) ) then"%(name) ] result = [ " if (allocated (%s) ) then"%(name) ]

View File

@ -1 +1 @@
version = "1.1.75" version = "1.2.2"