Skip to content

Introduction of field API interface in ectrans#314

Open
dhaumont wants to merge 128 commits intoecmwf-ifs:developfrom
dhaumont:field_api_interface
Open

Introduction of field API interface in ectrans#314
dhaumont wants to merge 128 commits intoecmwf-ifs:developfrom
dhaumont:field_api_interface

Conversation

@dhaumont
Copy link
Copy Markdown
Contributor

@dhaumont dhaumont commented Sep 26, 2025

Summary

This PR introduces a field API interface to ectrans. It is based on top of dump-checksums (PR #287)

Description of changes

  • The new field API interface is implemented in src/field_api:

    • src/field_api/trans/inv_trans_field_api.F90: inverse transform (calling inv_trans internally)
    • src/field_api/trans/dir_trans_field_api.F90: direct transform (calling dir_trans internally)
    • src/field_api/field_api_ectrans_mod.F90: helper functions
  • Optional compilation triggered by a new USE_FIELD_API configuration option. Adds a new dependency to field API.

  • Single and double precision for CPU and GPU

  • Accessible in ectrans-benchmark via a new option --field-api

    • src/programs/util/ectrans_field_api_helper.F90 contains the field API implementation
  • In the GPU version of ectrans-benchmark , setting llacc = .true. will force the intermediate fields on GPU. This requires additional memory copies host <-> device before and after the regular ectrans calls.

  • New unit tests have been added to test --field-api (CPU and GPU)

  • compare_checksums.py updated to compare the checksums with field-api with the regular version

  • nvhpc22.11 on CPU: bit reproducibility between the field API and the regular version has been partially adressed by clamping small values in spectral space after dir_trans in ectrans benchmark (2a7aa87). This only applies to double precision (single precision is only bit reproducible during the first time step and slightly different after)

Testing and validation

  • ATOS:
    • Intel 2021.4.0 - CPU: bit reproducible
    • nvhpc 22.11 - CPU: dp : bit reproducible, sp: not reproducible
    • nvhpc 22.11 on GPU: bit reproducible
  • Ubuntu laptop
    *Gfortran 13.3.0 - CPU : bit reproducible

Known limitations

  • no LAM version
  • no openMP version ( OpenACC only)
  • The GPU version with llacc = .true. requires memory transfers between CPU and GPU, that should be avoided
  • for nvhpc 22.11, the CPU version in sp is not bit reproducible ( first time step is bit reproducible, tiny differences after first iteration)

Initial pull request

dhaumont#1
Contains some comments from @samhatfield that needs to be integrated

Prototype in ARPEGE

See for instance this prototype of transinv_mdl_field_api.F90: https://github.com/dhaumont/IAL/blob/50t1_field_api_ectrans/arpifs/transform/transinv_mdl_field_api.F90
This version can be compiled using this bundle:
50t1_ectrans_field_api_interface

samhatfield added a commit that referenced this pull request Apr 16, 2026
PR #314 begins the implementation of a Field API interface to ecTrans. This work must be tested using the build-hpc suite. But because the branch is hosted in an external repository, the build-hpc action is not taken from the source branch of the PR but rather the target branch (develop) (for security reasons). So, this PR enables the two features which enable the Field API feature to be tested in build-hpc. We commit them to develop, and then the build-hpc action run in PR #314 will inherit them. These two features should not have any effect when another branch is tested.
wdeconinck pushed a commit that referenced this pull request Apr 16, 2026
* Enable GPU_STATIC and FIELD_API features in build-hpc

PR #314 begins the implementation of a Field API interface to ecTrans. This work must be tested using the build-hpc suite. But because the branch is hosted in an external repository, the build-hpc action is not taken from the source branch of the PR but rather the target branch (develop) (for security reasons). So, this PR enables the two features which enable the Field API feature to be tested in build-hpc. We commit them to develop, and then the build-hpc action run in PR #314 will inherit them. These two features should not have any effect when another branch is tested.

* Move GPU_STATIC feature to toolchain

* Make sure Field API is also built

* Try not to build or enable Field API on LUMI

* Try fixing CI error

* Try again
@dhaumont
Copy link
Copy Markdown
Contributor Author

dhaumont commented Apr 16, 2026

@samhatfield @wdeconinck
I just reordered the arguments and remove the ones that could be inferred from array dimensions:
dhaumont#5
Could you review it before I merge it here ? Thanks

@samhatfield samhatfield force-pushed the field_api_interface branch from 2dc498c to 45af499 Compare April 17, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants