diff --git a/src/common/m_checker_common.fpp b/src/common/m_checker_common.fpp index 2a1210ab66..2b8c1a4d12 100644 --- a/src/common/m_checker_common.fpp +++ b/src/common/m_checker_common.fpp @@ -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 @@ -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 diff --git a/src/common/m_constants.fpp b/src/common/m_constants.fpp index 516111ad9b..6998a5bfcb 100644 --- a/src/common/m_constants.fpp +++ b/src/common/m_constants.fpp @@ -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 diff --git a/src/common/m_helper.fpp b/src/common/m_helper.fpp index e3dd33de0a..14367618f1 100644 --- a/src/common/m_helper.fpp +++ b/src/common/m_helper.fpp @@ -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 diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index 405da58774..fc5a4e09f3 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -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 @@ -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 diff --git a/toolchain/templates/include/helpers.mako b/toolchain/templates/include/helpers.mako index 149161e877..a4086ee381 100644 --- a/toolchain/templates/include/helpers.mako +++ b/toolchain/templates/include/helpers.mako @@ -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."