From 7d63b88ee6958e3916621dcbe17cb465ea4b88f4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 11 Oct 2010 19:43:14 +0200 Subject: [PATCH] Improved parallel compilation : separated modules and subroutines Version:1.1.57 --- src/irp_stack.py | 1 + src/makefile.py | 18 ++++++++++++------ src/module.py | 21 +++++++++++++-------- src/modules.py | 13 ++++++++++++- src/version.py | 2 +- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/irp_stack.py b/src/irp_stack.py index 1046e47..1c347c3 100644 --- a/src/irp_stack.py +++ b/src/irp_stack.py @@ -105,6 +105,7 @@ end subroutine allocate(irp_stack(STACKMAX,nthread+1)) allocate(irp_cpu(STACKMAX,nthread+1)) allocate(stack_index(nthread+1)) + stack_index = 0 alloc = .True. endif stack_index(ithread+1) = stack_index(ithread+1)+1 diff --git a/src/makefile.py b/src/makefile.py index 2819e9b..3350d93 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -72,19 +72,21 @@ def run(): result += " %sirp_touches.irp.F90"%(irpdir) for m in mod: result += " %s%s.irp.F90"%(irpdir,m.name[:-4]) + result += " %s%s.irp.module.F90"%(irpdir,m.name[:-4]) print >>file, result result = "OBJ += %sirp_stack.irp.o"%(irpdir) for m in mod: if not m.is_main: result += " %s%s.irp.o"%(irpdir,m.name[:-4]) + result += " %s%s.irp.module.o"%(irpdir,m.name[:-4]) print >>file, result print >>file, "OBJ1 = $(patsubst %%, %s%%,$(notdir $(OBJ))) %sirp_touches.irp.o"%(irpdir,irpdir) all = filter(lambda x: modules[x].is_main, modules) all = map(lambda x: x[:-6], all) - all_o = map(lambda x: "%s.irp.o"%(x), all) + all_o = map(lambda x: "%s.irp.module.o %s.irp.o"%(x,x), all) print >>file, "ALL = %s"%(" ".join(all)) print >>file, "ALL_OBJ = %s"%(" ".join(all_o)) print >>file, "ALL_OBJ1 = $(patsubst %%, %s%%,$(notdir $(ALL_OBJ)))"%(irpdir) @@ -93,20 +95,20 @@ def run(): for m in mod: if m.is_main: exe = m.name[:-4] - print >>file, "%s: %s%s.irp.o $(OBJ1)"%(exe,irpdir,exe) - print >>file, "\t$(FC) -o $@ %s$@.irp.o $(OBJ1) $(LIB)"%(irpdir) + print >>file, "%s: %s%s.irp.o %s%s.irp.module.o $(OBJ1)"%(exe,irpdir,exe,irpdir,exe) + print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o $(OBJ1) $(LIB)"%(irpdir,irpdir) print >>file, "\t@make -s move" buffer = "" for m in mod: - filename = "%s%s.irp.o:"%(irpdir,m.name[:-4]) - mds = map (lambda x: " %s%s.irp.o"%(irpdir,x[:-4]),m.needed_modules) + filename = "%s%s.irp.o: %s%s.irp.module.o"%(irpdir,m.name[:-4],irpdir,m.name[:-4]) + mds = map (lambda x: " %s%s.irp.module.o"%(irpdir,x[:-4]),m.needed_modules) print >>file, filename+" ".join(mds) if not m.is_main: buffer += "\t - @echo '"+filename+" ".join(mds)+"' >> %sdist_Makefile\n"%(irpdir) print >>file, "%sirp_touches.irp.o:"%(irpdir), mds = filter(lambda x: not x.is_main,mod) - mds = map(lambda x: " %s%s.irp.o"%(irpdir,x.name[:-4]),mds) + mds = map(lambda x: " %s%s.irp.o %s%s.irp.o"%(irpdir,x.name[:-4],irpdir,x.name[:-4]),mds) print >>file," ".join(mds) @@ -137,6 +139,10 @@ def run(): print >>file, "\t- @cp %s$*.irp.F90 dist/$*/| DO_NOTHING="%(irpdir) print >>file, "\t- cd dist ; tar -zcvf ../$*.tar.gz $*\n" + print >>file, irpdir+"%.irp.module.o: "+irpdir+"%.irp.module.F90" + print >>file, "\t$(FC) $(FCFLAGS) -c "+irpdir+"$*.irp.module.F90 -o "+irpdir+"$*.irp.module.o" + print >>file, irpdir+"%.irp.o: "+irpdir+"%.irp.module.o "+irpdir+"%.irp.F90" + print >>file, "\t$(FC) $(FCFLAGS) -c "+irpdir+"$*.irp.F90 -o "+irpdir+"$*.irp.o" print >>file, irpdir+"%.irp.o: "+irpdir+"%.irp.F90" print >>file, "\t$(FC) $(FCFLAGS) -c "+irpdir+"$*.irp.F90 -o "+irpdir+"$*.irp.o" print >>file, irpdir+"%.o: %.F90" diff --git a/src/module.py b/src/module.py index c17ca34..c03deb4 100644 --- a/src/module.py +++ b/src/module.py @@ -34,6 +34,16 @@ from util import * class Fmodule(object): + header = \ + [ "! -*- F90 -*-", + "!", + "!-----------------------------------------------!", + "! This file was generated with the irpf90 tool. !", + "! !", + "! DO NOT MODIFY IT BY HAND !", + "!-----------------------------------------------!", + "" ] + def __init__(self,text,filename): self.text = put_info(text,filename) self.name = "%s_mod"%(filename[:-6]) @@ -62,16 +72,10 @@ class Fmodule(object): return self._variables variables = property(variables) + def head(self): if '_head' not in self.__dict__: - result = [ "! -*- F90 -*-", - "!", - "!-----------------------------------------------!", - "! This file was generated with the irpf90 tool. !", - "! !", - "! DO NOT MODIFY IT BY HAND !", - "!-----------------------------------------------!", - "", "module %s"%(self.name) ] + result = [ "module %s"%(self.name) ] result += self.use result += self.dec result += flatten( map(lambda x: variables[x].header,self.variables) ) @@ -209,6 +213,7 @@ class Fmodule(object): needed_modules = property(needed_modules) ###################################################################### + if __name__ == '__main__': from parsed_text import parsed_text for filename, text in parsed_text: diff --git a/src/modules.py b/src/modules.py index 258673b..1231e44 100644 --- a/src/modules.py +++ b/src/modules.py @@ -41,8 +41,19 @@ modules = create_modules() ###################################################################### def write_module(m): + # Module data + filename = irpdir+m.name[0:-4]+".irp.module.F90" + text = m.header + m.head + text = map(lambda x: "%s\n"%(x),text) + if not same_file(filename,text): + print filename + file = open(filename,"w") + file.writelines(text) + file.close() + + # Subroutines filename = irpdir+m.name[0:-4]+".irp.F90" - text = m.head + m.generated_text + m.residual_text + 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 diff --git a/src/version.py b/src/version.py index 2cc23d7..7ad8ece 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.56" +version = "1.1.57"