Add sfincs_timers module and enhance logging output - #353
Open
maartenvanormondt wants to merge 7 commits into
Open
Add sfincs_timers module and enhance logging output#353maartenvanormondt wants to merge 7 commits into
maartenvanormondt wants to merge 7 commits into
Conversation
Extracted from the urban_drainage branch: the timing and logging rework only. New sfincs_timers module (named wall-clock timers with timer_start/timer_stop/timer_elapsed) replaces the scattered tloop*/system_clock bookkeeping; timed subroutines lose their tloop arguments. sfincs_log gains fmt_real (leading-zero real formatting) and the startup banner, processes list, progress reporter, finish summary, per-timer summary and runtimes.txt writer moved out of sfincs_lib. Urban-drainage related timers and process lines are not part of this branch; they live on the qsrc branch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Update PlatformToolset from v143 to v145 for both Debug and Release x64 configurations in the netcdff_c Visual Studio project.
There was a problem hiding this comment.
Pull request overview
This PR introduces a centralized timing facility (sfincs_timers) and refactors core SFINCS routines to use named timers instead of scattered system_clock bookkeeping, while also consolidating user-facing logging into sfincs_log.
Changes:
- Added
sfincs_timersmodule (named timers built onomp_get_wtime) and wired it into the main driver and multiple physics/update routines. - Simplified many subroutine interfaces by removing
tlooptiming arguments and replacing manual timing accumulation withtimer_start/timer_stop. - Refactored logging: moved startup/process/progress/finished and runtime-summary output into
sfincs_log, and updated netCDF runtime output to use timer data.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| source/third_party_open/netcdf/netcdf-fortran-4.6.1/netcdff_c.vcxproj | Updates MSBuild toolset version used for the netCDF-Fortran static library project. |
| source/src/snapwave/snapwave_solver.f90 | Updates local timer helper to use 64-bit system_clock counters. |
| source/src/sfincs_wavemaker.f90 | Switches wavemaker timing from system_clock accumulation to sfincs_timers. |
| source/src/sfincs_timers.f90 | New module providing named wall-clock timers and iteration APIs for summaries. |
| source/src/sfincs_structures.f90 | Replaces manual timing in structure flux calculations with sfincs_timers. |
| source/src/sfincs_snapwave.f90 | Removes tloop argument and adds sfincs_timers instrumentation around SnapWave coupling. |
| source/src/sfincs_output.f90 | Replaces output routine timing accumulation with sfincs_timers and simplifies interfaces. |
| source/src/sfincs_nonhydrostatic.f90 | Removes tloop argument and instruments non-hydrostatic solver with sfincs_timers. |
| source/src/sfincs_ncoutput.F90 | Writes total runtime to netCDF outputs using timer_elapsed('simulation'). |
| source/src/sfincs_momentum.f90 | Removes tloop argument and instruments momentum computations with sfincs_timers. |
| source/src/sfincs_meteo.f90 | Removes tloop arguments and instruments meteo update routines with sfincs_timers. |
| source/src/sfincs_log.f90 | Major refactor: centralizes formatted log output, progress reporting, and timer summaries/runtimes output. |
| source/src/sfincs_lib.f90 | Main driver refactor: swaps manual system_clock bookkeeping for named timers and new log helpers; updates call sites for new signatures. |
| source/src/sfincs_infiltration.f90 | Removes tloop argument and instruments infiltration updates with sfincs_timers. |
| source/src/sfincs_discharges.f90 | Removes tloop argument and instruments discharge updates with sfincs_timers. |
| source/src/sfincs_date.f90 | Updates timer helper to use 64-bit system_clock counters. |
| source/src/sfincs_data.f90 | Removes obsolete global timing variables no longer needed after timer refactor. |
| source/src/sfincs_continuity.f90 | Removes tloop argument and instruments continuity update with sfincs_timers. |
| source/src/sfincs_boundaries.f90 | Removes tloop argument and instruments boundary updates with sfincs_timers (conditional on boundaries being active). |
| source/src/sfincs_bathtub.f90 | Removes tloop argument and instruments bathtub continuity timing via sfincs_timers. |
| source/src/Makefile.am | Adds sfincs_timers.f90 to build sources. |
| source/sfincs_lib/sfincs_lib.vfproj | Adds sfincs_timers.f90 to Visual Fortran project file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the SFINCS codebase to introduce a new timing utility module (
sfincs_timers) and replaces all manual timing logic with standardized timer calls. It also cleans up obsolete variables and code, simplifies subroutine interfaces by removing unused timing arguments, and consolidates logging routines for better maintainability and readability.Timing and Performance Measurement:
sfincs_timersmodule for unified timing; all previous manualsystem_clock-based timing in core routines (sfincs_lib.f90,sfincs_bathtub.f90,sfincs_boundaries.f90,sfincs_continuity.f90,sfincs_discharges.f90,sfincs_infiltration.f90) is replaced withtimer_startandtimer_stopcalls. This standardizes and simplifies performance measurement across the codebase. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]update_boundaries,update_discharges,update_infiltration_map,compute_water_levels,bathtub_compute_water_levels) are simplified by removingtlooparguments, since timing is now handled internally. [1] [2] [3] [4] [5]Code and Variable Cleanup:
count0,count1,count_rate,count_max,tloop, and related arrays/variables fromsfincs_data.f90andsfincs_lib.f90). [1] [2] [3] [4] [5]timersubroutine insfincs_date.f90to use 64-bit integers for improved timing accuracy.Logging Improvements:
sfincs_lib.f90with a call to a newwrite_startup_logroutine, and moved process summary logging to a newwrite_processes_logroutine for better clarity and maintainability. [1] [2]Build and Project File Updates:
sfincs_timers.f90to the build system and project files to ensure the new timing module is compiled and available. [1] [2]These changes collectively improve code maintainability, make performance profiling more consistent, and clean up legacy timing and logging code.