Skip to content

Commit 4486c96

Browse files
authored
Merge pull request #305 from mandli/fix-auxloc-array-bound
Update Testing
2 parents 6ffd3aa + 250c6ee commit 4486c96

File tree

3 files changed

+145
-38
lines changed

3 files changed

+145
-38
lines changed

.github/workflows/testing.yml

Lines changed: 116 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,52 @@ env:
1616

1717
jobs:
1818
tests:
19-
runs-on: ubuntu-latest
19+
name: >
20+
${{ matrix.os }} - ${{ matrix.toolchain.compiler }} ${{ matrix.build }} - py ${{ matrix.python-version }}
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
fail-fast: false # Probably want to turn this off for a large matrix
24+
matrix:
25+
os: [ubuntu-latest, macos-latest]
26+
build: [debug, opt]
27+
python-version: [3.12]
28+
toolchain:
29+
- {compiler: gcc, version: 14}
30+
- {compiler: gcc, version: 15}
31+
# - {compiler: intel, version: '2025.0'}
32+
# - {compiler: intel-classic, version: '2021.10'}
33+
# - {compiler: nvidia-hpc, version: '25.1'} # does not build python
34+
# - {compiler: lfortran, version: '0.45.0'} # lfortran not yet supported
35+
# - {compiler: flang, version: '20.1.0'} # flang not yet supported
36+
# include:
37+
# 3.8 does not seem to work.
38+
# - os: ubuntu-latest
39+
# build: opt
40+
# python-version: 3.8
41+
# toolchain: {compiler: gcc, version: 14}
42+
exclude:
43+
- os: ubuntu-latest
44+
toolchain: {compiler: gcc, version: 15}
45+
- os: macos-latest
46+
toolchain: {compiler: gcc, version: 14}
47+
2048
steps:
21-
- name: Set up Python 3.10
49+
- name: Set up Python ${{ matrix.python-version }}
2250
uses: actions/setup-python@v5
2351
with:
24-
python-version: "3.10"
25-
- name: Install dependencies
52+
python-version: ${{ matrix.python-version }}
53+
54+
- name: Set up compilers
55+
uses: fortran-lang/setup-fortran@v1
56+
id: setup-fortran
57+
with:
58+
compiler: ${{ matrix.toolchain.compiler }}
59+
version: ${{ matrix.toolchain.version }}
60+
61+
- name: Install python dependencies
2662
run: |
27-
sudo apt-get update
28-
sudo apt-get install gfortran
2963
python -m pip install --upgrade pip
3064
pip install flake8 meson-python ninja pytest numpy
31-
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3265
3366
- name: Checkout Clawpack
3467
uses: actions/[email protected]
@@ -39,13 +72,14 @@ jobs:
3972
- name: Checkout AMRClaw branch
4073
uses: actions/[email protected]
4174
with:
42-
path: amrclaw
75+
path: amrclaw
4376

