Home Contact Us Site Map  
 
       
    next up previous contents
Next: 5.4.3 Recipe 2: multi Up: 5.4 Adjoint dump & Previous: 5.4.1 Introduction   Contents

5.4.2 Recipe 1: single processor

  1. In ECCO_CPPOPTIONS.h set:
          #define ALLOW_DIVIDED_ADJOINT
          #undef  ALLOW_DIVIDED_ADJOINT_MPI
    

  2. Generate adjoint code. Using the TAF option '-pure', two codes are generated:
    • mdthe_main_loop:
      Is responsible for the forward trajectory, storing of outermost checkpoint levels to file, computation of cost function, and storing of cost function to file (1st step).
    • adthe_main_loop:
      Is responsible for computing one adjoint leg, dump adjoint state to file and write index info to file (2nd and consecutive steps).

      for adjoint code generation, e.g. add '-pure' to TAF option list

          make adtaf
      

    • One modification needs to be made to adjoint codes in S/R adecco_the_main_loop:

      There's a remaining issue with the '-pure' option. The 'call ad...' between 'call ad...' and the read of the snapshot file should be called only in the firt adjoint leg between $ nlev3$ and $ nlev3-1$ . In the ecco-branch, the following lines should be bracketed by an if (idivbeg .GE. nchklev_3) then, thus:

      ...
            xx_psbar_mean_dummy = onetape_xx_psbar_mean_dummy_3h(1)
            xx_tbar_mean_dummy = onetape_xx_tbar_mean_dummy_4h(1)
            xx_sbar_mean_dummy = onetape_xx_sbar_mean_dummy_5h(1)
            call barrier( mythid )
      cAdd(
            if (idivbeg .GE. nchklev_3) then
      cAdd)
      
            call adcost_final( mythid )
            call barrier( mythid )
            call adcost_sst( mythid )
            call adcost_ssh( mythid )
            call adcost_hyd( mythid )
            call adcost_averagesfields( mytime,myiter,mythid )
            call barrier( mythid )
      cAdd(
            endif
      cAdd)
      
      C----------------------------------------------
      C read snapshot
      C----------------------------------------------
            if (idivbeg .lt. nchklev_3) then
              open(unit=77,file='snapshot',status='old',form='unformatted',
           $iostat=iers)
      ...
      

      For the main code, in all likelihood the block which needs to be bracketed consists of adcost_final only.

    • Now the code can be copied as usual to adjoint_model.F and then be compiled:
          make adchange
          then compile
      


next up previous contents
Next: 5.4.3 Recipe 2: multi Up: 5.4 Adjoint dump & Previous: 5.4.1 Introduction   Contents
mitgcm-support@mitgcm.org
Copyright © 2006 Massachusetts Institute of Technology Last update 2018-01-23