/[MITgcm]/MITgcm/verification/natl_box_adjoint/README
ViewVC logotype

Diff of /MITgcm/verification/natl_box_adjoint/README

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

revision 1.1 by heimbach, Tue Feb 5 20:34:35 2002 UTC revision 1.1.2.29 by dimitri, Tue May 27 20:13:24 2003 UTC
# Line 0  Line 1 
1    # Example: Subtropical North Atlantic and Labrador Sea Areas
2    # ==========================================================
3    # - forward/adjoint run
4    # - optimization cost function
5    # - with KPP & shortwave heating
6    # - gmredi turned off (until merge to c48)
7    # - The input data is real*8
8    # - 4 timesteps
9    
10    
11    ####################
12    # Experiment no. 1 #
13    ####################
14    # Use air-sea fluxes as controls (standard case):
15    # perform gradient checks for first four elements of the
16    # heat flux part of the control vector (grdchkvarindex = 3).
17    
18    # Compile code in bin/:
19     cd bin
20     cp ../verification/natl_box_adjoint/code/.genmakerc .
21     cp ../verification/natl_box_adjoint/code/*.h .
22    # Configure and compile the code:
23     ../tools/genmake -makefile
24     make depend
25    # Generate the adjoint code:
26     cd ../adjoint
27     make adtaf
28     make adchange
29    # Go back and compile the code:
30     cd ../bin
31     make
32    # To run:
33     cd ../exe
34     cp ../verification/natl_box_adjoint/input/* .
35     ./mitgcmuv >&! output.txt
36    # To verify the results of the gradient check, type:
37     grep "ph-grd 3" output.txt
38    # A reference output is in:
39     grep "ph-grd 3" ../verification/natl_box_adjoint/results/output.txt
40    
41    
42    ####################
43    # Experiment no. 2 #
44    ####################
45    # Use bulk formulae and atmospheric state controls
46    # (only differences to experiment 1 are in
47    # ECCO_CPPOPTIONS.h and in data.grdchk):
48    # perform gradient checks for first four elements of the
49    # air temperture part of the control vector (grdchkvarindex = 7).
50    
51    # Compile code in bin/:
52     cd ../bin
53     rm -rf *.o *.f *.p rii_files
54     rm -rf *.F *.h *.c Makefile*
55     cp ../verification/natl_box_adjoint/code_bulk/.genmakerc .
56     cp ../verification/natl_box_adjoint/code_bulk/*.h .
57    # Configure and compile the code:
58     ../tools/genmake -makefile
59     make depend
60    # Generate the adjoint code:
61     cd ../adjoint
62     make adtaf
63     make adchange
64    # Go back and compile the code:
65     cd ../bin
66     make
67    # To run:
68     cd ../exe
69     cp ../verification/natl_box_adjoint/input_bulk/* .
70     cp ../verification/natl_box_adjoint/input/PH_*.data .
71     ./mitgcmuv >&! output.txt
72    # To verify the results of the gradient check, type:
73     grep "ph-grd 3" output.txt
74    # A reference output is in:
75     grep "ph-grd 3" ../verification/natl_box_adjoint/results_bulk/output.txt
76    
77    
78    ####################
79    # Experiment no. 4 #
80    ####################
81    # Same as exp. 2, but with ALLOW_SEAICE defined and useseaice = .true.
82    
83    # Compile code in bin/:
84     cd ../bin
85     rm -rf *.o *.f *.p rii_files
86     rm -rf *.F *.h *.c Makefile*
87     cp ../verification/natl_box_adjoint/code_seaice/*.h .
88     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
89     cp ../verification/natl_box_adjoint/code_seaice/SEAICE_OPTIONS.h.FLUXES SEAICE_OPTIONS.h
90    # Configure and compile the code:
91     ../tools/genmake -makefile
92     make depend
93    # Generate the adjoint code:
94     cd ../adjoint
95     cp ../verification/natl_box_adjoint/code_seaice/makefile .
96     make adtaf
97     make adchange
98     rm -f makefile
99    # Go back and compile the code:
100     cd ../bin
101     make
102    # To run:
103     cd ../exe
104     cp ../verification/natl_box_adjoint/input_bulk/* .
105     cp ../verification/natl_box_adjoint/input_seaice/data.seaice.cgrid data.seaice
106     cp ../verification/natl_box_adjoint/input_seaice/data.pkg .
107     cp ../verification/natl_box_adjoint/input/PH_*.data .
108     ./mitgcmuv >&! output.txt
109    # To verify the results of the gradient check, type:
110     grep "ph-grd 3" output.txt
111    # A reference output is in:
112     grep "ph-grd 3" ../verification/natl_box_adjoint/results_bulk/output.txt
113    
114    
115    ####################
116    # Experiment no. 5 #
117    ####################
118    # Same as exp. 4, but using sea-ice bulk formulae.
119    # This experiment tests pkg/seaice bulk formulae over open water.
120    # No sea-ice is formed anywhere in the domain.
121    # There is a discrepancy of up to 8% between ajoint
122    # model and finite difference gradients.
123    
124    # Compile code in bin/:
125     cd ../bin
126     rm -rf *.o *.f *.p rii_files
127     rm -rf *.F *.h *.c Makefile*
128     cp ../verification/natl_box_adjoint/code_seaice/*.h .
129     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
130    # Configure and compile the code:
131     ../tools/genmake -makefile
132     make depend
133    # Generate the adjoint code:
134     cd ../adjoint
135     cp ../verification/natl_box_adjoint/code_seaice/makefile .
136     make adtaf
137     make adchange
138     rm -f makefile
139    # Go back and compile the code:
140     cd ../bin
141     make
142    # To run:
143     cd ../exe
144     cp ../verification/natl_box_adjoint/input_bulk/* .
145     cp ../verification/natl_box_adjoint/input_seaice/data.seaice.cgrid data.seaice
146     cp ../verification/natl_box_adjoint/input_seaice/data.pkg .
147     cp ../verification/natl_box_adjoint/input/PH_*.data .
148     ./mitgcmuv >&! output.txt
149    # To verify the results of the gradient check, type:
150     grep "ph-grd 3" output.txt
151    # A reference output is in:
152     grep "ph-grd 3" ../verification/natl_box_adjoint/results_bulk/output.exp5
153    
154    
155    ####################
156    # Experiment no. 6 #
157    ####################
158    # Same as experiment 5, but in the Labrador Sea rather than in
159    # the North Atlantic subduction region.  The cost function is
160    # total ice volume over the 4-hour test period.
161    #
162    # The cost function data files are not used.  They contain:
163    # labsea_TP_fields   : filled with -9999
164    # labsea_TP_mean     : hour 100 ssh (cm) of lab_sea experiment
165    # labsea_ERS_fields  : filled with -9999
166    # labsea_SST_fields  : 14 * Levitus annual mean SST
167    # labsea_Lev.ptmp    : 14 * Levitus annual mean temperature
168    # labsea_Lev.salt    : 14 * Levitus annual mean salinity
169    # labsea_ssh.err     : filled with -9999
170    # labsea_geoid.err   : constant 0.2 with -9999 landmask
171    # labsea_totflux.err : 100 with -9999 landmask
172    # labsea_pme.err     : 4e-8 with -9999 landmask
173    # labsea_ustress.err : 3 with -9999 landmask
174    # labsea_vstress.err : 3 with -9999 landmask
175    
176    # To run:
177     cd ../exe
178     cp ../verification/natl_box_adjoint/input_seaice/* .
179     cp ../verification/natl_box_adjoint/input_bulk/data.grdchk .
180     ./mitgcmuv >&! output.txt
181    # To verify the results of the gradient check, type:
182     grep "ph-grd 3" output.txt
183    # A reference output is in:
184     grep "ph-grd 3" ../verification/natl_box_adjoint/results_seaice/output.txt
185    
186    
187    ####################
188    # Experiment no. 7 #
189    ####################
190    # Same as experiment 6, but finite difference gradient check for
191    # air temperature is computed and compared for the complete domain.
192    #
193    # Notes:
194    # variables xx_* contain control vector perturbation
195    # variables adxx_* contain cost function gradient relative to control
196    
197    # To run:
198     cd ../exe
199     cp ../verification/natl_box_adjoint/input_seaice/* .
200     ./mitgcmuv >&! output.txt
201    # To verify the results of the gradient check, type:
202     grep "ph-grd 3" output.txt > ph-grd.txt
203     cd ../verification/natl_box_adjoint/results_seaice
204     matlab
205     lookat_exp8
206    
207    
208    ####################
209    # Experiment no. 8 #
210    ####################
211    # Same as experiment 7, but starting from a checkpoint file.
212    
213    # To run:
214     cd ../../../exe
215     cp ../verification/natl_box_adjoint/input_seaice/* .
216     cp data.001 data
217     ./mitgcmuv >&! output.txt
218    # To verify the results of the gradient check, type:
219     grep "ph-grd 3" output.txt > ph-grd.txt
220     cd ../verification/natl_box_adjoint/results_seaice
221     matlab
222     lookat_exp8
223    
224    
225    ####################
226    # Experiment no. 9 #
227    ####################
228    # Same as experiment 8, but starting from time step 180.
229    # This includes a location (12,8) which experiences a phase
230    # transition from no-ice to sea-ice, and which therefore has
231    # a very large and inaccurate gradient.
232    
233    # To run:
234     cd ../../../exe
235     cp ../verification/natl_box_adjoint/input_seaice/* .
236     cp data.180 data
237     ./mitgcmuv >&! output.txt
238    # To verify the results of the gradient check, type:
239     grep "ph-grd 3" output.txt > ph-grd.txt
240     cd ../verification/natl_box_adjoint/results_seaice
241     matlab
242     lookat_exp8
243    
244    
245    #####################
246    # Experiment no. 10 #
247    #####################
248    # Set up a 100-day sensitivity experiment.
249    # Things start falling apart, see below.
250    # Longer integrations periods cause NANs in adjoint gradient.
251    # Note: cost_ssh is hardwired for 1-day ssh records
252    #       "topexperiod" in data.cost is never used.
253    
254    # Compile code in bin/:
255     cd ../../../bin
256     rm -rf *.o *.f *.p rii_files
257     rm -rf *.F *.h *.c Makefile*
258     cp ../verification/natl_box_adjoint/code_seaice/*.h .
259     rm -f tamc.h
260     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
261    # Configure and compile the code:
262     ../tools/genmake -makefile
263     make depend
264    # Generate the adjoint code:
265     cd ../adjoint
266     cp ../verification/natl_box_adjoint/code_seaice/makefile .
267     make adtaf
268     make adchange
269     rm -f makefile
270    # Go back and compile the code:
271     cd ../bin
272     make
273    # To run:
274     cd ../exe
275     cp ../verification/natl_box_adjoint/input_seaice/* .
276     cp data.100day data
277     cp ../verification/natl_box_adjoint/input_bulk/data.grdchk .
278     ./mitgcmuv >&! output.txt
279    # To verify the results of the gradient check, type:
280     grep "ph-grd 3" output.txt
281    
282    # For 100 days, adjoint gradient blows up for cost_ice_flag=1,2,3,4,5.
283    # Following table compares adjoint gradient to finite difference gradient
284    # for various choices of grdchk_eps and for cost_ice_flag=1.  The finite
285    # difference gradient is unstable, suggesting that tangent linear gradient
286    # is ill defined. 100 day experiment looks equally bad with cost_ice_flag=2.
287     adj grad -.441946498+276 -.143062040+277 -.116360092+277 0.400428239+277
288     1.d-12   -.177327175E+20 0.140230277E+20 -.254542273E+20 0.138603531E+19
289     1.d-8    0.174714613E+16 -.527867903E+15 0.403581037E+15 0.377322748E+12
290     1.d-4    0.999954825E+11 0.156018218E+12 -.474931072E+11 -.357260091E+11
291     1.d-2    0.634576350E+09 -.185440863E+10 -.599212833E+09 -.334417056E+10
292    
293    # 100 day experiment with cost_ice_flag = 3, but in North Atlantic
294    # domain, i.e., with no sea-ice is OK
295     adj grad  0.234593317E+17 0.166950683E+17 0.238665515E+17 0.249850733E+17
296     1.d-4     0.234313954E+17 0.166674930E+17 0.238322031E+17 0.249217155E+17
297    
298    # with same order of magnitude results as those from pkg/exf bulk formulae
299     adj grad  0.279968788E+17 0.226979382E+17 0.269224396E+17 0.323359773E+17
300     1.d-4     0.279944626E+17 0.226935335E+17 0.269274317E+17 0.323399293E+17
301    
302    # 10 day experiment with cost_ice_flag = 3 is OK
303     adj grad  0.353941629E+17 0.955451129E+16 -.265793314E+17 0.232229067E+16
304     1.d-4     0.353943893E+17 0.955563114E+16 -.265195776E+17 0.232137949E+16
305     1-fd/adj  -.639540199E-05 -.117207086E-03 0.224813073E-02 0.392362727E-03
306    
307    # 100 day experiment with cost_ice_flag = 3 fails
308     adj grad  0.134326162+285 0.434825818+285 0.353667347+285 -.121707013+286
309     1.d-4     -.248910431E+20 -.581887317E+20 0.530805948E+18 0.554441614E+20
310    
311    # 100 day experiment with cost_ice_flag = 4 fails
312     adj grad  0.942881479+279 0.305219181+280 0.248251262+280 -.854303341+280
313     1.d-4     0.550158678E+19 -.107685572E+20 -.139042495E+20 0.445855968E+20
314    
315    # 100 day experiment with cost_ice_flag = 5 fails
316     adj grad  0.149606733+285 0.484290396+285 0.393899563+285 -.135552065+286
317     1.d-4     -.300535490E+20 -.689378119E+20 0.300954675E+19 0.767231924E+20
318    
319    # It seems that linearization in the presence of a sea-ice model is very
320    # difficult.  Consider that a small perturbation at time zero may cause
321    # sea-ice to appear or not at a particular grid point.  The model response
322    # with sea-ice is completely different from that with no sea-ice, so that
323    # this small initial perturbation will have a large impact in ocean heat
324    # content, or even ocean plus sea-ice heat content.  One way around this
325    # may be a preliminary piece-wise optimization, say 10 days at a time, but
326    # without changing initial conditions, just the surface fluxes.  Another
327    # way may be to specify heat fluxes based on observed sea-ice extent, in
328    # order to force the model to have sea-ice where sea-ice is observed.  A
329    # third possiblity, similar to that provided by package MIX for KPP scheme
330    # in the telescoping configuration would be to store AREA or HEFF during
331    # forward model integrations and then to specify, rather than recompute,
332    # AREA or HEFF or both during adjoint model calculations.  The problem
333    # with this approach is that it would not be possible to compute
334    # sensitivity to a variable that held constant, rather tan computed?
335    # Perhaps sensitivity of cost function to AREA and to HEFF can be computed
336    # separately, by running the adjoint twice, once keeping HEFF constant and
337    # the second keeping AREA constant?
338    
339    # Now need a test to show that this is indeed the problem.
340    
341    
342    #####################
343    # Experiment no. 11 #
344    #####################
345    # Same as experiment 8, but using 2-CPU MPI configuration.
346    
347    # Compile code in bin/:
348     cd ../bin
349     rm -rf *.o *.f *.p rii_files
350     rm -rf *.F *.h *.c Makefile*
351     cp ../verification/natl_box_adjoint/code_seaice/*.h .
352     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
353     cp ../verification/natl_box_adjoint/code_seaice/SIZE.h.MPI SIZE.h
354     cp ../verification/natl_box_adjoint/code_seaice/CPP_EEOPTIONS.h.MPI CPP_EEOPTIONS.h
355    # Configure and compile the code:
356     ../tools/genmake -mpi -makefile
357    # ==> on alhena use:
358    # ../tools/genmake -platform=o2k -mpi -makefile
359     make depend
360    # Generate the adjoint code:
361     cd ../adjoint
362     cp ../verification/natl_box_adjoint/code_seaice/makefile .
363     make adtaf
364     make adchange
365     rm -f makefile
366    # Go back and compile the code:
367     cd ../bin
368     make
369    # To run:
370     cd ../exe
371     cp ../verification/natl_box_adjoint/input_seaice/* .
372     cp data.001 data
373     cp ../verification/natl_box_adjoint/input_bulk/data.grdchk .
374     mpirun -np 2 mitgcmuv
375    # To verify the results of the gradient check, type:
376     grep "ph-grd 3" STDOUT.0000
377    # To plot adjoint sensitivy fields
378     cd ../verification/natl_box_adjoint/results_seaice
379     matlab
380     lookat_exp10
381    
382    
383    #####################
384    # Experiment no. 12 #
385    #####################
386    # Same as experiment 6, but including LSR dynamic solver.
387    
388    # Compile code in bin/:
389     cd ../bin
390     rm -rf *.o *.f *.p rii_files
391     rm -rf *.F *.h *.c Makefile*
392     cp ../verification/natl_box_adjoint/code_seaice/*.h .
393     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
394     cp ../verification/natl_box_adjoint/code_seaice/SEAICE_OPTIONS.h.DYN SEAICE_OPTIONS.h
395    # Configure and compile the code:
396     ../tools/genmake -makefile
397     make depend
398    # Generate the adjoint code:
399     cd ../adjoint
400     cp ../verification/natl_box_adjoint/code_seaice/makefile.dyn makefile
401     make adtaf
402     make adchange
403     rm -f makefile
404    # Go back and compile the code:
405     cd ../bin
406     make
407    # To run:
408     cd ../exe
409     cp ../verification/natl_box_adjoint/input_seaice/* .
410     cp ../verification/natl_box_adjoint/input_bulk/data.grdchk .
411     ./mitgcmuv >&! output.txt
412    # To verify the results of the gradient check, type:
413     grep "ph-grd 3" output.txt
414    # The reference output, without dynamics is in:
415     grep "ph-grd 3" ../verification/natl_box_adjoint/results_seaice/output.txt
416    
417    
418    #####################
419    # Experiment no. 13 #
420    #####################
421    # Same as experiment 6, but with SEAICE_MULTILEVEL.
422    
423    # Compile code in bin/:
424     cd ../bin
425     rm -rf *.o *.f *.p rii_files
426     rm -rf *.F *.h *.c Makefile*
427     cp ../verification/natl_box_adjoint/code_seaice/*.h .
428     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
429     cp ../verification/natl_box_adjoint/code_seaice/SEAICE_OPTIONS.h.MULTILEVEL SEAICE_OPTIONS.h
430    # Configure and compile the code:
431     ../tools/genmake -makefile
432     make depend
433    # Generate the adjoint code:
434     cd ../adjoint
435     cp ../verification/natl_box_adjoint/code_seaice/makefile .
436     make adtaf
437     make adchange
438     rm -f makefile
439    # Go back and compile the code:
440     cd ../bin
441     make
442    # To run:
443     cd ../exe
444     cp ../verification/natl_box_adjoint/input_seaice/* .
445     cp ../verification/natl_box_adjoint/input_bulk/data.grdchk .
446     ./mitgcmuv >&! output.txt
447    # To verify the results of the gradient check, type:
448     grep "ph-grd 3" output.txt
449    # The reference output, with SEAICE_MULTILEVEL undefined is in:
450     grep "ph-grd 3" ../verification/natl_box_adjoint/results_seaice/output.txt
451    
452    # This test suggests that SEAICE_MULTILEVEL decreases the accuracy of
453    # the adjoint model, perhaps because the adjoint model is not handling
454    # multiple recomputations in budget properly.
455    
456    
457    #####################
458    # Experiment no. 14 #
459    #####################
460    # Same as in 14 but for a 100-day sensitivity experiment.
461    
462    # Compile code in bin/:
463     cd ../bin
464     rm -rf *.o *.f *.p rii_files
465     rm -rf *.F *.h *.c Makefile*
466     cp ../verification/natl_box_adjoint/code_seaice/*.h .
467     rm -f tamc.h
468     cp ../verification/natl_box_adjoint/code_seaice/.genmakerc .
469     cp ../verification/natl_box_adjoint/code_seaice/SEAICE_OPTIONS.h.MULTILEVEL SEAICE_OPTIONS.h
470    # Configure and compile the code:
471     ../tools/genmake -makefile
472     make depend
473    # Generate the adjoint code:
474     cd ../adjoint
475     cp ../verification/natl_box_adjoint/code_seaice/makefile .
476     make adtaf
477     make adchange
478     rm -f makefile
479    # Go back and compile the code:
480     cd ../bin
481     make
482    # To run:
483     cd ../exe
484     cp ../verification/natl_box_adjoint/input_seaice/* .
485     cp data.100day data
486     cp ../verification/natl_box_adjoint/input_bulk/data.grdchk .
487     ./mitgcmuv >&! output.txt
488    # To verify the results of the gradient check, type:
489     grep "ph-grd 3" output.txt
490    
491    # For 100-day experiment, the adjoint gradient blows up, as in Exp. 10
492     adj grad  -.160660304+210 -.378763253+210 -.239235971+211 -.386444881+209
493     1.d-4     0.251994583E+11 -.899637862E+10 0.372048919E+10 -.344972301E+10
494    
495    
496    #####################
497    # Experiment no. 20 #
498    #####################
499    # Same as experiment 10, but using divided adjoint.
500    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.29

  ViewVC Help
Powered by ViewVC 1.1.22