C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.            RAD_ALL.13287 
C                                                                                  RAD_ALL.13288 
C Use, duplication or disclosure of this code is subject to the                    RAD_ALL.13289 
C restrictions as set forth in the contract.                                       RAD_ALL.13290 
C                                                                                  RAD_ALL.13291 
C                Meteorological Office                                             RAD_ALL.13292 
C                London Road                                                       RAD_ALL.13293 
C                BRACKNELL                                                         RAD_ALL.13294 
C                Berkshire UK                                                      RAD_ALL.13295 
C                RG12 2SZ                                                          RAD_ALL.13296 
C                                                                                  RAD_ALL.13297 
C If no contract has been raised with this copy of the code, the use,              RAD_ALL.13298 
C duplication or disclosure of it is strictly prohibited.  Permission              RAD_ALL.13299 
C to do so must first be obtained in writing from the Head of Numerical            RAD_ALL.13300 
C Modelling at the above address.                                                  RAD_ALL.13301 
C ******************************COPYRIGHT******************************            RAD_ALL.13302 
C                                                                                  RAD_ALL.13303 
!+ Subroutine to find maximally overlapped energy transfer coefficients.           RAD_ALL.13304 
!                                                                                  RAD_ALL.13305 
! Method:                                                                          RAD_ALL.13306 
!       Straightforward.                                                           RAD_ALL.13307 
!                                                                                  RAD_ALL.13308 
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.13309 
!                                                                                  RAD_ALL.13310 
! History:                                                                         RAD_ALL.13311 
!       Version         Date                    Comment                            RAD_ALL.13312 
!       4.0             27-07-95                Original Code                      RAD_ALL.13313 
!                                               (J. M. Edwards)                    RAD_ALL.13314 
!       4.2             Nov. 96   T3E migration: CALL WHENFGT replaced             RAD_ALL.13315 
!                                  by portable fortran code.                       RAD_ALL.13316 
!                                                S.J.Swarbrick                     RAD_ALL.13317 
!                                                                                  RAD_ALL.13318 
! Description of Code:                                                             RAD_ALL.13319 
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.13320 
!                                                                                  RAD_ALL.13321 
!- ---------------------------------------------------------------------           RAD_ALL.13322 
      SUBROUTINE OVERLAP_MIX_MAXIMUM(N_PROFILE, N_LAYER, N_CLOUD_TOP               RAD_ALL.13323 
     &   , ISOLIR, I_SOLVER                                                        RAD_ALL.13324 
     &   , W_CLOUD, W_FREE                                                         RAD_ALL.13325 
     &   , CLOUD_OVERLAP                                                           RAD_ALL.13326 
     &   , NPD_PROFILE, NPD_LAYER                                                  RAD_ALL.13327 
     &   )                                                                         RAD_ALL.13328 
!                                                                                  RAD_ALL.13329 
!                                                                                  RAD_ALL.13330 
!                                                                                  RAD_ALL.13331 
      IMPLICIT NONE                                                                RAD_ALL.13332 
!                                                                                  RAD_ALL.13333 
!                                                                                  RAD_ALL.13334 
!     SIZES OF DUMMY ARRAYS.                                                       RAD_ALL.13335 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.13336 
     &     NPD_PROFILE                                                             RAD_ALL.13337 
!             MAXIMUM NUMBER OF PROFILES                                           RAD_ALL.13338 
     &   , NPD_LAYER                                                               RAD_ALL.13339 
!             MAXIMUM NUMBER OF LAYERS                                             RAD_ALL.13340 
!                                                                                  RAD_ALL.13341 
!     INCLUDE COMDECKS.                                                            RAD_ALL.13342 
!     ------------------------------------------------------------------           DIMFIX3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       DIMFIX3A.3     
!                                                                                  DIMFIX3A.4     
!     MODULE TO SET INTERNAL DIMENSIONS TIED TO ALGORITHMS,                        DIMFIX3A.5     
!     MOSTLY FOR CLOUDS.                                                           DIMFIX3A.6     
!                                                                                  DIMFIX3A.7     
      INTEGER                                                                      DIMFIX3A.8     
     &     NPD_CLOUD_COMPONENT                                                     DIMFIX3A.9     
!             NUMBER OF COMPONENTS OF CLOUDS                                       DIMFIX3A.10    
     &   , NPD_CLOUD_TYPE                                                          DIMFIX3A.11    
!             NUMBER OF PERMITTED TYPES OF CLOUDS.                                 DIMFIX3A.12    
     &   , NPD_CLOUD_REPRESENTATION                                                DIMFIX3A.13    
!             NUMBER OF PERMITTED REPRESENTATIONS OF CLOUDS.                       DIMFIX3A.14    
     &   , NPD_OVERLAP_COEFF                                                       DIMFIX3A.15    
!             NUMBER OF OVERLAP COEFFICIENTS FOR CLOUDS                            DIMFIX3A.16    
     &   , NPD_SOURCE_COEFF                                                        DIMFIX3A.17    
!             NUMBER OF COEFFICIENTS FOR TWO-STREAM SOURCES                        DIMFIX3A.18    
     &   , NPD_REGION                                                              DIMFIX3A.19    
!             NUMBER OF REGIONS IN A LAYER                                         DIMFIX3A.20    
!                                                                                  DIMFIX3A.21    
      PARAMETER(                                                                   DIMFIX3A.22    
     &     NPD_CLOUD_COMPONENT=4                                                   DIMFIX3A.23    
     &   , NPD_CLOUD_TYPE=4                                                        DIMFIX3A.24    
     &   , NPD_CLOUD_REPRESENTATION=4                                              DIMFIX3A.25    
     &   , NPD_OVERLAP_COEFF=18                                                    DIMFIX3A.26    
     &   , NPD_SOURCE_COEFF=2                                                      DIMFIX3A.27    
     &   , NPD_REGION=3                                                            DIMFIX3A.28    
     &   )                                                                         DIMFIX3A.29    
