Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
bf523ba
#1312: create initial ScalarArray example
mo-alistairp Jul 24, 2025
dc1ec4a
#1312: start adding code generation for ScalarArrays
mo-alistairp Aug 19, 2025
862f368
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Aug 19, 2025
1a07148
#1312: lint fix
mo-alistairp Aug 19, 2025
decf6c1
#1312: condense the scalar_array functionality into the scalar function
mo-alistairp Aug 19, 2025
6d74811
#1312L lint fix
mo-alistairp Aug 19, 2025
71c7d0c
#1312: fix the scalar type check logic
mo-alistairp Aug 19, 2025
fa6a7e6
#1312: remove the empty test file for now
mo-alistairp Aug 19, 2025
ae9ba03
#1312: fix the failing test
mo-alistairp Aug 19, 2025
4961046
#1312: actually fix the failing test
mo-alistairp Aug 19, 2025
bc8260f
#1312: lint fix
mo-alistairp Aug 19, 2025
8e2b3de
#1312: Add initial test implementation of ScalarArrays
mo-alistairp Aug 21, 2025
5b8c42d
#1312: fix tests to check that gh_scalar_array is being assigned prop…
mo-alistairp Aug 21, 2025
ea0e8f7
1312: add TODO to check whether is_scalar references need updating
mo-alistairp Aug 21, 2025
3b6ad7d
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Aug 21, 2025
33caeac
#1312: lint fix
mo-alistairp Aug 21, 2025
605d9ab
#1312: create a loose structure for acc access
mo-alistairp Aug 21, 2025
c9a5598
#1312: Code gen and stub gen for ScalarArrays
mo-alistairp Oct 21, 2025
bbb37b7
#1312: lint fix
mo-alistairp Oct 21, 2025
9f3cfb5
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Oct 21, 2025
8e311c2
#1312: lint fix
mo-alistairp Oct 21, 2025
ea6ae8d
#1312: lint fixes
mo-alistairp Oct 22, 2025
136d89e
#1312: move dimension array to lfric_scalar_args
mo-alistairp Oct 23, 2025
fd0d546
#1312: add declarations for ScalarArray
mo-alistairp Oct 24, 2025
50a2c09
#1312: Move ScalarArray declarations to its own file
mo-alistairp Nov 3, 2025
f4c685b
#1312: correct the type checking in declarations
mo-alistairp Nov 3, 2025
cc53390
#1312: return lfric_scalar_args to original state
mo-alistairp Nov 3, 2025
f3ee59e
#1312: fix if statement to exclude ScalarArray
mo-alistairp Nov 3, 2025
140b022
#1312: Add LFRicScalarArrayArga to paths
mo-alistairp Nov 4, 2025
8527d01
#1312: Alter ScalarArray declaration
mo-alistairp Nov 4, 2025
39f96fb
#1312: Lint fix
mo-alistairp Nov 4, 2025
3360be3
#1312: Lint fix
mo-alistairp Nov 4, 2025
02a42b2
#1312: Remove ScalarArrays from is_scalar
mo-alistairp Nov 4, 2025
6cf25bc
#1312: Fix is_scalar statement in lfric_loop
mo-alistairp Nov 5, 2025
a9dc367
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Nov 10, 2025
75692cc
#1312: reintroduce ScalarArray if statement in arg_ordering
mo-alistairp Nov 10, 2025
6edd5f3
#1312: add super scalar call to kern_stub_arg_list
mo-alistairp Nov 10, 2025
12b4a74
#1312: lint fix
mo-alistairp Nov 10, 2025
c455482
#1312: fix arg_ordering to include ScalarArrays in assertion
mo-alistairp Nov 10, 2025
184a624
#1312: Fix lfric_test to check ScalarArray rather than field
mo-alistairp Nov 10, 2025
20ecf84
#1312: change INTEGER_TYPE to LFRic equivalent
mo-alistairp Nov 10, 2025
35bc15a
#1312: add dims_array dimensions to ScalarArray declarations
mo-alistairp Nov 11, 2025
3a6ddc6
#1312: change find_or_create to lookup to fix code generation
mo-alistairp Nov 12, 2025
e92ca50
#1312: lint fix
mo-alistairp Nov 12, 2025
a21d57e
#1312: lint fix
mo-alistairp Nov 12, 2025
1d6b212
#1312: copy ScalarArray creation into the stub list
mo-alistairp Nov 13, 2025
1301f11
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Nov 13, 2025
a73d33b
#1312: Remove the temporary KernStubArgList code
mo-alistairp Nov 13, 2025
39b7cb9
#1312: Alter test cases to have 5 args in testkern to avoid error
mo-alistairp Nov 13, 2025
9556c2b
#1312: Try comment out changes to see if it fixes errors
mo-alistairp Nov 14, 2025
4052702
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Nov 14, 2025
86d3231
#1312: lint fix
mo-alistairp Nov 14, 2025
03c600a
#1312: add conditional to differentiate between code gen and stub gen
mo-alistairp Nov 14, 2025
b8c358f
#1312: Add partial stub generation code
mo-alistairp Nov 14, 2025
2216993
#1312: lint fix
mo-alistairp Nov 14, 2025
0d6874b
#1312: lint fix
mo-alistairp Nov 14, 2025
06fbf55
#1312: reinstate standard scalar behaviour in ArgOrdering
mo-alistairp Nov 17, 2025
aa7e39b
#1312: Fix the dimensions pf the ScalarArray stub gen
mo-alistairp Nov 21, 2025
0dcd904
#1312: add correct stub gen test
mo-alistairp Nov 21, 2025
13bcee0
#1312: Fix the stub gen to have the correct number of ScalarArray inputs
mo-alistairp Nov 21, 2025
0cc2463
#1312: lint fix
mo-alistairp Nov 21, 2025
531e181
#1312: Fix test in test to pass lint
mo-alistairp Nov 21, 2025
40aaf0e
#1312: remove code in KernCallArgList to fix the call in code generation
mo-alistairp Nov 24, 2025
18be0df
#1312: fix lint
mo-alistairp Nov 25, 2025
388d45e
#1312: remove print statement from stub_gen test
mo-alistairp Nov 25, 2025
f8d1a8a
#1312: lint fix
mo-alistairp Nov 25, 2025
502b618
#1312: tidy LFRicScalarArrayArgs
mo-alistairp Nov 25, 2025
da0a8d1
#1312: fix indentation in stub gen test
mo-alistairp Nov 25, 2025
013463c
#1312: Add error message to KernStubArgList because it no longer has …
mo-alistairp Nov 25, 2025
8249ade
#1312: Add stub declaration data type exception
mo-alistairp Nov 25, 2025
4d503fa
#1312: lint fix
mo-alistairp Nov 25, 2025
42ff5b7
#1312: Add test for ScalarArray intrinsic type
mo-alistairp Nov 26, 2025
662ac2e
#1312: remove print statements
mo-alistairp Nov 26, 2025
bfc3e47
#1312: Remove the KernCallAccArgList empty if statement to appease Co…
mo-alistairp Nov 26, 2025
463fcff
#1312: Test whether an exception is raised when a ScalarArray is call…
mo-alistairp Nov 26, 2025
9828122
#1312: remove todo
mo-alistairp Nov 26, 2025
05b2725
#1312: Tidy LFRicScalarArrayArgs
mo-alistairp Nov 26, 2025
abbed54
#1312: Add consideration for ScalarArrays in lfric.py
mo-alistairp Nov 26, 2025
ec15259
#1312: tidy scalar_array_invoke.f90
mo-alistairp Nov 26, 2025
f78a894
#1312: improve the multikernel_invokes_scalar_array_invalid description
mo-alistairp Nov 26, 2025
dc1bce9
#1312: Add authorship to relevant files
mo-alistairp Nov 26, 2025
5133a3c
Merge branch 'master' into 1312_scalararray_code_gen
mo-alistairp Nov 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/psyclone/domain/lfric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Author J. Henrichs, Bureau of Meteorology
# Modified: I. Kavcic, L. Turner and O. Brunt, Met Office
# Modified: I. Kavcic, L. Turner, O. Brunt and A. Pirrie, Met Office
# R. W. Ford and A. R. Porter, STFC Daresbury Lab