44-
- name: Install clawpack
77+
- name: Install clawpack python
4578
run: |
4679
pip install --no-build-isolation --editable .
4780
4881
- name: Lint with flake8
82+
if: ${{ matrix.build == 'debug' }}
4983
run: |
5084
cd ${CLAW}/amrclaw
5185
# stop the build if there are Python syntax errors or undefined names
@@ -55,6 +89,79 @@ jobs:
5589
5690
- name: Test with pytest
5791
run: |
92+
if [ "${{ matrix.toolchain.compiler }}" = "gcc" ]; then
93+
if [ "${{ matrix.build }}" = "debug" ]; then
94+
export FFLAGS="-O0 -g -fcheck=all -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow -finit-real=nan -finit-integer=nan -Wall -Wunderflow -Wextra -Wconversion -Wuninitialized -Warray-bounds -Wshadow -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wno-unused-but-set-variable"
95+
export OMP_NUM_THREADS=1
96+
elif [ "${{ matrix.build }}" = "opt" ]; then
97+
export FFLAGS="-O1 -fopenmp -funroll-loops -finline-functions -ftree-vectorize -fstack-protector-strong -flto -march=native"
98+
export OMP_NUM_THREADS=2
99+
else
100+
echo "Unknown build type: ${{ matrix.build }}"
101+
exit 1
102+
fi
103+
elif [ "${{ matrix.toolchain.compiler }}" = "intel-classic" ]; then
104+
if [ "${{ matrix.build }}" = "debug" ]; then
105+
export FFLAGS="-O0 -debug all -check all -warn all,nodec,interfaces -gen_interfaces -traceback -fpe0 -ftrapuv -init=snan,arrays -check bounds"
106+
export OMP_NUM_THREADS=1
107+
elif [ "${{ matrix.build }}" = "opt" ]; then
108+
export FFLAGS="-O -qopenmp -unroll -finline-functions -inline-forceinline -ipo -ip"
109+
export OMP_NUM_THREADS=2
110+
fi
111+
elif [ "${{ matrix.toolchain.compiler }}" = "intel" ]; then
112+
if [ "${{ matrix.build }}" = "debug" ]; then
113+
export FFLAGS="-O0 -debug all -check all -warn all,nodec,interfaces -gen_interfaces -traceback -fpe0 -ftrapuv -init=snan,arrays -check bounds"
114+
export OMP_NUM_THREADS=1
115+
elif [ "${{ matrix.build }}" = "opt" ]; then
116+
export FFLAGS="-O -qopenmp -unroll -finline-functions -inline-forceinline -ipo -ip"
117+
export OMP_NUM_THREADS=2
118+
else
119+
echo "Unknown build type: ${{ matrix.build }}"
120+
exit 1
121+
fi
122+
elif [ "${{ matrix.toolchain.compiler }}" = "nvidia-hpc" ]; then
123+
echo "nvidia-hpc compiler not yet supported"
124+
exit 1
125+
if [ "${{ matrix.build }}" = "debug" ]; then
126+
export FFLAGS="-g -O0 -check all -traceback"
127+
export OMP_NUM_THREADS=1
128+
elif [ "${{ matrix.build }}" = "opt" ]; then
129+
export FFLAGS="-O1 -qopenmp"
130+
export OMP_NUM_THREADS=2
131+
else
132+
echo "Unknown build type: ${{ matrix.build }}"
133+
exit 1
134+
fi
135+
elif [ "${{ matrix.toolchain.compiler }}" = "flang" ]; then
136+
echo "flang compiler not yet supported"
137+
exit 1
138+
if [ "${{ matrix.build }}" = "debug" ]; then
139+
export FFLAGS=""
140+
export OMP_NUM_THREADS=1
141+
elif [ "${{ matrix.build }}" = "opt" ]; then
142+
export FFLAGS=""
143+
export OMP_NUM_THREADS=2
144+
else
145+
echo "Unknown build type: ${{ matrix.build }}"
146+
exit 1
147+
fi
148+
elif [ "${{ matrix.toolchain.compiler }}" = "lfortran" ]; then
149+
if [ "${{ matrix.build }}" = "debug" ]; then
150+
export FFLAGS=""
151+
export OMP_NUM_THREADS=1
152+
elif [ "${{ matrix.build }}" = "opt" ]; then
153+
export FFLAGS="--fast --openmp"
154+
export OMP_NUM_THREADS=2
155+
else
156+
echo "Unknown build type: ${{ matrix.build }}"
157+
exit 1
158+
fi
159+
else
160+
echo "Unknown compiler: ${{ matrix.toolchain.compiler }}"
161+
exit 1
162+
fi
163+
echo "FFLAGS: $FFLAGS"
164+
echo "OMP_NUM_THREADS: $OMP_NUM_THREADS"
58165
cd ${CLAW}/amrclaw
59166
pytest
60167

src/2d/valout.f90

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
6767
"i6,' ndim'/," // &
6868
"i6,' nghost'/," // &
6969
"a10,' format'/,/)"
70-
70+
7171
character(len=*), parameter :: console_format = &
7272
"('AMRCLAW: Frame ',i4,' output files done at time t = ', d13.6,/)"
7373

