MODULE YOE_AERO_M7_DATA

  !**** *YOE_AERO_M7_DATA*   - (RE)DEFINES INDICES AND PARAMETERS OF M7 FOR THE AEROCOL ACTIVATION

  !     PURPOSE.
  !     --------
  !     WORK AS A COPY OF THE TM5 M7 AEROSOL RELATED VARIABLES
  !           

  !**   INTERFACE.
  !     ----------
  !     USED BY YOE_AER_ACTIV

  !        EXPLICIT ARGUMENTS :
  !        --------------------
  !        NONE

  !        IMPLICIT ARGUMENTS :
  !        --------------------
  !        

  !     METHOD.
  !     -------
  !        
  !
  !     Authors:
  !     --------
  !        P. Stier (MPI)                                 2001/2002
  !        E. Vignati and J. Wilson (JRC / EI)            2000

  !        SEE DOCUMENTATION

  !     EXTERNALS.
  !     ----------

  !     REFERENCE.
  !     ----------
  !     Vignati et al. JGR 2004

  !     AUTHORS.
  !     -------
  !        JONI-PEKKA PIETIKAINEN, FMI 2015
  !        DECLAN O'DONNELL, FMI 2015
  !
  !     MODIFICATIONS.
  !     --------------
  !        ORIGINAL : 20091113

  !     ------------------------------------------------------------------

  USE PARKIND1 ,ONLY : JPIM  , JPRB

  IMPLICIT NONE

  PUBLIC :: INITIALIZE_M7_DATA

  INTEGER(KIND=JPIM), PUBLIC, PARAMETER :: &
       & NMOD=7,            & !number of modes
       & NSOL=4               !number of soluble (hydrophilic) modes

  !--- Indices to each mode
  INTEGER(KIND=JPIM), PUBLIC, PARAMETER :: &
       & JP_NUCS = 1, &       ! soluble nucleation mode
       & JP_AITS = 2, &       ! soluble Aitken mode
       & JP_ACCS = 3, &       ! soluble accumulation mode
       & JP_COAS = 4, &       ! soluble coarse mode
       & JP_AITI = 5, &       ! insoluble Aitken mode
       & JP_ACCI = 6, &       ! insoluble accumulation mode
       & JP_COAI = 7          ! insoluble coarse mode

  !---  Standard deviation for the modes:
  
  REAL(KIND=JPRB), PUBLIC, PARAMETER :: SIGMA(NMOD)=(/ 1.59_JPRB, 1.59_JPRB, 1.59_JPRB, 2.00_JPRB, 1.59_JPRB, 1.59_JPRB, 2.00_JPRB /)
  

  !--- Natural logarithm of the standard deviation of each mode:
  !    Calulated in m7_initialize. 
  
  REAL(KIND=JPRB), PUBLIC :: SIGMALN(NMOD)
  
  !--- Conversion factors for lognormal particle size distributions: -------------
  !    Calulated in m7_initialize. 
  
  ! Conversion factor: count median radius to radius of average surface
  REAL(KIND=JPRB), PUBLIC :: CMR2RAS(NMOD) 

  ! Conversion factor: count median radius to mass mean radius
  REAL(KIND=JPRB), PUBLIC :: CMR2MMR(NMOD) 

  ! Conversion factor: count median radius to mass median radius
  REAL(KIND=JPRB), PUBLIC :: CMEDR2MMEDR(NMOD) 

  ! Conversion factor: count median radius to radius of average mass
  REAL(KIND=JPRB), PUBLIC :: CMR2RAM(NMOD) 

  ! Conversion factor: radius of average mass to count median radius
  REAL(KIND=JPRB), PUBLIC :: RAM2CMR(NMOD) 

  !--- Type specific physical constants:
  !
  REAL(KIND=JPRB), PUBLIC, PARAMETER ::     &
       & DH2SO4  = 1.841_JPRB,      & ! Density          H2SO4  [g cm-3]
       & DDUST   = 2.650_JPRB,      & ! Density          DU     [g cm-3]
       & DBC     = 1.8_JPRB,        & ! Density          BC     [g cm-3]
       & DOC     = 1.3_JPRB,        & ! Density          POM    [g cm-3]
       & DNACL   = 2.165_JPRB,      & ! Density          NaCl   [g cm-3]
       & DNA2SO4 = 2.68_JPRB,       & ! Density          Na2SO4 [g cm-3]
       & DNAHSO4 = 2.435_JPRB,      & ! Density          NaHSO4 [g cm-3]
       & DNH4NO3 = 1.73_JPRB,       & ! Density          NH4NO3 [g cm-3]
       & DMSA    = 1.48_JPRB,       & ! Density          MSA    [g cm-3]
       & DH2O    = 1.0_JPRB,        & ! Density          H2O    [g cm-3]
       & WH2SO4  = 98.0734_JPRB,    & ! Molecular weight H2SO4  [g mol-1]
       & WH2O    = 18.0_JPRB,       & ! Molecular weight H2O    [g mol-1]
       & WDAIR   = 28.970_JPRB,     & ! Molecular weight dry air[g mol-1]
       & WSO4    = 96.0576_JPRB,    & ! Molecular weight SO4    [g mol-1]
       & WSO2    = 64.0_JPRB,       & ! Molecular weight SO2    [g mol-1]
       & WNA     = 22.99_JPRB,      & ! Atomic    weight Na     [g mol-1]
       & WCL     = 35.453_JPRB,     & ! Atomic    weight Cl     [g mol-1]
       & WNACL   = 58.443_JPRB,     & ! Molecular weight NaCl   [g mol-1]
       & WNA2SO4 = 142.0376_JPRB,   & ! Molecular weight Na2SO4 [g mol-1]
       & WNAHSO4 = 120.0555_JPRB      ! Molecular weight NaHSO4 [g mol-1]

   REAL(KIND=JPRB), PUBLIC, PARAMETER ::     &
       & NH4NO3_FACTOR = (18.0383 + 62.0049) / 62.0049 ! Mass ratio of NH4NO3 over NO3

  ! kappa values:
  !
  REAL(KIND=JPRB), PUBLIC, PARAMETER ::  &
       & PPKAPPA_H2SO4 = 0.6_JPRB, &  
       & PPKAPPA_BC = 0.0_JPRB,  &  
       & PPKAPPA_OC = 0.1_JPRB,  &  
       & PPKAPPA_NACL = 1.0_JPRB,  &  
       & PPKAPPA_DU = 0.0_JPRB,  &
       & PPKAPPA_NH4NO3 = 0.6_JPRB,  &
       & PPKAPPA_MSA = 0.6_JPRB,  &
       & PPKAPPA_NA2SO4 = 0.95_JPRB

  ! Indices to coupling fields
  INTEGER(KIND=JPIM), PUBLIC :: ICPLSU1, ICPLSU2, ICPLSU3, ICPLSU4
  INTEGER(KIND=JPIM), PUBLIC :: ICPLBC2, ICPLBC3, ICPLBC4, ICPLBC5
  INTEGER(KIND=JPIM), PUBLIC :: ICPLOM2, ICPLOM3, ICPLOM4, ICPLOM5
  INTEGER(KIND=JPIM), PUBLIC :: ICPLSS3, ICPLSS4
  INTEGER(KIND=JPIM), PUBLIC :: ICPLDD3, ICPLDD4, ICPLDD6, ICPLDD7 
  INTEGER(KIND=JPIM), PUBLIC :: ICPLNO3, ICPLMSA
  INTEGER(KIND=JPIM), PUBLIC :: ICPLN2,  ICPLN3,  ICPLN4,  ICPLN5
  INTEGER(KIND=JPIM), PUBLIC :: ICPLN6,  ICPLN7 
  
  !     ----------------------------------------------------------------

CONTAINS


  SUBROUTINE INITIALIZE_M7_DATA

    ! Purpose:
    ! ---------
    ! Initializes constants and parameters of m7
    ! used in the aerocol-cloud interactions
    !
    ! Interface:
    ! ---------
    ! *initialize_m7_data*  is called from *suphec*
    !

    USE YOMHOOK,             ONLY: LHOOK, DR_HOOK
    USE YOMLUN,              ONLY: NULOUT

    IMPLICIT NONE

    INTEGER(KIND=JPIM) :: JMOD

    REAL(KIND=JPRB) :: ZHOOK_HANDLE

    !---executable procedure
    IF (LHOOK) CALL DR_HOOK('INITIALIZE_M7_DATA', 0, ZHOOK_HANDLE)
      
    DO JMOD=1, NMOD

       !--- 1) Calculate conversion factors for lognormal distributions:----
       !       Radius of average mass (ram) to count median radius (cmr) and 
       !       vice versa. Count median radius to radius of average 
       !       mass (ram).
       !       These factors depend on the standard deviation (sigma)
       !       of the lognormal distribution.
       !       (Based on the Hatch-Choate Conversins Equations;
       !        see Hinds, Chapter 4.5, 4.6 for more details.
       !        In particular equation 4.53.)

       !--- Count Median Radius to Mass Median Radius:

       CMEDR2MMEDR(JMOD) = EXP(3.0_JPRB*(LOG(SIGMA(JMOD)))**2)

       !--- Count Median Radius to Mass Mean Radius:

       CMR2MMR(JMOD) = EXP(3.5_JPRB*(LOG(SIGMA(JMOD)))**2)

       !--- Count Median Radius to Radius of Average Mass:

       CMR2RAM(JMOD) = EXP(1.5_JPRB*(LOG(SIGMA(JMOD)))**2)

       !--- Radius of Average Mass to Count Median Radius:

       RAM2CMR(JMOD) = 1._JPRB / CMR2RAM(JMOD)

       !--- Count Median Radius to Radius of Average Surface:

       CMR2RAS(JMOD) = EXP(1.0_JPRB*(LOG(SIGMA(JMOD)))**2)


       !--- 2) Calculate the natural logarithm of the standard deviation:

       SIGMALN(JMOD) = LOG(SIGMA(JMOD))

    END DO

    !--- set coupling indices to undefined
    ICPLSU1 = -1
    ICPLSU2 = -1
    ICPLSU3 = -1 
    ICPLSU4 = -1
    ICPLBC2 = -1 
    ICPLBC3 = -1
    ICPLBC4 = -1 
    ICPLBC5 = -1
    ICPLOM2 = -1 
    ICPLOM3 = -1
    ICPLOM4 = -1 
    ICPLOM5 = -1
    ICPLSS3 = -1 
    ICPLSS4 = -1
    ICPLDD3 = -1 
    ICPLDD4 = -1
    ICPLDD6 = -1 
    ICPLDD7 = -1
    ICPLNO3 = -1
    ICPLMSA = -1
    ICPLN2 = -1 
    ICPLN3 = -1
    ICPLN4 = -1
    ICPLN5 = -1
    ICPLN6 = -1
    ICPLN7 = -1

    WRITE(NULOUT,*) 'Constants for M7 aerosols initialized'

    IF (LHOOK) CALL DR_HOOK('INITIALIZE_M7_DATA', 1, ZHOOK_HANDLE)

    !--------------------------------------------------------------------

  END SUBROUTINE INITIALIZE_M7_DATA


END MODULE YOE_AERO_M7_DATA
