Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error handling in idas #384

Merged
merged 28 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
949f5cd
error handling in idas
balos1 Dec 6, 2023
5825d3a
Merge branch 'feature/error-handling-just-the-core-formatted' into fe…
balos1 Dec 6, 2023
f054841
Merge branch 'feature/error-handling-just-the-core-formatted' into fe…
balos1 Dec 7, 2023
33c4ff8
Merge branch 'feature/error-handling-just-the-core-formatted' into fe…
balos1 Dec 7, 2023
90191eb
Merge branch 'feature/error-handling-just-the-core-formatted' into fe…
balos1 Dec 7, 2023
a1fad02
Merge branch 'feature/error-handling-just-the-core-formatted' into fe…
balos1 Dec 7, 2023
5393e18
Merge branch 'feature/error-handling-just-the-core-formatted' into fe…
balos1 Dec 7, 2023
2329799
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 7, 2023
74f0968
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 7, 2023
81a2127
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 8, 2023
e4b07e2
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 8, 2023
b7ee83e
reapply refactor tool
balos1 Dec 8, 2023
1e19436
remove ida error handler function
balos1 Dec 8, 2023
208b380
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 8, 2023
330ded3
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 8, 2023
edf95dd
format after merge
balos1 Dec 8, 2023
8b04808
Update src/idas/idas.c
balos1 Dec 8, 2023
480d950
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 8, 2023
1c5ba2e
Merge remote-tracking branch 'origin/feature/error-handling-idas' int…
balos1 Dec 8, 2023
6c26fc6
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 11, 2023
dcd2902
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 11, 2023
0a04004
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 11, 2023
1d9cbc6
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 12, 2023
d9a8a7e
address comments
balos1 Dec 12, 2023
5394a8c
call GetLastError in ProcessError
balos1 Dec 12, 2023
10afdd4
Merge branch 'feature/error-handling-staging' into feature/error-hand…
balos1 Dec 12, 2023
44d4c27
Apply suggestions from code review
balos1 Dec 12, 2023
ceef64a
doc fixes
balos1 Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/idas/guide/source/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ Users now need to link to ``sundials_core`` in addition to the libraries already
This will be picked up automatically in projects that use the SUNDIALS CMake target. The library ``sundials_generic`` has been superceded by ``sundials_core`` and is no longer available.
This fixes some duplicate symbol errors on Windows when linking to multiple SUNDIALS libraries.

**Breaking change**
The functions ``IDASetErrFile`` and ``IDASetHandlerErrFn`` have been removed.
Users of these functions should use the :c:type:`SUNLogger` API instead.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

Changes in v5.6.2
-----------------

Expand Down
78 changes: 0 additions & 78 deletions doc/idas/guide/source/Usage/SIM.rst
balos1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -947,53 +947,6 @@ Main solver optional input functions
+--------------------------------------------------------------------+---------------------------------+----------------+


.. c:function:: int IDASetErrFile(void * ida_mem, FILE * errfp)
balos1 marked this conversation as resolved.
Show resolved Hide resolved

The function :c:func:`IDASetErrFile` specifies the file pointer where all IDAS
messages should be directed when using the default IDAS error handler
function.

**Arguments:**
* ``ida_mem`` -- pointer to the IDAS solver object.
* ``errfp`` -- pointer to output file.

**Return value:**
* ``IDA_SUCCESS`` -- The optional value has been successfully set.
* ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``.

**Notes:**
The default value for ``errfp`` is ``stderr``. Passing a value ``NULL``
disables all future error message output (except for the case in which the
IDAS memory pointer is ``NULL``). This use of :c:func:`IDASetErrFile` is
strongly discouraged.

.. warning::

If :c:func:`IDASetErrFile` is to be called, it should be called before any
other optional input functions, in order to take effect for any later
error message.

.. c:function:: int IDASetErrHandlerFn(void * ida_mem, IDAErrHandlerFn ehfun, void * eh_data)

The function :c:func:`IDASetErrHandlerFn` specifies the optional user-defined
function to be used in handling error messages.

