!-------------------------------------- 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 adw_main_tl - TLM of adw_main
*
#include "model_macros_f.h"
*

      subroutine adw_main_tl ( F_it ) 1,9
*
#include "impnone.cdk"
*
      integer F_it
*
*author
*     monique tanguay
*
*revision
* v2_31 - Tanguay M.        - initial MPI version
* v3_00 - Tanguay M.        - adapt to restructured adw_main 
* v3_31 - Tanguay M.        - SETTLS option
*
*language
*     fortran 77
*
*object
*     see id section
*
*arguments
*______________________________________________________________________
*        |                                                       |     |
* NAME   | DESCRIPTION                                           | I/O |
*--------|-------------------------------------------------------|-----|
* F_it   | total number of iterations for trajectories           |  i  |
*________|_______________________________________________________|_____|
*
*implicits
#include "glb_ld.cdk"
#include "lun.cdk"
#include "adw.cdk"
#include "orh.cdk"
#include "schm.cdk"
************************************************************************
*
      real , dimension (Adw_nit*Adw_njt*l_nk) :: u,v,w
      real , dimension (Adw_nit*Adw_njt*l_nk) :: um,vm,wm
      logical step_settls_L
*
************************************************************************
      if (Lun_debug_L) write (Lun_out,1000)
*
      step_settls_L = .NOT.(Orh_crank_L.or..not.Schm_settls_L)
*
*     ----------------------------
      if (.not.step_settls_L) then
*     ----------------------------
*
*        TRAJECTORY
*        ----------
         call adw_main_1_wnd_tr ( um, vm, wm, Adw_nit, Adw_njt, l_nk) 
*
*        TLM
*        ---
         call adw_main_1_wnd ( u, v, w, Adw_nit, Adw_njt, l_nk)
*
*        TLM and TRAJECTORY
*        ------------------
         call adw_main_2_pos_tl ( F_it, u, v, w, um, vm, wm )
*
*     ----
      else
*     ----
*
*        Recover TRAJ WINDS T1 and TW
*        ----------------------------
         call v4d_rwtraj (16)
*
*        TRAJECTORY
*        ----------
         call adw_main_1_wnd_settls_tr ( um, vm, wm, Adw_nit, Adw_njt, l_nk)
*
*        TLM
*        ---
         call adw_main_1_wnd_settls ( u, v, w, Adw_nit, Adw_njt, l_nk)
*
*        Recover TRAJ XT1 YT1 ZT1
*        ------------------------
         call v4d_rwtraj (15)
*
*        TLM and TRAJECTORY
*        ------------------
         call adw_main_2_pos_settls_tl ( F_it, u, v, w, um, vm, wm )
*
*     -----
      endif
*     -----
*
*     TLM and TRAJECTORY
*     ------------------
      call adw_main_3_int_tl ( u, v, w, um, vm, wm )
*
***********************************************************************
*
 1000  format(3X,'TLM of ADVECTE THE RIGHT-HAND-SIDES: (S/R ADW_MAIN_TL)')
*
      return
      end