Skip to content

Commit 4fc3642

Browse files
authored
Merge branch 'master' into mixlayer
2 parents a29daed + 59d0c09 commit 4fc3642

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+619
-527
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/lint-source.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
run: |
4343
! grep -iR -e '\.\.\.' -e '\-\-\-' -e '===' ./src/*
4444
45+
- name: Looking for false integers
46+
run: |
47+
! grep -onRP '(?<![0-9.eE\-])\b[0-9]*_wp\b' src/
48+
4549
- name: Looking for junk comments in examples
4650
run: |
4751
! grep -R '# ===' ./benchmarks **/*.py

.github/workflows/pmd.yml

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

src/common/m_checker_common.fpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ contains
322322
@:PROHIBIT(surface_tension .and. sigma < 0._wp, &
323323
"sigma must be greater than or equal to zero")
324324

325-
@:PROHIBIT(surface_tension .and. sigma == dflt_real, &
325+
@:PROHIBIT(surface_tension .and. f_approx_equal(sigma, dflt_real), &
326326
"sigma must be set if surface_tension is enabled")
327327

328328
@:PROHIBIT(.not. f_is_default(sigma) .and. .not. surface_tension, &
@@ -347,9 +347,12 @@ contains
347347
!! Called by s_check_inputs_common for all three stages
348348
impure subroutine s_check_inputs_moving_bc
349349
#:for X, VB2, VB3 in [('x', 'vb2', 'vb3'), ('y', 'vb3', 'vb1'), ('z', 'vb1', 'vb2')]
350-
if (any((/bc_${X}$%vb1, bc_${X}$%vb2, bc_${X}$%vb3/) /= 0._wp)) then
350+
if (.not. (f_approx_equal(bc_${X}$%vb1, 0._wp) .and. &
351+
f_approx_equal(bc_${X}$%vb2, 0._wp) .and. &
352+
f_approx_equal(bc_${X}$%vb3, 0._wp))) then
351353
if (bc_${X}$%beg == BC_SLIP_WALL) then
352-
if (any((/bc_${X}$%${VB2}$, bc_${X}$%${VB3}$/) /= 0._wp)) then
354+
if (.not. (f_approx_equal(bc_${X}$%${VB2}$, 0._wp) .and. &
355+
f_approx_equal(bc_${X}$%${VB3}$, 0._wp))) then
353356
call s_mpi_abort("bc_${X}$%beg must be -15 if "// &
354357
"bc_${X}$%${VB2}$ or bc_${X}$%${VB3}$ "// &
355358
"is set. Exiting.", CASE_FILE_ERROR_CODE)
@@ -362,9 +365,12 @@ contains
362365
#:endfor
363366

364367
#:for X, VE2, VE3 in [('x', 've2', 've3'), ('y', 've3', 've1'), ('z', 've1', 've2')]
365-
if (any((/bc_${X}$%ve1, bc_${X}$%ve2, bc_${X}$%ve3/) /= 0._wp)) then
368+
if (.not. (f_approx_equal(bc_${X}$%ve1, 0._wp) .and. &
369+
f_approx_equal(bc_${X}$%ve2, 0._wp) .and. &
370+
f_approx_equal(bc_${X}$%ve3, 0._wp))) then
366371
if (bc_${X}$%end == BC_SLIP_WALL) then
367-
if (any((/bc_${X}$%${VE2}$, bc_${X}$%${VE3}$/) /= 0._wp)) then
372+
if (.not. (f_approx_equal(bc_${X}$%${VE2}$, 0._wp) .and. &
373+
f_approx_equal(bc_${X}$%${VE3}$, 0._wp))) then
368374
call s_mpi_abort("bc_${X}$%end must be -15 if "// &
369375
"bc_${X}$%${VE2}$ or bc_${X}$%${VE3}$ "// &
370376
"is set. Exiting.", CASE_FILE_ERROR_CODE)

src/common/m_constants.fpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ module m_constants
88

99
character, parameter :: dflt_char = ' ' !< Default string value
1010

11-
real(wp), parameter :: dflt_real = -1e6_wp !< Default real value
12-
real(wp), parameter :: sgm_eps = 1e-16_wp !< Segmentation tolerance
13-
real(wp), parameter :: small_alf = 1e-11_wp !< Small alf tolerance
11+
real(wp), parameter :: dflt_real = -1.e6_wp !< Default real value
12+
real(wp), parameter :: sgm_eps = 1.e-16_wp !< Segmentation tolerance
13+
real(wp), parameter :: small_alf = 1.e-11_wp !< Small alf tolerance
1414
real(wp), parameter :: pi = 3.141592653589793_wp !< Pi
1515
real(wp), parameter :: verysmall = 1.e-12_wp !< Very small number
1616

@@ -26,7 +26,7 @@ module m_constants
2626
integer, parameter :: pathlen_max = 400
2727
integer, parameter :: nnode = 4 !< Number of QBMM nodes
2828
integer, parameter :: gp_layers = 3 !< Number of ghost point layers for IBM
29-
real(wp), parameter :: capillary_cutoff = 1e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
29+
real(wp), parameter :: capillary_cutoff = 1.e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
3030
real(wp), parameter :: acoustic_spatial_support_width = 2.5_wp !< Spatial support width of acoustic source, used in s_source_spatial
3131
real(wp), parameter :: dflt_vcfl_dt = 100._wp !< value of vcfl_dt when viscosity is off for computing adaptive timestep size
3232
real(wp), parameter :: broadband_spectral_level_constant = 20._wp !< The constant to scale the spectral level at the lower frequency bound
@@ -41,25 +41,25 @@ module m_constants
4141
integer, parameter :: Ifactor_bary_3D = 20 !< Multiple factor of the ratio (triangle area to cell face area) for interpolation on triangle facets for 3D models
4242
integer, parameter :: num_ray = 20 !< Default number of rays traced per cell
4343
real(wp), parameter :: ray_tracing_threshold = 0.9_wp !< Threshold above which the cell is marked as the model patch
44-
real(wp), parameter :: threshold_vector_zero = 1e-10 !< Threshold to treat the component of a vector to be zero
45-
real(wp), parameter :: threshold_edge_zero = 1e-10 !< Threshold to treat two edges to be overlapped
46-
real(wp), parameter :: threshold_bary = 1e-1 !< Threshold to interpolate a barycentric facet
47-
real(wp), parameter :: initial_distance_buffer = 1e12_wp !< Initialized levelset distance for the shortest path pair algorithm
44+
real(wp), parameter :: threshold_vector_zero = 1.e-10_wp !< Threshold to treat the component of a vector to be zero
45+
real(wp), parameter :: threshold_edge_zero = 1.e-10_wp !< Threshold to treat two edges to be overlapped
46+
real(wp), parameter :: threshold_bary = 1.e-1_wp !< Threshold to interpolate a barycentric facet
47+
real(wp), parameter :: initial_distance_buffer = 1.e12_wp !< Initialized levelset distance for the shortest path pair algorithm
4848

4949
! Lagrange bubbles constants
5050
integer, parameter :: mapCells = 3 !< Number of cells around the bubble where the smoothening function will have effect
5151
real(wp), parameter :: R_uni = 8314._wp ! Universal gas constant - J/kmol/K
5252

5353
! Strang Splitting constants
54-
real(wp), parameter :: dflt_adap_dt_tol = 1e-4_wp !< Default tolerance for adaptive step size
54+
real(wp), parameter :: dflt_adap_dt_tol = 1.e-4_wp !< Default tolerance for adaptive step size
5555
integer, parameter :: adap_dt_max_iters = 100 !< Maximum number of iterations
5656
! Constants of the algorithm described by Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary Differential Equations I, Chapter II.4
5757
! to choose the initial time step size for the adaptive time stepping routine
58-
real(wp), parameter :: threshold_first_guess = 1e-5_wp
59-
real(wp), parameter :: threshold_second_guess = 1e-15_wp
60-
real(wp), parameter :: scale_first_guess = 1e-3_wp
61-
real(wp), parameter :: scale_guess = 1e-2_wp
62-
real(wp), parameter :: small_guess = 1e-6_wp
58+
real(wp), parameter :: threshold_first_guess = 1.e-5_wp
59+
real(wp), parameter :: threshold_second_guess = 1.e-15_wp
60+
real(wp), parameter :: scale_first_guess = 1.e-3_wp
61+
real(wp), parameter :: scale_guess = 1.e-2_wp
62+
real(wp), parameter :: small_guess = 1.e-6_wp
6363

6464
! Relativity
6565
integer, parameter :: relativity_cons_to_prim_max_iter = 100

src/common/m_eigen_solver.f90

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module m_eigen_solver
1010

1111
use m_precision_select
1212

13+
use m_helper_basic !< Functions to compare floating point numbers
14+
1315
implicit none
1416

1517
private;
@@ -124,7 +126,7 @@ pure subroutine cbal(nm, nl, ar, ai, low, igh, scale)
124126

125127
do 110 i = 1, l
126128
if (i == j) go to 110
127-
if (ar(j, i) /= 0.0_wp .or. ai(j, i) /= 0.0_wp) go to 120
129+
if (.not. f_approx_equal(ar(j, i), 0.0_wp) .or. .not. f_approx_equal(ai(j, i), 0.0_wp)) go to 120
128130
110 end do
129131

130132
ml = l
@@ -140,7 +142,7 @@ pure subroutine cbal(nm, nl, ar, ai, low, igh, scale)
140142

141143
do 150 i = k, l
142144
if (i == j) go to 150
143-
if (ar(i, j) /= 0.0_wp .or. ai(i, j) /= 0.0_wp) go to 170
145+
if (.not. f_approx_equal(ar(i, j), 0.0_wp) .or. .not. f_approx_equal(ai(i, j), 0.0_wp)) go to 170
144146
150 end do
145147

146148
ml = k
@@ -164,7 +166,7 @@ pure subroutine cbal(nm, nl, ar, ai, low, igh, scale)
164166
r = r + abs(ar(i, j)) + abs(ai(i, j))
165167
200 end do
166168
! guard against zero c or r due to underflow
167-
if (c == 0.0_wp .or. r == 0.0_wp) go to 270
169+
if (f_approx_equal(c, 0.0_wp) .or. f_approx_equal(r, 0.0_wp)) go to 270
168170
g = r/radix
169171
f = 1.0_wp
170172
s = c + r
@@ -242,7 +244,7 @@ pure subroutine corth(nm, nl, low, igh, ar, ai, ortr, orti)
242244
do 90 i = ml, igh
243245
scale = scale + abs(ar(i, ml - 1)) + abs(ai(i, ml - 1))
244246
90 end do
245-
if (scale == 0._wp) go to 180
247+
if (f_approx_equal(scale, 0._wp)) go to 180
246248
mp = ml + igh
247249
! for i=igh step -1 until ml do
248250
do 100 ii = ml, igh
@@ -254,7 +256,7 @@ pure subroutine corth(nm, nl, low, igh, ar, ai, ortr, orti)
254256

255257
g = sqrt(h)
256258
call pythag(ortr(ml), orti(ml), f)
257-
if (f == 0._wp) go to 103
259+
if (f_approx_equal(f, 0._wp)) go to 103
258260
h = h + f*g
259261
g = g/f
260262
ortr(ml) = (1.0_wp + g)*ortr(ml)
@@ -374,8 +376,8 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
374376
! for i=igh-1 step -1 until low+1 do
375377
105 do 140 ii = 1, iend
376378
i = igh - ii
377-
if (abs(ortr(i)) == 0._wp .and. abs(orti(i)) == 0._wp) go to 140
378-
if (abs(hr(i, i - 1)) == 0._wp .and. abs(hi(i, i - 1)) == 0._wp) go to 140
379+
if (f_approx_equal(abs(ortr(i)), 0._wp) .and. f_approx_equal(abs(orti(i)), 0._wp)) go to 140
380+
if (f_approx_equal(abs(hr(i, i - 1)), 0._wp) .and. f_approx_equal(abs(hi(i, i - 1)), 0._wp)) go to 140
379381
! norm below is negative of h formed in corth
380382
norm = hr(i, i - 1)*ortr(i) + hi(i, i - 1)*orti(i)
381383
ip1 = i + 1
@@ -410,7 +412,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
410412

411413
do 170 i = l, igh
412414
ll = min0(i + 1, igh)
413-
if (abs(hi(i, i - 1)) == 0._wp) go to 170
415+
if (f_approx_equal(abs(hi(i, i - 1)), 0._wp)) go to 170
414416
call pythag(hr(i, i - 1), hi(i, i - 1), norm)
415417
yr = hr(i, i - 1)/norm
416418
yi = hi(i, i - 1)/norm
@@ -458,7 +460,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
458460
tst1 = abs(hr(l - 1, l - 1)) + abs(hi(l - 1, l - 1)) &
459461
+ abs(hr(l, l)) + abs(hi(l, l))
460462
tst2 = tst1 + abs(hr(l, l - 1))
461-
if (tst2 == tst1) go to 300
463+
if (f_approx_equal(tst2, tst1)) go to 300
462464
260 end do
463465
! form shift
464466
300 if (l == en) go to 660
@@ -468,7 +470,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
468470
si = hi(en, en)
469471
xr = hr(enm1, en)*hr(en, enm1)
470472
xi = hi(enm1, en)*hr(en, enm1)
471-
if (xr == 0.0_wp .and. xi == 0.0_wp) go to 340
473+
if (f_approx_equal(xr, 0.0_wp) .and. f_approx_equal(xi, 0.0_wp)) go to 340
472474
yr = (hr(enm1, enm1) - sr)/2.0_wp
473475
yi = (hi(enm1, enm1) - si)/2.0_wp
474476
call csroot(yr**2 - yi**2 + xr, 2.0_wp*yr*yi + xi, zzr, zzi)
@@ -522,7 +524,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
522524
500 end do
523525

524526
si = hi(en, en)
525-
if (abs(si) == 0._wp) go to 540
527+
if (f_approx_equal(abs(si), 0._wp)) go to 540
526528
call pythag(hr(en, en), si, norm)
527529
sr = hr(en, en)/norm
528530
si = si/norm
@@ -567,7 +569,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
567569
590 end do
568570
600 end do
569571

570-
if (abs(si) == 0._wp) go to 240
572+
if (f_approx_equal(abs(si), 0._wp)) go to 240
571573

572574
do 630 i = 1, en
573575
yr = hr(i, en)
@@ -602,7 +604,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
602604
end do
603605
end do
604606

605-
if (nl == 1 .or. norm == 0._wp) go to 1001
607+
if (nl == 1 .or. f_approx_equal(norm, 0._wp)) go to 1001
606608
! for en=nl step -1 until 2 do
607609
do 800 nn = 2, nl
608610
en = nl + 2 - nn
@@ -625,7 +627,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
625627

626628
yr = xr - wr(i)
627629
yi = xi - wi(i)
628-
if (yr /= 0.0_wp .or. yi /= 0.0_wp) go to 765
630+
if (.not. f_approx_equal(yr, 0.0_wp) .or. .not. f_approx_equal(yi, 0.0_wp)) go to 765
629631
tst1 = norm
630632
yr = tst1
631633
760 yr = 0.01_wp*yr
@@ -635,7 +637,7 @@ pure subroutine comqr2(nm, nl, low, igh, ortr, orti, hr, hi, wr, wi, zr, zi, ier
635637
call cdiv(zzr, zzi, yr, yi, hr(i, en), hi(i, en))
636638
! overflow control
637639
tr = abs(hr(i, en)) + abs(hi(i, en))
638-
if (tr == 0.0_wp) go to 780
640+
if (f_approx_equal(tr, 0.0_wp)) go to 780
639641
tst1 = tr
640642
tst2 = tst1 + 1.0_wp/tst1
641643
if (tst2 > tst1) go to 780
@@ -796,11 +798,11 @@ pure elemental subroutine pythag(a, b, c)
796798

797799
real(wp) :: p, r, s, t, u
798800
p = max(abs(a), abs(b))
799-
if (p == 0.0_wp) go to 20
801+
if (f_approx_equal(p, 0.0_wp)) go to 20
800802
r = (min(abs(a), abs(b))/p)**2
801803
10 continue
802804
t = 4.0_wp + r
803-
if (t == 4.0_wp) go to 20
805+
if (f_approx_equal(t, 4.0_wp)) go to 20
804806
s = r/t
805807
u = 1.0_wp + 2.0_wp*s
806808
p = u*p

0 commit comments

Comments
 (0)