Skip to content

Commit 50d5aea

Browse files
authored
Merge branch 'master' into rdma_mpi
2 parents 57b600b + a34f0ca commit 50d5aea

36 files changed

+606
-290
lines changed

.github/workflows/bench.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: 'Benchmark'
22

3-
on: pull_request
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
workflow_dispatch:
47

58
jobs:
69
file-changes:
@@ -20,11 +23,12 @@ jobs:
2023

2124
self:
2225
name: Georgia Tech | Phoenix (NVHPC)
23-
if: github.repository == 'MFlowCode/MFC' && needs.file-changes.outputs.checkall == 'true'
26+
if: github.repository == 'MFlowCode/MFC' && needs.file-changes.outputs.checkall == 'true' && ${{ github.event.review.state == 'approved' }}
2427
needs: file-changes
2528
strategy:
2629
matrix:
2730
device: ['cpu', 'gpu']
31+
fail-fast: false
2832
runs-on:
2933
group: phoenix
3034
labels: gt
@@ -56,6 +60,12 @@ jobs:
5660
(cd pr && . ./mfc.sh load -c p -m g)
5761
(cd pr && ./mfc.sh bench_diff ../master/bench-${{ matrix.device }}.yaml ../pr/bench-${{ matrix.device }}.yaml)
5862
63+
- name: Print Logs
64+
if: always()
65+
run: |
66+
cat pr/bench-${{ matrix.device }}.* 2>/dev/null || true
67+
cat master/bench-${{ matrix.device }}.* 2>/dev/null || true
68+
5969
- name: Archive Logs
6070
uses: actions/upload-artifact@v4
6171
if: always()

.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

docs/documentation/case.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ and use `patch_icpp(i)%%geometry = 7` and `patch_icpp(i)%%hcid = 200` in the inp
236236
Additional variables can be declared in `Hardcoded1[2,3]DVariables` and used in `hardcoded1[2,3]D`.
237237
As a convention, any hard coded patches that are part of the MFC master branch should be identified as 1[2,3]xx where the first digit indicates the number of dimensions.
238238

239+
The code provides three pre-built patches for dimensional extrusion of initial conditions:
240+
241+
- `case(170)`: Load 1D profile from data files
242+
- `case(270)`: Extrude 1D data to 2D domain
243+
- `case(370)`: Extrude 2D data to 3D domain
244+
245+
Setup: Only requires specifying `init_dir` and filename pattern via `zeros_default`. Grid dimensions are automatically detected from the data files.
246+
Implementation: All variables and file handling are managed in `src/pre_process/include/ExtrusionHardcodedIC.fpp` with no manual grid configuration needed.
247+
Usage: Ideal for initializing simulations from lower-dimensional solutions, enabling users to add perturbations or modifications to the base extruded fields for flow instability studies.
248+
239249
#### Parameter Descriptions
240250

241251
- `num_patches` defines the total number of patches defined in the domain.

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_helper_basic.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module m_helper_basic
2121
!> This procedure checks if two floating point numbers of wp are within tolerance.
2222
!! @param a First number.
2323
!! @param b Second number.
24-
!! @param tol_input Relative error (default = 1e-10_wp).
24+
!! @param tol_input Relative error (default = 1.e-10_wp).
2525
!! @return Result of the comparison.
2626
logical pure elemental function f_approx_equal(a, b, tol_input) result(res)
2727
!$acc routine seq
@@ -32,7 +32,7 @@ logical pure elemental function f_approx_equal(a, b, tol_input) result(res)
3232
if (present(tol_input)) then
3333
tol = tol_input
3434
else
35-
tol = 1e-10_wp
35+
tol = 1.e-10_wp
3636
end if
3737

3838
if (a == b) then

src/common/m_phase_change.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ contains
343343
344344
! Newton Solver for the pT-equilibrium
345345
ns = 0
346-
! change this relative error metric. 1e4_wp is just arbitrary
347-
do while ((abs(pS - pO) > palpha_eps) .and. (abs((pS - pO)/pO) > palpha_eps/1e4_wp) .or. (ns == 0))
346+
! change this relative error metric. 1.e4_wp is just arbitrary
347+
do while ((abs(pS - pO) > palpha_eps) .and. (abs((pS - pO)/pO) > palpha_eps/1.e4_wp) .or. (ns == 0))
348348
349349
! increasing counter
350350
ns = ns + 1
@@ -438,7 +438,7 @@ contains
438438
R2D(1) = 0.0_wp; R2D(2) = 0.0_wp
439439
DeltamP(1) = 0.0_wp; DeltamP(2) = 0.0_wp
440440
do while (((sqrt(R2D(1)**2 + R2D(2)**2) > ptgalpha_eps) &
441-
.and. ((sqrt(R2D(1)**2 + R2D(2)**2)/rhoe) > (ptgalpha_eps/1e6_wp))) &
441+
.and. ((sqrt(R2D(1)**2 + R2D(2)**2)/rhoe) > (ptgalpha_eps/1.e6_wp))) &
442442
.or. (ns == 0))
443443

444444
! Updating counter for the iterative procedure

src/common/m_variables_conversion.fpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ contains
280280
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
281281
end do
282282

283-
alpha_K = alpha_K/max(sum(alpha_K), 1e-16_wp)
283+
alpha_K = alpha_K/max(sum(alpha_K), 1.e-16_wp)
284284

285285
end if
286286

@@ -405,7 +405,7 @@ contains
405405
alpha_K(i) = min(max(0._wp, alpha_K(i)), 1._wp)
406406
end do
407407

408-
alpha_K = alpha_K/max(sum(alpha_K), 1e-16_wp)
408+
alpha_K = alpha_K/max(sum(alpha_K), 1.e-16_wp)
409409

