LCOV - code coverage report
Current view: top level - atmos_phys/to_be_ccppized - ccpp_const_utils.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 12 91.7 %
Date: 2025-04-28 18:59:15 Functions: 1 1 100.0 %

          Line data    Source code
       1             : ! ccpp_const_utils contains utility functions that use
       2             : ! the ccpp constituent properties pointer.
       3             : ! this code was separated out to remove circular dependencies.
       4             : module ccpp_const_utils
       5             :   implicit none
       6             :   private
       7             : 
       8             :   public :: ccpp_const_get_idx
       9             : 
      10             : contains
      11             : 
      12       70392 :   subroutine ccpp_const_get_idx(constituent_props, name, cindex, errmsg, errflg)
      13             :     use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
      14             : 
      15             :     ! Input arguments
      16             :     type(ccpp_constituent_prop_ptr_t), intent(in)  :: constituent_props(:)
      17             :     character(len=*),                  intent(in)  :: name   ! constituent name
      18             : 
      19             :     ! Output arguments
      20             :     integer,                           intent(out) :: cindex ! global constituent index
      21             :     character(len=512),                intent(out) :: errmsg ! error message
      22             :     integer,                           intent(out) :: errflg ! error flag
      23             : 
      24             :     ! Local variables
      25             :     integer            :: t_cindex
      26             :     character(len=256) :: t_const_name
      27             : 
      28       70392 :     errmsg = ''
      29       70392 :     errflg = 0
      30             : 
      31       70392 :     cindex = -1
      32             : 
      33             :     ! This convoluted loop is brought to you in exchange for avoiding a
      34             :     ! circular dependency on cam_ccpp_cap::cam_const_get_index.
      35       70392 :     const_props_loop: do t_cindex = lbound(constituent_props, 1), ubound(constituent_props, 1)
      36       70392 :        call constituent_props(t_cindex)%standard_name(t_const_name, errflg, errmsg)
      37       70392 :        if (errflg /= 0) then
      38             :           ! Abort subroutine and return with error.
      39           0 :           return
      40             :        end if
      41             : 
      42       70392 :        if (trim(t_const_name) == trim(name)) then
      43       70392 :           cindex = t_cindex
      44       70392 :           exit const_props_loop
      45             :        end if
      46             :     enddo const_props_loop
      47             : 
      48       70392 :   end subroutine ccpp_const_get_idx
      49             : 
      50             : end module ccpp_const_utils

Generated by: LCOV version 1.14