!                                                                                  DIMFIX3A.30    
!     ------------------------------------------------------------------           DIMFIX3A.31    
!     ------------------------------------------------------------------           PRMCH3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       PRMCH3A.3     
!                                                                                  PRMCH3A.4     
!     MODULE FOR SETTING MACHINE PRECISION.                                        PRMCH3A.5     
!                                                                                  PRMCH3A.6     
      REAL                                                                         PRMCH3A.7     
     &     TOL_MACHINE                                                             PRMCH3A.8     
!             MACHINE TOLERANCE                                                    PRMCH3A.9     
     &   , SQRT_TOL_MACHINE                                                        PRMCH3A.10    
!             SQRT OF MACHINE TOLERANCE                                            PRMCH3A.11    
!                                                                                  PRMCH3A.12    
!                                                                                  PRMCH3A.13    
!     THE PRECISION SHOULD BE ABOUT 2/2^(SIZE OF SIGNIFICAND)                      PRMCH3A.14    
!                                                                                  PRMCH3A.15    
!     THE IEEE-FORMAT USES 53 BITS FOR THE SIGNIFICAND                             PRMCH3A.16    
!     IN DOUBLE PRECISION                                                          PRMCH3A.17    
!                                                                                  PRMCH3A.18    
!     THE CRAY FORMAT USES 47 BITS IN SINGLE PRECISION.                            PRMCH3A.19    
!                                                                                  PRMCH3A.20    
      PARAMETER(                                                                   PRMCH3A.21    
     &     TOL_MACHINE=1.42E-14                                                    PRMCH3A.22    
     &   , SQRT_TOL_MACHINE=1.19E-7                                                PRMCH3A.23    
     &   )                                                                         PRMCH3A.24    
!                                                                                  PRMCH3A.25    
!     ------------------------------------------------------------------           PRMCH3A.26    
!     ------------------------------------------------------------------           PRECSN3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       PRECSN3A.3     
!                                                                                  PRECSN3A.4     
!     MODULE FOR SETTING MACHINE-DEPENDENT TOLERANCES.                             PRECSN3A.5     
!     (THE COMDECK PRMCH3A MUST ALWAYS BE INCLUDED BEFORE THIS COMDECK.)           PRECSN3A.6     
!                                                                                  PRECSN3A.7     
      REAL                                                                         PRECSN3A.8     
     &     TOL_DIV                                                                 PRECSN3A.9     
!             TOLERANCE FOR DIVISION                                               PRECSN3A.10    
     &   , TOL_TEST                                                                PRECSN3A.11    
!             TOLERANCE FOR TESTING EQUALITY                                       PRECSN3A.12    
!                                                                                  PRECSN3A.13    
      PARAMETER(                                                                   PRECSN3A.14    
     &     TOL_DIV=3.2E+01*TOL_MACHINE                                             PRECSN3A.15    
     &   , TOL_TEST=1.6E+01*TOL_MACHINE                                            PRECSN3A.16    
     &   )                                                                         PRECSN3A.17    
!                                                                                  PRECSN3A.18    
!     ------------------------------------------------------------------           PRECSN3A.19    
!     ------------------------------------------------------------------           SPCRG3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       SPCRG3A.3     
!                                                                                  SPCRG3A.4     
!     MODULE TO SET FLAGS FOR DIFFERENT PORTIONS                                   SPCRG3A.5     
!     OF THE SPECTRUM.                                                             SPCRG3A.6     
!                                                                                  SPCRG3A.7     
      INTEGER                                                                      SPCRG3A.8     
     &     IP_SOLAR                                                                SPCRG3A.9     
!             SOLAR REGION                                                         SPCRG3A.10    
     &   , IP_INFRA_RED                                                            SPCRG3A.11    
!             INFRA-RED REGION                                                     SPCRG3A.12    
!                                                                                  SPCRG3A.13    
      PARAMETER(                                                                   SPCRG3A.14    
     &     IP_SOLAR=1                                                              SPCRG3A.15    
     &   , IP_INFRA_RED=2                                                          SPCRG3A.16    
     &   )                                                                         SPCRG3A.17    
!                                                                                  SPCRG3A.18    
!     ------------------------------------------------------------------           SPCRG3A.19    
!     ------------------------------------------------------------------           SOLVER3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       SOLVER3A.3     
!                                                                                  SOLVER3A.4     
!     MODULE TO DEFINE REFERENCE NUMBERS FOR SOLVERS.                              SOLVER3A.5     
!                                                                                  SOLVER3A.6     
      INTEGER                                                                      SOLVER3A.7     
     &     IP_SOLVER_PENTADIAGONAL                                                 SOLVER3A.8     
!             PENTADIAGONAL SCHEME                                                 SOLVER3A.9     
     &   , IP_SOLVER_TRIDIAG_FULL                                                  SOLVER3A.10    
!             TRIDIAGONAL SOLVER FOR FLUXES                                        SOLVER3A.11    
     &   , IP_SOLVER_TRIDIAG_PRECOND                                               SOLVER3A.12    
!             TRIDIAGONAL SOLVER FOR FLUXES                                        SOLVER3A.13    
!             WITH PRECONDITIONING OF MATRIX                                       SOLVER3A.14    
     &   , IP_SOLVER_TRIDIAG_NET                                                   SOLVER3A.15    
!             TRIDIAGONAL SOLVER FOR NET FLUX                                      SOLVER3A.16    
     &   , IP_SOLVER_SCHMETZ                                                       SOLVER3A.17    
