Rename --debug flag to --verbose, add new debugging capability to detect array size mismatches, pretty-print auto-generated caps#404
Conversation
…ew --debug capability to add array size comparisons in auto-generated caps. Updates to formatting of auto-generated caps (no code changes)
gold2718
left a comment
There was a problem hiding this comment.
Looks okay although I think there are some extra calls to lower() which could be cleaned up.
| dim0 = int(dims[0]) | ||
| dim0 = dims[0] | ||
| except ValueError: | ||
| if not dims[0].lower() in metadata_define.keys(): |
There was a problem hiding this comment.
Isn't dims[0] already lowercase based on call to lower() on line 1170? If so, this applies to the lower() calls below.
There was a problem hiding this comment.
You are correct, I will clean this up before the regression testing starts (I think next week, after my PTO).
| array_size.append('({last}-{first}+1)'.format(last=dim1, first=dim0)) | ||
| var_size_expected = '({})'.format('*'.join(array_size)) | ||
| assign_test = ''' ! Check if variable {var_name} is associated/allocated and has the correct size | ||
| if (size({var_name})/={var_size_expected}) then |
There was a problem hiding this comment.
If {var_name} is not allocated, won't size({var_name}) crash?
There was a problem hiding this comment.
That is why it is inside the condition (created based on the active attribute). And that is exactly one of the things this PR/change should do - crash if an array isn't allocated even though the framework is told it should be.
Description
This PR renames the existing
--debugflag forccpp_prebuild.pyto--verbose, because this is what it does (enable verbose output from the script).It then repurposes the
--debugflag to assist debugging efforts with array size comparisons in the auto-generated caps. These comparisons are based on the actual size of the arrays versus the dimensions specified in the CCPP metadata. The comparisons are skipped for arrays whoseactiveattribute evaluates to.false., and altogether if the command line argument--debugis not specified.Also: Updates to formatting of auto-generated caps (no code changes) so that they look "nicer".
Fixes #405
Associated PRs:
NCAR/ccpp-physics#749
#404
https://github.com/NOAA-EMC/fv3atm/pull/407/files
NOAA-PSL/stochastic_physics#48
ufs-community/ufs-weather-model#850
For regression testing, see
ufs-community/ufs-weather-model#850