Implementation of tangent linear and adjoint models for neural networks based on a compiler library tool
Sa XiaoHao JingHonglu SunHaoyu Li
Sa Xiao
Hao Jing
Honglu Sun
Haoyu Li
+4
TorchNWP is a compilation library tool that bridges Fortran-based numerical weather prediction models and Python-based deep learning frameworks. It converts PyTorch models into a static binary with C/C++ interfaces via LibTorch, enabling their deployment within numerical models using hybrid Fortran/C/C++ programming. Crucially, TorchNWP implements tangent linear and adjoint models for neural networks at the C/C++ level, shielding the network's internal structure to simplify the construction of four-dimensional variational data assimilation systems. This allows efficient coupling of deep learning parameterization schemes, such as radiation and gravity wave drag, into operational models like CMA-GFS, improving accuracy and efficiency with minimal code changes.

arXiv ·
· March 17, 2026