!             SCHMETZ'S SCHEME                                                     SOLVER3A.18    
     &   , IP_SOLVER_MIX_11                                                        SOLVER3A.19    
!             MIXED COLUMN SCHEME USING FULL ENDEKADIAGONAL MATRIX                 SOLVER3A.20    
     &   , IP_SOLVER_MIX_FULL                                                      SOLVER3A.21    
!             MIXED COLUMN SCHEME FOR FULL FLUXES                                  SOLVER3A.22    
     &   , IP_SOLVER_MIX_NET                                                       SOLVER3A.23    
!             MIXED COLUMN SCHEME FOR NET FLUX                                     SOLVER3A.24    
     &   , IP_SOLVER_MIX_APP_SCAT                                                  SOLVER3A.25    
!             MIXED COLUMN SCHEME WITH APPROXIMATE SCATTERING                      SOLVER3A.26    
     &   , IP_SOLVER_MIX_NET_APP_SCAT                                              SOLVER3A.27    
!             MIXED COLUMN SCHEME FOR NET FLUXES                                   SOLVER3A.28    
!             WITH APPROXIMATE SCATTERING                                          SOLVER3A.29    
     &   , IP_SOLVER_MIX_DIRECT                                                    SOLVER3A.30    
!             DIRECT MIXED COLUMN SCHEME FOR FULL FLUXES                           SOLVER3A.31    
     &   , IP_SOLVER_MIX_DIRECT_NET                                                SOLVER3A.32    
!             DIRECT MIXED COLUMN SCHEME FOR NET FLUXES                            SOLVER3A.33    
     &   , IP_SOLVER_HOMOGEN_DIRECT                                                SOLVER3A.34    
!             DIRECT SOLVER FOR A HOMOGENEOUS COLUMN                               SOLVER3A.35    
     &   , IP_SOLVER_TRIPLE                                                        SOLVER3A.36    
!             DIRECT SOLVER FOR TRIPLE COLUMN                                      SOLVER3A.37    
     &   , IP_SOLVER_TRIPLE_APP_SCAT                                               SOLVER3A.38    
!             DIRECT SOLVER FOR TRIPLE COLUMN APPROXIMATING SCATTERING             SOLVER3A.39    
!                                                                                  SOLVER3A.40    
      PARAMETER(                                                                   SOLVER3A.41    
     &     IP_SOLVER_PENTADIAGONAL=1                                               SOLVER3A.42    
     &   , IP_SOLVER_TRIDIAG_FULL=2                                                SOLVER3A.43    
     &   , IP_SOLVER_TRIDIAG_PRECOND=3                                             SOLVER3A.44    
     &   , IP_SOLVER_TRIDIAG_NET=4                                                 SOLVER3A.45    
     &   , IP_SOLVER_SCHMETZ=5                                                     SOLVER3A.46    
     &   , IP_SOLVER_MIX_11=6                                                      SOLVER3A.47    
     &   , IP_SOLVER_MIX_FULL=7                                                    SOLVER3A.48    
     &   , IP_SOLVER_MIX_NET=8                                                     SOLVER3A.49    
     &   , IP_SOLVER_MIX_APP_SCAT=9                                                SOLVER3A.50    
     &   , IP_SOLVER_MIX_NET_APP_SCAT=10                                           SOLVER3A.51    
     &   , IP_SOLVER_MIX_DIRECT=11                                                 SOLVER3A.52    
     &   , IP_SOLVER_MIX_DIRECT_NET=12                                             SOLVER3A.53    
     &   , IP_SOLVER_HOMOGEN_DIRECT=13                                             SOLVER3A.54    
     &   , IP_SOLVER_TRIPLE=14                                                     SOLVER3A.55    
     &   , IP_SOLVER_TRIPLE_APP_SCAT=15                                            SOLVER3A.56    
     &   )                                                                         SOLVER3A.57    
!                                                                                  SOLVER3A.58    
!     ------------------------------------------------------------------           SOLVER3A.59    
!     ------------------------------------------------------------------           CLCFPT3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       CLCFPT3A.3     
!                                                                                  CLCFPT3A.4     
!     MODULE TO SET POINTERS IN CLOUD_OVERLAP.                                     CLCFPT3A.5     
!                                                                                  CLCFPT3A.6     
!     NOTE THAT SEVERAL POINTERS ARE IDENTICAL SINCE ONLY CERTAIN                  CLCFPT3A.7     
!     GROUPS OF COEFFICIENTS ARE RELEVANT TO A PARTICULAR SCHEME.                  CLCFPT3A.8     
!                                                                                  CLCFPT3A.9     
      INTEGER                                                                      CLCFPT3A.10    
     &     IP_CLOVLP_GFF                                                           CLCFPT3A.11    
!             POINTER TO GAMMA-FREE-FREE                                           CLCFPT3A.12    
     &   , IP_CLOVLP_GFC                                                           CLCFPT3A.13    
!             POINTER TO GAMMA-FREE-CLOUD                                          CLCFPT3A.14    
     &   , IP_CLOVLP_GCF                                                           CLCFPT3A.15    
!             POINTER TO GAMMA-CLOUD-FREE                                          CLCFPT3A.16    
     &   , IP_CLOVLP_GCC                                                           CLCFPT3A.17    
!             POINTER TO GAMMA-CLOUD-CLOUD                                         CLCFPT3A.18    
     &   , IP_CLOVLP_BFF                                                           CLCFPT3A.19    
!             POINTER TO BETA-FREE-FREE                                            CLCFPT3A.20    
     &   , IP_CLOVLP_BFC                                                           CLCFPT3A.21    
