!-------------------------------------- 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 hatoprg - downward vertical integration 
*
#include "model_macros_f.h"
*

      subroutine hatoprg ( F_gg, F_ff, F_con, F_hz_8, ng, Nk ) 10
*
      implicit none
*
      integer ng, Nk
      real F_gg(ng,Nk),F_ff(ng,Nk),F_con
      real*8  F_hz_8(Nk)
*
*author
*     J. Cote - rpn - nov 93 
*
*revision
* v2_00 - Desgagne M.       - initial MPI version (from hatoprg v1_03)
* v3_00 - Desgagne & Lee    - Lam configuration
* v3_21 - Desgagne M.       - Revision OpenMP
* v3_30 - Tanguay M.        - Revision Openmp LAM 
*
*object  DOWNWARD vertical integration 
*
*                 / z(sfc) 
*        G   =  C |        F dz 
*         k       / z(k)
*
*arguments
*  Name        I/O                 Description
*----------------------------------------------------------------
*  F_gg        O          resulting vertical integration
*  F_ff        I          input field to be integrated  
*  F_con       I          mutiplication coefficient 
*  F_hz_8      I          intervals in z-direction
*----------------------------------------------------------------
*
*implicits 
#include "glb_ld.cdk"
*
      integer i, k
      real*8 wk(G_nk-1),r
*
**
*     __________________________________________________________________
*
      wk(:  ) = .5*F_con*F_hz_8(:)
*
!$omp parallel private(r,k)
!$omp do
      do i= 1, ng
*
         r=0.
         do k= G_nk-1, 1, -1
*
           F_gg(i,k+1) = r
           r = r + wk(k)*( F_ff(i,k+1) + F_ff(i,k) )
*
         end do
         F_gg(i,1) = r
*
      end do
!$omp enddo
!$omp end parallel
*
*     __________________________________________________________________
*
      return
      end