'''Module for the LFRic domain.
Expand Down Expand Up @@ -71,6 +71,7 @@
from psyclone.domain.lfric.lfric_run_time_checks import LFRicRunTimeChecks
from psyclone.domain.lfric.lfric_invokes import LFRicInvokes
from psyclone.domain.lfric.lfric_scalar_args import LFRicScalarArgs
from psyclone.domain.lfric.lfric_scalar_array_args import LFRicScalarArrayArgs
from psyclone.domain.lfric.lfric_loop_bounds import LFRicLoopBounds
from psyclone.domain.lfric.lfric_kern_metadata import LFRicKernMetadata
from psyclone.domain.lfric.lfric_psy import LFRicPSy
Expand Down Expand Up @@ -105,5 +106,6 @@
'LFRicPSy',
'LFRicRunTimeChecks',
'LFRicScalarArgs',
'LFRicScalarArrayArgs',
'LFRicStencils',
'LFRicSymbolTable']
13 changes: 7 additions & 6 deletions src/psyclone/domain/lfric/arg_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab
# Modified I. Kavcic, A. Coughtrie and L. Turner, Met Office
# Modified I. Kavcic, A. Coughtrie, L. Turner, and A. Pirrie, Met Office
# Modified J. Henrichs, Bureau of Meteorology

'''This module implements the base class for managing arguments to
Expand Down Expand Up @@ -459,7 +459,7 @@ def generate(self, var_accesses=None):
self.operator(arg, var_accesses=var_accesses)
elif arg.argument_type == "gh_columnwise_operator":
self.cma_operator(arg, var_accesses=var_accesses)
elif arg.is_scalar:
elif arg.is_scalar or arg.is_scalar_array:
self.scalar(arg, var_accesses=var_accesses)
else:
raise GenerationError(
Expand Down Expand Up @@ -770,11 +770,11 @@ def scalar(self, scalar_arg, var_accesses=None):

'''
const = LFRicConstants()
if not scalar_arg.is_scalar:
if not (scalar_arg.is_scalar or scalar_arg.is_scalar_array):
raise InternalError(
f"Expected argument type to be one of "
f"{const.VALID_SCALAR_NAMES} but got "
f"'{scalar_arg.argument_type}'")
f"{const.VALID_SCALAR_NAMES + const.VALID_ARRAY_NAMES}"
f" but got '{scalar_arg.argument_type}'")

if scalar_arg.is_literal:
# If we have a literal, do not add it to the variable access
Expand All @@ -785,7 +785,8 @@ def scalar(self, scalar_arg, var_accesses=None):
var_accesses.add_access(Signature(scalar_arg.precision),
AccessType.CONSTANT, self._kern)
else:
self.append(scalar_arg.name, var_accesses, mode=scalar_arg.access,
self.append(scalar_arg.name, var_accesses,
mode=scalar_arg.access,
metadata_posn=scalar_arg.metadata_index)

def fs_common(self, function_space, var_accesses=None):
Expand Down
6 changes: 5 additions & 1 deletion src/psyclone/domain/lfric/kern_call_acc_arg_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ def fs_intergrid(self, function_space, var_accesses=None):
def scalar(self, scalar_arg, var_accesses=None):
'''
Override the default implementation as there's no need to specify
scalars for an OpenACC data region.
scalar values for an OpenACC data region. But there is a need for
ScalarArrays.

:param scalar_arg: the kernel argument.
:type scalar_arg: :py:class:`psyclone.lfric.LFRicKernelArgument`
Expand All @@ -271,6 +272,9 @@ def scalar(self, scalar_arg, var_accesses=None):
:py:class:`psyclone.core.VariablesAccessMap`]

