Skip to content

Commit f042d74

Browse files
committed
Bug fix and exercise change in testing.
1 parent ed3c91a commit f042d74

File tree

11 files changed

+90
-5
lines changed

11 files changed

+90
-5
lines changed

scripts/metavar.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,12 +1677,37 @@ def add_variable(self, newvar, run_env, exists_ok=False, gen_unique=False,
16771677
context=newvar.context)
16781678
# end if
16791679
# end if
1680+
# Check if local_name exists in Group. If applicable, Create new
1681+
# variable with uniquie name. There are two instances when new names are
1682+
# created:
1683+
# - Same <local_name> used in different DDTs.
1684+
# - Different <standard_name> using the same <local_name> in a Group.
1685+
# During the Group analyze phase, <gen_unique> is True.
16801686
lname = newvar.get_prop_value('local_name')
16811687
lvar = self.find_local_name(lname)
16821688
if lvar is not None:
1689+
# Check if <lvar> is part of a different DDT than <newvar>.
1690+
# The API uses the full variable references when calling the Group Caps,
1691+
# <lvar.call_string(self))> and <newvar.call_string(self)>.
1692+
# Within the context of a full reference, it is allowable for local_names
1693+
# to be the same in different data containers.
1694+
newvar_callstr = newvar.call_string(self)
1695+
lvar_callstr = lvar.call_string(self)
1696+
if newvar_callstr and lvar_callstr:
1697+
if newvar_callstr != lvar_callstr:
1698+
if not gen_unique:
1699+
exists_ok = True
1700+
# end if
1701+
# end if
1702+
# end if
16831703
if gen_unique:
16841704
new_lname = self.new_internal_variable_name(prefix=lname)
16851705
newvar = newvar.clone(new_lname)
1706+
# Local_name needs to be the local_name for the new
1707+
# internal variable, otherwise multiple instances of the same
1708+
# local_name in the Group cap will all be overwritten with the
1709+
# same local_name
1710+
lname = new_lname
16861711
elif not exists_ok:
16871712
errstr = 'Invalid local_name: {} already registered{}'
16881713
cstr = context_string(lvar.source.context, with_comma=True)

test/var_compatibility_test/effr_diag.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ end subroutine effr_diag_init
2727
!> \section arg_table_effr_diag_run Argument Table
2828
!! \htmlinclude arg_table_effr_diag_run.html
2929
!!
30-
subroutine effr_diag_run( effrr_in, errmsg, errflg)
30+
subroutine effr_diag_run( effrr_in, scalar_var, errmsg, errflg)
3131

3232
real(kind_phys), intent(in) :: effrr_in(:,:)
33+
real(kind_phys), intent(in) :: scalar_var
3334
character(len=512), intent(out) :: errmsg
3435
integer, intent(out) :: errflg
3536
!----------------------------------------------------------------

test/var_compatibility_test/effr_diag.meta

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
kind = kind_phys
3535
intent = in
3636
top_at_one = True
37+
[ scalar_var ]
38+
standard_name = scalar_variable_for_testing_c
39+
long_name = unused scalar variable C
40+
units = m
41+
dimensions = ()
42+
type = real
43+
kind = kind_phys
44+
intent = in
3745
[ errmsg ]
3846
standard_name = ccpp_error_message
3947
long_name = Error message for error handling in CCPP

test/var_compatibility_test/effr_post.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ end subroutine effr_post_init
2727
!> \section arg_table_effr_post_run Argument Table
2828
!! \htmlinclude arg_table_effr_post_run.html
2929
!!
30-
subroutine effr_post_run( effrr_inout, errmsg, errflg)
30+
subroutine effr_post_run( effrr_inout, scalar_var, errmsg, errflg)
3131

3232
real(kind_phys), intent(inout) :: effrr_inout(:,:)
33+
real(kind_phys), intent(in) :: scalar_var
3334
character(len=512), intent(out) :: errmsg
3435
integer, intent(out) :: errflg
3536
!----------------------------------------------------------------

test/var_compatibility_test/effr_post.meta

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
type = real
3434
kind = kind_phys
3535
intent = inout
36+
[ scalar_var ]
37+
standard_name = scalar_variable_for_testing_b
38+
long_name = unused scalar variable B
39+
units = m
40+
dimensions = ()
41+
type = real
42+
kind = kind_phys
43+
intent = in
3644
[ errmsg ]
3745
standard_name = ccpp_error_message
3846
long_name = Error message for error handling in CCPP

