/[MITgcm]/manual/s_examples/global_oce_optim/global_oce_estimation.tex
ViewVC logotype

Contents of /manual/s_examples/global_oce_optim/global_oce_estimation.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Wed Aug 3 15:48:06 2005 UTC (18 years, 9 months ago) by edhill
Branch: MAIN
Changes since 1.5: +12 -11 lines
File MIME type: application/x-tex
 o fix italics

1 % $Header: /u/gcmpack/manual/part3/case_studies/global_oce_estimation/global_oce_estimation.tex,v 1.5 2005/08/02 21:49:07 dfer Exp $
2 % $Name: $
3
4 \section[Global Ocean State Estimation Example]{Global Ocean State Estimation at $4^\circ$ Resolution}
5 \label{www:tutorials}
6 \label{sect:eg-global_state_estimate}
7 \begin{rawhtml}
8 <!-- CMIREDIR:eg-global_state_estimate: -->
9 \end{rawhtml}
10
11 \subsection{Overview}
12
13 Mean surface heat flux as a control variable : $Q_\mathrm{netm}$
14
15 This experiment illustrates the optimization (or data-assimilation) capacity
16 of the MITgcm. Using an ocean configuration with realistic geography and bathymetry on a
17 $4\times4^circ$ spherical polar grid, we estimate a time-independent surface heat flux correction
18 $Q_\mathrm{netm}$ that brings the model climatology into consistency with observations (Levitus
19 climatology).
20
21 This correction $Q_\mathrm{netm}$ (a 2D field only function of longitude and latitude) is
22 the control variable of an optimization problem. It is inferred by an iterative
23 procedure using an `adjoint technique' and a least-squares method (see, for example,
24 Stammer et al. (2002) and Ferreira et al. (2005)).
25
26 The ocean model is run forward in time and the quality of the solution is
27 determined by a cost function, $J_1$, a measure of the departure of the model
28 climatology from observations:
29 \begin{equation}
30 J_1=\frac{1}{N}\sum_{i=1}^N \left[ \frac{\overline{T}_i-\overline{T}_i^{lev}}{\sigma_i^T}\right]^2
31 \end{equation}
32 where $\overline{T}_i$ is the averaged model temperature and $\overline{T}_i^{lev}$
33 the annual mean observed temperature at each grid point $i$. The differences
34 are weighted by an a priori uncertainty $\sigma_i^T$ on observations (Levitus
35 and Boyer 1994). The error $\sigma_i^T$ is only a function of depth and varies
36 from 0.5 at the surface to 0.05~K at the bottom of the ocean, mainly reflecting
37 the decreasing temperature variance with depth. A value of $J_1$ of order 1 means
38 that the model is, on average, within observational uncertainties.
39
40 The cost function also places constraints on the correction to insure it is
41 "reasonnable", i.e. of order of the uncertainties on the observed surface heat
42 flux:
43 \begin{equation}
44 J_2 = \frac{1}{N} \sum_{i=1}^N \left[\frac{Q_\mathrm{netm}}{\sigma^x_i} \right]^2
45 \end{equation}
46 where $\sigma^x_i$ are the a priori errors (2d field from ECCO ..... Fig ?).
47
48 The total cost function is obtained as $J=\lambda_1 J_1+ \lambda_2 J_2$ where
49 $\lambda_1$ and $\lambda_2$ are weights controlling the relative contribution
50 of the two mcomponents. The adjoint model then provides the sensitivities
51 $\partial J/\partial Q_\mathrm{netm}$ of $J$ relative to the 2D fields
52 $Q_\mathrm{netm}$. Using a line-searching algorithm (Gilbert and Lemar\'{e}chal 1989),
53 $Q_\mathrm{netm}$ is adjusted in the sense to reduce $J$ --- the procedure is
54 repeated until convergence.
55
56 In the following example, the configuration is identical to the "Global ocean circulation"
57 tutorial where more details can be found. In each iteration, the model is started from
58 rest with temperature and salinity initial conditions taken from Levitus dataset and run
59 for a year. The first guess $Q_\mathrm{netm}$ is chosen to be zero.
60
61 The experiment employs two executables: one for the MITgcm and its adjoints and
62 one for the line-search algorithmi (offline optimization). The implementation of
63 the control variable $Q_\mathrm{netm}$, the cost function $J$ and the I/O required
64 for the commmunication betwwen the model and the line-search are described in details
65 in section 2. The compilation of the two executables is given in section 3.
66 A method to run the experiment is described in section 4.
67
68 Gilbert, J. C., and C. Lemar\'echal, 1989: Some numerical experiments with
69 variable-storage quasi-Newton algorithms. \textit{Math. Programm.,}
70 \textbf{45,} 407-435.
71
72 \subsection{Implemention of the control variable and the cost function}
73
74 All subroutines that require modifications are found in verifications/Optim/code\_ad
75
76 \subsubsection{The control variable}
77
78 The correction $Q_\mathrm{netm}$ is activated by setting ALLOW\_HFLUXM\_CONTROL to "define" in ECCO\_OPTIONS.h.
79
80 It is first implemented as a forcing variable. It is defined in FFIELDS.h,
81 initialized to zero in ini\_forcing.F, and then used in external\_forcing\_surf.F.
82
83 $Q_\mathrm{netm}$ is made a control variable in the ctrl package by modifying the following subroutines:
84
85 \begin{itemize}
86 \item ctrl\_init.F where $Q_\mathrm{netm}$ is defined as the control variable number 24,
87
88 \item ctrl\_pack.F which writes, at the end of iteration, the sensitivity of the cost function
89 $\partial J/\partial Q_\mathrm{netm}$ into a file to be used by the lins-search algorithm,
90
91 \item ctrl\_unpack.F which reads, at the start of each iteration, the updated perturbations as
92 provided by the line-search algorithm,
93
94 \item ctrl\_map\_forcing.F where the updated perturbation is added to the first guess $Q_\mathrm{netm}$.
95 \end{itemize}
96
97 Note also some minor changes in ctrl.h, ctrl\_readparams.F, and ctrl\_dummy.h (xx\_hfluxm\_file,
98 fname\_hfluxm, xx\_hfluxm\_dummy).
99
100 \subsubsection{Cost functions}
101
102 The cost functions are implemented using the cost package.
103
104 \begin{itemize}
105
106 \item The temperature cost function $J_1$ which measures the drift of the mean model
107 temperature from the Levitus climatology is implemented cost\_temp.F. It is
108 activated by ALLOW\_COST\_TEMP in ECCO\_OPTIONS.h. It requires the mean temperature of
109 the model which is obtained by accumulating the temperature in cost\_tile.F (called at
110 each time step).
111 The value of the cost function is stored in objf\_temp and its weight $\lambda_1$
112 in mult\_temp.
113
114 \item The heat flux cost function penalizing the departure of the surface heat flux from
115 observations is implemented in cost\_hflux.F, and activated by activated
116 ALLOW\_COST\_HFLUXM in ECCO\_OPTIONS.h. The value of the cost function is stored in
117 objf\_hfluxm and its weight $\lambda_2$ in mult\_hfluxm,
118
119 \item The subroutine cost\_final.F calls the cost\_functions subroutines
120 and make the (weighted) sum of the different contributions.
121
122 \item The weights used in the cost functions are read is cost\_weights.F.
123 The weigth of the cost functions are read in cost\_readparams.F from the input file
124 data.cost.
125
126 \end{itemize}
127
128
129 \subsection{Code Configuration}
130 \label{www:tutorials}
131 \label{SEC:eg_fourl_code_config}
132
133 The model configuration for this experiment resides under the
134 directory {\it verification/???/}. The experiment files in code\_ad/
135 and input\_ad/ contain the code customisations and parameter settings
136 for this experiment. Most of them are identical to those used in
137 the Global ocean experiment. Below we describe the customisations to
138 these files associated with this experiment.
139
140 \subsubsection{File {\it input/data}}
141
142
143 \subsection{Compiling}
144
145 The optimization experiment requires two executables: 1) the
146 MITgcm and its adjoints (it{mitgcmuv\_ad}) and 2) the line-search
147 algorithm ({\it optim.x})
148
149 \subsubsection{Compilation of MITgcm and its adjoint: {\it mitcgmuv\_ad}}
150
151 Before compiling, first note that, in the directory code\_ad/, two files
152 must be updated:
153 \begin{itemize}
154 \item code\_ad\_diff.list which lists new subroutines to be compiled
155 by the TAF software (cost\_temp.f and cost\_hflux.f here),
156
157 \item the adjoint\_hfluxm files which provides a list of the control variables
158 and the name of cost function to the TAF sotware.
159
160 \end{itemize}
161
162 Then, in the directory build\_ad/, type:
163 \begin{verbatim}
164 % ../../../tools/genmake2 -mods=../code\_ad -adof=../code\_ad/adjoint\_hfluxm
165 % make depend
166 % make adall
167 \end{verbatim}
168 to generate the MITgcm executable mitgcmuv\_ad
169
170 \subsubsection{Compilation of the line-search algorithm: {\it optim.x}}
171
172 This is done from the directories lsopt/ and optim/ (under MITgcm/)
173
174 In lsopt/, unzip the blash1 library you need, and change accordingly the
175 library in the Makefile. Compile with:
176 \begin{verbatim}
177 % make all
178 \end{verbatim}
179 (more details in lsopt\_doc.txt)
180
181 In optim/, the path of the directory where {\it mitgcm\_ad} was compliled must be specified
182 in the Makefile in the variable INCLUDEDIRS. The file name of the controle variable
183 (xx\_hfluxm\_file here) must be added to the namelist read by optim\_num.F
184
185 Then use
186 \begin{verbatim}
187 % make depend
188 \end{verbatim}
189 and
190 \begin{verbatim}
191 % make
192 \end{verbatim}
193 to generate the line-search executable {\it optim.x}.
194
195 \subsection{Running the estimation}
196
197 Copy the {\it mitgcmuv\_ad} executable to input\_ad and {\it optim.x}
198 to the subdirectory input\_ad/OPTIM. Move into input\_ad/.
199
200 The first iteration has be done "by hand". Check that the iteration number is set
201 to 0 in data.optim and run the Mitgcm
202 \begin{verbatim}
203 % ./mitgcmuv_ad
204 \end{verbatim}
205
206 The output files adxx\_hfluxm.0000000000.* and xx\_hfluxm.0000000000.* contain
207 the sensitivity of the cost function to $Q_\mathrm{netm}$ and the perturbations
208 to $Q_\mathrm{netm}$ (zero at the first iteration), respectively. Two other files
209 called ecco\_cost.. and ecco\_ctrl are also generated. They essentially contains
210 the same information as the adxx\_* and xx\_* files, but in a compressed format.
211 These two file are the only ones involved in the communication between the adjoint
212 model {\it mitgcmuv\_ad} and the line-search algorithm {\it optim.x}. The ecco\_cost*n
213 is an ouput of the adjoint model at iteration $n$ and an input of the line-search. The
214 latter returns an updated perturbation in ecco\_ctrl*n+1 to be used as an input of
215 the adjoint model at iteration n+1.
216
217 At the first iteration, move these two files ecco\_cost and ecco\_ctrl
218 to OPTIM/, open data.optim and check the iteration number is set to 0.
219 The target cost function {\it fmin} needs to be specified: a rule of thumb
220 suggest it should be set to about 0.95-0.90 times the value of the cost
221 function at the first iteration. This value is only used at the first
222 iteration and does not need to be updated afterwards.
223 However, it implicitly specifies the "pace" at which the cost function is
224 going down (if you are lucky and it goes down). More in the ECCO section maybe ?
225
226 Once this is done, run the line-search algorithm:
227 \begin{verbatim}
228 % ./optim.x
229 \end{verbatim}
230 which computes the updated perturbations for iteration 1 ecco\_ctrl\_1.
231
232 The following iterations can be executed automatically using the shell
233 script {\it cycsh}
234 found in input\_ad/. This script will take care of changing the iteration numbers in the
235 data.optim, launch the adjoint model, clean and store the ouputs, move the
236 ecco\_cost* and ecco\_ctrl* files, and run the line-search algotrithm.
237 Edit {\it cycsh} to specify the prefix of the directories used to store the ouputs and
238 the maximum number of iteration.
239

  ViewVC Help
Powered by ViewVC 1.1.22