diff --git a/examples/arrays/Makefile b/examples/arrays/Makefile index 6f23c7d..f44cdd2 100755 --- a/examples/arrays/Makefile +++ b/examples/arrays/Makefile @@ -77,7 +77,7 @@ LIBSRC_FPP_FILES = $(addsuffix .fpp,${LIBSRC_SOURCES}) #======================================================================= # names (without suffix), f90 sources -LIBSRC_WRAP_SOURCES = library +LIBSRC_WRAP_SOURCES = library parameters # file names LIBSRC_WRAP_FILES = $(addsuffix .f90,${LIBSRC_WRAP_SOURCES}) diff --git a/examples/arrays/parameters.f90 b/examples/arrays/parameters.f90 index 3546cd9..447421a 100644 --- a/examples/arrays/parameters.f90 +++ b/examples/arrays/parameters.f90 @@ -2,12 +2,15 @@ module parameters implicit none private +!public :: idp, isp, do_array_stuff public :: idp, isp INTEGER, PARAMETER :: idp=kind(1d0) INTEGER, PARAMETER :: isp=kind(1e0) contains + subroutine do_array_stuff() + end subroutine do_array_stuff end module parameters diff --git a/f90wrap/f90wrapgen.py b/f90wrap/f90wrapgen.py index 9d9dd94..a179cc3 100644 --- a/f90wrap/f90wrapgen.py +++ b/f90wrap/f90wrapgen.py @@ -395,10 +395,11 @@ def visit_Procedure(self, node): call_name = node.call_name log.info( 'F90WrapperGenerator visiting routine %s call_name %s mod_name %r' % (node.name, call_name, node.mod_name)) - self.write("subroutine %(sub_name)s%(arg_names)s" % - {'sub_name': self.prefix + node.name, - 'arg_names': '(' + ', '.join([arg.name for arg in node.arguments]) + ')' - if node.arguments else ''}) + sub_name = self.prefix + node.name + arg_names = '(' + ', '.join([arg.name for arg in node.arguments]) + ')' if node.arguments else '' + if node.mod_name is not None: + sub_name = self.prefix + node.mod_name + '__' + node.name + self.write("subroutine %s%s" % (sub_name, arg_names)) self.indent() self.write_uses_lines(node) self.write("implicit none") @@ -420,7 +421,7 @@ def visit_Procedure(self, node): self.write_transfer_out_lines(node) self.write_finalise_lines(node) self.dedent() - self.write("end subroutine %(sub_name)s" % {'sub_name': self.prefix + node.name}) + self.write("end subroutine %s" % (sub_name)) self.write() return self.generic_visit(node) diff --git a/f90wrap/pywrapgen.py b/f90wrap/pywrapgen.py index 75d0c79..59a5caf 100644 --- a/f90wrap/pywrapgen.py +++ b/f90wrap/pywrapgen.py @@ -328,6 +328,9 @@ def write_constructor(self, node): for arg in args]), f90_arg_names=', '.join(['%s=%s' % (arg.name, arg.py_value) for arg in node.arguments])) + if node.mod_name is not None: + dct['func_name'] = node.mod_name + '__' + node.name + self.write("def __init__(self, %(py_arg_names)s):" % dct) self.indent() self.write(format_doc_string(node)) @@ -361,6 +364,9 @@ def write_classmethod(self, node): ('None if %(arg_py_name)s is None else %(' 'arg_py_name)s._handle') % {'arg_py_name': arg.py_name}) + if node.mod_name is not None: + dct['func_name'] = node.mod_name + '__' + node.name + call_line = '%(call)s%(mod_name)s.%(prefix)s%(func_name)s(%(f90_arg_names)s)' % dct self.write('@classmethod') @@ -386,6 +392,8 @@ def write_destructor(self, node): 'optional' in arg.attributes and '=None' or '') for arg in node.arguments]), f90_arg_names=', '.join(['%s=%s' % (arg.name, arg.py_value) for arg in node.arguments])) + if node.mod_name is not None: + dct['func_name'] = node.mod_name + '__' + node.name self.write("def __del__(%(py_arg_names)s):" % dct) self.indent() self.write(format_doc_string(node)) @@ -414,6 +422,8 @@ def visit_Procedure(self, node): py_arg_names=', '.join([arg.py_name + py_arg_value(arg) for arg in node.arguments]), f90_arg_names=', '.join(['%s=%s' % (arg.name, arg.py_value) for arg in node.arguments]), call='') + if node.mod_name is not None: + dct['func_name'] = node.mod_name + '__' + node.name if isinstance(node, ft.Function): dct['result'] = ', '.join([ret_val.name for ret_val in node.ret_val])