Skip to content

Commit 0493443

Browse files
author
Archith Iyer
committed
fix NaN issue without skipping and retry each test 3 times in single precision
1 parent a5ebe3e commit 0493443

File tree

7 files changed

+138
-83
lines changed

7 files changed

+138
-83
lines changed

src/common/m_checker_common.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module m_checker_common
1818

1919
implicit none
2020

21-
private; public :: s_check_inputs_common
21+
private; public :: s_check_inputs_common, wp
2222

2323
contains
2424

src/common/m_precision_select.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module m_precision_select
1616
integer, parameter :: single_precision = selected_real_kind(6, 37)
1717
integer, parameter :: double_precision = selected_real_kind(15, 307)
1818

19+
integer, parameter :: sp = single_precision
20+
integer, parameter :: dp = double_precision
21+
1922
! Set the working precision (wp) to single or double precision
2023
#ifdef MFC_SINGLE_PRECISION
2124
integer, parameter :: wp = single_precision ! Change to single_precision if needed

src/post_process/m_data_output.fpp

Lines changed: 115 additions & 68 deletions
Large diffs are not rendered by default.

src/post_process/m_global_parameters.fpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module m_global_parameters
6565
!> @name Cell-center locations in the x-, y- and z-coordinate directions
6666
!> @{
6767
real(wp), allocatable, dimension(:) :: x_cc, x_root_cc, y_cc, z_cc
68+
real(sp), allocatable, dimension(:) :: x_root_cc_s, x_cc_s
6869
!> @}
6970

7071
!> Cell-width distributions in the x-, y- and z-coordinate directions
@@ -700,6 +701,8 @@ contains
700701
allocate (z_cb_s(-1 - offset_x%beg:m + offset_x%end))
701702
end if
702703
end if
704+
else
705+
allocate (x_cc_s(-buff_size:m + buff_size))
703706
end if
704707

705708
! Allocating the grid variables in the x-coordinate direction
@@ -727,6 +730,10 @@ contains
727730
allocate (x_root_cb(-1:m_root))
728731
allocate (x_root_cc(0:m_root))
729732

733+
if (precision == 1) then
734+
allocate (x_root_cc_s(0:m_root))
735+
end if
736+
730737
end if
731738

732739
allocate (adv(num_fluids))

src/post_process/m_mpi_proxy.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ contains
14141414
!! the second dimension corresponds to the processor rank.
14151415
subroutine s_mpi_gather_spatial_extents(spatial_extents)
14161416

1417-
real(wp), dimension(1:, 0:), intent(inout) :: spatial_extents
1417+
real(kind(0d0)), dimension(1:, 0:), intent(INOUT) :: spatial_extents
14181418

14191419
#ifdef MFC_MPI
14201420

@@ -1600,20 +1600,20 @@ contains
16001600
subroutine s_mpi_defragment_1d_flow_variable(q_sf, q_root_sf)
16011601

16021602
real(wp), &
1603-
dimension(0:m, 0:0, 0:0), &
1603+
dimension(0:m), &
16041604
intent(in) :: q_sf
16051605

16061606
real(wp), &
1607-
dimension(0:m_root, 0:0, 0:0), &
1607+
dimension(0:m), &
16081608
intent(inout) :: q_root_sf
16091609

16101610
#ifdef MFC_MPI
16111611

16121612
! Gathering the sub-domain flow variable data from all the processes
16131613
! and putting it back together for the entire computational domain
16141614
! on the process with rank 0
1615-
call MPI_GATHERV(q_sf(0, 0, 0), m + 1, mpi_p, &
1616-
q_root_sf(0, 0, 0), recvcounts, displs, &
1615+
call MPI_GATHERV(q_sf(0), m + 1, mpi_p, &
1616+
q_root_sf(0), recvcounts, displs, &
16171617
mpi_p, 0, MPI_COMM_WORLD, ierr)
16181618

16191619
#endif

toolchain/mfc/test/case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def create_directory(self):
212212
def __str__(self) -> str:
213213
return f"tests/[bold magenta]{self.get_uuid()}[/bold magenta]: {self.trace}"
214214

215+
# pylint: disable=global-statement, global-variable-not-assigned, too-many-return-statements
215216
def compute_tolerance(self) -> float:
216217
if ARG("single"):
217218
return 1e-1

toolchain/mfc/test/test.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ def test():
133133
# pylint: disable=too-many-locals, too-many-branches, too-many-statements, trailing-whitespace
134134
def _handle_case(case: TestCase, devices: typing.Set[int]):
135135
# pylint: disable=global-statement, global-variable-not-assigned
136-
global nSKIP
137-
138136
start_time = time.time()
139137

140138
tol = case.compute_tolerance()
@@ -202,11 +200,7 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
202200
raise MFCException(f"Test {case}: Failed to run h5dump. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
203201

204202
if "nan," in output:
205-
if not ARG("single"):
206-
raise MFCException(f"Test {case}: Post Process has detected a NaN. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
207-
cons.print(f"Test {case}: Skipping this test case as it cannot be run in single precision, please build MFC in double precision to run this test")
208-
nSKIP += 1
209-
return
203+
raise MFCException(f"Test {case}: Post Process has detected a NaN. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
210204

211205
if "inf," in output:
212206
raise MFCException(f"Test {case}: Post Process has detected an Infinity. You can find the run's output in {out_filepath}, and the case dictionary in {case.get_filepath()}.")
@@ -224,6 +218,10 @@ def handle_case(case: TestCase, devices: typing.Set[int]):
224218
global nFAIL, nPASS, nSKIP
225219

226220
nAttempts = 0
221+
if ARG('single'):
222+
max_attempts = max(ARG('max_attempts'), 3)
223+
else:
224+
max_attempts = ARG('max_attempts')
227225

228226
while True:
229227
nAttempts += 1
@@ -232,8 +230,7 @@ def handle_case(case: TestCase, devices: typing.Set[int]):
232230
_handle_case(case, devices)
233231
nPASS += 1
234232
except Exception as exc:
235-
if nAttempts < ARG("max_attempts"):
236-
cons.print(f"[bold yellow] Attempt {nAttempts}: Failed test {case.get_uuid()}. Retrying...[/bold yellow]")
233+
if nAttempts < max_attempts:
237234
continue
238235
nFAIL += 1
239236
cons.print(f"[bold red]Failed test {case} after {nAttempts} attempt(s).[/bold red]")

0 commit comments

Comments
 (0)