*=*=*=*= geopot.html =*=*=*=*
SUBROUTINE geopot

SUBROUTINE geopot


      SUBROUTINE geopot (ngrid,h, pks, phis, phi )
      IMPLICIT NONE

c=======================================================================
c
c   Auteur:  P. Le Van
c   -------
c
c   Objet:
c   ------
c
c    *******************************************************************
c    .... calcul du geopotentiel aux niveaux s  .....
c    *******************************************************************
c
c     ....   l'integration se fait de bas en haut  ....
c
c     h, pks et phis  sont des arguments d'entree pour le s-pg ......
c           phi        est  un argument de sortie pour le s-pg  .....
c
c=======================================================================
c-----------------------------------------------------------------------
c   Declarations:
c   -------------

#include "dimensions.h"
#include "paramet.h"
#include "comvert.h"

c   Arguments:
c   ----------

      INTEGER ngrid
      REAL h(ngrid,llm),pks(ngrid),phis(ngrid),phi(ngrid,llm)


c   Local:
c   ------

      REAL  dss2
      INTEGER   l,ij

c-----------------------------------------------------------------------
c     calcul de phi au niveau 1 pres du sol  .....

      DO 1 ij = 1,ngrid
      phi( ij,1 ) = phis( ij ) + pks( ij ) * h( ij,1 ) * ds( 1 )
   1  CONTINUE

c     calcul de phi aux niveaux superieurs  .......

      DO 6 l = 2,llm
      dss2 = 0.5*ds(l)

      DO 3 ij = 1,ngrid
      phi(ij,l) = phi(ij,l-1) + pks(ij) *( h(ij,l-1) + h(ij,l) ) *dss2
   3  CONTINUE

   6  CONTINUE
      RETURN
      END