Skip to content

Commit f718050

Browse files
committed
Merge Conflict
2 parents 90b3df3 + 82b2dea commit f718050

File tree

5 files changed

+123
-44
lines changed

5 files changed

+123
-44
lines changed

.github/workflows/frontier/submit.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ sbatch <<EOT
3333
#SBATCH -A CFD154 # charge account
3434
#SBATCH -N 1 # Number of nodes required
3535
$sbatch_device_opts
36-
#SBATCH -t 01:59:00 # Duration of the job (Ex: 15 mins)
36+
#SBATCH -t 03:59:00 # Duration of the job (Ex: 15 mins)
3737
#SBATCH -o$job_slug.out # Combined output and error messages file
3838
#SBATCH -p extended # Extended partition for shorter queues
39-
#SBATCH -q debug # Use debug QOS - only one job per user allowed in queue!
4039
#SBATCH -W # Do not exit until the submitted job terminates.
4140
4241
set -e

.github/workflows/pmd.yml

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,105 @@ jobs:
3030
unzip -q pmd.zip
3131
PMD_HOME="pmd-bin-${PMD_VERSION}"
3232
33+
SOURCE_DIR="${1:-src}"
34+
total_files=$(find "$SOURCE_DIR" -type f \( -name "*.f" -o -name "*.f90" -o -name "*.for" -o -name "*.fpp" -o -name "*.F" -o -name "*.F90" \) | wc -l)
35+
processed=0
36+
37+
find "$SOURCE_DIR" -type f \( -name "*.f" -o -name "*.f90" -o -name "*.for" -o -name "*.fpp" -o -name "*.F" -o -name "*.F90" \) -print0 |
38+
while IFS= read -r -d $'\0' file; do
39+
processed=$((processed + 1))
40+
echo -e "[$processed/$total_files] Processing ${file}..."
41+
42+
# Create a temporary file with same permissions as original
43+
TMP_FILE=$(mktemp)
44+
if [ $? -ne 0 ]; then
45+
echo -e "Failed to create temporary file for $file, skipping"
46+
continue
47+
fi
48+
49+
# Copy permissions from original file
50+
chmod --reference="$file" "$TMP_FILE"
51+
52+
# More comprehensive sed command to handle different Fortran comment styles:
53+
# 1. Replace lines that are entirely comments with an empty line:
54+
# - Lines starting with '!' (free form comments)
55+
# - Lines starting with 'c', 'C', '*', 'd', 'D' in column 1 (fixed form comments)
56+
# 2. Remove end-of-line comments (anything after '!' that isn't in a string)
57+
# 3. Preserve strings containing '!' characters
58+
sed -E '
59+
# First handle & continuation style (modern Fortran)
60+
:ampersand_loop
61+
/&[[:space:]]*$/ {
62+
N
63+
s/&[[:space:]]*\n[[:space:]]*(&)?/ /g
64+
tampersand_loop
65+
}
66+
67+
# Handle fixed-form continuation (column 6 indicator)
68+
:fixed_form_loop
69+
/^[[:space:]]{0,5}[^[:space:]!&]/ {
70+
N
71+
s/\n[[:space:]]{5}[^[:space:]]/ /g
72+
tfixed_form_loop
73+
}
74+
75+
# Remove any remaining continuation markers
76+
s/&//g
77+
78+
# Normalize spacing - replace multiple spaces with single space
79+
s/[[:space:]]{2,}/ /g
80+
81+
# Remove spaces around mathematical operators
82+
s/[[:space:]]*\*[[:space:]]*/*/g
83+
s/[[:space:]]*\+[[:space:]]*/+/g
84+
s/[[:space:]]*-[[:space:]]*/-/g
85+
s/[[:space:]]*\/[[:space:]]*/\//g
86+
s/[[:space:]]*\*\*[[:space:]]*/\*\*/g
87+
88+
# Remove spaces in common Fortran constructs (array indexing, function calls)
89+
s/\([[:space:]]*([^,)[:space:]]+)[[:space:]]*,/(\1,/g # First argument
90+
s/,[[:space:]]*([^,)[:space:]]+)[[:space:]]*,/,\1,/g # Middle arguments
91+
s/,[[:space:]]*([^,)[:space:]]+)[[:space:]]*\)/,\1)/g # Last argument
92+
s/\([[:space:]]*([^,)[:space:]]+)[[:space:]]*\)/(\1)/g # Single argument
93+
94+
# Remove spaces around brackets and parentheses
95+
s/\[[[:space:]]*/</g
96+
s/\[[[:space:]]*/>/g
97+
s/\[[[:space:]]*/</g
98+
s/[[:space:]]*\]/]/g
99+
s/\([[:space:]]*/(/g
100+
s/[[:space:]]*\)/)/g
101+
102+
# Remove spaces around comparison operators
103+
s/[[:space:]]*<=[[:space:]]*/</g
104+
s/[[:space:]]*>=[[:space:]]*/>/g
105+
s/[[:space:]]*<[[:space:]]*/</g
106+
s/[[:space:]]*>[[:space:]]*/>/g
107+
s/[[:space:]]*==[[:space:]]*/==/g
108+
109+
# Remove full-line comments
110+
/^\s*!/d
111+
/^[cC*dD]/d
112+
/^[ \t]*[cC*dD]/d
113+
/^[[:space:]]*$/d
114+
115+
# Remove end-of-line comments, preserving quoted strings
116+
s/([^"'\''\\]*("[^"]*")?('\''[^'\'']*'\''?)?[^"'\''\\]*)[!].*$/\1/
117+
' "$file" > "$TMP_FILE"
118+
119+
if cmp -s "$file" "$TMP_FILE"; then
120+
echo -e "No changes needed for $file"
121+
rm "$TMP_FILE"
122+
else
123+
# Overwrite the original file with the processed content
124+
mv "$TMP_FILE" "$file"
125+
echo -e "Successfully processed $file"
126+
fi
127+
done
128+
33129
"${PMD_HOME}/bin/pmd" cpd \
34130
--dir src \
35131
--language fortran \
36-
--minimum-tokens=40
132+
--minimum-tokens=20 \
133+
--no-fail-on-violation \
134+
--no-fail-on-error

src/common/m_helper_basic.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end function f_approx_equal
4747
!> This procedure checks if the point numbers of wp belongs to another array are within tolerance.
4848
!! @param a First number.
4949
!! @param b Array that contains several point numbers.
50-
!! @param tol_input Relative error (default = 1.e-10_wp).
50+
!! @param tol_input Relative error (default = 1e-10_wp).
5151
!! @return Result of the comparison.
5252
logical pure function f_approx_in_array(a, b, tol_input) result(res)
5353
!$acc routine seq
@@ -62,7 +62,7 @@ logical pure function f_approx_in_array(a, b, tol_input) result(res)
6262
if (present(tol_input)) then
6363
tol = tol_input
6464
else
65-
tol = 1.e-10_wp
65+
tol = 1e-10_wp
6666
end if
6767

6868
do i = 1, size(b)

src/pre_process/m_perturbation.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ contains
7373
perturb_alpha = q_prim_vf(E_idx + perturb_sph_fluid)%sf(i, j, k)
7474

7575
! Perturb partial density fields to match perturbed volume fraction fields
76-
! IF ((perturb_alpha >= 25.e-2_wp) .AND. (perturb_alpha <= 75.e-2_wp)) THEN
76+
! IF ((perturb_alpha >= 25e-2_wp) .AND. (perturb_alpha <= 75e-2_wp)) THEN
7777
if ((.not. f_approx_equal(perturb_alpha, 0._wp)) .and. (.not. f_approx_equal(perturb_alpha, 1._wp))) then
7878

7979
! Derive new partial densities

toolchain/mfc/bench.py

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ def bench(targets = None):
8181
# pylint: disable=too-many-branches
8282
def diff():
8383
lhs, rhs = file_load_yaml(ARG("lhs")), file_load_yaml(ARG("rhs"))
84-
8584
cons.print(f"[bold]Comparing Benchmarks: Speedups from [magenta]{os.path.relpath(ARG('lhs'))}[/magenta] to [magenta]{os.path.relpath(ARG('rhs'))}[/magenta] are displayed below. Thus, numbers > 1 represent increases in performance.[/bold]")
85+
8686
if lhs["metadata"] != rhs["metadata"]:
87-
def _lock_to_str(lock):
88-
return ' '.join([f"{k}={v}" for k, v in lock.items()])
87+
_lock_to_str = lambda lock: ' '.join([f"{k}={v}" for k, v in lock.items()])
8988

9089
cons.print(f"""\
9190
[bold yellow]Warning[/bold yellow]: Metadata in lhs and rhs are not equal.
@@ -114,56 +113,39 @@ def _lock_to_str(lock):
114113
table.add_column("[bold]Post Process[/bold]", justify="right")
115114

116115
err = 0
117-
118116
for slug in slugs:
119-
lhs_summary = lhs["cases"][slug]["output_summary"]
120-
rhs_summary = rhs["cases"][slug]["output_summary"]
121-
117+
lhs_summary, rhs_summary = lhs["cases"][slug]["output_summary"], rhs["cases"][slug]["output_summary"]
122118
speedups = ['N/A', 'N/A', 'N/A']
123119

124120
for i, target in enumerate(sorted(DEFAULT_TARGETS, key=lambda t: t.runOrder)):
125121
if (target.name not in lhs_summary) or (target.name not in rhs_summary):
126-
127-
err = 1
128-
129-
if target.name not in lhs_summary:
130-
cons.print(f"{target.name} not present in lhs_summary - Case: {slug}")
131-
132-
if target.name not in rhs_summary:
133-
cons.print(f"{target.name} not present in rhs_summary - Case: {slug}")
134-
135-
continue
122+
cons.print(f"{target.name} not present in lhs_summary or rhs_summary - Case: {slug}")
123+
err = 1; continue
136124

137125
if not math.isfinite(lhs_summary[target.name]["exec"]) or not math.isfinite(rhs_summary[target.name]["exec"]):
138126
err = 1
139127
cons.print(f"lhs_summary or rhs_summary reports non-real exec time for {target.name} - Case: {slug}")
140128

141-
exec_time_speedup = "N/A"
142129
try:
143-
exec_time_speedup = f'{lhs_summary[target.name]["exec"] / rhs_summary[target.name]["exec"]:.2f}'
130+
exec_time_value = lhs_summary[target.name]["exec"] / rhs_summary[target.name]["exec"]
131+
if exec_time_value < 0.9:
132+
cons.print(f"[bold yellow]Warning[/bold yellow]: Exec time speedup for {target.name} is less than 0.9 - Case: {slug}")
133+
speedups[i] = f"Exec: {exec_time_value:.2f}"
134+
if target == SIMULATION:
135+
if not math.isfinite(lhs_summary[target.name]["grind"]) or not math.isfinite(rhs_summary[target.name]["grind"]):
136+
err = 1
137+
cons.print(f"lhs_summary or rhs_summary reports non-real grind time for {target.name} - Case: {slug}")
138+
139+
grind_time_value = lhs_summary[target.name]["grind"] / rhs_summary[target.name]["grind"]
140+
speedups[i] += f" & Grind: {grind_time_value:.2f}"
141+
if grind_time_value <0.95:
142+
raise MFCException(f"Benchmarking failed since grind time speedup for {target.name} below acceptable threshold (<0.98) - Case: {slug}")
144143
except Exception as _:
145144
err = 1
146-
cons.print(f"lhs_summary or rhs_summary reports non-real exec time for {target.name} - Case: {slug}")
147-
148-
speedups[i] = f"Exec: {exec_time_speedup}"
149-
150-
if target == SIMULATION:
151-
grind_time_speedup = "N/A"
152-
if not math.isfinite(lhs_summary[target.name]["grind"]) or not math.isfinite(rhs_summary[target.name]["grind"]):
153-
err = 1
154-
cons.print(f"lhs_summary or rhs_summary reports non-real grind time for {target.name} - Case: {slug}")
155-
156-
try:
157-
grind_time_speedup = f'{lhs_summary[target.name]["grind"] / rhs_summary[target.name]["grind"]:.2f}'
158-
except Exception as _:
159-
err = 1
160-
cons.print(f"lhs_summary or rhs_summary reports non-real grind time for {target.name} - Case: {slug}")
161-
162-
speedups[i] += f" & Grind: {grind_time_speedup}"
145+
cons.print(f"lhs_summary or rhs_summary reports non-real grind time for {target.name} - Case: {slug}")
163146

164147
table.add_row(f"[magenta]{slug}[/magenta]", *speedups)
165148

166149
cons.raw.print(table)
167-
168-
if err != 0:
150+
if err:
169151
raise MFCException("Benchmarking failed")

0 commit comments

Comments
 (0)