**Arguments:**
* ``ida_mem`` -- pointer to the IDAS solver object.
* ``ehfun`` -- is the user's error handler function. See
:c:type:`IDAErrHandlerFn` for more details.
* ``eh_data`` -- pointer to user data passed to ``ehfun`` every time it is
called.

**Return value:**
* ``IDA_SUCCESS`` -- The function ``ehfun`` and data pointer ``eh_data`` have
been successfully set.
* ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``.

**Notes:**
Error messages indicating that the IDAS solver memory is ``NULL`` will always
be directed to ``stderr``.

.. c:function:: int IDASetUserData(void * ida_mem, void * user_data)

The function :c:func:`IDASetUserData` attaches a user-defined data pointer to the
Expand Down Expand Up @@ -3286,37 +3239,6 @@ The user must provide a function of type :c:type:`IDAResFn` defined as follows:
can be flagged, and IDAS will then try to correct it.


.. _IDAS.Usage.SIM.user_supplied.ehFn:

Error message handler function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As an alternative to the default behavior of directing error and warning
messages to the file pointed to by ``errfp`` (see :c:func:`IDASetErrFile`), the
user may provide a function of type :c:type:`IDAErrHandlerFn` to process any
such messages. The function type :c:type:`IDAErrHandlerFn` is defined as
follows:

.. c:type:: void (*IDAErrHandlerFn)(int error_code, const char *module, const char *function, char *msg, void *user_data)

This function processes error and warning messages from IDAS and its
sub-modules.

**Arguments:**
* ``error_code`` -- is the error code.
* ``module`` -- is the name of the IDAS module reporting the error.
* ``function`` -- is the name of the function in which the error occurred.
* ``eH_data`` -- is a pointer to user data, the same as the ``eh_data``
parameter passed to :c:func:`IDASetErrHandlerFn`.

**Return value:**
This function has no return value.

**Notes:**
``error_code`` is negative for errors and positive (``IDA_WARNING``) for
warnings. If a function that returns a pointer to memory encounters an error,
it sets ``error_code`` to 0.


.. _IDAS.Usage.SIM.user_supplied.ewtsetFn:

