summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>2009-12-14 11:11:48 +0100
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>2009-12-14 11:11:48 +0100
commite43b0ae081492d91bec6e150706d74b20e88abe2 (patch)
tree13b50e4b55a396ae59092d5a866cf7e9e31de02c
parent3f95cc5afaf474b79b7b9708b20f18ea6a52b4e5 (diff)
downloadcython-e43b0ae081492d91bec6e150706d74b20e88abe2.tar.gz
Remove fwrap (moved to http://hg.cython.org/fwrap-dev)
-rw-r--r--Tools/fwrap/Code.py164
-rw-r--r--Tools/fwrap/Main.py141
-rw-r--r--Tools/fwrap/Visitor.py1035
-rw-r--r--Tools/fwrap/WrapperArgs.py646
-rw-r--r--Tools/fwrap/__init__.py0
-rwxr-xr-xTools/fwrap/fwrap.py4
-rw-r--r--Tools/fwrap/fwrap_setup.py157
-rw-r--r--Tools/fwrap/runtests.py910
-rw-r--r--Tools/fwrap/tests/bugs.txt2
-rw-r--r--Tools/fwrap/tests/bugs/all_complex.f9548
-rw-r--r--Tools/fwrap/tests/bugs/all_complex_fwrap_doctest.py14
-rw-r--r--Tools/fwrap/tests/bugs/othermod.f957
-rw-r--r--Tools/fwrap/tests/bugs/use_module.f9583
-rw-r--r--Tools/fwrap/tests/bugs/use_module_fwrap_doctest.py6
-rw-r--r--Tools/fwrap/tests/compile/default_types.f9512
-rw-r--r--Tools/fwrap/tests/compile/int_args.f95151
-rw-r--r--Tools/fwrap/tests/compile/intargs_stuff/drive_int_args.c28
-rw-r--r--Tools/fwrap/tests/compile/intargs_stuff/wrap_int_args.f9596
-rw-r--r--Tools/fwrap/tests/compile/old_decl.f9518
-rw-r--r--Tools/fwrap/tests/compile/test_scope.f9552
-rw-r--r--Tools/fwrap/tests/run/all_ints.f9569
-rw-r--r--Tools/fwrap/tests/run/all_ints_fwrap_doctest.py14
-rw-r--r--Tools/fwrap/tests/run/all_logicals.f9593
-rw-r--r--Tools/fwrap/tests/run/all_logicals_fwrap_doctest.py14
-rw-r--r--Tools/fwrap/tests/run/all_reals.f9556
-rw-r--r--Tools/fwrap/tests/run/all_reals_fwrap_doctest.py14
-rw-r--r--Tools/fwrap/tests/run/default_types.f9512
-rw-r--r--Tools/fwrap/tests/run/default_types_fwrap_doctest.py4
-rw-r--r--Tools/fwrap/tests/run/int_args.f95151
-rw-r--r--Tools/fwrap/tests/run/int_args_fwrap_doctest.py8
-rw-r--r--Tools/fwrap/tests/run/old_decl.f9518
-rw-r--r--Tools/fwrap/tests/run/old_decl_fwrap_doctest.py6
-rw-r--r--Tools/fwrap/tests/run/simple_array.f95102
-rw-r--r--Tools/fwrap/utils.py16
34 files changed, 0 insertions, 4151 deletions
diff --git a/Tools/fwrap/Code.py b/Tools/fwrap/Code.py
deleted file mode 100644
index ec2dceb86..000000000
--- a/Tools/fwrap/Code.py
+++ /dev/null
@@ -1,164 +0,0 @@
-from Cython.StringIOTree import StringIOTree
-from cStringIO import StringIO
-
-INDENT = " "
-LINE_LENGTH = 79
-BREAK_CHARS = (' ', '\t', ',', '!')
-COMMENT_CHAR = '!'
-
-def break_line(line, level, max_len):
-
- line = INDENT*level+line
-
- if len(line) <= max_len:
- return [line, '']
-
- # break up line.
- in_comment = False
- in_string = False
- in_escape = False
- last_break_pos = -1
- for idx, ch in enumerate(line):
- if idx+1 > max_len:
- if last_break_pos < 0:
- raise RuntimeError("line too long and unable to break it up.")
- return [line[:last_break_pos]] + break_line(line[last_break_pos:], level, max_len)
-
- if ch in BREAK_CHARS and not in_comment and not in_string:
- last_break_pos = idx
-
- if ch == COMMENT_CHAR and not in_comment and not in_string:
- in_comment = True
- elif ch in ('"', "'") and not in_string and not in_comment:
- in_string = True
- elif ch in ('"', "'") and in_string and not in_escape and not in_comment:
- in_string = False
-
- if ch == '\\' and not in_escape:
- in_escape = True
- elif in_escape:
- in_escape = False
-
-class CodeWriter(object):
-
- def __init__(self, level, writer=None, **kwargs):
- if writer is None:
- self.sit = StringIOTree(**kwargs)
- else:
- self.sit = writer
- self.level = level
-
- def putln(self, line):
- self.sit.write(INDENT*self.level+line+"\n")
-
- def put(self, chunk, indent=False):
- if indent:
- chunk = ('\n'+INDENT*self.level).join(chunk.split('\n'))
- self.sit.write(chunk)
-
- def insertion_point(self, level=None):
- if level is None:
- level = self.level
- return type(self)(level, writer=self.sit.insertion_point())
-
- def insert(self, writer):
- self.sit.insert(writer.sit)
-
- def tell(self):
- return self.sit.stream.tell()
-
- def __getattr__(self, attr):
- return getattr(self.sit, attr)
-
-class FortranCodeWriter(CodeWriter):
-
- def putln(self, line, max_len=LINE_LENGTH):
-
- if len(line) <= max_len:
- self.sit.write(INDENT*self.level+line+"\n")
- else:
- multiline = "&\n".join([ln for ln in break_line(line, self.level, max_len) if ln])
- self.sit.write(multiline+'\n')
-
-class CompositeCodeBase(object):
-
- def __init__(self, level=0, writer=CodeWriter):
- self.level = level
- self.root = writer(level)
-
- def copyto(self, target):
- self.root.copyto(target)
-
- def getvalue(self):
- return self.root.getvalue()
-
-class UtilityCode(CompositeCodeBase):
- pass
-
-class InterfaceCode(CompositeCodeBase):
-
- def __init__(self, level=0):
- CompositeCodeBase.__init__(self, level, writer=FortranCodeWriter)
- self.has_subprogs = False
- self.top = self.root.insertion_point(level)
- self.block_start = self.root.insertion_point(level)
- self.use_stmts = self.root.insertion_point(level+1)
- self.declarations = self.root.insertion_point(level+1)
- self.block_end = self.root.insertion_point(level)
- self.bottom = self.root.insertion_point(level)
-
-class CompositeBlock(CompositeCodeBase):
- '''
- Base class for all Module, SubProgram (functions/subroutines) & program
- code blocks.
- '''
-
- def __init__(self, level=0):
- CompositeCodeBase.__init__(self, level, writer=FortranCodeWriter)
- self.has_subprogs = False
- self.top = self.root.insertion_point(level)
- self.block_start = self.root.insertion_point(level)
- self.use_stmts = self.root.insertion_point(level+1)
- self.implicit_none = self.root.insertion_point(level+1)
- self.declarations = self.root.insertion_point(level+1)
- self.executable_stmts = self.root.insertion_point(level+1)
- self.subprograms = self.root.insertion_point(level+1)
- self.block_end = self.root.insertion_point(level)
- self.bottom = self.root.insertion_point(level)
-
- self.implicit_none.putln("implicit none")
-
- def add_subprogram_block(self, subp):
- if not self.has_subprogs:
- self.has_subprogs = True
- self.subprograms.putln("contains")
- self.subprograms.insert(subp.root)
-
- def add_declaration_block(self, dec):
- self.declarations.insert(dec.root)
-
-class ModuleCode(CompositeBlock):
-
- block_type_str = "module"
-
-class SubProgramCode(CompositeBlock):
- pass
-
-class FunctionCode(SubProgramCode):
-
- block_type_str = "function"
-
-class SubroutineCode(SubProgramCode):
-
- block_type_str = "subroutine"
-
-class ProgramCode(CompositeBlock):
-
- block_type_str = "program"
-
-class CySuiteCode(CompositeCodeBase):
-
- def __init__(self, level=0):
- CompositeCodeBase.__init__(self, level)
- self.suite_start = self.root.insertion_point(level)
- self.suite_body = self.root.insertion_point(level+1)
diff --git a/Tools/fwrap/Main.py b/Tools/fwrap/Main.py
deleted file mode 100644
index 52552e69a..000000000
--- a/Tools/fwrap/Main.py
+++ /dev/null
@@ -1,141 +0,0 @@
-import os, sys, shutil
-from fparser import api
-from fparser import block_statements
-from Visitor import PrintTree, KindResolutionVisitor, \
- AutoConfigGenerator, FortranWrapperGenerator, \
- CHeaderGenerator, PxdGenerator, CyHeaderGenerator, \
- CyImplGenerator
-
-def main():
- from optparse import OptionParser
- parser = OptionParser()
- parser.add_option('--outdir', dest='outdir', default=os.path.curdir, help='base of output directory')
- parser.add_option('--indir', dest='indir', default=os.path.curdir, help='directory of fortran source files')
- parser.add_option('--projname', dest='projectname', default='fwrap_default', help='name of fwrap project -- will be the name of the directory.')
- options, sources = parser.parse_args()
-
- wrap(sources, options.outdir, options.indir, options.projectname)
-
-
-
-def setup_project(projectname, src_dir, outdir):
- fq_projdir = os.path.join(outdir, projectname)
- if os.path.isdir(fq_projdir):
- #XXX: make this more nuanced in the future.
- raise RuntimeError("Error, project directory %s already exists." % fq_projdir)
- os.mkdir(fq_projdir)
- return fq_projdir
-
-
-def wrap(filenames, directory, outdir, projectname):
-
- projectname = projectname.strip()
-
- projdir = setup_project(projectname, directory, outdir)
-
- print >>sys.stderr, "wrapping %s from %s in %s" % (filenames, directory, projdir)
-
- pipeline = [ KindResolutionVisitor(),
- AutoConfigGenerator(projectname),
- FortranWrapperGenerator(projectname),
- CHeaderGenerator(projectname),
- PxdGenerator(projectname),
- CyHeaderGenerator(projectname),
- CyImplGenerator(projectname)
- ]
-
- for fname in filenames:
- block = api.parse(os.path.join(directory, fname), analyze=True)
- for stage in pipeline:
- stage(block) # assumes no transformations to the parse tree.
-
- # write out the files.
- for stage in pipeline:
- if not stage.is_generator:
- continue
- out_fname = stage.make_fname(projectname)
- full_path = os.path.join(projdir, out_fname)
- fh = open(full_path, 'w')
- stage.copyto(fh)
- fh.close()
-
- # write out the makefile
- gen_makefile(projectname, filenames, directory, projdir)
-
- # copy the fortran source files to the project dir.
- for fname in filenames:
- shutil.copy(fname, projdir)
-
-def gen_makefile(projname, src_files, src_dir, out_dir):
- import sys
- PYTHON = '/usr/bin/python2.6'
- PY_INC = '-I/usr/include/python2.6'
- CYTHON = '/home/ksmith/GSoC/gsoc-kurt/cython.py'
- SRCDIR = src_dir
- if len(src_files) != 1:
- raise RuntimeError("not set-up for multiple fortran source files, yet.")
- SRCFILE = src_files[0]
- FORTSRCBASE, FORTSRCEXT = os.path.splitext(SRCFILE)
- PROJECTNAME = projname
- fh = open(os.path.join(out_dir, 'Makefile'), 'w')
- fh.write(makefile_template % locals())
-
- fh.close()
-
-makefile_template = '''
-PYTHON=%(PYTHON)s
-PY_INC=%(PY_INC)s
-CYTHON=%(CYTHON)s
-
-SRCDIR =%(SRCDIR)s
-
-FORTSRCBASE = %(FORTSRCBASE)s
-FORTSRCEXT = %(FORTSRCEXT)s
-
-CONFIG = config
-GENCONFIG = genconfig
-PROJNAME = %(PROJECTNAME)s
-FORTSOURCE = $(FORTSRCBASE)$(FORTSRCEXT)
-FORTWRAP = $(PROJNAME)_fortran
-
-FC = gfortran
-FFLAGS = -g -Wall -fPIC
-CFLAGS = -pthread -fno-strict-aliasing -g -fwrapv -Wall -Wstrict-prototypes -fPIC
-LFLAGS = -pthread -shared -Wl,-Bsymbolic-functions -lgfortran
-CC = gcc
-
-
-#------------------------------------------------------------------------------
-all: $(PROJNAME).so
-
-%%.c : %%.pyx $(CONFIG).h
- @$(PYTHON) $(CYTHON) $<
-
-$(FORTSRCBASE).o : $(SRCDIR)/$(FORTSOURCE)
- @$(FC) $(FFLAGS) -c $< -o $@
-
-$(CONFIG).h : $(GENCONFIG).f95
- @$(FC) $< -o $(GENCONFIG)
- @./$(GENCONFIG)
- @rm $(GENCONFIG)
-
-$(CONFIG).f95 : $(GENCONFIG).f95
- @$(FC) $< -o $(GENCONFIG)
- @./$(GENCONFIG)
- @rm $(GENCONFIG)
-
-$(CONFIG).o : $(CONFIG).f95
- @$(FC) $(FFLAGS) -c $< -o $@
-
-$(FORTWRAP).o : $(FORTWRAP).f95 $(CONFIG).o
- @$(FC) $(FFLAGS) -c $< -o $@
-
-$(PROJNAME).o : $(PROJNAME).c
- @$(CC) $(CFLAGS) $(PY_INC) -c $< -o $@
-
-$(PROJNAME).so : $(PROJNAME).o $(FORTWRAP).o $(FORTSRCBASE).o $(PROJNAME).o
- @$(CC) $(LFLAGS) $? -o $@
-
-clean:
- @rm *.o *.so *.c *.mod
-'''
diff --git a/Tools/fwrap/Visitor.py b/Tools/fwrap/Visitor.py
deleted file mode 100644
index 5c59f19ca..000000000
--- a/Tools/fwrap/Visitor.py
+++ /dev/null
@@ -1,1035 +0,0 @@
-#
-# classes BasicVisitor & TreeVisitor were lifted from Cython.Compiler.Visitor
-# and adapted for fwrap.
-#
-
-import inspect
-from pprint import pprint
-import re
-import sys
-from Code import CodeWriter, CompositeBlock, \
- ModuleCode, SubProgramCode, \
- SubroutineCode, ProgramCode, \
- UtilityCode, FunctionCode, InterfaceCode, \
- CySuiteCode
-from Cython.StringIOTree import StringIOTree
-from fparser.block_statements import Function, SubProgramStatement, \
- Module, Program, Subroutine, \
- EndFunction, EndSubroutine, Interface
-from fparser.statements import Use, Parameter, Dimension, Pointer
-from fparser.typedecl_statements import TypeDeclarationStatement
-import WrapperArgs
-from WrapperArgs import wrapper_var_factory
-from utils import warning, mangle_prefix, valid_name, CY_IMPORT_ALIAS
-
-class BasicVisitor(object):
- """A generic visitor base class which can be used for visiting any kind of object."""
- def __init__(self):
- self.dispatch_table = {}
-
- def visit(self, obj):
- cls = type(obj)
- try:
- handler_method = self.dispatch_table[cls]
- except KeyError:
- #print "Cache miss for class %s in visitor %s" % (
- # cls.__name__, type(self).__name__)
- # Must resolve, try entire hierarchy
- pattern = "visit_%s"
- mro = inspect.getmro(cls)
- handler_method = None
- for mro_cls in mro:
- if hasattr(self, pattern % mro_cls.__name__):
- handler_method = getattr(self, pattern % mro_cls.__name__)
- break
- if handler_method is None:
- print type(self), type(obj)
- if hasattr(self, 'access_path') and self.access_path:
- print self.access_path
- if self.access_path:
- print self.access_path[-1][0].pos
- print self.access_path[-1][0].__dict__
- raise RuntimeError("Visitor does not accept object: %s" % obj)
- #print "Caching " + cls.__name__
- self.dispatch_table[cls] = handler_method
- return handler_method(obj)
-
-class TreeVisitor(BasicVisitor):
- """
- Base class for writing visitors for a Cython tree, contains utilities for
- recursing such trees using visitors. Each node is
- expected to have a content iterable containing the names of attributes
- containing child nodes or lists of child nodes. Lists are not considered
- part of the tree structure (i.e. contained nodes are considered direct
- children of the parent node).
-
- visit_children visits each of the children of a given node (see the visit_children
- documentation). When recursing the tree using visit_children, an attribute
- access_path is maintained which gives information about the current location
- in the tree as a stack of tuples: (parent_node, attrname, index), representing
- the node, attribute and optional list index that was taken in each step in the path to
- the current node.
-
- Example:
-
- >>> class SampleNode(object):
- ... child_attrs = ["head", "body"]
- ... def __init__(self, value, head=None, body=None):
- ... self.value = value
- ... self.head = head
- ... self.body = body
- ... def __repr__(self): return "SampleNode(%s)" % self.value
- ...
- >>> tree = SampleNode(0, SampleNode(1), [SampleNode(2), SampleNode(3)])
- >>> class MyVisitor(TreeVisitor):
- ... def visit_SampleNode(self, node):
- ... print "in", node.value, self.access_path
- ... self.visitchildren(node)
- ... print "out", node.value
- ...
- >>> MyVisitor().visit(tree)
- in 0 []
- in 1 [(SampleNode(0), 'head', None)]
- out 1
- in 2 [(SampleNode(0), 'body', 0)]
- out 2
- in 3 [(SampleNode(0), 'body', 1)]
- out 3
- out 0
- """
-
- def __init__(self):
- super(TreeVisitor, self).__init__()
- self.access_path = []
-
- def __call__(self, tree):
- self.visit(tree)
- return tree
-
- def visit_Statement(self, node):
- self.visitchildren(node)
- return node
-
- def visitchild(self, child, parent, idx):
- self.access_path.append((parent, idx))
- result = self.visit(child)
- self.access_path.pop()
- return result
-
- def visitchildren(self, parent, attrs=None):
- """
- Visits the children of the given parent. If parent is None, returns
- immediately (returning None).
-
- The return value is a dictionary giving the results for each
- child (mapping the attribute name to either the return value
- or a list of return values (in the case of multiple children
- in an attribute)).
- """
-
- if parent is None: return None
- content = getattr(parent, 'content', None)
- if content is None or not isinstance(content, list):
- return None
- result = [self.visitchild(child, parent, idx) for (idx, child) in \
- enumerate(content)]
- return result
-
-class PrintTree(TreeVisitor):
-
- def __init__(self):
- TreeVisitor.__init__(self)
- self._indent = ""
-
- def indent(self):
- self._indent += " "
-
- def unindent(self):
- self._indent = self._indent[:-2]
-
- def visit_Statement(self, node):
- print("%s|%s" % (self._indent, type(node)))
- self.indent()
- self.visitchildren(node)
- self.unindent()
- return node
-
- def visit_TypeDeclarationStatement(self, node):
- print("%s %s" % (self._indent, node.name))
- return node
-
-
-class KindResolutionError(Exception):
- pass
-
-class KindResolutionVisitor(TreeVisitor):
-
- is_generator = False
-
- def visit_SubProgramStatement(self, node):
- #FIXME: when a variable's type is
- # integer*8 :: a
- # the get_kind() is the default integer kind (i.e., '4')
- # while the selector is ('8', '').
- interface_var_names = node.args[:]
- if isinstance(node, Function):
- interface_var_names += [node.result]
- for argname in interface_var_names:
- var = node.a.variables[argname]
- # vkr = VarKindResolution(var)
- wrapper_var = wrapper_var_factory(node, var)
- var.fwrap_wrapper_var = wrapper_var
- # var.fwrap_var_kind_res = vkr
- return node
-
-class GeneratorBase(TreeVisitor):
-
- is_generator = True
-
- @staticmethod
- def make_fname(base):
- raise NotImplementedError()
-
- def copyto(self, fh):
- raise NotImplementedError()
-
- def __call__(self, tree):
- self.visit(tree)
- return tree
-
-class AutoConfigGenerator(GeneratorBase):
-
- is_generator = True
-
- @staticmethod
- def make_fname(base):
- return "genconfig.f95"
-
- def get_temp_int(self):
- self.temp_ctr += 1
- return self.temp_ctr - 1
-
-
- def __init__(self, projname, *args, **kwargs):
- GeneratorBase.__init__(self, *args, **kwargs)
-
- self.default_types = []
-
- self.temp_ctr = 0
-
- self.projname = projname
-
- self.utility = UtilityCode()
- self.resolve_mod = ModuleCode()
- self.driver_prog = ProgramCode()
-
- self._init_toplevel()
-
- self.seen_mods = set()
- self.seen_subprograms = set()
- self.seen_resolved_names = set()
- self.resolve_subrs = {}
-
- local_ktp_subr = SubroutineCode(level=1)
- self.resolve_mod.add_subprogram_block(local_ktp_subr)
- self.resolve_subrs['local_ktp'] = local_ktp_subr
-
- self.type_len_subr = SubroutineCode(level=1)
- self.resolve_mod.add_subprogram_block(self.type_len_subr)
- self.resolve_subrs['type_len_subr'] = self.type_len_subr
-
- # Type used for array shapes.
- local_ktp_subr.executable_stmts.put(ktp_scalar_int_code % {
- 'scalar_int_expr' : 'c_long',
- 'type_name' : 'integer',
- 'mapped_name' : WrapperArgs.ARRAY_SHAPE_TYPE}
- )
-
-
-
- def _init_toplevel(self):
- self.utility.root.put(lookup_mod_code,indent=True)
- self.resolve_mod.block_start.putln("module resolve_mod")
- self.resolve_mod.block_end.putln("end module resolve_mod")
-
- self.driver_prog.block_start.putln("program autoconfig")
- self.driver_prog.block_end.putln("end program autoconfig")
-
- self.resolve_mod.use_stmts.putln("use iso_c_binding")
- self.resolve_mod.use_stmts.putln("use lookup_types")
-
- self.driver_prog.use_stmts.putln("use resolve_mod")
- self.driver_prog.declarations.putln("integer :: fh_num, ch_num, iserr")
-
- def visit_SubProgramStatement(self, node):
- for varw in all_varws(node):
- if varw.resolved_name in self.seen_resolved_names:
- continue
- self.seen_resolved_names.add(varw.resolved_name)
- if varw.defining_param is None and varw.length is None:
- # it's a literal integer, or selected_*_kind() or kind() call...
- assert varw.defining_scope is varw.var.parent.parent, `varw.defining_scope,varw.var.parent`
- subr_code = self.resolve_subrs['local_ktp']
- self.put_scalar_int_code(subr_code, varw)
- elif varw.defining_param is None and varw.length:
- # older declaration -- integer*8, integer*4, etc...
- subr_code = self.type_len_subr
- temp_name = "fwrap_temp%d" % self.get_temp_int()
- subr_code.declarations.putln("%s*%s :: %s" % (varw.type_name, varw.length, temp_name))
- subr_code.executable_stmts.put(ktp_scalar_int_code % {
- 'scalar_int_expr' : 'kind(%s)' % temp_name,
- 'type_name' : varw.type_name,
- 'mapped_name' : varw.resolved_name
- }, indent=True)
-
- else:
- raise NotImplementedError("ktps other than literal "
- "integers or kind() calls not currently supported")
- return node
-
- def put_scalar_int_code(self, subr_code, varw):
- subr_code.executable_stmts.put(ktp_scalar_int_code % {
- 'scalar_int_expr' : varw.ktp_str,
- 'type_name': varw.type_name,
- 'mapped_name' : varw.resolved_name
- }, indent=True)
-
-
- def copyto(self, fh):
-
- # write the utility code.
- self.utility.copyto(fh)
- # write the resove_mod code.
- self.driver_prog.executable_stmts.put(open_files_code % dict(projname=self.projname),indent=True)
- for subr_code_name, subr_code in self.resolve_subrs.items():
- subr_code.block_start.putln("subroutine %s(fh_num, ch_num, iserr)" % subr_code_name)
- subr_code.block_end.putln("end subroutine %s" % subr_code_name)
- subr_code.declarations.putln("integer, intent(in) :: fh_num, ch_num")
- subr_code.declarations.putln("integer, intent(out) :: iserr")
- subr_code.declarations.putln("integer :: ktp")
- subr_code.declarations.putln("character(len=ktp_str_len) :: fort_ktp_str, c_type_str")
- # write the subroutine wrapper call inside the driver_prog
- self.driver_prog.executable_stmts.putln("call %s(fh_num, ch_num, iserr)" % subr_code_name)
- self.driver_prog.executable_stmts.putln("if (iserr .gt. 0) then")
- self.driver_prog.executable_stmts.putln("stop \"an error occurred in the kind resolution\"")
- self.driver_prog.executable_stmts.putln("end if")
- self.resolve_mod.copyto(fh)
- # write the driver_prog
- self.driver_prog.executable_stmts.put(close_files_code % dict(projname=self.projname),indent=True)
- self.driver_prog.copyto(fh)
-
-class WrapperError(RuntimeError):
- pass
-
-
-class FortranWrapperGenerator(GeneratorBase):
-
- @staticmethod
- def make_fname(base):
- return "%s_fortran.f95" % base.strip()
-
- def __init__(self, projname, *args, **kwargs):
- GeneratorBase.__init__(self, *args, **kwargs)
-
- self.projname = projname
- self.utility = UtilityCode()
- self.wrapped_subps = []
- self.wrapped = set()
-
- def make_interface(self, node):
-
- assert isinstance(node, (Function, Subroutine))
-
- ifce_code = InterfaceCode(level=1)
- # put down the opening & closing.
- ifce_code.block_start.putln("interface")
- ifce_code.block_start.putln(node.tostr())
- endln = [ln for ln in node.content if isinstance(ln, (EndFunction, EndSubroutine))]
- assert len(endln) == 1
- endln = endln[0]
- ifce_code.block_end.putln("end %s %s" % (endln.blocktype, endln.name))
- ifce_code.block_end.putln("end interface")
- # use statements
- use_stmts = [st for st in node.content if isinstance(st, Use)]
- for us in use_stmts:
- ifce_code.use_stmts.putln(us.tofortran().strip())
- # declaration statements
- if node.a.implicit_rules is not None: #XXX
- warning("only 'implicit none' is supported currently -- may yield incorrect results.")
- ifce_code.declarations.putln("implicit none")
- ifce_decs = [st for st in node.content if isinstance(st, (TypeDeclarationStatement, Parameter, Dimension, Pointer))]
- for dec in ifce_decs:
- ifce_code.declarations.putln(dec.item.line.strip())
- return ifce_code
-
-
- def visit_SubProgramStatement(self, node):
- if isinstance(node.parent, Interface) and node.name in self.wrapped:
- return node
- else:
- self.wrapped.add(node.name)
- if isinstance(node, Function):
- subp_type_str = 'function'
- subp_code = FunctionCode()
- elif isinstance(node, Subroutine):
- subp_type_str = 'subroutine'
- subp_code = SubroutineCode()
- else:
- raise WrapperError()
-
- self.wrapped_subps.append(subp_code)
-
- argnames = []
- for varw in arg_varws(node):
- argnames.extend(varw.get_fort_argnames())
-
- wrapname = mangle_prefix+node.name
- # argnames = node.args[:]
- subp_code.block_start.putln("%(subp_type_str)s %(wrapname)s(%(arglst)s) bind(c,name=\"%(bindname)s\")" % \
- { 'subp_type_str' : subp_type_str,
- 'wrapname' : wrapname,
- 'arglst' : ', '.join(argnames),
- 'bindname' : node.name
- })
- subp_code.block_end.putln("end %s %s" % (subp_type_str, wrapname))
- subp_code.use_stmts.putln("use config")
-
- for varw in arg_varws(node):
- varw.generate_fort_declarations(subp_code.declarations)
-
- if isinstance(node, Function):
- # declare function return type
- retvar = node.a.variables[node.result]
- varw = retvar.fwrap_wrapper_var
- subp_code.declarations.putln("%(type_name)s(kind=%(ktp)s) :: %(func_name)s" % \
- {'type_name' : varw.type_name,
- 'ktp' : varw.resolved_name,
- 'func_name' : wrapname
- })
-
- # put down the wrapped subprog's interface here.
- ifce_code = self.make_interface(node)
- subp_code.declarations.insert(ifce_code.root)
-
- # pre-call code here.
- for varw in all_varws(node):
- varw.pre_call_fortran_code(subp_code.executable_stmts)
-
- # call the wrapped function/subr.
- pass_argnames = []
- for varw in arg_varws(node):
- pass_argnames.append(varw.get_fort_pass_argnames_map()[1])
-
- if isinstance(node, Function):
- subp_code.executable_stmts.putln("%(wrapname)s = %(funcname)s(%(arglst)s)" % \
- { 'wrapname' : wrapname,
- 'funcname' : node.name,
- 'arglst' : ', '.join(pass_argnames)
- })
- elif isinstance(node, Subroutine):
- subp_code.executable_stmts.putln("call %(subrname)s(%(arglst)s)" % \
- { 'subrname' : node.name,
- 'arglst' : ', '.join(pass_argnames)
- })
-
- # post-call code here.
- for varw in all_varws(node):
- varw.post_call_fortran_code(subp_code.executable_stmts)
-
- return node
-
-
- def copyto(self, fh):
- self.utility.copyto(fh)
- for wrapped_subp in self.wrapped_subps:
- wrapped_subp.copyto(fh)
-
-class CHeaderGenerator(GeneratorBase):
-
- @staticmethod
- def make_fname(base):
- return "%s_header.h" % base.strip()
-
- def __init__(self, projname, *args, **kwargs):
- GeneratorBase.__init__(self, *args, **kwargs)
-
- self.projname = projname
- self.preamble = CodeWriter(level=0)
- self.c_protos = CodeWriter(level=0)
- self.wrapped = set()
-
- # add include statement.
- self.preamble.putln('#include "config.h"')
- self.preamble.putln('\n')
-
- def visit_SubProgramStatement(self, node):
- if node.name in self.wrapped:
- return node
- else:
- self.wrapped.add(node.name)
- proto = c_prototype(node)
-
- self.c_protos.putln("%s %s(%s);" % \
- (proto['return_type'], proto['proto_name'], ", ".join(proto['arglst'])))
-
- return node
-
- def copyto(self, fh):
- self.preamble.copyto(fh)
- self.c_protos.copyto(fh)
-
-def arg_varws(node):
- varws = []
- interface_var_names = node.args[:]
- for argname in interface_var_names:
- var = node.a.variables[argname]
- varws.append(var.fwrap_wrapper_var)
- return varws
-
-def result_varw(node):
- if isinstance(node, Subroutine):
- return None
- var = node.a.variables[node.result]
- return var.fwrap_wrapper_var
-
-def all_varws(node):
- varws = arg_varws(node)
- if isinstance(node, Function):
- varws.append(result_varw(node))
- return varws
-
-def c_prototype(node):
- varws = arg_varws(node)
- c_arg_list = []
- for varw in varws:
- c_arg_list.extend(varw.get_c_proto_types())
- # get the return type string
- if isinstance(node, Subroutine):
- res_var_type_str = "void"
- elif isinstance(node, Function):
- res_varw = result_varw(node)
- proto_code_lst = res_varw.get_c_proto_types()
- assert len(proto_code_lst) == 1
- res_var_type_str = proto_code_lst[0]
-
- return {'return_type' : res_var_type_str,
- 'proto_name' : node.name,
- 'arglst' : c_arg_list
- }
-
-class PxdGenerator(GeneratorBase):
-
- @staticmethod
- def make_fname(base):
- return "%s_fortran.pxd" % base.rstrip()
-
- def __init__(self, projname, *args, **kwargs):
- GeneratorBase.__init__(self, *args, **kwargs)
-
- self.projname = projname
-
- self.seen_resolved_names = set()
- self.seen_subps = set()
-
- self.typedef_suite = CySuiteCode(level=0)
- self.proto_suite = CySuiteCode(level=0)
-
- # array shape type
- self.typedef_suite.suite_body.putln("ctypedef %s %s" % \
- ("long int", WrapperArgs.ARRAY_SHAPE_TYPE))
-
- def visit_SubProgramStatement(self, node):
- if node.name in self.seen_subps:
- return node
- self.seen_subps.add(node.name)
- for varw in all_varws(node):
- if varw.resolved_name in self.seen_resolved_names:
- continue
- self.seen_resolved_names.add(varw.resolved_name)
- typemap = {'integer' : 'int',
- 'character' : 'char',
- 'logical' : 'int',
- 'real' : 'float',
- 'doubleprecision' : 'float',
- 'complex' : 'float complex',
- 'doublecomplex' : 'double complex',
- }
- # if 'complex' in varw.type_name: #XXX TODO
- # raise NotImplementedError("complex ktp not currently supported.")
- self.typedef_suite.suite_body.putln("ctypedef %s %s" % \
- (typemap[varw.type_name], varw.resolved_name))
-
- proto = c_prototype(node)
- self.proto_suite.suite_body.putln("%s %s(%s)" % \
- (proto['return_type'],
- proto['proto_name'],
- ", ".join(proto['arglst'])))
- return node
-
- def copyto(self, fh):
- h_name = CHeaderGenerator.make_fname(self.projname)
- self.typedef_suite.suite_start.putln("cdef extern from \"%s\":" % h_name)
- self.proto_suite.suite_start.putln("cdef extern:")
- if not self.typedef_suite.suite_body.tell():
- self.typedef_suite.suite_body.putln("pass")
- self.typedef_suite.copyto(fh)
- fh.write('\n')
- if not self.proto_suite.suite_body.tell():
- self.proto_suite.suite_body.putln("pass")
- self.proto_suite.copyto(fh)
-
-class CyHeaderGenerator(GeneratorBase):
-
- @staticmethod
- def make_fname(base):
- return "%s.pxd" % base.rstrip()
-
- def __init__(self, projname, *args, **kwargs):
- GeneratorBase.__init__(self, *args, **kwargs)
- self.projname = projname
-
-
- self.import_code = UtilityCode(level=0)
- self.proto_code = UtilityCode(level=0)
-
- self.seen_subps = set()
-
- def visit_SubProgramStatement(self, node):
- if node.name in self.seen_subps:
- return node
- self.seen_subps.add(node.name)
- # TODO: return struct typedecl
- # Cython API function prototype
- cypro = cy_prototype(node)
-
- ret_type = cypro['return_type']
- if ret_type not in ('void',):
- ret_type = "%s.%s" % (CY_IMPORT_ALIAS, ret_type)
-
- arg_type_list = ["%s.%s" % (CY_IMPORT_ALIAS, arg_type) for (arg_type, _) in cypro['arglst']]
- self.proto_code.root.putln("cdef api %s cy_%s(%s)" % (
- ret_type,
- cypro['proto_name'],
- ", ".join(arg_type_list)))
-
- def copyto(self, fh):
- self.import_code.root.putln("cimport %s as %s" % (
- PxdGenerator.make_fname(self.projname).split('.')[0],
- CY_IMPORT_ALIAS))
- self.import_code.root.putln("")
- self.import_code.copyto(fh)
- self.proto_code.copyto(fh)
-
-def cy_prototype(node):
- res_varw = None
- if isinstance(node, Function):
- res_varw = result_varw(node)
-
- arglst = []
- for varw in arg_varws(node):
- names = varw.get_cy_arg_declarations()
- arglst.extend(names)
-
- if res_varw is None:
- res_str = "void"
- else:
- res_str = res_varw.resolved_name
-
- return { 'arglst' : arglst,
- 'proto_name' : node.name,
- 'return_type' : res_str}
-
-class CyImplGenerator(GeneratorBase):
-
- @staticmethod
- def make_fname(base):
- return "%s.pyx" % base.rstrip()
-
- def __init__(self, projname, *args, **kwargs):
- GeneratorBase.__init__(self, *args, **kwargs)
- self.projname = projname
-
- self.import_code = UtilityCode(level=0)
- self.functions = []
-
- self.seen_subps = set()
-
- def gen_api_func(self, node):
- is_func = isinstance(node, Function)
- avws = arg_varws(node)
- # cypro = cy_prototype(node)
- api_func = CySuiteCode(level=0)
-
- args = []; call_args = []
- for varw in avws:
- for type_name, arg_name in varw.get_cy_arg_declarations():
- args.append("%s.%s %s" % (CY_IMPORT_ALIAS, type_name, arg_name))
- for arg_name in varw.get_cy_pass_argnames():
- call_args.append(arg_name)
-
- res_varw = result_varw(node)
- if res_varw:
- ret_type = "%s.%s" % (CY_IMPORT_ALIAS, res_varw.resolved_name)
- else:
- ret_type = 'void'
-
- api_func.suite_start.putln("cdef api %s cy_%s(%s):" % (
- ret_type, node.name, ", ".join(args)))
-
- # generate declarations
- if is_func:
- ret_var = '__fwrap_return'
- api_func.suite_body.putln("cdef %s %s" % (
- ret_type, ret_var))
- for varw in avws:
- varw.generate_cy_declarations(api_func.suite_body)
-
- # generate pre-call code
- for varw in avws:
- varw.pre_call_cy_code(api_func.suite_body)
-
- # generate the call itself
- func_call = "%s.%s(%s)" % (CY_IMPORT_ALIAS,
- node.name,
- ", ".join(call_args))
- if is_func:
- api_func.suite_body.putln("%s = %s" % (
- ret_var, func_call))
- else:
- api_func.suite_body.putln(func_call)
-
- # post-call code
- for varw in avws:
- varw.post_call_cy_code(api_func.suite_body)
-
- # return value if function.
- if is_func:
- api_func.suite_body.putln("return %s" % ret_var)
-
- self.functions.append(api_func)
-
- def gen_py_func(self, node):
- py_func = CySuiteCode(level=0)
- args = []; call_args = []; ret_lst = []
- for varw in arg_varws(node):
- # no pointer types in python function argument list.
- # if varw.is_array:
- # import pdb; pdb.set_trace()
- # else:
- for type_name, arg_name in varw.get_py_arg_declarations():
- if varw.is_array:
- args.append(arg_name)
- call_args.append(arg_name)
- else:
- args.append("%s.%s %s" % (CY_IMPORT_ALIAS, type_name, arg_name))
- if varw.var.is_intent_inout() or varw.var.is_intent_out():
- call_args.append("&%s" % arg_name)
- else:
- call_args.append(arg_name)
- if varw.var.is_intent_inout() or varw.var.is_intent_out():
- ret_lst.append(arg_name)
-
- py_func.suite_start.putln("def %s(%s):" % (node.name, ", ".join(args)))
-
- proc_call = "cy_%s(%s)" % (node.name, ", ".join(call_args))
-
- if isinstance(node, Function):
- ret_var_name = '__fwrap_return'
- ret_varw = result_varw(node)
- ret_lst.insert(0, ret_var_name)
- ret_type = ret_varw.resolved_name
- py_func.suite_body.putln("cdef %s.%s %s" % (CY_IMPORT_ALIAS, ret_type, ret_var_name))
- proc_call = "%s = %s" % (ret_var_name, proc_call)
-
- py_func.suite_body.putln(proc_call)
- if not ret_lst:
- ret_tpl = ""
- elif len(ret_lst) == 1:
- ret_tpl = "(%s,)" % ret_lst[0]
- else:
- ret_tpl = "(%s)" % ", ".join(ret_lst)
- py_func.suite_body.putln("return %s" % ret_tpl)
-
- self.functions.append(py_func)
-
-
- def visit_SubProgramStatement(self, node):
- if node.name in self.seen_subps:
- return node
- self.seen_subps.add(node.name)
- self.gen_api_func(node)
- self.gen_py_func(node)
-
- def copyto(self, fh):
- self.import_code.root.putln("cimport %s as %s" % (
- PxdGenerator.make_fname(self.projname).split('.')[0],
- CY_IMPORT_ALIAS))
- self.import_code.root.putln("cimport numpy as np")
- self.import_code.root.putln("")
- self.import_code.copyto(fh)
-
- for func_code in self.functions:
- func_code.copyto(fh)
-
-#-------------------------------------------------------------------------------
-# Code templates.
-#-------------------------------------------------------------------------------
-open_files_code = """
-fh_num = 17
-ch_num = 18
-open(unit=fh_num, file='config.f95', status='REPLACE', form='FORMATTED', action='WRITE', iostat=iserr)
-if (iserr .gt. 0) then
- stop \"an error occured opening the file 'config.f95', unable to continue\"
-end if
-open(unit=ch_num, file='config.h', status='REPLACE', form='FORMATTED', action='WRITE', iostat=iserr)
-if (iserr .gt. 0) then
- stop \"an error occured opening the file 'config.h', unable to continue\"
-end if
-
-write(unit=fh_num, fmt="(' ',A)") "module config"
-write(unit=fh_num, fmt="(' ',A)") " use iso_c_binding"
-write(unit=fh_num, fmt="(' ',A)") " implicit none"
-
-"""
-
-close_files_code = """
-
-write(unit=fh_num, fmt="(' ',A)") "end module config"
-
-close(unit=fh_num)
-close(unit=ch_num)
-"""
-
-ktp_scalar_int_code = '''
-
-ktp = %(scalar_int_expr)s
-call lookup_%(type_name)s (ktp, fort_ktp_str, c_type_str, iserr)
-if (iserr .gt. 0) return
-write(unit=fh_num, fmt="(' ',2A)") "integer, parameter :: %(mapped_name)s = ", trim(adjustl(fort_ktp_str))
-write(unit=ch_num, fmt="(' ',3A)") "typedef ", trim(adjustl(c_type_str)), " %(mapped_name)s;"
-'''
-
-lookup_mod_code = '''
-module lookup_types
- use iso_c_binding
- implicit none
-
- integer, parameter :: ktp_str_len = 25
-
- contains
-
-
- subroutine lookup_real(real_kind, fort_ktp_str, c_type_str, iserr)
- use iso_c_binding
- implicit none
- integer, intent(in) :: real_kind
- character(len=ktp_str_len), intent(out) :: fort_ktp_str, c_type_str
- integer, intent(out) :: iserr
-
- iserr = 0
- ! make sure kind .gt. 0
- if (real_kind .lt. 0) then
- ! set error condition
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- endif
-
- if (real_kind .eq. c_float) then
- fort_ktp_str = "c_float"
- c_type_str = "float"
- return
- else if (real_kind .eq. c_double) then
- fort_ktp_str = "c_double"
- c_type_str = "double"
- return
- else if (real_kind .eq. c_long_double) then
- fort_ktp_str = "c_long_double"
- c_type_str = "long double"
- return
- else
- ! No corresponding interoperable type, set error.
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- end if
-
- end subroutine lookup_real
-
- subroutine lookup_integer(int_kind, fort_ktp_str, c_type_str, iserr)
- use iso_c_binding
- implicit none
- integer, intent(in) :: int_kind
- character(len=ktp_str_len), intent(out) :: fort_ktp_str, c_type_str
- integer, intent(out) :: iserr
-
- iserr = 0
- ! make sure kind .gt. 0
- if (int_kind .lt. 0) then
- ! set error condition
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- endif
-
- if (int_kind .eq. c_signed_char) then
- fort_ktp_str = "c_signed_char"
- c_type_str = "signed char"
- return
- else if (int_kind .eq. c_short) then
- fort_ktp_str = "c_short"
- c_type_str = "short int"
- return
- else if (int_kind .eq. c_int) then
- fort_ktp_str = "c_int"
- c_type_str = "int"
- return
- else if (int_kind .eq. c_long) then
- fort_ktp_str = "c_long"
- c_type_str = "long int"
- return
- else if (int_kind .eq. c_long_long) then
- ! XXX assumes C99 long long type exists
- fort_ktp_str = "c_long_long"
- c_type_str = "long long int"
- return
- else
- ! No corresponding interoperable type, set error.
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- end if
-
- end subroutine lookup_integer
-
- subroutine lookup_character(char_kind, fort_ktp_str, c_type_str, iserr)
- use iso_c_binding
- implicit none
- integer, intent(in) :: char_kind
- character(len=ktp_str_len), intent(out) :: fort_ktp_str, c_type_str
- integer, intent(out) :: iserr
-
- iserr = 0
- ! make sure kind .gt. 0
- if (char_kind .lt. 0) then
- ! set error condition
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- endif
-
- if (char_kind .eq. c_char) then
- fort_ktp_str = "c_char"
- c_type_str = "char"
- return
- else
- ! No corresponding interoperable type, set error.
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- end if
-
- end subroutine lookup_character
-
- subroutine lookup_logical(log_kind, fort_ktp_str, c_type_str, iserr)
- ! XXX assumes C99 _Bool.
- use iso_c_binding
- implicit none
- integer, intent(in) :: log_kind
- character(len=ktp_str_len), intent(out) :: fort_ktp_str, c_type_str
- integer, intent(out) :: iserr
-
- iserr = 0
- ! make sure kind .gt. 0
- if (log_kind .lt. 0) then
- ! set error condition
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- endif
-
-! if (log_kind .eq. c_bool) then
-! fort_ktp_str = "c_bool"
-! c_type_str = "_Bool"
-! return
-! else if (log_kind .eq. c_signed_char) then
- if (log_kind .eq. c_signed_char) then
- fort_ktp_str = "c_signed_char"
- c_type_str = "signed char"
- return
- else if (log_kind .eq. c_short) then
- fort_ktp_str = "c_short"
- c_type_str = "short int"
- return
- else if (log_kind .eq. c_int) then
- fort_ktp_str = "c_int"
- c_type_str = "int"
- return
- else if (log_kind .eq. c_long) then
- fort_ktp_str = "c_long"
- c_type_str = "long int"
- return
- else if (log_kind .eq. c_long_long) then
- ! XXX assumes C99 long long type exists
- fort_ktp_str = "c_long_long"
- c_type_str = "long long int"
- return
- else
- ! No corresponding interoperable type, set error.
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- end if
-
- end subroutine lookup_logical
-
- subroutine lookup_complex(complex_kind, fort_ktp_str, c_type_str, iserr)
- ! XXX assumes C99 _Complex.
- use iso_c_binding
- implicit none
- integer, intent(in) :: complex_kind
- character(len=ktp_str_len), intent(out) :: fort_ktp_str, c_type_str
- integer, intent(out) :: iserr
-
- iserr = 0
- ! make sure kind .gt. 0
- if (complex_kind .lt. 0) then
- ! set error condition
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- endif
-
- if (complex_kind .eq. c_float_complex) then
- fort_ktp_str = "c_float_complex"
- c_type_str = "float _Complex"
- return
- else if (complex_kind .eq. c_double_complex) then
- fort_ktp_str = "c_double_complex"
- c_type_str = "double _Complex"
- return
- else if (complex_kind .eq. c_long_double_complex) then
- fort_ktp_str = "c_long_double_complex"
- c_type_str = "long double _Complex"
- return
- else
- ! No corresponding interoperable type, set error.
- iserr = 1
- fort_ktp_str = ""
- c_type_str = ""
- return
- end if
-
- end subroutine lookup_complex
-
-end module lookup_types
-'''
diff --git a/Tools/fwrap/WrapperArgs.py b/Tools/fwrap/WrapperArgs.py
deleted file mode 100644
index 9961c14e3..000000000
--- a/Tools/fwrap/WrapperArgs.py
+++ /dev/null
@@ -1,646 +0,0 @@
-from fparser.block_statements import Function, SubProgramStatement, \
- Module, Program, Subroutine, \
- EndFunction, EndSubroutine, Interface
-from utils import warning, mangle_prefix, valid_name, CY_IMPORT_ALIAS
-
-class WrapperError(Exception):
- pass
-
-def _get_type_name(var):
- return var.typedecl.name.lower().replace(' ', '')
-
-def type_from_vkr(vkr):
- typename_to_class = {
- 'integer' : FortranIntegerType,
- 'real' : FortranRealType,
- 'doubleprecision' : FortranRealType,
- 'character': FortranCharacterType,
- 'logical' : FortranLogicalType,
- 'complex' : FortranComplexType,
- 'doublecomplex' : FortranComplexType
- }
- return typename_to_class[vkr.type_name](ktp=vkr.resolved_name)
-
-class VarKindResolution(object):
-
- short_type_name = {
- "integer" : "int",
- "real" : "real",
- "character" : "char",
- "logical" : "lgcl",
- "doubleprecision" : "dprc",
- "complex" : "cpx",
- "doublecomplex" : "dcpx"
- }
-
- def __init__(self, variable):
- self.var = variable # the variable that will have the ktp resolved.
- self.type_name = None # type of the variable ('integer', 'real', 'complex', 'logical', 'character')
- self.resolved_name = None # name that will be used for the ktp in the wrapper.
- self.ktp_str = None # string-form of the ktp.
- self.defining_param = None # 'variable' (parameter) that defines the ktp.
- self.defining_scope = None # scope in which the defining_param is defined.
- self.length = None
-
- self.init_from_var()
-
- if self.type_name not in ('integer', 'real', 'character', 'logical', 'complex'):
- raise WrapperError("unknown type name '%s'." % self.type_name)
-
- if not self.resolved_name:
- raise WrapperError("unable to resolve the kind type parameter for variable %s" % self.var.name)
-
-
- def init_from_var(self):
- self.type_name = _get_type_name(self.var)
- var_scope = self.var.typedecl.parent
- assert isinstance(var_scope, (SubProgramStatement, Module, Program))
- length, ktp = self.var.typedecl.selector
- ktp_str = str(ktp).lower().strip()
-
- self.resolved_name = ''
-
- if not ktp:
- self.handle_default_ktp()
- return
-
- ktp_parse = VarKindResolution.parse_ktp(ktp)
-
- stn = self.short_type_name
-
- if isinstance(ktp_parse[0], int):
- self.ktp_str = str(ktp_parse[0])
- self.resolved_name = mangle_prefix+stn[self.type_name]+ktp_str
- self.defining_scope = var_scope
- self.defining_param = None
-
- elif ktp_parse[0] == 'kind':
- self.ktp_str = ktp
- num_str = ktp_parse[1].replace('.','')
- num_str = num_str.replace('(','')
- num_str = num_str.replace(')','')
- num_str = num_str.replace(',','')
- self.resolved_name = mangle_prefix+stn[self.type_name]+'_kind'+num_str
- self.defining_scope = var_scope
- self.defining_param = None
-
- elif ktp_parse[0] == 'selected_int_kind':
- self.ktp_str = ktp
- self.resolved_name = mangle_prefix+stn[self.type_name]+'_slctd_int'+ktp_parse[1]
- self.defining_scope = var_scope
- self.defining_param = None
-
- elif ktp_parse[0] == 'selected_real_kind':
- self.resolved_name = mangle_prefix+stn[self.type_name]+'slctd_real'+ktp_parse[1]
- if len(ktp_parse) == 3:
- self.resolved_name += ktp_parse[2]
- self.ktp_str = ktp
- self.defining_scope = var_scope
- self.defining_param = None
-
- elif valid_name(ktp_parse[0]):
- # XXX TODO: still have to fill this in...
- raise NotImplementedError("kind-type-parameter '%s' is not resolvable yet" % ktp)
- # lookup_name = ktp_parse[0]
- # def_scope, var = find_defining_scope(var_scope, lookup_name)
- # assert var.is_parameter()
- # assert type(var.typedecl).name.lower() == 'integer'
- # if def_scope is var_scope:
- # # it's defined locally.
- # # TODO: check this over...
- # resolve_name = "%s_%s_%s" % (mangle_prefix, var_scope.name, var.name)
- # # self.local_param_ktp.append((resolve_name, var.init))
- # else:
- # # it's defined in a module, possibly with a use-rename.
- # resolve_name = "%s_%s_%s" % (mangle_prefix, var_scope.name, var.name)
- # raise RuntimeError("finish here!!!")
-
- else:
- raise KindResolutionError("unable to resolve kind-type-parameter '%s'" % ktp)
-
- @staticmethod
- def find_defining_scope(node, param_name):
- '''
- finds where param_name is defined in the local & enclosing scopes of node.
-
- returns (<defining-scope-block>, <variable-defined>)
-
- NOTE: the variable returned may not have the same name as param_name, due
- to a renaming in a use statement.
- '''
- raise NotImplementedError("finish me!!!")
-
- @staticmethod
- def parse_ktp(ktp):
- # this should ideally all be in the parser
- ktp = ktp.lower().strip()
- try:
- ktp_int = int(ktp)
- except ValueError:
- pass
- else:
- return (ktp_int,)
-
- if valid_name(ktp):
- return (ktp,)
-
- for sw in ('kind', 'selected_int_kind'):
- if ktp.startswith(sw):
- retval = [sw]
- ktp = ktp[len(sw):].strip()
- assert ktp[0] + ktp[-1] == '()'
- # handle the middle...
- arg = ktp[1:-1].strip()
- retval.append(arg.replace(' ',''))
- return tuple(retval)
-
- srk = 'selected_real_kind'
- if ktp.startswith(srk):
- retval = [srk]
- ktp = ktp[len(srk):].strip()
- assert ktp[0] + ktp[-1] == '()'
- arg = ktp[1:-1].split(',')
- retval.append(arg[0].replace(' ',''))
- if len(arg) == 2:
- retval.append(arg[1].replace(' ', ''))
- return tuple(retval)
-
- # nothing matches, raise error for now...
- raise KindResolutionError("unable to resolve kind-type-parameter '%s'" % ktp)
-
- def handle_default_ktp(self):
- length, ktp = self.var.typedecl.selector
- assert not ktp
- length = str(length).strip()
- type_name = self.type_name
- scope = self.var.typedecl.parent
-
- stn = self.short_type_name
- if length:
- warning("variable '%s' in '%s' declared with old syntax." % (self.var.name, scope.name))
- #XXX TODO ktp_str here is incorrect -- assumes the length is the same as a ktp, which ain't always so!!!
- # in autoconfig, for an integer*N variable:
- # declare local variable integer*N
- self.length = length
- self.ktp_str = None
- self.resolved_name = mangle_prefix+stn[type_name]+'_x_'+length
-
- # the default types follow.
- elif type_name == 'doubleprecision':
- self.ktp_str = 'kind(1.0D0)'
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
- self.type_name = 'real'
-
- elif type_name == 'logical':
- self.ktp_str = 'kind(.true.)'
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
-
- elif type_name == 'integer':
- self.ktp_str = 'kind(0)'
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
-
- elif type_name == 'real':
- self.ktp_str = 'kind(0.0)'
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
-
- elif type_name == 'character':
- self.ktp_str = "kind('a')"
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
-
- elif type_name == 'complex':
- self.ktp_str = 'kind((0.0,0.0))'
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
-
- elif type_name == 'doublecomplex':
- self.ktp_str = 'kind((0.0D0,0.0D0))'
- self.resolved_name = mangle_prefix+'default_'+stn[type_name]
- self.type_name = 'complex'
-
- else:
- raise KindResolutionError()
-
- # self.type_name, self.ktp_str, self.resolved_name are all set at this point.
-
- self.defining_scope = scope
- self.defining_param = None
-
-class Disambiguator(object):
-
- def __init__(self):
- self.counter = 0
-
- def __call__(self):
- ret = 'fw%d' % self.counter
- self.counter += 1
- return ret
-
-def wrapper_var_factory(node, var, _cache={}):
- _type_name_to_class = {
- 'integer' : IntegerWrapperVar,
- 'real' : RealWrapperVar,
- 'doubleprecision' : RealWrapperVar,
- 'character': CharacterWrapperVar,
- 'logical' : LogicalWrapperVar,
- 'complex' : ComplexWrapperVar,
- 'doublecomplex' : ComplexWrapperVar
- }
-
- _array_to_class = {
- 'integer' : IntegerArrayWrapperVar,
- 'real' : RealArrayWrapperVar,
- 'doubleprecision' : RealArrayWrapperVar,
- 'character': CharacterWrapperVar,
- 'logical' : LogicalArrayWrapperVar,
- 'complex' : ComplexArrayWrapperVar,
- 'doublecomplex' : ComplexArrayWrapperVar
- }
-
- d = _cache.get(node)
- if d is None:
- d = Disambiguator()
- _cache[node] = d
-
- type_name = _get_type_name(var)
-
- if var.is_array():
- return _array_to_class[type_name](var, d)
- else:
- return _type_name_to_class[type_name](var, d)
-
-INTENT_IN = 'IN'
-INTENT_OUT = 'OUT'
-INTENT_INOUT = 'INOUT'
-
-class FortranWrapperVar(object):
- #
- # A FortranWrapperVar is responsible for setting-up an appropriate
- # conversion between the fortran-wrapper procedure input arguments and the
- # argument of the wrapped procedure. Some argument types (real, integer,
- # complex if C99 _Complex is supported, etc.) have a 1-to-1 correspondence
- # with a C type. Others (logical) must be passed to the fortran wrapper
- # procedure as a different type (a C-int) and converted before or after the
- # wrapped procedure call, as appropriate.
-
- # Arrays are different. Each array argument of the wrapped procedure
- # requires multiple wrapper arguments (at least a data pointer and the
- # extent in each dimension). A c_f_pointer() call is required before the
- # wrapped procedure call, and possibly a copy is required for, e.g., a
- # C-int -> logical -> C-int type. Each array requires a temporary array
- # pointer that is the second argument to the c_f_pointer() call, and is the
- # array passed to the wrapped procedure.
-
- # XXX: user-defined type description here.
-
- is_array = False
-
- def __init__(self, var, disambig):
- self.disambig = disambig
- vkr = VarKindResolution(var)
- self.var = var
- self.type_name = vkr.type_name
- self.resolved_name = vkr.resolved_name
- self.ktp_str = vkr.ktp_str
- self.defining_param = vkr.defining_param
- self.defining_scope = vkr.defining_scope
- self.length = vkr.length
- self.vkr = vkr
- self.intent = None
-
- if var.is_intent_in(): self.intent = INTENT_IN
- elif var.is_intent_inout(): self.intent = INTENT_INOUT
- elif var.is_intent_out(): self.intent = INTENT_OUT
- # else:
- # node = self.defining_scope
- # if isinstance(node, Function) and \
- # self.var is node.a.variables[node.result]:
- # self.intent = None
-
- def get_py_arg_declarations(self):
- return ((self.resolved_name, self.var.name),)
-
- def get_py_pass_argnames(self):
- return (self.var.name,)
-
- def get_cy_arg_declarations(self):
- return ((self.get_c_proto_types()[0], self.var.name),)
-
- def pre_call_cy_code(self, code):
- pass
-
- def post_call_cy_code(self, code):
- pass
-
-
- def get_cy_pass_argnames(self):
- return (self.var.name,)
-
- def generate_cy_declarations(self, code):
- pass
-
- def get_c_proto_types(self):
- if self.intent == INTENT_IN:
- ret = self.resolved_name
- else:
- ret = self.resolved_name+'*'
- return [ret]
-
- def get_fort_argnames(self):
- return [self.var.name]
-
- def get_fort_pass_argnames_map(self):
- return (self.var.name, self.var.name)
-
- def generate_fort_declarations(self, code):
- var = self.var
- attributes = []
- if self.intent is not None:
- attributes.append('intent(%s)' % self.intent)
- if self.intent == INTENT_IN:
- attributes.append('value')
- # collect other attributes here...
- attr_str = ''
- if attributes:
- attr_str += ", " + (", ".join(attributes))
- decl = "%(type_name)s(kind=%(ktp)s) %(attrs)s :: %(var_name)s" % \
- { 'type_name' : self.type_name,
- 'attrs' : attr_str,
- 'ktp' : self.resolved_name,
- 'var_name' : self.var.name
- }
- code.putln(decl)
-
- def pre_call_fortran_code(self, code):
- pass
-
- def post_call_fortran_code(self, code):
- pass
-
-class LogicalWrapperVar(FortranWrapperVar):
-
- def __init__(self, *args, **kwargs):
- FortranWrapperVar.__init__(self, *args, **kwargs)
-
- self.int_proxy = Entry(self.disambig()+self.var.name, FortranIntegerType(self.resolved_name))
- self.int_proxy.is_arg = True
- self.int_proxy.intent = self.intent
- # self.int_proxy.attributes.append("intent(%s)" % self.intent)
- if self.intent == INTENT_IN:
- self.int_proxy.is_value = True
-
- self.log_var = Entry(self.disambig()+self.var.name, FortranLogicalType(self.resolved_name))
- self.log_var.is_arg = False
-
- def get_c_proto_types(self):
- if not self.int_proxy.is_value:
- return [self.int_proxy.get_base_type_name() + '*']
- else:
- return [self.int_proxy.get_base_type_name()]
-
- def get_fort_argnames(self):
- return [self.int_proxy.name]
-
- def get_fort_pass_argnames_map(self):
- return (self.var.name, self.log_var.name)
-
- def generate_fort_declarations(self, code):
- for entry in (self.int_proxy, self.log_var):
- entry.generate_fort_declaration(code)
-
- def pre_call_fortran_code(self, code):
- if self.intent in (INTENT_IN, INTENT_INOUT):
- code.putln("%s = logical(%s .ne. 0, kind=%s)" % (self.log_var.name, self.int_proxy.name, self.int_proxy.type.ktp))
-
- def post_call_fortran_code(self, code):
- if self.intent in (INTENT_INOUT, INTENT_OUT):
- code.putln("if (%s) then" % self.log_var.name )
- code.putln(" %s = 1 " % self.int_proxy.name)
- code.putln("else " )
- code.putln(" %s = 0 " % self.int_proxy.name)
- code.putln("endif " )
-
-class IntegerWrapperVar(FortranWrapperVar):
- pass
-
-class RealWrapperVar(FortranWrapperVar):
- pass
-
-class ComplexWrapperVar(FortranWrapperVar):
- pass
-
-class CharacterWrapperVar(FortranWrapperVar):
- pass
-
-# class CyArrayWrapperVar(object):
-
- # def __init__(self, fort_wrapper_var, disambig):
- # self.disambig = disambig
- # self.fort_wrapper_var = fort_wrapper_var
- # self.memview_in = Entry(self.disambig()+'mvs', fort_wrapper_var.var_entry.type)
- # self.ndim = fort_wrapper_var.ndim
-
- # def get_signature_types(self):
- # slice_decl = [":"]*self.ndim
- # slice_decl[0] = "::1"
- # return ["%s[%s]" % (self.memview_in.get_base_type_name(),','.join(slice_decl))]
-
-ARRAY_SHAPE_TYPE = "fwrap_ardim_long"
-class ArrayWrapperVar(FortranWrapperVar):
-
- def __init__(self, var, disambig):
- assert var.is_array()
- FortranWrapperVar.__init__(self, var, disambig)
- # array-specific initializations
- self.is_array = True
- self.is_explicit_shape = var.is_explicit_shape_array()
- self.is_assumed_shape = var.is_assumed_shape_array()
- self.is_assumed_size = var.is_assumed_size_array()
- self.array_spec = var.get_array_spec()
- self.ndim = len(self.array_spec)
-
- if not self.is_assumed_shape:
- raise NotImplementedError("only assumed shape arrays for now...")
-
- self.shape_array = Entry(self.disambig()+self.var.name,
- FortranArrayType(FortranIntegerType(ktp=ARRAY_SHAPE_TYPE),
- (str(self.ndim),)
- )
- )
-
- self.shape_array.is_arg = True
- self.shape_array.intent = INTENT_IN
-
- self.data_ptr = Entry(self.disambig()+self.var.name, FortranCPtrType())
- self.data_ptr.is_arg = True
- self.data_ptr.is_value = True
-
- self.arr_proxy = Entry(self.disambig()+self.var.name,
- FortranArrayType(type_from_vkr(self.vkr),
- (('',''),)*self.ndim))
- self.arr_proxy.is_pointer = True
-
- self.var_entry = Entry(self.var.name, type_from_vkr(self.vkr))
-
- def get_py_arg_declarations(self):
- return (('', self.var_entry.name),)
-
- def get_py_pass_argnames(self):
- return (self.var_entry.name,)
-
- def get_cy_arg_declarations(self):
- slice_decl = [":"]*self.ndim
- slice_decl[0] = "::1"
- return (("%s[%s]" % (self.var_entry.get_base_type_name(),','.join(slice_decl)),
- self.var_entry.name),)
-
- def get_cy_pass_argnames(self):
- return (self.data_ptr.name, self.shape_array.name)
-
- def generate_cy_declarations(self, code):
- if not self.is_assumed_shape:
- raise NotImplementedError("only assumed shape arrays for now...")
- code.putln("cdef %s.%s *%s" % (CY_IMPORT_ALIAS,
- self.var_entry.get_base_type_name(),
- self.data_ptr.name))
- code.putln("cdef %s.%s *%s" % (CY_IMPORT_ALIAS,
- self.shape_array.get_base_type_name(),
- self.shape_array.name))
-
- def pre_call_cy_code(self, code):
- code.putln("%s = <%s.%s*>%s._data" % (
- self.data_ptr.name,
- CY_IMPORT_ALIAS,
- self.var_entry.get_base_type_name(),
- self.var_entry.name))
- code.putln("%s = <%s.%s*>%s.shape" % (
- self.shape_array.name,
- CY_IMPORT_ALIAS,
- self.shape_array.get_base_type_name(),
- self.var_entry.name))
-
- def post_call_cy_code(self, code):
- pass
-
- def get_c_proto_types(self):
- return [self.var_entry.get_base_type_name()+'*', self.shape_array.get_base_type_name()+'*']
-
- def get_fort_argnames(self):
- return [self.data_ptr.name, self.shape_array.name]
-
- def get_fort_pass_argnames_map(self):
- return [self.var.name, self.arr_proxy.name]
-
- def generate_fort_declarations(self, code):
- if self.is_assumed_shape:
- for entry in (self.shape_array, self.data_ptr, self.arr_proxy):
- entry.generate_fort_declaration(code)
- else:
- raise NotImplementedError("only assumed shape arrays for now...")
-
- def pre_call_fortran_code(self, code):
- code.putln("call c_f_pointer(%s, %s, %s)" % (self.data_ptr.name, self.arr_proxy.name, self.shape_array.name))
-
- def post_call_fortran_code(self, code):
- pass
-
-class IntegerArrayWrapperVar(ArrayWrapperVar):
- pass
-
-class RealArrayWrapperVar(ArrayWrapperVar):
- pass
-
-class ComplexArrayWrapperVar(ArrayWrapperVar):
- pass
-
-class LogicalArrayWrapperVar(ArrayWrapperVar):
- pass
-
-_c_binding_to_c_type = {
- # 'c_int' : 'int',
- }
-
-class Entry(object):
-
- def __init__(self, name, type):
- self.name = name
- self.type = type
- self.is_arg = False
- self.is_value = False
- self.is_pointer = False
- self.intent = None
-
- def generate_fort_declaration(self, code):
- attributes = []
- if self.is_pointer:
- attributes.append('pointer')
- if self.is_value:
- # assert self.intent == INTENT_IN
- attributes.append('value')
- if self.intent:
- attributes.append('intent(%s)' % self.intent)
- before_colons = [self.type.get_type_code()] + self.type.attributes + attributes
- code.putln("%s :: %s" % (",".join(before_colons), self.name))
-
- def get_base_type_name(self):
- # ret = _c_binding_to_c_type.get(self.type.ktp, self.type.ktp)
- return self.type.ktp
- # if self.is_value:
- # return ret
- # else:
- # return ret+"*"
-
-class FortranType(object):
-
- def __init__(self, ktp=None):
- self.ktp = ktp
- self.attributes = []
-
- def get_type_code(self):
- if self.ktp:
- return "%s(kind=%s)" % (self.type_name, self.ktp)
- else:
- return self.type_name
-
-class FortranIntegerType(FortranType):
-
- type_name = "integer"
-
-class FortranRealType(FortranType):
-
- type_name = "real"
-
-class FortranCharacterType(FortranType):
-
- type_name = "character"
-
-class FortranLogicalType(FortranType):
-
- type_name = "logical"
-
-class FortranComplexType(FortranType):
-
- type_name = "complex"
-
-class FortranCPtrType(FortranType):
-
- def get_type_code(self):
- return "type(c_ptr)"
-
-class FortranArrayType(FortranType):
-
- def __init__(self, base_type, shape):
- self.base_type = base_type
- self.ktp = self.base_type.ktp
- self.shape = shape
- self.attributes = []
-
- dims = []
- for sh in shape:
- if len(sh) == 1:
- dims.append(sh[0])
- else:
- dims.append("%s:%s" % (sh[0], sh[1]))
-
- self.attributes.append("dimension(%s)" % (",".join(dims)))
-
- def get_type_code(self):
- return self.base_type.get_type_code()
diff --git a/Tools/fwrap/__init__.py b/Tools/fwrap/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/Tools/fwrap/__init__.py
+++ /dev/null
diff --git a/Tools/fwrap/fwrap.py b/Tools/fwrap/fwrap.py
deleted file mode 100755
index e673df49e..000000000
--- a/Tools/fwrap/fwrap.py
+++ /dev/null
@@ -1,4 +0,0 @@
-#! /usr/bin/env python
-from Main import main
-
-main()
diff --git a/Tools/fwrap/fwrap_setup.py b/Tools/fwrap/fwrap_setup.py
deleted file mode 100644
index 6b4449133..000000000
--- a/Tools/fwrap/fwrap_setup.py
+++ /dev/null
@@ -1,157 +0,0 @@
-from distutils.errors import DistutilsFileError
-from Cython.Distutils import build_ext as cy_build_ext
-from numpy.distutils.command.build_ext import build_ext as np_build_ext
-from numpy.distutils.extension import Extension as np_extension
-from numpy.distutils.core import setup
-import os
-
-
-class FwrapExtension(np_extension):
- def __init__ (self, name, sources,
- include_dirs=None,
- define_macros=None,
- undef_macros=None,
- library_dirs=None,
- libraries=None,
- runtime_library_dirs=None,
- extra_objects=None,
- extra_compile_args=None,
- extra_link_args=None,
- export_symbols=None,
- swig_opts=None,
- depends=None,
- language=None,
- f2py_options=None,
- module_dirs=None,
- pyrex_include_dirs = None,
- pyrex_create_listing = 0,
- pyrex_cplus = 0,
- pyrex_c_in_temp = 0,
- pyrex_gen_pxi = 0,
- fwrap_config_sources=None,
- fwrap_cython_sources = None,
- **kw):
-
- np_extension.__init__(self, name, sources,
- include_dirs,
- define_macros,
- undef_macros,
- library_dirs,
- libraries,
- runtime_library_dirs,
- extra_objects,
- extra_compile_args,
- extra_link_args,
- export_symbols,
- swig_opts,
- depends,
- language,
- f2py_options,
- module_dirs,
- )
-
- self.pyrex_include_dirs = pyrex_include_dirs or []
- self.pyrex_create_listing = pyrex_create_listing
- self.pyrex_cplus = pyrex_cplus
- self.pyrex_c_in_temp = pyrex_c_in_temp
- self.pyrex_gen_pxi = pyrex_gen_pxi
-
- self.fwrap_config_sources = fwrap_config_sources or []
- if len(fwrap_config_sources) != 1:
- raise DistutilsFileError("Only one fortran configuration file allowed.")
- self.fwrap_cython_sources = fwrap_cython_sources or []
-
-
-
-class fwrap_build_ext(np_build_ext, cy_build_ext):
-
- def initialize_options(self):
- np_build_ext.initialize_options(self)
- self.pyrex_cplus = 0
- self.pyrex_create_listing = 0
- self.pyrex_include_dirs = None
- self.pyrex_c_in_temp = 0
- self.pyrex_gen_pxi = 0
-
- def finalize_options (self):
- np_build_ext.finalize_options(self)
- if self.pyrex_include_dirs is None:
- self.pyrex_include_dirs = []
- elif type(self.pyrex_include_dirs) is StringType:
- self.pyrex_include_dirs = \
- self.pyrex_include_dirs.split(os.pathsep)
-
- def init_compilers(self):
-
- from distutils.ccompiler import new_compiler
- from numpy.distutils.fcompiler import new_fcompiler
-
- compiler_type = self.compiler
- # Initialize C compiler:
- self.compiler = new_compiler(compiler=compiler_type,
- verbose=self.verbose,
- dry_run=self.dry_run,
- force=self.force)
- self.compiler.customize(self.distribution)
- self.compiler.customize_cmd(self)
- self.compiler.show_customization()
-
- # Initialize Fortran compiler:
- ctype = self.fcompiler
- self._f90_compiler = new_fcompiler(compiler=self.fcompiler,
- verbose=self.verbose,
- dry_run=self.dry_run,
- force=self.force,
- requiref90=True,
- c_compiler = self.compiler)
- fcompiler = self._f90_compiler
- if fcompiler:
- ctype = fcompiler.compiler_type
- fcompiler.customize(self.distribution)
- if fcompiler and fcompiler.get_version():
- fcompiler.customize_cmd(self)
- fcompiler.show_customization()
- else:
- self.warn('f90_compiler=%s is not available.' %
- (ctype))
- self._f90_compiler = None
-
- # don't need cxx compiler.
- self._cxx_compiler = None
-
- def run(self):
-
- self.init_compilers()
- fcompiler = self._f90_compiler
-
- for ext in self.extensions:
-
- fullname = self.get_ext_fullname(ext.name)
-
- module_dirs = ext.module_dirs[:]
- module_build_dir = os.path.join(
- self.build_temp,os.path.dirname(
- self.get_ext_filename(fullname)))
-
- extra_postargs = fcompiler.module_options(
- module_dirs,module_build_dir)
-
- # generate fortran config files.
- assert len(ext.fwrap_config_sources) == 1
- config_source, config_result = ext.fwrap_config_sources[0]
- exname = os.path.splitext(config_source)[0]
-
- onames = fcompiler.compile([config_source],
- output_dir=self.build_temp,
- extra_postargs=extra_postargs)
- print fcompiler.link_executable(onames,
- exname,
- output_dir=self.build_temp,
- extra_postargs=extra_postargs)
- # TODO: untested on windows, may not work.
- fcompiler.spawn([os.path.join(self.build_temp,exname)])
-
- c_sources = cy_build_ext.cython_sources(self, ext.fwrap_cython_sources, ext)
- ext.sources = c_sources + [config_result] + ext.sources
- print ext.sources
- np_build_ext.build_extension(self, ext)
diff --git a/Tools/fwrap/runtests.py b/Tools/fwrap/runtests.py
deleted file mode 100644
index 9b95768f2..000000000
--- a/Tools/fwrap/runtests.py
+++ /dev/null
@@ -1,910 +0,0 @@
-#!/usr/bin/python
-
-import os, sys, re, shutil, unittest, doctest
-
-WITH_CYTHON = True
-
-from distutils.dist import Distribution
-from distutils.core import Extension
-from distutils.command.build_ext import build_ext as _build_ext
-distutils_distro = Distribution()
-
-TEST_DIRS = ['compile', 'errors', 'run', 'pyregr']
-TEST_RUN_DIRS = ['run', 'pyregr']
-
-# Lists external modules, and a matcher matching tests
-# which should be excluded if the module is not present.
-EXT_DEP_MODULES = {
- 'numpy' : re.compile('.*\.numpy_.*').match
-}
-
-def get_numpy_include_dirs():
- import numpy
- return [numpy.get_include()]
-
-EXT_DEP_INCLUDES = [
- # test name matcher , callable returning list
- (re.compile('numpy_.*').match, get_numpy_include_dirs),
-]
-
-VER_DEP_MODULES = {
-# such as:
-# (2,4) : lambda x: x in ['run.set']
-}
-
-INCLUDE_DIRS = [ d for d in os.getenv('INCLUDE', '').split(os.pathsep) if d ]
-CFLAGS = os.getenv('CFLAGS', '').split()
-
-class build_ext(_build_ext):
- def build_extension(self, ext):
- if ext.language == 'c++':
- try:
- self.compiler.compiler_so.remove('-Wstrict-prototypes')
- except Exception:
- pass
- _build_ext.build_extension(self, ext)
-
-class ErrorWriter(object):
- match_error = re.compile('(warning:)?(?:.*:)?\s*([-0-9]+)\s*:\s*([-0-9]+)\s*:\s*(.*)').match
- def __init__(self):
- self.output = []
- self.write = self.output.append
-
- def _collect(self, collect_errors, collect_warnings):
- s = ''.join(self.output)
- result = []
- for line in s.split('\n'):
- match = self.match_error(line)
- if match:
- is_warning, line, column, message = match.groups()
- if (is_warning and collect_warnings) or \
- (not is_warning and collect_errors):
- result.append( (int(line), int(column), message.strip()) )
- result.sort()
- return [ "%d:%d: %s" % values for values in result ]
-
- def geterrors(self):
- return self._collect(True, False)
-
- def getwarnings(self):
- return self._collect(False, True)
-
- def getall(self):
- return self._collect(True, True)
-
-class TestBuilderBase(object):
- def __init__(self, *args, **kwargs):
- pass
-
- def build_suite(self):
- pass
-
-class FwrapTestBuilder(object):
- def __init__(self, rootdir, workdir, selectors, exclude_selectors,
- cleanup_workdir, cleanup_sharedlibs):
- self.rootdir = rootdir
- self.workdir = workdir
- self.selectors = selectors
- self.exclude_selectors = exclude_selectors
- self.cleanup_workdir = cleanup_workdir
- self.cleanup_sharedlibs = cleanup_sharedlibs
-
- def build_suite(self):
- suite = unittest.TestSuite()
- test_dirs = TEST_DIRS
- filenames = os.listdir(self.rootdir)
- filenames.sort()
- for filename in filenames:
- path = os.path.join(self.rootdir, filename)
- if os.path.isdir(path) and filename in test_dirs:
- suite.addTest(
- self.handle_directory(path, filename))
- return suite
-
- def handle_directory(self, path, context):
- workdir = os.path.join(self.workdir, context)
- if not os.path.exists(workdir):
- os.makedirs(workdir)
-
- suite = unittest.TestSuite()
- filenames = os.listdir(path)
- filenames.sort()
- for filename in filenames:
- if os.path.splitext(filename)[1].lower() not in (".f", ".f77", ".f90", ".f95"):
- continue
- if filename.startswith('.'): continue # certain emacs backup files
- basename = os.path.splitext(filename)[0]
- fqbasename = "%s.%s" % (context, basename)
- if not [1 for match in self.selectors if match(fqbasename)]:
- continue
- if self.exclude_selectors:
- if [1 for match in self.exclude_selectors if match(fqbasename)]:
- continue
- if context in TEST_RUN_DIRS:
- # test_class = FwrapCompileTestCase
- test_class = FwrapRunTestCase
- else:
- test_class = FwrapCompileTestCase
- suite.addTest(self.build_test(test_class, path, workdir, filename))
- return suite
-
- def build_test(self, test_class, path, workdir, filename):
- return test_class(path, workdir, filename,
- cleanup_workdir=self.cleanup_workdir,
- cleanup_sharedlibs=self.cleanup_sharedlibs)
-
-class _devnull(object):
-
- def flush(self): pass
- def write(self, s): pass
-
- def read(self): return ''
-
-
-class FwrapCompileTestCase(unittest.TestCase):
- def __init__(self, directory, workdir, filename,
- cleanup_workdir=True, cleanup_sharedlibs=True):
- self.directory = directory
- self.workdir = workdir
- self.filename = filename
- self.cleanup_workdir = cleanup_workdir
- self.cleanup_sharedlibs = cleanup_sharedlibs
- unittest.TestCase.__init__(self)
-
- def shortDescription(self):
- return "wrapping %s" % self.filename
-
- def setUp(self):
- if self.workdir not in sys.path:
- sys.path.insert(0, self.workdir)
-
- def tearDown(self):
- try:
- sys.path.remove(self.workdir)
- except ValueError:
- pass
- if os.path.exists(self.workdir):
- if self.cleanup_workdir:
- for rmfile in os.listdir(self.workdir):
- # if not self.cleanup_workdir:
- # if rmfile.lower().startswith("wrap") or rmfile.lower().startswith("autoconfig"):
- # continue
- # if not self.cleanup_sharedlibs and rmfile.endswith(".so") or rmfile.endswith(".dll"):
- # continue
- try:
- rmfile = os.path.join(self.workdir, rmfile)
- if os.path.isdir(rmfile):
- shutil.rmtree(rmfile, ignore_errors=True)
- else:
- os.remove(rmfile)
- except IOError:
- pass
- else:
- os.makedirs(self.workdirs)
-
- def runTest(self):
- self.projname = os.path.splitext(self.filename)[0] + '_fwrap'
- self.projdir = os.path.join(self.workdir, self.projname)
- self.wrapped_filename = self.projname+'_fortran.f95'
- self.fwrap_config_source='genconfig.f95'
- self.fwrap_config_module_source='config.f95'
- self.fwrap_cython_source=self.projname+'.pyx'
- fq_fname = os.path.join(os.path.abspath(self.directory), self.filename)
- wrap([fq_fname], self.directory, self.workdir, self.projname)
- # self.runCompileTest()
- self.runCompileTest_distutils()
-
- def runCompileTest(self):
- from subprocess import Popen, PIPE, STDOUT, CalledProcessError
- p = Popen(['make'], cwd=self.projdir, close_fds=True,
- stdout=PIPE, stderr=STDOUT)
- output = p.communicate()[0]
- if p.returncode:
- raise CalledProcessError(p.returncode, "make")
-
-
- def runCompileTest_distutils(self):
- import sys
- CYTHON_DIR = os.path.abspath(os.path.join(os.path.pardir, os.path.pardir))
- FILENAME = self.filename
- WRAPPED_FILENAME = self.wrapped_filename
- PROJNAME = self.projname
- FWRAP_CONFIG_SOURCE = self.fwrap_config_source
- FWRAP_CONFIG_MODULE_SOURCE = self.fwrap_config_module_source
- FWRAP_CYTHON_SOURCE = self.fwrap_cython_source
-
- setup_source = '''
-import os,sys
-sys.path.insert(0, '%(CYTHON_DIR)s')
-
-from fwrap_setup import FwrapExtension, fwrap_build_ext, setup
-sources = ['%(FILENAME)s', '%(WRAPPED_FILENAME)s']
-ext = FwrapExtension(
- '%(PROJNAME)s',
- sources= ['%(FILENAME)s', '%(WRAPPED_FILENAME)s'],
- fwrap_config_sources=[('%(FWRAP_CONFIG_SOURCE)s', '%(FWRAP_CONFIG_MODULE_SOURCE)s')],
- fwrap_cython_sources=['%(FWRAP_CYTHON_SOURCE)s'],
- )
-setup(cmdclass={'build_ext' : fwrap_build_ext},
- ext_modules = [ext])
-''' % locals()
-
- setup_fqpath = os.path.join(self.projdir, 'setup.py')
- f = open(setup_fqpath,'w')
- f.write(setup_source)
- f.close()
-
- shutil.copy('fwrap_setup.py', self.projdir)
- shutil.copy(os.path.join(self.directory, self.filename), self.projdir)
- from distutils.core import run_setup
- thisdir = os.path.abspath(os.curdir)
- try:
- os.chdir(self.projdir)
- orig_stdout, orig_stderr = sys.stdout, sys.stderr
- sys.stdout = _devnull()
- sys.stderr = _devnull()
- run_setup(setup_fqpath, script_args=['build_ext', '--fcompiler=gnu95', '-lgfortran', '--inplace'])
- finally:
- os.chdir(thisdir)
- sys.stdout,sys.stderr = orig_stdout, orig_stderr
-
- def build_target_filenames(self, filename):
- fortran_wrapper = "wrap_%s" % filename
- c_header = "wrap_%s.h" % os.path.splitext(filename)[0]
- return (fortran_wrapper, c_header)
-
- def compile(self, directory, filename, workdir, incdir):
- self.run_wrapper(directory, filename, workdir, incdir)
-
- def run_wrapper(self, directory, filename, workdir, incdir):
- wrap(filename, directory, workdir)
-
-
-class FwrapRunTestCase(FwrapCompileTestCase):
- def shortDescription(self):
- return "compiling and running %s" % self.filename
-
- def run(self, result=None):
- if result is None:
- result = self.defaultTestResult()
- result.startTest(self)
- try:
- self.setUp()
- self.runTest()
- if self.projdir not in sys.path:
- sys.path.insert(0, self.projdir)
- doctest_mod_base = self.projname+'_doctest'
- doctest_mod_fqpath = os.path.join(self.directory, doctest_mod_base+'.py')
- shutil.copy(doctest_mod_fqpath, self.projdir)
- doctest.DocTestSuite(self.projname+'_doctest').run(result) #??
- except Exception:
- result.addError(self, sys.exc_info())
- result.stopTest(self)
- try:
- self.tearDown()
- except Exception:
- pass
-
-
-class TestBuilder(object):
- def __init__(self, rootdir, workdir, selectors, exclude_selectors, annotate,
- cleanup_workdir, cleanup_sharedlibs, with_pyregr, cython_only,
- languages, test_bugs):
- self.rootdir = rootdir
- self.workdir = workdir
- self.selectors = selectors
- self.exclude_selectors = exclude_selectors
- self.annotate = annotate
- self.cleanup_workdir = cleanup_workdir
- self.cleanup_sharedlibs = cleanup_sharedlibs
- self.with_pyregr = with_pyregr
- self.cython_only = cython_only
- self.languages = languages
- self.test_bugs = test_bugs
-
- def build_suite(self):
- suite = unittest.TestSuite()
- test_dirs = TEST_DIRS
- filenames = os.listdir(self.rootdir)
- filenames.sort()
- for filename in filenames:
- if not WITH_CYTHON and filename == "errors":
- # we won't get any errors without running Cython
- continue
- path = os.path.join(self.rootdir, filename)
- if os.path.isdir(path) and filename in test_dirs:
- if filename == 'pyregr' and not self.with_pyregr:
- continue
- suite.addTest(
- self.handle_directory(path, filename))
- return suite
-
- def handle_directory(self, path, context):
- workdir = os.path.join(self.workdir, context)
- if not os.path.exists(workdir):
- os.makedirs(workdir)
-
- expect_errors = (context == 'errors')
- suite = unittest.TestSuite()
- filenames = os.listdir(path)
- filenames.sort()
- for filename in filenames:
- if not (filename.endswith(".pyx") or filename.endswith(".py")):
- continue
- if filename.startswith('.'): continue # certain emacs backup files
- if context == 'pyregr' and not filename.startswith('test_'):
- continue
- module = os.path.splitext(filename)[0]
- fqmodule = "%s.%s" % (context, module)
- if not [ 1 for match in self.selectors
- if match(fqmodule) ]:
- continue
- if self.exclude_selectors:
- if [1 for match in self.exclude_selectors if match(fqmodule)]:
- continue
- if context in TEST_RUN_DIRS:
- if module.startswith("test_"):
- test_class = CythonUnitTestCase
- else:
- test_class = CythonRunTestCase
- else:
- test_class = CythonCompileTestCase
- for test in self.build_tests(test_class, path, workdir,
- module, expect_errors):
- suite.addTest(test)
- return suite
-
- def build_tests(self, test_class, path, workdir, module, expect_errors):
- if expect_errors:
- languages = self.languages[:1]
- else:
- languages = self.languages
- if 'cpp' in module and 'c' in languages:
- languages = list(languages)
- languages.remove('c')
- tests = [ self.build_test(test_class, path, workdir, module,
- language, expect_errors)
- for language in languages ]
- return tests
-
- def build_test(self, test_class, path, workdir, module,
- language, expect_errors):
- workdir = os.path.join(workdir, language)
- if not os.path.exists(workdir):
- os.makedirs(workdir)
- return test_class(path, workdir, module,
- language=language,
- expect_errors=expect_errors,
- annotate=self.annotate,
- cleanup_workdir=self.cleanup_workdir,
- cleanup_sharedlibs=self.cleanup_sharedlibs,
- cython_only=self.cython_only)
-
-class CythonCompileTestCase(unittest.TestCase):
- def __init__(self, directory, workdir, module, language='c',
- expect_errors=False, annotate=False, cleanup_workdir=True,
- cleanup_sharedlibs=True, cython_only=False):
- self.directory = directory
- self.workdir = workdir
- self.module = module
- self.language = language
- self.expect_errors = expect_errors
- self.annotate = annotate
- self.cleanup_workdir = cleanup_workdir
- self.cleanup_sharedlibs = cleanup_sharedlibs
- self.cython_only = cython_only
- unittest.TestCase.__init__(self)
-
- def shortDescription(self):
- return "compiling (%s) %s" % (self.language, self.module)
-
- def setUp(self):
- if self.workdir not in sys.path:
- sys.path.insert(0, self.workdir)
-
- def tearDown(self):
- try:
- sys.path.remove(self.workdir)
- except ValueError:
- pass
- try:
- del sys.modules[self.module]
- except KeyError:
- pass
- cleanup_c_files = WITH_CYTHON and self.cleanup_workdir
- cleanup_lib_files = self.cleanup_sharedlibs
- if os.path.exists(self.workdir):
- for rmfile in os.listdir(self.workdir):
- if not cleanup_c_files:
- if rmfile[-2:] in (".c", ".h") or rmfile[-4:] == ".cpp":
- continue
- if not cleanup_lib_files and rmfile.endswith(".so") or rmfile.endswith(".dll"):
- continue
- if self.annotate and rmfile.endswith(".html"):
- continue
- try:
- rmfile = os.path.join(self.workdir, rmfile)
- if os.path.isdir(rmfile):
- shutil.rmtree(rmfile, ignore_errors=True)
- else:
- os.remove(rmfile)
- except IOError:
- pass
- else:
- os.makedirs(self.workdir)
-
- def runTest(self):
- self.runCompileTest()
-
- def runCompileTest(self):
- self.compile(self.directory, self.module, self.workdir,
- self.directory, self.expect_errors, self.annotate)
-
- def find_module_source_file(self, source_file):
- if not os.path.exists(source_file):
- source_file = source_file[:-1]
- return source_file
-
- def build_target_filename(self, module_name):
- target = '%s.%s' % (module_name, self.language)
- return target
-
- def split_source_and_output(self, directory, module, workdir):
- source_file = os.path.join(directory, module) + '.pyx'
- source_and_output = open(
- self.find_module_source_file(source_file), 'rU')
- out = open(os.path.join(workdir, module + '.pyx'), 'w')
- for line in source_and_output:
- last_line = line
- if line.startswith("_ERRORS"):
- out.close()
- out = ErrorWriter()
- else:
- out.write(line)
- try:
- geterrors = out.geterrors
- except AttributeError:
- return []
- else:
- return geterrors()
-
- def run_cython(self, directory, module, targetdir, incdir, annotate):
- include_dirs = INCLUDE_DIRS[:]
- if incdir:
- include_dirs.append(incdir)
- source = self.find_module_source_file(
- os.path.join(directory, module + '.pyx'))
- target = os.path.join(targetdir, self.build_target_filename(module))
- options = CompilationOptions(
- pyrex_default_options,
- include_path = include_dirs,
- output_file = target,
- annotate = annotate,
- use_listing_file = False,
- cplus = self.language == 'cpp',
- generate_pxi = False)
- cython_compile(source, options=options,
- full_module_name=module)
-
- def run_distutils(self, module, workdir, incdir):
- cwd = os.getcwd()
- os.chdir(workdir)
- try:
- build_extension = build_ext(distutils_distro)
- build_extension.include_dirs = INCLUDE_DIRS[:]
- if incdir:
- build_extension.include_dirs.append(incdir)
- build_extension.finalize_options()
- ext_include_dirs = []
- for match, get_additional_include_dirs in EXT_DEP_INCLUDES:
- if match(module):
- ext_include_dirs += get_additional_include_dirs()
- extension = Extension(
- module,
- sources = [self.build_target_filename(module)],
- include_dirs = ext_include_dirs,
- extra_compile_args = CFLAGS,
- )
- if self.language == 'cpp':
- extension.language = 'c++'
- build_extension.extensions = [extension]
- build_extension.build_temp = workdir
- build_extension.build_lib = workdir
- build_extension.run()
- finally:
- os.chdir(cwd)
-
- def compile(self, directory, module, workdir, incdir,
- expect_errors, annotate):
- expected_errors = errors = ()
- if expect_errors:
- expected_errors = self.split_source_and_output(
- directory, module, workdir)
- directory = workdir
-
- if WITH_CYTHON:
- old_stderr = sys.stderr
- try:
- sys.stderr = ErrorWriter()
- self.run_cython(directory, module, workdir, incdir, annotate)
- errors = sys.stderr.geterrors()
- finally:
- sys.stderr = old_stderr
-
- if errors or expected_errors:
- for expected, error in zip(expected_errors, errors):
- self.assertEquals(expected, error)
- if len(errors) < len(expected_errors):
- expected_error = expected_errors[len(errors)]
- self.assertEquals(expected_error, None)
- elif len(errors) > len(expected_errors):
- unexpected_error = errors[len(expected_errors)]
- self.assertEquals(None, unexpected_error)
- else:
- if not self.cython_only:
- self.run_distutils(module, workdir, incdir)
-
-class CythonRunTestCase(CythonCompileTestCase):
- def shortDescription(self):
- return "compiling (%s) and running %s" % (self.language, self.module)
-
- def run(self, result=None):
- if result is None:
- result = self.defaultTestResult()
- result.startTest(self)
- try:
- self.setUp()
- self.runCompileTest()
- if not self.cython_only:
- doctest.DocTestSuite(self.module).run(result)
- except Exception:
- result.addError(self, sys.exc_info())
- result.stopTest(self)
- try:
- self.tearDown()
- except Exception:
- pass
-
-class CythonUnitTestCase(CythonCompileTestCase):
- def shortDescription(self):
- return "compiling (%s) tests in %s" % (self.language, self.module)
-
- def run(self, result=None):
- if result is None:
- result = self.defaultTestResult()
- result.startTest(self)
- try:
- self.setUp()
- self.runCompileTest()
- unittest.defaultTestLoader.loadTestsFromName(self.module).run(result)
- except Exception:
- result.addError(self, sys.exc_info())
- result.stopTest(self)
- try:
- self.tearDown()
- except Exception:
- pass
-
-def collect_unittests(path, module_prefix, suite, selectors):
- def file_matches(filename):
- return filename.startswith("Test") and filename.endswith(".py")
-
- def package_matches(dirname):
- return dirname == "Tests"
-
- loader = unittest.TestLoader()
-
- skipped_dirs = []
-
- for dirpath, dirnames, filenames in os.walk(path):
- if dirpath != path and "__init__.py" not in filenames:
- skipped_dirs.append(dirpath + os.path.sep)
- continue
- skip = False
- for dir in skipped_dirs:
- if dirpath.startswith(dir):
- skip = True
- if skip:
- continue
- parentname = os.path.split(dirpath)[-1]
- if package_matches(parentname):
- for f in filenames:
- if file_matches(f):
- filepath = os.path.join(dirpath, f)[:-len(".py")]
- modulename = module_prefix + filepath[len(path)+1:].replace(os.path.sep, '.')
- if not [ 1 for match in selectors if match(modulename) ]:
- continue
- module = __import__(modulename)
- for x in modulename.split('.')[1:]:
- module = getattr(module, x)
- suite.addTests([loader.loadTestsFromModule(module)])
-
-def collect_doctests(path, module_prefix, suite, selectors):
- def package_matches(dirname):
- return dirname not in ("Mac", "Distutils", "Plex")
- def file_matches(filename):
- return (filename.endswith(".py") and not ('~' in filename
- or '#' in filename or filename.startswith('.')))
- import doctest, types
- for dirpath, dirnames, filenames in os.walk(path):
- parentname = os.path.split(dirpath)[-1]
- if package_matches(parentname):
- for f in filenames:
- if file_matches(f):
- if not f.endswith('.py'): continue
- filepath = os.path.join(dirpath, f)[:-len(".py")]
- modulename = module_prefix + filepath[len(path)+1:].replace(os.path.sep, '.')
- if not [ 1 for match in selectors if match(modulename) ]:
- continue
- module = __import__(modulename)
- for x in modulename.split('.')[1:]:
- module = getattr(module, x)
- if hasattr(module, "__doc__") or hasattr(module, "__test__"):
- try:
- suite.addTest(doctest.DocTestSuite(module))
- except ValueError: # no tests
- pass
-
-class MissingDependencyExcluder:
- def __init__(self, deps):
- # deps: { module name : matcher func }
- self.exclude_matchers = []
- for mod, matcher in deps.items():
- try:
- __import__(mod)
- except ImportError:
- self.exclude_matchers.append(matcher)
- self.tests_missing_deps = []
- def __call__(self, testname):
- for matcher in self.exclude_matchers:
- if matcher(testname):
- self.tests_missing_deps.append(testname)
- return True
- return False
-
-class VersionDependencyExcluder:
- def __init__(self, deps):
- # deps: { version : matcher func }
- from sys import version_info
- self.exclude_matchers = []
- for ver, matcher in deps.items():
- if version_info < ver:
- self.exclude_matchers.append(matcher)
- self.tests_missing_deps = []
- def __call__(self, testname):
- for matcher in self.exclude_matchers:
- if matcher(testname):
- self.tests_missing_deps.append(testname)
- return True
- return False
-
-class FileListExcluder:
-
- def __init__(self, list_file):
- self.excludes = {}
- for line in open(list_file).readlines():
- line = line.strip()
- if line and line[0] != '#':
- self.excludes[line.split()[0]] = True
-
- def __call__(self, testname):
- return testname.split('.')[-1] in self.excludes
-
-if __name__ == '__main__':
- from optparse import OptionParser
- parser = OptionParser()
- parser.add_option("--no-cleanup", dest="cleanup_workdir",
- action="store_false", default=True,
- help="do not delete the generated C files (allows passing --no-cython on next run)")
- parser.add_option("--no-cleanup-sharedlibs", dest="cleanup_sharedlibs",
- action="store_false", default=True,
- help="do not delete the generated shared libary files (allows manual module experimentation)")
- # parser.add_option("--no-cython", dest="with_cython",
- # action="store_false", default=True,
- # help="do not run the Cython compiler, only the C compiler")
- # parser.add_option("--no-c", dest="use_c",
- # action="store_false", default=True,
- # help="do not test C compilation")
- # parser.add_option("--no-cpp", dest="use_cpp",
- # action="store_false", default=True,
- # help="do not test C++ compilation")
- # parser.add_option("--no-unit", dest="unittests",
- # action="store_false", default=True,
- # help="do not run the unit tests")
- # parser.add_option("--no-doctest", dest="doctests",
- # action="store_false", default=True,
- # help="do not run the doctests")
- # parser.add_option("--no-file", dest="filetests",
- # action="store_false", default=True,
- # help="do not run the file based tests")
- # parser.add_option("--no-pyregr", dest="pyregr",
- # action="store_false", default=True,
- # help="do not run the regression tests of CPython in tests/pyregr/")
- # parser.add_option("--cython-only", dest="cython_only",
- # action="store_true", default=False,
- # help="only compile pyx to c, do not run C compiler or run the tests")
- # parser.add_option("--no-refnanny", dest="with_refnanny",
- # action="store_false", default=True,
- # help="do not regression test reference counting")
- # parser.add_option("--sys-pyregr", dest="system_pyregr",
- # action="store_true", default=False,
- # help="run the regression tests of the CPython installation")
- parser.add_option("-x", "--exclude", dest="exclude",
- action="append", metavar="PATTERN",
- help="exclude tests matching the PATTERN")
- # parser.add_option("-C", "--coverage", dest="coverage",
- # action="store_true", default=False,
- # help="collect source coverage data for the Compiler")
- # parser.add_option("-A", "--annotate", dest="annotate_source",
- # action="store_true", default=True,
- # help="generate annotated HTML versions of the test source files")
- # parser.add_option("--no-annotate", dest="annotate_source",
- # action="store_false",
- # help="do not generate annotated HTML versions of the test source files")
- parser.add_option("-v", "--verbose", dest="verbosity",
- action="count", default=0,
- help="display test progress, pass twice to print test names")
- parser.add_option("-T", "--ticket", dest="tickets",
- action="append",
- help="a bug ticket number to run the respective test in 'tests/bugs'")
-
- options, cmd_args = parser.parse_args()
-
- if 0:
- if sys.version_info[0] >= 3:
- # make sure we do not import (or run) Cython itself
- options.doctests = False
- options.with_cython = False
- options.unittests = False
- options.pyregr = False
-
- if options.coverage:
- import coverage
- coverage.erase()
- coverage.start()
-
- WITH_CYTHON = options.with_cython
-
- if WITH_CYTHON:
- from Cython.Compiler.Main import \
- CompilationOptions, \
- default_options as pyrex_default_options, \
- compile as cython_compile
- from Cython.Compiler import Errors
- Errors.LEVEL = 0 # show all warnings
- # if 0
-
- # RUN ALL TESTS!
- ROOTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'tests')
- WORKDIR = os.path.join(os.getcwd(), 'BUILD')
- # UNITTEST_MODULE = "Cython"
- # UNITTEST_ROOT = os.path.join(os.getcwd(), UNITTEST_MODULE)
- if os.path.exists(WORKDIR):
- for path in os.listdir(WORKDIR):
- if path in ("support",): continue
- shutil.rmtree(os.path.join(WORKDIR, path), ignore_errors=True)
- if not os.path.exists(WORKDIR):
- os.makedirs(WORKDIR)
-
- if 0:
- if WITH_CYTHON:
- from Cython.Compiler.Version import version
- sys.stderr.write("Running tests against Cython %s\n" % version)
- from Cython.Compiler import DebugFlags
- DebugFlags.debug_temp_code_comments = 1
- else:
- sys.stderr.write("Running tests without Cython.\n")
- #if 0
-
- from Main import wrap
-
- sys.stderr.write("Python %s\n" % sys.version)
- sys.stderr.write("\n")
-
- # insert cython.py/Cython source directory into sys.path
- cython_dir = os.path.abspath(os.path.join(os.path.pardir, os.path.pardir))
- sys.path.insert(0, cython_dir)
-
- if 0:
- if options.with_refnanny:
- from pyximport.pyxbuild import pyx_to_dll
- libpath = pyx_to_dll(os.path.join("Cython", "Runtime", "refnanny.pyx"),
- build_in_temp=True,
- pyxbuild_dir=os.path.join(WORKDIR, "support"))
- sys.path.insert(0, os.path.split(libpath)[0])
- CFLAGS.append("-DCYTHON_REFNANNY")
-
- #if 0
- test_bugs = False
- if options.tickets:
- for ticket_number in options.tickets:
- test_bugs = True
- cmd_args.append('.*T%s$' % ticket_number)
- if not test_bugs:
- for selector in cmd_args:
- if selector.startswith('bugs'):
- test_bugs = True
-
-
- import re
- selectors = [ re.compile(r, re.I|re.U).search for r in cmd_args ]
- if not selectors:
- selectors = [ lambda x:True ]
-
- # Chech which external modules are not present and exclude tests
- # which depends on them (by prefix)
-
- exclude_selectors = []
-
- if options.exclude:
- exclude_selectors += [ re.compile(r, re.I|re.U).search for r in options.exclude ]
-
- if 0:
- missing_dep_excluder = MissingDependencyExcluder(EXT_DEP_MODULES)
- version_dep_excluder = VersionDependencyExcluder(VER_DEP_MODULES)
- exclude_selectors = [missing_dep_excluder, version_dep_excluder] # want to pring msg at exit
-
-
- if not test_bugs:
- exclude_selectors += [ FileListExcluder("tests/bugs.txt") ]
-
- if 0:
- languages = []
- if options.use_c:
- languages.append('c')
- if options.use_cpp:
- languages.append('cpp')
- # if 0
-
- test_suite = unittest.TestSuite()
-
- if 0:
- if options.unittests:
- collect_unittests(UNITTEST_ROOT, UNITTEST_MODULE + ".", test_suite, selectors)
-
- if options.doctests:
- collect_doctests(UNITTEST_ROOT, UNITTEST_MODULE + ".", test_suite, selectors)
- # if 0
-
- filetests = FwrapTestBuilder(ROOTDIR, WORKDIR, selectors, exclude_selectors,
- options.cleanup_workdir, options.cleanup_sharedlibs)
- test_suite.addTest(filetests.build_suite())
-
- if 0:
- if options.filetests and languages:
- filetests = TestBuilder(ROOTDIR, WORKDIR, selectors, exclude_selectors,
- options.annotate_source, options.cleanup_workdir,
- options.cleanup_sharedlibs, options.pyregr,
- options.cython_only, languages, test_bugs)
- test_suite.addTest(filetests.build_suite())
-
- if options.system_pyregr and languages:
- filetests = TestBuilder(ROOTDIR, WORKDIR, selectors, exclude_selectors,
- options.annotate_source, options.cleanup_workdir,
- options.cleanup_sharedlibs, True,
- options.cython_only, languages, test_bugs)
- test_suite.addTest(
- filetests.handle_directory(
- os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3], 'test'),
- 'pyregr'))
-
- unittest.TextTestRunner(verbosity=options.verbosity).run(test_suite)
-
- if 0:
- if options.coverage:
- coverage.stop()
- ignored_modules = ('Options', 'Version', 'DebugFlags', 'CmdLine')
- modules = [ module for name, module in sys.modules.items()
- if module is not None and
- name.startswith('Cython.Compiler.') and
- name[len('Cython.Compiler.'):] not in ignored_modules ]
- coverage.report(modules, show_missing=0)
-
- if missing_dep_excluder.tests_missing_deps:
- sys.stderr.write("Following tests excluded because of missing dependencies on your system:\n")
- for test in missing_dep_excluder.tests_missing_deps:
- sys.stderr.write(" %s\n" % test)
-
- if options.with_refnanny:
- import refnanny
- sys.stderr.write("\n".join([repr(x) for x in refnanny.reflog]))
diff --git a/Tools/fwrap/tests/bugs.txt b/Tools/fwrap/tests/bugs.txt
deleted file mode 100644
index aa48e8b1d..000000000
--- a/Tools/fwrap/tests/bugs.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-all_complex.f95
-all_complex_fwrap_doctest.py
diff --git a/Tools/fwrap/tests/bugs/all_complex.f95 b/Tools/fwrap/tests/bugs/all_complex.f95
deleted file mode 100644
index a7ee4099d..000000000
--- a/Tools/fwrap/tests/bugs/all_complex.f95
+++ /dev/null
@@ -1,48 +0,0 @@
-
- subroutine complex_default(r1,r2,r3)
- implicit none
- complex, intent(in) :: r1
- complex, intent(inout) :: r2
- complex, intent(out) :: r3
- r3 = r3 + r1 - r1
- r2 = r2 + r3 - r3
- end subroutine
- ! subroutine complex_x_len(r10,r11,r12,r13,r14,r15)
- ! implicit none
- ! complex*4, intent(in) :: r10
- ! complex*4, intent(inout) :: r11
- ! complex*4, intent(out) :: r12
- ! complex*8, intent(in) :: r13
- ! complex*8, intent(inout) :: r14
- ! complex*8, intent(out) :: r15
- ! end subroutine
- subroutine complex_kind_x(r7,r8,r9,r10,r11,r12)
- implicit none
- complex(kind=4), intent(in) :: r7
- complex(kind=4), intent(inout) :: r8
- complex(kind=4), intent(out) :: r9
- complex(kind=8), intent(in) :: r10
- complex(kind=8), intent(inout) :: r11
- complex(kind=8), intent(out) :: r12
- end subroutine
- subroutine complex_kind_call(r1,r2,r3,r4,r5,r6)
- implicit none
- complex(kind=kind((0.0,0.0))), intent(in) :: r1
- complex(kind=kind((0.0,0.0))), intent(inout) :: r2
- complex(kind=kind((0.0,0.0))), intent(out) :: r3
- complex(kind=kind((0.0D0,0.0D0))), intent(in) :: r4
- complex(kind=kind((0.0D0,0.0D0))), intent(inout) :: r5
- complex(kind=kind((0.0D0,0.0D0))), intent(out) :: r6
- end subroutine
- subroutine complex_srk_call(r1,r2,r3,r4,r5,r6,r7,r8,r9)
- implicit none
- complex(kind=selected_real_kind(1)), intent(in) :: r1
- complex(kind=selected_real_kind(1)), intent(inout) :: r2
- complex(kind=selected_real_kind(1)), intent(out) :: r3
- complex(kind=selected_real_kind(7)), intent(in) :: r4
- complex(kind=selected_real_kind(7)), intent(inout) :: r5
- complex(kind=selected_real_kind(7)), intent(out) :: r6
- complex(kind=selected_real_kind(14)), intent(in) :: r7
- complex(kind=selected_real_kind(14)), intent(inout) :: r8
- complex(kind=selected_real_kind(14)), intent(out) :: r9
- end subroutine
diff --git a/Tools/fwrap/tests/bugs/all_complex_fwrap_doctest.py b/Tools/fwrap/tests/bugs/all_complex_fwrap_doctest.py
deleted file mode 100644
index b9b64d1bf..000000000
--- a/Tools/fwrap/tests/bugs/all_complex_fwrap_doctest.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from all_complex_fwrap import *
-
-__doc__ = u'''
->>> complex_default(1+1j,2+2j,3+3j)
-(2.0, 3.0)
->>> real_x_len(10,11,12,13,14,15)
-(11.0, 12.0, 14.0, 15.0)
->>> real_kind_x(7,8,9,10,11,12)
-(8.0, 9.0, 11.0, 12.0)
->>> real_kind_call(1,2,3,4,5,6)
-(2.0, 3.0, 5.0, 6.0)
->>> real_srk_call(1,2,3,4,5,6,7,8,9)
-(2.0, 3.0, 5.0, 6.0, 8.0, 9.0)
-'''
diff --git a/Tools/fwrap/tests/bugs/othermod.f95 b/Tools/fwrap/tests/bugs/othermod.f95
deleted file mode 100644
index 0a50ea028..000000000
--- a/Tools/fwrap/tests/bugs/othermod.f95
+++ /dev/null
@@ -1,7 +0,0 @@
-
- module other
- implicit none
-
- integer, parameter :: other_int = selected_real_kind(14)
-
- end module other
diff --git a/Tools/fwrap/tests/bugs/use_module.f95 b/Tools/fwrap/tests/bugs/use_module.f95
deleted file mode 100644
index c515aaa80..000000000
--- a/Tools/fwrap/tests/bugs/use_module.f95
+++ /dev/null
@@ -1,83 +0,0 @@
- module other
- implicit none
-
- integer, parameter :: other_int = selected_real_kind(14)
- public :: other_int
- end module other
-
- module used
- use other, used_int => other_int
- implicit none
-
- integer, parameter :: r8 = selected_real_kind(10,10)
- integer, parameter :: foo = 4
-
- end module used
-
- module sub1
- use used
- implicit none
- end module sub1
-
- module sub2
- use used
- implicit none
- end module sub2
-
- module diamond
- use sub1
- use sub2
- implicit none
- end module diamond
-
- ! function user(arg0)
- ! use diamond, r4 => foo
- ! implicit none
- ! ! real(kind=r8), intent(in) :: arg0
- ! ! real(kind=r4), intent(in) :: arg0
- ! real(kind=used_int), intent(in) :: arg0
- ! real(kind=r8) user
-
- ! user = arg0
-
- ! end function user
-
- module conflict
- use sub2
- implicit none
-
- integer, parameter :: r8 = 4
-
- ! contains
-
- ! subroutine user(arg0)
- ! use sub2
- ! implicit none
- ! real(kind=r8), intent(inout) :: arg0
-
- ! arg0 = 10
-
- ! end subroutine
-
- end module
-
-
-
-
- ! program prog
- ! use diamond
-
- ! implicit none
-
- ! interface
- ! function user(arg)
- ! use diamond
- ! implicit none
- ! real(kind=r8), intent(in) :: arg
- ! real(kind=r8) user
- ! end function
- ! end interface
-
- ! print *, user(10.0_r8)
-
- ! end program
diff --git a/Tools/fwrap/tests/bugs/use_module_fwrap_doctest.py b/Tools/fwrap/tests/bugs/use_module_fwrap_doctest.py
deleted file mode 100644
index e81055a43..000000000
--- a/Tools/fwrap/tests/bugs/use_module_fwrap_doctest.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from use_module_fwrap import *
-
-__doc__ = u'''
->>> user(10.0)
-(10.0,)
-'''
diff --git a/Tools/fwrap/tests/compile/default_types.f95 b/Tools/fwrap/tests/compile/default_types.f95
deleted file mode 100644
index 11bb3d89b..000000000
--- a/Tools/fwrap/tests/compile/default_types.f95
+++ /dev/null
@@ -1,12 +0,0 @@
-subroutine bar(a,b,d)
-implicit none
-integer :: a
-real :: b
-! complex :: c
-double precision :: d
-! logical :: e
-! character :: f
-a = 1
-b = 2.0
-d = 3.0
-end subroutine bar
diff --git a/Tools/fwrap/tests/compile/int_args.f95 b/Tools/fwrap/tests/compile/int_args.f95
deleted file mode 100644
index 77b58298d..000000000
--- a/Tools/fwrap/tests/compile/int_args.f95
+++ /dev/null
@@ -1,151 +0,0 @@
-
-function int_args_func(a,b,c,d)
- integer(kind=8) :: int_args_func
- integer(kind=1), intent(in) :: a
- integer(kind=2), intent(in) :: b
- integer(kind=4), intent(in) :: c
- integer(kind=8), intent(out) :: d
-
- d = a + b + c
- int_args_func = 10
-
-end function int_args_func
-
-subroutine int_args_subr(a,b,c,d)
- integer(kind=1), intent(in) :: a
- integer(kind=2), intent(in) :: b
- integer(kind=4), intent(in) :: c
- integer(kind=8), intent(out) :: d
-
- d = a + b + c
-
-end subroutine int_args_subr
-
-! module dummy
- ! use iso_c_binding
- ! use kind_type_params
- ! integer, parameter :: fortran_int_1 = c_signed_char
-
- ! contains
-
- ! subroutine int_args_subr_wrap(a,b,c,d) bind(c,name="int_args_subr")
- ! implicit none
- ! integer(kind=fortran_int_1), intent(in) :: a
- ! integer(kind=c_short), intent(in) :: b
- ! integer(kind=c_int), intent(in) :: c
- ! integer(kind=c_int64_t), intent(out) :: d
- ! ! integer(kind=c_long), intent(in) :: a
- ! ! integer(kind=c_long), intent(in) :: b
- ! ! integer(kind=c_long), intent(in) :: c
- ! ! integer(kind=c_long), intent(out) :: d
-
- ! ! integer(kind=1) :: convert_a
- ! ! integer(kind=2) :: convert_b
- ! ! integer(kind=4) :: convert_c
- ! ! integer(kind=8) :: convert_d
-
- ! interface
- ! subroutine int_args_subr(a,b,c,d)
- ! use kind_type_params
- ! integer(kind=1), intent(in) :: a
- ! integer(kind=2), intent(in) :: b
- ! integer(kind=4), intent(in) :: c
- ! integer(kind=sik10), intent(out) :: d
- ! end subroutine int_args_subr
- ! end interface
-
- ! print *, "before call in wrapper in fortran"
- ! print *, a,b,c,d
-
- ! ! convert_a = a
- ! ! convert_b = b
- ! ! convert_c = c
- ! ! convert_d = d
-
- ! print *, "before call in wrapper in fortran, converted vals."
- ! print *, convert_a, convert_b, convert_c, convert_d
-
- ! ! call int_args_subr(convert_a,convert_b,convert_c,convert_d)
- ! call int_args_subr(a,b,c,d)
-
- ! ! d = convert_d
-
- ! ! print *, "after call in wrapper in fortran, converted vals."
- ! ! print *, convert_a, convert_b, convert_c, convert_d
-
-! end subroutine int_args_subr_wrap
-! end module dummy
-
-! program blargh
-! use dummy
- ! integer(kind=1) :: a
- ! integer(kind=2) :: b
- ! integer(kind=4) :: c
- ! integer(kind=8) :: d
- ! ! integer(kind=8) :: a
- ! ! integer(kind=8) :: b
- ! ! integer(kind=8) :: c
- ! ! integer(kind=8) :: d
- ! a = 1; b = 2; c = 3; d = 4
-! call int_args_subr_wrap(a,b,c,d)
- ! print *, a,b,c,d
-! end program blargh
-
- ! ====================
- ! integer types
- ! --------------------
-
- ! c_int 4
- ! c_short 2
- ! c_long 8
- ! c_long_long 8
- ! c_signed_char 1
- ! c_size_t 8
- ! c_int8_t 1
- ! c_int16_t 2
- ! c_int32_t 4
- ! c_int64_t 8
- ! c_int_least8_t 1
- ! c_int_least16_t 2
- ! c_int_least32_t 4
- ! c_int_least64_t 8
- ! c_int_fast8_t -2
- ! c_int_fast16_t -2
- ! c_int_fast32_t -2
- ! c_int_fast64_t -2
- ! c_intmax_t 8
- ! c_intptr_t 8
-
- ! ====================
- ! real types
- ! --------------------
-
- ! c_float 4
- ! c_double 8
- ! c_long_double 10
-
- ! ====================
- ! complex types
- ! --------------------
-
- ! c_float_complex 4
- ! c_double_complex 8
- ! c_long_double_complex 10
-
- ! ====================
- ! logical types
- ! --------------------
-
- ! c_bool 1
-
- ! ====================
- ! character types
- ! --------------------
-
- ! c_char 1
-
-! module kind_type_params
-! implicit none
-! integer, parameter :: sik10 = selected_int_kind(10)
-
-! end module kind_type_params
diff --git a/Tools/fwrap/tests/compile/intargs_stuff/drive_int_args.c b/Tools/fwrap/tests/compile/intargs_stuff/drive_int_args.c
deleted file mode 100644
index 510f0e9b6..000000000
--- a/Tools/fwrap/tests/compile/intargs_stuff/drive_int_args.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stdio.h>
-
-void *int_args_subr(signed char *, short *, int *, long *);
-long int_args_func(signed char *, short *, int *, long *);
-
-int main(int argc, char **argv) {
-
- signed char a = 1;
- short b = 2;
- int c = 4;
- long d = 8;
- long result = 0;
-
- printf("before subr call in c\n");
- printf("%hhd %hd %d %ld\n", a,b,c,d);
- int_args_subr(&a, &b, &c, &d);
- printf("after subr call in c\n");
- printf("%hhd %hd %d %ld\n", a,b,c,d);
-
- printf("before func call in c\n");
- printf("%hhd %hd %d %ld\n", a,b,c,d);
- result = int_args_func(&a, &b, &c, &d);
- printf("after func call in c\n");
- printf("%hhd %hd %d %ld result=%ld\n", a,b,c,d, result);
-
- return 0;
-}
-
diff --git a/Tools/fwrap/tests/compile/intargs_stuff/wrap_int_args.f95 b/Tools/fwrap/tests/compile/intargs_stuff/wrap_int_args.f95
deleted file mode 100644
index 88ba2901c..000000000
--- a/Tools/fwrap/tests/compile/intargs_stuff/wrap_int_args.f95
+++ /dev/null
@@ -1,96 +0,0 @@
-subroutine wrapsubr_int_args_subr(a,b,c,d) bind(c,name="int_args_subr")
- use iso_c_binding
- implicit none
- integer(kind=c_signed_char), intent(in) :: a
- integer(kind=c_short), intent(in) :: b
- integer(kind=c_int), intent(in) :: c
- integer(kind=c_long), intent(out) :: d
-
- interface
- subroutine int_args_subr(a,b,c,d)
- integer(kind=1), intent(in) :: a
- integer(kind=2), intent(in) :: b
- integer(kind=4), intent(in) :: c
- integer(kind=8), intent(out) :: d
- end subroutine int_args_subr
- end interface
-
- call int_args_subr(a,b,c,d)
-end subroutine wrapsubr_int_args_subr
-
-function wrapfunc_int_args_func(a,b,c,d) bind(c,name="int_args_func")
- use iso_c_binding
- implicit none
- integer(kind=c_long) :: wrapfunc_int_args_func
- integer(kind=c_signed_char), intent(in) :: a
- integer(kind=c_short), intent(in) :: b
- integer(kind=c_int), intent(in) :: c
- integer(kind=c_long), intent(out) :: d
-
- interface
- function int_args_func(a,b,c,d)
- integer(kind=8) :: int_args_func
- integer(kind=1), intent(in) :: a
- integer(kind=2), intent(in) :: b
- integer(kind=4), intent(in) :: c
- integer(kind=8), intent(out) :: d
- end function int_args_func
- end interface
-
- wrapfunc_int_args_func = int_args_func(a,b,c,d)
-end function wrapfunc_int_args_func
-
-! module dummy
- ! use iso_c_binding
- ! use kind_type_params
- ! integer, parameter :: fortran_int_1 = c_signed_char
-
- ! contains
-
- ! subroutine int_args_subr_wrap(a,b,c,d) bind(c,name="int_args_subr")
- ! implicit none
- ! integer(kind=fortran_int_1), intent(in) :: a
- ! integer(kind=c_short), intent(in) :: b
- ! integer(kind=c_int), intent(in) :: c
- ! integer(kind=c_int64_t), intent(out) :: d
- ! ! integer(kind=c_long), intent(in) :: a
- ! ! integer(kind=c_long), intent(in) :: b
- ! ! integer(kind=c_long), intent(in) :: c
- ! ! integer(kind=c_long), intent(out) :: d
-
- ! ! integer(kind=1) :: convert_a
- ! ! integer(kind=2) :: convert_b
- ! ! integer(kind=4) :: convert_c
- ! ! integer(kind=8) :: convert_d
-
- ! interface
- ! subroutine int_args_subr(a,b,c,d)
- ! use kind_type_params
- ! integer(kind=1), intent(in) :: a
- ! integer(kind=2), intent(in) :: b
- ! integer(kind=4), intent(in) :: c
- ! integer(kind=sik10), intent(out) :: d
- ! end subroutine int_args_subr
- ! end interface
-
- ! print *, "before call in wrapper in fortran"
- ! print *, a,b,c,d
-
- ! ! convert_a = a
- ! ! convert_b = b
- ! ! convert_c = c
- ! ! convert_d = d
-
- ! print *, "before call in wrapper in fortran, converted vals."
- ! print *, convert_a, convert_b, convert_c, convert_d
-
- ! ! call int_args_subr(convert_a,convert_b,convert_c,convert_d)
- ! call int_args_subr(a,b,c,d)
-
- ! ! d = convert_d
-
- ! ! print *, "after call in wrapper in fortran, converted vals."
- ! ! print *, convert_a, convert_b, convert_c, convert_d
-
-! end subroutine int_args_subr_wrap
-! end module dummy
diff --git a/Tools/fwrap/tests/compile/old_decl.f95 b/Tools/fwrap/tests/compile/old_decl.f95
deleted file mode 100644
index 164fdc863..000000000
--- a/Tools/fwrap/tests/compile/old_decl.f95
+++ /dev/null
@@ -1,18 +0,0 @@
-subroutine bar(a,b,c,d,e,f,g)
- implicit none
- integer*4, intent(inout) :: a
- real*4, intent(inout) :: b,c
- real*8, intent(inout) :: d
- integer*8, intent(inout) :: e
- double precision, intent(inout) :: f
- character(kind=1,len=8), intent(inout) :: g
-
- a = 1
- b = 2
- c = 2
- d = 3
- e = 4
- f = 5
- g = 6
-
-end subroutine bar
diff --git a/Tools/fwrap/tests/compile/test_scope.f95 b/Tools/fwrap/tests/compile/test_scope.f95
deleted file mode 100644
index b587e0dad..000000000
--- a/Tools/fwrap/tests/compile/test_scope.f95
+++ /dev/null
@@ -1,52 +0,0 @@
- module mod1
- implicit none
- integer, parameter :: GP = 6
- ! module_provides = {GP}
- ! use_provides = {}
- end module mod1
-
- module mod2
- implicit none
- integer, parameter :: SP = 5
- ! module_provides = {SP}
- ! use_provides = {}
- end module mod2
-
- module mod3
- use mod1
- implicit none
- integer, parameter :: DP = 0
- ! module_provides = {DP}
- ! use_provides = {GP}
- end module mod3
-
- module mod4
- use mod2
- implicit none
- ! module_provides = {}
- ! use_provides = {SP}
- end module mod4
-
- module mod5
- use mod3, lGP => GP
- use mod4
- implicit none
-
- integer, parameter :: FP = 1000
- integer(kind=kind(0)) :: dummy
- parameter (dummy = 20)
-
- ! module_provides = {FP, dummy}
- ! use_provides = {lGP, DP, SP}
- end module mod5
-
- program driver
- use mod5
- implicit none
-
- print *, DP
- print *, SP
- print *, lGP
- print *, FP
-
- end program driver
diff --git a/Tools/fwrap/tests/run/all_ints.f95 b/Tools/fwrap/tests/run/all_ints.f95
deleted file mode 100644
index d0df4c56b..000000000
--- a/Tools/fwrap/tests/run/all_ints.f95
+++ /dev/null
@@ -1,69 +0,0 @@
-
- subroutine int_default(i1,i2,i3)
- implicit none
- integer, intent(in) :: i1
- integer, intent(inout) :: i2
- integer, intent(out) :: i3
- i3 = i3 + i1 - i1
- i2 = i2 + i3 - i3
- end subroutine
- subroutine int_x_len(i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15)
- implicit none
- integer*1, intent(in) :: i4
- integer*1, intent(inout) :: i5
- integer*1, intent(out) :: i6
- integer*2, intent(in) :: i7
- integer*2, intent(inout) :: i8
- integer*2, intent(out) :: i9
- integer*4, intent(in) :: i10
- integer*4, intent(inout) :: i11
- integer*4, intent(out) :: i12
- integer*8, intent(in) :: i13
- integer*8, intent(inout) :: i14
- integer*8, intent(out) :: i15
- i6 = i4 + i5
- i9 = i7 + i8
- i12 = i10 + i11
- i15 = i13 + i14
- end subroutine
- subroutine int_kind_x(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12)
- implicit none
- integer(kind=1), intent(in) :: i1
- integer(kind=1), intent(inout) :: i2
- integer(kind=1), intent(out) :: i3
- integer(kind=2), intent(in) :: i4
- integer(kind=2), intent(inout) :: i5
- integer(kind=2), intent(out) :: i6
- integer(kind=4), intent(in) :: i7
- integer(kind=4), intent(inout) :: i8
- integer(kind=4), intent(out) :: i9
- integer(kind=8), intent(in) :: i10
- integer(kind=8), intent(inout) :: i11
- integer(kind=8), intent(out) :: i12
- i3 = i1 + i2
- i6 = i4 + i5
- i9 = i7 + i8
- i12 = i10 + i11
- end subroutine
- subroutine int_kind_call(i1,i2,i3)
- implicit none
- integer(kind=kind(0)), intent(in) :: i1
- integer(kind=kind(0)), intent(inout) :: i2
- integer(kind=kind(0)), intent(out) :: i3
- i3 = i1 + i2
- end subroutine
- subroutine int_sik_call(i1,i2,i3,i4,i5,i6,i7,i8,i9)
- implicit none
- integer(kind=selected_int_kind(1)), intent(in) :: i1
- integer(kind=selected_int_kind(1)), intent(inout) :: i2
- integer(kind=selected_int_kind(1)), intent(out) :: i3
- integer(kind=selected_int_kind(5)), intent(in) :: i4
- integer(kind=selected_int_kind(5)), intent(inout) :: i5
- integer(kind=selected_int_kind(5)), intent(out) :: i6
- integer(kind=selected_int_kind(10)), intent(in) :: i7
- integer(kind=selected_int_kind(10)), intent(inout) :: i8
- integer(kind=selected_int_kind(10)), intent(out) :: i9
- i3 = i1 + i2
- i6 = i4 + i5
- i9 = i7 + i8
- end subroutine
diff --git a/Tools/fwrap/tests/run/all_ints_fwrap_doctest.py b/Tools/fwrap/tests/run/all_ints_fwrap_doctest.py
deleted file mode 100644
index 21571ffef..000000000
--- a/Tools/fwrap/tests/run/all_ints_fwrap_doctest.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from all_ints_fwrap import *
-
-__doc__ = u'''
->>> int_default(1,2,3)
-(2, 3)
->>> int_x_len(1,2,3,4,5,6,7,8,9,10,11,12)
-(2, 3, 5, 9, 8, 15, 11, 21)
->>> int_kind_x(1,2,3,4,5,6,7,8,9,10,11,12)
-(2, 3, 5, 9, 8, 15, 11, 21)
->>> int_kind_call(1,2,3)
-(2, 3)
->>> int_sik_call(1,2,3,4,5,6,7,8,9)
-(2, 3, 5, 9, 8, 15)
-'''
diff --git a/Tools/fwrap/tests/run/all_logicals.f95 b/Tools/fwrap/tests/run/all_logicals.f95
deleted file mode 100644
index 4235db684..000000000
--- a/Tools/fwrap/tests/run/all_logicals.f95
+++ /dev/null
@@ -1,93 +0,0 @@
- subroutine log_default(i1,i2,i3)
- implicit none
- logical, intent(in) :: i1
- logical, intent(inout) :: i2
- logical, intent(out) :: i3
- i2 = .false. .and. i1
- i3 = .false.
- end subroutine
- subroutine log_x_len(i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15)
- implicit none
- logical*1, intent(in) :: i4
- logical*1, intent(inout) :: i5
- logical*1, intent(out) :: i6
- logical*2, intent(in) :: i7
- logical*2, intent(inout) :: i8
- logical*2, intent(out) :: i9
- logical*4, intent(in) :: i10
- logical*4, intent(inout) :: i11
- logical*4, intent(out) :: i12
- logical*8, intent(in) :: i13
- logical*8, intent(inout) :: i14
- logical*8, intent(out) :: i15
-
- i5= .false. .and. i4
- i6= .false. .and. i7
- i8= .false.
- i9= .false. .and. i10
- i11= .false.
- i12= .false.
- i14= .false. .and. i13
- i15= .false.
-
- end subroutine
- subroutine log_kind_x(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12)
- implicit none
- logical(kind=1), intent(in) :: i1
- logical(kind=1), intent(inout) :: i2
- logical(kind=1), intent(out) :: i3
- logical(kind=2), intent(in) :: i4
- logical(kind=2), intent(inout) :: i5
- logical(kind=2), intent(out) :: i6
- logical(kind=4), intent(in) :: i7
- logical(kind=4), intent(inout) :: i8
- logical(kind=4), intent(out) :: i9
- logical(kind=8), intent(in) :: i10
- logical(kind=8), intent(inout) :: i11
- logical(kind=8), intent(out) :: i12
-
- i2= .false. .and. i1
- i3= .false.
- i5= .false. .and. i4
- i6= .false.
- i8= .false. .and. i7
- i9= .false.
- i11= .false. .and. i10
- i12= .false.
-
- end subroutine
- subroutine log_kind_call(i1,i2,i3,i4,i5,i6)
- implicit none
- logical(kind=kind(.true.)), intent(in) :: i1
- logical(kind=kind(.true.)), intent(inout) :: i2
- logical(kind=kind(.true.)), intent(out) :: i3
- logical(kind=kind(0)), intent(in) :: i4
- logical(kind=kind(0)), intent(inout) :: i5
- logical(kind=kind(0)), intent(out) :: i6
-
- i2= .false. .and. i1
- i3= .false.
- i5= .false. .and. i4
- i6= .false.
-
- end subroutine
- subroutine log_sik_call(i1,i2,i3,i4,i5,i6,i7,i8,i9)
- implicit none
- logical(kind=selected_int_kind(1)), intent(in) :: i1
- logical(kind=selected_int_kind(1)), intent(inout) :: i2
- logical(kind=selected_int_kind(1)), intent(out) :: i3
- logical(kind=selected_int_kind(5)), intent(in) :: i4
- logical(kind=selected_int_kind(5)), intent(inout) :: i5
- logical(kind=selected_int_kind(5)), intent(out) :: i6
- logical(kind=selected_int_kind(10)), intent(in) :: i7
- logical(kind=selected_int_kind(10)), intent(inout) :: i8
- logical(kind=selected_int_kind(10)), intent(out) :: i9
-
- i2= .false. .and. i1
- i3= .false.
- i5= .false. .and. i4
- i6= .false.
- i8= .false. .and. i7
- i9= .false.
-
- end subroutine
diff --git a/Tools/fwrap/tests/run/all_logicals_fwrap_doctest.py b/Tools/fwrap/tests/run/all_logicals_fwrap_doctest.py
deleted file mode 100644
index ce768348d..000000000
--- a/Tools/fwrap/tests/run/all_logicals_fwrap_doctest.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from all_logicals_fwrap import *
-
-__doc__ = u'''
->>> log_default(1,0,3)
-(0, 0)
->>> log_x_len(1,2,3,4,5,6,7,8,9,10,11,12)
-(0, 0, 0, 0, 0, 0, 0, 0)
->>> log_kind_x(1,2,3,4,5,6,7,8,9,10,11,12)
-(0, 0, 0, 0, 0, 0, 0, 0)
->>> log_kind_call(1,2,3,4,5,6)
-(0, 0, 0, 0)
->>> log_sik_call(1,2,3,4,5,6,7,8,9)
-(0, 0, 0, 0, 0, 0)
-'''
diff --git a/Tools/fwrap/tests/run/all_reals.f95 b/Tools/fwrap/tests/run/all_reals.f95
deleted file mode 100644
index b96656986..000000000
--- a/Tools/fwrap/tests/run/all_reals.f95
+++ /dev/null
@@ -1,56 +0,0 @@
-
- subroutine real_default(r1,r2,r3)
- implicit none
- real, intent(in) :: r1
- real, intent(inout) :: r2
- real, intent(out) :: r3
- r3 = r1 + r2
- end subroutine
- subroutine real_x_len(r10,r11,r12,r13,r14,r15)
- implicit none
- real*4, intent(in) :: r10
- real*4, intent(inout) :: r11
- real*4, intent(out) :: r12
- real*8, intent(in) :: r13
- real*8, intent(inout) :: r14
- real*8, intent(out) :: r15
- r12 = r10 + r11
- r15 = r13 + r14
- end subroutine
- subroutine real_kind_x(r7,r8,r9,r10,r11,r12)
- implicit none
- real(kind=4), intent(in) :: r7
- real(kind=4), intent(inout) :: r8
- real(kind=4), intent(out) :: r9
- real(kind=8), intent(in) :: r10
- real(kind=8), intent(inout) :: r11
- real(kind=8), intent(out) :: r12
- r9 = r7 + r8
- r12 = r11 + r10
- end subroutine
- subroutine real_kind_call(r1,r2,r3,r4,r5,r6)
- implicit none
- real(kind=kind(0.0)), intent(in) :: r1
- real(kind=kind(0.0)), intent(inout) :: r2
- real(kind=kind(0.0)), intent(out) :: r3
- real(kind=kind(0.0D0)), intent(in) :: r4
- real(kind=kind(0.0D0)), intent(inout) :: r5
- real(kind=kind(0.0D0)), intent(out) :: r6
- r3 = r2 + r1
- r6 = r4 + r5
- end subroutine
- subroutine real_srk_call(r1,r2,r3,r4,r5,r6,r7,r8,r9)
- implicit none
- real(kind=selected_real_kind(1)), intent(in) :: r1
- real(kind=selected_real_kind(1)), intent(inout) :: r2
- real(kind=selected_real_kind(1)), intent(out) :: r3
- real(kind=selected_real_kind(7)), intent(in) :: r4
- real(kind=selected_real_kind(7)), intent(inout) :: r5
- real(kind=selected_real_kind(7)), intent(out) :: r6
- real(kind=selected_real_kind(14)), intent(in) :: r7
- real(kind=selected_real_kind(14)), intent(inout) :: r8
- real(kind=selected_real_kind(14)), intent(out) :: r9
- r3 = r1 + r2
- r6 = r4 + r5
- r9 = r7 + r8
- end subroutine
diff --git a/Tools/fwrap/tests/run/all_reals_fwrap_doctest.py b/Tools/fwrap/tests/run/all_reals_fwrap_doctest.py
deleted file mode 100644
index 0d492dc2b..000000000
--- a/Tools/fwrap/tests/run/all_reals_fwrap_doctest.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from all_reals_fwrap import *
-
-__doc__ = u'''
->>> real_default(1,2,3)
-(2.0, 3.0)
->>> real_x_len(10,11,12,13,14,15)
-(11.0, 21.0, 14.0, 27.0)
->>> real_kind_x(7,8,9,10,11,12)
-(8.0, 15.0, 11.0, 21.0)
->>> real_kind_call(1,2,3,4,5,6)
-(2.0, 3.0, 5.0, 9.0)
->>> real_srk_call(1,2,3,4,5,6,7,8,9)
-(2.0, 3.0, 5.0, 9.0, 8.0, 15.0)
-'''
diff --git a/Tools/fwrap/tests/run/default_types.f95 b/Tools/fwrap/tests/run/default_types.f95
deleted file mode 100644
index 11bb3d89b..000000000
--- a/Tools/fwrap/tests/run/default_types.f95
+++ /dev/null
@@ -1,12 +0,0 @@
-subroutine bar(a,b,d)
-implicit none
-integer :: a
-real :: b
-! complex :: c
-double precision :: d
-! logical :: e
-! character :: f
-a = 1
-b = 2.0
-d = 3.0
-end subroutine bar
diff --git a/Tools/fwrap/tests/run/default_types_fwrap_doctest.py b/Tools/fwrap/tests/run/default_types_fwrap_doctest.py
deleted file mode 100644
index 1fc73d380..000000000
--- a/Tools/fwrap/tests/run/default_types_fwrap_doctest.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from default_types_fwrap import *
-
-__doc__ = u'''
-'''
diff --git a/Tools/fwrap/tests/run/int_args.f95 b/Tools/fwrap/tests/run/int_args.f95
deleted file mode 100644
index 77b58298d..000000000
--- a/Tools/fwrap/tests/run/int_args.f95
+++ /dev/null
@@ -1,151 +0,0 @@
-
-function int_args_func(a,b,c,d)
- integer(kind=8) :: int_args_func
- integer(kind=1), intent(in) :: a
- integer(kind=2), intent(in) :: b
- integer(kind=4), intent(in) :: c
- integer(kind=8), intent(out) :: d
-
- d = a + b + c
- int_args_func = 10
-
-end function int_args_func
-
-subroutine int_args_subr(a,b,c,d)
- integer(kind=1), intent(in) :: a
- integer(kind=2), intent(in) :: b
- integer(kind=4), intent(in) :: c
- integer(kind=8), intent(out) :: d
-
- d = a + b + c
-
-end subroutine int_args_subr
-
-! module dummy
- ! use iso_c_binding
- ! use kind_type_params
- ! integer, parameter :: fortran_int_1 = c_signed_char
-
- ! contains
-
- ! subroutine int_args_subr_wrap(a,b,c,d) bind(c,name="int_args_subr")
- ! implicit none
- ! integer(kind=fortran_int_1), intent(in) :: a
- ! integer(kind=c_short), intent(in) :: b
- ! integer(kind=c_int), intent(in) :: c
- ! integer(kind=c_int64_t), intent(out) :: d
- ! ! integer(kind=c_long), intent(in) :: a
- ! ! integer(kind=c_long), intent(in) :: b
- ! ! integer(kind=c_long), intent(in) :: c
- ! ! integer(kind=c_long), intent(out) :: d
-
- ! ! integer(kind=1) :: convert_a
- ! ! integer(kind=2) :: convert_b
- ! ! integer(kind=4) :: convert_c
- ! ! integer(kind=8) :: convert_d
-
- ! interface
- ! subroutine int_args_subr(a,b,c,d)
- ! use kind_type_params
- ! integer(kind=1), intent(in) :: a
- ! integer(kind=2), intent(in) :: b
- ! integer(kind=4), intent(in) :: c
- ! integer(kind=sik10), intent(out) :: d
- ! end subroutine int_args_subr
- ! end interface
-
- ! print *, "before call in wrapper in fortran"
- ! print *, a,b,c,d
-
- ! ! convert_a = a
- ! ! convert_b = b
- ! ! convert_c = c
- ! ! convert_d = d
-
- ! print *, "before call in wrapper in fortran, converted vals."
- ! print *, convert_a, convert_b, convert_c, convert_d
-
- ! ! call int_args_subr(convert_a,convert_b,convert_c,convert_d)
- ! call int_args_subr(a,b,c,d)
-
- ! ! d = convert_d
-
- ! ! print *, "after call in wrapper in fortran, converted vals."
- ! ! print *, convert_a, convert_b, convert_c, convert_d
-
-! end subroutine int_args_subr_wrap
-! end module dummy
-
-! program blargh
-! use dummy
- ! integer(kind=1) :: a
- ! integer(kind=2) :: b
- ! integer(kind=4) :: c
- ! integer(kind=8) :: d
- ! ! integer(kind=8) :: a
- ! ! integer(kind=8) :: b
- ! ! integer(kind=8) :: c
- ! ! integer(kind=8) :: d
- ! a = 1; b = 2; c = 3; d = 4
-! call int_args_subr_wrap(a,b,c,d)
- ! print *, a,b,c,d
-! end program blargh
-
- ! ====================
- ! integer types
- ! --------------------
-
- ! c_int 4
- ! c_short 2
- ! c_long 8
- ! c_long_long 8
- ! c_signed_char 1
- ! c_size_t 8
- ! c_int8_t 1
- ! c_int16_t 2
- ! c_int32_t 4
- ! c_int64_t 8
- ! c_int_least8_t 1
- ! c_int_least16_t 2
- ! c_int_least32_t 4
- ! c_int_least64_t 8
- ! c_int_fast8_t -2
- ! c_int_fast16_t -2
- ! c_int_fast32_t -2
- ! c_int_fast64_t -2
- ! c_intmax_t 8
- ! c_intptr_t 8
-
- ! ====================
- ! real types
- ! --------------------
-
- ! c_float 4
- ! c_double 8
- ! c_long_double 10
-
- ! ====================
- ! complex types
- ! --------------------
-
- ! c_float_complex 4
- ! c_double_complex 8
- ! c_long_double_complex 10
-
- ! ====================
- ! logical types
- ! --------------------
-
- ! c_bool 1
-
- ! ====================
- ! character types
- ! --------------------
-
- ! c_char 1
-
-! module kind_type_params
-! implicit none
-! integer, parameter :: sik10 = selected_int_kind(10)
-
-! end module kind_type_params
diff --git a/Tools/fwrap/tests/run/int_args_fwrap_doctest.py b/Tools/fwrap/tests/run/int_args_fwrap_doctest.py
deleted file mode 100644
index 8ab0a57d3..000000000
--- a/Tools/fwrap/tests/run/int_args_fwrap_doctest.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from int_args_fwrap import *
-
-__doc__ = u'''
->>> int_args_func(1,2,3,4)
-(10, 6)
->>> int_args_subr(1,2,3,4)
-(6,)
-'''
diff --git a/Tools/fwrap/tests/run/old_decl.f95 b/Tools/fwrap/tests/run/old_decl.f95
deleted file mode 100644
index 9ca4e8c94..000000000
--- a/Tools/fwrap/tests/run/old_decl.f95
+++ /dev/null
@@ -1,18 +0,0 @@
-
-subroutine bar(a,b,c,d,e,f,g)
- implicit none
- integer*4, intent(inout) :: a
- real*4, intent(inout) :: b,c
- real*8, intent(inout) :: d
- integer*8, intent(inout) :: e
- double precision, intent(inout) :: f
- character(kind=1,len=8), intent(inout) :: g
-
- a = 1
- b = 2
- c = 2
- d = 3
- e = 4
- f = 5
-
-end subroutine bar
diff --git a/Tools/fwrap/tests/run/old_decl_fwrap_doctest.py b/Tools/fwrap/tests/run/old_decl_fwrap_doctest.py
deleted file mode 100644
index 94a6f968d..000000000
--- a/Tools/fwrap/tests/run/old_decl_fwrap_doctest.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from old_decl_fwrap import *
-
-__doc__ = u'''
->>> bar(1,2,3,4,5,6,7)
-(1, 2.0, 2.0, 3.0, 4, 5.0, 7)
-'''
diff --git a/Tools/fwrap/tests/run/simple_array.f95 b/Tools/fwrap/tests/run/simple_array.f95
deleted file mode 100644
index 7e9a0e1c9..000000000
--- a/Tools/fwrap/tests/run/simple_array.f95
+++ /dev/null
@@ -1,102 +0,0 @@
- ! subroutine pass_array(arr0, arr1, arr2, arr3)
- ! implicit none
- ! integer, dimension(0:10), intent(inout) :: arr0
- ! integer, dimension(1:10+1-1), intent(inout) :: &
- ! arr1(-1+1:10-3, -100+100:-100+110)
- ! integer, dimension(:,:), intent(inout) :: arr2(-2:,-1:,0:)
- ! integer, dimension(size(arr0,1)) :: arr3
-
- ! arr0 = 5
- ! arr1 = 10
-
- ! end subroutine pass_array
-
- subroutine pass_array(arr0, arr1, arr2)
- implicit none
- integer, dimension(:,:), intent(in) :: arr0
- integer, dimension(:,:), intent(inout) :: arr1
- integer, dimension(:,:), intent(out) :: arr2
-
- print *, arr0
- print *, arr1
-
- arr2 = arr1 + arr0
-
- end subroutine pass_array
-
- subroutine pass_5D(arr0, arr1, arr2)
- implicit none
- integer :: i,j,k,l,m
- integer, dimension(:,:,:,:,:), intent(in) :: arr0
- integer, dimension(:,:,:,:,:), intent(inout) :: arr1
- integer, dimension(:,:,:,:,:), intent(out) :: arr2
-
- print *, shape(arr0)
- print *, shape(arr1)
- print *, shape(arr2)
- ! print *, arr0
- ! print *, arr1
-
- do i = 1, size(arr0,1)
- do j = 1, size(arr0,2)
- do k = 1, size(arr0,3)
- do l = 1, size(arr0,4)
- do m = 1, size(arr0,5)
- print *, arr0(m,l,k,j,i)
- enddo
- enddo
- enddo
- enddo
- enddo
-
- arr2 = arr1 + arr0
-
- end subroutine pass_5D
-
- subroutine pass_3D(arr0, arr1, arr2)
- implicit none
- integer :: i,j,k,l,m
- integer, dimension(:,:,:), intent(in) :: arr0
- integer, dimension(:,:,:), intent(inout) :: arr1
- integer, dimension(:,:,:), intent(out) :: arr2
-
- print *, shape(arr0)
- print *, shape(arr1)
- print *, shape(arr2)
- ! print *, arr0
- ! print *, arr1
-
- do k = 1, size(arr0,1)
- do l = 1, size(arr0,2)
- do m = 1, size(arr0,3)
- print *, arr0(m,l,k)
- enddo
- enddo
- enddo
-
- arr2 = arr1 + arr0
-
- end subroutine pass_3D
-
- subroutine pass_2D(arr0, arr1, arr2)
- implicit none
- integer :: i,j,k,l,m
- integer, dimension(:,:,:), intent(in) :: arr0
- integer, dimension(:,:,:), intent(inout) :: arr1
- integer, dimension(:,:,:), intent(out) :: arr2
-
- print *, shape(arr0)
- print *, shape(arr1)
- print *, shape(arr2)
- ! print *, arr0
- ! print *, arr1
-
- do l = 1, size(arr0,1)
- do m = 1, size(arr0,2)
- print *, arr0(m,l)
- enddo
- enddo
-
- arr2 = arr1 + arr0
-
- end subroutine pass_2D
diff --git a/Tools/fwrap/utils.py b/Tools/fwrap/utils.py
deleted file mode 100644
index 92ea8d5ba..000000000
--- a/Tools/fwrap/utils.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import sys
-import re
-
-LEVEL = 0
-
-def warning(message, position=None, level=0, stream=sys.stderr):
- if level < LEVEL:
- return
- # for now, echo on stream
- stream.write("warning: %s\n" % message)
- stream.flush()
-
-mangle_prefix = 'fwrap_'
-valid_name = re.compile(r'[a-z]\w+$',re.I).match
-
-CY_IMPORT_ALIAS = "__wf"