Skip to content

Conversation

@mo-mglover
Copy link
Collaborator

@mo-mglover mo-mglover commented Jan 9, 2026

Description

The change is a workaround for an apparent compiler bug.

Unallocated actual arguments passed to optional dummy arguments count as not present, according to the Standard. The code should behave the same way as if the argument was not passed at all. There was a transient runtime issue with one compiler, whereby such an argument was sometimes handled correctly and sometimes not. Crucially, it happens in the specific case where the actual argument is itself local to a subroutine (and does not have the save attribute).

The change in this PR makes the argument actually not present if unallocated, without relying on the compiler to treat it as such.

Linked issues

Closes #216

Type of change

Change should be transparent.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • New tests have been added
  • Tests have been modified to accommodate this change

Tag / no tag cases are already covered by the testing framework. Tested with the following skeleton program. With the issue being transient, ran the test many times. The output file produced was vernier-output-0 each time, with no strange characters. [Also tested with a tag, to check that functionality wasn't broken.]

program main
use vernier_mod
use mpi
implicit none

integer(kind=vik) :: vnr_handle

integer :: ierr

call mpi_init(ierr)
call vernier_init()

call vernier_start(vnr_handle, "main")
call sleep(1)
call vernier_stop(vnr_handle)

call vernier_write()
call vernier_finalize()

call mpi_finalize(ierr)

end program main

The GCC-13 + MPI tests failed the first time around. The address sanitizer reported memory leaks. Succeeded on rerun. Not clear that the failure was connected to the changes in this PR.

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation - none needed.
  • My changes generate no new warnings
  • have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes, for both debug and optimised builds

@mo-mglover mo-mglover self-assigned this Jan 9, 2026
@mo-mglover mo-mglover marked this pull request as ready for review January 9, 2026 15:21
Copy link
Collaborator

@andrewcoughtrie andrewcoughtrie left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@andrewcoughtrie andrewcoughtrie added this pull request to the merge queue Jan 20, 2026
Merged via the queue into MetOffice:main with commit d61f968 Jan 20, 2026
10 checks passed
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.

[Bug]: Corrupt output file names with CCE

2 participants