!-------------------------------------- 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 itf_phy_uvgridscal0_ad - ADJ of itf_phy_uvgridscal0 
*                               (variant for OPENMP LAM) 
*
#include "model_macros_f.h"
*

      subroutine itf_phy_uvgridscal0_ad (F_put,F_pvt,DIST_DIM,Nk,vers) 4,4
*
      implicit none
*
      integer DIST_DIM,Nk
      real F_put (DIST_SHAPE,Nk), F_pvt (DIST_SHAPE,Nk)
      logical vers
*
*author
*     Stephane Laroche     - Janvier 2001
*
*revision
* v3_00 - Laroche S.       - initial MPI version
* v3_21 - Tanguay M.       - Revision Openmp 
* v3_30 - Tanguay M.       - Revision Openmp LAM 
* v3_31 - Tanguay M.       - replace G_nk and l_nk by Nk
*
*object
*	ADJ of Cubic interpolation of the dynamics fields from their own grid
*	to the grid where the physics tendencies are computed
*	
*arguments
*  Name        I/O                 Description
*----------------------------------------------------------------
* F_put       
* F_pvt
* vers          I          .true.  wind grid ---> scalar grid    
*                          .false. wind grid <--- scalar grid 
*----------------------------------------------------------------
*    
*implicits
#include "glb_ld.cdk"
#include "schm.cdk"
#include "intuv.cdk"
#include "inuvl.cdk"
*
**
      integer i,j,k,i0,j0,in,jn
      integer nsu,ndu,nsv,ndv
      real wk1(LDIST_SHAPE,Nk)
      real*8, parameter :: ZERO_8 = 0.0
*
*     ---------------------------------------------------------------
*
      if(vers) then
       nsu = 1
       ndu = 0
       nsv = 2
       ndv = 0
      else
       nsu = 0
       ndu = 1
       nsv = 0
       ndv = 2
      endif
C
C     y component
C
      call uv_acg2g_tr(nsv,ndv,i0,in,j0,jn)
*
!$omp parallel 
*
!$omp do
      do k=1,Nk
         do j=l_miny,l_maxy
         do i=l_minx,l_maxx
            wk1(i,j,k) = ZERO_8
        end do
        end do
         do j= j0, jn
         do i= i0, in
            wk1(i,j,k)   = F_pvt(i,j,k)
            F_pvt(i,j,k) = ZERO_8
        end do
        end do
      end do
!$omp end do
*
!$omp end parallel 
*
      call uv_acg2g0_ad(wk1,F_pvt,nsv,ndv,LDIST_DIM,Nk,i0,in,j0,jn)
C
C     x component
C

      call uv_acg2g_tr(nsu,ndu,i0,in,j0,jn)
*
!$omp parallel 

!$omp do
      do k=1,Nk
         do j=l_miny,l_maxy
         do i=l_minx,l_maxx
            wk1(i,j,k) = ZERO_8
        end do
        end do
         do j= j0, jn
         do i= i0, in
            wk1(i,j,k)   = F_put(i,j,k)
            F_put(i,j,k) = ZERO_8
        end do
        end do
      end do
!$omp end do
*
!$omp end parallel 
*
      call uv_acg2g0_ad(wk1,F_put,nsu,ndu,LDIST_DIM,Nk,i0,in,j0,jn)
*
*     ---------------------------------------------------------------
*
      return
      end