From 91ac0ac940d22305d2fb8b83235e56443af01133 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 7 Dec 2012 15:12:10 +0100 Subject: [PATCH] IRP_ALIGN introduced --- src/command_line.py | 6 +++--- src/parsed_text.py | 2 +- src/preprocessed_text.py | 4 +++- src/variable.py | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/command_line.py b/src/command_line.py index c0a2d86..549b8ae 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -43,7 +43,7 @@ options['g'] = [ 'profile' , 'Generate profile code', 0 ] options['t'] = [ 'touch' , 'Display which entities are touched', 1 ] options['m'] = [ 'memory' , 'Debug memory info', 0 ] options['z'] = [ 'openmp' , 'Automatic openMP tasks (may not work)', 0 ] -options['l'] = [ 'align' , 'Align arrays using compiler directives', 1 ] +options['l'] = [ 'align' , 'Align arrays using compiler directives. Sets the $IRP_ALIGN variable', 1 ] options['s'] = [ 'substitute' , 'Substitute values for loop max values', 1 ] options['r'] = [ 'no_directives', 'Ignore compiler directives !DEC$ and !DIR$', 0 ] options['n'] = [ 'inline' , 'all|providers|builders : Force inlining of providers or builders', 1 ] @@ -106,10 +106,10 @@ class CommandLine(object): def align(self): if '_align' not in self.__dict__: - self._align = 0 + self._align = '1' for o,a in self.opts: if o in [ "-l", '--'+options['l'][0] ]: - self._align = int(a) + self._align = a return self._align align = property(fget=align) diff --git a/src/parsed_text.py b/src/parsed_text.py index 0171740..6338061 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -526,7 +526,7 @@ def perform_loop_substitutions(): result = [] append = result.append for vars,line in text: - if type(line) in [ Do, If, Elseif] : + if type(line) in [ Do, If, Elseif ] : for k,v in command_line.substituted.items(): reg = v[1] while reg.search(line.text) is not None: diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 576e455..cb92b13 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -96,8 +96,9 @@ def get_type (i, filename, line, is_doc): assert type(is_doc) == bool line = line.rstrip() + line = line.replace("$IRP_ALIGN",command_line.align) lower_line0 = line.lstrip().lower() - lower_line = lower_line0.replace("!"," ! ") + lower_line = lower_line0.replace("!"," ! ") # Replacements lower_line = re_elseif.sub("elseif",lower_line) @@ -106,6 +107,7 @@ def get_type (i, filename, line, is_doc): lower_line = re_endmodule.sub("endmodule",lower_line) lower_line = re_endif.sub("endif",lower_line) lower_line = re_endselect.sub("endselect",lower_line) + for c in """()'"[]""": lower_line = lower_line.replace(c," "+c+" ") diff --git a/src/variable.py b/src/variable.py index 8608f5d..bd7a6dc 100644 --- a/src/variable.py +++ b/src/variable.py @@ -233,8 +233,8 @@ class Variable(object): if '_header' not in self.__dict__: name = self.name 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.dim != [] and command_line.align != '1': + self._header += [" !DIR$ ATTRIBUTES ALIGN: %s :: %s"%(command_line.align,name)] if self.is_main: self._header += [ " logical :: %s_is_built = .False."%(name) ] return self._header