10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-10-30 10:48:15 +01:00

Compiles with Python3

This commit is contained in:
Anthony Scemama 2020-01-27 18:43:22 +01:00
parent 2ea0e86564
commit 8b773a9d45
25 changed files with 141 additions and 138 deletions

View File

@ -0,0 +1,4 @@
# For relative imports to work in Python 3.6
import os, sys
sys.path = [ os.path.dirname(os.path.realpath(__file__)) ] + sys.path

View File

@ -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

View File

@ -24,8 +24,8 @@
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
from .command_line import command_line
from . import irpf90_t
from command_line import command_line
import irpf90_t
def run():
template = """

View File

@ -26,7 +26,7 @@
import getopt, sys
from .version import version
from version import version
import re
description = "IRPF90 Fortran preprocessor."
@ -248,9 +248,9 @@ def do_$LONG(self):
return self._do_$LONG
do_$LONG = property(fget=do_$LONG)
"""
for short in options:
long = options[short][0]
exec(t.replace("$LONG",int).replace("$SHORT",short)) #in locals()
for short_opt in options:
long_opt = options[short_opt][0]
exec(t.replace("$LONG",long_opt).replace("$SHORT",short_opt)) #in locals()
def do_run(self):
if '_do_run' not in self.__dict__:

View File

@ -25,12 +25,12 @@
# 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):
@ -295,7 +295,7 @@ def do_print_subroutines_rst(sub):
######################################################################
def run():
from . import parsed_text
import parsed_text
import os,sys
pid1 = os.fork()
if pid1 == 0:

View File

@ -26,8 +26,8 @@
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
######################################################################

View File

@ -27,10 +27,10 @@
import os
from . import util
from . import makefile
from . import irpf90_t
from .command_line import command_line
import util
import makefile
import irpf90_t
from command_line import command_line
initialized = False

View File

@ -25,14 +25,14 @@
# scemama@irsamc.ups-tlse.fr
from . import util
from .command_line import command_line
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
from . import irpf90_t
import irpf90_t
FILENAME = irpf90_t.irpdir+"irp_stack.irp.F90"

View File

@ -26,16 +26,15 @@
from . import vim
import vim
import os,sys
try:
wd = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0,(wd+"/../src/"))
except:
pass
sys.setcheckinterval(1000)
from .command_line import command_line
from command_line import command_line
def main():
@ -45,16 +44,16 @@ def main():
command_line.usage()
if command_line.do_version:
from .version import 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:
@ -62,7 +61,7 @@ def main():
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,))
@ -79,39 +78,39 @@ def main():
init()
from . import irp_stack
import irp_stack
irp_stack.create()
from . import makefile
import makefile
makefile.create()
if command_line.do_codelet:
from . import profile
import profile
profile.build_rdtsc()
from . import codelet
import codelet
codelet.run()
from .modules import modules, write_module
from modules import modules, write_module
for m in list(modules.keys()):
write_module(modules[m])
makefile.run()
from . import touches
import touches
touches.create()
# import checkpoint
# checkpoint.create()
from . import create_man
import create_man
create_man.run()
if command_line.do_profile:
from . import profile
import profile
profile.run()
if command_line.do_openmp:
from . import locks
import locks
locks.create()
if __name__ == '__main__':

View File

@ -29,7 +29,7 @@ from zlib import crc32
irpdir = "IRPF90_temp/"
mandir = "IRPF90_man/"
irp_id = abs(crc32(os.getcwd()))
irp_id = abs(crc32(os.getcwd().encode()))
class Line(object):
@ -387,7 +387,7 @@ 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('.')

View File

@ -29,7 +29,7 @@ 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]))

View File

@ -25,11 +25,11 @@
# 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():

View File

@ -26,8 +26,8 @@
import os,sys
from . import irpf90_t
from .command_line import command_line
import irpf90_t
from command_line import command_line
irpdir = irpf90_t.irpdir
mandir = irpf90_t.mandir
@ -82,12 +82,12 @@ def create_gitignore():
######################################################################
def run_ninja():
from . import ninja
import ninja
ninja.run()
######################################################################
def run_make():
from .modules import modules
from modules import modules
mod = []
for m in list(modules.values()):
mod.append(m)

View File

@ -25,12 +25,12 @@
# scemama@irsamc.ups-tlse.fr
from .irpf90_t import *
from .variable import *
from .variables import variables
from .command_line import command_line
from . import preprocessed_text
from .util import *
from irpf90_t import *
from variable import *
from variables import variables
from command_line import command_line
import preprocessed_text
from util import *
class Fmodule(object):
@ -67,7 +67,7 @@ class Fmodule(object):
def variables(self):
if '_variables' not in self.__dict__:
from .variables import variables
from variables import variables
name = self.name
self._variables = [x for x in variables if variables[x].fmodule == name]
return self._variables
@ -119,8 +119,8 @@ class Fmodule(object):
def residual_text(self):
if '_residual_text' not in self.__dict__:
from .variables import build_use, call_provides
from .parsed_text import move_to_top
from variables import build_use, call_provides
from parsed_text import move_to_top
def remove_providers(text):
result = []
inside = False
@ -215,7 +215,7 @@ class Fmodule(object):
######################################################################
if __name__ == '__main__':
from .parsed_text import parsed_text
from parsed_text import parsed_text
for filename, text in parsed_text:
if filename == 'vmc_step.irp.f':
x = Fmodule(text,filename)

