C *****************************COPYRIGHT******************************             RAD_ALL.7713  
C (c) CROWN COPYRIGHT 1996, METEOROLOGICAL OFFICE, All Rights Reserved.            RAD_ALL.7714  
C                                                                                  RAD_ALL.7715  
C Use, duplication or disclosure of this code is subject to the                    RAD_ALL.7716  
C restrictions as set forth in the contract.                                       RAD_ALL.7717  
C                                                                                  RAD_ALL.7718  
C                Meteorological Office                                             RAD_ALL.7719  
C                London Road                                                       RAD_ALL.7720  
C                BRACKNELL                                                         RAD_ALL.7721  
C                Berkshire UK                                                      RAD_ALL.7722  
C                RG12 2SZ                                                          RAD_ALL.7723  
C                                                                                  RAD_ALL.7724  
C If no contract has been raised with this copy of the code, the use,              RAD_ALL.7725  
C duplication or disclosure of it is strictly prohibited.  Permission              RAD_ALL.7726  
C to do so must first be obtained in writing from the Head of Numerical            RAD_ALL.7727  
C Modelling at the above address.                                                  RAD_ALL.7728  
C ******************************COPYRIGHT******************************            RAD_ALL.7729  
C                                                                                  RAD_ALL.7730  
!+ Subroutine to determine the global topmost cloudy layer.                        RAD_ALL.7731  
!                                                                                  RAD_ALL.7732  
! Purpose:                                                                         RAD_ALL.7733  
!   The routine determines the topmost cloudy layer over the whole                 RAD_ALL.7734  
!   computational domain for use in configurations of the model where              RAD_ALL.7735  
!   results must be bit-reproducible irrespective of the number of                 RAD_ALL.7736  
!   segments.                                                                      RAD_ALL.7737  
!                                                                                  RAD_ALL.7738  
! Method:                                                                          RAD_ALL.7739  
!   The arrays LCA for layer cloud and CCT for convective cloud are                RAD_ALL.7740  
!   searched to determine the topmost layer occupied by cloud.                     RAD_ALL.7741  
!                                                                                  RAD_ALL.7742  
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.7743  
!                                                                                  RAD_ALL.7744  
! History:                                                                         RAD_ALL.7745  
!       Version         Date                    Comment                            RAD_ALL.7746  
!       4.2             17-12-96                Original Code                      RAD_ALL.7747  
!                                               (J. M. Edwards)                    RAD_ALL.7748  
!        4.3             17-04-97                Delete trailing blank l           RAD_ALL.7749  
!                                                (A. Brady)                        RAD_ALL.7750  
!       4.4             23-09-97                Lower limit set for                RAD_ALL.7751  
!                                               searching.                         RAD_ALL.7752  
!                                               (J. M. Edwards)                    RAD_ALL.7753  
!                                                                                  RAD_ALL.7754  
! Description of Code:                                                             RAD_ALL.7755  
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.7756  
!                                                                                  RAD_ALL.7757  
!- ---------------------------------------------------------------------           RAD_ALL.7758  
      SUBROUTINE R2_GLOBAL_CLOUD_TOP(N_POINTS, NLEVS, NCLDS                        RAD_ALL.7759  
!                       Convective cloud Fields                                    RAD_ALL.7760  
     &   , CCA, CCT                                                                RAD_ALL.7761  
!                       Layer cloud Fields                                         RAD_ALL.7762  
     &   , LCA                                                                     RAD_ALL.7763  
!                       Calculated top of cloud fields.                            RAD_ALL.7764  
     &   , GLOBAL_CLOUD_TOP                                                        RAD_ALL.7765  
!                       Size of arrays                                             RAD_ALL.7766  
     &   , ND_POINTS                                                               RAD_ALL.7767  
     &   )                                                                         RAD_ALL.7768  
!                                                                                  RAD_ALL.7769  
!                                                                                  RAD_ALL.7770  
!                                                                                  RAD_ALL.7771  
      IMPLICIT NONE                                                                RAD_ALL.7772  
!                                                                                  RAD_ALL.7773  
!                                                                                  RAD_ALL.7774  
!     DUMMY ARGUMENTS                                                              RAD_ALL.7775  
!                                                                                  RAD_ALL.7776  
!     SIZES OF ARRAYS.                                                             RAD_ALL.7777  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.7778  
     &     ND_POINTS                                                               RAD_ALL.7779  
