From 1b3924c615d506b25f57c83b3fda1df4441135ba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 9 Jul 2013 17:05:56 +0200 Subject: [PATCH 01/23] Bug introduced in previous commit. Corrected --- README | 1 + man/man1/irpf90.1.gz | Bin 1320 -> 1318 bytes packages/Makefile | 2 +- src/command_line.py | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README b/README index 789b34a..da145fc 100644 --- a/README +++ b/README @@ -19,6 +19,7 @@ ${IRPF90_HOME} is the location of your irpf90 directory:: cat << EOF >> ${HOME}/.bash_profile export PYTHONPATH=${IRPF90_HOME}/src:${PYTHONPATH} export PATH=${IRPF90_HOME}/bin:${PATH} + export MANPATH=${IRPF90_HOME}/man:${MANPATH} EOF diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz index 1342fca6f0e8255fa10eb82049f5491493b24c5e..5ec373ad8f5aeb42e429a59c293bd61569c028f8 100644 GIT binary patch literal 1318 zcmV+>1=;!^iwFoWHrr7E18H(_W;rk}F#wfTZExE)5dO|zaSbw{#bU*FQEW9ZU|#Gt z23p6koDV}46tr}*iAbbIQg&VR$M24kUz$4D`XLTq?)AC5hl-L5_$W10a)q!$jaGWh zAh)Iji?O$L>T8SH0>Ai3MB@EH#OML^yS>**r~4cI{SN)!;LTgOU))4OM2lOP%xCZ3 zcA*Cs7jV&w`d#{WA)@#ero)e8(OxGVcxSA)9D_A0E6Y;p71WM@CuLQrRC$gr{ zdJv5YAD*+dzi*@mXXKvMd=MS+<7M~Z%wg}`VgEryZ61^9Xgpnrh$bFGYWM`l$tpHdwMsEC$Wf{grOUC59`;_8=-8KQ-gmpl~+bPa&^S!xFSoVaeOnM z%odZosfb*)SLAuvs0Y&%TiMBxfHN`hbGf6f!U zq^W!bv{{=h5@ZXYG!_9e^imb>3WybC7L57Y8>?ginetXGYbJ%Q^6PL}$@GyZMUaJ! za^x||C&@2s@2kP}b(3IJS1#%J!eNx#B%cK=?g9)?KwZ$?U&It6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qy&}!SMyA37@Mp6j)J7VuN{5b(3IFS2pgs!ipd>aW?l@+KKwaY9U&s^_bRYNPUMe!F1e^GO z7SY*o3}jUZkW?xHB8AnC0wJ3D621rPkhBOf8yxNN)*iQ37{|tmlN%JXFpi?>V%b%K zFay4_xV~aWlzJo12puh_he%iTx?|Yy16U$L3NZ(r`5=?p7^CZ&Kx^E3 z6SwmRaI&PTArdK0tVNGLvR0*&+PX~*|LB-m6aw5}kH6^Hwt#MaAZn1xiT^ zet(dXt&~*Ku@HZ-#pE|M)?$=OBNFVqT>!V(i{zLy>(ln_kk*T=Z zv8^^w6x&`Ohouu+v2TS!t`!^8FK}b{&bCicqRR>mn^s?Lgk|K!3fF*mNu4(S7=D-? z+A*MMWa2Bwu|w1k_W!sUf?r_hR0Z#cVLdtE&1&ZataMFP-E~4N+Yn1^Kg_2Au-T9q zop8@H*Qx02I{NAWY(dk5Lf`kjWxua#SsizF0X$fd)dgfkS$@jaR5cQ}EYS+ti?RWmQ{UUf$m-d^nl=EXzjO*5t`)H#73oa< z;mu@vd+EF2%_Ll09={m{TMB1uAY@64BDA3Vczzt!A0>sQn3(RlG0X6J_G}oAnA}+vZ17GKw z$gJb4Ze7)?#tO83*KCfRaTMRQ;u}20n(yn_ZiyNi`agLDqv;gJAEWz|=X4J7+f@xi zdKB?7?w Date: Thu, 11 Jul 2013 00:40:20 +0200 Subject: [PATCH 02/23] Openmp bug Version:1.2.21 --- src/command_line.py | 1 + src/preprocessed_text.py | 1 - src/version.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command_line.py b/src/command_line.py index 4aba685..f25e81b 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -51,6 +51,7 @@ options['u'] = [ 'unused' , 'Print unused providers', 0 ] class CommandLine(object): + do_openmp = False def __init__(self): global options self._opts = None diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 5d47938..50a4652 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -671,7 +671,6 @@ def change_includes(text): if type(line) == Include: txt = line.text.replace('"',"'").split("'") if len(txt) != 3: - print txt error.fail(line,"Error in include statement") filename = txt[1].strip() try: diff --git a/src/version.py b/src/version.py index ea274a4..6d399f3 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.2.20" +version = "1.2.21" From b0d955cb854819184e8d08e99ea40a11ff40bcec Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 3 Oct 2013 11:20:58 +0200 Subject: [PATCH 03/23] Bug in makefile with cython --- man/man1/irpf90.1.gz | Bin 1318 -> 1317 bytes src/Makefile | 2 +- src/version.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz index 5ec373ad8f5aeb42e429a59c293bd61569c028f8..ebc370e27a0ecd8ca7bdfe3afc100803b37f715f 100644 GIT binary patch delta 1298 zcmV+t1?~E#3Z)7zABzYG7bo0N00U`qaAr9$E-?U=R&8(FHW2>KUvUdEpu=LtPEiy! zFkoKnwgQnZC4bTj_$W2ha)q!$jaGWhp|GX`i;1^Q<{OLo0>Ai3MB?2+#ONX1^an4~ zUjH@yy@A22VgEJUFK#0tqQ!fN=d-tO`Y?ct3%D3WH+}kdA)@3xOh+FlqPtFe@YYyw zIRaGR8sep&Qbebi5o1T z&zCt4_;!vp`S>X9N@$;>XMW!#3Ffoa?zORL-2SXZO5kS{nvf_paq{={ZkEJ}h}wjqAN3FG zm(eSsY+X=;e=@aKMmutK#OAmnOXEp$JCA3J_--m9SML>h9yTgR2Oz(j4b&TDjjkBg z?OJ7PaEb?|P$b(8lQ>bhf{l{k*Z80F1TSbRe}4notW6#XvIS5XivT%#sY-VR#0oMG z#(d+ARkDO!d8?KUlfqW{b-1i$_DGZ>$ihZB@|YHJ`s>>JdU$=^CKxrfOMAX_7!@`x zW&w-40K*ed7j*X*F~ykNr@ge7W1%#Paroy5osFbGmL-DXQZW!YEO#6T)6D1iEjUl4 z#eay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YTHON=python PYVERSION=$(shell $(PYTHON) -c "import sys; print(sys.version[:3])") -HAS_CYTHON=$(shell which cython &> /dev/null && echo 1 || echo 0) +HAS_CYTHON=$(shell bash -c "which cython &> /dev/null && echo 1 || echo 0") ifneq ($(HAS_CYTHON),0) ../bin/irpf90: irpf90.exe diff --git a/src/version.py b/src/version.py index ea274a4..26ccef1 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.2.20" +version = "1.2.22" From bb41e2cd736219772c1fdb55e8cf7dae8e659b06 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 8 Nov 2013 00:08:09 +0100 Subject: [PATCH 04/23] Bug with += --- src/parsed_text.py | 1 - src/preprocessed_text.py | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/parsed_text.py b/src/parsed_text.py index 2c07ad1..a63220e 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -82,7 +82,6 @@ def check_touch(line,vars,main_vars): all_others = make_single(flatten( map(fun,main_vars) )) all_others.sort() vars.sort() - print vars for x,y in zip(vars,all_others): if x != y: message = "The following entities should be touched:\n" diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 50a4652..7e7ae4a 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -355,24 +355,15 @@ def add_operators(text): for line in text: buffer = line.text if "+=" in buffer: - if "if" in buffer: + if buffer.lstrip().startswith("if "): re_incr = re.compile(r"(.*)(\))(\s*)(.*)(\+=)(.*$)",re.S) line.text = re.sub(re_incr,r'\1\2\4=\4+(\6)', buffer) else: line.text = re.sub(re_incr,r'\1\2=\2+(\4)', buffer) elif "-=" in buffer: - if "if" in buffer: - re_decr = re.compile(r"(.*)(\))(\s*)(.*)(\-=)(.*$)",re.S) - line.text = re.sub(re_decr,r'\1\2\4=\4-(\6)', buffer) - else: - line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer) -# line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer) + line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer) elif "*=" in buffer: - if "if" in buffer: - re_mult = re.compile(r"(.*)(\))(\s*)(.*)(\*=)(.*$)",re.S) - line.text = re.sub(re_mult,r'\1\2\4=\4*(\6)', buffer) - else: - line.text = re.sub(re_mult,r'\1\2=\2*(\4)', buffer) + line.text = re.sub(re_mult,r'\1\2=\2*(\4)', buffer) result.append(line) return result @@ -671,6 +662,7 @@ def change_includes(text): if type(line) == Include: txt = line.text.replace('"',"'").split("'") if len(txt) != 3: + print txt error.fail(line,"Error in include statement") filename = txt[1].strip() try: From 57a09925e4c48c8bb884c36438563d370c2380ba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 12 Nov 2013 09:53:16 +0100 Subject: [PATCH 05/23] Added man pages --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 98226fd..31a6ddf 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,5 @@ src: $(MAKE) -C $@ man: - $(MAKE) -C $@ + - $(MAKE) -C $@ From efd67d12f96a229b6054429b7047c6bfdcb3b74a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 20 Nov 2013 17:43:03 +0100 Subject: [PATCH 06/23] Work to do --- example/input.irp.f | 22 ---------------------- src/command_line.py | 10 ++++++++++ src/irpf90_t.py | 3 +++ 3 files changed, 13 insertions(+), 22 deletions(-) delete mode 100644 example/input.irp.f diff --git a/example/input.irp.f b/example/input.irp.f deleted file mode 100644 index 2f5049a..0000000 --- a/example/input.irp.f +++ /dev/null @@ -1,22 +0,0 @@ - BEGIN_PROVIDER [ integer, d1 ] -&BEGIN_PROVIDER [ integer, d2 ] -&BEGIN_PROVIDER [ integer, d3 ] -&BEGIN_PROVIDER [ integer, d4 ] -&BEGIN_PROVIDER [ integer, d5 ] - - print *, 'd1' - read(*,*) d1 - - BEGIN_TEMPLATE - print *, '$X' - read(*,*) $X - ASSERT ( $X > $Y ) - - SUBST [ X, Y ] - d2; d1;; - d3; d2;; - d4; d3;; - d5; d4;; - END_TEMPLATE -END_PROVIDER - diff --git a/src/command_line.py b/src/command_line.py index f25e81b..11facfa 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -48,6 +48,7 @@ options['s'] = [ 'substitute' , 'Substitute values in do loops for generating options['r'] = [ 'no_directives', 'Ignore all compiler directives !DEC$ and !DIR$', 0 ] options['n'] = [ 'inline' , 'all|providers|builders : Force inlining of providers or builders', 1 ] options['u'] = [ 'unused' , 'Print unused providers', 0 ] +options['I'] = [ 'include' , 'Include directory', 1 ] class CommandLine(object): @@ -67,6 +68,15 @@ class CommandLine(object): return self._defined defined = property(fget=defined) + def include_dir(self): + if '_include_dir' not in self.__dict__: + self._include_dir = [] + for o,a in self.opts: + if o in [ "-I", '--'+options['I'][0] ]: + self._include_dir.append(a) + return self._include_dir + include_dir = property(fget=include_dir) + def inline(self): if '_inline' not in self.__dict__: self._inline = "" diff --git a/src/irpf90_t.py b/src/irpf90_t.py index 3d413e2..6aaa30a 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -349,8 +349,11 @@ def create_irpf90_files(): def is_irpf90_file(filename): return filename.endswith(".irp.f") and not filename.startswith('.') result = filter ( is_irpf90_file, os.listdir(os.getcwd()) ) + for dir in command_line.include_dir: + result += map(lambda x: dir+'/'+x, filter ( is_irpf90_file, os.listdir(dir) ) ) return result irpf90_files = create_irpf90_files() +print irpf90_files From fd3b7437928dd5d5071433660699ad9440438b48 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 11 Dec 2013 14:00:27 +0100 Subject: [PATCH 07/23] Added -I option --- bin/irpf90 | 2 +- example/Makefile | 2 +- man/man1/irpf90.1.gz | Bin 1317 -> 1328 bytes src/command_line.py | 2 ++ src/init.py | 35 ++++++++++++++++--------- src/irpf90_t.py | 3 +-- src/makefile.py | 55 ++++++++++++++++++++++----------------- src/module.py | 3 ++- src/modules.py | 4 +-- src/preprocessed_text.py | 6 ++++- src/util.py | 9 ++++--- src/variable.py | 2 +- src/version.py | 2 +- 13 files changed, 74 insertions(+), 51 deletions(-) diff --git a/bin/irpf90 b/bin/irpf90 index e537e26..d9d2360 120000 --- a/bin/irpf90 +++ b/bin/irpf90 @@ -1 +1 @@ -../src/irpf90.exe \ No newline at end of file +../src/irpf90_python.exe \ No newline at end of file diff --git a/example/Makefile b/example/Makefile index 0a69231..2b8aa7f 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,4 +1,4 @@ -IRPF90 = ~/irpf90/bin/irpf90 -a -d +IRPF90 = python ../src/irpf90.py -I input -a -d FC = gfortran FCFLAGS= -O2 diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz index ebc370e27a0ecd8ca7bdfe3afc100803b37f715f..c4212e362d156794ee4a22ccd5a1869885986dfb 100644 GIT binary patch literal 1328 zcmV-01<(2)iwFpGF{n}i18H(_W;rk}F#wfTTW{J(6n>vyaT;Z%t~NM8v=2pEY1u$q zOD#c|Jgn-d8tgHQV$XQz0;TGY-*d*skc4Qr58%0+`{g?mr5Es-E2#Nez*;C_xDz=P zMps}&;*8InHzHq(Z!TgH`_PeSHG*M(aFg~1L;MY(|88`11NY0@h_Pt-5#q)C{kuL4 z;Nk)<2GOvOp9>ZxA7M8BJZ0^5+JpDnI72oVy*9k6q*{Zw^dDDsDKqI{AqruH$^W8h&g$3YGdPAtKG+I>@)!jyB8?cfZrI1M5HWNExxPq5N=?0)?G)n{Zk4>=7Y_p@glp zs4*?#^p}lu_2~M#aWL|=O?$4iA}UN;%tI{hLKvO}b%}R>AyQ0GecDTVxhSL(Y!W^e zqqF5`$f^_|DOD7R99DZWgka`t{2r`B(4vUh=qN94z8qDQ`)+ zwZb?y&Yaw$L<{32nJ$*6@*ysOuPm;wm=TrUiZet<$$970%CAoZhkXP~45q^LfG&bR znKy?=S$@g;yDs*mYYlhV5io!V0rsq-wA_Bn9=WoEzMGS9`~H8=6g)b$N{77R#0tbB4vked%!O zJq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$i&Q+ruszBFw?dI4SNAXQ3zM)g9`M!?bmZ_no|0j=NGMT{WLvr`zIh{fJV%fkA zKZ^7ipPu}m7v(z_qx;4CySW%?dfoI6k_;>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]) + result += " %s%s.irp.o"%(irpdir,m.filename) + result += " %s%s.irp.module.o"%(irpdir,m.filename) print >>file, result - print >>file, "OBJ1 = $(patsubst %%, %s%%,$(notdir $(OBJ))) %sirp_touches.irp.o"%(irpdir,irpdir), + print >>file, "OBJ1 = $(OBJ) %sirp_touches.irp.o"%(irpdir), if command_line.do_profile: print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", if command_line.do_openmp: @@ -106,14 +110,14 @@ def run(): print >>file, "ifdef USE_IRPF90_A" for m in mod: if m.is_main: - exe = m.name[:-4] + exe = m.filename print >>file, "%s: %s%s.irp.o %s%s.irp.module.o irpf90.a"%(exe,irpdir,exe,irpdir,exe) print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o irpf90.a $(LIB)"%(irpdir,irpdir) print >>file, "\t@$(MAKE) -s move" print >>file, "else" for m in mod: if m.is_main: - exe = m.name[:-4] + exe = m.filename 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" @@ -121,14 +125,16 @@ def run(): buffer = "" for m in mod: - 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) + filename = "%s%s.irp.o: %s%s.irp.module.o"%(irpdir,m.filename,irpdir,m.filename) + needed_modules = filter( lambda x: modules[x].name in m.needed_modules, modules ) + needed_files = map(lambda x: modules[x].filename, needed_modules) + mds = map (lambda x: " %s%s.irp.module.o"%(irpdir,x),needed_files) print >>file, filename," ".join(mds)," ".join(m.includes) 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 %s%s.irp.o"%(irpdir,x.name[:-4],irpdir,x.name[:-4]),mds) + mds = map(lambda x: " %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename),mds) print >>file," ".join(mds) if command_line.do_profile: print >>file, "%sirp_profile.irp.o:"%(irpdir), @@ -165,18 +171,19 @@ 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" - print >>file, "\t$(FC) $(FCFLAGS) -c $*.F90 -o "+irpdir+"$*.o" - print >>file, irpdir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+irpdir+"$*.o" - print >>file, irpdir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+irpdir+"$*.o" - print >>file, irpdir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+irpdir+"$*.o" - print >>file, irpdir+"%.irp.F90: irpf90.make\n" + for dir in [ irpdir ] + map(lambda x: irpdir+x, command_line.include_dir): + print >>file, dir+"%.irp.module.o: "+dir+"%.irp.module.F90" + print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o" + print >>file, dir+"%.irp.o: "+dir+"%.irp.module.o "+dir+"%.irp.F90" + print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o" + print >>file, dir+"%.irp.o: "+dir+"%.irp.F90" + print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o" + print >>file, dir+"%.o: %.F90" + print >>file, "\t$(FC) $(FCFLAGS) -c $*.F90 -o "+dir+"$*.o" + print >>file, dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o" + print >>file, dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o" + print >>file, dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o" + print >>file, dir+"%.irp.F90: irpf90.make\n" print >>file, "move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n" print >>file, "irpf90.a: $(OBJ1)\n\t$(AR) crf irpf90.a $(OBJ1)\n" print >>file, "clean:\n\trm -rf $(EXE) $(OBJ1) irpf90.a $(ALL_OBJ1) $(ALL)\n" diff --git a/src/module.py b/src/module.py index 0711ed4..4bb9f49 100644 --- a/src/module.py +++ b/src/module.py @@ -46,7 +46,8 @@ class Fmodule(object): def __init__(self,text,filename): self.text = put_info(text,filename) - self.name = "%s_mod"%(filename[:-6]) + self.filename = filename[:-6] + self.name = "%s_mod"%(self.filename).replace('/','__') def is_main(self): if '_is_main' not in self.__dict__: diff --git a/src/modules.py b/src/modules.py index ec060a2..2974442 100644 --- a/src/modules.py +++ b/src/modules.py @@ -42,7 +42,7 @@ modules = create_modules() ###################################################################### def write_module(m): # Module data - filename = irpdir+m.name[0:-4]+".irp.module.F90" + filename = irpdir+m.filename+".irp.module.F90" text = m.header + m.head text = map(lambda x: "%s\n"%(x),text) if not same_file(filename,text): @@ -52,7 +52,7 @@ def write_module(m): file.close() # Subroutines - filename = irpdir+m.name[0:-4]+".irp.F90" + filename = irpdir+m.filename+".irp.F90" text = m.header + m.generated_text + m.residual_text text = map(lambda x: "%s\n"%(x),text) if not same_file(filename,text): diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 7e7ae4a..4941ea2 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -664,7 +664,11 @@ def change_includes(text): if len(txt) != 3: print txt error.fail(line,"Error in include statement") - filename = txt[1].strip() + directory = (("./"+line.filename).rsplit('/',1)[0]+'/')[2:] + if directory == "": + filename = txt[1].strip() + else: + filename = directory+txt[1].strip() try: file = open(filename,'r') file.close() diff --git a/src/util.py b/src/util.py index 54421e3..f5935d2 100644 --- a/src/util.py +++ b/src/util.py @@ -35,7 +35,10 @@ def lower(x): def same_file(filename,txt): assert isinstance(filename,str) - assert type(txt) == list + if (type(txt) == list): + buffer = ''.join(txt) + else: + buffer = txt try: file = open(filename,"r") @@ -44,12 +47,10 @@ def same_file(filename,txt): stream = file.read() file.close() - buffer = ''.join(txt) - if len(stream) != len(buffer): return False if stream != buffer: - return False + return False return True def build_dim(dim): diff --git a/src/variable.py b/src/variable.py index f9eb512..817aba9 100644 --- a/src/variable.py +++ b/src/variable.py @@ -200,7 +200,7 @@ class Variable(object): ############################################################ def fmodule(self): if '_fmodule' not in self.__dict__: - self._fmodule = self.line.filename[0].split('.irp.f')[0]+'_mod' + self._fmodule = self.line.filename[0].replace('/','__').split('.irp.f')[0]+'_mod' return self._fmodule fmodule = property(fmodule) diff --git a/src/version.py b/src/version.py index 26ccef1..253dc6a 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.2.22" +version = "1.3.00" From f1d3eba3bc630db31c4c9011301ef595344d254d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 11 Dec 2013 14:49:02 +0100 Subject: [PATCH 08/23] Fixed bug with Cython --- bin/irpf90 | 2 +- man/man1/irpf90.1.gz | Bin 1328 -> 1329 bytes src/Makefile | 7 ++----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/irpf90 b/bin/irpf90 index d9d2360..e537e26 120000 --- a/bin/irpf90 +++ b/bin/irpf90 @@ -1 +1 @@ -../src/irpf90_python.exe \ No newline at end of file +../src/irpf90.exe \ No newline at end of file diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz index c4212e362d156794ee4a22ccd5a1869885986dfb..19b980fd63735b02d03d8b8f66004f7460eb41ab 100644 GIT binary patch literal 1329 zcmV-11vyaT;Z%RvR23-G@b5Y1u$q zq?RB|9#(Z!4fYt1V$XQz0-@@U-*d(W+>~gy58%0+`{g?mB^U6CE2#NKz(y!xxDy%V zMps}&?2J#HHzHe!Cl|4Zy+4v@HG*M(aFg@~L;MY3a5H-Q7VcNK5o6Kn1I(6-cfa>x z02dc7~=#Al3CDjJJrTy=_FO6b#NCI)o76gBGj#LY%3mL!)0ND}oKIjV5< zz#0}hJSXdL-%yXv(7nj{z)E3ylq5(9lW4iTQ_RWg!}oyPFPL@eIw%sHF%@T>?ecyVzzsYZA$EZ zRw6p^GYmdBibWj%J-=JTvzSGV!_bfV$MsG081e=79 z#prA~8nP}0NJ^nlKT zKdCo{5^w$5Xzwrp*SS|ImDqJ#Fox}9S;88#V5DlWIwS@4tBf1mdslnMc7;$_O_+Hq zD@>Jml8%-fTG>~?E!zo{#%&OBySN7@D@rg%BE#mks4-a9vUFVAw639DxhzG;x#lEj z4Q@fIvo2@Rau%Yj*@C=4Drq6?k5uxQKj|=eXge?ER}|L9=$OX{Zn11hF=tpj+?Nig z-lHI^0AteBv#1c%IA(pP%_G@%;K#n|*j64&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FeXhsiwZ%FW7c=tJd$k(e(b9g+sZ>Jlya@unErtq!}qqGTA8kD6l_|4xfPa? z5-VI2#7ip5@u&F1tgGCJ8kdQ096J=F-pT*tW(Z+{rc)Mz9)|hkfH$kX6R^^rvbsMp zv1(1Mu>8=UCV?}gaj&doMA3I zGAgG7)&dT~P^CmI-Sc z|7<|X!x_C{D7gr4hpJ~y)kkn|Md3>*2;D-Ltto3nZds-k0v&k+c0+YT~>;CQVFC@D#2@(*t&)7#5X1#c$t;_@iXw$iYlt&@nUf+gJ&%cJzjjWa6OP-&6PTT-@~tYbJZ7M+yJmB&j3fEBCEwyH=KPSyc1zIEOp0goGMP?c z{3*G6HhJfezFm13()`4^eR}eLhR+if /dev/null && echo 1 || echo 0") ifneq ($(HAS_CYTHON),0) -../bin/irpf90: irpf90.exe - rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90.exe irpf90 - -irpf90.exe: irpf90.so - gcc build/*/irpf90.o -L/usr/lib64 -lpython$(PYVERSION) -o irpf90.exe +../bin/irpf90: irpf90.so + rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90 irpf90.so : $(wildcard *.py) irpf90.c ./cython_setup.py build_ext --inplace From b5499b8a2f0175913002d5a2b789f15fe4705269 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 13 Dec 2013 10:28:05 +0100 Subject: [PATCH 09/23] Added autocompletion in irpman --- bin/irpman | 36 +++++++++++++++++++++--------------- src/irpman.py | 39 +++++++++++++++++++++++++++++++++++++++ src/version.py | 2 +- 3 files changed, 61 insertions(+), 16 deletions(-) create mode 100755 src/irpman.py diff --git a/bin/irpman b/bin/irpman index fac6e30..f102f6a 100755 --- a/bin/irpman +++ b/bin/irpman @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/bin/bash # IRPF90 is a Fortran90 preprocessor written in Python for programming using # the Implicit Reference to Parameters (IRP) method. # Copyright (C) 2009 Anthony SCEMAMA @@ -24,19 +24,25 @@ # 31062 Toulouse Cedex 4 # scemama@irsamc.ups-tlse.fr +# Define auto-completion for bash -import os -import sys - -wd = os.path.abspath(os.path.dirname(__file__)) -sys.path.insert(0,(wd+"/../src/")) -sys.path.insert(0,(wd+"/../share/irpf90/src/")) - -if len(sys.argv) != 2: - print "Usage:" - print sys.argv[0]+" " - sys.exit(1) - -from irpf90_t import mandir -os.system("man ./"+mandir+sys.argv[1].lower()+".l") +case "$0" in + *bash*) + _irpman_complete() + { + local cur + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $(compgen -W "`cat irpf90_entities | cut -d':' -f 4 | cut -d ' ' -f 2`" -- "$cur" ) ) + } && complete -F _irpman_complete irpman + ;; + *) + if [[ -z $1 ]] ; then + echo "To activate auto-completion in bash:" + echo "source $(which irpman)" + else + python $(dirname $0)/../src/irpman.py $1 + fi + ;; +esac diff --git a/src/irpman.py b/src/irpman.py new file mode 100755 index 0000000..c0253a8 --- /dev/null +++ b/src/irpman.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# IRPF90 is a Fortran90 preprocessor written in Python for programming using +# the Implicit Reference to Parameters (IRP) method. +# Copyright (C) 2009 Anthony SCEMAMA +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Anthony Scemama +# LCPQ - IRSAMC - CNRS +# Universite Paul Sabatier +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 +# scemama@irsamc.ups-tlse.fr + + +import os +import sys + +wd = os.path.abspath(os.path.dirname(__file__)) +from irpf90_t import mandir +filename = sys.argv[1].lower()+".l" +if filename not in os.listdir(mandir): + print "%s does not exist"%(sys.argv[1]) + sys.exit(-1) + +os.system("man ./"+mandir+sys.argv[1].lower()+".l") + diff --git a/src/version.py b/src/version.py index 253dc6a..35ec9a3 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.00" +version = "1.3.1" From 3ce56dcdea40ccbdede7e3bbddb23462e554512c Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 3 Jan 2014 16:22:24 +0100 Subject: [PATCH 10/23] Forgot file --- example/input/input.irp.f | 22 ++++++++++++++++++++++ example/uvwt.irp.f | 1 + man/man1/irpf90.1.gz | Bin 1329 -> 1332 bytes 3 files changed, 23 insertions(+) create mode 100644 example/input/input.irp.f diff --git a/example/input/input.irp.f b/example/input/input.irp.f new file mode 100644 index 0000000..2f5049a --- /dev/null +++ b/example/input/input.irp.f @@ -0,0 +1,22 @@ + BEGIN_PROVIDER [ integer, d1 ] +&BEGIN_PROVIDER [ integer, d2 ] +&BEGIN_PROVIDER [ integer, d3 ] +&BEGIN_PROVIDER [ integer, d4 ] +&BEGIN_PROVIDER [ integer, d5 ] + + print *, 'd1' + read(*,*) d1 + + BEGIN_TEMPLATE + print *, '$X' + read(*,*) $X + ASSERT ( $X > $Y ) + + SUBST [ X, Y ] + d2; d1;; + d3; d2;; + d4; d3;; + d5; d4;; + END_TEMPLATE +END_PROVIDER + diff --git a/example/uvwt.irp.f b/example/uvwt.irp.f index 32803b2..f8be7e8 100644 --- a/example/uvwt.irp.f +++ b/example/uvwt.irp.f @@ -20,6 +20,7 @@ BEGIN_PROVIDER [ integer, u2 ] integer :: fu ! u2 = fu(d3,d4) u2 = d3+d4+1 + ASSERT (u2 > d3) END_PROVIDER integer function fu(x,y) diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz index 19b980fd63735b02d03d8b8f66004f7460eb41ab..0bd7baaa3930211d2fe926a0a883b050f17ee171 100644 GIT binary patch literal 1332 zcmV-41QlwBA7@jH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2&PYUBdPM&VKhBllbqfFhh%R-t From 61997d670aee58310dda9414d65e22208a3f1a34 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 7 Jan 2014 17:01:40 +0100 Subject: [PATCH 11/23] Added auto codelet generation --- bin/irpf90 | 2 +- src/codelet.py | 45 ++++++++++++++++++++++++++++++++++++++++ src/command_line.py | 23 ++++++++++++++++++++ src/irpf90.py | 13 +++++++++--- src/irpf90_t.py | 2 ++ src/makefile.py | 6 +++--- src/preprocessed_text.py | 1 + src/profile.py | 2 +- 8 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 src/codelet.py diff --git a/bin/irpf90 b/bin/irpf90 index e537e26..d9d2360 120000 --- a/bin/irpf90 +++ b/bin/irpf90 @@ -1 +1 @@ -../src/irpf90.exe \ No newline at end of file +../src/irpf90_python.exe \ No newline at end of file diff --git a/src/codelet.py b/src/codelet.py new file mode 100644 index 0000000..c11d95e --- /dev/null +++ b/src/codelet.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +from command_line import command_line +import irpf90_t + +def run(): + template = """ +program codelet_%(name)s + implicit none + integer :: i + double precision :: ticks_0, ticks_1, cpu_0, cpu_1 + integer, parameter :: irp_imax = %(NMAX)d + + %(precondition)s + + call provide_%(name)s + + double precision :: irp_rdtsc + + call cpu_time(cpu_0) + ticks_0 = irp_rdtsc() + do i=1,irp_imax + call bld_%(name)s + enddo + ticks_1 = irp_rdtsc() + call cpu_time(cpu_1) + print *, '%(name)s' + print *, '-----------' + print *, 'Cycles:' + print *, (ticks_1-ticks_0)/dble(irp_imax) + print *, 'Seconds:' + print *, (cpu_1-cpu_0)/dble(irp_imax) +end + + """ + + name, NMAX, precondition, filename = command_line.codelet + if precondition is None: + precondition = "" + else: + precondition = "PROVIDE "+precondition + file = open(filename,'w') + file.write(template%locals()) + file.close() + + diff --git a/src/command_line.py b/src/command_line.py index 4524ecf..35569d0 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -49,6 +49,7 @@ options['r'] = [ 'no_directives', 'Ignore all compiler directives !DEC$ and !DIR options['n'] = [ 'inline' , 'all|providers|builders : Force inlining of providers or builders', 1 ] options['u'] = [ 'unused' , 'Print unused providers', 0 ] options['I'] = [ 'include' , 'Include directory', 1 ] +options['c'] = [ 'codelet' , 'entity:NMAX or entity:precondition:NMAX : Generate a codelet to profile a provider running NMAX times', 1 ] class CommandLine(object): @@ -100,6 +101,28 @@ class CommandLine(object): return self._substituted substituted = property(fget=substituted) + def codelet(self): + if '_codelet' not in self.__dict__: + self._codelet = [] + for o,a in self.opts: + if o in [ "-c", '--'+options['c'][0] ]: + buffer = a.split(':') + filename = 'codelet_'+buffer[0]+'.irp.f' + if len(buffer) == 2: + self._codelet = [buffer[0], int(buffer[1]), None, filename] + elif len(buffer) == 3: + self._codelet = [buffer[0], int(buffer[2]), buffer[1], filename] + else: + print """ +Error in codelet definition. Use: +--codelet=provider:NMAX +or +--codelet=provider:precondition:NMAX +""" + sys.exit(1) + return self._codelet + codelet = property(fget=codelet) + def preprocessed(self): if '_preprocessed' not in self.__dict__: self._preprocessed = [] diff --git a/src/irpf90.py b/src/irpf90.py index 4cc43c1..eaed0e9 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -35,8 +35,9 @@ except: pass sys.setcheckinterval(1000) +from command_line import command_line + def main(): - from command_line import command_line vim.install() @@ -72,9 +73,14 @@ def main(): for x in parents: print "- %s"%(x,) - if not command_line.do_run: - return + if command_line.do_codelet: + import profile + profile.build_rdtsc() + import codelet + codelet.run() + if not command_line.do_run: + return init() @@ -102,3 +108,4 @@ def main(): if __name__ == '__main__': main() + diff --git a/src/irpf90_t.py b/src/irpf90_t.py index 1068ada..57658c4 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -351,6 +351,8 @@ def create_irpf90_files(): result = filter ( is_irpf90_file, os.listdir(os.getcwd()) ) for dir in command_line.include_dir: result += map(lambda x: dir+x, filter ( is_irpf90_file, os.listdir(dir) ) ) + if command_line.do_codelet: + result += [command_line.codelet[3]] return result irpf90_files = create_irpf90_files() diff --git a/src/makefile.py b/src/makefile.py index 03ea7fd..311b887 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -61,8 +61,7 @@ irpf90.make: $(wildcard *.irp.f) ###################################################################### def run(): - from modules import modules - if os.fork() == 0: + from modules import modules mod = [] for m in modules.values(): mod.append(m) @@ -94,6 +93,8 @@ def run(): print >>file, "OBJ1 = $(OBJ) %sirp_touches.irp.o"%(irpdir), if command_line.do_profile: print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", + if command_line.do_codelet: + print >>file, " irp_rdtsc.o", if command_line.do_openmp: print >>file, " %sirp_locks.irp.o"%(irpdir), else: @@ -191,4 +192,3 @@ def run(): print >>file, "\t- rm -rf "+irpdir+" "+mandir+" irpf90.make irpf90_variables dist\n" file.close() - sys.exit(0) diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 4941ea2..9eb2db3 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -788,6 +788,7 @@ def check_begin_end(text): error.fail(text[begin],"Missing 'end%s'"%(x,)) def find_matching_end_subfunpro(begin,x): + line = text[begin] for i in range(begin+1,len(text)): line = text[i] if type(line) == x: diff --git a/src/profile.py b/src/profile.py index f1321d6..abf0b92 100644 --- a/src/profile.py +++ b/src/profile.py @@ -20,7 +20,6 @@ import subprocess import tempfile import os import threading -from variables import variables def build_rdtsc(): file,filename = tempfile.mkstemp() @@ -36,6 +35,7 @@ def build_rdtsc(): threading.Thread(target=t).start() def build_module(): + from variables import variables data = """ module irp_timer double precision :: irp_profile(3,%(n)d) From 89ab32443ccb5badade8d311aa34ccfe3f292e04 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 27 Feb 2014 14:06:31 +0100 Subject: [PATCH 12/23] Corrected bug with unexisting directories --- README | 5 +++-- man/man1/irpf90.1.gz | Bin 1329 -> 1471 bytes src/command_line.py | 2 ++ src/init.py | 9 ++++++++- src/irpf90_t.py | 6 +++++- src/module.py | 2 +- src/version.py | 2 +- 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README b/README index da145fc..a0d98c3 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ Dependencies - GNU make (>= 3.81 recommended) - Python > 2.3 -- Any Fortran 90 compiler (Intel recommended, for example) +- Any Fortran 90 compiler (Intel recommended) Installing IRPF90 ----------------- @@ -21,6 +21,7 @@ ${IRPF90_HOME} is the location of your irpf90 directory:: export PATH=${IRPF90_HOME}/bin:${PATH} export MANPATH=${IRPF90_HOME}/man:${MANPATH} EOF + . ${HOME}/.bash_profile Using IRPF90 @@ -43,6 +44,6 @@ Author ------ | Anthony Scemama, LCPQ-IRSAMC, CNRS-Universite Paul Sabatier -| scemama@irsamc.ups-tlse.fr +| | http://scemama.mooo.com diff --git a/man/man1/irpf90.1.gz b/man/man1/irpf90.1.gz index 19b980fd63735b02d03d8b8f66004f7460eb41ab..2e0b640df0b1ebd4d280207fad1caa290f8aa9f5 100644 GIT binary patch literal 1471 zcmV;w1wi^AiwFq7J^E4r18H(_W;rk}F#wfUZExE)5dO|zaWyia#bU*FR}AwoU|!<3 z1{%k(9Be}s6tqO!L?lupDLXFuwrw4qbCaC0`3#3ndJ9 zBBPbj1sM@LQ>CslB3psn%3k|2rwlT&B{|T&#o< zDi!23%{Zil6UM@!NEtHL4GONhQe{H9ZZ5VWr=H);MBneuMF|_%+^nTyNpjYwBvBu6 zq6kZOtUlrwpVHOt*V4l$&EDM;i~Xk-2X`!L;+RaY#?u9hkg@1dOn^=d zSw!=gd~_IngUYiWK8E6nvkjs@_Mb7Xts6FO((SbMljh?fU+ehB40d#$eJ7aDX1iPa zro`@hH6noTIZ%Z_LE`xD>CG&j#4M@4vQIg|d>6ZHkGV95|<~sN}F_DZbh^*$!Zp`xCt;k0(F7CKhP!3yqdWaXg+cPW97dMSN*7K4(T0dMlm~I%-ZE&8f~rF5DsVpO2CI znB0Ciy&nBV0JNE+=2NWzKG+rZ*pS-x3``n*K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VAw639DxhzG;x#lEj z4Q@fIvo2@Rau%Yj*@C=4Drq6?k5uxQKj|=eXge?ER}|L9=$OX{Zn11hF=tpj+?Nig z-lHI^0AteBv#1c%IA(pP%_G@%;K#n|*j64&p_CiN#`F)|7{0gd)Jk<#qhQnW%dN1C zlvv@KAYM{Yjz7-c&ySTGQR6c4#IZv$>PPv1+zcTs&~(Z|(8DmF9PnnncLLVhQ&#sK z6RXz53d;}uX#&`6NQ_Q-fTZh8baownbqs7tjfO!t-UO10VA>*AtX?t;|z0o zB%^XVP@V+qR&ZK~^bvuP#f9EkL@`7oAfT+|*I*6K+C5dU5&w9MVs;WyAB#$$vQ${x z_-6x39?s|uL&-&WJ5)Vusy>2yD{@~#PUsf8Y(rTia?4V!5a`Goum#n**b}sDp-76VtJGvxp78i8cMBe zOJ=k7p%$#HMT&rz9-@biKkFseYH-@81)E4)ml)e-a1dHL8XMeDtdM{}9ASZl4Jn|4 zJ>u&Iol%4ZIAL&*djhkLD&MN|%3}uFx@$J4$~cj4TkS%ug2&PYUBdPM&VKhBllbqfFhh%R-t diff --git a/src/command_line.py b/src/command_line.py index 35569d0..593f807 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -74,6 +74,8 @@ class CommandLine(object): self._include_dir = [] for o,a in self.opts: if o in [ "-I", '--'+options['I'][0] ]: + if len(a) < 1: + print "Error: -I option needs a directory" if a[-1] != '/': a = a+'/' self._include_dir.append(a) diff --git a/src/init.py b/src/init.py index 4fd25d1..7bddb42 100644 --- a/src/init.py +++ b/src/init.py @@ -63,10 +63,17 @@ def init(): makefile.create() # Copy current files in the irpdir + ls = os.listdir(os.getcwd()) + print ls for dir in ['./']+command_line.include_dir: + try: + os.stat(dir) + except: + print dir,'not in dir' + continue for filename in os.listdir(dir): filename = dir+filename - if not filename[0].startswith(".") and not os.path.isdir(filename): + if not filename.startswith(".") and not os.path.isdir(filename): try: file = open(filename,"r") except IOError: diff --git a/src/irpf90_t.py b/src/irpf90_t.py index 57658c4..ae1b73a 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -350,7 +350,11 @@ def create_irpf90_files(): return filename.endswith(".irp.f") and not filename.startswith('.') result = filter ( is_irpf90_file, os.listdir(os.getcwd()) ) for dir in command_line.include_dir: - result += map(lambda x: dir+x, filter ( is_irpf90_file, os.listdir(dir) ) ) + try: + os.stat(dir) + result += map(lambda x: dir+x, filter ( is_irpf90_file, os.listdir(dir) ) ) + except: + continue if command_line.do_codelet: result += [command_line.codelet[3]] return result diff --git a/src/module.py b/src/module.py index 4bb9f49..a817f40 100644 --- a/src/module.py +++ b/src/module.py @@ -47,7 +47,7 @@ class Fmodule(object): def __init__(self,text,filename): self.text = put_info(text,filename) self.filename = filename[:-6] - self.name = "%s_mod"%(self.filename).replace('/','__') + self.name = "%s_mod"%(self.filename).replace('/','__').replace('.','Dot') def is_main(self): if '_is_main' not in self.__dict__: diff --git a/src/version.py b/src/version.py index 35ec9a3..cfa2db6 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.1" +version = "1.3.3" From d71c2c42297ce49f5bec0addbe880257ebc7ce3e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 27 Feb 2014 14:07:20 +0100 Subject: [PATCH 13/23] Fixed man error in make --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 31a6ddf..97732c1 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ .PHONY: all src man -all: src man - src: $(MAKE) -C $@ man: - $(MAKE) -C $@ +all: src man + From b508923bab68d1db0ecc4644de732a3abd1f6377 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 28 Feb 2014 11:12:20 +0100 Subject: [PATCH 14/23] Forgot to remove debug print --- src/init.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/init.py b/src/init.py index 7bddb42..94b82c1 100644 --- a/src/init.py +++ b/src/init.py @@ -63,8 +63,6 @@ def init(): makefile.create() # Copy current files in the irpdir - ls = os.listdir(os.getcwd()) - print ls for dir in ['./']+command_line.include_dir: try: os.stat(dir) From b1982206ea812baa45ac6dfcb3e51711079a4b6b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 11 Mar 2014 15:43:02 +0100 Subject: [PATCH 15/23] Add tags for vi navigation --- src/create_man.py | 13 +++++++++++++ src/version.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/create_man.py b/src/create_man.py index 4e461c9..fe4ad7f 100644 --- a/src/create_man.py +++ b/src/create_man.py @@ -27,6 +27,7 @@ from variable import Variable from variables import variables +from subroutines import subroutines from irpf90_t import * from util import * @@ -103,11 +104,23 @@ def run(): sys.exit(0) if os.fork() == 0: + tags = [] l = variables.keys() file = open("irpf90_entities","w") l.sort() for v in l: do_print_short(file,variables[v]) + line = variables[v].line + tags.append( '%s\t%s\t/%s/;"\n'%(v,line.filename[0],line.text.split('!')[0].strip()) ) + file.close() + l = subroutines.keys() + for v in l: + line = subroutines[v].line + tags.append('%s\t%s\t/%s/;"\n'%(v,line.filename,line.text.split('!')[0].strip())) + tags.sort() + file = open("tags","w") + for line in tags: + file.write(line) file.close() sys.exit(0) diff --git a/src/version.py b/src/version.py index cfa2db6..08d6483 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.3" +version = "1.3.4" From e74ffd8e7a0b7871cf57ca60e3ca46ef72474a3a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 13 Mar 2014 10:31:10 +0100 Subject: [PATCH 16/23] Added irpf90_indent --- bin/irpf90_indent | 40 +++++++ src/irpf90_indent.py | 247 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+) create mode 100755 bin/irpf90_indent create mode 100755 src/irpf90_indent.py diff --git a/bin/irpf90_indent b/bin/irpf90_indent new file mode 100755 index 0000000..2310fdd --- /dev/null +++ b/bin/irpf90_indent @@ -0,0 +1,40 @@ +#!/usr/bin/python +# IRPF90 is a Fortran90 preprocessor written in Python for programming using +# the Implicit Reference to Parameters (IRP) method. +# Copyright (C) 2009 Anthony SCEMAMA +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Anthony Scemama +# LCPQ - IRSAMC - CNRS +# Universite Paul Sabatier +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 +# scemama@irsamc.ups-tlse.fr + + +import os +import sys + +wd = os.path.abspath(os.path.dirname(__file__)) +sys.path.insert(0,(wd+"/../src/")) +sys.path.insert(0,(wd+"/../share/irpf90/src/")) + +def main(): + import irpf90_indent + irpf90_indent.main() + +main() + diff --git a/src/irpf90_indent.py b/src/irpf90_indent.py new file mode 100755 index 0000000..bda0dcb --- /dev/null +++ b/src/irpf90_indent.py @@ -0,0 +1,247 @@ +#!/usr/bin/python + +import sys +import re + +LENMAX = 70 +tabn = 2 +tab = " "*tabn + +class Grep(object): + + re_begin_program = re.compile(r"^\s*program\s",flags=re.I) + def begin_program(self,string): + return re.match(self.re_begin_program,string) is not None + + re_end_program = re.compile(r"\s*(end\s*!?$|end\s*program)",flags=re.I) + def end_program(self,string): + return re.match(self.re_end_program,string) is not None + + re_begin_subroutine = re.compile(r"^\s*subroutine\s",flags=re.I) + def begin_subroutine(self,string): + return re.match(self.re_begin_subroutine,string) is not None + + re_end_subroutine = re.compile(r"\s*(end\s*!?$|end\s*subroutine)",flags=re.I) + def end_subroutine(self,string): + return re.match(self.re_end_subroutine,string) is not None + + re_begin_function = re.compile(r"^.*function\s+.*\(",flags=re.I) + def begin_function(self,string): + return re.match(self.re_begin_function,string) is not None + + re_end_function = re.compile(r"\s*(end\s*!?$|end\s*function)",flags=re.I) + def end_function(self,string): + return re.match(self.re_end_function,string) is not None + + re_begin_provider = re.compile(r"^\s*&?begin_provider\s",flags=re.I) + def begin_provider(self,string): + return re.match(self.re_begin_provider,string) is not None + + re_end_provider = re.compile(r"^\s*end_provider\s*(!.*)?$", flags=re.I) + def end_provider(self,string): + return re.match(self.re_end_provider,string) is not None + + re_begin_do = re.compile(r"^\s*do\s+",flags=re.I) + def begin_do(self,string): + return re.match(self.re_begin_do,string) is not None + + re_end_do = re.compile(r"^\s*end\s*do\s*(!.*)?$",flags=re.I) + def end_do(self,string): + return re.match(self.re_end_do,string) is not None + + re_begin_if = re.compile(r"^\s*if(\(|\s+).*(&|then)\s*(!.*)?$",flags=re.I) + def begin_if(self,string): + return re.match(self.re_begin_if,string) is not None + + re_else = re.compile(r"^\s*else",flags=re.I) + def xelse(self,string): + return re.match(self.re_else,string) is not None + + re_end_if = re.compile(r"^\s*end\s*if\s*(!.*)?$",flags=re.I) + def end_if(self,string): + return re.match(self.re_end_if,string) is not None + + re_begin_select = re.compile(r"^\s*select\s*case",flags=re.I) + def begin_select(self,string): + return re.match(self.re_begin_select,string) is not None + + re_case = re.compile(r"^\s*case\s*\(",flags=re.I) + def case(self,string): + return re.match(self.re_case,string) is not None + + re_end_select = re.compile(r"^\s*end\s*select\s*(!.*)?$",flags=re.I) + def end_select(self,string): + return re.match(self.re_end_select,string) is not None + + re_continuation = re.compile(r"^\s*\S+.*&") + def continuation(self,string): + return re.match(self.re_continuation,string) is not None + + re_declaration = re.compile(r"^.*::.*$") + def declaration(self,string): + return re.match(self.re_declaration,string) is not None + +grep = Grep() + +class indent(object): + + def __init__(self): + """Run the program""" + self.run() + + def format_declaration(self,string,n): + l,r = string.split('::') + return l.strip().ljust(n) + ' :: '+ r.strip() + + def format_continuation(self,string,n): + buffer = string.split('&') + if len(buffer) == 1: + l = buffer[0] + return l + else: + l, r = buffer + return l.strip().ljust(69-len(n)) + '&'+ r.strip() + + def get_filename(self): + """The file name is the first argument""" + if '_filename' not in self.__dict__: + try: + self._filename = sys.argv[1] + except: + self._filename = None + return self._filename + filename=property(fget=get_filename) + + def get_text(self): + """The text of the file is a list of lines""" + if '_text' not in self.__dict__: + if self.filename is not None: + f = open(self.filename,'r') + self._text = f.read().splitlines() + f.close() + else: + self._text = sys.stdin.read().splitlines() + return self._text + text=property(fget=get_text) + + def indentlevel(self,line): + line = line.rstrip() + k=0 + if len(line) > 0: + while line[k] == ' ': + k+=1 + return k + + def run(self): + lines = self.text + indent0 = " "*self.indentlevel(self.text[0]) + k = indent0 + line = "" + for i in range(len(self.text)): + prevline = line + line = self.text[i].strip() + if grep.continuation(line): + line = self.format_continuation(line,k) + + if grep.continuation(prevline): + print k+2*tab+self.format_continuation(line,k+2*tab) + continue + + if grep.begin_subroutine(line): + print line + k = indent0+tab + continue + + if grep.begin_function(line): + print line + k = indent0+tab + continue + + if grep.begin_program(line): + print line + k = indent0+tab + continue + + if grep.begin_provider(line): + if line[0] != '&': + k = indent0+tab + if grep.begin_provider(self.text[i+1].strip()): + print " "+line + else: + print line + else: + print line + continue + + if grep.declaration(line): + print k+self.format_declaration(line,30) + continue + + if grep.begin_do(line): + print k+line + k += tab + continue + + if grep.begin_if(line): + print k+line + k += tab + continue + + if grep.xelse(line): + print k[:-tabn]+line + continue + + if grep.begin_select(line): + print k+line + k += 2*tab + continue + + if grep.case(line): + print k[:-tabn]+line + continue + + if grep.end_do(line): + k = k[:-tabn] + print k+line + continue + + if grep.end_if(line): + k = k[:-tabn] + print k+line + continue + + if grep.end_select(line): + k = k[:-2*tabn] + print k+line + continue + + if grep.end_subroutine(line): + print line + k = indent0 + continue + + if grep.end_function(line): + print line + k = indent0 + continue + + if grep.end_provider(line): + print line + k = indent0 + continue + + if grep.end_program(line): + print line + k = indent0 + continue + + print k+line + + +def main(): + indent() + + +if __name__ == '__main__': + main() + From 67e6def1514f50f39b12d7c700cc22ae7fd67d1d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 13 Mar 2014 14:44:47 +0100 Subject: [PATCH 17/23] Added support of documentation of subroutines and functions --- bin/irpman | 4 ++-- src/create_man.py | 43 +++++++++++++++++++++++++++++++++++++++++++ src/makefile.py | 4 ++-- src/subroutine.py | 3 ++- src/subroutines.py | 18 ++++++++++++++++++ src/variable.py | 12 ++++++++++++ src/version.py | 2 +- 7 files changed, 80 insertions(+), 6 deletions(-) diff --git a/bin/irpman b/bin/irpman index f102f6a..175af7a 100755 --- a/bin/irpman +++ b/bin/irpman @@ -33,14 +33,14 @@ case "$0" in local cur COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} - COMPREPLY=( $(compgen -W "`cat irpf90_entities | cut -d':' -f 4 | cut -d ' ' -f 2`" -- "$cur" ) ) + COMPREPLY=( $(compgen -W "`cat tags | cut -d' ' -f 1`" -- "$cur" ) ) } && complete -F _irpman_complete irpman ;; *) if [[ -z $1 ]] ; then echo "To activate auto-completion in bash:" - echo "source $(which irpman)" + echo "source " $0 else python $(dirname $0)/../src/irpman.py $1 fi diff --git a/src/create_man.py b/src/create_man.py index fe4ad7f..724c522 100644 --- a/src/create_man.py +++ b/src/create_man.py @@ -27,6 +27,7 @@ from variable import Variable from variables import variables +from subroutine import Sub from subroutines import subroutines from irpf90_t import * from util import * @@ -94,6 +95,46 @@ def do_print(var): process_deps(file,var.needed_by) file.close() +###################################################################### +def process_declaration_subroutine(file, sub): + print >>file, sub.line.text.split('!')[0].strip() + +# for line in sub.text: +###################################################################### +def do_print_subroutines(sub): + assert type(sub) == Sub + filename = sub.line.filename + name = sub.name + file = open("%s%s.l"%(mandir,sub.name), "w") + print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name) + print >>file, ".SH Declaration" + print >>file, ".nf" + process_declaration_subroutine(file,sub) + print >>file, ".ni" + if sub.doc != []: + print >>file, ".SH Description" + for l in sub.doc: + process_doc(file,l) + print >>file, ".SH File\n.P" + print >>file, filename + if sub.needs != []: + sub.needs.sort() + print >>file, ".SH Needs" + process_deps(file,sub.needs) + if sub.called_by != []: + sub.called_by.sort() + print >>file, ".SH Called by" + process_deps(file,sub.called_by) + if sub.calls != []: + sub.calls.sort() + print >>file, ".SH Calls" + process_deps(file,sub.calls) + if sub.touches != []: + sub.touches.sort() + print >>file, ".SH Touches" + process_deps(file,sub.touches) + file.close() + ###################################################################### def run(): import parsed_text @@ -101,6 +142,8 @@ def run(): if os.fork() == 0: for v in variables.values(): do_print(v) + for s in subroutines.values(): + do_print_subroutines(s) sys.exit(0) if os.fork() == 0: diff --git a/src/makefile.py b/src/makefile.py index 311b887..c638745 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -53,9 +53,9 @@ LIB= include irpf90.make -irpf90.make: $(wildcard *.irp.f) +irpf90.make: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile \t$(IRPF90) -""" +"""%(irpdir) file.write(t) file.close() diff --git a/src/subroutine.py b/src/subroutine.py index c379892..5003310 100644 --- a/src/subroutine.py +++ b/src/subroutine.py @@ -37,6 +37,7 @@ class Sub(object): assert len(text) > 0 assert type(text[0]) in [Subroutine, Function] self.text = text + self.called_by = [] ############################################################ def name(self): @@ -114,7 +115,7 @@ class Sub(object): buffer = filter(lambda x: type(x) == Call,self.text) self._calls = [] for line in buffer: - sub = line.text.split('(',1)[0].split()[1] + sub = line.text.split('(',1)[0].split()[1].lower() self._calls.append(sub) self._calls = make_single(self._calls) return self._calls diff --git a/src/subroutines.py b/src/subroutines.py index 5491e95..90edb68 100644 --- a/src/subroutines.py +++ b/src/subroutines.py @@ -25,7 +25,10 @@ # scemama@irsamc.ups-tlse.fr +from util import * from subroutine import * +from variables import variables +from variable import Variable from irpf90_t import * def create_subroutines(): @@ -47,7 +50,22 @@ def create_subroutines(): inside = False return result +def create_called_by(subs,vars): + for s in subs.values() + vars.values(): + if type(s) == Variable and s.same_as != s.name: + continue + for x in s.calls: + try: + subs[x].called_by.append(s.name) + except KeyError: + pass + + for s in subs.values(): + s.called_by = make_single(s.called_by) + s.called_by.sort() + subroutines = create_subroutines() +create_called_by(subroutines,variables) if __name__ == '__main__': for v in subroutines.keys(): diff --git a/src/variable.py b/src/variable.py index 817aba9..b8418d5 100644 --- a/src/variable.py +++ b/src/variable.py @@ -130,6 +130,18 @@ class Variable(object): return self._includes includes = property(includes) + ############################################################ + def calls(self): + if '_calls' not in self.__dict__: + self._calls = [] + text = self.text + for line in filter(lambda x: type(x) == Call,text): + sub = line.text.split('(',1)[0].split()[1].lower() + self._calls.append(sub) + make_single(self._calls) + return self._calls + calls=property(fget=calls) + ############################################################ def others(self): if '_others' not in self.__dict__: diff --git a/src/version.py b/src/version.py index 08d6483..a19185e 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.4" +version = "1.3.5" From 051e65ebf9a8fffdaeec53530c5e47547ac50fe2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 13 Mar 2014 15:10:02 +0100 Subject: [PATCH 18/23] support for recursive subroutines in indent --- src/irpf90_indent.py | 2 +- src/subroutine.py | 2 +- src/variable.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/irpf90_indent.py b/src/irpf90_indent.py index bda0dcb..eb042da 100755 --- a/src/irpf90_indent.py +++ b/src/irpf90_indent.py @@ -17,7 +17,7 @@ class Grep(object): def end_program(self,string): return re.match(self.re_end_program,string) is not None - re_begin_subroutine = re.compile(r"^\s*subroutine\s",flags=re.I) + re_begin_subroutine = re.compile(r"^\s*(recursive)?\s*subroutine\s",flags=re.I) def begin_subroutine(self,string): return re.match(self.re_begin_subroutine,string) is not None diff --git a/src/subroutine.py b/src/subroutine.py index 5003310..01c7f94 100644 --- a/src/subroutine.py +++ b/src/subroutine.py @@ -59,7 +59,7 @@ class Sub(object): if '_doc' not in self.__dict__: def f(l): return buffer = filter(lambda l:type(l) == Doc, self.text) - self._doc = map(lambda l: l.text[1:], buffer) + self._doc = map(lambda l: l.text.lstrip()[1:], buffer) if buffer == []: error.warn(None,"Subroutine %s is not documented"%(self.name)) return self._doc diff --git a/src/variable.py b/src/variable.py index b8418d5..c8f452d 100644 --- a/src/variable.py +++ b/src/variable.py @@ -106,7 +106,7 @@ class Variable(object): if '_doc' not in self.__dict__: text = self.text buffer = filter(lambda l:type(l) == Doc, text) - self._doc = map(lambda l: l.text[1:], buffer) + self._doc = map(lambda l: l.text.lstrip()[1:], buffer) if buffer == []: error.warn(None,"Variable %s is not documented"%(self.name)) return self._doc From 49dcdbeefd0b3b7749ebae686e40412e080f2025 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 24 Mar 2014 17:05:52 +0100 Subject: [PATCH 19/23] Compile first external sources --- src/makefile.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/makefile.py b/src/makefile.py index c638745..edd5f82 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -83,14 +83,14 @@ def run(): result += " %s%s.irp.module.F90"%(irpdir,m.filename) print >>file, result - result = "OBJ += %sirp_stack.irp.o"%(irpdir) + result = "OBJ_IRP = " for m in mod: if not m.is_main: result += " %s%s.irp.o"%(irpdir,m.filename) result += " %s%s.irp.module.o"%(irpdir,m.filename) print >>file, result - print >>file, "OBJ1 = $(OBJ) %sirp_touches.irp.o"%(irpdir), + print >>file, "OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o"%(irpdir), if command_line.do_profile: print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", if command_line.do_codelet: @@ -126,7 +126,7 @@ def run(): buffer = "" for m in mod: - filename = "%s%s.irp.o: %s%s.irp.module.o"%(irpdir,m.filename,irpdir,m.filename) + filename = "%s%s.irp.o: $(OBJ) %s%s.irp.module.o"%(irpdir,m.filename,irpdir,m.filename) needed_modules = filter( lambda x: modules[x].name in m.needed_modules, modules ) needed_files = map(lambda x: modules[x].filename, needed_modules) mds = map (lambda x: " %s%s.irp.module.o"%(irpdir,x),needed_files) @@ -150,14 +150,14 @@ def run(): # print >>file, "\t- @echo FCFLAGS=$(FCFLAGS) >> %sdist_Makefile"%(irpdir) # print >>file, "\t- @echo LIB=$(LIB) >> %sdist_Makefile"%(irpdir) # print >>file, "\t- @echo .DEFAULT_GOAL: exe >> %sdist_Makefile"%(irpdir) -# print >>file, "\t- @echo 'exe: $$(EXE).irp.F90 $(OBJ) irp_touches.irp.o' >> %sdist_Makefile"%(irpdir) -# print >>file, "\t- @echo '\t$$(FC) -o $$(EXE) $$(EXE).irp.F90 $(OBJ) irp_touches.irp.o $$(LIB)' >> %sdist_Makefile"%(irpdir) +# print >>file, "\t- @echo 'exe: $$(EXE).irp.F90 $(OBJ_IRP) $(OBJ) irp_touches.irp.o' >> %sdist_Makefile"%(irpdir) +# print >>file, "\t- @echo '\t$$(FC) -o $$(EXE) $$(EXE).irp.F90 $(OBJ_IRP) $(OBJ) irp_touches.irp.o $$(LIB)' >> %sdist_Makefile"%(irpdir) # print >>file, "\t- @echo '%%.o: %%.F90' >> %sdist_Makefile"%(irpdir) # print >>file, "\t- @echo '\t$$(FC) $$(FCFLAGS) -c $$*.F90 -o $$*.o' >> %sdist_Makefile"%(irpdir) # print >>file, "\t- @echo 'clean:' >> %sdist_Makefile"%(irpdir) # print >>file, "\t- @echo '\trm *.o *.mod $$(EXE) 2>/dev/null' >> %sdist_Makefile"%(irpdir) # print >>file, buffer -# print >>file, "\t- @echo '\tirp_touches.irp.o: irp_touches.irp.F90 $(OBJ) >> %sdist_Makefile"%(irpdir) +# print >>file, "\t- @echo '\tirp_touches.irp.o: irp_touches.irp.F90 $(OBJ_IRP) $(OBJ) >> %sdist_Makefile"%(irpdir) # print >>file, "%%.dist: %sdist_Makefile"%(irpdir) # print >>file, "\t- @mkdir -p dist/$*| DO_NOTHING=" @@ -186,7 +186,7 @@ def run(): print >>file, dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o" print >>file, dir+"%.irp.F90: irpf90.make\n" print >>file, "move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n" - print >>file, "irpf90.a: $(OBJ1)\n\t$(AR) crf irpf90.a $(OBJ1)\n" + print >>file, "irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) crf irpf90.a $(OBJ1)\n" print >>file, "clean:\n\trm -rf $(EXE) $(OBJ1) irpf90.a $(ALL_OBJ1) $(ALL)\n" print >>file, "veryclean:\n\t- $(MAKE) clean\n" print >>file, "\t- rm -rf "+irpdir+" "+mandir+" irpf90.make irpf90_variables dist\n" From 1ed4a118277657ff94b59722a64d84f683ecb3a3 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 1 Apr 2014 11:57:54 +0200 Subject: [PATCH 20/23] Compile external sources first --- src/makefile.py | 8 ++++---- src/version.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/makefile.py b/src/makefile.py index edd5f82..4eb9579 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -133,7 +133,7 @@ def run(): print >>file, filename," ".join(mds)," ".join(m.includes) if not m.is_main: buffer += "\t - @echo '"+filename+" ".join(mds)+"' >> %sdist_Makefile\n"%(irpdir) - print >>file, "%sirp_touches.irp.o:"%(irpdir), + print >>file, "%sirp_touches.irp.o: $(OBJ) "%(irpdir), mds = filter(lambda x: not x.is_main,mod) mds = map(lambda x: " %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename),mds) print >>file," ".join(mds) @@ -173,11 +173,11 @@ def run(): # print >>file, "\t- cd dist ; tar -zcvf ../$*.tar.gz $*\n" for dir in [ irpdir ] + map(lambda x: irpdir+x, command_line.include_dir): - print >>file, dir+"%.irp.module.o: "+dir+"%.irp.module.F90" + print >>file, dir+"%.irp.module.o: $(OBJ) "+dir+"%.irp.module.F90" print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o" - print >>file, dir+"%.irp.o: "+dir+"%.irp.module.o "+dir+"%.irp.F90" + print >>file, dir+"%.irp.o: $(OBJ) "+dir+"%.irp.module.o "+dir+"%.irp.F90" print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o" - print >>file, dir+"%.irp.o: "+dir+"%.irp.F90" + print >>file, dir+"%.irp.o: $(OBJ) "+dir+"%.irp.F90" print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o" print >>file, dir+"%.o: %.F90" print >>file, "\t$(FC) $(FCFLAGS) -c $*.F90 -o "+dir+"$*.o" diff --git a/src/version.py b/src/version.py index a19185e..9c0c0ee 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.5" +version = "1.3.6" From 76224d63547bcb690a0c6ad2c7b82622e1e275f2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 1 Apr 2014 17:47:06 +0200 Subject: [PATCH 21/23] Error messages cleaned --- src/irpf90_t.py | 51 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/irpf90_t.py b/src/irpf90_t.py index ae1b73a..73dff2b 100644 --- a/src/irpf90_t.py +++ b/src/irpf90_t.py @@ -54,286 +54,329 @@ class Line(object): lower = property(fget=get_lower) class Empty_line(Line): + str="Empty_line" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Empty_line",self.i,self.text) class Simple_line(Line): + str="Simple_line" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Simple_line",self.i,self.text) class Declaration(Line): + str="Declaration" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Declaration",self.i,self.text) class Continue(Line): + str="Continue" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Continue",self.i,self.text) class Begin_provider(Line): - str = "Provider" + str="Begin_provider" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Begin_provider",self.i,self.text) class Cont_provider(Line): + str="Cont_provider" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Cont_provider",self.i,self.text) class End_provider(Line): + str="End_provider" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("End_provider",self.i,self.text) class Begin_doc(Line): + str="Begin_doc" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Begin_doc",self.i,self.text) class Doc(Line): + str="Doc" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Doc",self.i,self.text) class End_doc(Line): + str="End_doc" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("End_doc",self.i,self.text) class Begin_shell(Line): + str="Begin_shell" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Begin_shell",self.i,self.text) class End_shell(Line): + str="End_shell" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("End_shell",self.i,self.text) class Begin_template(Line): + str="Begin_template" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Begin_template",self.i,self.text) class End_template(Line): + str="End_template" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("End_template",self.i,self.text) class Subst(Line): + str="Subst" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Subst",self.i,self.text) class Assert(Line): + str="Assert" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Assert",self.i,self.text) class Touch(Line): + str="Touch" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Touch",self.i,self.text) class SoftTouch(Touch): + str="SoftTouch" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("SoftTouch",self.i,self.text) class Irp_read(Line): + str="Irp_read" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Irp_read",self.i,self.text) class Irp_write(Line): + str="Irp_write" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Irp_write",self.i,self.text) class Irp_If(Line): + str="Irp_If" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Irp_If",self.i,self.text) class Irp_Else(Line): + str="Irp_Else" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Irp_Else",self.i,self.text) class Irp_Endif(Line): + str="Irp_Endif" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Irp_Endif",self.i,self.text) class Openmp(Line): + str="Openmp" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Openmp",self.i,self.text) class Directive(Line): + str="Directive" 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): + str="Use" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Use",self.i,self.text) class Do(Line): + str="Do" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Do",self.i,self.text) class Enddo (Line): + str="Enddo" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Enddo",self.i,self.text) class If(Line): + str="If" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("If",self.i,self.text) class Elseif(Line): + str="Elseif" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Elseif",self.i,self.text) class Else(Line): + str="Else" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Else",self.i,self.text) class Endif(Line): + str="Endif" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Endif",self.i,self.text) class Select(Line): + str="Select" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Select",self.i,self.text) class Case(Line): + str="Case" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Case",self.i,self.text) class End_select(Line): + str="End_select" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("End_select",self.i,self.text) class Program(Line): - str = "Program" + str="Program" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Program",self.i,self.text) class Subroutine(Line): - str = "Subroutine" + str="Subroutine" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Subroutine",self.i,self.text) class Function(Line): - str = "Function" + str="Function" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Function",self.i,self.text) class Call(Line): + str="Call" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Call",self.i,self.text) class Provide(Line): + str="Provide" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Provide",self.i,self.text) class NoDep(Line): + str="NoDep" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("NoDep",self.i,self.text) class Return (Line): + str="Return" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Return",self.i,self.text) class Include(Line): + str="Include" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Include",self.i,self.text) class Implicit (Line): + str="Implicit" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Implicit",self.i,self.text) class Free(Line): + str="Free" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("Free",self.i,self.text) class End(Line): + str="End" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): return "%20s:%5d : %s"%("End",self.i,self.text) class Provide_all (Line): + str="Provide_all" def __init__(self,i,text,filename): Line.__init__(self,i,text,filename) def __repr__(self): From 557959f51a875a006e2a271cde3f4658a4217688 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 2 Apr 2014 13:46:43 +0200 Subject: [PATCH 22/23] Gitignore file added --- src/makefile.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/makefile.py b/src/makefile.py index 4eb9579..281c0e2 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -32,6 +32,8 @@ irpdir = irpf90_t.irpdir mandir = irpf90_t.mandir FILENAME = "Makefile" +FILENAME_GITIGNORE = ".gitignore" +IRPF90_MAKE = 'irpf90.make' ###################################################################### def create(): @@ -51,11 +53,26 @@ SRC= OBJ= LIB= -include irpf90.make +include %s -irpf90.make: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile +%s: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile \t$(IRPF90) -"""%(irpdir) +"""%(IRPF90_MAKE,IRPF90_MAKE,irpdir) + file.write(t) + file.close() + create_gitignore() + +###################################################################### +def create_gitignore(): + has_makefile = True + try: + file = open(FILENAME_GITIGNORE,"r") + except IOError: + has_makefile = False + if has_makefile: + return + file = open(FILENAME_GITIGNORE,"w") + t = "\n".join([ irpdir, mandir, IRPF90_MAKE, 'irpf90_entities' ]) file.write(t) file.close() @@ -66,7 +83,7 @@ def run(): for m in modules.values(): mod.append(m) - file = open('irpf90.make','w') + file = open(IRPF90_MAKE,'w') result = "" result += "FC+=-I %s "%(irpdir) for i in command_line.include_dir: @@ -184,11 +201,11 @@ def run(): print >>file, dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o" print >>file, dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o" print >>file, dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o" - print >>file, dir+"%.irp.F90: irpf90.make\n" + print >>file, dir+"%.irp.F90: %s\n"%(IRPF90_MAKE) print >>file, "move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n" print >>file, "irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) crf irpf90.a $(OBJ1)\n" print >>file, "clean:\n\trm -rf $(EXE) $(OBJ1) irpf90.a $(ALL_OBJ1) $(ALL)\n" print >>file, "veryclean:\n\t- $(MAKE) clean\n" - print >>file, "\t- rm -rf "+irpdir+" "+mandir+" irpf90.make irpf90_variables dist\n" + print >>file, "\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist\n" file.close() From d152eab8d11bc8e9cbd5add8d325ec6b94ea9daf Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 2 Apr 2014 17:07:27 +0200 Subject: [PATCH 23/23] IRPF90_MAKE variable --- src/makefile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/makefile.py b/src/makefile.py index 281c0e2..b267b4b 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -33,7 +33,7 @@ mandir = irpf90_t.mandir FILENAME = "Makefile" FILENAME_GITIGNORE = ".gitignore" -IRPF90_MAKE = 'irpf90.make' +IRPF90_MAKE = "irpf90.make" ###################################################################### def create(): @@ -72,7 +72,7 @@ def create_gitignore(): if has_makefile: return file = open(FILENAME_GITIGNORE,"w") - t = "\n".join([ irpdir, mandir, IRPF90_MAKE, 'irpf90_entities' ]) + t = "\n".join([ irpdir, mandir, IRPF90_MAKE, 'irpf90_entities', 'tags' ]) file.write(t) file.close() @@ -201,7 +201,7 @@ def run(): print >>file, dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o" print >>file, dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o" print >>file, dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o" - print >>file, dir+"%.irp.F90: %s\n"%(IRPF90_MAKE) + print >>file, dir+"%.irp.F90: "+IRPF90_MAKE+"\n" print >>file, "move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n" print >>file, "irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) crf irpf90.a $(OBJ1)\n" print >>file, "clean:\n\trm -rf $(EXE) $(OBJ1) irpf90.a $(ALL_OBJ1) $(ALL)\n"