Skip to content

Fix(#66): Initiate MPAs - #67

Open
cecilieha wants to merge 3 commits into
devfrom
bug/i66-mpas
Open

cecilieha wants to merge 3 commits into
devfrom
bug/i66-mpas

Conversation

@cecilieha

Copy link
Copy Markdown
Collaborator

Your commits explain the who, what, where and when of these changes. Your code shows the how. You do not need to reiterate this. This PR should complete the big picture by telling the why.

Justification

The MPAs were not initiated, due to predayt. this has been changed with tstop, and fixes the issue in NoBa.

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other change (if none of the other choices apply)

Further comments

If this is a New Feature, Breaking change, or a bug fix, the Atlantis Manual will need to be updated to reflect these changes.
Now would be a good time to create an issue in the Atlantis Manual repo and begin documenting your changes.

Reviewer instructions:

Assign at least 2 reviewers:

  • one of which should be a maintainer,
  • the others should be familiar with the subject changes. Please add these under the assignees field

Please detail the process reviewers will need to follow to properly test these changes. It is especially helpful to identify the exact code needed to conduct a local build/review/test and to specify any aspects of the testing that may not be obvious.

@cecilieha
cecilieha requested a review from jacobkasper June 22, 2026 08:37
@cecilieha
cecilieha changed the base branch from main to dev June 22, 2026 08:42
@cecilieha cecilieha added the bug Something isn't working label Jun 22, 2026
@jacobkasper

Copy link
Copy Markdown
Collaborator

is it recommended that i try this fix on my model version before approving the merge?

@cecilieha

Copy link
Copy Markdown
Collaborator Author

yes, this particular loop also includes displacement, so need to be sure that it doesn't break that.

@andybeet andybeet changed the title Bug/i66 mpas Bug(#66): Initiate MPAs Aug 13, 2026
@andybeet andybeet changed the title Bug(#66): Initiate MPAs Fix(#66): Initiate MPAs Nov 2, 2026
@jacobkasper

jacobkasper commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks Cecilie, good catch. I looked into why I don't see this in my model, and it comes down to the time step.

Why it depends on dt: Ecology_Time_Check() in attime.c sets predayt = dayt on the first step of each new day. So if (bm->dayt != bm->predayt) is false on the first step of every day. I ran that logic over 30 days:

dt steps guard true
6 h 120 90
12 h 60 30
24 h 30 0

At 12 h (SETas and my model), Check_For_Active_MPA() still runs once a day, so MPAs switch on, at most half a day late. At 24 h it never runs. I'm guessing NoBa runs at 24 h?

Concerns with the current fix:

  1. tstop is in seconds (while (bm.t < bm.tstop)) and dayt is in days. So dayt != tstop is effectively always true. It fixes the bug by removing the guard, not by testing for a new day.
  2. As you suspected, displacement is affected. In the !EffortModelsActive branch, bm->Effort isn't reset between steps. Effort[ij] *= F_rescale and Effort[new_fish_loc] += F_displaced compound on every call, and the result goes straight into F as Displace_rescale in atHarvestCatch.c. With this change:
    • 24 h models with flagdisplace = 1 go from no displacement to compounding displacement every step. Receiving boxes have no upper limit.
    • 12 h models run displacement twice as often as now, so their results change too.
  3. The same guard is at atManage.c:360 in the effort-model branch, so models with effort models at 24 h still never activate MPAs.

Suggestion: add a proper new-day flag in attime.c, set inside the thisday >= lastday + 1.0 block like newweek/newmonth, and use it in both places. That keeps the once-a-day behaviour at any dt and leaves 12 h models unchanged. The Effort compounding in the displacement loop is probably worth its own issue.

Small things: please remove the commented-out //CH line, add Fixes #66 to the description, add a CHANGELOG entry, and use a commit subject like [Manage] Fix MPAs never activating with 24h dt.

Test suggestion: run SETas with dt 24 hour and one MPA closed. Compare dev with this branch, with and without flagdisplace. Also check that a 12 h SETas run is unchanged by the fix.


@cecilieha

Copy link
Copy Markdown
Collaborator Author

Hi jacob, i've fixed accordingly to your suggestions, and updated the changelog. great if you can have another look!

@jacobkasper

Copy link
Copy Markdown
Collaborator

HI Cecilie, Can you please check your commit? I don't see any new changes.
image

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants