10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-07-21 10:23:28 +02:00

Switched to Python3

This commit is contained in:
Anthony Scemama 2020-01-27 18:22:35 +01:00
parent 02a5f1c3d9
commit 2ea0e86564
37 changed files with 510 additions and 513 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -37,7 +37,7 @@ case "$0" in
echo "source " $0
fi
else
exec python2 $(dirname $0)/../src/irpman.py $1
exec python3 $(dirname $0)/../src/irpman.py $1
fi
;;

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -1,4 +1,4 @@
IRPF90 = python2 ../src/irpf90.py -I input
IRPF90 = python3 ../src/irpf90.py -I input
FC = ifort
FCFLAGS= -O2
NINJA =

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
import sys, os
wd = os.path.abspath(os.path.dirname(__file__))

View File

@ -28,7 +28,7 @@
function run ()
{
cat << EOF | exec python2 - $@
cat << EOF | exec python3 - $@
import sys, os
from irpf90_libs.irpf90_t import mandir

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -25,10 +25,10 @@
# scemama@irsamc.ups-tlse.fr
from irpf90_t import *
from util import *
from variables import variables
from modules import modules
from .irpf90_t import *
from .util import *
from .variables import variables
from .modules import modules
CHECKPOINT_UNIT_NUMBER=63
@ -36,10 +36,10 @@ FILENAME=irpdir+'irp_checkpoint.irp.F90'
def create():
out_write = [ "subroutine irp_checkpoint_write" ]
l = variables.keys()
l = list(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):
main_modules = [x for x in modules if modules[x].is_main]
for m in [x for x in modules if not modules[x].is_main]:
out_write += [ " use %s"%(modules[m].name) ]
out_write += [ " implicit none" ]
out_write += [ " integer, parameter :: iunit = %d"%(CHECKPOINT_UNIT_NUMBER) ]

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -24,8 +24,8 @@
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
from command_line import command_line
import irpf90_t
from .command_line import command_line
from . import irpf90_t
def run():
template = """

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -26,7 +26,7 @@
import getopt, sys
from version import version
from .version import version
import re
description = "IRPF90 Fortran preprocessor."
@ -76,7 +76,7 @@ class CommandLine(object):
for o,a in self.opts:
if o in [ "-I", '--'+options['I'][0] ]:
if len(a) < 1:
print "Error: -I option needs a directory"
print("Error: -I option needs a directory")
if a[-1] != '/':
a = a+'/'
self._include_dir.append(a)
@ -116,12 +116,12 @@ class CommandLine(object):
elif len(buffer) == 3:
self._codelet = [buffer[0], int(buffer[2]), buffer[1], filename]
else:
print """
print("""
Error in codelet definition. Use:
--codelet=provider:NMAX
or
--codelet=provider:precondition:NMAX
"""
""")
sys.exit(1)
return self._codelet
codelet = property(fget=codelet)
@ -209,11 +209,11 @@ Options:
"""
t = t.replace("$EXE",self.executable_name)
t = t.replace("$DESCR",description)
print t
print(t)
print_options()
print ""
print "Version : ", version
print ""
print("")
print("Version : ", version)
print("")
def opts(self):
if self._opts is None:
@ -228,10 +228,10 @@ Options:
try:
self._opts, args = getopt.getopt(self.argv[1:], optlist[0], optlist[1])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
# print help information and exit:
self.usage()
print str(err) # will print something like "option -a not recognized"
print(str(err)) # will print something like "option -a not recognized"
sys.exit(2)
return self._opts
@ -250,7 +250,7 @@ do_$LONG = property(fget=do_$LONG)
"""
for short in options:
long = options[short][0]
exec t.replace("$LONG",long).replace("$SHORT",short) #in locals()
exec(t.replace("$LONG",int).replace("$SHORT",short)) #in locals()
def do_run(self):
if '_do_run' not in self.__dict__:
@ -267,7 +267,7 @@ do_$LONG = property(fget=do_$LONG)
command_line = CommandLine()
def print_options():
keys = options.keys()
keys = list(options.keys())
keys.sort()
import subprocess
for k in keys:
@ -275,8 +275,8 @@ def print_options():
p1 = subprocess.Popen(["fold", "-s", "-w", "40"],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
description = p1.communicate(description)[0]
description = description.replace('\n','\n'.ljust(27))
print ("-%s, --%s"%(k,options[k][0])).ljust(25), description+'\n'
print "\n"
print(("-%s, --%s"%(k,options[k][0])).ljust(25), description+'\n')
print("\n")
if __name__ == '__main__':
print_options()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -25,22 +25,22 @@
# scemama@irsamc.ups-tlse.fr
from variable import Variable
from variables import variables
from subroutine import Sub
from subroutines import subroutines
from irpf90_t import *
from util import *
from .variable import Variable
from .variables import variables
from .subroutine import Sub
from .subroutines import subroutines
from .irpf90_t import *
from .util import *
def do_print_short(file,var):
"""Makes a short print, as in irpf90_entities"""
assert type(var) == Variable
print >>file, "%s : %s :: %s %s"%( \
print("%s : %s :: %s %s"%( \
var.line.filename[0].ljust(35),
var.type.ljust(30),
var.name.ljust(25),
build_dim(var.dim) )
build_dim(var.dim) ), file=file)
######################################################################
def process_doc(file,line):
@ -48,13 +48,13 @@ def process_doc(file,line):
line = line.strip()
if line == "":
line = ".br"
print >>file, line
print(line, file=file)
######################################################################
def process_deps(file,l):
assert type(l) == list
for v in l:
print >>file, "%s\n.br"%(v,)
print("%s\n.br"%(v,), file=file)
######################################################################
def process_types(file,var):
@ -65,7 +65,7 @@ def process_types(file,var):
var = variables[var]
Type = var.type
dim = build_dim(var.dim)
print >>file, "%s\t:: %s\t%s"%(Type,name,dim)
print("%s\t:: %s\t%s"%(Type,name,dim), file=file)
######################################################################
def do_print(var):
@ -73,32 +73,32 @@ def do_print(var):
filename = var.line.filename[0]
name = var.name
file = open("%s%s.l"%(mandir,var.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
print('.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name), file=file)
if var.same_as != var.name:
var = variables[var.same_as]
print >>file, ".SH Declaration"
print >>file, ".nf"
print(".SH Declaration", file=file)
print(".nf", file=file)
process_types(file,var)
print >>file, ".ni"
print(".ni", file=file)
if var.doc != []:
print >>file, ".SH Description"
print(".SH Description", file=file)
for l in var.doc:
process_doc(file,l)
print >>file, ".SH File\n.P"
print >>file, filename
print(".SH File\n.P", file=file)
print(filename, file=file)
if var.needs != []:
var.needs.sort()
print >>file, ".SH Needs"
print(".SH Needs", file=file)
process_deps(file,var.needs)
if var.needed_by != []:
var.needed_by.sort()
print >>file, ".SH Needed by"
print(".SH Needed by", file=file)
process_deps(file,var.needed_by)
print >>file, ".SH Instability factor"
print(".SH Instability factor", file=file)
fo = len(var.children)
fi = len(var.parents)
print >>file, "%5.1f %%"%(100.* (fi / (fi+fo+.000001) ))
print >>file, ".br"
print("%5.1f %%"%(100.* (fi / (fi+fo+.000001) )), file=file)
print(".br", file=file)
file.close()
######################################################################
@ -108,12 +108,12 @@ def do_print_rst(var):
filename = var.line.filename[0]
name = var.name
file = open("%s%s.rst"%(mandir,var.name), "w")
print >>file, ".. c:var:: %s\n"%(var.name.lower())
print >>file, ""
print >>file, " File : :file:`"+filename+"`"
print >>file, ""
print >>file, " .. code:: fortran"
print >>file, ""
print(".. c:var:: %s\n"%(var.name.lower()), file=file)
print("", file=file)
print(" File : :file:`"+filename+"`", file=file)
print("", file=file)
print(" .. code:: fortran", file=file)
print("", file=file)
if var.same_as != var.name:
var = variables[var.same_as]
for v in [var.name] + var.others:
@ -121,9 +121,9 @@ def do_print_rst(var):
v = variables[v]
Type = v.type
dim = build_dim(v.dim)
print >>file, " %s\t:: %s\t%s"%(Type,name,dim)
print >>file, ""
print >>file, ""
print(" %s\t:: %s\t%s"%(Type,name,dim), file=file)
print("", file=file)
print("", file=file)
if var.doc != []:
d = []
@ -146,33 +146,33 @@ def do_print_rst(var):
if loop:
d = [ l[1:] for l in d ]
for line in d:
print >>file, " "+line
print >>file, ""
print(" "+line, file=file)
print("", file=file)
if var.needs != []:
var.needs.sort()
print >>file, " Needs:"
print >>file, ""
print >>file, " .. hlist::"
print >>file, " :columns: 3"
print >>file, ""
print(" Needs:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in var.needs:
print >>file, " * :c:data:`%s`"%(variables[v].same_as.lower(),)
print >>file, ""
print(" * :c:data:`%s`"%(variables[v].same_as.lower(),), file=file)
print("", file=file)
if var.needed_by != []:
var.needed_by.sort()
print >>file, " Needed by:"
print >>file, ""
print >>file, " .. hlist::"
print >>file, " :columns: 3"
print >>file, ""
print(" Needed by:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in var.needed_by:
print >>file, " * :c:data:`%s`"%(variables[v].same_as.lower(),)
print >>file, ""
print(" * :c:data:`%s`"%(variables[v].same_as.lower(),), file=file)
print("", file=file)
file.close()
######################################################################
def process_declaration_subroutine(file, sub):
print >>file, sub.line.text.split('!')[0].strip()
print(sub.line.text.split('!')[0].strip(), file=file)
# for line in sub.text:
######################################################################
@ -181,38 +181,38 @@ def do_print_subroutines(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"
print('.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name), file=file)
print(".SH Declaration", file=file)
print(".nf", file=file)
process_declaration_subroutine(file,sub)
print >>file, ".ni"
print(".ni", file=file)
if sub.doc != []:
print >>file, ".SH Description"
print(".SH Description", file=file)
for l in sub.doc:
process_doc(file,l)
print >>file, ".SH File\n.P"
print >>file, filename
print(".SH File\n.P", file=file)
print(filename, file=file)
if sub.needs != []:
sub.needs.sort()
print >>file, ".SH Needs"
print(".SH Needs", file=file)
process_deps(file,sub.needs)
if sub.called_by != []:
sub.called_by.sort()
print >>file, ".SH Called by"
print(".SH Called by", file=file)
process_deps(file,sub.called_by)
if sub.calls != []:
sub.calls.sort()
print >>file, ".SH Calls"
print(".SH Calls", file=file)
process_deps(file,sub.calls)
if sub.touches != []:
sub.touches.sort()
print >>file, ".SH Touches"
print(".SH Touches", file=file)
process_deps(file,sub.touches)
print >>file, ".SH Instability factor"
print(".SH Instability factor", file=file)
fo = len(sub.needs)+len(sub.calls)+len(sub.touches)
fi = len(sub.called_by)
print >>file, "%5.1f %%"%(100.* (fi / (fi+fo+.000001) ))
print >>file, ".br"
print("%5.1f %%"%(100.* (fi / (fi+fo+.000001) )), file=file)
print(".br", file=file)
file.close()
######################################################################
@ -222,15 +222,15 @@ def do_print_subroutines_rst(sub):
filename = sub.line.filename
name = sub.name
file = open("%s%s.rst"%(mandir,sub.name), "w")
print >>file, ".. c:function:: %s:\n"%(sub.name.lower())
print >>file, ""
print >>file, " File : :file:`"+filename+"`"
print >>file, ""
print >>file, " .. code:: fortran"
print >>file, ""
print >>file, " "+sub.line.text.split('!')[0].strip()
print >>file, ""
print >>file, ""
print(".. c:function:: %s:\n"%(sub.name.lower()), file=file)
print("", file=file)
print(" File : :file:`"+filename+"`", file=file)
print("", file=file)
print(" .. code:: fortran", file=file)
print("", file=file)
print(" "+sub.line.text.split('!')[0].strip(), file=file)
print("", file=file)
print("", file=file)
if sub.doc != []:
d = list(sub.doc)
loop = True
@ -246,63 +246,63 @@ def do_print_subroutines_rst(sub):
if loop:
d = [ l[1:] for l in d ]
for l in d:
print >>file, " "+l
print >>file, ""
print(" "+l, file=file)
print("", file=file)
if sub.needs != []:
sub.needs.sort()
print >>file, " Needs:"
print >>file, ""
print >>file, " .. hlist::"
print >>file, " :columns: 3"
print >>file, ""
print(" Needs:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.needs:
print >>file, " * :c:data:`%s`"%(variables[v].same_as.lower(),)
print >>file, ""
print(" * :c:data:`%s`"%(variables[v].same_as.lower(),), file=file)
print("", file=file)
if sub.called_by != []:
sub.called_by.sort()
print >>file, " Called by:"
print >>file, ""
print >>file, " .. hlist::"
print >>file, " :columns: 3"
print >>file, ""
print(" Called by:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.called_by:
if v in subroutines:
print >>file, " * :c:func:`%s`"%(v.lower(),)
print(" * :c:func:`%s`"%(v.lower(),), file=file)
elif v in variables:
print >>file, " * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),)
print >>file, ""
print(" * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),), file=file)
print("", file=file)
if sub.calls != []:
sub.calls.sort()
print >>file, " Calls:"
print >>file, ""
print >>file, " .. hlist::"
print >>file, " :columns: 3"
print >>file, ""
print(" Calls:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.calls:
print >>file, " * :c:func:`%s`"%(v.lower(),)
print >>file, ""
print(" * :c:func:`%s`"%(v.lower(),), file=file)
print("", file=file)
if sub.touches != []:
sub.touches.sort()
print >>file, " Touches:"
print >>file, ""
print >>file, " .. hlist::"
print >>file, " :columns: 3"
print >>file, ""
print(" Touches:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.touches:
print >>file, " * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),)
print >>file, ""
print(" * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),), file=file)
print("", file=file)
file.close()
######################################################################
def run():
import parsed_text
from . import parsed_text
import os,sys
pid1 = os.fork()
if pid1 == 0:
for v in variables.values():
for v in list(variables.values()):
do_print(v)
do_print_rst(v)
for s in subroutines.values():
for s in list(subroutines.values()):
do_print_subroutines(s)
do_print_subroutines_rst(s)
sys.exit(0)
@ -310,7 +310,7 @@ def run():
pid2 = os.fork()
if pid2 == 0:
tags = []
l = variables.keys()
l = list(variables.keys())
file = open("irpf90_entities","w")
l.sort()
for v in l:
@ -318,7 +318,7 @@ def run():
line = variables[v].line
tags.append( '%s\t%s\t%d\n'%(v,line.filename[0],line.i) )
file.close()
l = subroutines.keys()
l = list(subroutines.keys())
for v in l:
line = subroutines[v].line
tags.append('%s\t%s\t%d\n'%(v,line.filename,line.i))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -26,20 +26,20 @@
import sys
from irpf90_t import *
from command_line import command_line
from .irpf90_t import *
from .command_line import command_line
do_warnings = command_line.do_warnings
######################################################################
def fail(line,message):
print """
print("""
Error:
-----
"""
print message, '\n'
""")
print(message, '\n')
if line is not None:
assert isinstance(line,Line)
print "file %s ; line %d :\n %s"%(line.filename,line.i,line.text)
print("file %s ; line %d :\n %s"%(line.filename,line.i,line.text))
sys.exit(1)
@ -49,14 +49,14 @@ def warn(line,message):
return
if line is not None:
assert isinstance(line,Line)
print """
print("""
Warning:
-------
"""
print message, '\n'
print "file %s, line %d:\n %s"%(line.filename,line.i,line.text)
""")
print(message, '\n')
print("file %s, line %d:\n %s"%(line.filename,line.i,line.text))
else:
print "Warning: %s"%(message)
print("Warning: %s"%(message))
######################################################################

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -27,10 +27,10 @@
import os
import util
import makefile
import irpf90_t
from command_line import command_line
from . import util
from . import makefile
from . import irpf90_t
from .command_line import command_line
initialized = False
@ -67,7 +67,7 @@ def init():
try:
os.stat(dir)
except:
print dir,'not in dir'
print(dir,'not in dir')
continue
for filename in os.listdir(dir):
filename = dir+filename
@ -76,7 +76,7 @@ def init():
file = open(filename,"r")
except IOError:
if command_line.do_warnings:
print "Warning : Unable to read file %s."%(filename)
print("Warning : Unable to read file %s."%(filename))
else:
buffer = file.read()
file.close()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -25,14 +25,14 @@
# scemama@irsamc.ups-tlse.fr
import util
from command_line import command_line
from . import util
from .command_line import command_line
do_debug = command_line.do_debug
do_openmp = command_line.do_openmp
do_memory = command_line.do_memory
import irpf90_t
from . import irpf90_t
FILENAME = irpf90_t.irpdir+"irp_stack.irp.F90"
@ -149,7 +149,7 @@ end subroutine
"""
txt = txt.split('\n')
txt = map(lambda x: x+"\n",txt)
txt = [x+"\n" for x in txt]
if not util.same_file(FILENAME, txt):
file = open(FILENAME,'w')
file.writelines(txt)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -26,7 +26,7 @@
import vim
from . import vim
import os,sys
try:
wd = os.path.abspath(os.path.dirname(__file__))
@ -35,7 +35,7 @@ except:
pass
sys.setcheckinterval(1000)
from command_line import command_line
from .command_line import command_line
def main():
@ -45,33 +45,33 @@ def main():
command_line.usage()
if command_line.do_version:
from version import version
print version
from .version import version
print(version)
from init import init
from .init import init
if command_line.do_init:
init()
if command_line.do_preprocess:
init()
from preprocessed_text import preprocessed_text
from .preprocessed_text import preprocessed_text
for filename,text in preprocessed_text:
if filename in command_line.preprocessed:
for line in text:
print line.text
print(line.text)
if command_line.do_touch:
from variables import variables
from .variables import variables
for var in command_line.touched:
if var not in variables:
print "%s is not an IRP entity"%(var,)
print("%s is not an IRP entity"%(var,))
else:
print "Touching %s invalidates the following entities:"%(var,)
print("Touching %s invalidates the following entities:"%(var,))
parents = variables[var].parents
parents.sort()
for x in parents:
print "- %s"%(x,)
print("- %s"%(x,))
if not command_line.do_run:
@ -79,39 +79,39 @@ def main():
init()
import irp_stack
from . import irp_stack
irp_stack.create()
import makefile
from . import makefile
makefile.create()
if command_line.do_codelet:
import profile
from . import profile
profile.build_rdtsc()
import codelet
from . import codelet
codelet.run()
from modules import modules, write_module
for m in modules.keys():
from .modules import modules, write_module
for m in list(modules.keys()):
write_module(modules[m])
makefile.run()
import touches
from . import touches
touches.create()
# import checkpoint
# checkpoint.create()
import create_man
from . import create_man
create_man.run()
if command_line.do_profile:
import profile
from . import profile
profile.run()
if command_line.do_openmp:
import locks
from . import locks
locks.create()
if __name__ == '__main__':

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -169,21 +169,21 @@ class indent(object):
line = self.format_continuation(line,k)
if grep.continuation(prevline):
print k+2*tab+self.format_continuation(line,k+2*tab)
print(k+2*tab+self.format_continuation(line,k+2*tab))
continue
if grep.begin_subroutine(line):
print line
print(line)
k = indent0+tab
continue
if grep.begin_function(line):
print line
print(line)
k = indent0+tab
continue
if grep.begin_program(line):
print line
print(line)
k = indent0+tab
continue
@ -191,76 +191,76 @@ class indent(object):
if line[0] != '&':
k = indent0+tab
if grep.begin_provider(self.text[i+1].strip()):
print " "+line
print(" "+line)
else:
print line
print(line)
else:
print line
print(line)
continue
if grep.declaration(line):
print k+self.format_declaration(line,30)
print(k+self.format_declaration(line,30))
continue
if grep.begin_do(line):
print k+line
print(k+line)
k += tab
continue
if grep.begin_if(line):
print k+line
print(k+line)
k += tab
continue
if grep.xelse(line):
print k[:-tabn]+line
print(k[:-tabn]+line)
continue
if grep.begin_select(line):
print k+line
print(k+line)
k += 2*tab
continue
if grep.case(line):
print k[:-tabn]+line
print(k[:-tabn]+line)
continue
if grep.end_do(line):
k = k[:-tabn]
print k+line
print(k+line)
continue
if grep.end_if(line):
k = k[:-tabn]
print k+line
print(k+line)
continue
if grep.end_select(line):
k = k[:-2*tabn]
print k+line
print(k+line)
continue
if grep.end_subroutine(line):
print line
print(line)
k = indent0
continue
if grep.end_function(line):
print line
print(line)
k = indent0
continue
if grep.end_provider(line):
print line
print(line)
k = indent0
continue
if grep.end_program(line):
print line
print(line)
k = indent0
continue
print k+line
print(k+line)
def main():

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -387,15 +387,15 @@ class Provide_all (Line):
def create_irpf90_files():
result = []
from command_line import command_line
from .command_line import command_line
import os
def is_irpf90_file(filename):
return filename.endswith(".irp.f") and not filename.startswith('.')
result = filter ( is_irpf90_file, os.listdir(os.getcwd()) )
result = list(filter ( is_irpf90_file, os.listdir(os.getcwd()) ))
for dir in command_line.include_dir:
try:
os.stat(dir)
result += map(lambda x: dir+x, filter ( is_irpf90_file, os.listdir(dir) ) )
result += [dir+x for x in list(filter ( is_irpf90_file, os.listdir(dir) ))]
except:
continue
if command_line.do_codelet:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -29,10 +29,10 @@ import os
import sys
wd = os.path.abspath(os.path.dirname(__file__))
from irpf90_t import mandir
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])
print("%s does not exist"%(sys.argv[1]))
sys.exit(-1)
os.system("man ./"+mandir+sys.argv[1].lower()+".l")

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -25,16 +25,16 @@
# scemama@irsamc.ups-tlse.fr
from command_line import command_line
from .command_line import command_line
from irpf90_t import *
from util import *
from variables import variables
from .irpf90_t import *
from .util import *
from .variables import variables
FILENAME=irpdir+'irp_locks.irp.F90'
def create():
out = []
l = variables.keys()
l = list(variables.keys())
l.sort
for v in l:
var = variables[v]
@ -47,7 +47,7 @@ def create():
out += [ " call irp_lock_%s(.True.)"%v ]
out += [ " call irp_lock_%s(.False.)"%v ]
out += [ "end subroutine" ]
out = map(lambda x: "%s\n"%(x),out)
out = ["%s\n"%(x) for x in out]
if not same_file(FILENAME,out):
file = open(FILENAME,'w')
file.writelines(out)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -26,8 +26,8 @@
import os,sys
import irpf90_t
from command_line import command_line
from . import irpf90_t
from .command_line import command_line
irpdir = irpf90_t.irpdir
mandir = irpf90_t.mandir
@ -82,14 +82,14 @@ def create_gitignore():
######################################################################
def run_ninja():
import ninja
from . import ninja
ninja.run()
######################################################################
def run_make():
from modules import modules
from .modules import modules
mod = []
for m in modules.values():
for m in list(modules.values()):
mod.append(m)
file = open(IRPF90_MAKE,'w')
@ -108,41 +108,41 @@ def run_make():
for m in mod:
result += " %s%s.irp.F90"%(irpdir,m.filename)
result += " %s%s.irp.module.F90"%(irpdir,m.filename)
print >>file, result
print(result, file=file)
result = "OBJ_IRP = %sirp_stack.irp.o "%(irpdir)
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(result, file=file)
print >>file, "OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o "%(irpdir),
print("OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o "%(irpdir), end=' ', file=file)
# print >>file, " %sirp_checkpoint.irp.o"%(irpdir),
if command_line.do_profile:
print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o",
print(" %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", end=' ', file=file)
if command_line.do_codelet:
print >>file, " irp_rdtsc.o",
print(" irp_rdtsc.o", end=' ', file=file)
if command_line.do_openmp:
print >>file, " %sirp_locks.irp.o"%(irpdir)
print(" %sirp_locks.irp.o"%(irpdir), file=file)
else:
print >>file, ""
print("", file=file)
all = filter(lambda x: modules[x].is_main, modules)
all = map(lambda x: x[:-6], 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)
print >>file, "all:$(ALL)"
print >>file, "\t@$(MAKE) -s move"
all = [x for x in modules if modules[x].is_main]
all = [x[:-6] for x in all]
all_o = ["%s.irp.module.o %s.irp.o"%(x,x) for x in all]
print("ALL = %s"%(" ".join(all)), file=file)
print("ALL_OBJ = %s"%(" ".join(all_o)), file=file)
print("ALL_OBJ1 = $(patsubst %%, %s%%,$(notdir $(ALL_OBJ)))"%(irpdir), file=file)
print("all:$(ALL)", file=file)
print("\t@$(MAKE) -s move", file=file)
# print >>file, "ifdef USE_IRPF90_A"
for m in mod:
if m.is_main:
exe = m.filename
print >>file, "%s: %s%s.irp.o %s%s.irp.module.o IRPF90_temp/irpf90.a"%(exe,irpdir,exe,irpdir,exe)
print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o IRPF90_temp/irpf90.a $(LIB)"%(irpdir,irpdir)
print >>file, "\t@$(MAKE) -s move"
print("%s: %s%s.irp.o %s%s.irp.module.o IRPF90_temp/irpf90.a"%(exe,irpdir,exe,irpdir,exe), file=file)
print("\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o IRPF90_temp/irpf90.a $(LIB)"%(irpdir,irpdir), file=file)
print("\t@$(MAKE) -s move", file=file)
# print >>file, "else"
# for m in mod:
# if m.is_main:
@ -155,43 +155,43 @@ def run_make():
buffer = ""
for m in mod:
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)
print >>file, filename," ".join(mds)," ".join(m.includes)
needed_modules = [x for x in modules if modules[x].name in m.needed_modules]
needed_files = [modules[x].filename for x in needed_modules]
mds = [" %s%s.irp.module.o"%(irpdir,x) for x in needed_files]
print(filename," ".join(mds)," ".join(m.includes), file=file)
if not m.is_main:
buffer += "\t - @echo '"+filename+" ".join(mds)+"' >> %sdist_Makefile\n"%(irpdir)
# print >>file, "%sirp_touches.irp.o %sirp_checkpoint.irp.o: $(OBJ) "%(irpdir,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)
print("%sirp_touches.irp.o: $(OBJ) "%(irpdir), end=' ', file=file)
mds = [x for x in mod if not x.is_main]
mds = [" %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename) for x in mds]
print(" ".join(mds), file=file)
if command_line.do_profile:
print >>file, "%sirp_profile.irp.o:"%(irpdir),
print >>file," ".join(mds)
print("%sirp_profile.irp.o:"%(irpdir), end=' ', file=file)
print(" ".join(mds), file=file)
if command_line.do_openmp:
print >>file, "%sirp_locks.irp.o:"%(irpdir),
print >>file," ".join(mds)
print("%sirp_locks.irp.o:"%(irpdir), end=' ', file=file)
print(" ".join(mds), file=file)
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"
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: $(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"
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