CaMa‐PyTorch (v1.0): A New Catchment‐Based Macro‐Scale Floodplain Model Written in PyTorch
Zenghui Liu, Qiyu Li, Qingliang Li, Zhongwang Wei, Cheng Zhang, Hua Yuan, Yunfeng Lv, Jingquan Ren, Xiaoming Shi, Yongjiu DaiAbstract
Accurate simulation of river discharge underpins hydrological research, climate‐impact assessment, and flood forecasting. CaMa‐Flood, a widely used global river‐routing model, applies physically based principles to represent water transport through river networks. However, its legacy Fortran implementation restricts compatibility with modern AI frameworks and prevents efficient GPU utilization. Here, we present CaMa‐PyTorch (v1.0), a Python reimplementation of CaMa‐Flood v4.23 within PyTorch. A custom indexing scheme reproduces the flexible array operations of the Fortran model while preserving its river network logic and core algorithms. We evaluated numerical fidelity through modular tests and a continuous simulation over the continental United States at 0.0833° resolution from 2005 through 2010. Daily streamflow observations from the Global Runoff Data Centre (GRDC) provided an external benchmark, and model behavior was assessed using hydrograph comparisons, residual analyses, spatial diagnostics, and standard performance metrics. Across these evaluations, CaMa‐PyTorch closely reproduced the temporal and spatial discharge patterns generated by the Fortran implementation. Its tensor architecture also supports parallel computation and GPU execution. As a proof‐of‐concept for machine learning interoperability, a long short‐term memory (LSTM) network was used to postprocess simulated discharge and improved predictive performance. This experiment demonstrates output level coupling with a PyTorch data‐driven module but does not constitute a fully differentiable modeling system. CaMa‐PyTorch therefore provides a numerically faithful and computationally flexible basis for large scale river modeling and future research on more closely integrated physical and data‐driven approaches.