!             POINTER TO BETA-FREE-CLOUD                                           CLCFPT3A.22    
     &   , IP_CLOVLP_BCF                                                           CLCFPT3A.23    
!             POINTER TO BETA-CLOUD-FREE                                           CLCFPT3A.24    
     &   , IP_CLOVLP_BCC                                                           CLCFPT3A.25    
!             POINTER TO BETA-CLOUD-CLOUD                                          CLCFPT3A.26    
     &   , IP_CLOVLP_GFM                                                           CLCFPT3A.27    
!             POINTER TO GAMMA_F-                                                  CLCFPT3A.28    
     &   , IP_CLOVLP_GFP                                                           CLCFPT3A.29    
!             POINTER TO GAMMA_F+                                                  CLCFPT3A.30    
     &   , IP_CLOVLP_BFM                                                           CLCFPT3A.31    
!             POINTER TO BETA_F-                                                   CLCFPT3A.32    
     &   , IP_CLOVLP_BFP                                                           CLCFPT3A.33    
!             POINTER TO BETA_F+                                                   CLCFPT3A.34    
     &   , IP_CLOVLP_GM                                                            CLCFPT3A.35    
!             POINTER TO GAMMA_-                                                   CLCFPT3A.36    
     &   , IP_CLOVLP_GP                                                            CLCFPT3A.37    
!             POINTER TO GAMMA_+                                                   CLCFPT3A.38    
     &   , IP_CLOVLP_BM                                                            CLCFPT3A.39    
!             POINTER TO BETA_-                                                    CLCFPT3A.40    
     &   , IP_CLOVLP_BP                                                            CLCFPT3A.41    
!             POINTER TO BETA_+                                                    CLCFPT3A.42    
!                                                                                  CLCFPT3A.43    
!     POINTERS FOR TRIPLE OVERLAPS:                                                CLCFPT3A.44    
      INTEGER                                                                      CLCFPT3A.45    
     &     IP_CLOVLP_V11                                                           CLCFPT3A.46    
     &   , IP_CLOVLP_V12                                                           CLCFPT3A.47    
     &   , IP_CLOVLP_V13                                                           CLCFPT3A.48    
     &   , IP_CLOVLP_V21                                                           CLCFPT3A.49    
     &   , IP_CLOVLP_V22                                                           CLCFPT3A.50    
     &   , IP_CLOVLP_V23                                                           CLCFPT3A.51    
     &   , IP_CLOVLP_V31                                                           CLCFPT3A.52    
     &   , IP_CLOVLP_V32                                                           CLCFPT3A.53    
     &   , IP_CLOVLP_V33                                                           CLCFPT3A.54    
     &   , IP_CLOVLP_U11                                                           CLCFPT3A.55    
     &   , IP_CLOVLP_U12                                                           CLCFPT3A.56    
     &   , IP_CLOVLP_U13                                                           CLCFPT3A.57    
     &   , IP_CLOVLP_U21                                                           CLCFPT3A.58    
     &   , IP_CLOVLP_U22                                                           CLCFPT3A.59    
     &   , IP_CLOVLP_U23                                                           CLCFPT3A.60    
     &   , IP_CLOVLP_U31                                                           CLCFPT3A.61    
     &   , IP_CLOVLP_U32                                                           CLCFPT3A.62    
     &   , IP_CLOVLP_U33                                                           CLCFPT3A.63    
!                                                                                  CLCFPT3A.64    
      PARAMETER(                                                                   CLCFPT3A.65    
     &     IP_CLOVLP_GFF=1                                                         CLCFPT3A.66    
     &   , IP_CLOVLP_GFC=2                                                         CLCFPT3A.67    
     &   , IP_CLOVLP_GCF=3                                                         CLCFPT3A.68    
     &   , IP_CLOVLP_GCC=4                                                         CLCFPT3A.69    
     &   , IP_CLOVLP_BFF=5                                                         CLCFPT3A.70    
     &   , IP_CLOVLP_BFC=6                                                         CLCFPT3A.71    
     &   , IP_CLOVLP_BCF=7                                                         CLCFPT3A.72    
     &   , IP_CLOVLP_BCC=8                                                         CLCFPT3A.73    
     &   , IP_CLOVLP_GFM=5                                                         CLCFPT3A.74    
     &   , IP_CLOVLP_GFP=6                                                         CLCFPT3A.75    
     &   , IP_CLOVLP_BFM=7                                                         CLCFPT3A.76    
     &   , IP_CLOVLP_BFP=8                                                         CLCFPT3A.77    
     &   , IP_CLOVLP_GM=5                                                          CLCFPT3A.78    
     &   , IP_CLOVLP_GP=6                                                          CLCFPT3A.79    
     &   , IP_CLOVLP_BM=7                                                          CLCFPT3A.80    
     &   , IP_CLOVLP_BP=8                                                          CLCFPT3A.81    
     &   )                                                                         CLCFPT3A.82    
