Skip to content

Implement workarounds for modern diag manager with NVHPC#1897

Draft
edoyango wants to merge 7 commits into
NOAA-GFDL:mainfrom
edoyango:nvhpc-modern-diag
Draft

Implement workarounds for modern diag manager with NVHPC#1897
edoyango wants to merge 7 commits into
NOAA-GFDL:mainfrom
edoyango:nvhpc-modern-diag

Conversation

@edoyango

@edoyango edoyango commented Jul 7, 2026

Copy link
Copy Markdown

Description

This PR is built on top of #1873

There are a couple compiler bugs in nvfortran that cause segfaults when using the modern diag manager. One is when sorting filenames (see #1895), and the other is when registering diagnostics (see #1896). This PR addresses them both with workarounds.

The filename sorting issue uses the workaround suggested by nvidia, which was to specify the input character length explicitly in fms_array_to_pointer, rather than using deferred shape arrays. This worked because the call sites passes arrays of character length 255. However, the test needed to be updated as the test passed in characters of length 10. This does reduce the flexibility of fms_array_to_pointer. An alternative workaround is to inline the routines manually (I think this would only be needed in two places).

The registration issue is addressed by changing explicit shape to deferred shape (same workaround as suggested in the issue).

Fixes #1895
Fixes #1896

How Has This Been Tested?

  • Running MOM6 double gyre with modern diag manager
  • Running diag manager tests with NVHPC 26.3 and GCC 15.2 and confirming no changes in pass/fails.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes
    • pass with GCC
    • fail with NVHPC
      • previously diag_yaml checks would hang, but now they pass (but fail). Next hang at reduction checks.

rem1776 and others added 7 commits May 14, 2026 15:38
Forwarding an absent optional class(*) actual into an explicit-shape dummy
varRANGE(2) makes nvfortran (NVHPC 26.3/26.5) emit an unconditional copy-in
from the absent descriptor, segfaulting register_static_field when the
optional range is omitted (nvbugs TPR #38728). Change the dummy to
assumed-shape varRANGE(:) in both fms_register_diag_field_obj entry points,
and enforce the size-2 contract explicitly now that the shape is no longer
fixed.
)

nvfortran (NVHPC 26.3/26.5) miscomputes the per-element c_loc offset for a
len=* assumed-shape character dummy, so c_loc(my_array(i)) is wrong for every
element past the first, corrupting the modern diag_manager file/variable sort
(nvbugs TPR #38727). Give the dummy an explicit element length
(character(len=FMS_MAX_FILE_LEN)) so the stride is computed correctly. This
requires callers to pass a matching len=FMS_MAX_FILE_LEN array; the two diag
callers already do, and the string_utils unit test is updated from len=10 to
len=FMS_MAX_FILE_LEN to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fms_diag_object%fms_register_static_field crashes with NVHPC fms_array_to_pointer returns garbage pointers with NVHPC

1 participant