From 7474cdbe4ceaff462585e94c53cbc18917931a75 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Mon, 20 Apr 2026 14:46:31 +0100 Subject: [PATCH 1/5] Update broken links to psyclone documentation --- applications/coupled/documentation/mainpage.md | 2 +- applications/simple_diffusion/documentation/mainpage.md | 2 +- applications/skeleton/documentation/mainpage.md | 2 +- documentation/source/how_to_use_it/lfric_datamodel/field.rst | 4 ++-- .../source/how_to_use_it/lfric_datamodel/function_space.rst | 2 +- infrastructure/source/kernel_metadata/argument_mod.F90 | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/applications/coupled/documentation/mainpage.md b/applications/coupled/documentation/mainpage.md index 1808dc799..5b23befc8 100644 --- a/applications/coupled/documentation/mainpage.md +++ b/applications/coupled/documentation/mainpage.md @@ -26,6 +26,6 @@ operations which can be specified within an invoke call in the algorithm layer b directly by the infrastructure. For more up-to-date information about the LFRic-specific Built-ins functionality (e.g. names, argument order) please refer to the -dynamo 0.3 API Built-ins documentation. +dynamo 0.3 API Built-ins documentation. diff --git a/applications/simple_diffusion/documentation/mainpage.md b/applications/simple_diffusion/documentation/mainpage.md index 0a88fba99..aed16e313 100644 --- a/applications/simple_diffusion/documentation/mainpage.md +++ b/applications/simple_diffusion/documentation/mainpage.md @@ -26,6 +26,6 @@ operations which can be specified within an invoke call in the algorithm layer b directly by the infrastructure. For more up-to-date information about the LFRic-specific Built-ins functionality (e.g. names, argument order) please refer to the -dynamo 0.3 API Built-ins documentation. +dynamo 0.3 API Built-ins documentation. diff --git a/applications/skeleton/documentation/mainpage.md b/applications/skeleton/documentation/mainpage.md index cf7c2bc2a..ea23f31f6 100644 --- a/applications/skeleton/documentation/mainpage.md +++ b/applications/skeleton/documentation/mainpage.md @@ -26,6 +26,6 @@ operations which can be specified within an invoke call in the algorithm layer b directly by the infrastructure. For more up-to-date information about the LFRic-specific Built-ins functionality (e.g. names, argument order) please refer to the -dynamo 0.3 API Built-ins documentation. +dynamo 0.3 API Built-ins documentation. diff --git a/documentation/source/how_to_use_it/lfric_datamodel/field.rst b/documentation/source/how_to_use_it/lfric_datamodel/field.rst index b248e1a48..74757ed30 100644 --- a/documentation/source/how_to_use_it/lfric_datamodel/field.rst +++ b/documentation/source/how_to_use_it/lfric_datamodel/field.rst @@ -74,7 +74,7 @@ rather than adopting the name of the original field. take advantage of any shared memory parallelism. Therefore, use of ``copy_field_serial`` is not advised. If the data needs to be copied, then use the ``setval_x`` `built-in - `_ + `_ after the field is initialised. Initialising new fields with ``setval_x`` allows PSyclone to optimise the copy. @@ -270,7 +270,7 @@ The infrastructure supports 32-bit integer fields: ``integer_field_type``. Their creation and usage is essentially the same as for real fields. One key difference is that real fields and integer fields have their own set of `PSyclone built-in operations -`_. +`_. Currently, there is no known requirement for 64-bit integer fields, so a 64-bit integer field is not supported. diff --git a/documentation/source/how_to_use_it/lfric_datamodel/function_space.rst b/documentation/source/how_to_use_it/lfric_datamodel/function_space.rst index 5d09529ee..39f59e637 100644 --- a/documentation/source/how_to_use_it/lfric_datamodel/function_space.rst +++ b/documentation/source/how_to_use_it/lfric_datamodel/function_space.rst @@ -51,7 +51,7 @@ version, and finally the next entity / argument. The ``fs_type`` refers to one of a number of available function space types. A `high-level description -`_ +`_ of supported function spaces can be found in the PSyclone documentation. Refer to GungHo documentation for a comprehensive description of each function space. diff --git a/infrastructure/source/kernel_metadata/argument_mod.F90 b/infrastructure/source/kernel_metadata/argument_mod.F90 index 6a8e585bf..a2eb8d9f5 100644 --- a/infrastructure/source/kernel_metadata/argument_mod.F90 +++ b/infrastructure/source/kernel_metadata/argument_mod.F90 @@ -9,7 +9,7 @@ !> @details In order to create the correct PSy code, PSyclone requires several !! kernel argument properties. These properties are stored in kernels !! as the kernel metadata descriptors (see PSyclone documentation: -!! https://psyclone.readthedocs.io/en/stable/dynamo0p3.html#metadata). +!! https://psyclone.readthedocs.io/en/stable/user_guide/lfric.html#metadata). !! The elements of PSyclone LFRic API kernel metadata are: !! !! 1) `type(arg_type) :: meta_args(...)` that describes properties of From 9f4b1b9f1069f0377712cf9e0f2f00619060f57f Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Mon, 20 Apr 2026 14:49:21 +0100 Subject: [PATCH 2/5] Add support for psyclone 3.3, nvfortran and amdflang --- .../mesh/runtime_partition_lfric_mod.f90 | 3 ++ .../sci_map_inter_element_order_alg_mod.x90 | 2 +- infrastructure/build/cxx/amdclang++.mk | 10 +++++ infrastructure/build/fortran/amdflang.mk | 38 +++++++++++++++++++ .../build/psyclone/psyclone_tools.py | 21 ++++++---- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 infrastructure/build/cxx/amdclang++.mk create mode 100644 infrastructure/build/fortran/amdflang.mk diff --git a/components/driver/source/mesh/runtime_partition_lfric_mod.f90 b/components/driver/source/mesh/runtime_partition_lfric_mod.f90 index 3916697b7..6a3bd0697 100644 --- a/components/driver/source/mesh/runtime_partition_lfric_mod.f90 +++ b/components/driver/source/mesh/runtime_partition_lfric_mod.f90 @@ -63,6 +63,9 @@ subroutine get_partition_parameters( partitioning_nml, & panel_xproc = partitioning_nml%panel_xproc() panel_yproc = partitioning_nml%panel_yproc() + ! Deallocation needed to prevent nvfortran compiler issue + if (allocated(decomposition)) deallocate(decomposition) + select case (panel_decomposition) case ( panel_decomposition_auto ) diff --git a/components/science/source/algorithm/sci_map_inter_element_order_alg_mod.x90 b/components/science/source/algorithm/sci_map_inter_element_order_alg_mod.x90 index ba66921b1..4177d7c8a 100644 --- a/components/science/source/algorithm/sci_map_inter_element_order_alg_mod.x90 +++ b/components/science/source/algorithm/sci_map_inter_element_order_alg_mod.x90 @@ -11,7 +11,7 @@ module sci_map_inter_element_order_alg_mod - use constants_mod, only: i_def + use constants_mod, only: i_def, r_def use field_mod, only: field_type use integer_field_mod, only: integer_field_type use fs_continuity_mod, only: W3, Wtheta, W2 diff --git a/infrastructure/build/cxx/amdclang++.mk b/infrastructure/build/cxx/amdclang++.mk new file mode 100644 index 000000000..e375d4512 --- /dev/null +++ b/infrastructure/build/cxx/amdclang++.mk @@ -0,0 +1,10 @@ +############################################################################## +# (c) Crown copyright 2017 Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +############################################################################## + +$(info ** Chosen GNU C++ compiler) + +CXX_RUNTIME_LIBRARY=stdc++ + diff --git a/infrastructure/build/fortran/amdflang.mk b/infrastructure/build/fortran/amdflang.mk new file mode 100644 index 000000000..d58525a46 --- /dev/null +++ b/infrastructure/build/fortran/amdflang.mk @@ -0,0 +1,38 @@ +############################################################################## +# Copyright (c) 2017, Met Office, on behalf of HMSO and Queen's Printer +# For further details please refer to the file LICENCE which you +# should have received as part of this distribution. +############################################################################## +# Various things specific to the GNU Fortran compiler. +############################################################################## +# +# This macro is evaluated now (:= syntax) so it may be used as many times as +# desired without wasting time rerunning it. +# +$(info ** Chosen AMD Flang) + +F_MOD_DESTINATION_ARG = -J +F_MOD_SOURCE_ARG = -I + +FFLAGS_OPENMP = -fopenmp +LDFLAGS_OPENMP = -fopenmp + +FFLAGS_COMPILER = +FFLAGS_NO_OPTIMISATION = -O0 +FFLAGS_SAFE_OPTIMISATION = -O2 +FFLAGS_RISKY_OPTIMISATION = -Ofast +FFLAGS_DEBUG = -g +FFLAGS_WARNINGS = +FFLAGS_UNIT_WARNINGS = +FFLAGS_INIT = +FFLAGS_RUNTIME = +# fast-debug flags set separately as Intel compiler needs platform-specific control on them +FFLAGS_FASTD_INIT = $(FFLAGS_INIT) +FFLAGS_FASTD_RUNTIME = $(FFLAGS_RUNTIME) + +# Option for checking code meets Fortran standard (flang only supports 2018) +FFLAGS_FORTRAN_STANDARD = -std=f2018 + +LDFLAGS_COMPILER = + +FPPFLAGS = -P diff --git a/infrastructure/build/psyclone/psyclone_tools.py b/infrastructure/build/psyclone/psyclone_tools.py index 14060c3e2..2ece54dbf 100644 --- a/infrastructure/build/psyclone/psyclone_tools.py +++ b/infrastructure/build/psyclone/psyclone_tools.py @@ -14,11 +14,16 @@ from psyclone.domain.lfric import LFRicConstants from psyclone.psyGen import InvokeSchedule from psyclone.psyir.nodes import Loop, Routine, Directive +try: + from psyclone.psyir.transformations import OMPParallelTrans +except ImportError: + # Support for psyclone < 3.3 + from psyclone.transformations import OMPParallelTrans + from psyclone.transformations import ( - Dynamo0p3ColourTrans, - Dynamo0p3OMPLoopTrans, - Dynamo0p3RedundantComputationTrans, - OMPParallelTrans, + LFRicColourTrans, + LFRicOMPLoopTrans, + LFRicRedundantComputationTrans, ) # List of allowed 'setval_*' built-ins for redundant computation transformation @@ -50,7 +55,7 @@ def redundant_computation_setval(psyir): """ # Import redundant computation transformation - rtrans = Dynamo0p3RedundantComputationTrans() + rtrans = LFRicRedundantComputationTrans() # Loop over all the InvokeSchedule in the PSyIR object for subroutine in psyir.walk(InvokeSchedule): @@ -72,14 +77,14 @@ def colour_loops(psyir, enable_tiling=False): """ Applies the colouring transformation to all applicable loops and optionally enables tiling. - It creates the instance of `Dynamo0p3ColourTrans` only once. + It creates the instance of `LFRicColourTrans` only once. :param psyir: the PSyIR of the PSy-layer. :type psyir: :py:class:`psyclone.psyir.nodes.FileContainer` """ const = LFRicConstants() - ctrans = Dynamo0p3ColourTrans() + ctrans = LFRicColourTrans() # Loop over all the subroutines in the PSyIR object for subroutine in psyir.walk(Routine): @@ -104,7 +109,7 @@ def openmp_parallelise_loops(psyir): :type psyir: :py:class:`psyclone.psyir.nodes.FileContainer` """ - otrans = Dynamo0p3OMPLoopTrans() + otrans = LFRicOMPLoopTrans() oregtrans = OMPParallelTrans() # Loop over all the InvokeSchedule in the PSyIR object From 673d9d95d8d88a46a5c5eb3f8ab04c8b1a99fe53 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Mon, 20 Apr 2026 15:57:07 +0100 Subject: [PATCH 3/5] Fix nvfortran bug with polymorphic allocation --- .../driver/source/mesh/runtime_partition_lfric_mod.f90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/driver/source/mesh/runtime_partition_lfric_mod.f90 b/components/driver/source/mesh/runtime_partition_lfric_mod.f90 index 6a3bd0697..52b942e35 100644 --- a/components/driver/source/mesh/runtime_partition_lfric_mod.f90 +++ b/components/driver/source/mesh/runtime_partition_lfric_mod.f90 @@ -63,27 +63,35 @@ subroutine get_partition_parameters( partitioning_nml, & panel_xproc = partitioning_nml%panel_xproc() panel_yproc = partitioning_nml%panel_yproc() - ! Deallocation needed to prevent nvfortran compiler issue + ! nvfortran does not properly support the polymorphic allocation, to fix it + ! deallocate the polymorphic class and allocate each concrete type inside + ! the select cases if (allocated(decomposition)) deallocate(decomposition) select case (panel_decomposition) case ( panel_decomposition_auto ) + allocate(auto_decomposition_type :: decomposition) decomposition = auto_decomposition_type() case ( panel_decomposition_row ) + allocate(row_decomposition_type :: decomposition) decomposition = row_decomposition_type() case ( panel_decomposition_column ) + allocate(column_decomposition_type :: decomposition) decomposition = column_decomposition_type() case ( panel_decomposition_custom ) + allocate(custom_decomposition_type :: decomposition) decomposition = custom_decomposition_type( panel_xproc, panel_yproc ) case ( panel_decomposition_auto_nonuniform ) + allocate(auto_nonuniform_decomposition_type :: decomposition) decomposition = auto_nonuniform_decomposition_type() case ( panel_decomposition_guided_nonuniform ) + allocate(guided_nonuniform_decomposition_type :: decomposition) decomposition = guided_nonuniform_decomposition_type( panel_xproc ) case default From 6e11023622843212548c943f2db87f58dd985d54 Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Mon, 20 Apr 2026 16:43:19 +0100 Subject: [PATCH 4/5] Sign CLA and update copyright as recommended in the contributors guide --- CONTRIBUTORS.md | 1 + infrastructure/build/cxx/amdclang++.mk | 2 +- infrastructure/build/fortran/amdflang.mk | 13 +++++-------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 92ef52a5d..df5f2b78c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -25,5 +25,6 @@ | Pierre-siddall | Pierre Siddall | Met Office | 2026-01-29 | | mo-lucy-gordon | Lucy Gordon | Met Office | 2026-03-18 | | shreybh1 | Shrey Bhardwaj | Met Office | 2026-03-26 | +| sergisiso | Sergi Siso | UKRI-STFC | 2026-04-20 | diff --git a/infrastructure/build/cxx/amdclang++.mk b/infrastructure/build/cxx/amdclang++.mk index e375d4512..10b6ab43e 100644 --- a/infrastructure/build/cxx/amdclang++.mk +++ b/infrastructure/build/cxx/amdclang++.mk @@ -1,5 +1,5 @@ ############################################################################## -# (c) Crown copyright 2017 Met Office. All rights reserved. +# (c) Crown copyright Met Office. All rights reserved. # The file LICENCE, distributed with this code, contains details of the terms # under which the code may be used. ############################################################################## diff --git a/infrastructure/build/fortran/amdflang.mk b/infrastructure/build/fortran/amdflang.mk index d58525a46..14817232f 100644 --- a/infrastructure/build/fortran/amdflang.mk +++ b/infrastructure/build/fortran/amdflang.mk @@ -1,14 +1,11 @@ ############################################################################## -# Copyright (c) 2017, Met Office, on behalf of HMSO and Queen's Printer -# For further details please refer to the file LICENCE which you -# should have received as part of this distribution. +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. ############################################################################## -# Various things specific to the GNU Fortran compiler. +# Various things specific to the amdflang compiler. ############################################################################## -# -# This macro is evaluated now (:= syntax) so it may be used as many times as -# desired without wasting time rerunning it. -# + $(info ** Chosen AMD Flang) F_MOD_DESTINATION_ARG = -J From fb2c1d1347c27d2b9a1b8e5abe47e3a286f98fcd Mon Sep 17 00:00:00 2001 From: Sergi Siso Date: Tue, 21 Apr 2026 15:54:33 +0100 Subject: [PATCH 5/5] Fix amdclang info message --- infrastructure/build/cxx/amdclang++.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/build/cxx/amdclang++.mk b/infrastructure/build/cxx/amdclang++.mk index 10b6ab43e..78e4e64f1 100644 --- a/infrastructure/build/cxx/amdclang++.mk +++ b/infrastructure/build/cxx/amdclang++.mk @@ -4,7 +4,7 @@ # under which the code may be used. ############################################################################## -$(info ** Chosen GNU C++ compiler) +$(info ** Chosen AMD Clang C++ compiler) CXX_RUNTIME_LIBRARY=stdc++