Skip to content

Remove dead ACC loop directives in s_derive_center_of_mass#1282

Draft
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix/dead-acc-loop-directives
Draft

Remove dead ACC loop directives in s_derive_center_of_mass#1282
sbryngelson wants to merge 1 commit intoMFlowCode:masterfrom
sbryngelson:fix/dead-acc-loop-directives

Conversation

@sbryngelson
Copy link
Member

Summary

  • In s_derive_center_of_mass (m_derived_variables.fpp), two $:GPU_LOOP(parallelism='[seq]') directives appeared before the c_m zero-initialization loops, outside any GPU parallel region.
  • These expanded to !$acc loop seq with no surrounding !$acc parallel/!$acc kernels, so the compiler silently ignored them. CCE 19.0.0 correctly warns: ftn-7255: loop marked for accelerator worksharing but not inside an accelerator region.
  • The initialization runs on CPU and is pushed to device via the existing $:GPU_UPDATE(device='[c_m]') immediately after — the structure is correct, the directives were just dead code.
  • Replace the 7-line nested loop with c_m(:, :) = 0.0_wp, which is idiomatic Fortran and eliminates the spurious directives.

Test plan

  • Verify ftn-7255 warning is gone from the CCE 19.0.0 (cpe/25.03) build of simulation
  • Confirm s_derive_center_of_mass produces identical results (center-of-mass values unchanged)

🤖 Generated with Claude Code

The two $:GPU_LOOP(parallelism='[seq]') directives before the c_m
zero-initialization loops in s_derive_center_of_mass were outside
any GPU parallel region and were silently ignored by the compiler
(CCE 19.0.0 warns ftn-7255: "loop marked for accelerator worksharing
but not inside an accelerator region").

The initialization runs on CPU before the GPU_UPDATE that pushes c_m
to device. Replace the nested loop with a simple Fortran array
assignment, which is idiomatic and eliminates the dead directives.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 1, 2026

Claude Code Review

Head SHA: b1dc5c9

Files changed: 1

  • src/simulation/m_derived_variables.fpp

Summary:

  • Removes 7 lines of dead GPU loop directives and replaces them with 1 idiomatic Fortran array assignment
  • The original code used $:GPU_LOOP(parallelism='[seq]') directives outside any GPU parallel region — they expanded to dangling ! loop seq without a surrounding ! parallel/! kernels, making them no-ops that triggered a CCE 19.0.0 compiler warning (ftn-7255)
  • The replacement c_m(:, :) = 0.0_wp is correct Fortran, removes the spurious directives, and leaves the existing $:GPU_UPDATE(device='[c_m]') downstream untouched — the semantics are unchanged
  • Net change: -6 lines, cleaner code, silences a legitimate compiler warning

Findings:

No issues found. The change is correct and minimal.

Improvement opportunities (optional):

  • None — this is as clean as it gets for this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant