From f19ae57594219d259f27305a67093daf0bbd9f38 Mon Sep 17 00:00:00 2001 From: Cody Balos Date: Wed, 6 Dec 2023 20:39:46 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Daniel R. Reynolds Co-authored-by: David Gardner --- doc/shared/sundials/Errors.rst | 6 +----- doc/shared/sundials/Fortran.rst | 12 ++++++++++-- include/sundials/priv/sundials_errors_impl.h | 16 ++++++++-------- include/sundials/priv/sundials_mpi_errors_impl.h | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/doc/shared/sundials/Errors.rst b/doc/shared/sundials/Errors.rst index b4df8ac04d..533850f1f7 100644 --- a/doc/shared/sundials/Errors.rst +++ b/doc/shared/sundials/Errors.rst @@ -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 diff --git a/doc/shared/sundials/Fortran.rst b/doc/shared/sundials/Fortran.rst index 85fa829c11..b1d209ca7a 100644 --- a/doc/shared/sundials/Fortran.rst +++ b/doc/shared/sundials/Fortran.rst @@ -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`` @@ -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: diff --git a/include/sundials/priv/sundials_errors_impl.h b/include/sundials/priv/sundials_errors_impl.h index f97b43c73a..ea3817f63d 100644 --- a/include/sundials/priv/sundials_errors_impl.h +++ b/include/sundials/priv/sundials_errors_impl.h @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/include/sundials/priv/sundials_mpi_errors_impl.h b/include/sundials/priv/sundials_mpi_errors_impl.h index 3c5137e7db..5608fc3623 100644 --- a/include/sundials/priv/sundials_mpi_errors_impl.h +++ b/include/sundials/priv/sundials_mpi_errors_impl.h @@ -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)