!-------------------------------------- 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 --------------------------------------
!

subroutine oda_LT 4,9
  use mod4dv, only : l4dvar
  USE procs_topo,only : myid 
  implicit none
  !
  !Purpose: Adjoint of Localisation (3D) / Adjoint Model (4D) operator
  !Compute adjoint grided increments from adjoint profiled increments
  !  ->In 3D mode : Call the adjoint of the bilinear interpolator
  !  ->In 4D mode : Send adjoint profiled increments to the ADJM and wait
  !    for the grided adjoint increments
  !  ->Results are saved in COMGD
  !
  !Author  : S. Pellerin *ARMA/MRB January 2009
  !
  !Revision:
  !
  ! Luc Fillion - ARMA/EC - 5 May 2009 - Upgrade 3dvar LU/GU to v_10_2_2.
  ! Bin HE     - ARMA/MRB  - Oct. 2009 - Implemented MPI to 3DVAR. 
  ! Luc Fillion - ARMA/EC - 17 Jul 2009 - Introduce lcva_3db for 3dvar-fgat-TL-INMI.
  ! Luc Fillion - ARMA/EC - 18 Nov 2009 - Introduce rotated Gaussian grid option and gd2mvogenad...
  ! Luc Fillion - ARMA/EC - 5 May 2010 - Upgrade regional development to v_11_01_2b:
  !                         - Change logical parameters and introduce general gd2mvogenad.	
  !
#include "comdim.cdk"
#include "comcva.cdk"
#include "comgd0.cdk"
#include "comgrd_param.cdk"
  ! Local declarations
  integer :: nl_ilev,nl_err
  integer :: ierr,tgsize,sizegd 
   
  call tmg_start(51,'VAR_CH') !
  call apreobs
  call tmg_stop(51)        !

  call tmg_start(76,'GD<->PROF')
  GD=0.0D0
  sizegd=size(GD) 
  if(l4dvar.and.(.not.lcva_3db)) then
    if(grd_roule) then
      !
      !         Adjoint of: Rotate tangential wind components to real sphere tangential components
      !
      call auvrot2uv
    endif

     !
     !     Communicate adjoint profiles to the adjoint model
     !     
     call putprofad
     !     
     !     and wait for its backward integration (gridded) results
     !     
     if(myid == 0) call getdx('A')
     CALL rpn_comm_bcast(GD,sizegd,"mpi_double_precision",0,"GRID",ierr)
     if(.not.grd_roule.and.grd_typ.eq.'GU') then
        CALL gd2mvoad('TG',1)
     else
        call gd2mvogenad('TG',1)
     endif 
  else
     CALL NEWBILINAD
  endif
  call tmg_stop (76)

end subroutine oda_LT