'''
# TODO: Add implementation of OpenACC data region for ScalarArrays
# If the argument is a simple scalar value then doesn't need values
# added to OpenACC region


# ============================================================================
Expand Down
1 change: 0 additions & 1 deletion src/psyclone/domain/lfric/kern_call_arg_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ def scalar(self, scalar_arg,
else:
sym = self._symtab.lookup(scalar_arg.name)
self.psyir_append(Reference(sym))

# TODO uncomment this method when ensuring we only pass ncell3d once
# to any given kernel.
# def mesh_ncell3d(self):
Expand Down
31 changes: 30 additions & 1 deletion src/psyclone/domain/lfric/kern_stub_arg_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab
# Modified I. Kavcic, A. Coughtrie and L. Turner, Met Office
# Modified I. Kavcic, A. Coughtrie, L. Turner and A. Pirrie, Met Office
# Modified J. Henrichs, Bureau of Meteorology

'''This module implements a class that creates the argument list
Expand Down Expand Up @@ -133,6 +133,35 @@ def cma_operator(self, arg, var_accesses=None):
_local_args += [bandwidth, alpha, beta, gamma_m, gamma_p]
self.extend(_local_args, var_accesses)

def scalar(self, scalar_arg, var_accesses=None):
'''Add the name associated with the scalar argument to the argument
list and optionally add this scalar to the variable access
information.

:param scalar_arg: the kernel argument.
:type scalar_arg: :py:class:`psyclone.lfric.LFRicKernelArgument`
:param var_accesses: optional VariablesAccessMap instance that \
stores information about variable accesses.
:type var_accesses: \
:py:class:`psyclone.core.VariablesAccessMap`

:raises InternalError: if the argument is not a recognised scalar type.

'''
const = LFRicConstants()
if not (scalar_arg.is_scalar or scalar_arg.is_scalar_array):
raise InternalError(
f"Expected argument type to be one of "
f"{const.VALID_SCALAR_NAMES + const.VALID_ARRAY_NAMES}"
f" but got '{scalar_arg.argument_type}'")

