!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
! version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r gem_run_ad - ADJ of gem_run_tl
*
#include "model_macros_f.h"
*
subroutine gem_run_ad (F_dgtflt_L, F_rstrt_L) 2,23
*
implicit none
*
logical F_dgtflt_L, F_rstrt_L
*
*author
* M.Tanguay
*
*revision
* v2_10 - Tanguay M. - initial MPI version
* v2_21 - Tanguay M. - modification as in gem_run
* v2_31 - Tanguay M. - adapt ADJ to diffusion in gem_run
* v3_00 - Ek N./Tanguay M. - introduce v4d_ctrlgrd
* v3_00 - Laroche S. - include simplified physics
* v3_01 - Tanguay M. - introduce identity option
* v3_02 - Tanguay M. - ADJ of Eigv_parity_L and Hspng_main done
* v3_02 - Tanguay M. - cosmetics for identity option
* v3_02 - Buehner M. - integration stops when timestep V4dg_steplast is reached (not 0)
* v3_03 - Tanguay M. - Call hdif_phy
* v3_11 - Tanguay M. - Extend TRAJ for conversion for DYNOUT2
* - ADJ of digital filter
* v3_20 - Tanguay M. - Adjoint Surfix
* - Introduce Hzd_hdif0_L
* v3_30 - Tanguay M. - Adapt TL/AD to Clim_clima_L
* v3_31 - Tanguay M. - Add TMG timings
*
*object
* see id section
*
*arguments
*----------------------------------------------------------------
* F_dgtflt_L I Digital initiatization mode
* F_rstrt_L O Is a restart required
*----------------------------------------------------------------
*
*implicits
#include "glb_ld.cdk"
#include "init.cdk"
#include "lun.cdk"
#include "step.cdk"
#include "rstr.cdk"
#include "schm.cdk"
#include "lctl.cdk"
#include "v4dg.cdk"
#include "clim.cdk"
#include "vt1m.cdk"
#include "hzd.cdk"
#include "eigv.cdk"
#include "fft.cdk"
#include "vspng.cdk"
#include "hspng.cdk"
*
logical identity_4dvar_L
integer last_step,initial_step
* ______________________________________________________
*
if( F_rstrt_L ) call gem_stop
('gem_run_ad',-1)
if( Clim_climat_L ) call gem_stop
('gem_run_ad',-1)
if( Schm_chems_L ) call gem_stop
('gem_run_ad',-1)
* ______________________________________________________
*
identity_4dvar_L = V4dg_conf.ne.0.and.V4dg_identity_L
*
initial_step = Lctl_step
last_step = V4dg_steplast
*
if (Init_balgm_L.and..not.F_dgtflt_L.and.(Step_total.ge.(Init_dfnp-1)/2))
$ last_step = (Init_dfnp-1)/2
*
500 continue
*
if (F_dgtflt_L) then
if (Lun_out.gt.0) write(Lun_out,1000) Lctl_step,initial_step
else
if (Lun_out.gt.0) write(Lun_out,1001) Lctl_step,last_step,initial_step
endif
*
* 4D-Var: Read trajectory for conversion if requested
* ---------------------------------------------------
call v4d_rwconv0
*C Evaluate gradient forcing at required time
* ------------------------------------------
call tmg_start0
(56, 'PRO_AD' )
call v4d_ctrlgrd
()
call tmg_stop0
(56)
*
if (Schm_sfix_L) call surfix_ad
( )
*
* Adjoint of
*C Digital filter
* --------------
if ( F_dgtflt_L ) call digflt_ad
( )
*
*C Perform output if required
* --------------------------
call blocstat
()
if (V4dg_output_L) call out_dyn_ad
()
*
* Adjoint of
*C Diffusion, Dynamics and Physics
* -------------------------------
if ( .not.identity_4dvar_L ) then
*
* Adjoint of
* Physics timestep & Horizontal diffusion & Vertical sponge
* ---------------------------------------------------------
call tmg_start0
(63, 'PHY_AD' )
call hdif_phy_ad
call tmg_stop0
(63)
*
* Adjoint of
* Dynamics timestep
* -----------------
call tmg_start0
(62, 'DYN_AD' )
call dynstep_ad
( )
call tmg_stop0
(62)
*
* Adjoint of
* Horizontal diffusion & Vertical sponge (Initial timestep)
* ---------------------------------------------------------
if (Lctl_step.eq.1.and.Hzd_hdif0_1_L) call hdif0_ad
*
endif ! identity_4dvar_L
*
if (Lun_out.gt.0) write(Lun_out,3000) Lctl_step
*
Lctl_step = Lctl_step - 1
*
if (Lctl_step.gt.last_step) goto 500
*
if (Lun_out.gt.0) write(Lun_out,4000) Lctl_step
*
* 4D-Var: Read trajectory for conversion if requested
* ---------------------------------------------------
call v4d_rwconv0
*
*C Evaluate gradient forcing at INITIAL time (before adjoint of preprocessing)
* ---------------------------------------------------------------------------
call tmg_start0
(56, 'PRO_AD' )
call v4d_ctrlgrd
()
call tmg_stop0
(56)
*
*C Perform output if required
* --------------------------
if (V4dg_output_L) call v4d_blocstat
()
*
* ---------------------------------------------------------------
*
1000 format(/,'GEM_RUN_AD: PERFORMING ADJ INITIALIZATION TIMESTEP #',I8,
$ ' OUT OF ',I8,
+ /,'================================================')
1001 format(/,'GEM_RUN_AD: PERFORMING TIMESTEP #',I8,' BETWEEN ',I8,' AND ',I8,
+ /,'=================================================')
3000 format(/,'THE TIME STEP ',I8,' IS COMPLETED')
4000 format(/,'END OF THE TIME LOOP (S/R GEM_RUN_AD) AT TIMESTEP',I8,
+/,'========================================================')
*
* ---------------------------------------------------------------
*
return
end