!                                                                                  CLCFPT3A.83    
      PARAMETER(                                                                   CLCFPT3A.84    
     &     IP_CLOVLP_V11=1                                                         CLCFPT3A.85    
     &   , IP_CLOVLP_V12=2                                                         CLCFPT3A.86    
     &   , IP_CLOVLP_V13=3                                                         CLCFPT3A.87    
     &   , IP_CLOVLP_V21=4                                                         CLCFPT3A.88    
     &   , IP_CLOVLP_V22=5                                                         CLCFPT3A.89    
     &   , IP_CLOVLP_V23=6                                                         CLCFPT3A.90    
     &   , IP_CLOVLP_V31=7                                                         CLCFPT3A.91    
     &   , IP_CLOVLP_V32=8                                                         CLCFPT3A.92    
     &   , IP_CLOVLP_V33=9                                                         CLCFPT3A.93    
     &   , IP_CLOVLP_U11=10                                                        CLCFPT3A.94    
     &   , IP_CLOVLP_U12=11                                                        CLCFPT3A.95    
     &   , IP_CLOVLP_U13=12                                                        CLCFPT3A.96    
     &   , IP_CLOVLP_U21=13                                                        CLCFPT3A.97    
     &   , IP_CLOVLP_U22=14                                                        CLCFPT3A.98    
     &   , IP_CLOVLP_U23=15                                                        CLCFPT3A.99    
     &   , IP_CLOVLP_U31=16                                                        CLCFPT3A.100   
     &   , IP_CLOVLP_U32=17                                                        CLCFPT3A.101   
     &   , IP_CLOVLP_U33=18                                                        CLCFPT3A.102   
     &   )                                                                         CLCFPT3A.103   
!                                                                                  CLCFPT3A.104   
!     ------------------------------------------------------------------           CLCFPT3A.105   
!                                                                                  RAD_ALL.13349 
!     DUMMY ARGUMENTS.                                                             RAD_ALL.13350 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.13351 
     &     N_PROFILE                                                               RAD_ALL.13352 
!             NUMBER OF PROFILES                                                   RAD_ALL.13353 
     &   , N_LAYER                                                                 RAD_ALL.13354 
!             NUMBER OF LAYERS                                                     RAD_ALL.13355 
     &   , N_CLOUD_TOP                                                             RAD_ALL.13356 
!             TOPMOST CLOUDY LAYER                                                 RAD_ALL.13357 
     &   , ISOLIR                                                                  RAD_ALL.13358 
!             SPECTRAL REGION                                                      RAD_ALL.13359 
     &   , I_SOLVER                                                                RAD_ALL.13360 
