!-------------------------------------- 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 --------------------------------------
!
*DECK 

      SUBROUTINE PROJEF ( P, PDS ) 1,1
#if defined (DOC)
*
***s/r PROJEF  -  Computes the matrix used to perform finite-element
*                 projection in the vertical coordinate, used
*                 by subroutine FEVOP.
*                 
*
*Author  : Gilles Verner -  Jun 1984
*
*Revision: Luc Fillion - RPN/AES Jan 94: Major modifications to suit the
*                                        variational analysis environment.
*        - Luc Fillion - Jan 97 - Uses 3D-Var's levels rather than previously specified levels.
*Arguments
*     o : P     = Output matrix
*     i : PDS   = Vector of sigma-increments. 
*
#endif
      IMPLICIT NONE
*implicits
#include "comdim.cdk"
C
      REAL*8 P(NFLEV,NFLEV), PDS(NFLEV)
C
      INTEGER  JI, IM
      REAL*8     ZT, ZS
*modules
      EXTERNAL MATOZ
C
      CALL MATOZ ( P, NFLEV, NFLEV, NFLEV )
      PDS(NFLEV) = 0.
      ZT = 1./3.
      ZS = 1./6.
      P(1,1) = ZT * PDS(1)
      DO 10 JI = 2, NFLEV
        IM = JI-1
        P(JI,IM) = ZS * PDS(IM)
        P(IM,JI) = P(JI,IM)
 10     P(JI,JI) = ZT * (PDS(IM) + PDS(JI))
C
C
      RETURN
      END