(1) In 2D and 3D configurations, the full adjoint barotropic solution is split between two time level indices. The value of these indices depend where you are in the code. Recall that ROMS/TOMS have a predictor/corrector scheme and there are three barotropic time indices: kstp, krhs, and knew. The values for these indices are cycled between 1, 2, and 3 in routine ad_main2d or ad_main3d. For example, when the output routine (ad_output) is called, at the bottom of ad_main2d or ad_main3d, the full adjoint solution is the sum of indices kstp and krhs in 2D applications and kstp and knew in 3D applications.
(2) In 3D applications, the value of the adjoint free-surface (ad_zeta) is zero out after a call to ad_rhs3d. Its value needs to be recoved from ad_Zt_avg1 by a call to ad_set_depth at the end of the backward time-stepping of the adjoint model. Notice that ad_ini_gather is called at the bottom of ad_main3d to do such task. As matter of fact, ad_ini_gather is the adjoint of ROMS/TOMS initialization procedure and has nothing do with ad_initial. This maybe a little confusing but we are talking here about the order of initialization tasks between forward and backward simulations. Notice that in the forward time-stepping the following tasks take place:
Code: Select all
(a) Set initial conditions to the following state variables at time index 1:
zeta(i,j,1) Free-surface
ubar(i,j,1) 2D u-momentum
vbar(i,j,1) 2D v-momentum
u(i,j,k,1) 3D u-momentum
v(i,j,k,1) 3D v-momentum
t(i,j,k,1,itrc) Active and passive tracers
(b) Impose boundary conditions on all state variables.
(c) Since the initial value of the free-surface (zeta) is known, set barotropic time-averaged free-surface (Zt_avg1) to that value and then compute level thicknesses (Hz) by a call to routine set_depth.
Good luck,