From b42f50c0c47d175325055cfe99d1b3286aab61b2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 Jul 2011 07:29:01 +0200 Subject: [PATCH 1/4] Aligned errays Version:1.1.76 --- src/preprocessed_text.py | 2 +- src/variable.py | 2 ++ src/version.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 1dff0cb..4fbab80 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -146,7 +146,7 @@ instead of if firstword.startswith("case("): return [ Case(i,line,filename) ], is_doc - if lower_line0[1:5] == "$omp": + if lower_line0[1:5] in ["$omp", "dec$", "dir$"]: return [ Openmp(i,line,filename) ], is_doc if re_decl.match(lower_line) is not None: diff --git a/src/variable.py b/src/variable.py index 7b2e847..02d4654 100644 --- a/src/variable.py +++ b/src/variable.py @@ -231,6 +231,8 @@ class Variable(object): self._header = [ " %s :: %s %s"%(self.type, name, build_dim_colons(self) ) ] if self.is_main: self._header += [ " logical :: %s_is_built = .False."%(name) ] + if "allocatable" in self.type: + self._header += ["!DEC$ ATTRIBUTES ALIGN: 32 :: %s"%(name)] return self._header header = property(header) diff --git a/src/version.py b/src/version.py index 7264fb1..45ef7ce 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.75" +version = "1.1.76" From f265c48e8ba3af0ccf6fc8489988253e424372ae Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 18 Jul 2011 11:31:18 +0200 Subject: [PATCH 2/4] Minor modification Version:1.1.77 --- src/variable.py | 2 +- src/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/variable.py b/src/variable.py index 02d4654..05e9f21 100644 --- a/src/variable.py +++ b/src/variable.py @@ -231,7 +231,7 @@ class Variable(object): self._header = [ " %s :: %s %s"%(self.type, name, build_dim_colons(self) ) ] if self.is_main: self._header += [ " logical :: %s_is_built = .False."%(name) ] - if "allocatable" in self.type: + if self.dim != []: self._header += ["!DEC$ ATTRIBUTES ALIGN: 32 :: %s"%(name)] return self._header header = property(header) diff --git a/src/version.py b/src/version.py index 45ef7ce..8e259e3 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.76" +version = "1.1.77" From 1e0afc9f5c170ae6c3842e678d2c58f2c95a5bbd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 4 Aug 2011 14:04:14 +0200 Subject: [PATCH 3/4] Alignment is an option (-l) and compiler directives can be disabled (-r) Version:1.2.01 --- src/command_line.py | 26 +++++++++++++++++++++++--- src/irpf90_t.py | 6 ++++++ src/parsed_text.py | 1 + src/preprocessed_text.py | 10 ++++++---- src/variable.py | 11 ++++++----- src/version.py | 2 +- 6 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/command_line.py b/src/command_line.py index 5c79137..da43acb 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -41,6 +41,8 @@ options['p'] = [ 'preprocess' , 'Preprocess file', 1 ] 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['r'] = [ 'no_directives', 'Ignore compiler directives !DEC$ and !DIR$', 0 ] class CommandLine(object): @@ -54,7 +56,7 @@ class CommandLine(object): if '_defined' not in self.__dict__: self._defined = [] for o,a in self.opts: - if o in [ "-D", options['D'][0] ]: + if o in [ "-D", '--'+options['D'][0] ]: self._defined.append(a) return self._defined defined = property(fget=defined) @@ -63,7 +65,7 @@ class CommandLine(object): if '_preprocessed' not in self.__dict__: self._preprocessed = [] for o,a in self.opts: - if o in [ "-p", options['p'][0] ]: + if o in [ "-p", '--'+options['p'][0] ]: self._preprocessed.append(a) return self._preprocessed preprocessed = property(fget=preprocessed) @@ -72,11 +74,29 @@ class CommandLine(object): if '_touched' not in self.__dict__: self._touched = [] 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()) return self._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): t = """ $EXE - $DESCR diff --git a/src/irpf90_t.py b/src/irpf90_t.py index 7ff70c0..7508034 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -197,6 +197,12 @@ class Openmp(Line): def __repr__(self): 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): def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) diff --git a/src/parsed_text.py b/src/parsed_text.py index c8a0380..8902fe1 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -134,6 +134,7 @@ def get_parsed_text(): Begin_shell, End_shell, Openmp, + Directive, Use, Enddo, End_select, diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 4fbab80..83b4d5e 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -146,8 +146,10 @@ instead of if firstword.startswith("case("): return [ Case(i,line,filename) ], is_doc - if lower_line0[1:5] in ["$omp", "dec$", "dir$"]: + if lower_line0[1:5] == "$omp": 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 "function" in buffer[1:3]: @@ -321,7 +323,7 @@ def form(text): re2 = re.compile(r"^\s*[!#]") re3 = re.compile(r"^\s*[^ 0-9]+") for line in text: - if type(line) in [ Empty_line, Doc, Openmp ]: + if type(line) in [ Empty_line, Doc, Openmp, Directive ]: pass else: if len(line.text) > 5: @@ -368,7 +370,7 @@ def remove_comments(text,form): if form == Free_form: for line in text: - if type(line) in [ Openmp, Doc] : + if type(line) in [ Openmp, Doc, Directive] : result.append(line) elif type(line) == Empty_line: pass @@ -382,7 +384,7 @@ def remove_comments(text,form): return result else: for line in text: - if type(line) in [ Openmp, Doc ]: + if type(line) in [ Openmp, Doc, Directive ]: result.append(line) elif type(line) == Empty_line: pass diff --git a/src/variable.py b/src/variable.py index 05e9f21..b1d02b5 100644 --- a/src/variable.py +++ b/src/variable.py @@ -229,10 +229,10 @@ 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.is_main: self._header += [ " logical :: %s_is_built = .False."%(name) ] - if self.dim != []: - self._header += ["!DEC$ ATTRIBUTES ALIGN: 32 :: %s"%(name)] return self._header header = property(header) @@ -460,12 +460,13 @@ class Variable(object): result = " allocate(%s(%s),stat=irp_err)" result = result%(name,','.join(self.dim)) if command_line.do_memory: - tmp = "\n print *, 'Allocating %s(%s), (',%s,')'" + tmp = "\n print *, %s, 'Allocating %s(%s), (',%s,')'" d = ','.join(self.dim) + d2 = '*'.join(self.dim) if ":" in d: - result += tmp%(name,d,"''") + result += tmp%('-1',name,d,"''") else: - result += tmp%(name,d,d) + result += tmp%(d2,name,d,d) return result result = [ " if (allocated (%s) ) then"%(name) ] diff --git a/src/version.py b/src/version.py index 8e259e3..766b517 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.77" +version = "1.2.01" From 162465f0b756706c52ff1ef3fca1538c59970ef9 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 17 Aug 2011 12:17:12 +0200 Subject: [PATCH 4/4] Nothing Version:1.2.2 --- src/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.py b/src/version.py index 766b517..2be6f8b 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.2.01" +version = "1.2.2"