ccpp-framework icon indicating copy to clipboard operation
ccpp-framework copied to clipboard

Allow output allocatable variables without specific dimensions

Open peverwhee opened this issue 5 months ago • 3 comments

Description

Similar to how we handle the run-time constituents, there should be a way to indicate to the framework that the physics will handle variable allocation and we do not yet know the dimensions.

Solution

If a variable has the following metadata attributes when it first appears:

  1. allocatable = True
  2. dimensions = (:,:) (just the shape)
  3. intent = out

the cap will just declare the variable but not do any allocation or dimensions checking.

peverwhee avatar Jul 24 '25 15:07 peverwhee

This sounds like a job for the new "register" phase!

mkavulich avatar Aug 07 '25 16:08 mkavulich

@gold2718 From discussion today, we are questioning the purpose/need for the "allocatable" flag (as it currently has no effect) since it seems as if we will always have to allocate variables at the very beginning of execution anyway. Could you weigh in on what you might envision this flag accomplishing?

mkavulich avatar Aug 07 '25 16:08 mkavulich

At the very least, it should be checked against existing variables. For instance, if the host is providing a variable and a scheme has an allocatable output with the same standard name, this is likely to cause problems, especially if the host model variable is not allocatable but also by unexpectedly re-allocating a host-model variable. I do not know if this is being checked but in general, we may want to only allow one allocation of an allocatable variable. To implement this requires metadata.

gold2718 avatar Aug 08 '25 09:08 gold2718