!             SOLVER TO BE USED                                                    RAD_ALL.13361 
      REAL      !, INTENT(IN)                                                      RAD_ALL.13362 
     &     W_CLOUD(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.13363 
!             CLOUD AMOUNTS                                                        RAD_ALL.13364 
!                                                                                  RAD_ALL.13365 
      REAL      !, INTENT(OUT)                                                     RAD_ALL.13366 
     &     W_FREE(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.13367 
!             CLOUD-FREE AMOUNTS                                                   RAD_ALL.13368 
     &   , CLOUD_OVERLAP(NPD_PROFILE, 0: NPD_LAYER, NPD_OVERLAP_COEFF)             RAD_ALL.13369 
!             COEFFICIENTS FOR TRANSFER OF ENERGY AT INTERFACE                     RAD_ALL.13370 
!                                                                                  RAD_ALL.13371 
!                                                                                  RAD_ALL.13372 
!     LOCAL ARGUMENTS.                                                             RAD_ALL.13373 
      INTEGER                                                                      RAD_ALL.13374 
     &     I                                                                       RAD_ALL.13375 
!             LOOP VARIABLE                                                        RAD_ALL.13376 
     &   , L                                                                       RAD_ALL.13377 
!             LOOP VARIABLE                                                        RAD_ALL.13378 
     &   , K                                                                       RAD_ALL.13379 
!             LOOP VARIABLE                                                        RAD_ALL.13380 
     &   , KK                                                                      RAD_ALL.13381 
!             LOOP VARIABLE                                                        RAD_ALL.13382 
     &   , N_INDEX                                                                 RAD_ALL.13383 
!             NUMBER OF INDICES IN WHEN TEST                                       RAD_ALL.13384 
     &   , INDEX(NPD_PROFILE)                                                      RAD_ALL.13385 
!             INDICES OF WHEN TEST                                                 RAD_ALL.13386 
      REAL                                                                         RAD_ALL.13387 
     &     G_FF(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13388 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13389 
     &   , G_FC(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13390 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13391 
     &   , G_CF(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13392 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13393 
     &   , G_CC(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13394 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13395 
     &   , B_FF(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13396 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13397 
     &   , B_FC(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13398 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13399 
     &   , B_CF(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13400 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13401 
     &   , B_CC(NPD_PROFILE, 0: NPD_LAYER)                                         RAD_ALL.13402 
!             BASIC TRANSFER COEFFICIENT                                           RAD_ALL.13403 
!                                                                                  RAD_ALL.13404 
!     SUBROUTINES CALLED:                                                          RAD_ALL.13405 
!                                                                                  RAD_ALL.13406 
!     CRAY DIRECTIVES FOR THE WHOLE ROUTINE:                                       RAD_ALL.13407 
!     POINTS ARE NOT REPEATED IN THE INDEXING ARRAY, SO IT IS SAFE                 RAD_ALL.13408 
!     TO VECTORIZE OVER INDIRECTLY ADDRESSED ARRAYS.                               RAD_ALL.13409 
Cfpp$ NODEPCHK R                                                                   RAD_ALL.13410 
!                                                                                  RAD_ALL.13411 
!                                                                                  RAD_ALL.13412 
!                                                                                  RAD_ALL.13413 
!     SET THE FREE FRACTIONS IN EACH LAYER.                                        RAD_ALL.13414 
      DO I=1, N_CLOUD_TOP-1                                                        RAD_ALL.13415 
         DO L=1, N_PROFILE                                                         RAD_ALL.13416 
            W_FREE(L, I)=1.0E+00                                                   RAD_ALL.13417 
         ENDDO                                                                     RAD_ALL.13418 
      ENDDO                                                                        RAD_ALL.13419 
      DO I=N_CLOUD_TOP, N_LAYER                                                    RAD_ALL.13420 
         DO L=1, N_PROFILE                                                         RAD_ALL.13421 
            W_FREE(L, I)=1.0E+00-W_CLOUD(L, I)                                     RAD_ALL.13422 
         ENDDO                                                                     RAD_ALL.13423 
      ENDDO                                                                        RAD_ALL.13424 
!                                                                                  RAD_ALL.13425 
!     EVALUATE THE EXTENT OF OVERLAP BETWEEN LAYERS OF CLOUD                       RAD_ALL.13426 
!     AT THE INTERFACE BETWEEN THE ITH AND (I+1)ST LAYER ON THE                    RAD_ALL.13427 
!     ASSUMPTION OF MAXIMUM OVERLAP BETWEEN ADJACENT LAYERS.                       RAD_ALL.13428 
!     THE TOP AND BOTTOM BOUNDARIES ARE EXCEPTIONAL.                               RAD_ALL.13429 
!                                                                                  RAD_ALL.13430 
!     HERE IS IS EASIEST TO FIND THE BASIC TRANSFER COEFFICIENTS                   RAD_ALL.13431 
!     AND DEDUCE ALL OTHERS FROM THEM.                                             RAD_ALL.13432 
!                                                                                  RAD_ALL.13433 
!     COEFFICIENTS ARE NOT REQUIRED IF THERE ARE NO CLOUDY LAYERS,                 RAD_ALL.13434 
!     IN WHICH CASE N_CLOUD_TOP WILL BE SET TO N_LAYER+1.                          RAD_ALL.13435 
      IF (N_CLOUD_TOP.LE.N_LAYER) THEN                                             RAD_ALL.13436 
         DO L=1, N_PROFILE                                                         RAD_ALL.13437 
!                                                                                  RAD_ALL.13438 
!           TOPMOST CLOUDY BOUNDARY:                                               RAD_ALL.13439 
            G_FF(L, N_CLOUD_TOP-1)=W_FREE(L, N_CLOUD_TOP)                          RAD_ALL.13440 
            G_FC(L, N_CLOUD_TOP-1)=W_CLOUD(L, N_CLOUD_TOP)                         RAD_ALL.13441 
            G_CF(L, N_CLOUD_TOP-1)=0.0E+00                                         RAD_ALL.13442 
            G_CC(L, N_CLOUD_TOP-1)=1.0E+00                                         RAD_ALL.13443 
            B_FF(L, N_CLOUD_TOP-1)=1.0E+00                                         RAD_ALL.13444 
            B_FC(L, N_CLOUD_TOP-1)=1.0E+00                                         RAD_ALL.13445 
            B_CF(L, N_CLOUD_TOP-1)=0.0E+00                                         RAD_ALL.13446 
            B_CC(L, N_CLOUD_TOP-1)=0.0E+00                                         RAD_ALL.13447 
!                                                                                  RAD_ALL.13448 
!           BOTTOM BOUNDARY:                                                       RAD_ALL.13449 
            G_FF(L, N_LAYER)=1.0E+00                                               RAD_ALL.13450 
            G_FC(L, N_LAYER)=0.0E+00                                               RAD_ALL.13451 
            G_CF(L, N_LAYER)=1.0E+00                                               RAD_ALL.13452 
            G_CC(L, N_LAYER)=0.0E+00                                               RAD_ALL.13453 
            B_FF(L, N_LAYER)=W_FREE(L, N_LAYER)                                    RAD_ALL.13454 
            B_FC(L, N_LAYER)=0.0E+00                                               RAD_ALL.13455 
            B_CF(L, N_LAYER)=W_CLOUD(L, N_LAYER)                                   RAD_ALL.13456 
            B_CC(L, N_LAYER)=1.0E+00                                               RAD_ALL.13457 
!                                                                                  RAD_ALL.13458 
         ENDDO                                                                     RAD_ALL.13459 
      ENDIF                                                                        RAD_ALL.13460 
!                                                                                  RAD_ALL.13461 
      DO I=N_CLOUD_TOP, N_LAYER-1                                                  RAD_ALL.13462 
!                                                                                  RAD_ALL.13463 
!        SET DEFAULT VALUES FOR COMPLETELY CLEAR OR CLOUDY LAYERS                  RAD_ALL.13464 
!        AND OVERWRITE IN NORMAL CASES.                                            RAD_ALL.13465 
!                                                                                  RAD_ALL.13466 
!        GAMMAS:                                                                   RAD_ALL.13467 
!                                                                                  RAD_ALL.13468 
         DO L=1, N_PROFILE                                                         RAD_ALL.13469 
            G_CC(L, I)=1.0E+00                                                     RAD_ALL.13470 
            G_FF(L, I)=1.0E+00                                                     RAD_ALL.13471 
         ENDDO                                                                     RAD_ALL.13472 
!                                                                                  RAD_ALL.13473 
         N_INDEX=0                                                                 RAD_ALL.13474 
         DO L   =1,N_PROFILE                                                       RAD_ALL.13475 
           IF (W_CLOUD(L,I).GT.TOL_DIV) THEN                                       RAD_ALL.13476 
             N_INDEX =N_INDEX+1                                                    RAD_ALL.13477 
             INDEX(N_INDEX)=L                                                      RAD_ALL.13478 
           END IF                                                                  RAD_ALL.13479 
         END DO                                                                    RAD_ALL.13480 
!                                                                                  RAD_ALL.13481 
         DO K=1, N_INDEX                                                           RAD_ALL.13482 
            KK=INDEX(K)                                                            RAD_ALL.13483 
            G_CC(KK, I)=MIN(1.0E+00, W_CLOUD(KK, I+1)/W_CLOUD(KK, I))              RAD_ALL.13484 
         ENDDO                                                                     RAD_ALL.13485 
!                                                                                  RAD_ALL.13486 
         N_INDEX=0                                                                 RAD_ALL.13487 
         DO L   =1,N_PROFILE                                                       RAD_ALL.13488 
           IF (W_FREE(L,I).GT.TOL_DIV) THEN                                        RAD_ALL.13489 
             N_INDEX =N_INDEX+1                                                    RAD_ALL.13490 
             INDEX(N_INDEX)=L                                                      RAD_ALL.13491 
           END IF                                                                  RAD_ALL.13492 
         END DO                                                                    RAD_ALL.13493 
!                                                                                  RAD_ALL.13494 
         DO K=1, N_INDEX                                                           RAD_ALL.13495 
            KK=INDEX(K)                                                            RAD_ALL.13496 
            G_FF(KK, I)=MIN(1.0E+00, W_FREE(KK, I+1)/W_FREE(KK, I))                RAD_ALL.13497 
         ENDDO                                                                     RAD_ALL.13498 
!        INFER THE OTHER VALUES FROM GENERIC RELATIONS.                            RAD_ALL.13499 
         DO L=1, N_PROFILE                                                         RAD_ALL.13500 
            G_FC(L, I)=1.0E+00-G_FF(L, I)                                          RAD_ALL.13501 
            G_CF(L, I)=1.0E+00-G_CC(L, I)                                          RAD_ALL.13502 
         ENDDO                                                                     RAD_ALL.13503 
!                                                                                  RAD_ALL.13504 
!                                                                                  RAD_ALL.13505 
!        BETAS:                                                                    RAD_ALL.13506 
!                                                                                  RAD_ALL.13507 
         DO L=1, N_PROFILE                                                         RAD_ALL.13508 
            B_CC(L, I)=1.0E+00                                                     RAD_ALL.13509 
            B_FF(L, I)=1.0E+00                                                     RAD_ALL.13510 
         ENDDO                                                                     RAD_ALL.13511 
!                                                                                  RAD_ALL.13512 
         N_INDEX=0                                                                 RAD_ALL.13513 
         DO L   =1,N_PROFILE                                                       RAD_ALL.13514 
           IF (W_CLOUD(L,I+1).GT.TOL_DIV) THEN                                     RAD_ALL.13515 
             N_INDEX =N_INDEX+1                                                    RAD_ALL.13516 
             INDEX(N_INDEX)=L                                                      RAD_ALL.13517 
           END IF                                                                  RAD_ALL.13518 
         END DO                                                                    RAD_ALL.13519 
!                                                                                  RAD_ALL.13520 
         DO K=1, N_INDEX                                                           RAD_ALL.13521 
            KK=INDEX(K)                                                            RAD_ALL.13522 
            B_CC(KK, I)=MIN(1.0E+00, W_CLOUD(KK, I)/W_CLOUD(KK, I+1))              RAD_ALL.13523 
         ENDDO                                                                     RAD_ALL.13524 
!                                                                                  RAD_ALL.13525 
         N_INDEX=0                                                                 RAD_ALL.13526 
         DO L   =1,N_PROFILE                                                       RAD_ALL.13527 
           IF (W_FREE(L,I+1).GT.TOL_DIV) THEN                                      RAD_ALL.13528 
             N_INDEX =N_INDEX+1                                                    RAD_ALL.13529 
             INDEX(N_INDEX)=L                                                      RAD_ALL.13530 
           END IF                                                                  RAD_ALL.13531 
         END DO                                                                    RAD_ALL.13532 
!                                                                                  RAD_ALL.13533 
         DO K=1, N_INDEX                                                           RAD_ALL.13534 
            KK=INDEX(K)                                                            RAD_ALL.13535 
            B_FF(KK, I)=MIN(1.0E+00, W_FREE(KK, I)/W_FREE(KK, I+1))                RAD_ALL.13536 
         ENDDO                                                                     RAD_ALL.13537 
!        INFER THE OTHER VALUSE FROM GENERIC RELATIONS.                            RAD_ALL.13538 
         DO L=1, N_PROFILE                                                         RAD_ALL.13539 
            B_FC(L, I)=1.0E+00-B_CC(L, I)                                          RAD_ALL.13540 
            B_CF(L, I)=1.0E+00-B_FF(L, I)                                          RAD_ALL.13541 
         ENDDO                                                                     RAD_ALL.13542 
!                                                                                  RAD_ALL.13543 
      ENDDO                                                                        RAD_ALL.13544 
!                                                                                  RAD_ALL.13545 
!     NOW CALCULATE THE OVERLAPPED ARRAYS USING THE BASIC COEFFICIENTS.            RAD_ALL.13546 
!                                                                                  RAD_ALL.13547 
!     IN THE SOLAR REGION COEFFICIENTS FOR DOWNWARD COUPLING OF THE                RAD_ALL.13548 
!     FLUXES ARE REQUIRED. THESE COEFFICIENTS ARE ALSO NEEDED FOR                  RAD_ALL.13549 
!     INFRA-RED CALCULATIONS WITH APPROXIMATE SCATTERING, OR                       RAD_ALL.13550 
!     WHENEVER THE DIRECT SOLVER IS USED.                                          RAD_ALL.13551 
!                                                                                  RAD_ALL.13552 
      IF ( ( (I_SOLVER.EQ.IP_SOLVER_MIX_DIRECT).OR.                                RAD_ALL.13553 
     &       (I_SOLVER.EQ.IP_SOLVER_MIX_DIRECT_NET) ).OR.                          RAD_ALL.13554 
     &     (ISOLIR.EQ.IP_SOLAR).OR.                                                RAD_ALL.13555 
     &     ( (ISOLIR.EQ.IP_INFRA_RED).AND.                                         RAD_ALL.13556 
     &     ( (I_SOLVER.EQ.IP_SOLVER_MIX_APP_SCAT).OR.                              RAD_ALL.13557 
     &       (I_SOLVER.EQ.IP_SOLVER_MIX_NET_APP_SCAT) ) ) ) THEN                   RAD_ALL.13558 
!                                                                                  RAD_ALL.13559 
         DO I=N_CLOUD_TOP-1, N_LAYER                                               RAD_ALL.13560 
            DO L=1, N_PROFILE                                                      RAD_ALL.13561 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GFF)=G_FF(L, I)                       RAD_ALL.13562 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GFC)=G_FC(L, I)                       RAD_ALL.13563 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GCF)=G_CF(L, I)                       RAD_ALL.13564 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GCC)=G_CC(L, I)                       RAD_ALL.13565 
            ENDDO                                                                  RAD_ALL.13566 
         ENDDO                                                                     RAD_ALL.13567 
!                                                                                  RAD_ALL.13568 
      ENDIF                                                                        RAD_ALL.13569 
!                                                                                  RAD_ALL.13570 
!     WITH APPROXIMATE SCATTERING IN THE LONGWAVE, OR WHENEVER                     RAD_ALL.13571 
!     A DIRECT SOLVER IS USED, THE CORRESPONDING                                   RAD_ALL.13572 
!     UPWARD COEFFICIENTS ARE NEEDED.                                              RAD_ALL.13573 
!                                                                                  RAD_ALL.13574 
      IF ( ( (I_SOLVER.EQ.IP_SOLVER_MIX_DIRECT).OR.                                RAD_ALL.13575 
     &       (I_SOLVER.EQ.IP_SOLVER_MIX_DIRECT_NET) ).OR.                          RAD_ALL.13576 
     &     (ISOLIR.EQ.IP_INFRA_RED).AND.                                           RAD_ALL.13577 
     &     ( (I_SOLVER.EQ.IP_SOLVER_MIX_APP_SCAT).OR.                              RAD_ALL.13578 
     &       (I_SOLVER.EQ.IP_SOLVER_MIX_NET_APP_SCAT) ) ) THEN                     RAD_ALL.13579 
!                                                                                  RAD_ALL.13580 
         DO I=N_CLOUD_TOP-1, N_LAYER                                               RAD_ALL.13581 
            DO L=1, N_PROFILE                                                      RAD_ALL.13582 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BFF)=B_FF(L, I)                       RAD_ALL.13583 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BFC)=B_FC(L, I)                       RAD_ALL.13584 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BCF)=B_CF(L, I)                       RAD_ALL.13585 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BCC)=B_CC(L, I)                       RAD_ALL.13586 
            ENDDO                                                                  RAD_ALL.13587 
         ENDDO                                                                     RAD_ALL.13588 
      ENDIF                                                                        RAD_ALL.13589 
!                                                                                  RAD_ALL.13590 
!                                                                                  RAD_ALL.13591 
      IF (I_SOLVER.EQ.IP_SOLVER_MIX_FULL) THEN                                     RAD_ALL.13592 
!                                                                                  RAD_ALL.13593 
         DO I=N_CLOUD_TOP-1, N_LAYER                                               RAD_ALL.13594 
            DO L=1, N_PROFILE                                                      RAD_ALL.13595 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GFM)=G_FF(L, I)-G_CF(L, I)            RAD_ALL.13596 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GFP)=G_FF(L, I)+G_CF(L, I)            RAD_ALL.13597 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BFM)=B_FF(L, I)-B_FC(L, I)            RAD_ALL.13598 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BFP)=B_FF(L, I)+B_FC(L, I)            RAD_ALL.13599 
            ENDDO                                                                  RAD_ALL.13600 
         ENDDO                                                                     RAD_ALL.13601 
