*IF DEF,RECON                                                              CVHGT1A.2      
C *****************************COPYRIGHT******************************     CVHGT1A.3      
C (c) CROWN COPYRIGHT 1996, METEOROLOGICAL OFFICE, All Rights Reserved.    CVHGT1A.4      
C                                                                          CVHGT1A.5      
C Use, duplication or disclosure of this code is subject to the            CVHGT1A.6      
C restrictions as set forth in the contract.                               CVHGT1A.7      
C                                                                          CVHGT1A.8      
C                Meteorological Office                                     CVHGT1A.9      
C                London Road                                               CVHGT1A.10     
C                BRACKNELL                                                 CVHGT1A.11     
C                Berkshire UK                                              CVHGT1A.12     
C                RG12 2SZ                                                  CVHGT1A.13     
C                                                                          CVHGT1A.14     
C If no contract has been raised with this copy of the code, the use,      CVHGT1A.15     
C duplication or disclosure of it is strictly prohibited.  Permission      CVHGT1A.16     
C to do so must first be obtained in writing from the Head of Numerical    CVHGT1A.17     
C Modelling at the above address.                                          CVHGT1A.18     
C ******************************COPYRIGHT******************************    CVHGT1A.19     
! Returns the height of each v point on the Charney-Phillips grid given    CVHGT1A.20     
!                                                                          CVHGT1A.21     
! Subroutine interface:                                                    CVHGT1A.22     

      SUBROUTINE CV_HGT(z_in,z_out,                                         3CVHGT1A.23     
     &                  points,levels,j,row_length,                        CVHGT1A.24     
     &                  lam)                                               CVHGT1A.25     
                                                                           CVHGT1A.26     
      IMPLICIT NONE                                                        CVHGT1A.27     
!                                                                          CVHGT1A.28     
! Description: Calculates the height at each v point on the Charney        CVHGT1A.29     
!              Phillips grid using an average of the two adjacent height   CVHGT1A.30     
!              of the pressure points along each column.                   CVHGT1A.31     
!                                                                          CVHGT1A.32     
!                                                                          CVHGT1A.33     
! Current Code Owner: I Edmond                                             CVHGT1A.34     
!                                                                          CVHGT1A.35     
! History:                                                                 CVHGT1A.36     
! Version   Date     Comment                                               CVHGT1A.37     
! -------   ----     -------                                               CVHGT1A.38     
! 4.1       15/6/96   Original code. Ian Edmond                            CVHGT1A.39     
!                                                                          CVHGT1A.40     
! Code Description:                                                        CVHGT1A.41     
!   Language: FORTRAN 77 + common extensions.                              CVHGT1A.42     
!   This code is written to UMDP3 v6 programming standards.                CVHGT1A.43     
!                                                                          CVHGT1A.44     
! System component covered: <appropriate code>                             CVHGT1A.45     
! System Task:              <appropriate code>                             CVHGT1A.46     
!                                                                          CVHGT1A.47     
! Declarations:                                                            CVHGT1A.48     
!   These are of the form:-                                                CVHGT1A.49     
!     INTEGER      ExampleVariable      !Description of variable           CVHGT1A.50     
!                                                                          CVHGT1A.51     
! Subroutine arguments                                                     CVHGT1A.52     
!   Scalar arguments with intent(in):                                      CVHGT1A.53     
       INTEGER                                                             CVHGT1A.54     
     & points      ! Number of points to be processed.                     CVHGT1A.55     
     &,levels      ! Number of levels in source data.                      CVHGT1A.56     
     &,row_length  ! Number of columns per level.                          CVHGT1A.57     
                                                                           CVHGT1A.58     
!   Array  arguments with intent(in):                                      CVHGT1A.59     
       REAL                                                                CVHGT1A.60     
     & z_in(points,levels) ! Full level heights. i.e press level heights   CVHGT1A.61     
                                                                           CVHGT1A.62     
!   Array  arguments with intent(out):                                     CVHGT1A.63     
      REAL                                                                 CVHGT1A.64     
     & z_out(points-row_length) ! 3-D field of heights at which            CVHGT1A.65     
     &                                 ! PF v is stored.                   CVHGT1A.66     
                                                                           CVHGT1A.67     
! Local scalars:                                                           CVHGT1A.68     
       INTEGER                                                             CVHGT1A.69     
     & i,j                                                                 CVHGT1A.70     
                                                                           CVHGT1A.71     
       LOGICAL                                                             CVHGT1A.72     
     & lam                                                                 CVHGT1A.73     
                                                                           CVHGT1A.74     
!- End of header                                                           CVHGT1A.75     
                                                                           CVHGT1A.76     
        Do i = 1, points-row_length                                        CVHGT1A.77     
                                                                           CVHGT1A.78     
         ! v is only defined for (rows-1) rows.                            CVHGT1A.79     
          z_out(i) = (z_in(i,j) + z_in(i+row_length,j)) / 2.0              CVHGT1A.80     
                                                                           CVHGT1A.81     
        End do ! i                                                         CVHGT1A.82     
                                                                           CVHGT1A.83     
      RETURN                                                               CVHGT1A.84     
      END                                                                  CVHGT1A.85     
*ENDIF                                                                     CVHGT1A.86