Skip to content

Add sfincs_timers module and enhance logging output - #353

Open
maartenvanormondt wants to merge 7 commits into
mainfrom
timers_log
Open

Add sfincs_timers module and enhance logging output#353
maartenvanormondt wants to merge 7 commits into
mainfrom
timers_log

Conversation

@maartenvanormondt

Copy link
Copy Markdown
Contributor

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:

  • Introduced a new sfincs_timers module for unified timing; all previous manual system_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 with timer_start and timer_stop calls. 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]
  • Subroutine signatures for update routines (e.g., update_boundaries, update_discharges, update_infiltration_map, compute_water_levels, bathtub_compute_water_levels) are simplified by removing tloop arguments, since timing is now handled internally. [1] [2] [3] [4] [5]

Code and Variable Cleanup:

  • Removed obsolete or redundant variables related to manual timing (e.g., count0, count1, count_rate, count_max, tloop, and related arrays/variables from sfincs_data.f90 and sfincs_lib.f90). [1] [2] [3] [4] [5]
  • Updated the timer subroutine in sfincs_date.f90 to use 64-bit integers for improved timing accuracy.

Logging Improvements:

  • Replaced the verbose ASCII-art startup log in sfincs_lib.f90 with a call to a new write_startup_log routine, and moved process summary logging to a new write_processes_log routine for better clarity and maintainability. [1] [2]

Build and Project File Updates:

  • Added sfincs_timers.f90 to 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.

maartenvanormondt and others added 3 commits July 13, 2026 15:51
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_timers module (named timers built on omp_get_wtime) and wired it into the main driver and multiple physics/update routines.
  • Simplified many subroutine interfaces by removing tloop timing arguments and replacing manual timing accumulation with timer_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.

Comment thread source/src/sfincs_log.f90 Outdated
Comment thread source/src/sfincs_log.f90
Comment thread source/src/snapwave/snapwave_solver.f90 Outdated
Comment thread source/src/sfincs_snapwave.f90 Outdated
maartenvanormondt and others added 2 commits July 13, 2026 18:35
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>
@maartenvanormondt
maartenvanormondt requested a review from Leynse July 13, 2026 20:15
@Leynse Leynse added this to the v2.4.1 milestone Jul 15, 2026
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.

4 participants