Skip to content

orbit_timestep_fo leaves ierr undefined on success #505

Description

@krystophny

Bug

simple::orbit_timestep_fo declares ierr as intent(out) but does not assign
it when both fo_step and fo_to_gc return FO_OK.

At src/simple.f90:231-275, every failure/loss branch assigns ierr and
returns. The normal path updates z at lines 272-274 and then returns without
defining ierr.

Reproduction

Call the public wrapper on a valid initialized full-orbit state without relying
on a previous value:

integer :: ierr
call orbit_timestep_fo(fo, z, ierr)
print *, ierr

With a valid axisymmetric Boozer chartmap and a successful first step, a
standalone diagnostic built with GNU Fortran 16.1.1 received an arbitrary
nonzero integer even though the state advanced successfully. Calling the
underlying fo_step followed by fo_to_gc returned FO_OK for the same
state.

The production loop currently tends to mask this because its caller retains an
already-zero status variable. That is not valid for an intent(out) dummy:
the actual argument becomes undefined on entry and the procedure must define
it on every normal return path.

Expected behavior

Set ierr = 0 (or the public success constant, if one is introduced) on the
successful path before returning.

Add a test that initializes ierr to a nonzero sentinel, performs one valid
full-orbit step through orbit_timestep_fo, and requires both successful state
advance and ierr == 0.

Environment and evidence

  • SIMPLE revision: 10ac7e76f6159789bf2c38b4386a5fdbc3347bf8
  • compiler: GNU Fortran 16.1.1
  • source: src/simple.f90:231-275

No production source change is included in this report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions