NCAR / ccpp-framework

Common Community Physics Package (CCPP)
http://www.dtcenter.org/community-code/common-community-physics-package-ccpp/
Other
26 stars 62 forks source link

Suite-level variables edge case for when variable is used only in run phases #559

Open peverwhee opened 2 months ago

peverwhee commented 2 months ago

Description

When you have a situation like this:

   Group 1:
      scheme_x_run:
         real(kind_phys), intent(out) :: some_variable(:,:) ! some_variable_standard_name

   Group 2:
      scheme_y_run:
         real(kind_phys), intent(in)  :: some_variable(:,:) ! some_variable_standard_name

where some_variable_standard_name is not used in any other phase and is not a host variable:

  1. The framework will promote some_variable_standard_name to the suite level (which is the correct behavior)
  2. The framework will attempt to allocate that variable in the suite init phase, but will try to allocate it to horizontal_loop_begin:horizontal_loop_end (which are unavailable and disallowed to exist in the init phase).

Steps to Reproduce

  1. Modify an existing test to reflect the situation described above (variable must be in run phase of two different schemes in two different groups and must have dimension horizontal_loop_extent)
  2. The error you will see will look like this: parse_source.CCPPError: Dimension variable, 'horizontal_loop_begin', not found, at <metadata file>

Additional Context

I'm not sure how/if it's currently working when the you have the same situation as above but with dimension horizontal_dimension.

Not sure how to fix yet; need to figure out to ensure we pass horizontal_dimension into the suite init phase and manually override the variable's dimensions to allocate to horizontal_dimension (rather than horizontal_loop_extent)

peverwhee commented 2 months ago

Problem not specific to horizontal_loop_extent - also appears if you use horizontal_dimension and horizontal_dimension is not already being passed in to an init phase.