test/var_compatibility_test/effr_pre.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ end subroutine effr_pre_init
2626
!> \section arg_table_effr_pre_run Argument Table
2727
!! \htmlinclude arg_table_effr_pre_run.html
2828
!!
29-
subroutine effr_pre_run( effrr_inout, errmsg, errflg)
29+
subroutine effr_pre_run( effrr_inout, scalar_var, errmsg, errflg)
3030

3131
real(kind_phys), intent(inout) :: effrr_inout(:,:)
32+
real(kind_phys), intent(in) :: scalar_var
3233
character(len=512), intent(out) :: errmsg
3334
integer, intent(out) :: errflg
3435
!----------------------------------------------------------------

test/var_compatibility_test/effr_pre.meta

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
type = real
3434
kind = kind_phys
3535
intent = inout
36+
[ scalar_var ]
37+
standard_name = scalar_variable_for_testing_a
38+
long_name = unused scalar variable A
39+
units = m
40+
dimensions = ()
41+
type = real
42+
kind = kind_phys
43+
intent = in
3644
[ errmsg ]
3745
standard_name = ccpp_error_message
3846
long_name = Error message for error handling in CCPP

test/var_compatibility_test/test_host.F90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,16 @@ program test
351351

352352
character(len=cs), target :: test_parts1(1) = (/ 'radiation ' /)
353353

354-
character(len=cm), target :: test_invars1(8) = (/ &
354+
character(len=cm), target :: test_invars1(11) = (/ &
355355
'effective_radius_of_stratiform_cloud_rain_particle ', &
356356
'effective_radius_of_stratiform_cloud_liquid_water_particle', &
357357
'effective_radius_of_stratiform_cloud_snow_particle ', &
358358
'effective_radius_of_stratiform_cloud_graupel ', &
359359
'cloud_graupel_number_concentration ', &
360360
'scalar_variable_for_testing ', &
361+
'scalar_variable_for_testing_a ', &
362+
'scalar_variable_for_testing_b ', &
363+
'scalar_variable_for_testing_c ', &
361364
'flag_indicating_cloud_microphysics_has_graupel ', &
362365
'flag_indicating_cloud_microphysics_has_ice '/)
363366

@@ -371,7 +374,7 @@ program test
371374
'cloud_ice_number_concentration ', &
372375
'scalar_variable_for_testing ' /)
373376

374-
character(len=cm), target :: test_reqvars1(12) = (/ &
377+
character(len=cm), target :: test_reqvars1(15) = (/ &
375378
'ccpp_error_code ', &
376379
'ccpp_error_message ', &
377380
'effective_radius_of_stratiform_cloud_rain_particle ', &
@@ -382,6 +385,9 @@ program test
382385
'cloud_graupel_number_concentration ', &
383386
'cloud_ice_number_concentration ', &
384387
'scalar_variable_for_testing ', &
388+
'scalar_variable_for_testing_a ', &
389+
'scalar_variable_for_testing_b ', &
390+
'scalar_variable_for_testing_c ', &
385391
'flag_indicating_cloud_microphysics_has_graupel ', &
386392
'flag_indicating_cloud_microphysics_has_ice '/)
387393

test/var_compatibility_test/test_host_data.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module test_host_data
1313
ncg, & ! number concentration of cloud graupel
1414
nci ! number concentration of cloud ice
1515
real(kind_phys) :: scalar_var
16+
real(kind_phys) :: scalar_varA
17+
real(kind_phys) :: scalar_varB
18+
real(kind_phys) :: scalar_varC
1619
end type physics_state
1720

1821
public allocate_physics_state

test/var_compatibility_test/test_host_data.meta

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,24 @@
5959
dimensions = ()
6060
type = real
6161
kind = kind_phys
62+
[scalar_varA]
63+
standard_name = scalar_variable_for_testing_a
64+
long_name = unused scalar variable A
65+
units = m
66+
dimensions = ()
67+
type = real
68+
kind = kind_phys
69+
[scalar_varB]
70+
standard_name = scalar_variable_for_testing_b
71+
long_name = unused scalar variable B
72+
units = m
73+
dimensions = ()
74+
type = real
75+
kind = kind_phys
76+
[scalar_varC]
77+
standard_name = scalar_variable_for_testing_c
78+
long_name = unused scalar variable C
79+
units = m
80+
dimensions = ()
81+
type = real
82+
kind = kind_phys

0 commit comments

Comments
 (0)