if scalar_arg.is_scalar:
self.append(scalar_arg.name, var_accesses)
else:
# ScalarArray
self.append("dims_" + scalar_arg.name, var_accesses)
self.append(scalar_arg.name, var_accesses)

def field_vector(self, 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
Expand Down
11 changes: 8 additions & 3 deletions src/psyclone/domain/lfric/lfric_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab
# Modified I. Kavcic, A. Coughtrie, L. Turner and O. Brunt, Met Office
# Modified I. Kavcic, A. Coughtrie, L. Turner, O. Brunt
# and A. Pirrie, Met Office
# Modified J. Henrichs, Bureau of Meteorology
# Modified A. B. G. Chalk and N. Nobre, STFC Daresbury Lab

Expand Down Expand Up @@ -93,10 +94,13 @@ def __init__(self, alg_invocation, idx, invokes):
from psyclone.domain.lfric import (
LFRicCellIterators, LFRicHaloDepths, LFRicLoopBounds,
LFRicRunTimeChecks,
LFRicScalarArgs, LFRicFields, LFRicDofmaps, LFRicStencils)
LFRicScalarArgs, LFRicScalarArrayArgs, LFRicFields, LFRicDofmaps,
LFRicStencils)

self.scalar_args = LFRicScalarArgs(self)

self.scalar_array_args = LFRicScalarArrayArgs(self)

# Initialise our Invoke stencil information
self.stencil = LFRicStencils(self)

Expand Down Expand Up @@ -274,7 +278,8 @@ def setup_psy_layer_symbols(self):