View File

@ -25,10 +25,10 @@
# scemama@irsamc.ups-tlse.fr
from .irpf90_t import *
from .parsed_text import parsed_text
from .module import Fmodule
from .util import *
from irpf90_t import *
from parsed_text import parsed_text
from module import Fmodule
from util import *
######################################################################
def create_modules():

View File

@ -26,9 +26,9 @@
import os,sys
from . import irpf90_t
from .command_line import command_line
from .modules import modules
from import irpf90_t
from command_line import command_line
from modules import modules
irpdir = irpf90_t.irpdir
mandir = irpf90_t.mandir
irp_id = irpf90_t.irp_id
@ -257,7 +257,7 @@ veryclean: clean
""".format(irpdir, targets)
from . import makefile
import makefile
with open(makefile.IRPF90_MAKE,'w') as file:
file.write(result)

View File

@ -25,13 +25,13 @@
# scemama@irsamc.ups-tlse.fr
from .util import *
from .irpf90_t import *
from .variables import variables
from .preprocessed_text import preprocessed_text
from .subroutines import subroutines
from util import *
from irpf90_t import *
from variables import variables
from preprocessed_text import preprocessed_text
from subroutines import subroutines
import regexps, re
from . import error
import error
vtuple = [(v, variables[v].same_as, variables[v].regexp) for v in list(variables.keys())]
stuple = [(s, subroutines[s].regexp) for s in list(subroutines.keys())]
@ -497,7 +497,7 @@ parsed_text = result
######################################################################
from .command_line import command_line
from command_line import command_line
def check_opt():
if not command_line.do_checkopt:

View File

@ -24,11 +24,11 @@
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
from .irpf90_t import *
from .regexps import *
from . import error
from .command_line import command_line
from .util import *
from irpf90_t import *
from regexps import *
import error
from command_line import command_line
from util import *
# Local regular expressions
re_endif = re.compile("end\s+if")

View File

@ -45,7 +45,7 @@ import subprocess
import tempfile
import os
import threading
from .irpf90_t import irpdir
from irpf90_t import irpdir
def build_rdtsc():
filename = irpdir+"irp_rdtsc.c"
@ -60,7 +60,7 @@ def build_rdtsc():
threading.Thread(target=t).start()
def build_module():
from .variables import variables
from variables import variables
data = """
module irp_timer
double precision :: irp_profile(3,%(n)d)

View File

@ -25,9 +25,9 @@
# scemama@irsamc.ups-tlse.fr
from .irpf90_t import *
from .util import *
from . import error
from irpf90_t import *
from util import *
import error
class Sub(object):
@ -75,7 +75,7 @@ class Sub(object):
############################################################
def touches(self):
if '_touches' not in self.__dict__:
from .subroutines import subroutines
from subroutines import subroutines
self._touches = []
for line in [x for x in self.text if type(x) in [Touch, SoftTouch]]:
self._touches += line.text.split()[1:]
@ -89,7 +89,7 @@ class Sub(object):
############################################################
def needs(self):
if '_needs' not in self.__dict__:
from . import parsed_text
import parsed_text
self._needs = make_single(self._needs)
return self._needs
needs = property(needs)
@ -97,7 +97,7 @@ class Sub(object):
############################################################
def to_provide(self):
if '_to_provide' not in self.__dict__:
from . import parsed_text
import parsed_text
return self._to_provide
to_provide = property(to_provide)
@ -124,8 +124,8 @@ class Sub(object):
######################################################################
if __name__ == '__main__':
from .preprocessed_text import preprocessed_text
from .variables import variables
from .subroutines import subroutines
from preprocessed_text import preprocessed_text
from variables import variables
from subroutines import subroutines
print([variables[x].needs for x in subroutines['full_ci'].needs])
print(subroutines['full_ci'].calls)

View File

@ -25,14 +25,14 @@
# scemama@irsamc.ups-tlse.fr
from .util import *
from .subroutine import *
from .variables import variables
from .variable import Variable
from .irpf90_t import *
from util import *
from subroutine import *
from variables import variables
from variable import Variable
from irpf90_t import *
def create_subroutines():
from .preprocessed_text import preprocessed_text
from preprocessed_text import preprocessed_text
result = {}
for filename, text in preprocessed_text:
buffer = []

View File

@ -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
FILENAME=irpdir+'irp_touches.irp.F90'

