Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,26 @@ application at::
This is only required for modules with transformation scripts held in the
``transmute/`` directory (non-LFRic source or modules that are not
targeted by the LFRic Core ``psyclone.mk`` file). Some applications will
not have this .mk file.
not have this .mk file.


Modifying the PSyclone command(s)
---------------------------------

To assist with more flexible use of the PSyclone command(s) for the two DSL methods,
PSyKAl and Transmute, a flag has been added to allow users to adjust the flags used
with the command.
The main options are still required by default, but options that could be adjustable
per site, or potentially per file are being allowed, like compiler options.
An example is the use of ``-l all``, which has caused issues with some compilers,
such as Intel or Nvidia.

* ``PSYCLONE_TRANSMUTE_EXTRAS`` - used by Transmute
* ``PSYCLONE_PSYKAL_EXTRAS`` - used by PSyKAl

This has not been expanded further, however a user should be able to override them at
a site level, and a file level.
For just a site level, this could be set in the build option in the site cylc file.
Per file, which may be needed to preserve compiler clauses, and add optimisations in, a
makefile will need to export privatised versions of these per file and imported into
the application.
52 changes: 37 additions & 15 deletions documentation/source/developer_guide/psyclone/psyclone_scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ filename. ::
Storing a local transformation script, ``local.py``
+++++++++++++++++++++++++++++++++++++++++++++++++++
All files to be optimised by transmute (see ``psyclone_transmute_file_list.mk``)
in ``large_scale_precipitation`` will use this script unless overwritten with
a matching filename.::
in the ``large_scale_precipitation`` directory will use this script unless overwritten
with a matching source filename.::

optimisation/
└── <platform>/
Expand All @@ -71,7 +71,7 @@ For a script with matching source filename
└── ls_ppn.F90


* In the **built** ``lfric_atm`` application, ``ls_ppn.F90`` is found here -
* To understand the required path for storing a matching source filename, the build directory of a built application should be consulted. In the **built** ``lfric_atm`` application, ``ls_ppn.F90`` is found here -
**use this path**::

<lfric_atm working directory>/
Expand Down Expand Up @@ -102,25 +102,47 @@ apply module-specific PSyclone transformations. This can be found at::
└── build/
└── psyclone_transmute_file_list.mk

Within this makefile there are environment variables that hold the names of
Fortran modules/transformation scripts that the science interface PSyclone
makefile should target. These are::
Within this makefile there are several environment variables which control the
how files are passed to PSyclone Transmute.
These are:

PSYCLONE_PHSYICS_FILES_IMPORT
PSYCLONE_PHSYICS_FILES_FCM
* ``PSYCLONE_PHYSICS_FILES``
* ``PSYCLONE_PASS_NO_SCRIPT``
* ``TRANSMUTE_INCLUDE_METHOD``
* ``PSYCLONE_DIRECTORIES``
* ``PSYCLONE_PHYSICS_EXCEPTION``

* If the module for which you are adding a transformation script lives in the
LFRic Apps directory, please use ``PSYCLONE_PHSYICS_FILES_IMPORT``. This
includes any non-LFRic source stored in the ``interfaces/`` directory.

* If the module is being imported from UKCA, JULES, CASIM, UM, SOCRATES, or any
other code base and does not have a copy in the LFRic Apps repository, please
use the ``PSYCLONE_PHSYICS_FILES_FCM`` variable.
``PSYCLONE_PHYSICS_FILES`` is used with ``TRANSMUTE_INCLUDE_METHOD`` ``specify_include``.
File names (without the type), which are to be affected by PSyclone, are added to this list.
A PSyclone transformation script is applied to each respective file.
The global.py script with be used as default, overwritten with alternatives as advised above.
This is also currently the default method as we slowly transformation additional science files
across to using PSyclone.

