Ignore:
Timestamp:
Mar 19, 2024, 3:34:21 PM (2 months ago)
Author:
idelkadi
Message:

Ecrad update in LMDZ / Implementation of Ecrad double call in LMDZ

  • version 1.6.1 (commit 210d7911380f53a788c3cad73b3cf9b4e022ef87)
  • interface routines between lmdz and ecrad grouped in a new "lmdz" directory
  • double call method redesigned so as to go through the Ecrad initialization and configuration part only once for the entire simulation
  • clean-up in the read.F routine: delete unitules arguments
  • modification of default gas model in namelist (default: ECCKD)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/ecrad/radiation/radiation_gas.F90

    r4773 r4853  
    7272     procedure :: assert_units => assert_units_gas
    7373     procedure :: get        => get_gas
     74     procedure :: get_scaling
    7475     procedure :: reverse    => reverse_gas
    7576     procedure :: out_of_physical_bounds
     
    355356    real(jprb), optional, intent(in)    :: scale_factor
    356357
    357     integer :: ig
     358    integer :: jg
    358359
    359360    ! Scaling factor to convert from old to new
     
    396397      end if
    397398    else
    398       do ig = 1,this%ntype
    399         call this%set_units(iunits, igas=this%icode(ig), scale_factor=new_sf)
     399      do jg = 1,this%ntype
     400        call this%set_units(iunits, igas=this%icode(jg), scale_factor=new_sf)
    400401      end do
    401402    end if
     
    403404  end subroutine set_units_gas
    404405
    405 
     406 
     407  !---------------------------------------------------------------------
     408  ! Return a vector indicating the scaling that one would need to
     409  ! apply to each gas in order to obtain the dimension units in
     410  ! "iunits" (which can be IVolumeMixingRatio or IMassMixingRatio)
     411  subroutine get_scaling(this, iunits, scaling)
     412    class(gas_type), intent(in)  :: this
     413    integer,         intent(in)  :: iunits
     414    real(jprb),      intent(out) :: scaling(NMaxGases)
     415    integer :: jg
     416   
     417    scaling = this%scale_factor
     418    do jg = 1,NMaxGases
     419      if (iunits == IMassMixingRatio .and. this%iunits(jg) == IVolumeMixingRatio) then
     420        scaling(jg) = scaling(jg) * GasMolarMass(jg) / AirMolarMass
     421      else if (iunits == IVolumeMixingRatio .and. this%iunits(jg) == IMassMixingRatio) then
     422        scaling(jg) = scaling(jg) * AirMolarMass / GasMolarMass(jg)
     423      end if
     424    end do
     425   
     426  end subroutine get_scaling
     427
     428 
    406429  !---------------------------------------------------------------------
    407430  ! Assert that gas mixing ratio units are "iunits", applying to gas
    408431  ! with ID "igas" if present, otherwise to all gases. Otherwise the
    409   ! program will exit. Otional argument scale factor specifies any
    410   ! subsequent multiplication to apply; for PPMV one would use
    411   ! iunits=IVolumeMixingRatio and scale_factor=1.0e6.
    412   recursive subroutine assert_units_gas(this, iunits, igas, scale_factor)
     432  ! program will exit, except if the optional argument "istatus" is
     433  ! provided in which case it will return true if the units are
     434  ! correct and false if they are not. Optional argument scale factor
     435  ! specifies any subsequent multiplication to apply; for PPMV one
     436  ! would use iunits=IVolumeMixingRatio and scale_factor=1.0e6.
     437  recursive subroutine assert_units_gas(this, iunits, igas, scale_factor, istatus)
    413438
    414439    use radiation_io,   only : nulerr, radiation_abort
    415440
    416     class(gas_type),      intent(in) :: this
    417     integer,              intent(in) :: iunits
    418     integer,    optional, intent(in) :: igas
    419     real(jprb), optional, intent(in) :: scale_factor
    420 
    421     integer :: ig
     441    class(gas_type),      intent(in)  :: this
     442    integer,              intent(in)  :: iunits
     443    integer,    optional, intent(in)  :: igas
     444    real(jprb), optional, intent(in)  :: scale_factor
     445    logical,    optional, intent(out) :: istatus
     446
     447    integer :: jg
    422448
    423449    real(jprb) :: sf
     
    429455    end if
    430456
     457    if (present(istatus)) then
     458      istatus = .true.
     459    end if
     460   
    431461    if (present(igas)) then
    432462      if (this%is_present(igas)) then
    433463        if (iunits /= this%iunits(igas)) then
    434           write(nulerr,'(a,a,a)') '*** Error: ', trim(GasName(igas)), &
    435                &  ' is not in the required units'
    436           call radiation_abort()
     464          if (present(istatus)) then
     465            istatus = .false.
     466          else
     467            write(nulerr,'(a,a,a)') '*** Error: ', trim(GasName(igas)), &
     468                 &  ' is not in the required units'
     469            call radiation_abort()
     470          end if
    437471        else if (sf /= this%scale_factor(igas)) then
    438           write(nulerr,'(a,a,a,e12.4,a,e12.4)') '*** Error: ', GasName(igas), &
    439                &  ' scaling of ', this%scale_factor(igas), &
    440                &  ' does not match required ', sf
    441           call radiation_abort()
     472          if (present(istatus)) then
     473            istatus = .false.
     474          else
     475            write(nulerr,'(a,a,a,e12.4,a,e12.4)') '*** Error: ', GasName(igas), &
     476                 &  ' scaling of ', this%scale_factor(igas), &
     477                 &  ' does not match required ', sf
     478            call radiation_abort()
     479          end if
    442480        end if
    443481      end if
    444482    else
    445       do ig = 1,this%ntype
    446         call this%assert_units(iunits, igas=this%icode(ig), scale_factor=sf)
     483      do jg = 1,this%ntype
     484        call this%assert_units(iunits, igas=this%icode(jg), scale_factor=sf, istatus=istatus)
    447485      end do
    448486    end if
Note: See TracChangeset for help on using the changeset viewer.