Runtime checks for function space IDs on fields on ANY_SPACE passed to kernels

Open
#830 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
fortran, python
Domain
compilers

Research direction

Start by tracing built-in metadata parsing and PSy-layer generation, then compare the checks shown in the linked LFRic psykal_lite_mod example. Follow the RUN_TIME_CHECKS option and identify how function-space IDs are available for fields passed to ANY_SPACE_n kernels. Done means generated code detects mismatched spaces when enabled and avoids those checks when disabled, with corresponding tests.

Written by the indexing model from the issue text.

Description

bug LFRic

We currently do not check that function space IDs of the fields defined as ANY_SPACE_n in the kernel metadata are indeed on the same space.

One such example are built-ins. We check for the function spaces when parsing built-ins metadata (definition file in PSyclone). However, we currently do not generate PSy-layer code that would check the function space IDs of fields passed to built-in kernels. This leads to out-of-bounds errors in LFRic in full debug.

The examples of runtime function space ID checks can be found in LFRic psykal_lite_mod

    !sanity check
    undf = field1_proxy%vspace%get_undf()
    if(undf /= field2_proxy%vspace%get_undf() ) then
      ! they are not on the same function space
      call log_event("PSy:multiply_field_data:field1 and field2 live on different w-spaces" &
                    , LOG_LEVEL_ERROR)
      !abort
      stop
    endif
    if(undf /= field_res_proxy%vspace%get_undf() ) then
      ! they are not on the same function space
      call log_event("PSy:multiply_field_data:field1 and result_field live on different w-spaces" &
                    , LOG_LEVEL_ERROR)
      !abort
      stop
    endif

These checks can be turned off or on via the RUN_TIME_CHECKS option.

Dominant language
Python
Stars
137
Forks
36
Avg merge
6d 16h
Merged PRs (30d)
18

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stfc/PSyclone

All issues in stfc/PSyclone

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.