Skip to content
Merged
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 capgen/generator/host_constituents.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def _wrap_method_subs(host_dict) -> List[str]:
'ccpp_const_get_index', 'const_index',
[
('stdname', 'character(len=*), intent(in) :: stdname',
'standard_name=stdname'),
'standard_name=to_lower(stdname)'),
('const_index', 'integer, intent(out) :: const_index',
'index=const_index'),
],
Expand Down Expand Up @@ -580,6 +580,7 @@ def _generate_host_constituents(
lines.append('module {}'.format(_HOST_CONST_MOD))
lines.append('')
lines.append('{}use ccpp_kinds, only: kind_phys'.format(_INDENT))
lines.append('{}use ccpp_constituent_prop_mod, only: to_lower'.format(_INDENT))
lines.append('{}use {}, only: &'.format(_INDENT, _CONST_PROP_MOD))
lines.append('{}{}, &'.format(_INDENT * 2, _CONST_DDT))
lines.append('{}{}, &'.format(_INDENT * 2, _CONST_PROP_TYPE))
Expand Down
30 changes: 29 additions & 1 deletion capgen/src/ccpp_constituent_prop_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,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 @@ -416,7 +419,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 @@ -2676,4 +2679,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
7 changes: 4 additions & 3 deletions capgen/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 All @@ -12,6 +12,7 @@ module ccpp_scheme_utils
public :: ccpp_initialize_constituent_ptr ! Used by framework to initialize
public :: ccpp_constituent_index ! Lookup index constituent by name
public :: ccpp_constituent_indices ! Lookup indices of consitutents by name
public :: to_lower ! Utility to convert string to lowercase

!! Private module variables & interfaces

Expand Down Expand Up @@ -81,7 +82,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 +111,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 end-to-end-tests/advection/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, errcode)
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 end-to-end-tests/advection/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