``PSYCLONE_PASS_NO_SCRIPT`` has been implemented primarily for the ``TRANSMUTE_INCLUDE_METHOD``
``specify_include``, however can be expanded to either.
It controls whether files are to be passed to PSyclone, but not to have a script applied to them.
This can be useful to remove existing clauses from a file, but not add anything back.
files to be affected this way should only be added to this list, as they will be filtered out of
``PSYCLONE_PHYSICS_FILES`` anyway.
Comment on lines +125 to +130
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``PSYCLONE_PASS_NO_SCRIPT`` has been implemented primarily for the ``TRANSMUTE_INCLUDE_METHOD``
``specify_include``, however can be expanded to either.
It controls whether files are to be passed to PSyclone, but not to have a script applied to them.
This can be useful to remove existing clauses from a file, but not add anything back.
files to be affected this way should only be added to this list, as they will be filtered out of
``PSYCLONE_PHYSICS_FILES`` anyway.
``PSYCLONE_PASS_NO_SCRIPT`` specifies files to be passed to PSyclone without any associated transformation scripts.
The primary use case is to remove existing clauses from a file without modifying the Fortran source.
Any files included in ``PSYCLONE_PASS_NO_SCRIPT`` are filtered out of the ``PSYCLONE_PHYSICS_FILES`` list.
No transformation scripts will be applied to files in this list regardless of the ``TRANSMUTE_INCLUDE_METHOD``.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I'm not sure specify_exclude actually works for PSYCLONE_PASS_NO_SCRIPT.

I've implemented a very minimum viable product currently, whilst FAB/BAF or simular is being developed. I think I wanted to highlight this here somewhat that the intended use is with specify_include at this time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I wasn't aware of that. Can I suggest modifying the wording to reflect this? Currently, the phrase "can be expanded to either" suggests to me that users can use PSYCLONE_PASS_NO_SCRIPT with specify_exclude. Maybe this is clearer?

Suggested change
``PSYCLONE_PASS_NO_SCRIPT`` has been implemented primarily for the ``TRANSMUTE_INCLUDE_METHOD``
``specify_include``, however can be expanded to either.
It controls whether files are to be passed to PSyclone, but not to have a script applied to them.
This can be useful to remove existing clauses from a file, but not add anything back.
files to be affected this way should only be added to this list, as they will be filtered out of
``PSYCLONE_PHYSICS_FILES`` anyway.
``PSYCLONE_PASS_NO_SCRIPT`` has been implemented for the ``TRANSMUTE_INCLUDE_METHOD``
``specify_include``. Use of this variable for the ``specify_exclude`` method is not mature,
though work is planned (see [GitHub issue number here]).
This variable specifies files to be passed to PSyclone without applying any transformations.
This can be useful to remove existing clauses from a file without modifying the Fortran source.
Any files included in ``PSYCLONE_PASS_NO_SCRIPT`` are filtered out of the ``PSYCLONE_PHYSICS_FILES`` list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I agree that the wording would be a little clearer if it were changed to something like Oakley's suggestions for lines 128 and 130 specifically:

    • "This variable specifies files to be passed to PSyclone without applying any transformations.
      and
    • "Any files included in PSYCLONE_PASS_NO_SCRIPT are filtered out of the PSYCLONE_PHYSICS_FILES list." .

    And then you could leave in your other lines to just reflect what is currently possible?

  • Maybe you could also change line 126 to "however this could be expanded to exclude in the future" ?


``TRANSMUTE_INCLUDE_METHOD`` can be set to either ``specify_include`` or ``specify_exclude``.
With ``specify_include``, ``PSYCLONE_PHYSICS_FILES`` will be used to define the list of files
to be passed to the PSyclone Transmute command, and with ``specify_exclude``,
``PSYCLONE_DIRECTORIES`` and ``PSYCLONE_PHYSICS_EXCEPTION`` will be used.

``PSYCLONE_DIRECTORIES`` is used with ``TRANSMUTE_INCLUDE_METHOD`` ``specify_exclude``.
It provides a list of directories instead, where the build system populates the list of files to
be passed to PSyclone with all of the files in the directory.
``PSYCLONE_PHYSICS_EXCEPTION`` is used to filter the list of files found in each respective
``PSYCLONE_DIRECTORIES`` and remove them. This can often be used with .h files currently.


Module/transformation script names should be added in the following style (in
accordance with GNUMake)::

PSYCLONE_PHSYICS_FILES_IMPORT = \
PSYCLONE_PHYSICS_FILES = \
ls_ppn \
lsp_taper_ndrop \
mphys_air_density_mod
Expand Down
Loading