From 452b20c40b59a284c6b442d8d54b34dbe35d012e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 1 Jun 2015 14:56:41 +0200 Subject: [PATCH] Less printing --- src/command_line.py | 10 ++++++++++ src/error.py | 4 ++++ src/init.py | 3 ++- src/modules.py | 4 ++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/command_line.py b/src/command_line.py index 18ce6ae..d6dc093 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -50,6 +50,7 @@ options['r'] = [ 'no_directives', 'Ignore all compiler directives !DEC$ and !DIR options['s'] = [ 'substitute' , 'Substitute values in do loops for generating specific optimized code.', 1 ] options['t'] = [ 'touch' , 'Display which entities are touched when touching the variable given as an argument.', 1 ] options['v'] = [ 'version' , 'Prints version of irpf90', 0 ] +options['w'] = [ 'warnings' , 'Activate Warnings', 0 ] options['z'] = [ 'openmp' , 'Activate for OpenMP code', 0 ] class CommandLine(object): @@ -161,6 +162,15 @@ or return self._coarray coarray = property(fget=coarray) + def warnings(self): + if '_warnings' not in self.__dict__: + self._warnings= False + for o,a in self.opts: + if o in [ "-w", '--'+options['w'][0] ]: + self._warnings= True + return self._warnings + do_warnings = property(fget=warnings) + def openmp(self): if '_openmp' not in self.__dict__: self._openmp = False diff --git a/src/error.py b/src/error.py index 42580b1..811759c 100644 --- a/src/error.py +++ b/src/error.py @@ -27,6 +27,8 @@ import sys from irpf90_t import * +from command_line import command_line +do_warnings = command_line.do_warnings ###################################################################### def fail(line,message): @@ -43,6 +45,8 @@ Error: ###################################################################### def warn(line,message): + if not command_line.do_warnings: + return if line is not None: assert isinstance(line,Line) print """ diff --git a/src/init.py b/src/init.py index a33b7d5..cf46025 100644 --- a/src/init.py +++ b/src/init.py @@ -75,7 +75,8 @@ def init(): try: file = open(filename,"r") except IOError: - print "Warning : Unable to read file %s."%(filename) + if command_line.do_warnings: + print "Warning : Unable to read file %s."%(filename) else: buffer = file.read() file.close() diff --git a/src/modules.py b/src/modules.py index 6457820..9a18051 100644 --- a/src/modules.py +++ b/src/modules.py @@ -46,7 +46,7 @@ def write_module(m): text = m.header + m.head text = map(lambda x: "%s\n"%(x),text) if not same_file(filename,text): - print filename +# print filename file = open(filename,"w") file.writelines(text) file.close() @@ -56,7 +56,7 @@ def write_module(m): text = m.header + m.generated_text + m.residual_text text = map(lambda x: "%s\n"%(x),text) if not same_file(filename,text): - print filename +# print filename file = open(filename,"w") file.writelines(text) file.close()