How to use the f90wrap.fortran.Fortran 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
__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)
        if ret_val is None:
            ret_val = Argument()
        self.ret_val = ret_val
        self.ret_val_doc = ret_val_doc


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

class Declaration(Fortran):
    """
    type : `str` , default ``""``
        The type of the declaration

    attributes : list of `str` , default ``None``
        A list of attributes defined in the declaration (eg. intent(in), allocatable)

    value : `str`
        A value given to the variable upon definition
        (eg. value=8 in ``"integer :: x = 8"``
    """
    __doc__ = _rep_des(Fortran.__doc__, "Base class representing a declaration statement") + __doc__
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
if type(other) != type(self):
            return False
        for a in attrs:
            try:
                ret = ret and getattr(self, a) == getattr(other, a)
            except:
                return False
            if not ret:
                return False
        return True

    def __neq__(self, other):
        return not self.__eq__(other)


class Root(Fortran):
    """
    programs : `list` of `fortran.Program`, default ``None``
        A list of Programs within the parse tree.

    modules : `list` of `fortran.Module`, default ``None``
        A list of modules within the parse tree

    procedures : `list` of `fortran.Procedure`, default ``None``
        A list of top-level procedures within the parse tree.
    """
    __doc__ = _rep_des(Fortran.__doc__, "The Root node of a Fortan parse tree") + __doc__
    _fields = ['programs', 'modules', 'procedures']

    def __init__(self, name='', filename='', doc=None, lineno=0,
                 programs=None, modules=None, procedures=None):
        Fortran.__init__(self, name, filename, doc, lineno)
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
Fortran.__init__(self, name, filename, doc, lineno)
        if attributes is None: attributes = []
        self.attributes = attributes
        self.type = type
        self.value = value


class Element(Declaration):
    __doc__ = _rep_des(Declaration.__doc__, "Represents a Module or Derived-Type Element.")
    pass

class Argument(Declaration):
    __doc__ = _rep_des(Declaration.__doc__, "Represents a Procedure Argument.")
    pass

class Type(Fortran):
    """
    elements : list of :class:`fortran.Element`
        Variables within the type

    procedures : list of :class:`fortran.Procedure`
        Procedures defined with the type.
    """
    __doc__ = _rep_des(Fortran.__doc__, "Represents a Fortran Derived-type.") + __doc__
    _fields = ['elements', 'procedures', 'interfaces']

    def __init__(self, name='', filename='', doc=None,
                 lineno=0, elements=None, procedures=None, interfaces=None,
                 mod_name=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if elements is None: elements = []
        self.elements = elements
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
def __init__(self, name='', filename='', doc=None,
                 lineno=0, elements=None, procedures=None, interfaces=None,
                 mod_name=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if elements is None: elements = []
        self.elements = elements
        if procedures is None: procedures = []
        self.procedures = procedures
        if interfaces is None: interfaces = []
        self.interfaces = interfaces
        self.mod_name = mod_name
        self.super_types_dimensions = set()


class Interface(Fortran):
    """
    procedures : list of :class:`fortran.Procedure`
        The procedures listed in the interface.

    mod_name : `str` , default ``None``
        The name of the module in which the interface is found, if any.

    type_name : `str` , default ``None``
        The name of the type in which the interface is defined, if any.
    """
    __doc__ = _rep_des(Fortran.__doc__, "Represents a Fortran Interface.") + __doc__
    _fields = ['procedures']

    def __init__(self, name='', filename='', doc=None,
                 lineno=0, procedures=None, mod_name=None, type_name=None):
        Fortran.__init__(self, name, filename, doc, lineno)
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
self.public_symbols = public_symbols
        if private_symbols is None:
            private_symbols = []
        self.private_symbols = private_symbols

    # Required for the Module object to be hashable so one can create sets of Modules
    # So this function should return a unique imprint of the object
    # I guess the filename + the module name should be unique enough ?
    # Also, hash requires an integer, so we convert the string to integers with the
    # same number of digits to ensure one-to-one conversion.
    # This is maybe unnecessarily long ?
    def __hash__(self):
        return int(''.join(str(ord(x)).zfill(3) for x in self.filename + self.name))


class Procedure(Fortran):
    """
    arguments : list of :class:`fortran.Argument`
        A list of arguments to the procedure

    uses : list of `str` or `tuple` , default ``None``
        A list of modules that this procedure uses. If the entry is a tuple, it
        should be in the form (uses,only,[only,..]), where the `only` entries
        are subroutines/elements in the used module.

    attributes : list of `str`, default ``None``
        Attributes of the procedure

    mod_name : `str` , default ``None``
        The name of the module in which the procedure is found, if any.

    type_name : `str` , default ``None``
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
def iter_child_nodes(node):
    """
    Yield all direct child nodes of *node*, that is, all fields that are nodes
    and all items of fields that are lists of nodes.
    """
    for name, field in iter_fields(node):
        if isinstance(field, Fortran):
            yield field
        elif isinstance(field, list):
            for item in field:
                if isinstance(item, Fortran):
                    yield item
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
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


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

class Declaration(Fortran):
    """
    type : `str` , default ``""``
        The type of the declaration

    attributes : list of `str` , default ``None``
        A list of attributes defined in the declaration (eg. intent(in), allocatable)

    value : `str`
        A value given to the variable upon definition
        (eg. value=8 in ``"integer :: x = 8"``
    """
    __doc__ = _rep_des(Fortran.__doc__, "Base class representing a declaration statement") + __doc__
    def __init__(self, name='', filename='', doc=None, lineno=0,
                 attributes=None, type='', value=''):
        Fortran.__init__(self, name, filename, doc, lineno)
        if attributes is None: attributes = []
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
def __init__(self, name='', filename='', doc=None, lineno=0,
                 programs=None, modules=None, procedures=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if programs is None:
            programs = []
        self.programs = programs
        if modules is None:
            modules = []
        self.modules = modules
        if procedures is None:
            procedures = []
        self.procedures = procedures


class Program(Fortran):
    """
    procedures : list of :class:`fortran.Procedure` , default ``None``
        A list of procedures within the program's scope.
    """
    __doc__ = _rep_des(Fortran.__doc__, "Class to represent a Fortran main program.") + __doc__
    _fields = ['procedures']

    def __init__(self, name='', filename='', doc=None, lineno=0,
                 procedures=None, uses=None):
        Fortran.__init__(self, name, filename, doc, lineno)
        if procedures is None:
            procedures = []
        self.procedures = procedures
        if uses is None:
            uses = []
        self.uses = uses
github jameskermode / f90wrap / f90wrap / fortran.py View on Github external
"""
    __doc__ = _rep_des(Fortran.__doc__, "Class to represent a Fortran main program.") + __doc__
    _fields = ['procedures']

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


class Module(Fortran):
    """
    types : list of :class:`fortran.Type` , default ``None``
        Derived-types defined in the module

    elements : list of :class:`fortran.Element` , default ``None``
        Module-level variables in the module

    procedures : list of :class:`fortran.Procedure` , default ``None``
        A list of procedures defined in the module

    interfaces : list of :class:`fortran.Interface` , default ``None``
        A list of interfaces defined in the module

    uses : list of `str` or `tuple` , default ``None``
        A list of modules that this module uses. If the entry is a tuple, it
        should be in the form (uses,only,[only,..]), where the `only` entries