LCOV - code coverage report
Current view: | top level - utils/cam_ccpp - ccpp_constituent_prop_mod.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 30 | 46 | 65.2 %
Date: | 2024-12-17 17:57:11 |  | Functions: | 5 | 7 | 71.4 %

              Line data    Source code
           1             : ! This module is the CAM version of the CCPP generated module of the same name
           2             : module ccpp_constituent_prop_mod
           3             :
           4             :    implicit none
           5             :    private
           6             :
           7             :    ! Define CAM version of constituent properties mod
           8             :    type, public :: ccpp_constituent_prop_ptr_t
           9             :       logical, private :: thermo_active = .false.
          10             :       logical, private :: water_species = .false.
          11             :    contains
          12             :       procedure :: standard_name     => ccp_get_standard_name
          13             :       procedure :: is_thermo_active  => ccp_is_thermo_active
          14             :       procedure :: is_water_species  => ccp_is_water_species
          15             :       procedure :: set_thermo_active => ccp_set_thermo_active
          16             :       procedure :: set_water_species => ccp_set_water_species
          17             :    end type ccpp_constituent_prop_ptr_t
          18             :
          19             :    ! CCPP properties init routine
          20             :    public :: ccpp_const_props_init
          21             :
          22             :    ! Public properties DDT variable:
          23             :    type(ccpp_constituent_prop_ptr_t), allocatable, public :: ccpp_const_props(:)
          24             :
          25             : contains
          26             :
          27             : !+++++++++++++++++++++++++++++++++++++++
          28             : !CCPP constituent properties DDT methods
          29             : !+++++++++++++++++++++++++++++++++++++++
          30             :
          31           0 :    subroutine ccp_get_standard_name(this, std_name, errcode, errmsg)
          32             :       ! Return this constituent's standard name
          33             :
          34             :       ! Dummy arguments
          35             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
          36             :       character(len=*),                     intent(out) :: std_name
          37             :       integer,          optional,           intent(out) :: errcode
          38             :       character(len=*), optional,           intent(out) :: errmsg
          39             :
          40           0 :       std_name = 'Not Used!'
          41             :
          42             :       ! Provide err values if requested:
          43           0 :       if(present(errcode)) then
          44           0 :          errcode = 0
          45             :       end if
          46           0 :       if(present(errmsg)) then
          47           0 :          errmsg = 'Still Not Used!'
          48             :       end if
          49             :
          50           0 :    end subroutine ccp_get_standard_name
          51             :
          52             :    !------
          53             :
          54   885524112 :    subroutine ccp_is_thermo_active(this, val_out, errcode, errmsg)
          55             :
          56             :       ! Dummy arguments
          57             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
          58             :       logical,                              intent(out) :: val_out
          59             :       integer,          optional,           intent(out) :: errcode
          60             :       character(len=*), optional,           intent(out) :: errmsg
          61             :
          62             :       ! Pass back thermo active property:
          63   885524112 :       val_out = this%thermo_active
          64             :
          65             :       ! Provide err values if requested:
          66   885524112 :       if(present(errcode)) then
          67           0 :          errcode = 0
          68             :       end if
          69   885524112 :       if(present(errmsg)) then
          70           0 :          errmsg = ''
          71             :       end if
          72             :
          73   885524112 :    end subroutine ccp_is_thermo_active
          74             :
          75             :    !------
          76             :
          77   483013152 :    subroutine ccp_is_water_species(this, val_out, errcode, errmsg)
          78             :
          79             :       ! Dummy arguments
          80             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
          81             :       logical,                              intent(out) :: val_out
          82             :       integer,          optional,           intent(out) :: errcode
          83             :       character(len=*), optional,           intent(out) :: errmsg
          84             :
          85             :       ! Pass back water species property:
          86   483013152 :       val_out = this%water_species
          87             :
          88             :       ! Provide err values if requested:
          89   483013152 :       if(present(errcode)) then
          90           0 :          errcode = 0
          91             :       end if
          92   483013152 :       if(present(errmsg)) then
          93           0 :          errmsg = ''
          94             :       end if
          95             :
          96   483013152 :    end subroutine ccp_is_water_species
          97             :
          98             :    !------
          99             :
         100        9216 :    subroutine ccp_set_thermo_active(this, thermo_flag, errcode, errmsg)
         101             :       ! Set whether this constituent is thermodynamically active, which
         102             :       ! means that certain physics schemes will use this constitutent
         103             :       ! when calculating thermodynamic quantities (e.g. enthalpy).
         104             :
         105             :       ! Dummy arguments
         106             :       class(ccpp_constituent_prop_ptr_t),   intent(inout) :: this
         107             :       logical,                              intent(in)    :: thermo_flag
         108             :       integer,          optional,           intent(out)   :: errcode
         109             :       character(len=*), optional,           intent(out)   :: errmsg
         110             :
         111             :       ! Set thermodynamically active flag for this constituent:
         112        9216 :       this%thermo_active = thermo_flag
         113             :
         114             :       ! Provide err values if requested:
         115        9216 :       if(present(errcode)) then
         116           0 :          errcode = 0
         117             :       end if
         118        9216 :       if(present(errmsg)) then
         119           0 :          errmsg = ''
         120             :       end if
         121             :
         122        9216 :    end subroutine ccp_set_thermo_active
         123             :
         124             :    !------
         125             :
         126        9216 :    subroutine ccp_set_water_species(this, water_flag, errcode, errmsg)
         127             :       ! Set whether this constituent is a water species, which means
         128             :       ! that this constituent represents a particular phase or type
         129             :       ! of water in the atmosphere.
         130             :
         131             :       ! Dummy arguments
         132             :       class(ccpp_constituent_prop_ptr_t),   intent(inout) :: this
         133             :       logical,                              intent(in)    :: water_flag
         134             :       integer,          optional,           intent(out)   :: errcode
         135             :       character(len=*), optional,           intent(out)   :: errmsg
         136             :
         137             :       ! Set thermodynamically active flag for this constituent:
         138        9216 :       this%water_species = water_flag
         139             :
         140             :       ! Provide err values if requested:
         141        9216 :       if(present(errcode)) then
         142           0 :          errcode = 0
         143             :       end if
         144        9216 :       if(present(errmsg)) then
         145           0 :          errmsg = ''
         146             :       end if
         147             :
         148        9216 :    end subroutine ccp_set_water_species
         149             :
         150             : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
         151             : !CAM-equivalent CCPP constituents initialization routine
         152             : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
         153             :
         154        1536 : subroutine ccpp_const_props_init()
         155             :
         156             :     ! Use statements:
         157             :     use constituents,    only: pcnst
         158             :     use cam_abortutils,  only: handle_allocate_error
         159             :     use air_composition, only: dry_air_species_num
         160             :     use air_composition, only: thermodynamic_active_species_idx
         161             :
         162             :     ! Local variables:
         163             :     integer :: ierr
         164             :     integer :: m
         165             :
         166             :     character(len=*), parameter :: subname = 'ccpp_const_prop_init:'
         167             :
         168             :     ! Allocate constituents object:
         169       18432 :     allocate(ccpp_const_props(pcnst), stat=ierr)
         170             :
         171             :     ! Check if allocation succeeded:
         172        1536 :     call handle_allocate_error(ierr, subname, 'ccpp_const_props(pcnst)')
         173             :
         174             :     ! Set "thermo_active" property:
         175       18432 :     do m = 1,pcnst
         176       87552 :        if(any(thermodynamic_active_species_idx == m)) then
         177        9216 :           call ccpp_const_props(m)%set_thermo_active(.true.)
         178             :        end if
         179             :     end do
         180             :
         181             :     ! Set "water_species" property:
         182       18432 :     do m=1,pcnst
         183      104448 :        if(any(thermodynamic_active_species_idx(dry_air_species_num+1:) == m)) then
         184        9216 :           call ccpp_const_props(m)%set_water_species(.true.)
         185             :        end if
         186             :     end do
         187             :
         188        1536 : end subroutine ccpp_const_props_init
         189             :
         190           0 : end module ccpp_constituent_prop_mod

Generated by: LCOV version 1.14