# Example: Subtropical North Atlantic and Labrador Sea Areas # ========================================================== # - forward/adjoint run # - optimization cost function # - The input data is real*8 # - The tests below assume that a "taf" executable is available # (http://www.fastopt.de/) >>>>>>>>>>>>>>>>>>>> DO THESE THINGS FIRST <<<<<<<<<<<<<<<<<<<< cvs co MITgcm_code cvs co MITgcm/verification/natl_box_adjoint cvs co MITgcm/verification/lab_sea cd MITgcm emacs verification/natl_box_adjoint/README & cd verification/natl_box_adjoint gunzip results*/output*.gz mkdir exe cd input wget -nd -r -A"PH*" http://batsi.mit.edu/datasets/MITgcm_input_files/MITgcm/verification/natl_box_adjoint/input cd ../input_seaice wget -nd -r -A"*labsea*" http://batsi.mit.edu/datasets/MITgcm_input_files/MITgcm/verification/natl_box_adjoint/input_seaice wget -nd -r -A"pickup*" http://batsi.mit.edu/datasets/MITgcm_input_files/MITgcm/verification/natl_box_adjoint/input_seaice >>>>>>>>>>>>>>>>>>>> DO THESE THINGS FIRST <<<<<<<<<<<<<<<<<<<< #################### # Experiment no. 1 # #################### # Use air-sea fluxes as controls (standard case): # perform gradient checks for first four elements of the # heat flux part of the control vector (grdchkvarindex = 3). # - with GMREDI, KPP, and shortwave heating # - 4 timesteps # Compile code in build/: cd ../build ../../../tools/genmake2 -ieee -mods=../code make depend make adall # To run: cd ../exe cp ../input/* . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # A reference output is in: grep grad-res ../results/output.txt_adm #################### # Experiment no. 2 # #################### # Use bulk formulae and atmospheric state controls # (only differences to experiment 1 are in # ECCO_CPPOPTIONS.h and in data.grdchk): # perform gradient checks for first four elements of the # air temperture part of the control vector (grdchkvarindex = 7). # Compile code in build/: cd ../build rm -f *.o *.f *.p rii_files *.flow rm -f *.F *.h *.c Makefile* *.template genmake_* ../../../tools/genmake2 -ieee -mods=../code_bulk make depend make adall # To run: cd ../exe cp ../input_bulk/* . cp ../input_bulk/data.grdchk_precip data.grdchk cp ../input/PH_*.data . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # A reference output is in: grep grad-res ../results_bulk/output.txt_adm #################### # Experiment no. 4 # #################### # Same as exp. 2, but with ALLOW_SEAICE defined and useseaice = .true. # Compile code in build/: cd ../build rm -f *.o *.f *.p rii_files *.flow rm -f *.F *.h *.c Makefile* *.template genmake_* ../../../tools/genmake2 -ieee -mods=../code_seaice cp ../code_seaice/SEAICE_OPTIONS.h.FLUXES SEAICE_OPTIONS.h make depend make adall # To run: cd ../exe cp ../input_bulk/* . cp ../input_bulk/data.grdchk_precip data.grdchk cp ../input_seaice/data.seaice.cgrid data.seaice cp ../input_seaice/data.pkg . cp ../input_seaice/data.diagnostics . cp ../input/PH_*.data . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # A reference output is in: grep grad-res ../results_seaice/output_exp4.txt_adm #################### # Experiment no. 5 # #################### # Same as exp. 4, but using sea-ice bulk formulae. # This experiment tests pkg/seaice bulk formulae over open water. # No sea-ice is formed anywhere in the domain. # Compile code in build/: cd ../build rm -f *.o *.f *.p rii_files *.flow rm -f *.F *.h *.c Makefile* *.template genmake_* ../../../tools/genmake2 -ieee -mods=../code_seaice make depend make adall # To run: cd ../exe cp ../input_bulk/* . cp ../input_bulk/data.grdchk_precip data.grdchk cp ../input_seaice/data.seaice.cgrid data.seaice cp ../input_seaice/data.pkg . cp ../input_seaice/data.diagnostics . cp ../input/PH_*.data . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # A reference output is in: grep grad-res ../results_seaice/output_exp5.txt_adm #################### # Experiment no. 6 # #################### # Same as experiment 5, but in the Labrador Sea rather than in # the North Atlantic subduction region. The cost function is # total ice volume over the 4-hour test period. # # The cost function data files are not used. They contain: # labsea_TP_fields : filled with -9999 # labsea_TP_mean : hour 100 ssh (cm) of lab_sea experiment # labsea_ERS_fields : filled with -9999 # labsea_SST_fields : 14 * Levitus annual mean SST # labsea_Lev.ptmp : 14 * Levitus annual mean temperature # labsea_Lev.salt : 14 * Levitus annual mean salinity # labsea_ssh.err : filled with -9999 # labsea_geoid.err : constant 0.2 with -9999 landmask # labsea_totflux.err : 100 with -9999 landmask # labsea_pme.err : 4e-8 with -9999 landmask # labsea_ustress.err : 3 with -9999 landmask # labsea_vstress.err : 3 with -9999 landmask # To run: cd ../exe cp ../input_seaice/* . cp ../input_bulk/data.grdchk . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # A reference output is in: grep grad-res ../results_seaice/output_exp6.txt_adm #################### # Experiment no. 6a # #################### # Same as experiment 6, but cost function is now misfit between # daily mean seaice model AREA (fractional ice coverage) and # Scanning Microwave Radiometer (SMR) observations; # fileneme: labsea_daily92to03_20x16_ICECONC # Gradient check needs to run long enough (e.g. 240 timesteps) # for sufficiently large gradients to build. # # To run: cd ../exe cp ../input_seaice/* . cp ../input_seaice/data.240 data cp ../input_seaice/data.seaice.cost_smrarea data.seaice cp ../input_bulk/data.grdchk . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # A reference output is in: grep grad-res ../results_seaice/output_exp6a.txt_adm #################### # Experiment no. 7 # #################### # Same as experiment 6, but finite difference gradient check for # air temperature is computed and compared for the complete domain. # # Notes: # variables xx_* contain control vector perturbation # variables adxx_* contain cost function gradient relative to control # To run: cd ../exe cp ../input_seaice/* . \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt > grad-res.txt cd ../results_seaice # plot with matlab: matlab lookat_exp8 #################### # Experiment no. 8 # #################### # Same as experiment 7, but starting from a checkpoint file. # To run: cd ../exe cp ../input_seaice/* . cp data.001 data \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt > grad-res.txt cd ../results_seaice matlab lookat_exp8 #################### # Experiment no. 9 # #################### # Same as experiment 8, but starting from time step 180. # This includes a location (12,8) which experiences a phase # transition from no-ice to sea-ice, and which therefore has # a very large and inaccurate gradient. # To run: cd ../exe cp ../input_seaice/* . cp data.180 data \rm output.txt ../build/mitgcmuv_ad >& output.txt # To verify the results of the gradient check, type: grep grad-res output.txt > grad-res.txt cd ../results_seaice matlab lookat_exp8 ##################### # Experiment no. 10 # ##################### # Set up a 100-day sensitivity experiment. # Things start falling apart, see below. # Longer integrations periods cause NANs in adjoint gradient. # Note: cost_ssh is hardwired for 1-day ssh records # "topexperiod" in data.cost is never used. # Compile code in build/: cd ../build rm -f *.o *.f *.p rii_files *.flow rm -f *.F *.h *.c Makefile* *.template genmake_* ../../../tools/genmake2 -mods=../code_seaice make depend make adall make ftlall # First run for 24 hours: cd ../exe cp ../input_seaice/* . cp data.24 data cp ../input_bulk/data.grdchk . # run the ADM \rm output.txt_adm ../build/mitgcmuv_ad >& output.txt_adm # run the TLM \rm output.txt_tlm ../build/mitgcmuv_ftl >& output.txt_tlm # To verify the results of the gradient check, type: grep grad-res output.txt_adm grep grad-res output.txt_tlm # A reference output is in: grep grad-res ../results_seaice/output_exp10.txt_adm grep grad-res ../results_seaice/output_exp10.txt_tlm # Now run for 100 days: cp data.100day data \rm output.txt_adm ../build/mitgcmuv_ad >& output.txt_adm grep grad-res output.txt_adm # grad-res proc # i j k fc ref fc + eps fc - eps grad-res proc # i j k adj grad fd grad 1 - fd/adj grad-res ------------------------------- grad-res 0 1 17 2 1 0.584991977E+12 0.584969292E+12 0.585035823E+12 grad-res 0 1 1 20 0 -.154328414E+42 -.332655172E+12 0.100000000E+01 # Now modify data.pkg and run for 100 days without KPP and GM: emacs -nw data.pkg \rm output.txt_adm ../build/mitgcmuv_ad < /dev/null >& output.txt_adm & grep grad-res output.txt_adm # grad-res proc # i j k fc ref fc + eps fc - eps grad-res proc # i j k adj grad fd grad 1 - fd/adj grad-res ------------------------------- grad-res 0 1 17 2 1 0.775568418E+12 0.775568716E+12 0.775568120E+12 grad-res 0 1 1 20 0 0.298288524E+10 0.298245351E+10 0.144733246E-03 # Now modify data and run for 375 days without KPP and GM: emacs -nw data \rm output.txt_adm ../build/mitgcmuv_ad < /dev/null >& output.txt_adm & grep grad-res output.txt_adm # grad-res proc # i j k fc ref fc + eps fc - eps grad-res proc # i j k adj grad fd grad 1 - fd/adj grad-res ------------------------------- grad-res 0 1 17 2 1 0.896287794E+12 0.896287828E+12 0.896287760E+12 grad-res 0 1 1 20 0 0.341242829E+09 0.341148397E+09 0.276729326E-03 grad-res ------------------------------- grad-res 0 2 20 4 1 0.896287794E+12 0.896287837E+12 0.896287752E+12 grad-res 0 2 2 40 0 0.425898569E+09 0.424819718E+09 0.253311730E-02 grad-res ------------------------------- grad-res 0 3 19 6 1 0.896287794E+12 0.896287810E+12 0.896287779E+12 grad-res 0 3 3 60 0 0.155522387E+09 0.155305087E+09 0.139722658E-02 grad-res ------------------------------- grad-res 0 4 11 8 1 0.896287794E+12 0.896335295E+12 0.896334240E+12 grad-res 0 4 4 80 0 0.205181064E+12 0.527474334E+10 0.974292251E+00 # Now modify data and run for 3650 days without KPP and GM: emacs -nw data \rm output.txt_adm ../build/mitgcmuv_ad < /dev/null >& output.txt_adm & grep grad-res output.txt_adm # grad-res proc # i j k fc ref fc + eps fc - eps grad-res proc # i j k adj grad fd grad 1 - fd/adj grad-res ------------------------------- grad-res 0 1 17 2 1 0.589620342E+12 0.588645621E+12 0.580985192E+12 grad-res 0 1 1 20 0 0.191626271E+43 0.383021453E+14 0.100000000E+01 grad-res ------------------------------- grad-res 0 2 20 4 1 0.589620342E+12 0.592671001E+12 0.589646830E+12 grad-res 0 2 2 40 0 0.267667844E+43 0.151208553E+14 0.100000000E+01 grad-res ------------------------------- grad-res 0 3 19 6 1 0.589620342E+12 0.589897088E+12 0.590977596E+12 grad-res 0 3 3 60 0 0.941766989E+42 -.540254080E+13 0.100000000E+01 grad-res ------------------------------- grad-res 0 4 11 8 1 0.589620342E+12 0.594465341E+12 0.591740211E+12 grad-res 0 4 4 80 0 0.115838596E+46 0.136256470E+14 0.100000000E+01 ##################### # Experiment no. 11 # ##################### >>>>>>>>>> PH: THIS ONE NOT YET UPDATED <<<<<<<<<< # Same as experiment 8, but using 2-CPU MPI configuration. # Compile code in bin/: cd ../bin rm -rf *.o *.f *.p rii_files rm -rf *.F *.h *.c Makefile* cp ../verification/natl_box_adjoint/code_seaice/*.h . cp ../verification/natl_box_adjoint/code_seaice/.genmakerc . cp ../verification/natl_box_adjoint/code_seaice/SIZE.h.MPI SIZE.h cp ../verification/natl_box_adjoint/code_seaice/CPP_EEOPTIONS.h.MPI CPP_EEOPTIONS.h # Configure and compile the code: ../tools/genmake -mpi -makefile # ==> on alhena use: # ../tools/genmake -platform=o2k -mpi -makefile make depend # Generate the adjoint code: cd ../adjoint cp ../verification/natl_box_adjoint/code_seaice/makefile . make adtaf make adchange rm -f makefile # Go back and compile the code: cd ../bin make # To run: cd ../exe cp ../verification/natl_box_adjoint/input_seaice/* . cp data.001 data cp ../verification/natl_box_adjoint/input_bulk/data.grdchk . mpirun -np 2 mitgcmuv # To verify the results of the gradient check, type: grep "ph-grd 3" STDOUT.0000 # To plot adjoint sensitivy fields cd ../verification/natl_box_adjoint/results_seaice matlab lookat_exp10 ##################### # Experiment no. 12 # ##################### # Same as experiment 6, but including LSR dynamic solver. # Compile code in build/: cd ../build rm -f *.o *.f *.p rii_files *.flow rm -f *.F *.h *.c Makefile* *.template genmake_* ../../../tools/genmake2 -ieee -mods=../code_seaice cp ../code_seaice/SEAICE_OPTIONS.h.DYN SEAICE_OPTIONS.h make depend make adall make ftlall # To run: cd ../exe cp ../input_seaice/* . cp data.seaice.lsr data.seaice cp ../input_bulk/data.grdchk . # run the ADM ../build/mitgcmuv_ad >&! output.txt_adm # run the TLM ../build/mitgcmuv_ftl >&! output.txt_tlm # To verify the results of the gradient check, type: grep grad-res output.txt_adm # A reference output is in: grep grad-res ../results_seaice/output_exp12.txt_adm ##################### # Experiment no. 13 # ##################### # Same as experiment 12, but finite difference gradient check for # air temperature is computed and compared for the complete domain. # To run: cd ../exe cp ../input_seaice/* . cp data.seaice.lsr data.seaice ../build/mitgcmuv_ad >&! output.txt_adm # To verify the results of the gradient check, type: grep grad-res output.txt_adm > grad-res.txt cd ../results_seaice matlab lookat_exp8 ##################### # Experiment no. 14 # ##################### >>>>>>>>>> PH: THIS ONE NOT YET UPDATED <<<<<<<<<< # Same as in 12 but for a 100-day sensitivity experiment. # Compile code in bin/: cd ../bin rm -rf *.o *.f *.p rii_files rm -rf *.F *.h *.c Makefile* cp ../verification/natl_box_adjoint/code_seaice/*.h . rm -f tamc.h cp ../verification/natl_box_adjoint/code_seaice/.genmakerc . cp ../verification/natl_box_adjoint/code_seaice/SEAICE_OPTIONS.h.MULTILEVEL SEAICE_OPTIONS.h # Configure and compile the code: ../tools/genmake -makefile make depend # Generate the adjoint code: cd ../adjoint cp ../verification/natl_box_adjoint/code_seaice/makefile . make adtaf make adchange rm -f makefile # Go back and compile the code: cd ../bin make # To run: cd ../exe cp ../verification/natl_box_adjoint/input_seaice/* . cp data.100day data cp ../verification/natl_box_adjoint/input_bulk/data.grdchk . cp data.seaice.lsr data.seaice ../build/mitgcmuv >&! output.txt # To verify the results of the gradient check, type: grep "ph-grd 3" output.txt # For 100-day experiment, with cost_ice_flag = 1, the adjoint gradient # blows up, as in Exp. 10 # 1.d-04 0.251994583E+11 -.899637862E+10 0.372048919E+10 -.344972301E+10 # adj grad -.160660304+210 -.378763253+210 -.239235971+211 -.386444881+209 # With cost_ice_flag = 2, i.e., mean sea-ice area # 1.d-04 -.152618243E+11 0.605974121E+06 -.155375485E+11 -.153368205E+11 # adj grad 0.000000000E+00 0.000000000E+00 -.124076923E+09 0.000000000E+00 # With cost_ice_flag = 6, i.e., a quadratic cost function # 1.d-12 -.106128607E+12 0.106330784E+12 -.106446555E+12 -.106237252E+12 # 1.d-08 0.106450924E+08 0.103670536E+05 0.349155947E+05 0.335081902E+05 # 1.d-04 -.106143365E+04 0.206965778E+00 -.105672737E+04 -.106326894E+04 # 1.d-02 -.120891636E-02 0.106325012E+02 0.841459268E+01 -.107119297E+02 # 1.d-01 -.102221209E-02 -.124805738E-02 0.821489714E+01 -.331974254E-02 # 1.d-00 0.113825328E-03 -.105881751E+00 0.104550010E+02 -.106209116E+00 # adj grad 0.000000000E+00 0.000000000E+00 0.887775373E+01 0.000000000E+00 ##################### # Experiment no. 15 # ##################### # Same as experiment 6, but with SEAICE_MULTILEVEL. # Compile code in build/: rm -f *.o *.f *.p rii_files *.flow rm -f *.F *.h *.c Makefile* *.template genmake_* ../../../tools/genmake2 -ieee -mods=../code_seaice cp ../code_seaice/SEAICE_OPTIONS.h.MULTILEVEL SEAICE_OPTIONS.h make depend make adall # To run: cd ../exe cp ../input_seaice/* . cp ../input_bulk/data.grdchk . ../build/mitgcmuv_ad >&! output.txt # To verify the results of the gradient check, type: grep grad-res output.txt # The reference output is in: grep grad-res ../results_seaice/output_exp15.txt_adm # This test suggests that SEAICE_MULTILEVEL decreases the accuracy of # the adjoint model, perhaps because the adjoint model is not handling # multiple recomputations in budget properly. ##################### # Experiment no. 20 # ##################### # Same as experiment 10, but using divided adjoint.