Inner Product and Sanity Check:
The driver pert_roms.F can be used to perform inner product and sanity check. It is a measure of consistency between tangent linear and adjoint algorithms. It can be executed in two different modes:
(1) Multiple perturbation mode: The tangent linear and adjoint models are executed for each perturbed interior point, one point at the time. The standard input parameters ERstr and ERend are used to achive multiple executions of both model kernels. The value for ERend is re-writen internally to its appropriate value. The resulting tangent linear (T) and adjoint (A) N-by-N matrices yield a symmetric matrix, such that T - tanspose(A), is zero within round off. This is known as the inner product test and is activated with switch INNER_PRODUCT. This is a highly idealized test that can be run in 2D and 3D congurations using input scripts roms2d_inner.in and roms3d_inner.in. The results are analyzed using Matlab scripts adjoint2d.m and adjoint3d.m, respectively.
(2) Single perturbation mode: The tangent linear and adjoint models are excuted once for a single specified interior point. This option can be activated with switch SANITY_CHECK and can be done in any application. The only file needed is the nonlinear forward tracjectory NetCDF file. This test is more practical and inexpensive. It also test the algorithm selected by the application CPP options. The point to perturb can be specified at random in the standard input model script. Please specify interior point to pertub in the vector user as follows:
Code: Select all
user(1) => State variable ID to perturb:
[1] free-surface
[2] 2D u-momentum
[3] 2D v-momentum
[4] 3D u-momentum
[5] 3D v-momentum
[6] temperature
[7] salinity
user(2) => I-index to perturb
user(3) => J-index to perturb
user(4) => K-index to perturb (3D state fields)
grep "Sanity Check" MyLogFile
Gradient Check:
The driver grad_roms.F can be used to check the gradient (adjoint model) by using the same structure as that for variational data assimilation. It is a measure of the correctness of the tangent linear and adjoint models. It can be run with any application with the same set-up (nonlinear and tangent linear initial NetCDF files, observation NetCDF file) for incremental 4DVAR, but with GRADIENT_CHECK activated and IS4DVAR undefined.
Let's denote the state vector as s. The cost function is the given by J(s). Suppose we perturb s by pds where p is a scalar. Then, using Taylor expansion to first-order we have:
Code: Select all
J(s+pds) = J(s) + Transpose[grad(J)](pds)
Code: Select all
g(p) = [J(s+pds) - J(s)] / Transpose[grad(J)](pds)
and
h(p) = [g(p) - 1] / p
In the algorithm, the outer loop is used to perturb a particular tangent linear model state variable and the inner loop as the pertubation amplitude p, such that,
Code: Select all
p = 10 ** FLOAT(-inner)
The driver will report to standard output file. To see these values just type
grep "Gradient" MyLogFile
Tangent Linear Model Linearization Check
The tlcheck_roms.F driver can be used to check the linearization of the tangent linear model. It can be run with any application with the same set-up (nonlinear and tangent linear initial NetCDF files, observation NetCDF file) for incremental 4DVAR, but with TLM_CHECK activated and IS4DVAR undefined. This driver is similar to the gradient check, except that now both nonlinear and tangent linear initial conditions are pertubed.
Good Luck, H