!+ Subroutine to set the actual process options for the radiation code.            RAD_ALL.5635  
!                                                                                  RAD_ALL.5636  
! Purpose:                                                                         RAD_ALL.5637  
!   To set a consistent set of process options for the radiation.                  RAD_ALL.5638  
!                                                                                  RAD_ALL.5639  
! Method:                                                                          RAD_ALL.5640  
!   The global options for the spectral region are compared with the               RAD_ALL.5641  
!   contents of the spectral file. The global options should be set                RAD_ALL.5642  
!   to reflect the capabilities of the code enabled in the model.                  RAD_ALL.5643  
!                                                                                  RAD_ALL.5644  
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.5645  
!                                                                                  RAD_ALL.5646  
! History:                                                                         RAD_ALL.5647  
!       Version         Date                    Comment                            RAD_ALL.5648  
!       4.1             04-03-96                Original Code                      RAD_ALL.5649  
!                                               (J. M. Edwards)                    RAD_ALL.5650  
!                                               Parts of this code are             RAD_ALL.5651  
!                                               rather redundant. The              RAD_ALL.5652  
!                                               form of writing is for             RAD_ALL.5653  
!                                               near consistency with              RAD_ALL.5654  
!                                               HADAM3.                            RAD_ALL.5655  
!                                                                                  RAD_ALL.5656  
! Description of Code:                                                             RAD_ALL.5657  
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.5658  
!                                                                                  RAD_ALL.5659  
!- ---------------------------------------------------------------------           RAD_ALL.5660  
      SUBROUTINE R2_COMPARE_PROC(IERR, L_PRESENT                                   RAD_ALL.5661  
     &   , L_RAYLEIGH_PERMITTED, L_GAS_PERMITTED, L_CONTINUUM_PERMITTED            RAD_ALL.5662  
     &   , L_DROP_PERMITTED, L_AEROSOL_PERMITTED                                   RAD_ALL.5663  
     &   , L_AEROSOL_CCN_PERMITTED, L_ICE_PERMITTED                                RAD_ALL.5664  
     &   , L_USE_SULPC_DIRECT, L_USE_SULPC_INDIRECT                                RAD_ALL.5665  
     &   , L_CLIMAT_AEROSOL                                                        RAD_ALL.5666  
     &   , L_RAYLEIGH, L_GAS, L_CONTINUUM                                          RAD_ALL.5667  
     &   , L_DROP, L_AEROSOL, L_AEROSOL_CCN, L_ICE                                 RAD_ALL.5668  
     &   , NPD_TYPE                                                                RAD_ALL.5669  
     &   )                                                                         RAD_ALL.5670  
!                                                                                  RAD_ALL.5671  
!                                                                                  RAD_ALL.5672  
!                                                                                  RAD_ALL.5673  
      IMPLICIT NONE                                                                RAD_ALL.5674  
!                                                                                  RAD_ALL.5675  
!                                                                                  RAD_ALL.5676  
!     COMDECKS INCLUDED.                                                           RAD_ALL.5677  
!     ------------------------------------------------------------------           STDIO3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       STDIO3A.3     
!                                                                                  STDIO3A.4     
!     MODULE TO SET UNIT NUMBERS FOR STANDARD I/O.                                 STDIO3A.5     
!                                                                                  STDIO3A.6     
      INTEGER                                                                      STDIO3A.7     
     &     IU_STDIN                                                                STDIO3A.8     
!             UNIT NUMBER FOR STANDARD INPUT                                       STDIO3A.9     
     &   , IU_STDOUT                                                               STDIO3A.10    
!             UNIT NUMBER FOR STANDARD OUTPUT                                      STDIO3A.11    
     *   , IU_ERR                                                                  STDIO3A.12    
!             UNIT NUMBER FOR ERROR MESSAGES                                       STDIO3A.13    
!                                                                                  STDIO3A.14    
      PARAMETER(                                                                   STDIO3A.15    
     &     IU_STDIN=5                                                              STDIO3A.16    
     &   , IU_STDOUT=6                                                             STDIO3A.17    
     *   , IU_ERR=6                                                                STDIO3A.18    
     &   )                                                                         STDIO3A.19    