View File

@ -68,7 +68,7 @@ def build_dim_colons(v):
return "(%s)"%(','.join(x))
from . import error
import error
def find_subname(line):
buffer = line.lower
if not buffer.endswith(')'):
@ -119,7 +119,7 @@ def put_info(text,filename):
assert type(text) == list
if len(text) > 0:
assert type(text[0]) == tuple
from .irpf90_t import Line
from irpf90_t import Line
assert type(text[0][0]) == list
assert isinstance(text[0][1], Line)
lenmax = 80 - len(filename)

View File

@ -25,10 +25,10 @@
# scemama@irsamc.ups-tlse.fr
from .irpf90_t import *
from .util import *
from . import error
from .command_line import command_line
from irpf90_t import *
from util import *
import error
from command_line import command_line
class Variable(object):
@ -45,7 +45,7 @@ class Variable(object):
############################################################
def is_touched(self):
if '_is_touched' not in self.__dict__:
from .variables import variables
from variables import variables
result = self.is_read
for i in self.children:
if variables[i].is_touched:
@ -66,7 +66,7 @@ class Variable(object):
############################################################
def is_written(self):
if '_is_written' not in self.__dict__:
from .variables import variables
from variables import variables
result = False
for i in self.parents:
if variables[i].is_written:
@ -79,7 +79,7 @@ class Variable(object):
############################################################
def is_read(self):
if '_is_read' not in self.__dict__:
from .variables import variables
from variables import variables
result = False
for i in self.parents:
if variables[i].is_read:
@ -187,7 +187,7 @@ dimension.
if not self.is_main:
self._allocate = []
else:
from .variables import variables
from variables import variables
def f(var):
return variables[var].dim != []
self._allocate = list(filter ( f, self.others + [self.name] ))
@ -276,10 +276,10 @@ dimension.
if not self.is_main:
self._toucher = []
else:
from .modules import modules
from .variables import variables
from modules import modules
from variables import variables
if '_needed_by' not in self.__dict__:
from . import parsed_text
import parsed_text
parents = self.parents
parents.sort()
mods = [variables[x].fmodule for x in parents]
@ -309,8 +309,8 @@ dimension.
if not command_line.do_openmp:
self._locker = []
else:
from .modules import modules
from .variables import variables
from modules import modules
from variables import variables
name = self.name
result = [ "subroutine irp_lock_%s(set)"%(name) ]
result += [ " use omp_lib",
@ -348,8 +348,8 @@ dimension.
self._reader = []
else:
if '_needs' not in self.__dict__:
from . import parsed_text
from .variables import variables
import parsed_text
from variables import variables
name = self.name
result = [ \
"subroutine reader_%s(irp_num)"%(name),
@ -393,9 +393,9 @@ dimension.
if not self.is_main:
self._writer = []
else:
from .variables import variables
from variables import variables
if '_needs' not in self.__dict__:
from . import parsed_text
import parsed_text
name = self.name
result = [ \
"subroutine writer_%s(irp_num)"%(name),
@ -464,8 +464,8 @@ dimension.
self._provider = []
else:
if '_to_provide' not in self.__dict__:
from . import parsed_text
from .variables import variables, build_use, call_provides
import parsed_text
from variables import variables, build_use, call_provides
name = self.name
same_as = self.same_as
@ -576,8 +576,8 @@ dimension.
if not self.is_main:
self._builder = []
else:
from . import parsed_text
from .variables import build_use, call_provides
import parsed_text
from variables import build_use, call_provides
for filename,buffer in parsed_text.parsed_text:
if self.line.filename[0].startswith(filename):
break
@ -642,9 +642,9 @@ dimension.
if '_children' not in self.__dict__:
if not self.is_main:
self._children = []
from .variables import variables
from variables import variables
if '_needs' not in self.__dict__:
from . import parsed_text
import parsed_text
result = []
for x in self.needs:
result.append(x)
@ -664,9 +664,9 @@ dimension.
if not self.is_main:
self._parents = []
else:
from .variables import variables
from variables import variables
if '_needed_by' not in self.__dict__:
from . import parsed_text
import parsed_text
result = []
for x in self.needed_by:
result.append(x)
@ -682,8 +682,8 @@ dimension.
######################################################################
if __name__ == '__main__':
from .preprocessed_text import preprocessed_text
from .variables import variables
from preprocessed_text import preprocessed_text
from variables import variables
#for v in variables.keys():
# print v
def print_dot(x,done):

View File

@ -25,14 +25,14 @@
# scemama@irsamc.ups-tlse.fr
from .variable import *
from .irpf90_t import *
from .command_line import command_line
from .util import *
from variable import *
from irpf90_t import *
from command_line import command_line
from util import *
######################################################################
def create_variables():
from .preprocessed_text import preprocessed_text
from preprocessed_text import preprocessed_text
result = {}
icount = 0
for filename, text in preprocessed_text: