!+ Subroutine to set fields of climatological aerosols in HADCM3.                  RAD_ALL.4836  
!                                                                                  RAD_ALL.4837  
! Purpose:                                                                         RAD_ALL.4838  
!   This routine sets the mixing ratios of climatological aerosols.                RAD_ALL.4839  
!   A separate subroutine is used to ensure that the mixing ratios                 RAD_ALL.4840  
!   of these aerosols are bit-comparable with earlier versions of                  RAD_ALL.4841  
!   the model where the choice of aerosols was more restricted:                    RAD_ALL.4842  
!   keeping the code in its original form reduces the opportunity                  RAD_ALL.4843  
!   for optimizations which compromise bit-reproducibilty.                         RAD_ALL.4844  
!   The climatoogy used here is the one devised for HADCM3.                        RAD_ALL.4845  
!                                                                                  RAD_ALL.4846  
! Method:                                                                          RAD_ALL.4847  
!   Straightforward.                                                               RAD_ALL.4848  
!                                                                                  RAD_ALL.4849  
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.4850  
!                                                                                  RAD_ALL.4851  
! History:                                                                         RAD_ALL.4852  
!       Version         Date                    Comment                            RAD_ALL.4853  
!       4.4             29-09-97                Original Code                      RAD_ALL.4854  
!                                               very closely based on              RAD_ALL.4855  
!                                               previous versions of               RAD_ALL.4856  
!                                               this scheme.                       RAD_ALL.4857  
!                                               (J. M. Edwards)                    RAD_ALL.4858  
!                                                                                  RAD_ALL.4859  
! Description of Code:                                                             RAD_ALL.4860  
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.4861  
!                                                                                  RAD_ALL.4862  
!- ---------------------------------------------------------------------           RAD_ALL.4863  
      SUBROUTINE R2_SET_AERO_CLIM_HADCM3(N_PROFILE, NLEVS                          RAD_ALL.4864  
     &   , I_GATHER                                                                RAD_ALL.4865  
     &   , N_LEVELS_BL                                                             RAD_ALL.4866  
     &   , LAND, LYING_SNOW, PSTAR, AB, BB, TRINDX                                 RAD_ALL.4867  
     &   , AEROSOL_MIX_RATIO_CLIM                                                  RAD_ALL.4868  
     &   , NPD_FIELD, NPD_PROFILE, NPD_LAYER                                       RAD_ALL.4869  
     &   )                                                                         RAD_ALL.4870  
!                                                                                  RAD_ALL.4871  
!                                                                                  RAD_ALL.4872  
!                                                                                  RAD_ALL.4873  
      IMPLICIT NONE                                                                RAD_ALL.4874  
!                                                                                  RAD_ALL.4875  
!                                                                                  RAD_ALL.4876  
!     COMDECKS INCLUDED.                                                           RAD_ALL.4877  
C*L------------------COMDECK C_G----------------------------------------           C_G.2     
C G IS MEAN ACCEL DUE TO GRAVITY AT EARTH'S SURFACE                                C_G.3     
      REAL G                                                                       C_G.4     
                                                                                   C_G.5     
      PARAMETER(G=9.80665)                                                         C_G.6     
C*----------------------------------------------------------------------           C_G.7     
!                                                                                  RAD_ALL.4879  
!     DUMMY ARGUMENTS.                                                             RAD_ALL.4880  
!                                                                                  RAD_ALL.4881  
!     SIZES OF ARRAYS:                                                             RAD_ALL.4882  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.4883  
     &     NPD_FIELD                                                               RAD_ALL.4884  
!             FIELD SIZE IN CALLING PROGRAM                                        RAD_ALL.4885  
     &   , NPD_PROFILE                                                             RAD_ALL.4886  
!             SIZE OF ARRAY OF PROFILES                                            RAD_ALL.4887  
     &   , NPD_LAYER                                                               RAD_ALL.4888  
!             MAXIMUM NUMBER OF LAYERS                                             RAD_ALL.4889  
!                                                                                  RAD_ALL.4890  
!     ACTUAL SIZES USED:                                                           RAD_ALL.4891  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.4892  
     &     N_PROFILE                                                               RAD_ALL.4893  
!             NUMBER OF PROFILES                                                   RAD_ALL.4894  
     &   , NLEVS                                                                   RAD_ALL.4895  
!             NUMBER OF ATMOSPHERIC LAYERS                                         RAD_ALL.4896  
     &   , N_LEVELS_BL                                                             RAD_ALL.4897  
!             NUMBER OF LEVELS IN THE BOUNDARY LAYER                               RAD_ALL.4898  
!                                                                                  RAD_ALL.4899  
!     GATHERING ARRAY:                                                             RAD_ALL.4900  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.4901  
     &     I_GATHER(NPD_FIELD)                                                     RAD_ALL.4902  
!             LIST OF POINTS TO GATHER                                             RAD_ALL.4903  
!                                                                                  RAD_ALL.4904  
!     GENERAL ATMOSPHERIC PROPERTIES:                                              RAD_ALL.4905  
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.4906  
     &     TRINDX(NPD_FIELD)                                                       RAD_ALL.4907  
!             LAYER BOUNDARY OF TROPOPAUSE                                         RAD_ALL.4908  
      REAL      !, INTENT(IN)                                                      RAD_ALL.4909  
     &     PSTAR(NPD_FIELD)                                                        RAD_ALL.4910  
!             SURFACE PRESSURES                                                    RAD_ALL.4911  
     &   , AB(NLEVS+1)                                                             RAD_ALL.4912  
!             A AT BOUNDARIES OF LAYERS                                            RAD_ALL.4913  
     &   , BB(NLEVS+1)                                                             RAD_ALL.4914  
!             B AT BOUNDARIES OF LAYERS                                            RAD_ALL.4915  
!                                                                                  RAD_ALL.4916  
!     SURFACE FIELDS                                                               RAD_ALL.4917  
      LOGICAL   !, INTENT(IN)                                                      RAD_ALL.4918  
     &     LAND(NPD_FIELD)                                                         RAD_ALL.4919  
!             LAND-SEA MASK                                                        RAD_ALL.4920  
      REAL      !, INTENT(IN)                                                      RAD_ALL.4921  
     &     LYING_SNOW(NPD_FIELD)                                                   RAD_ALL.4922  
!             DEPTH OF LYING SNOW                                                  RAD_ALL.4923  
!                                                                                  RAD_ALL.4924  
      REAL      !, INTENT(OUT)                                                     RAD_ALL.4925  
     &     AEROSOL_MIX_RATIO_CLIM(NPD_PROFILE, 0: NPD_LAYER, 5)                    RAD_ALL.4926  
!             MIXING RATIOS OF CLIMATOLOGICAL AEROSOLS                             RAD_ALL.4927  
!                                                                                  RAD_ALL.4928  
!                                                                                  RAD_ALL.4929  
!                                                                                  RAD_ALL.4930  
!     LOCAL VARIABLES:                                                             RAD_ALL.4931  
      INTEGER                                                                      RAD_ALL.4932  
     &     I                                                                       RAD_ALL.4933  
!             LOOP VARIABLE                                                        RAD_ALL.4934  
     &   , J                                                                       RAD_ALL.4935  
!             LOOP VARIABLE                                                        RAD_ALL.4936  
     &   , L                                                                       RAD_ALL.4937  
!             LOOP VARIABLE                                                        RAD_ALL.4938  
     &   , LG                                                                      RAD_ALL.4939  
!             INDEX FOR GATHERING                                                  RAD_ALL.4940  
     &   , BLTOP                                                                   RAD_ALL.4941  
!             INDEX OF UPPER BOUNDARY OF PLANETARY BOUNDARY LAYER                  RAD_ALL.4942  
      REAL                                                                         RAD_ALL.4943  
     &     PRESSURE_WT(NPD_FIELD)                                                  RAD_ALL.4944  
!             ARRAY FOR SCALING AEROSOL AMOUNTS FOR DIFFERENT SURFACE              RAD_ALL.4945  
!             PRESSURES                                                            RAD_ALL.4946  
!                                                                                  RAD_ALL.4947  
!     TOTAL COLUMN MASS (KG M-2) OF EACH AEROSOL SPECIES IN                        RAD_ALL.4948  
!     THE BOUNDARY LAYER, THE FREE TROPOSPHERE AND THE STRATOSPHERE                RAD_ALL.4949  
!     RESPECTIVELY. THIS MODEL ASSUMES THAT THERE ARE FIVE AEROSOLS.               RAD_ALL.4950  
      REAL                                                                         RAD_ALL.4951  
     &     BL_OCEANMASS(5)                                                         RAD_ALL.4952  
     &   , BL_LANDMASS(5)                                                          RAD_ALL.4953  
     &   , FREETROP_MASS(5)                                                        RAD_ALL.4954  
     &   , STRAT_MASS(5)                                                           RAD_ALL.4955  
