diff --git a/scripts/constituents.py b/scripts/constituents.py index e7e182c0..c1bf7016 100644 --- a/scripts/constituents.py +++ b/scripts/constituents.py @@ -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 to the constituent array index " + \ "for .", 2) cap.comment("If is not found, set to -1 " + \ @@ -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 diff --git a/scripts/host_cap.py b/scripts/host_cap.py index fb2e7012..76de0278 100644 --- a/scripts/host_cap.py +++ b/scripts/host_cap.py @@ -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): ############################################################################### diff --git a/src/ccpp_constituent_prop_mod.F90 b/src/ccpp_constituent_prop_mod.F90 index d881e308..e46fda6e 100644 --- a/src/ccpp_constituent_prop_mod.F90 +++ b/src/ccpp_constituent_prop_mod.F90 @@ -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 @@ -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) @@ -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 diff --git a/src/ccpp_scheme_utils.F90 b/src/ccpp_scheme_utils.F90 index d4de6499..b3f1bd3e 100644 --- a/src/ccpp_scheme_utils.F90 +++ b/src/ccpp_scheme_utils.F90 @@ -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 @@ -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 @@ -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 , 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 diff --git a/test/advection_test/cld_liq.F90 b/test/advection_test/cld_liq.F90 index cb02cf11..ce799082 100644 --- a/test/advection_test/cld_liq.F90 +++ b/test/advection_test/cld_liq.F90 @@ -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', & diff --git a/test/advection_test/test_host_data.F90 b/test/advection_test/test_host_data.F90 index f360ad79..00c08c22 100644 --- a/test/advection_test/test_host_data.F90 +++ b/test/advection_test/test_host_data.F90 @@ -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)