Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel R. Reynolds <[email protected]>
Co-authored-by: David Gardner <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent bb36a4f commit f19ae57
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
6 changes: 1 addition & 5 deletions doc/shared/sundials/Errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ Error Checking

.. versionadded:: 7.0.0

Until version 7.0.0, error reporting and handling was inconsistent throughout SUNDIALS. The SUNDIALS
core was hit and miss with error reporting via return codes and output no error messages. The
packages of SUNDIALS (CVODE, ARKODE etc.) all reported errors through package specific ``int`` codes
and error handler callbacks. The packages defaulted to printing error messages to a file, stdout, or
stderr. Starting with version 7.0.0 all of SUNDIALS (the core, implementations of core modules, and
Until version 7.0.0, error reporting and handling was inconsistent throughout SUNDIALS. Starting with version 7.0.0 all of SUNDIALS (the core, implementations of core modules, and
packages) reports error mesages through the :c:type:`SUNLogger` API. Furthermore, functions in the
SUNDIALS core API (i.e., ``SUN`` or ``N_V`` functions only) either return a :c:type:`SUNErrCode`, or
(if they don't return a :c:type:`SUNErrCode`) they internally record an error code (if an error
Expand Down
12 changes: 10 additions & 2 deletions doc/shared/sundials/Fortran.rst
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,13 @@ a C file pointer, SUNDIALS provides two utility functions for creating a
:param fp: The ``FILE*`` that will be open when the function returns.
This should be a `type(c_ptr)` in the Fortran.
:return: The function returns a :c:type:`SUNErrCode`
:return: A :c:type:`SUNErrCode`
.. versionchanged:: 7.0.0
The function signature was updated to return a `SUNErrCode` and take a `FILE**` as the last input parameter rather then return a `FILE*`.
.. c:function:: SUNErrCode SUNDIALSFileClose(FILE** fp)
The function deallocates a C ``FILE*`` by calling the C function ``fclose``
Expand All @@ -542,7 +546,11 @@ a C file pointer, SUNDIALS provides two utility functions for creating a
:param fp: the C ``FILE*`` that was previously obtained from ``fopen``.
This should have the Fortran type ``type(c_ptr)``. Note that if either
``stdout`` or ``stderr`` were opened using :c:func:`SUNDIALSFileOpen()`
then that stream *will not be closed* by this function.
.. versionchanged:: 7.0.0
The function signature was updated to return a `SUNErrCode`.
.. _SUNDIALS.Fortran.Portability:
Expand Down
16 changes: 8 additions & 8 deletions include/sundials/priv/sundials_errors_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ void SUNHandleSecondError(int line, const char* func, const char* file,
assumptions. If the expression should be strictly assumed as true, then use
SUNAssert instead.
Use SUNAssert macros to check for conditions that do not make sense. E.g.,
to check if malloc returned NULL. Use SUNCheck macros for checking inputs.
Use SUNAssert macros to check for conditions that do not make sense e.g.,
to check if malloc returned NULL.
:param expr: an expression to evaluate as true or false
:param code: the error code to pass to the error handler if the expression is
Expand All @@ -196,8 +196,8 @@ void SUNHandleSecondError(int line, const char* func, const char* file,

/*
SUNCheckNoRet is the same as SUNCheck but *does not return from the caller*.
Use SUNAssert macros to check for conditions that do not make sense. E.g.,
to check if malloc returned NULL. Use SUNCheck macros for checking inputs.
Use SUNAssert macros to check for conditions that do not make sense e.g.,
to check if malloc returned NULL.
:param expr: an expression to evaluate as true or false
:param code: the error code to pass to the error handler if the expression is
Expand All @@ -220,8 +220,8 @@ void SUNHandleSecondError(int line, const char* func, const char* file,

/*
SUNCheckNull is the same as SUNCheck but *returns NULL from the caller*.
Use SUNAssert macros to check for conditions that do not make sense. E.g.,
to check if malloc returned NULL. Use SUNCheck macros for checking inputs.
Use SUNAssert macros to check for conditions that do not make sense e.g.,
to check if malloc returned NULL.
:param expr: an expression to evaluate as true or false
:param code: the error code to pass to the error handler if the expression is
Expand All @@ -245,8 +245,8 @@ void SUNHandleSecondError(int line, const char* func, const char* file,

/*
SUNCheckNull is the same as SUNCheck but *returns void from the caller*.
Use SUNAssert macros to check for conditions that do not make sense. E.g.,
to check if malloc returned NULL. Use SUNCheck macros for checking inputs.
Use SUNAssert macros to check for conditions that do not make sense e.g.,
to check if malloc returned NULL.
:param expr: an expression to evaluate as true or false
:param code: the error code to pass to the error handler if the expression is
Expand Down
2 changes: 1 addition & 1 deletion include/sundials/priv/sundials_mpi_errors_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{ \
SUNHandleErrWithMsg(__LINE__, __func__, __FILE__, msg, SUN_ERR_MPI_FAIL, \
SUNCTX_); \
return SUN_ERR_MPI_FAIL; s \
return SUN_ERR_MPI_FAIL; \
} \
} \
while (0)
Expand Down

0 comments on commit f19ae57

Please sign in to comment.