How to use the f90wrap.fortran.Procedure function in f90wrap

To help you get started, we’ve selected a few f90wrap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
mod_name=None, type_name=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if arguments is None: arguments = []
        self.arguments = arguments
        if uses is None: uses = []
        self.uses = uses
        if attributes is None: attributes = []
        self.attributes = attributes
        self.mod_name = mod_name
        self.type_name = type_name

class Subroutine(Procedure):
    __doc__ = _rep_des(Procedure.__doc__, "Represents a Fortran Subroutine.")
    pass

class Function(Procedure):
    """
    ret_val : :class:`fortran.Argument`
        The argument which is the returned value

    ret_val_doc : `str`
        The documentation of the returned value
    """
    __doc__ = _rep_des(Procedure.__doc__, "Represents a Fortran Function.") + __doc__
    _fields = ['arguments', 'ret_val']

    def __init__(self, name='', filename='', doc=None, lineno=0,
                 arguments=None, uses=None, attributes=None,
                 ret_val=None, ret_val_doc=None, mod_name=None, type_name=None):
        Procedure.__init__(self, name, filename, doc,
                           lineno, arguments, uses, attributes,
                           mod_name, type_name)
github jameskermode / f90wrap / f90wrap / pywrapgen.py View on Github external
def format_call_signature(node):
    if isinstance(node, ft.Procedure):
        sig = ''
        if isinstance(node, ft.Function):
            sig += ', '.join(ret_val.py_name for ret_val in node.ret_val)
            sig += ' = '
        if 'constructor' in node.attributes:
            sig += node.type_name.title()
        elif 'destructor' in node.attributes:
            return 'Destructor for class %s' % node.type_name.title()
        else:
            if hasattr(node, 'method_name'):
                sig += node.method_name
            else:
                sig += node.name
        sig += '('
        had_optional = False
        for i, arg in enumerate(node.arguments):
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
def __init__(self, name='', filename='', doc=None, lineno=0,
                 arguments=None, uses=None, attributes=None,
                 mod_name=None, type_name=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if arguments is None: arguments = []
        self.arguments = arguments
        if uses is None: uses = []
        self.uses = uses
        if attributes is None: attributes = []
        self.attributes = attributes
        self.mod_name = mod_name
        self.type_name = type_name

class Subroutine(Procedure):
    __doc__ = _rep_des(Procedure.__doc__, "Represents a Fortran Subroutine.")
    pass

class Function(Procedure):
    """
    ret_val : :class:`fortran.Argument`
        The argument which is the returned value

    ret_val_doc : `str`
        The documentation of the returned value
    """
    __doc__ = _rep_des(Procedure.__doc__, "Represents a Fortran Function.") + __doc__
    _fields = ['arguments', 'ret_val']

    def __init__(self, name='', filename='', doc=None, lineno=0,
                 arguments=None, uses=None, attributes=None,
                 ret_val=None, ret_val_doc=None, mod_name=None, type_name=None):
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
_fields = ['arguments']

    def __init__(self, name='', filename='', doc=None, lineno=0,
                 arguments=None, uses=None, attributes=None,
                 mod_name=None, type_name=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if arguments is None: arguments = []
        self.arguments = arguments
        if uses is None: uses = []
        self.uses = uses
        if attributes is None: attributes = []
        self.attributes = attributes
        self.mod_name = mod_name
        self.type_name = type_name

class Subroutine(Procedure):
    __doc__ = _rep_des(Procedure.__doc__, "Represents a Fortran Subroutine.")
    pass

class Function(Procedure):
    """
    ret_val : :class:`fortran.Argument`
        The argument which is the returned value

    ret_val_doc : `str`
        The documentation of the returned value
    """
    __doc__ = _rep_des(Procedure.__doc__, "Represents a Fortran Function.") + __doc__
    _fields = ['arguments', 'ret_val']

    def __init__(self, name='', filename='', doc=None, lineno=0,
                 arguments=None, uses=None, attributes=None,
github jameskermode / f90wrap / f90wrap / pywrapgen.py View on Github external
def _format_line_no(lineno):
        """
        Format Fortran source code line numbers

        FIXME could link to source repository (e.g. github)
        """
        if isinstance(lineno, slice):
            return 'lines %d-%d' % (lineno.start, lineno.stop - 1)
        else:
            return 'line %d' % lineno

    doc = [format_call_signature(node), '']
    doc.append('')
    doc.append('Defined at %s %s' % (node.filename, _format_line_no(node.lineno)))

    if isinstance(node, ft.Procedure):
        # For procedures, write parameters and return values in numpydoc format
        doc.append('')
        # Input parameters
        for i, arg in enumerate(node.arguments):
            pytype = ft.f2py_type(arg.type, arg.attributes)
            if i == 0:
                doc.append("Parameters")
                doc.append("----------")
            doc.append("%s : %s" % (arg.name, pytype))
            if arg.doc:
                for d in arg.doc:
                    doc.append("\t%s" % d)
                doc.append("")

        if isinstance(node, ft.Function):
            for i, arg in enumerate(node.ret_val):
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
def walk_procedures(tree, include_ret_val=True):
    """
    Walk over all nodes in tree and yield tuples
    (module, procedure, arguments).

    If `include_ret_val` is true then Function return values are
    inserted after last non-optional argument.
    """
    for node in walk(tree):
        if not isinstance(node, Procedure):
            continue

        arguments = node.arguments[:]
        if include_ret_val and isinstance(node, Function):
            arguments.append(node.ret_val)

        mod = find_procedure_module(tree, node)

        yield (mod, node, arguments)
github jameskermode / f90wrap / f90wrap / transform.py View on Github external
def add_missing_destructors(tree):
    for node in ft.walk(tree):
        if not isinstance(node, ft.Type):
            continue
        for child in ft.iter_child_nodes(node):
            if isinstance(child, ft.Procedure):
                if 'destructor' in child.attributes:
                    logging.info('found destructor %s' % child.name)
                    break
        else:

            logging.info('adding missing destructor for %s' % node.name)
            new_node = ft.Subroutine('%s_finalise' % node.name,
                                     node.filename,
                                     ['Automatically generated destructor for %s' % node.name],
                                     node.lineno,
                                     [ft.Argument(name='this',  # self.prefix + 'this' would probably be safer
                                                  filename=node.filename,
                                                  doc=['Object to be destructed'],
                                                  lineno=node.lineno,
                                                  attributes=['intent(inout)'],
                                                  type='type(%s)' % node.name)],
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
def __init__(self, name='', filename='', doc=None, lineno=0,
                 arguments=None, uses=None, attributes=None,
                 ret_val=None, ret_val_doc=None, mod_name=None, type_name=None):
        Procedure.__init__(self, name, filename, doc,
                           lineno, arguments, uses, attributes,
                           mod_name, type_name)
        if ret_val is None:
            ret_val = Argument()
        self.ret_val = ret_val
        self.ret_val_doc = ret_val_doc