Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2394 support char logical in psydata #2509

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

hiker
Copy link
Collaborator

@hiker hiker commented Feb 22, 2024

No description provided.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.88%. Comparing base (4b3662e) to head (96d917d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2509   +/-   ##
=======================================
  Coverage   99.88%   99.88%           
=======================================
  Files         359      359           
  Lines       50264    50264           
=======================================
  Hits        50208    50208           
  Misses         56       56           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hiker hiker added LFRic Issue relates to the LFRic domain PSyData NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH ready for review and removed NG-ARCH Issues relevant to the GPU parallelisation of LFRic and other models expected to be used in NG-ARCH labels Dec 17, 2024
Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

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

Nice, small PR :-)
Would it be possible to extend one of the examples to make use of/exercise this new functionality? Otherwise it's completely untested :-(
Also, I have a concern about the 'number of bits' being specified for logical and character variables. I can't remember how you use this information?

lib/read_only/Makefile Outdated Show resolved Hide resolved
lib/value_range_check/Makefile Outdated Show resolved Hide resolved
lib/value_range_check/value_range_check_base.jinja Outdated Show resolved Hide resolved
lib/value_range_check/value_range_check_base.jinja Outdated Show resolved Hide resolved
@hiker
Copy link
Collaborator Author

hiker commented Jan 9, 2025

Nice, small PR :-) Would it be possible to extend one of the examples to make use of/exercise this new functionality? Otherwise it's completely untested :-(

That was a bit of a headache, since neither gocean nor lfric support character strings. So I've added a new generic read-only verification library, and added an example as nemo/eg6. I couldn't add an examples that will actually throw an error (since PSyclone processes the file and does not support loc or sizeof, which was the trick I used in gocean). There is documentation how you can manually modify the psy file to trigger an error (but admittedly that's kind of stupid). Suggestions welcome.

Also, I have a concern about the 'number of bits' being specified for logical and character variables. I can't remember how you use this information?

I have also refactored all of that, so no more bits specified. Unfortunately, all of that that made this PR somewhat bigger :)


This will create a library called ``lib_read_only.a``.
An executable example for using the generic read-only-verification
library is included in ``examples/gocean/eg6/``.
Copy link
Member

Choose a reason for hiding this comment

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

nemo/eg6 rather than gocean?

# Author: A. R. Porter, STFC Daresbury Lab
# Modified J. Henrichs, Bureau of Meteorology

# Makefile for the 5th NEMO example. Uses PSyclone (which must
Copy link
Member

Choose a reason for hiding this comment

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

First sentence is wrong (and could just be removed).

@@ -0,0 +1,98 @@
# PSyclone NEMO Example 6 - Read-only Verification
Copy link
Member

Choose a reason for hiding this comment

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

Please add a brief section to examples/nemo/README.md to mention this new example.

@@ -783,6 +783,14 @@ compilation instructions are in the ``README.md`` file, including how
to switch from using the stand-alone extraction library to the NetCDF-based
one (see :ref:`extraction_libraries` for details).

Example 6: Read-only Verification
Copy link
Member

Choose a reason for hiding this comment

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

I realise we have duplication between this text and the markdown README files. If you're feeling keen, we could experiment with removing this section and replacing it with an include of the appropriate README. Sphinx's include directive supports a 'parser' option which apparently allows this (https://docutils.sourceforge.io/docs/ref/rst/directives.html#include-options). However, now that I write all that, I think perhaps that would be a separate issue.

If you copy the lines 32 and 33 from ``dummy.f90`` into ``psy.f90``,
the code will modify ``logical_var`` (by using out-of-bound array accesses.
Or you could just manually set ``logical_var = .true.``). If you then
compile again, an error will be produced.
Copy link
Member

Choose a reason for hiding this comment

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

This worked for me. Good stuff. Only wrinkle is that doing make compile again ran PSyclone and over-wrote my modified psy.f90 file. I had to cut-n-paste the compile and link lines to build with the modified psy.f90 file. Not a biggie. Either mention it here or perhaps it's just a small tweak to the Makefile?

@@ -0,0 +1,35 @@
program dummy
Copy link
Member

Choose a reason for hiding this comment

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

Please add the ususal license and a brief comment summarising the purpose of this file.

Copy link
Member

Choose a reason for hiding this comment

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

You could take the opportunity to say this is really just about exercising aspects of the read-only verification library.

# -----------------------------------------------------------------------------
# Author: J. Henrichs, Australian Bureau of Meteorology


Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment saying that this Makefile is for the read-only checking lib for generic Fortran code.

# Read-only Verification Library for Generic Fortran Code

This library implements the [PSyData API](
https://psyclone.readthedocs.io/en/latest/psy_data.html#read-only-verification-library-for-gocean)
Copy link
Member

Choose a reason for hiding this comment

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

This link is for gocean. Is that deliberate?

The compilation process will create the wrapper library ``lib_read_only.a``.

Similar to compilation of the [examples](
https://psyclone.readthedocs.io/en/latest/examples.html#compilation), the
Copy link
Member

Choose a reason for hiding this comment

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

Should be tutorials_and_examples.html I think.

lib/value_range_check/value_range_check_base.jinja Outdated Show resolved Hide resolved
Copy link
Member

@arporter arporter left a comment

Choose a reason for hiding this comment

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

Thanks very much Joerg. Just a few minor things now.
In testing the compilation of the examples I discovered that the xdsl Makefile was broken (spaces instead of tabs) so I've taken the liberty of fixing that and pushed it on your branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LFRic Issue relates to the LFRic domain PSyData reviewed with actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants