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 3 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
217 changes: 132 additions & 85 deletions src/idas/idaa.c

Large diffs are not rendered by default.

105 changes: 56 additions & 49 deletions src/idas/idaa_io.c

Large diffs are not rendered by default.

599 changes: 315 additions & 284 deletions src/idas/idas.c

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions src/idas/idas_bbdpre.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,

if (ida_mem == NULL)
{
IDAProcessError(NULL, IDALS_MEM_NULL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(NULL, IDALS_MEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_NULL);
return (IDALS_MEM_NULL);
}
Expand All @@ -91,7 +91,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
/* Test if the LS linear solver interface has been created */
if (IDA_mem->ida_lmem == NULL)
{
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_LMEM_NULL);
return (IDALS_LMEM_NULL);
}
Expand All @@ -100,7 +100,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
/* Test compatibility of NVECTOR package with the BBD preconditioner */
if (IDA_mem->ida_tempv1->ops->nvgetarraypointer == NULL)
{
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, __LINE__, __func__, __FILE__,
MSGBBD_BAD_NVECTOR);
return (IDALS_ILL_INPUT);
}
Expand All @@ -110,7 +110,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
pdata = (IBBDPrecData)malloc(sizeof *pdata);
if (pdata == NULL)
{
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -137,7 +137,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
{
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -150,7 +150,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -162,7 +162,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -175,7 +175,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -189,7 +189,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -204,7 +204,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -220,7 +220,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -239,7 +239,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNMatDestroy(pdata->PP);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand All @@ -258,7 +258,7 @@ int IDABBDPrecInit(void* ida_mem, sunindextype Nlocal, sunindextype mudq,
SUNLinSolFree(pdata->LS);
free(pdata);
pdata = NULL;
IDAProcessError(IDA_mem, IDALS_SUNLS_FAIL, "IDASBBDPRE", "IDABBDPrecInit",
IDAProcessError(IDA_mem, IDALS_SUNLS_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_SUNLS_FAIL);
return (IDALS_SUNLS_FAIL);
}
Expand Down Expand Up @@ -324,7 +324,7 @@ int IDABBDPrecReInit(void* ida_mem, sunindextype mudq, sunindextype mldq,

if (ida_mem == NULL)
{
IDAProcessError(NULL, IDALS_MEM_NULL, "IDASBBDPRE", "IDABBDPrecReInit",
IDAProcessError(NULL, IDALS_MEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_NULL);
return (IDALS_MEM_NULL);
}
Expand All @@ -333,7 +333,7 @@ int IDABBDPrecReInit(void* ida_mem, sunindextype mudq, sunindextype mldq,
/* Test if the LS linear solver interface has been created */
if (IDA_mem->ida_lmem == NULL)
{
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDASBBDPRE", "IDABBDPrecReInit",
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_LMEM_NULL);
return (IDALS_LMEM_NULL);
}
Expand All @@ -342,7 +342,7 @@ int IDABBDPrecReInit(void* ida_mem, sunindextype mudq, sunindextype mldq,
/* Test if the preconditioner data is non-NULL */
if (idals_mem->pdata == NULL)
{
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, "IDASBBDPRE", "IDABBDPrecReInit",
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_PMEM_NULL);
return (IDALS_PMEM_NULL);
}
Expand Down Expand Up @@ -371,24 +371,24 @@ int IDABBDPrecGetWorkSpace(void* ida_mem, long int* lenrwBBDP, long int* leniwBB

if (ida_mem == NULL)
{
IDAProcessError(NULL, IDALS_MEM_NULL, "IDASBBDPRE",
"IDABBDPrecGetWorkSpace", MSGBBD_MEM_NULL);
IDAProcessError(NULL, IDALS_MEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_NULL);
return (IDALS_MEM_NULL);
}
IDA_mem = (IDAMem)ida_mem;

if (IDA_mem->ida_lmem == NULL)
{
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDASBBDPRE",
"IDABBDPrecGetWorkSpace", MSGBBD_LMEM_NULL);
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_LMEM_NULL);
return (IDALS_LMEM_NULL);
}
idals_mem = (IDALsMem)IDA_mem->ida_lmem;

if (idals_mem->pdata == NULL)
{
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, "IDASBBDPRE",
"IDABBDPrecGetWorkSpace", MSGBBD_PMEM_NULL);
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_PMEM_NULL);
return (IDALS_PMEM_NULL);
}
pdata = (IBBDPrecData)idals_mem->pdata;
Expand All @@ -408,24 +408,24 @@ int IDABBDPrecGetNumGfnEvals(void* ida_mem, long int* ngevalsBBDP)

if (ida_mem == NULL)
{
IDAProcessError(NULL, IDALS_MEM_NULL, "IDASBBDPRE",
"IDABBDPrecGetNumGfnEvals", MSGBBD_MEM_NULL);
IDAProcessError(NULL, IDALS_MEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_NULL);
return (IDALS_MEM_NULL);
}
IDA_mem = (IDAMem)ida_mem;

if (IDA_mem->ida_lmem == NULL)
{
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, "IDASBBDPRE",
"IDABBDPrecGetNumGfnEvals", MSGBBD_LMEM_NULL);
IDAProcessError(IDA_mem, IDALS_LMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_LMEM_NULL);
return (IDALS_LMEM_NULL);
}
idals_mem = (IDALsMem)IDA_mem->ida_lmem;

if (idals_mem->pdata == NULL)
{
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, "IDASBBDPRE",
"IDABBDPrecGetNumGfnEvals", MSGBBD_PMEM_NULL);
IDAProcessError(IDA_mem, IDALS_PMEM_NULL, __LINE__, __func__, __FILE__,
MSGBBD_PMEM_NULL);
return (IDALS_PMEM_NULL);
}
pdata = (IBBDPrecData)idals_mem->pdata;
Expand Down Expand Up @@ -485,7 +485,7 @@ static int IDABBDPrecSetup(sunrealtype tt, N_Vector yy, N_Vector yp,
pdata->tempv3, pdata->tempv4);
if (retval < 0)
{
IDAProcessError(IDA_mem, -1, "IDASBBDPRE", "IDABBDPrecSetup",
IDAProcessError(IDA_mem, -1, __LINE__, __func__, __FILE__,
MSGBBD_FUNC_FAILED);
return (-1);
}
Expand Down Expand Up @@ -739,7 +739,7 @@ int IDABBDPrecInitB(void* ida_mem, int which, sunindextype NlocalB,
/* Check if ida_mem is allright. */
if (ida_mem == NULL)
{
IDAProcessError(NULL, IDALS_MEM_NULL, "IDASBBDPRE", "IDABBDPrecInitB",
IDAProcessError(NULL, IDALS_MEM_NULL, __LINE__, __func__, __FILE__,
MSG_LS_IDAMEM_NULL);
return (IDALS_MEM_NULL);
}
Expand All @@ -748,7 +748,7 @@ int IDABBDPrecInitB(void* ida_mem, int which, sunindextype NlocalB,
/* Is ASA initialized? */
if (IDA_mem->ida_adjMallocDone == SUNFALSE)
{
IDAProcessError(IDA_mem, IDALS_NO_ADJ, "IDASBBDPRE", "IDABBDPrecInitB",
IDAProcessError(IDA_mem, IDALS_NO_ADJ, __LINE__, __func__, __FILE__,
MSG_LS_NO_ADJ);
return (IDALS_NO_ADJ);
}
Expand All @@ -757,7 +757,7 @@ int IDABBDPrecInitB(void* ida_mem, int which, sunindextype NlocalB,
/* Check the value of which */
if (which >= IDAADJ_mem->ia_nbckpbs)
{
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, "IDASBBDPRE", "IDABBDPrecInitB",
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, __LINE__, __func__, __FILE__,
MSG_LS_BAD_WHICH);
return (IDALS_ILL_INPUT);
}
Expand All @@ -784,7 +784,7 @@ int IDABBDPrecInitB(void* ida_mem, int which, sunindextype NlocalB,
idabbdB_mem = (IDABBDPrecDataB)malloc(sizeof(*idabbdB_mem));
if (idabbdB_mem == NULL)
{
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, "IDASBBDPRE", "IDABBDPrecInitB",
IDAProcessError(IDA_mem, IDALS_MEM_FAIL, __LINE__, __func__, __FILE__,
MSGBBD_MEM_FAIL);
return (IDALS_MEM_FAIL);
}
Expand Down Expand Up @@ -813,7 +813,7 @@ int IDABBDPrecReInitB(void* ida_mem, int which, sunindextype mudqB,
/* Check if ida_mem is allright. */
if (ida_mem == NULL)
{
IDAProcessError(NULL, IDALS_MEM_NULL, "IDASBBDPRE", "IDABBDPrecReInitB",
IDAProcessError(NULL, IDALS_MEM_NULL, __LINE__, __func__, __FILE__,
MSG_LS_IDAMEM_NULL);
return (IDALS_MEM_NULL);
}
Expand All @@ -822,7 +822,7 @@ int IDABBDPrecReInitB(void* ida_mem, int which, sunindextype mudqB,
/* Is ASA initialized? */
if (IDA_mem->ida_adjMallocDone == SUNFALSE)
{
IDAProcessError(IDA_mem, IDALS_NO_ADJ, "IDASBBDPRE", "IDABBDPrecReInitB",
IDAProcessError(IDA_mem, IDALS_NO_ADJ, __LINE__, __func__, __FILE__,
MSG_LS_NO_ADJ);
return (IDALS_NO_ADJ);
}
Expand All @@ -831,7 +831,7 @@ int IDABBDPrecReInitB(void* ida_mem, int which, sunindextype mudqB,
/* Check the value of which */
if (which >= IDAADJ_mem->ia_nbckpbs)
{
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, "IDASBBDPRE", "IDABBDPrecReInitB",
IDAProcessError(IDA_mem, IDALS_ILL_INPUT, __LINE__, __func__, __FILE__,
MSG_LS_BAD_WHICH);
return (IDALS_ILL_INPUT);
}
Expand Down Expand Up @@ -895,7 +895,7 @@ static int IDAAglocal(sunindextype NlocalB, sunrealtype tt, N_Vector yyB,
IDAADJ_mem->ia_ypTmp, NULL, NULL);
if (flag != IDA_SUCCESS)
{
IDAProcessError(IDA_mem, -1, "IDASBBDPRE", "IDAAglocal", MSGBBD_BAD_T);
IDAProcessError(IDA_mem, -1, __LINE__, __func__, __FILE__, MSGBBD_BAD_T);
return (-1);
}
}
Expand Down Expand Up @@ -937,7 +937,7 @@ static int IDAAgcomm(sunindextype NlocalB, sunrealtype tt, N_Vector yyB,
IDAADJ_mem->ia_ypTmp, NULL, NULL);
if (flag != IDA_SUCCESS)
{
IDAProcessError(IDA_mem, -1, "IDASBBDPRE", "IDAAgcomm", MSGBBD_BAD_T);
IDAProcessError(IDA_mem, -1, __LINE__, __func__, __FILE__, MSGBBD_BAD_T);
return (-1);
}
}
Expand Down
Loading