!-------------------------------------- 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 GDTOMVOAD 1,1
*
#if defined (DOC)
*
***s/r GDTOMVOAD- Adjoint of the observation operator with observations
*                 located at each analysis grid point (special case of BILINAD)
*
*Author  : Mark Buehner October, 1998
*
*Revision:
**    Purpose:  The Adjoint of GDTOMVO
*
*
#endif
      IMPLICIT NONE
*implicits
#include "pardim.cdk"
#include "comdim.cdk"
#include "comdimo.cdk"
#include "comleg.cdk"
#include "comgem.cdk"
#include "comgd0.cdk"
#include "commvo.cdk"
#include "comstate.cdk"
*
      INTEGER   JLEV, JGL, JLON, JOBS, JK
      INTEGER   ILON, ILOS, ILA, IMAX
C
C*    0. PUT TO ZERO EXTRA ROWS IN GRAD TABLES
C     ----------------------------------------
C
      CALL TRANSFER('ZGD0')
C
C*    2. LOOP OVER ALL THE OBSERVATIONS
C     ---------------------------------
      JOBS=0
      IMAX = NILON(1)
      DO ILON = 1, IMAX
        DO ILA = 1, NJ
          JOBS=JOBS+1
          DO JK = 1, nflev
            if(NGEXIST(nguu).eq.1) then
              ut0(ILON,JK,ILA) = gomu(JK,JOBS)
            endif
            if(NGEXIST(ngvv).eq.1) then
              vt0(ILON,JK,ILA) = gomv(JK,JOBS)
            endif
            if(NGEXIST(ngq).eq.1) then
              q0(ILON,JK,ILA) = gomq(JK,JOBS)
            endif
            if(NGEXIST(nggz).eq.1) then
              gz0(ILON,JK,ILA) = gomgz(JK,JOBS)
            endif
            if(NGEXIST(ngtt).eq.1) then
              tt0(ILON,JK,ILA) = gomt(JK,JOBS)
            endif
            if(NGEXIST(ngoz).eq.1) then
              goz0(ILON,JK,ILA) = gomoz(JK,JOBS)
            endif
            if(NGEXIST(ngtr).eq.1) then
              gtr0(ILON,JK,ILA) = gomtr(JK,JOBS)
            endif
          enddo
          if(NGEXIST(ngps).eq.1) then
            gps0(ILON,1,ILA) = gomps(1,JOBS)
          endif
        enddo
      enddo
C
C     1.0  TRANSFORM PHYSICAL GRADIENTS INTO COVARIANTS
C
      DO JLEV = 1, NFLEV
        DO JGL = 1, NJ
          IMAX = NILON(JGL)
          DO JLON = 1, IMAX
            UT0(JLON,JLEV,JGL) = UT0(JLON,JLEV,JGL) * CONPHY(JGL)
            VT0(JLON,JLEV,JGL) = VT0(JLON,JLEV,JGL) * CONPHY(JGL)
          ENDDO
        ENDDO
      ENDDO
C
      DO JLEV = 1, NKGDIM
        DO JGL = 1, NJ
          IMAX = NILON(JGL)
          DO JLON = 1, IMAX
            GD(JLON,JLEV,JGL) = GD(JLON,JLEV,JGL) *
     +           NILON(JGL) / RWT(JGL)
          ENDDO
        ENDDO
      ENDDO
C
      RETURN
      END