!                                                                                  STDIO3A.20    
!     ------------------------------------------------------------------           STDIO3A.21    
!     ------------------------------------------------------------------           ERROR3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       ERROR3A.3     
!                                                                                  ERROR3A.4     
!     MODULE TO SET ERROR FLAGS IN THE RADIATION CODE.                             ERROR3A.5     
!                                                                                  ERROR3A.6     
      INTEGER                                                                      ERROR3A.7     
     &     I_NORMAL                                                                ERROR3A.8     
!             ERROR FREE CONDITION                                                 ERROR3A.9     
     &   , I_ERR_FATAL                                                             ERROR3A.10    
!             FATAL ERROR: IMMEDIATE RETURN                                        ERROR3A.11    
     &   , I_ABORT_CALCULATION                                                     ERROR3A.12    
!             CALCULATION ABORTED                                                  ERROR3A.13    
     &   , I_MISSING_DATA                                                          ERROR3A.14    
!             MISSING DATA ERROR: CONDITIONAL                                      ERROR3A.15    
     &   , I_ERR_IO                                                                ERROR3A.16    
!             I/O ERROR                                                            ERROR3A.17    
     &   , I_ERR_RANGE                                                             ERROR3A.18    
!             INTERPOLATION RANGE ERROR                                            ERROR3A.19    
     &   , I_ERR_EXIST                                                             ERROR3A.20    
!             EXISTENCE ERROR                                                      ERROR3A.21    
!                                                                                  ERROR3A.22    
      PARAMETER(                                                                   ERROR3A.23    
     &     I_NORMAL=0                                                              ERROR3A.24    
     &   , I_ERR_FATAL=1                                                           ERROR3A.25    
     &   , I_ABORT_CALCULATION=2                                                   ERROR3A.26    
     &   , I_MISSING_DATA=3                                                        ERROR3A.27    
     &   , I_ERR_IO=4                                                              ERROR3A.28    
     &   , I_ERR_RANGE=5                                                           ERROR3A.29    
     &   , I_ERR_EXIST=6                                                           ERROR3A.30    
     &   )                                                                         ERROR3A.31    
!                                                                                  ERROR3A.32    
!     ------------------------------------------------------------------           ERROR3A.33    
!                                                                                  RAD_ALL.5680  
!                                                                                  RAD_ALL.5681  
!     DUMMY ARGUMENTS:                                                             RAD_ALL.5682  
      INTEGER   !, INTENT(OUT)                                                     RAD_ALL.5683  
     &     IERR                                                                    RAD_ALL.5684  
!             ERROR FLAG                                                           RAD_ALL.5685  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.5686  
     &     NPD_TYPE                                                                RAD_ALL.5687  
!             NUMBER OF TYPES OF SPECTRAL DATA                                     RAD_ALL.5688  
!                                                                                  RAD_ALL.5689  
      LOGICAL   !, INTENT(IN)                                                      RAD_ALL.5690  
     &     L_PRESENT(0: NPD_TYPE)                                                  RAD_ALL.5691  
!             ARRAY INDICATING BLOCKS OF DATA PRESENT                              RAD_ALL.5692  
!             IN THE SPECTRAL FILE.                                                RAD_ALL.5693  
!                                                                                  RAD_ALL.5694  
!     PROCESSES PERMITTED WITHIN THE UNIFIED MODEL.                                RAD_ALL.5695  
      LOGICAL   !, INTENT(IN)                                                      RAD_ALL.5696  
     &     L_RAYLEIGH_PERMITTED                                                    RAD_ALL.5697  
!             RAYLEIGH SCATTERING PERMITTED IN THE MODEL                           RAD_ALL.5698  
     &   , L_GAS_PERMITTED                                                         RAD_ALL.5699  
