diff --git a/scripts/ccpp_suite.py b/scripts/ccpp_suite.py index d19ca4e8..91414cbd 100644 --- a/scripts/ccpp_suite.py +++ b/scripts/ccpp_suite.py @@ -23,6 +23,7 @@ from parse_tools import init_log, set_log_to_null from suite_objects import CallList, Group, Scheme from metavar import CCPP_LOOP_VAR_STDNAMES +from var_props import is_horizontal_dimension # pylint: disable=too-many-lines @@ -308,6 +309,32 @@ def find_variable(self, standard_name=None, source_var=None, self.add_variable(var, self.__run_env) # Remove the variable from the group group.remove_variable(standard_name) + # Make sure the variable's dimensions are available + # at the init stage (for allocation) + for group in self.groups: + # only add dimension variables to init phase calling list + if group.name == self.__suite_init_group.name: + dims = var.get_dimensions() + # replace horizontal loop dimension if necessary + for idx, dim in enumerate(dims): + if is_horizontal_dimension(dim): + if 'horizontal_loop' in dim: + dims[idx] = 'ccpp_constant_one:horizontal_dimension' + # end if + # end if + # end for + subst_dict = {'dimensions': dims} + prop_dict = var.copy_prop_dict(subst_dict=subst_dict) + temp_var = Var(prop_dict, + ParseSource(var.get_prop_value('scheme'), + var.get_prop_value('local_name'), var.context), + self.__run_env) + # Add dimensions if they're not already there + group.add_variable_dimensions(temp_var, [], + adjust_intent=True, + to_dict=group.call_list) + # end if + # end for else: emsg = ("Group, {}, claimed it had created {} " "but variable was not found") diff --git a/test/capgen_test/run_test b/test/capgen_test/run_test index 6798f584..15f48a53 100755 --- a/test/capgen_test/run_test +++ b/test/capgen_test/run_test @@ -151,6 +151,7 @@ required_vars_temp="${required_vars_temp},horizontal_dimension" required_vars_temp="${required_vars_temp},horizontal_loop_begin" required_vars_temp="${required_vars_temp},horizontal_loop_end" required_vars_temp="${required_vars_temp},index_of_water_vapor_specific_humidity" +required_vars_temp="${required_vars_temp},number_of_tracers" required_vars_temp="${required_vars_temp},potential_temperature" required_vars_temp="${required_vars_temp},potential_temperature_at_interface" required_vars_temp="${required_vars_temp},potential_temperature_increment" @@ -164,6 +165,7 @@ input_vars_temp="${input_vars_temp},horizontal_dimension" input_vars_temp="${input_vars_temp},horizontal_loop_begin" input_vars_temp="${input_vars_temp},horizontal_loop_end" input_vars_temp="${input_vars_temp},index_of_water_vapor_specific_humidity" +input_vars_temp="${input_vars_temp},number_of_tracers" input_vars_temp="${input_vars_temp},potential_temperature" input_vars_temp="${input_vars_temp},potential_temperature_at_interface" input_vars_temp="${input_vars_temp},potential_temperature_increment" diff --git a/test/capgen_test/temp_adjust.F90 b/test/capgen_test/temp_adjust.F90 index 5aba4c0b..c3cc50f0 100644 --- a/test/capgen_test/temp_adjust.F90 +++ b/test/capgen_test/temp_adjust.F90 @@ -18,7 +18,7 @@ MODULE temp_adjust !! \htmlinclude arg_table_temp_adjust_run.html !! subroutine temp_adjust_run(foo, timestep, temp_prev, temp_layer, qv, ps, & - errmsg, errflg, innie, outie, optsie) + to_promote, promote_pcnst, errmsg, errflg, innie, outie, optsie) integer, intent(in) :: foo real(kind_phys), intent(in) :: timestep @@ -26,6 +26,8 @@ subroutine temp_adjust_run(foo, timestep, temp_prev, temp_layer, qv, ps, & real(kind_phys), intent(inout) :: ps(:) REAL(kind_phys), intent(in) :: temp_prev(:) REAL(kind_phys), intent(inout) :: temp_layer(foo) + real(kind_phys), intent(in) :: to_promote(:) + real(kind_phys), intent(in) :: promote_pcnst(:) character(len=512), intent(out) :: errmsg integer, optional, intent(out) :: errflg real(kind_phys), optional, intent(in) :: innie diff --git a/test/capgen_test/temp_adjust.meta b/test/capgen_test/temp_adjust.meta index 17eabcdb..02b5fa73 100644 --- a/test/capgen_test/temp_adjust.meta +++ b/test/capgen_test/temp_adjust.meta @@ -50,6 +50,20 @@ units = Pa dimensions = (horizontal_loop_extent) intent = inout +[ to_promote ] + standard_name = promote_this_variable_to_suite + units = K + dimensions = (horizontal_loop_extent) + type = real + kind = kind_phys + intent = in +[ promote_pcnst ] + standard_name = promote_this_variable_with_no_horizontal_dimension + units = K + dimensions = (number_of_tracers) + type = real + kind = kind_phys + intent = in [ errmsg ] standard_name = ccpp_error_message long_name = Error message for error handling in CCPP diff --git a/test/capgen_test/temp_set.F90 b/test/capgen_test/temp_set.F90 index fc2a9f39..a780433f 100644 --- a/test/capgen_test/temp_set.F90 +++ b/test/capgen_test/temp_set.F90 @@ -19,7 +19,7 @@ MODULE temp_set !! \htmlinclude arg_table_temp_set_run.html !! SUBROUTINE temp_set_run(ncol, lev, timestep, temp_level, temp, ps, & - errmsg, errflg) + to_promote, promote_pcnst, errmsg, errflg) !---------------------------------------------------------------- IMPLICIT NONE !---------------------------------------------------------------- @@ -29,6 +29,8 @@ SUBROUTINE temp_set_run(ncol, lev, timestep, temp_level, temp, ps, & real(kind_phys), intent(in) :: timestep real(kind_phys), intent(in) :: ps(:) REAL(kind_phys), INTENT(inout) :: temp_level(:, :) + real(kind_phys), intent(out) :: to_promote(:, :) + real(kind_phys), intent(out) :: promote_pcnst(:) character(len=512), intent(out) :: errmsg integer, intent(out) :: errflg !---------------------------------------------------------------- diff --git a/test/capgen_test/temp_set.meta b/test/capgen_test/temp_set.meta index c3c919e5..b6c403ce 100644 --- a/test/capgen_test/temp_set.meta +++ b/test/capgen_test/temp_set.meta @@ -47,6 +47,20 @@ units = Pa dimensions = (horizontal_loop_extent) intent = in +[ to_promote ] + standard_name = promote_this_variable_to_suite + units = K + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + type = real + kind = kind_phys + intent = out +[ promote_pcnst ] + standard_name = promote_this_variable_with_no_horizontal_dimension + units = K + dimensions = (number_of_tracers) + type = real + kind = kind_phys + intent = out [ errmsg ] standard_name = ccpp_error_message long_name = Error message for error handling in CCPP diff --git a/test/capgen_test/test_reports.py b/test/capgen_test/test_reports.py index 8682a7b0..5b50215f 100644 --- a/test/capgen_test/test_reports.py +++ b/test/capgen_test/test_reports.py @@ -79,6 +79,7 @@ def usage(errmsg=None): _REQUIRED_VARS_DDT = _INPUT_VARS_DDT + _OUTPUT_VARS_DDT _PROT_VARS_TEMP = ["horizontal_loop_begin", "horizontal_loop_end", "horizontal_dimension", "vertical_layer_dimension", + "number_of_tracers", # Added for --debug "index_of_water_vapor_specific_humidity", "vertical_interface_dimension"]