Ignore:
Timestamp:
Mar 31, 2023, 8:42:57 PM (15 months ago)
Author:
lguez
Message:

Merge LMDZ_ECRad branch back into trunk!

Location:
LMDZ6/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk

  • LMDZ6/trunk/libf/phylmd/ecrad/radiation_gas.F90

    r3908 r4489  
    1919
    2020  use parkind1, only : jprb
     21  use radiation_gas_constants
    2122
    2223  implicit none
    2324  public
    24 
    25   ! Gas codes; these indices match those of RRTM-LW up to 7
    26   integer, parameter :: IGasNotPresent = 0
    27   integer, parameter :: IH2O   = 1
    28   integer, parameter :: ICO2   = 2
    29   integer, parameter :: IO3    = 3
    30   integer, parameter :: IN2O   = 4
    31   integer, parameter :: ICO    = 5
    32   integer, parameter :: ICH4   = 6
    33   integer, parameter :: IO2    = 7
    34   integer, parameter :: ICFC11 = 8
    35   integer, parameter :: ICFC12 = 9
    36   integer, parameter :: IHCFC22= 10
    37   integer, parameter :: ICCl4  = 11
    38   integer, parameter :: INO2   = 12
    39   integer, parameter :: NMaxGases = 12
    40 
    41   ! Molar masses (g mol-1) of dry air and the various gases above
    42   real(jprb), parameter :: IAirMolarMass = 28.970
    43   real(jprb), parameter, dimension(0:NMaxGases) :: IGasMolarMass = (/ &
    44        & 0.0_jprb,        & ! Gas not present
    45        & 18.0152833_jprb, & ! H2O
    46        & 44.011_jprb,     & ! CO2
    47        & 47.9982_jprb,    & ! O3
    48        & 44.013_jprb,     & ! N2O
    49        & 28.0101_jprb,    & ! CO
    50        & 16.043_jprb,     & ! CH4
    51        & 31.9988_jprb,    & ! O2
    52        & 137.3686_jprb,   & ! CFC11
    53        & 120.914_jprb,    & ! CFC12
    54        & 86.469_jprb,     & ! HCFC22
    55        & 153.823_jprb,    & ! CCl4   
    56        & 46.0055_jprb /)    ! NO2
    57 
    58   ! The corresponding names of the gases in upper and lower case, used
    59   ! for reading variables from the input file
    60   character*6, dimension(NMaxGases), parameter :: GasName &
    61        &  = (/'H2O   ','CO2   ','O3    ','N2O   ','CO    ','CH4   ', &
    62        &      'O2    ','CFC11 ','CFC12 ','HCFC22','CCl4  ','NO2   '/)
    63   character*6, dimension(NMaxGases), parameter :: GasLowerCaseName &
    64        &  = (/'h2o   ','co2   ','o3    ','n2o   ','co    ','ch4   ', &
    65        &      'o2    ','cfc11 ','cfc12 ','hcfc22','ccl4  ','no2   '/)
    6625
    6726  ! Available units
     
    12180
    12281  !---------------------------------------------------------------------
     82  ! Allocate a derived type for holding gas mixing ratios given the
     83  ! number of columns and levels
    12384  subroutine allocate_gas(this, ncol, nlev)
    12485
     
    191152    integer,    optional, intent(in)    :: istartcol
    192153
    193     integer :: i1, i2
     154    integer :: i1, i2, jc, jk
     155
    194156
    195157    real(jprb)                          :: hook_handle
     
    245207    this%iunits(igas) = iunits
    246208    this%is_well_mixed(igas) = .false.
    247     this%mixing_ratio(i1:i2,:,igas) = mixing_ratio
    248 
     209
     210    do jk = 1,this%nlev
     211      do jc = i1,i2
     212        this%mixing_ratio(jc,jk,igas) = mixing_ratio(jc-i1+1,jk)
     213      end do
     214    end do
    249215    if (present(scale_factor)) then
    250216      this%scale_factor(igas) = scale_factor
     
    276242    real(jprb)                          :: hook_handle
    277243
    278     integer :: i1, i2
     244    integer :: i1, i2, jc, jk
    279245
    280246    if (lhook) call dr_hook('radiation_gas:put_well_mixed',0,hook_handle)
     
    326292    this%iunits(igas)                  = iunits
    327293    this%is_well_mixed(igas)           = .true.
    328     this%mixing_ratio(i1:i2,:,igas)    = mixing_ratio
    329 
     294
     295    do jk = 1,this%nlev
     296      do jc = i1,i2
     297        this%mixing_ratio(jc,jk,igas) = mixing_ratio
     298      end do
     299    end do
    330300    if (present(scale_factor)) then
    331301      this%scale_factor(igas) = scale_factor
     
    344314  ! immediately, but changes the scale factor for the specified gas,
    345315  ! ready to be used in set_units_gas.
    346 
    347316  subroutine scale_gas(this, igas, scale_factor, lverbose)
    348317
     
    411380        if (iunits == IMassMixingRatio &
    412381             &   .and. this%iunits(igas) == IVolumeMixingRatio) then
    413           sf = sf * IGasMolarMass(igas) / IAirMolarMass
     382          sf = sf * GasMolarMass(igas) / AirMolarMass
    414383        else if (iunits == IVolumeMixingRatio &
    415384             &   .and. this%iunits(igas) == IMassMixingRatio) then
    416           sf = sf * IAirMolarMass / IGasMolarMass(igas)
     385          sf = sf * AirMolarMass / GasMolarMass(igas)
    417386        end if
    418387        sf = sf * this%scale_factor(igas)
     
    538507      if (iunits == IMassMixingRatio &
    539508           &   .and. this%iunits(igas) == IVolumeMixingRatio) then
    540         sf = sf * IGasMolarMass(igas) / IAirMolarMass
     509        sf = sf * GasMolarMass(igas) / AirMolarMass
    541510      else if (iunits == IVolumeMixingRatio &
    542511           &   .and. this%iunits(igas) == IMassMixingRatio) then
    543         sf = sf * IAirMolarMass / IGasMolarMass(igas)
     512        sf = sf * AirMolarMass / GasMolarMass(igas)
    544513      end if
    545514      sf = sf * this%scale_factor(igas)
     
    591560
    592561    use yomhook,          only : lhook, dr_hook
    593     use radiation_config, only : out_of_bounds_3d
     562    use radiation_check, only : out_of_bounds_3d
    594563
    595564    class(gas_type),   intent(inout) :: this
Note: See TracChangeset for help on using the changeset viewer.