A Rust implementation of Muskingum-Cunge channel routing for NextGen hydrological modeling frameworks, inspired by t-route.
- Multiple routing kernels: Pure Rust, modernized Fortran (t-route), legacy Fortran (t-route), and C implementations
- Parallel wave-front routing: Processes independent network branches concurrently using topological ordering
- NetCDF and CSV output: Produces t-route-compatible NetCDF output files
- GeoPackage input: Reads network topology and channel parameters from NextGen hydrofabric GeoPackage databases
src/
├── main.rs # Entry point and simulation orchestration
├── cli.rs # Command-line interface (clap)
├── config.rs # Configuration structures
├── network.rs # Network topology and database operations
├── state.rs # Node status tracking
├── routing.rs # Parallel wave-front routing engine
├── io/
│ ├── csv.rs # CSV reading/writing
│ ├── netcdf.rs # NetCDF output
│ └── results.rs # Simulation results storage
└── kernel/
└── muskingum/
├── mod.rs # Kernel dispatcher
├── rs_route/
│ └── mc_kernel.rs # Pure Rust Muskingum-Cunge implementation
├── t_route.rs # Fortran t-route FFI bindings
├── t-route/ # Fortran source (modernized + legacy)
├── c_mc.rs # C Muskingum-Cunge FFI bindings
└── c_mc/ # C source
libhdf5-devlibnetcdf-devlibsqlite3-devgfortrangcc
On Ubuntu/Debian:
sudo apt install -y libhdf5-dev libnetcdf-dev libsqlite3-dev gfortran gccRequires Rust 1.85+ (edition 2024). Install via rustup.
# Build in release mode
cargo build --release
# Run routing on a NextGen output directory
cargo run --release -- <path/to/ngen-run-directory>Usage: rs-route [OPTIONS] <ROUTE_DIR>
Arguments:
<ROUTE_DIR> Path to NextGen run directory
Options:
-i, --internal-timestep-seconds <N> Internal routing timestep in seconds [default: 300]
-k, --kernel <KERNEL> Routing kernel to use [default: t-route-modernized]
[possible values: route-rs, t-route-modernized,
t-route-legacy, c-muskingum-cunge]
The target directory should follow the NextGen output convention:
<route_dir>/
├── config/
│ └── *.gpkg # Hydrofabric GeoPackage
└── outputs/
├── ngen/ # NextGen model output CSVs (cat-*.csv)
└── troute/ # Routing output directory
cargo testA small test dataset is included in tests/one_cat/ for integration testing.