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

Annotation 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.7 - (hide annotations) (download) (as text)
Tue Jun 27 19:08:22 2006 UTC (17 years, 11 months ago) by molod
Branch: MAIN
Changes since 1.6: +3 -2 lines
File MIME type: application/x-tex
Add cross references between tutorials and verification file system directories

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

  ViewVC Help
Powered by ViewVC 1.1.22