410410
end if
411411

@@ -960,7 +960,7 @@ contains
960960

961961
dW = -f/df_dW
962962
W = W + dW
963-
if (abs(dW) < 1e-12*W) exit
963+
if (abs(dW) < 1.e-12_wp*W) exit
964964
end do
965965

966966
! Recalculate pressure using converged W
@@ -1014,7 +1014,7 @@ contains
10141014
if (model_eqns /= 4) then
10151015
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l) &
10161016
/rho_K
1017-
dyn_pres_K = dyn_pres_K + 5e-1_wp*qK_cons_vf(i)%sf(j, k, l) &
1017+
dyn_pres_K = dyn_pres_K + 5.e-1_wp*qK_cons_vf(i)%sf(j, k, l) &
10181018
*qK_prim_vf(i)%sf(j, k, l)
10191019
else
10201020
qK_prim_vf(i)%sf(j, k, l) = qK_cons_vf(i)%sf(j, k, l) &
@@ -1520,11 +1520,11 @@ contains
15201520
R_gas = gas_constant/mix_mol_weight
15211521
T_K = pres_K/rho_K/R_gas
15221522
call get_mixture_energy_mass(T_K, Y_K, E_K)
1523-
E_K = rho_K*E_K + 5e-1_wp*rho_K*vel_K_sum
1523+
E_K = rho_K*E_K + 5.e-1_wp*rho_K*vel_K_sum
15241524
else
15251525
! Computing the energy from the pressure
15261526
E_K = gamma_K*pres_K + pi_inf_K &
1527-
+ 5e-1_wp*rho_K*vel_K_sum + qv_K
1527+
+ 5.e-1_wp*rho_K*vel_K_sum + qv_K
15281528
end if
15291529

15301530
! mass flux, this should be \alpha_i \rho_i u_i
@@ -1659,7 +1659,7 @@ contains
16591659
(rho*(1._wp - adv(num_fluids)))
16601660
end if
16611661
else
1662-
c = ((H - 5e-1*vel_sum)/gamma)
1662+
c = ((H - 5.e-1*vel_sum)/gamma)
16631663
end if
16641664

16651665
if (mixture_err .and. c < 0._wp) then

src/post_process/m_data_output.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ contains
13291329
rho = rho + adv(l)*q_prim_vf(l)%sf(i, j, k)
13301330
end do
13311331
1332-
H = ((gamma + 1_wp)*pres + pi_inf)/rho
1332+
H = ((gamma + 1._wp)*pres + pi_inf)/rho
13331333
13341334
call s_compute_speed_of_sound(pres, rho, &
13351335
gamma, pi_inf, &

src/post_process/m_derived_variables.fpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ contains
212212
end if
213213

214214
if (mixture_err .and. q_sf(i, j, k) < 0._wp) then
215-
q_sf(i, j, k) = 1e-16_wp
215+
q_sf(i, j, k) = 1.e-16_wp
216216
else
217217
q_sf(i, j, k) = sqrt(q_sf(i, j, k))
218218
end if
@@ -285,8 +285,8 @@ contains
285285
end if
286286
end if
287287

288-
if (abs(top) < 1e-8_wp) top = 0._wp
289-
if (abs(bottom) < 1e-8_wp) bottom = 0._wp
288+
if (abs(top) < 1.e-8_wp) top = 0._wp
289+
if (abs(bottom) < 1.e-8_wp) bottom = 0._wp
290290

291291
if (f_approx_equal(top, bottom)) then
292292
slope = 1._wp
@@ -295,20 +295,20 @@ contains
295295
! (bottom == 0._wp .AND. top /= 0._wp)) THEN
296296
! slope = 0._wp
297297
else
298-
slope = (top*bottom)/(bottom**2._wp + 1e-16_wp)
298+
slope = (top*bottom)/(bottom**2._wp + 1.e-16_wp)
299299
end if
300300

301301
! Flux limiter function
302302
if (flux_lim == 1) then ! MINMOD (MM)
303303
q_sf(j, k, l) = max(0._wp, min(1._wp, slope))
304304
elseif (flux_lim == 2) then ! MUSCL (MC)
305-
q_sf(j, k, l) = max(0._wp, min(2._wp*slope, 5e-1_wp*(1._wp + slope), 2._wp))
305+
q_sf(j, k, l) = max(0._wp, min(2._wp*slope, 5.e-1_wp*(1._wp + slope), 2._wp))
306306
elseif (flux_lim == 3) then ! OSPRE (OP)
307-
q_sf(j, k, l) = (15e-1_wp*(slope**2._wp + slope))/(slope**2._wp + slope + 1._wp)
307+
q_sf(j, k, l) = (15.e-1_wp*(slope**2._wp + slope))/(slope**2._wp + slope + 1._wp)
308308
elseif (flux_lim == 4) then ! SUPERBEE (SB)
309309
q_sf(j, k, l) = max(0._wp, min(1._wp, 2._wp*slope), min(slope, 2._wp))
310310
elseif (flux_lim == 5) then ! SWEBY (SW) (beta = 1.5)
311-
q_sf(j, k, l) = max(0._wp, min(15e-1_wp*slope, 1._wp), min(slope, 15e-1_wp))
311+
q_sf(j, k, l) = max(0._wp, min(15.e-1_wp*slope, 1._wp), min(slope, 15.e-1_wp))
312312
elseif (flux_lim == 6) then ! VAN ALBADA (VA)
313313
q_sf(j, k, l) = (slope**2._wp + slope)/(slope**2._wp + 1._wp)
314314
elseif (flux_lim == 7) then ! VAN LEER (VL)

0 commit comments

Comments
 (0)