!             HORIZONTAL DIMENSION OF ARRAYS                                       RAD_ALL.7780  
!                                                                                  RAD_ALL.7781  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.7782  
     &     N_POINTS                                                                RAD_ALL.7783  
!             NUMBER OF POINTS TO CONSIDER                                         RAD_ALL.7784  
     &   , NLEVS                                                                   RAD_ALL.7785  
!             NUMBER OF LEVELS CONSIDERED                                          RAD_ALL.7786  
     &   , NCLDS                                                                   RAD_ALL.7787  
!             NUMBER OF CLOUDY LAYERS                                              RAD_ALL.7788  
!                                                                                  RAD_ALL.7789  
!     FIELDS FOR CONVECTIVE CLOUDS                                                 RAD_ALL.7790  
      REAL      !, INTENT(IN)                                                      RAD_ALL.7791  
     &     CCA(ND_POINTS)                                                          RAD_ALL.7792  
!             AMOUNTS OF CONVECTIVE CLOUD                                          RAD_ALL.7793  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.7794  
     &     CCT(ND_POINTS)                                                          RAD_ALL.7795  
!             LEVEL OF TOP OF CONVECTIVE CLOUD                                     RAD_ALL.7796  
!             I.E. CONVECTIVE CLOUD REACHES THE BASE OF LAYER CCT,                 RAD_ALL.7797  
!             BUT DOES NOT EXTEND INTO IT.                                         RAD_ALL.7798  
!                                                                                  RAD_ALL.7799  
!     FIELDS FOR STRATIFORM CLOUDS                                                 RAD_ALL.7800  
      REAL      !, INTENT(IN)                                                      RAD_ALL.7801  
     &     LCA(ND_POINTS, NCLDS)                                                   RAD_ALL.7802  
!             AMOUNTS OF LAYER CLOUD                                               RAD_ALL.7803  
!                                                                                  RAD_ALL.7804  
      INTEGER   !, INTENT(OUT)                                                     RAD_ALL.7805  
     &     GLOBAL_CLOUD_TOP                                                        RAD_ALL.7806  
!             GLOBAL TOPMOST CLOUDY LEVEL                                          RAD_ALL.7807  
!                                                                                  RAD_ALL.7808  
!                                                                                  RAD_ALL.7809  
!     LOCAL VARIABLES                                                              RAD_ALL.7810  
      INTEGER                                                                      RAD_ALL.7811  
     &     L                                                                       RAD_ALL.7812  
!             LOOP VARIABLE                                                        RAD_ALL.7813  
      LOGICAL                                                                      RAD_ALL.7814  
     &     L_LAYER_CLEAR                                                           RAD_ALL.7815  
!             FLAG FOR LAYER FREE OF CLOUDS                                        RAD_ALL.7816  
!                                                                                  RAD_ALL.7817  
!                                                                                  RAD_ALL.7818  
!                                                                                  RAD_ALL.7819  
!     INITIALIZE THE CLOUD-TOP TO THE LAYER ABOVE THAT IN WHICH CLOUDS             RAD_ALL.7820  
!     ARE PERMITTED AND REDUCE UNTIL NON-EMPTY LAYERS ARE FOUND.                   RAD_ALL.7821  
      GLOBAL_CLOUD_TOP=NCLDS+1                                                     RAD_ALL.7822  
      L_LAYER_CLEAR=.TRUE.                                                         RAD_ALL.7823  
      DO WHILE ( (L_LAYER_CLEAR).AND.(GLOBAL_CLOUD_TOP.GT.1) )                     RAD_ALL.7824  
         GLOBAL_CLOUD_TOP=GLOBAL_CLOUD_TOP-1                                       RAD_ALL.7825  
         DO L=1, N_POINTS                                                          RAD_ALL.7826  
            L_LAYER_CLEAR=L_LAYER_CLEAR.AND.                                       RAD_ALL.7827  
     &         (LCA(L, GLOBAL_CLOUD_TOP).LE.0.0E+00).AND.                          RAD_ALL.7828  
     &         ( (CCA(L).LE.0.0E+00).OR.                                           RAD_ALL.7829  
     &           (CCT(L).LT.GLOBAL_CLOUD_TOP-1) )                                  RAD_ALL.7830  
         ENDDO                                                                     RAD_ALL.7831  
      ENDDO                                                                        RAD_ALL.7832  
!                                                                                  RAD_ALL.7833  
!                                                                                  RAD_ALL.7834  
!                                                                                  RAD_ALL.7835  
      RETURN                                                                       RAD_ALL.7836  
      END   
