# Test of the adjoint and of the linear-tangent#

## Description#

For every inversion case study, it is necessary to compute a test of the adjoint before running a full variational inversion. It allows to detect any error specifi to your test case and that were never met before. If the computation costs of the inversion set-up are very high, it is possible to execute a adjoint test with a simplified set-up, but it is important to include configurations that can generate errors (month of February, several months/years in a row, etc.).

This test consists in checking that: $$\langle \mathcal{H}(\delta \mathbf{x}) \vert \mathcal{H}(\delta \mathbf{x}) \rangle = \langle \delta \mathbf{x} \vert \mathcal{H}^* \circ \mathcal{H}(\delta \mathbf{x}) \rangle$$.

$$\mathcal{H}(\delta \mathbf{x})$$ is computed with the tangent linear model, and then $$\mathcal{H}^*\circ \mathcal{H}(\delta \mathbf{x})$$ is calculated with the adjoint.

In principle, the two terms of the equation are never exactly equal. Nevertheless, the difference should never exceed several times the machine accuracy.

## Configuration#

The following Yaml template is valid for the adjoint test:

mode:
plugin:
name: adj-tl_test
version: std

# Magnitude of the increment for dx
increments: 0.2

# (optional) Type of increments:
# - 'cst' for all equal to 'increments';
# - 'rand' for a centered normal distribution with magnitude 'increments'
# Default is 'cst' if not specified
incrmode: cst

# Testing space. Should be one of: control, chi
testspace: chi


The Yaml arguments are:

• increments: determines the value of $$\delta \mathbf{x}$$, which should be taken within a reasonable range around 0

• incrmode: the type of increments

• should be one of: cst, rand

• the default value is cst if not specified

• if cst all elements of $$\delta \mathbf{x}$$ are set to the same value

• if rand elements of $$\delta \mathbf{x}$$ follow a centered normal distribution with standard deviation increments

• it is recommended to execute an adjoint test with both mode to make sure that some errors do not compensate each other

• testspace: testing space

• should be one of: control, chi; default is control when not specified

• if control the test is applied to $$\delta \mathbf{x}$$ in the control space

• if chi the test is computed in the minimization space on $$\delta \mathbf{\chi}$$; it allows validating operations at the control space level, e.g., $$\delta \mathbf{x} \rightarrow \mathbf{B}^{1/2} \delta \mathbf{x}$$

## Requirements#

The adjoint test requires the following plugins to be executed properly:

1. an observation operator to compute $$\mathbf{x} \rightarrow \mathcal{H}(\mathbf{x})$$ and its adjoint; optional: default is (standard, std)

2. a control vector to define the control vector shape and corresponding operations; mandatory

3. an observation vector to define observations to be compared with; mandatory

The following plugins are indirectly needed to compute the test of the adjoint, through the observation operator (see details here):

1. a numerical model; mandatory