!                                                                                  RAD_ALL.13602 
!                                                                                  RAD_ALL.13603 
      ELSE IF ( (I_SOLVER.EQ.IP_SOLVER_MIX_NET).OR.                                RAD_ALL.13604 
     &          (I_SOLVER.EQ.IP_SOLVER_MIX_11) ) THEN                              RAD_ALL.13605 
!                                                                                  RAD_ALL.13606 
         DO I=N_CLOUD_TOP-1, N_LAYER                                               RAD_ALL.13607 
            DO L=1, N_PROFILE                                                      RAD_ALL.13608 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GM)                                   RAD_ALL.13609 
     &            =G_FF(L, I)+G_CC(L, I)-G_CF(L, I)-G_FC(L, I)                     RAD_ALL.13610 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_GP)                                   RAD_ALL.13611 
     &            =G_FF(L, I)-G_CC(L, I)+G_CF(L, I)-G_FC(L, I)                     RAD_ALL.13612 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BM)                                   RAD_ALL.13613 
     &            =B_FF(L, I)+B_CC(L, I)-B_CF(L, I)-B_FC(L, I)                     RAD_ALL.13614 
               CLOUD_OVERLAP(L, I, IP_CLOVLP_BP)                                   RAD_ALL.13615 
     &            =B_FF(L, I)-B_CC(L, I)-B_CF(L, I)+B_FC(L, I)                     RAD_ALL.13616 
            ENDDO                                                                  RAD_ALL.13617 
         ENDDO                                                                     RAD_ALL.13618 
!                                                                                  RAD_ALL.13619 
!                                                                                  RAD_ALL.13620 
      ENDIF                                                                        RAD_ALL.13621 
!                                                                                  RAD_ALL.13622 
!                                                                                  RAD_ALL.13623 
!                                                                                  RAD_ALL.13624 
      RETURN                                                                       RAD_ALL.13625 
      END  
