From c9c5f87fdc558032dab2465a580fd7e839301bb8 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 22 Oct 2009 13:32:51 +0200 Subject: [PATCH] Added -o option to check where the code can be optimized Version:1.1.41 --- example/Makefile | 2 +- example/input.irp.f | 3 --- src/command_line.py | 1 + src/parsed_text.py | 20 ++++++++++++++++++++ src/version.py | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/example/Makefile b/example/Makefile index 0612439..4602bb7 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,6 +1,6 @@ IRPF90 = irpf90 #-a -d FC = gfortran -FCFLAGS= -ffree-line-length-none -O2 +FCFLAGS= -O2 SRC= OBJ= diff --git a/example/input.irp.f b/example/input.irp.f index 2eee5bf..e41611b 100644 --- a/example/input.irp.f +++ b/example/input.irp.f @@ -12,8 +12,5 @@ for i in range(1,6): print " ASSERT ( d%d > d%d )"%(i,i-1) END_SHELL - print *, & - 'ceci est un ' & - //'test' END_PROVIDER diff --git a/src/command_line.py b/src/command_line.py index 8186cd0..de9531e 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -36,6 +36,7 @@ options['a'] = [ 'assert' , 'Activate assertions', 0 ] options['h'] = [ 'help' , 'Print this help', 0 ] options['i'] = [ 'init' , 'Initialize current directory', 0 ] options['D'] = [ 'define' , 'Define variable', 1 ] +options['o'] = [ 'checkopt' , 'Show where optimization may be required', 0 ] options['p'] = [ 'preprocess' , 'Preprocess file', 1 ] class CommandLine(object): diff --git a/src/parsed_text.py b/src/parsed_text.py index 78f145e..41d83d3 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -440,6 +440,26 @@ for filename,text in parsed_text: result.append ( (filename,text) ) parsed_text = result +###################################################################### +from command_line import command_line + +def check_opt(): + if not command_line.do_checkopt: + return + + for filename, text in parsed_text: + do_level = 0 + for vars,line in text: + if do_level > 0 and vars != []: + print "Optimization: %s line %d"%(line.filename,line.i) + for v in vars: + print " PROVIDE ",v + if isinstance(line,Do): + do_level += 1 + elif isinstance(line,Enddo): + do_level -= 1 +check_opt() + ###################################################################### if __name__ == '__main__': for i in range(len(parsed_text)): diff --git a/src/version.py b/src/version.py index dadb024..fef004d 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.40" +version = "1.1.41"