Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/constituents.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ def write_host_routines(cap, host, reg_funcname, init_funcname, num_const_funcna
substmt = f"subroutine {const_index_func}"
cap.blank_line()
cap.write(f"{substmt}(stdname, const_index, {err_dummy_str})", 1)
cap.write("use ccpp_constituent_prop_mod, only: to_lower", 2)
cap.comment("Set <const_index> to the constituent array index " + \
"for <stdname>.", 2)
cap.comment("If <stdname> is not found, set <const_index> to -1 " + \
Expand All @@ -755,7 +756,7 @@ def write_host_routines(cap, host, reg_funcname, init_funcname, num_const_funcna
# end for
cap.blank_line()
cap.write(f"call {const_obj_name}%const_index(const_index, " + \
f"stdname, {obj_err_callstr})", 2)
f"to_lower(stdname), {obj_err_callstr})", 2)
cap.write(f"end {substmt}", 1)

@staticmethod
Expand Down
8 changes: 0 additions & 8 deletions scripts/host_cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,6 @@ def constituent_model_const_props(host_model):
hstr = f"{host_model.name}_model_const_properties"
return unique_local_name(hstr, host_model)

###############################################################################
def constituent_model_const_index(host_model):
###############################################################################
"""Return the name of the interface that returns the array index of
a constituent array given its standard name"""
hstr = f"{host_model.name}_const_get_index"
return unique_local_name(hstr, host_model)

###############################################################################
def add_constituent_vars(cap, host_model, suite_list, run_env):
###############################################################################
Expand Down
30 changes: 29 additions & 1 deletion src/ccpp_constituent_prop_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ module ccpp_constituent_prop_mod
procedure :: constituent_props_ptr => ccp_constituent_props_ptr
end type ccpp_model_constituents_t

! Public interfaces
public to_lower

! Private interfaces
private to_str
private initialize_errvars
Expand Down Expand Up @@ -407,7 +410,7 @@ subroutine ccp_instantiate(this, std_name, long_name, diag_name, units, &
else
errcode = 0
errmsg = ''
this%var_std_name = trim(std_name)
this%var_std_name = trim(to_lower(std_name))
end if
if (errcode == 0) then
this%var_long_name = trim(long_name)
Expand Down Expand Up @@ -2633,4 +2636,29 @@ subroutine ccpt_set_water_species(this, water_flag, errcode, errmsg)

end subroutine ccpt_set_water_species

!#######################################################################

function to_lower(str)

character(len=*), intent(in) :: str ! String to convert to lower case
character(len=len(str)) :: to_lower

! Local variables
integer :: i ! Index
integer :: aseq ! ascii collating sequence
integer :: upper_to_lower ! integer to convert case
character(len=1) :: ctmp ! Character temporary

upper_to_lower = iachar("a") - iachar("A")

do i = 1, len(str)
ctmp = str(i:i)
aseq = iachar(ctmp)
if (aseq >= iachar("A") .and. aseq <= iachar("Z")) &
ctmp = achar(aseq + upper_to_lower)
to_lower(i:i) = ctmp
end do

end function to_lower

end module ccpp_constituent_prop_mod
6 changes: 3 additions & 3 deletions src/ccpp_scheme_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ccpp_scheme_utils
! Module of utilities available to CCPP schemes

use ccpp_constituent_prop_mod, only: ccpp_model_constituents_t, &
int_unassigned
int_unassigned, to_lower

implicit none
private
Expand Down Expand Up @@ -81,7 +81,7 @@ subroutine ccpp_constituent_index(standard_name, const_index, errcode, errmsg)

call check_initialization(caller=subname, errcode=errcode, errmsg=errmsg)
if (status_ok(errcode)) then
call constituent_obj%const_index(const_index, standard_name, &
call constituent_obj%const_index(const_index, to_lower(standard_name), &
errcode, errmsg)
else
const_index = int_unassigned
Expand Down Expand Up @@ -110,7 +110,7 @@ subroutine ccpp_constituent_indices(standard_names, const_inds, errcode, errmsg)
do indx = 1, size(standard_names)
! For each std name in <standard_names>, find the const. index
call constituent_obj%const_index(const_inds(indx), &
standard_names(indx), errcode, errmsg)
to_lower(standard_names(indx)), errcode, errmsg)
if (errcode /= 0) then
exit
end if
Expand Down
2 changes: 1 addition & 1 deletion test/advection_test/cld_liq.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ subroutine cld_liq_register(dyn_const, errmsg, errflg)
errmsg = 'Error allocating dyn_const in cld_liq_register'
return
end if
call dyn_const(1)%instantiate(std_name="dyn_const3_wrt_moist_air_and_condensed_water", long_name='dyn const3', &
call dyn_const(1)%instantiate(std_name="DYN_const3_wrt_moist_air_and_condensed_water", long_name='dyn const3', &
diag_name='DYNCONST3', units='kg kg-1', default_value=1._kind_phys, &
vertical_dim='vertical_layer_dimension', advected=.true., &
water_species=.true., mixing_ratio_type='dry', &
Expand Down
2 changes: 1 addition & 1 deletion test/advection_test/test_host_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module test_host_data
!! \htmlinclude arg_table_test_host_data.html
integer, public, parameter :: num_consts = 3
character(len=32), public, parameter :: std_name_array(num_consts) = (/ &
'specific_humidity ', &
'SPECIFIC_HUMIDITY ', &
'cloud_liquid_dry_mixing_ratio', &
'cloud_ice_dry_mixing_ratio ' /)
character(len=32), public, parameter :: const_std_name = std_name_array(1)
Expand Down
Loading