37 '''Module containing the LFRicKernelMetadata
38 kernel-layer-specific class that captures the LFRic kernel metadata.
43 from fparser.two
import Fortran2003
44 from fparser.two.utils
import walk, get_child
48 ColumnwiseOperatorArgMetadata
51 FieldVectorArgMetadata
55 InterGridVectorArgMetadata
62 EvaluatorTargetsMetadata
70 MetaRefElementMetadata
85 '''Contains LFRic kernel metadata. This class supports kernel
86 metadata creation, modification, loading from a fortran string,
87 writing to a fortran string, raising from existing language-level
88 PSyIR and lowering to language-level PSyIR.
90 :param operates_on: the name of the quantity that this kernel is \
91 intended to iterate over.
92 :type operates_on: Optional[str]
93 :param shapes: if a kernel requires basis or differential-basis \
94 functions then the metadata must also specify the set of points on \
95 which these functions are required. This information is provided \
96 by the gh_shape component of the metadata.
97 :type shapes: Optional[List[str]]
98 :param evaluator_targets: the function spaces on which an \
99 evaluator is required.
100 :type evaluator_targets: Optional[List[str]]
101 :param meta_args: a list of 'meta_arg' objects which capture the \
102 metadata values of the kernel arguments.
103 :type meta_args: Optional[List[:py:class:`psyclone.domain.lfric.kernel.\
105 :param meta_funcs: a list of 'meta_func' objects which capture whether \
106 quadrature or evaluator data is required for a given function space.
107 :type meta_funcs: Optional[List[:py:class:`psyclone.domain.lfric.kernel.\
108 MetaFuncsArgMetadata`]]
109 :param meta_ref_element: a kernel that requires properties \
110 of the reference element in LFRic specifies those properties \
111 through the meta_reference_element metadata entry.
112 :type meta_ref_element: Optional[:py:class:`psyclone.domain.lfric.kernel.\
113 RefElementArgMetadata`]
114 :param meta_mesh: a kernel that requires properties of the LFRic \
115 mesh object specifies those properties through the meta_mesh \
117 :type meta_mesh: Optional[:py:class:`psyclone.domain.lfric.kernel.\
118 MetaMeshArgMetadata`]
119 :param procedure_name: the name of the kernel procedure to call.
120 :type procedure_name: Optional[str]
121 :param name: the name of the symbol to use for the metadata in \
122 language-level PSyIR.
123 :type name: Optional[str]
127 fparser2_class = Fortran2003.Derived_Type_Def
130 def __init__(self, operates_on=None, shapes=None, evaluator_targets=None,
131 meta_args=None, meta_funcs=None, meta_ref_element=None,
132 meta_mesh=None, procedure_name=None, name=None):
143 self.
_name_name =
None
145 if operates_on
is not None:
147 if shapes
is not None:
149 if evaluator_targets
is not None:
152 if meta_args
is not None:
154 if meta_funcs
is not None:
156 if meta_ref_element
is not None:
159 if meta_mesh
is not None:
161 if procedure_name
is not None:
168 def _validation_error_str(self, description):
169 '''Utility to extend a validation error message in a standard form,
170 with additional context information.
172 :param str description: the original error description.
174 :returns: an updated error description.
181 f
"{description} in kernel metadata '{name}' for procedure "
185 '''Only certain metadata combinations are allowed in LFRic. This
186 routine checks that any such constraints are respected.
188 :raises ParseError: if any validation checks fail.
210 def _get_kernel_type(self):
211 '''Returns the type of kernel, based on the metadata stored in this
212 instance. LFRic supports different types of kernel and the
213 type can be inferred from the kernel metadata as each kernel
214 type has different constraints on the allowed metadata values
215 and combinations. Also checks that the metadata conforms to
216 any rules associated with the particular kernel type.
218 :returns: the type of kernel that this metadata describes.
223 [InterGridArgMetadata, InterGridVectorArgMetadata]):
227 if self.
meta_args_getmeta_args_get(ColumnwiseOperatorArgMetadata):
230 return f
"cma-{cma_type}"
237 return "general-purpose"
239 def _validate_generic_kernel(self):
240 '''Validation checks common to multiple kernel types.
242 :raises ParseError: if any validation checks fail.
251 [FieldArgMetadata, FieldVectorArgMetadata, OperatorArgMetadata,
252 ColumnwiseOperatorArgMetadata, InterGridArgMetadata,
253 InterGridVectorArgMetadata]):
255 "Kernel metadata with 'operates_on != domain' must have at "
256 "least one meta_args argument that is a field, field vector, "
257 "intergrid field, intergrid vector field, LMA operator or "
258 "CMA operator (in order to determine the appropriate "
259 "iteration space), however this metadata has none"))
264 [OperatorArgMetadata, ColumnwiseOperatorArgMetadata])
267 [FieldArgMetadata, FieldVectorArgMetadata,
268 InterGridArgMetadata, InterGridVectorArgMetadata])
269 for field_arg
in field_args:
270 if field_arg.datatype !=
"gh_real":
272 f
"Kernel metadata with a meta_args operator argument "
273 f
"must only contain meta_args real-valued field "
274 f
"arguments, however found a field of type "
275 f
"'{field_arg.datatype}'"))
277 def _validate_general_purpose_kernel(self):
278 '''Validation checks for a general purpose kernel.
280 :raises ParseError: if any validation checks fail.
289 "A general purpose kernel should not operate on a domain, "
290 "however this does"))
300 if type(meta_arg)
not in [
301 FieldArgMetadata, FieldVectorArgMetadata,
302 OperatorArgMetadata, ScalarArgMetadata]:
304 f
"General purpose kernels with 'operates_on == "
305 f
"cell_column' should only have meta_arg arguments "
306 f
"of type field, field vector, LMA operator or scalar"
307 f
", but found '{meta_arg.check_name}'"))
333 def _validate_domain_kernel(self):
334 '''Validation checks for a domain kernel.
336 :raises ParseError: if any validation checks fail.
344 f
"Domain kernels should have their operates_on metadata set "
345 f
"to 'domain', but found '{self.operates_on}'"))
349 if type(meta_arg)
not in [
350 ScalarArgMetadata, FieldArgMetadata,
351 FieldVectorArgMetadata]:
353 f
"Domain kernels should only have meta_arg arguments "
354 f
"of type field, field vector, or scalar, but found "
355 f
"'{meta_arg.check_name}'"))
361 [FieldArgMetadata, FieldVectorArgMetadata])
362 for meta_arg
in fields_metadata:
363 if meta_arg.function_space
not in \
364 lfric_constants.DISCONTINUOUS_FUNCTION_SPACES:
366 f
"Domain kernels meta_arg arguments of type field, or "
367 f
"field vector should be on a discontinuous function "
368 f
"space, but found '{meta_arg.function_space}'"))
371 f
"Domain kernels meta_arg arguments of type field, or "
372 f
"field vector should not have any stencil accesses, but "
373 f
"found a stencil of type '{meta_arg.stencil}'"))
378 "Domain kernels should not specify basis or differential "
379 "basis functions metadata, but this does"))
384 "Domain kernels should not specify mesh property metadata, "
387 def _cma_kernel_type(self):
388 '''Determine the type of CMA (Column Matrix Assembly) kernel this is.
390 :returns: the type of cma kernel this metadata respresents.
403 return "matrix-matrix"
405 def _validate_generic_cma_kernel(self):
406 '''Validation checks for a generic CMA kernel.
408 :raises ParseError: if any validation checks fail.
417 f
"A CMA kernel should only operate on a 'cell_column', but "
418 f
"found '{self.operates_on}'"))
421 cma_ops = self.
meta_args_getmeta_args_get(ColumnwiseOperatorArgMetadata)
424 "A CMA kernel should contain at least one cma operator "
425 "argument but none are specified in the meta_args metadata"))
429 [InterGridArgMetadata, InterGridVectorArgMetadata]):
431 "A CMA kernel should not contain any intergrid arguments, "
432 "but at least one was found"))
437 "A CMA kernel should not contain any field vector arguments, "
438 "but at least one was found"))
441 fields_metadata = self.
meta_args_getmeta_args_get(FieldArgMetadata)
442 for meta_arg
in fields_metadata:
445 "A CMA kernel should not contain any fields with stencil "
446 "accesses, but at least one was found"))
448 def _validate_cma_assembly_kernel(self):
449 '''Validation checks for a CMA assembly kernel.
451 :raises ParseError: if any validation checks fail.
458 cma_ops = self.
meta_args_getmeta_args_get(ColumnwiseOperatorArgMetadata)
459 if len(cma_ops) != 1:
461 f
"A CMA assembly kernel should contain one CMA operator "
462 f
"argument, however {len(cma_ops)} were found"))
465 if cma_ops[0].access ==
"gh_read":
467 f
"A CMA assembly kernel should contain one CMA operator "
468 f
"argument with write access, however it has access "
469 f
"'{cma_ops[0].access}'"))
474 "A CMA assembly kernel should contain at least one LMA "
475 "operator but none were found"))
479 if type(meta_arg)
is not ColumnwiseOperatorArgMetadata:
480 if meta_arg.access !=
"gh_read":
482 f
"A CMA assembly kernel should have all arguments as "
483 f
"read-only apart from the CMA argument, but found "
484 f
"non-CMA argument with access '{meta_arg.access}'"))
487 def _validate_cma_apply_kernel(self):
488 '''Validation checks for a CMA apply kernel.
490 :raises ParseError: if any validation checks fail.
500 if type(meta_arg)
not in [
501 ColumnwiseOperatorArgMetadata, FieldArgMetadata]:
503 f
"A CMA apply kernel should only contain field or CMA "
504 f
"operator arguments, but found '{meta_arg.check_name}'"))
507 cma_ops = self.
meta_args_getmeta_args_get(ColumnwiseOperatorArgMetadata)
508 if len(cma_ops) != 1:
510 f
"A CMA apply kernel should contain one CMA operator "
511 f
"argument, however found {len(cma_ops)}"))
515 if cma_op.access !=
"gh_read":
517 f
"A CMA apply kernel should contain one CMA operator argument "
518 f
"with read access, however the operator has access "
519 f
"'{cma_op.access}'"))
522 field_args = self.
meta_args_getmeta_args_get(FieldArgMetadata)
525 "A CMA apply kernel should contain two field arguments, but "
527 if len(field_args) != 2:
529 if len(field_args) == 1:
532 f
"A CMA apply kernel should contain two field arguments, but "
533 f
"{len(field_args)} {word} found"))
536 if not ((field_args[0].access ==
"gh_read" and
537 field_args[1].access
in lfric_constants.WRITE_ACCESSES)
or
538 (field_args[0].access
in lfric_constants.WRITE_ACCESSES
and
539 field_args[1].access ==
"gh_read")):
541 f
"A CMA apply kernel should contain two field arguments, one "
542 f
"of which is read and the other written, but found "
543 f
"'{field_args[0].access}' and '{field_args[1].access}'"))
548 if field_args[0].access
in lfric_constants.WRITE_ACCESSES:
549 writer_field = field_args[0]
550 reader_field = field_args[1]
552 reader_field = field_args[0]
553 writer_field = field_args[1]
554 if writer_field.function_space != cma_op.function_space_to:
556 f
"In a CMA apply kernel, the function space of the written "
557 f
"field must match the function space of the CMA operator's "
558 f
"'to' function space, but found "
559 f
"'{writer_field.function_space}' and "
560 f
"'{cma_op.function_space_to}' respectively"))
561 if reader_field.function_space != cma_op.function_space_from:
563 f
"In a CMA apply kernel, the function space of the read "
564 f
"field must match the function space of the CMA operator's "
565 f
"'from' function space, but found "
566 f
"'{reader_field.function_space}' and "
567 f
"'{cma_op.function_space_from}' respectively"))
569 def _validate_cma_matrix_matrix_kernel(self):
570 '''Validation checks for a CMA matrix-matrix kernel.
572 :raises ParseError: if any validation checks fail.
582 if type(meta_arg)
not in [
583 ColumnwiseOperatorArgMetadata, ScalarArgMetadata]:
585 f
"A CMA matrix-matrix kernel must only contain CMA "
586 f
"operators or scalars, but found "
587 f
"'{meta_arg.check_name}'"))
592 type(meta_arg)
is ColumnwiseOperatorArgMetadata
593 and meta_arg.access
in lfric_constants.WRITE_ACCESSES]
595 if len(cma_writers) != 1:
597 f
"A CMA matrix-matrix kernel must write to exactly one CMA "
598 f
"operator argument, but found {len(cma_writers)} writers"))
605 def _validate_intergrid_kernel(self):
606 '''Validation checks for an inter-grid kernel.
608 :raises ParseError: if any validation checks fail.
617 f
"An intergrid kernel should only operate on a "
618 f
"'cell_column', but found '{self.operates_on}'"))
622 if not isinstance(meta_arg, InterGridArgMetadata):
624 f
"An intergrid kernel should only have intergrid "
625 f
"arguments, but found '{meta_arg.check_name}'"))
628 if meta_arg.mesh_arg ==
"gh_coarse"]
632 "An intergrid kernel should have at least one intergrid "
633 "argument on the coarse mesh, but none were found"))
637 coarse_function_space = coarse_args[0].function_space
638 for coarse_arg
in coarse_args[1:]:
639 if coarse_arg.function_space != coarse_function_space:
641 f
"An intergrid kernel should have all of its arguments, "
642 f
"that are on the coarse mesh, on the same function "
643 f
"space. However, '{coarse_arg.function_space}' and "
644 f
"'{coarse_function_space}' differ"))
647 if meta_arg.mesh_arg ==
"gh_fine"]
651 "An intergrid kernel should have at least one intergrid "
652 "argument on the fine mesh, but none were found"))
654 fine_function_space = fine_args[0].function_space
657 for fine_arg
in fine_args[1:]:
658 if fine_arg.function_space != fine_function_space:
660 f
"An intergrid kernel should have all of its arguments, "
661 f
"that are on the fine mesh, on the same function "
662 f
"space. However, '{fine_arg.function_space}' and "
663 f
"'{fine_function_space}' differ"))
668 if coarse_function_space == fine_function_space:
670 f
"An intergrid kernel should have different function spaces "
671 f
"for the arguments on the coarse mesh and the arguments on "
672 f
"the fine mesh. However, both are on "
673 f
"'{coarse_function_space}'"))
677 '''Create a new instance of LFRicKernelMetadata populated with
678 metadata from a kernel in language-level PSyIR.
680 :param symbol: the symbol in which the metadata is stored \
681 in language-level PSyIR.
682 :type symbol: :py:class:`psyclone.psyir.symbols.DataTypeSymbol`
684 :returns: an instance of LFRicKernelMetadata.
685 :rtype: :py:class:`psyclone.domain.lfric.kernel.psyir.\
688 :raises TypeError: if the symbol argument is not the expected \
690 :raises InternalError: if the datatype of the provided symbol \
691 is not the expected type.
694 if not isinstance(symbol, DataTypeSymbol):
696 f
"Expected a DataTypeSymbol but found a "
697 f
"{type(symbol).__name__}.")
699 datatype = symbol.datatype
701 if not isinstance(datatype, UnsupportedFortranType):
703 f
"Expected kernel metadata to be stored in the PSyIR as "
704 f
"an UnsupportedFortranType, but found "
705 f
"{type(datatype).__name__}.")
709 return LFRicKernelMetadata.create_from_fortran_string(
710 datatype.declaration)
714 '''Create an instance of this class from an fparser2 tree.
716 :param fparser2_tree: fparser2 tree containing the metadata \
718 :type fparser2_tree: \
719 :py:class:`fparser.two.Fortran2003.Derived_Type_Ref`
721 :returns: an instance of LFRicKernelMetadata.
722 :rtype: :py:class:`psyclone.domain.lfric.kernel.psyir.\
725 :raises ParseError: if one of the meta_args entries is an \
727 :raises ParseError: if the metadata type does not extend kernel_type.
730 LFRicKernelMetadata.check_fparser2(
731 fparser2_tree, Fortran2003.Derived_Type_Def)
735 for fparser2_node
in walk(
736 fparser2_tree, Fortran2003.Data_Component_Def_Stmt):
737 fortran_string = str(fparser2_node).lower()
739 if "operates_on" in fortran_string:
741 kernel_metadata._operates_on = OperatesOnMetadata.\
743 elif "meta_args" in fortran_string:
744 kernel_metadata._meta_args = MetaArgsMetadata.\
746 elif "meta_funcs" in fortran_string:
747 kernel_metadata._meta_funcs = MetaFuncsMetadata.\
749 elif "gh_shape" in fortran_string:
751 kernel_metadata._shapes = ShapesMetadata.create_from_fparser2(
753 elif "gh_evaluator_targets" in fortran_string:
755 kernel_metadata._evaluator_targets = EvaluatorTargetsMetadata.\
757 elif "meta_reference_element" in fortran_string:
758 kernel_metadata._meta_ref_element = MetaRefElementMetadata.\
760 elif "meta_mesh" in fortran_string:
761 kernel_metadata._meta_mesh = MetaMeshMetadata.\
765 f
"Found unexpected metadata declaration "
766 f
"'{str(fparser2_node)}' in '{str(fparser2_tree)}'.")
769 kernel_metadata.name = fparser2_tree.children[0].children[1].tostr()
771 attribute_list = fparser2_tree.children[0].children[0]
772 str_attribute_list = str(attribute_list).lower() \
773 if attribute_list
else ""
774 if (attribute_list
is None or
775 "extends(kernel_type)" not in str_attribute_list):
777 f
"The metadata type declaration should extend kernel_type, "
778 f
"but found '{fparser2_tree.children[0]}' in {fparser2_tree}.")
779 kernel_metadata.procedure_name = \
780 LFRicKernelMetadata._get_procedure_name(fparser2_tree)
782 return kernel_metadata
785 '''Lower the metadata to language-level PSyIR.
787 :returns: metadata as stored in language-level PSyIR.
788 :rtype: :py:class:`psyclone.psyir.symbols.DataTypeSymbol`
791 return DataTypeSymbol(
795 def _get_procedure_name(spec_part):
796 '''Internal utility that extracts the procedure name from an
797 fparser2 tree that captures LFRic metadata.
799 TODO Issue #1946: potentially update the metadata to capture
800 interface names as well as the interface itself. The procedure
801 name will then no longer be optional.
803 :param spec_part: the fparser2 parse tree containing the metadata.
804 :type spec_part: :py:class:`fparser.two.Fortran2003.Derived_Type_Def`
806 :returns: the value of the property.
807 :rtype: Optional[str]
809 :raises ParseError: if the metadata is invalid.
814 type_bound_procedure = get_child(
815 spec_part, Fortran2003.Type_Bound_Procedure_Part)
816 if not type_bound_procedure:
818 if len(type_bound_procedure.children) != 2:
820 f
"Expecting a type-bound procedure, but found "
822 specific_binding = type_bound_procedure.children[1]
823 if not isinstance(specific_binding, Fortran2003.Specific_Binding):
825 f
"Expecting a specific binding for the type-bound "
826 f
"procedure, but found '{specific_binding}' in "
828 binding_name = specific_binding.children[3]
829 procedure_name = specific_binding.children[4]
830 if binding_name.string.lower() !=
"code" and procedure_name:
832 f
"Expecting the type-bound procedure binding-name to be "
833 f
"'code' if there is a procedure name, but found "
834 f
"'{str(binding_name)}' in '{spec_part}'.")
835 if not procedure_name:
838 procedure_name = binding_name
839 return procedure_name.string
843 :returns: the metadata represented by this instance as Fortran.
846 :raises ValueError: if the values for name, meta_arg, \
847 operates_on and procedure_name have not been set.
852 f
"Values for operates_on, meta_args and name "
853 f
"must be provided before calling the fortran_string method, "
854 f
"but found '{self.operates_on}', '{self._meta_args}' "
855 f
"and '{self.name}' respectively.")
857 operates_on = f
" {self._operates_on.fortran_string()}"
858 meta_args = f
" {self._meta_args.fortran_string()}"
862 shapes = f
" {self._shapes.fortran_string()}"
864 evaluator_targets =
""
866 evaluator_targets = f
" {self._evaluator_targets.fortran_string()}"
870 meta_funcs = f
" {self._meta_funcs.fortran_string()}"
872 meta_ref_element =
""
874 meta_ref_element = f
" {self._meta_ref_element.fortran_string()}"
878 meta_mesh = f
" {self._meta_mesh.fortran_string()}"
887 f
" PROCEDURE, NOPASS :: {self.procedure_name}\n")
890 f
"TYPE, PUBLIC, EXTENDS(kernel_type) :: {self.name}\n"
893 f
"{meta_ref_element}"
896 f
"{evaluator_targets}"
899 f
"END TYPE {self.name}\n")
905 :returns: the type of kernel that this is.
911 def operates_on(self):
913 :returns: the kernel operates_on property specified by the \
922 def operates_on(self, value):
924 :param str value: set the kernel operates_on property \
925 in the metadata to the specified value.
933 :returns: a list of shape metadata values.
934 :rtype: Optional[List[str]]
937 if self.
_shapes_shapes
is None:
939 return self.
_shapes_shapes.shapes
944 :param values: set the shape metadata to the \
945 supplied list of values.
946 :type values: List[str]
954 :returns: a list of evaluator_targets metadata values.
955 :rtype: Optional[List[str]]
962 @evaluator_targets.setter
965 :param values: set the evaluator_targets metadata to the \
966 supplied list of values.
967 :type values: List[str]
975 :returns: a list of 'meta_arg' objects which capture the \
976 metadata values of the kernel arguments.
977 :rtype: Optional[List[:py:class:`psyclone.domain.lfric.kernel.\
983 return self.
_meta_args_meta_args.meta_args_args
988 :param values: set the meta_args metadata to the \
989 supplied list of values.
990 :type values: List[:py:class:`psyclone.domain.lfric.kernel.\
999 :returns: a list of meta_funcs metadata values.
1000 :rtype: Optional[List[:py:class:`psyclone.domain.lfric.kernel.\
1001 MetaFuncsArgMetadata`]]
1006 return self.
_meta_funcs_meta_funcs.meta_funcs_args
1011 :param values: set the meta_funcs metadata to the \
1012 supplied list of values.
1013 :type values: List[:py:class:`psyclone.domain.lfric.kernel.\
1014 MetaFuncsArgMetadata`]
1022 :returns: a list of meta_reference_element metadata values.
1023 :rtype: Optional[List[:py:class:`psyclone.domain.lfric.kernel.\
1024 MetaRefElementArgMetadata`]]
1031 @meta_ref_element.setter
1034 :param values: set the meta_funcs metadata to the \
1035 supplied list of values.
1036 :type values: List[:py:class:`psyclone.domain.lfric.kernel.\
1037 MetaRefElementArgMetadata`]
1045 :returns: a list of meta_mesh metadata values.
1046 :rtype: Optional[List[:py:class:`psyclone.domain.lfric.kernel.\
1047 MetaMeshArgMetadata`]]
1052 return self.
_meta_mesh_meta_mesh.meta_mesh_args
1057 :param values: set the meta_mesh metadata to the \
1058 supplied list of values.
1059 :type values: List[:py:class:`psyclone.domain.lfric.kernel.\
1060 MetaMeshArgMetadata`]
1066 def procedure_name(self):
1068 :returns: the kernel procedure name specified by the metadata.
1073 @procedure_name.setter
1074 def procedure_name(self, value):
1076 :param Optional[str] value: set the kernel procedure name in the \
1077 metadata to the specified value.
1079 :raises ValueError: if the metadata has an invalid value.
1084 FortranReader.validate_name(value)
1085 except (ValueError, TypeError)
as err:
1087 f
"Expected procedure_name to be a valid Fortran name but "
1088 f
"found '{value}'.")
from err
1094 :returns: the name of the symbol that will contain the \
1095 metadata when lowering.
1099 return self.
_name_name
1102 def name(self, value):
1104 :param str value: set the name of the symbol that will contain \
1105 the metadata when lowering.
1107 :raises ValueError: if the name is not valid.
1110 FortranReader.validate_name(value)
1111 self.
_name_name = value
1114 '''Return a list of meta_args entries with names that match the
1117 :param types: a meta_arg type or list of meta_arg types.
1118 :type names: :py:class:`psyclone.domain.lfric.kernel.\
1119 CommonMetaArgMetadata` or List[:py:class:`psyclone.domain.\
1120 lfric.kernel.CommonMetaArgMetadata`]
1122 :returns: a list of meta_args entries.
1124 py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata`]
1126 :raises TypeError: if the types argument is not of the correct type.
1129 if not (isinstance(types, list)
or
1130 (inspect.isclass(types)
and
1131 issubclass(types, CommonMetaArgMetadata))):
1133 f
"Expected a subclass of CommonMetaArgMetadata or a list for "
1134 f
"the 'types' argument, but found '{type(types).__name__}'.")
1135 if isinstance(types, list):
1139 for my_type
in my_types:
1140 if not (inspect.isclass(my_type)
and
1141 issubclass(my_type, CommonMetaArgMetadata)):
1143 f
"Expected list entries in the 'types' argument to be "
1144 f
"subclasses of CommonMetaArgMetadata, but found "
1145 f
"'{type(my_type).__name__}'.")
1149 if type(meta_arg)
in my_types]
1152 '''Utility function to return any field (plus field vector, intergrid
1153 or intergrid vector) meta_args in metadata that have the same
1154 type as those specified in arg_types and are on the function
1155 space specified in function_space.
1157 :param arg_types: meta_arg classes indicating which meta_arg \
1160 :py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata` or \
1162 :py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata`]
1163 :param str function_space: the specified function space.
1165 :returns: a list of meta_args.
1166 :type arg_types: List[ \
1167 :py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata`]
1170 return [arg
for arg
in self.
meta_args_getmeta_args_get(arg_types)
1171 if arg.function_space == function_space]
1174 '''Utility function to return any operator meta_args in metadata that
1175 have the same type as those specified in arg_types and their
1176 from or to function spaces are the same as the function space
1177 specified in function_space.
1179 :param arg_types: meta_arg classes indicating which meta_arg \
1182 :py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata` or \
1184 :py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata`]
1185 :param str function_space: the specified function space.
1187 :returns: a list of meta_args.
1188 :type arg_types: List[ \
1189 :py:class:`psyclone.domain.lfric.kernel.CommonMetaArgMetadata`]
1192 return [arg
for arg
in self.
meta_args_getmeta_args_get(arg_types)
1193 if function_space
in [arg.function_space_to,
1194 arg.function_space_from]]
1197 __all__ = [
"LFRicKernelMetadata"]
def operator_meta_args_on_fs(self, arg_types, function_space)
def _validate_cma_matrix_matrix_kernel(self)
def meta_ref_element(self)
def evaluator_targets(self)
def _cma_kernel_type(self)
def _validate_cma_apply_kernel(self)
def _validate_generic_cma_kernel(self)
def create_from_fparser2(fparser2_tree)
def _validate_generic_kernel(self)
def _get_kernel_type(self)
def meta_args_get(self, types)
def _validate_domain_kernel(self)
def _validation_error_str(self, description)
def procedure_name(self, value)
def field_meta_args_on_fs(self, arg_types, function_space)
def meta_mesh(self, values)
def operates_on(self, value)
def meta_args(self, values)
def _validate_cma_assembly_kernel(self)
def _validate_intergrid_kernel(self)
def create_from_psyir(symbol)
def meta_funcs(self, values)
def _validate_general_purpose_kernel(self)