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 1dff0cb..83b4d5e 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -148,6 +148,8 @@ instead of 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 7b2e847..b1d02b5 100644 --- a/src/variable.py +++ b/src/variable.py @@ -229,6 +229,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.is_main: self._header += [ " logical :: %s_is_built = .False."%(name) ] return self._header @@ -458,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 7264fb1..2be6f8b 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.75" +version = "1.2.2"