!                                                                                  RAD_ALL.4956  
!     INITIALIZATION FOR THE CLIMATOLOGICAL AEROSOL MODEL                          RAD_ALL.4957  
      DATA BL_LANDMASS/2.77579E-5, 6.70018E-5, 0.0, 9.57169E-7, 0.0/               RAD_ALL.4958  
      DATA BL_OCEANMASS/1.07535E-5, 0.0, 2.043167E-4, 0.0, 0.0/                    RAD_ALL.4959  
      DATA FREETROP_MASS/3.46974E-6, 8.37523E-6, 0.0, 1.19646E-7, 0.0/             RAD_ALL.4960  
      DATA STRAT_MASS/0.0, 0.0, 0.0, 0.0, 1.86604E-6/                              RAD_ALL.4961  
!                                                                                  RAD_ALL.4962  
!                                                                                  RAD_ALL.4963  
!                                                                                  RAD_ALL.4964  
!     TROPOSPHERIC AEROSOL LOADING IS A SIMPLE FUNCTION OF SURFACE                 RAD_ALL.4965  
!     PRESSURE: HALVING PSTAR HALVES THE TROPOSPHERIC AEROSOL BURDEN.              RAD_ALL.4966  
!     THE STRATOSPHERIC BURDEN IS INDEPENDENT OF PSTAR.  NOTE THE                  RAD_ALL.4967  
!     FACTOR MULTIPLING AEROSOL AMOUNTS USES A REFERENCE PRESSURE                  RAD_ALL.4968  
!     OF 1013 mbars.                                                               RAD_ALL.4969  
      DO L=1, N_PROFILE                                                            RAD_ALL.4970  
        PRESSURE_WT(L)=PSTAR(I_GATHER(L))*(1.0/1.013E5)                            RAD_ALL.4971  
      END DO                                                                       RAD_ALL.4972  
!                                                                                  RAD_ALL.4973  
!     For each of the 5 aerosol species, the column amount in the                  RAD_ALL.4974  
!     boundary layer, free troposphere and stratosphere are known for              RAD_ALL.4975  
!     a standard atmosphere over ocean and land. These can be used                 RAD_ALL.4976  
!     to find mixing ratios for the UM by dividing toal aerosol by                 RAD_ALL.4977  
!     total air mass (and using pressure weighting in the                          RAD_ALL.4978  
!     troposphere).                                                                RAD_ALL.4979  
!                                                                                  RAD_ALL.4980  
!     Firstly, mixing ratios are set for the 5 aerosol species in the              RAD_ALL.4981  
!     stratosphere.                                                                RAD_ALL.4982  
      DO I=1,5                                                                     RAD_ALL.4983  
        DO L=1, N_PROFILE                                                          RAD_ALL.4984  
          LG=I_GATHER(L)                                                           RAD_ALL.4985  
          AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-TRINDX(LG),I)                           RAD_ALL.4986  
     &      =STRAT_MASS(I)*G/                                                      RAD_ALL.4987  
     &      ((AB(TRINDX(LG))+BB(TRINDX(LG))*PSTAR(LG))                             RAD_ALL.4988  
     &      -(AB(NLEVS+1)+BB(NLEVS+1)*PSTAR(LG)))                                  RAD_ALL.4989  
        END DO                                                                     RAD_ALL.4990  
      END DO                                                                       RAD_ALL.4991  
      DO I=1,5                                                                     RAD_ALL.4992  
        DO L=1, N_PROFILE                                                          RAD_ALL.4993  
          LG=I_GATHER(L)                                                           RAD_ALL.4994  
            DO J=(TRINDX(LG)+1),NLEVS                                              RAD_ALL.4995  
              AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-J,I)=                               RAD_ALL.4996  
     &          AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-TRINDX(LG),I)                     RAD_ALL.4997  
            END DO                                                                 RAD_ALL.4998  
         END DO                                                                    RAD_ALL.4999  
       END DO                                                                      RAD_ALL.5000  
