Skip to content

Refactor adapters and simplify output handling with new helpers#8

Merged
JoshCu merged 9 commits into
mainfrom
CI
Mar 6, 2026
Merged

Refactor adapters and simplify output handling with new helpers#8
JoshCu merged 9 commits into
mainfrom
CI

Conversation

@JoshCu

@JoshCu JoshCu commented Mar 6, 2026

Copy link
Copy Markdown
Owner
  • abstract bmi adapter boilerplate to shared helper functions
  • merge different runner types
  • split up load_model into smaller functions
  • add DivideDataStore trait for a generic to use when reading and writing catchment data of different types
  • tidy up netcdf writing
  • add unit tests for output formats
  • simplify readme, move details to docs

JoshCu and others added 8 commits March 6, 2026 12:57
- Add function_failed() and not_implemented() helpers to error.rs
- Add to_cstring(), verify_config_path(), and impl_bmi_drop! macro to adapters/mod.rs
- Update all adapters (c.rs, fortran.rs, python.rs, sloth.rs) to use helpers
- Update output modules and resample.rs to use function_failed helper
- Add TODO comments for get/set_value generic helper in c.rs and fortran.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…TIMESTEP_EPSILON

- Merge print_active_conversions() and print_all_unit_info() into print_unit_conversions(active_only)
- Replace all BmiError::FunctionFailed constructions with function_failed() helper
- Replace scattered magic epsilon values (1e-9, 1e-12) with TIMESTEP_EPSILON constant

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…_unit_conversions

Break the 147-line load_model method into focused helper methods:
- create_adapter: adapter selection and initialization
- query_model_timestep: timestep querying with fallback
- build_unit_conversions: unit conversion table construction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create DivideDataStore trait in output/mod.rs for unified per-location writes
- Add CsvStore (output/csv.rs) implementing DivideDataStore
- Add DivideDataStore impl for NetCdfWriter
- Add ZarrStore wrapper with DivideDataStore impl
- Replace run_worker_csv, run_worker_netcdf, run_worker_zarr with single
  run_worker loop using Box<dyn DivideDataStore>
- Extract collect_columns helper to eliminate 3x duplication
- Move format_epoch from main.rs to output/csv.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The init_netcdf + write_batch pattern was copy-pasted 4 times across
the match arms. Extract into a flush_batch closure and merge the
Shutdown and Disconnected arms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests write synthetic data (2 locations, 3 variables, 25 timesteps) through
each DivideDataStore implementation, read it back, and verify:
- Per-format roundtrip correctness (CSV, NetCDF, Zarr)
- Cross-format equivalence (all formats produce the same data within
  f32 precision tolerance)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
README reduced from 468 to 93 lines, keeping only essentials:
- Project description, building, usage, config example, output formats

Detailed content moved to:
- docs/configuration.md - field reference tables, library usage
- docs/module-types.md - bmi_c, bmi_fortran, bmi_python, SLOTH
- docs/features.md - unit conversion, aliases, dependency resolution
- docs/netcdf-forcing.md - NetCDF forcing file format spec

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JoshCu
JoshCu force-pushed the CI branch 2 times, most recently from 47a47dd to 272c045 Compare March 6, 2026 22:28
@JoshCu
JoshCu merged commit 3f518cd into main Mar 6, 2026
1 check passed
@JoshCu
JoshCu deleted the CI branch April 7, 2026 16:51
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.

1 participant