Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lfric_styling/lfric_styling.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def lowercase_keywords(file):
with open(file, "r") as fp:
lines = fp.read()
for keyword in NEW_KEYWORDS:
# regex to check if a keyword is preceded with a '!' symbol
# regex to check if a keyword is preceded with a '!' symbol,
# unless the comment is an OpenMP directive starting with '!$OMP',
# or if it matches a keyword and group each.
pattern = rf"((?:(?<=!)).*|(\b{re.escape(keyword.upper())}\b))"
pattern = rf"((?:(?<=!)(?!\$OMP)).*|(\b{re.escape(keyword.upper())}\b))"
lines = re.sub(pattern, convert_to_lower, lines, flags=re.MULTILINE)

with open(file, "w") as fp:
Expand Down
10 changes: 9 additions & 1 deletion lfric_styling/styling_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# For further details please refer to the file LICENSE
# which you should have received as part of this distribution.
# Created date: 10/03/2025
# Modified date: 14/03/2025
# Modified date: 30/09/2025
# *****************************COPYRIGHT*******************************

"""
Expand Down Expand Up @@ -224,6 +224,7 @@
"ddim",
"deallocate",
"decode",
"default",
"deferred",
"delim",
"derf",
Expand Down Expand Up @@ -258,6 +259,7 @@
"dtan",
"dtanh",
"dtime",
"dynamic",
"elemental",
"else",
"encode",
Expand Down Expand Up @@ -488,12 +490,14 @@
"nextrec",
"nint",
"nml",
"no wait",
"none",
"non_intrinsic",
"non_overridable",
"nopass",
"norm2",
"not",
"nowait",
"null",
"nullify",
"number",
Expand All @@ -511,6 +515,7 @@
"pad",
"parameter",
"parity",
"parallel",
"pass",
"perror",
"pointer",
Expand Down Expand Up @@ -587,6 +592,7 @@
"save",
"scale",
"scan",
"schedule",
"secnds",
"second",
"select",
Expand All @@ -597,6 +603,7 @@
"sequential",
"set_exponent",
"shape",
"shared",
"shifta",
"shiftl",
"shiftr",
Expand All @@ -616,6 +623,7 @@
"sqrt",
"srand",
"stat",
"static",
"status",
"stat_failed_image",
"stat_locked",
Expand Down
Loading