Skip to content

Commit 77fed24

Browse files
committed
Merge branch 'singlePrecisionFix' of github.com:wilfonba/MFC-Wilfong into singlePrecisionFix
2 parents 8ef9fda + 19a2ccf commit 77fed24

File tree

6 files changed

+339
-282
lines changed

6 files changed

+339
-282
lines changed

mfc.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,6 @@ elif [ "$1" == "format" ]; then
230230
ok "MFC has been fprettify'ied."
231231

232232
exit 0
233-
elif [ "$1" == "cloc" ]; then
234-
if ! command -v cloc > /dev/null 2>&1; then
235-
error "cloc (github.com/AlDanial/cloc) is not installed."
236-
237-
exit 1
238-
fi
239-
240-
cloc . --exclude-dir=build,tests,examples,.vscode,.github \
241-
--fullpath --not-match-d=src/*/*/autogen
242-
243-
exit $?
244233
elif [ "$1" == "docker" ]; then
245234
shift;
246235

src/pre_process/m_checker.f90

Lines changed: 231 additions & 226 deletions
Large diffs are not rendered by default.

src/simulation/m_checker.fpp

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -72,55 +72,70 @@ contains
7272
! Simulation Algorithm Parameters ==================================
7373
if (all(model_eqns /= (/1, 2, 3, 4/))) then
7474
call s_mpi_abort('Unsupported value of model_eqns. Exiting ...')
75-
elseif (model_eqns == 2 .and. bubbles .and. bubble_model == 1) then
76-
call s_mpi_abort('The 5-equation bubbly flow model requires bubble_model = 2 (Keller--Miksis)')
77-
elseif (bubbles .and. nb < 1) then
78-
call s_mpi_abort('The Ensemble-Averaged Bubble Model requires nb >= 1')
79-
elseif (bubbles .and. bubble_model == 3 .and. (polytropic .neqv. .true.)) then
80-
call s_mpi_abort('RP bubbles require polytropic compression')
81-
elseif (cyl_coord .and. bubbles) then
82-
call s_mpi_abort('Bubble models untested in cylindrical coordinates')
83-
elseif (model_eqns == 3 .and. bubbles) then
84-
call s_mpi_abort('Bubble models untested with 6-equation model')
85-
elseif (model_eqns == 1 .and. bubbles) then
86-
call s_mpi_abort('Bubble models untested with pi-gamma model')
87-
elseif (model_eqns == 4 .and. num_fluids /= 1) then
75+
end if
76+
77+
if (bubbles) then
78+
if (model_eqns == 2 .and. bubble_model == 1) then
79+
call s_mpi_abort('The 5-equation bubbly flow model requires bubble_model = 2 (Keller--Miksis)')
80+
elseif (nb < 1) then
81+
call s_mpi_abort('The Ensemble-Averaged Bubble Model requires nb >= 1')
82+
elseif (bubble_model == 3 .and. (polytropic .neqv. .true.)) then
83+
call s_mpi_abort('RP bubbles require polytropic compression')
84+
elseif (cyl_coord) then
85+
call s_mpi_abort('Bubble models untested in cylindrical coordinates')
86+
elseif (model_eqns == 3) then
87+
call s_mpi_abort('Bubble models untested with 6-equation model')
88+
elseif (model_eqns == 1) then
89+
call s_mpi_abort('Bubble models untested with pi-gamma model')
90+
!TODO: Comment this out when testing riemann with hll
91+
elseif (riemann_solver /= 2) then
92+
call s_mpi_abort('Bubble modeling requires riemann_solver = 2')
93+
elseif (avg_state == 1) then
94+
call s_mpi_abort('Unsupported combination of values of '// &
95+
'bubbles and Roe average (please use avg_state = 2). '// &
96+
'Exiting ...')
97+
end if
98+
end if
99+
100+
if (model_eqns == 4 .and. num_fluids /= 1) then
88101
call s_mpi_abort('The 4-equation model implementation is not a multi-component and requires num_fluids = 1')
89-
elseif (bubbles .and. riemann_solver /= 2) then
90-
call s_mpi_abort('Bubble modeling requires riemann_solver = 2')
91-
elseif ((bubbles .neqv. .true.) .and. polydisperse) then
102+
end if
103+
104+
if ((bubbles .neqv. .true.) .and. polydisperse) then
92105
call s_mpi_abort('Polydisperse bubble modeling requires the bubble switch to be activated')
93106
elseif (polydisperse .and. (poly_sigma == dflt_real)) then
94107
call s_mpi_abort('Polydisperse bubble modeling requires poly_sigma > 0')
95108
elseif (qbmm .and. (bubbles .neqv. .true.)) then
96109
call s_mpi_abort('QBMM requires bubbles')
97110
elseif (qbmm .and. (nnode /= 4)) then
98111
call s_mpi_abort('nnode not supported')
99-
elseif (model_eqns == 3 .and. riemann_solver /= 2) then
100-
call s_mpi_abort('Unsupported combination of values of '// &
101-
'model_eqns (6-eq) and riemann_solver (please use riemann_solver = 2). '// &
102-
'Exiting ...')
103-
elseif (model_eqns == 3 .and. alt_soundspeed) then
104-
call s_mpi_abort('Unsupported combination of values of '// &
105-
'model_eqns (6-eq) and alt_soundspeed. '// &
106-
'Exiting ...')
107-
elseif (model_eqns == 3 .and. avg_state == 1) then
108-
call s_mpi_abort('Unsupported combination of values of '// &
109-
'model_eqns (6-eq) and Roe average (please use avg_state = 2). '// &
110-
'Exiting ...')
111-
elseif (bubbles .and. avg_state == 1) then
112-
call s_mpi_abort('Unsupported combination of values of '// &
113-
'bubbles and Roe average (please use avg_state = 2). '// &
114-
'Exiting ...')
115-
elseif (model_eqns == 3 .and. wave_speeds == 2) then
116-
call s_mpi_abort('Unsupported combination of values of '// &
117-
'model_eqns (6-eq) and wave_speeds (please use wave_speeds = 1). '// &
118-
'Exiting ...')
119-
elseif (model_eqns == 3 .and. (cyl_coord .and. p /= 0)) then
120-
call s_mpi_abort('Unsupported combination of values of '// &
121-
'model_eqns (6-eq) and cylindrical coordinates. '// &
122-
'Exiting ...')
123-
elseif (num_fluids /= dflt_int &
112+
end if
113+
114+
if (model_eqns ==3 ) then
115+
if (riemann_solver /= 2) then
116+
call s_mpi_abort('Unsupported combination of values of '// &
117+
'model_eqns (6-eq) and riemann_solver (please use riemann_solver = 2). '// &
118+
'Exiting ...')
119+
elseif (alt_soundspeed) then
120+
call s_mpi_abort('Unsupported combination of values of '// &
121+
'model_eqns (6-eq) and alt_soundspeed. '// &
122+
'Exiting ...')
123+
elseif (avg_state == 1) then
124+
call s_mpi_abort('Unsupported combination of values of '// &
125+
'model_eqns (6-eq) and Roe average (please use avg_state = 2). '// &
126+
'Exiting ...')
127+
elseif (wave_speeds == 2) then
128+
call s_mpi_abort('Unsupported combination of values of '// &
129+
'model_eqns (6-eq) and wave_speeds (please use wave_speeds = 1). '// &
130+
'Exiting ...')
131+
elseif (cyl_coord .and. p /= 0) then
132+
call s_mpi_abort('Unsupported combination of values of '// &
133+
'model_eqns (6-eq) and cylindrical coordinates. '// &
134+
'Exiting ...')
135+
end if
136+
end if
137+
138+
if (num_fluids /= dflt_int &
124139
.and. &
125140
(num_fluids < 1 .or. num_fluids > num_fluids)) then
126141
call s_mpi_abort('Unsupported value of num_fluids. Exiting ...')

toolchain/mfc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import signal, getpass, platform, itertools, dataclasses
44

5-
from mfc import args, lock, build, bench, state
5+
from mfc import args, lock, build, bench, state, count
66
from mfc.state import ARG
77
from mfc.run import run
88
from mfc.test import test
@@ -16,7 +16,7 @@ def __print_greeting():
1616

1717
host_line = f"{getpass.getuser()}@{platform.node()} [{platform.system()}]"
1818
targets_line = f"[bold]--targets {format_list_to_string(ARG('targets'), 'magenta', 'None')}[/bold]"
19-
help_line = "$ ./mfc.sh \[build, run, test, clean] --help"
19+
help_line = "$ ./mfc.sh \[build, run, test, clean, count] --help"
2020

2121
MFC_SIDEBAR_LINES = [
2222
"",
@@ -49,7 +49,7 @@ def __checks():
4949

5050
def __run():
5151
{"test": test.test, "run": run.run, "build": build.build,
52-
"clean": build.clean, "bench": bench.bench
52+
"clean": build.clean, "bench": bench.bench, "count": count.count
5353
}[ARG("command")]()
5454

5555

toolchain/mfc/args.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def parse(config):
2626
build = parsers.add_parser(name="build", help="Build MFC and its dependencies.", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
2727
clean = parsers.add_parser(name="clean", help="Clean build artifacts.", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
2828
bench = parsers.add_parser(name="bench", help="Benchmark MFC (for CI).", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
29+
count = parsers.add_parser(name="count", help="Count LOC in MFC.", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
2930

3031
def add_common_arguments(p, mask = None):
3132
if mask is None:
@@ -98,6 +99,9 @@ def add_common_arguments(p, mask = None):
9899
# === BENCH ===
99100
add_common_arguments(bench, "t")
100101

102+
# === COUNT ===
103+
add_common_arguments(count)
104+
101105
args: dict = vars(parser.parse_args())
102106

103107
# Add default arguments of other subparsers
@@ -109,7 +113,7 @@ def append_defaults_to_data(name: str, parser):
109113
args[key] = val
110114

111115
for a, b in [("run", run ), ("test", test ), ("build", build),
112-
("clean", clean), ("bench", bench)]:
116+
("clean", clean), ("bench", bench), ("count", count)]:
113117
append_defaults_to_data(a, b)
114118

115119
if args["command"] is None:

toolchain/mfc/count.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os, glob, typing, typing
2+
3+
from .common import MFC_ROOTDIR
4+
from .printer import cons
5+
6+
import rich.table
7+
8+
def handle_dir(dirpath: str) -> typing.Tuple[typing.List[typing.Tuple[str, int]], int]:
9+
files = []
10+
total = 0
11+
12+
for filepath in glob.glob(os.path.join(dirpath, '*.*f*')):
13+
with open(filepath) as f:
14+
count = sum(1 if not l.isspace() else 0 for l in f.read().split('\n'))
15+
files.append((filepath, count))
16+
total += count
17+
18+
files.sort(key=lambda x: x[1], reverse=True)
19+
20+
return (files, total)
21+
22+
def count():
23+
cons.print("[bold]Counting lines of code in [magenta]MFC[/magenta][/bold] (excluding whitespace lines)")
24+
cons.print()
25+
cons.indent()
26+
27+
total = 0
28+
for codedir in ['common', 'pre_process', 'simulation', 'post_process']:
29+
dirfiles, dircount = handle_dir(os.path.join(MFC_ROOTDIR, 'src', codedir))
30+
table = rich.table.Table(show_header=True, box=rich.table.box.SIMPLE)
31+
table.add_column(f"File (in [magenta]{codedir}[/magenta])", justify="left")
32+
table.add_column(f"Lines ([cyan]{dircount}[/cyan])", justify="right")
33+
34+
for filepath, count in dirfiles:
35+
table.add_row(f"{os.path.basename(filepath)}", f"[bold cyan]{count}[/bold cyan]")
36+
37+
total += dircount
38+
39+
cons.raw.print(table)
40+
41+
cons.print(f"[bold]Total MFC lines: [bold cyan]{total}[/bold cyan].[/bold]")
42+
cons.print()
43+
cons.unindent()
44+

0 commit comments

Comments
 (0)