You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a location for documenting either false failure flags or missing failure flags from the UMDP3 checker.
It is intended to inform the follow on PR from #234
At the time of writing, the only false failures spotted so far ar the incorrect labelling of the variable 'long' as a deprecated intrinsic. Given that variable names shouldn't be the same as intrinsics anyway, this is morst likely to require a change top the UM's code, but is listed here in case a solution at this end materializes.
I think this is a known bug where .TRUE. or .FALSE. trips up the uppercase variable checker, e.g. in um/src/atmosphere/dynamics/conservation_diag_mod.F90
A possible solution to both the .TRUE. etc problem and the camel case one - although, in this definition variables like FOO_BAR_BAZ are accepted, which might not be what we want.
The change to lowercase_variable_names() in umdp3_checker_rules.py is as follows:
It strips off everything after an = sign to deal with logicals, functions, null pointers etc, and then uses a pattern which matches something that starts with two upper case characters and, if that matches, only matches if it is not followed by an underscore or a word character. This seems to work in most - all? - cases. The only snag is that the (?>...) syntax requires python 3.11.
Sam Clarke-Green (@t00sa) - we may need to have a chat. Are you getting these errors with the version implemented by #234 ?
That change is supposed to have fixed :
code styling failures seen in comments at the ends of lines
preprocessor macros being mis-identified as Fortran intrinsics
Errors (such as .TRUE. and .FALSE.) being found to right of an "=" where assingnment is made during declaration.
Also, in the code I'm looking at there is no longer has a method called lowercase_variable_names in umdp3_checker_rules.py. I think that was removed by the change previous to #234
The replacement to lowercase_variable_names is r3_4_2_no_full_uppercase_variable_names in umdp3_rules_S3.py and among other fixes it broadens what is accepted to anything where, having trimmed anything left of ::, split on ,s and then removed anything to the right of =s, it checks to see if variable.upper() != variable where true is considered a pass. So where the previous iteration tried to be more of a CamelCase check where 2 or more adjacent uppercase letters would be considered a fail - the current just abhors anything fully uppercase. Which is much more in keeping with the stuff we see in the UM such as REAL, INTENT(IN OUT) :: STASHwork14(:) ! STASH workspace
The one's I'll have to double check are if =>NULL and BIT_SIZE(0)/8 still give it problems, which makes me "oh so grateful" for unit tests and the fact that you've posted the real lines that have issues.
The reason is that quoted strings are removed, which leaves the variable name (when clean_line is split by ,) as "]". This is evaluated as uppercase. Could be eliminated by checking that the variable name contains actual letter characters.
...Alternatively, this may be the reason queried by the comment in the code:
defremove_quoted(line: str) ->str:
"""Remove quoted strings from a line"""""" TODO: The original version replaced the quoted sections with a "blessed reference", presumably becuase they were 're-inserted' at some stage. No idea if that capability is still required."""
This is due to a failure to concatenate lines where there is a comment line in the middle - resulting in the full line being evaluated as: REAL(KIND=real_umphys), INTENT(IN OUT) :: and therefore there the variable name detected is an empty string.
A possible fix is to add in an extra while True loop in the concatenate_lines method - such as:
defconcatenate_lines(lines: List[str], line_no: int) ->str:
...
whileline.rstrip().endswith("&"):
line=line.rstrip()[:-1] # Remove the continuation characterwhileTrue:
# Loop over lines until the next_line is not a commentline_no+=1ifline_no>len(lines):
break# Avoid going out of boundsnext_line=lines[line_no-1]
ifnotnext_line.lstrip().startswith('!'):
break
This will fix the imminent problem, but we've lost the out-of-bounds break out of the original while loop - so it's not a complete solution.
Another fix, if we're happy that concatenate_lines is not actually doing its job, is to simply check that the the variable being checked is not a zero length string.
I have added a couple of Sam's examples and both of Erica's as tests in the unit tests for 'r3_4_2_no_full_uppercase_variable_names' - None of them register as a failure.
Similarly, I've run the script in "full check" mode on the parent directories of the files indicated in the comments. (can't currently request checks on a single file)
None of the files indicated are throwing the errors listed here (others, yes, mostly long lines, unlabelled exit statements and multiple program units, but not 'No Full Uppercase variable names'
Activity
t00sa commentedon May 19, 2026
This is a false positive:
The bit of code responsible is as follows and removing the comment after the continuation character makes the problem go away:
t00sa commentedon May 19, 2026
Preprocessor macros are being picked up as lowercase or unseparated keywords:
Relevant section of code is:
t00sa commentedon May 19, 2026
Also, I'm not sure if this is a false positive or not: a comment line over 80 characters getting picked up as a long line.
t00sa commentedon May 19, 2026
I think this is a known bug where
.TRUE.or.FALSE.trips up the uppercase variable checker, e.g. inum/src/atmosphere/dynamics/conservation_diag_mod.F90This also causes false positives:
Also:
t00sa commentedon May 19, 2026
This one is just a diagnostic message mismatch - the error reported is
UPPERCASE variable nameeven though the variable is mixed case:t00sa commentedon May 19, 2026
A possible solution to both the
.TRUE.etc problem and the camel case one - although, in this definition variables likeFOO_BAR_BAZare accepted, which might not be what we want.The change to
lowercase_variable_names()inumdp3_checker_rules.pyis as follows:It strips off everything after an
=sign to deal with logicals, functions, null pointers etc, and then uses a pattern which matches something that starts with two upper case characters and, if that matches, only matches if it is not followed by an underscore or a word character. This seems to work in most - all? - cases. The only snag is that the(?>...)syntax requires python 3.11.r-sharp commentedon May 21, 2026
Sam Clarke-Green (@t00sa) - we may need to have a chat. Are you getting these errors with the version implemented by #234 ?
That change is supposed to have fixed :
Also, in the code I'm looking at there is no longer has a method called
lowercase_variable_namesinumdp3_checker_rules.py. I think that was removed by the change previous to #234The replacement to
lowercase_variable_namesisr3_4_2_no_full_uppercase_variable_namesinumdp3_rules_S3.pyand among other fixes it broadens what is accepted to anything where, having trimmed anything left of::, split on,s and then removed anything to the right of=s, it checks to see ifvariable.upper() != variablewheretrueis considered a pass. So where the previous iteration tried to be more of a CamelCase check where 2 or more adjacent uppercase letters would be considered a fail - the current just abhors anything fully uppercase. Which is much more in keeping with the stuff we see in the UM such asREAL, INTENT(IN OUT) :: STASHwork14(:) ! STASH workspaceThe one's I'll have to double check are if
=>NULLandBIT_SIZE(0)/8still give it problems, which makes me "oh so grateful" for unit tests and the fact that you've posted the real lines that have issues.ericaneininger commentedon Jun 11, 2026
The following is erroneously reported as an uppercase variable name.
The reason is that quoted strings are removed, which leaves the variable name (when
clean_lineis split by,) as "]". This is evaluated as uppercase. Could be eliminated by checking that the variable name contains actual letter characters.Relevant code snippets from
umdp3_rules.s3.py:...Alternatively, this may be the reason queried by the comment in the code:
ericaneininger commentedon Jun 11, 2026
The following are erroneously reported as an uppercase variable names.
At line 154:
This is due to a failure to concatenate lines where there is a comment line in the middle - resulting in the full line being evaluated as:
REAL(KIND=real_umphys), INTENT(IN OUT) ::and therefore there the variable name detected is an empty string.A possible fix is to add in an extra
while Trueloop in theconcatenate_linesmethod - such as:This will fix the imminent problem, but we've lost the out-of-bounds break out of the original while loop - so it's not a complete solution.
Similarly, at L174:
Another fix, if we're happy that
concatenate_linesis not actually doing its job, is to simply check that the the variable being checked is not a zero length string.r-sharp commentedon Oct 16, 2026
I have added a couple of Sam's examples and both of Erica's as tests in the unit tests for 'r3_4_2_no_full_uppercase_variable_names' - None of them register as a failure.
Similarly, I've run the script in "full check" mode on the parent directories of the files indicated in the comments. (can't currently request checks on a single file)
None of the files indicated are throwing the errors listed here (others, yes, mostly long lines, unlabelled exit statements and multiple program units, but not 'No Full Uppercase variable names'