Skip to content

feat(prt): configurable event buffering#2789

Open
wpbonelli wants to merge 7 commits into
MODFLOW-ORG:developfrom
wpbonelli:prt-event-buffer
Open

feat(prt): configurable event buffering#2789
wpbonelli wants to merge 7 commits into
MODFLOW-ORG:developfrom
wpbonelli:prt-event-buffer

Conversation

@wpbonelli
Copy link
Copy Markdown
Member

@wpbonelli wpbonelli commented Apr 24, 2026

Previously PRT model particle events were written to output file(s) immediately. This was a deliberate choice motivated by MP7 suffering OOM errors when consolidating internal scratch files before writing the final output file.

With GWF models using adaptive time stepping (ATS), or with multiple Picard iterations when PRT and GWF are in the same solution group, output would be written for discarded solve attempts. Events should only end up in output files for the final, successful solve.

To gate events until a successful solve, buffer them until it's known whether they should be written. Introduce two buffering strategies, in memory and scratch file, with a new OC option SCRATCH_BUFFER enabling the latter. Memory buffering is used by default.

Since the buffer could conceivably grow large for models with lots of particles or lots of action per time step (e.g., the final time step when extended tracking is on), the scratch file approach is provided to let the modeler avoid OOM errors at the price of more file IO.

While this departs from informal MF6 convention to avoid scratch files in general, it's a well motivated option, not on by default.

This is a pure refactor but for the new option, which I figure merits calling it a feature. It was split out of #2753. The retry misbehavior is fixed in that PR, not here.


Checklist of items for pull request

  • Replaced section above with description of pull request
  • Formatted new and modified Fortran source files with fprettify
  • Added doxygen comments to new and modified procedures
  • Updated develop.toml with a plain-language description of the bug fix, change, feature; required for changes that may affect users
  • Removed checklist items not relevant to this pull request

@wpbonelli wpbonelli added this to the 6.7.1 milestone Apr 24, 2026
@wpbonelli wpbonelli added enhancement code refactor Nonfunctional changes option MF6 IO related labels Apr 24, 2026
@wpbonelli wpbonelli marked this pull request as ready for review May 11, 2026 12:38
Comment thread src/Model/ParticleTracking/prt.f90
Comment thread src/Solution/ParticleTracker/Particle/ParticleTracks.f90
Comment thread src/Solution/ParticleTracker/Particle/ParticleTracks.f90 Outdated
Comment thread src/Solution/ParticleTracker/Particle/ParticleTracks.f90 Outdated
@Manangka
Copy link
Copy Markdown
Contributor

Hi @wpbonelli, I had a look at your PR and left some of my thoughts. Feel free to ignore any of my suggestions

@wpbonelli
Copy link
Copy Markdown
Member Author

thanks @Manangka good thoughts all.

@wpbonelli wpbonelli requested a review from aprovost-usgs May 11, 2026 20:25
Comment thread src/Solution/ParticleTracker/Particle/ParticleTracks.f90 Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code refactor Nonfunctional changes enhancement option MF6 IO related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants