*IF DEF,A01_1A,OR,DEF,A01_1B,OR,DEF,A01_2A,OR,DEF,A01_2B                   AWI3F402.4      
C ******************************COPYRIGHT******************************    GTS2F400.9955   
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.    GTS2F400.9956   
C                                                                          GTS2F400.9957   
C Use, duplication or disclosure of this code is subject to the            GTS2F400.9958   
C restrictions as set forth in the contract.                               GTS2F400.9959   
C                                                                          GTS2F400.9960   
C                Meteorological Office                                     GTS2F400.9961   
C                London Road                                               GTS2F400.9962   
C                BRACKNELL                                                 GTS2F400.9963   
C                Berkshire UK                                              GTS2F400.9964   
C                RG12 2SZ                                                  GTS2F400.9965   
C                                                                          GTS2F400.9966   
C If no contract has been raised with this copy of the code, the use,      GTS2F400.9967   
C duplication or disclosure of it is strictly prohibited.  Permission      GTS2F400.9968   
C to do so must first be obtained in writing from the Head of Numerical    GTS2F400.9969   
C Modelling at the above address.                                          GTS2F400.9970   
C ******************************COPYRIGHT******************************    GTS2F400.9971   
C                                                                          GTS2F400.9972   
CLL Subroutine SWDTCA   ----------------------------------------------     SWDTCA1A.3      
CLL                                                                        SWDTCA1A.4      
CLL Purpose :                                                              SWDTCA1A.5      
CLL  It calculates a total cloud amount diagnostic, the fraction of the    SWDTCA1A.6      
CLL  grid-box where cloud exists at some level(s), consistent with the     SWDTCA1A.7      
CLL  random overlap assumption used in the SW and whichever cloud          SWDTCA1A.8      
CLL  distribution is being used there.                                     SWDTCA1A.9      
CLL  Suitable for single column model use.                                 SWDTCA1A.10     
CLL                                                                        SWDTCA1A.11     
CLL                      Author: William Ingram 15 Oct 1992                SWDTCA1A.12     
CLL                                                                        SWDTCA1A.13     
CLL  Model            Modification history from model version 3.0:         SWDTCA1A.14     
CLL version  Date                                                          SWDTCA1A.15     
CLL                                                                        SWDTCA1A.16     
CLL Programming standard :                                                 SWDTCA1A.17     
CLL  It conforms to programming standard A of UMDP 4 (version 2 18/1/90)   SWDTCA1A.18     
CLL  and has no features deprecated by 8X.                                 SWDTCA1A.19     
CLL  The code is standard FORTRAN 77 except for having ! comments          SWDTCA1A.20     
CLL                                                                        SWDTCA1A.21     
CLL Logical components covered : D23 (radiation diagnostics)               SWDTCA1A.22     
CLL                                                                        SWDTCA1A.23     
CLL Project task : P23 (radiation)                                         SWDTCA1A.24     
CLL                                                                        SWDTCA1A.25     
CLL External documentation:                                                SWDTCA1A.26     
CLL                                                                        SWDTCA1A.27     
CLLEND -----------------------------------------------------------------   SWDTCA1A.28     

      SUBROUTINE SWDTCA (LCA, CCA, NCLDS, L1, L2, TCA)                      6SWDTCA1A.29     
C                                                                          SWDTCA1A.30     
      INTEGER!, INTENT (IN)                                                SWDTCA1A.31     
     &     L1,                       ! First dimension of input arrays     SWDTCA1A.32     
     &     L2,                       ! Number of points to be treated      SWDTCA1A.33     
     &     NCLDS                     ! Number of layers with cloud         SWDTCA1A.34     
      REAL!, INTENT (IN)                                                   SWDTCA1A.35     
     &     LCA(L1,NCLDS), CCA(L1)    ! Layer & convective cloud fraction   SWDTCA1A.36     
      REAL!, INTENT (OUT) ::                                               SWDTCA1A.37     
     &     TCA(L1)                   ! Total cloud amount                  SWDTCA1A.38     
C                                                                          SWDTCA1A.39     
CL    !  SWDTCA has no EXTERNAL calls                                      SWDTCA1A.40     
CL    !  and no dynamically allocated workspace.                           SWDTCA1A.41     
C*                                                                         SWDTCA1A.42     
      INTEGER LEVEL, J               ! Loopers over level & point          SWDTCA1A.43     
C                                                                          SWDTCA1A.44     
CL    ! Since LCA is the fractional cover by layer cloud outside the       SWDTCA1A.45     
CL    ! convective cloud, can just multiply the cloud-free fractions       SWDTCA1A.46     
CL    ! together for each cloud present:                                   SWDTCA1A.47     
C     !                                                                    SWDTCA1A.48     
C                                                                          SWDTCA1A.49     
      DO J=1, L2                                                           SWDTCA1A.50     
        TCA(J) = 1. - CCA(J)                                               SWDTCA1A.51     
      ENDDO                                                                SWDTCA1A.52     
      DO 100 LEVEL=1, NCLDS                                                SWDTCA1A.53     
        DO J=1, L2                                                         SWDTCA1A.54     
          TCA(J) = TCA(J) * ( 1. - LCA(J,LEVEL) )                          SWDTCA1A.55     
        ENDDO                                                              SWDTCA1A.56     
  100 CONTINUE                                                             SWDTCA1A.57     
C                                                                          SWDTCA1A.58     
CL    !  Finally, convert clear fraction into total cloud amount:          SWDTCA1A.59     
C                                                                          SWDTCA1A.60     
      DO J=1, L2                                                           SWDTCA1A.61     
        TCA(J) = 1. - TCA(J)                                               SWDTCA1A.62     
      ENDDO                                                                SWDTCA1A.63     
C                                                                          SWDTCA1A.64     
      RETURN                                                               SWDTCA1A.65     
      END                                                                  SWDTCA1A.66     
*ENDIF A01_1A,OR,A01_1B,OR,A01_2A                                          SWDTCA1A.67