Skip to content

Commit

Permalink
Checker Error Message (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisZYJ authored Jan 26, 2025
1 parent 6b3e012 commit 43812d8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/common/m_checker_common.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ contains
if (any((/bc_${X}$%${VB2}$, bc_${X}$%${VB3}$/) /= 0._wp)) then
call s_mpi_abort("bc_${X}$%beg must be -15 if "// &
"bc_${X}$%${VB2}$ or bc_${X}$%${VB3}$ "// &
"is set. Exiting.")
"is set. Exiting.", CASE_FILE_ERROR_CODE)
end if
elseif (bc_${X}$%beg /= -16) then
call s_mpi_abort("bc_${X}$%beg must be -15 or -16 if "// &
"bc_${X}$%vb[1,2,3] is set. Exiting.")
"bc_${X}$%vb[1,2,3] is set. Exiting.", CASE_FILE_ERROR_CODE)
end if
end if
#:endfor
Expand All @@ -354,11 +354,11 @@ contains
if (any((/bc_${X}$%${VE2}$, bc_${X}$%${VE3}$/) /= 0._wp)) then
call s_mpi_abort("bc_${X}$%end must be -15 if "// &
"bc_${X}$%${VE2}$ or bc_${X}$%${VE3}$ "// &
"is set. Exiting.")
"is set. Exiting.", CASE_FILE_ERROR_CODE)
end if
elseif (bc_${X}$%end /= -16) then
call s_mpi_abort("bc_${X}$%end must be -15 or -16 if "// &
"bc_${X}$%ve[1,2,3] is set. Exiting.")
"bc_${X}$%ve[1,2,3] is set. Exiting.", CASE_FILE_ERROR_CODE)
end if
end if
#:endfor
Expand Down
3 changes: 3 additions & 0 deletions src/common/m_constants.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ module m_constants
real(wp), parameter :: ERRCON = 1.89e-4_wp !< Limit to slightly increase dt when truncation error is between ERRCON and 1
real(wp), parameter :: PGROW = -0.2_wp !< Factor to increase dt when truncation error is between ERRCON and 1

! System constants
integer, parameter :: CASE_FILE_ERROR_CODE = 22

end module m_constants
13 changes: 5 additions & 8 deletions src/common/m_helper.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,14 @@ contains
subroutine s_prohibit_abort(condition, message)
character(len=*), intent(in) :: condition, message
print *, " "
print *, " "
print *, " CASE FILE ERROR "
print *, " "
print *, "Prohibited condition: ", trim(condition)
print *, ""
print *, "CASE FILE ERROR"
print *, " - Prohibited condition: ", trim(condition)
if (len_trim(message) > 0) then
print *, "Note: ", trim(message)
print *, " - Note: ", trim(message)
end if
print *, " "
print *, ""
call s_mpi_abort
call s_mpi_abort(code=CASE_FILE_ERROR_CODE)
end subroutine s_prohibit_abort
!> This function generates the unassociated legendre poynomials
Expand Down
19 changes: 12 additions & 7 deletions src/common/m_mpi_common.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,10 @@ contains
!> The subroutine terminates the MPI execution environment.
!! @param prnt error message to be printed
subroutine s_mpi_abort(prnt)
subroutine s_mpi_abort(prnt, code)
character(len=*), intent(in), optional :: prnt
integer, intent(in), optional :: code
if (present(prnt)) then
print *, prnt
Expand All @@ -485,14 +486,18 @@ contains
end if
#ifndef MFC_MPI
stop 1
if (present(code)) then
stop code
else
stop 1
end if
#else
! Terminating the MPI environment
call MPI_ABORT(MPI_COMM_WORLD, 1, ierr)
if (present(code)) then
call MPI_ABORT(MPI_COMM_WORLD, code, ierr)
else
call MPI_ABORT(MPI_COMM_WORLD, 1, ierr)
end if
#endif
end subroutine s_mpi_abort
Expand Down
5 changes: 5 additions & 0 deletions toolchain/templates/include/helpers.mako
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ END
t_${target.name}_stop=$(python3 -c 'import time; print(time.time())')
if [ $code -eq 22 ]; then
echo
error "$YELLOW CASE FILE ERROR$COLOR_RESET > $YELLOW Case file has prohibited conditions as stated above.$COLOR_RESET"
fi
if [ $code -ne 0 ]; then
echo
error ":( $MAGENTA${target.get_install_binpath(case)}$COLOR_RESET failed with exit code $MAGENTA$code$COLOR_RESET."
Expand Down

0 comments on commit 43812d8

Please sign in to comment.