!             GASEOUS ABSORPTION PERMITTED IN THE MODEL                            RAD_ALL.5700  
     &   , L_CONTINUUM_PERMITTED                                                   RAD_ALL.5701  
!             CONTINUUM ABSORPTION PERMITTED IN THE MODEL                          RAD_ALL.5702  
     &   , L_DROP_PERMITTED                                                        RAD_ALL.5703  
!             CLOUD DROPLET EXTINCTION PERMITTED IN THE MODEL                      RAD_ALL.5704  
     &   , L_AEROSOL_PERMITTED                                                     RAD_ALL.5705  
!             AEROSOL EXTINCTION PERMITTED IN THE MODEL                            RAD_ALL.5706  
     &   , L_AEROSOL_CCN_PERMITTED                                                 RAD_ALL.5707  
!             DETERMINATION OF CCN FROM AEROSOLS PERMITTED IN THE MODEL            RAD_ALL.5708  
     &   , L_ICE_PERMITTED                                                         RAD_ALL.5709  
!             ICE EXTINCTION PERMITTED IN THE MODEL                                RAD_ALL.5710  
!                                                                                  RAD_ALL.5711  
!     OPTIONS PASSED IN                                                            RAD_ALL.5712  
      LOGICAL                                                                      RAD_ALL.5713  
     &     L_USE_SULPC_DIRECT                                                      RAD_ALL.5714  
!             LOGICAL TO USE SULPHUR CYCLE FOR THE DIRECT EFFECT                   RAD_ALL.5715  
     &   , L_USE_SULPC_INDIRECT                                                    RAD_ALL.5716  
!             LOGICAL TO USE SULPHUR CYCLE FOR THE INDIRECT EFFECT                 RAD_ALL.5717  
     &   , L_CLIMAT_AEROSOL                                                        RAD_ALL.5718  
!             LOGICAL TO USE CLIMATOLOGICAL AEROSOL MODEL                          RAD_ALL.5719  
!                                                                                  RAD_ALL.5720  
!     PROCESSES TO BE ENABLED IN THE RUN.                                          RAD_ALL.5721  
      LOGICAL   !, INTENT(OUT)                                                     RAD_ALL.5722  
     &     L_RAYLEIGH                                                              RAD_ALL.5723  
!             RAYLEIGH SCATTERING TO BE ENABLED IN THE RUN                         RAD_ALL.5724  
     &   , L_GAS                                                                   RAD_ALL.5725  
!             GASEOUS ABSORPTION TO BE ENABLED IN THE RUN                          RAD_ALL.5726  
     &   , L_CONTINUUM                                                             RAD_ALL.5727  
!             CONTINUUM ABSORPTION TO BE ENABLED IN THE RUN                        RAD_ALL.5728  
     &   , L_DROP                                                                  RAD_ALL.5729  
!             CLOUD DROPLET EXTINCTION TO BE ENABLED IN THE RUN                    RAD_ALL.5730  
     &   , L_AEROSOL                                                               RAD_ALL.5731  
!             AEROSOL EXTINCTION TO BE ENABLED IN THE RUN                          RAD_ALL.5732  
     &   , L_AEROSOL_CCN                                                           RAD_ALL.5733  
!             DETERMINATION OF CCN FROM AEROSOL TO BE ENABLED IN THE RUN           RAD_ALL.5734  
     &   , L_ICE                                                                   RAD_ALL.5735  
