!-------------------------------------- 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 afvezvrot - Adjoint of vezvrot.
!

      subroutine afvezvrot(pu,pv,pro,kobs,knk) 1,3
!
      IMPLICIT NONE
      integer knk,kobs 
      real*8 pu(knk),pv(knk),pro(3,3)
!
!Author: Luc Fillion - ARMA/MSC - 17 Feb 05
!
!revision: Luc Fillion - ARMA/MSC - 25 Feb 2005: Fast version of avezvrot
!
#include "taglam4d.cdk"
#include "comdimo.cdk"
#include "comroto.cdk"
!
      integer ji,jj,jk
      real*8 zsinlonr,zcoslonr,zsinlatr,zcoslatr
      real*8 zcoslonob,zsinlonob,zrsinlatob
      real*8 zuvcart(3,knk)
      real*8 zxyz(3,knk)
      real*8 zro(3,3)
!
!!
      do ji=1,3
      do jj=1,3
        zro(ji,jj)=pro(jj,ji)
      enddo
      enddo
!
      zcoslonob=rcoslonob(kobs)
      zsinlonob=rsinlonob(kobs)
      zrsinlatob=rrsinlatob(kobs)
!
      call afcartauv(zuvcart,pu,pv,zcoslonob,zsinlonob,zrsinlatob,knk)
!
      do jk=1,knk
        zxyz(1,jk)=0.0
        zxyz(2,jk)=0.0
        zxyz(3,jk)=0.0
      enddo
!
      call mxm8(zro,3,zuvcart,3,zxyz,knk)
!
      zsinlonr=rsinlonr(kobs)
      zcoslonr=rcoslonr(kobs)
      zsinlatr=rsinlatr(kobs)
      zcoslatr=rcoslatr(kobs)
!
      call afuvacart(pu,pv,zxyz,zsinlonr,zcoslonr,zsinlatr,zcoslatr,knk)
!
      return
      end