From 9819222f25567d9cbd7c68b349a46cb79afd2b9a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 30 Mar 2015 21:22:27 +0200 Subject: [PATCH] Added checkpoint_write --- src/checkpoint.py | 73 +++++++++++++++++++++++++++++++++++++++++++++++ src/irpf90.py | 3 ++ src/makefile.py | 32 ++------------------- src/version.py | 2 +- 4 files changed, 80 insertions(+), 30 deletions(-) create mode 100644 src/checkpoint.py diff --git a/src/checkpoint.py b/src/checkpoint.py new file mode 100644 index 0000000..9a8358a --- /dev/null +++ b/src/checkpoint.py @@ -0,0 +1,73 @@ +#!/usr/bin/env 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 + + +from irpf90_t import * +from util import * +from variables import variables +from modules import modules + +CHECKPOINT_UNIT_NUMBER=63 + +FILENAME=irpdir+'irp_checkpoint.irp.F90' + +def create(): + out_write = [ "subroutine irp_checkpoint_write" ] + l = variables.keys() + l.sort + main_modules = filter(lambda x: modules[x].is_main, modules) + for m in filter(lambda x: not modules[x].is_main, modules): + out_write += [ " use %s"%(modules[m].name) ] + out_write += [ " implicit none" ] + out_write += [ " integer, parameter :: iunit = %d"%(CHECKPOINT_UNIT_NUMBER) ] + out_write += [ " open(unit=%d,file='irp_checkpoint.dat',status='UNKNOWN',action='WRITE')"%(CHECKPOINT_UNIT_NUMBER) ] + for v in l: + var = variables[v] + if var.is_main: + out_write += [ " if (%s_is_built) then"%(v) ] + for w in [v]+var.others: + d = variables[w].dim + if d == []: + out_write += [ " write(iunit,*) '%s', 0"%(w) ] + else: + out_write += [ " write(iunit, *) '%s', %d"%(w, len(d)), + " write(iunit, *) %s"%(",".join( + [ "size(%s,%d)"%(w,i+1) for i in range(len(d)) ] )) + ] + out_write += [ " write(iunit,*) %s"%(w) ] + out_write += [ " endif" ] + out_write += [ " close(%d)"%(CHECKPOINT_UNIT_NUMBER) ] + out_write += [ "end" ] + + out = '\n'.join(out_write) + if not same_file(FILENAME,out): + file = open(FILENAME,'w') + file.writelines(out) + file.close() + +if __name__ == '__main__': + create() + diff --git a/src/irpf90.py b/src/irpf90.py index 528289c..ada860f 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -100,6 +100,9 @@ def main(): import touches touches.create() + import checkpoint + checkpoint.create() + import create_man create_man.run() diff --git a/src/makefile.py b/src/makefile.py index cfc55e8..d1ce7eb 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -91,6 +91,7 @@ def run(): result += "\n" result += "SRC += %sirp_stack.irp.F90"%(irpdir) result += " %sirp_touches.irp.F90"%(irpdir) + result += " %sirp_checkpoint.irp.F90"%(irpdir) if command_line.do_openmp: result += " %sirp_locks.irp.F90"%(irpdir) if command_line.do_profile: @@ -107,7 +108,7 @@ def run(): result += " %s%s.irp.module.o"%(irpdir,m.filename) print >>file, result - print >>file, "OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o"%(irpdir), + print >>file, "OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o %sirp_checkpoint.irp.o"%(irpdir,irpdir), if command_line.do_profile: print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", if command_line.do_codelet: @@ -150,7 +151,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: $(OBJ) "%(irpdir), + print >>file, "%sirp_touches.irp.o %sirp_checkpoint.irp.o: $(OBJ) "%(irpdir,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) @@ -162,33 +163,6 @@ def run(): print >>file," ".join(mds) -# print >>file, "%sdist_Makefile:"%(irpdir) -# print >>file, "\t- @echo FC=$(FC) > %sdist_Makefile"%(irpdir) -# 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) $(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_IRP) $(OBJ) >> %sdist_Makefile"%(irpdir) - -# print >>file, "%%.dist: %sdist_Makefile"%(irpdir) -# print >>file, "\t- @mkdir -p dist/$*| DO_NOTHING=" -# print >>file, "\t- @cp %s* dist/$*/| DO_NOTHING="%(irpdir) -# print >>file, "\t- @for i in $(ALL) $(OBJ) irp_touches.irp.o $(ALL_OBJ); do rm dist/$*/$$i ; done| DO_NOTHING=" -# print >>file, "\t- @for i in $(ALL) ; do rm dist/$*/$$i.irp.F90 ; done| DO_NOTHING=" -# print >>file, "\t- @rm dist/$*/{*.irp.f,*.mod,irpf90_entities}| DO_NOTHING=" -# print >>file, "\t- @rm dist/$*/*.mod 2>/dev/null| DO_NOTHING=" -# print >>file, "\t- @echo 'EXE = $*' > dist/$*/Makefile| DO_NOTHING=" -# print >>file, "\t- @cat dist/$*/dist_Makefile >> dist/$*/Makefile| DO_NOTHING=" -# print >>file, "\t- @rm dist/$*/dist_Makefile| DO_NOTHING=" -# print >>file, "\t- @cp %s$*.irp.F90 dist/$*/| DO_NOTHING="%(irpdir) -# 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: $(OBJ) "+dir+"%.irp.module.F90" print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o" diff --git a/src/version.py b/src/version.py index 0c46db4..38ec8ed 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.5.1" +version = "1.6.0"