Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix indivisible reduction periods warning #3408

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Conversation

haakon-e
Copy link
Member

@haakon-e haakon-e commented Oct 29, 2024

As far as I can tell, #3396 implemented the warning for indivisible frequencies incorrectly.

e.g., if

periods_reductions = Set([Dates.Second(3600)])  # every hour
checkpoint_frequency = Dates.Millisecond(1800000)  # every 30 minutes, i.e. the value of dt_save_state_to_disk

I currently get the warning: Warning: Some accumulated diagnostics might not be evenly divisible by the checkpointing frequency (30 minutes)

but, unless I am misunderstanding what's going on here, this should be perfectly fine.


This PR essentially reverses the order of the arguments to CA.isdivisible so that we now have:

if any(
    x -> !CA.isdivisible(x, checkpoint_frequency),
    periods_reductions,
)
    accum_str = join(CA.promote_period.(collect(periods_reductions)), ", ")
    checkpt_str = CA.promote_period(checkpoint_frequency)
    @warn "Diagnostics are accumulated at frequencies ($accum_str), which may not be evenly divisible by the checkpointing frequency (dt_save_state_to_disk = $checkpt_str)"
end

@Sbozzolo
Copy link
Member

I think the warning is correct: if you have hourly diagnostics, but checkpoints every 30 minutes, you could restart the simulation from an invalid state if you restart from odd checkpoints.

@haakon-e
Copy link
Member Author

I see. So I did indeed misunderstand it then. I think I got caught up in the phrasing

Some accumulated diagnostics might not be evenly divisible by the checkpointing frequency

suggesting that we check if (accumulated diagnostics) / (checkpointing frequency) is an integer, but we actually do the opposite.

@Sbozzolo
Copy link
Member

I think you are right. Feel free to flip the phrasing in this PR.

@haakon-e
Copy link
Member Author

haakon-e commented Oct 29, 2024

something like this?

"The checkpointing frequency (dt_save_state_to_disk = $checkpt_str) should be an integer multiple of all diagnostics accumulation periods ($accum_str) to simulations can be safely restarted from any checkpoint"

@Sbozzolo Sbozzolo added this pull request to the merge queue Oct 29, 2024
Merged via the queue into main with commit 3f4a24a Oct 29, 2024
16 checks passed
@Sbozzolo Sbozzolo deleted the he/diag-reductions-warning branch October 29, 2024 15:57
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.

2 participants