Captures the parse tree and name of a kernel subroutine.
:param ktype_ast: the fparser1 parse tree for the Kernel meta-data.
:type ktype_ast: :py:class:`fparser.one.block_statements.Type`
:param str ktype_name: name of the Fortran type holding the Kernel \
meta-data.
:param modast: the fparser1 parse tree for the module containing the \
Kernel routine.
:type modast: :py:class:`fparser.one.block_statements.BeginSource`
Definition at line 507 of file kernel.py.
def psyclone.parse.kernel.KernelProcedure.get_procedure |
( |
|
ast, |
|
|
|
name, |
|
|
|
modast |
|
) |
| |
|
static |
Get the name of the subroutine associated with the Kernel. This is
a type-bound procedure in the meta-data which may take one of three
forms:
PROCEDURE, nopass :: code => <proc_name>
or
PROCEDURE, nopass :: <proc_name>
or if there is no type-bound procedure, an interface may be used:
INTERFACE <proc_name>
:param ast: the fparser1 parse tree for the Kernel meta-data.
:type ast: :py:class:`fparser.one.block_statements.Type`
:param str name: the name of the Fortran type holding the Kernel \
meta-data.
:param modast: the fparser1 parse tree for the module containing the \
Kernel routine.
:type modast: :py:class:`fparser.one.block_statements.BeginSource`
:returns: 2-tuple of the fparser1 parse tree of the Subroutine \
statement and the name of that Subroutine.
:rtype: (:py:class:`fparser1.block_statements.Subroutine`, str)
:raises ParseError: if the supplied Kernel meta-data does not \
have a type-bound procedure or interface.
:raises ParseError: if no implementation is found for the \
type-bound procedure or interface module \
procedures.
:raises ParseError: if the type-bound procedure specifies a binding \
name but the generic name is not "code".
:raises InternalError: if we get an empty string for the name of the \
type-bound procedure.
Definition at line 526 of file kernel.py.
526 def get_procedure(ast, name, modast):
528 Get the name of the subroutine associated with the Kernel. This is
529 a type-bound procedure in the meta-data which may take one of three
531 PROCEDURE, nopass :: code => <proc_name>
533 PROCEDURE, nopass :: <proc_name>
534 or if there is no type-bound procedure, an interface may be used:
535 INTERFACE <proc_name>
537 :param ast: the fparser1 parse tree for the Kernel meta-data.
538 :type ast: :py:class:`fparser.one.block_statements.Type`
539 :param str name: the name of the Fortran type holding the Kernel \
541 :param modast: the fparser1 parse tree for the module containing the \
543 :type modast: :py:class:`fparser.one.block_statements.BeginSource`
545 :returns: 2-tuple of the fparser1 parse tree of the Subroutine \
546 statement and the name of that Subroutine.
547 :rtype: (:py:class:`fparser1.block_statements.Subroutine`, str)
549 :raises ParseError: if the supplied Kernel meta-data does not \
550 have a type-bound procedure or interface.
551 :raises ParseError: if no implementation is found for the \
552 type-bound procedure or interface module \
554 :raises ParseError: if the type-bound procedure specifies a binding \
555 name but the generic name is not "code".
556 :raises InternalError: if we get an empty string for the name of the \
557 type-bound procedure.
561 for statement
in ast.content:
562 if isinstance(statement, fparser1.statements.SpecificBinding):
567 if statement.name.lower() !=
"code":
569 f
"Kernel type {name} binds to a specific procedure"
570 f
" but does not use 'code' as the generic name.")
571 bname = statement.bname.lower()
573 bname = statement.name.lower()
578 bname, subnames = get_kernel_interface(name, modast)
582 f
"Kernel type {name} does not bind a specific procedure "
583 f
"or provide an explicit interface")
586 f
"Empty Kernel name returned for Kernel type {name}.")
592 for subname
in subnames:
593 for statement, _
in fpapi.walk(modast):
594 if isinstance(statement,
595 fparser1.block_statements.Subroutine) \
596 and statement.name.lower() \
598 procedure_count = procedure_count + 1
599 if procedure_count == 1:
607 f
"kernel.py:KernelProcedure:get_procedure: Kernel "
608 f
"subroutine '{subname}' not found.")