Recipes for adjoint code construction

Ralf Giering, T. Kaminski

ACM Transactions on Mathematical Software · 1998 · 854 citations · 25 references

DOIFull text

Open access

Concepts

TL;DR

Adjoint models, which compute gradients of cost functions with respect to control variables, are increasingly used in meteorology and oceanography for data assimilation, model tuning, sensitivity analysis, and singular vector determination, and their generation can be viewed as reverse‑mode differentiation of scalar‑valued functions. The paper proposes a method for adjoint code generation based on simple principles that enable straightforward construction rules for adjoint statements and full subprograms. The method introduces construction rules illustrated with examples and is implemented in the tangent linear and adjoint model compiler (TAMC). The authors note that loops and variable redefinitions cause conflicts, making manual adjoint coding time‑consuming and error‑prone, and demonstrate that automatic generation provides a clear advantage.

Abstract

Adjoint models are increasingly being developed for use in meteorology and oceanography. Typical applications are data assimilation, model tuning, sensitivity analysis, and determination of singular vectors. The adjoint model computes the gradient of a cost function with respect to control variables. Generation of adjoint code may be seen as the special case of differentiation of algorithms in reverse mode, where the dependent function is a scalar. The described method for adjoint code generation is based on a few basic principles, which permits the establishment of simple construction rules for adjoint statements and complete adjoint subprograms. These rules are presented and illustrated with some examples. Conflicts that occur due to loops and redefinition of variables are also discussed. Direct coding of the adjoint of a more sophisticated model is extremely time consuming and subject to errors. Hence, automatic generation of adjoint code represents a distinct advantage. An implementation of the method, described in this article, is the tangent linear and adjoint model compiler (TAMC).

References

25