Expand Down
6 changes: 0 additions & 6 deletions include/idas/idas.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ typedef int (*IDARootFn)(sunrealtype t, N_Vector y, N_Vector yp,

typedef int (*IDAEwtFn)(N_Vector y, N_Vector ewt, void* user_data);

typedef void (*IDAErrHandlerFn)(int error_code, const char* module,
const char* function, char* msg, void* user_data);

typedef int (*IDAQuadRhsFn)(sunrealtype tres, N_Vector yy, N_Vector yp,
N_Vector rrQ, void* user_data);

Expand Down Expand Up @@ -192,9 +189,6 @@ SUNDIALS_EXPORT int IDASetMaxBacksIC(void* ida_mem, int maxbacks);

/* Optional input functions */
SUNDIALS_EXPORT int IDASetDeltaCjLSetup(void* ida_max, sunrealtype dcj);
SUNDIALS_EXPORT int IDASetErrHandlerFn(void* ida_mem, IDAErrHandlerFn ehfun,
void* eh_data);
SUNDIALS_EXPORT int IDASetErrFile(void* ida_mem, FILE* errfp);
SUNDIALS_EXPORT int IDASetUserData(void* ida_mem, void* user_data);
SUNDIALS_EXPORT int IDASetMaxOrd(void* ida_mem, int maxord);
SUNDIALS_EXPORT int IDASetMaxNumSteps(void* ida_mem, long int mxsteps);
Expand Down
30 changes: 0 additions & 30 deletions src/idas/fmod/fidas_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,36 +534,6 @@ SWIGEXPORT int _wrap_FIDASetDeltaCjLSetup(void *farg1, double const *farg2) {
}


SWIGEXPORT int _wrap_FIDASetErrHandlerFn(void *farg1, IDAErrHandlerFn farg2, void *farg3) {
int fresult ;
void *arg1 = (void *) 0 ;
IDAErrHandlerFn arg2 = (IDAErrHandlerFn) 0 ;
void *arg3 = (void *) 0 ;
int result;

arg1 = (void *)(farg1);
arg2 = (IDAErrHandlerFn)(farg2);
arg3 = (void *)(farg3);
result = (int)IDASetErrHandlerFn(arg1,arg2,arg3);
fresult = (int)(result);
return fresult;
}


SWIGEXPORT int _wrap_FIDASetErrFile(void *farg1, void *farg2) {
int fresult ;
void *arg1 = (void *) 0 ;
FILE *arg2 = (FILE *) 0 ;
int result;

arg1 = (void *)(farg1);
arg2 = (FILE *)(farg2);
result = (int)IDASetErrFile(arg1,arg2);
fresult = (int)(result);
return fresult;
}


SWIGEXPORT int _wrap_FIDASetUserData(void *farg1, void *farg2) {
int fresult ;
void *arg1 = (void *) 0 ;
Expand Down
56 changes: 0 additions & 56 deletions src/idas/fmod/fidas_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ module fidas_mod
public :: FIDASetStepToleranceIC
public :: FIDASetMaxBacksIC
public :: FIDASetDeltaCjLSetup
public :: FIDASetErrHandlerFn
public :: FIDASetErrFile
public :: FIDASetUserData
public :: FIDASetMaxOrd
public :: FIDASetMaxNumSteps
Expand Down Expand Up @@ -512,25 +510,6 @@ function swigc_FIDASetDeltaCjLSetup(farg1, farg2) &
integer(C_INT) :: fresult
end function

function swigc_FIDASetErrHandlerFn(farg1, farg2, farg3) &
bind(C, name="_wrap_FIDASetErrHandlerFn") &
result(fresult)
use, intrinsic :: ISO_C_BINDING
type(C_PTR), value :: farg1
type(C_FUNPTR), value :: farg2
type(C_PTR), value :: farg3
integer(C_INT) :: fresult
end function

function swigc_FIDASetErrFile(farg1, farg2) &
bind(C, name="_wrap_FIDASetErrFile") &
result(fresult)
use, intrinsic :: ISO_C_BINDING
type(C_PTR), value :: farg1
type(C_PTR), value :: farg2
integer(C_INT) :: fresult
end function

function swigc_FIDASetUserData(farg1, farg2) &
bind(C, name="_wrap_FIDASetUserData") &
result(fresult)
Expand Down Expand Up @@ -2919,41 +2898,6 @@ function FIDASetDeltaCjLSetup(ida_max, dcj) &
swig_result = fresult
end function

function FIDASetErrHandlerFn(ida_mem, ehfun, eh_data) &
result(swig_result)
use, intrinsic :: ISO_C_BINDING
integer(C_INT) :: swig_result
type(C_PTR) :: ida_mem
type(C_FUNPTR), intent(in), value :: ehfun
type(C_PTR) :: eh_data
integer(C_INT) :: fresult
type(C_PTR) :: farg1
type(C_FUNPTR) :: farg2
type(C_PTR) :: farg3

farg1 = ida_mem
farg2 = ehfun
farg3 = eh_data
fresult = swigc_FIDASetErrHandlerFn(farg1, farg2, farg3)
swig_result = fresult
end function

function FIDASetErrFile(ida_mem, errfp) &
result(swig_result)
use, intrinsic :: ISO_C_BINDING
integer(C_INT) :: swig_result
type(C_PTR) :: ida_mem
type(C_PTR) :: errfp
integer(C_INT) :: fresult
type(C_PTR) :: farg1
type(C_PTR) :: farg2

farg1 = ida_mem
farg2 = errfp
fresult = swigc_FIDASetErrFile(farg1, farg2)
swig_result = fresult
end function

function FIDASetUserData(ida_mem, user_data) &
result(swig_result)
use, intrinsic :: ISO_C_BINDING
Expand Down
Loading