psyclone.domain.lfric.kern_call_arg_list
This module implements a class that manages the argument for a kernel call. It especially adds all implicitly required parameters. It creates the argument in two formats: first as a list of strings, but also as a list of PSyIR nodes. TODO #1930: the support for the string format should be removed as we migrate to use PSyIR in LFRic.
Classes
KernCallArgList
: Creates the argument list required to call kernel “kern” from the
- class psyclone.domain.lfric.kern_call_arg_list.KernCallArgList(kern)
Creates the argument list required to call kernel “kern” from the PSy-layer and captures the positions of the following arguments in the argument list: nlayers, number of quadrature points and number of degrees of freedom. The ordering and type of arguments is captured by the base class.
- Parameters:
kern (
psyclone.domain.lfric.LFRicKern
) – The kernel that is being called.
Inheritance
- class NdfInfo(position, function_space)
- function_space
Alias for field number 1
- position
Alias for field number 0
- append_structure_reference(module_name, user_type, member_list, name, tag=None, overwrite_datatype=None)
Creates a reference to a variable of a user-defined type. If required, the required import statements will all be generated.
- Parameters:
module_name (str) – the name of the module from which the user-defined type must be imported.
user_type (str) – the name of the user-defined type.
member_list (List[str]) – the members used hierarchically.
name (str) – the name of the variable to be used in the Reference.
tag (Optional[str]) – tag to use for the variable, defaults to the name
overwrite_datatype (Optional[
psyclone.psyir.symbols.DataType
]) – the datatype for the reference, which will overwrite the value determined by analysing the corresponding user defined type. This is useful when e.g. the module that declares the structure cannot be accessed.
- Returns:
the symbol that is used in the reference
- Return type:
- basis(function_space, var_accesses=None)
Add basis function information for this function space to the argument list and optionally to the variable access information.
- Parameters:
function_space (
psyclone.domain.lfric.FunctionSpace
) – the function space for which the basis function is required.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- cell_map(var_accesses=None)
Add cell-map and related cell counts (for inter-grid kernels) to the argument list. If supplied it also stores these accesses to the var_access object.
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- cell_position(var_accesses=None)
Adds a cell argument to the argument list and if supplied stores this access in var_accesses.
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- cell_ref_name(var_accesses=None)
Utility routine which determines whether to return the cell value or the colourmap lookup value. If supplied it also stores this access in var_accesses.
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.- Returns:
the Fortran code needed to access the current cell index.
- Return type:
Tuple[str, py:class:psyclone.psyir.nodes.Reference]
- cma_operator(arg, var_accesses=None)
Add the CMA operator and associated scalars to the argument list and optionally add them to the variable access information.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the CMA operator argument.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- diff_basis(function_space, var_accesses=None)
Add differential basis information for the function space to the argument list. If supplied it also stores this access in var_accesses.
- Parameters:
function_space (
psyclone.domain.lfric.FunctionSpace
) – the function space for which the differential basis functions are required.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- field(arg, var_accesses=None)
Add the field array associated with the argument ‘arg’ to the argument list. If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the field to be added.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- field_bcs_kernel(function_space, var_accesses=None)
Implement the boundary_dofs array fix for a field. If supplied it also stores this access in var_accesses.
- Parameters:
function_space (
psyclone.domain.lfric.FunctionSpace
) – the function space for which boundary dofs are required.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- Raises:
GenerationError – if the bcs kernel does not contain a field as argument (but e.g. an operator).
- field_vector(argvect, var_accesses=None)
Add the field vector associated with the argument ‘argvect’ to the argument list. If supplied it also stores these accesses to the var_access object.
- Parameters:
argvect (
psyclone.dynamo0p3.DynKernelArgument
) – the field vector to add.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- fs_common(function_space, var_accesses=None)
Add function-space related arguments common to LMA operators and fields. If supplied it also stores this access in var_accesses.
- Parameters:
function_space (
psyclone.domain.lfric.FunctionSpace
) – the function space for which the related arguments common to LMA operators and fields are added.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- fs_compulsory_field(function_space, var_accesses=None)
Add compulsory arguments associated with this function space to the list. If supplied it also stores this access in var_accesses.
- Parameters:
function_space (
psyclone.domain.lfric.FunctionSpace
) – the function space for which the compulsory arguments are added.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- fs_intergrid(function_space, var_accesses=None)
Add function-space related arguments for an intergrid kernel. If supplied it also stores this access in var_accesses.
- Parameters:
function_space (
psyclone.domain.lfric.FunctionSpace
) – the function space for which to add argumentsvar_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- get_user_type(module_name, user_type, name, tag=None)
Returns the symbol for a user-defined type. If required, the required import statements will all be generated.
- Parameters:
module_name (str) – the name of the module from which the user-defined type must be imported.
user_type (str) – the name of the user-defined type.
name (str) – the name of the variable to be used in the Reference.
tag (Optional[str]) – tag to use for the variable, defaults to the name
- Returns:
the symbol that is used in the reference
- Return type:
- mesh_height(var_accesses=None)
Add mesh height (nlayers) to the argument list and if supplied stores this access in var_accesses.
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- mesh_properties(var_accesses=None)
Provide the kernel arguments required for the mesh properties specified in the kernel metadata. If supplied it also stores this access in var_accesses.
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- property ndf_positions
- Returns:
the position(s) in the argument list and the function space(s) associated with the variable(s) that pass(es) the number of degrees of freedom for the function space. The generate method must be called first.
- Return type:
list of namedtuple (position=int, function_space=str).
- Raises:
InternalError – if the generate() method has not been called.
- property nlayers_positions
- Returns:
the position(s) in the argument list of the variable(s) that passes the number of layers. The generate method must be called first.
- Return type:
list of int.
- Raises:
InternalError – if the generate() method has not been called.
- property nqp_positions
- Returns:
the positions in the argument list of the variables that pass the number of quadrature points. The number and type of these will change depending on the type of quadrature. A list of dictionaries is returned with the quadrature types being the keys to the dictionaries and their position in the argument list being the values. At the moment only XYoZ is supported (which has horizontal and vertical quadrature points). The generate method must be called first.
- Return type:
[{str: int, …}]
- Raises:
InternalError – if the generate() method has not been called.
- operator(arg, var_accesses=None)
Add the operator arguments to the argument list. If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the meta-data description of the operator.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- operator_bcs_kernel(function_space, var_accesses=None)
Supply necessary additional arguments for the kernel that applies boundary conditions to a LMA operator. If supplied it also stores this access in var_accesses.
- Parameters:
function_space (
psyclone.dynamo3.FunctionSpace
) – unused, only for consistency with base class.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- quad_rule(var_accesses=None)
Add quadrature-related information to the kernel argument list. Adds the necessary arguments to the argument list, and optionally adds variable access information to the var_accesses object.
- Parameters:
var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- scalar(scalar_arg, var_accesses=None)
Add the necessary argument for a scalar quantity as well as an appropriate Symbol to the SymbolTable.
- Parameters:
scalar_arg (
psyclone.dynamo0p3.DynKernelArgument
) – the scalar kernel argument.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance that stores information about variable accesses.
- stencil(arg, var_accesses=None)
Add general stencil information associated with the argument ‘arg’ to the argument list. If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the meta-data description of the kernel argument with which the stencil is associated.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- stencil_2d(arg, var_accesses=None)
Add general 2D stencil information associated with the argument ‘arg’ to the argument list. If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the meta-data description of the kernel argument with which the stencil is associated.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- stencil_2d_max_extent(arg, var_accesses=None)
Add the maximum branch extent for a 2D stencil associated with the argument ‘arg’ to the argument list. If supplied it also stores this in var_accesses.
- Parameters:
arg (
pclone.dynamo0p3.DynKernelArgument
) – the kernel argument with which the stencil is associated.var_accesses (
psyclone.core.SingleVariableAccessInfo
) – optional SingleVariableAccessInfo instance to store the information about variable accesses.
- stencil_2d_unknown_extent(arg, var_accesses=None)
Add 2D stencil information to the argument list associated with the argument ‘arg’ if the extent is unknown. If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the kernel argument with which the stencil is associated.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- stencil_unknown_direction(arg, var_accesses=None)
Add stencil information to the argument list associated with the argument ‘arg’ if the direction is unknown (i.e. it’s being supplied in a variable). If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the kernel argument with which the stencil is associated.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.
- stencil_unknown_extent(arg, var_accesses=None)
Add stencil information to the argument list associated with the argument ‘arg’ if the extent is unknown. If supplied it also stores this access in var_accesses.
- Parameters:
arg (
psyclone.dynamo0p3.DynKernelArgument
) – the kernel argument with which the stencil is associated.var_accesses (
psyclone.core.VariablesAccessInfo
) – optional VariablesAccessInfo instance to store the information about variable accesses.