'''
# Declare all quantities required by this PSy routine (Invoke)
for entities in [self.scalar_args, self.fields, self.lma_ops,
for entities in [self.scalar_args, self. scalar_array_args,
self.fields, self.lma_ops,
self.stencil, self.meshes,
self.function_spaces, self.dofmaps, self.cma_ops,
self.boundary_conditions, self.evaluators,
Expand Down
18 changes: 12 additions & 6 deletions src/psyclone/domain/lfric/lfric_kern.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# Authors R. W. Ford, A. R. Porter and S. Siso, STFC Daresbury Lab
# Modified I. Kavcic, A. Coughtrie, L. Turner and O. Brunt, Met Office
# Modified I. Kavcic, A. Coughtrie, L. Turner, O. Brunt
# and A. Pirrie, Met Office
# Modified J. Henrichs, Bureau of Meteorology
# Modified A. B. G. Chalk and N. Nobre, STFC Daresbury Lab

Expand Down Expand Up @@ -196,7 +197,8 @@ def load_meta(self, ktype):
elif descriptor.argument_type.lower() == "gh_field":
pre = "field_"
elif (descriptor.argument_type.lower() in
const.VALID_SCALAR_NAMES):
(const.VALID_SCALAR_NAMES +
const.VALID_ARRAY_NAMES)):
if descriptor.data_type.lower() == "gh_real":
pre = "rscalar_"
elif descriptor.data_type.lower() == "gh_integer":
Expand All @@ -208,6 +210,9 @@ def load_meta(self, ktype):
f"Expected one of {const.VALID_SCALAR_DATA_TYPES} "
f"data types for a scalar argument but found "
f"'{descriptor.data_type}'.")
if (descriptor.argument_type.lower() in
const.VALID_ARRAY_NAMES):
pre += "array_"
else:
raise GenerationError(
f"LFRicKern.load_meta() expected one of "
Expand Down Expand Up @@ -772,15 +777,16 @@ def gen_stub(self) -> Container:
# Import here to avoid circular dependency
# pylint: disable=import-outside-toplevel
from psyclone.domain.lfric import (
LFRicCellIterators, LFRicScalarArgs, LFRicFields,
LFRicDofmaps, LFRicStencils)
LFRicCellIterators, LFRicScalarArgs, LFRicScalarArrayArgs,
LFRicFields, LFRicDofmaps, LFRicStencils)
from psyclone.lfric import (
LFRicFunctionSpaces, LFRicCMAOperators, LFRicBoundaryConditions,
LFRicLMAOperators, LFRicMeshProperties, LFRicBasisFunctions,
LFRicReferenceElement)
for entities in [LFRicCellIterators, LFRicDofmaps, LFRicFunctionSpaces,
LFRicCMAOperators, LFRicScalarArgs, LFRicFields,
LFRicLMAOperators, LFRicStencils, LFRicBasisFunctions,
LFRicCMAOperators, LFRicScalarArgs,
LFRicScalarArrayArgs, LFRicFields, LFRicLMAOperators,
LFRicStencils, LFRicBasisFunctions,
LFRicBoundaryConditions, LFRicReferenceElement,
LFRicMeshProperties]:
entities(self).stub_declarations()
Expand Down
2 changes: 1 addition & 1 deletion src/psyclone/domain/lfric/lfric_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def _halo_read_access(self, arg):

'''
const = LFRicConstants()
if arg.is_scalar or arg.is_operator:
if arg.is_scalar or arg.is_operator or arg.is_scalar_array:
# Scalars and operators do not have halos
return False
if arg.is_field:
Expand Down
8 changes: 5 additions & 3 deletions src/psyclone/domain/lfric/lfric_scalar_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def invoke_declarations(self):
intrinsic_type=const.MAPPING_DATA_TYPES["gh_logical"])

for intent in FORTRAN_INTENT_NAMES:
scal = [arg.declaration_name for arg in self._scalar_args[intent]]
scal = [arg.declaration_name for
arg in self._scalar_args[intent]]
rscal = [arg.declaration_name for
arg in self._real_scalars[intent]]
iscal = [arg.declaration_name for
Expand Down Expand Up @@ -171,8 +172,9 @@ def stub_declarations(self):
raise InternalError(
f"Found an unsupported data type "
f"'{arg.descriptor.data_type}' for the scalar "
f"argument '{arg.declaration_name}'. Supported types "
f"are {const.VALID_SCALAR_DATA_TYPES}.")
f"argument '{arg.declaration_name}'. "
f"Supported types are "
f"{const.VALID_SCALAR_DATA_TYPES}.")

# Create declarations
self._create_declarations()
Expand Down
Loading
Loading