TerraFlow (version 1.0): a differentiable multi-backend nonhydrostatic atmospheric dynamical core on unstructured spherical meshes
Abstract. Atmospheric modeling increasingly requires dynamical cores that combine efficient simulation with gradient computation for sensitivity analysis and parameter estimation. To address these needs, we present TerraFlow (version 1.0), a differentiable, multi-backend nonhydrostatic atmospheric dynamical core that supports both JAX and PyTorch on unstructured spherical meshes. Built on a layer-averaged finite-volume formulation in a dry-mass vertical coordinate, TerraFlow uses a common array and state-update interface to execute the same numerical operators with either backend. This design brings automatic differentiation, just-in-time compilation, and graphics processing unit (GPU) acceleration across both backends together with distributed forward integration through the Message Passing Interface in a unified framework. Five idealized tests evaluate the model's numerical performance, demonstrating that it reproduces the principal features of passive-tracer transport, large-scale rotational flow, and nonhydrostatic gravity waves. To assess local derivative accuracy, we use finite-difference comparisons and Taylor remainder tests in short nonhydrostatic integrations. For both backends, directional derivatives computed by automatic differentiation agree with centered finite-difference estimates to relative errors below 10−4 for all tested output fields over suitable perturbation ranges, and the loss Taylor remainders exhibit second-order convergence. The resulting gradients support a successful inversion that recovers two prescribed initial potential-temperature perturbation amplitudes from noise-free synthetic observations in six updates. Computational efficiency is assessed separately through double-precision hydrostatic benchmarks, in which one NVIDIA RTX 4090 achieves forward-integration speedups of approximately 2.3–7.0 relative to corresponding runs on 10 central processing unit (CPU) nodes with 2560 cores in total, excluding compilation, model construction, and output. By bringing efficient forward simulation and verified local differentiation into a shared numerical implementation, TerraFlow provides a common framework for atmospheric sensitivity analysis and gradient-based parameter estimation across two computational backends.