@@ -84,7 +84,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
8484
! Note: Currently outputs all aux components if any are requested
8585
out_aux = ((output_aux_num > 0) .and. &
8686
((.not. output_aux_onlyonce) .or. (abs(time - t0) < 1d-90)))
87-
87+
8888
! Construct file names
8989
file_name(1) = 'fort.qxxxx'
9090
file_name(2) = 'fort.txxxx'
@@ -137,10 +137,11 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
137137
num_cells(1) = node(ndihi, grid_ptr) - node(ndilo, grid_ptr) + 1
138138
num_cells(2) = node(ndjhi, grid_ptr) - node(ndjlo, grid_ptr) + 1
139139
q_loc = node(store1, grid_ptr)
140+
aux_loc = node(storeaux, grid_ptr)
140141
lower_corner = [rnode(cornxlo, grid_ptr), rnode(cornylo, grid_ptr)]
141142

142-
! Write out header data
143-
143+
! Write out header data
144+
144145
write(out_unit, header_format_2d) grid_ptr, level, &
145146
num_cells(1), &
146147
num_cells(2), &
@@ -149,8 +150,8 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
149150
delta(1), delta(2)
150151

151152
! Output grids
152-
153-
! Round off if nearly zero
153+
154+
! Round off if nearly zero
154155
! (Do this for all output_format's)
155156
forall (m = 1:num_eqn, &
156157
i=num_ghost + 1:num_cells(1) + num_ghost, &
@@ -162,7 +163,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
162163

163164
if (output_format == 1) then
164165
! ascii output
165-
166+
166167
do j = num_ghost + 1, num_cells(2) + num_ghost
167168
do i = num_ghost + 1, num_cells(1) + num_ghost
168169
write(out_unit, "(50e26.16)") &
@@ -173,7 +174,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
173174

174175
else if (output_format==2 .or. output_format==3) then
175176
! binary32 or binary64
176-
177+
177178
! Note: We are writing out ghost cell data also,
178179
! so need to update this
179180
call bound(time,num_eqn,num_ghost,alloc(q_loc), &
@@ -183,7 +184,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
183184

184185
i = (iadd(num_eqn, num_cells(1) + 2 * num_ghost, &
185186
num_cells(2) + 2 * num_ghost))
186-
187+
187188
if (output_format == 2) then
188189
! binary32 (shorten to 4-byte)
189190
allocate(q4(num_eqn * (num_cells(1) + 2 * num_ghost) &
@@ -196,11 +197,11 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
196197
! binary64 (full 8-byte)
197198
write(out_unit + 1) alloc(iadd(1, 1, 1):i)
198199
endif
199-
200-
200+
201+
201202
else if (output_format == 4) then
202203
#ifdef HDF5
203-
! Create data space - handles dimensions of the corresponding
204+
! Create data space - handles dimensions of the corresponding
204205
! data set - annoyingling need to stick grid size into other
205206
! data type
206207
dims = (/ num_eqn, num_cells(1) + 2 * num_ghost, &
@@ -221,15 +222,15 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
221222
#endif
222223
else
223224
print *, "Unsupported output format", output_format,"."
224-
stop
225+
stop
225226
endif
226227

227228
grid_ptr = node(levelptr, grid_ptr)
228229
end do
229230
end do
230231

231232
close(out_unit)
232-
233+
233234
if (output_format==2 .or. output_format==3) then
234235
close(unit=out_unit + 1)
235236
end if
@@ -253,7 +254,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
253254
#ifdef HDF5
254255
! Create group for aux
255256
call h5gcreate_f(hdf_file, "/aux", aux_group, hdf_error)
256-
#endif
257+
#endif
257258
end if
258259

259260
do level = level_begin, level_end
@@ -274,7 +275,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
274275
! ASCII output
275276
case(1)
276277

277-
! We only output header info for aux data if writing
278+
! We only output header info for aux data if writing
278279
! ASCII data
279280
write(out_unit, header_format_2d) grid_ptr, level, &
280281
num_cells(1), &
@@ -299,7 +300,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
299300
end do
300301
write(out_unit, *) ' '
301302
end do
302-
303+
303304
case(2)
304305
! binary32
305306
! Note: We are writing out ghost cell data also
@@ -310,19 +311,19 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
310311
aux4 = real(alloc(iaddaux(1, 1, 1):i), kind=4)
311312
write(out_unit) aux4
312313
deallocate(aux4)
313-
314+
314315
case(3)
315316
! binary64
316317
! Note: We are writing out ghost cell data also
317318
i = (iaddaux(num_aux, num_cells(1) + 2 * num_ghost, &
318319
num_cells(2) + 2 * num_ghost))
319320
write(out_unit) alloc(iaddaux(1, 1, 1):i)
320-
321+
321322

322323
! HDF5 output
323324
case(4)
324325
#ifdef HDF5
325-
! Create data space - handles dimensions of the corresponding
326+
! Create data space - handles dimensions of the corresponding
326327
! data set - annoyingling need to stick grid size into other
327328
! data type
328329
dims = (/ num_aux, num_cells(1) + 2 * num_ghost, &
@@ -346,18 +347,18 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
346347
#endif
347348
case default
348349
print *, "Unsupported output format", output_format,"."
349-
stop
350+
stop
350351

351352
end select
352353
grid_ptr = node(levelptr, grid_ptr)
353354
end do
354355
end do
355-
356+
356357
if ((output_format == 1) .or. (output_format == 2) .or. &
357358
(output_format == 3)) then
358359
close(out_unit)
359360
end if
360-
361+
361362
end if
362363

363364
#ifdef HDF5
@@ -375,7 +376,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
375376
! Note: We need to print out num_ghost too in order to strip ghost cells
376377
! from q array when reading in pyclaw.io.binary
377378

378-
379+
379380
if (output_format == 1) then
380381
file_format = 'ascii'
381382
else if (output_format == 2) then
@@ -385,7 +386,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
385386
else if (output_format == 4) then
386387
file_format = 'hdf'
387388
endif
388-
389+
389390
write(out_unit, t_file_format) time, num_eqn, num_grids, num_aux, 2, &
390391
num_ghost, file_format
391392
close(out_unit)
@@ -395,7 +396,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
395396
open(unit=out_unit, file=timing_file_name, form='formatted', &
396397
status='unknown', action='write', position='append')
397398
!status='old', action='write', position='append')
398-
399+
399400
timing_line = "(e16.6, ', ', e16.6, ', ', e16.6"
400401
do level=1, mxnest
401402
timing_substr = ", ', ', e16.6, ', ', e16.6, ', ', e16.6"
@@ -419,7 +420,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
419420
write(out_unit, timing_line) time, timeTick_overall, t_CPU_overall, &
420421
(real(tvoll(i), kind=8) / real(clock_rate, kind=8), &
421422
tvollCPU(i), rvoll(i), i=1,mxnest)
422-
423+
423424
close(out_unit)
424425

425426
! ==========================================================================
@@ -452,5 +453,3 @@ pure integer function iaddaux(m, i, j)
452453
end function iaddaux
453454

454455
end subroutine valout
455-
456-

src/3d/valout.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
127127
num_cells(2) = node(ndjhi, grid_ptr) - node(ndjlo, grid_ptr) + 1
128128
num_cells(3) = node(ndkhi, grid_ptr) - node(ndklo, grid_ptr) + 1
129129
q_loc = node(store1, grid_ptr)
130+
aux_loc = node(storeaux, grid_ptr)
130131
lower_corner = [rnode(cornxlo, grid_ptr), &
131132
rnode(cornylo, grid_ptr), &
132133
rnode(cornzlo, grid_ptr)]

0 commit comments

Comments
 (0)