!      Now, the mixing ratios are set for the 5 aerosol species                    RAD_ALL.5001  
!      in the free troposphere.                                                    RAD_ALL.5002  
!      The half-level at the top of the boundary layer is BLTOP                    RAD_ALL.5003  
       BLTOP=N_LEVELS_BL+1                                                         RAD_ALL.5004  
       DO I=1,5                                                                    RAD_ALL.5005  
         DO L=1, N_PROFILE                                                         RAD_ALL.5006  
           LG=I_GATHER(L)                                                          RAD_ALL.5007  
           AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-BLTOP,I)                               RAD_ALL.5008  
     &       =FREETROP_MASS(I)*G*                                                  RAD_ALL.5009  
     &       PRESSURE_WT(L)/((AB(BLTOP)+BB(BLTOP)*PSTAR(LG))-                      RAD_ALL.5010  
     &       (AB(TRINDX(LG))+BB(TRINDX(LG))*PSTAR(LG)))                            RAD_ALL.5011  
         END DO                                                                    RAD_ALL.5012  
       END DO                                                                      RAD_ALL.5013  
       DO L=1, N_PROFILE                                                           RAD_ALL.5014  
         LG=I_GATHER(L)                                                            RAD_ALL.5015  
         IF ((BLTOP+1).LE.(TRINDX(LG)-1)) THEN                                     RAD_ALL.5016  
           DO I=1,5                                                                RAD_ALL.5017  
             DO J=(BLTOP+1),(TRINDX(LG)-1)                                         RAD_ALL.5018  
               AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-J,I)=                              RAD_ALL.5019  
     &           AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-BLTOP,I)                         RAD_ALL.5020  
             END DO                                                                RAD_ALL.5021  
           END DO                                                                  RAD_ALL.5022  
         END IF                                                                    RAD_ALL.5023  
       END DO                                                                      RAD_ALL.5024  
!                                                                                  RAD_ALL.5025  
!      Now, the boundary layer mixing ratios are set for the                       RAD_ALL.5026  
!      5 aerosol species. A continental aerosol is used over most land             RAD_ALL.5027  
!      areas, but not over ice sheets, which are identified by the                 RAD_ALL.5028  
!      criterion used in the boundary layer scheme that the mass of                RAD_ALL.5029  
!      lying snow exceeds 5000 kgm-2. Over ice sheets a maritime                   RAD_ALL.5030  
!      aerosol is used.                                                            RAD_ALL.5031  
       DO I=1,5                                                                    RAD_ALL.5032  
         DO L=1, N_PROFILE                                                         RAD_ALL.5033  
           LG=I_GATHER(L)                                                          RAD_ALL.5034  
           IF ( LAND(LG).AND.(LYING_SNOW(LG).LT.5.0E+03) ) THEN                    RAD_ALL.5035  
            AEROSOL_MIX_RATIO_CLIM(L,NLEVS+2-BLTOP,I)                              RAD_ALL.5036  
     &        =BL_LANDMASS(I)*G*PRESSURE_WT(L)                                     RAD_ALL.5037  
     &        /(PSTAR(LG)-(AB(BLTOP)+BB(BLTOP)*PSTAR(LG)))                         RAD_ALL.5038  
           ELSE                                                                    RAD_ALL.5039  
            AEROSOL_MIX_RATIO_CLIM(L,NLEVS+2-BLTOP,I)                              RAD_ALL.5040  
     &        =BL_OCEANMASS(I)*G*PRESSURE_WT(L)                                    RAD_ALL.5041  
     &        /(PSTAR(LG)-(AB(BLTOP)+BB(BLTOP)*PSTAR(LG)))                         RAD_ALL.5042  
           END IF                                                                  RAD_ALL.5043  
         END DO                                                                    RAD_ALL.5044  
       END DO                                                                      RAD_ALL.5045  
       DO I=1,5                                                                    RAD_ALL.5046  
         DO L=1, N_PROFILE                                                         RAD_ALL.5047  
           DO J=1,(BLTOP-2)                                                        RAD_ALL.5048  
             AEROSOL_MIX_RATIO_CLIM(L,NLEVS+1-J,I)=                                RAD_ALL.5049  
     &         AEROSOL_MIX_RATIO_CLIM(L,NLEVS+2-BLTOP,I)                           RAD_ALL.5050  
           END DO                                                                  RAD_ALL.5051  
         END DO                                                                    RAD_ALL.5052  
       END DO                                                                      RAD_ALL.5053  
!                                                                                  RAD_ALL.5054  
!                                                                                  RAD_ALL.5055  
!                                                                                  RAD_ALL.5056  
      RETURN                                                                       RAD_ALL.5057  
      END  
