Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtney Peverley committed May 29, 2024
1 parent c781edc commit 6e165e5
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
5 changes: 0 additions & 5 deletions scripts/ccpp_capgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,6 @@ def capgen(run_env, return_db=False):
# end if
# First up, handle the host files
host_model = parse_host_model_files(host_files, host_name, run_env)
# We always need to parse the ccpp_constituent_prop_ptr_t DDT
const_prop_mod = os.path.join(src_dir, "ccpp_constituent_prop_mod.meta")
if const_prop_mod not in scheme_files:
scheme_files = [const_prop_mod] + scheme_files
# end if
# Next, parse the scheme files
# We always need to parse the ccpp_constituent_prop_ptr_t DDT
const_prop_mod = os.path.join(src_dir, "ccpp_constituent_prop_mod.meta")
Expand Down
2 changes: 1 addition & 1 deletion scripts/constituents.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def write_host_routines(cap, host, reg_funcname, init_funcname, num_const_funcna
cap.write(f"integer{spc} :: num_dyn_consts", 2)
cap.write(f"integer{spc} :: index, index_start", 2)
cap.write(f"integer{spc} :: field_ind", 2)
cap.write(f"type({CONST_PROP_TYPE}), pointer :: const_prop", 2)
cap.write(f"type({CONST_PROP_TYPE}), pointer :: const_prop => NULL()", 2)
# Declare dynamic constituent properties variables
for idx, scheme in enumerate(sorted(dyn_const_dict)):
cap.comment(f"dynamic constituent props variable for {scheme}", 2)
Expand Down
11 changes: 5 additions & 6 deletions src/ccpp_constituent_prop_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,8 @@ subroutine ccp_model_const_add_metadata(this, field_data, errcode, errmsg)
! Local variables
character(len=errmsg_len) :: error
character(len=*), parameter :: subname = 'ccp_model_const_add_metadata'
type(ccpp_constituent_properties_t), pointer :: cprop
type(ccpp_constituent_properties_t), pointer :: cprop => NULL()
character(len=stdname_len) :: standard_name
integer :: cindex
logical :: match

if (this%okay_to_add(errcode=errcode, errmsg=errmsg, &
Expand All @@ -1176,13 +1175,12 @@ subroutine ccp_model_const_add_metadata(this, field_data, errcode, errmsg)
cprop => this%find_const(standard_name)
if (associated(cprop)) then
! Standard name already in table, let's see if the existing constituent is the same
cindex = cprop%const_index()
match = cprop%is_match(field_data)
if (match) then
! Existing constituent is a match - no need to throw an error, just don't add
return
else
! Existing constituent is not a match - this is ane rror
! Existing constituent is not a match - this is an error
call append_errvars(1, "ERROR: Trying to add constituent " // &
trim(standard_name) // " but an incompatible" // &
" constituent with this name already exists", subname, &
Expand Down Expand Up @@ -1261,6 +1259,7 @@ function ccp_model_const_find_const(this, standard_name, errcode, errmsg) &
character(len=*), parameter :: subname = 'ccp_model_const_find_const'

nullify(cprop)

hval => this%hash_table%table_value(standard_name, errmsg=error)
if (len_trim(error) > 0) then
call append_errvars(1, trim(error), subname, &
Expand Down Expand Up @@ -1630,7 +1629,7 @@ subroutine ccp_model_const_index(this, index, standard_name, errcode, errmsg)
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variables
type(ccpp_constituent_properties_t), pointer :: cprop
type(ccpp_constituent_properties_t), pointer :: cprop => NULL()
character(len=*), parameter :: subname = "ccp_model_const_index"

if (this%const_props_locked(errcode=errcode, errmsg=errmsg, warn_func=subname)) then
Expand Down Expand Up @@ -1660,7 +1659,7 @@ subroutine ccp_model_const_metadata(this, standard_name, const_data, &
integer, optional, intent(out) :: errcode
character(len=*), optional, intent(out) :: errmsg
! Local variables
type(ccpp_constituent_properties_t), pointer :: cprop
type(ccpp_constituent_properties_t), pointer :: cprop => NULL()
character(len=*), parameter :: subname = "ccp_model_const_metadata"

if (this%const_props_locked(errcode=errcode, errmsg=errmsg, warn_func=subname)) then
Expand Down
15 changes: 15 additions & 0 deletions test/advection_test/test_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,21 @@ subroutine test_host(retval, test_suites)
! Reset error flag to continue testing other properties:
errflg = 0
end if
call const_props(index_dyn2)%is_moist(const_log, errflg, errmsg)
if (errflg /= 0) then
write(6, '(a,i0,a,a,i0,/,a)') "ERROR: Error, ", errflg, " trying ", &
"to get moist prop for dyn_const2 index = ", index_dyn2, trim(errmsg)
errflg_final = -1 ! Notify test script that a failure occurred
end if
if (errflg == 0) then
if (.not. const_log) then
write(6, *) "ERROR: dyn_const2 is not moist but should be"
errflg_final = -1
end if
else
! Reset error flag to continue testing other properties:
errflg = 0
end if

! -------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! Test parameterization with no vertical level
! Test parameterization with a dynamic constituents routine with the same name as another parameterization's
!

MODULE duplicate_dyn_const
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! Test parameterization with no vertical level
! Test parameterization that is missing the specified dynamic constituents routine
!

MODULE temp_adjust
Expand Down
2 changes: 1 addition & 1 deletion test/var_compatibility_test/run_test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ scriptdir="$( cd $( dirname $0 ); pwd -P )"
##
## Option default values
##
defdir="va_build"
defdir="ct_build"
build_dir="${currdir}/${defdir}"
cleanup="PASS" # Other supported options are ALWAYS and NEVER
verbosity=0
Expand Down

0 comments on commit 6e165e5

Please sign in to comment.