Skip to content

refactor: shared logger module and data verbosity for KIM and QL-Balance#121

Merged
marjohma merged 11 commits intomainfrom
feature/io-refactor
Mar 26, 2026
Merged

refactor: shared logger module and data verbosity for KIM and QL-Balance#121
marjohma merged 11 commits intomainfrom
feature/io-refactor

Conversation

@marjohma
Copy link
Copy Markdown
Member

Summary

Closes #116.

  • Add shared logger module (common/logger/logger_m.f90) with leveled output (SILENT → TRACE), format helpers (fmt_val), and a clean API (log_info, log_debug, log_warning, log_error, etc.)
  • Replace ad-hoc verbosity flags with two unified integer controls per code: log_level (console output) and data_verbosity (HDF5/file output)
  • Migrate ~880 write/print statements across 25 source files (9 KIM, 16 QL-Balance) to use the logger module

Removed variables (clean break)

Code Removed Replaced by
KIM fdebug, fstatus, fdiagnostics log_level, data_verbosity
QL-Balance debug_mode, diagnostics_output log_level, data_verbosity

Existing namelists must update these variable names. Format toggles (ihdf5IO, hdf5_output) and feature flags (suppression_mode, misalign_diffusion) are unchanged.

Test plan

  • make clean && make all — full clean build succeeds
  • All KIM tests pass (7/7)
  • All QL-Balance tests pass except test_rhs_balance (pre-existing failure on main)
  • No references to old variables remain (grep verified)
  • CI build-and-test passes
  • Golden record test passes with new data_verbosity variable

🤖 Generated with Claude Code

marjohma and others added 11 commits March 25, 2026 14:14
Design document for issue #116. Introduces a shared logger module in
common/logger/ with leveled output (SILENT→TRACE), format helpers, and
a separate data_verbosity integer for HDF5 output control.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Detailed task-by-task plan for issue #116: shared logger module,
config variable migration, source file migration for KIM and
QL-Balance, Python interface and golden record test updates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New common/logger/logger_m.f90 provides:
- Log levels: SILENT, RESULT, ERROR, WARNING, INFO, DEBUG, TRACE
- Leveled output: log_error, log_warning, log_info, log_debug, log_trace
- Format helpers: fmt_val overloaded for real, integer, logical, string

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…a_verbosity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…l and data_verbosity

WIP: source files still reference old variables, will be migrated next.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Convert write/print statements across 9 KIM source files to use
logger_m calls. Replace fdebug/fstatus guards with log_info/log_debug/
log_trace, fdiagnostics guards with data_verbosity checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Convert write/print statements across 16 QL-Balance source files to
use logger_m calls. Replace debug_mode guards with log_debug,
diagnostics_output guards with data_verbosity checks. Convert
read_config.f90 display block to fmt_val calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The golden record test uses main's namelist template (which has
diagnostics_output) for the reference run, and the current branch's
template (which has data_verbosity) for the comparison run. Set the
correct key based on what's in the loaded template.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marjohma marjohma merged commit b1f5876 into main Mar 26, 2026
1 check passed
@marjohma marjohma deleted the feature/io-refactor branch March 26, 2026 10:22
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.

Refactor IO in QL-Balance and KIM

1 participant