!             ICE EXTINCTION TO BE ENABLED IN THE RUN                              RAD_ALL.5736  
!                                                                                  RAD_ALL.5737  
!                                                                                  RAD_ALL.5738  
!                                                                                  RAD_ALL.5739  
!     EACH OPTICAL PROCESS INCLUDED IN THE RADIATION CODE MAY BE                   RAD_ALL.5740  
!     PERMITTED OR DENIED IN THE UNIFIED MODEL, DEPENDING ON THE                   RAD_ALL.5741  
!     PRESENCE OF SUPPORTING CODE. TO BE ENABLED IN A RUN AN OPTICAL               RAD_ALL.5742  
!     PROCESS MUST BE PERMITTED IN THE UNIFIED MODEL AND HAVE                      RAD_ALL.5743  
!     SUITABLE SPECTRAL DATA.                                                      RAD_ALL.5744  
      L_RAYLEIGH=L_RAYLEIGH_PERMITTED.AND.L_PRESENT(3)                             RAD_ALL.5745  
      L_GAS=L_GAS_PERMITTED.AND.L_PRESENT(5)                                       RAD_ALL.5746  
      L_CONTINUUM=L_CONTINUUM_PERMITTED.AND.L_PRESENT(9)                           RAD_ALL.5747  
      L_DROP=L_DROP_PERMITTED.AND.L_PRESENT(10)                                    RAD_ALL.5748  
      L_ICE=L_ICE_PERMITTED.AND.L_PRESENT(12)                                      RAD_ALL.5749  
!                                                                                  RAD_ALL.5750  
!     SET THE CONTROLLING FLAG FOR THE DIRECT RADIATIVE EFFECTS OF                 RAD_ALL.5751  
!     AEROSOLS.                                                                    RAD_ALL.5752  
      IF (L_AEROSOL_PERMITTED) THEN                                                RAD_ALL.5753  
!        SET THE FLAG AND THEN CHECK THE SPECTRAL FILE.                            RAD_ALL.5754  
         L_AEROSOL=L_USE_SULPC_DIRECT.OR.L_CLIMAT_AEROSOL                          RAD_ALL.5755  
         IF (L_AEROSOL.AND.(.NOT.L_PRESENT(11))) THEN                              RAD_ALL.5756  
            WRITE(IU_ERR, '(/A, /A)')                                              RAD_ALL.5757  
     &         '*** ERROR: THE SPECTRAL FILE CONTAINS NO DATA '                    RAD_ALL.5758  
     &         //'FOR AEROSOLS.', 'SUCH DATA ARE REQUIRED FOR THE '                RAD_ALL.5759  
     &         //'DIRECT EFFECT.'                                                  RAD_ALL.5760  
            IERR=I_ERR_FATAL                                                       RAD_ALL.5761  
            RETURN                                                                 RAD_ALL.5762  
         ENDIF                                                                     RAD_ALL.5763  
      ELSE                                                                         RAD_ALL.5764  
!        CHECK THAT AEROSOLS HAVE NOT BEEN REQUESTED                               RAD_ALL.5765  
!        WHEN NOT PERMITTED.                                                       RAD_ALL.5766  
         IF (L_USE_SULPC_DIRECT.OR.L_CLIMAT_AEROSOL) THEN                          RAD_ALL.5767  
            WRITE(IU_ERR, '(/A, /A)')                                              RAD_ALL.5768  
     &         '*** ERROR: THE DIRECT EFFECTS AEROSOLS ARE NOT '                   RAD_ALL.5769  
     &         , 'PERMITTED IN THIS CONFIGURATION OF THE '                         RAD_ALL.5770  
     &         //'RADIATION CODE.'                                                 RAD_ALL.5771  
            IERR=I_ERR_FATAL                                                       RAD_ALL.5772  
            RETURN                                                                 RAD_ALL.5773  
         ENDIF                                                                     RAD_ALL.5774  
      ENDIF                                                                        RAD_ALL.5775  
!                                                                                  RAD_ALL.5776  
!     SET THE CONTROLLING FLAG FOR THE INDIRECT EFFECTS OF AEROSOLS.               RAD_ALL.5777  
!     AT PRESENT THIS DEPENDS SOLELY ON THE SULPHUR CYCLE.                         RAD_ALL.5778  
      L_AEROSOL_CCN=L_USE_SULPC_INDIRECT                                           RAD_ALL.5779  
!                                                                                  RAD_ALL.5780  
!                                                                                  RAD_ALL.5781  
!                                                                                  RAD_ALL.5782  
      RETURN                                                                       RAD_ALL.5783  
      END 
