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: 47 72 65.3 %
Date: 2025-03-14 01:30:37 Functions: 7 10 70.0 %

          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             :       logical, private :: species_is_dry
      12             :       character(len=256) :: std_name = ''
      13             : 
      14             :       contains
      15             :       procedure :: standard_name     => ccp_get_standard_name
      16             :       procedure :: set_standard_name => ccp_set_standard_name
      17             :       procedure :: is_thermo_active  => ccp_is_thermo_active
      18             :       procedure :: is_water_species  => ccp_is_water_species
      19             :       procedure :: set_thermo_active => ccp_set_thermo_active
      20             :       procedure :: set_water_species => ccp_set_water_species
      21             :       procedure :: is_dry            => ccp_is_dry
      22             :       procedure :: set_dry           => ccp_set_dry
      23             : 
      24             :    end type ccpp_constituent_prop_ptr_t
      25             : 
      26             :    ! CCPP properties init routine
      27             :    public :: ccpp_const_props_init
      28             : 
      29             :    ! Public properties DDT variable:
      30             :    type(ccpp_constituent_prop_ptr_t), allocatable, public :: ccpp_const_props(:)
      31             : 
      32             : contains
      33             : 
      34             : !+++++++++++++++++++++++++++++++++++++++
      35             : !CCPP constituent properties DDT methods
      36             : !+++++++++++++++++++++++++++++++++++++++
      37             : 
      38    63221760 :    subroutine ccp_get_standard_name(this, std_name, errcode, errmsg)
      39             :       ! Return this constituent's standard name
      40             : 
      41             :       ! Dummy arguments
      42             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
      43             :       character(len=*),                     intent(out) :: std_name
      44             :       integer,          optional,           intent(out) :: errcode
      45             :       character(len=*), optional,           intent(out) :: errmsg
      46             : 
      47    63221760 :       std_name = this%std_name
      48             : 
      49             :       ! Provide err values if requested:
      50    63221760 :       if(present(errcode)) then
      51           0 :          errcode = 0
      52             :       end if
      53    63221760 :       if(present(errmsg)) then
      54           0 :          errmsg = ''
      55             :       end if
      56             : 
      57    63221760 :    end subroutine ccp_get_standard_name
      58             : 
      59             :    !------
      60             : 
      61        1536 :    subroutine ccp_set_standard_name(this, std_name, errcode, errmsg)
      62             :       ! Set this constituent's standard name
      63             : 
      64             :       ! Dummy arguments
      65             :       class(ccpp_constituent_prop_ptr_t),   intent(inout)  :: this
      66             :       character(len=*),                     intent(in)  :: std_name
      67             :       integer,          optional,           intent(out) :: errcode
      68             :       character(len=*), optional,           intent(out) :: errmsg
      69             : 
      70        1536 :       this%std_name = std_name
      71             : 
      72             :       ! Provide err values if requested:
      73        1536 :       if(present(errcode)) then
      74           0 :          errcode = 0
      75             :       end if
      76        1536 :       if(present(errmsg)) then
      77           0 :          errmsg = ''
      78             :       end if
      79             : 
      80        1536 :    end subroutine ccp_set_standard_name
      81             : 
      82             :    !------
      83             : 
      84           0 :    subroutine ccp_is_thermo_active(this, val_out, errcode, errmsg)
      85             : 
      86             :       ! Dummy arguments
      87             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
      88             :       logical,                              intent(out) :: val_out
      89             :       integer,          optional,           intent(out) :: errcode
      90             :       character(len=*), optional,           intent(out) :: errmsg
      91             : 
      92             :       ! Pass back thermo active property:
      93           0 :       val_out = this%thermo_active
      94             : 
      95             :       ! Provide err values if requested:
      96           0 :       if(present(errcode)) then
      97           0 :          errcode = 0
      98             :       end if
      99           0 :       if(present(errmsg)) then
     100           0 :          errmsg = ''
     101             :       end if
     102             : 
     103           0 :    end subroutine ccp_is_thermo_active
     104             : 
     105             :    !------
     106             : 
     107           0 :    subroutine ccp_is_water_species(this, val_out, errcode, errmsg)
     108             : 
     109             :       ! Dummy arguments
     110             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
     111             :       logical,                              intent(out) :: val_out
     112             :       integer,          optional,           intent(out) :: errcode
     113             :       character(len=*), optional,           intent(out) :: errmsg
     114             : 
     115             :       ! Pass back water species property:
     116           0 :       val_out = this%water_species
     117             : 
     118             :       ! Provide err values if requested:
     119           0 :       if(present(errcode)) then
     120           0 :          errcode = 0
     121             :       end if
     122           0 :       if(present(errmsg)) then
     123           0 :          errmsg = ''
     124             :       end if
     125             : 
     126           0 :    end subroutine ccp_is_water_species
     127             : 
     128             :    !------
     129             : 
     130    13789440 :    subroutine ccp_is_dry(this, val_out, errcode, errmsg)
     131             : 
     132             :       ! Dummy arguments
     133             :       class(ccpp_constituent_prop_ptr_t),   intent(in)  :: this
     134             :       logical,                              intent(out) :: val_out
     135             :       integer,          optional,           intent(out) :: errcode
     136             :       character(len=*), optional,           intent(out) :: errmsg
     137             : 
     138             :       ! Pass back water species property:
     139    13789440 :       val_out = this%species_is_dry
     140             : 
     141             :       ! Provide err values if requested:
     142    13789440 :       if(present(errcode)) then
     143    13789440 :          errcode = 0
     144             :       end if
     145    13789440 :       if(present(errmsg)) then
     146    13789440 :          errmsg = ''
     147             :       end if
     148             : 
     149    13789440 :    end subroutine ccp_is_dry
     150             : 
     151             :    !------
     152             : 
     153        7680 :    subroutine ccp_set_thermo_active(this, thermo_flag, errcode, errmsg)
     154             :       ! Set whether this constituent is thermodynamically active, which
     155             :       ! means that certain physics schemes will use this constitutent
     156             :       ! when calculating thermodynamic quantities (e.g. enthalpy).
     157             : 
     158             :       ! Dummy arguments
     159             :       class(ccpp_constituent_prop_ptr_t),   intent(inout) :: this
     160             :       logical,                              intent(in)    :: thermo_flag
     161             :       integer,          optional,           intent(out)   :: errcode
     162             :       character(len=*), optional,           intent(out)   :: errmsg
     163             : 
     164             :       ! Set thermodynamically active flag for this constituent:
     165        7680 :       this%thermo_active = thermo_flag
     166             : 
     167             :       ! Provide err values if requested:
     168        7680 :       if(present(errcode)) then
     169           0 :          errcode = 0
     170             :       end if
     171        7680 :       if(present(errmsg)) then
     172           0 :          errmsg = ''
     173             :       end if
     174             : 
     175        7680 :    end subroutine ccp_set_thermo_active
     176             : 
     177             :    !------
     178             : 
     179        7680 :    subroutine ccp_set_water_species(this, water_flag, errcode, errmsg)
     180             :       ! Set whether this constituent is a water species, which means
     181             :       ! that this constituent represents a particular phase or type
     182             :       ! of water in the atmosphere.
     183             : 
     184             :       ! Dummy arguments
     185             :       class(ccpp_constituent_prop_ptr_t),   intent(inout) :: this
     186             :       logical,                              intent(in)    :: water_flag
     187             :       integer,          optional,           intent(out)   :: errcode
     188             :       character(len=*), optional,           intent(out)   :: errmsg
     189             : 
     190             :       ! Set thermodynamically active flag for this constituent:
     191        7680 :       this%water_species = water_flag
     192             : 
     193             :       ! Provide err values if requested:
     194        7680 :       if(present(errcode)) then
     195           0 :          errcode = 0
     196             :       end if
     197        7680 :       if(present(errmsg)) then
     198           0 :          errmsg = ''
     199             :       end if
     200             : 
     201        7680 :    end subroutine ccp_set_water_species
     202             : 
     203      602112 :    subroutine ccp_set_dry(this, dry_flag, errcode, errmsg)
     204             :       ! Set whether this constituent is a dry species or not using the dry_flag which is passed in
     205             : 
     206             :       ! Dummy arguments
     207             :       class(ccpp_constituent_prop_ptr_t),   intent(inout) :: this
     208             :       logical,                              intent(in)    :: dry_flag
     209             :       integer,          optional,           intent(out)   :: errcode
     210             :       character(len=*), optional,           intent(out)   :: errmsg
     211             : 
     212             :       ! Set dry_flag for this constituent:
     213      602112 :       this%species_is_dry = dry_flag
     214             : 
     215             :       ! Provide err values if requested:
     216      602112 :       if(present(errcode)) then
     217           0 :          errcode = 0
     218             :       end if
     219      602112 :       if(present(errmsg)) then
     220           0 :          errmsg = ''
     221             :       end if
     222             : 
     223      602112 :    end subroutine ccp_set_dry
     224             : 
     225             : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
     226             : !CAM-equivalent CCPP constituents initialization routine
     227             : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++
     228             : 
     229        1536 : subroutine ccpp_const_props_init(ix_qv)
     230             : 
     231             :     ! Use statements:
     232             :     use constituents,    only: pcnst, cnst_get_type_byind
     233             :     use cam_abortutils,  only: handle_allocate_error
     234             :     use air_composition, only: dry_air_species_num
     235             :     use air_composition, only: thermodynamic_active_species_idx
     236             : 
     237             :     integer, intent(in) :: ix_qv
     238             :     ! Local variables:
     239             :     integer :: ierr
     240             :     integer :: m
     241             : 
     242             :     character(len=*), parameter :: subname = 'ccpp_const_prop_init:'
     243             : 
     244             :     ! Allocate constituents object:
     245      603648 :     allocate(ccpp_const_props(pcnst), stat=ierr)
     246             : 
     247             :     ! Check if allocation succeeded:
     248        1536 :     call handle_allocate_error(ierr, subname, 'ccpp_const_props(pcnst)')
     249             : 
     250             :     ! Set "thermo_active" property:
     251      603648 :     do m = 1,pcnst
     252     3591168 :        if(any(thermodynamic_active_species_idx == m)) then
     253        7680 :           call ccpp_const_props(m)%set_thermo_active(.true.)
     254             :        end if
     255             :     end do
     256             : 
     257             :     ! Set "water_species" property:
     258      603648 :     do m=1,pcnst
     259     3591168 :        if(any(thermodynamic_active_species_idx(dry_air_species_num+1:) == m)) then
     260        7680 :           call ccpp_const_props(m)%set_water_species(.true.)
     261             :        end if
     262             :     end do
     263             : 
     264             :     ! Set "set_dry" property:
     265      603648 :     do m=1,pcnst
     266      603648 :        if (cnst_get_type_byind(m).eq.'dry') then
     267      245760 :           call ccpp_const_props(m)%set_dry(.true.)
     268             :        else
     269      958464 :           call ccpp_const_props(m)%set_dry(.false.)
     270             :        end if
     271             :     end do
     272             : 
     273             :     ! Set "std_name" property:
     274        1536 :     call ccpp_const_props(ix_qv)%set_standard_name('water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water')
     275             : 
     276        1536 : end subroutine ccpp_const_props_init
     277             : 
     278           0 : end module ccpp_constituent_prop_mod

Generated by: LCOV version 1.14