From 2e4a1007b54d0eb70d34e670ee4ee448e658bf6e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 6 Feb 2025 16:39:24 -0600 Subject: [PATCH 001/114] Initial implementation of command-line control over ARKODE inputs --- examples/arkode/C_serial/ark_analytic.c | 6 +- include/arkode/arkode.h | 4 + src/arkode/arkode_io.c | 342 ++++++++++++++++++++++++ 3 files changed, 351 insertions(+), 1 deletion(-) diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index d226f2a00b..9981408da6 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -62,7 +62,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype atol); /* Main Program */ -int main(void) +int main(int argc, char* argv[]) { /* general problem parameters */ sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ @@ -130,6 +130,10 @@ int main(void) flag = ARKodeSetLinear(arkode_mem, 0); if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } + /* Override any current settings with command-line options */ + flag = ARKodeSetFromCommandLine(arkode_mem, argc, argv); + if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } + /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); fprintf(UFID, "# t u\n"); diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index eec76a520a..a2c37affe1 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -214,6 +214,10 @@ typedef enum * Shared API routines * -------------------------- */ +/* Command-line control over ARKODE options */ +SUNDIALS_EXPORT int ARKodeSetFromCommandLine(void* arkode_mem, int argc, + char* argv[]); + /* Resize and Reset functions */ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, sunrealtype hscale, sunrealtype t0, diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index e26c76ab62..4a6b3e892f 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,347 @@ ARKODE optional input functions ===============================================================*/ +/*--------------------------------------------------------------- + ARKodeSetFromCommandLine: + + Parses the command line to control scalar-valued ARKODE options. + + (this leverages a few typedefs and static utility routines) + ---------------------------------------------------------------*/ +typedef int (*arkIntSetFn)(void*,int); +typedef int (*arkLongSetFn)(void*,long int); +typedef int (*arkRealSetFn)(void*,sunrealtype); +typedef int (*arkBoolSetFn)(void*); +static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], + const char* argtest, arkIntSetFn fname, + sunbooleantype *arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i], argtest) == 0) + { + int iarg = atoi(argv[++(*i)]); + if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[(*i)-1], argv[*i]); + return ARK_ILL_INPUT; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], + const char* argtest, arkLongSetFn fname, + sunbooleantype *arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i], argtest) == 0) + { + long int iarg = atol(argv[++(*i)]); + if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[(*i)-1], argv[*i]); + return ARK_ILL_INPUT; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], + const char* argtest, arkRealSetFn fname, + sunbooleantype *arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i], argtest) == 0) + { + sunrealtype rarg = atof(argv[++(*i)]); + if (fname((void*) ark_mem, rarg) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[(*i)-1], argv[*i]); + return ARK_ILL_INPUT; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +static int CheckAndSetBoolArg(ARKodeMem ark_mem, int *i, char *argv[], + const char* argtest, arkBoolSetFn fname, + sunbooleantype *arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i], argtest) == 0) + { + if (fname((void*) ark_mem) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", argv[*i]); + return ARK_ILL_INPUT; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Set list of integer command-line arguments, and the corresponding set routine */ + int num_int_keys = 15; + char* int_keys[] = {"arkode.order", + "arkode.interpolant_degree", + "arkode.linear", + "arkode.autonomous", + "arkode.deduce_implicit_rhs", + "arkode.lsetup_frequency", + "arkode.predictor_method", + "arkode.max_nonlin_iters", + "arkode.max_hnil_warns", + "arkode.interpolate_stop_time", + "arkode.max_num_constr_fails", + "arkode.adaptivity_adjustment", + "arkode.small_num_efails", + "arkode.max_err_test_fails", + "arkode.max_conv_fails"}; + arkIntSetFn int_set[] = {ARKodeSetOrder, + ARKodeSetInterpolantDegree, + ARKodeSetLinear, + ARKodeSetAutonomous, + ARKodeSetDeduceImplicitRhs, + ARKodeSetLSetupFrequency, + ARKodeSetPredictorMethod, + ARKodeSetMaxNonlinIters, + ARKodeSetMaxHnilWarns, + ARKodeSetInterpolateStopTime, + ARKodeSetMaxNumConstrFails, + ARKodeSetAdaptivityAdjustment, + ARKodeSetSmallNumEFails, + ARKodeSetMaxErrTestFails, + ARKodeSetMaxConvFails}; + + int num_long_keys = 1; + char* long_keys[] = {"arkode.max_num_steps"}; + arkLongSetFn long_set[] = {ARKodeSetMaxNumSteps}; + + int num_real_keys = 18; + char* real_keys[] = {"arkode.nonlin_crdown", + "arkode.nonlin_rdiv", + "arkode.delta_gamma_max", + "arkode.nonlin_conv_coef", + "arkode.init_step", + "arkode.min_step", + "arkode.max_step", + "arkode.stop_time", + "arkode.fixed_step", + "arkode.step_direction", + "arkode.cfl_fraction", + "arkode.safety_factor", + "arkode.error_bias", + "arkode.max_growth", + "arkode.min_reduction", + "arkode.max_first_growth", + "arkode.max_efail_growth", + "arkode.max_cfail_growth"}; + arkRealSetFn real_set[] = {ARKodeSetNonlinCRDown, + ARKodeSetNonlinRDiv, + ARKodeSetDeltaGammaMax, + ARKodeSetNonlinConvCoef, + ARKodeSetInitStep, + ARKodeSetMinStep, + ARKodeSetMaxStep, + ARKodeSetStopTime, + ARKodeSetFixedStep, + ARKodeSetStepDirection, + ARKodeSetCFLFraction, + ARKodeSetSafetyFactor, + ARKodeSetErrorBias, + ARKodeSetMaxGrowth, + ARKodeSetMinReduction, + ARKodeSetMaxFirstGrowth, + ARKodeSetMaxEFailGrowth, + ARKodeSetMaxCFailGrowth}; + + int num_bool_keys = 4; + char* bool_keys[] = {"arkode.nonlinear", + "arkode.clear_stop_time", + "arkode.no_inactive_root_warn", + "arkode.reset_accumulated_error"}; + arkBoolSetFn bool_set[] = {ARKodeSetNonlinear, + ARKodeClearStopTime, + ARKodeSetNoInactiveRootWarn, + ARKodeResetAccumulatedError}; + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with "arkode." */ + if (strncmp(argv[i], "arkode.", 7) != 0) { continue; } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + if (CheckAndSetIntArg(ark_mem, &i, argv, int_keys[j], + int_set[j], &arg_used) != ARK_SUCCESS) + { + return ARK_ILL_INPUT; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + if (CheckAndSetLongArg(ark_mem, &i, argv, long_keys[j], + long_set[j], &arg_used) != ARK_SUCCESS) + { + return ARK_ILL_INPUT; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + if (CheckAndSetRealArg(ark_mem, &i, argv, real_keys[j], + real_set[j], &arg_used) != ARK_SUCCESS) + { + return ARK_ILL_INPUT; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all bool command-line options */ + for (j = 0; j < num_bool_keys; j++) + { + if (CheckAndSetBoolArg(ark_mem, &i, argv, bool_keys[j], + bool_set[j], &arg_used) != ARK_SUCCESS) + { + return ARK_ILL_INPUT; + } + if (arg_used) break; + } + if (arg_used) continue; + + /*** handle all remaining command-line options ***/ + + if (strcmp(argv[i], "arkode.interpolant_type") == 0) + { + i++; + retval = 1; + if (strcmp(argv[i], "ARK_INTERP_HERMITE") == 0) + { + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); + } + else if (strcmp(argv[i], "ARK_INTERP_LAGRANGE") == 0) + { + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + } + else if (strcmp(argv[i], "ARK_INTERP_NONE") == 0) + { + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_NONE); + } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[i-1], argv[i]); + return ARK_ILL_INPUT; + } + arg_used = SUNTRUE; + continue; + } + + if (strcmp(argv[i], "arkode.tolerances") == 0) + { + sunrealtype rtol = atof(argv[++i]); + sunrealtype atol = atof(argv[++i]); + retval = ARKodeSStolerances(arkode_mem, rtol, atol); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s %s", + argv[i-2], argv[i-1], argv[i]); + return ARK_ILL_INPUT; + } + arg_used = SUNTRUE; + continue; + } + + if (strcmp(argv[i], "arkode.fixed_step_bounds") == 0) + { + sunrealtype lb = atof(argv[++i]); + sunrealtype ub = atof(argv[++i]); + retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s %s", + argv[i-2], argv[i-1], argv[i]); + return ARK_ILL_INPUT; + } + arg_used = SUNTRUE; + continue; + } + + if (strcmp(argv[i], "arkode.accum_error_type") == 0) + { + i++; + retval = 1; + if (strcmp(argv[i], "ARK_ACCUMERROR_NONE") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); + } + else if (strcmp(argv[i], "ARK_ACCUMERROR_MAX") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_MAX); + } + else if (strcmp(argv[i], "ARK_ACCUMERROR_SUM") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_SUM); + } + else if (strcmp(argv[i], "ARK_ACCUMERROR_AVG") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_AVG); + } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[i-1], argv[i]); + return ARK_ILL_INPUT; + } + arg_used = SUNTRUE; + continue; + } + + /* warn for uninterpreted arkode.X arguments */ + arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- ARKodeSetDefaults: From 4ee0cede1bc208ecb7bbae15c035f5d8cf3b52a2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 6 Feb 2025 16:57:50 -0600 Subject: [PATCH 002/114] Added const qualifier --- src/arkode/arkode_io.c | 76 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 4a6b3e892f..308f33515e 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -137,21 +137,21 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* Set list of integer command-line arguments, and the corresponding set routine */ int num_int_keys = 15; - char* int_keys[] = {"arkode.order", - "arkode.interpolant_degree", - "arkode.linear", - "arkode.autonomous", - "arkode.deduce_implicit_rhs", - "arkode.lsetup_frequency", - "arkode.predictor_method", - "arkode.max_nonlin_iters", - "arkode.max_hnil_warns", - "arkode.interpolate_stop_time", - "arkode.max_num_constr_fails", - "arkode.adaptivity_adjustment", - "arkode.small_num_efails", - "arkode.max_err_test_fails", - "arkode.max_conv_fails"}; + const char* int_keys[] = {"arkode.order", + "arkode.interpolant_degree", + "arkode.linear", + "arkode.autonomous", + "arkode.deduce_implicit_rhs", + "arkode.lsetup_frequency", + "arkode.predictor_method", + "arkode.max_nonlin_iters", + "arkode.max_hnil_warns", + "arkode.interpolate_stop_time", + "arkode.max_num_constr_fails", + "arkode.adaptivity_adjustment", + "arkode.small_num_efails", + "arkode.max_err_test_fails", + "arkode.max_conv_fails"}; arkIntSetFn int_set[] = {ARKodeSetOrder, ARKodeSetInterpolantDegree, ARKodeSetLinear, @@ -169,28 +169,28 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) ARKodeSetMaxConvFails}; int num_long_keys = 1; - char* long_keys[] = {"arkode.max_num_steps"}; + const char* long_keys[] = {"arkode.max_num_steps"}; arkLongSetFn long_set[] = {ARKodeSetMaxNumSteps}; int num_real_keys = 18; - char* real_keys[] = {"arkode.nonlin_crdown", - "arkode.nonlin_rdiv", - "arkode.delta_gamma_max", - "arkode.nonlin_conv_coef", - "arkode.init_step", - "arkode.min_step", - "arkode.max_step", - "arkode.stop_time", - "arkode.fixed_step", - "arkode.step_direction", - "arkode.cfl_fraction", - "arkode.safety_factor", - "arkode.error_bias", - "arkode.max_growth", - "arkode.min_reduction", - "arkode.max_first_growth", - "arkode.max_efail_growth", - "arkode.max_cfail_growth"}; + const char* real_keys[] = {"arkode.nonlin_crdown", + "arkode.nonlin_rdiv", + "arkode.delta_gamma_max", + "arkode.nonlin_conv_coef", + "arkode.init_step", + "arkode.min_step", + "arkode.max_step", + "arkode.stop_time", + "arkode.fixed_step", + "arkode.step_direction", + "arkode.cfl_fraction", + "arkode.safety_factor", + "arkode.error_bias", + "arkode.max_growth", + "arkode.min_reduction", + "arkode.max_first_growth", + "arkode.max_efail_growth", + "arkode.max_cfail_growth"}; arkRealSetFn real_set[] = {ARKodeSetNonlinCRDown, ARKodeSetNonlinRDiv, ARKodeSetDeltaGammaMax, @@ -211,10 +211,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) ARKodeSetMaxCFailGrowth}; int num_bool_keys = 4; - char* bool_keys[] = {"arkode.nonlinear", - "arkode.clear_stop_time", - "arkode.no_inactive_root_warn", - "arkode.reset_accumulated_error"}; + const char* bool_keys[] = {"arkode.nonlinear", + "arkode.clear_stop_time", + "arkode.no_inactive_root_warn", + "arkode.reset_accumulated_error"}; arkBoolSetFn bool_set[] = {ARKodeSetNonlinear, ARKodeClearStopTime, ARKodeSetNoInactiveRootWarn, From 7fe32c780b69f7a9afb7ba35534bacfeeb93639f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 25 Feb 2025 08:50:59 -0600 Subject: [PATCH 003/114] Apply suggestions from code review Co-authored-by: Steven Roberts --- include/arkode/arkode.h | 2 +- src/arkode/arkode_io.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index a2c37affe1..847349f553 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -216,7 +216,7 @@ typedef enum /* Command-line control over ARKODE options */ SUNDIALS_EXPORT int ARKodeSetFromCommandLine(void* arkode_mem, int argc, - char* argv[]); + const char* argv[]); /* Resize and Reset functions */ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 308f33515e..f896be8a50 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -226,7 +226,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) sunbooleantype arg_used = SUNFALSE; /* skip command-line arguments that do not begin with "arkode." */ - if (strncmp(argv[i], "arkode.", 7) != 0) { continue; } + static const char *prefix = "arkode."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) @@ -281,7 +282,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) if (strcmp(argv[i], "arkode.interpolant_type") == 0) { i++; - retval = 1; + retval = ARK_ILL_INPUT; if (strcmp(argv[i], "ARK_INTERP_HERMITE") == 0) { retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); From 567d88524e7987b0b4ef95130d0b926d412f87d2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 25 Feb 2025 09:04:31 -0600 Subject: [PATCH 004/114] Additional updates based on PR feedback --- src/arkode/arkode_io.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index f896be8a50..dce63d3618 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -45,7 +45,7 @@ typedef int (*arkIntSetFn)(void*,int); typedef int (*arkLongSetFn)(void*,long int); typedef int (*arkRealSetFn)(void*,sunrealtype); -typedef int (*arkBoolSetFn)(void*); +typedef int (*arkActionSetFn)(void*); static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], const char* argtest, arkIntSetFn fname, sunbooleantype *arg_used) @@ -53,7 +53,8 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], *arg_used = SUNFALSE; if (strcmp(argv[*i], argtest) == 0) { - int iarg = atoi(argv[++(*i)]); + int iarg = atoi(argv[*i]); + (*i) += 1; if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -106,9 +107,9 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetBoolArg(ARKodeMem ark_mem, int *i, char *argv[], - const char* argtest, arkBoolSetFn fname, - sunbooleantype *arg_used) +static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], + const char* argtest, arkActionSetFn fname, + sunbooleantype *arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i], argtest) == 0) @@ -124,7 +125,7 @@ static int CheckAndSetBoolArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) +int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -210,15 +211,15 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) ARKodeSetMaxEFailGrowth, ARKodeSetMaxCFailGrowth}; - int num_bool_keys = 4; - const char* bool_keys[] = {"arkode.nonlinear", - "arkode.clear_stop_time", - "arkode.no_inactive_root_warn", - "arkode.reset_accumulated_error"}; - arkBoolSetFn bool_set[] = {ARKodeSetNonlinear, - ARKodeClearStopTime, - ARKodeSetNoInactiveRootWarn, - ARKodeResetAccumulatedError}; + int num_action_keys = 4; + const char* action_keys[] = {"arkode.nonlinear", + "arkode.clear_stop_time", + "arkode.no_inactive_root_warn", + "arkode.reset_accumulated_error"}; + arkActionSetFn action_set[] = {ARKodeSetNonlinear, + ARKodeClearStopTime, + ARKodeSetNoInactiveRootWarn, + ARKodeResetAccumulatedError}; int i, j, retval; for (i = 1; i < argc; i++) @@ -265,11 +266,11 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) } if (arg_used) continue; - /* check all bool command-line options */ - for (j = 0; j < num_bool_keys; j++) + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) { - if (CheckAndSetBoolArg(ark_mem, &i, argv, bool_keys[j], - bool_set[j], &arg_used) != ARK_SUCCESS) + if (CheckAndSetActionArg(ark_mem, &i, argv, action_keys[j], + action_set[j], &arg_used) != ARK_SUCCESS) { return ARK_ILL_INPUT; } @@ -306,7 +307,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) continue; } - if (strcmp(argv[i], "arkode.tolerances") == 0) + if (strcmp(argv[i], "arkode.scalar_tolerances") == 0) { sunrealtype rtol = atof(argv[++i]); sunrealtype atol = atof(argv[++i]); From 834be7726ad5e5e3828c82d1cf87c5dca7e0729d Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 25 Feb 2025 09:14:18 -0600 Subject: [PATCH 005/114] Added const for char* argv[] to subsidiary functions --- src/arkode/arkode_io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index dce63d3618..7aed5ef29d 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -46,7 +46,7 @@ typedef int (*arkIntSetFn)(void*,int); typedef int (*arkLongSetFn)(void*,long int); typedef int (*arkRealSetFn)(void*,sunrealtype); typedef int (*arkActionSetFn)(void*); -static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, const char *argv[], const char* argtest, arkIntSetFn fname, sunbooleantype *arg_used) { @@ -67,7 +67,7 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, const char *argv[], const char* argtest, arkLongSetFn fname, sunbooleantype *arg_used) { @@ -87,7 +87,7 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, const char *argv[], const char* argtest, arkRealSetFn fname, sunbooleantype *arg_used) { @@ -107,7 +107,7 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, const char *argv[], const char* argtest, arkActionSetFn fname, sunbooleantype *arg_used) { From 843b24067f458676023ae9e605a8bd115e24a7b6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 11:52:20 -0600 Subject: [PATCH 006/114] Converted separate arrays to arrays of structs --- src/arkode/arkode_io.c | 158 ++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 87 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 7aed5ef29d..03bc193d93 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -43,9 +43,25 @@ (this leverages a few typedefs and static utility routines) ---------------------------------------------------------------*/ typedef int (*arkIntSetFn)(void*,int); +struct arkKeyIntPair { + const char* key; + arkIntSetFn set; +}; typedef int (*arkLongSetFn)(void*,long int); +struct arkKeyLongPair { + const char* key; + arkLongSetFn set; +}; typedef int (*arkRealSetFn)(void*,sunrealtype); +struct arkKeyRealPair { + const char* key; + arkRealSetFn set; +}; typedef int (*arkActionSetFn)(void*); +struct arkKeyActionPair { + const char* key; + arkActionSetFn set; +}; static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, const char *argv[], const char* argtest, arkIntSetFn fname, sunbooleantype *arg_used) @@ -53,8 +69,8 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, const char *argv[], *arg_used = SUNFALSE; if (strcmp(argv[*i], argtest) == 0) { - int iarg = atoi(argv[*i]); (*i) += 1; + int iarg = atoi(argv[*i]); if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -74,7 +90,8 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, const char *argv[], *arg_used = SUNFALSE; if (strcmp(argv[*i], argtest) == 0) { - long int iarg = atol(argv[++(*i)]); + (*i) += 1; + long int iarg = atol(argv[*i]); if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -94,7 +111,8 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, const char *argv[], *arg_used = SUNFALSE; if (strcmp(argv[*i], argtest) == 0) { - sunrealtype rarg = atof(argv[++(*i)]); + (*i) += 1; + sunrealtype rarg = atof(argv[*i]); if (fname((void*) ark_mem, rarg) != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -137,89 +155,55 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) ark_mem = (ARKodeMem)arkode_mem; /* Set list of integer command-line arguments, and the corresponding set routine */ + static struct arkKeyIntPair int_pairs[] = + {{"arkode.order", ARKodeSetOrder}, + {"arkode.interpolant_degree", ARKodeSetInterpolantDegree}, + {"arkode.linear", ARKodeSetLinear}, + {"arkode.autonomous", ARKodeSetAutonomous}, + {"arkode.deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, + {"arkode.lsetup_frequency", ARKodeSetLSetupFrequency}, + {"arkode.predictor_method", ARKodeSetPredictorMethod}, + {"arkode.max_nonlin_iters", ARKodeSetMaxNonlinIters}, + {"arkode.max_hnil_warns", ARKodeSetMaxHnilWarns}, + {"arkode.interpolate_stop_time", ARKodeSetInterpolateStopTime}, + {"arkode.max_num_constr_fails", ARKodeSetMaxNumConstrFails}, + {"arkode.adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, + {"arkode.small_num_efails", ARKodeSetSmallNumEFails}, + {"arkode.max_err_test_fails", ARKodeSetMaxErrTestFails}, + {"arkode.max_conv_fails", ARKodeSetMaxConvFails}}; int num_int_keys = 15; - const char* int_keys[] = {"arkode.order", - "arkode.interpolant_degree", - "arkode.linear", - "arkode.autonomous", - "arkode.deduce_implicit_rhs", - "arkode.lsetup_frequency", - "arkode.predictor_method", - "arkode.max_nonlin_iters", - "arkode.max_hnil_warns", - "arkode.interpolate_stop_time", - "arkode.max_num_constr_fails", - "arkode.adaptivity_adjustment", - "arkode.small_num_efails", - "arkode.max_err_test_fails", - "arkode.max_conv_fails"}; - arkIntSetFn int_set[] = {ARKodeSetOrder, - ARKodeSetInterpolantDegree, - ARKodeSetLinear, - ARKodeSetAutonomous, - ARKodeSetDeduceImplicitRhs, - ARKodeSetLSetupFrequency, - ARKodeSetPredictorMethod, - ARKodeSetMaxNonlinIters, - ARKodeSetMaxHnilWarns, - ARKodeSetInterpolateStopTime, - ARKodeSetMaxNumConstrFails, - ARKodeSetAdaptivityAdjustment, - ARKodeSetSmallNumEFails, - ARKodeSetMaxErrTestFails, - ARKodeSetMaxConvFails}; + static struct arkKeyLongPair long_pairs[] = + {{"arkode.max_num_steps", ARKodeSetMaxNumSteps}}; int num_long_keys = 1; - const char* long_keys[] = {"arkode.max_num_steps"}; - arkLongSetFn long_set[] = {ARKodeSetMaxNumSteps}; + static struct arkKeyRealPair real_pairs[] = + {{"arkode.nonlin_crdown", ARKodeSetNonlinCRDown}, + {"arkode.nonlin_rdiv", ARKodeSetNonlinRDiv}, + {"arkode.delta_gamma_max", ARKodeSetDeltaGammaMax}, + {"arkode.nonlin_conv_coef", ARKodeSetNonlinConvCoef}, + {"arkode.init_step", ARKodeSetInitStep}, + {"arkode.min_step", ARKodeSetMinStep}, + {"arkode.max_step", ARKodeSetMaxStep}, + {"arkode.stop_time", ARKodeSetStopTime}, + {"arkode.fixed_step", ARKodeSetFixedStep}, + {"arkode.step_direction", ARKodeSetStepDirection}, + {"arkode.cfl_fraction", ARKodeSetCFLFraction}, + {"arkode.safety_factor", ARKodeSetSafetyFactor}, + {"arkode.error_bias", ARKodeSetErrorBias}, + {"arkode.max_growth", ARKodeSetMaxGrowth}, + {"arkode.min_reduction", ARKodeSetMinReduction}, + {"arkode.max_first_growth", ARKodeSetMaxFirstGrowth}, + {"arkode.max_efail_growth", ARKodeSetMaxEFailGrowth}, + {"arkode.max_cfail_growth", ARKodeSetMaxCFailGrowth}}; int num_real_keys = 18; - const char* real_keys[] = {"arkode.nonlin_crdown", - "arkode.nonlin_rdiv", - "arkode.delta_gamma_max", - "arkode.nonlin_conv_coef", - "arkode.init_step", - "arkode.min_step", - "arkode.max_step", - "arkode.stop_time", - "arkode.fixed_step", - "arkode.step_direction", - "arkode.cfl_fraction", - "arkode.safety_factor", - "arkode.error_bias", - "arkode.max_growth", - "arkode.min_reduction", - "arkode.max_first_growth", - "arkode.max_efail_growth", - "arkode.max_cfail_growth"}; - arkRealSetFn real_set[] = {ARKodeSetNonlinCRDown, - ARKodeSetNonlinRDiv, - ARKodeSetDeltaGammaMax, - ARKodeSetNonlinConvCoef, - ARKodeSetInitStep, - ARKodeSetMinStep, - ARKodeSetMaxStep, - ARKodeSetStopTime, - ARKodeSetFixedStep, - ARKodeSetStepDirection, - ARKodeSetCFLFraction, - ARKodeSetSafetyFactor, - ARKodeSetErrorBias, - ARKodeSetMaxGrowth, - ARKodeSetMinReduction, - ARKodeSetMaxFirstGrowth, - ARKodeSetMaxEFailGrowth, - ARKodeSetMaxCFailGrowth}; + static struct arkKeyActionPair action_pairs[] = + {{"arkode.nonlinear", ARKodeSetNonlinear}, + {"arkode.clear_stop_time", ARKodeClearStopTime}, + {"arkode.no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, + {"arkode.reset_accumulated_error", ARKodeResetAccumulatedError}}; int num_action_keys = 4; - const char* action_keys[] = {"arkode.nonlinear", - "arkode.clear_stop_time", - "arkode.no_inactive_root_warn", - "arkode.reset_accumulated_error"}; - arkActionSetFn action_set[] = {ARKodeSetNonlinear, - ARKodeClearStopTime, - ARKodeSetNoInactiveRootWarn, - ARKodeResetAccumulatedError}; int i, j, retval; for (i = 1; i < argc; i++) @@ -233,8 +217,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - if (CheckAndSetIntArg(ark_mem, &i, argv, int_keys[j], - int_set[j], &arg_used) != ARK_SUCCESS) + if (CheckAndSetIntArg(ark_mem, &i, argv, int_pairs[j].key, + int_pairs[j].set, &arg_used) != ARK_SUCCESS) { return ARK_ILL_INPUT; } @@ -245,8 +229,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - if (CheckAndSetLongArg(ark_mem, &i, argv, long_keys[j], - long_set[j], &arg_used) != ARK_SUCCESS) + if (CheckAndSetLongArg(ark_mem, &i, argv, long_pairs[j].key, + long_pairs[j].set, &arg_used) != ARK_SUCCESS) { return ARK_ILL_INPUT; } @@ -257,8 +241,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - if (CheckAndSetRealArg(ark_mem, &i, argv, real_keys[j], - real_set[j], &arg_used) != ARK_SUCCESS) + if (CheckAndSetRealArg(ark_mem, &i, argv, real_pairs[j].key, + real_pairs[j].set, &arg_used) != ARK_SUCCESS) { return ARK_ILL_INPUT; } @@ -269,8 +253,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - if (CheckAndSetActionArg(ark_mem, &i, argv, action_keys[j], - action_set[j], &arg_used) != ARK_SUCCESS) + if (CheckAndSetActionArg(ark_mem, &i, argv, action_pairs[j].key, + action_pairs[j].set, &arg_used) != ARK_SUCCESS) { return ARK_ILL_INPUT; } From 81da9180f2926554ba0cfede880449c6df7d7630 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 12:17:42 -0600 Subject: [PATCH 007/114] Removed const decorator from argv inputs to ARKodeSetFromCommandLine, since that causes compilation warnings/errors because main() uses char* argv[]. --- include/arkode/arkode.h | 2 +- src/arkode/arkode_io.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 847349f553..a2c37affe1 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -216,7 +216,7 @@ typedef enum /* Command-line control over ARKODE options */ SUNDIALS_EXPORT int ARKodeSetFromCommandLine(void* arkode_mem, int argc, - const char* argv[]); + char* argv[]); /* Resize and Reset functions */ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 03bc193d93..cd6ae7d078 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -62,7 +62,7 @@ struct arkKeyActionPair { const char* key; arkActionSetFn set; }; -static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, const char *argv[], +static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], const char* argtest, arkIntSetFn fname, sunbooleantype *arg_used) { @@ -83,7 +83,7 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, const char *argv[], return ARK_SUCCESS; } -static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, const char *argv[], +static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], const char* argtest, arkLongSetFn fname, sunbooleantype *arg_used) { @@ -104,7 +104,7 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, const char *argv[], return ARK_SUCCESS; } -static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, const char *argv[], +static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], const char* argtest, arkRealSetFn fname, sunbooleantype *arg_used) { @@ -125,7 +125,7 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, const char *argv[], return ARK_SUCCESS; } -static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, const char *argv[], +static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], const char* argtest, arkActionSetFn fname, sunbooleantype *arg_used) { @@ -143,7 +143,7 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, const char *argv[], return ARK_SUCCESS; } -int ARKodeSetFromCommandLine(void* arkode_mem, int argc, const char* argv[]) +int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) From ccb3a0dba3a99154c86da4a1124c6c24f58cce25 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 12:21:10 -0600 Subject: [PATCH 008/114] Updated swig interfaces --- src/arkode/fmod_int32/farkode_mod.c | 45 ++++++++++++++++-------- src/arkode/fmod_int32/farkode_mod.f90 | 50 ++++++++++++++++++++++----- src/arkode/fmod_int64/farkode_mod.c | 45 ++++++++++++++++-------- src/arkode/fmod_int64/farkode_mod.f90 | 50 ++++++++++++++++++++++----- 4 files changed, 146 insertions(+), 44 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index cf23905ff6..66a7d0fb55 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -242,6 +242,20 @@ enum { #include "arkode/arkode_ls.h" +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include #ifdef _MSC_VER # ifndef strtoull @@ -270,20 +284,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,6 +315,23 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } +SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, int const *farg2, SwigClassWrapper const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + char **arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + SWIG_check_mutable(*farg3, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,int,char *[])", return 0); + arg3 = (char **)(farg3->cptr); + result = (int)ARKodeSetFromCommandLine(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 6aa2552cd8..ed0f0649a6 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -115,6 +115,18 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FARKodeSetFromCommandLine public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -268,14 +280,6 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -479,6 +483,17 @@ module farkode_mod ! WRAPPER DECLARATIONS interface +function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(SwigClassWrapper) :: farg3 +integer(C_INT) :: fresult +end function + function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2462,6 +2477,25 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS +function FARKodeSetFromCommandLine(arkode_mem, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg3 + +farg1 = arkode_mem +farg2 = argc +farg3 = argv%swigdata +fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) +swig_result = fresult +end function + function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 0c4024af1f..500ded761e 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -242,6 +242,20 @@ enum { #include "arkode/arkode_ls.h" +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include #ifdef _MSC_VER # ifndef strtoull @@ -270,20 +284,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,6 +315,23 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } +SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, int const *farg2, SwigClassWrapper const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + char **arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + SWIG_check_mutable(*farg3, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,int,char *[])", return 0); + arg3 = (char **)(farg3->cptr); + result = (int)ARKodeSetFromCommandLine(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index f29b57f5c3..2195b9604b 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -115,6 +115,18 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FARKodeSetFromCommandLine public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -268,14 +280,6 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -479,6 +483,17 @@ module farkode_mod ! WRAPPER DECLARATIONS interface +function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +type(SwigClassWrapper) :: farg3 +integer(C_INT) :: fresult +end function + function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2462,6 +2477,25 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS +function FARKodeSetFromCommandLine(arkode_mem, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(SwigClassWrapper) :: farg3 + +farg1 = arkode_mem +farg2 = argc +farg3 = argv%swigdata +fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) +swig_result = fresult +end function + function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 3ff15742414cd28cb85cb28fc5393338f7868a24 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 12:37:47 -0600 Subject: [PATCH 009/114] Updated handling of errors when setting command-line arguments --- src/arkode/arkode_io.c | 80 ++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index cd6ae7d078..c1dd3f053d 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -71,12 +71,13 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], { (*i) += 1; int iarg = atoi(argv[*i]); - if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) + int retval = fname((void*) ark_mem, iarg); + if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", argv[(*i)-1], argv[*i]); - return ARK_ILL_INPUT; + return retval; } *arg_used = SUNTRUE; } @@ -92,12 +93,13 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], { (*i) += 1; long int iarg = atol(argv[*i]); - if (fname((void*) ark_mem, iarg) != ARK_SUCCESS) + int retval = fname((void*) ark_mem, iarg); + if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", argv[(*i)-1], argv[*i]); - return ARK_ILL_INPUT; + return retval; } *arg_used = SUNTRUE; } @@ -113,12 +115,13 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], { (*i) += 1; sunrealtype rarg = atof(argv[*i]); - if (fname((void*) ark_mem, rarg) != ARK_SUCCESS) + int retval = fname((void*) ark_mem, rarg); + if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", argv[(*i)-1], argv[*i]); - return ARK_ILL_INPUT; + return retval; } *arg_used = SUNTRUE; } @@ -132,11 +135,12 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], *arg_used = SUNFALSE; if (strcmp(argv[*i], argtest) == 0) { - if (fname((void*) ark_mem) != ARK_SUCCESS) + int retval = fname((void*) ark_mem); + if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", argv[*i]); - return ARK_ILL_INPUT; + return retval; } *arg_used = SUNTRUE; } @@ -217,11 +221,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - if (CheckAndSetIntArg(ark_mem, &i, argv, int_pairs[j].key, - int_pairs[j].set, &arg_used) != ARK_SUCCESS) - { - return ARK_ILL_INPUT; - } + retval = CheckAndSetIntArg(ark_mem, &i, argv, int_pairs[j].key, + int_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } if (arg_used) continue; @@ -229,11 +231,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - if (CheckAndSetLongArg(ark_mem, &i, argv, long_pairs[j].key, - long_pairs[j].set, &arg_used) != ARK_SUCCESS) - { - return ARK_ILL_INPUT; - } + retval = CheckAndSetLongArg(ark_mem, &i, argv, long_pairs[j].key, + long_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } if (arg_used) continue; @@ -241,11 +241,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - if (CheckAndSetRealArg(ark_mem, &i, argv, real_pairs[j].key, - real_pairs[j].set, &arg_used) != ARK_SUCCESS) - { - return ARK_ILL_INPUT; - } + retval = CheckAndSetRealArg(ark_mem, &i, argv, real_pairs[j].key, + real_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } if (arg_used) continue; @@ -253,11 +251,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - if (CheckAndSetActionArg(ark_mem, &i, argv, action_pairs[j].key, - action_pairs[j].set, &arg_used) != ARK_SUCCESS) - { - return ARK_ILL_INPUT; - } + retval = CheckAndSetActionArg(ark_mem, &i, argv, action_pairs[j].key, + action_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } if (arg_used) continue; @@ -282,10 +278,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) } if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", argv[i-1], argv[i]); - return ARK_ILL_INPUT; + return retval; } arg_used = SUNTRUE; continue; @@ -298,10 +294,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) retval = ARKodeSStolerances(arkode_mem, rtol, atol); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s %s", argv[i-2], argv[i-1], argv[i]); - return ARK_ILL_INPUT; + return retval; } arg_used = SUNTRUE; continue; @@ -314,10 +310,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s %s", argv[i-2], argv[i-1], argv[i]); - return ARK_ILL_INPUT; + return retval; } arg_used = SUNTRUE; continue; @@ -326,7 +322,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) if (strcmp(argv[i], "arkode.accum_error_type") == 0) { i++; - retval = 1; + retval = ARK_ILL_INPUT; if (strcmp(argv[i], "ARK_ACCUMERROR_NONE") == 0) { retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); @@ -345,10 +341,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) } if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", argv[i-1], argv[i]); - return ARK_ILL_INPUT; + return retval; } arg_used = SUNTRUE; continue; @@ -1718,7 +1714,7 @@ int ARKodeSetNoInactiveRootWarn(void* arkode_mem) if (ark_mem->root_mem == NULL) { arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); + MSG_ARK_NO_ROOT); return (ARK_MEM_NULL); } ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; From 5697de0744ae59dc54fe86ad6c44f25b586dcb66 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 15:49:57 -0600 Subject: [PATCH 010/114] Updated ARKodeSetFromCommandLine to include an input 'arkid' that should be matched to process command-line arguments, which should support MRI and operator-splitting --- examples/arkode/C_serial/ark_analytic.c | 2 +- include/arkode/arkode.h | 4 +- src/arkode/arkode_io.c | 157 ++++++++++++++---------- 3 files changed, 92 insertions(+), 71 deletions(-) diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index 9981408da6..cd88fb3ba0 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Override any current settings with command-line options */ - flag = ARKodeSetFromCommandLine(arkode_mem, argc, argv); + flag = ARKodeSetFromCommandLine(arkode_mem, "", argc, argv); if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } /* Open output stream for results, output comment line */ diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index a2c37affe1..7ccf73f65b 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -215,8 +215,8 @@ typedef enum * -------------------------- */ /* Command-line control over ARKODE options */ -SUNDIALS_EXPORT int ARKodeSetFromCommandLine(void* arkode_mem, int argc, - char* argv[]); +SUNDIALS_EXPORT int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, + int argc, char* argv[]); /* Resize and Reset functions */ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index c1dd3f053d..5b34baa807 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -40,7 +40,7 @@ Parses the command line to control scalar-valued ARKODE options. - (this leverages a few typedefs and static utility routines) + (this leverages a multiple typedefs and static utility routines) ---------------------------------------------------------------*/ typedef int (*arkIntSetFn)(void*,int); struct arkKeyIntPair { @@ -63,11 +63,11 @@ struct arkKeyActionPair { arkActionSetFn set; }; static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], - const char* argtest, arkIntSetFn fname, - sunbooleantype *arg_used) + const int offset, const char* argtest, + arkIntSetFn fname, sunbooleantype *arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i], argtest) == 0) + if (strcmp(argv[*i]+offset, argtest) == 0) { (*i) += 1; int iarg = atoi(argv[*i]); @@ -85,11 +85,11 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], } static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], - const char* argtest, arkLongSetFn fname, - sunbooleantype *arg_used) + const int offset, const char* argtest, + arkLongSetFn fname, sunbooleantype *arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i], argtest) == 0) + if (strcmp(argv[*i]+offset, argtest) == 0) { (*i) += 1; long int iarg = atol(argv[*i]); @@ -107,11 +107,11 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], } static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], - const char* argtest, arkRealSetFn fname, - sunbooleantype *arg_used) + const int offset, const char* argtest, + arkRealSetFn fname, sunbooleantype *arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i], argtest) == 0) + if (strcmp(argv[*i]+offset, argtest) == 0) { (*i) += 1; sunrealtype rarg = atof(argv[*i]); @@ -129,11 +129,11 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], } static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], - const char* argtest, arkActionSetFn fname, - sunbooleantype *arg_used) + const int offset, const char* argtest, + arkActionSetFn fname, sunbooleantype *arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i], argtest) == 0) + if (strcmp(argv[*i]+offset, argtest) == 0) { int retval = fname((void*) ark_mem); if (retval != ARK_SUCCESS) @@ -147,7 +147,8 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) +int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, + int argc, char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -160,53 +161,53 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* Set list of integer command-line arguments, and the corresponding set routine */ static struct arkKeyIntPair int_pairs[] = - {{"arkode.order", ARKodeSetOrder}, - {"arkode.interpolant_degree", ARKodeSetInterpolantDegree}, - {"arkode.linear", ARKodeSetLinear}, - {"arkode.autonomous", ARKodeSetAutonomous}, - {"arkode.deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, - {"arkode.lsetup_frequency", ARKodeSetLSetupFrequency}, - {"arkode.predictor_method", ARKodeSetPredictorMethod}, - {"arkode.max_nonlin_iters", ARKodeSetMaxNonlinIters}, - {"arkode.max_hnil_warns", ARKodeSetMaxHnilWarns}, - {"arkode.interpolate_stop_time", ARKodeSetInterpolateStopTime}, - {"arkode.max_num_constr_fails", ARKodeSetMaxNumConstrFails}, - {"arkode.adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, - {"arkode.small_num_efails", ARKodeSetSmallNumEFails}, - {"arkode.max_err_test_fails", ARKodeSetMaxErrTestFails}, - {"arkode.max_conv_fails", ARKodeSetMaxConvFails}}; + {{"order", ARKodeSetOrder}, + {"interpolant_degree", ARKodeSetInterpolantDegree}, + {"linear", ARKodeSetLinear}, + {"autonomous", ARKodeSetAutonomous}, + {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, + {"lsetup_frequency", ARKodeSetLSetupFrequency}, + {"predictor_method", ARKodeSetPredictorMethod}, + {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, + {"max_hnil_warns", ARKodeSetMaxHnilWarns}, + {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, + {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, + {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, + {"small_num_efails", ARKodeSetSmallNumEFails}, + {"max_err_test_fails", ARKodeSetMaxErrTestFails}, + {"max_conv_fails", ARKodeSetMaxConvFails}}; int num_int_keys = 15; static struct arkKeyLongPair long_pairs[] = - {{"arkode.max_num_steps", ARKodeSetMaxNumSteps}}; + {{"max_num_steps", ARKodeSetMaxNumSteps}}; int num_long_keys = 1; static struct arkKeyRealPair real_pairs[] = - {{"arkode.nonlin_crdown", ARKodeSetNonlinCRDown}, - {"arkode.nonlin_rdiv", ARKodeSetNonlinRDiv}, - {"arkode.delta_gamma_max", ARKodeSetDeltaGammaMax}, - {"arkode.nonlin_conv_coef", ARKodeSetNonlinConvCoef}, - {"arkode.init_step", ARKodeSetInitStep}, - {"arkode.min_step", ARKodeSetMinStep}, - {"arkode.max_step", ARKodeSetMaxStep}, - {"arkode.stop_time", ARKodeSetStopTime}, - {"arkode.fixed_step", ARKodeSetFixedStep}, - {"arkode.step_direction", ARKodeSetStepDirection}, - {"arkode.cfl_fraction", ARKodeSetCFLFraction}, - {"arkode.safety_factor", ARKodeSetSafetyFactor}, - {"arkode.error_bias", ARKodeSetErrorBias}, - {"arkode.max_growth", ARKodeSetMaxGrowth}, - {"arkode.min_reduction", ARKodeSetMinReduction}, - {"arkode.max_first_growth", ARKodeSetMaxFirstGrowth}, - {"arkode.max_efail_growth", ARKodeSetMaxEFailGrowth}, - {"arkode.max_cfail_growth", ARKodeSetMaxCFailGrowth}}; + {{"nonlin_crdown", ARKodeSetNonlinCRDown}, + {"nonlin_rdiv", ARKodeSetNonlinRDiv}, + {"delta_gamma_max", ARKodeSetDeltaGammaMax}, + {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, + {"init_step", ARKodeSetInitStep}, + {"min_step", ARKodeSetMinStep}, + {"max_step", ARKodeSetMaxStep}, + {"stop_time", ARKodeSetStopTime}, + {"fixed_step", ARKodeSetFixedStep}, + {"step_direction", ARKodeSetStepDirection}, + {"cfl_fraction", ARKodeSetCFLFraction}, + {"safety_factor", ARKodeSetSafetyFactor}, + {"error_bias", ARKodeSetErrorBias}, + {"max_growth", ARKodeSetMaxGrowth}, + {"min_reduction", ARKodeSetMinReduction}, + {"max_first_growth", ARKodeSetMaxFirstGrowth}, + {"max_efail_growth", ARKodeSetMaxEFailGrowth}, + {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; int num_real_keys = 18; static struct arkKeyActionPair action_pairs[] = - {{"arkode.nonlinear", ARKodeSetNonlinear}, - {"arkode.clear_stop_time", ARKodeClearStopTime}, - {"arkode.no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, - {"arkode.reset_accumulated_error", ARKodeResetAccumulatedError}}; + {{"nonlinear", ARKodeSetNonlinear}, + {"clear_stop_time", ARKodeClearStopTime}, + {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, + {"reset_accumulated_error", ARKodeResetAccumulatedError}}; int num_action_keys = 4; int i, j, retval; @@ -218,11 +219,24 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) static const char *prefix = "arkode."; if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + /* set offset length to disregard for subsequent command-line tests */ + int offset = strlen(prefix); + + /* check against supplied arkid input: + if not supplied, then just process remaining text as a normal argument; + if supplied, verify that it matches the supplied arkid, and update offset */ + if (strlen(arkid) > 0) + { + if (strncmp(argv[i]+offset, arkid, strlen(arkid)) != 0) { continue; } + offset += strlen(arkid) + 1; + } + /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = CheckAndSetIntArg(ark_mem, &i, argv, int_pairs[j].key, - int_pairs[j].set, &arg_used); + retval = CheckAndSetIntArg(ark_mem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -231,8 +245,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = CheckAndSetLongArg(ark_mem, &i, argv, long_pairs[j].key, - long_pairs[j].set, &arg_used); + retval = CheckAndSetLongArg(ark_mem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -241,8 +256,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = CheckAndSetRealArg(ark_mem, &i, argv, real_pairs[j].key, - real_pairs[j].set, &arg_used); + retval = CheckAndSetRealArg(ark_mem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -251,8 +267,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = CheckAndSetActionArg(ark_mem, &i, argv, action_pairs[j].key, - action_pairs[j].set, &arg_used); + retval = CheckAndSetActionArg(ark_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -260,7 +277,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) /*** handle all remaining command-line options ***/ - if (strcmp(argv[i], "arkode.interpolant_type") == 0) + if (strcmp(argv[i]+offset, "interpolant_type") == 0) { i++; retval = ARK_ILL_INPUT; @@ -287,10 +304,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) continue; } - if (strcmp(argv[i], "arkode.scalar_tolerances") == 0) + if (strcmp(argv[i]+offset, "scalar_tolerances") == 0) { - sunrealtype rtol = atof(argv[++i]); - sunrealtype atol = atof(argv[++i]); + i++; + sunrealtype rtol = atof(argv[i]); + i++; + sunrealtype atol = atof(argv[i]); retval = ARKodeSStolerances(arkode_mem, rtol, atol); if (retval != ARK_SUCCESS) { @@ -303,10 +322,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) continue; } - if (strcmp(argv[i], "arkode.fixed_step_bounds") == 0) + if (strcmp(argv[i]+offset, "fixed_step_bounds") == 0) { - sunrealtype lb = atof(argv[++i]); - sunrealtype ub = atof(argv[++i]); + i++; + sunrealtype lb = atof(argv[i]); + i++; + sunrealtype ub = atof(argv[i]); retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); if (retval != ARK_SUCCESS) { @@ -319,7 +340,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, int argc, char* argv[]) continue; } - if (strcmp(argv[i], "arkode.accum_error_type") == 0) + if (strcmp(argv[i]+offset, "accum_error_type") == 0) { i++; retval = ARK_ILL_INPUT; From 229c013b4ff4befcfecde7263e46a9440e959cb6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 15:50:35 -0600 Subject: [PATCH 011/114] Updated swig interfaces --- src/arkode/fmod_int32/farkode_mod.c | 44 ++++++++--------- src/arkode/fmod_int32/farkode_mod.f90 | 68 +++++++++++++++------------ src/arkode/fmod_int64/farkode_mod.c | 44 ++++++++--------- src/arkode/fmod_int64/farkode_mod.f90 | 68 +++++++++++++++------------ 4 files changed, 120 insertions(+), 104 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index 66a7d0fb55..fd7662a5b5 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -242,20 +242,6 @@ enum { #include "arkode/arkode_ls.h" -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include #ifdef _MSC_VER # ifndef strtoull @@ -281,6 +267,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include @@ -315,18 +315,20 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } -SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, int const *farg2, SwigClassWrapper const *farg3) { +SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; - char **arg3 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - SWIG_check_mutable(*farg3, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,int,char *[])", return 0); - arg3 = (char **)(farg3->cptr); - result = (int)ARKodeSetFromCommandLine(arg1,arg2,arg3); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)ARKodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); fresult = (int)(result); return fresult; } diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index ed0f0649a6..037203f032 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -126,6 +126,10 @@ module farkode_mod type, public :: SWIGTYPE_p_p_char type(SwigClassWrapper), public :: swigdata end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FARKodeSetFromCommandLine public :: FARKodeResize public :: FARKodeReset @@ -204,10 +208,6 @@ module farkode_mod public :: FARKodeGetRootInfo public :: FARKodeGetUserData public :: FARKodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FARKodeGetReturnFlagName public :: FARKodeWriteParameters public :: FARKodeGetNumExpSteps @@ -483,14 +483,16 @@ module farkode_mod ! WRAPPER DECLARATIONS interface -function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) & +function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FARKodeSetFromCommandLine") & result(fresult) use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper import :: swigclasswrapper type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(SwigClassWrapper) :: farg3 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 integer(C_INT) :: fresult end function @@ -2477,22 +2479,44 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS -function FARKodeSetFromCommandLine(arkode_mem, argc, argv) & + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FARKodeSetFromCommandLine(arkode_mem, arkid, argc, argv) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: arkid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars integer(C_INT), intent(in) :: argc class(SWIGTYPE_p_p_char), intent(in) :: argv integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(SwigClassWrapper) :: farg3 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 farg1 = arkode_mem -farg2 = argc -farg3 = argv%swigdata -fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) +call SWIG_string_to_chararray(arkid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) swig_result = fresult end function @@ -5386,24 +5410,6 @@ function FARKodeButcherTable_LoadDIRK(imethod) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - function FARKodeButcherTable_LoadDIRKByName(imethod) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 500ded761e..6a1d14181e 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -242,20 +242,6 @@ enum { #include "arkode/arkode_ls.h" -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include #ifdef _MSC_VER # ifndef strtoull @@ -281,6 +267,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include @@ -315,18 +315,20 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } -SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, int const *farg2, SwigClassWrapper const *farg3) { +SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; - char **arg3 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - SWIG_check_mutable(*farg3, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,int,char *[])", return 0); - arg3 = (char **)(farg3->cptr); - result = (int)ARKodeSetFromCommandLine(arg1,arg2,arg3); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)ARKodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); fresult = (int)(result); return fresult; } diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 2195b9604b..60d949cf9b 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -126,6 +126,10 @@ module farkode_mod type, public :: SWIGTYPE_p_p_char type(SwigClassWrapper), public :: swigdata end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FARKodeSetFromCommandLine public :: FARKodeResize public :: FARKodeReset @@ -204,10 +208,6 @@ module farkode_mod public :: FARKodeGetRootInfo public :: FARKodeGetUserData public :: FARKodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FARKodeGetReturnFlagName public :: FARKodeWriteParameters public :: FARKodeGetNumExpSteps @@ -483,14 +483,16 @@ module farkode_mod ! WRAPPER DECLARATIONS interface -function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) & +function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FARKodeSetFromCommandLine") & result(fresult) use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper import :: swigclasswrapper type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(SwigClassWrapper) :: farg3 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 integer(C_INT) :: fresult end function @@ -2477,22 +2479,44 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS -function FARKodeSetFromCommandLine(arkode_mem, argc, argv) & + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FARKodeSetFromCommandLine(arkode_mem, arkid, argc, argv) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: arkid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars integer(C_INT), intent(in) :: argc class(SWIGTYPE_p_p_char), intent(in) :: argv integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -type(SwigClassWrapper) :: farg3 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 farg1 = arkode_mem -farg2 = argc -farg3 = argv%swigdata -fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3) +call SWIG_string_to_chararray(arkid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) swig_result = fresult end function @@ -5386,24 +5410,6 @@ function FARKodeButcherTable_LoadDIRK(imethod) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - function FARKodeButcherTable_LoadDIRKByName(imethod) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 6d55e2d63f75db26434cdf3c4bc11537d17ae060 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 15:52:11 -0600 Subject: [PATCH 012/114] Updated comment --- src/arkode/arkode_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 5b34baa807..baa1febd34 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -224,7 +224,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, /* check against supplied arkid input: if not supplied, then just process remaining text as a normal argument; - if supplied, verify that it matches the supplied arkid, and update offset */ + if supplied, verify that it matches the supplied arkid, and update offset + to trim both the arkid and the trailing "." */ if (strlen(arkid) > 0) { if (strncmp(argv[i]+offset, arkid, strlen(arkid)) != 0) { continue; } From f88f66beb9ae6124b787b8531a5bd7352e3d4f71 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 15:58:18 -0600 Subject: [PATCH 013/114] Updated formatting --- src/arkode/arkode_io.c | 173 ++++++++++++++++++++++------------------- 1 file changed, 91 insertions(+), 82 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index baa1febd34..65c5f8f5ef 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -42,41 +42,53 @@ (this leverages a multiple typedefs and static utility routines) ---------------------------------------------------------------*/ -typedef int (*arkIntSetFn)(void*,int); -struct arkKeyIntPair { +typedef int (*arkIntSetFn)(void*, int); + +struct arkKeyIntPair +{ const char* key; arkIntSetFn set; }; -typedef int (*arkLongSetFn)(void*,long int); -struct arkKeyLongPair { + +typedef int (*arkLongSetFn)(void*, long int); + +struct arkKeyLongPair +{ const char* key; arkLongSetFn set; }; -typedef int (*arkRealSetFn)(void*,sunrealtype); -struct arkKeyRealPair { + +typedef int (*arkRealSetFn)(void*, sunrealtype); + +struct arkKeyRealPair +{ const char* key; arkRealSetFn set; }; + typedef int (*arkActionSetFn)(void*); -struct arkKeyActionPair { + +struct arkKeyActionPair +{ const char* key; arkActionSetFn set; }; -static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], + +static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], const int offset, const char* argtest, - arkIntSetFn fname, sunbooleantype *arg_used) + arkIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i]+offset, argtest) == 0) + if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; - int iarg = atoi(argv[*i]); - int retval = fname((void*) ark_mem, iarg); + int iarg = atoi(argv[*i]); + int retval = fname((void*)ark_mem, iarg); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[(*i)-1], argv[*i]); + argv[(*i) - 1], argv[*i]); return retval; } *arg_used = SUNTRUE; @@ -84,21 +96,21 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], const int offset, const char* argtest, - arkLongSetFn fname, sunbooleantype *arg_used) + arkLongSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i]+offset, argtest) == 0) + if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; long int iarg = atol(argv[*i]); - int retval = fname((void*) ark_mem, iarg); + int retval = fname((void*)ark_mem, iarg); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[(*i)-1], argv[*i]); + argv[(*i) - 1], argv[*i]); return retval; } *arg_used = SUNTRUE; @@ -106,21 +118,21 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], const int offset, const char* argtest, - arkRealSetFn fname, sunbooleantype *arg_used) + arkRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i]+offset, argtest) == 0) + if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; sunrealtype rarg = atof(argv[*i]); - int retval = fname((void*) ark_mem, rarg); + int retval = fname((void*)ark_mem, rarg); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[(*i)-1], argv[*i]); + argv[(*i) - 1], argv[*i]); return retval; } *arg_used = SUNTRUE; @@ -128,14 +140,14 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], +static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], const int offset, const char* argtest, - arkActionSetFn fname, sunbooleantype *arg_used) + arkActionSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i]+offset, argtest) == 0) + if (strcmp(argv[*i] + offset, argtest) == 0) { - int retval = fname((void*) ark_mem); + int retval = fname((void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -147,8 +159,8 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int *i, char *argv[], return ARK_SUCCESS; } -int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, - int argc, char* argv[]) +int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, + char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -161,52 +173,52 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, /* Set list of integer command-line arguments, and the corresponding set routine */ static struct arkKeyIntPair int_pairs[] = - {{"order", ARKodeSetOrder}, - {"interpolant_degree", ARKodeSetInterpolantDegree}, - {"linear", ARKodeSetLinear}, - {"autonomous", ARKodeSetAutonomous}, - {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, - {"lsetup_frequency", ARKodeSetLSetupFrequency}, - {"predictor_method", ARKodeSetPredictorMethod}, - {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, - {"max_hnil_warns", ARKodeSetMaxHnilWarns}, + {{"order", ARKodeSetOrder}, + {"interpolant_degree", ARKodeSetInterpolantDegree}, + {"linear", ARKodeSetLinear}, + {"autonomous", ARKodeSetAutonomous}, + {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, + {"lsetup_frequency", ARKodeSetLSetupFrequency}, + {"predictor_method", ARKodeSetPredictorMethod}, + {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, + {"max_hnil_warns", ARKodeSetMaxHnilWarns}, {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, - {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, + {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, - {"small_num_efails", ARKodeSetSmallNumEFails}, - {"max_err_test_fails", ARKodeSetMaxErrTestFails}, - {"max_conv_fails", ARKodeSetMaxConvFails}}; + {"small_num_efails", ARKodeSetSmallNumEFails}, + {"max_err_test_fails", ARKodeSetMaxErrTestFails}, + {"max_conv_fails", ARKodeSetMaxConvFails}}; int num_int_keys = 15; - static struct arkKeyLongPair long_pairs[] = - {{"max_num_steps", ARKodeSetMaxNumSteps}}; + static struct arkKeyLongPair long_pairs[] = { + {"max_num_steps", ARKodeSetMaxNumSteps}}; int num_long_keys = 1; static struct arkKeyRealPair real_pairs[] = - {{"nonlin_crdown", ARKodeSetNonlinCRDown}, - {"nonlin_rdiv", ARKodeSetNonlinRDiv}, - {"delta_gamma_max", ARKodeSetDeltaGammaMax}, + {{"nonlin_crdown", ARKodeSetNonlinCRDown}, + {"nonlin_rdiv", ARKodeSetNonlinRDiv}, + {"delta_gamma_max", ARKodeSetDeltaGammaMax}, {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, - {"init_step", ARKodeSetInitStep}, - {"min_step", ARKodeSetMinStep}, - {"max_step", ARKodeSetMaxStep}, - {"stop_time", ARKodeSetStopTime}, - {"fixed_step", ARKodeSetFixedStep}, - {"step_direction", ARKodeSetStepDirection}, - {"cfl_fraction", ARKodeSetCFLFraction}, - {"safety_factor", ARKodeSetSafetyFactor}, - {"error_bias", ARKodeSetErrorBias}, - {"max_growth", ARKodeSetMaxGrowth}, - {"min_reduction", ARKodeSetMinReduction}, + {"init_step", ARKodeSetInitStep}, + {"min_step", ARKodeSetMinStep}, + {"max_step", ARKodeSetMaxStep}, + {"stop_time", ARKodeSetStopTime}, + {"fixed_step", ARKodeSetFixedStep}, + {"step_direction", ARKodeSetStepDirection}, + {"cfl_fraction", ARKodeSetCFLFraction}, + {"safety_factor", ARKodeSetSafetyFactor}, + {"error_bias", ARKodeSetErrorBias}, + {"max_growth", ARKodeSetMaxGrowth}, + {"min_reduction", ARKodeSetMinReduction}, {"max_first_growth", ARKodeSetMaxFirstGrowth}, {"max_efail_growth", ARKodeSetMaxEFailGrowth}, {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; int num_real_keys = 18; static struct arkKeyActionPair action_pairs[] = - {{"nonlinear", ARKodeSetNonlinear}, - {"clear_stop_time", ARKodeClearStopTime}, - {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, + {{"nonlinear", ARKodeSetNonlinear}, + {"clear_stop_time", ARKodeClearStopTime}, + {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, {"reset_accumulated_error", ARKodeResetAccumulatedError}}; int num_action_keys = 4; @@ -216,7 +228,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, sunbooleantype arg_used = SUNFALSE; /* skip command-line arguments that do not begin with "arkode." */ - static const char *prefix = "arkode."; + static const char* prefix = "arkode."; if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } /* set offset length to disregard for subsequent command-line tests */ @@ -228,16 +240,15 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, to trim both the arkid and the trailing "." */ if (strlen(arkid) > 0) { - if (strncmp(argv[i]+offset, arkid, strlen(arkid)) != 0) { continue; } + if (strncmp(argv[i] + offset, arkid, strlen(arkid)) != 0) { continue; } offset += strlen(arkid) + 1; } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = CheckAndSetIntArg(ark_mem, &i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + retval = CheckAndSetIntArg(ark_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -246,9 +257,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = CheckAndSetLongArg(ark_mem, &i, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + retval = CheckAndSetLongArg(ark_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -257,9 +267,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = CheckAndSetRealArg(ark_mem, &i, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + retval = CheckAndSetRealArg(ark_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -278,7 +287,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, /*** handle all remaining command-line options ***/ - if (strcmp(argv[i]+offset, "interpolant_type") == 0) + if (strcmp(argv[i] + offset, "interpolant_type") == 0) { i++; retval = ARK_ILL_INPUT; @@ -298,50 +307,50 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[i-1], argv[i]); + argv[i - 1], argv[i]); return retval; } arg_used = SUNTRUE; continue; } - if (strcmp(argv[i]+offset, "scalar_tolerances") == 0) + if (strcmp(argv[i] + offset, "scalar_tolerances") == 0) { i++; sunrealtype rtol = atof(argv[i]); i++; sunrealtype atol = atof(argv[i]); - retval = ARKodeSStolerances(arkode_mem, rtol, atol); + retval = ARKodeSStolerances(arkode_mem, rtol, atol); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s %s", - argv[i-2], argv[i-1], argv[i]); + argv[i - 2], argv[i - 1], argv[i]); return retval; } arg_used = SUNTRUE; continue; } - if (strcmp(argv[i]+offset, "fixed_step_bounds") == 0) + if (strcmp(argv[i] + offset, "fixed_step_bounds") == 0) { i++; sunrealtype lb = atof(argv[i]); i++; sunrealtype ub = atof(argv[i]); - retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); + retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s %s", - argv[i-2], argv[i-1], argv[i]); + argv[i - 2], argv[i - 1], argv[i]); return retval; } arg_used = SUNTRUE; continue; } - if (strcmp(argv[i]+offset, "accum_error_type") == 0) + if (strcmp(argv[i] + offset, "accum_error_type") == 0) { i++; retval = ARK_ILL_INPUT; @@ -365,7 +374,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[i-1], argv[i]); + argv[i - 1], argv[i]); return retval; } arg_used = SUNTRUE; From 9a552b925d2c54abc26f0a8ae7903b69b07ebc58 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Feb 2025 16:53:19 -0600 Subject: [PATCH 014/114] Updated type for 'offset' to size_t to avoid conversion warnings/errors --- src/arkode/arkode_io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 65c5f8f5ef..f41fc86d85 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -75,7 +75,7 @@ struct arkKeyActionPair }; static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], - const int offset, const char* argtest, + const size_t offset, const char* argtest, arkIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; @@ -97,7 +97,7 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], } static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], - const int offset, const char* argtest, + const size_t offset, const char* argtest, arkLongSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; @@ -119,7 +119,7 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], } static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], - const int offset, const char* argtest, + const size_t offset, const char* argtest, arkRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; @@ -141,7 +141,7 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], } static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], - const int offset, const char* argtest, + const size_t offset, const char* argtest, arkActionSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; @@ -232,7 +232,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } /* set offset length to disregard for subsequent command-line tests */ - int offset = strlen(prefix); + size_t offset = strlen(prefix); /* check against supplied arkid input: if not supplied, then just process remaining text as a normal argument; From 62fecacb98f51e32ed7e41511d26956a629294f5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 12:39:46 -0600 Subject: [PATCH 015/114] Apply suggestions from code review to automatically determine the number of options in each category. Co-authored-by: Steven Roberts --- src/arkode/arkode_io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index f41fc86d85..6b6cf7b40a 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -188,11 +188,11 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"small_num_efails", ARKodeSetSmallNumEFails}, {"max_err_test_fails", ARKodeSetMaxErrTestFails}, {"max_conv_fails", ARKodeSetMaxConvFails}}; - int num_int_keys = 15; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct arkKeyLongPair long_pairs[] = { {"max_num_steps", ARKodeSetMaxNumSteps}}; - int num_long_keys = 1; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static struct arkKeyRealPair real_pairs[] = {{"nonlin_crdown", ARKodeSetNonlinCRDown}, @@ -213,14 +213,14 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"max_first_growth", ARKodeSetMaxFirstGrowth}, {"max_efail_growth", ARKodeSetMaxEFailGrowth}, {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; - int num_real_keys = 18; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); static struct arkKeyActionPair action_pairs[] = {{"nonlinear", ARKodeSetNonlinear}, {"clear_stop_time", ARKodeClearStopTime}, {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, {"reset_accumulated_error", ARKodeResetAccumulatedError}}; - int num_action_keys = 4; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; for (i = 1; i < argc; i++) From 3eece32577f5db562f29398857dffe51ad1e0985 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 12:45:55 -0600 Subject: [PATCH 016/114] Moved command-line input control to a separate file --- src/arkode/CMakeLists.txt | 1 + src/arkode/arkode_cli.c | 393 ++++++++++++++++++++++++++++++++++++++ src/arkode/arkode_io.c | 358 +--------------------------------- 3 files changed, 395 insertions(+), 357 deletions(-) create mode 100644 src/arkode/arkode_cli.c diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt index 3e3634f7b1..1a55755ef2 100644 --- a/src/arkode/CMakeLists.txt +++ b/src/arkode/CMakeLists.txt @@ -27,6 +27,7 @@ set(arkode_SOURCES arkode_butcher_dirk.c arkode_butcher_erk.c arkode_butcher.c + arkode_cli.c arkode_erkstep_io.c arkode_erkstep.c arkode_forcingstep.c diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c new file mode 100644 index 0000000000..7ab909607d --- /dev/null +++ b/src/arkode/arkode_cli.c @@ -0,0 +1,393 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to ARKODE. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "arkode/arkode.h" +#include "arkode_impl.h" +#include "arkode_interp_impl.h" +#include "arkode_user_controller.h" + +/*=============================================================== + Command-line input utility types and routines + ===============================================================*/ + +typedef int (*arkIntSetFn)(void*, int); + +struct arkKeyIntPair +{ + const char* key; + arkIntSetFn set; +}; + +typedef int (*arkLongSetFn)(void*, long int); + +struct arkKeyLongPair +{ + const char* key; + arkLongSetFn set; +}; + +typedef int (*arkRealSetFn)(void*, sunrealtype); + +struct arkKeyRealPair +{ + const char* key; + arkRealSetFn set; +}; + +typedef int (*arkActionSetFn)(void*); + +struct arkKeyActionPair +{ + const char* key; + arkActionSetFn set; +}; + +static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkIntSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int iarg = atoi(argv[*i]); + int retval = fname((void*)ark_mem, iarg); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[(*i) - 1], argv[*i]); + return retval; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkLongSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + long int iarg = atol(argv[*i]); + int retval = fname((void*)ark_mem, iarg); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[(*i) - 1], argv[*i]); + return retval; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkRealSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + sunrealtype rarg = atof(argv[*i]); + int retval = fname((void*)ark_mem, rarg); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[(*i) - 1], argv[*i]); + return retval; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + +static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkActionSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + int retval = fname((void*)ark_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", argv[*i]); + return retval; + } + *arg_used = SUNTRUE; + } + return ARK_SUCCESS; +} + + +/*--------------------------------------------------------------- + ARKodeSetFromCommandLine: + + Parses the command line to control scalar-valued ARKODE options. + + (this leverages a multiple typedefs and static utility routines) + ---------------------------------------------------------------*/ + + int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, + char* argv[]) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Set list of integer command-line arguments, and the corresponding set routine */ + static struct arkKeyIntPair int_pairs[] = + {{"order", ARKodeSetOrder}, + {"interpolant_degree", ARKodeSetInterpolantDegree}, + {"linear", ARKodeSetLinear}, + {"autonomous", ARKodeSetAutonomous}, + {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, + {"lsetup_frequency", ARKodeSetLSetupFrequency}, + {"predictor_method", ARKodeSetPredictorMethod}, + {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, + {"max_hnil_warns", ARKodeSetMaxHnilWarns}, + {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, + {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, + {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, + {"small_num_efails", ARKodeSetSmallNumEFails}, + {"max_err_test_fails", ARKodeSetMaxErrTestFails}, + {"max_conv_fails", ARKodeSetMaxConvFails}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct arkKeyLongPair long_pairs[] = { + {"max_num_steps", ARKodeSetMaxNumSteps}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct arkKeyRealPair real_pairs[] = + {{"nonlin_crdown", ARKodeSetNonlinCRDown}, + {"nonlin_rdiv", ARKodeSetNonlinRDiv}, + {"delta_gamma_max", ARKodeSetDeltaGammaMax}, + {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, + {"init_step", ARKodeSetInitStep}, + {"min_step", ARKodeSetMinStep}, + {"max_step", ARKodeSetMaxStep}, + {"stop_time", ARKodeSetStopTime}, + {"fixed_step", ARKodeSetFixedStep}, + {"step_direction", ARKodeSetStepDirection}, + {"cfl_fraction", ARKodeSetCFLFraction}, + {"safety_factor", ARKodeSetSafetyFactor}, + {"error_bias", ARKodeSetErrorBias}, + {"max_growth", ARKodeSetMaxGrowth}, + {"min_reduction", ARKodeSetMinReduction}, + {"max_first_growth", ARKodeSetMaxFirstGrowth}, + {"max_efail_growth", ARKodeSetMaxEFailGrowth}, + {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + static struct arkKeyActionPair action_pairs[] = + {{"nonlinear", ARKodeSetNonlinear}, + {"clear_stop_time", ARKodeClearStopTime}, + {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, + {"reset_accumulated_error", ARKodeResetAccumulatedError}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with "arkode." */ + static const char* prefix = "arkode."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + + /* set offset length to disregard for subsequent command-line tests */ + size_t offset = strlen(prefix); + + /* check against supplied arkid input: + if not supplied, then just process remaining text as a normal argument; + if supplied, verify that it matches the supplied arkid, and update offset + to trim both the arkid and the trailing "." */ + if (strlen(arkid) > 0) + { + if (strncmp(argv[i] + offset, arkid, strlen(arkid)) != 0) { continue; } + offset += strlen(arkid) + 1; + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = CheckAndSetIntArg(ark_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = CheckAndSetLongArg(ark_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = CheckAndSetRealArg(ark_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) { return retval; } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = CheckAndSetActionArg(ark_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != ARK_SUCCESS) { return retval; } + if (arg_used) break; + } + if (arg_used) continue; + + /*** handle all remaining command-line options ***/ + + if (strcmp(argv[i] + offset, "interpolant_type") == 0) + { + i++; + retval = ARK_ILL_INPUT; + if (strcmp(argv[i], "ARK_INTERP_HERMITE") == 0) + { + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); + } + else if (strcmp(argv[i], "ARK_INTERP_LAGRANGE") == 0) + { + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + } + else if (strcmp(argv[i], "ARK_INTERP_NONE") == 0) + { + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_NONE); + } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[i - 1], argv[i]); + return retval; + } + arg_used = SUNTRUE; + continue; + } + + if (strcmp(argv[i] + offset, "scalar_tolerances") == 0) + { + i++; + sunrealtype rtol = atof(argv[i]); + i++; + sunrealtype atol = atof(argv[i]); + retval = ARKodeSStolerances(arkode_mem, rtol, atol); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s %s", + argv[i - 2], argv[i - 1], argv[i]); + return retval; + } + arg_used = SUNTRUE; + continue; + } + + if (strcmp(argv[i] + offset, "fixed_step_bounds") == 0) + { + i++; + sunrealtype lb = atof(argv[i]); + i++; + sunrealtype ub = atof(argv[i]); + retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s %s", + argv[i - 2], argv[i - 1], argv[i]); + return retval; + } + arg_used = SUNTRUE; + continue; + } + + if (strcmp(argv[i] + offset, "accum_error_type") == 0) + { + i++; + retval = ARK_ILL_INPUT; + if (strcmp(argv[i], "ARK_ACCUMERROR_NONE") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); + } + else if (strcmp(argv[i], "ARK_ACCUMERROR_MAX") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_MAX); + } + else if (strcmp(argv[i], "ARK_ACCUMERROR_SUM") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_SUM); + } + else if (strcmp(argv[i], "ARK_ACCUMERROR_AVG") == 0) + { + retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_AVG); + } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s %s", + argv[i - 1], argv[i]); + return retval; + } + arg_used = SUNTRUE; + continue; + } + + /* warn for uninterpreted arkode.X arguments */ + arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (ARK_SUCCESS); +} + +/*=============================================================== + EOF + ===============================================================*/ diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 6b6cf7b40a..583f10adda 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -12,10 +12,7 @@ * SUNDIALS Copyright End *--------------------------------------------------------------- * This is the implementation file for the optional input and - * output functions for the ARKODE infrastructure; these routines - * should not be called directly by the user; instead they are - * provided as utility routines for ARKODE time-step modules - * to use. + * output functions for the ARKODE infrastructure. *--------------------------------------------------------------*/ #include @@ -35,359 +32,6 @@ ARKODE optional input functions ===============================================================*/ -/*--------------------------------------------------------------- - ARKodeSetFromCommandLine: - - Parses the command line to control scalar-valued ARKODE options. - - (this leverages a multiple typedefs and static utility routines) - ---------------------------------------------------------------*/ -typedef int (*arkIntSetFn)(void*, int); - -struct arkKeyIntPair -{ - const char* key; - arkIntSetFn set; -}; - -typedef int (*arkLongSetFn)(void*, long int); - -struct arkKeyLongPair -{ - const char* key; - arkLongSetFn set; -}; - -typedef int (*arkRealSetFn)(void*, sunrealtype); - -struct arkKeyRealPair -{ - const char* key; - arkRealSetFn set; -}; - -typedef int (*arkActionSetFn)(void*); - -struct arkKeyActionPair -{ - const char* key; - arkActionSetFn set; -}; - -static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkIntSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - (*i) += 1; - int iarg = atoi(argv[*i]); - int retval = fname((void*)ark_mem, iarg); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[(*i) - 1], argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkLongSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - (*i) += 1; - long int iarg = atol(argv[*i]); - int retval = fname((void*)ark_mem, iarg); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[(*i) - 1], argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkRealSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - (*i) += 1; - sunrealtype rarg = atof(argv[*i]); - int retval = fname((void*)ark_mem, rarg); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[(*i) - 1], argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkActionSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - int retval = fname((void*)ark_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, - char* argv[]) -{ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - - /* Set list of integer command-line arguments, and the corresponding set routine */ - static struct arkKeyIntPair int_pairs[] = - {{"order", ARKodeSetOrder}, - {"interpolant_degree", ARKodeSetInterpolantDegree}, - {"linear", ARKodeSetLinear}, - {"autonomous", ARKodeSetAutonomous}, - {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, - {"lsetup_frequency", ARKodeSetLSetupFrequency}, - {"predictor_method", ARKodeSetPredictorMethod}, - {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, - {"max_hnil_warns", ARKodeSetMaxHnilWarns}, - {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, - {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, - {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, - {"small_num_efails", ARKodeSetSmallNumEFails}, - {"max_err_test_fails", ARKodeSetMaxErrTestFails}, - {"max_conv_fails", ARKodeSetMaxConvFails}}; - static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - - static struct arkKeyLongPair long_pairs[] = { - {"max_num_steps", ARKodeSetMaxNumSteps}}; - static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - - static struct arkKeyRealPair real_pairs[] = - {{"nonlin_crdown", ARKodeSetNonlinCRDown}, - {"nonlin_rdiv", ARKodeSetNonlinRDiv}, - {"delta_gamma_max", ARKodeSetDeltaGammaMax}, - {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, - {"init_step", ARKodeSetInitStep}, - {"min_step", ARKodeSetMinStep}, - {"max_step", ARKodeSetMaxStep}, - {"stop_time", ARKodeSetStopTime}, - {"fixed_step", ARKodeSetFixedStep}, - {"step_direction", ARKodeSetStepDirection}, - {"cfl_fraction", ARKodeSetCFLFraction}, - {"safety_factor", ARKodeSetSafetyFactor}, - {"error_bias", ARKodeSetErrorBias}, - {"max_growth", ARKodeSetMaxGrowth}, - {"min_reduction", ARKodeSetMinReduction}, - {"max_first_growth", ARKodeSetMaxFirstGrowth}, - {"max_efail_growth", ARKodeSetMaxEFailGrowth}, - {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; - static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - - static struct arkKeyActionPair action_pairs[] = - {{"nonlinear", ARKodeSetNonlinear}, - {"clear_stop_time", ARKodeClearStopTime}, - {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, - {"reset_accumulated_error", ARKodeResetAccumulatedError}}; - static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - - int i, j, retval; - for (i = 1; i < argc; i++) - { - sunbooleantype arg_used = SUNFALSE; - - /* skip command-line arguments that do not begin with "arkode." */ - static const char* prefix = "arkode."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } - - /* set offset length to disregard for subsequent command-line tests */ - size_t offset = strlen(prefix); - - /* check against supplied arkid input: - if not supplied, then just process remaining text as a normal argument; - if supplied, verify that it matches the supplied arkid, and update offset - to trim both the arkid and the trailing "." */ - if (strlen(arkid) > 0) - { - if (strncmp(argv[i] + offset, arkid, strlen(arkid)) != 0) { continue; } - offset += strlen(arkid) + 1; - } - - /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) - { - retval = CheckAndSetIntArg(ark_mem, &i, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } - if (arg_used) break; - } - if (arg_used) continue; - - /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) - { - retval = CheckAndSetLongArg(ark_mem, &i, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } - if (arg_used) break; - } - if (arg_used) continue; - - /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) - { - retval = CheckAndSetRealArg(ark_mem, &i, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } - if (arg_used) break; - } - if (arg_used) continue; - - /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) - { - retval = CheckAndSetActionArg(ark_mem, &i, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); - if (retval != ARK_SUCCESS) { return retval; } - if (arg_used) break; - } - if (arg_used) continue; - - /*** handle all remaining command-line options ***/ - - if (strcmp(argv[i] + offset, "interpolant_type") == 0) - { - i++; - retval = ARK_ILL_INPUT; - if (strcmp(argv[i], "ARK_INTERP_HERMITE") == 0) - { - retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); - } - else if (strcmp(argv[i], "ARK_INTERP_LAGRANGE") == 0) - { - retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); - } - else if (strcmp(argv[i], "ARK_INTERP_NONE") == 0) - { - retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_NONE); - } - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[i - 1], argv[i]); - return retval; - } - arg_used = SUNTRUE; - continue; - } - - if (strcmp(argv[i] + offset, "scalar_tolerances") == 0) - { - i++; - sunrealtype rtol = atof(argv[i]); - i++; - sunrealtype atol = atof(argv[i]); - retval = ARKodeSStolerances(arkode_mem, rtol, atol); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s %s", - argv[i - 2], argv[i - 1], argv[i]); - return retval; - } - arg_used = SUNTRUE; - continue; - } - - if (strcmp(argv[i] + offset, "fixed_step_bounds") == 0) - { - i++; - sunrealtype lb = atof(argv[i]); - i++; - sunrealtype ub = atof(argv[i]); - retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s %s", - argv[i - 2], argv[i - 1], argv[i]); - return retval; - } - arg_used = SUNTRUE; - continue; - } - - if (strcmp(argv[i] + offset, "accum_error_type") == 0) - { - i++; - retval = ARK_ILL_INPUT; - if (strcmp(argv[i], "ARK_ACCUMERROR_NONE") == 0) - { - retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); - } - else if (strcmp(argv[i], "ARK_ACCUMERROR_MAX") == 0) - { - retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_MAX); - } - else if (strcmp(argv[i], "ARK_ACCUMERROR_SUM") == 0) - { - retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_SUM); - } - else if (strcmp(argv[i], "ARK_ACCUMERROR_AVG") == 0) - { - retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_AVG); - } - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[i - 1], argv[i]); - return retval; - } - arg_used = SUNTRUE; - continue; - } - - /* warn for uninterpreted arkode.X arguments */ - arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); - } - - return (ARK_SUCCESS); -} /*--------------------------------------------------------------- ARKodeSetDefaults: From 17000e9c076ed2ca53b7f7a280d04ec36986ab65 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 12:54:26 -0600 Subject: [PATCH 017/114] Updated handling of arkid input according to Steven's suggestion --- src/arkode/arkode_cli.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 7ab909607d..7a5b3a2f8b 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -226,21 +226,18 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], { sunbooleantype arg_used = SUNFALSE; - /* skip command-line arguments that do not begin with "arkode." */ - static const char* prefix = "arkode."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } - - /* set offset length to disregard for subsequent command-line tests */ - size_t offset = strlen(prefix); - - /* check against supplied arkid input: - if not supplied, then just process remaining text as a normal argument; - if supplied, verify that it matches the supplied arkid, and update offset - to trim both the arkid and the trailing "." */ - if (strlen(arkid) > 0) + /* if arkid is supplied, skip command-line arguments that do not begin with arkid; + else, skip command-line arguments that do not begin with "arkode." */ + size_t offset; + if (strlen(arkid) > 0) { + if (strncmp(argv[i], arkid, strlen(arkid)) != 0) { continue; } + offset = strlen(arkid) + 1; + } + else { - if (strncmp(argv[i] + offset, arkid, strlen(arkid)) != 0) { continue; } - offset += strlen(arkid) + 1; + static const char* prefix = "arkode."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); } /* check all "int" command-line options */ From cbdaf2dfa86e436dad5f18b1487d74dacf164f82 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 12:56:56 -0600 Subject: [PATCH 018/114] Updated includes now that cli interface is separated into a new file --- src/arkode/arkode_cli.c | 6 ------ src/arkode/arkode_io.c | 1 - 2 files changed, 7 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 7a5b3a2f8b..faa6b60d60 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -18,15 +18,9 @@ #include #include #include -#include -#include -#include #include - #include "arkode/arkode.h" #include "arkode_impl.h" -#include "arkode_interp_impl.h" -#include "arkode_user_controller.h" /*=============================================================== Command-line input utility types and routines diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 583f10adda..f1541013e9 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include From 44abb69fd06313c03191f40161c4e48a9f4fb733 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 13:03:37 -0600 Subject: [PATCH 019/114] Added support for a new writeparameters command-line option, that will call ARKodeWriteParameters after setting all command-line inputs. --- src/arkode/arkode_cli.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index faa6b60d60..f1fd871041 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -152,7 +152,7 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], (this leverages a multiple typedefs and static utility routines) ---------------------------------------------------------------*/ - int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, +int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, char* argv[]) { ARKodeMem ark_mem; @@ -216,6 +216,7 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; + sunbooleantype write_parameters = SUNFALSE; for (i = 1; i < argc; i++) { sunbooleantype arg_used = SUNFALSE; @@ -371,11 +372,36 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], continue; } - /* warn for uninterpreted arkode.X arguments */ + if (strcmp(argv[i] + offset, "writeparameters") == 0) + { + write_parameters = SUNTRUE; + arg_used = SUNTRUE; + continue; + } + + /* warn for uninterpreted arkid.X arguments */ arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, "WARNING: argument %s was not handled\n", argv[i]); } + /* Call stepper-specific SetFromCommandLine routine (if supplied) */ + + + /* Call ARKodeWriteParameters (if requested) now that all + command-line options have been set -- WARNING: this knows + nothing about MPI, so it could be redundantly written by all + processes if requested. */ + if (write_parameters) + { + retval = ARKodeWriteParameters(arkode_mem, stdout); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error writing parameters to stdout"); + return retval; + } + } + return (ARK_SUCCESS); } From d65c219944b7317d0510dcdcb06c78d8938c1659 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 13:28:40 -0600 Subject: [PATCH 020/114] Added function pointer for stepper-specific setfromcommandline functions (none are implemented yet) --- src/arkode/arkode.c | 1 + src/arkode/arkode_cli.c | 95 ++++++++++++++++------------------------ src/arkode/arkode_impl.h | 45 +++++++++++++++++++ 3 files changed, 84 insertions(+), 57 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index eefba1aee8..b848dfbcc3 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1545,6 +1545,7 @@ ARKodeMem arkCreate(SUNContext sunctx) ark_mem->step_setstagepredictfn = NULL; ark_mem->step_getnumrhsevals = NULL; ark_mem->step_setstepdirection = NULL; + ark_mem->step_setfromcommandline = NULL; ark_mem->step_getnumlinsolvsetups = NULL; ark_mem->step_setadaptcontroller = NULL; ark_mem->step_getestlocalerrors = NULL; diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index f1fd871041..98c0369518 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -23,44 +23,12 @@ #include "arkode_impl.h" /*=============================================================== - Command-line input utility types and routines + Command-line input utility routines ===============================================================*/ -typedef int (*arkIntSetFn)(void*, int); - -struct arkKeyIntPair -{ - const char* key; - arkIntSetFn set; -}; - -typedef int (*arkLongSetFn)(void*, long int); - -struct arkKeyLongPair -{ - const char* key; - arkLongSetFn set; -}; - -typedef int (*arkRealSetFn)(void*, sunrealtype); - -struct arkKeyRealPair -{ - const char* key; - arkRealSetFn set; -}; - -typedef int (*arkActionSetFn)(void*); - -struct arkKeyActionPair -{ - const char* key; - arkActionSetFn set; -}; - -static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkIntSetFn fname, sunbooleantype* arg_used) +int arkCheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) @@ -80,9 +48,9 @@ static int CheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], return ARK_SUCCESS; } -static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkLongSetFn fname, sunbooleantype* arg_used) +int arkCheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkLongSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) @@ -102,9 +70,9 @@ static int CheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], return ARK_SUCCESS; } -static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkRealSetFn fname, sunbooleantype* arg_used) +int arkCheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) @@ -124,9 +92,9 @@ static int CheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], return ARK_SUCCESS; } -static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkActionSetFn fname, sunbooleantype* arg_used) +int arkCheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkActionSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) @@ -153,7 +121,7 @@ static int CheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], ---------------------------------------------------------------*/ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, - char* argv[]) + char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -238,8 +206,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = CheckAndSetIntArg(ark_mem, &i, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + retval = arkCheckAndSetIntArg(ark_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -248,8 +216,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = CheckAndSetLongArg(ark_mem, &i, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); + retval = arkCheckAndSetLongArg(ark_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -258,8 +226,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = CheckAndSetRealArg(ark_mem, &i, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); + retval = arkCheckAndSetRealArg(ark_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -268,9 +236,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = CheckAndSetActionArg(ark_mem, &i, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); + retval = arkCheckAndSetActionArg(ark_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) break; } @@ -379,13 +347,26 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, continue; } + /* Call stepper-specific SetFromCommandLine routine (if supplied) to + process this command-line argument */ + if (ark_mem->step_setfromcommandline) + { + retval = ark_mem->step_setfromcommandline(ark_mem, &i, argv, + offset, &arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", argv[i]); + return retval; + } + if (arg_used) { continue; } + } + /* warn for uninterpreted arkid.X arguments */ arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, "WARNING: argument %s was not handled\n", argv[i]); } - /* Call stepper-specific SetFromCommandLine routine (if supplied) */ - /* Call ARKodeWriteParameters (if requested) now that all command-line options have been set -- WARNING: this knows diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 4ef09d44c4..e9de0e1d5b 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -224,6 +224,9 @@ typedef int (*ARKTimestepGetNumRhsEvals)(ARKodeMem ark_mem, int partition_index, long int* num_rhs_evals); typedef int (*ARKTimestepSetStepDirection)(ARKodeMem ark_mem, sunrealtype stepdir); +typedef int (*ARKTimestepSetFromCommandLine)(ARKodeMem ark_mem, int* i, + char* argv[], const size_t offset, + sunbooleantype* arg_used); /* time stepper interface functions -- temporal adaptivity */ typedef int (*ARKTimestepGetEstLocalErrors)(ARKodeMem ark_mem, N_Vector ele); @@ -414,6 +417,7 @@ struct ARKodeMemRec ARKTimestepSetOrder step_setorder; ARKTimestepGetNumRhsEvals step_getnumrhsevals; ARKTimestepSetStepDirection step_setstepdirection; + ARKTimestepSetFromCommandLine step_setfromcommandline; /* Time stepper module -- temporal adaptivity */ sunbooleantype step_supports_adaptive; @@ -594,6 +598,47 @@ int arkExpStab(N_Vector y, sunrealtype t, sunrealtype* hstab, void* user_data); void arkProcessError(ARKodeMem ark_mem, int error_code, int line, const char* func, const char* file, const char* msgfmt, ...); +/*=============================================================== + ARKODE COMMAND-LINE INPUT UTILITY TYPES AND ROUTINES + ===============================================================*/ + +typedef int (*arkIntSetFn)(void*, int); +struct arkKeyIntPair +{ + const char* key; + arkIntSetFn set; +}; +typedef int (*arkLongSetFn)(void*, long int); +struct arkKeyLongPair +{ + const char* key; + arkLongSetFn set; +}; +typedef int (*arkRealSetFn)(void*, sunrealtype); +struct arkKeyRealPair +{ + const char* key; + arkRealSetFn set; +}; +typedef int (*arkActionSetFn)(void*); +struct arkKeyActionPair +{ + const char* key; + arkActionSetFn set; +}; +int arkCheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkIntSetFn fname, sunbooleantype* arg_used); +int arkCheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkLongSetFn fname, sunbooleantype* arg_used); +int arkCheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkRealSetFn fname, sunbooleantype* arg_used); +int arkCheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, const char* argtest, + arkActionSetFn fname, sunbooleantype* arg_used); + /*=============================================================== ARKODE PRIVATE FUNCTION PROTOTYPES ===============================================================*/ From 60e3287be48784ad8ca791ed2f31e0fba90ab23e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 27 Feb 2025 15:42:51 -0600 Subject: [PATCH 021/114] Added placeholder for ARKStep command-line processing (needs to be filled in), along with comments to myself on next steps --- src/arkode/arkode_arkstep_io.c | 13 +++++++++++++ src/arkode/arkode_cli.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 5b382fc949..c97068e37e 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -628,6 +628,19 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Private functions attached to ARKODE ===============================================================*/ +/*--------------------------------------------------------------- + arkStep_SetFromCommandLine: + + Provides command-line control over ARKStep-specific "set" routines. + ---------------------------------------------------------------*/ +int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used) +{ + + return (ARK_SUCCESS); +} + + /*--------------------------------------------------------------- arkStep_SetRelaxFn: diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 98c0369518..e917af31b9 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -23,7 +23,7 @@ #include "arkode_impl.h" /*=============================================================== - Command-line input utility routines + Command-line input utility routines -- create more of these: TwoInt, TwoReal, String, TwoString. Remove direct calls to arkProcessError, and instead have the calling routine return a slightly more generic error message that omits the extra arguments. Propagate both this set of routines and the function types to the SUNDIALS level, so that they can be used across all integrators. ===============================================================*/ int arkCheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], From 20e3232f4fb0c98a810fd99782c66aebbc59daf4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 1 Mar 2025 21:47:08 -0600 Subject: [PATCH 022/114] Moved typedefs and general CLI utility routines up to SUNDIALS level, and added some extras for wider support --- include/sundials/priv/sundials_cli.h | 120 ++++++++++++++++ src/arkode/arkode_cli.c | 198 ++++++++------------------- src/arkode/arkode_impl.h | 41 ------ src/sundials/CMakeLists.txt | 4 +- src/sundials/sundials_cli.c | 155 +++++++++++++++++++++ 5 files changed, 337 insertions(+), 181 deletions(-) create mode 100644 include/sundials/priv/sundials_cli.h create mode 100644 src/sundials/sundials_cli.c diff --git a/include/sundials/priv/sundials_cli.h b/include/sundials/priv/sundials_cli.h new file mode 100644 index 0000000000..0a1ada24c7 --- /dev/null +++ b/include/sundials/priv/sundials_cli.h @@ -0,0 +1,120 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * SUNDIALS command-line utility definitions. + * -----------------------------------------------------------------*/ + +#ifndef _SUNDIALS_CLI_H +#define _SUNDIALS_CLI_H + +#include +#include "sundials/sundials_types.h" +#include "sundials/sundials_errors.h" + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* utilities for integer "set" routines */ +typedef int (*sunIntSetFn)(void*, int); +struct sunKeyIntPair +{ + const char* key; + sunIntSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetIntArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunIntSetFn fname, sunbooleantype* arg_used); + +/* utilities for pair-of-integer "set" routines */ +typedef int (*sunTwoIntSetFn)(void*, int, int); +struct sunKeyTwoIntPair +{ + const char* key; + sunTwoIntSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunTwoIntSetFn fname, sunbooleantype* arg_used); + +/* utilities for long int "set" routines */ +typedef int (*sunLongSetFn)(void*, long int); +struct sunKeyLongPair +{ + const char* key; + sunLongSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunLongSetFn fname, sunbooleantype* arg_used); + +/* utilities for sunrealtype "set" routines */ +typedef int (*sunRealSetFn)(void*, sunrealtype); +struct sunKeyRealPair +{ + const char* key; + sunRealSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetRealArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunRealSetFn fname, sunbooleantype* arg_used); + +/* utilities for pair-of-sunrealtype "set" routines */ +typedef int (*sunTwoRealSetFn)(void*, sunrealtype, sunrealtype); +struct sunKeyTwoRealPair +{ + const char* key; + sunTwoRealSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunTwoRealSetFn fname, sunbooleantype* arg_used); + +/* utilities for char* "set" routines */ +typedef int (*sunCharSetFn)(void*, char* argv); +struct sunKeyCharPair +{ + const char* key; + sunCharSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunCharSetFn fname, sunbooleantype* arg_used); + +/* utilities for pair-of-char* "set" routines */ +typedef int (*sunTwoCharSetFn)(void*, char* argv1, char* argv2); +struct sunKeyTwoCharPair +{ + const char* key; + sunTwoCharSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunTwoCharSetFn fname, sunbooleantype* arg_used); + +/* utilities for action "set" routines */ +typedef int (*sunActionSetFn)(void*); +struct sunKeyActionPair +{ + const char* key; + sunActionSetFn set; +}; +SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* i, + char* argv[], const size_t offset, const char* argtest, + sunActionSetFn fname, sunbooleantype* arg_used); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index e917af31b9..8dbc5b85bb 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -19,99 +19,10 @@ #include #include #include +#include #include "arkode/arkode.h" #include "arkode_impl.h" -/*=============================================================== - Command-line input utility routines -- create more of these: TwoInt, TwoReal, String, TwoString. Remove direct calls to arkProcessError, and instead have the calling routine return a slightly more generic error message that omits the extra arguments. Propagate both this set of routines and the function types to the SUNDIALS level, so that they can be used across all integrators. - ===============================================================*/ - -int arkCheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkIntSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - (*i) += 1; - int iarg = atoi(argv[*i]); - int retval = fname((void*)ark_mem, iarg); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[(*i) - 1], argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -int arkCheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkLongSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - (*i) += 1; - long int iarg = atol(argv[*i]); - int retval = fname((void*)ark_mem, iarg); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[(*i) - 1], argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -int arkCheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkRealSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - (*i) += 1; - sunrealtype rarg = atof(argv[*i]); - int retval = fname((void*)ark_mem, rarg); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", - argv[(*i) - 1], argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - -int arkCheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkActionSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) - { - int retval = fname((void*)ark_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", argv[*i]); - return retval; - } - *arg_used = SUNTRUE; - } - return ARK_SUCCESS; -} - - /*--------------------------------------------------------------- ARKodeSetFromCommandLine: @@ -133,7 +44,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, ark_mem = (ARKodeMem)arkode_mem; /* Set list of integer command-line arguments, and the corresponding set routine */ - static struct arkKeyIntPair int_pairs[] = + static struct sunKeyIntPair int_pairs[] = {{"order", ARKodeSetOrder}, {"interpolant_degree", ARKodeSetInterpolantDegree}, {"linear", ARKodeSetLinear}, @@ -151,11 +62,11 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"max_conv_fails", ARKodeSetMaxConvFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct arkKeyLongPair long_pairs[] = { + static struct sunKeyLongPair long_pairs[] = { {"max_num_steps", ARKodeSetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct arkKeyRealPair real_pairs[] = + static struct sunKeyRealPair real_pairs[] = {{"nonlin_crdown", ARKodeSetNonlinCRDown}, {"nonlin_rdiv", ARKodeSetNonlinRDiv}, {"delta_gamma_max", ARKodeSetDeltaGammaMax}, @@ -176,7 +87,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct arkKeyActionPair action_pairs[] = + static struct sunKeyTwoRealPair tworeal_pairs[] = + {{"scalar_tolerances", ARKodeSStolerances}, + {"fixed_step_bounds", ARKodeSetFixedStepBounds}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + + static struct sunKeyActionPair action_pairs[] = {{"nonlinear", ARKodeSetNonlinear}, {"clear_stop_time", ARKodeClearStopTime}, {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, @@ -206,9 +122,15 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = arkCheckAndSetIntArg(ark_mem, &i, argv, offset, int_pairs[j].key, + retval = sunCheckAndSetIntArg(arkode_mem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } if (arg_used) break; } if (arg_used) continue; @@ -216,9 +138,15 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = arkCheckAndSetLongArg(ark_mem, &i, argv, offset, long_pairs[j].key, + retval = sunCheckAndSetLongArg(arkode_mem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } if (arg_used) break; } if (arg_used) continue; @@ -226,9 +154,31 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = arkCheckAndSetRealArg(ark_mem, &i, argv, offset, real_pairs[j].key, + retval = sunCheckAndSetRealArg(arkode_mem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(arkode_mem, &i, argv, offset, tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } if (arg_used) break; } if (arg_used) continue; @@ -236,10 +186,16 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = arkCheckAndSetActionArg(ark_mem, &i, argv, offset, + retval = sunCheckAndSetActionArg(arkode_mem, &i, argv, offset, action_pairs[j].key, action_pairs[j].set, - &arg_used); - if (retval != ARK_SUCCESS) { return retval; } + &arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } if (arg_used) break; } if (arg_used) continue; @@ -273,42 +229,6 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, continue; } - if (strcmp(argv[i] + offset, "scalar_tolerances") == 0) - { - i++; - sunrealtype rtol = atof(argv[i]); - i++; - sunrealtype atol = atof(argv[i]); - retval = ARKodeSStolerances(arkode_mem, rtol, atol); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s %s", - argv[i - 2], argv[i - 1], argv[i]); - return retval; - } - arg_used = SUNTRUE; - continue; - } - - if (strcmp(argv[i] + offset, "fixed_step_bounds") == 0) - { - i++; - sunrealtype lb = atof(argv[i]); - i++; - sunrealtype ub = atof(argv[i]); - retval = ARKodeSetFixedStepBounds(arkode_mem, lb, ub); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s %s", - argv[i - 2], argv[i - 1], argv[i]); - return retval; - } - arg_used = SUNTRUE; - continue; - } - if (strcmp(argv[i] + offset, "accum_error_type") == 0) { i++; diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index e9de0e1d5b..6dca949bfc 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -598,47 +598,6 @@ int arkExpStab(N_Vector y, sunrealtype t, sunrealtype* hstab, void* user_data); void arkProcessError(ARKodeMem ark_mem, int error_code, int line, const char* func, const char* file, const char* msgfmt, ...); -/*=============================================================== - ARKODE COMMAND-LINE INPUT UTILITY TYPES AND ROUTINES - ===============================================================*/ - -typedef int (*arkIntSetFn)(void*, int); -struct arkKeyIntPair -{ - const char* key; - arkIntSetFn set; -}; -typedef int (*arkLongSetFn)(void*, long int); -struct arkKeyLongPair -{ - const char* key; - arkLongSetFn set; -}; -typedef int (*arkRealSetFn)(void*, sunrealtype); -struct arkKeyRealPair -{ - const char* key; - arkRealSetFn set; -}; -typedef int (*arkActionSetFn)(void*); -struct arkKeyActionPair -{ - const char* key; - arkActionSetFn set; -}; -int arkCheckAndSetIntArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkIntSetFn fname, sunbooleantype* arg_used); -int arkCheckAndSetLongArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkLongSetFn fname, sunbooleantype* arg_used); -int arkCheckAndSetRealArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkRealSetFn fname, sunbooleantype* arg_used); -int arkCheckAndSetActionArg(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, const char* argtest, - arkActionSetFn fname, sunbooleantype* arg_used); - /*=============================================================== ARKODE PRIVATE FUNCTION PROTOTYPES ===============================================================*/ diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index a6b46b054a..a0e8877730 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -81,6 +81,7 @@ add_prefix(${SUNDIALS_SOURCE_DIR}/include/sundials/ sundials_HEADERS) set(sundials_SOURCES sundials_adaptcontroller.c sundials_band.c + sundials_cli.c sundials_context.c sundials_dense.c sundials_direct.c @@ -135,7 +136,8 @@ sundials_add_library( # Install private headers install( FILES ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_context_impl.h - ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_errors_impl.h + ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_errors_impl.h + ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_cli.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials/priv") if(ENABLE_MPI) diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c new file mode 100644 index 0000000000..f8ec0eae34 --- /dev/null +++ b/src/sundials/sundials_cli.c @@ -0,0 +1,155 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to ARKODE. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +/*=============================================================== + Command-line input utility routines + ===============================================================*/ + +int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunIntSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int iarg = atoi(argv[*i]); + int retval = fname(mem, iarg); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunTwoIntSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int iarg1 = atoi(argv[*i]); + (*i) += 1; + int iarg2 = atoi(argv[*i]); + int retval = fname(mem, iarg1, iarg2); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunLongSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + long int iarg = atol(argv[*i]); + int retval = fname(mem, iarg); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunRealSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + sunrealtype rarg = atof(argv[*i]); + int retval = fname(mem, rarg); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunTwoRealSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + sunrealtype rarg1 = atof(argv[*i]); + (*i) += 1; + sunrealtype rarg2 = atof(argv[*i]); + int retval = fname(mem, rarg1, rarg2); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunCharSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int retval = fname(mem, argv[*i]); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunTwoCharSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + int retval = fname(mem, argv[*i+1], argv[*i+2]); + (*i) += 2; + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetActionArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunActionSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + int retval = fname(mem); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + From 00991b5ed11260c2ad8692f4b1511a5dd64259e9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 1 Mar 2025 22:09:08 -0600 Subject: [PATCH 023/114] Added command-line support to ARKStep --- include/sundials/priv/sundials_cli.h | 4 +-- src/arkode/arkode_arkstep.c | 1 + src/arkode/arkode_arkstep_impl.h | 2 ++ src/arkode/arkode_arkstep_io.c | 45 ++++++++++++++++++++++++++++ src/arkode/arkode_cli.c | 9 ++---- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/include/sundials/priv/sundials_cli.h b/include/sundials/priv/sundials_cli.h index 0a1ada24c7..2c2514e3d6 100644 --- a/include/sundials/priv/sundials_cli.h +++ b/include/sundials/priv/sundials_cli.h @@ -81,7 +81,7 @@ SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* i, sunTwoRealSetFn fname, sunbooleantype* arg_used); /* utilities for char* "set" routines */ -typedef int (*sunCharSetFn)(void*, char* argv); +typedef int (*sunCharSetFn)(void*, const char*); struct sunKeyCharPair { const char* key; @@ -92,7 +92,7 @@ SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* i, sunCharSetFn fname, sunbooleantype* arg_used); /* utilities for pair-of-char* "set" routines */ -typedef int (*sunTwoCharSetFn)(void*, char* argv1, char* argv2); +typedef int (*sunTwoCharSetFn)(void*, const char*, const char*); struct sunKeyTwoCharPair { const char* key; diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 0093728575..b61638c5ac 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -105,6 +105,7 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, ark_mem->step_printmem = arkStep_PrintMem; ark_mem->step_setdefaults = arkStep_SetDefaults; ark_mem->step_computestate = arkStep_ComputeState; + ark_mem->step_setfromcommandline = arkStep_SetFromCommandLine; ark_mem->step_setrelaxfn = arkStep_SetRelaxFn; ark_mem->step_setorder = arkStep_SetOrder; ark_mem->step_setnonlinearsolver = arkStep_SetNonlinearSolver; diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 9dcc375bbf..93e70f7d2d 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -190,6 +190,8 @@ int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used); int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int arkStep_SetDefaults(ARKodeMem ark_mem); int arkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index c97068e37e..62be64a778 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "arkode_arkstep_impl.h" @@ -637,6 +638,50 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyTwoCharPair twochar_pairs[] = + {{"table_names", ARKStepSetTableName}}; + static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); + + static struct sunKeyActionPair action_pairs[] = + {{"set_explicit", ARKStepSetExplicit}, + {"set_implicit", ARKStepSetImplicit}, + {"set_imex", ARKStepSetImEx}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + /* check all "twochar" command-line options */ + int j, retval; + for (j = 0; j < num_twochar_keys; j++) + { + retval = sunCheckAndSetTwoCharArg((void*) ark_mem, i, argv, offset, + twochar_pairs[j].key, + twochar_pairs[j].set, arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + twochar_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = sunCheckAndSetActionArg((void*) ark_mem, i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + return (ARK_SUCCESS); } diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 8dbc5b85bb..3af0ccd79b 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -43,7 +43,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, } ark_mem = (ARKodeMem)arkode_mem; - /* Set list of integer command-line arguments, and the corresponding set routine */ + /* Set lists of command-line arguments, and the corresponding set routines */ static struct sunKeyIntPair int_pairs[] = {{"order", ARKodeSetOrder}, {"interpolant_degree", ARKodeSetInterpolantDegree}, @@ -273,12 +273,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { retval = ark_mem->step_setfromcommandline(ark_mem, &i, argv, offset, &arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", argv[i]); - return retval; - } + if (retval != ARK_SUCCESS) { return retval; } if (arg_used) { continue; } } From a4513415a579bb38c009512c8f86dabb269b3e98 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 1 Mar 2025 22:16:48 -0600 Subject: [PATCH 024/114] Added command-line support to ERKStep --- src/arkode/arkode_erkstep.c | 1 + src/arkode/arkode_erkstep_impl.h | 2 ++ src/arkode/arkode_erkstep_io.c | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index ab2f150b63..1ea4d2e916 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -89,6 +89,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) ark_mem->step_resize = erkStep_Resize; ark_mem->step_free = erkStep_Free; ark_mem->step_printmem = erkStep_PrintMem; + ark_mem->step_setfromcommandline = erkStep_SetFromCommandLine; ark_mem->step_setdefaults = erkStep_SetDefaults; ark_mem->step_setrelaxfn = erkStep_SetRelaxFn; ark_mem->step_setorder = erkStep_SetOrder; diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 8c6de3b7d4..7cae0be9d1 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -81,6 +81,8 @@ int erkStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used); int erkStep_SetDefaults(ARKodeMem ark_mem); int erkStep_SetOrder(ARKodeMem ark_mem, int ord); int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 1edda14763..d37ba9bb22 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "arkode_erkstep_impl.h" @@ -255,6 +256,39 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Private functions attached to ARKODE ===============================================================*/ +/*--------------------------------------------------------------- + erkStep_SetFromCommandLine: + + Provides command-line control over ERKStep-specific "set" routines. + ---------------------------------------------------------------*/ +int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used) +{ + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyCharPair char_pairs[] = {{"table_name", ERKStepSetTableName}}; + static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); + + /* check all "char" command-line options */ + int j, retval; + for (j = 0; j < num_char_keys; j++) + { + retval = sunCheckAndSetCharArg((void*) ark_mem, i, argv, offset, + char_pairs[j].key, + char_pairs[j].set, arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + char_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- erkStep_SetRelaxFn: From 48809608753714c11e77b1aeb1af6fed98ad0906 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 2 Mar 2025 08:31:23 -0600 Subject: [PATCH 025/114] Added command-line support to SPRKStep and LSRKStep --- src/arkode/arkode_lsrkstep.c | 25 +++---- src/arkode/arkode_lsrkstep_impl.h | 2 + src/arkode/arkode_lsrkstep_io.c | 109 ++++++++++++++++++++++++++++-- src/arkode/arkode_sprkstep.c | 23 ++++--- src/arkode/arkode_sprkstep_impl.h | 2 + src/arkode/arkode_sprkstep_io.c | 53 +++++++++++++++ 6 files changed, 185 insertions(+), 29 deletions(-) diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index d86af26b87..01519c0543 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -166,18 +166,19 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, } /* Attach step_mem structure and function pointers to ark_mem */ - ark_mem->step_init = lsrkStep_Init; - ark_mem->step_fullrhs = lsrkStep_FullRHS; - ark_mem->step = lsrkStep_TakeStepRKC; - ark_mem->step_printallstats = lsrkStep_PrintAllStats; - ark_mem->step_writeparameters = lsrkStep_WriteParameters; - ark_mem->step_free = lsrkStep_Free; - ark_mem->step_printmem = lsrkStep_PrintMem; - ark_mem->step_setdefaults = lsrkStep_SetDefaults; - ark_mem->step_getnumrhsevals = lsrkStep_GetNumRhsEvals; - ark_mem->step_getestlocalerrors = lsrkStep_GetEstLocalErrors; - ark_mem->step_mem = (void*)step_mem; - ark_mem->step_supports_adaptive = SUNTRUE; + ark_mem->step_init = lsrkStep_Init; + ark_mem->step_fullrhs = lsrkStep_FullRHS; + ark_mem->step = lsrkStep_TakeStepRKC; + ark_mem->step_printallstats = lsrkStep_PrintAllStats; + ark_mem->step_writeparameters = lsrkStep_WriteParameters; + ark_mem->step_free = lsrkStep_Free; + ark_mem->step_printmem = lsrkStep_PrintMem; + ark_mem->step_setfromcommandline = lsrkStep_SetFromCommandLine; + ark_mem->step_setdefaults = lsrkStep_SetDefaults; + ark_mem->step_getnumrhsevals = lsrkStep_GetNumRhsEvals; + ark_mem->step_getestlocalerrors = lsrkStep_GetEstLocalErrors; + ark_mem->step_mem = (void*)step_mem; + ark_mem->step_supports_adaptive = SUNTRUE; /* Set default values for optional inputs */ retval = lsrkStep_SetDefaults((void*)ark_mem); diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 98dba553be..d0866dc5bb 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -186,6 +186,8 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used); int lsrkStep_SetDefaults(ARKodeMem ark_mem); int lsrkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 4ae0d494fa..4109defe11 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "arkode_lsrkstep_impl.h" @@ -264,10 +265,10 @@ int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps) /*--------------------------------------------------------------- LSRKStepSetMaxNumStages sets the maximum number of stages allowed. - If the combination of the maximum number of stages and the current - time step size in the LSRKStep module does not allow for a stable - step, the step routine returns to ARKODE for an updated (refined) - step size. The number of such returns is tracked in a counter, + If the combination of the maximum number of stages and the current + time step size in the LSRKStep module does not allow for a stable + step, the step routine returns to ARKODE for an updated (refined) + step size. The number of such returns is tracked in a counter, which can be accessed using ARKodeGetNumExpSteps. ---------------------------------------------------------------*/ int LSRKStepSetMaxNumStages(void* arkode_mem, int stage_max_limit) @@ -385,8 +386,8 @@ int LSRKStepSetNumSSPStages(void* arkode_mem, int num_of_stages) break; case ARKODE_LSRK_SSP_S_3: - /* The SSP3 method differs significantly when s = 4. Therefore, the case - where num_of_stages = 4 is considered separately to avoid unnecessary + /* The SSP3 method differs significantly when s = 4. Therefore, the case + where num_of_stages = 4 is considered separately to avoid unnecessary boolean checks and improve computational efficiency. */ /* We check that num_of_stages is a perfect square. Note the call to sqrt @@ -491,6 +492,102 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) Private functions attached to ARKODE ===============================================================*/ +/*--------------------------------------------------------------- + lsrkStep_SetFromCommandLine: + + Provides command-line control over LSRKStep-specific "set" routines. + ---------------------------------------------------------------*/ +int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used) +{ + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyCharPair char_pairs[] = + {{"sts_method", LSRKStepSetSTSMethodByName}, + {"ssp_method", LSRKStepSetSSPMethodByName}}; + static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); + + static struct sunKeyLongPair long_pairs[] = + {{"dom_eig_frequency", LSRKStepSetDomEigFrequency}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct sunKeyIntPair int_pairs[] = + {{"max_num_stages", LSRKStepSetMaxNumStages}, + {"num_ssp_stages", LSRKStepSetNumSSPStages}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct sunKeyRealPair real_pairs[] = + {{"dom_eig_safety_factor", LSRKStepSetDomEigSafetyFactor}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + /* check all "char" command-line options */ + int j, retval; + for (j = 0; j < num_char_keys; j++) + { + retval = sunCheckAndSetCharArg((void*) ark_mem, i, argv, offset, + char_pairs[j].key, + char_pairs[j].set, arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + char_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + /* check all "long int" command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg((void*) ark_mem, i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg((void*) ark_mem, i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + /* check all "real" command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg((void*) ark_mem, i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- lsrkStep_SetDefaults: diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index b81728f976..84a941191b 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -108,17 +108,18 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, N_VConst(ZERO, step_mem->yerr); } else { step_mem->yerr = NULL; } - ark_mem->step_init = sprkStep_Init; - ark_mem->step_fullrhs = sprkStep_FullRHS; - ark_mem->step = sprkStep_TakeStep; - ark_mem->step_printallstats = sprkStep_PrintAllStats; - ark_mem->step_writeparameters = sprkStep_WriteParameters; - ark_mem->step_resize = sprkStep_Resize; - ark_mem->step_free = sprkStep_Free; - ark_mem->step_setdefaults = sprkStep_SetDefaults; - ark_mem->step_setorder = sprkStep_SetOrder; - ark_mem->step_getnumrhsevals = sprkStep_GetNumRhsEvals; - ark_mem->step_mem = (void*)step_mem; + ark_mem->step_init = sprkStep_Init; + ark_mem->step_fullrhs = sprkStep_FullRHS; + ark_mem->step = sprkStep_TakeStep; + ark_mem->step_printallstats = sprkStep_PrintAllStats; + ark_mem->step_writeparameters = sprkStep_WriteParameters; + ark_mem->step_resize = sprkStep_Resize; + ark_mem->step_free = sprkStep_Free; + ark_mem->step_setfromcommandline = sprkStep_SetFromCommandLine; + ark_mem->step_setdefaults = sprkStep_SetDefaults; + ark_mem->step_setorder = sprkStep_SetOrder; + ark_mem->step_getnumrhsevals = sprkStep_GetNumRhsEvals; + ark_mem->step_mem = (void*)step_mem; /* Set default values for optional inputs */ retval = sprkStep_SetDefaults((void*)ark_mem); diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index 4c5a39326a..a67ffc29e8 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -73,6 +73,8 @@ int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used); int sprkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int sprkStep_SetDefaults(ARKodeMem ark_mem); int sprkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index f67b802ce5..16e788c22b 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "arkode/arkode.h" #include "arkode/arkode_sprk.h" @@ -208,6 +209,58 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) Private functions attached to ARKODE ===============================================================*/ +/*--------------------------------------------------------------- + sprkStep_SetFromCommandLine: + + Provides command-line control over SPRKStep-specific "set" routines. + ---------------------------------------------------------------*/ +int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used) +{ + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyCharPair char_pairs[] = {{"method_name", SPRKStepSetMethodName}}; + static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); + + static struct sunKeyIntPair int_pairs[] = {{"use_compensated_sums", SPRKStepSetUseCompensatedSums}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + /* check all "char" command-line options */ + int j, retval; + for (j = 0; j < num_char_keys; j++) + { + retval = sunCheckAndSetCharArg((void*) ark_mem, i, argv, offset, + char_pairs[j].key, char_pairs[j].set, + arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + char_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg((void*) ark_mem, i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + arg_used); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (*arg_used) { return ARK_SUCCESS; } + } + + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- sprkStep_SetDefaults: From 961ed951718b819a47dcfeeb7668c07c7af63f35 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 2 Mar 2025 20:40:27 -0600 Subject: [PATCH 026/114] Added command-line support to MRIStep --- src/arkode/arkode_arkstep_impl.h | 2 +- src/arkode/arkode_mristep.c | 1 + src/arkode/arkode_mristep_impl.h | 2 ++ src/arkode/arkode_mristep_io.c | 42 ++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 93e70f7d2d..23a40b0798 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -191,7 +191,7 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used); + const size_t offset, sunbooleantype* arg_used); int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int arkStep_SetDefaults(ARKodeMem ark_mem); int arkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 2cdc1d9f17..23e1d2b916 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -110,6 +110,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_printmem = mriStep_PrintMem; ark_mem->step_setdefaults = mriStep_SetDefaults; ark_mem->step_computestate = mriStep_ComputeState; + ark_mem->step_setfromcommandline = mriStep_SetFromCommandLine; ark_mem->step_setorder = mriStep_SetOrder; ark_mem->step_setnonlinearsolver = mriStep_SetNonlinearSolver; ark_mem->step_setlinear = mriStep_SetLinear; diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 3385ddae2b..7eeae7da4a 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -230,6 +230,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used); int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C); int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); int mriStep_SetDefaults(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index d272508c7a..fe7ee42720 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "arkode_mristep_impl.h" @@ -248,6 +249,47 @@ int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) Private functions attached to ARKODE ===============================================================*/ +/*--------------------------------------------------------------- + mriStep_SetFromCommandLine: + + Provides command-line control over MRIStep-specific "set" routines. + ---------------------------------------------------------------*/ +int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], + const size_t offset, sunbooleantype* arg_used) +{ + + /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling + table; however, these may be specified by name, so here we'll support + a command-line argument to specify the MRIStepCoupling table name, + create the table with that name, attach it to MRIStep (who copies its + values), and then free the table. */ + if (strcmp(argv[*i] + offset, "mristep_coupling_table") == 0) + { + (*i)++; + MRIStepCoupling Coupling = MRIStepCoupling_LoadTableByName(argv[*i]); + if (Coupling == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting command-line argument %s %s (invalid table name)", + argv[(*i)-1], argv[*i]); + return ARK_ILL_INPUT; + } + int retval = MRIStepSetCoupling(ark_mem, Coupling); + MRIStepCoupling_Free(Coupling); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument %s %s (SetCoupling failed)", + argv[(*i)-1], argv[*i]); + return retval; + } + *arg_used = SUNTRUE; + return ARK_SUCCESS; + } + + return ARK_SUCCESS; +} + /*--------------------------------------------------------------- mriStep_SetAdaptController: From dd2986166cda9780f2266e447b2eff2b0f87a961 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 2 Mar 2025 20:53:48 -0600 Subject: [PATCH 027/114] Added command-line support to ark_kpr_mri.c for manual testing (passes) --- examples/arkode/C_serial/ark_kpr_mri.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index af68b96c0d..3b2dcedd1c 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -529,6 +529,11 @@ int main(int argc, char* argv[]) retval = ARKodeSetFixedStep(inner_arkode_mem, hf); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } + /* Override any current settings with command-line options -- enforce + the prefix "inner" */ + retval = ARKodeSetFromCommandLine(inner_arkode_mem, "inner", argc, argv); + if (check_retval(&retval, "ARKodeSetFromCommandLine", 1)) { return 1; } + /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); if (check_retval(&retval, "ARKodeCreateMRIStepInnerStepper", 1)) { return 1; } @@ -679,6 +684,11 @@ int main(int argc, char* argv[]) retval = ARKodeSetFixedStep(arkode_mem, hs); if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } + /* Override any current settings with command-line options -- enforce + the prefix "outer" */ + retval = ARKodeSetFromCommandLine(arkode_mem, "outer", argc, argv); + if (check_retval(&retval, "ARKodeSetFromCommandLine", 1)) { return 1; } + /* * Integrate ODE */ From c175f56439d2116c609fa0c471b7ecdd9d731f54 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 2 Mar 2025 21:03:20 -0600 Subject: [PATCH 028/114] Formatting --- examples/arkode/C_serial/ark_kpr_mri.c | 4 +- include/sundials/priv/sundials_cli.h | 78 +++++++++++++++++--------- src/arkode/arkode_arkstep_io.c | 26 ++++----- src/arkode/arkode_cli.c | 42 ++++++++------ src/arkode/arkode_erkstep_io.c | 12 ++-- src/arkode/arkode_io.c | 1 - src/arkode/arkode_lsrkstep_io.c | 40 ++++++------- src/arkode/arkode_mristep_io.c | 15 +++-- src/arkode/arkode_sprkstep_io.c | 20 +++---- src/sundials/CMakeLists.txt | 4 +- src/sundials/sundials_cli.c | 39 +++++++------ 11 files changed, 156 insertions(+), 125 deletions(-) diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 3b2dcedd1c..8bc6b54594 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -531,8 +531,8 @@ int main(int argc, char* argv[]) /* Override any current settings with command-line options -- enforce the prefix "inner" */ - retval = ARKodeSetFromCommandLine(inner_arkode_mem, "inner", argc, argv); - if (check_retval(&retval, "ARKodeSetFromCommandLine", 1)) { return 1; } + retval = ARKodeSetFromCommandLine(inner_arkode_mem, "inner", argc, argv); + if (check_retval(&retval, "ARKodeSetFromCommandLine", 1)) { return 1; } /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); diff --git a/include/sundials/priv/sundials_cli.h b/include/sundials/priv/sundials_cli.h index 2c2514e3d6..2f3a6d07e1 100644 --- a/include/sundials/priv/sundials_cli.h +++ b/include/sundials/priv/sundials_cli.h @@ -18,8 +18,8 @@ #define _SUNDIALS_CLI_H #include -#include "sundials/sundials_types.h" #include "sundials/sundials_errors.h" +#include "sundials/sundials_types.h" #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -27,91 +27,119 @@ extern "C" { /* utilities for integer "set" routines */ typedef int (*sunIntSetFn)(void*, int); + struct sunKeyIntPair { const char* key; sunIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunIntSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, sunIntSetFn fname, + sunbooleantype* arg_used); /* utilities for pair-of-integer "set" routines */ typedef int (*sunTwoIntSetFn)(void*, int, int); + struct sunKeyTwoIntPair { const char* key; sunTwoIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunTwoIntSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunTwoIntSetFn fname, + sunbooleantype* arg_used); /* utilities for long int "set" routines */ typedef int (*sunLongSetFn)(void*, long int); + struct sunKeyLongPair { const char* key; sunLongSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunLongSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, sunLongSetFn fname, + sunbooleantype* arg_used); /* utilities for sunrealtype "set" routines */ typedef int (*sunRealSetFn)(void*, sunrealtype); + struct sunKeyRealPair { const char* key; sunRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetRealArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunRealSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, sunRealSetFn fname, + sunbooleantype* arg_used); /* utilities for pair-of-sunrealtype "set" routines */ typedef int (*sunTwoRealSetFn)(void*, sunrealtype, sunrealtype); + struct sunKeyTwoRealPair { const char* key; sunTwoRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunTwoRealSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunTwoRealSetFn fname, + sunbooleantype* arg_used); /* utilities for char* "set" routines */ typedef int (*sunCharSetFn)(void*, const char*); + struct sunKeyCharPair { const char* key; sunCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunCharSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, sunCharSetFn fname, + sunbooleantype* arg_used); /* utilities for pair-of-char* "set" routines */ typedef int (*sunTwoCharSetFn)(void*, const char*, const char*); + struct sunKeyTwoCharPair { const char* key; sunTwoCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunTwoCharSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunTwoCharSetFn fname, + sunbooleantype* arg_used); /* utilities for action "set" routines */ typedef int (*sunActionSetFn)(void*); + struct sunKeyActionPair { const char* key; sunActionSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* i, - char* argv[], const size_t offset, const char* argtest, - sunActionSetFn fname, sunbooleantype* arg_used); + +SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunActionSetFn fname, + sunbooleantype* arg_used); #ifdef __cplusplus } diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 62be64a778..c2f04d8b27 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -21,9 +21,9 @@ #include #include +#include #include #include -#include #include "arkode_arkstep_impl.h" @@ -637,23 +637,24 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyTwoCharPair twochar_pairs[] = - {{"table_names", ARKStepSetTableName}}; - static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); - - static struct sunKeyActionPair action_pairs[] = - {{"set_explicit", ARKStepSetExplicit}, - {"set_implicit", ARKStepSetImplicit}, - {"set_imex", ARKStepSetImEx}}; + static struct sunKeyTwoCharPair twochar_pairs[] = { + {"table_names", ARKStepSetTableName}}; + static const int num_twochar_keys = sizeof(twochar_pairs) / + sizeof(*twochar_pairs); + + static struct sunKeyActionPair action_pairs[] = {{"set_explicit", + ARKStepSetExplicit}, + {"set_implicit", + ARKStepSetImplicit}, + {"set_imex", ARKStepSetImEx}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); /* check all "twochar" command-line options */ int j, retval; for (j = 0; j < num_twochar_keys; j++) { - retval = sunCheckAndSetTwoCharArg((void*) ark_mem, i, argv, offset, + retval = sunCheckAndSetTwoCharArg((void*)ark_mem, i, argv, offset, twochar_pairs[j].key, twochar_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -669,7 +670,7 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg((void*) ark_mem, i, argv, offset, + retval = sunCheckAndSetActionArg((void*)ark_mem, i, argv, offset, action_pairs[j].key, action_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -685,7 +686,6 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], return (ARK_SUCCESS); } - /*--------------------------------------------------------------- arkStep_SetRelaxFn: diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 3af0ccd79b..d9d88c57b4 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include "arkode/arkode.h" #include "arkode_impl.h" @@ -32,7 +32,7 @@ ---------------------------------------------------------------*/ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, - char* argv[]) + char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -87,10 +87,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = - {{"scalar_tolerances", ARKodeSStolerances}, - {"fixed_step_bounds", ARKodeSetFixedStepBounds}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + static struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", + ARKodeSStolerances}, + {"fixed_step_bounds", + ARKodeSetFixedStepBounds}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); static struct sunKeyActionPair action_pairs[] = {{"nonlinear", ARKodeSetNonlinear}, @@ -108,7 +110,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* if arkid is supplied, skip command-line arguments that do not begin with arkid; else, skip command-line arguments that do not begin with "arkode." */ size_t offset; - if (strlen(arkid) > 0) { + if (strlen(arkid) > 0) + { if (strncmp(argv[i], arkid, strlen(arkid)) != 0) { continue; } offset = strlen(arkid) + 1; } @@ -122,8 +125,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(arkode_mem, &i, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + retval = sunCheckAndSetIntArg(arkode_mem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -138,8 +142,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(arkode_mem, &i, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); + retval = sunCheckAndSetLongArg(arkode_mem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -154,8 +159,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(arkode_mem, &i, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); + retval = sunCheckAndSetRealArg(arkode_mem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -170,7 +176,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(arkode_mem, &i, argv, offset, tworeal_pairs[j].key, + retval = sunCheckAndSetTwoRealArg(arkode_mem, &i, argv, offset, + tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (retval != ARK_SUCCESS) { @@ -263,7 +270,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, if (strcmp(argv[i] + offset, "writeparameters") == 0) { write_parameters = SUNTRUE; - arg_used = SUNTRUE; + arg_used = SUNTRUE; continue; } @@ -271,8 +278,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, process this command-line argument */ if (ark_mem->step_setfromcommandline) { - retval = ark_mem->step_setfromcommandline(ark_mem, &i, argv, - offset, &arg_used); + retval = ark_mem->step_setfromcommandline(ark_mem, &i, argv, offset, + &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) { continue; } } @@ -282,7 +289,6 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, "WARNING: argument %s was not handled\n", argv[i]); } - /* Call ARKodeWriteParameters (if requested) now that all command-line options have been set -- WARNING: this knows nothing about MPI, so it could be redundantly written by all diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index d37ba9bb22..82f140ef57 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -21,9 +21,9 @@ #include #include +#include #include #include -#include #include "arkode_erkstep_impl.h" @@ -264,18 +264,18 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = {{"table_name", ERKStepSetTableName}}; + static struct sunKeyCharPair char_pairs[] = { + {"table_name", ERKStepSetTableName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); /* check all "char" command-line options */ int j, retval; for (j = 0; j < num_char_keys; j++) { - retval = sunCheckAndSetCharArg((void*) ark_mem, i, argv, offset, - char_pairs[j].key, - char_pairs[j].set, arg_used); + retval = sunCheckAndSetCharArg((void*)ark_mem, i, argv, offset, + char_pairs[j].key, char_pairs[j].set, + arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index f1541013e9..bda1f3aa29 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -31,7 +31,6 @@ ARKODE optional input functions ===============================================================*/ - /*--------------------------------------------------------------- ARKodeSetDefaults: diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 4109defe11..73d0d18fb8 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -17,9 +17,9 @@ #include #include +#include #include #include -#include #include #include "arkode_lsrkstep_impl.h" @@ -500,33 +500,34 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = - {{"sts_method", LSRKStepSetSTSMethodByName}, - {"ssp_method", LSRKStepSetSSPMethodByName}}; + static struct sunKeyCharPair char_pairs[] = {{"sts_method", + LSRKStepSetSTSMethodByName}, + {"ssp_method", + LSRKStepSetSSPMethodByName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); - static struct sunKeyLongPair long_pairs[] = - {{"dom_eig_frequency", LSRKStepSetDomEigFrequency}}; + static struct sunKeyLongPair long_pairs[] = { + {"dom_eig_frequency", LSRKStepSetDomEigFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyIntPair int_pairs[] = - {{"max_num_stages", LSRKStepSetMaxNumStages}, - {"num_ssp_stages", LSRKStepSetNumSSPStages}}; + static struct sunKeyIntPair int_pairs[] = {{"max_num_stages", + LSRKStepSetMaxNumStages}, + {"num_ssp_stages", + LSRKStepSetNumSSPStages}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyRealPair real_pairs[] = - {{"dom_eig_safety_factor", LSRKStepSetDomEigSafetyFactor}}; + static struct sunKeyRealPair real_pairs[] = { + {"dom_eig_safety_factor", LSRKStepSetDomEigSafetyFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); /* check all "char" command-line options */ int j, retval; for (j = 0; j < num_char_keys; j++) { - retval = sunCheckAndSetCharArg((void*) ark_mem, i, argv, offset, - char_pairs[j].key, - char_pairs[j].set, arg_used); + retval = sunCheckAndSetCharArg((void*)ark_mem, i, argv, offset, + char_pairs[j].key, char_pairs[j].set, + arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -540,7 +541,7 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "long int" command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg((void*) ark_mem, i, argv, offset, + retval = sunCheckAndSetLongArg((void*)ark_mem, i, argv, offset, long_pairs[j].key, long_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -556,9 +557,8 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg((void*) ark_mem, i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - arg_used); + retval = sunCheckAndSetIntArg((void*)ark_mem, i, argv, offset, + int_pairs[j].key, int_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -572,7 +572,7 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "real" command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg((void*) ark_mem, i, argv, offset, + retval = sunCheckAndSetRealArg((void*)ark_mem, i, argv, offset, real_pairs[j].key, real_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index fe7ee42720..baf7384c19 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -18,9 +18,9 @@ #include #include +#include #include #include -#include #include "arkode_mristep_impl.h" @@ -257,7 +257,6 @@ int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { - /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling table; however, these may be specified by name, so here we'll support a command-line argument to specify the MRIStepCoupling table name, @@ -269,18 +268,18 @@ int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], MRIStepCoupling Coupling = MRIStepCoupling_LoadTableByName(argv[*i]); if (Coupling == NULL) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "error setting command-line argument %s %s (invalid table name)", - argv[(*i)-1], argv[*i]); + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, + __FILE__, "error setting command-line argument %s %s (invalid table name)", + argv[(*i) - 1], argv[*i]); return ARK_ILL_INPUT; } int retval = MRIStepSetCoupling(ark_mem, Coupling); MRIStepCoupling_Free(Coupling); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument %s %s (SetCoupling failed)", - argv[(*i)-1], argv[*i]); + arkProcessError(ark_mem, retval, __LINE__, __func__, + __FILE__, "error setting command-line argument %s %s (SetCoupling failed)", + argv[(*i) - 1], argv[*i]); return retval; } *arg_used = SUNTRUE; diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 16e788c22b..6dfddd2253 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -21,9 +21,9 @@ #include #include +#include #include #include -#include #include "arkode/arkode.h" #include "arkode/arkode_sprk.h" @@ -217,21 +217,22 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = {{"method_name", SPRKStepSetMethodName}}; + static struct sunKeyCharPair char_pairs[] = { + {"method_name", SPRKStepSetMethodName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); - static struct sunKeyIntPair int_pairs[] = {{"use_compensated_sums", SPRKStepSetUseCompensatedSums}}; + static struct sunKeyIntPair int_pairs[] = { + {"use_compensated_sums", SPRKStepSetUseCompensatedSums}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); /* check all "char" command-line options */ int j, retval; for (j = 0; j < num_char_keys; j++) { - retval = sunCheckAndSetCharArg((void*) ark_mem, i, argv, offset, - char_pairs[j].key, char_pairs[j].set, - arg_used); + retval = sunCheckAndSetCharArg((void*)ark_mem, i, argv, offset, + char_pairs[j].key, char_pairs[j].set, + arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -245,9 +246,8 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg((void*) ark_mem, i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - arg_used); + retval = sunCheckAndSetIntArg((void*)ark_mem, i, argv, offset, + int_pairs[j].key, int_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index a0e8877730..1d5d4eb252 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -136,8 +136,8 @@ sundials_add_library( # Install private headers install( FILES ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_context_impl.h - ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_errors_impl.h - ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_cli.h + ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_errors_impl.h + ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_cli.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials/priv") if(ENABLE_MPI) diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index f8ec0eae34..b6ebb7b4f1 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -18,22 +18,22 @@ #include #include #include -#include #include +#include /*=============================================================== Command-line input utility routines ===============================================================*/ -int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], - const size_t offset, const char* argtest, - sunIntSetFn fname, sunbooleantype* arg_used) +int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], const size_t offset, + const char* argtest, sunIntSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; - int iarg = atoi(argv[*i]); + int iarg = atoi(argv[*i]); int retval = fname(mem, iarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -51,7 +51,7 @@ int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], (*i) += 1; int iarg1 = atoi(argv[*i]); (*i) += 1; - int iarg2 = atoi(argv[*i]); + int iarg2 = atoi(argv[*i]); int retval = fname(mem, iarg1, iarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -59,32 +59,32 @@ int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], - const size_t offset, const char* argtest, - sunLongSetFn fname, sunbooleantype* arg_used) +int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t offset, + const char* argtest, sunLongSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; long int iarg = atol(argv[*i]); - int retval = fname(mem, iarg); + int retval = fname(mem, iarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } return SUN_SUCCESS; } -int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], - const size_t offset, const char* argtest, - sunRealSetFn fname, sunbooleantype* arg_used) +int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, + const char* argtest, sunRealSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; sunrealtype rarg = atof(argv[*i]); - int retval = fname(mem, rarg); + int retval = fname(mem, rarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } @@ -102,16 +102,16 @@ int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], sunrealtype rarg1 = atof(argv[*i]); (*i) += 1; sunrealtype rarg2 = atof(argv[*i]); - int retval = fname(mem, rarg1, rarg2); + int retval = fname(mem, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } return SUN_SUCCESS; } -int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], - const size_t offset, const char* argtest, - sunCharSetFn fname, sunbooleantype* arg_used) +int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], const size_t offset, + const char* argtest, sunCharSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) @@ -131,7 +131,7 @@ int sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], *arg_used = SUNFALSE; if (strcmp(argv[*i] + offset, argtest) == 0) { - int retval = fname(mem, argv[*i+1], argv[*i+2]); + int retval = fname(mem, argv[*i + 1], argv[*i + 2]); (*i) += 2; if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -152,4 +152,3 @@ int sunCheckAndSetActionArg(void* mem, int* i, char* argv[], } return SUN_SUCCESS; } - From b1fd734468ce6670d893216b47d8c65d73e110db Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 14:18:33 -0500 Subject: [PATCH 029/114] Update src/arkode/arkode_cli.c Update format for command-line option to call `ARKodeWriteParameters` Co-authored-by: Steven Roberts --- src/arkode/arkode_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index d9d88c57b4..1b1f2000f4 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -267,7 +267,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, continue; } - if (strcmp(argv[i] + offset, "writeparameters") == 0) + if (strcmp(argv[i] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; arg_used = SUNTRUE; From d24a61a8e74c8c7956c0d5b781c330831f2e4c5c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 16:50:29 -0500 Subject: [PATCH 030/114] Moved sundials_cli.h to src/sundials --- src/arkode/arkode_arkstep_io.c | 2 +- src/arkode/arkode_cli.c | 2 +- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_lsrkstep_io.c | 2 +- src/arkode/arkode_mristep_io.c | 2 +- src/arkode/arkode_sprkstep_io.c | 2 +- src/sundials/CMakeLists.txt | 1 - src/sundials/sundials_cli.c | 2 +- {include/sundials/priv => src/sundials}/sundials_cli.h | 0 9 files changed, 7 insertions(+), 8 deletions(-) rename {include/sundials/priv => src/sundials}/sundials_cli.h (100%) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index c2f04d8b27..89a6e63ea0 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -21,10 +21,10 @@ #include #include -#include #include #include +#include "sundials_cli.h" #include "arkode_arkstep_impl.h" /*=============================================================== diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 1b1f2000f4..f1aac67dcd 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include "sundials_cli.h" #include "arkode/arkode.h" #include "arkode_impl.h" diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 82f140ef57..85e3589cd0 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -21,10 +21,10 @@ #include #include -#include #include #include +#include "sundials_cli.h" #include "arkode_erkstep_impl.h" /*=============================================================== diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 73d0d18fb8..9236f1a4ee 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -17,11 +17,11 @@ #include #include -#include #include #include #include +#include "sundials_cli.h" #include "arkode_lsrkstep_impl.h" /*=============================================================== diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index baf7384c19..8bc19cbc53 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -18,10 +18,10 @@ #include #include -#include #include #include +#include "sundials_cli.h" #include "arkode_mristep_impl.h" /*=============================================================== diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 6dfddd2253..81ed0dc357 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -21,10 +21,10 @@ #include #include -#include #include #include +#include "sundials_cli.h" #include "arkode/arkode.h" #include "arkode/arkode_sprk.h" #include "arkode_sprkstep_impl.h" diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 1d5d4eb252..b012026ef2 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -137,7 +137,6 @@ sundials_add_library( install( FILES ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_context_impl.h ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_errors_impl.h - ${SUNDIALS_SOURCE_DIR}/include/sundials/priv/sundials_cli.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials/priv") if(ENABLE_MPI) diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index b6ebb7b4f1..32f12255e0 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include "sundials_cli.h" /*=============================================================== Command-line input utility routines diff --git a/include/sundials/priv/sundials_cli.h b/src/sundials/sundials_cli.h similarity index 100% rename from include/sundials/priv/sundials_cli.h rename to src/sundials/sundials_cli.h From a0e5a17fb88376572efafff733da25e02469ccf2 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 17:39:42 -0500 Subject: [PATCH 031/114] Added ARKODE command-line control for linear solver set routines --- src/arkode/arkode_cli.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index f1aac67dcd..a5894e11e0 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -21,14 +21,13 @@ #include #include "sundials_cli.h" #include "arkode/arkode.h" +#include "arkode/arkode_ls.h" #include "arkode_impl.h" /*--------------------------------------------------------------- ARKodeSetFromCommandLine: Parses the command line to control scalar-valued ARKODE options. - - (this leverages a multiple typedefs and static utility routines) ---------------------------------------------------------------*/ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, @@ -59,11 +58,13 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, {"small_num_efails", ARKodeSetSmallNumEFails}, {"max_err_test_fails", ARKodeSetMaxErrTestFails}, - {"max_conv_fails", ARKodeSetMaxConvFails}}; + {"max_conv_fails", ARKodeSetMaxConvFails}, + {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = { - {"max_num_steps", ARKodeSetMaxNumSteps}}; + {"max_num_steps", ARKodeSetMaxNumSteps}, + {"jac_eval_frequency", ARKodeSetJacEvalFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static struct sunKeyRealPair real_pairs[] = @@ -84,7 +85,11 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"min_reduction", ARKodeSetMinReduction}, {"max_first_growth", ARKodeSetMaxFirstGrowth}, {"max_efail_growth", ARKodeSetMaxEFailGrowth}, - {"max_cfail_growth", ARKodeSetMaxCFailGrowth}}; + {"max_cfail_growth", ARKodeSetMaxCFailGrowth}, + {"eps_lin", ARKodeSetEpsLin}, + {"mass_eps_lin", ARKodeSetMassEpsLin}, + {"ls_norm_factor", ARKodeSetLSNormFactor}, + {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); static struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", From 459c58b665031a644428469f1a8f60e3b9c6bf37 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 17:40:02 -0500 Subject: [PATCH 032/114] Added command-line control for CVODE --- examples/cvode/CXX_serial/cv_kpr.cpp | 4 ++++ include/cvode/cvode.h | 2 ++ src/cvode/CMakeLists.txt | 1 + 3 files changed, 7 insertions(+) diff --git a/examples/cvode/CXX_serial/cv_kpr.cpp b/examples/cvode/CXX_serial/cv_kpr.cpp index 3d36ddaf5c..5a3f22612a 100644 --- a/examples/cvode/CXX_serial/cv_kpr.cpp +++ b/examples/cvode/CXX_serial/cv_kpr.cpp @@ -110,6 +110,10 @@ int main(int argc, char* argv[]) flag = CVodeSetUserData(cvode_mem, udata); if (check_flag(flag, "CVodeSetUserData")) { return 1; } + /* Override any current settings with command-line options */ + flag = CVodeSetFromCommandLine(cvode_mem, "", argc, argv); + if (check_flag(flag, "CVodeSetFromCommandLine")) { return 1; } + // Initial time and fist output time sunrealtype tret = ZERO; sunrealtype tout = tret + opts.dtout; diff --git a/include/cvode/cvode.h b/include/cvode/cvode.h index 7466766f2b..edfd9c0ea9 100644 --- a/include/cvode/cvode.h +++ b/include/cvode/cvode.h @@ -116,6 +116,8 @@ SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun); /* Optional input functions */ +SUNDIALS_EXPORT int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, + int argc, char* argv[]); SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints); SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem, sunrealtype dgmax_lsetup); diff --git a/src/cvode/CMakeLists.txt b/src/cvode/CMakeLists.txt index 6f94b3b085..7a7b6ecb89 100644 --- a/src/cvode/CMakeLists.txt +++ b/src/cvode/CMakeLists.txt @@ -22,6 +22,7 @@ set(cvode_SOURCES cvode.c cvode_bandpre.c cvode_bbdpre.c + cvode_cli.c cvode_diag.c cvode_io.c cvode_ls.c From d35479ed3695d6bd8b62c0becd5162a499eeaf5f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 17:40:10 -0500 Subject: [PATCH 033/114] Added command-line control for CVODE --- src/cvode/cvode_cli.c | 217 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 src/cvode/cvode_cli.c diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c new file mode 100644 index 0000000000..30e4e3535c --- /dev/null +++ b/src/cvode/cvode_cli.c @@ -0,0 +1,217 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to CVODE. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "sundials_cli.h" +#include "cvode/cvode.h" +#include "cvode/cvode_ls.h" +#include "cvode/cvode_proj.h" +#include "cvode_impl.h" + +/*--------------------------------------------------------------- + CVodeSetFromCommandLine: + + Parses the command line to control scalar-valued CVODE options. + ---------------------------------------------------------------*/ + +int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, + char* argv[]) +{ + CVodeMem cv_mem; + if (cvode_mem == NULL) + { + cvProcessError(NULL, CV_MEM_NULL, __LINE__, __func__, __FILE__, + MSGCV_NO_MEM); + return (CV_MEM_NULL); + } + cv_mem = (CVodeMem)cvode_mem; + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyIntPair int_pairs[] = + {{"max_conv_fails", CVodeSetMaxConvFails}, + {"max_err_test_fails", CVodeSetMaxErrTestFails}, + {"max_hnil_warns", CVodeSetMaxHnilWarns}, + {"max_nonlin_iters", CVodeSetMaxNonlinIters}, + {"max_order", CVodeSetMaxOrd}, + {"stab_lim_det", CVodeSetStabLimDet}, + {"interpolate_stop_time", CVodeSetInterpolateStopTime}, + {"use_integrator_fused_kernels", CVodeSetUseIntegratorFusedKernels}, + {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, + {"proj_err_est", CVodeSetProjErrEst}, + {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct sunKeyLongPair long_pairs[] = { + {"lsetup_frequency", CVodeSetLSetupFrequency}, + {"max_num_steps", CVodeSetMaxNumSteps}, + {"monitor_frequency", CVodeSetMonitorFrequency}, + {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, + {"jac_eval_frequency", CVodeSetJacEvalFrequency}, + {"proj_frequency", CVodeSetProjFrequency}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct sunKeyRealPair real_pairs[] = + {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {"init_step", CVodeSetInitStep}, + {"max_step", CVodeSetMaxStep}, + {"min_step", CVodeSetMinStep}, + {"stop_time", CVodeSetStopTime}, + {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, + {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, + {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, + {"eta_max", CVodeSetEtaMax}, + {"eta_min", CVodeSetEtaMin}, + {"eta_min_err_fail", CVodeSetEtaMinErrFail}, + {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, + {"eta_conv_fail", CVodeSetEtaConvFail}, + {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, + {"eps_lin", CVodeSetEpsLin}, + {"ls_norm_factor", CVodeSetLSNormFactor}, + {"eps_proj", CVodeSetEpsProj}, + {"proj_fail_eta", CVodeSetProjFailEta}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + static struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", CVodeSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + + static struct sunKeyActionPair action_pairs[] = + {{"clear_stop_time", CVodeClearStopTime}, + {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if cvid is supplied, skip command-line arguments that do not begin with cvid; + else, skip command-line arguments that do not begin with "cvode." */ + size_t offset; + if (strlen(cvid) > 0) + { + if (strncmp(argv[i], cvid, strlen(cvid)) != 0) { continue; } + offset = strlen(cvid) + 1; + } + else + { + static const char* prefix = "cvode."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* warn for uninterpreted cvid.X arguments */ + cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (CV_SUCCESS); +} + +/*=============================================================== + EOF + ===============================================================*/ From 3a9a4ff4aa2e46e849e5ed28966eb3a0e2bd45a6 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 20:13:51 -0500 Subject: [PATCH 034/114] Added command-line control to CVODES --- examples/cvodes/serial/cvsAnalytic_mels.c | 6 +- include/cvodes/cvodes.h | 2 + src/cvodes/CMakeLists.txt | 1 + src/cvodes/cvodes_cli.c | 320 ++++++++++++++++++++++ src/sundials/sundials_cli.c | 57 ++++ src/sundials/sundials_cli.h | 45 +++ 6 files changed, 430 insertions(+), 1 deletion(-) create mode 100644 src/cvodes/cvodes_cli.c diff --git a/examples/cvodes/serial/cvsAnalytic_mels.c b/examples/cvodes/serial/cvsAnalytic_mels.c index 87d89c5459..b660180c6f 100644 --- a/examples/cvodes/serial/cvsAnalytic_mels.c +++ b/examples/cvodes/serial/cvsAnalytic_mels.c @@ -66,7 +66,7 @@ static int check_retval(void* returnvalue, const char* funcname, int opt); static SUNContext sunctx; /* Main Program */ -int main(void) +int main(int argc, char* argv[]) { /* general problem parameters */ sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ @@ -127,6 +127,10 @@ int main(void) retval = CVodeSetLinearSolver(cvode_mem, LS, NULL); if (check_retval(&retval, "CVodeSetLinearSolver", 1)) { return 1; } + /* Override any current settings with command-line options */ + retval = CVodeSetFromCommandLine(cvode_mem, "", argc, argv); + if (check_retval(&retval, "CVodeSetFromCommandLine", 1)) { return (1); } + /* In loop, call CVode, print results, and test for error. Break out of loop when NOUT preset output times have been reached. */ t = T0; diff --git a/include/cvodes/cvodes.h b/include/cvodes/cvodes.h index 5ac59dbde2..7ffe3d73b6 100644 --- a/include/cvodes/cvodes.h +++ b/include/cvodes/cvodes.h @@ -187,6 +187,8 @@ SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun); /* Optional input functions */ +SUNDIALS_EXPORT int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, + int argc, char* argv[]); SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints); SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem, sunrealtype dgmax_lsetup); diff --git a/src/cvodes/CMakeLists.txt b/src/cvodes/CMakeLists.txt index 9888aebfbe..9a0c3079ec 100644 --- a/src/cvodes/CMakeLists.txt +++ b/src/cvodes/CMakeLists.txt @@ -24,6 +24,7 @@ set(cvodes_SOURCES cvodes.c cvodes_bandpre.c cvodes_bbdpre.c + cvodes_cli.c cvodes_diag.c cvodes_io.c cvodes_ls.c diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c new file mode 100644 index 0000000000..674e144b50 --- /dev/null +++ b/src/cvodes/cvodes_cli.c @@ -0,0 +1,320 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to CVODE. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "sundials_cli.h" +#include "cvodes/cvodes.h" +#include "cvodes/cvodes_ls.h" +#include "cvodes/cvodes_proj.h" +#include "cvodes_impl.h" + +/*--------------------------------------------------------------- + CVodeSetFromCommandLine: + + Parses the command line to control scalar-valued CVODE options. + ---------------------------------------------------------------*/ + +int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, + char* argv[]) +{ + CVodeMem cv_mem; + if (cvode_mem == NULL) + { + cvProcessError(NULL, CV_MEM_NULL, __LINE__, __func__, __FILE__, + MSGCV_NO_MEM); + return (CV_MEM_NULL); + } + cv_mem = (CVodeMem)cvode_mem; + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyIntPair int_pairs[] = { + {"max_conv_fails", CVodeSetMaxConvFails}, + {"max_err_test_fails", CVodeSetMaxErrTestFails}, + {"max_hnil_warns", CVodeSetMaxHnilWarns}, + {"max_nonlin_iters", CVodeSetMaxNonlinIters}, + {"max_order", CVodeSetMaxOrd}, + {"stab_lim_det", CVodeSetStabLimDet}, + {"interpolate_stop_time", CVodeSetInterpolateStopTime}, + {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"quad_err_con", CVodeSetQuadErrCon}, + {"sens_err_con", CVodeSetSensErrCon}, + {"sens_max_nonlin_iters", CVodeSetSensMaxNonlinIters}, + {"quad_sens_err_con", CVodeSetQuadSensErrCon}, + {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, + {"proj_err_est", CVodeSetProjErrEst}, + {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct sunKeyLongPair long_pairs[] = { + {"lsetup_frequency", CVodeSetLSetupFrequency}, + {"max_num_steps", CVodeSetMaxNumSteps}, + {"monitor_frequency", CVodeSetMonitorFrequency}, + {"jac_eval_frequency", CVodeSetJacEvalFrequency}, + {"proj_frequency", CVodeSetProjFrequency}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct sunKeyRealPair real_pairs[] = { + {"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {"init_step", CVodeSetInitStep}, + {"max_step", CVodeSetMaxStep}, + {"min_step", CVodeSetMinStep}, + {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, + {"stop_time", CVodeSetStopTime}, + {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, + {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, + {"eta_max", CVodeSetEtaMax}, + {"eta_min", CVodeSetEtaMin}, + {"eta_min_err_fail", CVodeSetEtaMinErrFail}, + {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, + {"eta_conv_fail", CVodeSetEtaConvFail}, + {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, + {"eps_lin", CVodeSetEpsLin}, + {"ls_norm_factor", CVodeSetLSNormFactor}, + {"eps_proj", CVodeSetEpsProj}, + {"proj_fail_eta", CVodeSetProjFailEta}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", CVodeSStolerances}, + {"quad_scalar_tolerances", CVodeQuadSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + + static struct sunKeyTwoIntPair twoint_pairs[] = { + {"max_ord_b", CVodeSetMaxOrdB}, + {"stab_lim_det_b", CVodeSetStabLimDetB}, + {"quad_err_con_b", CVodeSetQuadErrConB}, + {"linear_solution_scaling_b", CVodeSetLinearSolutionScalingB}}; + static const int num_twoint_keys = sizeof(twoint_pairs) / sizeof(*twoint_pairs); + + static struct sunKeyActionPair action_pairs[] = { + {"clear_stop_time", CVodeClearStopTime}, + {"adj_no_sensi", CVodeSetAdjNoSensi}, + {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + static struct sunKeyIntRealPair int_real_pairs[] = { + {"sens_dq_method", CVodeSetSensDQMethod}, + {"init_step_b", CVodeSetInitStepB}, + {"min_step_b", CVodeSetMinStepB}, + {"max_step_b", CVodeSetMaxStepB}, + {"eps_lin_b", CVodeSetEpsLinB}, + {"ls_norm_factor_b", CVodeSetLSNormFactorB}}; + static const int num_int_real_keys = sizeof(int_real_pairs) / + sizeof(*int_real_pairs); + + static struct sunKeyIntRealRealPair int_real_real_pairs[] = { + {"scalar_tolerances_b", CVodeSStolerancesB}, + {"quad_scalar_tolerances_b", CVodeQuadSStolerancesB}}; + static const int num_int_real_real_keys = sizeof(int_real_real_pairs) / + sizeof(*int_real_real_pairs); + + static struct sunKeyIntLongPair int_long_pairs[] = { + {"max_num_steps_b", CVodeSetMaxNumStepsB}}; + static const int num_int_long_keys = sizeof(int_long_pairs) / + sizeof(*int_long_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if cvid is supplied, skip command-line arguments that do not begin with cvid; + else, skip command-line arguments that do not begin with "cvode." */ + size_t offset; + if (strlen(cvid) > 0) + { + if (strncmp(argv[i], cvid, strlen(cvid)) != 0) { continue; } + offset = strlen(cvid) + 1; + } + else + { + static const char* prefix = "cvodes."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-int command-line options */ + for (j = 0; j < num_twoint_keys; j++) + { + retval = sunCheckAndSetTwoIntArg(cvode_mem, &i, argv, offset, + twoint_pairs[j].key, + twoint_pairs[j].set, &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + twoint_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all int+real command-line options */ + for (j = 0; j < num_int_real_keys; j++) + { + retval = sunCheckAndSetIntRealArg(cvode_mem, &i, argv, offset, + int_real_pairs[j].key, + int_real_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all int+long command-line options */ + for (j = 0; j < num_int_long_keys; j++) + { + retval = sunCheckAndSetIntLongArg(cvode_mem, &i, argv, offset, + int_long_pairs[j].key, + int_long_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all int+real+real command-line options */ + for (j = 0; j < num_int_real_real_keys; j++) + { + retval = sunCheckAndSetIntRealRealArg(cvode_mem, &i, argv, offset, + int_real_real_pairs[j].key, + int_real_real_pairs[j].set, + &arg_used); + if (retval != CV_SUCCESS) + { + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* warn for uninterpreted cvid.X arguments */ + cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (CV_SUCCESS); +} + +/*=============================================================== + EOF + ===============================================================*/ diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index 32f12255e0..f2b1df210a 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -75,6 +75,63 @@ int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t offset, return SUN_SUCCESS; } +int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunIntRealSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int iarg = atoi(argv[*i]); + (*i) += 1; + sunrealtype rarg = atof(argv[*i]); + int retval = fname(mem, iarg, rarg); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunIntRealRealSetFn fname, + sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int iarg = atoi(argv[*i]); + (*i) += 1; + sunrealtype rarg1 = atof(argv[*i]); + (*i) += 1; + sunrealtype rarg2 = atof(argv[*i]); + int retval = fname(mem, iarg, rarg1, rarg2); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + +int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], + const size_t offset, const char* argtest, + sunIntLongSetFn fname, sunbooleantype* arg_used) +{ + *arg_used = SUNFALSE; + if (strcmp(argv[*i] + offset, argtest) == 0) + { + (*i) += 1; + int iarg = atoi(argv[*i]); + (*i) += 1; + long int larg = atol(argv[*i]); + int retval = fname(mem, iarg, larg); + if (retval != SUN_SUCCESS) { return retval; } + *arg_used = SUNTRUE; + } + return SUN_SUCCESS; +} + int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunRealSetFn fname, sunbooleantype* arg_used) diff --git a/src/sundials/sundials_cli.h b/src/sundials/sundials_cli.h index 2f3a6d07e1..e2d7110010 100644 --- a/src/sundials/sundials_cli.h +++ b/src/sundials/sundials_cli.h @@ -68,6 +68,51 @@ SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const char* argtest, sunLongSetFn fname, sunbooleantype* arg_used); +/* utilities for pair int/sunrealtype "set" routines */ +typedef int (*sunIntRealSetFn)(void*, int, sunrealtype); + +struct sunKeyIntRealPair +{ + const char* key; + sunIntRealSetFn set; +}; + +SUNDIALS_EXPORT int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunIntRealSetFn fname, + sunbooleantype* arg_used); + +/* utilities for triplet int/sunrealtype/sunrealtype "set" routines */ +typedef int (*sunIntRealRealSetFn)(void*, int, sunrealtype, sunrealtype); + +struct sunKeyIntRealRealPair +{ + const char* key; + sunIntRealRealSetFn set; +}; + +SUNDIALS_EXPORT int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunIntRealRealSetFn fname, + sunbooleantype* arg_used); + +/* utilities for pair int/long int "set" routines */ +typedef int (*sunIntLongSetFn)(void*, int, long int); + +struct sunKeyIntLongPair +{ + const char* key; + sunIntLongSetFn set; +}; + +SUNDIALS_EXPORT int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], + const size_t offset, + const char* argtest, + sunIntLongSetFn fname, + sunbooleantype* arg_used); + /* utilities for sunrealtype "set" routines */ typedef int (*sunRealSetFn)(void*, sunrealtype); From 0c525e0ceb78fc4017ec04e12effd95209abd627 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 20:33:32 -0500 Subject: [PATCH 035/114] Added command-line control to IDA --- examples/cvode/CXX_serial/cv_kpr.cpp | 2 +- examples/ida/serial/idaAnalytic_mels.c | 6 +- include/ida/ida.h | 4 + src/ida/CMakeLists.txt | 2 +- src/ida/ida_cli.c | 208 +++++++++++++++++++++++++ 5 files changed, 219 insertions(+), 3 deletions(-) create mode 100644 src/ida/ida_cli.c diff --git a/examples/cvode/CXX_serial/cv_kpr.cpp b/examples/cvode/CXX_serial/cv_kpr.cpp index 5a3f22612a..628be80d9c 100644 --- a/examples/cvode/CXX_serial/cv_kpr.cpp +++ b/examples/cvode/CXX_serial/cv_kpr.cpp @@ -110,7 +110,7 @@ int main(int argc, char* argv[]) flag = CVodeSetUserData(cvode_mem, udata); if (check_flag(flag, "CVodeSetUserData")) { return 1; } - /* Override any current settings with command-line options */ + // Override any current settings with command-line options flag = CVodeSetFromCommandLine(cvode_mem, "", argc, argv); if (check_flag(flag, "CVodeSetFromCommandLine")) { return 1; } diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index 2cd01d06c5..37ee3c54ad 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -64,7 +64,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype atol); /* Main Program */ -int main(void) +int main(int argc, char* argv[]) { /* SUNDIALS context object */ SUNContext ctx; @@ -124,6 +124,10 @@ int main(void) retval = IDASetLinearSolver(ida_mem, LS, NULL); if (check_retval(&retval, "IDASetLinearSolver", 1)) { return (1); } + /* Override any current settings with command-line options */ + retval = IDASetFromCommandLine(ida_mem, "", argc, argv); + if (check_retval(&retval, "IDASetFromCommandLine", 1)) { return 1; } + /* In loop, call IDASolve, print results, and test for error. Stops when the final time has been reached. */ t = T0; diff --git a/include/ida/ida.h b/include/ida/ida.h index 17e82d2d09..c9bdbcd14c 100644 --- a/include/ida/ida.h +++ b/include/ida/ida.h @@ -114,6 +114,10 @@ SUNDIALS_EXPORT int IDAWFtolerances(void* ida_mem, IDAEwtFn efun); /* Initial condition calculation function */ SUNDIALS_EXPORT int IDACalcIC(void* ida_mem, int icopt, sunrealtype tout1); +/* Command-line control over scalar-valued set routines */ +SUNDIALS_EXPORT int IDASetFromCommandLine(void* ida_mem, const char* idaid, + int argc, char* argv[]); + /* Initial condition calculation optional input functions */ SUNDIALS_EXPORT int IDASetNonlinConvCoefIC(void* ida_mem, sunrealtype epiccon); SUNDIALS_EXPORT int IDASetMaxNumStepsIC(void* ida_mem, int maxnh); diff --git a/src/ida/CMakeLists.txt b/src/ida/CMakeLists.txt index 53902e76ac..97a2290047 100644 --- a/src/ida/CMakeLists.txt +++ b/src/ida/CMakeLists.txt @@ -18,7 +18,7 @@ install(CODE "MESSAGE(\"\nInstall IDA\n\")") # Add variable ida_SOURCES with the sources for the IDA library -set(ida_SOURCES ida.c ida_bbdpre.c ida_ic.c ida_io.c ida_ls.c ida_nls.c) +set(ida_SOURCES ida.c ida_bbdpre.c ida_cli.c ida_ic.c ida_io.c ida_ls.c ida_nls.c) # Add variable ida_HEADERS with the exported IDA header files set(ida_HEADERS ida.h ida_bbdpre.h ida_ls.h) diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c new file mode 100644 index 0000000000..f8b85797b2 --- /dev/null +++ b/src/ida/ida_cli.c @@ -0,0 +1,208 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to IDA. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "sundials_cli.h" +#include "ida/ida.h" +#include "ida/ida_ls.h" +#include "ida_impl.h" + +/*--------------------------------------------------------------- + IDASetFromCommandLine: + + Parses the command line to control scalar-valued IDA options. + ---------------------------------------------------------------*/ + +int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, + char* argv[]) +{ + IDAMem IDA_mem; + if (ida_mem == NULL) + { + IDAProcessError(NULL, IDA_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_NO_MEM); + return (IDA_MEM_NULL); + } + IDA_mem = (IDAMem)ida_mem; + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyIntPair int_pairs[] = { + {"max_num_steps_ic", IDASetMaxNumStepsIC}, + {"max_num_jacs_ic", IDASetMaxNumJacsIC}, + {"max_num_iters_ic", IDASetMaxNumItersIC}, + {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"max_backs_ic", IDASetMaxBacksIC}, + {"max_order", IDASetMaxOrd}, + {"max_err_test_fails", IDASetMaxErrTestFails}, + {"suppress_alg", IDASetSuppressAlg}, + {"max_conv_fails", IDASetMaxConvFails}, + {"max_nonlin_iters", IDASetMaxNonlinIters}, + {"linear_solution_scaling", IDASetLinearSolutionScaling}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct sunKeyLongPair long_pairs[] = { + {"max_num_steps", IDASetMaxNumSteps}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct sunKeyRealPair real_pairs[] = { + {"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, + {"step_tolerance_ic", IDASetStepToleranceIC}, + {"delta_cj_lsetup", IDASetDeltaCjLSetup}, + {"init_step", IDASetInitStep}, + {"max_step", IDASetMaxStep}, + {"min_step", IDASetMinStep}, + {"stop_time", IDASetStopTime}, + {"eta_min", IDASetEtaMin}, + {"eta_max", IDASetEtaMax}, + {"eta_low", IDASetEtaLow}, + {"eta_min_err_fail", IDASetEtaMinErrFail}, + {"eta_conv_fail", IDASetEtaConvFail}, + {"nonlin_conv_coef", IDASetNonlinConvCoef}, + {"eps_lin", IDASetEpsLin}, + {"ls_norm_factor", IDASetLSNormFactor}, + {"increment_factor", IDASetIncrementFactor}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, + {"scalar_tolerances", IDASStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + + static struct sunKeyActionPair action_pairs[] = { + {"clear_stop_time", IDAClearStopTime}, + {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if idaid is supplied, skip command-line arguments that do not begin with idaid; + else, skip command-line arguments that do not begin with "ida." */ + size_t offset; + if (strlen(idaid) > 0) + { + if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } + offset = strlen(idaid) + 1; + } + else + { + static const char* prefix = "ida."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* warn for uninterpreted idaid.X arguments */ + IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (IDA_SUCCESS); +} + +/*=============================================================== + EOF + ===============================================================*/ From 8cc31f8c3169cae914fc076769b3fb5b2e0507b4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 20:53:10 -0500 Subject: [PATCH 036/114] Added command-line control to IDAS --- examples/idas/serial/idasAnalytic_mels.c | 6 +- include/idas/idas.h | 4 + src/cvodes/cvodes_cli.c | 2 +- src/idas/CMakeLists.txt | 1 + src/idas/idas_cli.c | 314 +++++++++++++++++++++++ 5 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 src/idas/idas_cli.c diff --git a/examples/idas/serial/idasAnalytic_mels.c b/examples/idas/serial/idasAnalytic_mels.c index c15314b9e9..de8ad645d2 100644 --- a/examples/idas/serial/idasAnalytic_mels.c +++ b/examples/idas/serial/idasAnalytic_mels.c @@ -64,7 +64,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype atol); /* Main Program */ -int main(void) +int main(int argc, char* argv[]) { /* SUNDIALS context object */ SUNContext ctx; @@ -124,6 +124,10 @@ int main(void) retval = IDASetLinearSolver(ida_mem, LS, NULL); if (check_retval(&retval, "IDASetLinearSolver", 1)) { return (1); } + /* Override any current settings with command-line options */ + retval = IDASetFromCommandLine(ida_mem, "", argc, argv); + if (check_retval(&retval, "IDASetFromCommandLine", 1)) { return 1; } + /* In loop, call IDASolve, print results, and test for error. Stops when the final time has been reached. */ t = T0; diff --git a/include/idas/idas.h b/include/idas/idas.h index 4de0052a40..f07526ad2e 100644 --- a/include/idas/idas.h +++ b/include/idas/idas.h @@ -178,6 +178,10 @@ SUNDIALS_EXPORT int IDAWFtolerances(void* ida_mem, IDAEwtFn efun); /* Initial condition calculation function */ SUNDIALS_EXPORT int IDACalcIC(void* ida_mem, int icopt, sunrealtype tout1); +/* Command-line control over scalar-valued set routines */ +SUNDIALS_EXPORT int IDASetFromCommandLine(void* ida_mem, const char* idaid, + int argc, char* argv[]); + /* Initial condition calculation optional input functions */ SUNDIALS_EXPORT int IDASetNonlinConvCoefIC(void* ida_mem, sunrealtype epiccon); SUNDIALS_EXPORT int IDASetMaxNumStepsIC(void* ida_mem, int maxnh); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 674e144b50..0953b0de9d 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -137,7 +137,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, sunbooleantype arg_used = SUNFALSE; /* if cvid is supplied, skip command-line arguments that do not begin with cvid; - else, skip command-line arguments that do not begin with "cvode." */ + else, skip command-line arguments that do not begin with "cvodes." */ size_t offset; if (strlen(cvid) > 0) { diff --git a/src/idas/CMakeLists.txt b/src/idas/CMakeLists.txt index 7b9f71f92b..f6a502c514 100644 --- a/src/idas/CMakeLists.txt +++ b/src/idas/CMakeLists.txt @@ -21,6 +21,7 @@ install(CODE "MESSAGE(\"\nInstall IDAS\n\")") set(idas_SOURCES idas.c idaa.c + idas_cli.c idas_io.c idas_ic.c idaa_io.c diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c new file mode 100644 index 0000000000..aeb40593d2 --- /dev/null +++ b/src/idas/idas_cli.c @@ -0,0 +1,314 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to IDA. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "sundials_cli.h" +#include "idas/idas.h" +#include "idas/idas_ls.h" +#include "idas_impl.h" + +/*--------------------------------------------------------------- + IDASetFromCommandLine: + + Parses the command line to control scalar-valued IDA options. + ---------------------------------------------------------------*/ + +int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, + char* argv[]) +{ + IDAMem IDA_mem; + if (ida_mem == NULL) + { + IDAProcessError(NULL, IDA_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_NO_MEM); + return (IDA_MEM_NULL); + } + IDA_mem = (IDAMem)ida_mem; + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyIntPair int_pairs[] = { + {"max_num_steps_ic", IDASetMaxNumStepsIC}, + {"max_num_jacs_ic", IDASetMaxNumJacsIC}, + {"max_num_iters_ic", IDASetMaxNumItersIC}, + {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"max_backs_ic", IDASetMaxBacksIC}, + {"max_order", IDASetMaxOrd}, + {"max_err_test_fails", IDASetMaxErrTestFails}, + {"suppress_alg", IDASetSuppressAlg}, + {"max_conv_fails", IDASetMaxConvFails}, + {"max_nonlin_iters", IDASetMaxNonlinIters}, + {"quad_err_con", IDASetQuadErrCon}, + {"sens_err_con", IDASetSensErrCon}, + {"sens_max_nonlin_iters", IDASetSensMaxNonlinIters}, + {"quad_sens_err_con", IDASetQuadSensErrCon}, + {"linear_solution_scaling", IDASetLinearSolutionScaling}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct sunKeyLongPair long_pairs[] = { + {"max_num_steps", IDASetMaxNumSteps}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct sunKeyRealPair real_pairs[] = { + {"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, + {"step_tolerance_ic", IDASetStepToleranceIC}, + {"delta_cj_lsetup", IDASetDeltaCjLSetup}, + {"init_step", IDASetInitStep}, + {"max_step", IDASetMaxStep}, + {"min_step", IDASetMinStep}, + {"stop_time", IDASetStopTime}, + {"eta_min", IDASetEtaMin}, + {"eta_max", IDASetEtaMax}, + {"eta_low", IDASetEtaLow}, + {"eta_min_err_fail", IDASetEtaMinErrFail}, + {"eta_conv_fail", IDASetEtaConvFail}, + {"nonlin_conv_coef", IDASetNonlinConvCoef}, + {"eps_lin", IDASetEpsLin}, + {"ls_norm_factor", IDASetLSNormFactor}, + {"increment_factor", IDASetIncrementFactor}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, + {"scalar_tolerances", IDASStolerances}, + {"quad_scalar_tolerances", IDAQuadSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + + static struct sunKeyTwoIntPair twoint_pairs[] = { + {"max_ord_b", IDASetMaxOrdB}, + {"suppress_alg_b", IDASetSuppressAlgB}, + {"quad_err_con_b", IDASetQuadErrConB}, + {"linear_solution_scaling_b", IDASetLinearSolutionScalingB}}; + static const int num_twoint_keys = sizeof(twoint_pairs) / sizeof(*twoint_pairs); + + static struct sunKeyActionPair action_pairs[] = { + {"clear_stop_time", IDAClearStopTime}, + {"no_inactive_root_warn", IDASetNoInactiveRootWarn}, + {"sens_toggle_off", IDASensToggleOff}, + {"adj_no_sensi", IDAAdjSetNoSensi}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + static struct sunKeyIntRealPair int_real_pairs[] = { + {"sens_dq_method", IDASetSensDQMethod}, + {"init_step_b", IDASetInitStepB}, + {"max_step_b", IDASetMaxStepB}, + {"eps_lin_b", IDASetEpsLinB}, + {"ls_norm_factor_b", IDASetLSNormFactorB}, + {"increment_factor_b", IDASetIncrementFactorB}}; + static const int num_int_real_keys = sizeof(int_real_pairs) / + sizeof(*int_real_pairs); + + static struct sunKeyIntRealRealPair int_real_real_pairs[] = { + {"scalar_tolerances_b", IDASStolerancesB}, + {"quad_scalar_tolerances_b", IDAQuadSStolerancesB}}; + static const int num_int_real_real_keys = sizeof(int_real_real_pairs) / + sizeof(*int_real_real_pairs); + + static struct sunKeyIntLongPair int_long_pairs[] = { + {"max_num_steps_b", IDASetMaxNumStepsB}}; + static const int num_int_long_keys = sizeof(int_long_pairs) / + sizeof(*int_long_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if idaid is supplied, skip command-line arguments that do not begin with idaid; + else, skip command-line arguments that do not begin with "idas." */ + size_t offset; + if (strlen(idaid) > 0) + { + if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } + offset = strlen(idaid) + 1; + } + else + { + static const char* prefix = "idas."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-int command-line options */ + for (j = 0; j < num_twoint_keys; j++) + { + retval = sunCheckAndSetTwoIntArg(ida_mem, &i, argv, offset, + twoint_pairs[j].key, + twoint_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + twoint_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all int+real command-line options */ + for (j = 0; j < num_int_real_keys; j++) + { + retval = sunCheckAndSetIntRealArg(ida_mem, &i, argv, offset, + int_real_pairs[j].key, + int_real_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all int+long command-line options */ + for (j = 0; j < num_int_long_keys; j++) + { + retval = sunCheckAndSetIntLongArg(ida_mem, &i, argv, offset, + int_long_pairs[j].key, + int_long_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all int+real+real command-line options */ + for (j = 0; j < num_int_real_real_keys; j++) + { + retval = sunCheckAndSetIntRealRealArg(ida_mem, &i, argv, offset, + int_real_real_pairs[j].key, + int_real_real_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* warn for uninterpreted idaid.X arguments */ + IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (IDA_SUCCESS); +} + +/*=============================================================== + EOF + ===============================================================*/ From d67bd22a707883e40bd6455c38d103e7371cbaba Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 21:10:31 -0500 Subject: [PATCH 037/114] Added command-line control to KINSOL --- examples/kinsol/serial/kinRoberts_fp.c | 8 +- include/kinsol/kinsol.h | 2 + src/kinsol/CMakeLists.txt | 2 +- src/kinsol/kinsol_cli.c | 178 +++++++++++++++++++++++++ 4 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 src/kinsol/kinsol_cli.c diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c index 37172c118b..91fadaaff4 100644 --- a/examples/kinsol/serial/kinRoberts_fp.c +++ b/examples/kinsol/serial/kinRoberts_fp.c @@ -82,7 +82,7 @@ static int check_ans(N_Vector u, sunrealtype rtol, sunrealtype atol); *-------------------------------------------------------------------- */ -int main(void) +int main(int argc, char* argv[]) { SUNContext sunctx; sunrealtype fnormtol, fnorm; @@ -147,6 +147,11 @@ int main(void) retval = KINSetFuncNormTol(kmem, fnormtol); if (check_retval(&retval, "KINSetFuncNormTol", 1)) { return (1); } + /* Override any current settings with command-line options */ + + retval = KINSetFromCommandLine(kmem, "", argc, argv); + if (check_retval(&retval, "KINSetFromCommandLine", 1)) { return (1); } + /* ------------- * Initial guess * ------------- */ @@ -154,6 +159,7 @@ int main(void) N_VConst(ZERO, y); Ith(y, 1) = ONE; + /* ---------------------------- * Call KINSol to solve problem * ---------------------------- */ diff --git a/include/kinsol/kinsol.h b/include/kinsol/kinsol.h index 73a6fd5870..887bcb0520 100644 --- a/include/kinsol/kinsol.h +++ b/include/kinsol/kinsol.h @@ -100,6 +100,8 @@ SUNDIALS_EXPORT int KINSol(void* kinmem, N_Vector uu, int strategy, N_Vector u_scale, N_Vector f_scale); /* Optional input functions */ +SUNDIALS_EXPORT int KINSetFromCommandLine(void* kinmem, const char* kinid, + int argc, char* argv[]); SUNDIALS_EXPORT int KINSetUserData(void* kinmem, void* user_data); SUNDIALS_EXPORT int KINSetDamping(void* kinmem, sunrealtype beta); SUNDIALS_EXPORT int KINSetMAA(void* kinmem, long int maa); diff --git a/src/kinsol/CMakeLists.txt b/src/kinsol/CMakeLists.txt index e3c8a8bb77..5b52ae1dc6 100644 --- a/src/kinsol/CMakeLists.txt +++ b/src/kinsol/CMakeLists.txt @@ -18,7 +18,7 @@ install(CODE "MESSAGE(\"\nInstall KINSOL\n\")") # Add variable kinsol_SOURCES with the sources for the KINSOL library -set(kinsol_SOURCES kinsol.c kinsol_bbdpre.c kinsol_io.c kinsol_ls.c) +set(kinsol_SOURCES kinsol.c kinsol_bbdpre.c kinsol_cli.c kinsol_io.c kinsol_ls.c) # Add variable kinsol_HEADERS with the exported KINSOL header files set(kinsol_HEADERS kinsol.h kinsol_bbdpre.h kinsol_ls.h) diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c new file mode 100644 index 0000000000..fe6db284d8 --- /dev/null +++ b/src/kinsol/kinsol_cli.c @@ -0,0 +1,178 @@ +/*--------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2025, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This file provides command-line control over optional inputs + * to KINSOL. + *--------------------------------------------------------------*/ + +#include +#include +#include +#include +#include "sundials_cli.h" +#include "kinsol/kinsol.h" +#include "kinsol/kinsol_ls.h" +#include "kinsol_impl.h" + +/*--------------------------------------------------------------- + KINSetFromCommandLine: + + Parses the command line to control scalar-valued KINSOL options. + ---------------------------------------------------------------*/ + +int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, + char* argv[]) +{ + KINMem kin_mem; + if (kinmem == NULL) + { + KINProcessError(NULL, KIN_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_NO_MEM); + return (KIN_MEM_NULL); + } + kin_mem = (KINMem)kinmem; + + /* Set lists of command-line arguments, and the corresponding set routines */ + static struct sunKeyIntPair int_pairs[] = { + {"orth_aa", KINSetOrthAA}, + {"return_newest", KINSetReturnNewest}, + {"no_init_setup", KINSetNoInitSetup}, + {"no_res_mon", KINSetNoResMon}, + {"eta_form", KINSetEtaForm}, + {"no_min_eps", KINSetNoMinEps}}; + static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); + + static struct sunKeyLongPair long_pairs[] = { + {"m_aa", KINSetMAA}, + {"delay_aa", KINSetDelayAA}, + {"num_max_iters", KINSetNumMaxIters}, + {"max_setup_calls", KINSetMaxSetupCalls}, + {"max_sub_setup_calls", KINSetMaxSubSetupCalls}, + {"max_beta_fails", KINSetMaxBetaFails}}; + static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); + + static struct sunKeyRealPair real_pairs[] = { + {"damping", KINSetDamping}, + {"damping_aa", KINSetDampingAA}, + {"eta_const_value", KINSetEtaConstValue}, + {"res_mon_const_value", KINSetResMonConstValue}, + {"max_newton_step", KINSetMaxNewtonStep}, + {"rel_err_func", KINSetRelErrFunc}, + {"func_norm_tol", KINSetFuncNormTol}, + {"scaled_step_tol", KINSetScaledStepTol}}; + static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); + + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"eta_params", KINSetEtaParams}, + {"res_mon_params", KINSetResMonParams}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if kinid is supplied, skip command-line arguments that do not begin with kinid; + else, skip command-line arguments that do not begin with "kinsol." */ + size_t offset; + if (strlen(kinid) > 0) + { + if (strncmp(argv[i], kinid, strlen(kinid)) != 0) { continue; } + offset = strlen(kinid) + 1; + } + else + { + static const char* prefix = "kinsol."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg(kinmem, &i, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); + if (retval != KIN_SUCCESS) + { + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg(kinmem, &i, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); + if (retval != KIN_SUCCESS) + { + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg(kinmem, &i, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); + if (retval != KIN_SUCCESS) + { + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(kinmem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != KIN_SUCCESS) + { + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } + if (arg_used) break; + } + if (arg_used) continue; + + /* warn for uninterpreted kinid.X arguments */ + KINProcessError(kin_mem, KIN_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } + + return (KIN_SUCCESS); +} + +/*=============================================================== + EOF + ===============================================================*/ From 7db9133f03722c9f8ca61df92646157bd040ccb7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 21:18:15 -0500 Subject: [PATCH 038/114] Regenerated SWIG interfaces --- src/cvode/fmod_int32/fcvode_mod.c | 49 ++++++++++++++++ src/cvode/fmod_int32/fcvode_mod.f90 | 74 ++++++++++++++++++++++-- src/cvode/fmod_int64/fcvode_mod.c | 49 ++++++++++++++++ src/cvode/fmod_int64/fcvode_mod.f90 | 74 ++++++++++++++++++++++-- src/cvodes/fmod_int32/fcvodes_mod.c | 25 +++++++- src/cvodes/fmod_int32/fcvodes_mod.f90 | 82 +++++++++++++++++++++++---- src/cvodes/fmod_int64/fcvodes_mod.c | 25 +++++++- src/cvodes/fmod_int64/fcvodes_mod.f90 | 82 +++++++++++++++++++++++---- src/ida/fmod_int32/fida_mod.c | 49 ++++++++++++++++ src/ida/fmod_int32/fida_mod.f90 | 74 ++++++++++++++++++++++-- src/ida/fmod_int64/fida_mod.c | 49 ++++++++++++++++ src/ida/fmod_int64/fida_mod.f90 | 74 ++++++++++++++++++++++-- src/idas/fmod_int32/fidas_mod.c | 25 +++++++- src/idas/fmod_int32/fidas_mod.f90 | 82 +++++++++++++++++++++++---- src/idas/fmod_int64/fidas_mod.c | 25 +++++++- src/idas/fmod_int64/fidas_mod.f90 | 82 +++++++++++++++++++++++---- src/kinsol/fmod_int32/fkinsol_mod.c | 49 ++++++++++++++++ src/kinsol/fmod_int32/fkinsol_mod.f90 | 74 ++++++++++++++++++++++-- src/kinsol/fmod_int64/fkinsol_mod.c | 49 ++++++++++++++++ src/kinsol/fmod_int64/fkinsol_mod.f90 | 74 ++++++++++++++++++++++-- 20 files changed, 1082 insertions(+), 84 deletions(-) diff --git a/src/cvode/fmod_int32/fcvode_mod.c b/src/cvode/fmod_int32/fcvode_mod.c index 68f9ba20f1..c7d0f2efee 100644 --- a/src/cvode/fmod_int32/fcvode_mod.c +++ b/src/cvode/fmod_int32/fcvode_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -236,6 +252,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -332,6 +362,25 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int32/fcvode_mod.f90 b/src/cvode/fmod_int32/fcvode_mod.f90 index 2e53b4bb9e..0040b0e6eb 100644 --- a/src/cvode/fmod_int32/fcvode_mod.f90 +++ b/src/cvode/fmod_int32/fcvode_mod.f90 @@ -69,6 +69,22 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -135,10 +151,6 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -267,6 +279,19 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FCVodeSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1460,6 +1485,47 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int64/fcvode_mod.c b/src/cvode/fmod_int64/fcvode_mod.c index a42a5d51e8..c48adf0678 100644 --- a/src/cvode/fmod_int64/fcvode_mod.c +++ b/src/cvode/fmod_int64/fcvode_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -236,6 +252,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -332,6 +362,25 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int64/fcvode_mod.f90 b/src/cvode/fmod_int64/fcvode_mod.f90 index 9aba027f07..0d2dfa7e34 100644 --- a/src/cvode/fmod_int64/fcvode_mod.f90 +++ b/src/cvode/fmod_int64/fcvode_mod.f90 @@ -69,6 +69,22 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -135,10 +151,6 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -267,6 +279,19 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FCVodeSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1460,6 +1485,47 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int32/fcvodes_mod.c b/src/cvodes/fmod_int32/fcvodes_mod.c index 473678dc27..41b1c4bfd7 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.c +++ b/src/cvodes/fmod_int32/fcvodes_mod.c @@ -264,9 +264,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -281,6 +278,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -406,6 +406,25 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int32/fcvodes_mod.f90 b/src/cvodes/fmod_int32/fcvodes_mod.f90 index a288b74705..b54d0fba2e 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int32/fcvodes_mod.f90 @@ -100,6 +100,22 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -170,10 +186,6 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -268,14 +280,6 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -442,6 +446,19 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FCVodeSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2867,6 +2884,47 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int64/fcvodes_mod.c b/src/cvodes/fmod_int64/fcvodes_mod.c index d3cbbca1d6..bcd330a87c 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.c +++ b/src/cvodes/fmod_int64/fcvodes_mod.c @@ -264,9 +264,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -281,6 +278,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -406,6 +406,25 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int64/fcvodes_mod.f90 b/src/cvodes/fmod_int64/fcvodes_mod.f90 index c2cdf3a0a3..21154ea34b 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int64/fcvodes_mod.f90 @@ -100,6 +100,22 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -170,10 +186,6 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -268,14 +280,6 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -442,6 +446,19 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FCVodeSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2867,6 +2884,47 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int32/fida_mod.c b/src/ida/fmod_int32/fida_mod.c index 68dfeea91f..1323ccbb78 100644 --- a/src/ida/fmod_int32/fida_mod.c +++ b/src/ida/fmod_int32/fida_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -347,6 +377,25 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int32/fida_mod.f90 b/src/ida/fmod_int32/fida_mod.f90 index 136521893f..aa002698ee 100644 --- a/src/ida/fmod_int32/fida_mod.f90 +++ b/src/ida/fmod_int32/fida_mod.f90 @@ -68,6 +68,22 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -135,10 +151,6 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -252,6 +264,19 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FIDASetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1307,6 +1332,47 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int64/fida_mod.c b/src/ida/fmod_int64/fida_mod.c index 02def580d4..e5048513ef 100644 --- a/src/ida/fmod_int64/fida_mod.c +++ b/src/ida/fmod_int64/fida_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -347,6 +377,25 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int64/fida_mod.f90 b/src/ida/fmod_int64/fida_mod.f90 index 5e3fee8ae6..a19bfdc511 100644 --- a/src/ida/fmod_int64/fida_mod.f90 +++ b/src/ida/fmod_int64/fida_mod.f90 @@ -68,6 +68,22 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -135,10 +151,6 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -252,6 +264,19 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FIDASetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1307,6 +1332,47 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int32/fidas_mod.c b/src/idas/fmod_int32/fidas_mod.c index c39dff4a1f..f7df16c727 100644 --- a/src/idas/fmod_int32/fidas_mod.c +++ b/src/idas/fmod_int32/fidas_mod.c @@ -262,9 +262,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -279,6 +276,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,6 +422,25 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int32/fidas_mod.f90 b/src/idas/fmod_int32/fidas_mod.f90 index db6f376bfc..55c79bc554 100644 --- a/src/idas/fmod_int32/fidas_mod.f90 +++ b/src/idas/fmod_int32/fidas_mod.f90 @@ -93,6 +93,22 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -165,10 +181,6 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -261,14 +273,6 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -424,6 +428,19 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FIDASetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2756,6 +2773,47 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int64/fidas_mod.c b/src/idas/fmod_int64/fidas_mod.c index 196fd9f52b..ecffd9bcd4 100644 --- a/src/idas/fmod_int64/fidas_mod.c +++ b/src/idas/fmod_int64/fidas_mod.c @@ -262,9 +262,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -279,6 +276,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,6 +422,25 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int64/fidas_mod.f90 b/src/idas/fmod_int64/fidas_mod.f90 index b379e13d36..16ea7332c7 100644 --- a/src/idas/fmod_int64/fidas_mod.f90 +++ b/src/idas/fmod_int64/fidas_mod.f90 @@ -93,6 +93,22 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -165,10 +181,6 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -261,14 +273,6 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -424,6 +428,19 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FIDASetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2756,6 +2773,47 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int32/fkinsol_mod.c b/src/kinsol/fmod_int32/fkinsol_mod.c index 28e47ca143..9f2d8124a7 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.c +++ b/src/kinsol/fmod_int32/fkinsol_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -283,6 +313,25 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } +SWIGEXPORT int _wrap_FKINSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "KINSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)KINSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int32/fkinsol_mod.f90 b/src/kinsol/fmod_int32/fkinsol_mod.f90 index b536144611..2ad3ef01ce 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int32/fkinsol_mod.f90 @@ -60,6 +60,22 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FKINSetFromCommandLine public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -94,10 +110,6 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -165,6 +177,19 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function +function swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FKINSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -748,6 +773,47 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FKINSetFromCommandLine(kinmem, kinid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: kinmem +character(kind=C_CHAR, len=*), target :: kinid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = kinmem +call SWIG_string_to_chararray(kinid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int64/fkinsol_mod.c b/src/kinsol/fmod_int64/fkinsol_mod.c index 59cc57d5b2..b510edc23c 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.c +++ b/src/kinsol/fmod_int64/fkinsol_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -283,6 +313,25 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } +SWIGEXPORT int _wrap_FKINSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "KINSetFromCommandLine(void *,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (int)KINSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int64/fkinsol_mod.f90 b/src/kinsol/fmod_int64/fkinsol_mod.f90 index 12ca4ddc6e..e9ae8316d6 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int64/fkinsol_mod.f90 @@ -60,6 +60,22 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FKINSetFromCommandLine public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -94,10 +110,6 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -165,6 +177,19 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function +function swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FKINSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -748,6 +773,47 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FKINSetFromCommandLine(kinmem, kinid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: kinmem +character(kind=C_CHAR, len=*), target :: kinid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = kinmem +call SWIG_string_to_chararray(kinid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING From f74753906f9983b8bc215af1ee0ff08a370d4432 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 21:18:45 -0500 Subject: [PATCH 039/114] Formatting --- examples/kinsol/serial/kinRoberts_fp.c | 1 - src/arkode/arkode_arkstep_io.c | 2 +- src/arkode/arkode_cli.c | 9 +- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_lsrkstep_io.c | 2 +- src/arkode/arkode_mristep_io.c | 2 +- src/arkode/arkode_sprkstep_io.c | 2 +- src/cvode/cvode_cli.c | 65 ++++----- src/cvodes/cvodes_cli.c | 189 ++++++++++++------------- src/ida/ida_cli.c | 97 +++++++------ src/idas/idas_cli.c | 147 ++++++++++--------- src/kinsol/kinsol_cli.c | 76 +++++----- src/sundials/sundials_cli.c | 8 +- 13 files changed, 294 insertions(+), 308 deletions(-) diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c index 91fadaaff4..2294549c4f 100644 --- a/examples/kinsol/serial/kinRoberts_fp.c +++ b/examples/kinsol/serial/kinRoberts_fp.c @@ -159,7 +159,6 @@ int main(int argc, char* argv[]) N_VConst(ZERO, y); Ith(y, 1) = ONE; - /* ---------------------------- * Call KINSol to solve problem * ---------------------------- */ diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 89a6e63ea0..ad707655f6 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -24,8 +24,8 @@ #include #include -#include "sundials_cli.h" #include "arkode_arkstep_impl.h" +#include "sundials_cli.h" /*=============================================================== Exported optional input functions. diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index a5894e11e0..97fa64e06d 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -19,10 +19,10 @@ #include #include #include -#include "sundials_cli.h" #include "arkode/arkode.h" #include "arkode/arkode_ls.h" #include "arkode_impl.h" +#include "sundials_cli.h" /*--------------------------------------------------------------- ARKodeSetFromCommandLine: @@ -62,9 +62,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { - {"max_num_steps", ARKodeSetMaxNumSteps}, - {"jac_eval_frequency", ARKodeSetJacEvalFrequency}}; + static struct sunKeyLongPair long_pairs[] = {{"max_num_steps", + ARKodeSetMaxNumSteps}, + {"jac_eval_frequency", + ARKodeSetJacEvalFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static struct sunKeyRealPair real_pairs[] = diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 85e3589cd0..b777769817 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -24,8 +24,8 @@ #include #include -#include "sundials_cli.h" #include "arkode_erkstep_impl.h" +#include "sundials_cli.h" /*=============================================================== Exported optional input functions. diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 9236f1a4ee..c096f0002e 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -21,8 +21,8 @@ #include #include -#include "sundials_cli.h" #include "arkode_lsrkstep_impl.h" +#include "sundials_cli.h" /*=============================================================== Exported optional input functions. diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 8bc19cbc53..09b1daa0e6 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -21,8 +21,8 @@ #include #include -#include "sundials_cli.h" #include "arkode_mristep_impl.h" +#include "sundials_cli.h" /*=============================================================== Exported optional input functions. diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 81ed0dc357..4c164683a5 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -24,10 +24,10 @@ #include #include -#include "sundials_cli.h" #include "arkode/arkode.h" #include "arkode/arkode_sprk.h" #include "arkode_sprkstep_impl.h" +#include "sundials_cli.h" /*=============================================================== Exported optional input functions. diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 30e4e3535c..5081ef6990 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -19,11 +19,11 @@ #include #include #include -#include "sundials_cli.h" #include "cvode/cvode.h" #include "cvode/cvode_ls.h" #include "cvode/cvode_proj.h" #include "cvode_impl.h" +#include "sundials_cli.h" /*--------------------------------------------------------------- CVodeSetFromCommandLine: @@ -37,8 +37,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, CVodeMem cv_mem; if (cvode_mem == NULL) { - cvProcessError(NULL, CV_MEM_NULL, __LINE__, __func__, __FILE__, - MSGCV_NO_MEM); + cvProcessError(NULL, CV_MEM_NULL, __LINE__, __func__, __FILE__, MSGCV_NO_MEM); return (CV_MEM_NULL); } cv_mem = (CVodeMem)cvode_mem; @@ -59,13 +58,13 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { - {"lsetup_frequency", CVodeSetLSetupFrequency}, - {"max_num_steps", CVodeSetMaxNumSteps}, - {"monitor_frequency", CVodeSetMonitorFrequency}, - {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, - {"jac_eval_frequency", CVodeSetJacEvalFrequency}, - {"proj_frequency", CVodeSetProjFrequency}}; + static struct sunKeyLongPair long_pairs[] = + {{"lsetup_frequency", CVodeSetLSetupFrequency}, + {"max_num_steps", CVodeSetMaxNumSteps}, + {"monitor_frequency", CVodeSetMonitorFrequency}, + {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, + {"jac_eval_frequency", CVodeSetJacEvalFrequency}, + {"proj_frequency", CVodeSetProjFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static struct sunKeyRealPair real_pairs[] = @@ -89,14 +88,17 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = - {{"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, - {"scalar_tolerances", CVodeSStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - - static struct sunKeyActionPair action_pairs[] = - {{"clear_stop_time", CVodeClearStopTime}, - {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; + static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", + CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", + CVodeSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); + + static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + CVodeClearStopTime}, + {"no_inactive_root_warn", + CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; @@ -122,14 +124,13 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); + "error setting command-line argument: %s", + int_pairs[j].key); return retval; } if (arg_used) break; @@ -145,8 +146,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); + "error setting command-line argument: %s", + long_pairs[j].key); return retval; } if (arg_used) break; @@ -162,8 +163,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); + "error setting command-line argument: %s", + real_pairs[j].key); return retval; } if (arg_used) break; @@ -179,8 +180,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); + "error setting command-line argument: %s", + tworeal_pairs[j].key); return retval; } if (arg_used) break; @@ -196,8 +197,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); + "error setting command-line argument: %s", + action_pairs[j].key); return retval; } if (arg_used) break; @@ -206,7 +207,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* warn for uninterpreted cvid.X arguments */ cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[i]); } return (CV_SUCCESS); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 0953b0de9d..f8823aa17a 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -19,11 +19,11 @@ #include #include #include -#include "sundials_cli.h" #include "cvodes/cvodes.h" #include "cvodes/cvodes_ls.h" #include "cvodes/cvodes_proj.h" #include "cvodes_impl.h" +#include "sundials_cli.h" /*--------------------------------------------------------------- CVodeSetFromCommandLine: @@ -37,92 +37,92 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, CVodeMem cv_mem; if (cvode_mem == NULL) { - cvProcessError(NULL, CV_MEM_NULL, __LINE__, __func__, __FILE__, - MSGCV_NO_MEM); + cvProcessError(NULL, CV_MEM_NULL, __LINE__, __func__, __FILE__, MSGCV_NO_MEM); return (CV_MEM_NULL); } cv_mem = (CVodeMem)cvode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"max_conv_fails", CVodeSetMaxConvFails}, - {"max_err_test_fails", CVodeSetMaxErrTestFails}, - {"max_hnil_warns", CVodeSetMaxHnilWarns}, - {"max_nonlin_iters", CVodeSetMaxNonlinIters}, - {"max_order", CVodeSetMaxOrd}, - {"stab_lim_det", CVodeSetStabLimDet}, - {"interpolate_stop_time", CVodeSetInterpolateStopTime}, - {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, - {"quad_err_con", CVodeSetQuadErrCon}, - {"sens_err_con", CVodeSetSensErrCon}, - {"sens_max_nonlin_iters", CVodeSetSensMaxNonlinIters}, - {"quad_sens_err_con", CVodeSetQuadSensErrCon}, - {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, - {"proj_err_est", CVodeSetProjErrEst}, - {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; + static struct sunKeyIntPair int_pairs[] = + {{"max_conv_fails", CVodeSetMaxConvFails}, + {"max_err_test_fails", CVodeSetMaxErrTestFails}, + {"max_hnil_warns", CVodeSetMaxHnilWarns}, + {"max_nonlin_iters", CVodeSetMaxNonlinIters}, + {"max_order", CVodeSetMaxOrd}, + {"stab_lim_det", CVodeSetStabLimDet}, + {"interpolate_stop_time", CVodeSetInterpolateStopTime}, + {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"quad_err_con", CVodeSetQuadErrCon}, + {"sens_err_con", CVodeSetSensErrCon}, + {"sens_max_nonlin_iters", CVodeSetSensMaxNonlinIters}, + {"quad_sens_err_con", CVodeSetQuadSensErrCon}, + {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, + {"proj_err_est", CVodeSetProjErrEst}, + {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { - {"lsetup_frequency", CVodeSetLSetupFrequency}, - {"max_num_steps", CVodeSetMaxNumSteps}, - {"monitor_frequency", CVodeSetMonitorFrequency}, - {"jac_eval_frequency", CVodeSetJacEvalFrequency}, - {"proj_frequency", CVodeSetProjFrequency}}; + static struct sunKeyLongPair long_pairs[] = + {{"lsetup_frequency", CVodeSetLSetupFrequency}, + {"max_num_steps", CVodeSetMaxNumSteps}, + {"monitor_frequency", CVodeSetMonitorFrequency}, + {"jac_eval_frequency", CVodeSetJacEvalFrequency}, + {"proj_frequency", CVodeSetProjFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, - {"init_step", CVodeSetInitStep}, - {"max_step", CVodeSetMaxStep}, - {"min_step", CVodeSetMinStep}, - {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, - {"stop_time", CVodeSetStopTime}, - {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, - {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, - {"eta_max", CVodeSetEtaMax}, - {"eta_min", CVodeSetEtaMin}, - {"eta_min_err_fail", CVodeSetEtaMinErrFail}, - {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, - {"eta_conv_fail", CVodeSetEtaConvFail}, - {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, - {"eps_lin", CVodeSetEpsLin}, - {"ls_norm_factor", CVodeSetLSNormFactor}, - {"eps_proj", CVodeSetEpsProj}, - {"proj_fail_eta", CVodeSetProjFailEta}}; + static struct sunKeyRealPair real_pairs[] = + {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {"init_step", CVodeSetInitStep}, + {"max_step", CVodeSetMaxStep}, + {"min_step", CVodeSetMinStep}, + {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, + {"stop_time", CVodeSetStopTime}, + {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, + {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, + {"eta_max", CVodeSetEtaMax}, + {"eta_min", CVodeSetEtaMin}, + {"eta_min_err_fail", CVodeSetEtaMinErrFail}, + {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, + {"eta_conv_fail", CVodeSetEtaConvFail}, + {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, + {"eps_lin", CVodeSetEpsLin}, + {"ls_norm_factor", CVodeSetLSNormFactor}, + {"eps_proj", CVodeSetEpsProj}, + {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, - {"scalar_tolerances", CVodeSStolerances}, - {"quad_scalar_tolerances", CVodeQuadSStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + static struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", CVodeSStolerances}, + {"quad_scalar_tolerances", CVodeQuadSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); - static struct sunKeyTwoIntPair twoint_pairs[] = { - {"max_ord_b", CVodeSetMaxOrdB}, - {"stab_lim_det_b", CVodeSetStabLimDetB}, - {"quad_err_con_b", CVodeSetQuadErrConB}, - {"linear_solution_scaling_b", CVodeSetLinearSolutionScalingB}}; + static struct sunKeyTwoIntPair twoint_pairs[] = + {{"max_ord_b", CVodeSetMaxOrdB}, + {"stab_lim_det_b", CVodeSetStabLimDetB}, + {"quad_err_con_b", CVodeSetQuadErrConB}, + {"linear_solution_scaling_b", CVodeSetLinearSolutionScalingB}}; static const int num_twoint_keys = sizeof(twoint_pairs) / sizeof(*twoint_pairs); - static struct sunKeyActionPair action_pairs[] = { - {"clear_stop_time", CVodeClearStopTime}, - {"adj_no_sensi", CVodeSetAdjNoSensi}, - {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; + static struct sunKeyActionPair action_pairs[] = + {{"clear_stop_time", CVodeClearStopTime}, + {"adj_no_sensi", CVodeSetAdjNoSensi}, + {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - static struct sunKeyIntRealPair int_real_pairs[] = { - {"sens_dq_method", CVodeSetSensDQMethod}, - {"init_step_b", CVodeSetInitStepB}, - {"min_step_b", CVodeSetMinStepB}, - {"max_step_b", CVodeSetMaxStepB}, - {"eps_lin_b", CVodeSetEpsLinB}, - {"ls_norm_factor_b", CVodeSetLSNormFactorB}}; + static struct sunKeyIntRealPair int_real_pairs[] = + {{"sens_dq_method", CVodeSetSensDQMethod}, + {"init_step_b", CVodeSetInitStepB}, + {"min_step_b", CVodeSetMinStepB}, + {"max_step_b", CVodeSetMaxStepB}, + {"eps_lin_b", CVodeSetEpsLinB}, + {"ls_norm_factor_b", CVodeSetLSNormFactorB}}; static const int num_int_real_keys = sizeof(int_real_pairs) / sizeof(*int_real_pairs); - static struct sunKeyIntRealRealPair int_real_real_pairs[] = { - {"scalar_tolerances_b", CVodeSStolerancesB}, - {"quad_scalar_tolerances_b", CVodeQuadSStolerancesB}}; + static struct sunKeyIntRealRealPair int_real_real_pairs[] = + {{"scalar_tolerances_b", CVodeSStolerancesB}, + {"quad_scalar_tolerances_b", CVodeQuadSStolerancesB}}; static const int num_int_real_real_keys = sizeof(int_real_real_pairs) / sizeof(*int_real_real_pairs); @@ -154,14 +154,13 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); + "error setting command-line argument: %s", + int_pairs[j].key); return retval; } if (arg_used) break; @@ -177,8 +176,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); + "error setting command-line argument: %s", + long_pairs[j].key); return retval; } if (arg_used) break; @@ -194,8 +193,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); + "error setting command-line argument: %s", + real_pairs[j].key); return retval; } if (arg_used) break; @@ -206,13 +205,13 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_twoint_keys; j++) { retval = sunCheckAndSetTwoIntArg(cvode_mem, &i, argv, offset, - twoint_pairs[j].key, - twoint_pairs[j].set, &arg_used); + twoint_pairs[j].key, twoint_pairs[j].set, + &arg_used); if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - twoint_pairs[j].key); + "error setting command-line argument: %s", + twoint_pairs[j].key); return retval; } if (arg_used) break; @@ -228,8 +227,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); + "error setting command-line argument: %s", + tworeal_pairs[j].key); return retval; } if (arg_used) break; @@ -245,8 +244,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); + "error setting command-line argument: %s", + action_pairs[j].key); return retval; } if (arg_used) break; @@ -258,13 +257,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = sunCheckAndSetIntRealArg(cvode_mem, &i, argv, offset, int_real_pairs[j].key, - int_real_pairs[j].set, - &arg_used); + int_real_pairs[j].set, &arg_used); if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_real_pairs[j].key); + "error setting command-line argument: %s", + int_real_pairs[j].key); return retval; } if (arg_used) break; @@ -276,13 +274,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = sunCheckAndSetIntLongArg(cvode_mem, &i, argv, offset, int_long_pairs[j].key, - int_long_pairs[j].set, - &arg_used); + int_long_pairs[j].set, &arg_used); if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_long_pairs[j].key); + "error setting command-line argument: %s", + int_long_pairs[j].key); return retval; } if (arg_used) break; @@ -299,8 +296,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, if (retval != CV_SUCCESS) { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_real_real_pairs[j].key); + "error setting command-line argument: %s", + int_real_real_pairs[j].key); return retval; } if (arg_used) break; @@ -309,7 +306,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* warn for uninterpreted cvid.X arguments */ cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[i]); } return (CV_SUCCESS); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index f8b85797b2..7a3d071684 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -19,10 +19,10 @@ #include #include #include -#include "sundials_cli.h" #include "ida/ida.h" #include "ida/ida_ls.h" #include "ida_impl.h" +#include "sundials_cli.h" /*--------------------------------------------------------------- IDASetFromCommandLine: @@ -36,58 +36,60 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDAMem IDA_mem; if (ida_mem == NULL) { - IDAProcessError(NULL, IDA_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_NO_MEM); + IDAProcessError(NULL, IDA_MEM_NULL, __LINE__, __func__, __FILE__, MSG_NO_MEM); return (IDA_MEM_NULL); } IDA_mem = (IDAMem)ida_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"max_num_steps_ic", IDASetMaxNumStepsIC}, - {"max_num_jacs_ic", IDASetMaxNumJacsIC}, - {"max_num_iters_ic", IDASetMaxNumItersIC}, - {"linesearch_off_ic", IDASetLineSearchOffIC}, - {"max_backs_ic", IDASetMaxBacksIC}, - {"max_order", IDASetMaxOrd}, - {"max_err_test_fails", IDASetMaxErrTestFails}, - {"suppress_alg", IDASetSuppressAlg}, - {"max_conv_fails", IDASetMaxConvFails}, - {"max_nonlin_iters", IDASetMaxNonlinIters}, - {"linear_solution_scaling", IDASetLinearSolutionScaling}}; + static struct sunKeyIntPair int_pairs[] = + {{"max_num_steps_ic", IDASetMaxNumStepsIC}, + {"max_num_jacs_ic", IDASetMaxNumJacsIC}, + {"max_num_iters_ic", IDASetMaxNumItersIC}, + {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"max_backs_ic", IDASetMaxBacksIC}, + {"max_order", IDASetMaxOrd}, + {"max_err_test_fails", IDASetMaxErrTestFails}, + {"suppress_alg", IDASetSuppressAlg}, + {"max_conv_fails", IDASetMaxConvFails}, + {"max_nonlin_iters", IDASetMaxNonlinIters}, + {"linear_solution_scaling", IDASetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = { {"max_num_steps", IDASetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, - {"step_tolerance_ic", IDASetStepToleranceIC}, - {"delta_cj_lsetup", IDASetDeltaCjLSetup}, - {"init_step", IDASetInitStep}, - {"max_step", IDASetMaxStep}, - {"min_step", IDASetMinStep}, - {"stop_time", IDASetStopTime}, - {"eta_min", IDASetEtaMin}, - {"eta_max", IDASetEtaMax}, - {"eta_low", IDASetEtaLow}, - {"eta_min_err_fail", IDASetEtaMinErrFail}, - {"eta_conv_fail", IDASetEtaConvFail}, - {"nonlin_conv_coef", IDASetNonlinConvCoef}, - {"eps_lin", IDASetEpsLin}, - {"ls_norm_factor", IDASetLSNormFactor}, - {"increment_factor", IDASetIncrementFactor}}; + static struct sunKeyRealPair real_pairs[] = + {{"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, + {"step_tolerance_ic", IDASetStepToleranceIC}, + {"delta_cj_lsetup", IDASetDeltaCjLSetup}, + {"init_step", IDASetInitStep}, + {"max_step", IDASetMaxStep}, + {"min_step", IDASetMinStep}, + {"stop_time", IDASetStopTime}, + {"eta_min", IDASetEtaMin}, + {"eta_max", IDASetEtaMax}, + {"eta_low", IDASetEtaLow}, + {"eta_min_err_fail", IDASetEtaMinErrFail}, + {"eta_conv_fail", IDASetEtaConvFail}, + {"nonlin_conv_coef", IDASetNonlinConvCoef}, + {"eps_lin", IDASetEpsLin}, + {"ls_norm_factor", IDASetLSNormFactor}, + {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, - {"scalar_tolerances", IDASStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - - static struct sunKeyActionPair action_pairs[] = { - {"clear_stop_time", IDAClearStopTime}, - {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; + static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", + IDASetEtaFixedStepBounds}, + {"scalar_tolerances", + IDASStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); + + static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + IDAClearStopTime}, + {"no_inactive_root_warn", + IDASetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; @@ -113,9 +115,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -130,9 +131,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -147,9 +147,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index aeb40593d2..25a6cae78c 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -19,10 +19,10 @@ #include #include #include -#include "sundials_cli.h" #include "idas/idas.h" #include "idas/idas_ls.h" #include "idas_impl.h" +#include "sundials_cli.h" /*--------------------------------------------------------------- IDASetFromCommandLine: @@ -36,87 +36,87 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDAMem IDA_mem; if (ida_mem == NULL) { - IDAProcessError(NULL, IDA_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_NO_MEM); + IDAProcessError(NULL, IDA_MEM_NULL, __LINE__, __func__, __FILE__, MSG_NO_MEM); return (IDA_MEM_NULL); } IDA_mem = (IDAMem)ida_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"max_num_steps_ic", IDASetMaxNumStepsIC}, - {"max_num_jacs_ic", IDASetMaxNumJacsIC}, - {"max_num_iters_ic", IDASetMaxNumItersIC}, - {"linesearch_off_ic", IDASetLineSearchOffIC}, - {"max_backs_ic", IDASetMaxBacksIC}, - {"max_order", IDASetMaxOrd}, - {"max_err_test_fails", IDASetMaxErrTestFails}, - {"suppress_alg", IDASetSuppressAlg}, - {"max_conv_fails", IDASetMaxConvFails}, - {"max_nonlin_iters", IDASetMaxNonlinIters}, - {"quad_err_con", IDASetQuadErrCon}, - {"sens_err_con", IDASetSensErrCon}, - {"sens_max_nonlin_iters", IDASetSensMaxNonlinIters}, - {"quad_sens_err_con", IDASetQuadSensErrCon}, - {"linear_solution_scaling", IDASetLinearSolutionScaling}}; + static struct sunKeyIntPair int_pairs[] = + {{"max_num_steps_ic", IDASetMaxNumStepsIC}, + {"max_num_jacs_ic", IDASetMaxNumJacsIC}, + {"max_num_iters_ic", IDASetMaxNumItersIC}, + {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"max_backs_ic", IDASetMaxBacksIC}, + {"max_order", IDASetMaxOrd}, + {"max_err_test_fails", IDASetMaxErrTestFails}, + {"suppress_alg", IDASetSuppressAlg}, + {"max_conv_fails", IDASetMaxConvFails}, + {"max_nonlin_iters", IDASetMaxNonlinIters}, + {"quad_err_con", IDASetQuadErrCon}, + {"sens_err_con", IDASetSensErrCon}, + {"sens_max_nonlin_iters", IDASetSensMaxNonlinIters}, + {"quad_sens_err_con", IDASetQuadSensErrCon}, + {"linear_solution_scaling", IDASetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = { {"max_num_steps", IDASetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, - {"step_tolerance_ic", IDASetStepToleranceIC}, - {"delta_cj_lsetup", IDASetDeltaCjLSetup}, - {"init_step", IDASetInitStep}, - {"max_step", IDASetMaxStep}, - {"min_step", IDASetMinStep}, - {"stop_time", IDASetStopTime}, - {"eta_min", IDASetEtaMin}, - {"eta_max", IDASetEtaMax}, - {"eta_low", IDASetEtaLow}, - {"eta_min_err_fail", IDASetEtaMinErrFail}, - {"eta_conv_fail", IDASetEtaConvFail}, - {"nonlin_conv_coef", IDASetNonlinConvCoef}, - {"eps_lin", IDASetEpsLin}, - {"ls_norm_factor", IDASetLSNormFactor}, - {"increment_factor", IDASetIncrementFactor}}; + static struct sunKeyRealPair real_pairs[] = + {{"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, + {"step_tolerance_ic", IDASetStepToleranceIC}, + {"delta_cj_lsetup", IDASetDeltaCjLSetup}, + {"init_step", IDASetInitStep}, + {"max_step", IDASetMaxStep}, + {"min_step", IDASetMinStep}, + {"stop_time", IDASetStopTime}, + {"eta_min", IDASetEtaMin}, + {"eta_max", IDASetEtaMax}, + {"eta_low", IDASetEtaLow}, + {"eta_min_err_fail", IDASetEtaMinErrFail}, + {"eta_conv_fail", IDASetEtaConvFail}, + {"nonlin_conv_coef", IDASetNonlinConvCoef}, + {"eps_lin", IDASetEpsLin}, + {"ls_norm_factor", IDASetLSNormFactor}, + {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, - {"scalar_tolerances", IDASStolerances}, - {"quad_scalar_tolerances", IDAQuadSStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + static struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, + {"scalar_tolerances", IDASStolerances}, + {"quad_scalar_tolerances", IDAQuadSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); - static struct sunKeyTwoIntPair twoint_pairs[] = { - {"max_ord_b", IDASetMaxOrdB}, - {"suppress_alg_b", IDASetSuppressAlgB}, - {"quad_err_con_b", IDASetQuadErrConB}, - {"linear_solution_scaling_b", IDASetLinearSolutionScalingB}}; + static struct sunKeyTwoIntPair twoint_pairs[] = + {{"max_ord_b", IDASetMaxOrdB}, + {"suppress_alg_b", IDASetSuppressAlgB}, + {"quad_err_con_b", IDASetQuadErrConB}, + {"linear_solution_scaling_b", IDASetLinearSolutionScalingB}}; static const int num_twoint_keys = sizeof(twoint_pairs) / sizeof(*twoint_pairs); - static struct sunKeyActionPair action_pairs[] = { - {"clear_stop_time", IDAClearStopTime}, - {"no_inactive_root_warn", IDASetNoInactiveRootWarn}, - {"sens_toggle_off", IDASensToggleOff}, - {"adj_no_sensi", IDAAdjSetNoSensi}}; + static struct sunKeyActionPair action_pairs[] = + {{"clear_stop_time", IDAClearStopTime}, + {"no_inactive_root_warn", IDASetNoInactiveRootWarn}, + {"sens_toggle_off", IDASensToggleOff}, + {"adj_no_sensi", IDAAdjSetNoSensi}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - static struct sunKeyIntRealPair int_real_pairs[] = { - {"sens_dq_method", IDASetSensDQMethod}, - {"init_step_b", IDASetInitStepB}, - {"max_step_b", IDASetMaxStepB}, - {"eps_lin_b", IDASetEpsLinB}, - {"ls_norm_factor_b", IDASetLSNormFactorB}, - {"increment_factor_b", IDASetIncrementFactorB}}; + static struct sunKeyIntRealPair int_real_pairs[] = + {{"sens_dq_method", IDASetSensDQMethod}, + {"init_step_b", IDASetInitStepB}, + {"max_step_b", IDASetMaxStepB}, + {"eps_lin_b", IDASetEpsLinB}, + {"ls_norm_factor_b", IDASetLSNormFactorB}, + {"increment_factor_b", IDASetIncrementFactorB}}; static const int num_int_real_keys = sizeof(int_real_pairs) / sizeof(*int_real_pairs); - static struct sunKeyIntRealRealPair int_real_real_pairs[] = { - {"scalar_tolerances_b", IDASStolerancesB}, - {"quad_scalar_tolerances_b", IDAQuadSStolerancesB}}; + static struct sunKeyIntRealRealPair int_real_real_pairs[] = + {{"scalar_tolerances_b", IDASStolerancesB}, + {"quad_scalar_tolerances_b", IDAQuadSStolerancesB}}; static const int num_int_real_real_keys = sizeof(int_real_real_pairs) / sizeof(*int_real_real_pairs); @@ -148,9 +148,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -165,9 +164,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -182,9 +180,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -200,8 +197,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_twoint_keys; j++) { retval = sunCheckAndSetTwoIntArg(ida_mem, &i, argv, offset, - twoint_pairs[j].key, - twoint_pairs[j].set, &arg_used); + twoint_pairs[j].key, twoint_pairs[j].set, + &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -252,8 +249,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = sunCheckAndSetIntRealArg(ida_mem, &i, argv, offset, int_real_pairs[j].key, - int_real_pairs[j].set, - &arg_used); + int_real_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, @@ -270,8 +266,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = sunCheckAndSetIntLongArg(ida_mem, &i, argv, offset, int_long_pairs[j].key, - int_long_pairs[j].set, - &arg_used); + int_long_pairs[j].set, &arg_used); if (retval != IDA_SUCCESS) { IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index fe6db284d8..865c6f5489 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -19,10 +19,10 @@ #include #include #include -#include "sundials_cli.h" #include "kinsol/kinsol.h" #include "kinsol/kinsol_ls.h" #include "kinsol_impl.h" +#include "sundials_cli.h" /*--------------------------------------------------------------- KINSetFromCommandLine: @@ -30,52 +30,49 @@ Parses the command line to control scalar-valued KINSOL options. ---------------------------------------------------------------*/ -int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, - char* argv[]) +int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[]) { KINMem kin_mem; if (kinmem == NULL) { - KINProcessError(NULL, KIN_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_NO_MEM); + KINProcessError(NULL, KIN_MEM_NULL, __LINE__, __func__, __FILE__, MSG_NO_MEM); return (KIN_MEM_NULL); } kin_mem = (KINMem)kinmem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"orth_aa", KINSetOrthAA}, - {"return_newest", KINSetReturnNewest}, - {"no_init_setup", KINSetNoInitSetup}, - {"no_res_mon", KINSetNoResMon}, - {"eta_form", KINSetEtaForm}, - {"no_min_eps", KINSetNoMinEps}}; + static struct sunKeyIntPair int_pairs[] = {{"orth_aa", KINSetOrthAA}, + {"return_newest", KINSetReturnNewest}, + {"no_init_setup", KINSetNoInitSetup}, + {"no_res_mon", KINSetNoResMon}, + {"eta_form", KINSetEtaForm}, + {"no_min_eps", KINSetNoMinEps}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { - {"m_aa", KINSetMAA}, - {"delay_aa", KINSetDelayAA}, - {"num_max_iters", KINSetNumMaxIters}, - {"max_setup_calls", KINSetMaxSetupCalls}, - {"max_sub_setup_calls", KINSetMaxSubSetupCalls}, - {"max_beta_fails", KINSetMaxBetaFails}}; + static struct sunKeyLongPair long_pairs[] = + {{"m_aa", KINSetMAA}, + {"delay_aa", KINSetDelayAA}, + {"num_max_iters", KINSetNumMaxIters}, + {"max_setup_calls", KINSetMaxSetupCalls}, + {"max_sub_setup_calls", KINSetMaxSubSetupCalls}, + {"max_beta_fails", KINSetMaxBetaFails}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"damping", KINSetDamping}, - {"damping_aa", KINSetDampingAA}, - {"eta_const_value", KINSetEtaConstValue}, - {"res_mon_const_value", KINSetResMonConstValue}, - {"max_newton_step", KINSetMaxNewtonStep}, - {"rel_err_func", KINSetRelErrFunc}, - {"func_norm_tol", KINSetFuncNormTol}, - {"scaled_step_tol", KINSetScaledStepTol}}; + static struct sunKeyRealPair real_pairs[] = + {{"damping", KINSetDamping}, + {"damping_aa", KINSetDampingAA}, + {"eta_const_value", KINSetEtaConstValue}, + {"res_mon_const_value", KINSetResMonConstValue}, + {"max_newton_step", KINSetMaxNewtonStep}, + {"rel_err_func", KINSetRelErrFunc}, + {"func_norm_tol", KINSetFuncNormTol}, + {"scaled_step_tol", KINSetScaledStepTol}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"eta_params", KINSetEtaParams}, - {"res_mon_params", KINSetResMonParams}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + static struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_params", KINSetEtaParams}, {"res_mon_params", KINSetResMonParams}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); int i, j, retval; for (i = 1; i < argc; i++) @@ -100,9 +97,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(kinmem, &i, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + retval = sunCheckAndSetIntArg(kinmem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); if (retval != KIN_SUCCESS) { KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, @@ -117,9 +113,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(kinmem, &i, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + retval = sunCheckAndSetLongArg(kinmem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); if (retval != KIN_SUCCESS) { KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, @@ -134,9 +129,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(kinmem, &i, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + retval = sunCheckAndSetRealArg(kinmem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); if (retval != KIN_SUCCESS) { KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index f2b1df210a..1048ac871c 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -15,11 +15,11 @@ * to ARKODE. *--------------------------------------------------------------*/ +#include "sundials_cli.h" #include #include #include #include -#include "sundials_cli.h" /*=============================================================== Command-line input utility routines @@ -86,7 +86,7 @@ int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], int iarg = atoi(argv[*i]); (*i) += 1; sunrealtype rarg = atof(argv[*i]); - int retval = fname(mem, iarg, rarg); + int retval = fname(mem, iarg, rarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } @@ -107,7 +107,7 @@ int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], sunrealtype rarg1 = atof(argv[*i]); (*i) += 1; sunrealtype rarg2 = atof(argv[*i]); - int retval = fname(mem, iarg, rarg1, rarg2); + int retval = fname(mem, iarg, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } @@ -125,7 +125,7 @@ int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], int iarg = atoi(argv[*i]); (*i) += 1; long int larg = atol(argv[*i]); - int retval = fname(mem, iarg, larg); + int retval = fname(mem, iarg, larg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } From 1e6f96f6e784c5e8889aa5ff1c02981043c7559b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 12 Mar 2025 21:21:27 -0500 Subject: [PATCH 040/114] Applied spelling 'patch', that forced me to rename the long-int variable 'larg' as 'large' --- src/sundials/sundials_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index 1048ac871c..6c7d207506 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -124,8 +124,8 @@ int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], (*i) += 1; int iarg = atoi(argv[*i]); (*i) += 1; - long int larg = atol(argv[*i]); - int retval = fname(mem, iarg, larg); + long int large = atol(argv[*i]); + int retval = fname(mem, iarg, large); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } From cefc028e119947e082fd484445da219fd1141391 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 14 Mar 2025 07:27:39 -0500 Subject: [PATCH 041/114] Added command-line control over SUNAdaptControllers --- .../arkode/CXX_serial/ark_heat2D_lsrk.cpp | 9 +- .../sunadaptcontroller_imexgus.h | 7 + .../sunadaptcontroller_mrihtol.h | 16 ++ .../sunadaptcontroller_soderlind.h | 5 + include/sundials/sundials_adaptcontroller.h | 7 + .../imexgus/sunadaptcontroller_imexgus.c | 110 +++++++++- .../mrihtol/sunadaptcontroller_mrihtol.c | 108 +++++++++- .../soderlind/sunadaptcontroller_soderlind.c | 204 +++++++++++++++++- src/sundials/sundials_adaptcontroller.c | 37 +++- 9 files changed, 461 insertions(+), 42 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index f7de7638fe..960b36a1ef 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -303,6 +303,8 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } + flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", argc, argv); + if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) { return 1; } flag = ARKodeSetAdaptController(arkode_mem, C); if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } @@ -656,13 +658,6 @@ static int ReadInputs(int* argc, char*** argv, UserData* udata) InputHelp(); return -1; } - // Unknown input - else - { - cerr << "ERROR: Invalid input " << arg << endl; - InputHelp(); - return -1; - } } // Recompute total number of nodes diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index e5158df6ce..d2e7c5347c 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -49,10 +49,16 @@ typedef struct _SUNAdaptControllerContent_ImExGus* SUNAdaptControllerContent_ImE SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i); + SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_ImExGus(SUNAdaptController C); @@ -61,6 +67,7 @@ SUNErrCode SUNAdaptController_EstimateStep_ImExGus(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Reset_ImExGus(SUNAdaptController C); diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 692ed1ca53..624f96552e 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -47,36 +47,52 @@ SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, SUNAdaptController TolControl, SUNContext sunctx); + +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController C, SUNAdaptController* Cslow); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_GetFastController_MRIHTol(SUNAdaptController C, SUNAdaptController* Cfast); + SUNDIALS_EXPORT SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C); + SUNDIALS_EXPORT int SUNAdaptController_EstimateStepTol_MRIHTol( SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew); + SUNDIALS_EXPORT int SUNAdaptController_Reset_MRIHTol(SUNAdaptController C); + SUNDIALS_EXPORT int SUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController C); + SUNDIALS_EXPORT int SUNAdaptController_Write_MRIHTol(SUNAdaptController C, FILE* fptr); + SUNDIALS_EXPORT int SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, sunrealtype bias); + SUNDIALS_EXPORT int SUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController C, sunrealtype H, sunrealtype tolfac, sunrealtype DSM, sunrealtype dsm); + SUNDIALS_EXPORT int SUNAdaptController_Space_MRIHTol(SUNAdaptController C, long int* lenrw, long int* leniw); diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index 9681ba3e3e..ec08f2d423 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -53,6 +53,11 @@ typedef struct _SUNAdaptControllerContent_Soderlind* SUNAdaptControllerContent_S SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k1, sunrealtype k2, diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 7e2055cb78..590db5878e 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -73,6 +73,8 @@ struct _generic_SUNAdaptController_Ops /* OPTIONAL for all SUNAdaptController implementations. */ SUNErrCode (*destroy)(SUNAdaptController C); SUNErrCode (*reset)(SUNAdaptController C); + SUNErrCode (*setfromcommandline)(SUNAdaptController C, const char* Cid, + int argc, char* argv[]); SUNErrCode (*setdefaults)(SUNAdaptController C); SUNErrCode (*write)(SUNAdaptController C, FILE* fptr); SUNErrCode (*seterrorbias)(SUNAdaptController C, sunrealtype bias); @@ -147,6 +149,11 @@ SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Reset(SUNAdaptController C); +/* Function to update internal controller parameters from the command line. */ +SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); + /* Function to set the controller parameters to their default values. */ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetDefaults(SUNAdaptController C); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index c8517c9cbf..db481ca83f 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -24,6 +25,7 @@ #include #include "sundials_macros.h" +#include "sundials_cli.h" /* --------------- * Macro accessors @@ -71,14 +73,15 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) SUNCheckLastErrNull(); /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ImExGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; - C->ops->reset = SUNAdaptController_Reset_ImExGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; - C->ops->write = SUNAdaptController_Write_ImExGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; - C->ops->updateh = SUNAdaptController_UpdateH_ImExGus; - C->ops->space = SUNAdaptController_Space_ImExGus; + C->ops->gettype = SUNAdaptController_GetType_ImExGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; + C->ops->reset = SUNAdaptController_Reset_ImExGus; + C->ops->setfromcommandline = SUNAdaptController_SetFromCommandLine_ImExGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; + C->ops->write = SUNAdaptController_Write_ImExGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; + C->ops->updateh = SUNAdaptController_UpdateH_ImExGus; + C->ops->space = SUNAdaptController_Space_ImExGus; /* Create content */ content = NULL; @@ -95,6 +98,97 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) return (C); } +/* ----------------------------------------------------------------- + * Function to control ImExGus parameters from the command line + */ + +SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) +{ + SUNFunctionBegin(C->sunctx); + + int i, j; + SUNErrCode retval; + sunbooleantype write_parameters = SUNFALSE; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if Cid is supplied, skip command-line arguments that do not begin with Cid; + else, skip command-line arguments that do not begin with "sunadaptcontroller." */ + size_t offset; + if (strlen(Cid) > 0) + { + if (strncmp(argv[i], Cid, strlen(Cid)) != 0) { continue; } + offset = strlen(Cid) + 1; + } + else + { + static const char* prefix = "sunadaptcontroller_imexgus."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over SetParams function */ + if (strcmp(argv[i] + offset, "params") == 0) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + i += 1; + sunrealtype rarg3 = atof(argv[i]); + i += 1; + sunrealtype rarg4 = atof(argv[i]); + retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetDefaults function */ + if (strcmp(argv[i] + offset, "defaults") == 0) + { + retval = SUNAdaptController_SetDefaults_ImExGus(C); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetErrorBias function */ + if (strcmp(argv[i] + offset, "error_bias") == 0) + { + i += 1; + sunrealtype rarg = atof(argv[i]); + retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* check whether it was requested that all parameters be printed to screen */ + if (strcmp(argv[i] + offset, "write_parameters") == 0) + { + write_parameters = SUNTRUE; + arg_used = SUNTRUE; + continue; + } + } + + /* Call SUNAdaptController_Write_ImExGus (if requested) now that all + command-line options have been set -- WARNING: this knows + nothing about MPI, so it could be redundantly written by all + processes if requested. */ + if (write_parameters) + { + retval = SUNAdaptController_Write_ImExGus(C, stdout); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ----------------------------------------------------------------- * Function to set ImExGus parameters */ diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 24d8c4bf07..8d35a6c24a 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -24,6 +25,7 @@ #include "sundials/sundials_errors.h" #include "sundials_macros.h" +#include "sundials_cli.h" /* ------------------ * Default parameters @@ -76,14 +78,15 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, SUNCheckLastErrNull(); /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_MRIHTol; - C->ops->estimatesteptol = SUNAdaptController_EstimateStepTol_MRIHTol; - C->ops->reset = SUNAdaptController_Reset_MRIHTol; - C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; - C->ops->write = SUNAdaptController_Write_MRIHTol; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; - C->ops->updatemrihtol = SUNAdaptController_UpdateMRIHTol_MRIHTol; - C->ops->space = SUNAdaptController_Space_MRIHTol; + C->ops->gettype = SUNAdaptController_GetType_MRIHTol; + C->ops->estimatesteptol = SUNAdaptController_EstimateStepTol_MRIHTol; + C->ops->reset = SUNAdaptController_Reset_MRIHTol; + C->ops->setfromcommandline = SUNAdaptController_SetFromCommandLine_MRIHTol; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; + C->ops->write = SUNAdaptController_Write_MRIHTol; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; + C->ops->updatemrihtol = SUNAdaptController_UpdateMRIHTol_MRIHTol; + C->ops->space = SUNAdaptController_Space_MRIHTol; /* Create content */ content = NULL; @@ -105,6 +108,95 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, return C; } +/* ----------------------------------------------------------------- + * Function to control MRIHTol parameters from the command line + */ + +SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) +{ + SUNFunctionBegin(C->sunctx); + + int i, j; + SUNErrCode retval; + sunbooleantype write_parameters = SUNFALSE; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if Cid is supplied, skip command-line arguments that do not begin with Cid; + else, skip command-line arguments that do not begin with "sunadaptcontroller." */ + size_t offset; + if (strlen(Cid) > 0) + { + if (strncmp(argv[i], Cid, strlen(Cid)) != 0) { continue; } + offset = strlen(Cid) + 1; + } + else + { + static const char* prefix = "sunadaptcontroller_mrihtol."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over SetParams function */ + if (strcmp(argv[i] + offset, "params") == 0) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + i += 1; + sunrealtype rarg3 = atof(argv[i]); + retval = SUNAdaptController_SetParams_MRIHTol(C, rarg1, rarg2, rarg3); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetDefaults function */ + if (strcmp(argv[i] + offset, "defaults") == 0) + { + retval = SUNAdaptController_SetDefaults_MRIHTol(C); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetErrorBias function */ + if (strcmp(argv[i] + offset, "error_bias") == 0) + { + i += 1; + sunrealtype rarg = atof(argv[i]); + retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* check whether it was requested that all parameters be printed to screen */ + if (strcmp(argv[i] + offset, "write_parameters") == 0) + { + write_parameters = SUNTRUE; + arg_used = SUNTRUE; + continue; + } + } + + /* Call SUNAdaptController_Write_MRIHTol (if requested) now that all + command-line options have been set -- WARNING: this knows + nothing about MPI, so it could be redundantly written by all + processes if requested. */ + if (write_parameters) + { + retval = SUNAdaptController_Write_MRIHTol(C, stdout); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ----------------------------------------------------------------- * Function to set MRIHTol parameters */ diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 8292f05bb0..9fd90b80c2 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -24,6 +25,7 @@ #include #include "sundials_macros.h" +#include "sundials_cli.h" /* --------------- * Macro accessors @@ -85,14 +87,15 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) SUNCheckLastErrNull(); /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_Soderlind; - C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; - C->ops->reset = SUNAdaptController_Reset_Soderlind; - C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; - C->ops->write = SUNAdaptController_Write_Soderlind; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; - C->ops->updateh = SUNAdaptController_UpdateH_Soderlind; - C->ops->space = SUNAdaptController_Space_Soderlind; + C->ops->gettype = SUNAdaptController_GetType_Soderlind; + C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; + C->ops->reset = SUNAdaptController_Reset_Soderlind; + C->ops->setfromcommandline = SUNAdaptController_SetFromCommandLine_Soderlind; + C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; + C->ops->write = SUNAdaptController_Write_Soderlind; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; + C->ops->updateh = SUNAdaptController_UpdateH_Soderlind; + C->ops->space = SUNAdaptController_Space_Soderlind; /* Create content */ content = NULL; @@ -109,6 +112,191 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) return (C); } +/* ----------------------------------------------------------------- + * Function to control Soderlind parameters from the command line + */ + +SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) +{ + SUNFunctionBegin(C->sunctx); + + int i, j; + SUNErrCode retval; + sunbooleantype write_parameters = SUNFALSE; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if Cid is supplied, skip command-line arguments that do not begin with Cid; + else, skip command-line arguments that do not begin with "sunadaptcontroller." */ + size_t SOffset, PIDOffset, PIOffset, IOffset, ExpGusOffset, ImpGusOffset; + const char* SPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_soderlind."; + const char* PIDPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pid."; + const char* PIPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pi."; + const char* IPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_i."; + const char* ExpGusPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_expgus."; + const char* ImpGusPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_impgus."; + if (strlen(Cid) > 0) + { + SOffset = PIDOffset = PIOffset = IOffset = ExpGusOffset = ImpGusOffset = strlen(Cid) + 1; + } else { + SOffset = strlen(SPrefix); + PIDOffset = strlen(PIDPrefix); + PIOffset = strlen(PIPrefix); + IOffset = strlen(IPrefix); + ExpGusOffset = strlen(ExpGusPrefix); + ImpGusOffset = strlen(ImpGusPrefix); + } + + /* control over SetParams_Soderlind function */ + if ((strncmp(argv[i], SPrefix, strlen(SPrefix)) == 0) && + (strcmp(argv[i] + SOffset, "params") == 0)) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + i += 1; + sunrealtype rarg3 = atof(argv[i]); + i += 1; + sunrealtype rarg4 = atof(argv[i]); + i += 1; + sunrealtype rarg5 = atof(argv[i]); + retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, rarg4, rarg5); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetParams_PID function */ + if ((strncmp(argv[i], PIDPrefix, strlen(PIDPrefix)) == 0) && + (strcmp(argv[i] + PIDOffset, "params") == 0)) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + i += 1; + sunrealtype rarg3 = atof(argv[i]); + retval = SUNAdaptController_SetParams_PID(C, rarg1, rarg2, rarg3); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetParams_PI function */ + if ((strncmp(argv[i], PIPrefix, strlen(PIPrefix)) == 0) && + (strcmp(argv[i] + PIOffset, "params") == 0)) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetParams_I function */ + if ((strncmp(argv[i], IPrefix, strlen(IPrefix)) == 0) && + (strcmp(argv[i] + IOffset, "params") == 0)) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + retval = SUNAdaptController_SetParams_I(C, rarg1); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetParams_ExpGus function */ + if ((strncmp(argv[i], ExpGusPrefix, strlen(ExpGusPrefix)) == 0) && + (strcmp(argv[i] + ExpGusOffset, "params") == 0)) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetParams_ImpGus function */ + if ((strncmp(argv[i], ImpGusPrefix, strlen(ImpGusPrefix)) == 0) && + (strcmp(argv[i] + ImpGusOffset, "params") == 0)) + { + i += 1; + sunrealtype rarg1 = atof(argv[i]); + i += 1; + sunrealtype rarg2 = atof(argv[i]); + retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetDefaults_Soderlind function */ + if ((strcmp(argv[i] + SOffset, "defaults") == 0) || + (strcmp(argv[i] + PIDOffset, "defaults") == 0) || + (strcmp(argv[i] + PIOffset, "defaults") == 0) || + (strcmp(argv[i] + IOffset, "defaults") == 0) || + (strcmp(argv[i] + ExpGusOffset, "defaults") == 0) || + (strcmp(argv[i] + ImpGusOffset, "defaults") == 0)) + { + retval = SUNAdaptController_SetDefaults_Soderlind(C); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over SetErrorBias_Soderlind function */ + if ((strcmp(argv[i] + SOffset, "error_bias") == 0) || + (strcmp(argv[i] + PIDOffset, "error_bias") == 0) || + (strcmp(argv[i] + PIOffset, "error_bias") == 0) || + (strcmp(argv[i] + IOffset, "error_bias") == 0) || + (strcmp(argv[i] + ExpGusOffset, "error_bias") == 0) || + (strcmp(argv[i] + ImpGusOffset, "error_bias") == 0)) + { + i += 1; + sunrealtype rarg = atof(argv[i]); + retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* check whether it was requested that all parameters be printed to screen */ + if ((strcmp(argv[i] + SOffset, "write_parameters") == 0) || + (strcmp(argv[i] + PIDOffset, "write_parameters") == 0) || + (strcmp(argv[i] + PIOffset, "write_parameters") == 0) || + (strcmp(argv[i] + IOffset, "write_parameters") == 0) || + (strcmp(argv[i] + ExpGusOffset, "write_parameters") == 0) || + (strcmp(argv[i] + ImpGusOffset, "write_parameters") == 0)) + { + write_parameters = SUNTRUE; + arg_used = SUNTRUE; + continue; + } + } + + /* Call SUNAdaptController_Write_Soderlind (if requested) now that all + command-line options have been set -- WARNING: this knows + nothing about MPI, so it could be redundantly written by all + processes if requested. */ + if (write_parameters) + { + retval = SUNAdaptController_Write_Soderlind(C, stdout); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ----------------------------------------------------------------- * Function to set Soderlind parameters */ diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 9664e0934f..aaf0ed1032 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -46,17 +46,18 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->destroy = NULL; - ops->reset = NULL; - ops->estimatestep = NULL; - ops->estimatesteptol = NULL; - ops->setdefaults = NULL; - ops->write = NULL; - ops->seterrorbias = NULL; - ops->updateh = NULL; - ops->updatemrihtol = NULL; - ops->space = NULL; + ops->gettype = NULL; + ops->destroy = NULL; + ops->reset = NULL; + ops->estimatestep = NULL; + ops->estimatesteptol = NULL; + ops->setfromcommandline = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->seterrorbias = NULL; + ops->updateh = NULL; + ops->updatemrihtol = NULL; + ops->space = NULL; /* attach ops and initialize content to NULL */ C->ops = ops; @@ -168,6 +169,20 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) return (ier); } +SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) +{ + SUNErrCode ier = SUN_SUCCESS; + if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } + SUNFunctionBegin(C->sunctx); + if (C->ops->setfromcommandline) + { + ier = C->ops->setfromcommandline(C, Cid, argc, argv); + } + return (ier); +} + SUNErrCode SUNAdaptController_SetDefaults(SUNAdaptController C) { SUNErrCode ier = SUN_SUCCESS; From b2765500a62d6fda8303ee24998e9b7ee814fbff Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 14 Mar 2025 07:28:37 -0500 Subject: [PATCH 042/114] Updated Swig interfaces --- .../fsunadaptcontroller_imexgus_mod.c | 74 +++++++++++++++++++ .../fsunadaptcontroller_imexgus_mod.f90 | 70 ++++++++++++++++++ .../fsunadaptcontroller_imexgus_mod.c | 74 +++++++++++++++++++ .../fsunadaptcontroller_imexgus_mod.f90 | 70 ++++++++++++++++++ .../fsunadaptcontroller_mrihtol_mod.c | 33 +++++++++ .../fsunadaptcontroller_mrihtol_mod.f90 | 62 ++++++++++++++++ .../fsunadaptcontroller_mrihtol_mod.c | 33 +++++++++ .../fsunadaptcontroller_mrihtol_mod.f90 | 62 ++++++++++++++++ .../fsunadaptcontroller_soderlind_mod.c | 74 +++++++++++++++++++ .../fsunadaptcontroller_soderlind_mod.f90 | 70 ++++++++++++++++++ .../fsunadaptcontroller_soderlind_mod.c | 74 +++++++++++++++++++ .../fsunadaptcontroller_soderlind_mod.f90 | 70 ++++++++++++++++++ src/sundials/fmod_int32/fsundials_core_mod.c | 49 ++++++++++++ .../fmod_int32/fsundials_core_mod.f90 | 49 ++++++++++++ src/sundials/fmod_int64/fsundials_core_mod.c | 49 ++++++++++++ .../fmod_int64/fsundials_core_mod.f90 | 49 ++++++++++++ 16 files changed, 962 insertions(+) diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c index 9d4e4a3afd..5f08ac9e61 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -220,6 +275,25 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_ImExGus(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 index 4dc30dc6a1..4fa583355f 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 @@ -26,6 +26,22 @@ module fsunadaptcontroller_imexgus_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_ImExGus + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetFromCommandLine_ImExGus public :: FSUNAdaptController_SetParams_ImExGus public :: FSUNAdaptController_GetType_ImExGus public :: FSUNAdaptController_EstimateStep_ImExGus @@ -46,6 +62,19 @@ function swigc_FSUNAdaptController_ImExGus(farg1) & type(C_PTR) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ImExGus") & result(fresult) @@ -150,6 +179,47 @@ function FSUNAdaptController_ImExGus(sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetFromCommandLine_ImExGus(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetParams_ImExGus(c, k1e, k2e, k1i, k2i) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c index 9d4e4a3afd..5f08ac9e61 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -220,6 +275,25 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_ImExGus(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 index 4dc30dc6a1..4fa583355f 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 @@ -26,6 +26,22 @@ module fsunadaptcontroller_imexgus_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_ImExGus + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetFromCommandLine_ImExGus public :: FSUNAdaptController_SetParams_ImExGus public :: FSUNAdaptController_GetType_ImExGus public :: FSUNAdaptController_EstimateStep_ImExGus @@ -46,6 +62,19 @@ function swigc_FSUNAdaptController_ImExGus(farg1) & type(C_PTR) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ImExGus") & result(fresult) @@ -150,6 +179,47 @@ function FSUNAdaptController_ImExGus(sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetFromCommandLine_ImExGus(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetParams_ImExGus(c, k1e, k2e, k1i, k2i) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index 41ec1e1d1c..05bea32a6c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -297,6 +297,20 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; @@ -464,6 +478,25 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(SUNAdaptControll } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_MRIHTol(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index e7afddd833..1f0fe2fbb0 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -55,6 +55,14 @@ module fsunadaptcontroller_mrihtol_mod module procedure swigf_create_SUNAdaptControllerContent_MRIHTol_ end interface public :: FSUNAdaptController_MRIHTol + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetFromCommandLine_MRIHTol public :: FSUNAdaptController_SetParams_MRIHTol public :: FSUNAdaptController_GetSlowController_MRIHTol public :: FSUNAdaptController_GetFastController_MRIHTol @@ -187,6 +195,19 @@ function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & type(C_PTR) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIHTol") & result(fresult) @@ -481,6 +502,47 @@ function FSUNAdaptController_MRIHTol(hcontrol, tolcontrol, sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetFromCommandLine_MRIHTol(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tolfac, inner_max_tolfac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index 41ec1e1d1c..05bea32a6c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -297,6 +297,20 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; @@ -464,6 +478,25 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(SUNAdaptControll } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_MRIHTol(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index e7afddd833..1f0fe2fbb0 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -55,6 +55,14 @@ module fsunadaptcontroller_mrihtol_mod module procedure swigf_create_SUNAdaptControllerContent_MRIHTol_ end interface public :: FSUNAdaptController_MRIHTol + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetFromCommandLine_MRIHTol public :: FSUNAdaptController_SetParams_MRIHTol public :: FSUNAdaptController_GetSlowController_MRIHTol public :: FSUNAdaptController_GetFastController_MRIHTol @@ -187,6 +195,19 @@ function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & type(C_PTR) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIHTol") & result(fresult) @@ -481,6 +502,47 @@ function FSUNAdaptController_MRIHTol(hcontrol, tolcontrol, sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetFromCommandLine_MRIHTol(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tolfac, inner_max_tolfac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c index 20bcb023cb..9d8424928b 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -220,6 +275,25 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_Soderlind(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 index 67d65f5068..27bcb0cf4a 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 @@ -26,6 +26,22 @@ module fsunadaptcontroller_soderlind_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_Soderlind + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetFromCommandLine_Soderlind public :: FSUNAdaptController_SetParams_Soderlind public :: FSUNAdaptController_GetType_Soderlind public :: FSUNAdaptController_EstimateStep_Soderlind @@ -56,6 +72,19 @@ function swigc_FSUNAdaptController_Soderlind(farg1) & type(C_PTR) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetParams_Soderlind(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FSUNAdaptController_SetParams_Soderlind") & result(fresult) @@ -251,6 +280,47 @@ function FSUNAdaptController_Soderlind(sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetFromCommandLine_Soderlind(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetParams_Soderlind(c, k1, k2, k3, k4, k5) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c index 20bcb023cb..9d8424928b 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -220,6 +275,25 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_Soderlind(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 index 67d65f5068..27bcb0cf4a 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 @@ -26,6 +26,22 @@ module fsunadaptcontroller_soderlind_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_Soderlind + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetFromCommandLine_Soderlind public :: FSUNAdaptController_SetParams_Soderlind public :: FSUNAdaptController_GetType_Soderlind public :: FSUNAdaptController_EstimateStep_Soderlind @@ -56,6 +72,19 @@ function swigc_FSUNAdaptController_Soderlind(farg1) & type(C_PTR) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetParams_Soderlind(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FSUNAdaptController_SetParams_Soderlind") & result(fresult) @@ -251,6 +280,47 @@ function FSUNAdaptController_Soderlind(sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetFromCommandLine_Soderlind(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetParams_Soderlind(c, k1, k2, k3, k4, k5) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 71d14a3c36..2c8f2e3064 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -193,6 +193,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -292,6 +308,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_adaptcontroller.h" +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include "sundials/sundials_stepper.h" SWIGEXPORT void _wrap_FSUNLogErrHandlerFn(int const *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, SwigArrayWrapper *farg4, int const *farg5, void *farg6, void *farg7) { @@ -2598,6 +2628,25 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index b56a9a040b..4b9728bf32 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -522,6 +522,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset + type(C_FUNPTR), public :: setfromcommandline type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias @@ -542,6 +543,18 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FSUNAdaptController_SetFromCommandLine public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -2044,6 +2057,19 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -4993,6 +5019,29 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function +function FSUNAdaptController_SetFromCommandLine(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index b389504c8d..ae4365ffe5 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -193,6 +193,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -292,6 +308,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_adaptcontroller.h" +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include "sundials/sundials_stepper.h" SWIGEXPORT void _wrap_FSUNLogErrHandlerFn(int const *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, SwigArrayWrapper *farg4, int const *farg5, void *farg6, void *farg7) { @@ -2598,6 +2628,25 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine(SUNAdaptController,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNAdaptController_SetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 30a58656d0..a0b04bbfcc 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -522,6 +522,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset + type(C_FUNPTR), public :: setfromcommandline type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias @@ -542,6 +543,18 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FSUNAdaptController_SetFromCommandLine public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -2044,6 +2057,19 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -4993,6 +5019,29 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function +function FSUNAdaptController_SetFromCommandLine(c, cid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING From f0cc75663b87622fc91d3f3b2524cdf0271a65ea Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:04:22 -0500 Subject: [PATCH 043/114] Added command-line control over SUNLinearSolvers --- examples/arkode/C_serial/ark_heat1D.c | 8 +- include/sundials/sundials_linearsolver.h | 6 + include/sunlinsol/sunlinsol_klu.h | 3 + include/sunlinsol/sunlinsol_magmadense.h | 3 + include/sunlinsol/sunlinsol_pcg.h | 5 + include/sunlinsol/sunlinsol_spbcgs.h | 3 + include/sunlinsol/sunlinsol_spfgmr.h | 3 + include/sunlinsol/sunlinsol_spgmr.h | 3 + include/sunlinsol/sunlinsol_sptfqmr.h | 3 + include/sunlinsol/sunlinsol_superlumt.h | 3 + src/sundials/fmod_int32/fsundials_core_mod.c | 31 ++++- .../fmod_int32/fsundials_core_mod.f90 | 60 ++++++++-- src/sundials/fmod_int64/fsundials_core_mod.c | 31 ++++- .../fmod_int64/fsundials_core_mod.f90 | 60 ++++++++-- src/sundials/sundials_linearsolver.c | 44 ++++--- .../klu/fmod_int32/fsunlinsol_klu_mod.c | 53 +++++++++ .../klu/fmod_int32/fsunlinsol_klu_mod.f90 | 62 ++++++++++ .../klu/fmod_int64/fsunlinsol_klu_mod.c | 53 +++++++++ .../klu/fmod_int64/fsunlinsol_klu_mod.f90 | 62 ++++++++++ src/sunlinsol/klu/sunlinsol_klu.c | 65 ++++++++-- .../magmadense/sunlinsol_magmadense.cpp | 61 ++++++++-- .../pcg/fmod_int32/fsunlinsol_pcg_mod.c | 74 ++++++++++++ .../pcg/fmod_int32/fsunlinsol_pcg_mod.f90 | 70 +++++++++++ .../pcg/fmod_int64/fsunlinsol_pcg_mod.c | 74 ++++++++++++ .../pcg/fmod_int64/fsunlinsol_pcg_mod.f90 | 70 +++++++++++ src/sunlinsol/pcg/sunlinsol_pcg.c | 101 +++++++++++++--- .../spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c | 74 ++++++++++++ .../fmod_int32/fsunlinsol_spbcgs_mod.f90 | 70 +++++++++++ .../spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c | 74 ++++++++++++ .../fmod_int64/fsunlinsol_spbcgs_mod.f90 | 70 +++++++++++ src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 101 +++++++++++++--- .../spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c | 74 ++++++++++++ .../fmod_int32/fsunlinsol_spfgmr_mod.f90 | 70 +++++++++++ .../spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c | 74 ++++++++++++ .../fmod_int64/fsunlinsol_spfgmr_mod.f90 | 70 +++++++++++ src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 112 +++++++++++++++--- .../spgmr/fmod_int32/fsunlinsol_spgmr_mod.c | 74 ++++++++++++ .../spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 | 70 +++++++++++ .../spgmr/fmod_int64/fsunlinsol_spgmr_mod.c | 74 ++++++++++++ .../spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 | 70 +++++++++++ src/sunlinsol/spgmr/sunlinsol_spgmr.c | 112 +++++++++++++++--- .../fmod_int32/fsunlinsol_sptfqmr_mod.c | 74 ++++++++++++ .../fmod_int32/fsunlinsol_sptfqmr_mod.f90 | 70 +++++++++++ .../fmod_int64/fsunlinsol_sptfqmr_mod.c | 74 ++++++++++++ .../fmod_int64/fsunlinsol_sptfqmr_mod.f90 | 70 +++++++++++ src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 101 +++++++++++++--- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 65 ++++++++-- 47 files changed, 2505 insertions(+), 149 deletions(-) diff --git a/examples/arkode/C_serial/ark_heat1D.c b/examples/arkode/C_serial/ark_heat1D.c index 55280ec256..7369e8010a 100644 --- a/examples/arkode/C_serial/ark_heat1D.c +++ b/examples/arkode/C_serial/ark_heat1D.c @@ -71,7 +71,7 @@ static int Jac(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, N_Vector fy, static int check_flag(void* flagvalue, const char* funcname, int opt); /* Main Program */ -int main(void) +int main(int argc, char* argv[]) { /* general problem parameters */ sunrealtype T0 = SUN_RCONST(0.0); /* initial time */ @@ -150,6 +150,12 @@ int main(void) flag = ARKodeSetLinear(arkode_mem, 0); if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } + /* Override any current settings with command-line options */ + flag = ARKodeSetFromCommandLine(arkode_mem, "", argc, argv); + if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } + flag = SUNLinSolSetFromCommandLine(LS, "", argc, argv); + if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } + /* output mesh to disk */ FID = fopen("heat_mesh.txt", "w"); for (i = 0; i < N; i++) { fprintf(FID, " %.16" ESYM "\n", udata->dx * i); } diff --git a/include/sundials/sundials_linearsolver.h b/include/sundials/sundials_linearsolver.h index f641a1df7c..e938201eb0 100644 --- a/include/sundials/sundials_linearsolver.h +++ b/include/sundials/sundials_linearsolver.h @@ -118,6 +118,8 @@ struct _generic_SUNLinearSolver_Ops SUNErrCode (*setpreconditioner)(SUNLinearSolver, void*, SUNPSetupFn, SUNPSolveFn); SUNErrCode (*setscalingvectors)(SUNLinearSolver, N_Vector, N_Vector); + SUNErrCode (*setfromcommandline)(SUNLinearSolver, const char* Cid, + int argc, char* argv[]); SUNErrCode (*setzeroguess)(SUNLinearSolver, sunbooleantype); SUNErrCode (*initialize)(SUNLinearSolver); int (*setup)(SUNLinearSolver, SUNMatrix); @@ -168,6 +170,10 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1, N_Vector s2); +SUNDIALS_EXPORT +SUNErrCode SUNLinSolSetFromCommandLine(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess(SUNLinearSolver S, sunbooleantype onoff); diff --git a/include/sunlinsol/sunlinsol_klu.h b/include/sunlinsol/sunlinsol_klu.h index 22c3a0c506..9c0117a6ba 100644 --- a/include/sunlinsol/sunlinsol_klu.h +++ b/include/sunlinsol/sunlinsol_klu.h @@ -131,6 +131,9 @@ SUNDIALS_EXPORT sun_klu_common* SUNLinSol_KLUGetCommon(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_KLU(SUNLinearSolver S); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT int SUNLinSolSetup_KLU(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_KLU(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, sunrealtype tol); diff --git a/include/sunlinsol/sunlinsol_magmadense.h b/include/sunlinsol/sunlinsol_magmadense.h index 3aff791908..f2e709c968 100644 --- a/include/sunlinsol/sunlinsol_magmadense.h +++ b/include/sunlinsol/sunlinsol_magmadense.h @@ -65,6 +65,9 @@ SUNDIALS_EXPORT int SUNLinSol_MagmaDense_SetAsync(SUNLinearSolver S, SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_MagmaDense(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_MagmaDense(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_MagmaDense(SUNLinearSolver S); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT int SUNLinSolSetup_MagmaDense(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_MagmaDense(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, diff --git a/include/sunlinsol/sunlinsol_pcg.h b/include/sunlinsol/sunlinsol_pcg.h index 545a426f8d..fa18800614 100644 --- a/include/sunlinsol/sunlinsol_pcg.h +++ b/include/sunlinsol/sunlinsol_pcg.h @@ -87,6 +87,11 @@ SUNLinearSolver_ID SUNLinSolGetID_PCG(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_PCG(SUNLinearSolver S); +SUNDIALS_EXPORT +SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_PCG(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_spbcgs.h b/include/sunlinsol/sunlinsol_spbcgs.h index e4e458c28d..0bc1f1f9e1 100644 --- a/include/sunlinsol/sunlinsol_spbcgs.h +++ b/include/sunlinsol/sunlinsol_spbcgs.h @@ -83,6 +83,9 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S, int maxl); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPBCGS(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPBCGS(SUNLinearSolver S); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPBCGS(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_spfgmr.h b/include/sunlinsol/sunlinsol_spfgmr.h index 4016726a9a..55df42665e 100644 --- a/include/sunlinsol/sunlinsol_spfgmr.h +++ b/include/sunlinsol/sunlinsol_spfgmr.h @@ -84,6 +84,9 @@ typedef struct _SUNLinearSolverContent_SPFGMR* SUNLinearSolverContent_SPFGMR; SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S, int pretype); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S, diff --git a/include/sunlinsol/sunlinsol_spgmr.h b/include/sunlinsol/sunlinsol_spgmr.h index b0ac8866d7..9f23f215ab 100644 --- a/include/sunlinsol/sunlinsol_spgmr.h +++ b/include/sunlinsol/sunlinsol_spgmr.h @@ -93,6 +93,9 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S, SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPGMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPGMR(SUNLinearSolver S); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPGMR(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_sptfqmr.h b/include/sunlinsol/sunlinsol_sptfqmr.h index 9dd24644f6..91ab886227 100644 --- a/include/sunlinsol/sunlinsol_sptfqmr.h +++ b/include/sunlinsol/sunlinsol_sptfqmr.h @@ -85,6 +85,9 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S, int maxl) SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPTFQMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPTFQMR(SUNLinearSolver S); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPTFQMR(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_superlumt.h b/include/sunlinsol/sunlinsol_superlumt.h index 01900910fb..22d6f31622 100644 --- a/include/sunlinsol/sunlinsol_superlumt.h +++ b/include/sunlinsol/sunlinsol_superlumt.h @@ -95,6 +95,9 @@ typedef struct _SUNLinearSolverContent_SuperLUMT* SUNLinearSolverContent_SuperLU SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT(SUNLinearSolver S); diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 2c8f2e3064..18a0a2faaa 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -302,12 +302,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" -#include "sundials/sundials_nonlinearsolver.h" - - -#include "sundials/sundials_adaptcontroller.h" - - typedef struct { void* cptr; int cmemflags; @@ -322,6 +316,12 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include "sundials/sundials_nonlinearsolver.h" + + +#include "sundials/sundials_adaptcontroller.h" + + #include "sundials/sundials_stepper.h" SWIGEXPORT void _wrap_FSUNLogErrHandlerFn(int const *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, SwigArrayWrapper *farg4, int const *farg5, void *farg6, void *farg7) { @@ -2180,6 +2180,25 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 4b9728bf32..3b09a5b37b 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -411,6 +411,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: setatimes type(C_FUNPTR), public :: setpreconditioner type(C_FUNPTR), public :: setscalingvectors + type(C_FUNPTR), public :: setfromcommandline type(C_FUNPTR), public :: setzeroguess type(C_FUNPTR), public :: initialize type(C_FUNPTR), public :: setup @@ -435,6 +436,18 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FSUNLinSolSetFromCommandLine public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -543,17 +556,6 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type public :: FSUNAdaptController_SetFromCommandLine public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write @@ -1769,6 +1771,19 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -4503,6 +4518,29 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function +function FSUNLinSolSetFromCommandLine(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index ae4365ffe5..6557fbf760 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -302,12 +302,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" -#include "sundials/sundials_nonlinearsolver.h" - - -#include "sundials/sundials_adaptcontroller.h" - - typedef struct { void* cptr; int cmemflags; @@ -322,6 +316,12 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include "sundials/sundials_nonlinearsolver.h" + + +#include "sundials/sundials_adaptcontroller.h" + + #include "sundials/sundials_stepper.h" SWIGEXPORT void _wrap_FSUNLogErrHandlerFn(int const *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, SwigArrayWrapper *farg4, int const *farg5, void *farg6, void *farg7) { @@ -2180,6 +2180,25 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index a0b04bbfcc..4509f697f6 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -411,6 +411,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: setatimes type(C_FUNPTR), public :: setpreconditioner type(C_FUNPTR), public :: setscalingvectors + type(C_FUNPTR), public :: setfromcommandline type(C_FUNPTR), public :: setzeroguess type(C_FUNPTR), public :: initialize type(C_FUNPTR), public :: setup @@ -435,6 +436,18 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FSUNLinSolSetFromCommandLine public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -543,17 +556,6 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type public :: FSUNAdaptController_SetFromCommandLine public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write @@ -1769,6 +1771,19 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -4503,6 +4518,29 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function +function FSUNLinSolSetFromCommandLine(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/sundials_linearsolver.c b/src/sundials/sundials_linearsolver.c index 7f54dfc983..cbe73f9c7d 100644 --- a/src/sundials/sundials_linearsolver.c +++ b/src/sundials/sundials_linearsolver.c @@ -57,21 +57,22 @@ SUNLinearSolver SUNLinSolNewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->getid = NULL; - ops->setatimes = NULL; - ops->setpreconditioner = NULL; - ops->setscalingvectors = NULL; - ops->setzeroguess = NULL; - ops->initialize = NULL; - ops->setup = NULL; - ops->solve = NULL; - ops->numiters = NULL; - ops->resnorm = NULL; - ops->resid = NULL; - ops->lastflag = NULL; - ops->space = NULL; - ops->free = NULL; + ops->gettype = NULL; + ops->getid = NULL; + ops->setatimes = NULL; + ops->setpreconditioner = NULL; + ops->setscalingvectors = NULL; + ops->setfromcommandline = NULL; + ops->setzeroguess = NULL; + ops->initialize = NULL; + ops->setup = NULL; + ops->solve = NULL; + ops->numiters = NULL; + ops->resnorm = NULL; + ops->resid = NULL; + ops->lastflag = NULL; + ops->space = NULL; + ops->free = NULL; /* attach ops and initialize content and context to NULL */ LS->ops = ops; @@ -147,6 +148,19 @@ SUNErrCode SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1, N_Vector s return (ier); } +SUNErrCode SUNLinSolSetFromCommandLine(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) +{ + SUNErrCode ier = SUN_SUCCESS; + if (S == NULL) { return SUN_ERR_ARG_CORRUPT; } + SUNFunctionBegin(S->sunctx); + if (S->ops->setfromcommandline) + { + return (S->ops->setfromcommandline(S, LSid, argc, argv)); + } + return (ier); +} + SUNErrCode SUNLinSolSetZeroGuess(SUNLinearSolver S, sunbooleantype onoff) { if (S->ops->setzeroguess) { return (S->ops->setzeroguess(S, onoff)); } diff --git a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c index 504612c0e0..34783ed3d3 100644 --- a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c +++ b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c @@ -185,6 +185,15 @@ enum { }; +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -229,6 +238,31 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { return result; } + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_KLU(N_Vector farg1, SUNMatrix farg2, void *farg3) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -352,6 +386,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_KLU(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_KLU(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_KLU(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetup_KLU(SUNLinearSolver farg1, SUNMatrix farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 index bbd312f674..ce7c7cccb2 100644 --- a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 +++ b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 @@ -54,6 +54,14 @@ module fsunlinsol_klu_mod public :: FSUNLinSolGetType_KLU public :: FSUNLinSolGetID_KLU public :: FSUNLinSolInitialize_KLU + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_KLU public :: FSUNLinSolSetup_KLU public :: FSUNLinSolSolve_KLU public :: FSUNLinSolLastFlag_KLU @@ -143,6 +151,19 @@ function swigc_FSUNLinSolInitialize_KLU(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_KLU") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetup_KLU(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetup_KLU") & result(fresult) @@ -330,6 +351,47 @@ function FSUNLinSolInitialize_KLU(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_KLU(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetup_KLU(s, a) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c index 3e7b8d0614..c3deeca4de 100644 --- a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c +++ b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c @@ -185,6 +185,15 @@ enum { }; +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -229,6 +238,31 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { return result; } + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_KLU(N_Vector farg1, SUNMatrix farg2, void *farg3) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -352,6 +386,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_KLU(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_KLU(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_KLU(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetup_KLU(SUNLinearSolver farg1, SUNMatrix farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 index f836c8b140..da1c859145 100644 --- a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 +++ b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 @@ -54,6 +54,14 @@ module fsunlinsol_klu_mod public :: FSUNLinSolGetType_KLU public :: FSUNLinSolGetID_KLU public :: FSUNLinSolInitialize_KLU + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_KLU public :: FSUNLinSolSetup_KLU public :: FSUNLinSolSolve_KLU public :: FSUNLinSolLastFlag_KLU @@ -143,6 +151,19 @@ function swigc_FSUNLinSolInitialize_KLU(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_KLU") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetup_KLU(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetup_KLU") & result(fresult) @@ -330,6 +351,47 @@ function FSUNLinSolInitialize_KLU(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_KLU(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetup_KLU(s, a) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index abcc8a5026..837d7a725f 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -19,12 +19,14 @@ #include #include #include +#include #include #include #include #include "sundials_macros.h" +#include "sundials_cli.h" #define ONE SUN_RCONST(1.0) #define TWOTHIRDS SUN_RCONST(0.666666666666666666666666666666667) @@ -79,14 +81,15 @@ SUNLinearSolver SUNLinSol_KLU(N_Vector y, SUNMatrix A, SUNContext sunctx) if (S == NULL) { return (NULL); } /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_KLU; - S->ops->getid = SUNLinSolGetID_KLU; - S->ops->initialize = SUNLinSolInitialize_KLU; - S->ops->setup = SUNLinSolSetup_KLU; - S->ops->solve = SUNLinSolSolve_KLU; - S->ops->lastflag = SUNLinSolLastFlag_KLU; - S->ops->space = SUNLinSolSpace_KLU; - S->ops->free = SUNLinSolFree_KLU; + S->ops->gettype = SUNLinSolGetType_KLU; + S->ops->getid = SUNLinSolGetID_KLU; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_KLU; + S->ops->initialize = SUNLinSolInitialize_KLU; + S->ops->setup = SUNLinSolSetup_KLU; + S->ops->solve = SUNLinSolSolve_KLU; + S->ops->lastflag = SUNLinSolLastFlag_KLU; + S->ops->space = SUNLinSolSpace_KLU; + S->ops->free = SUNLinSolFree_KLU; /* Create content */ content = NULL; @@ -168,6 +171,52 @@ SUNErrCode SUNLinSol_KLUReInit(SUNLinearSolver S, SUNMatrix A, sunindextype nnz, return SUN_SUCCESS; } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spbcgs." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "klu."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over SetOrdering function */ + if (strcmp(argv[i] + offset, "ordering") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_KLUSetOrdering(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to set the ordering type for a KLU linear solver */ diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 2ac907ec54..dac98f564d 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -14,9 +14,11 @@ #include #include +#include #include #include #include +#include "sundials_cli.h" /* Interfaces to match 'sunrealtype' with the correct MAGMA functions */ #if defined(SUNDIALS_DOUBLE_PRECISION) @@ -105,14 +107,15 @@ SUNLinearSolver SUNLinSol_MagmaDense(N_Vector y, SUNMatrix Amat, SUNContext sunc if (S == NULL) { return (NULL); } /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_MagmaDense; - S->ops->getid = SUNLinSolGetID_MagmaDense; - S->ops->initialize = SUNLinSolInitialize_MagmaDense; - S->ops->setup = SUNLinSolSetup_MagmaDense; - S->ops->solve = SUNLinSolSolve_MagmaDense; - S->ops->lastflag = SUNLinSolLastFlag_MagmaDense; - S->ops->space = SUNLinSolSpace_MagmaDense; - S->ops->free = SUNLinSolFree_MagmaDense; + S->ops->gettype = SUNLinSolGetType_MagmaDense; + S->ops->getid = SUNLinSolGetID_MagmaDense; + S->ops->initialize = SUNLinSolInitialize_MagmaDense; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_MagmaDense; + S->ops->setup = SUNLinSolSetup_MagmaDense; + S->ops->solve = SUNLinSolSolve_MagmaDense; + S->ops->lastflag = SUNLinSolLastFlag_MagmaDense; + S->ops->space = SUNLinSolSpace_MagmaDense; + S->ops->free = SUNLinSolFree_MagmaDense; /* Create content */ content = NULL; @@ -231,6 +234,48 @@ SUNErrCode SUNLinSolInitialize_MagmaDense(SUNLinearSolver S) return SUN_SUCCESS; } +SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spbcgs." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "magmadense."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over SetAsync function */ + if (strcmp(argv[i] + offset, "async") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + int SUNLinSolSetup_MagmaDense(SUNLinearSolver S, SUNMatrix A) { /* Check for valid inputs */ diff --git a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c index 9c2f9bcb44..21b6c5bc3f 100644 --- a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c +++ b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_pcg.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_PCG(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -290,6 +345,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_PCG(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_PCG(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_PCG(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_PCG(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 index 5a38ae2960..e6d03beb3e 100644 --- a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 +++ b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 @@ -32,6 +32,22 @@ module fsunlinsol_pcg_mod public :: FSUNLinSolGetType_PCG public :: FSUNLinSolGetID_PCG public :: FSUNLinSolInitialize_PCG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_PCG public :: FSUNLinSolSetATimes_PCG public :: FSUNLinSolSetPreconditioner_PCG public :: FSUNLinSolSetScalingVectors_PCG @@ -100,6 +116,19 @@ function swigc_FSUNLinSolInitialize_PCG(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_PCG") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_PCG(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_PCG") & result(fresult) @@ -309,6 +338,47 @@ function FSUNLinSolInitialize_PCG(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_PCG(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_PCG(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c index 6173f11b75..e32266823b 100644 --- a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c +++ b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_pcg.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_PCG(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -290,6 +345,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_PCG(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_PCG(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_PCG(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_PCG(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 index b6f5851f0e..b0cc010b96 100644 --- a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 +++ b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 @@ -32,6 +32,22 @@ module fsunlinsol_pcg_mod public :: FSUNLinSolGetType_PCG public :: FSUNLinSolGetID_PCG public :: FSUNLinSolInitialize_PCG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_PCG public :: FSUNLinSolSetATimes_PCG public :: FSUNLinSolSetPreconditioner_PCG public :: FSUNLinSolSetScalingVectors_PCG @@ -100,6 +116,19 @@ function swigc_FSUNLinSolInitialize_PCG(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_PCG") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_PCG(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_PCG") & result(fresult) @@ -309,6 +338,47 @@ function FSUNLinSolInitialize_PCG(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_PCG(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_PCG(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 4f524e020e..3c5ef7b996 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -25,6 +26,7 @@ #include "sundials_logger_impl.h" #include "sundials_macros.h" +#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -69,21 +71,22 @@ SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl, SUNContext sunc SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_PCG; - S->ops->getid = SUNLinSolGetID_PCG; - S->ops->setatimes = SUNLinSolSetATimes_PCG; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_PCG; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_PCG; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_PCG; - S->ops->initialize = SUNLinSolInitialize_PCG; - S->ops->setup = SUNLinSolSetup_PCG; - S->ops->solve = SUNLinSolSolve_PCG; - S->ops->numiters = SUNLinSolNumIters_PCG; - S->ops->resnorm = SUNLinSolResNorm_PCG; - S->ops->resid = SUNLinSolResid_PCG; - S->ops->lastflag = SUNLinSolLastFlag_PCG; - S->ops->space = SUNLinSolSpace_PCG; - S->ops->free = SUNLinSolFree_PCG; + S->ops->gettype = SUNLinSolGetType_PCG; + S->ops->getid = SUNLinSolGetID_PCG; + S->ops->setatimes = SUNLinSolSetATimes_PCG; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_PCG; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_PCG; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_PCG; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_PCG; + S->ops->initialize = SUNLinSolInitialize_PCG; + S->ops->setup = SUNLinSolSetup_PCG; + S->ops->solve = SUNLinSolSolve_PCG; + S->ops->numiters = SUNLinSolNumIters_PCG; + S->ops->resnorm = SUNLinSolResNorm_PCG; + S->ops->resid = SUNLinSolResid_PCG; + S->ops->lastflag = SUNLinSolLastFlag_PCG; + S->ops->space = SUNLinSolSpace_PCG; + S->ops->free = SUNLinSolFree_PCG; /* Create content */ content = NULL; @@ -127,6 +130,74 @@ SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl, SUNContext sunc return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spbcgs." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "pcg."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over PrecType function */ + if (strcmp(argv[i] + offset, "prec_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_PCGSetPrecType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over Maxl function */ + if (strcmp(argv[i] + offset, "maxl") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_PCGSetMaxl(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over ZeroGuess function */ + if (strcmp(argv[i] + offset, "zero_guess") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSolSetZeroGuess_PCG(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to set the type of preconditioning for PCG to use */ diff --git a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c index 1a864f19a6..ec519caa5f 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c +++ b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spbcgs.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPBCGS(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -290,6 +345,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPBCGS(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPBCGS(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPBCGS(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 index b83fe50880..b7329e5729 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 +++ b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 @@ -32,6 +32,22 @@ module fsunlinsol_spbcgs_mod public :: FSUNLinSolGetType_SPBCGS public :: FSUNLinSolGetID_SPBCGS public :: FSUNLinSolInitialize_SPBCGS + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPBCGS public :: FSUNLinSolSetATimes_SPBCGS public :: FSUNLinSolSetPreconditioner_SPBCGS public :: FSUNLinSolSetScalingVectors_SPBCGS @@ -100,6 +116,19 @@ function swigc_FSUNLinSolInitialize_SPBCGS(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPBCGS") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_SPBCGS(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPBCGS") & result(fresult) @@ -309,6 +338,47 @@ function FSUNLinSolInitialize_SPBCGS(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPBCGS(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_SPBCGS(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c index 731012db16..7fff1a827a 100644 --- a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c +++ b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spbcgs.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPBCGS(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -290,6 +345,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPBCGS(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPBCGS(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPBCGS(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 index 3530bf5bf3..822c105b3a 100644 --- a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 +++ b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 @@ -32,6 +32,22 @@ module fsunlinsol_spbcgs_mod public :: FSUNLinSolGetType_SPBCGS public :: FSUNLinSolGetID_SPBCGS public :: FSUNLinSolInitialize_SPBCGS + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPBCGS public :: FSUNLinSolSetATimes_SPBCGS public :: FSUNLinSolSetPreconditioner_SPBCGS public :: FSUNLinSolSetScalingVectors_SPBCGS @@ -100,6 +116,19 @@ function swigc_FSUNLinSolInitialize_SPBCGS(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPBCGS") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_SPBCGS(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPBCGS") & result(fresult) @@ -309,6 +338,47 @@ function FSUNLinSolInitialize_SPBCGS(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPBCGS(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_SPBCGS(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 5c941c5e22..4eb193e49d 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -27,6 +28,7 @@ #include "sundials/sundials_errors.h" #include "sundials_logger_impl.h" #include "sundials_macros.h" +#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -78,21 +80,22 @@ SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPBCGS; - S->ops->getid = SUNLinSolGetID_SPBCGS; - S->ops->setatimes = SUNLinSolSetATimes_SPBCGS; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPBCGS; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPBCGS; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPBCGS; - S->ops->initialize = SUNLinSolInitialize_SPBCGS; - S->ops->setup = SUNLinSolSetup_SPBCGS; - S->ops->solve = SUNLinSolSolve_SPBCGS; - S->ops->numiters = SUNLinSolNumIters_SPBCGS; - S->ops->resnorm = SUNLinSolResNorm_SPBCGS; - S->ops->resid = SUNLinSolResid_SPBCGS; - S->ops->lastflag = SUNLinSolLastFlag_SPBCGS; - S->ops->space = SUNLinSolSpace_SPBCGS; - S->ops->free = SUNLinSolFree_SPBCGS; + S->ops->gettype = SUNLinSolGetType_SPBCGS; + S->ops->getid = SUNLinSolGetID_SPBCGS; + S->ops->setatimes = SUNLinSolSetATimes_SPBCGS; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPBCGS; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPBCGS; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPBCGS; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPBCGS; + S->ops->initialize = SUNLinSolInitialize_SPBCGS; + S->ops->setup = SUNLinSolSetup_SPBCGS; + S->ops->solve = SUNLinSolSolve_SPBCGS; + S->ops->numiters = SUNLinSolNumIters_SPBCGS; + S->ops->resnorm = SUNLinSolResNorm_SPBCGS; + S->ops->resid = SUNLinSolResid_SPBCGS; + S->ops->lastflag = SUNLinSolLastFlag_SPBCGS; + S->ops->space = SUNLinSolSpace_SPBCGS; + S->ops->free = SUNLinSolFree_SPBCGS; /* Create content */ content = NULL; @@ -149,6 +152,74 @@ SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spbcgs." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "spbcgs."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over PrecType function */ + if (strcmp(argv[i] + offset, "prec_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over Maxl function */ + if (strcmp(argv[i] + offset, "maxl") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over ZeroGuess function */ + if (strcmp(argv[i] + offset, "zero_guess") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to set the type of preconditioning for SPBCGS to use */ diff --git a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c index 9cb339ae7c..e388a2613f 100644 --- a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c +++ b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spfgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -226,6 +281,25 @@ SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *fa } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPFGMR(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSol_SPFGMRSetPrecType(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 index 6a8f7896e8..1952cd604c 100644 --- a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 +++ b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 @@ -28,6 +28,22 @@ module fsunlinsol_spfgmr_mod integer(C_INT), parameter, public :: SUNSPFGMR_MAXL_DEFAULT = 5_C_INT integer(C_INT), parameter, public :: SUNSPFGMR_MAXRS_DEFAULT = 0_C_INT public :: FSUNLinSol_SPFGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPFGMR public :: FSUNLinSol_SPFGMRSetPrecType public :: FSUNLinSol_SPFGMRSetGSType public :: FSUNLinSol_SPFGMRSetMaxRestarts @@ -60,6 +76,19 @@ function swigc_FSUNLinSol_SPFGMR(farg1, farg2, farg3, farg4) & type(C_PTR) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPFGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSol_SPFGMRSetPrecType(farg1, farg2) & bind(C, name="_wrap_FSUNLinSol_SPFGMRSetPrecType") & result(fresult) @@ -249,6 +278,47 @@ function FSUNLinSol_SPFGMR(y, pretype, maxl, sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPFGMR(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSol_SPFGMRSetPrecType(s, pretype) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c index 7c30b5166d..b9f98a270d 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c +++ b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spfgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -226,6 +281,25 @@ SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *fa } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPFGMR(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSol_SPFGMRSetPrecType(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 index 88ae7451b5..30834e8051 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 +++ b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 @@ -28,6 +28,22 @@ module fsunlinsol_spfgmr_mod integer(C_INT), parameter, public :: SUNSPFGMR_MAXL_DEFAULT = 5_C_INT integer(C_INT), parameter, public :: SUNSPFGMR_MAXRS_DEFAULT = 0_C_INT public :: FSUNLinSol_SPFGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPFGMR public :: FSUNLinSol_SPFGMRSetPrecType public :: FSUNLinSol_SPFGMRSetGSType public :: FSUNLinSol_SPFGMRSetMaxRestarts @@ -60,6 +76,19 @@ function swigc_FSUNLinSol_SPFGMR(farg1, farg2, farg3, farg4) & type(C_PTR) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPFGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSol_SPFGMRSetPrecType(farg1, farg2) & bind(C, name="_wrap_FSUNLinSol_SPFGMRSetPrecType") & result(fresult) @@ -249,6 +278,47 @@ function FSUNLinSol_SPFGMR(y, pretype, maxl, sunctx) & call c_f_pointer(fresult, swig_result) end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPFGMR(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSol_SPFGMRSetPrecType(s, pretype) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index bc6b4576c1..799fe4b04f 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -26,6 +27,7 @@ #include "sundials_logger_impl.h" #include "sundials_macros.h" +#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -78,21 +80,22 @@ SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPFGMR; - S->ops->getid = SUNLinSolGetID_SPFGMR; - S->ops->setatimes = SUNLinSolSetATimes_SPFGMR; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPFGMR; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPFGMR; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPFGMR; - S->ops->initialize = SUNLinSolInitialize_SPFGMR; - S->ops->setup = SUNLinSolSetup_SPFGMR; - S->ops->solve = SUNLinSolSolve_SPFGMR; - S->ops->numiters = SUNLinSolNumIters_SPFGMR; - S->ops->resnorm = SUNLinSolResNorm_SPFGMR; - S->ops->resid = SUNLinSolResid_SPFGMR; - S->ops->lastflag = SUNLinSolLastFlag_SPFGMR; - S->ops->space = SUNLinSolSpace_SPFGMR; - S->ops->free = SUNLinSolFree_SPFGMR; + S->ops->gettype = SUNLinSolGetType_SPFGMR; + S->ops->getid = SUNLinSolGetID_SPFGMR; + S->ops->setatimes = SUNLinSolSetATimes_SPFGMR; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPFGMR; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPFGMR; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPFGMR; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPFGMR; + S->ops->initialize = SUNLinSolInitialize_SPFGMR; + S->ops->setup = SUNLinSolSetup_SPFGMR; + S->ops->solve = SUNLinSolSolve_SPFGMR; + S->ops->numiters = SUNLinSolNumIters_SPFGMR; + S->ops->resnorm = SUNLinSolResNorm_SPFGMR; + S->ops->resid = SUNLinSolResid_SPFGMR; + S->ops->lastflag = SUNLinSolLastFlag_SPFGMR; + S->ops->space = SUNLinSolSpace_SPFGMR; + S->ops->free = SUNLinSolFree_SPFGMR; /* Create content */ content = NULL; @@ -137,6 +140,85 @@ SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spfgmr." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "spfgmr."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over PrecType function */ + if (strcmp(argv[i] + offset, "prec_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over GSType function */ + if (strcmp(argv[i] + offset, "gs_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPFGMRSetGSType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over MaxRestarts function */ + if (strcmp(argv[i] + offset, "max_restarts") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over ZeroGuess function */ + if (strcmp(argv[i] + offset, "zero_guess") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to toggle preconditioning on/off -- turns on if pretype is any * one of SUN_PREC_LEFT, SUN_PREC_RIGHT or SUN_PREC_BOTH; otherwise turns off diff --git a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c index 2be19f50fe..28c7e7503c 100644 --- a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c +++ b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -304,6 +359,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPGMR(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPGMR(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPGMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 index b71379bbb2..b978afeecd 100644 --- a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 +++ b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 @@ -34,6 +34,22 @@ module fsunlinsol_spgmr_mod public :: FSUNLinSolGetType_SPGMR public :: FSUNLinSolGetID_SPGMR public :: FSUNLinSolInitialize_SPGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPGMR public :: FSUNLinSolSetATimes_SPGMR public :: FSUNLinSolSetPreconditioner_SPGMR public :: FSUNLinSolSetScalingVectors_SPGMR @@ -111,6 +127,19 @@ function swigc_FSUNLinSolInitialize_SPGMR(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_SPGMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPGMR") & result(fresult) @@ -336,6 +365,47 @@ function FSUNLinSolInitialize_SPGMR(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPGMR(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_SPGMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c index 8063348bb1..dbd3f9b108 100644 --- a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c +++ b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -304,6 +359,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPGMR(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPGMR(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPGMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 index 950e7ee8a7..5b8222fe8d 100644 --- a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 +++ b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 @@ -34,6 +34,22 @@ module fsunlinsol_spgmr_mod public :: FSUNLinSolGetType_SPGMR public :: FSUNLinSolGetID_SPGMR public :: FSUNLinSolInitialize_SPGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPGMR public :: FSUNLinSolSetATimes_SPGMR public :: FSUNLinSolSetPreconditioner_SPGMR public :: FSUNLinSolSetScalingVectors_SPGMR @@ -111,6 +127,19 @@ function swigc_FSUNLinSolInitialize_SPGMR(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_SPGMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPGMR") & result(fresult) @@ -336,6 +365,47 @@ function FSUNLinSolInitialize_SPGMR(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPGMR(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_SPGMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 55a472987c..3b8bd3fd51 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -26,6 +27,7 @@ #include "sundials_logger_impl.h" #include "sundials_macros.h" +#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -76,21 +78,22 @@ SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPGMR; - S->ops->getid = SUNLinSolGetID_SPGMR; - S->ops->setatimes = SUNLinSolSetATimes_SPGMR; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPGMR; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPGMR; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPGMR; - S->ops->initialize = SUNLinSolInitialize_SPGMR; - S->ops->setup = SUNLinSolSetup_SPGMR; - S->ops->solve = SUNLinSolSolve_SPGMR; - S->ops->numiters = SUNLinSolNumIters_SPGMR; - S->ops->resnorm = SUNLinSolResNorm_SPGMR; - S->ops->resid = SUNLinSolResid_SPGMR; - S->ops->lastflag = SUNLinSolLastFlag_SPGMR; - S->ops->space = SUNLinSolSpace_SPGMR; - S->ops->free = SUNLinSolFree_SPGMR; + S->ops->gettype = SUNLinSolGetType_SPGMR; + S->ops->getid = SUNLinSolGetID_SPGMR; + S->ops->setatimes = SUNLinSolSetATimes_SPGMR; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPGMR; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPGMR; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPGMR; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPGMR; + S->ops->initialize = SUNLinSolInitialize_SPGMR; + S->ops->setup = SUNLinSolSetup_SPGMR; + S->ops->solve = SUNLinSolSolve_SPGMR; + S->ops->numiters = SUNLinSolNumIters_SPGMR; + S->ops->resnorm = SUNLinSolResNorm_SPGMR; + S->ops->resid = SUNLinSolResid_SPGMR; + S->ops->lastflag = SUNLinSolLastFlag_SPGMR; + S->ops->space = SUNLinSolSpace_SPGMR; + S->ops->free = SUNLinSolFree_SPGMR; /* Create content */ content = NULL; @@ -134,6 +137,85 @@ SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spgmr." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "spgmr."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over PrecType function */ + if (strcmp(argv[i] + offset, "prec_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPGMRSetPrecType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over GSType function */ + if (strcmp(argv[i] + offset, "gs_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPGMRSetGSType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over MaxRestarts function */ + if (strcmp(argv[i] + offset, "max_restarts") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over ZeroGuess function */ + if (strcmp(argv[i] + offset, "zero_guess") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to set the type of preconditioning for SPGMR to use */ diff --git a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c index f16ec912e2..648b2c233f 100644 --- a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c +++ b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_sptfqmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPTFQMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -290,6 +345,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPTFQMR(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPTFQMR(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPTFQMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 index e34a320d20..2d2bd25ed5 100644 --- a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 +++ b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 @@ -32,6 +32,22 @@ module fsunlinsol_sptfqmr_mod public :: FSUNLinSolGetType_SPTFQMR public :: FSUNLinSolGetID_SPTFQMR public :: FSUNLinSolInitialize_SPTFQMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPTFQMR public :: FSUNLinSolSetATimes_SPTFQMR public :: FSUNLinSolSetPreconditioner_SPTFQMR public :: FSUNLinSolSetScalingVectors_SPTFQMR @@ -100,6 +116,19 @@ function swigc_FSUNLinSolInitialize_SPTFQMR(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPTFQMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_SPTFQMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPTFQMR") & result(fresult) @@ -309,6 +338,47 @@ function FSUNLinSolInitialize_SPTFQMR(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPTFQMR(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_SPTFQMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c index b5fee5a458..de16e81331 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c +++ b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_sptfqmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPTFQMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -290,6 +345,25 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPTFQMR(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char **arg4 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (int)(*farg3); + SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver,char const *,int,char *[])", return 0); + arg4 = (char **)(farg4->cptr); + result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPTFQMR(arg1,(char const *)arg2,arg3,arg4); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPTFQMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 index ffc1fc0626..6b87ed1ef8 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 +++ b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 @@ -32,6 +32,22 @@ module fsunlinsol_sptfqmr_mod public :: FSUNLinSolGetType_SPTFQMR public :: FSUNLinSolGetID_SPTFQMR public :: FSUNLinSolInitialize_SPTFQMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetFromCommandLine_SPTFQMR public :: FSUNLinSolSetATimes_SPTFQMR public :: FSUNLinSolSetPreconditioner_SPTFQMR public :: FSUNLinSolSetScalingVectors_SPTFQMR @@ -100,6 +116,19 @@ function swigc_FSUNLinSolInitialize_SPTFQMR(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPTFQMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(SwigClassWrapper) :: farg4 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetATimes_SPTFQMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPTFQMR") & result(fresult) @@ -309,6 +338,47 @@ function FSUNLinSolInitialize_SPTFQMR(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetFromCommandLine_SPTFQMR(s, lsid, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: farg3 +type(SwigClassWrapper) :: farg4 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +farg3 = argc +farg4 = argv%swigdata +fresult = swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + function FSUNLinSolSetATimes_SPTFQMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index cc13ae7068..212b54da86 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -25,6 +26,7 @@ #include "sundials_logger_impl.h" #include "sundials_macros.h" +#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -75,21 +77,22 @@ SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPTFQMR; - S->ops->getid = SUNLinSolGetID_SPTFQMR; - S->ops->setatimes = SUNLinSolSetATimes_SPTFQMR; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPTFQMR; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPTFQMR; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPTFQMR; - S->ops->initialize = SUNLinSolInitialize_SPTFQMR; - S->ops->setup = SUNLinSolSetup_SPTFQMR; - S->ops->solve = SUNLinSolSolve_SPTFQMR; - S->ops->numiters = SUNLinSolNumIters_SPTFQMR; - S->ops->resnorm = SUNLinSolResNorm_SPTFQMR; - S->ops->resid = SUNLinSolResid_SPTFQMR; - S->ops->lastflag = SUNLinSolLastFlag_SPTFQMR; - S->ops->space = SUNLinSolSpace_SPTFQMR; - S->ops->free = SUNLinSolFree_SPTFQMR; + S->ops->gettype = SUNLinSolGetType_SPTFQMR; + S->ops->getid = SUNLinSolGetID_SPTFQMR; + S->ops->setatimes = SUNLinSolSetATimes_SPTFQMR; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPTFQMR; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPTFQMR; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPTFQMR; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPTFQMR; + S->ops->initialize = SUNLinSolInitialize_SPTFQMR; + S->ops->setup = SUNLinSolSetup_SPTFQMR; + S->ops->solve = SUNLinSolSolve_SPTFQMR; + S->ops->numiters = SUNLinSolNumIters_SPTFQMR; + S->ops->resnorm = SUNLinSolResNorm_SPTFQMR; + S->ops->resid = SUNLinSolResid_SPTFQMR; + S->ops->lastflag = SUNLinSolLastFlag_SPTFQMR; + S->ops->space = SUNLinSolSpace_SPTFQMR; + S->ops->free = SUNLinSolFree_SPTFQMR; /* Create content */ content = NULL; @@ -149,6 +152,74 @@ SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spbcgs." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "sptfqmr."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over PrecType function */ + if (strcmp(argv[i] + offset, "prec_type") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over Maxl function */ + if (strcmp(argv[i] + offset, "maxl") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + /* control over ZeroGuess function */ + if (strcmp(argv[i] + offset, "zero_guess") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to set the type of preconditioning for SPTFQMR to use */ diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index fc35e33735..08be2b4513 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -20,12 +20,14 @@ #include #include +#include #include #include #include #include "sundials_macros.h" +#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -91,14 +93,15 @@ SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, if (S == NULL) { return (NULL); } /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SuperLUMT; - S->ops->getid = SUNLinSolGetID_SuperLUMT; - S->ops->initialize = SUNLinSolInitialize_SuperLUMT; - S->ops->setup = SUNLinSolSetup_SuperLUMT; - S->ops->solve = SUNLinSolSolve_SuperLUMT; - S->ops->lastflag = SUNLinSolLastFlag_SuperLUMT; - S->ops->space = SUNLinSolSpace_SuperLUMT; - S->ops->free = SUNLinSolFree_SuperLUMT; + S->ops->gettype = SUNLinSolGetType_SuperLUMT; + S->ops->getid = SUNLinSolGetID_SuperLUMT; + S->ops->initialize = SUNLinSolInitialize_SuperLUMT; + S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SuperLUMT; + S->ops->setup = SUNLinSolSetup_SuperLUMT; + S->ops->solve = SUNLinSolSolve_SuperLUMT; + S->ops->lastflag = SUNLinSolLastFlag_SuperLUMT; + S->ops->space = SUNLinSolSpace_SuperLUMT; + S->ops->free = SUNLinSolFree_SuperLUMT; /* Create content */ content = NULL; @@ -203,6 +206,52 @@ SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, + const char* LSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(S->sunctx); + + int i, j; + SUNErrCode retval; + for (i = 1; i < argc; i++) + { + sunbooleantype arg_used = SUNFALSE; + + /* if LSid is supplied, skip command-line arguments that do not begin with LSid; + else, skip command-line arguments that do not begin with "spbcgs." */ + size_t offset; + if (strlen(LSid) > 0) + { + if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + offset = strlen(LSid) + 1; + } + else + { + static const char* prefix = "superlumt."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over PrecType function */ + if (strcmp(argv[i] + offset, "ordering") == 0) + { + i += 1; + int iarg = atoi(argv[i]); + retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); + if (retval != SUN_SUCCESS) { return retval; } + arg_used = SUNTRUE; + continue; + } + + } + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to set the ordering type for a SuperLUMT linear solver */ From 1aced244e92bbd9746deeb3e4487a90bc063ab28 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:13:12 -0500 Subject: [PATCH 044/114] Fixed unused variable warning/error --- src/sunlinsol/klu/sunlinsol_klu.c | 5 +---- src/sunlinsol/pcg/sunlinsol_pcg.c | 7 +------ src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 7 +------ src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 8 +------- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 8 +------- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 7 +------ src/sunlinsol/superlumt/sunlinsol_superlumt.c | 5 +---- 7 files changed, 7 insertions(+), 40 deletions(-) diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 837d7a725f..ea897c1dcc 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -181,12 +181,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; @@ -209,7 +207,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_KLUSetOrdering(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 3c5ef7b996..8f7bd28752 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -140,12 +140,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; @@ -168,7 +166,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_PCGSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -179,7 +176,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_PCGSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -190,7 +186,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSolSetZeroGuess_PCG(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 4eb193e49d..593b338501 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -162,12 +162,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; @@ -190,7 +188,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -201,7 +198,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -212,7 +208,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 799fe4b04f..c11e415d8b 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -150,12 +150,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spfgmr." */ size_t offset; @@ -178,7 +176,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -189,7 +186,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPFGMRSetGSType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -200,7 +196,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -211,7 +206,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 3b8bd3fd51..1434df2f09 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -147,12 +147,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spgmr." */ size_t offset; @@ -175,7 +173,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPGMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -186,7 +183,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPGMRSetGSType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -197,7 +193,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -208,7 +203,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 212b54da86..b0865cf9d2 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -162,12 +162,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; @@ -190,7 +188,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -201,7 +198,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -212,7 +208,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 08be2b4513..dc4462ad68 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -216,12 +216,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int i; SUNErrCode retval; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; @@ -244,7 +242,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, int iarg = atoi(argv[i]); retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } From 29dfdce240a794ffa399b80231e06db5e50adb4c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:16:38 -0500 Subject: [PATCH 045/114] Fixed unused variable warning/error --- .../imexgus/sunadaptcontroller_imexgus.c | 8 +------- .../mrihtol/sunadaptcontroller_mrihtol.c | 8 +------- .../soderlind/sunadaptcontroller_soderlind.c | 13 +------------ 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index db481ca83f..e595158fc7 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -108,13 +108,11 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int i, j; + int i; SUNErrCode retval; sunbooleantype write_parameters = SUNFALSE; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; @@ -143,7 +141,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, sunrealtype rarg4 = atof(argv[i]); retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -152,7 +149,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, { retval = SUNAdaptController_SetDefaults_ImExGus(C); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -163,7 +159,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, sunrealtype rarg = atof(argv[i]); retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -171,7 +166,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, if (strcmp(argv[i] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; - arg_used = SUNTRUE; continue; } } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 8d35a6c24a..48fe9d17c9 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -118,13 +118,11 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int i, j; + int i; SUNErrCode retval; sunbooleantype write_parameters = SUNFALSE; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; @@ -151,7 +149,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, sunrealtype rarg3 = atof(argv[i]); retval = SUNAdaptController_SetParams_MRIHTol(C, rarg1, rarg2, rarg3); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -160,7 +157,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, { retval = SUNAdaptController_SetDefaults_MRIHTol(C); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -171,7 +167,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, sunrealtype rarg = atof(argv[i]); retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -179,7 +174,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, if (strcmp(argv[i] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; - arg_used = SUNTRUE; continue; } } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 9fd90b80c2..d3c6083148 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -122,13 +122,11 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int i, j; + int i; SUNErrCode retval; sunbooleantype write_parameters = SUNFALSE; for (i = 1; i < argc; i++) { - sunbooleantype arg_used = SUNFALSE; - /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t SOffset, PIDOffset, PIOffset, IOffset, ExpGusOffset, ImpGusOffset; @@ -166,7 +164,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg5 = atof(argv[i]); retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, rarg4, rarg5); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -182,7 +179,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg3 = atof(argv[i]); retval = SUNAdaptController_SetParams_PID(C, rarg1, rarg2, rarg3); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -196,7 +192,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg2 = atof(argv[i]); retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -208,7 +203,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg1 = atof(argv[i]); retval = SUNAdaptController_SetParams_I(C, rarg1); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -222,7 +216,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg2 = atof(argv[i]); retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -236,7 +229,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg2 = atof(argv[i]); retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -250,7 +242,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, { retval = SUNAdaptController_SetDefaults_Soderlind(C); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -266,7 +257,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg = atof(argv[i]); retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } @@ -279,7 +269,6 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, (strcmp(argv[i] + ImpGusOffset, "write_parameters") == 0)) { write_parameters = SUNTRUE; - arg_used = SUNTRUE; continue; } } From 7fc20d1d3c898f6702ea96647861fe22b611918e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:23:21 -0500 Subject: [PATCH 046/114] formatting --- .../arkode/CXX_serial/ark_heat2D_lsrk.cpp | 8 +++- .../sunadaptcontroller_soderlind.h | 3 +- include/sundials/sundials_adaptcontroller.h | 4 +- include/sundials/sundials_linearsolver.h | 4 +- include/sunlinsol/sunlinsol_klu.h | 3 +- include/sunlinsol/sunlinsol_magmadense.h | 5 +-- include/sunlinsol/sunlinsol_pcg.h | 3 +- include/sunlinsol/sunlinsol_spbcgs.h | 3 +- include/sunlinsol/sunlinsol_spfgmr.h | 3 +- include/sunlinsol/sunlinsol_spgmr.h | 3 +- include/sunlinsol/sunlinsol_sptfqmr.h | 3 +- include/sunlinsol/sunlinsol_superlumt.h | 5 +-- src/ida/CMakeLists.txt | 9 +++- src/kinsol/CMakeLists.txt | 3 +- .../imexgus/sunadaptcontroller_imexgus.c | 7 +-- .../mrihtol/sunadaptcontroller_mrihtol.c | 4 +- .../soderlind/sunadaptcontroller_soderlind.c | 43 +++++++++++-------- src/sundials/sundials_adaptcontroller.c | 4 +- src/sundials/sundials_cli.c | 2 +- src/sunlinsol/klu/sunlinsol_klu.c | 8 ++-- .../magmadense/sunlinsol_magmadense.cpp | 7 ++- src/sunlinsol/pcg/sunlinsol_pcg.c | 12 +++--- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 12 +++--- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 14 +++--- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 14 +++--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 13 +++--- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 9 ++-- 27 files changed, 109 insertions(+), 99 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index 960b36a1ef..7a06ea6d55 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -303,8 +303,12 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", argc, argv); - if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) { return 1; } + flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", argc, + argv); + if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) + { + return 1; + } flag = ARKodeSetAdaptController(arkode_mem, C); if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index ec08f2d423..e257e0f4ec 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -56,7 +56,8 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx); SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, const char* Cid, - int argc, char* argv[]); + int argc, + char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 590db5878e..e1422507b8 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -151,8 +151,8 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C); /* Function to update internal controller parameters from the command line. */ SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); + const char* Cid, int argc, + char* argv[]); /* Function to set the controller parameters to their default values. */ SUNDIALS_EXPORT diff --git a/include/sundials/sundials_linearsolver.h b/include/sundials/sundials_linearsolver.h index e938201eb0..5165322c7e 100644 --- a/include/sundials/sundials_linearsolver.h +++ b/include/sundials/sundials_linearsolver.h @@ -118,8 +118,8 @@ struct _generic_SUNLinearSolver_Ops SUNErrCode (*setpreconditioner)(SUNLinearSolver, void*, SUNPSetupFn, SUNPSolveFn); SUNErrCode (*setscalingvectors)(SUNLinearSolver, N_Vector, N_Vector); - SUNErrCode (*setfromcommandline)(SUNLinearSolver, const char* Cid, - int argc, char* argv[]); + SUNErrCode (*setfromcommandline)(SUNLinearSolver, const char* Cid, int argc, + char* argv[]); SUNErrCode (*setzeroguess)(SUNLinearSolver, sunbooleantype); SUNErrCode (*initialize)(SUNLinearSolver); int (*setup)(SUNLinearSolver, SUNMatrix); diff --git a/include/sunlinsol/sunlinsol_klu.h b/include/sunlinsol/sunlinsol_klu.h index 9c0117a6ba..b7d4013d31 100644 --- a/include/sunlinsol/sunlinsol_klu.h +++ b/include/sunlinsol/sunlinsol_klu.h @@ -133,7 +133,8 @@ SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); + int argc, + char* argv[]); SUNDIALS_EXPORT int SUNLinSolSetup_KLU(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_KLU(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, sunrealtype tol); diff --git a/include/sunlinsol/sunlinsol_magmadense.h b/include/sunlinsol/sunlinsol_magmadense.h index f2e709c968..93dfee3fc2 100644 --- a/include/sunlinsol/sunlinsol_magmadense.h +++ b/include/sunlinsol/sunlinsol_magmadense.h @@ -65,9 +65,8 @@ SUNDIALS_EXPORT int SUNLinSol_MagmaDense_SetAsync(SUNLinearSolver S, SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_MagmaDense(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_MagmaDense(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_MagmaDense(SUNLinearSolver S); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, - const char* LSid, - int argc, char* argv[]); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense( + SUNLinearSolver S, const char* LSid, int argc, char* argv[]); SUNDIALS_EXPORT int SUNLinSolSetup_MagmaDense(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_MagmaDense(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, diff --git a/include/sunlinsol/sunlinsol_pcg.h b/include/sunlinsol/sunlinsol_pcg.h index fa18800614..a0e4f49c2d 100644 --- a/include/sunlinsol/sunlinsol_pcg.h +++ b/include/sunlinsol/sunlinsol_pcg.h @@ -88,8 +88,7 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_PCG(SUNLinearSolver S); SUNDIALS_EXPORT -SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, - const char* LSid, +SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, int argc, char* argv[]); SUNDIALS_EXPORT diff --git a/include/sunlinsol/sunlinsol_spbcgs.h b/include/sunlinsol/sunlinsol_spbcgs.h index 0bc1f1f9e1..56ab474497 100644 --- a/include/sunlinsol/sunlinsol_spbcgs.h +++ b/include/sunlinsol/sunlinsol_spbcgs.h @@ -85,7 +85,8 @@ SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPBCGS(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); + int argc, + char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPBCGS(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_spfgmr.h b/include/sunlinsol/sunlinsol_spfgmr.h index 55df42665e..d6b19b4b48 100644 --- a/include/sunlinsol/sunlinsol_spfgmr.h +++ b/include/sunlinsol/sunlinsol_spfgmr.h @@ -86,7 +86,8 @@ SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNContext sunctx); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); + int argc, + char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S, int pretype); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S, diff --git a/include/sunlinsol/sunlinsol_spgmr.h b/include/sunlinsol/sunlinsol_spgmr.h index 9f23f215ab..fc86375493 100644 --- a/include/sunlinsol/sunlinsol_spgmr.h +++ b/include/sunlinsol/sunlinsol_spgmr.h @@ -95,7 +95,8 @@ SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPGMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); + int argc, + char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPGMR(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_sptfqmr.h b/include/sunlinsol/sunlinsol_sptfqmr.h index 91ab886227..61e3515b9d 100644 --- a/include/sunlinsol/sunlinsol_sptfqmr.h +++ b/include/sunlinsol/sunlinsol_sptfqmr.h @@ -87,7 +87,8 @@ SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPTFQMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); + int argc, + char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPTFQMR(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_superlumt.h b/include/sunlinsol/sunlinsol_superlumt.h index 22d6f31622..930bfae801 100644 --- a/include/sunlinsol/sunlinsol_superlumt.h +++ b/include/sunlinsol/sunlinsol_superlumt.h @@ -95,9 +95,8 @@ typedef struct _SUNLinearSolverContent_SuperLUMT* SUNLinearSolverContent_SuperLU SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, SUNContext sunctx); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, - const char* LSid, - int argc, char* argv[]); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT( + SUNLinearSolver S, const char* LSid, int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT(SUNLinearSolver S); diff --git a/src/ida/CMakeLists.txt b/src/ida/CMakeLists.txt index 97a2290047..ddf07f9312 100644 --- a/src/ida/CMakeLists.txt +++ b/src/ida/CMakeLists.txt @@ -18,7 +18,14 @@ install(CODE "MESSAGE(\"\nInstall IDA\n\")") # Add variable ida_SOURCES with the sources for the IDA library -set(ida_SOURCES ida.c ida_bbdpre.c ida_cli.c ida_ic.c ida_io.c ida_ls.c ida_nls.c) +set(ida_SOURCES + ida.c + ida_bbdpre.c + ida_cli.c + ida_ic.c + ida_io.c + ida_ls.c + ida_nls.c) # Add variable ida_HEADERS with the exported IDA header files set(ida_HEADERS ida.h ida_bbdpre.h ida_ls.h) diff --git a/src/kinsol/CMakeLists.txt b/src/kinsol/CMakeLists.txt index 5b52ae1dc6..27554b2f3e 100644 --- a/src/kinsol/CMakeLists.txt +++ b/src/kinsol/CMakeLists.txt @@ -18,7 +18,8 @@ install(CODE "MESSAGE(\"\nInstall KINSOL\n\")") # Add variable kinsol_SOURCES with the sources for the KINSOL library -set(kinsol_SOURCES kinsol.c kinsol_bbdpre.c kinsol_cli.c kinsol_io.c kinsol_ls.c) +set(kinsol_SOURCES kinsol.c kinsol_bbdpre.c kinsol_cli.c kinsol_io.c + kinsol_ls.c) # Add variable kinsol_HEADERS with the exported KINSOL header files set(kinsol_HEADERS kinsol.h kinsol_bbdpre.h kinsol_ls.h) diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index e595158fc7..26b9d7b2a1 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -24,8 +24,8 @@ #include #include -#include "sundials_macros.h" #include "sundials_cli.h" +#include "sundials_macros.h" /* --------------- * Macro accessors @@ -139,7 +139,8 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, sunrealtype rarg3 = atof(argv[i]); i += 1; sunrealtype rarg4 = atof(argv[i]); - retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); + retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, + rarg4); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -157,7 +158,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, { i += 1; sunrealtype rarg = atof(argv[i]); - retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); + retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 48fe9d17c9..3b26199c6d 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -24,8 +24,8 @@ #include "sundials/priv/sundials_errors_impl.h" #include "sundials/sundials_errors.h" -#include "sundials_macros.h" #include "sundials_cli.h" +#include "sundials_macros.h" /* ------------------ * Default parameters @@ -165,7 +165,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, { i += 1; sunrealtype rarg = atof(argv[i]); - retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); + retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index d3c6083148..02c0136b4e 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -24,8 +24,8 @@ #include #include -#include "sundials_macros.h" #include "sundials_cli.h" +#include "sundials_macros.h" /* --------------- * Macro accessors @@ -130,20 +130,26 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t SOffset, PIDOffset, PIOffset, IOffset, ExpGusOffset, ImpGusOffset; - const char* SPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_soderlind."; + const char* SPrefix = (strlen(Cid) > 0) ? Cid + : "sunadaptcontroller_soderlind."; const char* PIDPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pid."; - const char* PIPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pi."; - const char* IPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_i."; - const char* ExpGusPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_expgus."; - const char* ImpGusPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_impgus."; + const char* PIPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pi."; + const char* IPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_i."; + const char* ExpGusPrefix = (strlen(Cid) > 0) ? Cid + : "sunadaptcontroller_expgus."; + const char* ImpGusPrefix = (strlen(Cid) > 0) ? Cid + : "sunadaptcontroller_impgus."; if (strlen(Cid) > 0) { - SOffset = PIDOffset = PIOffset = IOffset = ExpGusOffset = ImpGusOffset = strlen(Cid) + 1; - } else { - SOffset = strlen(SPrefix); - PIDOffset = strlen(PIDPrefix); - PIOffset = strlen(PIPrefix); - IOffset = strlen(IPrefix); + SOffset = PIDOffset = PIOffset = IOffset = ExpGusOffset = ImpGusOffset = + strlen(Cid) + 1; + } + else + { + SOffset = strlen(SPrefix); + PIDOffset = strlen(PIDPrefix); + PIOffset = strlen(PIPrefix); + IOffset = strlen(IPrefix); ExpGusOffset = strlen(ExpGusPrefix); ImpGusOffset = strlen(ImpGusPrefix); } @@ -162,7 +168,8 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg4 = atof(argv[i]); i += 1; sunrealtype rarg5 = atof(argv[i]); - retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, rarg4, rarg5); + retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, + rarg4, rarg5); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -190,7 +197,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg1 = atof(argv[i]); i += 1; sunrealtype rarg2 = atof(argv[i]); - retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); + retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -201,7 +208,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, { i += 1; sunrealtype rarg1 = atof(argv[i]); - retval = SUNAdaptController_SetParams_I(C, rarg1); + retval = SUNAdaptController_SetParams_I(C, rarg1); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -214,7 +221,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg1 = atof(argv[i]); i += 1; sunrealtype rarg2 = atof(argv[i]); - retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); + retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -227,7 +234,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg1 = atof(argv[i]); i += 1; sunrealtype rarg2 = atof(argv[i]); - retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); + retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -255,7 +262,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, { i += 1; sunrealtype rarg = atof(argv[i]); - retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); + retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; } diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index aaf0ed1032..1c3272f8b0 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -170,8 +170,8 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) } SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) + const char* Cid, int argc, + char* argv[]) { SUNErrCode ier = SUN_SUCCESS; if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index 6c7d207506..ed5c5a9913 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -125,7 +125,7 @@ int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], int iarg = atoi(argv[*i]); (*i) += 1; long int large = atol(argv[*i]); - int retval = fname(mem, iarg, large); + int retval = fname(mem, iarg, large); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index ea897c1dcc..56542e2cd7 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -25,8 +25,8 @@ #include #include -#include "sundials_macros.h" #include "sundials_cli.h" +#include "sundials_macros.h" #define ONE SUN_RCONST(1.0) #define TWOTHIRDS SUN_RCONST(0.666666666666666666666666666666667) @@ -175,8 +175,7 @@ SUNErrCode SUNLinSol_KLUReInit(SUNLinearSolver S, SUNMatrix A, sunindextype nnz, * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, - const char* LSid, +SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -205,11 +204,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_KLUSetOrdering(S, iarg); + retval = SUNLinSol_KLUSetOrdering(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index dac98f564d..b14774a022 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -235,8 +235,8 @@ SUNErrCode SUNLinSolInitialize_MagmaDense(SUNLinearSolver S) } SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, - const char* LSid, - int argc, char* argv[]) + const char* LSid, int argc, + char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -266,12 +266,11 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); + retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); if (retval != SUN_SUCCESS) { return retval; } arg_used = SUNTRUE; continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 8f7bd28752..153bd27915 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -24,9 +24,9 @@ #include #include +#include "sundials_cli.h" #include "sundials_logger_impl.h" #include "sundials_macros.h" -#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -134,8 +134,7 @@ SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl, SUNContext sunc * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, - const char* LSid, +SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -164,7 +163,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_PCGSetPrecType(S, iarg); + retval = SUNLinSol_PCGSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -174,7 +173,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_PCGSetMaxl(S, iarg); + retval = SUNLinSol_PCGSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -184,11 +183,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSolSetZeroGuess_PCG(S, iarg); + retval = SUNLinSolSetZeroGuess_PCG(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 593b338501..4c1c6b48c8 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -26,9 +26,9 @@ #include #include "sundials/sundials_errors.h" +#include "sundials_cli.h" #include "sundials_logger_impl.h" #include "sundials_macros.h" -#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -156,8 +156,7 @@ SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, - const char* LSid, +SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -186,7 +185,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); + retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -196,7 +195,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); + retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -206,11 +205,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); + retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index c11e415d8b..e56ce0cf69 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -25,9 +25,9 @@ #include #include +#include "sundials_cli.h" #include "sundials_logger_impl.h" #include "sundials_macros.h" -#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -144,8 +144,7 @@ SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, - const char* LSid, +SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -174,7 +173,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); + retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -184,7 +183,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPFGMRSetGSType(S, iarg); + retval = SUNLinSol_SPFGMRSetGSType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -194,7 +193,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); + retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -204,11 +203,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); + retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 1434df2f09..5290d53cc0 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -25,9 +25,9 @@ #include #include +#include "sundials_cli.h" #include "sundials_logger_impl.h" #include "sundials_macros.h" -#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -141,8 +141,7 @@ SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, - const char* LSid, +SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -171,7 +170,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPGMRSetPrecType(S, iarg); + retval = SUNLinSol_SPGMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -181,7 +180,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPGMRSetGSType(S, iarg); + retval = SUNLinSol_SPGMRSetGSType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -191,7 +190,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); + retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -201,11 +200,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); + retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index b0865cf9d2..f3b4840a49 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -24,9 +24,9 @@ #include #include +#include "sundials_cli.h" #include "sundials_logger_impl.h" #include "sundials_macros.h" -#include "sundials_cli.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -157,8 +157,8 @@ SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, */ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, - const char* LSid, - int argc, char* argv[]) + const char* LSid, int argc, + char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -186,7 +186,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); + retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -196,7 +196,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); + retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } @@ -206,11 +206,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); + retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index dc4462ad68..8e42c77091 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -26,8 +26,8 @@ #include #include -#include "sundials_macros.h" #include "sundials_cli.h" +#include "sundials_macros.h" #define ZERO SUN_RCONST(0.0) #define ONE SUN_RCONST(1.0) @@ -211,8 +211,8 @@ SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, */ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, - const char* LSid, - int argc, char* argv[]) + const char* LSid, int argc, + char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -240,11 +240,10 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, { i += 1; int iarg = atoi(argv[i]); - retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); + retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } - } return SUN_SUCCESS; } From 63466df866992ee926ae922c1dc9291a7cbd424a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:30:28 -0500 Subject: [PATCH 047/114] Minor updates to hopeflly fix build on Windows/MSVC --- examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index 7a06ea6d55..6cd27a0b18 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -59,6 +59,7 @@ #include "arkode/arkode_lsrkstep.h" // access to LSRKStep #include "nvector/nvector_serial.h" // access to the serial N_Vector +#include "sundials/sundials_adaptcontroller.h" #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" @@ -303,8 +304,8 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", argc, - argv); + flag = (int) SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", + argc, argv); if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) { return 1; From 16dfb9696b60ada8dfb264c3401f10b2b954576a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:34:30 -0500 Subject: [PATCH 048/114] Fixed missing include --- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 8e42c77091..cfe0a82c02 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -23,6 +23,7 @@ #include #include +#include #include #include From e35b1bf8773ced509f483fa8b6d90daa2ec94b93 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:36:52 -0500 Subject: [PATCH 049/114] Fixed missing include --- src/sunlinsol/klu/sunlinsol_klu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 56542e2cd7..55e4bbd564 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -22,6 +22,7 @@ #include #include +#include #include #include From 575a86f0ee113489251875ddb253c50ab9d2f28e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:47:30 -0500 Subject: [PATCH 050/114] formatting --- examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp | 6 +++--- src/sunlinsol/klu/sunlinsol_klu.c | 2 +- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index 6cd27a0b18..f100458e85 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -59,9 +59,9 @@ #include "arkode/arkode_lsrkstep.h" // access to LSRKStep #include "nvector/nvector_serial.h" // access to the serial N_Vector -#include "sundials/sundials_adaptcontroller.h" #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" +#include "sundials/sundials_adaptcontroller.h" // Macros for problem constants #define PI SUN_RCONST(3.141592653589793238462643383279502884197169) @@ -304,8 +304,8 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = (int) SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", - argc, argv); + flag = (int)SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", + argc, argv); if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) { return 1; diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 55e4bbd564..e5808ec050 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -21,8 +21,8 @@ #include #include -#include #include +#include #include #include diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index cfe0a82c02..26930dc956 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -22,8 +22,8 @@ #include #include -#include #include +#include #include #include From 4ab74ca7b1560a2414b05b8c72418fc93dc45d31 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:57:34 -0500 Subject: [PATCH 051/114] Added missing SUNDIALS_EXPORT --- include/sundials/sundials_adaptcontroller.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index e1422507b8..796fa2d317 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -150,6 +150,7 @@ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Reset(SUNAdaptController C); /* Function to update internal controller parameters from the command line. */ +SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, const char* Cid, int argc, char* argv[]); From e4c57e0ada4b48a0ca68760b15e3ce9a19ccdf17 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 21:58:38 -0500 Subject: [PATCH 052/114] Removed explicit cast that I introduced when trying to resolve Windows build issue --- examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index f100458e85..6f4993b59b 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -304,8 +304,8 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = (int)SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", - argc, argv); + flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", + argc, argv); if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) { return 1; From bb35002d55fae5f5c0a6459458551b2a533afe40 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sat, 15 Mar 2025 22:04:31 -0500 Subject: [PATCH 053/114] formatting --- examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp index 6f4993b59b..4ad89f1747 100644 --- a/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp @@ -304,8 +304,8 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", - argc, argv); + flag = SUNAdaptController_SetFromCommandLine(C, "sunadaptcontroller", argc, + argv); if (check_flag(&flag, "SUNAdaptControllerSetFromCommandLine", 1)) { return 1; From ef344c674e2ab1c38d24d735fd203189c926b968 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Sun, 23 Mar 2025 07:24:42 -0500 Subject: [PATCH 054/114] Added documentation for command-line control --- .../source/Usage/ARKStep/User_callable.rst | 11 + .../source/Usage/ERKStep/User_callable.rst | 3 + .../source/Usage/LSRKStep/User_callable.rst | 66 ++++-- .../source/Usage/MRIStep/User_callable.rst | 5 + .../source/Usage/SPRKStep/User_callable.rst | 10 + .../guide/source/Usage/User_callable.rst | 192 +++++++++++++++++- doc/cvode/guide/source/Usage/index.rst | 173 +++++++++++++++- doc/cvodes/guide/source/Usage/ADJ.rst | 29 ++- doc/cvodes/guide/source/Usage/FSA.rst | 12 ++ doc/cvodes/guide/source/Usage/SIM.rst | 180 +++++++++++++++- doc/ida/guide/source/Usage/index.rst | 137 ++++++++++++- doc/idas/guide/source/Usage/ADJ.rst | 38 +++- doc/idas/guide/source/Usage/FSA.rst | 35 +++- doc/idas/guide/source/Usage/SIM.rst | 146 ++++++++++++- doc/kinsol/guide/source/Usage/index.rst | 95 ++++++++- src/arkode/arkode_arkstep_io.c | 9 +- src/arkode/arkode_cli.c | 106 +++++----- src/arkode/arkode_lsrkstep_io.c | 14 +- src/cvode/cvode_cli.c | 94 +++++---- src/cvodes/cvodes_cli.c | 2 +- src/ida/ida_cli.c | 74 ++++--- src/idas/idas_cli.c | 2 +- src/kinsol/kinsol_cli.c | 16 +- 23 files changed, 1245 insertions(+), 204 deletions(-) diff --git a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst index 08f30b9ff9..e8feb1b4ee 100644 --- a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst @@ -1255,6 +1255,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int pointers *fe* or *fi* passed to :c:func:`ARKStepCreate` are ``NULL``, but may be set directly by the user if desired. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.set_imex". .. c:function:: int ARKStepSetExplicit(void* arkode_mem) @@ -1279,6 +1281,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int f(t,y)`, then we recommend that the ERKStep time-stepper module be used instead. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.set_explicit". .. c:function:: int ARKStepSetImplicit(void* arkode_mem) @@ -1298,6 +1302,9 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int passed to :c:func:`ARKStepCreate` is ``NULL``, but may be set directly by the user if desired. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.set_implicit". + .. c:function:: int ARKStepSetTables(void* arkode_mem, int q, int p, ARKodeButcherTable Bi, ARKodeButcherTable Be) @@ -1437,6 +1444,10 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int In all cases, error-checking is performed to ensure that the tables exist. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.table_names". + + **Warning:** This should not be used with :c:func:`ARKodeSetOrder`. diff --git a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst index d5f7659863..bfcc710aec 100644 --- a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst @@ -934,7 +934,10 @@ Optional inputs for IVP method selection **Warning:** This should not be used with :c:func:`ARKodeSetOrder`. + .. note:: + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.table_name". .. _ARKODE.Usage.ERKStep.ERKStepAdaptivityInput: diff --git a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst index ac150cd8d5..5a143a5d5a 100644 --- a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst @@ -156,6 +156,10 @@ Allowable Method Families * *ARK_SUCCESS* if successful * *ARK_ILL_INPUT* if an argument had an illegal value (e.g. typo in the method name). + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.sts_method". .. c:function:: int LSRKStepSetSSPMethodByName(void* arkode_mem, const char* emethod); @@ -171,6 +175,10 @@ Allowable Method Families * *ARK_SUCCESS* if successful * *ARK_ILL_INPUT* if an argument had an illegal value (e.g. typo in the method name). + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.ssp_method". .. c:function:: int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); @@ -187,7 +195,9 @@ Allowable Method Families * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. * *ARK_ILL_INPUT* ``dom_eig = NULL`` and LSRKStep does not currently estimate this internally. - .. note:: This function is currently required when either the RKC or RKL methods are used. + .. note:: + + This function is currently required when either the RKC or RKL methods are used. .. c:function:: int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); @@ -203,9 +213,16 @@ Allowable Method Families * *ARK_SUCCESS* if successful * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. -.. note:: If LSRKStepSetDomEigFrequency routine is not called, then the default ``nsteps`` is set to :math:`25` as recommended in :cite:p:`VSH:04`. - Calling this function with ``nsteps < 0`` resets the default value while ``nsteps = 0`` refers to constant dominant eigenvalue. + .. note:: + + If LSRKStepSetDomEigFrequency routine is not called, then the default ``nsteps`` + is set to :math:`25` as recommended in :cite:p:`VSH:04`. + + Calling this function with ``nsteps < 0`` resets the default value while + ``nsteps = 0`` refers to constant dominant eigenvalue. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.dom_eig_frequency". .. c:function:: int LSRKStepSetMaxNumStages(void* arkode_mem, int stage_max_limit); @@ -220,10 +237,18 @@ Allowable Method Families * *ARK_SUCCESS* if successful * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. -.. note:: If LSRKStepSetMaxNumStages routine is not called, then the default ``stage_max_limit`` is - set to :math:`200`. Calling this function with ``stage_max_limit < 2`` resets the default value. - This limit should be chosen with consideration of the following proportionality: :math:`s^2 \sim - h\lambda`, - where :math:`s` is the number of stages used, :math:`h` is the current step size and :math:`\lambda` is the dominant eigenvalue. + .. note:: + + If LSRKStepSetMaxNumStages routine is not called, then the default ``stage_max_limit`` + is set to :math:`200`. Calling this function with ``stage_max_limit < 2`` resets the + default value. + + This limit should be chosen with consideration of the following proportionality: + :math:`s^2 \sim - h\lambda`, where :math:`s` is the number of stages used, :math:`h` + is the current step size and :math:`\lambda` is the dominant eigenvalue. + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_num_stages". .. c:function:: int LSRKStepSetDomEigSafetyFactor(void* arkode_mem, sunrealtype dom_eig_safety); @@ -241,8 +266,14 @@ Allowable Method Families * *ARK_SUCCESS* if successful * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. -.. note:: If LSRKStepSetDomEigSafetyFactor routine is not called, then the default ``dom_eig_safety`` is - set to :math:`1.01`. Calling this function with ``dom_eig_safety < 1`` resets the default value. + .. note:: + + If LSRKStepSetDomEigSafetyFactor routine is not called, then the default + ``dom_eig_safety`` is set to :math:`1.01`. Calling this function with + ``dom_eig_safety < 1`` resets the default value. + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.dom_eig_safety_factor". .. c:function:: int LSRKStepSetNumSSPStages(void* arkode_mem, int num_of_stages); @@ -262,12 +293,17 @@ Allowable Method Families * *ARKLS_MEM_NULL* if ``arkode_mem`` was ``NULL``. * *ARK_ILL_INPUT* if an argument had an illegal value (e.g. SSP method is not declared) -.. note:: If LSRKStepSetNumSSPStages routine is not called, then the default ``num_of_stages`` is - set. Calling this function with ``num_of_stages <= 0`` resets the default values: + .. note:: + + If LSRKStepSetNumSSPStages routine is not called, then the default ``num_of_stages`` + is set. Calling this function with ``num_of_stages <= 0`` resets the default values: + + * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_S_2` + * ``num_of_stages = 9`` for :c:enumerator:`ARKODE_LSRK_SSP_S_3` + * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_10_4` - * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_S_2` - * ``num_of_stages = 9`` for :c:enumerator:`ARKODE_LSRK_SSP_S_3` - * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_10_4` + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.num_ssp_stages". .. _ARKODE.Usage.LSRKStep.OptionalOutputs: @@ -359,6 +395,7 @@ dependent variable vector. * *ARK_ILL_INPUT* if an argument had an illegal value. .. note:: + All previously set options are retained but may be updated by calling the appropriate "Set" functions. @@ -386,6 +423,7 @@ dependent variable vector. * *ARK_ILL_INPUT* if an argument had an illegal value. .. note:: + All previously set options are retained but may be updated by calling the appropriate "Set" functions. diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index 8514af3f71..2b12e86ace 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -800,6 +800,11 @@ Optional inputs for IVP method selection For a description of the :c:type:`MRIStepCoupling` type and related functions for creating Butcher tables see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.coupling_table", where *C* + is itself constructed by passing the command-line option to + :c:func:`MRIStepCoupling_LoadTableByName`. + .. warning:: This should not be used with :c:func:`ARKodeSetOrder`. diff --git a/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst index 13db1851e1..b239e5672e 100644 --- a/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst @@ -479,6 +479,11 @@ Optional inputs for IVP method selection :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument had an illegal value + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.method_name". + .. warning:: This should not be used with :c:func:`ARKodeSetOrder`. @@ -501,6 +506,11 @@ Optional inputs for IVP method selection :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument had an illegal value + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.use_compensated_sums". + .. _ARKODE.Usage.SPRKStep.SPRKStepRootfindingInput: diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index a5798450e0..da650f498c 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -133,6 +133,11 @@ Alternatively, the user may supply a custom function to supply the :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. :retval ARK_ILL_INPUT: an argument had an illegal value (e.g. a negative tolerance). + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.scalar_tolerances". + .. versionadded:: 6.1.0 @@ -882,6 +887,7 @@ Optional inputs for ARKODE ================================================ ======================================= ======================= Optional input Function name Default ================================================ ======================================= ======================= +Set ARKODE options from the command line :c:func:`ARKodeSetFromCommandLine` internal Return ARKODE parameters to their defaults :c:func:`ARKodeSetDefaults` internal Set integrator method order :c:func:`ARKodeSetOrder` 4 Set dense output interpolation type (SPRKStep) :c:func:`ARKodeSetInterpolantType` ``ARK_INTERP_LAGRANGE`` @@ -906,6 +912,39 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr +.. c:function:: int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, char* argv[]) + + Passes command-line arguments to ARKODE to set options. + + :param arkode_mem: pointer to the ARKODE memory block. + :param arkid: String to use as prefix for ARKODE command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval other: error return value from relevant ARKODE "set" routine. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. These + are left unchanged by :c:func:`ARKodeSetFromCommandLine`. + + If the *arkid* argument is ``NULL`` then ``arkode.`` will be used for all ARKODE command-line + options, e.g., to set the integrator order of accuracy the default command-line option would be "arkode.order". + When using a combination of ARKODE integrators (e.g., via MRIStep, SplittingStep or + ForcingStep), it is recommended that users call :c:func:`ARKodeSetFromCommandLine` for each + ARKODE integrator using distinct *arkid* inputs, so that each ARKODE integrator can be controlled + separately. + + ARKODE options set via command-line arguments to :c:func:`ARKodeSetFromCommandLine` will overwrite + any previously-set values. + + The supported command-line options are documented within each ARKODE "set" routine. + + .. versionadded:: x.y.z + + .. c:function:: int ARKodeSetDefaults(void* arkode_mem) Resets all optional input parameters to ARKODE's original @@ -952,6 +991,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr ARKODE memory block, it cannot be changed after the first call to :c:func:`ARKodeEvolve`, unless ``*StepReInit`` is called. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.order". + .. versionadded:: 6.1.0 @@ -999,6 +1041,11 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr :retval ARK_ILL_INPUT: the *itype* argument is not recognized or the interpolation module has already been initialized. + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.interpolant_type". + .. versionchanged:: 6.1.0 This function replaces stepper specific versions in ARKStep, ERKStep, @@ -1046,6 +1093,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr obtained by the integrator are returned at the ends of the time interval. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.interpolant_degree". + .. versionadded:: 6.1.0 @@ -1102,6 +1152,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr routines will provide no useful information to the solver, and at worst they may interfere with the desired fixed step size. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.fixed_step". + .. versionadded:: 6.1.0 @@ -1114,7 +1167,7 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr selects forward integration, a negative value selects backward integration, and zero leaves the current direction unchanged. - + :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. @@ -1131,6 +1184,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr estimated at the next call to :c:func:`ARKodeEvolve` or can be specified with :c:func:`ARKodeSetInitStep`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.step_direction". + .. versionadded:: 6.2.0 @@ -1159,6 +1215,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr This routine will also reset the step size and error history. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.init_step". + .. versionadded:: 6.1.0 @@ -1187,6 +1246,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr A negative value indicates that no warning messages should be issued. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_hnil_warns". + .. versionadded:: 6.1.0 @@ -1211,6 +1273,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr Passing *mxsteps* < 0 disables the test (not recommended). + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_num_steps". + .. versionadded:: 6.1.0 @@ -1233,6 +1298,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_step". + .. versionadded:: 6.1.0 @@ -1255,6 +1323,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr Pass *hmin* :math:`\le 0.0` to set the default value of 0. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.min_step". + .. versionadded:: 6.1.0 @@ -1282,6 +1353,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr :c:func:`ARKodeReset` will remain active but can be disabled by calling :c:func:`ARKodeClearStopTime`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.stop_time". + .. versionadded:: 6.1.0 @@ -1297,6 +1371,11 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.interpolate_stop_time". + .. versionadded:: 6.1.0 @@ -1314,6 +1393,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr The stop time can be re-enabled though a new call to :c:func:`ARKodeSetStopTime`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.clear_stop_time". + .. versionadded:: 6.1.0 @@ -1339,6 +1421,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr this function must be made *before* any calls to :c:func:`ARKodeSetLinearSolver` and/or :c:func:`ARKodeSetMassLinearSolver`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.linear". + .. versionadded:: 6.1.0 @@ -1363,6 +1448,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr The default value is 7; set *maxnef* :math:`\le 0` to specify this default. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_err_test_fails". + .. versionadded:: 6.1.0 @@ -1434,6 +1522,9 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr Passing *maxfails* <= 0 results in ARKODE using the default value (10). + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_num_constr_fails". + .. versionadded:: 6.1.0 @@ -1522,6 +1613,9 @@ Reset accumulated error :c:func:`ARKodeReset This should be called prior to calling :c:func:`ARKodeEvolve`, and can only be reset following a call to ``*StepReInit``. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.adaptivity_adjustment". + .. versionadded:: 6.1.0 @@ -1545,6 +1639,9 @@ Reset accumulated error :c:func:`ARKodeReset Any non-positive parameter will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.cfl_fraction". + .. versionadded:: 6.1.0 @@ -1573,6 +1670,9 @@ Reset accumulated error :c:func:`ARKodeReset :c:func:`ARKodeSetAdaptController` will be called, then this routine must be called *second*. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.error_bias". + .. versionadded:: 6.1.0 @@ -1596,6 +1696,9 @@ Reset accumulated error :c:func:`ARKodeReset Any interval *not* containing 1.0 will imply a reset to the default values. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.fixed_step_bounds". + .. versionadded:: 6.1.0 @@ -1621,6 +1724,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_cfail_growth". + .. versionadded:: 6.1.0 @@ -1644,6 +1750,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_efail_growth". + .. versionadded:: 6.1.0 @@ -1668,6 +1777,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 1.0` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_first_growth". + .. versionadded:: 6.1.0 @@ -1692,6 +1804,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 1.0` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_growth". + .. versionadded:: 6.1.0 @@ -1718,6 +1833,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value outside the interval :math:`(0,1)` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.min_reduction". + .. versionadded:: 6.1.0 @@ -1742,6 +1860,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 0` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.safety_factor". + .. versionadded:: 6.1.0 @@ -1766,6 +1887,9 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 0` will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.small_num_efails". + .. versionadded:: 6.1.0 @@ -1850,6 +1974,10 @@ tolerance. A non-default error accumulation strategy can be disabled by calling :c:func:`ARKodeSetAccumulatedErrorType` with the argument ``ARK_ACCUMERROR_NONE``. + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.accum_error_type". :param arkode_mem: pointer to the ARKODE memory block. :param accum_type: accumulation strategy. @@ -1874,6 +2002,11 @@ tolerance. :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported by the current time-stepping module. + .. note:: + + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.reset_accumulated_error". + .. versionadded:: 6.2.0 @@ -1967,6 +2100,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS :c:func:`ARKodeSetDeltaGammaMax` to reset the step size ratio threshold to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.nonlinear". + .. versionadded:: 6.1.0 @@ -2019,6 +2155,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS evaluation but instead evaluate the necessary quantities within the preconditioner setup function using the input values. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.autonomous". + .. versionadded:: 6.1.0 @@ -2054,6 +2193,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS The default value is 0. If *method* is set to an undefined value, this default predictor will be used. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.predictor_method". + .. versionadded:: 6.1.0 @@ -2132,6 +2274,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS The default value is 3; set *maxcor* :math:`\le 0` to specify this default. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_nonlin_iters". + .. versionadded:: 6.1.0 @@ -2156,6 +2301,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS The default value is 0.1; set *nlscoef* :math:`\le 0` to specify this default. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.nonlin_conv_coef". + .. versionadded:: 6.1.0 @@ -2178,6 +2326,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS Any non-positive parameter will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.nonlin_crdown". + .. versionadded:: 6.1.0 @@ -2202,6 +2353,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS Any non-positive parameter will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.nonlin_rdiv". + .. versionadded:: 6.1.0 @@ -2234,6 +2388,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS convergence failure still occurs, the time step size is reduced by the factor *etacf* (set within :c:func:`ARKodeSetMaxCFailGrowth`). + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.max_conv_fails". + .. versionadded:: 6.1.0 @@ -2257,6 +2414,9 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS This is only compatible with time-stepping modules that support implicit algebraic solvers. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.deduce_implicit_rhs". + .. versionadded:: 6.1.0 @@ -2364,6 +2524,9 @@ is recomputed using the current :math:`\gamma` value. Any non-positive parameter will imply a reset to the default value. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.delta_gamma_max". + .. versionadded:: 6.1.0 .. index:: @@ -2392,6 +2555,9 @@ is recomputed using the current :math:`\gamma` value. step. If **msbp** is 0, the default value of 20 will be used. A negative value forces a linear solver step at each implicit stage. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.lsetup_frequency". + .. versionadded:: 6.1.0 @@ -2434,6 +2600,9 @@ is recomputed using the current :math:`\gamma` value. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKodeSetLinearSolver`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.jac_eval_frequency". + .. versionadded:: 6.1.0 @@ -2621,6 +2790,9 @@ data in the program. The user data pointer may be specified through Linear solution scaling is enabled by default when a matrix-based linear solver is attached. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.linear_solution_scaling". + .. versionadded:: 6.1.0 @@ -2958,6 +3130,9 @@ the user through the :c:func:`ARKodeSetEpsLin` function. interface has been initialized through a call to :c:func:`ARKodeSetLinearSolver`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.eps_lin". + .. versionadded:: 6.1.0 @@ -2988,6 +3163,9 @@ the user through the :c:func:`ARKodeSetEpsLin` function. Passing a value *eplifac* :math:`\le 0` indicates to use the default value of 0.05. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.mass_eps_lin". + .. versionadded:: 6.1.0 @@ -3036,6 +3214,9 @@ allow for additional user control over these conversion factors. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKodeSetLinearSolver`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.ls_norm_factor". + .. versionadded:: 6.1.0 @@ -3069,6 +3250,9 @@ allow for additional user control over these conversion factors. This function must be called *after* the ARKLS mass matrix solver interface has been initialized through a call to :c:func:`ARKodeSetMassLinearSolver`. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.mass_ls_norm_factor". + .. versionadded:: 6.1.0 @@ -3139,6 +3323,9 @@ Disable inactive root warnings :c:func:`ARKodeSetNoInactiveRootWarn` e first step), ARKODE will issue a warning which can be disabled with this optional input function. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.no_inactive_root_warn". + .. versionadded:: 6.1.0 @@ -4701,6 +4888,9 @@ Output all ARKODE solver parameters :c:func:`ARKodeWriteParameters` for this pointer, since parameters for all processes would be identical. + This routine will be called by :c:func:`ARKodeSetFromCommandLine` + when using the command-line option "arkid.write_parameters". + .. versionadded:: 6.1.0 diff --git a/doc/cvode/guide/source/Usage/index.rst b/doc/cvode/guide/source/Usage/index.rst index 54162e53f0..cf2ccbde84 100644 --- a/doc/cvode/guide/source/Usage/index.rst +++ b/doc/cvode/guide/source/Usage/index.rst @@ -386,6 +386,10 @@ the call to :c:func:`CVodeInit` * ``CV_NO_MALLOC`` -- The allocation function returned ``NULL`` * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.scalar_tolerances". + .. c:function:: int CVodeSVtolerances(void* cvode_mem, sunrealtype reltol, N_Vector abstol) The function ``CVodeSVtolerances`` specifies scalar relative tolerance and vector absolute tolerances. @@ -825,6 +829,9 @@ Main solver optional input functions +-------------------------------+---------------------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +===============================+=============================================+================+ + | Set CVODE optional inputs | :c:func:`CVodeSetFromCommandLine` | | + | from the command line | | | + +-------------------------------+---------------------------------------------+----------------+ | User data | :c:func:`CVodeSetUserData` | ``NULL`` | +-------------------------------+---------------------------------------------+----------------+ | Maximum order for BDF method | :c:func:`CVodeSetMaxOrd` | 5 | @@ -865,6 +872,35 @@ Main solver optional input functions +-------------------------------+---------------------------------------------+----------------+ +.. c:function:: int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, char* argv[]) + + Passes command-line arguments to CVODE to set options. + + :param cvode_mem: pointer to the CVODE memory block. + :param cvid: String to use as prefix for CVODE command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :retval CV_SUCCESS: the function exited successfully. + :retval CV_MEM_NULL: ``cvode_mem`` was ``NULL``. + :retval other: error return value from relevant CVODE "set" routine. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + These are left unchanged by :c:func:`CVodeSetFromCommandLine`. + + If the *cvid* argument is ``NULL`` then ``cvode.`` will be used for all CVODE command-line + options, e.g., to set the maximum order of accuracy the default command-line option would + be "cvode.max_order". + + CVODE options set via command-line arguments to :c:func:`CVodeSetFromCommandLine` will + overwrite any previously-set values. + + The supported command-line options are documented within each CVODE "set" routine. + + .. versionadded:: x.y.z + .. c:function:: int CVodeSetUserData(void* cvode_mem, void * user_data) The function ``CVodeSetUserData`` specifies the user data block ``user_data`` and attaches it to the main CVODE memory block. @@ -918,6 +954,9 @@ Main solver optional input functions **Notes:** The monitor function that will be called can be set with ``CVodeSetMonitorFn``. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.monitor_frequency". + .. warning:: Modifying the solution in this function will result in undefined behavior. This function is only intended to be used for monitoring the integrator. SUNDIALS must be built with the CMake option ``SUNDIALS_BUILD_WITH_MONITORING``, to utilize this function. See :numref:`Installation` for more information. @@ -940,6 +979,9 @@ Main solver optional input functions An input value greater than the default will result in the default value. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_order". + .. c:function:: int CVodeSetMaxNumSteps(void* cvode_mem, long int mxsteps) The function ``CVodeSetMaxNumSteps`` specifies the maximum number of steps to be taken by the solver in its attempt to reach the next output time. @@ -957,6 +999,9 @@ Main solver optional input functions Passing ``mxsteps`` < 0 disables the test (not recommended). + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_num_steps". + .. c:function:: int CVodeSetMaxHnilWarns(void* cvode_mem, int mxhnil) The function ``CVodeSetMaxHnilWarns`` specifies the maximum number of messages issued by the solver warning that :math:`t+h=t` on the next internal step. @@ -972,6 +1017,9 @@ Main solver optional input functions **Notes:** The default value is 10. A negative value for ``mxhnil`` indicates that no warning messages should be issued. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_hnil_warns". + .. c:function:: int CVodeSetStabLimDet(void* cvode_mem, sunbooleantype stldet) The function ``CVodeSetStabLimDet`` indicates if the BDF stability limit detection algorithm should be used. See :numref:`CVODE.Mathematics.stablimit` for further details. @@ -988,6 +1036,9 @@ Main solver optional input functions **Notes:** The default value is ``SUNFALSE``. If ``stldet = SUNTRUE`` when BDF is used and the method order is greater than or equal to 3, then an internal function, ``CVsldet``, is called to detect a possible stability limit. If such a limit is detected, then the order is reduced. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.stab_lim_det". + .. c:function:: int CVodeSetInitStep(void* cvode_mem, sunrealtype hin) The function ``CVodeSetInitStep`` specifies the initial step size. @@ -1003,6 +1054,9 @@ Main solver optional input functions **Notes:** By default, CVODE estimates the initial step size to be the solution :math:`h` of the equation :math:`0.5 h^2 \ddot{y} = 1`, where :math:`\ddot{y}` is an estimated second derivative of the solution at :math:`t_0`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.init_step". + .. c:function:: int CVodeSetMinStep(void* cvode_mem, sunrealtype hmin) The function ``CVodeSetMinStep`` specifies a lower bound on the magnitude of the step size. @@ -1019,6 +1073,9 @@ Main solver optional input functions **Notes:** The default value is 0.0. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.min_step". + .. c:function:: int CVodeSetMaxStep(void* cvode_mem, sunrealtype hmax) The function ``CVodeSetMaxStep`` specifies an upper bound on the magnitude of the step size. @@ -1035,6 +1092,9 @@ Main solver optional input functions **Notes:** Pass ``hmax`` = 0.0 to obtain the default value :math:`\infty`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_step". + .. c:function:: int CVodeSetStopTime(void* cvode_mem, sunrealtype tstop) The function ``CVodeSetStopTime`` specifies the value of the independent variable :math:`t` past which the solution is not to proceed. @@ -1056,6 +1116,9 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`CVodeReInit` will remain active but can be disabled by calling :c:func:`CVodeClearStopTime`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.stop_time". + .. c:function:: int CVodeSetInterpolateStopTime(void* cvode_mem, sunbooleantype interp) The function ``CVodeSetInterpolateStopTime`` specifies that the output solution should be @@ -1070,6 +1133,11 @@ Main solver optional input functions * ``CV_SUCCESS`` -- The optional value has been successfully set. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.interpolate_stop_time". + + .. versionadded:: 6.6.0 .. c:function:: int CVodeClearStopTime(void* cvode_mem) @@ -1087,6 +1155,9 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`CVodeSetStopTime`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.clear_stop_time". + .. versionadded:: 6.5.1 .. c:function:: int CVodeSetMaxErrTestFails(void* cvode_mem, int maxnef) @@ -1104,6 +1175,9 @@ Main solver optional input functions **Notes:** The default value is 7. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_err_test_fails". + .. c:function:: int CVodeSetConstraints(void* cvode_mem, N_Vector constraints) The function ``CVodeSetConstraints`` specifies a vector defining inequality constraints for each component of the solution vector y. @@ -1139,9 +1213,12 @@ Main solver optional input functions * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. **Notes:** - SUNDIALS must be compiled appropriately for specialized kernels to be available. The CMake option ``SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS`` must be set to - ``ON`` when SUNDIALS is compiled. See the entry for this option in :numref:`Installation.Options` for more information. - Currently, the fused kernels are only supported when using CVODE with the :ref:`NVECTOR_CUDA ` and :ref:`NVECTOR_HIP ` implementations of the ``N_Vector``. + SUNDIALS must be compiled appropriately for specialized kernels to be available. The CMake option ``SUNDIALS_BUILD_PACKAGE_FUSED_KERNELS`` must be set to + ``ON`` when SUNDIALS is compiled. See the entry for this option in :numref:`Installation.Options` for more information. + Currently, the fused kernels are only supported when using CVODE with the :ref:`NVECTOR_CUDA ` and :ref:`NVECTOR_HIP ` implementations of the ``N_Vector``. + + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.use_integrator_fused_kernels". .. _CVODE.Usage.CC.optional_input.optin_ls: @@ -1261,6 +1338,10 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.dgmax_lsetup". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetDeltaGammaMaxBadJac(void* cvode_mem, sunrealtype dgmax_jbad) @@ -1282,6 +1363,10 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.delta_gamma_max_bad_jac". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetLSetupFrequency(void* cvode_mem, long int msbp) @@ -1300,6 +1385,9 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function **Notes:** Positive values of ``msbp`` specify the linear solver setup frequency. For example, an input of ``1`` means the setup function will be called every time step while an input of ``2`` means it will be called called every other time step. If ``msbp = 0``, the default value of 20 will be used. Otherwise an error is returned. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.lsetup_frequency". + .. c:function:: int CVodeSetJacEvalFrequency(void* cvode_mem, long int msbj) The function ``CVodeSetJacEvalFrequency`` Specifies the number of steps after @@ -1334,6 +1422,9 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function This function must be called after the CVLS linear solver interface has been initialized through a call to :c:func:`CVodeSetLinearSolver`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.jac_eval_frequency". + When using matrix-based linear solver modules, the CVLS solver interface needs a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or the linear system :math:`M = I - \gamma J`. The function to evaluate :math:`J(t,y)` must @@ -1435,6 +1526,9 @@ using the current :math:`\gamma` as part of the solve. By default scaling is enabled with matrix-based linear solvers when using BDF methods. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.linear_solution_scaling". + When using matrix-free linear solver modules, the CVLS solver interface requires a function to compute an approximation to the product between the Jacobian matrix :math:`J(t,y)` and a vector :math:`v`. The @@ -1590,6 +1684,9 @@ the :c:func:`CVodeSetEpsLin` function. If ``eplifac`` = 0.0 is passed, the default value is used. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eps_lin". + .. versionadded:: 4.0.0 Replaces the deprecated function ``CVSpilsSetEpsLin``. @@ -1616,6 +1713,9 @@ the :c:func:`CVodeSetEpsLin` function. Prior to the introduction of ``N_VGetLength`` in SUNDIALS v5.0.0 (CVODE v5.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.ls_norm_factor". + .. _CVODE.Usage.CC.optional_input.optin_nls: @@ -1661,6 +1761,9 @@ nonlinear solver. **Notes:** The default value is 3. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_nonlin_iters". + .. c:function:: int CVodeSetMaxConvFails(void* cvode_mem, int maxncf) The function ``CVodeSetMaxConvFails`` specifies the maximum number of nonlinear solver convergence failures permitted during one step. @@ -1676,6 +1779,9 @@ nonlinear solver. **Notes:** The default value is 10. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_conv_fails". + .. c:function:: int CVodeSetNonlinConvCoef(void* cvode_mem, sunrealtype nlscoef) The function ``CVodeSetNonlinConvCoef`` specifies the safety factor used in the nonlinear convergence test (see :numref:`CVODE.Mathematics.ivp_sol`). @@ -1691,6 +1797,9 @@ nonlinear solver. **Notes:** The default value is 0.1. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.nonlin_conv_coef". + .. c:function:: int CVodeSetNlsRhsFn(void* cvode_mem, CVRhsFn f) The function ``CVodeSetNlsRhsFn`` specifies an alternative right-hand side function for use in nonlinear system function evaluations. @@ -1798,6 +1907,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_fixed_step_bounds". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMaxFirstStep(void* cvode_mem, sunrealtype eta_max_fs) @@ -1817,6 +1930,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max_first_step". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMaxEarlyStep(void* cvode_mem, sunrealtype eta_max_es) @@ -1847,6 +1964,9 @@ step size adaptivity. factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetNumStepsEtaMaxEarlyStep`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.set_max_early_step". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetNumStepsEtaMaxEarlyStep(void* cvode_mem, long int small_nst) @@ -1874,6 +1994,9 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetEtaMaxEarlyStep`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.num_steps_eta_max_early_step". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMax(void* cvode_mem, sunrealtype eta_max_gs) @@ -1901,6 +2024,9 @@ step size adaptivity. The factor for steps early in the integration is set by :c:func:`CVodeSetEtaMaxEarlyStep`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMin(void* cvode_mem, sunrealtype eta_min) @@ -1920,6 +2046,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_min". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMinErrFail(void *cvode_mem, sunrealtype eta_min_ef) @@ -1940,6 +2070,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_min_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMaxErrFail(void* cvode_mem, sunrealtype eta_max_ef) @@ -1966,6 +2100,12 @@ step size adaptivity. size factor :math:`\eta_{\mathrm{min\_ef}}` can be set with :c:func:`CVodeSetNumFailsEtaMaxErrFail`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.num_efails_eta_max_err_fail". + + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetNumFailsEtaMaxErrFail(void *cvode_mem, int small_nef) @@ -2013,6 +2153,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_conv_fail". + .. versionadded:: 6.2.0 @@ -2067,6 +2211,9 @@ the rootfinding algorithm. **Notes:** CVODE will not report the initial conditions as a possible zero-crossing (assuming that one or more components :math:`g_i` are zero at the initial time). However, if it appears that some :math:`g_i` is identically zero at the initial time (i.e., :math:`g_i` is zero at the initial time and after the first step), CVODE will issue a warning which can be disabled with this optional input function. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.no_inactive_root_warn". + .. _CVODE.Usage.CC.optional_input.optin_proj: @@ -2110,6 +2257,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.proj_err_est". + .. versionadded:: 5.3.0 .. c:function:: int CVodeSetProjFrequency(void* cvode_mem, long int freq) @@ -2125,6 +2276,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.proj_frequency". + .. versionadded:: 5.3.0 .. c:function:: int CVodeSetMaxNumProjFails(void* cvode_mem, int max_fails) @@ -2140,6 +2295,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_num_proj_fails". + .. versionadded:: 5.3.0 .. c:function:: int CVodeSetEpsProj(void* cvode_mem, sunrealtype eps) @@ -2155,6 +2314,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eps_proj". + .. versionadded:: 5.3.0 .. c:function:: int CVodeSetProjFailEta(void* cvode_mem, sunrealtype eta) @@ -2170,6 +2333,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.proj_fail_eta". + .. versionadded:: 5.3.0 diff --git a/doc/cvodes/guide/source/Usage/ADJ.rst b/doc/cvodes/guide/source/Usage/ADJ.rst index 178a8cbcc8..fd291c2202 100644 --- a/doc/cvodes/guide/source/Usage/ADJ.rst +++ b/doc/cvodes/guide/source/Usage/ADJ.rst @@ -584,6 +584,10 @@ call to :c:func:`CVodeInitB` or :c:func:`CVodeInitBS`. * ``CV_NO_ADJ`` -- The function :c:func:`CVodeAdjInit` has not been previously called. * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.scalar_tolerances_b". + .. c:function:: int CVodeSVtolerancesB(void * cvode_mem, int which, sunrealtype reltolB, N_Vector abstolB) @@ -819,9 +823,9 @@ At any time during the integration of the forward problem, the user can disable the checkpointing of the forward sensitivities by calling the following function: -.. c:function:: int CVodeAdjSetNoSensi(void * cvode_mem) +.. c:function:: int CVodeSetAdjNoSensi(void * cvode_mem) - The function :c:func:`CVodeAdjSetNoSensi` instructs :c:func:`CVodeF` not to + The function :c:func:`CVodeSetAdjNoSensi` instructs :c:func:`CVodeF` not to save checkpointing data for forward sensitivities anymore. **Arguments:** @@ -832,6 +836,10 @@ function: * ``CV_MEM_NULL`` -- ``cvode_mem`` was ``NULL``. * ``CV_NO_ADJ`` -- The function :c:func:`CVodeAdjInit` has not been previously called. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.adj_no_sensi". + .. _CVODES.Usage.ADJ.user_callable.optional_input_b: @@ -877,7 +885,10 @@ The optional input functions defined for the backward problem are: Their return value ``flag`` (of type ``int``) can have any of the return values of their counterparts, but it can also be ``CV_NO_ADJ`` if :c:func:`CVodeAdjInit` has not been called, or ``CV_ILL_INPUT`` if ``which`` was -an invalid identifier. +an invalid identifier. The above routines may be controlled using command-line +options via :c:func:`CVodeSetFromCommandLine`, where the command-line argument is +appended with the suffix "_b", e.g., ``CVodeSetMaxOrdB`` can be controlled by the +command-line option "cvid.max_order_b". Linear solver interface optional input functions """""""""""""""""""""""""""""""""""""""""""""""" @@ -996,6 +1007,8 @@ disable solution scaling when using a matrix-based linear solver. By default scaling is enabled with matrix-based linear solvers when using BDF methods. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.linear_solution_scaling_b". .. c:function:: int CVodeSetJacTimesB(void * cvode_mem, int which, CVLsJacTimesSetupFnB jsetupB, CVLsJacTimesVecFnB jtvB) @@ -1160,6 +1173,9 @@ potentially non-differentiable factor. The default value is :math:`0.05`. Passing a value ``eplifacB = 0.0`` also indicates using the default value. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eps_lin_b". + .. versionadded:: 4.0.0 Replaces the deprecated function ``CVSpilsSetEpsLinB``. @@ -1192,6 +1208,9 @@ potentially non-differentiable factor. v5.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.ls_norm_factor_b". + .. _CVODES.Usage.ADJ.user_callable.optional_output_b: @@ -1439,7 +1458,9 @@ optional values are specified. Their return value ``flag`` (of type ``int``) can have any of the return values of its counterparts, but it can also be ``CV_NO_ADJ`` if the function :c:func:`CVodeAdjInit` has not been previously called or ``CV_ILL_INPUT`` if the -parameter ``which`` was an invalid identifier. +parameter ``which`` was an invalid identifier. The first two routines above may +be controlled using command-line options "cvid.quad_err_con_b" and +"cvid.quad_scalar_tolerances_b" when using :c:func:`CVodeSetFromCommandLine`. Access to optional outputs related to backward quadrature integration can be obtained by calling the corresponding ``CVodeGetQuad*`` functions (see diff --git a/doc/cvodes/guide/source/Usage/FSA.rst b/doc/cvodes/guide/source/Usage/FSA.rst index 23f2a7d171..e3bb48b2a4 100644 --- a/doc/cvodes/guide/source/Usage/FSA.rst +++ b/doc/cvodes/guide/source/Usage/FSA.rst @@ -804,6 +804,9 @@ time and, if successful, takes effect immediately. The default value are ``DQtype == CV_CENTERED`` and ``DQrhomax=0.0``. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.sens_dq_method". + .. c:function:: int CVodeSetSensErrCon(void * cvode_mem, sunbooleantype errconS) @@ -825,6 +828,9 @@ time and, if successful, takes effect immediately. variables are excluded from the error tests. Note that, in any event, all variables are considered in the convergence tests. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.sens_err_con". + .. c:function:: int CVodeSetSensMaxNonlinIters(void * cvode_mem, int maxcorS) @@ -843,6 +849,9 @@ time and, if successful, takes effect immediately. **Notes:** The default value is 3. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.sens_max_nonlin_iters". + .. _CVODES.Usage.FSA.user_callable.optional_output: @@ -1595,6 +1604,9 @@ integration of sensitivity-dependent quadrature equations. **Notes:** By default, ``errconQS`` is set to ``SUNFALSE``. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.quad_sens_err_con". + .. warning:: It is illegal to call :c:func:`CVodeSetQuadSensErrCon` before a call to :c:func:`CVodeQuadSensInit`. diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index d4fa362041..a10ab0bf88 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -389,6 +389,10 @@ the call to :c:func:`CVodeInit`. * ``CV_NO_MALLOC`` -- The allocation function returned ``NULL``. * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.scalar_tolerances". + .. c:function:: int CVodeSVtolerances(void* cvode_mem, sunrealtype reltol, N_Vector abstol) The function ``CVodeSVtolerances`` specifies scalar relative tolerance and vector absolute tolerances. @@ -834,6 +838,9 @@ Main solver optional input functions +---------------------------------+---------------------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +=================================+=============================================+================+ + | Set CVODES optional inputs | :c:func:`CVodeSetFromCommandLine` | | + | from the command line | | | + +---------------------------------+---------------------------------------------+----------------+ | User data | :c:func:`CVodeSetUserData` | ``NULL`` | +---------------------------------+---------------------------------------------+----------------+ | Maximum order for BDF method | :c:func:`CVodeSetMaxOrd` | 5 | @@ -870,6 +877,36 @@ Main solver optional input functions +---------------------------------+---------------------------------------------+----------------+ +.. c:function:: int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, char* argv[]) + + Passes command-line arguments to CVODES to set options. + + :param cvode_mem: pointer to the CVODES memory block. + :param cvid: String to use as prefix for CVODES command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :retval CV_SUCCESS: the function exited successfully. + :retval CV_MEM_NULL: ``cvode_mem`` was ``NULL``. + :retval other: error return value from relevant CVODES "set" routine. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + These are left unchanged by :c:func:`CVodeSetFromCommandLine`. + + If the *cvid* argument is ``NULL`` then ``cvodes.`` will be used for all CVODES command-line + options, e.g., to set the maximum order of accuracy the default command-line option would + be "cvodes.max_order". + + CVODES options set via command-line arguments to :c:func:`CVodeSetFromCommandLine` will + overwrite any previously-set values. + + The supported command-line options are documented within each CVODES "set" routine. + + .. versionadded:: x.y.z + + .. c:function:: int CVodeSetUserData(void* cvode_mem, void * user_data) The function ``CVodeSetUserData`` specifies the user data block ``user_data`` and attaches it to the main CVODES memory block. @@ -923,6 +960,9 @@ Main solver optional input functions **Notes:** The monitor function that will be called can be set with ``CVodeSetMonitorFn``. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.monitor_frequency". + .. warning:: Modifying the solution in this function will result in undefined behavior. This function is only intended to be used for monitoring the integrator. SUNDIALS must be built with the CMake option ``SUNDIALS_BUILD_WITH_MONITORING``, to utilize this function. See :numref:`Installation` for more information. @@ -945,6 +985,9 @@ Main solver optional input functions An input value greater than the default will result in the default value. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_order". + .. c:function:: int CVodeSetMaxNumSteps(void* cvode_mem, long int mxsteps) The function ``CVodeSetMaxNumSteps`` specifies the maximum number of steps to be taken by the solver in its attempt to reach the next output time. @@ -962,6 +1005,9 @@ Main solver optional input functions Passing ``mxsteps`` < 0 disables the test (not recommended). + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_num_steps". + .. c:function:: int CVodeSetMaxHnilWarns(void* cvode_mem, int mxhnil) The function ``CVodeSetMaxHnilWarns`` specifies the maximum number of messages issued by the solver warning that :math:`t+h=t` on the next internal step. @@ -977,6 +1023,9 @@ Main solver optional input functions **Notes:** The default value is 10. A negative value for ``mxhnil`` indicates that no warning messages should be issued. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_hnil_warns". + .. c:function:: int CVodeSetStabLimDet(void* cvode_mem, sunbooleantype stldet) The function ``CVodeSetStabLimDet`` indicates if the BDF stability limit detection algorithm should be used. See :numref:`CVODES.Mathematics.stablimit` for further details. @@ -993,6 +1042,9 @@ Main solver optional input functions **Notes:** The default value is ``SUNFALSE``. If ``stldet = SUNTRUE`` when BDF is used and the method order is greater than or equal to 3, then an internal function, ``CVsldet``, is called to detect a possible stability limit. If such a limit is detected, then the order is reduced. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.stab_lim_det". + .. c:function:: int CVodeSetInitStep(void* cvode_mem, sunrealtype hin) The function ``CVodeSetInitStep`` specifies the initial step size. @@ -1008,6 +1060,9 @@ Main solver optional input functions **Notes:** By default, CVODES estimates the initial step size to be the solution :math:`h` of the equation :math:`0.5 h^2 \ddot{y} = 1`, where :math:`\ddot{y}` is an estimated second derivative of the solution at :math:`t_0`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.init_step". + .. c:function:: int CVodeSetMinStep(void* cvode_mem, sunrealtype hmin) The function ``CVodeSetMinStep`` specifies a lower bound on the magnitude of the step size. @@ -1024,6 +1079,9 @@ Main solver optional input functions **Notes:** The default value is 0.0. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.min_step". + .. c:function:: int CVodeSetMaxStep(void* cvode_mem, sunrealtype hmax) The function ``CVodeSetMaxStep`` specifies an upper bound on the magnitude of the step size. @@ -1040,6 +1098,9 @@ Main solver optional input functions **Notes:** Pass ``hmax`` = 0.0 to obtain the default value :math:`\infty`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_step". + .. c:function:: int CVodeSetStopTime(void* cvode_mem, sunrealtype tstop) The function ``CVodeSetStopTime`` specifies the value of the independent variable :math:`t` past which the solution is not to proceed. @@ -1061,6 +1122,9 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`CVodeReInit` will remain active but can be disabled by calling :c:func:`CVodeClearStopTime`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.stop_time". + .. c:function:: int CVodeSetInterpolateStopTime(void* cvode_mem, sunbooleantype interp) The function ``CVodeSetInterpolateStopTime`` specifies that the output solution should be @@ -1075,6 +1139,10 @@ Main solver optional input functions * ``CV_SUCCESS`` -- The optional value has been successfully set. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.interpolate_stop_time". + .. versionadded:: 6.6.0 .. c:function:: int CVodeClearStopTime(void* cvode_mem) @@ -1092,6 +1160,9 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`CVodeSetStopTime`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.clear_stop_time". + .. versionadded:: 6.5.1 .. c:function:: int CVodeSetMaxErrTestFails(void* cvode_mem, int maxnef) @@ -1109,6 +1180,9 @@ Main solver optional input functions **Notes:** The default value is 7. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_err_test_fails". + .. c:function:: int CVodeSetConstraints(void* cvode_mem, N_Vector constraints) The function ``CVodeSetConstraints`` specifies a vector defining inequality constraints for each component of the solution vector y. @@ -1258,6 +1332,10 @@ using the current :math:`\gamma` value. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.dgmax_lsetup". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetDeltaGammaMaxBadJac(void* cvode_mem, sunrealtype dgmax_jbad) @@ -1279,6 +1357,10 @@ using the current :math:`\gamma` value. * ``CV_MEM_NULL`` -- The CVODE memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.delta_gamma_max_bad_jac". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetLSetupFrequency(void* cvode_mem, long int msbp) @@ -1297,6 +1379,9 @@ using the current :math:`\gamma` value. **Notes:** Positive values of ``msbp`` specify the linear solver setup frequency. For example, an input of ``1`` means the setup function will be called every time step while an input of ``2`` means it will be called called every other time step. If ``msbp = 0``, the default value of 20 will be used. Otherwise an error is returned. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.lsetup_frequency". + .. c:function:: int CVodeSetJacEvalFrequency(void* cvode_mem, long int msbj) The function ``CVodeSetJacEvalFrequency`` Specifies the number of steps after @@ -1331,6 +1416,9 @@ using the current :math:`\gamma` value. This function must be called after the CVLS linear solver interface has been initialized through a call to :c:func:`CVodeSetLinearSolver`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.jac_eval_frequency". + When using matrix-based linear solver modules, the CVLS solver interface needs a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or the linear system :math:`M = I - \gamma J`. The function to evaluate :math:`J(t,y)` must @@ -1432,6 +1520,9 @@ using the current :math:`\gamma` as part of the solve. By default scaling is enabled with matrix-based linear solvers when using BDF methods. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.linear_solution_scaling". + When using matrix-free linear solver modules, the CVLS solver interface requires a function to compute an approximation to the product between the Jacobian matrix :math:`J(t,y)` and a vector :math:`v`. The @@ -1587,6 +1678,9 @@ the :c:func:`CVodeSetEpsLin` function. If ``eplifac`` = 0.0 is passed, the default value is used. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eps_lin". + .. versionadded:: 4.0.0 Replaces the deprecated function ``CVSpilsSetEpsLin``. @@ -1613,6 +1707,12 @@ the :c:func:`CVodeSetEpsLin` function. Prior to the introduction of ``N_VGetLength`` in SUNDIALS v5.0.0 (CVODES v5.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.ls_norm_factor". + + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.ls_norm_factor". + .. _CVODES.Usage.SIM.optional_input.optin_nls: @@ -1658,6 +1758,9 @@ nonlinear solver. **Notes:** The default value is 3. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_nonlin_iters". + .. c:function:: int CVodeSetMaxConvFails(void* cvode_mem, int maxncf) The function ``CVodeSetMaxConvFails`` specifies the maximum number of nonlinear solver convergence failures permitted during one step. @@ -1673,6 +1776,9 @@ nonlinear solver. **Notes:** The default value is 10. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_conv_fails". + .. c:function:: int CVodeSetNonlinConvCoef(void* cvode_mem, sunrealtype nlscoef) The function ``CVodeSetNonlinConvCoef`` specifies the safety factor used in the nonlinear convergence test (see :numref:`CVODES.Mathematics.ivp_sol`). @@ -1688,6 +1794,9 @@ nonlinear solver. **Notes:** The default value is 0.1. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.nonlin_conv_coef". + .. c:function:: int CVodeSetNlsRhsFn(void* cvode_mem, CVRhsFn f) The function ``CVodeSetNlsRhsFn`` specifies an alternative right-hand side function for use in nonlinear system function evaluations. @@ -1795,6 +1904,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_fixed_step_bounds". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMaxFirstStep(void* cvode_mem, sunrealtype eta_max_fs) @@ -1814,6 +1927,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max_first_step". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMaxEarlyStep(void* cvode_mem, sunrealtype eta_max_es) @@ -1844,6 +1961,9 @@ step size adaptivity. factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetNumStepsEtaMaxEarlyStep`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max_early_step". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetNumStepsEtaMaxEarlyStep(void* cvode_mem, long int small_nst) @@ -1898,6 +2018,9 @@ step size adaptivity. The factor for steps early in the integration is set by :c:func:`CVodeSetEtaMaxEarlyStep`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMin(void* cvode_mem, sunrealtype eta_min) @@ -1917,6 +2040,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_min". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMinErrFail(void *cvode_mem, sunrealtype eta_min_ef) @@ -1937,6 +2064,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_min_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMaxErrFail(void* cvode_mem, sunrealtype eta_max_ef) @@ -1963,6 +2094,9 @@ step size adaptivity. size factor :math:`\eta_{\mathrm{min\_ef}}` can be set with :c:func:`CVodeSetNumFailsEtaMaxErrFail`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_max_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetNumFailsEtaMaxErrFail(void *cvode_mem, int small_nef) @@ -1990,6 +2124,9 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_ef}}` can be set with :c:func:`CVodeSetEtaMaxErrFail`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.num_efails_eta_max_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaConvFail(void* cvode_mem, sunrealtype eta_cf) @@ -2010,6 +2147,10 @@ step size adaptivity. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eta_conv_fail". + .. versionadded:: 6.2.0 @@ -2062,8 +2203,15 @@ the rootfinding algorithm. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. **Notes:** - CVODES will not report the initial conditions as a possible zero-crossing (assuming that one or more components :math:`g_i` are zero at the initial time). However, if it appears that some :math:`g_i` is identically zero at the initial time (i.e., :math:`g_i` is zero at the initial time and after the first step), CVODES will issue a warning which can be disabled with this optional input function. + CVODES will not report the initial conditions as a possible zero-crossing + (assuming that one or more components :math:`g_i` are zero at the initial time). + However, if it appears that some :math:`g_i` is identically zero at the initial + time (i.e., :math:`g_i` is zero at the initial time and after the first step), + CVODES will issue a warning which can be disabled with this optional input + function. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.no_inactive_root_warn". .. _CVODES.Usage.SIM.optional_input.optin_proj: @@ -2107,6 +2255,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.proj_err_est". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetProjFrequency(void* cvode_mem, long int freq) @@ -2122,6 +2274,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.proj_frequency". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetMaxNumProjFails(void* cvode_mem, int max_fails) @@ -2137,6 +2293,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.max_num_proj_fails". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEpsProj(void* cvode_mem, sunrealtype eps) @@ -2152,6 +2312,13 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eps_lin". + + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.eps_proj". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetProjFailEta(void* cvode_mem, sunrealtype eta) @@ -2167,6 +2334,10 @@ the projection when solving an IVP with constraints. * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.proj_fail_eta". + .. versionadded:: 6.2.0 @@ -4059,6 +4230,9 @@ of quadrature equations. **Notes:** By default, ``errconQ`` is set to ``SUNFALSE``. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.quad_err_con". + .. warning:: It is illegal to call ``CVodeSetQuadErrCon`` before a call to ``CVodeQuadInit``. @@ -4083,6 +4257,10 @@ integration tolerances for quadrature variables. * ``CV_MEM_NULL`` -- The ``cvode_mem`` pointer is ``NULL``. * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.quad_scalar_tolerances". + .. c:function:: int CVodeQuadSVtolerances(void * cvode_mem, sunrealtype reltolQ, N_Vector abstolQ) diff --git a/doc/ida/guide/source/Usage/index.rst b/doc/ida/guide/source/Usage/index.rst index 8647287eb6..239a4bee3f 100644 --- a/doc/ida/guide/source/Usage/index.rst +++ b/doc/ida/guide/source/Usage/index.rst @@ -383,6 +383,10 @@ norms). Note that this call must be made after the call to :c:func:`IDAInit`. called. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.scalar_tolerances". + .. c:function:: int IDASVtolerances(void* ida_mem, sunrealtype reltol, N_Vector abstol) The function ``IDASVtolerances`` specifies scalar relative tolerance and @@ -906,6 +910,8 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +--------------------------------------------------------------------+---------------------------------+----------------+ + | Set IDA optional inputs from the command line | :c:func:`IDASetFromCommandLine` | | + +--------------------------------------------------------------------+---------------------------------+----------------+ | User data | :c:func:`IDASetUserData` | NULL | +--------------------------------------------------------------------+---------------------------------+----------------+ | Maximum order for BDF method | :c:func:`IDASetMaxOrd` | 5 | @@ -932,6 +938,35 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ +.. c:function:: int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, char* argv[]) + + Passes command-line arguments to IDA to set options. + + :param ida_mem: pointer to the IDA solver objectd. + :param idaid: String to use as prefix for IDA command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :retval IDA_SUCCESS: the function exited successfully. + :retval IDA_MEM_NULL: ``ida_mem`` was ``NULL``. + :retval other: error return value from relevant IDA "set" routine. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + These are left unchanged by :c:func:`IDASetFromCommandLine`. + + If the *idaid* argument is ``NULL`` then ``ida.`` will be used for all IDA command-line + options, e.g., to set the maximum order of accuracy the default command-line option would + be "ida.max_order". + + IDA options set via command-line arguments to :c:func:`IDASetFromCommandLine` will + overwrite any previously-set values. + + The supported command-line options are documented within each IDA "set" routine. + + .. versionadded:: x.y.z + .. c:function:: int IDASetUserData(void * ida_mem, void * user_data) The function ``IDASetUserData`` attaches a user-defined data pointer to the @@ -977,6 +1012,9 @@ Main solver optional input functions requirements for the internal IDA memory block and its value cannot be increased past the value set when :c:func:`IDAInit` was called. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_order". + .. c:function:: int IDASetMaxNumSteps(void * ida_mem, long int mxsteps) The function ``IDASetMaxNumSteps`` specifies the maximum number of steps to @@ -994,6 +1032,9 @@ Main solver optional input functions Passing ``mxsteps`` = 0 results in IDA using the default value (500). Passing ``mxsteps`` < 0 disables the test (not recommended). + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_steps". + .. c:function:: int IDASetInitStep(void * ida_mem, sunrealtype hin) The function ``IDASetInitStep`` specifies the initial step size. @@ -1012,6 +1053,9 @@ Main solver optional input functions :math:`\|h \dot{y} \|_{{\scriptsize WRMS}} = 1/2`, with an added restriction that :math:`|h| \leq .001|t_{\text{out}} - t_0|`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.init_step". + .. c:function:: int IDASetMinStep(void * ida_mem, sunrealtype hmin) The function ``IDASetMinStep`` specifies the minimum absolute value of the @@ -1028,6 +1072,10 @@ Main solver optional input functions * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. * ``IDA_ILL_INPUT`` -- ``hmin`` is negative. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.min_step". + .. versionadded:: 6.2.0 .. c:function:: int IDASetMaxStep(void * ida_mem, sunrealtype hmax) @@ -1048,6 +1096,9 @@ Main solver optional input functions **Notes:** Pass ``hmax = 0`` to obtain the default value :math:`\infty`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_step". + .. c:function:: int IDASetStopTime(void * ida_mem, sunrealtype tstop) The function ``IDASetStopTime`` specifies the value of the independent @@ -1073,6 +1124,9 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`IDAReInit` will remain active but can be disabled by calling :c:func:`IDAClearStopTime`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.stop_time". + .. c:function:: int IDAClearStopTime(void* ida_mem) Disables the stop time set with :c:func:`IDASetStopTime`. @@ -1088,6 +1142,9 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`IDASetStopTime`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.clear_stop_time". + .. versionadded:: 6.5.1 .. c:function:: int IDASetMaxErrTestFails(void * ida_mem, int maxnef) @@ -1107,6 +1164,9 @@ Main solver optional input functions **Notes:** The default value is 10. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_err_test_fails". + .. c:function:: int IDASetSuppressAlg(void * ida_mem, sunbooleantype suppressalg) The function ``IDASetSuppressAlg`` indicates whether or not to suppress @@ -1129,6 +1189,9 @@ Main solver optional input functions 1, whereas it is generally *encouraged* for systems of index 2 or more. See pp. 146-147 of :cite:p:`BCP:96` for more on this issue. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.suppress_alg". + .. c:function:: int IDASetId(void * ida_mem, N_Vector id) The function ``IDASetId`` specifies algebraic/differential components in the @@ -1288,6 +1351,10 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. * ``IDA_SUCCESS`` -- The flag value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.delta_cj_lsetup". + .. versionadded:: 6.2.0 .. c:function:: int IDASetLinearSolutionScaling(void * ida_mem, sunbooleantype onoff) @@ -1312,6 +1379,9 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. initialized through a call to :c:func:`IDASetLinearSolver`. By default scaling is enabled with matrix-based linear solvers. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.linear_solution_scaling". + When using matrix-free linear solver modules, the IDALS solver interface requires a function to compute an approximation to the product between the @@ -1402,6 +1472,9 @@ finite-difference approximation, via a call to :c:func:`IDASetIncrementFactor`. linear solver interface has been initialized through a call to :c:func:`IDASetLinearSolver`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.increment_factor". + .. versionadded:: 4.0.0 Replaces the deprecated function ``IDASpilsSetIncrementFactor``. @@ -1522,6 +1595,9 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default :c:func:`IDASetLinearSolver`. If ``eplifac`` :math:`= 0.0` is passed, the default value is used. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eps_lin". + .. versionadded:: 4.0.0 Replaces the deprecated function ``IDASpilsSetEpsLin``. @@ -1555,6 +1631,9 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default value of ``nrmfac`` was computed using :c:func:`N_VDotProd` i.e., the ``nrmfac < 0`` case. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.ls_norm_factor". + .. _IDA.Usage.CC.optional_input.optin_nls: @@ -1598,6 +1677,9 @@ nonlinear solver. **Notes:** The default value is 4. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_nonlin_iters". + .. c:function:: int IDASetMaxConvFails(void * ida_mem, int maxncf) @@ -1616,6 +1698,9 @@ nonlinear solver. **Notes:** The default value is 10. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_conv_fails". + .. c:function:: int IDASetNonlinConvCoef(void * ida_mem, sunrealtype nlscoef) @@ -1634,6 +1719,9 @@ nonlinear solver. **Notes:** The default value is 0.33. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.nonlin_conv_coef". + .. c:function:: int IDASetNlsResFn(void * ida_mem, IDAResFn res) @@ -1710,6 +1798,9 @@ to set optional inputs controlling the initial condition calculation. :math:`J^{-1}F(t_0, y, \dot{y})` must be :math:`\leq \mathtt{epiccon}`, where :math:`J` is the system Jacobian. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.nonlin_conv_coef_ic". + .. c:function:: int IDASetMaxNumStepsIC(void * ida_mem, int maxnh) The function ``IDASetMaxNumStepsIC`` specifies the maximum number of steps @@ -1729,6 +1820,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`5`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_steps_ic". + .. c:function:: int IDASetMaxNumJacsIC(void * ida_mem, int maxnj) The function ``IDASetMaxNumJacsIC`` specifies the maximum number of the @@ -1748,6 +1842,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`4`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_jacs_ic". + .. c:function:: int IDASetMaxNumItersIC(void * ida_mem, int maxnit) The function ``IDASetMaxNumItersIC`` specifies the maximum number of Newton @@ -1766,6 +1863,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`10`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_iters_ic". + .. c:function:: int IDASetMaxBacksIC(void * ida_mem, int maxbacks) The function ``IDASetMaxBacksIC`` specifies the maximum number of linesearch @@ -1784,6 +1884,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`100`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_backs_ic". + .. c:function:: int IDASetLineSearchOffIC(void * ida_mem, sunbooleantype lsoff) The function ``IDASetLineSearchOffIC`` specifies whether to turn on or off @@ -1799,8 +1902,10 @@ to set optional inputs controlling the initial condition calculation. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** + The default value is ``SUNFALSE``. - The default value is ``SUNFALSE``. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.linesearch_off_ic". .. c:function:: int IDASetStepToleranceIC(void * ida_mem, int steptol) @@ -1819,6 +1924,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`(\text{unit roundoff})^{2/3}`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.step_tolerance_ic". + .. _IDA.Usage.CC.optional_input.optin_step_adapt: @@ -1886,6 +1994,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_fixed_step_bounds". + .. versionadded:: 6.2.0 .. c:function:: int IDASetEtaMax(void* ida_mem, sunrealtype eta_max) @@ -1903,6 +2015,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_max". + .. versionadded:: 6.2.0 .. c:function:: int IDASetEtaMin(void* ida_mem, sunrealtype eta_min) @@ -1923,6 +2039,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_min". + .. versionadded:: 6.2.0 .. c:function:: int IDASetEtaLow(void* ida_mem, sunrealtype eta_low) @@ -1943,6 +2063,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_low". + .. versionadded:: 6.2.0 .. c:function:: int IDASetEtaMinErrFail(void* ida_mem, sunrealtype eta_min_ef) @@ -1963,6 +2087,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_min_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int IDASetEtaConvFail(void* ida_mem, sunrealtype eta_cf) @@ -1983,6 +2111,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_conv_fail". + .. versionadded:: 6.2.0 @@ -2055,6 +2187,9 @@ rootfinding algorithm. first step), IDA will issue a warning which can be disabled with this optional input function. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.no_inactive_root_warn". + .. _IDA.Usage.CC.optional_dky: diff --git a/doc/idas/guide/source/Usage/ADJ.rst b/doc/idas/guide/source/Usage/ADJ.rst index 0368cf958d..104816c3a6 100644 --- a/doc/idas/guide/source/Usage/ADJ.rst +++ b/doc/idas/guide/source/Usage/ADJ.rst @@ -398,6 +398,10 @@ function: * ``IDA_MEM_NULL`` -- The ``ida_mem`` was ``NULL``. * ``IDA_NO_ADJ`` -- The function :c:func:`IDAAdjInit` has not been previously called. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.adj_no_sensi". + .. _IDAS.Usage.ADJ.user_callable.idasolvef: @@ -626,6 +630,10 @@ call to :c:func:`IDAInitB` or :c:func:`IDAInitBS`. * ``IDA_NO_ADJ`` -- The function :c:func:`IDAAdjInit` has not been previously called. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.scalar_tolerances_b". + .. c:function:: int IDASVtolerancesB(void * ida_mem, int which, sunrealtype reltolB, N_Vector abstolB) @@ -963,7 +971,11 @@ The optional input functions defined for the backward problem are: Their return value ``flag`` (of type ``int``) can have any of the return values of their counterparts, but it can also be ``IDA_NO_ADJ`` if :c:func:`IDAAdjInit` has -not been called, or ``IDA_ILL_INPUT`` if ``which`` was an invalid identifier. +not been called, or ``IDA_ILL_INPUT`` if ``which`` was an invalid identifier. The +above routines may be controlled using command-line options via +:c:func:`IDASetFromCommandLine`, where the command-line argument is +appended with the suffix "_b", e.g., ``IDASetMaxOrdB`` can be controlled by the +command-line option "idaid.max_order_b". Linear solver interface optional input functions """""""""""""""""""""""""""""""""""""""""""""""" @@ -1042,11 +1054,14 @@ disable solution scaling when using a matrix-based linear solver. **Notes:** - By default scaling is enabled with matrix-based linear solvers when using - BDF methods. + By default scaling is enabled with matrix-based linear solvers when using + BDF methods. - By default scaling is enabled with matrix-based linear solvers when using BDF - methods. + By default scaling is enabled with matrix-based linear solvers when using BDF + methods. + + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.linear_solution_scaling_b". When using a matrix-free linear solver module for the backward problem, the IDALS linear solver interface requires a function to compute an @@ -1132,6 +1147,9 @@ setting increments for the finite-difference approximation, via a call to **Notes:** The default value is :math:`1.0`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.increment_factor_b". + .. versionadded:: 3.0.0 Replaces the deprecated function ``IDASpilsSetIncrementFactorB``. @@ -1265,6 +1283,9 @@ These may be accomplished through calling the following functions: Passing a value ``eplifacB`` :math:`= 0.0` also indicates using the default value. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eps_lin_b". + .. versionadded:: 3.0.0 Replaces the deprecated function ``IDASpilsSetEpsLinB``. @@ -1301,6 +1322,9 @@ These may be accomplished through calling the following functions: v4.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.ls_norm_factor_b". + .. _IDAS.Usage.ADJ.user_callable.optional_output_b: @@ -1591,7 +1615,9 @@ optional values are specified. Their return value ``flag`` (of type ``int``) can have any of the return values of its counterparts, but it can also be ``IDA_NO_ADJ`` if the function :c:func:`IDAAdjInit` has not been previously called or ``IDA_ILL_INPUT`` if the -parameter ``which`` was an invalid identifier. +parameter ``which`` was an invalid identifier. The first two routines above may +be controlled using command-line options "idaid.quad_err_con_b" and +"idaid.quad_scalar_tolerances_b" when using :c:func:`IDASetFromCommandLine`. Access to optional outputs related to backward quadrature integration can be obtained by calling the corresponding ``IDAGetQuad*`` functions (see diff --git a/doc/idas/guide/source/Usage/FSA.rst b/doc/idas/guide/source/Usage/FSA.rst index b89ea26bf6..47feb40d1f 100644 --- a/doc/idas/guide/source/Usage/FSA.rst +++ b/doc/idas/guide/source/Usage/FSA.rst @@ -353,6 +353,9 @@ function is provided: Since sensitivity-related memory is not deallocated, sensitivities can be reactivated at a later time (using :c:func:`IDASensReInit`). + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.sens_toggle_off". + Forward sensitivity tolerance specification functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -742,17 +745,20 @@ time and, if successful, takes effect immediately. **Notes:** - If ``DQrhomax`` :math:`= 0.0`, then no switching is performed. The - approximation is done simultaneously using either centered or forward finite - differences, depending on the value of ``DQtype``. For values of - ``DQrhomax`` :math:`\ge 1.0`, the simultaneous approximation is used whenever - the estimated finite difference perturbations for states and parameters are - within a factor of ``DQrhomax``, and the separate approximation is used - otherwise. Note that a value ``DQrhomax`` :math:`<1.0` will effectively - disable switching. See :numref:`IDAS.Mathematics.FSA` for more details. + If ``DQrhomax`` :math:`= 0.0`, then no switching is performed. The + approximation is done simultaneously using either centered or forward finite + differences, depending on the value of ``DQtype``. For values of + ``DQrhomax`` :math:`\ge 1.0`, the simultaneous approximation is used whenever + the estimated finite difference perturbations for states and parameters are + within a factor of ``DQrhomax``, and the separate approximation is used + otherwise. Note that a value ``DQrhomax`` :math:`<1.0` will effectively + disable switching. See :numref:`IDAS.Mathematics.FSA` for more details. + + The default value are ``DQtype == IDA_CENTERED`` and + ``DQrhomax``:math:`=0.0`. - The default value are ``DQtype == IDA_CENTERED`` and - ``DQrhomax``:math:`=0.0`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.sens_dq_method". .. c:function:: int IDASetSensErrCon(void * ida_mem, sunbooleantype errconS) @@ -775,6 +781,9 @@ time and, if successful, takes effect immediately. variables are excluded from the error tests. Note that, in any event, all variables are considered in the convergence tests. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idas.sens_err_con". + .. c:function:: int IDASetSensMaxNonlinIters(void * ida_mem, int maxcorS) @@ -793,6 +802,9 @@ time and, if successful, takes effect immediately. **Notes:** The default value is 3. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idas.sens_max_nonlin_iters". + .. _IDAS.Usage.FSA.user_callable.optional_output: @@ -1429,6 +1441,9 @@ of sensitivity-dependent quadrature equations. **Notes:** By default, ``errconQS`` is set to ``SUNFALSE``. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idas.quad_sens_err_con". + .. warning:: It is illegal to call :c:func:`IDASetQuadSensErrCon` before a call to :c:func:`IDAQuadSensInit`. diff --git a/doc/idas/guide/source/Usage/SIM.rst b/doc/idas/guide/source/Usage/SIM.rst index a73e525c6c..0fc7e9b013 100644 --- a/doc/idas/guide/source/Usage/SIM.rst +++ b/doc/idas/guide/source/Usage/SIM.rst @@ -381,6 +381,10 @@ norms). Note that this call must be made after the call to :c:func:`IDAInit`. called. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.scalar_tolerances". + .. c:function:: int IDASVtolerances(void* ida_mem, sunrealtype reltol, N_Vector abstol) The function :c:func:`IDASVtolerances` specifies scalar relative tolerance and @@ -910,6 +914,8 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | + +====================================================================+=================================+================+ + | Set IDAS optional inputs from the command line | :c:func:`IDASetFromCommandLine` | | +--------------------------------------------------------------------+---------------------------------+----------------+ | User data | :c:func:`IDASetUserData` | NULL | +--------------------------------------------------------------------+---------------------------------+----------------+ @@ -937,6 +943,36 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ +.. c:function:: int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, char* argv[]) + + Passes command-line arguments to IDAS to set options. + + :param ida_mem: pointer to the IDAS memory block. + :param idaid: String to use as prefix for IDAS command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :retval IDA_SUCCESS: the function exited successfully. + :retval IDA_MEM_NULL: ``ida_mem`` was ``NULL``. + :retval other: error return value from relevant IDAS "set" routine. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + These are left unchanged by :c:func:`IDASetFromCommandLine`. + + If the *idaid* argument is ``NULL`` then ``idas.`` will be used for all IDAS command-line + options, e.g., to set the maximum order of accuracy the default command-line option would + be "idaid.max_order". + + IDAS options set via command-line arguments to :c:func:`IDASetFromCommandLine` will + overwrite any previously-set values. + + The supported command-line options are documented within each IDAS "set" routine. + + .. versionadded:: x.y.z + + .. c:function:: int IDASetUserData(void * ida_mem, void * user_data) The function :c:func:`IDASetUserData` attaches a user-defined data pointer to the @@ -982,6 +1018,9 @@ Main solver optional input functions requirements for the internal IDAS memory block and its value cannot be increased past the value set when :c:func:`IDAInit` was called. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_order". + .. c:function:: int IDASetMaxNumSteps(void * ida_mem, long int mxsteps) The function :c:func:`IDASetMaxNumSteps` specifies the maximum number of steps to @@ -999,6 +1038,9 @@ Main solver optional input functions Passing ``mxsteps`` = 0 results in IDAS using the default value (500). Passing ``mxsteps`` < 0 disables the test (not recommended). + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_steps". + .. c:function:: int IDASetInitStep(void * ida_mem, sunrealtype hin) The function :c:func:`IDASetInitStep` specifies the initial step size. @@ -1017,6 +1059,9 @@ Main solver optional input functions :math:`\|h \dot{y} \|_{{\scriptsize WRMS}} = 1/2`, with an added restriction that :math:`|h| \leq .001|t_{\text{out}} - t_0|`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.init_step". + .. c:function:: int IDASetMinStep(void * ida_mem, sunrealtype hmin) The function :c:func:`IDASetMinStep` specifies the minimum absolute value of @@ -1033,6 +1078,10 @@ Main solver optional input functions * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. * ``IDA_ILL_INPUT`` -- ``hmin`` is negative. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.min_step". + .. versionadded:: 5.2.0 .. c:function:: int IDASetMaxStep(void * ida_mem, sunrealtype hmax) @@ -1053,6 +1102,9 @@ Main solver optional input functions **Notes:** Pass ``hmax = 0`` to obtain the default value :math:`\infty`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_step". + .. c:function:: int IDASetStopTime(void * ida_mem, sunrealtype tstop) The function :c:func:`IDASetStopTime` specifies the value of the independent @@ -1078,6 +1130,9 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`IDAReInit` will remain active but can be disabled by calling :c:func:`IDAClearStopTime`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.stop_time". + .. c:function:: int IDAClearStopTime(void* ida_mem) Disables the stop time set with :c:func:`IDASetStopTime`. @@ -1093,6 +1148,9 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`IDASetStopTime`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.clear_stop_time". + .. versionadded:: 6.5.1 .. c:function:: int IDASetMaxErrTestFails(void * ida_mem, int maxnef) @@ -1112,6 +1170,9 @@ Main solver optional input functions **Notes:** The default value is 10. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_err_test_fails". + .. c:function:: int IDASetSuppressAlg(void * ida_mem, sunbooleantype suppressalg) The function :c:func:`IDASetSuppressAlg` indicates whether or not to suppress @@ -1134,6 +1195,9 @@ Main solver optional input functions 1, whereas it is generally *encouraged* for systems of index 2 or more. See pp. 146-147 of :cite:p:`BCP:96` for more on this issue. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.suppress_alg". + .. c:function:: int IDASetId(void * ida_mem, N_Vector id) The function :c:func:`IDASetId` specifies algebraic/differential components in the @@ -1300,6 +1364,10 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. * ``IDA_SUCCESS`` -- The flag value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.delta_cj_lsetup". + .. versionadded:: 5.2.0 .. c:function:: int IDASetLinearSolutionScaling(void * ida_mem, sunbooleantype onoff) @@ -1324,6 +1392,9 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. initialized through a call to :c:func:`IDASetLinearSolver`. By default scaling is enabled with matrix-based linear solvers. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.linear_solution_scaling". + When using matrix-free linear solver modules, the IDALS solver interface requires a function to compute an approximation to the product between the @@ -1414,6 +1485,9 @@ finite-difference approximation, via a call to :c:func:`IDASetIncrementFactor`. linear solver interface has been initialized through a call to :c:func:`IDASetLinearSolver`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.increment_factor". + .. versionadded:: 3.0.0 Replaces the deprecated function ``IDASpilsSetIncrementFactor``. @@ -1534,6 +1608,9 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default :c:func:`IDASetLinearSolver`. If ``eplifac`` :math:`= 0.0` is passed, the default value is used. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eps_lin". + .. versionadded:: 3.0.0 Replaces the deprecated function ``IDASpilsSetEpsLin``. @@ -1567,6 +1644,9 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default value of ``nrmfac`` was computed using :c:func:`N_VDotProd` i.e., the ``nrmfac < 0`` case. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.ls_norm_factor". + .. _IDAS.Usage.SIM.user_callable.optional_input.nls: @@ -1610,6 +1690,9 @@ nonlinear solver. **Notes:** The default value is 4. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_nonlin_iters". + .. c:function:: int IDASetMaxConvFails(void * ida_mem, int maxncf) @@ -1628,6 +1711,9 @@ nonlinear solver. **Notes:** The default value is 10. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_conv_fails". + .. c:function:: int IDASetNonlinConvCoef(void * ida_mem, sunrealtype nlscoef) @@ -1646,6 +1732,9 @@ nonlinear solver. **Notes:** The default value is 0.33. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.nonlin_conv_coef". + .. c:function:: int IDASetNlsResFn(void * ida_mem, IDAResFn res) @@ -1726,6 +1815,9 @@ to set optional inputs controlling the initial condition calculation. :math:`J^{-1}F(t_0, y, \dot{y})` must be :math:`\leq \mathtt{epiccon}`, where :math:`J` is the system Jacobian. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.nonlin_conv_coef_ic". + .. c:function:: int IDASetMaxNumStepsIC(void * ida_mem, int maxnh) The function :c:func:`IDASetMaxNumStepsIC` specifies the maximum number of steps @@ -1745,6 +1837,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`5`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_steps_ic". + .. c:function:: int IDASetMaxNumJacsIC(void * ida_mem, int maxnj) The function :c:func:`IDASetMaxNumJacsIC` specifies the maximum number of the @@ -1764,6 +1859,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`4`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_jacs_ic". + .. c:function:: int IDASetMaxNumItersIC(void * ida_mem, int maxnit) The function :c:func:`IDASetMaxNumItersIC` specifies the maximum number of Newton @@ -1782,6 +1880,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`10`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_num_iters_ic". + .. c:function:: int IDASetMaxBacksIC(void * ida_mem, int maxbacks) The function :c:func:`IDASetMaxBacksIC` specifies the maximum number of linesearch @@ -1804,6 +1905,9 @@ to set optional inputs controlling the initial condition calculation. the limit ``maxbacks`` applies in the calculation of both the initial state values and the initial sensitivities. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.max_backs_ic". + .. c:function:: int IDASetLineSearchOffIC(void * ida_mem, sunbooleantype lsoff) @@ -1821,7 +1925,10 @@ to set optional inputs controlling the initial condition calculation. **Notes:** - The default value is ``SUNFALSE``. + The default value is ``SUNFALSE``. + + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.linesearch_off_ic". .. c:function:: int IDASetStepToleranceIC(void * ida_mem, int steptol) @@ -1840,6 +1947,9 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`(\text{unit roundoff})^{2/3}`. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.step_tolerance_ic". + .. _IDAS.Usage.SIM.user_callable.optional_input.step_adapt: @@ -1907,6 +2017,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_fixed_step_bounds". + .. versionadded:: 5.2.0 .. c:function:: int IDASetEtaMax(void* ida_mem, sunrealtype eta_max) @@ -1924,6 +2038,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_max". + .. versionadded:: 5.2.0 .. c:function:: int IDASetEtaMin(void* ida_mem, sunrealtype eta_min) @@ -1944,6 +2062,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_min". + .. versionadded:: 5.2.0 .. c:function:: int IDASetEtaLow(void* ida_mem, sunrealtype eta_low) @@ -1964,6 +2086,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_low". + .. versionadded:: 5.2.0 .. c:function:: int IDASetEtaMinErrFail(void* ida_mem, sunrealtype eta_min_ef) @@ -1984,6 +2110,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_min_err_fail". + .. versionadded:: 5.2.0 .. c:function:: int IDASetEtaConvFail(void* ida_mem, sunrealtype eta_cf) @@ -2004,6 +2134,10 @@ step size adaptivity. * ``IDA_SUCCESS`` -- The optional value has been successfully set. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.eta_conv_fail". + .. versionadded:: 5.2.0 @@ -2076,6 +2210,9 @@ rootfinding algorithm. first step), IDAS will issue a warning which can be disabled with this optional input function. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.no_inactive_root_warn". + .. _IDAS.Usage.SIM.user_callable.optional_dky: @@ -3868,6 +4005,9 @@ of quadrature equations. **Notes:** By default, ``errconQ`` is set to ``SUNFALSE``. + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.quad_err_con". + .. warning:: It is illegal to call :c:func:`IDASetQuadErrCon` before a call to :c:func:`IDAQuadInit`. @@ -3890,6 +4030,10 @@ quadrature variables. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. + **Notes:** + This routine will be called by :c:func:`IDASetFromCommandLine` + when using the command-line option "idaid.quad_scalar_tolerances". + .. c:function:: int IDAQuadSVtolerances(void * ida_mem, sunrealtype reltolQ, N_Vector abstolQ) diff --git a/doc/kinsol/guide/source/Usage/index.rst b/doc/kinsol/guide/source/Usage/index.rst index c9de0ca4aa..20c2f314b9 100644 --- a/doc/kinsol/guide/source/Usage/index.rst +++ b/doc/kinsol/guide/source/Usage/index.rst @@ -456,6 +456,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. +========================================================+==================================+==============================+ | **KINSOL main solver** | | | +--------------------------------------------------------+----------------------------------+------------------------------+ + | Set KINSOL optional inputs from the command line | :c:func:`KINSetFromCommandLine` | | + +--------------------------------------------------------+----------------------------------+------------------------------+ | Data for problem-defining function | :c:func:`KINSetUserData` | ``NULL`` | +--------------------------------------------------------+----------------------------------+------------------------------+ | Max. number of nonlinear iterations | :c:func:`KINSetNumMaxIters` | 200 | @@ -519,6 +521,35 @@ negative, so a test ``retval`` :math:`<0` will catch any error. +--------------------------------------------------------+----------------------------------+------------------------------+ +.. c:function:: int KINSetFromCommandLine(void* kin_mem, const char* kinid, int argc, char* argv[]) + + Passes command-line arguments to KINSOL to set options. + + :param kin_mem: pointer to the KINSOL memory block. + :param kinid: String to use as prefix for KINSOL command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :retval KIN_SUCCESS: the function exited successfully. + :retval KIN_MEM_NULL: ``kin_mem`` was ``NULL``. + :retval other: error return value from relevant KINSOL "set" routine. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + These are left unchanged by :c:func:`KINSetFromCommandLine`. + + If the *kinid* argument is ``NULL`` then ``kinsol.`` will be used for all KINSOL command-line + options, e.g., to set the maximum order of accuracy the default command-line option would + be "kinsol.max_order". + + KINSOL options set via command-line arguments to :c:func:`KINSetFromCommandLine` will + overwrite any previously-set values. + + The supported command-line options are documented within each KINSOL "set" routine. + + .. versionadded:: x.y.z + .. c:function:: int KINSetUserData(void * kin_mem, void * user_data) The function :c:func:`KINSetUserData` specifies the pointer to user-defined @@ -560,6 +591,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``mxiter`` is ``MXITER_DEFAULT`` :math:`=200`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.num_max_iters". + .. c:function:: int KINSetNoInitSetup(void * kin_mem, sunbooleantype noInitSetup) @@ -583,6 +617,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. problems, in which the final preconditioner or Jacobian value from one problem is to be used initially for the next problem. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.no_init_setup". + .. c:function:: int KINSetNoResMon(void * kin_mem, sunbooleantype noNNIResMon) @@ -602,6 +639,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. When using a direct solver, the default value for ``noNNIResMon`` is ``SUNFALSE``, meaning that the nonlinear residual will be monitored. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.no_res_mon". + .. warning:: Residual monitoring is only available for use with matrix-based linear solver modules. @@ -647,6 +687,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The value of ``msbset`` (see :c:func:`KINSetMaxSetupCalls`) should be a multiple of ``msbsetsub``. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.max_sub_setup_calls". + .. warning:: Residual monitoring is only available for use with matrix-based linear solver modules. @@ -699,6 +742,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. where :math:`\eta_{\text{min}} = 10^{-4}` and :math:`\eta_{\text{max}} = 0.9`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.eta_form". + .. c:function:: int KINSetEtaConstValue(void * kin_mem, sunrealtype eta) @@ -718,6 +764,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The default value for ``eta`` is :math:`0.1`. The legal values are :math:`0.0 <` ``eta`` :math:`\le 1.0`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.eta_const_value". + .. c:function:: int KINSetEtaParams(void * kin_mem, sunrealtype egamma, sunrealtype ealpha) @@ -740,6 +789,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. :math:`2.0`, respectively. The legal values are :math:`0.0 <` ``egamma`` :math:`\le 1.0` and :math:`1.0<` ``ealpha`` :math:`\le 2.0`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.eta_params". + .. c:function:: int KINSetResMonConstValue(void * kin_mem, sunrealtype omegaconst) @@ -759,6 +811,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The default value for ``omegaconst`` is :math:`0.9`. The legal values are :math:`0.0 <` ``omegaconst`` :math:`< 1.0`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.res_mon_const_value". + .. c:function:: int KINSetResMonParams(void * kin_mem, sunrealtype omegamin, sunrealtype omegamax) @@ -781,6 +836,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. and :math:`0.9`, respectively. The legal values are :math:`0.0 <` ``omegamin`` :math:`<` ``omegamax`` :math:`< 1.0`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.res_mon_params". + .. warning:: Residual monitoring is only available for use with matrix-based linear solver modules. @@ -805,6 +863,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. positive minimum value, equal to :math:`0.01`*``fnormtol``, is applied to :math:`\epsilon` (see :c:func:`KINSetFuncNormTol` below). + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.no_min_eps". + .. c:function:: int KINSetMaxNewtonStep(void * kin_mem, sunrealtype mxnewtstep) @@ -825,6 +886,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The default value of ``mxnewtstep`` is :math:`1000\, \| u_0 \|_{D_u}`, where :math:`u_0` is the initial guess. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.max_newton_step". + .. c:function:: int KINSetMaxBetaFails(void * kin_mem, sunrealtype mxnbcf) @@ -844,6 +908,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value of ``mxnbcf`` is ``MXNBCF_DEFAULT`` :math:`=10`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.max_beta_fails". + .. c:function:: int KINSetRelErrFunc(void * kin_mem, sunrealtype relfunc) @@ -866,6 +933,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``relfunc`` is :math:`U` = unit roundoff. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.rel_err_func". + .. c:function:: int KINSetFuncNormTol(void * kin_mem, sunrealtype fnormtol) @@ -886,6 +956,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``fnormtol`` is (unit roundoff) :math:`^{1/3}`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.func_norm_tol". + .. c:function:: int KINSetScaledStepTol(void * kin_mem, sunrealtype scsteptol) @@ -905,6 +978,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``scsteptol`` is (unit roundoff) :math:`^{2/3}`. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.scaled_step_tol". + .. c:function:: int KINSetConstraints(void * kin_mem, N_Vector constraints) @@ -974,6 +1050,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value of ``ret_newest`` is ``SUNFALSE``. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.return_newest". + .. c:function:: int KINSetDamping(void * kin_mem, sunrealtype beta) @@ -1001,6 +1080,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. ``beta`` is extremely small (close to zero), this can lead to an excessively tight tolerance. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.damping". + .. c:function:: int KINSetMAA(void * kin_mem, long int maa) @@ -1026,6 +1108,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. call should be made before the call to KINSetMAA, as the latter uses the value of ``mxiter``. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.m_aa". + .. c:function:: int KINSetDampingAA(void * kin_mem, sunrealtype beta) @@ -1052,6 +1137,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. value provided to :c:func:`KINSetDampingAA` is applied to all iterations and any value provided to :c:func:`KINSetDamping` is ignored. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.damping_aa". + .. c:function:: int KINSetDelayAA(void * kin_mem, long int delay) @@ -1070,6 +1158,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value of ``delay`` is 0, indicating no delay. + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.delay_aa". + .. c:function:: int KINSetOrthAA(void* kin_mem, int orthaa) @@ -1101,6 +1192,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. An example of how to use this function can be found in ``examples/kinsol/serial/kinAnalytic_fp.c`` + This routine will be called by :c:func:`KINSetFromCommandLine` + when using the command-line option "kinid.orth_aa". .. _KINSOL.Usage.CC.optional_inputs.optin_ls: @@ -1453,7 +1546,7 @@ functions are described next. .. versionadded:: 6.3.0 -.. c:function:: int KINPrintAllStats(void* cvode_mem, FILE* outfile, SUNOutputFormat fmt) +.. c:function:: int KINPrintAllStats(void* kin_mem, FILE* outfile, SUNOutputFormat fmt) The function :c:func:`KINPrintAllStats` outputs all of the nonlinear solver, linear solver, and other statistics. diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index ad707655f6..7482d13ef9 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -643,11 +643,10 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); - static struct sunKeyActionPair action_pairs[] = {{"set_explicit", - ARKStepSetExplicit}, - {"set_implicit", - ARKStepSetImplicit}, - {"set_imex", ARKStepSetImEx}}; + static struct sunKeyActionPair action_pairs[] = { + {"set_explicit", ARKStepSetExplicit}, + {"set_implicit", ARKStepSetImplicit}, + {"set_imex", ARKStepSetImEx}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); /* check all "twochar" command-line options */ diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 97fa64e06d..247e50df8f 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -43,68 +43,66 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, ark_mem = (ARKodeMem)arkode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = - {{"order", ARKodeSetOrder}, - {"interpolant_degree", ARKodeSetInterpolantDegree}, - {"linear", ARKodeSetLinear}, - {"autonomous", ARKodeSetAutonomous}, - {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, - {"lsetup_frequency", ARKodeSetLSetupFrequency}, - {"predictor_method", ARKodeSetPredictorMethod}, - {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, - {"max_hnil_warns", ARKodeSetMaxHnilWarns}, - {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, - {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, - {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, - {"small_num_efails", ARKodeSetSmallNumEFails}, - {"max_err_test_fails", ARKodeSetMaxErrTestFails}, - {"max_conv_fails", ARKodeSetMaxConvFails}, - {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; + static struct sunKeyIntPair int_pairs[] = { + {"order", ARKodeSetOrder}, + {"interpolant_degree", ARKodeSetInterpolantDegree}, + {"linear", ARKodeSetLinear}, + {"autonomous", ARKodeSetAutonomous}, + {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, + {"lsetup_frequency", ARKodeSetLSetupFrequency}, + {"predictor_method", ARKodeSetPredictorMethod}, + {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, + {"max_hnil_warns", ARKodeSetMaxHnilWarns}, + {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, + {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, + {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, + {"small_num_efails", ARKodeSetSmallNumEFails}, + {"max_err_test_fails", ARKodeSetMaxErrTestFails}, + {"max_conv_fails", ARKodeSetMaxConvFails}, + {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = {{"max_num_steps", - ARKodeSetMaxNumSteps}, - {"jac_eval_frequency", - ARKodeSetJacEvalFrequency}}; + static struct sunKeyLongPair long_pairs[] = { + {"max_num_steps", ARKodeSetMaxNumSteps}, + {"jac_eval_frequency", ARKodeSetJacEvalFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = - {{"nonlin_crdown", ARKodeSetNonlinCRDown}, - {"nonlin_rdiv", ARKodeSetNonlinRDiv}, - {"delta_gamma_max", ARKodeSetDeltaGammaMax}, - {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, - {"init_step", ARKodeSetInitStep}, - {"min_step", ARKodeSetMinStep}, - {"max_step", ARKodeSetMaxStep}, - {"stop_time", ARKodeSetStopTime}, - {"fixed_step", ARKodeSetFixedStep}, - {"step_direction", ARKodeSetStepDirection}, - {"cfl_fraction", ARKodeSetCFLFraction}, - {"safety_factor", ARKodeSetSafetyFactor}, - {"error_bias", ARKodeSetErrorBias}, - {"max_growth", ARKodeSetMaxGrowth}, - {"min_reduction", ARKodeSetMinReduction}, - {"max_first_growth", ARKodeSetMaxFirstGrowth}, - {"max_efail_growth", ARKodeSetMaxEFailGrowth}, - {"max_cfail_growth", ARKodeSetMaxCFailGrowth}, - {"eps_lin", ARKodeSetEpsLin}, - {"mass_eps_lin", ARKodeSetMassEpsLin}, - {"ls_norm_factor", ARKodeSetLSNormFactor}, - {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; + static struct sunKeyRealPair real_pairs[] = { + {"nonlin_crdown", ARKodeSetNonlinCRDown}, + {"nonlin_rdiv", ARKodeSetNonlinRDiv}, + {"delta_gamma_max", ARKodeSetDeltaGammaMax}, + {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, + {"init_step", ARKodeSetInitStep}, + {"min_step", ARKodeSetMinStep}, + {"max_step", ARKodeSetMaxStep}, + {"stop_time", ARKodeSetStopTime}, + {"fixed_step", ARKodeSetFixedStep}, + {"step_direction", ARKodeSetStepDirection}, + {"cfl_fraction", ARKodeSetCFLFraction}, + {"safety_factor", ARKodeSetSafetyFactor}, + {"error_bias", ARKodeSetErrorBias}, + {"max_growth", ARKodeSetMaxGrowth}, + {"min_reduction", ARKodeSetMinReduction}, + {"max_first_growth", ARKodeSetMaxFirstGrowth}, + {"max_efail_growth", ARKodeSetMaxEFailGrowth}, + {"max_cfail_growth", ARKodeSetMaxCFailGrowth}, + {"eps_lin", ARKodeSetEpsLin}, + {"mass_eps_lin", ARKodeSetMassEpsLin}, + {"ls_norm_factor", ARKodeSetLSNormFactor}, + {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", - ARKodeSStolerances}, - {"fixed_step_bounds", - ARKodeSetFixedStepBounds}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"scalar_tolerances", ARKodeSStolerances}, + {"fixed_step_bounds", ARKodeSetFixedStepBounds}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = - {{"nonlinear", ARKodeSetNonlinear}, - {"clear_stop_time", ARKodeClearStopTime}, - {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, - {"reset_accumulated_error", ARKodeResetAccumulatedError}}; + static struct sunKeyActionPair action_pairs[] = { + {"nonlinear", ARKodeSetNonlinear}, + {"clear_stop_time", ARKodeClearStopTime}, + {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, + {"reset_accumulated_error", ARKodeResetAccumulatedError}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index c096f0002e..2646952ff7 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -501,20 +501,18 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = {{"sts_method", - LSRKStepSetSTSMethodByName}, - {"ssp_method", - LSRKStepSetSSPMethodByName}}; + static struct sunKeyCharPair char_pairs[] = { + {"sts_method", LSRKStepSetSTSMethodByName}, + {"ssp_method", LSRKStepSetSSPMethodByName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); static struct sunKeyLongPair long_pairs[] = { {"dom_eig_frequency", LSRKStepSetDomEigFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyIntPair int_pairs[] = {{"max_num_stages", - LSRKStepSetMaxNumStages}, - {"num_ssp_stages", - LSRKStepSetNumSSPStages}}; + static struct sunKeyIntPair int_pairs[] = { + {"max_num_stages", LSRKStepSetMaxNumStages}, + {"num_ssp_stages", LSRKStepSetNumSSPStages}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyRealPair real_pairs[] = { diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 5081ef6990..7b62e4d12e 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -43,62 +43,60 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, cv_mem = (CVodeMem)cvode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = - {{"max_conv_fails", CVodeSetMaxConvFails}, - {"max_err_test_fails", CVodeSetMaxErrTestFails}, - {"max_hnil_warns", CVodeSetMaxHnilWarns}, - {"max_nonlin_iters", CVodeSetMaxNonlinIters}, - {"max_order", CVodeSetMaxOrd}, - {"stab_lim_det", CVodeSetStabLimDet}, - {"interpolate_stop_time", CVodeSetInterpolateStopTime}, - {"use_integrator_fused_kernels", CVodeSetUseIntegratorFusedKernels}, - {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, - {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, - {"proj_err_est", CVodeSetProjErrEst}, - {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; + static struct sunKeyIntPair int_pairs[] = { + {"max_conv_fails", CVodeSetMaxConvFails}, + {"max_err_test_fails", CVodeSetMaxErrTestFails}, + {"max_hnil_warns", CVodeSetMaxHnilWarns}, + {"max_nonlin_iters", CVodeSetMaxNonlinIters}, + {"max_order", CVodeSetMaxOrd}, + {"stab_lim_det", CVodeSetStabLimDet}, + {"interpolate_stop_time", CVodeSetInterpolateStopTime}, + {"use_integrator_fused_kernels", CVodeSetUseIntegratorFusedKernels}, + {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, + {"proj_err_est", CVodeSetProjErrEst}, + {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = - {{"lsetup_frequency", CVodeSetLSetupFrequency}, - {"max_num_steps", CVodeSetMaxNumSteps}, - {"monitor_frequency", CVodeSetMonitorFrequency}, - {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, - {"jac_eval_frequency", CVodeSetJacEvalFrequency}, - {"proj_frequency", CVodeSetProjFrequency}}; + static struct sunKeyLongPair long_pairs[] = { + {"lsetup_frequency", CVodeSetLSetupFrequency}, + {"max_num_steps", CVodeSetMaxNumSteps}, + {"monitor_frequency", CVodeSetMonitorFrequency}, + {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, + {"jac_eval_frequency", CVodeSetJacEvalFrequency}, + {"proj_frequency", CVodeSetProjFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = - {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, - {"init_step", CVodeSetInitStep}, - {"max_step", CVodeSetMaxStep}, - {"min_step", CVodeSetMinStep}, - {"stop_time", CVodeSetStopTime}, - {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, - {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, - {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, - {"eta_max", CVodeSetEtaMax}, - {"eta_min", CVodeSetEtaMin}, - {"eta_min_err_fail", CVodeSetEtaMinErrFail}, - {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, - {"eta_conv_fail", CVodeSetEtaConvFail}, - {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, - {"eps_lin", CVodeSetEpsLin}, - {"ls_norm_factor", CVodeSetLSNormFactor}, - {"eps_proj", CVodeSetEpsProj}, - {"proj_fail_eta", CVodeSetProjFailEta}}; + static struct sunKeyRealPair real_pairs[] = { + {"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {"init_step", CVodeSetInitStep}, + {"max_step", CVodeSetMaxStep}, + {"min_step", CVodeSetMinStep}, + {"stop_time", CVodeSetStopTime}, + {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, + {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, + {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, + {"eta_max", CVodeSetEtaMax}, + {"eta_min", CVodeSetEtaMin}, + {"eta_min_err_fail", CVodeSetEtaMinErrFail}, + {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, + {"eta_conv_fail", CVodeSetEtaConvFail}, + {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, + {"eps_lin", CVodeSetEpsLin}, + {"ls_norm_factor", CVodeSetLSNormFactor}, + {"eps_proj", CVodeSetEpsProj}, + {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", - CVodeSetEtaFixedStepBounds}, - {"scalar_tolerances", - CVodeSStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", CVodeSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", - CVodeClearStopTime}, - {"no_inactive_root_warn", - CVodeSetNoInactiveRootWarn}}; + static struct sunKeyActionPair action_pairs[] = { + {"clear_stop_time", CVodeClearStopTime}, + {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index f8823aa17a..ecf9362836 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -98,7 +98,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, sizeof(*tworeal_pairs); static struct sunKeyTwoIntPair twoint_pairs[] = - {{"max_ord_b", CVodeSetMaxOrdB}, + {{"max_order_b", CVodeSetMaxOrdB}, {"stab_lim_det_b", CVodeSetStabLimDetB}, {"quad_err_con_b", CVodeSetQuadErrConB}, {"linear_solution_scaling_b", CVodeSetLinearSolutionScalingB}}; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 7a3d071684..a5731c74b3 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -42,54 +42,52 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDA_mem = (IDAMem)ida_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = - {{"max_num_steps_ic", IDASetMaxNumStepsIC}, - {"max_num_jacs_ic", IDASetMaxNumJacsIC}, - {"max_num_iters_ic", IDASetMaxNumItersIC}, - {"linesearch_off_ic", IDASetLineSearchOffIC}, - {"max_backs_ic", IDASetMaxBacksIC}, - {"max_order", IDASetMaxOrd}, - {"max_err_test_fails", IDASetMaxErrTestFails}, - {"suppress_alg", IDASetSuppressAlg}, - {"max_conv_fails", IDASetMaxConvFails}, - {"max_nonlin_iters", IDASetMaxNonlinIters}, - {"linear_solution_scaling", IDASetLinearSolutionScaling}}; + static struct sunKeyIntPair int_pairs[] = { + {"max_num_steps_ic", IDASetMaxNumStepsIC}, + {"max_num_jacs_ic", IDASetMaxNumJacsIC}, + {"max_num_iters_ic", IDASetMaxNumItersIC}, + {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"max_backs_ic", IDASetMaxBacksIC}, + {"max_order", IDASetMaxOrd}, + {"max_err_test_fails", IDASetMaxErrTestFails}, + {"suppress_alg", IDASetSuppressAlg}, + {"max_conv_fails", IDASetMaxConvFails}, + {"max_nonlin_iters", IDASetMaxNonlinIters}, + {"linear_solution_scaling", IDASetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = { {"max_num_steps", IDASetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = - {{"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, - {"step_tolerance_ic", IDASetStepToleranceIC}, - {"delta_cj_lsetup", IDASetDeltaCjLSetup}, - {"init_step", IDASetInitStep}, - {"max_step", IDASetMaxStep}, - {"min_step", IDASetMinStep}, - {"stop_time", IDASetStopTime}, - {"eta_min", IDASetEtaMin}, - {"eta_max", IDASetEtaMax}, - {"eta_low", IDASetEtaLow}, - {"eta_min_err_fail", IDASetEtaMinErrFail}, - {"eta_conv_fail", IDASetEtaConvFail}, - {"nonlin_conv_coef", IDASetNonlinConvCoef}, - {"eps_lin", IDASetEpsLin}, - {"ls_norm_factor", IDASetLSNormFactor}, - {"increment_factor", IDASetIncrementFactor}}; + static struct sunKeyRealPair real_pairs[] = { + {"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, + {"step_tolerance_ic", IDASetStepToleranceIC}, + {"delta_cj_lsetup", IDASetDeltaCjLSetup}, + {"init_step", IDASetInitStep}, + {"max_step", IDASetMaxStep}, + {"min_step", IDASetMinStep}, + {"stop_time", IDASetStopTime}, + {"eta_min", IDASetEtaMin}, + {"eta_max", IDASetEtaMax}, + {"eta_low", IDASetEtaLow}, + {"eta_min_err_fail", IDASetEtaMinErrFail}, + {"eta_conv_fail", IDASetEtaConvFail}, + {"nonlin_conv_coef", IDASetNonlinConvCoef}, + {"eps_lin", IDASetEpsLin}, + {"ls_norm_factor", IDASetLSNormFactor}, + {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", - IDASetEtaFixedStepBounds}, - {"scalar_tolerances", - IDASStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static struct sunKeyTwoRealPair tworeal_pairs[] = { + {"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, + {"scalar_tolerances", IDASStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", - IDAClearStopTime}, - {"no_inactive_root_warn", - IDASetNoInactiveRootWarn}}; + static struct sunKeyActionPair action_pairs[] = { + {"clear_stop_time", IDAClearStopTime}, + {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 25a6cae78c..57c54fb460 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -91,7 +91,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, sizeof(*tworeal_pairs); static struct sunKeyTwoIntPair twoint_pairs[] = - {{"max_ord_b", IDASetMaxOrdB}, + {{"max_order_b", IDASetMaxOrdB}, {"suppress_alg_b", IDASetSuppressAlgB}, {"quad_err_con_b", IDASetQuadErrConB}, {"linear_solution_scaling_b", IDASetLinearSolutionScalingB}}; diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 865c6f5489..bd96afe5d5 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -41,12 +41,13 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ kin_mem = (KINMem)kinmem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = {{"orth_aa", KINSetOrthAA}, - {"return_newest", KINSetReturnNewest}, - {"no_init_setup", KINSetNoInitSetup}, - {"no_res_mon", KINSetNoResMon}, - {"eta_form", KINSetEtaForm}, - {"no_min_eps", KINSetNoMinEps}}; + static struct sunKeyIntPair int_pairs[] = + {{"orth_aa", KINSetOrthAA}, + {"return_newest", KINSetReturnNewest}, + {"no_init_setup", KINSetNoInitSetup}, + {"no_res_mon", KINSetNoResMon}, + {"eta_form", KINSetEtaForm}, + {"no_min_eps", KINSetNoMinEps}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = @@ -70,7 +71,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); static struct sunKeyTwoRealPair tworeal_pairs[] = - {{"eta_params", KINSetEtaParams}, {"res_mon_params", KINSetResMonParams}}; + {{"eta_params", KINSetEtaParams}, + {"res_mon_params", KINSetResMonParams}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); From 5793e297bcc9d636d64d43e7795db1884d0ea6a8 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 25 Mar 2025 08:52:12 -0500 Subject: [PATCH 055/114] Formatting --- src/arkode/arkode_arkstep_io.c | 9 +- src/arkode/arkode_cli.c | 106 ++++++------- src/arkode/arkode_lsrkstep_io.c | 14 +- src/cvode/cvode_cli.c | 94 ++++++------ src/ida/ida_cli.c | 259 ++++++++++++++++---------------- src/kinsol/kinsol_cli.c | 16 +- 6 files changed, 254 insertions(+), 244 deletions(-) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 7482d13ef9..ad707655f6 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -643,10 +643,11 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); - static struct sunKeyActionPair action_pairs[] = { - {"set_explicit", ARKStepSetExplicit}, - {"set_implicit", ARKStepSetImplicit}, - {"set_imex", ARKStepSetImEx}}; + static struct sunKeyActionPair action_pairs[] = {{"set_explicit", + ARKStepSetExplicit}, + {"set_implicit", + ARKStepSetImplicit}, + {"set_imex", ARKStepSetImEx}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); /* check all "twochar" command-line options */ diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 247e50df8f..97fa64e06d 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -43,66 +43,68 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, ark_mem = (ARKodeMem)arkode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"order", ARKodeSetOrder}, - {"interpolant_degree", ARKodeSetInterpolantDegree}, - {"linear", ARKodeSetLinear}, - {"autonomous", ARKodeSetAutonomous}, - {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, - {"lsetup_frequency", ARKodeSetLSetupFrequency}, - {"predictor_method", ARKodeSetPredictorMethod}, - {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, - {"max_hnil_warns", ARKodeSetMaxHnilWarns}, - {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, - {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, - {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, - {"small_num_efails", ARKodeSetSmallNumEFails}, - {"max_err_test_fails", ARKodeSetMaxErrTestFails}, - {"max_conv_fails", ARKodeSetMaxConvFails}, - {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; + static struct sunKeyIntPair int_pairs[] = + {{"order", ARKodeSetOrder}, + {"interpolant_degree", ARKodeSetInterpolantDegree}, + {"linear", ARKodeSetLinear}, + {"autonomous", ARKodeSetAutonomous}, + {"deduce_implicit_rhs", ARKodeSetDeduceImplicitRhs}, + {"lsetup_frequency", ARKodeSetLSetupFrequency}, + {"predictor_method", ARKodeSetPredictorMethod}, + {"max_nonlin_iters", ARKodeSetMaxNonlinIters}, + {"max_hnil_warns", ARKodeSetMaxHnilWarns}, + {"interpolate_stop_time", ARKodeSetInterpolateStopTime}, + {"max_num_constr_fails", ARKodeSetMaxNumConstrFails}, + {"adaptivity_adjustment", ARKodeSetAdaptivityAdjustment}, + {"small_num_efails", ARKodeSetSmallNumEFails}, + {"max_err_test_fails", ARKodeSetMaxErrTestFails}, + {"max_conv_fails", ARKodeSetMaxConvFails}, + {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { - {"max_num_steps", ARKodeSetMaxNumSteps}, - {"jac_eval_frequency", ARKodeSetJacEvalFrequency}}; + static struct sunKeyLongPair long_pairs[] = {{"max_num_steps", + ARKodeSetMaxNumSteps}, + {"jac_eval_frequency", + ARKodeSetJacEvalFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"nonlin_crdown", ARKodeSetNonlinCRDown}, - {"nonlin_rdiv", ARKodeSetNonlinRDiv}, - {"delta_gamma_max", ARKodeSetDeltaGammaMax}, - {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, - {"init_step", ARKodeSetInitStep}, - {"min_step", ARKodeSetMinStep}, - {"max_step", ARKodeSetMaxStep}, - {"stop_time", ARKodeSetStopTime}, - {"fixed_step", ARKodeSetFixedStep}, - {"step_direction", ARKodeSetStepDirection}, - {"cfl_fraction", ARKodeSetCFLFraction}, - {"safety_factor", ARKodeSetSafetyFactor}, - {"error_bias", ARKodeSetErrorBias}, - {"max_growth", ARKodeSetMaxGrowth}, - {"min_reduction", ARKodeSetMinReduction}, - {"max_first_growth", ARKodeSetMaxFirstGrowth}, - {"max_efail_growth", ARKodeSetMaxEFailGrowth}, - {"max_cfail_growth", ARKodeSetMaxCFailGrowth}, - {"eps_lin", ARKodeSetEpsLin}, - {"mass_eps_lin", ARKodeSetMassEpsLin}, - {"ls_norm_factor", ARKodeSetLSNormFactor}, - {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; + static struct sunKeyRealPair real_pairs[] = + {{"nonlin_crdown", ARKodeSetNonlinCRDown}, + {"nonlin_rdiv", ARKodeSetNonlinRDiv}, + {"delta_gamma_max", ARKodeSetDeltaGammaMax}, + {"nonlin_conv_coef", ARKodeSetNonlinConvCoef}, + {"init_step", ARKodeSetInitStep}, + {"min_step", ARKodeSetMinStep}, + {"max_step", ARKodeSetMaxStep}, + {"stop_time", ARKodeSetStopTime}, + {"fixed_step", ARKodeSetFixedStep}, + {"step_direction", ARKodeSetStepDirection}, + {"cfl_fraction", ARKodeSetCFLFraction}, + {"safety_factor", ARKodeSetSafetyFactor}, + {"error_bias", ARKodeSetErrorBias}, + {"max_growth", ARKodeSetMaxGrowth}, + {"min_reduction", ARKodeSetMinReduction}, + {"max_first_growth", ARKodeSetMaxFirstGrowth}, + {"max_efail_growth", ARKodeSetMaxEFailGrowth}, + {"max_cfail_growth", ARKodeSetMaxCFailGrowth}, + {"eps_lin", ARKodeSetEpsLin}, + {"mass_eps_lin", ARKodeSetMassEpsLin}, + {"ls_norm_factor", ARKodeSetLSNormFactor}, + {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"scalar_tolerances", ARKodeSStolerances}, - {"fixed_step_bounds", ARKodeSetFixedStepBounds}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", + ARKodeSStolerances}, + {"fixed_step_bounds", + ARKodeSetFixedStepBounds}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = { - {"nonlinear", ARKodeSetNonlinear}, - {"clear_stop_time", ARKodeClearStopTime}, - {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, - {"reset_accumulated_error", ARKodeResetAccumulatedError}}; + static struct sunKeyActionPair action_pairs[] = + {{"nonlinear", ARKodeSetNonlinear}, + {"clear_stop_time", ARKodeClearStopTime}, + {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, + {"reset_accumulated_error", ARKodeResetAccumulatedError}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 2646952ff7..c096f0002e 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -501,18 +501,20 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = { - {"sts_method", LSRKStepSetSTSMethodByName}, - {"ssp_method", LSRKStepSetSSPMethodByName}}; + static struct sunKeyCharPair char_pairs[] = {{"sts_method", + LSRKStepSetSTSMethodByName}, + {"ssp_method", + LSRKStepSetSSPMethodByName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); static struct sunKeyLongPair long_pairs[] = { {"dom_eig_frequency", LSRKStepSetDomEigFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyIntPair int_pairs[] = { - {"max_num_stages", LSRKStepSetMaxNumStages}, - {"num_ssp_stages", LSRKStepSetNumSSPStages}}; + static struct sunKeyIntPair int_pairs[] = {{"max_num_stages", + LSRKStepSetMaxNumStages}, + {"num_ssp_stages", + LSRKStepSetNumSSPStages}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyRealPair real_pairs[] = { diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 7b62e4d12e..5081ef6990 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -43,60 +43,62 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, cv_mem = (CVodeMem)cvode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"max_conv_fails", CVodeSetMaxConvFails}, - {"max_err_test_fails", CVodeSetMaxErrTestFails}, - {"max_hnil_warns", CVodeSetMaxHnilWarns}, - {"max_nonlin_iters", CVodeSetMaxNonlinIters}, - {"max_order", CVodeSetMaxOrd}, - {"stab_lim_det", CVodeSetStabLimDet}, - {"interpolate_stop_time", CVodeSetInterpolateStopTime}, - {"use_integrator_fused_kernels", CVodeSetUseIntegratorFusedKernels}, - {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, - {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, - {"proj_err_est", CVodeSetProjErrEst}, - {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; + static struct sunKeyIntPair int_pairs[] = + {{"max_conv_fails", CVodeSetMaxConvFails}, + {"max_err_test_fails", CVodeSetMaxErrTestFails}, + {"max_hnil_warns", CVodeSetMaxHnilWarns}, + {"max_nonlin_iters", CVodeSetMaxNonlinIters}, + {"max_order", CVodeSetMaxOrd}, + {"stab_lim_det", CVodeSetStabLimDet}, + {"interpolate_stop_time", CVodeSetInterpolateStopTime}, + {"use_integrator_fused_kernels", CVodeSetUseIntegratorFusedKernels}, + {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, + {"proj_err_est", CVodeSetProjErrEst}, + {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { - {"lsetup_frequency", CVodeSetLSetupFrequency}, - {"max_num_steps", CVodeSetMaxNumSteps}, - {"monitor_frequency", CVodeSetMonitorFrequency}, - {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, - {"jac_eval_frequency", CVodeSetJacEvalFrequency}, - {"proj_frequency", CVodeSetProjFrequency}}; + static struct sunKeyLongPair long_pairs[] = + {{"lsetup_frequency", CVodeSetLSetupFrequency}, + {"max_num_steps", CVodeSetMaxNumSteps}, + {"monitor_frequency", CVodeSetMonitorFrequency}, + {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, + {"jac_eval_frequency", CVodeSetJacEvalFrequency}, + {"proj_frequency", CVodeSetProjFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, - {"init_step", CVodeSetInitStep}, - {"max_step", CVodeSetMaxStep}, - {"min_step", CVodeSetMinStep}, - {"stop_time", CVodeSetStopTime}, - {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, - {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, - {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, - {"eta_max", CVodeSetEtaMax}, - {"eta_min", CVodeSetEtaMin}, - {"eta_min_err_fail", CVodeSetEtaMinErrFail}, - {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, - {"eta_conv_fail", CVodeSetEtaConvFail}, - {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, - {"eps_lin", CVodeSetEpsLin}, - {"ls_norm_factor", CVodeSetLSNormFactor}, - {"eps_proj", CVodeSetEpsProj}, - {"proj_fail_eta", CVodeSetProjFailEta}}; + static struct sunKeyRealPair real_pairs[] = + {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {"init_step", CVodeSetInitStep}, + {"max_step", CVodeSetMaxStep}, + {"min_step", CVodeSetMinStep}, + {"stop_time", CVodeSetStopTime}, + {"nonlin_conv_coef", CVodeSetNonlinConvCoef}, + {"eta_max_first_step", CVodeSetEtaMaxFirstStep}, + {"eta_max_early_step", CVodeSetEtaMaxEarlyStep}, + {"eta_max", CVodeSetEtaMax}, + {"eta_min", CVodeSetEtaMin}, + {"eta_min_err_fail", CVodeSetEtaMinErrFail}, + {"eta_max_err_fail", CVodeSetEtaMaxErrFail}, + {"eta_conv_fail", CVodeSetEtaConvFail}, + {"delta_gamma_max_bad_jac", CVodeSetDeltaGammaMaxBadJac}, + {"eps_lin", CVodeSetEpsLin}, + {"ls_norm_factor", CVodeSetLSNormFactor}, + {"eps_proj", CVodeSetEpsProj}, + {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, - {"scalar_tolerances", CVodeSStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", + CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", + CVodeSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = { - {"clear_stop_time", CVodeClearStopTime}, - {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; + static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + CVodeClearStopTime}, + {"no_inactive_root_warn", + CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index a5731c74b3..7ffd889ea8 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -42,162 +42,167 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDA_mem = (IDAMem)ida_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = { - {"max_num_steps_ic", IDASetMaxNumStepsIC}, - {"max_num_jacs_ic", IDASetMaxNumJacsIC}, - {"max_num_iters_ic", IDASetMaxNumItersIC}, - {"linesearch_off_ic", IDASetLineSearchOffIC}, - {"max_backs_ic", IDASetMaxBacksIC}, - {"max_order", IDASetMaxOrd}, - {"max_err_test_fails", IDASetMaxErrTestFails}, - {"suppress_alg", IDASetSuppressAlg}, - {"max_conv_fails", IDASetMaxConvFails}, - {"max_nonlin_iters", IDASetMaxNonlinIters}, - {"linear_solution_scaling", IDASetLinearSolutionScaling}}; + static struct sunKeyIntPair int_pairs[] = + {{"max_num_steps_ic", IDASetMaxNumStepsIC}, + {"max_num_jacs_ic", IDASetMaxNumJacsIC}, + {"max_num_iters_ic", IDASetMaxNumItersIC}, + {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"max_backs_ic", IDASetMaxBacksIC}, + {"max_order", IDASetMaxOrd}, + {"max_err_test_fails", IDASetMaxErrTestFails}, + {"suppress_alg", IDASetSuppressAlg}, + {"max_conv_fails", IDASetMaxConvFails}, + {"max_nonlin_iters", IDASetMaxNonlinIters}, + {"linear_solution_scaling", IDASetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = { {"max_num_steps", IDASetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = { - {"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, - {"step_tolerance_ic", IDASetStepToleranceIC}, - {"delta_cj_lsetup", IDASetDeltaCjLSetup}, - {"init_step", IDASetInitStep}, - {"max_step", IDASetMaxStep}, - {"min_step", IDASetMinStep}, - {"stop_time", IDASetStopTime}, - {"eta_min", IDASetEtaMin}, - {"eta_max", IDASetEtaMax}, - {"eta_low", IDASetEtaLow}, - {"eta_min_err_fail", IDASetEtaMinErrFail}, - {"eta_conv_fail", IDASetEtaConvFail}, - {"nonlin_conv_coef", IDASetNonlinConvCoef}, - {"eps_lin", IDASetEpsLin}, - {"ls_norm_factor", IDASetLSNormFactor}, - {"increment_factor", IDASetIncrementFactor}}; + static struct sunKeyRealPair real_pairs[] = + {{"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, + {"step_tolerance_ic", IDASetStepToleranceIC}, + {"delta_cj_lsetup", IDASetDeltaCjLSetup}, + {"init_step", IDASetInitStep}, + {"max_step", IDASetMaxStep}, + {"min_step", IDASetMinStep}, + {"stop_time", IDASetStopTime}, + {"eta_min", IDASetEtaMin}, + {"eta_max", IDASetEtaMax}, + {"eta_low", IDASetEtaLow}, + {"eta_min_err_fail", IDASetEtaMinErrFail}, + {"eta_conv_fail", IDASetEtaConvFail}, + {"nonlin_conv_coef", IDASetNonlinConvCoef}, + {"eps_lin", IDASetEpsLin}, + {"ls_norm_factor", IDASetLSNormFactor}, + {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = { - {"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, - {"scalar_tolerances", IDASStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / - sizeof(*tworeal_pairs); + static struct sunKeyTwoRealPair tworeal_pairs[] = {"eta_fixed_step_bounds", + IDASetEtaFixedStepBounds}, + { + "scalar_tolerances", IDASStolerances + } +}; - static struct sunKeyActionPair action_pairs[] = { - {"clear_stop_time", IDAClearStopTime}, - {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; - static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); +static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); - int i, j, retval; - for (i = 1; i < argc; i++) - { - sunbooleantype arg_used = SUNFALSE; +static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + IDAClearStopTime}, + {"no_inactive_root_warn", + IDASetNoInactiveRootWarn}}; +static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - /* if idaid is supplied, skip command-line arguments that do not begin with idaid; +int i, j, retval; +for (i = 1; i < argc; i++) +{ + sunbooleantype arg_used = SUNFALSE; + + /* if idaid is supplied, skip command-line arguments that do not begin with idaid; else, skip command-line arguments that do not begin with "ida." */ - size_t offset; - if (strlen(idaid) > 0) - { - if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } - offset = strlen(idaid) + 1; - } - else - { - static const char* prefix = "ida."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + size_t offset; + if (strlen(idaid) > 0) + { + if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } + offset = strlen(idaid) + 1; + } + else + { + static const char* prefix = "ida."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } - /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) + { + retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) { - retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) - { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } - if (arg_used) continue; + if (arg_used) break; + } + if (arg_used) continue; - /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) + { + retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) { - retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) - { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } - if (arg_used) continue; + if (arg_used) break; + } + if (arg_used) continue; - /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) + { + retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) { - retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) - { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } - if (arg_used) continue; + if (arg_used) break; + } + if (arg_used) continue; - /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) + { + retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) { - retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) - { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } - if (arg_used) continue; + if (arg_used) break; + } + if (arg_used) continue; - /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) + { + retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) { - retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); - if (retval != IDA_SUCCESS) - { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (arg_used) break; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } - if (arg_used) continue; - - /* warn for uninterpreted idaid.X arguments */ - IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + if (arg_used) break; } + if (arg_used) continue; + + /* warn for uninterpreted idaid.X arguments */ + IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); +} - return (IDA_SUCCESS); +return (IDA_SUCCESS); } /*=============================================================== diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index bd96afe5d5..865c6f5489 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -41,13 +41,12 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ kin_mem = (KINMem)kinmem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = - {{"orth_aa", KINSetOrthAA}, - {"return_newest", KINSetReturnNewest}, - {"no_init_setup", KINSetNoInitSetup}, - {"no_res_mon", KINSetNoResMon}, - {"eta_form", KINSetEtaForm}, - {"no_min_eps", KINSetNoMinEps}}; + static struct sunKeyIntPair int_pairs[] = {{"orth_aa", KINSetOrthAA}, + {"return_newest", KINSetReturnNewest}, + {"no_init_setup", KINSetNoInitSetup}, + {"no_res_mon", KINSetNoResMon}, + {"eta_form", KINSetEtaForm}, + {"no_min_eps", KINSetNoMinEps}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static struct sunKeyLongPair long_pairs[] = @@ -71,8 +70,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); static struct sunKeyTwoRealPair tworeal_pairs[] = - {{"eta_params", KINSetEtaParams}, - {"res_mon_params", KINSetResMonParams}}; + {{"eta_params", KINSetEtaParams}, {"res_mon_params", KINSetResMonParams}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); From e8dad9811c7a1b140c0689ed1d1efdbc8a85f7cf Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 25 Mar 2025 09:01:32 -0500 Subject: [PATCH 056/114] Fixed quotation marks --- doc/arkode/guide/source/Usage/User_callable.rst | 2 +- doc/cvode/guide/source/Usage/index.rst | 2 +- doc/cvodes/guide/source/Usage/SIM.rst | 2 +- doc/ida/guide/source/Usage/index.rst | 2 +- doc/idas/guide/source/Usage/SIM.rst | 2 +- doc/kinsol/guide/source/Usage/index.rst | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 49702c3cef..ad49d1c586 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -927,7 +927,7 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. These + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`ARKodeSetFromCommandLine`. If the *arkid* argument is ``NULL`` then ``arkode.`` will be used for all ARKODE command-line diff --git a/doc/cvode/guide/source/Usage/index.rst b/doc/cvode/guide/source/Usage/index.rst index a61e50b055..460f09d042 100644 --- a/doc/cvode/guide/source/Usage/index.rst +++ b/doc/cvode/guide/source/Usage/index.rst @@ -887,7 +887,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`CVodeSetFromCommandLine`. If the *cvid* argument is ``NULL`` then ``cvode.`` will be used for all CVODE command-line diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index efbd33483f..584692673a 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -892,7 +892,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`CVodeSetFromCommandLine`. If the *cvid* argument is ``NULL`` then ``cvodes.`` will be used for all CVODES command-line diff --git a/doc/ida/guide/source/Usage/index.rst b/doc/ida/guide/source/Usage/index.rst index 9059a13d50..d79a5da30a 100644 --- a/doc/ida/guide/source/Usage/index.rst +++ b/doc/ida/guide/source/Usage/index.rst @@ -953,7 +953,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`IDASetFromCommandLine`. If the *idaid* argument is ``NULL`` then ``ida.`` will be used for all IDA command-line diff --git a/doc/idas/guide/source/Usage/SIM.rst b/doc/idas/guide/source/Usage/SIM.rst index d346fe0c8f..44f31a427b 100644 --- a/doc/idas/guide/source/Usage/SIM.rst +++ b/doc/idas/guide/source/Usage/SIM.rst @@ -958,7 +958,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`IDASetFromCommandLine`. If the *idaid* argument is ``NULL`` then ``idas.`` will be used for all IDAS command-line diff --git a/doc/kinsol/guide/source/Usage/index.rst b/doc/kinsol/guide/source/Usage/index.rst index ff0d615ff5..a6e984f6db 100644 --- a/doc/kinsol/guide/source/Usage/index.rst +++ b/doc/kinsol/guide/source/Usage/index.rst @@ -536,7 +536,7 @@ negative, so a test ``retval`` :math:`<0` will catch any error. .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main'' routine. + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`KINSetFromCommandLine`. If the *kinid* argument is ``NULL`` then ``kinsol.`` will be used for all KINSOL command-line From af73d8ec395a39c5fe5f3947abb774d94cdc021a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 26 Mar 2025 13:39:20 -0500 Subject: [PATCH 057/114] Documented command-line control over SUNAdaptController and SUNLinearSolver implementations --- .../SUNAdaptController_Description.rst | 50 +++++++++++++ .../SUNAdaptController_ImExGus.rst | 11 +++ .../SUNAdaptController_MRIHTol.rst | 11 +++ .../SUNAdaptController_Soderlind.rst | 72 ++++++++++++++++++- doc/shared/sunlinsol/SUNLinSol_API.rst | 34 +++++++++ doc/shared/sunlinsol/SUNLinSol_KLU.rst | 9 +++ doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst | 10 +++ doc/shared/sunlinsol/SUNLinSol_PCG.rst | 12 ++++ doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst | 16 ++++- doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst | 18 +++++ doc/shared/sunlinsol/SUNLinSol_SPGMR.rst | 18 +++++ doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst | 15 +++- doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst | 9 +++ 13 files changed, 280 insertions(+), 5 deletions(-) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 2e61c89673..935f35822a 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -93,6 +93,12 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_Reset` + .. c:member:: SUNErrCode (*setfromcommandline)(SUNAdaptController C, const char* Cid, int argc, char* argv[]) + + The function implementing :c:func:`SUNAdaptController_SetFromCommandLine` + + .. versionadded:: x.y.z + .. c:member:: SUNErrCode (*setdefaults)(SUNAdaptController C) The function implementing :c:func:`SUNAdaptController_SetDefaults` @@ -261,6 +267,35 @@ note these requirements below. Additionally, we note the behavior of the base SU :return: :c:type:`SUNErrCode` indicating success or failure. +.. c:function:: SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, const char* Cid, int argc, char* argv[]) + + Passes command-line arguments to SUNAdaptController implementations. + + :param C: the :c:type:`SUNAdaptController` object. + :param Cid: String to use as prefix for command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :return: :c:type:`SUNErrCode` indicating success or failure. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These + are left unchanged by :c:func:`SUNAdaptController_SetFromCommandLine`. + + If the *Cid* argument is ``NULL`` then an implementation-specific prefix will be used for the + relevant command-line options -- see each implementation for its default prefix value. + When using a combination of SUNAdaptController objects (e.g., within MRIStep, SplittingStep or + ForcingStep), it is recommended that users call :c:func:`SUNAdaptController_SetFromCommandLine` + for each controller using distinct *Cid* inputs, so that each controller can be configured + separately. + + SUNAdaptController options set via command-line arguments to + :c:func:`SUNAdaptController_SetFromCommandLine` will overwrite any previously-set values. + + .. versionadded:: x.y.z + + .. c:function:: SUNErrCode SUNAdaptController_SetDefaults(SUNAdaptController C) Sets the controller parameters to their default values. @@ -268,6 +303,11 @@ note these requirements below. Additionally, we note the behavior of the base SU :param C: the :c:type:`SUNAdaptController` object. :return: :c:type:`SUNErrCode` indicating success or failure. + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.defaults". + .. c:function:: SUNErrCode SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) @@ -277,6 +317,11 @@ note these requirements below. Additionally, we note the behavior of the base SU :param fptr: the output stream to write the parameters to. :return: :c:type:`SUNErrCode` indicating success or failure. + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.write_parameters". + .. c:function:: SUNErrCode SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) @@ -289,6 +334,11 @@ note these requirements below. Additionally, we note the behavior of the base SU the default value for the controller. :return: :c:type:`SUNErrCode` indicating success or failure. + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.error_bias". + .. c:function:: SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 54ba98a836..08f60a9199 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -106,6 +106,12 @@ routines: SUNAdaptController C = SUNAdaptController_ImExGus(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_imexgus". + .. c:function:: SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) This user-callable function provides control over the relevant parameters @@ -124,3 +130,8 @@ routines: .. code-block:: c retval = SUNAdaptController_SetParams_ImExGus(C, 0.4, 0.3, -1.0, 1.0); + + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 4a49424222..7eaac23bcc 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -142,6 +142,12 @@ also provides the following additional user-callable routines: :returns: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_mrihtol". + .. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac) @@ -157,6 +163,11 @@ also provides the following additional user-callable routines: :returns: :c:type:`SUNErrCode` indicating success or failure. + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". + Usage ----- diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index a1ff1404d1..4901ebcc32 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -100,6 +100,12 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_Soderlind(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_soderlind". + .. c:function:: SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3, sunrealtype k4, sunrealtype k5) This user-callable function provides control over the relevant parameters @@ -121,6 +127,11 @@ also provides the following additional user-callable routines: /* Specify parameters for Soderlind's H_{0}312 controller */ retval = SUNAdaptController_SetParams_Soderlind(C, 0.25, 0.5, 0.25, -0.75, -0.25); + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". + .. c:function:: SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) @@ -138,6 +149,12 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_PID(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_pid". + .. c:function:: SUNErrCode SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) This user-callable function provides control over the relevant parameters @@ -156,6 +173,11 @@ also provides the following additional user-callable routines: retval = SUNAdaptController_SetParams_PID(C, 0.58, -0.21, 0.1); + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". + .. c:function:: SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) @@ -173,6 +195,13 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_PI(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_pi". + + .. c:function:: SUNErrCode SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) This user-callable function provides control over the relevant parameters @@ -190,6 +219,11 @@ also provides the following additional user-callable routines: retval = SUNAdaptController_SetParams_PI(C, 0.8, -0.31); + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". + .. c:function:: SUNAdaptController SUNAdaptController_I(SUNContext sunctx) @@ -207,6 +241,13 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_I(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_i". + + .. c:function:: SUNErrCode SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) This user-callable function provides control over the relevant parameters @@ -223,6 +264,11 @@ also provides the following additional user-callable routines: retval = SUNAdaptController_SetParams_I(C, 1.0); + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". + .. c:function:: SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) @@ -241,10 +287,17 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_expgus". + + .. c:function:: SUNErrCode SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) This user-callable function provides control over the relevant parameters - above for the explicit Gustafsson controller, setting :math:`k_3 = k_4 = k_5 = 0`. + above for the explicit Gustafsson controller, setting :math:`k_3 = k_4 = k_5 = 0`. This should be called *before* the time integrator is called to evolve the problem. .. note:: @@ -269,6 +322,11 @@ also provides the following additional user-callable routines: retval = SUNAdaptController_SetParams_ExpGus(C, 0.367, 0.268); + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". + .. c:function:: SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) @@ -287,6 +345,13 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_impgus". + + .. c:function:: SUNErrCode SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) This user-callable function provides control over the relevant parameters @@ -314,3 +379,8 @@ also provides the following additional user-callable routines: .. code-block:: c retval = SUNAdaptController_SetParams_ImpGus(C, 0.98, 0.95); + + .. note:: + + This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` + when using the command-line option "Cid.params". diff --git a/doc/shared/sunlinsol/SUNLinSol_API.rst b/doc/shared/sunlinsol/SUNLinSol_API.rst index 155ebb571e..b73b1a013c 100644 --- a/doc/shared/sunlinsol/SUNLinSol_API.rst +++ b/doc/shared/sunlinsol/SUNLinSol_API.rst @@ -240,6 +240,35 @@ the functionality for any optional routine should leave the corresponding function pointer ``NULL`` instead of supplying a dummy routine. +.. c:function:: SUNErrCode SUNLinSolSetFromCommandLine(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) + + This *optional* routine allows command-line control over various options within a SUNLinearSolver implementation. + + :param S: the :c:type:`SUNLinearSolver` object. + :param LSid: String to use as prefix for command-line options. + :param argc: Number of command-line options provided to executable. + :param argv: Array of strings containing command-line options provided to executable. + + :return: :c:type:`SUNErrCode` indicating success or failure. + + .. note:: + + The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These + are left unchanged by :c:func:`SUNLinSolSetFromCommandLine`. + + If the *LSid* argument is ``NULL`` then an implementation-specific prefix will be used for the + relevant command-line options -- see each implementation for its default prefix value. + When using a combination of SUNLinearSolver objects (e.g., for system and mass matrices within + ARKStep), it is recommended that users call :c:func:`SUNLinSolSetFromCommandLine` + for each controller using distinct *LSid* inputs, so that each solver can be configured + separately. + + SUNLinearSolver options set via command-line arguments to + :c:func:`SUNLinSolSetFromCommandLine` will overwrite any previously-set values. + + .. versionadded:: x.y.z + + .. c:function:: SUNErrCode SUNLinSolSetATimes(SUNLinearSolver LS, void* A_data, SUNATimesFn ATimes) *Required for matrix-free linear solvers* (otherwise optional). @@ -328,6 +357,11 @@ function pointer ``NULL`` instead of supplying a dummy routine. each call to :c:func:`SUNLinSolSolve`. + If supported by the SUNLinearSolver implementation, this routine will be called + by :c:func:`SUNLinSolSetFromCommandLine` when using the command-line option + "LSid.zero_guess". + + .. _SUNLinSol.GetFn: SUNLinearSolver "get" functions diff --git a/doc/shared/sunlinsol/SUNLinSol_KLU.rst b/doc/shared/sunlinsol/SUNLinSol_KLU.rst index c5a9679676..29b8ee5b02 100644 --- a/doc/shared/sunlinsol/SUNLinSol_KLU.rst +++ b/doc/shared/sunlinsol/SUNLinSol_KLU.rst @@ -60,6 +60,10 @@ user-callable routines: SUNDIALS, these will be included within this compatibility check. + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "klu". + .. c:function:: SUNErrCode SUNLinSol_KLUReInit(SUNLinearSolver S, SUNMatrix A, sunindextype nnz, int reinit_type) @@ -114,6 +118,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.ordering". + .. c:function:: sun_klu_symbolic* SUNLinSol_KLUGetSymbolic(SUNLinearSolver S) diff --git a/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst b/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst index f9c0806c07..0b7459be6b 100644 --- a/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst +++ b/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst @@ -83,6 +83,11 @@ In addition, the module provides the following user-callable routines: the input matrix and vector to determine the linear system size and to assess compatibility with the solver. + **Notes:** + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "magmadense". + .. c:function:: SUNErrCode SUNLinSol_MagmaDense_SetAsync(SUNLinearSolver LS, sunbooleantype onoff) This function can be used to toggle the linear solver between asynchronous @@ -97,6 +102,11 @@ In addition, the module provides the following user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.async". + SUNLinearSolver_MagmaDense Content ----------------------------------- diff --git a/doc/shared/sunlinsol/SUNLinSol_PCG.rst b/doc/shared/sunlinsol/SUNLinSol_PCG.rst index c2e0bad2c4..7f373bf41a 100644 --- a/doc/shared/sunlinsol/SUNLinSol_PCG.rst +++ b/doc/shared/sunlinsol/SUNLinSol_PCG.rst @@ -135,6 +135,11 @@ The module SUNLinSol_PCG provides the following user-callable routines: preconditioning should work appropriately even for packages designed with one-sided preconditioning in mind. + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "pcg". + + .. c:function:: SUNErrCode SUNLinSol_PCGSetPrecType(SUNLinearSolver S, int pretype) This function updates the flag indicating use of preconditioning. @@ -156,6 +161,8 @@ The module SUNLinSol_PCG provides the following user-callable routines: ``SUN_PREC_RIGHT``, or ``SUN_PREC_BOTH`` will enable preconditioning; ``SUN_PREC_NONE`` disables preconditioning. + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.prec_type". .. c:function:: SUNErrCode SUNLinSol_PCGSetMaxl(SUNLinearSolver S, int maxl) @@ -170,6 +177,11 @@ The module SUNLinSol_PCG provides the following user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.maxl". + .. _SUNLinSol.PCG.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst b/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst index 35a676d7ba..e206991bef 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst @@ -79,11 +79,13 @@ user-callable routines: preconditioning options with these solvers, this use mode is not supported and may result in inferior performance. - .. note:: - With ``SUN_PREC_RIGHT`` or ``SUN_PREC_BOTH`` the initial guess must be zero (use :c:func:`SUNLinSolSetZeroGuess` to indicate the initial guess is zero). + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "spbcgs". + .. c:function:: SUNErrCode SUNLinSol_SPBCGSSetPrecType(SUNLinearSolver S, int pretype) @@ -101,6 +103,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.prec_type". + .. c:function:: SUNErrCode SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S, int maxl) @@ -114,6 +121,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.maxl". + .. _SUNLinSol.SPBCGS.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst b/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst index 86b26fdd29..0c0f447c00 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst @@ -84,6 +84,11 @@ user-callable routines: these packages, this use mode is not supported and may result in inferior performance. + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "spfgmr". + + .. c:function:: SUNErrCode SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S, int pretype) This function updates the flag indicating use of preconditioning. @@ -107,6 +112,9 @@ user-callable routines: will result in use of ``SUN_PREC_RIGHT``; any other integer input will result in the default (no preconditioning). + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.prec_type". + .. c:function:: SUNErrCode SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S, int gstype) @@ -122,6 +130,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.gs_type". + .. c:function:: SUNErrCode SUNLinSol_SPFGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) @@ -135,6 +148,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.max_restarts". + .. _SUNLinSol.SPFGMR.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst b/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst index e35e9ce213..6991da9db2 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst @@ -77,6 +77,9 @@ user-callable routines: with these solvers, this use mode is not supported and may result in inferior performance. + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "spgmr". .. c:function:: SUNErrCode SUNLinSol_SPGMRSetPrecType(SUNLinearSolver S, int pretype) @@ -94,6 +97,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.prec_type". + .. c:function:: SUNErrCode SUNLinSol_SPGMRSetGSType(SUNLinearSolver S, int gstype) @@ -109,6 +117,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.gs_type". + .. c:function:: SUNErrCode SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) @@ -122,6 +135,11 @@ user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.max_restarts". + .. _SUNLinSol.SPGMR.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst b/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst index 1f4468b9b3..a8c1e4f8d4 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst @@ -78,11 +78,12 @@ The module SUNLinSol_SPTFQMR provides the following user-callable routines: with these solvers, this use mode is not supported and may result in inferior performance. - .. note:: - With ``SUN_PREC_RIGHT`` or ``SUN_PREC_BOTH`` the initial guess must be zero (use :c:func:`SUNLinSolSetZeroGuess` to indicate the initial guess is zero). + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "sptfqmr". .. c:function:: SUNErrCode SUNLinSol_SPTFQMRSetPrecType(SUNLinearSolver S, int pretype) @@ -101,6 +102,11 @@ The module SUNLinSol_SPTFQMR provides the following user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.prec_type". + .. c:function:: SUNErrCode SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S, int maxl) @@ -114,6 +120,11 @@ The module SUNLinSol_SPTFQMR provides the following user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.maxl". + .. _SUNLinSol.SPTFQMR.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst index 3fae265146..ff8d72e014 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst @@ -72,6 +72,10 @@ The module SUNLinSol_SuperLUMT provides the following user-callable routines: The ``num_threads`` argument is not checked and is passed directly to SuperLU_MT routines. + This SUNLinearSolver implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNLinSolSetFromCommandLine` + to be "superlumt.". + .. c:function:: SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice) @@ -95,6 +99,11 @@ The module SUNLinSol_SuperLUMT provides the following user-callable routines: **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` + when using the command-line option "LSid.ordering". + .. _SUNLinSol.SuperLUMT.Description: From 3b4197186195df5e007debcb8297c7ea5716d1d7 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Apr 2025 22:27:59 -0500 Subject: [PATCH 058/114] Removed SetFromCommandLine functions from linear solver and adaptivity controller implementation-specific header functions. Attempted to remove SetFromCommandLine functions from SWIG interfaces; regenerated SWIG --- .../sunadaptcontroller_imexgus.h | 5 - .../sunadaptcontroller_mrihtol.h | 5 - .../sunadaptcontroller_soderlind.h | 6 -- include/sunlinsol/sunlinsol_klu.h | 4 - include/sunlinsol/sunlinsol_magmadense.h | 2 - include/sunlinsol/sunlinsol_pcg.h | 4 - include/sunlinsol/sunlinsol_spbcgs.h | 4 - include/sunlinsol/sunlinsol_spfgmr.h | 4 - include/sunlinsol/sunlinsol_spgmr.h | 4 - include/sunlinsol/sunlinsol_sptfqmr.h | 4 - include/sunlinsol/sunlinsol_superlumt.h | 2 - src/arkode/fmod_int32/farkode_mod.c | 25 +---- src/arkode/fmod_int32/farkode_mod.f90 | 100 ++++++------------ src/arkode/fmod_int64/farkode_mod.c | 25 +---- src/arkode/fmod_int64/farkode_mod.f90 | 100 ++++++------------ src/cvode/fmod_int32/fcvode_mod.c | 49 --------- src/cvode/fmod_int32/fcvode_mod.f90 | 74 +------------ src/cvode/fmod_int64/fcvode_mod.c | 49 --------- src/cvode/fmod_int64/fcvode_mod.f90 | 74 +------------ src/cvodes/fmod_int32/fcvodes_mod.c | 25 +---- src/cvodes/fmod_int32/fcvodes_mod.f90 | 82 +++----------- src/cvodes/fmod_int64/fcvodes_mod.c | 25 +---- src/cvodes/fmod_int64/fcvodes_mod.f90 | 82 +++----------- src/ida/fmod_int32/fida_mod.c | 49 --------- src/ida/fmod_int32/fida_mod.f90 | 74 +------------ src/ida/fmod_int64/fida_mod.c | 49 --------- src/ida/fmod_int64/fida_mod.f90 | 74 +------------ src/idas/fmod_int32/fidas_mod.c | 25 +---- src/idas/fmod_int32/fidas_mod.f90 | 82 +++----------- src/idas/fmod_int64/fidas_mod.c | 25 +---- src/idas/fmod_int64/fidas_mod.f90 | 82 +++----------- src/kinsol/fmod_int32/fkinsol_mod.c | 49 --------- src/kinsol/fmod_int32/fkinsol_mod.f90 | 74 +------------ src/kinsol/fmod_int64/fkinsol_mod.c | 49 --------- src/kinsol/fmod_int64/fkinsol_mod.f90 | 74 +------------ .../fsunadaptcontroller_imexgus_mod.c | 74 ------------- .../fsunadaptcontroller_imexgus_mod.f90 | 70 ------------ .../fsunadaptcontroller_imexgus_mod.c | 74 ------------- .../fsunadaptcontroller_imexgus_mod.f90 | 70 ------------ .../imexgus/sunadaptcontroller_imexgus.c | 10 ++ .../fsunadaptcontroller_mrihtol_mod.c | 33 ------ .../fsunadaptcontroller_mrihtol_mod.f90 | 62 ----------- .../fsunadaptcontroller_mrihtol_mod.c | 33 ------ .../fsunadaptcontroller_mrihtol_mod.f90 | 62 ----------- .../mrihtol/sunadaptcontroller_mrihtol.c | 10 ++ .../fsunadaptcontroller_soderlind_mod.c | 74 ------------- .../fsunadaptcontroller_soderlind_mod.f90 | 70 ------------ .../fsunadaptcontroller_soderlind_mod.c | 74 ------------- .../fsunadaptcontroller_soderlind_mod.f90 | 70 ------------ .../soderlind/sunadaptcontroller_soderlind.c | 11 ++ .../klu/fmod_int32/fsunlinsol_klu_mod.c | 53 ---------- .../klu/fmod_int32/fsunlinsol_klu_mod.f90 | 62 ----------- .../klu/fmod_int64/fsunlinsol_klu_mod.c | 53 ---------- .../klu/fmod_int64/fsunlinsol_klu_mod.f90 | 62 ----------- src/sunlinsol/klu/sunlinsol_klu.c | 9 ++ .../magmadense/sunlinsol_magmadense.cpp | 10 ++ .../pcg/fmod_int32/fsunlinsol_pcg_mod.c | 74 ------------- .../pcg/fmod_int32/fsunlinsol_pcg_mod.f90 | 70 ------------ .../pcg/fmod_int64/fsunlinsol_pcg_mod.c | 74 ------------- .../pcg/fmod_int64/fsunlinsol_pcg_mod.f90 | 70 ------------ src/sunlinsol/pcg/sunlinsol_pcg.c | 9 ++ .../spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c | 74 ------------- .../fmod_int32/fsunlinsol_spbcgs_mod.f90 | 70 ------------ .../spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c | 74 ------------- .../fmod_int64/fsunlinsol_spbcgs_mod.f90 | 70 ------------ src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 9 ++ .../spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c | 74 ------------- .../fmod_int32/fsunlinsol_spfgmr_mod.f90 | 70 ------------ .../spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c | 74 ------------- .../fmod_int64/fsunlinsol_spfgmr_mod.f90 | 70 ------------ src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 9 ++ .../spgmr/fmod_int32/fsunlinsol_spgmr_mod.c | 74 ------------- .../spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 | 70 ------------ .../spgmr/fmod_int64/fsunlinsol_spgmr_mod.c | 74 ------------- .../spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 | 70 ------------ src/sunlinsol/spgmr/sunlinsol_spgmr.c | 9 ++ .../fmod_int32/fsunlinsol_sptfqmr_mod.c | 74 ------------- .../fmod_int32/fsunlinsol_sptfqmr_mod.f90 | 70 ------------ .../fmod_int64/fsunlinsol_sptfqmr_mod.c | 74 ------------- .../fmod_int64/fsunlinsol_sptfqmr_mod.f90 | 70 ------------ src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 9 ++ src/sunlinsol/superlumt/sunlinsol_superlumt.c | 9 ++ swig/arkode/farkode_mod.i | 4 +- swig/cvode/fcvode_mod.i | 3 + swig/cvodes/fcvodes_mod.i | 4 +- swig/ida/fida_mod.i | 4 +- swig/idas/fidas_mod.i | 4 +- swig/kinsol/fkinsol_mod.i | 4 +- swig/sunadaptcontroller/fsunadaptcontroller.i | 3 + swig/sunlinsol/fsunlinsol.i | 4 +- swig/sunlinsol/fsunlinsol_klu_mod.i | 1 - swig/sunlinsol/fsunlinsol_pcg_mod.i | 1 - swig/sunlinsol/fsunlinsol_spbcgs_mod.i | 1 - swig/sunlinsol/fsunlinsol_spfgmr_mod.i | 1 - swig/sunlinsol/fsunlinsol_spgmr_mod.i | 1 - swig/sunlinsol/fsunlinsol_sptfqmr_mod.i | 1 - 96 files changed, 278 insertions(+), 3758 deletions(-) diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index 394cd82726..a35b998097 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -51,11 +51,6 @@ typedef struct _SUNAdaptControllerContent_ImExGus* SUNAdaptControllerContent_ImE SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx); -SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); - SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 1942b4bf70..38e8affd9c 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -48,11 +48,6 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, SUNAdaptController TolControl, SUNContext sunctx); -SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); - SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index 302ea91baf..7651de6d78 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -56,12 +56,6 @@ typedef struct _SUNAdaptControllerContent_Soderlind* SUNAdaptControllerContent_S SUNDIALS_EXPORT SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx); -SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, - const char* Cid, - int argc, - char* argv[]); - SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k1, sunrealtype k2, diff --git a/include/sunlinsol/sunlinsol_klu.h b/include/sunlinsol/sunlinsol_klu.h index 7c679b90cf..35591bc398 100644 --- a/include/sunlinsol/sunlinsol_klu.h +++ b/include/sunlinsol/sunlinsol_klu.h @@ -131,10 +131,6 @@ SUNDIALS_EXPORT sun_klu_common* SUNLinSol_KLUGetCommon(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_KLU(SUNLinearSolver S); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, - const char* LSid, - int argc, - char* argv[]); SUNDIALS_EXPORT int SUNLinSolSetup_KLU(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_KLU(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, sunrealtype tol); diff --git a/include/sunlinsol/sunlinsol_magmadense.h b/include/sunlinsol/sunlinsol_magmadense.h index 1bcfe6125e..f36ea680cc 100644 --- a/include/sunlinsol/sunlinsol_magmadense.h +++ b/include/sunlinsol/sunlinsol_magmadense.h @@ -65,8 +65,6 @@ SUNDIALS_EXPORT int SUNLinSol_MagmaDense_SetAsync(SUNLinearSolver S, SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_MagmaDense(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_MagmaDense(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_MagmaDense(SUNLinearSolver S); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense( - SUNLinearSolver S, const char* LSid, int argc, char* argv[]); SUNDIALS_EXPORT int SUNLinSolSetup_MagmaDense(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_MagmaDense(SUNLinearSolver S, SUNMatrix A, N_Vector x, N_Vector b, diff --git a/include/sunlinsol/sunlinsol_pcg.h b/include/sunlinsol/sunlinsol_pcg.h index e68e11b4b8..bef14ab107 100644 --- a/include/sunlinsol/sunlinsol_pcg.h +++ b/include/sunlinsol/sunlinsol_pcg.h @@ -87,10 +87,6 @@ SUNLinearSolver_ID SUNLinSolGetID_PCG(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_PCG(SUNLinearSolver S); -SUNDIALS_EXPORT -SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); - SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_PCG(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_spbcgs.h b/include/sunlinsol/sunlinsol_spbcgs.h index d3513bbd9c..dbebee6567 100644 --- a/include/sunlinsol/sunlinsol_spbcgs.h +++ b/include/sunlinsol/sunlinsol_spbcgs.h @@ -83,10 +83,6 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S, int maxl); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPBCGS(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPBCGS(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPBCGS(SUNLinearSolver S); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, - const char* LSid, - int argc, - char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPBCGS(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_spfgmr.h b/include/sunlinsol/sunlinsol_spfgmr.h index 0da7e7b97e..f9ba1929ad 100644 --- a/include/sunlinsol/sunlinsol_spfgmr.h +++ b/include/sunlinsol/sunlinsol_spfgmr.h @@ -84,10 +84,6 @@ typedef struct _SUNLinearSolverContent_SPFGMR* SUNLinearSolverContent_SPFGMR; SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNContext sunctx); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, - const char* LSid, - int argc, - char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S, int pretype); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S, diff --git a/include/sunlinsol/sunlinsol_spgmr.h b/include/sunlinsol/sunlinsol_spgmr.h index e0a54648de..827afb0055 100644 --- a/include/sunlinsol/sunlinsol_spgmr.h +++ b/include/sunlinsol/sunlinsol_spgmr.h @@ -93,10 +93,6 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S, SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPGMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPGMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPGMR(SUNLinearSolver S); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, - const char* LSid, - int argc, - char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPGMR(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_sptfqmr.h b/include/sunlinsol/sunlinsol_sptfqmr.h index 59eec3ceb1..437874fd15 100644 --- a/include/sunlinsol/sunlinsol_sptfqmr.h +++ b/include/sunlinsol/sunlinsol_sptfqmr.h @@ -85,10 +85,6 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S, int maxl) SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SPTFQMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_SPTFQMR(SUNLinearSolver S); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_SPTFQMR(SUNLinearSolver S); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, - const char* LSid, - int argc, - char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetATimes_SPTFQMR(SUNLinearSolver S, void* A_data, SUNATimesFn ATimes); diff --git a/include/sunlinsol/sunlinsol_superlumt.h b/include/sunlinsol/sunlinsol_superlumt.h index 42220dff6c..4bdb08ef04 100644 --- a/include/sunlinsol/sunlinsol_superlumt.h +++ b/include/sunlinsol/sunlinsol_superlumt.h @@ -95,8 +95,6 @@ typedef struct _SUNLinearSolverContent_SuperLUMT* SUNLinearSolverContent_SuperLU SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, SUNContext sunctx); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT( - SUNLinearSolver S, const char* LSid, int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT(SUNLinearSolver S); diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index fd7662a5b5..cf23905ff6 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -267,6 +267,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -281,9 +284,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,25 +315,6 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } -SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)ARKodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 02d9213bce..c7f65b633e 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -115,22 +115,6 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FARKodeSetFromCommandLine public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -208,6 +192,10 @@ module farkode_mod public :: FARKodeGetRootInfo public :: FARKodeGetUserData public :: FARKodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FARKodeGetReturnFlagName public :: FARKodeWriteParameters public :: FARKodeGetNumExpSteps @@ -280,6 +268,14 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -486,19 +482,6 @@ module farkode_mod ! WRAPPER DECLARATIONS interface -function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FARKodeSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2482,47 +2465,6 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FARKodeSetFromCommandLine(arkode_mem, arkid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: arkid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = arkode_mem -call SWIG_string_to_chararray(arkid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5413,6 +5355,24 @@ function FARKodeButcherTable_LoadDIRK(imethod) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + function FARKodeButcherTable_LoadDIRKByName(imethod) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 6a1d14181e..0c4024af1f 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -267,6 +267,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -281,9 +284,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,25 +315,6 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } -SWIGEXPORT int _wrap_FARKodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "ARKodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)ARKodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 1d057dc665..c01ee2cb3e 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -115,22 +115,6 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FARKodeSetFromCommandLine public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -208,6 +192,10 @@ module farkode_mod public :: FARKodeGetRootInfo public :: FARKodeGetUserData public :: FARKodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FARKodeGetReturnFlagName public :: FARKodeWriteParameters public :: FARKodeGetNumExpSteps @@ -280,6 +268,14 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -486,19 +482,6 @@ module farkode_mod ! WRAPPER DECLARATIONS interface -function swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FARKodeSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2482,47 +2465,6 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FARKodeSetFromCommandLine(arkode_mem, arkid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: arkid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = arkode_mem -call SWIG_string_to_chararray(arkid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FARKodeSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5413,6 +5355,24 @@ function FARKodeButcherTable_LoadDIRK(imethod) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + function FARKodeButcherTable_LoadDIRKByName(imethod) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int32/fcvode_mod.c b/src/cvode/fmod_int32/fcvode_mod.c index c7d0f2efee..68f9ba20f1 100644 --- a/src/cvode/fmod_int32/fcvode_mod.c +++ b/src/cvode/fmod_int32/fcvode_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -252,20 +236,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -362,25 +332,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int32/fcvode_mod.f90 b/src/cvode/fmod_int32/fcvode_mod.f90 index 0040b0e6eb..2e53b4bb9e 100644 --- a/src/cvode/fmod_int32/fcvode_mod.f90 +++ b/src/cvode/fmod_int32/fcvode_mod.f90 @@ -69,22 +69,6 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -151,6 +135,10 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -279,19 +267,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FCVodeSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1485,47 +1460,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int64/fcvode_mod.c b/src/cvode/fmod_int64/fcvode_mod.c index c48adf0678..a42a5d51e8 100644 --- a/src/cvode/fmod_int64/fcvode_mod.c +++ b/src/cvode/fmod_int64/fcvode_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -252,20 +236,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -362,25 +332,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int64/fcvode_mod.f90 b/src/cvode/fmod_int64/fcvode_mod.f90 index 0d2dfa7e34..9aba027f07 100644 --- a/src/cvode/fmod_int64/fcvode_mod.f90 +++ b/src/cvode/fmod_int64/fcvode_mod.f90 @@ -69,22 +69,6 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -151,6 +135,10 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -279,19 +267,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FCVodeSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1485,47 +1460,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int32/fcvodes_mod.c b/src/cvodes/fmod_int32/fcvodes_mod.c index 41b1c4bfd7..473678dc27 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.c +++ b/src/cvodes/fmod_int32/fcvodes_mod.c @@ -264,6 +264,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -278,9 +281,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -406,25 +406,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int32/fcvodes_mod.f90 b/src/cvodes/fmod_int32/fcvodes_mod.f90 index b54d0fba2e..a288b74705 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int32/fcvodes_mod.f90 @@ -100,22 +100,6 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -186,6 +170,10 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -280,6 +268,14 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -446,19 +442,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FCVodeSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2884,47 +2867,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int64/fcvodes_mod.c b/src/cvodes/fmod_int64/fcvodes_mod.c index bcd330a87c..d3cbbca1d6 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.c +++ b/src/cvodes/fmod_int64/fcvodes_mod.c @@ -264,6 +264,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -278,9 +281,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -406,25 +406,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "CVodeSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)CVodeSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int64/fcvodes_mod.f90 b/src/cvodes/fmod_int64/fcvodes_mod.f90 index 21154ea34b..c2cdf3a0a3 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int64/fcvodes_mod.f90 @@ -100,22 +100,6 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetFromCommandLine public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -186,6 +170,10 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -280,6 +268,14 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -446,19 +442,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FCVodeSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2884,47 +2867,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetFromCommandLine(cvode_mem, cvid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FCVodeSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int32/fida_mod.c b/src/ida/fmod_int32/fida_mod.c index 1323ccbb78..68dfeea91f 100644 --- a/src/ida/fmod_int32/fida_mod.c +++ b/src/ida/fmod_int32/fida_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -377,25 +347,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int32/fida_mod.f90 b/src/ida/fmod_int32/fida_mod.f90 index aa002698ee..136521893f 100644 --- a/src/ida/fmod_int32/fida_mod.f90 +++ b/src/ida/fmod_int32/fida_mod.f90 @@ -68,22 +68,6 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -151,6 +135,10 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -264,19 +252,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FIDASetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1332,47 +1307,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int64/fida_mod.c b/src/ida/fmod_int64/fida_mod.c index e5048513ef..02def580d4 100644 --- a/src/ida/fmod_int64/fida_mod.c +++ b/src/ida/fmod_int64/fida_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -377,25 +347,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int64/fida_mod.f90 b/src/ida/fmod_int64/fida_mod.f90 index a19bfdc511..5e3fee8ae6 100644 --- a/src/ida/fmod_int64/fida_mod.f90 +++ b/src/ida/fmod_int64/fida_mod.f90 @@ -68,22 +68,6 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -151,6 +135,10 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -264,19 +252,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FIDASetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1332,47 +1307,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int32/fidas_mod.c b/src/idas/fmod_int32/fidas_mod.c index f7df16c727..c39dff4a1f 100644 --- a/src/idas/fmod_int32/fidas_mod.c +++ b/src/idas/fmod_int32/fidas_mod.c @@ -262,6 +262,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -276,9 +279,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,25 +422,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int32/fidas_mod.f90 b/src/idas/fmod_int32/fidas_mod.f90 index 55c79bc554..db6f376bfc 100644 --- a/src/idas/fmod_int32/fidas_mod.f90 +++ b/src/idas/fmod_int32/fidas_mod.f90 @@ -93,22 +93,6 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -181,6 +165,10 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -273,6 +261,14 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -428,19 +424,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FIDASetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2773,47 +2756,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int64/fidas_mod.c b/src/idas/fmod_int64/fidas_mod.c index ecffd9bcd4..196fd9f52b 100644 --- a/src/idas/fmod_int64/fidas_mod.c +++ b/src/idas/fmod_int64/fidas_mod.c @@ -262,6 +262,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -276,9 +279,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,25 +422,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "IDASetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)IDASetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int64/fidas_mod.f90 b/src/idas/fmod_int64/fidas_mod.f90 index 16ea7332c7..b379e13d36 100644 --- a/src/idas/fmod_int64/fidas_mod.f90 +++ b/src/idas/fmod_int64/fidas_mod.f90 @@ -93,22 +93,6 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetFromCommandLine public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -181,6 +165,10 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -273,6 +261,14 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -428,19 +424,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FIDASetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2773,47 +2756,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetFromCommandLine(ida_mem, idaid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FIDASetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int32/fkinsol_mod.c b/src/kinsol/fmod_int32/fkinsol_mod.c index 9f2d8124a7..28e47ca143 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.c +++ b/src/kinsol/fmod_int32/fkinsol_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -313,25 +283,6 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } -SWIGEXPORT int _wrap_FKINSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "KINSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)KINSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int32/fkinsol_mod.f90 b/src/kinsol/fmod_int32/fkinsol_mod.f90 index 2ad3ef01ce..b536144611 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int32/fkinsol_mod.f90 @@ -60,22 +60,6 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FKINSetFromCommandLine public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -110,6 +94,10 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -177,19 +165,6 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function -function swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FKINSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -773,47 +748,6 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FKINSetFromCommandLine(kinmem, kinid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: kinmem -character(kind=C_CHAR, len=*), target :: kinid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = kinmem -call SWIG_string_to_chararray(kinid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int64/fkinsol_mod.c b/src/kinsol/fmod_int64/fkinsol_mod.c index b510edc23c..59cc57d5b2 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.c +++ b/src/kinsol/fmod_int64/fkinsol_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -313,25 +283,6 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } -SWIGEXPORT int _wrap_FKINSetFromCommandLine(void *farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "KINSetFromCommandLine(void *,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (int)KINSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int64/fkinsol_mod.f90 b/src/kinsol/fmod_int64/fkinsol_mod.f90 index e9ae8316d6..12ca4ddc6e 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int64/fkinsol_mod.f90 @@ -60,22 +60,6 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FKINSetFromCommandLine public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -110,6 +94,10 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -177,19 +165,6 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function -function swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FKINSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -773,47 +748,6 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FKINSetFromCommandLine(kinmem, kinid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: kinmem -character(kind=C_CHAR, len=*), target :: kinid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = kinmem -call SWIG_string_to_chararray(kinid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FKINSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c index 5f08ac9e61..9d4e4a3afd 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -275,25 +220,6 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_ImExGus(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 index 4fa583355f..4dc30dc6a1 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 @@ -26,22 +26,6 @@ module fsunadaptcontroller_imexgus_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_ImExGus - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNAdaptController_SetFromCommandLine_ImExGus public :: FSUNAdaptController_SetParams_ImExGus public :: FSUNAdaptController_GetType_ImExGus public :: FSUNAdaptController_EstimateStep_ImExGus @@ -62,19 +46,6 @@ function swigc_FSUNAdaptController_ImExGus(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_ImExGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ImExGus") & result(fresult) @@ -179,47 +150,6 @@ function FSUNAdaptController_ImExGus(sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNAdaptController_SetFromCommandLine_ImExGus(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetParams_ImExGus(c, k1e, k2e, k1i, k2i) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c index 5f08ac9e61..9d4e4a3afd 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -275,25 +220,6 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_ImExGus(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_ImExGus(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 index 4fa583355f..4dc30dc6a1 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 @@ -26,22 +26,6 @@ module fsunadaptcontroller_imexgus_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_ImExGus - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNAdaptController_SetFromCommandLine_ImExGus public :: FSUNAdaptController_SetParams_ImExGus public :: FSUNAdaptController_GetType_ImExGus public :: FSUNAdaptController_EstimateStep_ImExGus @@ -62,19 +46,6 @@ function swigc_FSUNAdaptController_ImExGus(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_ImExGus") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetParams_ImExGus(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FSUNAdaptController_SetParams_ImExGus") & result(fresult) @@ -179,47 +150,6 @@ function FSUNAdaptController_ImExGus(sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNAdaptController_SetFromCommandLine_ImExGus(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine_ImExGus(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetParams_ImExGus(c, k1e, k2e, k1i, k2i) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 73ae26dc9c..a88a9e3066 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -51,6 +51,16 @@ #define DEFAULT_K2I SUN_RCONST(0.95) #define DEFAULT_BIAS SUN_RCONST(1.5) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); + /* ----------------------------------------------------------------- * exported functions * ----------------------------------------------------------------- */ diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index 05bea32a6c..41ec1e1d1c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -297,20 +297,6 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; @@ -478,25 +464,6 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(SUNAdaptControll } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_MRIHTol(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index 1f0fe2fbb0..e7afddd833 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -55,14 +55,6 @@ module fsunadaptcontroller_mrihtol_mod module procedure swigf_create_SUNAdaptControllerContent_MRIHTol_ end interface public :: FSUNAdaptController_MRIHTol - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNAdaptController_SetFromCommandLine_MRIHTol public :: FSUNAdaptController_SetParams_MRIHTol public :: FSUNAdaptController_GetSlowController_MRIHTol public :: FSUNAdaptController_GetFastController_MRIHTol @@ -195,19 +187,6 @@ function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIHTol") & result(fresult) @@ -502,47 +481,6 @@ function FSUNAdaptController_MRIHTol(hcontrol, tolcontrol, sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNAdaptController_SetFromCommandLine_MRIHTol(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tolfac, inner_max_tolfac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index 05bea32a6c..41ec1e1d1c 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -297,20 +297,6 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; @@ -478,25 +464,6 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_MRIHTol(SUNAdaptControll } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_MRIHTol(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_MRIHTol(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index 1f0fe2fbb0..e7afddd833 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -55,14 +55,6 @@ module fsunadaptcontroller_mrihtol_mod module procedure swigf_create_SUNAdaptControllerContent_MRIHTol_ end interface public :: FSUNAdaptController_MRIHTol - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNAdaptController_SetFromCommandLine_MRIHTol public :: FSUNAdaptController_SetParams_MRIHTol public :: FSUNAdaptController_GetSlowController_MRIHTol public :: FSUNAdaptController_GetFastController_MRIHTol @@ -195,19 +187,6 @@ function swigc_FSUNAdaptController_MRIHTol(farg1, farg2, farg3) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_MRIHTol") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetParams_MRIHTol(farg1, farg2, farg3, farg4) & bind(C, name="_wrap_FSUNAdaptController_SetParams_MRIHTol") & result(fresult) @@ -502,47 +481,6 @@ function FSUNAdaptController_MRIHTol(hcontrol, tolcontrol, sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNAdaptController_SetFromCommandLine_MRIHTol(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine_MRIHTol(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetParams_MRIHTol(c, inner_max_relch, inner_min_tolfac, inner_max_tolfac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 3b26199c6d..4feb83bb58 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -49,6 +49,16 @@ #define MRIHTOL_INNER_MIN_TOLFAC(C) (MRIHTOL_CONTENT(C)->inner_min_tolfac) #define MRIHTOL_INNER_MAX_TOLFAC(C) (MRIHTOL_CONTENT(C)->inner_max_tolfac) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); + /* ----------------------------------------------------------------- * exported functions * ----------------------------------------------------------------- */ diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c index 9d8424928b..20bcb023cb 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -275,25 +220,6 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_Soderlind(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 index 27bcb0cf4a..67d65f5068 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 @@ -26,22 +26,6 @@ module fsunadaptcontroller_soderlind_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_Soderlind - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNAdaptController_SetFromCommandLine_Soderlind public :: FSUNAdaptController_SetParams_Soderlind public :: FSUNAdaptController_GetType_Soderlind public :: FSUNAdaptController_EstimateStep_Soderlind @@ -72,19 +56,6 @@ function swigc_FSUNAdaptController_Soderlind(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_Soderlind") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetParams_Soderlind(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FSUNAdaptController_SetParams_Soderlind") & result(fresult) @@ -280,47 +251,6 @@ function FSUNAdaptController_Soderlind(sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNAdaptController_SetFromCommandLine_Soderlind(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetParams_Soderlind(c, k1, k2, k3, k4, k5) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c index 9d8424928b..20bcb023cb 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -275,25 +220,6 @@ SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine_Soderlind(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetParams_Soderlind(SUNAdaptController farg1, double const *farg2, double const *farg3, double const *farg4, double const *farg5, double const *farg6) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 index 27bcb0cf4a..67d65f5068 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 @@ -26,22 +26,6 @@ module fsunadaptcontroller_soderlind_mod ! DECLARATION CONSTRUCTS public :: FSUNAdaptController_Soderlind - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNAdaptController_SetFromCommandLine_Soderlind public :: FSUNAdaptController_SetParams_Soderlind public :: FSUNAdaptController_GetType_Soderlind public :: FSUNAdaptController_EstimateStep_Soderlind @@ -72,19 +56,6 @@ function swigc_FSUNAdaptController_Soderlind(farg1) & type(C_PTR) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine_Soderlind") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetParams_Soderlind(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FSUNAdaptController_SetParams_Soderlind") & result(fresult) @@ -280,47 +251,6 @@ function FSUNAdaptController_Soderlind(sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNAdaptController_SetFromCommandLine_Soderlind(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine_Soderlind(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetParams_Soderlind(c, k1, k2, k3, k4, k5) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 00d4795f5c..4868dc839d 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -66,6 +66,17 @@ #define DEFAULT_IMPGUS_K2 SUN_RCONST(0.95) #define DEFAULT_BIAS SUN_RCONST(1.5) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, + const char* Cid, + int argc, + char* argv[]); + /* ----------------------------------------------------------------- * exported functions * ----------------------------------------------------------------- */ diff --git a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c index 34783ed3d3..504612c0e0 100644 --- a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c +++ b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c @@ -185,15 +185,6 @@ enum { }; -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -238,31 +229,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { return result; } - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_KLU(N_Vector farg1, SUNMatrix farg2, void *farg3) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -386,25 +352,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_KLU(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_KLU(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_KLU(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetup_KLU(SUNLinearSolver farg1, SUNMatrix farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 index ce7c7cccb2..bbd312f674 100644 --- a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 +++ b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 @@ -54,14 +54,6 @@ module fsunlinsol_klu_mod public :: FSUNLinSolGetType_KLU public :: FSUNLinSolGetID_KLU public :: FSUNLinSolInitialize_KLU - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_KLU public :: FSUNLinSolSetup_KLU public :: FSUNLinSolSolve_KLU public :: FSUNLinSolLastFlag_KLU @@ -151,19 +143,6 @@ function swigc_FSUNLinSolInitialize_KLU(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_KLU") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetup_KLU(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetup_KLU") & result(fresult) @@ -351,47 +330,6 @@ function FSUNLinSolInitialize_KLU(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_KLU(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetup_KLU(s, a) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c index c3deeca4de..3e7b8d0614 100644 --- a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c +++ b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c @@ -185,15 +185,6 @@ enum { }; -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -238,31 +229,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { return result; } - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_KLU(N_Vector farg1, SUNMatrix farg2, void *farg3) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -386,25 +352,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_KLU(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_KLU(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_KLU(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetup_KLU(SUNLinearSolver farg1, SUNMatrix farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 index da1c859145..f836c8b140 100644 --- a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 +++ b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 @@ -54,14 +54,6 @@ module fsunlinsol_klu_mod public :: FSUNLinSolGetType_KLU public :: FSUNLinSolGetID_KLU public :: FSUNLinSolInitialize_KLU - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_KLU public :: FSUNLinSolSetup_KLU public :: FSUNLinSolSolve_KLU public :: FSUNLinSolLastFlag_KLU @@ -151,19 +143,6 @@ function swigc_FSUNLinSolInitialize_KLU(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_KLU") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetup_KLU(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetup_KLU") & result(fresult) @@ -351,47 +330,6 @@ function FSUNLinSolInitialize_KLU(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_KLU(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_KLU(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetup_KLU(s, a) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index e5808ec050..599b097dc7 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -46,6 +46,15 @@ #define COMMON(S) (KLU_CONTENT(S)->common) #define SOLVE(S) (KLU_CONTENT(S)->klu_solver) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index b14774a022..e4bc3e95d3 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -56,6 +56,16 @@ #define LASTFLAG(S) (MAGMADENSE_CONTENT(S)->last_flag) #define ASYNCHRONOUS(S) (MAGMADENSE_CONTENT(S)->async) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + + /* * ---------------------------------------------------------------------------- * Implementation specific routines diff --git a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c index 21b6c5bc3f..9c2f9bcb44 100644 --- a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c +++ b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_pcg.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_PCG(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -345,25 +290,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_PCG(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_PCG(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_PCG(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_PCG(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 index e6d03beb3e..5a38ae2960 100644 --- a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 +++ b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 @@ -32,22 +32,6 @@ module fsunlinsol_pcg_mod public :: FSUNLinSolGetType_PCG public :: FSUNLinSolGetID_PCG public :: FSUNLinSolInitialize_PCG - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_PCG public :: FSUNLinSolSetATimes_PCG public :: FSUNLinSolSetPreconditioner_PCG public :: FSUNLinSolSetScalingVectors_PCG @@ -116,19 +100,6 @@ function swigc_FSUNLinSolInitialize_PCG(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_PCG") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_PCG(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_PCG") & result(fresult) @@ -338,47 +309,6 @@ function FSUNLinSolInitialize_PCG(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_PCG(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_PCG(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c index e32266823b..6173f11b75 100644 --- a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c +++ b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_pcg.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_PCG(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -345,25 +290,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_PCG(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_PCG(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_PCG(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_PCG(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 index b0cc010b96..b6f5851f0e 100644 --- a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 +++ b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 @@ -32,22 +32,6 @@ module fsunlinsol_pcg_mod public :: FSUNLinSolGetType_PCG public :: FSUNLinSolGetID_PCG public :: FSUNLinSolInitialize_PCG - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_PCG public :: FSUNLinSolSetATimes_PCG public :: FSUNLinSolSetPreconditioner_PCG public :: FSUNLinSolSetScalingVectors_PCG @@ -116,19 +100,6 @@ function swigc_FSUNLinSolInitialize_PCG(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_PCG") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_PCG(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_PCG") & result(fresult) @@ -338,47 +309,6 @@ function FSUNLinSolInitialize_PCG(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_PCG(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_PCG(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_PCG(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 153bd27915..c61b582c81 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -41,6 +41,15 @@ #define PRETYPE(S) (PCG_CONTENT(S)->pretype) #define LASTFLAG(S) (PCG_CONTENT(S)->last_flag) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c index ec519caa5f..1a864f19a6 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c +++ b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_spbcgs.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPBCGS(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -345,25 +290,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPBCGS(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPBCGS(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPBCGS(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 index b7329e5729..b83fe50880 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 +++ b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 @@ -32,22 +32,6 @@ module fsunlinsol_spbcgs_mod public :: FSUNLinSolGetType_SPBCGS public :: FSUNLinSolGetID_SPBCGS public :: FSUNLinSolInitialize_SPBCGS - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPBCGS public :: FSUNLinSolSetATimes_SPBCGS public :: FSUNLinSolSetPreconditioner_SPBCGS public :: FSUNLinSolSetScalingVectors_SPBCGS @@ -116,19 +100,6 @@ function swigc_FSUNLinSolInitialize_SPBCGS(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPBCGS") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_SPBCGS(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPBCGS") & result(fresult) @@ -338,47 +309,6 @@ function FSUNLinSolInitialize_SPBCGS(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPBCGS(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_SPBCGS(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c index 7fff1a827a..731012db16 100644 --- a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c +++ b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_spbcgs.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPBCGS(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -345,25 +290,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPBCGS(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPBCGS(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPBCGS(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 index 822c105b3a..3530bf5bf3 100644 --- a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 +++ b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 @@ -32,22 +32,6 @@ module fsunlinsol_spbcgs_mod public :: FSUNLinSolGetType_SPBCGS public :: FSUNLinSolGetID_SPBCGS public :: FSUNLinSolInitialize_SPBCGS - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPBCGS public :: FSUNLinSolSetATimes_SPBCGS public :: FSUNLinSolSetPreconditioner_SPBCGS public :: FSUNLinSolSetScalingVectors_SPBCGS @@ -116,19 +100,6 @@ function swigc_FSUNLinSolInitialize_SPBCGS(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPBCGS") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_SPBCGS(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPBCGS") & result(fresult) @@ -338,47 +309,6 @@ function FSUNLinSolInitialize_SPBCGS(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPBCGS(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPBCGS(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_SPBCGS(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 4c1c6b48c8..4977f42869 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -43,6 +43,15 @@ #define PRETYPE(S) (SPBCGS_CONTENT(S)->pretype) #define LASTFLAG(S) (SPBCGS_CONTENT(S)->last_flag) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c index e388a2613f..9cb339ae7c 100644 --- a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c +++ b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_spfgmr.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -281,25 +226,6 @@ SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *fa } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPFGMR(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSol_SPFGMRSetPrecType(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 index 1952cd604c..6a8f7896e8 100644 --- a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 +++ b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 @@ -28,22 +28,6 @@ module fsunlinsol_spfgmr_mod integer(C_INT), parameter, public :: SUNSPFGMR_MAXL_DEFAULT = 5_C_INT integer(C_INT), parameter, public :: SUNSPFGMR_MAXRS_DEFAULT = 0_C_INT public :: FSUNLinSol_SPFGMR - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPFGMR public :: FSUNLinSol_SPFGMRSetPrecType public :: FSUNLinSol_SPFGMRSetGSType public :: FSUNLinSol_SPFGMRSetMaxRestarts @@ -76,19 +60,6 @@ function swigc_FSUNLinSol_SPFGMR(farg1, farg2, farg3, farg4) & type(C_PTR) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPFGMR") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSol_SPFGMRSetPrecType(farg1, farg2) & bind(C, name="_wrap_FSUNLinSol_SPFGMRSetPrecType") & result(fresult) @@ -278,47 +249,6 @@ function FSUNLinSol_SPFGMR(y, pretype, maxl, sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPFGMR(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSol_SPFGMRSetPrecType(s, pretype) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c index b9f98a270d..7c30b5166d 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c +++ b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_spfgmr.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -281,25 +226,6 @@ SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *fa } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPFGMR(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSol_SPFGMRSetPrecType(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 index 30834e8051..88ae7451b5 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 +++ b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 @@ -28,22 +28,6 @@ module fsunlinsol_spfgmr_mod integer(C_INT), parameter, public :: SUNSPFGMR_MAXL_DEFAULT = 5_C_INT integer(C_INT), parameter, public :: SUNSPFGMR_MAXRS_DEFAULT = 0_C_INT public :: FSUNLinSol_SPFGMR - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPFGMR public :: FSUNLinSol_SPFGMRSetPrecType public :: FSUNLinSol_SPFGMRSetGSType public :: FSUNLinSol_SPFGMRSetMaxRestarts @@ -76,19 +60,6 @@ function swigc_FSUNLinSol_SPFGMR(farg1, farg2, farg3, farg4) & type(C_PTR) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPFGMR") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSol_SPFGMRSetPrecType(farg1, farg2) & bind(C, name="_wrap_FSUNLinSol_SPFGMRSetPrecType") & result(fresult) @@ -278,47 +249,6 @@ function FSUNLinSol_SPFGMR(y, pretype, maxl, sunctx) & call c_f_pointer(fresult, swig_result) end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPFGMR(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPFGMR(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSol_SPFGMRSetPrecType(s, pretype) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index e56ce0cf69..10be55b574 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -41,6 +41,15 @@ #define SPFGMR_CONTENT(S) ((SUNLinearSolverContent_SPFGMR)(S->content)) #define LASTFLAG(S) (SPFGMR_CONTENT(S)->last_flag) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c index 28c7e7503c..2be19f50fe 100644 --- a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c +++ b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_spgmr.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -359,25 +304,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPGMR(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPGMR(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPGMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 index b978afeecd..b71379bbb2 100644 --- a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 +++ b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 @@ -34,22 +34,6 @@ module fsunlinsol_spgmr_mod public :: FSUNLinSolGetType_SPGMR public :: FSUNLinSolGetID_SPGMR public :: FSUNLinSolInitialize_SPGMR - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPGMR public :: FSUNLinSolSetATimes_SPGMR public :: FSUNLinSolSetPreconditioner_SPGMR public :: FSUNLinSolSetScalingVectors_SPGMR @@ -127,19 +111,6 @@ function swigc_FSUNLinSolInitialize_SPGMR(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPGMR") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_SPGMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPGMR") & result(fresult) @@ -365,47 +336,6 @@ function FSUNLinSolInitialize_SPGMR(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPGMR(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_SPGMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c index dbd3f9b108..8063348bb1 100644 --- a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c +++ b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_spgmr.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -359,25 +304,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPGMR(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPGMR(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPGMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 index 5b8222fe8d..950e7ee8a7 100644 --- a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 +++ b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 @@ -34,22 +34,6 @@ module fsunlinsol_spgmr_mod public :: FSUNLinSolGetType_SPGMR public :: FSUNLinSolGetID_SPGMR public :: FSUNLinSolInitialize_SPGMR - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPGMR public :: FSUNLinSolSetATimes_SPGMR public :: FSUNLinSolSetPreconditioner_SPGMR public :: FSUNLinSolSetScalingVectors_SPGMR @@ -127,19 +111,6 @@ function swigc_FSUNLinSolInitialize_SPGMR(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPGMR") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_SPGMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPGMR") & result(fresult) @@ -365,47 +336,6 @@ function FSUNLinSolInitialize_SPGMR(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPGMR(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPGMR(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_SPGMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 5290d53cc0..3459ae8a37 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -41,6 +41,15 @@ #define SPGMR_CONTENT(S) ((SUNLinearSolverContent_SPGMR)(S->content)) #define LASTFLAG(S) (SPGMR_CONTENT(S)->last_flag) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c index 648b2c233f..f16ec912e2 100644 --- a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c +++ b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_sptfqmr.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPTFQMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -345,25 +290,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPTFQMR(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPTFQMR(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPTFQMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 index 2d2bd25ed5..e34a320d20 100644 --- a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 +++ b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 @@ -32,22 +32,6 @@ module fsunlinsol_sptfqmr_mod public :: FSUNLinSolGetType_SPTFQMR public :: FSUNLinSolGetID_SPTFQMR public :: FSUNLinSolInitialize_SPTFQMR - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPTFQMR public :: FSUNLinSolSetATimes_SPTFQMR public :: FSUNLinSolSetPreconditioner_SPTFQMR public :: FSUNLinSolSetScalingVectors_SPTFQMR @@ -116,19 +100,6 @@ function swigc_FSUNLinSolInitialize_SPTFQMR(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPTFQMR") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_SPTFQMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPTFQMR") & result(fresult) @@ -338,47 +309,6 @@ function FSUNLinSolInitialize_SPTFQMR(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPTFQMR(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_SPTFQMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c index de16e81331..b5fee5a458 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c +++ b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -224,45 +208,6 @@ enum { #include "sunlinsol/sunlinsol_sptfqmr.h" - -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; - - -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; -} - - -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPTFQMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -345,25 +290,6 @@ SWIGEXPORT int _wrap_FSUNLinSolInitialize_SPTFQMR(SUNLinearSolver farg1) { } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine_SPTFQMR(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetATimes_SPTFQMR(SUNLinearSolver farg1, void *farg2, SUNATimesFn farg3) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 index 6b87ed1ef8..ffc1fc0626 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 +++ b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 @@ -32,22 +32,6 @@ module fsunlinsol_sptfqmr_mod public :: FSUNLinSolGetType_SPTFQMR public :: FSUNLinSolGetID_SPTFQMR public :: FSUNLinSolInitialize_SPTFQMR - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FSUNLinSolSetFromCommandLine_SPTFQMR public :: FSUNLinSolSetATimes_SPTFQMR public :: FSUNLinSolSetPreconditioner_SPTFQMR public :: FSUNLinSolSetScalingVectors_SPTFQMR @@ -116,19 +100,6 @@ function swigc_FSUNLinSolInitialize_SPTFQMR(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine_SPTFQMR") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetATimes_SPTFQMR(farg1, farg2, farg3) & bind(C, name="_wrap_FSUNLinSolSetATimes_SPTFQMR") & result(fresult) @@ -338,47 +309,6 @@ function FSUNLinSolInitialize_SPTFQMR(s) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSUNLinSolSetFromCommandLine_SPTFQMR(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine_SPTFQMR(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetATimes_SPTFQMR(s, a_data, atimes) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index f3b4840a49..8d9a466a3f 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -40,6 +40,15 @@ #define SPTFQMR_CONTENT(S) ((SUNLinearSolverContent_SPTFQMR)(S->content)) #define LASTFLAG(S) (SPTFQMR_CONTENT(S)->last_flag) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 26930dc956..c722dc7d51 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -56,6 +56,15 @@ #define ORDERING(S) (SLUMT_CONTENT(S)->ordering) #define OPTIONS(S) (SLUMT_CONTENT(S)->options) +/* + * ---------------------------------------------------------------------------- + * Un-exported implementation specific routines + * ---------------------------------------------------------------------------- + */ + +SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT( SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); + /* * ----------------------------------------------------------------- * exported functions diff --git a/swig/arkode/farkode_mod.i b/swig/arkode/farkode_mod.i index 8c9d9d9b09..5b607134dd 100644 --- a/swig/arkode/farkode_mod.i +++ b/swig/arkode/farkode_mod.i @@ -18,6 +18,9 @@ %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore ARKodeSetFromCommandLine; + %{ #include "arkode/arkode.h" #include "arkode/arkode_bandpre.h" @@ -46,4 +49,3 @@ %include "arkode/arkode_butcher_erk.h" %include "arkode/arkode_sprk.h" %include "arkode/arkode_ls.h" - diff --git a/swig/cvode/fcvode_mod.i b/swig/cvode/fcvode_mod.i index 454de23b75..d14082dc36 100644 --- a/swig/cvode/fcvode_mod.i +++ b/swig/cvode/fcvode_mod.i @@ -18,6 +18,9 @@ %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore CVodeSetFromCommandLine; + %{ #include "cvode/cvode.h" #include "cvode/cvode_bandpre.h" diff --git a/swig/cvodes/fcvodes_mod.i b/swig/cvodes/fcvodes_mod.i index ae0dfe2115..97de9b20b3 100644 --- a/swig/cvodes/fcvodes_mod.i +++ b/swig/cvodes/fcvodes_mod.i @@ -18,6 +18,9 @@ %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore CVodeSetFromCommandLine; + %{ #include "cvodes/cvodes.h" #include "cvodes/cvodes_bandpre.h" @@ -34,4 +37,3 @@ %include "cvodes/cvodes_bbdpre.h" %include "cvodes/cvodes_diag.h" %include "cvodes/cvodes_ls.h" - diff --git a/swig/ida/fida_mod.i b/swig/ida/fida_mod.i index 4d0d48316a..db5c52270f 100644 --- a/swig/ida/fida_mod.i +++ b/swig/ida/fida_mod.i @@ -18,6 +18,9 @@ %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore IDASetFromCommandLine; + %{ #include "ida/ida.h" #include "ida/ida_bbdpre.h" @@ -30,4 +33,3 @@ %include "ida/ida.h" %include "ida/ida_bbdpre.h" %include "ida/ida_ls.h" - diff --git a/swig/idas/fidas_mod.i b/swig/idas/fidas_mod.i index c38978a9d8..7c543c53f0 100644 --- a/swig/idas/fidas_mod.i +++ b/swig/idas/fidas_mod.i @@ -18,6 +18,9 @@ %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore IDASetFromCommandLine; + %{ #include "idas/idas.h" #include "idas/idas_bbdpre.h" @@ -30,4 +33,3 @@ %include "idas/idas.h" %include "idas/idas_bbdpre.h" %include "idas/idas_ls.h" - diff --git a/swig/kinsol/fkinsol_mod.i b/swig/kinsol/fkinsol_mod.i index c0940e2d36..864a7772ee 100644 --- a/swig/kinsol/fkinsol_mod.i +++ b/swig/kinsol/fkinsol_mod.i @@ -18,6 +18,9 @@ %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore KINSetFromCommandLine; + %{ #include "kinsol/kinsol.h" #include "kinsol/kinsol_bbdpre.h" @@ -30,4 +33,3 @@ %include "kinsol/kinsol.h" %include "kinsol/kinsol_bbdpre.h" %include "kinsol/kinsol_ls.h" - diff --git a/swig/sunadaptcontroller/fsunadaptcontroller.i b/swig/sunadaptcontroller/fsunadaptcontroller.i index 5a2a02e2ed..01e1817286 100644 --- a/swig/sunadaptcontroller/fsunadaptcontroller.i +++ b/swig/sunadaptcontroller/fsunadaptcontroller.i @@ -17,6 +17,9 @@ // Include shared configuration %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore SUNAdaptController_SetFromCommandLine; + %{ #include "sundials/sundials_adaptcontroller.h" %} diff --git a/swig/sunlinsol/fsunlinsol.i b/swig/sunlinsol/fsunlinsol.i index d005677b35..9a9786f5e7 100644 --- a/swig/sunlinsol/fsunlinsol.i +++ b/swig/sunlinsol/fsunlinsol.i @@ -17,6 +17,9 @@ // Include shared configuration %include "../sundials/fsundials.i" +// Ignore command-line processing functions since they are not supported in Fortran +%ignore SUNLinSolSetFromCommandLine; + %{ #include "sundials/sundials_linearsolver.h" %} @@ -28,4 +31,3 @@ %define %sunlinsol_impl(TYPE) %ignore _SUNLinearSolverContent_## TYPE ##; %enddef - diff --git a/swig/sunlinsol/fsunlinsol_klu_mod.i b/swig/sunlinsol/fsunlinsol_klu_mod.i index dcc98de099..074153f13f 100644 --- a/swig/sunlinsol/fsunlinsol_klu_mod.i +++ b/swig/sunlinsol/fsunlinsol_klu_mod.i @@ -28,4 +28,3 @@ // Process and wrap functions in the following files %include "sunlinsol/sunlinsol_klu.h" - diff --git a/swig/sunlinsol/fsunlinsol_pcg_mod.i b/swig/sunlinsol/fsunlinsol_pcg_mod.i index 81e5704e12..cdd37032fb 100644 --- a/swig/sunlinsol/fsunlinsol_pcg_mod.i +++ b/swig/sunlinsol/fsunlinsol_pcg_mod.i @@ -28,4 +28,3 @@ // Process and wrap functions in the following files %include "sunlinsol/sunlinsol_pcg.h" - diff --git a/swig/sunlinsol/fsunlinsol_spbcgs_mod.i b/swig/sunlinsol/fsunlinsol_spbcgs_mod.i index 57fc087ca2..b65c471f3b 100644 --- a/swig/sunlinsol/fsunlinsol_spbcgs_mod.i +++ b/swig/sunlinsol/fsunlinsol_spbcgs_mod.i @@ -28,4 +28,3 @@ // Process and wrap functions in the following files %include "sunlinsol/sunlinsol_spbcgs.h" - diff --git a/swig/sunlinsol/fsunlinsol_spfgmr_mod.i b/swig/sunlinsol/fsunlinsol_spfgmr_mod.i index d8ec5f7ed5..98de89d846 100644 --- a/swig/sunlinsol/fsunlinsol_spfgmr_mod.i +++ b/swig/sunlinsol/fsunlinsol_spfgmr_mod.i @@ -28,4 +28,3 @@ // Process and wrap functions in the following files %include "sunlinsol/sunlinsol_spfgmr.h" - diff --git a/swig/sunlinsol/fsunlinsol_spgmr_mod.i b/swig/sunlinsol/fsunlinsol_spgmr_mod.i index 06f7963709..9d8bcf53d6 100644 --- a/swig/sunlinsol/fsunlinsol_spgmr_mod.i +++ b/swig/sunlinsol/fsunlinsol_spgmr_mod.i @@ -28,4 +28,3 @@ // Process and wrap functions in the following files %include "sunlinsol/sunlinsol_spgmr.h" - diff --git a/swig/sunlinsol/fsunlinsol_sptfqmr_mod.i b/swig/sunlinsol/fsunlinsol_sptfqmr_mod.i index 02e50554e0..518e1b2de3 100644 --- a/swig/sunlinsol/fsunlinsol_sptfqmr_mod.i +++ b/swig/sunlinsol/fsunlinsol_sptfqmr_mod.i @@ -28,4 +28,3 @@ // Process and wrap functions in the following files %include "sunlinsol/sunlinsol_sptfqmr.h" - From 4528bdfe6b6d109b0289ca709a3161707a0c8133 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Apr 2025 22:34:42 -0500 Subject: [PATCH 059/114] Updated commands to remove SetFromCommandLine routines from some SWIG interfaces; regenerated SWIG --- src/sundials/fmod_int32/fsundials_core_mod.c | 68 --------------- .../fmod_int32/fsundials_core_mod.f90 | 85 ------------------- src/sundials/fmod_int64/fsundials_core_mod.c | 68 --------------- .../fmod_int64/fsundials_core_mod.f90 | 85 ------------------- swig/sunadaptcontroller/fsunadaptcontroller.i | 3 - swig/sundials/fsundials_adaptcontroller.i | 3 + swig/sundials/fsundials_linearsolver.i | 4 +- swig/sunlinsol/fsunlinsol.i | 3 - 8 files changed, 6 insertions(+), 313 deletions(-) diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 18a0a2faaa..71d14a3c36 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -193,22 +193,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -302,20 +286,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include "sundials/sundials_nonlinearsolver.h" @@ -2180,25 +2150,6 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; @@ -2647,25 +2598,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 3b09a5b37b..d20774fac6 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -436,18 +436,6 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - public :: FSUNLinSolSetFromCommandLine public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -556,7 +544,6 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset - public :: FSUNAdaptController_SetFromCommandLine public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -1771,19 +1758,6 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -2072,19 +2046,6 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -4518,29 +4479,6 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function -function FSUNLinSolSetFromCommandLine(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5057,29 +4995,6 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function -function FSUNAdaptController_SetFromCommandLine(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index 6557fbf760..b389504c8d 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -193,22 +193,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -302,20 +286,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include "sundials/sundials_nonlinearsolver.h" @@ -2180,25 +2150,6 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } -SWIGEXPORT int _wrap_FSUNLinSolSetFromCommandLine(SUNLinearSolver farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetFromCommandLine(SUNLinearSolver,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNLinSolSetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; @@ -2647,25 +2598,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetFromCommandLine(SUNAdaptController farg1, SwigArrayWrapper *farg2, int const *farg3, SwigClassWrapper const *farg4) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char **arg4 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (int)(*farg3); - SWIG_check_mutable(*farg4, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetFromCommandLine(SUNAdaptController,char const *,int,char *[])", return 0); - arg4 = (char **)(farg4->cptr); - result = (SUNErrCode)SUNAdaptController_SetFromCommandLine(arg1,(char const *)arg2,arg3,arg4); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 4509f697f6..1058785add 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -436,18 +436,6 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - public :: FSUNLinSolSetFromCommandLine public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -556,7 +544,6 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset - public :: FSUNAdaptController_SetFromCommandLine public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -1771,19 +1758,6 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNLinSolSetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -2072,19 +2046,6 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FSUNAdaptController_SetFromCommandLine") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(SwigClassWrapper) :: farg4 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -4518,29 +4479,6 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function -function FSUNLinSolSetFromCommandLine(s, lsid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNLinSolSetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5057,29 +4995,6 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function -function FSUNAdaptController_SetFromCommandLine(c, cid, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: farg3 -type(SwigClassWrapper) :: farg4 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -farg3 = argc -farg4 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetFromCommandLine(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/swig/sunadaptcontroller/fsunadaptcontroller.i b/swig/sunadaptcontroller/fsunadaptcontroller.i index 01e1817286..5a2a02e2ed 100644 --- a/swig/sunadaptcontroller/fsunadaptcontroller.i +++ b/swig/sunadaptcontroller/fsunadaptcontroller.i @@ -17,9 +17,6 @@ // Include shared configuration %include "../sundials/fsundials.i" -// Ignore command-line processing functions since they are not supported in Fortran -%ignore SUNAdaptController_SetFromCommandLine; - %{ #include "sundials/sundials_adaptcontroller.h" %} diff --git a/swig/sundials/fsundials_adaptcontroller.i b/swig/sundials/fsundials_adaptcontroller.i index 7e19649630..74d8eea519 100644 --- a/swig/sundials/fsundials_adaptcontroller.i +++ b/swig/sundials/fsundials_adaptcontroller.i @@ -14,6 +14,9 @@ // Swig interface file // --------------------------------------------------------------- +// Ignore command-line processing functions since they are not supported in Fortran +%ignore SUNAdaptController_SetFromCommandLine; + %{ #include "sundials/sundials_adaptcontroller.h" %} diff --git a/swig/sundials/fsundials_linearsolver.i b/swig/sundials/fsundials_linearsolver.i index c999802d28..1027ed45b8 100644 --- a/swig/sundials/fsundials_linearsolver.i +++ b/swig/sundials/fsundials_linearsolver.i @@ -14,6 +14,9 @@ // Swig interface file // --------------------------------------------------------------- +// Ignore command-line processing functions since they are not supported in Fortran +%ignore SUNLinSolSetFromCommandLine; + // insert the include into the swig wrapper %{ #include "sundials/sundials_iterative.h" @@ -25,4 +28,3 @@ // Process and wrap functions in the following files %include "sundials/sundials_iterative.h" %include "sundials/sundials_linearsolver.h" - diff --git a/swig/sunlinsol/fsunlinsol.i b/swig/sunlinsol/fsunlinsol.i index 9a9786f5e7..31aeff5507 100644 --- a/swig/sunlinsol/fsunlinsol.i +++ b/swig/sunlinsol/fsunlinsol.i @@ -17,9 +17,6 @@ // Include shared configuration %include "../sundials/fsundials.i" -// Ignore command-line processing functions since they are not supported in Fortran -%ignore SUNLinSolSetFromCommandLine; - %{ #include "sundials/sundials_linearsolver.h" %} From 1882fec505e835131c2e5fe65a76511f662690fb Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Apr 2025 22:55:44 -0500 Subject: [PATCH 060/114] Fixed missing { --- src/ida/ida_cli.c | 203 ++++++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 104 deletions(-) diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 7ffd889ea8..3b1923163a 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -79,130 +79,125 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {"eta_fixed_step_bounds", - IDASetEtaFixedStepBounds}, + static struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, + {"scalar_tolerances", IDASStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / + sizeof(*tworeal_pairs); + + static struct sunKeyActionPair action_pairs[] = + {{"clear_stop_time", IDAClearStopTime}, + {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; + static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + + int i, j, retval; + for (i = 1; i < argc; i++) { - "scalar_tolerances", IDASStolerances - } -}; - -static const int num_tworeal_keys = sizeof(tworeal_pairs) / - sizeof(*tworeal_pairs); + sunbooleantype arg_used = SUNFALSE; -static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", - IDAClearStopTime}, - {"no_inactive_root_warn", - IDASetNoInactiveRootWarn}}; -static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - -int i, j, retval; -for (i = 1; i < argc; i++) -{ - sunbooleantype arg_used = SUNFALSE; - - /* if idaid is supplied, skip command-line arguments that do not begin with idaid; + /* if idaid is supplied, skip command-line arguments that do not begin with idaid; else, skip command-line arguments that do not begin with "ida." */ - size_t offset; - if (strlen(idaid) > 0) - { - if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } - offset = strlen(idaid) + 1; - } - else - { - static const char* prefix = "ida."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + size_t offset; + if (strlen(idaid) > 0) + { + if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } + offset = strlen(idaid) + 1; + } + else + { + static const char* prefix = "ida."; + if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } - /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) - { - retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + /* check all "int" command-line options */ + for (j = 0; j < num_int_keys; j++) { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; + retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + int_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; + } + if (arg_used) break; } - if (arg_used) break; - } - if (arg_used) continue; + if (arg_used) continue; - /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) - { - retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + /* check all long int command-line options */ + for (j = 0; j < num_long_keys; j++) { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; + retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + long_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; + } + if (arg_used) break; } - if (arg_used) break; - } - if (arg_used) continue; + if (arg_used) continue; - /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) - { - retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + /* check all real command-line options */ + for (j = 0; j < num_real_keys; j++) { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; + retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + real_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; + } + if (arg_used) break; } - if (arg_used) break; - } - if (arg_used) continue; + if (arg_used) continue; - /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) - { - retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + /* check all pair-of-real command-line options */ + for (j = 0; j < num_tworeal_keys; j++) { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; + retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; + } + if (arg_used) break; } - if (arg_used) break; - } - if (arg_used) continue; + if (arg_used) continue; - /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) - { - retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); - if (retval != IDA_SUCCESS) + /* check all action command-line options */ + for (j = 0; j < num_action_keys; j++) { - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; + retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + action_pairs[j].key, action_pairs[j].set, + &arg_used); + if (retval != IDA_SUCCESS) + { + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; + } + if (arg_used) break; } - if (arg_used) break; - } - if (arg_used) continue; + if (arg_used) continue; - /* warn for uninterpreted idaid.X arguments */ - IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); -} + /* warn for uninterpreted idaid.X arguments */ + IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, + "WARNING: argument %s was not handled\n", argv[i]); + } -return (IDA_SUCCESS); + return (IDA_SUCCESS); } /*=============================================================== From 5596787b2bc5620598b1e6f05b3859fca89ad241 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 1 Apr 2025 23:05:58 -0500 Subject: [PATCH 061/114] Formatting --- src/ida/ida_cli.c | 16 +++++++++------- .../magmadense/sunlinsol_magmadense.cpp | 6 +++--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 5 +++-- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 5 +++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 3b1923163a..7a3d071684 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -79,15 +79,17 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = - {{"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, - {"scalar_tolerances", IDASStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", + IDASetEtaFixedStepBounds}, + {"scalar_tolerances", + IDASStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = - {{"clear_stop_time", IDAClearStopTime}, - {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; + static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + IDAClearStopTime}, + {"no_inactive_root_warn", + IDASetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index e4bc3e95d3..c40ad38e48 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -62,9 +62,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); - +SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]); /* * ---------------------------------------------------------------------------- diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 8d9a466a3f..403f29826d 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -46,8 +46,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]); /* * ----------------------------------------------------------------- diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index c722dc7d51..0cfed4077f 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -62,8 +62,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT( SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]); /* * ----------------------------------------------------------------- From 09e2303c4737c60bea08a34a0a5a0e15df1b9751 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 22 May 2025 11:46:24 -0400 Subject: [PATCH 062/114] Applied all minor suggestions from code review. Will start on larger changes next --- .../guide/source/Usage/User_callable.rst | 2 +- doc/cvode/guide/source/Usage/index.rst | 7 ++-- doc/cvodes/guide/source/Usage/SIM.rst | 5 +-- doc/ida/guide/source/Usage/index.rst | 2 +- doc/idas/guide/source/Usage/SIM.rst | 2 +- doc/kinsol/guide/source/Usage/index.rst | 2 +- .../SUNAdaptController_Description.rst | 2 +- doc/shared/sunlinsol/SUNLinSol_API.rst | 2 +- doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst | 2 +- src/arkode/arkode_cli.c | 26 ++++++++------ .../imexgus/sunadaptcontroller_imexgus.c | 10 +++--- .../mrihtol/sunadaptcontroller_mrihtol.c | 8 ++--- src/sundials/sundials_cli.c | 35 ++++++++++--------- 13 files changed, 53 insertions(+), 52 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index ad49d1c586..a7cb7aa4c2 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -927,7 +927,7 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`ARKodeSetFromCommandLine`. If the *arkid* argument is ``NULL`` then ``arkode.`` will be used for all ARKODE command-line diff --git a/doc/cvode/guide/source/Usage/index.rst b/doc/cvode/guide/source/Usage/index.rst index f1e72c092f..abb4d5691f 100644 --- a/doc/cvode/guide/source/Usage/index.rst +++ b/doc/cvode/guide/source/Usage/index.rst @@ -887,7 +887,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`CVodeSetFromCommandLine`. If the *cvid* argument is ``NULL`` then ``cvode.`` will be used for all CVODE command-line @@ -1965,7 +1965,7 @@ step size adaptivity. :c:func:`CVodeSetNumStepsEtaMaxEarlyStep`. This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.set_max_early_step". + when using the command-line option "cvid.eta_max_early_step". .. versionadded:: 6.2.0 @@ -2100,9 +2100,6 @@ step size adaptivity. size factor :math:`\eta_{\mathrm{min\_ef}}` can be set with :c:func:`CVodeSetNumFailsEtaMaxErrFail`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.num_efails_eta_max_err_fail". - This routine will be called by :c:func:`CVodeSetFromCommandLine` when using the command-line option "cvid.eta_max_err_fail". diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index 9464f3710b..59195a8367 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -892,7 +892,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`CVodeSetFromCommandLine`. If the *cvid* argument is ``NULL`` then ``cvodes.`` will be used for all CVODES command-line @@ -1710,9 +1710,6 @@ the :c:func:`CVodeSetEpsLin` function. This routine will be called by :c:func:`CVodeSetFromCommandLine` when using the command-line option "cvid.ls_norm_factor". - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.ls_norm_factor". - .. _CVODES.Usage.SIM.optional_input.optin_nls: diff --git a/doc/ida/guide/source/Usage/index.rst b/doc/ida/guide/source/Usage/index.rst index d79a5da30a..ba6138c105 100644 --- a/doc/ida/guide/source/Usage/index.rst +++ b/doc/ida/guide/source/Usage/index.rst @@ -953,7 +953,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`IDASetFromCommandLine`. If the *idaid* argument is ``NULL`` then ``ida.`` will be used for all IDA command-line diff --git a/doc/idas/guide/source/Usage/SIM.rst b/doc/idas/guide/source/Usage/SIM.rst index 44f31a427b..ba7d804c71 100644 --- a/doc/idas/guide/source/Usage/SIM.rst +++ b/doc/idas/guide/source/Usage/SIM.rst @@ -958,7 +958,7 @@ Main solver optional input functions .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`IDASetFromCommandLine`. If the *idaid* argument is ``NULL`` then ``idas.`` will be used for all IDAS command-line diff --git a/doc/kinsol/guide/source/Usage/index.rst b/doc/kinsol/guide/source/Usage/index.rst index 71e56d5d4b..42ad0bb709 100644 --- a/doc/kinsol/guide/source/Usage/index.rst +++ b/doc/kinsol/guide/source/Usage/index.rst @@ -540,7 +540,7 @@ negative, so a test ``retval`` :math:`<0` will catch any error. .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`KINSetFromCommandLine`. If the *kinid* argument is ``NULL`` then ``kinsol.`` will be used for all KINSOL command-line diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 935f35822a..4a1a94dd4b 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -280,7 +280,7 @@ note these requirements below. Additionally, we note the behavior of the base SU .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`SUNAdaptController_SetFromCommandLine`. If the *Cid* argument is ``NULL`` then an implementation-specific prefix will be used for the diff --git a/doc/shared/sunlinsol/SUNLinSol_API.rst b/doc/shared/sunlinsol/SUNLinSol_API.rst index b73b1a013c..4e6997e7e8 100644 --- a/doc/shared/sunlinsol/SUNLinSol_API.rst +++ b/doc/shared/sunlinsol/SUNLinSol_API.rst @@ -253,7 +253,7 @@ function pointer ``NULL`` instead of supplying a dummy routine. .. note:: - The *argc* and *argv* arguments should be those supplied to the user's ``main`` routine. These + The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These are left unchanged by :c:func:`SUNLinSolSetFromCommandLine`. If the *LSid* argument is ``NULL`` then an implementation-specific prefix will be used for the diff --git a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst index ff8d72e014..19cc70ad4d 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst @@ -74,7 +74,7 @@ The module SUNLinSol_SuperLUMT provides the following user-callable routines: This SUNLinearSolver implementation sets the default prefix for command-line arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "superlumt.". + to be "superlumt". .. c:function:: SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 97fa64e06d..3d3648b362 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -108,6 +108,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); int i, j, retval; + SUNErrCode sunretval; sunbooleantype write_parameters = SUNFALSE; for (i = 1; i < argc; i++) { @@ -131,11 +132,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntArg(arkode_mem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) + if (sunretval != SUN_SUCCESS) { + retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_pairs[j].key); @@ -148,11 +150,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetLongArg(arkode_mem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) + if (sunretval != SUN_SUCCESS) { + retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", long_pairs[j].key); @@ -165,11 +168,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetRealArg(arkode_mem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) + if (sunretval != SUN_SUCCESS) { + retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", real_pairs[j].key); @@ -182,11 +186,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(arkode_mem, &i, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) + if (sunretval != SUN_SUCCESS) { + retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", tworeal_pairs[j].key); @@ -199,11 +204,12 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(arkode_mem, &i, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); - if (retval != ARK_SUCCESS) + if (sunretval != SUN_SUCCESS) { + retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", action_pairs[j].key); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index a88a9e3066..d7b6afc15a 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -141,13 +141,13 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, if (strcmp(argv[i] + offset, "params") == 0) { i += 1; - sunrealtype rarg1 = atof(argv[i]); + sunrealtype rarg1 = SUNStrToReal(argv[i]); i += 1; - sunrealtype rarg2 = atof(argv[i]); + sunrealtype rarg2 = SUNStrToReal(argv[i]); i += 1; - sunrealtype rarg3 = atof(argv[i]); + sunrealtype rarg3 = SUNStrToReal(argv[i]); i += 1; - sunrealtype rarg4 = atof(argv[i]); + sunrealtype rarg4 = SUNStrToReal(argv[i]); retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); if (retval != SUN_SUCCESS) { return retval; } @@ -166,7 +166,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, if (strcmp(argv[i] + offset, "error_bias") == 0) { i += 1; - sunrealtype rarg = atof(argv[i]); + sunrealtype rarg = SUNStrToReal(argv[i]); retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 4feb83bb58..6bc6212b51 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -152,11 +152,11 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, if (strcmp(argv[i] + offset, "params") == 0) { i += 1; - sunrealtype rarg1 = atof(argv[i]); + sunrealtype rarg1 = SUNStrToReal(argv[i]); i += 1; - sunrealtype rarg2 = atof(argv[i]); + sunrealtype rarg2 = SUNStrToReal(argv[i]); i += 1; - sunrealtype rarg3 = atof(argv[i]); + sunrealtype rarg3 = SUNStrToReal(argv[i]); retval = SUNAdaptController_SetParams_MRIHTol(C, rarg1, rarg2, rarg3); if (retval != SUN_SUCCESS) { return retval; } continue; @@ -174,7 +174,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, if (strcmp(argv[i] + offset, "error_bias") == 0) { i += 1; - sunrealtype rarg = atof(argv[i]); + sunrealtype rarg = SUNStrToReal(argv[i]); retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index ed5c5a9913..76492e9c0a 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -20,12 +20,13 @@ #include #include #include +#include /*=============================================================== Command-line input utility routines ===============================================================*/ -int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunIntSetFn fname, sunbooleantype* arg_used) { @@ -41,7 +42,7 @@ int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], const size_t offset, return SUN_SUCCESS; } -int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunTwoIntSetFn fname, sunbooleantype* arg_used) { @@ -59,7 +60,7 @@ int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunLongSetFn fname, sunbooleantype* arg_used) { @@ -75,7 +76,7 @@ int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t offset, return SUN_SUCCESS; } -int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunIntRealSetFn fname, sunbooleantype* arg_used) { @@ -85,7 +86,7 @@ int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], (*i) += 1; int iarg = atoi(argv[*i]); (*i) += 1; - sunrealtype rarg = atof(argv[*i]); + sunrealtype rarg = SUNStrToReal(argv[*i]); int retval = fname(mem, iarg, rarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -93,7 +94,7 @@ int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunIntRealRealSetFn fname, sunbooleantype* arg_used) @@ -104,9 +105,9 @@ int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], (*i) += 1; int iarg = atoi(argv[*i]); (*i) += 1; - sunrealtype rarg1 = atof(argv[*i]); + sunrealtype rarg1 = SUNStrToReal(argv[*i]); (*i) += 1; - sunrealtype rarg2 = atof(argv[*i]); + sunrealtype rarg2 = SUNStrToReal(argv[*i]); int retval = fname(mem, iarg, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -114,7 +115,7 @@ int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunIntLongSetFn fname, sunbooleantype* arg_used) { @@ -132,7 +133,7 @@ int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunRealSetFn fname, sunbooleantype* arg_used) { @@ -140,7 +141,7 @@ int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; - sunrealtype rarg = atof(argv[*i]); + sunrealtype rarg = SUNStrToReal(argv[*i]); int retval = fname(mem, rarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -148,7 +149,7 @@ int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, return SUN_SUCCESS; } -int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunTwoRealSetFn fname, sunbooleantype* arg_used) { @@ -156,9 +157,9 @@ int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], if (strcmp(argv[*i] + offset, argtest) == 0) { (*i) += 1; - sunrealtype rarg1 = atof(argv[*i]); + sunrealtype rarg1 = SUNStrToReal(argv[*i]); (*i) += 1; - sunrealtype rarg2 = atof(argv[*i]); + sunrealtype rarg2 = SUNStrToReal(argv[*i]); int retval = fname(mem, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -166,7 +167,7 @@ int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetCharArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunCharSetFn fname, sunbooleantype* arg_used) { @@ -181,7 +182,7 @@ int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], const size_t offset, return SUN_SUCCESS; } -int sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunTwoCharSetFn fname, sunbooleantype* arg_used) { @@ -196,7 +197,7 @@ int sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -int sunCheckAndSetActionArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetActionArg(void* mem, int* i, char* argv[], const size_t offset, const char* argtest, sunActionSetFn fname, sunbooleantype* arg_used) { From a1f74ce23e56ea7465928756a2b914439fddc4ba Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 22 May 2025 11:55:59 -0400 Subject: [PATCH 063/114] Converted other integrator cli files to SUNErrCode --- src/cvode/cvode_cli.c | 26 ++++++++++++++--------- src/cvodes/cvodes_cli.c | 46 +++++++++++++++++++++++++---------------- src/ida/ida_cli.c | 26 ++++++++++++++--------- src/idas/idas_cli.c | 46 +++++++++++++++++++++++++---------------- src/kinsol/kinsol_cli.c | 21 ++++++++++++------- 5 files changed, 101 insertions(+), 64 deletions(-) diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 5081ef6990..53058498ae 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -101,6 +101,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + SUNErrCode sunretval; int i, j, retval; for (i = 1; i < argc; i++) { @@ -124,10 +125,11 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_pairs[j].key); @@ -140,11 +142,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", long_pairs[j].key); @@ -157,11 +160,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", real_pairs[j].key); @@ -174,11 +178,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", tworeal_pairs[j].key); @@ -191,11 +196,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", action_pairs[j].key); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index ecf9362836..14eedcb19e 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -131,6 +131,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); + SUNErrCode sunretval; int i, j, retval; for (i = 1; i < argc; i++) { @@ -154,10 +155,11 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_pairs[j].key); @@ -170,11 +172,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", long_pairs[j].key); @@ -187,11 +190,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", real_pairs[j].key); @@ -204,11 +208,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all pair-of-int command-line options */ for (j = 0; j < num_twoint_keys; j++) { - retval = sunCheckAndSetTwoIntArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoIntArg(cvode_mem, &i, argv, offset, twoint_pairs[j].key, twoint_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", twoint_pairs[j].key); @@ -221,11 +226,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", tworeal_pairs[j].key); @@ -238,11 +244,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", action_pairs[j].key); @@ -255,11 +262,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+real command-line options */ for (j = 0; j < num_int_real_keys; j++) { - retval = sunCheckAndSetIntRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealArg(cvode_mem, &i, argv, offset, int_real_pairs[j].key, int_real_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_real_pairs[j].key); @@ -272,11 +280,12 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+long command-line options */ for (j = 0; j < num_int_long_keys; j++) { - retval = sunCheckAndSetIntLongArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntLongArg(cvode_mem, &i, argv, offset, int_long_pairs[j].key, int_long_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_long_pairs[j].key); @@ -289,12 +298,13 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+real+real command-line options */ for (j = 0; j < num_int_real_real_keys; j++) { - retval = sunCheckAndSetIntRealRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealRealArg(cvode_mem, &i, argv, offset, int_real_real_pairs[j].key, int_real_real_pairs[j].set, &arg_used); - if (retval != CV_SUCCESS) + if (sunretval != CV_SUCCESS) { + retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_real_real_pairs[j].key); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 7a3d071684..52847a4300 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -92,6 +92,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDASetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); + SUNErrCode sunretval; int i, j, retval; for (i = 1; i < argc; i++) { @@ -115,10 +116,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_pairs[j].key); @@ -131,10 +133,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + sunretval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", long_pairs[j].key); @@ -147,10 +150,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + sunretval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", real_pairs[j].key); @@ -163,11 +167,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", tworeal_pairs[j].key); @@ -180,11 +185,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", action_pairs[j].key); diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 57c54fb460..84a96017f0 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -125,6 +125,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); + SUNErrCode sunretval; int i, j, retval; for (i = 1; i < argc; i++) { @@ -148,10 +149,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_pairs[j].key); @@ -164,10 +166,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + sunretval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", long_pairs[j].key); @@ -180,10 +183,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + sunretval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", real_pairs[j].key); @@ -196,11 +200,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all pair-of-int command-line options */ for (j = 0; j < num_twoint_keys; j++) { - retval = sunCheckAndSetTwoIntArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoIntArg(ida_mem, &i, argv, offset, twoint_pairs[j].key, twoint_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", twoint_pairs[j].key); @@ -213,11 +218,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", tworeal_pairs[j].key); @@ -230,11 +236,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", action_pairs[j].key); @@ -247,11 +254,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+real command-line options */ for (j = 0; j < num_int_real_keys; j++) { - retval = sunCheckAndSetIntRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealArg(ida_mem, &i, argv, offset, int_real_pairs[j].key, int_real_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_real_pairs[j].key); @@ -264,11 +272,12 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+long command-line options */ for (j = 0; j < num_int_long_keys; j++) { - retval = sunCheckAndSetIntLongArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntLongArg(ida_mem, &i, argv, offset, int_long_pairs[j].key, int_long_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_long_pairs[j].key); @@ -281,12 +290,13 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+real+real command-line options */ for (j = 0; j < num_int_real_real_keys; j++) { - retval = sunCheckAndSetIntRealRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealRealArg(ida_mem, &i, argv, offset, int_real_real_pairs[j].key, int_real_real_pairs[j].set, &arg_used); - if (retval != IDA_SUCCESS) + if (sunretval != IDA_SUCCESS) { + retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_real_real_pairs[j].key); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 865c6f5489..53d913aa0b 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -74,6 +74,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); + SUNErrCode sunretval; int i, j, retval; for (i = 1; i < argc; i++) { @@ -97,10 +98,11 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg(kinmem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(kinmem, &i, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); - if (retval != KIN_SUCCESS) + if (sunretval != KIN_SUCCESS) { + retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", int_pairs[j].key); @@ -113,10 +115,11 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg(kinmem, &i, argv, offset, long_pairs[j].key, + sunretval = sunCheckAndSetLongArg(kinmem, &i, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); - if (retval != KIN_SUCCESS) + if (sunretval != KIN_SUCCESS) { + retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", long_pairs[j].key); @@ -129,10 +132,11 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg(kinmem, &i, argv, offset, real_pairs[j].key, + sunretval = sunCheckAndSetRealArg(kinmem, &i, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); - if (retval != KIN_SUCCESS) + if (sunretval != KIN_SUCCESS) { + retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", real_pairs[j].key); @@ -145,11 +149,12 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - retval = sunCheckAndSetTwoRealArg(kinmem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(kinmem, &i, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); - if (retval != KIN_SUCCESS) + if (sunretval != KIN_SUCCESS) { + retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s", tworeal_pairs[j].key); From 87c67aee3f6ba9f5fa0808fa711ad1ef2073dcae Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 22 May 2025 12:04:04 -0400 Subject: [PATCH 064/114] Converted 'static struct sunKey*' to 'static const struct sunKey*' --- src/arkode/arkode_arkstep_io.c | 4 ++-- src/arkode/arkode_cli.c | 10 +++++----- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_lsrkstep_io.c | 8 ++++---- src/arkode/arkode_sprkstep_io.c | 4 ++-- src/cvode/cvode_cli.c | 10 +++++----- src/cvodes/cvodes_cli.c | 18 +++++++++--------- src/ida/ida_cli.c | 10 +++++----- src/idas/idas_cli.c | 18 +++++++++--------- src/kinsol/kinsol_cli.c | 8 ++++---- 10 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index ad707655f6..d2496aa44b 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -638,12 +638,12 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyTwoCharPair twochar_pairs[] = { + static const struct sunKeyTwoCharPair twochar_pairs[] = { {"table_names", ARKStepSetTableName}}; static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); - static struct sunKeyActionPair action_pairs[] = {{"set_explicit", + static const struct sunKeyActionPair action_pairs[] = {{"set_explicit", ARKStepSetExplicit}, {"set_implicit", ARKStepSetImplicit}, diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 3d3648b362..0bf7caaf4a 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -43,7 +43,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, ark_mem = (ARKodeMem)arkode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = + static const struct sunKeyIntPair int_pairs[] = {{"order", ARKodeSetOrder}, {"interpolant_degree", ARKodeSetInterpolantDegree}, {"linear", ARKodeSetLinear}, @@ -62,13 +62,13 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = {{"max_num_steps", + static const struct sunKeyLongPair long_pairs[] = {{"max_num_steps", ARKodeSetMaxNumSteps}, {"jac_eval_frequency", ARKodeSetJacEvalFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = + static const struct sunKeyRealPair real_pairs[] = {{"nonlin_crdown", ARKodeSetNonlinCRDown}, {"nonlin_rdiv", ARKodeSetNonlinRDiv}, {"delta_gamma_max", ARKodeSetDeltaGammaMax}, @@ -93,14 +93,14 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", + static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", ARKodeSStolerances}, {"fixed_step_bounds", ARKodeSetFixedStepBounds}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = + static const struct sunKeyActionPair action_pairs[] = {{"nonlinear", ARKodeSetNonlinear}, {"clear_stop_time", ARKodeClearStopTime}, {"no_inactive_root_warn", ARKodeSetNoInactiveRootWarn}, diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index b777769817..cfea0a5ffd 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -265,7 +265,7 @@ int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = { + static const struct sunKeyCharPair char_pairs[] = { {"table_name", ERKStepSetTableName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index c096f0002e..b679c05513 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -501,23 +501,23 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = {{"sts_method", + static const struct sunKeyCharPair char_pairs[] = {{"sts_method", LSRKStepSetSTSMethodByName}, {"ssp_method", LSRKStepSetSSPMethodByName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); - static struct sunKeyLongPair long_pairs[] = { + static const struct sunKeyLongPair long_pairs[] = { {"dom_eig_frequency", LSRKStepSetDomEigFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyIntPair int_pairs[] = {{"max_num_stages", + static const struct sunKeyIntPair int_pairs[] = {{"max_num_stages", LSRKStepSetMaxNumStages}, {"num_ssp_stages", LSRKStepSetNumSSPStages}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyRealPair real_pairs[] = { + static const struct sunKeyRealPair real_pairs[] = { {"dom_eig_safety_factor", LSRKStepSetDomEigSafetyFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 4c164683a5..8334ed9b41 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -218,11 +218,11 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], const size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyCharPair char_pairs[] = { + static const struct sunKeyCharPair char_pairs[] = { {"method_name", SPRKStepSetMethodName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); - static struct sunKeyIntPair int_pairs[] = { + static const struct sunKeyIntPair int_pairs[] = { {"use_compensated_sums", SPRKStepSetUseCompensatedSums}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 53058498ae..f2181297b5 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -43,7 +43,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, cv_mem = (CVodeMem)cvode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = + static const struct sunKeyIntPair int_pairs[] = {{"max_conv_fails", CVodeSetMaxConvFails}, {"max_err_test_fails", CVodeSetMaxErrTestFails}, {"max_hnil_warns", CVodeSetMaxHnilWarns}, @@ -58,7 +58,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = + static const struct sunKeyLongPair long_pairs[] = {{"lsetup_frequency", CVodeSetLSetupFrequency}, {"max_num_steps", CVodeSetMaxNumSteps}, {"monitor_frequency", CVodeSetMonitorFrequency}, @@ -67,7 +67,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"proj_frequency", CVodeSetProjFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = + static const struct sunKeyRealPair real_pairs[] = {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, {"init_step", CVodeSetInitStep}, {"max_step", CVodeSetMaxStep}, @@ -88,14 +88,14 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", + static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, {"scalar_tolerances", CVodeSStolerances}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + static const struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", CVodeClearStopTime}, {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 14eedcb19e..cd659d58ac 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -43,7 +43,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, cv_mem = (CVodeMem)cvode_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = + static const struct sunKeyIntPair int_pairs[] = {{"max_conv_fails", CVodeSetMaxConvFails}, {"max_err_test_fails", CVodeSetMaxErrTestFails}, {"max_hnil_warns", CVodeSetMaxHnilWarns}, @@ -61,7 +61,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = + static const struct sunKeyLongPair long_pairs[] = {{"lsetup_frequency", CVodeSetLSetupFrequency}, {"max_num_steps", CVodeSetMaxNumSteps}, {"monitor_frequency", CVodeSetMonitorFrequency}, @@ -69,7 +69,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"proj_frequency", CVodeSetProjFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = + static const struct sunKeyRealPair real_pairs[] = {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, {"init_step", CVodeSetInitStep}, {"max_step", CVodeSetMaxStep}, @@ -90,27 +90,27 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = + static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, {"scalar_tolerances", CVodeSStolerances}, {"quad_scalar_tolerances", CVodeQuadSStolerances}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyTwoIntPair twoint_pairs[] = + static const struct sunKeyTwoIntPair twoint_pairs[] = {{"max_order_b", CVodeSetMaxOrdB}, {"stab_lim_det_b", CVodeSetStabLimDetB}, {"quad_err_con_b", CVodeSetQuadErrConB}, {"linear_solution_scaling_b", CVodeSetLinearSolutionScalingB}}; static const int num_twoint_keys = sizeof(twoint_pairs) / sizeof(*twoint_pairs); - static struct sunKeyActionPair action_pairs[] = + static const struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", CVodeClearStopTime}, {"adj_no_sensi", CVodeSetAdjNoSensi}, {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - static struct sunKeyIntRealPair int_real_pairs[] = + static const struct sunKeyIntRealPair int_real_pairs[] = {{"sens_dq_method", CVodeSetSensDQMethod}, {"init_step_b", CVodeSetInitStepB}, {"min_step_b", CVodeSetMinStepB}, @@ -120,13 +120,13 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_int_real_keys = sizeof(int_real_pairs) / sizeof(*int_real_pairs); - static struct sunKeyIntRealRealPair int_real_real_pairs[] = + static const struct sunKeyIntRealRealPair int_real_real_pairs[] = {{"scalar_tolerances_b", CVodeSStolerancesB}, {"quad_scalar_tolerances_b", CVodeQuadSStolerancesB}}; static const int num_int_real_real_keys = sizeof(int_real_real_pairs) / sizeof(*int_real_real_pairs); - static struct sunKeyIntLongPair int_long_pairs[] = { + static const struct sunKeyIntLongPair int_long_pairs[] = { {"max_num_steps_b", CVodeSetMaxNumStepsB}}; static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 52847a4300..47613e5cc8 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -42,7 +42,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDA_mem = (IDAMem)ida_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = + static const struct sunKeyIntPair int_pairs[] = {{"max_num_steps_ic", IDASetMaxNumStepsIC}, {"max_num_jacs_ic", IDASetMaxNumJacsIC}, {"max_num_iters_ic", IDASetMaxNumItersIC}, @@ -56,11 +56,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"linear_solution_scaling", IDASetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { + static const struct sunKeyLongPair long_pairs[] = { {"max_num_steps", IDASetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = + static const struct sunKeyRealPair real_pairs[] = {{"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, {"step_tolerance_ic", IDASetStepToleranceIC}, {"delta_cj_lsetup", IDASetDeltaCjLSetup}, @@ -79,14 +79,14 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", + static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, {"scalar_tolerances", IDASStolerances}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", + static const struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", IDAClearStopTime}, {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 84a96017f0..d9b428df3d 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -42,7 +42,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDA_mem = (IDAMem)ida_mem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = + static const struct sunKeyIntPair int_pairs[] = {{"max_num_steps_ic", IDASetMaxNumStepsIC}, {"max_num_jacs_ic", IDASetMaxNumJacsIC}, {"max_num_iters_ic", IDASetMaxNumItersIC}, @@ -60,11 +60,11 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"linear_solution_scaling", IDASetLinearSolutionScaling}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = { + static const struct sunKeyLongPair long_pairs[] = { {"max_num_steps", IDASetMaxNumSteps}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = + static const struct sunKeyRealPair real_pairs[] = {{"nonlin_conv_coef_ic", IDASetNonlinConvCoefIC}, {"step_tolerance_ic", IDASetStepToleranceIC}, {"delta_cj_lsetup", IDASetDeltaCjLSetup}, @@ -83,28 +83,28 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = + static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, {"scalar_tolerances", IDASStolerances}, {"quad_scalar_tolerances", IDAQuadSStolerances}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static struct sunKeyTwoIntPair twoint_pairs[] = + static const struct sunKeyTwoIntPair twoint_pairs[] = {{"max_order_b", IDASetMaxOrdB}, {"suppress_alg_b", IDASetSuppressAlgB}, {"quad_err_con_b", IDASetQuadErrConB}, {"linear_solution_scaling_b", IDASetLinearSolutionScalingB}}; static const int num_twoint_keys = sizeof(twoint_pairs) / sizeof(*twoint_pairs); - static struct sunKeyActionPair action_pairs[] = + static const struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", IDAClearStopTime}, {"no_inactive_root_warn", IDASetNoInactiveRootWarn}, {"sens_toggle_off", IDASensToggleOff}, {"adj_no_sensi", IDAAdjSetNoSensi}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - static struct sunKeyIntRealPair int_real_pairs[] = + static const struct sunKeyIntRealPair int_real_pairs[] = {{"sens_dq_method", IDASetSensDQMethod}, {"init_step_b", IDASetInitStepB}, {"max_step_b", IDASetMaxStepB}, @@ -114,13 +114,13 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, static const int num_int_real_keys = sizeof(int_real_pairs) / sizeof(*int_real_pairs); - static struct sunKeyIntRealRealPair int_real_real_pairs[] = + static const struct sunKeyIntRealRealPair int_real_real_pairs[] = {{"scalar_tolerances_b", IDASStolerancesB}, {"quad_scalar_tolerances_b", IDAQuadSStolerancesB}}; static const int num_int_real_real_keys = sizeof(int_real_real_pairs) / sizeof(*int_real_real_pairs); - static struct sunKeyIntLongPair int_long_pairs[] = { + static const struct sunKeyIntLongPair int_long_pairs[] = { {"max_num_steps_b", IDASetMaxNumStepsB}}; static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 53d913aa0b..52cbf01a1c 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -41,7 +41,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ kin_mem = (KINMem)kinmem; /* Set lists of command-line arguments, and the corresponding set routines */ - static struct sunKeyIntPair int_pairs[] = {{"orth_aa", KINSetOrthAA}, + static const struct sunKeyIntPair int_pairs[] = {{"orth_aa", KINSetOrthAA}, {"return_newest", KINSetReturnNewest}, {"no_init_setup", KINSetNoInitSetup}, {"no_res_mon", KINSetNoResMon}, @@ -49,7 +49,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ {"no_min_eps", KINSetNoMinEps}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - static struct sunKeyLongPair long_pairs[] = + static const struct sunKeyLongPair long_pairs[] = {{"m_aa", KINSetMAA}, {"delay_aa", KINSetDelayAA}, {"num_max_iters", KINSetNumMaxIters}, @@ -58,7 +58,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ {"max_beta_fails", KINSetMaxBetaFails}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); - static struct sunKeyRealPair real_pairs[] = + static const struct sunKeyRealPair real_pairs[] = {{"damping", KINSetDamping}, {"damping_aa", KINSetDampingAA}, {"eta_const_value", KINSetEtaConstValue}, @@ -69,7 +69,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ {"scaled_step_tol", KINSetScaledStepTol}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static struct sunKeyTwoRealPair tworeal_pairs[] = + static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_params", KINSetEtaParams}, {"res_mon_params", KINSetResMonParams}}; static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); From 4f1f51c49c5692256beba2d2bb8d3ca231ede430 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 22 May 2025 14:49:10 -0400 Subject: [PATCH 065/114] Converted *SetFromCommandLine routines to treat NULL-valued IDs as the default prefix --- examples/arkode/C_serial/ark_analytic.c | 2 +- examples/arkode/C_serial/ark_heat1D.c | 4 ++-- examples/cvode/CXX_serial/cv_kpr.cpp | 2 +- examples/cvodes/serial/cvsAnalytic_mels.c | 2 +- examples/ida/serial/idaAnalytic_mels.c | 2 +- examples/idas/serial/idasAnalytic_mels.c | 2 +- examples/kinsol/serial/kinRoberts_fp.c | 2 +- src/arkode/arkode_cli.c | 2 +- src/cvode/cvode_cli.c | 2 +- src/cvodes/cvodes_cli.c | 2 +- src/ida/ida_cli.c | 2 +- src/idas/idas_cli.c | 2 +- src/kinsol/kinsol_cli.c | 2 +- .../imexgus/sunadaptcontroller_imexgus.c | 2 +- .../mrihtol/sunadaptcontroller_mrihtol.c | 2 +- .../soderlind/sunadaptcontroller_soderlind.c | 20 +++++++++---------- src/sunlinsol/klu/sunlinsol_klu.c | 2 +- .../magmadense/sunlinsol_magmadense.cpp | 2 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 2 +- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 2 +- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 2 +- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 2 +- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 2 +- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- 24 files changed, 34 insertions(+), 34 deletions(-) diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index cd88fb3ba0..b4bcaad89f 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -131,7 +131,7 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Override any current settings with command-line options */ - flag = ARKodeSetFromCommandLine(arkode_mem, "", argc, argv); + flag = ARKodeSetFromCommandLine(arkode_mem, NULL, argc, argv); if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } /* Open output stream for results, output comment line */ diff --git a/examples/arkode/C_serial/ark_heat1D.c b/examples/arkode/C_serial/ark_heat1D.c index 7369e8010a..3505db8bb9 100644 --- a/examples/arkode/C_serial/ark_heat1D.c +++ b/examples/arkode/C_serial/ark_heat1D.c @@ -151,9 +151,9 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Override any current settings with command-line options */ - flag = ARKodeSetFromCommandLine(arkode_mem, "", argc, argv); + flag = ARKodeSetFromCommandLine(arkode_mem, NULL, argc, argv); if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } - flag = SUNLinSolSetFromCommandLine(LS, "", argc, argv); + flag = SUNLinSolSetFromCommandLine(LS, NULL, argc, argv); if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } /* output mesh to disk */ diff --git a/examples/cvode/CXX_serial/cv_kpr.cpp b/examples/cvode/CXX_serial/cv_kpr.cpp index 628be80d9c..fe150f2c22 100644 --- a/examples/cvode/CXX_serial/cv_kpr.cpp +++ b/examples/cvode/CXX_serial/cv_kpr.cpp @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) if (check_flag(flag, "CVodeSetUserData")) { return 1; } // Override any current settings with command-line options - flag = CVodeSetFromCommandLine(cvode_mem, "", argc, argv); + flag = CVodeSetFromCommandLine(cvode_mem, NULL, argc, argv); if (check_flag(flag, "CVodeSetFromCommandLine")) { return 1; } // Initial time and fist output time diff --git a/examples/cvodes/serial/cvsAnalytic_mels.c b/examples/cvodes/serial/cvsAnalytic_mels.c index b660180c6f..24f249a3e9 100644 --- a/examples/cvodes/serial/cvsAnalytic_mels.c +++ b/examples/cvodes/serial/cvsAnalytic_mels.c @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeSetLinearSolver", 1)) { return 1; } /* Override any current settings with command-line options */ - retval = CVodeSetFromCommandLine(cvode_mem, "", argc, argv); + retval = CVodeSetFromCommandLine(cvode_mem, NULL, argc, argv); if (check_retval(&retval, "CVodeSetFromCommandLine", 1)) { return (1); } /* In loop, call CVode, print results, and test for error. diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index 37ee3c54ad..8eda72316d 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDASetLinearSolver", 1)) { return (1); } /* Override any current settings with command-line options */ - retval = IDASetFromCommandLine(ida_mem, "", argc, argv); + retval = IDASetFromCommandLine(ida_mem, NULL, argc, argv); if (check_retval(&retval, "IDASetFromCommandLine", 1)) { return 1; } /* In loop, call IDASolve, print results, and test for error. diff --git a/examples/idas/serial/idasAnalytic_mels.c b/examples/idas/serial/idasAnalytic_mels.c index de8ad645d2..8a981d68c2 100644 --- a/examples/idas/serial/idasAnalytic_mels.c +++ b/examples/idas/serial/idasAnalytic_mels.c @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDASetLinearSolver", 1)) { return (1); } /* Override any current settings with command-line options */ - retval = IDASetFromCommandLine(ida_mem, "", argc, argv); + retval = IDASetFromCommandLine(ida_mem, NULL, argc, argv); if (check_retval(&retval, "IDASetFromCommandLine", 1)) { return 1; } /* In loop, call IDASolve, print results, and test for error. diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c index 2294549c4f..de7a60d11a 100644 --- a/examples/kinsol/serial/kinRoberts_fp.c +++ b/examples/kinsol/serial/kinRoberts_fp.c @@ -149,7 +149,7 @@ int main(int argc, char* argv[]) /* Override any current settings with command-line options */ - retval = KINSetFromCommandLine(kmem, "", argc, argv); + retval = KINSetFromCommandLine(kmem, NULL, argc, argv); if (check_retval(&retval, "KINSetFromCommandLine", 1)) { return (1); } /* ------------- diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 0bf7caaf4a..48906691ad 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -117,7 +117,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* if arkid is supplied, skip command-line arguments that do not begin with arkid; else, skip command-line arguments that do not begin with "arkode." */ size_t offset; - if (strlen(arkid) > 0) + if (arkid != NULL) { if (strncmp(argv[i], arkid, strlen(arkid)) != 0) { continue; } offset = strlen(arkid) + 1; diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index f2181297b5..59eeeb77ed 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -110,7 +110,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* if cvid is supplied, skip command-line arguments that do not begin with cvid; else, skip command-line arguments that do not begin with "cvode." */ size_t offset; - if (strlen(cvid) > 0) + if (cvid != NULL) { if (strncmp(argv[i], cvid, strlen(cvid)) != 0) { continue; } offset = strlen(cvid) + 1; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index cd659d58ac..5530090635 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -140,7 +140,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* if cvid is supplied, skip command-line arguments that do not begin with cvid; else, skip command-line arguments that do not begin with "cvodes." */ size_t offset; - if (strlen(cvid) > 0) + if (cvid != NULL) { if (strncmp(argv[i], cvid, strlen(cvid)) != 0) { continue; } offset = strlen(cvid) + 1; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 47613e5cc8..b39bf7a7d7 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -101,7 +101,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* if idaid is supplied, skip command-line arguments that do not begin with idaid; else, skip command-line arguments that do not begin with "ida." */ size_t offset; - if (strlen(idaid) > 0) + if (idaid != NULL) { if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } offset = strlen(idaid) + 1; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index d9b428df3d..7b11b9b4bd 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -134,7 +134,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* if idaid is supplied, skip command-line arguments that do not begin with idaid; else, skip command-line arguments that do not begin with "idas." */ size_t offset; - if (strlen(idaid) > 0) + if (idaid != NULL) { if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } offset = strlen(idaid) + 1; diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 52cbf01a1c..f5092ec5db 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -83,7 +83,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* if kinid is supplied, skip command-line arguments that do not begin with kinid; else, skip command-line arguments that do not begin with "kinsol." */ size_t offset; - if (strlen(kinid) > 0) + if (kinid != NULL) { if (strncmp(argv[i], kinid, strlen(kinid)) != 0) { continue; } offset = strlen(kinid) + 1; diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index d7b6afc15a..4ffa16da6e 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -125,7 +125,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; - if (strlen(Cid) > 0) + if (Cid != NULL) { if (strncmp(argv[i], Cid, strlen(Cid)) != 0) { continue; } offset = strlen(Cid) + 1; diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 6bc6212b51..b1a7a15336 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -136,7 +136,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; - if (strlen(Cid) > 0) + if (Cid != NULL) { if (strncmp(argv[i], Cid, strlen(Cid)) != 0) { continue; } offset = strlen(Cid) + 1; diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 4868dc839d..f3ea71e5ad 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -135,16 +135,16 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t SOffset, PIDOffset, PIOffset, IOffset, ExpGusOffset, ImpGusOffset; - const char* SPrefix = (strlen(Cid) > 0) ? Cid - : "sunadaptcontroller_soderlind."; - const char* PIDPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pid."; - const char* PIPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_pi."; - const char* IPrefix = (strlen(Cid) > 0) ? Cid : "sunadaptcontroller_i."; - const char* ExpGusPrefix = (strlen(Cid) > 0) ? Cid - : "sunadaptcontroller_expgus."; - const char* ImpGusPrefix = (strlen(Cid) > 0) ? Cid - : "sunadaptcontroller_impgus."; - if (strlen(Cid) > 0) + const char* SPrefix = (Cid != NULL) ? Cid + : "sunadaptcontroller_soderlind."; + const char* PIDPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_pid."; + const char* PIPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_pi."; + const char* IPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_i."; + const char* ExpGusPrefix = (Cid != NULL) ? Cid + : "sunadaptcontroller_expgus."; + const char* ImpGusPrefix = (Cid != NULL) ? Cid + : "sunadaptcontroller_impgus."; + if (Cid != NULL) { SOffset = PIDOffset = PIOffset = IOffset = ExpGusOffset = ImpGusOffset = strlen(Cid) + 1; diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 599b097dc7..301b7c975c 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -197,7 +197,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index c40ad38e48..f0dead6bfc 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -259,7 +259,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index c61b582c81..397ca82818 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -155,7 +155,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 4977f42869..c4eef75cc1 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -177,7 +177,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSi /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 10be55b574..1e7e187ffb 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -165,7 +165,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSi /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spfgmr." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 3459ae8a37..4547c80b83 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -162,7 +162,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spgmr." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 403f29826d..87068a5760 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -179,7 +179,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 0cfed4077f..7c81931da9 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -234,7 +234,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (strlen(LSid) > 0) + if (LSid != __DARWIN_NULL) { if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; From 2728204bd9a38e6b8bc15193b50066afcf7132dc Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 22 May 2025 15:08:48 -0400 Subject: [PATCH 066/114] Removed 'const' from offset argument to ARKODE stepper-specific SetFromCommandLine routines --- src/arkode/arkode_arkstep_impl.h | 2 +- src/arkode/arkode_arkstep_io.c | 2 +- src/arkode/arkode_erkstep_impl.h | 2 +- src/arkode/arkode_erkstep_io.c | 2 +- src/arkode/arkode_impl.h | 2 +- src/arkode/arkode_lsrkstep_impl.h | 2 +- src/arkode/arkode_lsrkstep_io.c | 2 +- src/arkode/arkode_mristep_impl.h | 2 +- src/arkode/arkode_mristep_io.c | 2 +- src/arkode/arkode_sprkstep_impl.h | 2 +- src/arkode/arkode_sprkstep_io.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 23a40b0798..1f20d788ad 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -191,7 +191,7 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used); + size_t offset, sunbooleantype* arg_used); int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int arkStep_SetDefaults(ARKodeMem ark_mem); int arkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index d2496aa44b..38c2e8ca8d 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -635,7 +635,7 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Provides command-line control over ARKStep-specific "set" routines. ---------------------------------------------------------------*/ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used) + size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ static const struct sunKeyTwoCharPair twochar_pairs[] = { diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 7cae0be9d1..defea5d419 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -82,7 +82,7 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used); + size_t offset, sunbooleantype* arg_used); int erkStep_SetDefaults(ARKodeMem ark_mem); int erkStep_SetOrder(ARKodeMem ark_mem, int ord); int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index cfea0a5ffd..74b9623420 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -262,7 +262,7 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Provides command-line control over ERKStep-specific "set" routines. ---------------------------------------------------------------*/ int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used) + size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ static const struct sunKeyCharPair char_pairs[] = { diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 6dca949bfc..2577833871 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -225,7 +225,7 @@ typedef int (*ARKTimestepGetNumRhsEvals)(ARKodeMem ark_mem, int partition_index, typedef int (*ARKTimestepSetStepDirection)(ARKodeMem ark_mem, sunrealtype stepdir); typedef int (*ARKTimestepSetFromCommandLine)(ARKodeMem ark_mem, int* i, - char* argv[], const size_t offset, + char* argv[], size_t offset, sunbooleantype* arg_used); /* time stepper interface functions -- temporal adaptivity */ diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index d0866dc5bb..35262298b5 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -187,7 +187,7 @@ int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used); + size_t offset, sunbooleantype* arg_used); int lsrkStep_SetDefaults(ARKodeMem ark_mem); int lsrkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index b679c05513..35babd26fe 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -498,7 +498,7 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) Provides command-line control over LSRKStep-specific "set" routines. ---------------------------------------------------------------*/ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used) + size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ static const struct sunKeyCharPair char_pairs[] = {{"sts_method", diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 7eeae7da4a..e140c26b0f 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -231,7 +231,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used); + size_t offset, sunbooleantype* arg_used); int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C); int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); int mriStep_SetDefaults(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 09b1daa0e6..42fca6b8a5 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -255,7 +255,7 @@ int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) Provides command-line control over MRIStep-specific "set" routines. ---------------------------------------------------------------*/ int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used) + size_t offset, sunbooleantype* arg_used) { /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling table; however, these may be specified by name, so here we'll support diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index a67ffc29e8..e19ba98dee 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -74,7 +74,7 @@ int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used); + size_t offset, sunbooleantype* arg_used); int sprkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int sprkStep_SetDefaults(ARKodeMem ark_mem); int sprkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 8334ed9b41..cee60c3ceb 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -215,7 +215,7 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) Provides command-line control over SPRKStep-specific "set" routines. ---------------------------------------------------------------*/ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], - const size_t offset, sunbooleantype* arg_used) + size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ static const struct sunKeyCharPair char_pairs[] = { From c82a9542229beeeecf901ec6c12836722c59a644 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 22 May 2025 18:43:24 -0400 Subject: [PATCH 067/114] Additional fixes to address PR reviews --- src/arkode/arkode_arkstep_impl.h | 2 +- src/arkode/arkode_arkstep_io.c | 6 +- src/arkode/arkode_cli.c | 50 +++---- src/arkode/arkode_erkstep_impl.h | 2 +- src/arkode/arkode_erkstep_io.c | 4 +- src/arkode/arkode_impl.h | 2 +- src/arkode/arkode_lsrkstep_impl.h | 2 +- src/arkode/arkode_lsrkstep_io.c | 10 +- src/arkode/arkode_mristep_impl.h | 2 +- src/arkode/arkode_mristep_io.c | 12 +- src/arkode/arkode_sprkstep_impl.h | 2 +- src/arkode/arkode_sprkstep_io.c | 6 +- src/cvode/cvode_cli.c | 20 +-- src/cvodes/cvodes_cli.c | 28 ++-- src/ida/ida_cli.c | 20 +-- src/idas/idas_cli.c | 28 ++-- src/kinsol/kinsol_cli.c | 18 +-- .../imexgus/sunadaptcontroller_imexgus.c | 36 ++--- .../mrihtol/sunadaptcontroller_mrihtol.c | 32 ++--- .../soderlind/sunadaptcontroller_soderlind.c | 128 +++++++++--------- src/sundials/sundials_cli.c | 108 +++++++-------- src/sundials/sundials_cli.h | 22 +-- src/sunlinsol/klu/sunlinsol_klu.c | 14 +- .../magmadense/sunlinsol_magmadense.cpp | 14 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 26 ++-- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 26 ++-- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 32 ++--- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 32 ++--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 26 ++-- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 14 +- 30 files changed, 362 insertions(+), 362 deletions(-) diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 1f20d788ad..9055dddbf8 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -190,7 +190,7 @@ int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int arkStep_SetDefaults(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 38c2e8ca8d..a0d670c63b 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -634,7 +634,7 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Provides command-line control over ARKStep-specific "set" routines. ---------------------------------------------------------------*/ -int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ @@ -654,7 +654,7 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], int j, retval; for (j = 0; j < num_twochar_keys; j++) { - retval = sunCheckAndSetTwoCharArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetTwoCharArg((void*)ark_mem, argidx, argv, offset, twochar_pairs[j].key, twochar_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -670,7 +670,7 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - retval = sunCheckAndSetActionArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetActionArg((void*)ark_mem, argidx, argv, offset, action_pairs[j].key, action_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 48906691ad..f8bf5df11e 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -107,10 +107,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"reset_accumulated_error", ARKodeResetAccumulatedError}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - int i, j, retval; + int idx, j, retval; SUNErrCode sunretval; sunbooleantype write_parameters = SUNFALSE; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -119,20 +119,20 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, size_t offset; if (arkid != NULL) { - if (strncmp(argv[i], arkid, strlen(arkid)) != 0) { continue; } + if (strncmp(argv[idx], arkid, strlen(arkid)) != 0) { continue; } offset = strlen(arkid) + 1; } else { static const char* prefix = "arkode."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntArg(arkode_mem, &idx, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) @@ -150,7 +150,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetLongArg(arkode_mem, &idx, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) @@ -168,7 +168,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetRealArg(arkode_mem, &idx, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) @@ -186,7 +186,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - sunretval = sunCheckAndSetTwoRealArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(arkode_mem, &idx, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) @@ -204,7 +204,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - sunretval = sunCheckAndSetActionArg(arkode_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(arkode_mem, &idx, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) @@ -221,19 +221,19 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /*** handle all remaining command-line options ***/ - if (strcmp(argv[i] + offset, "interpolant_type") == 0) + if (strcmp(argv[idx] + offset, "interpolant_type") == 0) { - i++; + idx++; retval = ARK_ILL_INPUT; - if (strcmp(argv[i], "ARK_INTERP_HERMITE") == 0) + if (strcmp(argv[idx], "ARK_INTERP_HERMITE") == 0) { retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); } - else if (strcmp(argv[i], "ARK_INTERP_LAGRANGE") == 0) + else if (strcmp(argv[idx], "ARK_INTERP_LAGRANGE") == 0) { retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); } - else if (strcmp(argv[i], "ARK_INTERP_NONE") == 0) + else if (strcmp(argv[idx], "ARK_INTERP_NONE") == 0) { retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_NONE); } @@ -241,30 +241,30 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[i - 1], argv[i]); + argv[idx - 1], argv[idx]); return retval; } arg_used = SUNTRUE; continue; } - if (strcmp(argv[i] + offset, "accum_error_type") == 0) + if (strcmp(argv[idx] + offset, "accum_error_type") == 0) { - i++; + idx++; retval = ARK_ILL_INPUT; - if (strcmp(argv[i], "ARK_ACCUMERROR_NONE") == 0) + if (strcmp(argv[idx], "ARK_ACCUMERROR_NONE") == 0) { retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_NONE); } - else if (strcmp(argv[i], "ARK_ACCUMERROR_MAX") == 0) + else if (strcmp(argv[idx], "ARK_ACCUMERROR_MAX") == 0) { retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_MAX); } - else if (strcmp(argv[i], "ARK_ACCUMERROR_SUM") == 0) + else if (strcmp(argv[idx], "ARK_ACCUMERROR_SUM") == 0) { retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_SUM); } - else if (strcmp(argv[i], "ARK_ACCUMERROR_AVG") == 0) + else if (strcmp(argv[idx], "ARK_ACCUMERROR_AVG") == 0) { retval = ARKodeSetAccumulatedErrorType(arkode_mem, ARK_ACCUMERROR_AVG); } @@ -272,14 +272,14 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument: %s %s", - argv[i - 1], argv[i]); + argv[idx - 1], argv[idx]); return retval; } arg_used = SUNTRUE; continue; } - if (strcmp(argv[i] + offset, "write_parameters") == 0) + if (strcmp(argv[idx] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; arg_used = SUNTRUE; @@ -290,7 +290,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, process this command-line argument */ if (ark_mem->step_setfromcommandline) { - retval = ark_mem->step_setfromcommandline(ark_mem, &i, argv, offset, + retval = ark_mem->step_setfromcommandline(ark_mem, &idx, argv, offset, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) { continue; } @@ -298,7 +298,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* warn for uninterpreted arkid.X arguments */ arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[idx]); } /* Call ARKodeWriteParameters (if requested) now that all diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index defea5d419..f92bf4cd74 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -81,7 +81,7 @@ int erkStep_Init(ARKodeMem ark_mem, sunrealtype tout, int init_type); int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); int erkStep_SetDefaults(ARKodeMem ark_mem); int erkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 74b9623420..24bbc68bf9 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -261,7 +261,7 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, Provides command-line control over ERKStep-specific "set" routines. ---------------------------------------------------------------*/ -int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ @@ -273,7 +273,7 @@ int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], int j, retval; for (j = 0; j < num_char_keys; j++) { - retval = sunCheckAndSetCharArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetCharArg((void*)ark_mem, argidx, argv, offset, char_pairs[j].key, char_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 2577833871..74c0e58143 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -224,7 +224,7 @@ typedef int (*ARKTimestepGetNumRhsEvals)(ARKodeMem ark_mem, int partition_index, long int* num_rhs_evals); typedef int (*ARKTimestepSetStepDirection)(ARKodeMem ark_mem, sunrealtype stepdir); -typedef int (*ARKTimestepSetFromCommandLine)(ARKodeMem ark_mem, int* i, +typedef int (*ARKTimestepSetFromCommandLine)(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index 35262298b5..bfea89f2d1 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -186,7 +186,7 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); int lsrkStep_SetDefaults(ARKodeMem ark_mem); int lsrkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 35babd26fe..6b6a479a16 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -497,7 +497,7 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) Provides command-line control over LSRKStep-specific "set" routines. ---------------------------------------------------------------*/ -int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ @@ -525,7 +525,7 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], int j, retval; for (j = 0; j < num_char_keys; j++) { - retval = sunCheckAndSetCharArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetCharArg((void*)ark_mem, argidx, argv, offset, char_pairs[j].key, char_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -541,7 +541,7 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "long int" command-line options */ for (j = 0; j < num_long_keys; j++) { - retval = sunCheckAndSetLongArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetLongArg((void*)ark_mem, argidx, argv, offset, long_pairs[j].key, long_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -557,7 +557,7 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetIntArg((void*)ark_mem, argidx, argv, offset, int_pairs[j].key, int_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) { @@ -572,7 +572,7 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "real" command-line options */ for (j = 0; j < num_real_keys; j++) { - retval = sunCheckAndSetRealArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetRealArg((void*)ark_mem, argidx, argv, offset, real_pairs[j].key, real_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index e140c26b0f..7a158c8327 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -230,7 +230,7 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C); int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index 42fca6b8a5..409e8e193e 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -254,7 +254,7 @@ int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) Provides command-line control over MRIStep-specific "set" routines. ---------------------------------------------------------------*/ -int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used) { /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling @@ -262,15 +262,15 @@ int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], a command-line argument to specify the MRIStepCoupling table name, create the table with that name, attach it to MRIStep (who copies its values), and then free the table. */ - if (strcmp(argv[*i] + offset, "mristep_coupling_table") == 0) + if (strcmp(argv[*argidx] + offset, "mristep_coupling_table") == 0) { - (*i)++; - MRIStepCoupling Coupling = MRIStepCoupling_LoadTableByName(argv[*i]); + (*argidx)++; + MRIStepCoupling Coupling = MRIStepCoupling_LoadTableByName(argv[*argidx]); if (Coupling == NULL) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "error setting command-line argument %s %s (invalid table name)", - argv[(*i) - 1], argv[*i]); + argv[(*argidx) - 1], argv[*argidx]); return ARK_ILL_INPUT; } int retval = MRIStepSetCoupling(ark_mem, Coupling); @@ -279,7 +279,7 @@ int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting command-line argument %s %s (SetCoupling failed)", - argv[(*i) - 1], argv[*i]); + argv[(*argidx) - 1], argv[*argidx]); return retval; } *arg_used = SUNTRUE; diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index e19ba98dee..f4684edbfa 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -73,7 +73,7 @@ int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used); int sprkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int sprkStep_SetDefaults(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index cee60c3ceb..c4c4f4e2f5 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -214,7 +214,7 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) Provides command-line control over SPRKStep-specific "set" routines. ---------------------------------------------------------------*/ -int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], +int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ @@ -230,7 +230,7 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], int j, retval; for (j = 0; j < num_char_keys; j++) { - retval = sunCheckAndSetCharArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetCharArg((void*)ark_mem, argidx, argv, offset, char_pairs[j].key, char_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) @@ -246,7 +246,7 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* i, char* argv[], /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - retval = sunCheckAndSetIntArg((void*)ark_mem, i, argv, offset, + retval = sunCheckAndSetIntArg((void*)ark_mem, argidx, argv, offset, int_pairs[j].key, int_pairs[j].set, arg_used); if (retval != ARK_SUCCESS) { diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 59eeeb77ed..c528e4fe6c 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -102,8 +102,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); SUNErrCode sunretval; - int i, j, retval; - for (i = 1; i < argc; i++) + int idx, j, retval; + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -112,20 +112,20 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, size_t offset; if (cvid != NULL) { - if (strncmp(argv[i], cvid, strlen(cvid)) != 0) { continue; } + if (strncmp(argv[idx], cvid, strlen(cvid)) != 0) { continue; } offset = strlen(cvid) + 1; } else { static const char* prefix = "cvode."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { @@ -142,7 +142,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetLongArg(cvode_mem, &idx, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -160,7 +160,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetRealArg(cvode_mem, &idx, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -178,7 +178,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &idx, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -196,7 +196,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - sunretval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(cvode_mem, &idx, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -213,7 +213,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* warn for uninterpreted cvid.X arguments */ cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[idx]); } return (CV_SUCCESS); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 5530090635..13dabc4b33 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -132,8 +132,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, sizeof(*int_long_pairs); SUNErrCode sunretval; - int i, j, retval; - for (i = 1; i < argc; i++) + int idx, j, retval; + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -142,20 +142,20 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, size_t offset; if (cvid != NULL) { - if (strncmp(argv[i], cvid, strlen(cvid)) != 0) { continue; } + if (strncmp(argv[idx], cvid, strlen(cvid)) != 0) { continue; } offset = strlen(cvid) + 1; } else { static const char* prefix = "cvodes."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(cvode_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { @@ -172,7 +172,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetLongArg(cvode_mem, &idx, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -190,7 +190,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetRealArg(cvode_mem, &idx, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -208,7 +208,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all pair-of-int command-line options */ for (j = 0; j < num_twoint_keys; j++) { - sunretval = sunCheckAndSetTwoIntArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoIntArg(cvode_mem, &idx, argv, offset, twoint_pairs[j].key, twoint_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -226,7 +226,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &idx, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -244,7 +244,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - sunretval = sunCheckAndSetActionArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(cvode_mem, &idx, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -262,7 +262,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+real command-line options */ for (j = 0; j < num_int_real_keys; j++) { - sunretval = sunCheckAndSetIntRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealArg(cvode_mem, &idx, argv, offset, int_real_pairs[j].key, int_real_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -280,7 +280,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+long command-line options */ for (j = 0; j < num_int_long_keys; j++) { - sunretval = sunCheckAndSetIntLongArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntLongArg(cvode_mem, &idx, argv, offset, int_long_pairs[j].key, int_long_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) @@ -298,7 +298,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+real+real command-line options */ for (j = 0; j < num_int_real_real_keys; j++) { - sunretval = sunCheckAndSetIntRealRealArg(cvode_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealRealArg(cvode_mem, &idx, argv, offset, int_real_real_pairs[j].key, int_real_real_pairs[j].set, &arg_used); @@ -316,7 +316,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* warn for uninterpreted cvid.X arguments */ cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[idx]); } return (CV_SUCCESS); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index b39bf7a7d7..1825d6f4c7 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -93,8 +93,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); SUNErrCode sunretval; - int i, j, retval; - for (i = 1; i < argc; i++) + int idx, j, retval; + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -103,20 +103,20 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, size_t offset; if (idaid != NULL) { - if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } + if (strncmp(argv[idx], idaid, strlen(idaid)) != 0) { continue; } offset = strlen(idaid) + 1; } else { static const char* prefix = "ida."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { @@ -133,7 +133,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { @@ -150,7 +150,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { @@ -167,7 +167,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - sunretval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(ida_mem, &idx, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -185,7 +185,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - sunretval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(ida_mem, &idx, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -202,7 +202,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* warn for uninterpreted idaid.X arguments */ IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[idx]); } return (IDA_SUCCESS); diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 7b11b9b4bd..9b5a923a85 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -126,8 +126,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, sizeof(*int_long_pairs); SUNErrCode sunretval; - int i, j, retval; - for (i = 1; i < argc; i++) + int idx, j, retval; + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -136,20 +136,20 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, size_t offset; if (idaid != NULL) { - if (strncmp(argv[i], idaid, strlen(idaid)) != 0) { continue; } + if (strncmp(argv[idx], idaid, strlen(idaid)) != 0) { continue; } offset = strlen(idaid) + 1; } else { static const char* prefix = "idas."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(ida_mem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { @@ -166,7 +166,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(ida_mem, &i, argv, offset, long_pairs[j].key, + sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { @@ -183,7 +183,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(ida_mem, &i, argv, offset, real_pairs[j].key, + sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { @@ -200,7 +200,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all pair-of-int command-line options */ for (j = 0; j < num_twoint_keys; j++) { - sunretval = sunCheckAndSetTwoIntArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoIntArg(ida_mem, &idx, argv, offset, twoint_pairs[j].key, twoint_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -218,7 +218,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - sunretval = sunCheckAndSetTwoRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(ida_mem, &idx, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -236,7 +236,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all action command-line options */ for (j = 0; j < num_action_keys; j++) { - sunretval = sunCheckAndSetActionArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetActionArg(ida_mem, &idx, argv, offset, action_pairs[j].key, action_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -254,7 +254,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+real command-line options */ for (j = 0; j < num_int_real_keys; j++) { - sunretval = sunCheckAndSetIntRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealArg(ida_mem, &idx, argv, offset, int_real_pairs[j].key, int_real_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -272,7 +272,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+long command-line options */ for (j = 0; j < num_int_long_keys; j++) { - sunretval = sunCheckAndSetIntLongArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntLongArg(ida_mem, &idx, argv, offset, int_long_pairs[j].key, int_long_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) @@ -290,7 +290,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+real+real command-line options */ for (j = 0; j < num_int_real_real_keys; j++) { - sunretval = sunCheckAndSetIntRealRealArg(ida_mem, &i, argv, offset, + sunretval = sunCheckAndSetIntRealRealArg(ida_mem, &idx, argv, offset, int_real_real_pairs[j].key, int_real_real_pairs[j].set, &arg_used); @@ -308,7 +308,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* warn for uninterpreted idaid.X arguments */ IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[idx]); } return (IDA_SUCCESS); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index f5092ec5db..f510b42daa 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -75,8 +75,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ sizeof(*tworeal_pairs); SUNErrCode sunretval; - int i, j, retval; - for (i = 1; i < argc; i++) + int idx, j, retval; + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -85,20 +85,20 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ size_t offset; if (kinid != NULL) { - if (strncmp(argv[i], kinid, strlen(kinid)) != 0) { continue; } + if (strncmp(argv[idx], kinid, strlen(kinid)) != 0) { continue; } offset = strlen(kinid) + 1; } else { static const char* prefix = "kinsol."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(kinmem, &i, argv, offset, int_pairs[j].key, + sunretval = sunCheckAndSetIntArg(kinmem, &idx, argv, offset, int_pairs[j].key, int_pairs[j].set, &arg_used); if (sunretval != KIN_SUCCESS) { @@ -115,7 +115,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(kinmem, &i, argv, offset, long_pairs[j].key, + sunretval = sunCheckAndSetLongArg(kinmem, &idx, argv, offset, long_pairs[j].key, long_pairs[j].set, &arg_used); if (sunretval != KIN_SUCCESS) { @@ -132,7 +132,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(kinmem, &i, argv, offset, real_pairs[j].key, + sunretval = sunCheckAndSetRealArg(kinmem, &idx, argv, offset, real_pairs[j].key, real_pairs[j].set, &arg_used); if (sunretval != KIN_SUCCESS) { @@ -149,7 +149,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all pair-of-real command-line options */ for (j = 0; j < num_tworeal_keys; j++) { - sunretval = sunCheckAndSetTwoRealArg(kinmem, &i, argv, offset, + sunretval = sunCheckAndSetTwoRealArg(kinmem, &idx, argv, offset, tworeal_pairs[j].key, tworeal_pairs[j].set, &arg_used); if (sunretval != KIN_SUCCESS) @@ -166,7 +166,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* warn for uninterpreted kinid.X arguments */ KINProcessError(kin_mem, KIN_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[i]); + "WARNING: argument %s was not handled\n", argv[idx]); } return (KIN_SUCCESS); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 4ffa16da6e..34007d36fe 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -117,37 +117,37 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int i; + int idx; SUNErrCode retval; sunbooleantype write_parameters = SUNFALSE; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; if (Cid != NULL) { - if (strncmp(argv[i], Cid, strlen(Cid)) != 0) { continue; } + if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } offset = strlen(Cid) + 1; } else { static const char* prefix = "sunadaptcontroller_imexgus."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over SetParams function */ - if (strcmp(argv[i] + offset, "params") == 0) + if (strcmp(argv[idx] + offset, "params") == 0) { - i += 1; - sunrealtype rarg1 = SUNStrToReal(argv[i]); - i += 1; - sunrealtype rarg2 = SUNStrToReal(argv[i]); - i += 1; - sunrealtype rarg3 = SUNStrToReal(argv[i]); - i += 1; - sunrealtype rarg4 = SUNStrToReal(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg3 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg4 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); if (retval != SUN_SUCCESS) { return retval; } @@ -155,7 +155,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, } /* control over SetDefaults function */ - if (strcmp(argv[i] + offset, "defaults") == 0) + if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_ImExGus(C); if (retval != SUN_SUCCESS) { return retval; } @@ -163,17 +163,17 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, } /* control over SetErrorBias function */ - if (strcmp(argv[i] + offset, "error_bias") == 0) + if (strcmp(argv[idx] + offset, "error_bias") == 0) { - i += 1; - sunrealtype rarg = SUNStrToReal(argv[i]); + idx += 1; + sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* check whether it was requested that all parameters be printed to screen */ - if (strcmp(argv[i] + offset, "write_parameters") == 0) + if (strcmp(argv[idx] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; continue; diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index b1a7a15336..18d6dba04c 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -128,42 +128,42 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int i; + int idx; SUNErrCode retval; sunbooleantype write_parameters = SUNFALSE; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; if (Cid != NULL) { - if (strncmp(argv[i], Cid, strlen(Cid)) != 0) { continue; } + if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } offset = strlen(Cid) + 1; } else { static const char* prefix = "sunadaptcontroller_mrihtol."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over SetParams function */ - if (strcmp(argv[i] + offset, "params") == 0) + if (strcmp(argv[idx] + offset, "params") == 0) { - i += 1; - sunrealtype rarg1 = SUNStrToReal(argv[i]); - i += 1; - sunrealtype rarg2 = SUNStrToReal(argv[i]); - i += 1; - sunrealtype rarg3 = SUNStrToReal(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg3 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_MRIHTol(C, rarg1, rarg2, rarg3); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over SetDefaults function */ - if (strcmp(argv[i] + offset, "defaults") == 0) + if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_MRIHTol(C); if (retval != SUN_SUCCESS) { return retval; } @@ -171,17 +171,17 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, } /* control over SetErrorBias function */ - if (strcmp(argv[i] + offset, "error_bias") == 0) + if (strcmp(argv[idx] + offset, "error_bias") == 0) { - i += 1; - sunrealtype rarg = SUNStrToReal(argv[i]); + idx += 1; + sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* check whether it was requested that all parameters be printed to screen */ - if (strcmp(argv[i] + offset, "write_parameters") == 0) + if (strcmp(argv[idx] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; continue; diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index f3ea71e5ad..dce456f63c 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -127,10 +127,10 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int i; + int idx; SUNErrCode retval; sunbooleantype write_parameters = SUNFALSE; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ @@ -160,19 +160,19 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_Soderlind function */ - if ((strncmp(argv[i], SPrefix, strlen(SPrefix)) == 0) && - (strcmp(argv[i] + SOffset, "params") == 0)) + if ((strncmp(argv[idx], SPrefix, strlen(SPrefix)) == 0) && + (strcmp(argv[idx] + SOffset, "params") == 0)) { - i += 1; - sunrealtype rarg1 = atof(argv[i]); - i += 1; - sunrealtype rarg2 = atof(argv[i]); - i += 1; - sunrealtype rarg3 = atof(argv[i]); - i += 1; - sunrealtype rarg4 = atof(argv[i]); - i += 1; - sunrealtype rarg5 = atof(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg3 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg4 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg5 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, rarg4, rarg5); if (retval != SUN_SUCCESS) { return retval; } @@ -180,77 +180,77 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_PID function */ - if ((strncmp(argv[i], PIDPrefix, strlen(PIDPrefix)) == 0) && - (strcmp(argv[i] + PIDOffset, "params") == 0)) + if ((strncmp(argv[idx], PIDPrefix, strlen(PIDPrefix)) == 0) && + (strcmp(argv[idx] + PIDOffset, "params") == 0)) { - i += 1; - sunrealtype rarg1 = atof(argv[i]); - i += 1; - sunrealtype rarg2 = atof(argv[i]); - i += 1; - sunrealtype rarg3 = atof(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg3 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_PID(C, rarg1, rarg2, rarg3); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over SetParams_PI function */ - if ((strncmp(argv[i], PIPrefix, strlen(PIPrefix)) == 0) && - (strcmp(argv[i] + PIOffset, "params") == 0)) + if ((strncmp(argv[idx], PIPrefix, strlen(PIPrefix)) == 0) && + (strcmp(argv[idx] + PIOffset, "params") == 0)) { - i += 1; - sunrealtype rarg1 = atof(argv[i]); - i += 1; - sunrealtype rarg2 = atof(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over SetParams_I function */ - if ((strncmp(argv[i], IPrefix, strlen(IPrefix)) == 0) && - (strcmp(argv[i] + IOffset, "params") == 0)) + if ((strncmp(argv[idx], IPrefix, strlen(IPrefix)) == 0) && + (strcmp(argv[idx] + IOffset, "params") == 0)) { - i += 1; - sunrealtype rarg1 = atof(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_I(C, rarg1); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over SetParams_ExpGus function */ - if ((strncmp(argv[i], ExpGusPrefix, strlen(ExpGusPrefix)) == 0) && - (strcmp(argv[i] + ExpGusOffset, "params") == 0)) + if ((strncmp(argv[idx], ExpGusPrefix, strlen(ExpGusPrefix)) == 0) && + (strcmp(argv[idx] + ExpGusOffset, "params") == 0)) { - i += 1; - sunrealtype rarg1 = atof(argv[i]); - i += 1; - sunrealtype rarg2 = atof(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over SetParams_ImpGus function */ - if ((strncmp(argv[i], ImpGusPrefix, strlen(ImpGusPrefix)) == 0) && - (strcmp(argv[i] + ImpGusOffset, "params") == 0)) + if ((strncmp(argv[idx], ImpGusPrefix, strlen(ImpGusPrefix)) == 0) && + (strcmp(argv[idx] + ImpGusOffset, "params") == 0)) { - i += 1; - sunrealtype rarg1 = atof(argv[i]); - i += 1; - sunrealtype rarg2 = atof(argv[i]); + idx += 1; + sunrealtype rarg1 = SUNStrToReal(argv[idx]); + idx += 1; + sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over SetDefaults_Soderlind function */ - if ((strcmp(argv[i] + SOffset, "defaults") == 0) || - (strcmp(argv[i] + PIDOffset, "defaults") == 0) || - (strcmp(argv[i] + PIOffset, "defaults") == 0) || - (strcmp(argv[i] + IOffset, "defaults") == 0) || - (strcmp(argv[i] + ExpGusOffset, "defaults") == 0) || - (strcmp(argv[i] + ImpGusOffset, "defaults") == 0)) + if ((strcmp(argv[idx] + SOffset, "defaults") == 0) || + (strcmp(argv[idx] + PIDOffset, "defaults") == 0) || + (strcmp(argv[idx] + PIOffset, "defaults") == 0) || + (strcmp(argv[idx] + IOffset, "defaults") == 0) || + (strcmp(argv[idx] + ExpGusOffset, "defaults") == 0) || + (strcmp(argv[idx] + ImpGusOffset, "defaults") == 0)) { retval = SUNAdaptController_SetDefaults_Soderlind(C); if (retval != SUN_SUCCESS) { return retval; } @@ -258,27 +258,27 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetErrorBias_Soderlind function */ - if ((strcmp(argv[i] + SOffset, "error_bias") == 0) || - (strcmp(argv[i] + PIDOffset, "error_bias") == 0) || - (strcmp(argv[i] + PIOffset, "error_bias") == 0) || - (strcmp(argv[i] + IOffset, "error_bias") == 0) || - (strcmp(argv[i] + ExpGusOffset, "error_bias") == 0) || - (strcmp(argv[i] + ImpGusOffset, "error_bias") == 0)) + if ((strcmp(argv[idx] + SOffset, "error_bias") == 0) || + (strcmp(argv[idx] + PIDOffset, "error_bias") == 0) || + (strcmp(argv[idx] + PIOffset, "error_bias") == 0) || + (strcmp(argv[idx] + IOffset, "error_bias") == 0) || + (strcmp(argv[idx] + ExpGusOffset, "error_bias") == 0) || + (strcmp(argv[idx] + ImpGusOffset, "error_bias") == 0)) { - i += 1; - sunrealtype rarg = atof(argv[i]); + idx += 1; + sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* check whether it was requested that all parameters be printed to screen */ - if ((strcmp(argv[i] + SOffset, "write_parameters") == 0) || - (strcmp(argv[i] + PIDOffset, "write_parameters") == 0) || - (strcmp(argv[i] + PIOffset, "write_parameters") == 0) || - (strcmp(argv[i] + IOffset, "write_parameters") == 0) || - (strcmp(argv[i] + ExpGusOffset, "write_parameters") == 0) || - (strcmp(argv[i] + ImpGusOffset, "write_parameters") == 0)) + if ((strcmp(argv[idx] + SOffset, "write_parameters") == 0) || + (strcmp(argv[idx] + PIDOffset, "write_parameters") == 0) || + (strcmp(argv[idx] + PIOffset, "write_parameters") == 0) || + (strcmp(argv[idx] + IOffset, "write_parameters") == 0) || + (strcmp(argv[idx] + ExpGusOffset, "write_parameters") == 0) || + (strcmp(argv[idx] + ImpGusOffset, "write_parameters") == 0)) { write_parameters = SUNTRUE; continue; diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index 76492e9c0a..b75212c938 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -26,15 +26,15 @@ Command-line input utility routines ===============================================================*/ -SUNErrCode sunCheckAndSetIntArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - int iarg = atoi(argv[*i]); + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); int retval = fname(mem, iarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -42,17 +42,17 @@ SUNErrCode sunCheckAndSetIntArg(void* mem, int* i, char* argv[], const size_t of return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - int iarg1 = atoi(argv[*i]); - (*i) += 1; - int iarg2 = atoi(argv[*i]); + (*argidx) += 1; + int iarg1 = atoi(argv[*argidx]); + (*argidx) += 1; + int iarg2 = atoi(argv[*argidx]); int retval = fname(mem, iarg1, iarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -60,15 +60,15 @@ SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunLongSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - long int iarg = atol(argv[*i]); + (*argidx) += 1; + long int iarg = atol(argv[*argidx]); int retval = fname(mem, iarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -76,17 +76,17 @@ SUNErrCode sunCheckAndSetLongArg(void* mem, int* i, char* argv[], const size_t o return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - int iarg = atoi(argv[*i]); - (*i) += 1; - sunrealtype rarg = SUNStrToReal(argv[*i]); + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg = SUNStrToReal(argv[*argidx]); int retval = fname(mem, iarg, rarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -94,20 +94,20 @@ SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntRealRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - int iarg = atoi(argv[*i]); - (*i) += 1; - sunrealtype rarg1 = SUNStrToReal(argv[*i]); - (*i) += 1; - sunrealtype rarg2 = SUNStrToReal(argv[*i]); + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg1 = SUNStrToReal(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg2 = SUNStrToReal(argv[*argidx]); int retval = fname(mem, iarg, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -115,17 +115,17 @@ SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntLongSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - int iarg = atoi(argv[*i]); - (*i) += 1; - long int large = atol(argv[*i]); + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + (*argidx) += 1; + long int large = atol(argv[*argidx]); int retval = fname(mem, iarg, large); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -133,15 +133,15 @@ SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - sunrealtype rarg = SUNStrToReal(argv[*i]); + (*argidx) += 1; + sunrealtype rarg = SUNStrToReal(argv[*argidx]); int retval = fname(mem, rarg); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -149,17 +149,17 @@ SUNErrCode sunCheckAndSetRealArg(void* mem, int* i, char* argv[], const size_t o return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - sunrealtype rarg1 = SUNStrToReal(argv[*i]); - (*i) += 1; - sunrealtype rarg2 = SUNStrToReal(argv[*i]); + (*argidx) += 1; + sunrealtype rarg1 = SUNStrToReal(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg2 = SUNStrToReal(argv[*argidx]); int retval = fname(mem, rarg1, rarg2); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; @@ -167,42 +167,42 @@ SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetCharArg(void* mem, int* i, char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunCharSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - (*i) += 1; - int retval = fname(mem, argv[*i]); + (*argidx) += 1; + int retval = fname(mem, argv[*argidx]); if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoCharSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { - int retval = fname(mem, argv[*i + 1], argv[*i + 2]); - (*i) += 2; + int retval = fname(mem, argv[*argidx + 1], argv[*argidx + 2]); + (*argidx) += 2; if (retval != SUN_SUCCESS) { return retval; } *arg_used = SUNTRUE; } return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetActionArg(void* mem, int* i, char* argv[], +SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunActionSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; - if (strcmp(argv[*i] + offset, argtest) == 0) + if (strcmp(argv[*argidx] + offset, argtest) == 0) { int retval = fname(mem); if (retval != SUN_SUCCESS) { return retval; } diff --git a/src/sundials/sundials_cli.h b/src/sundials/sundials_cli.h index e2d7110010..8cb0ee0665 100644 --- a/src/sundials/sundials_cli.h +++ b/src/sundials/sundials_cli.h @@ -34,7 +34,7 @@ struct sunKeyIntPair sunIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntSetFn fname, sunbooleantype* arg_used); @@ -48,7 +48,7 @@ struct sunKeyTwoIntPair sunTwoIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoIntSetFn fname, @@ -63,7 +63,7 @@ struct sunKeyLongPair sunLongSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunLongSetFn fname, sunbooleantype* arg_used); @@ -77,7 +77,7 @@ struct sunKeyIntRealPair sunIntRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntRealArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntRealSetFn fname, @@ -92,7 +92,7 @@ struct sunKeyIntRealRealPair sunIntRealRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntRealRealArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntRealRealSetFn fname, @@ -107,7 +107,7 @@ struct sunKeyIntLongPair sunIntLongSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntLongArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntLongSetFn fname, @@ -122,7 +122,7 @@ struct sunKeyRealPair sunRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetRealArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunRealSetFn fname, sunbooleantype* arg_used); @@ -136,7 +136,7 @@ struct sunKeyTwoRealPair sunTwoRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoRealSetFn fname, @@ -151,7 +151,7 @@ struct sunKeyCharPair sunCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunCharSetFn fname, sunbooleantype* arg_used); @@ -165,7 +165,7 @@ struct sunKeyTwoCharPair sunTwoCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoCharSetFn fname, @@ -180,7 +180,7 @@ struct sunKeyActionPair sunActionSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* i, char* argv[], +SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunActionSetFn fname, diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 301b7c975c..049fac491c 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -190,30 +190,30 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "klu."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over SetOrdering function */ - if (strcmp(argv[i] + offset, "ordering") == 0) + if (strcmp(argv[idx] + offset, "ordering") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_KLUSetOrdering(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index f0dead6bfc..eacccc5049 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -250,9 +250,9 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i, j; + int idx, j; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { sunbooleantype arg_used = SUNFALSE; @@ -261,21 +261,21 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "magmadense."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over SetAsync function */ - if (strcmp(argv[i] + offset, "async") == 0) + if (strcmp(argv[idx] + offset, "async") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); if (retval != SUN_SUCCESS) { return retval; } arg_used = SUNTRUE; diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 397ca82818..8b77e08b0e 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -148,50 +148,50 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "pcg."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over PrecType function */ - if (strcmp(argv[i] + offset, "prec_type") == 0) + if (strcmp(argv[idx] + offset, "prec_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_PCGSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over Maxl function */ - if (strcmp(argv[i] + offset, "maxl") == 0) + if (strcmp(argv[idx] + offset, "maxl") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_PCGSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over ZeroGuess function */ - if (strcmp(argv[i] + offset, "zero_guess") == 0) + if (strcmp(argv[idx] + offset, "zero_guess") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_PCG(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index c4eef75cc1..dac0b4ff72 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -170,50 +170,50 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSi { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "spbcgs."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over PrecType function */ - if (strcmp(argv[i] + offset, "prec_type") == 0) + if (strcmp(argv[idx] + offset, "prec_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over Maxl function */ - if (strcmp(argv[i] + offset, "maxl") == 0) + if (strcmp(argv[idx] + offset, "maxl") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over ZeroGuess function */ - if (strcmp(argv[i] + offset, "zero_guess") == 0) + if (strcmp(argv[idx] + offset, "zero_guess") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 1e7e187ffb..e8cd642299 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -158,60 +158,60 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSi { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spfgmr." */ size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "spfgmr."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over PrecType function */ - if (strcmp(argv[i] + offset, "prec_type") == 0) + if (strcmp(argv[idx] + offset, "prec_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over GSType function */ - if (strcmp(argv[i] + offset, "gs_type") == 0) + if (strcmp(argv[idx] + offset, "gs_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetGSType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over MaxRestarts function */ - if (strcmp(argv[i] + offset, "max_restarts") == 0) + if (strcmp(argv[idx] + offset, "max_restarts") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over ZeroGuess function */ - if (strcmp(argv[i] + offset, "zero_guess") == 0) + if (strcmp(argv[idx] + offset, "zero_guess") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 4547c80b83..8f9471ab1c 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -155,60 +155,60 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spgmr." */ size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "spgmr."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over PrecType function */ - if (strcmp(argv[i] + offset, "prec_type") == 0) + if (strcmp(argv[idx] + offset, "prec_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over GSType function */ - if (strcmp(argv[i] + offset, "gs_type") == 0) + if (strcmp(argv[idx] + offset, "gs_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetGSType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over MaxRestarts function */ - if (strcmp(argv[i] + offset, "max_restarts") == 0) + if (strcmp(argv[idx] + offset, "max_restarts") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over ZeroGuess function */ - if (strcmp(argv[i] + offset, "zero_guess") == 0) + if (strcmp(argv[idx] + offset, "zero_guess") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 87068a5760..edb5e321b7 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -172,50 +172,50 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; if (LSid != NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "sptfqmr."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over PrecType function */ - if (strcmp(argv[i] + offset, "prec_type") == 0) + if (strcmp(argv[idx] + offset, "prec_type") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over Maxl function */ - if (strcmp(argv[i] + offset, "maxl") == 0) + if (strcmp(argv[idx] + offset, "maxl") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; } /* control over ZeroGuess function */ - if (strcmp(argv[i] + offset, "zero_guess") == 0) + if (strcmp(argv[idx] + offset, "zero_guess") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 7c81931da9..d722bf6e55 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -227,30 +227,30 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int i; + int idx; SUNErrCode retval; - for (i = 1; i < argc; i++) + for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; if (LSid != __DARWIN_NULL) { - if (strncmp(argv[i], LSid, strlen(LSid)) != 0) { continue; } + if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { static const char* prefix = "superlumt."; - if (strncmp(argv[i], prefix, strlen(prefix)) != 0) { continue; } + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } /* control over PrecType function */ - if (strcmp(argv[i] + offset, "ordering") == 0) + if (strcmp(argv[idx] + offset, "ordering") == 0) { - i += 1; - int iarg = atoi(argv[i]); + idx += 1; + int iarg = atoi(argv[idx]); retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); if (retval != SUN_SUCCESS) { return retval; } continue; From 73abfbab9bfc41639efd1037cb252c1e78d3a631 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Jun 2025 00:00:20 -0500 Subject: [PATCH 068/114] Applied formatting patch --- src/arkode/arkode_arkstep_io.c | 9 ++- src/arkode/arkode_cli.c | 35 ++++++----- src/arkode/arkode_lsrkstep_io.c | 13 ++-- src/cvode/cvode_cli.c | 37 ++++++------ src/cvodes/cvodes_cli.c | 39 ++++++------ src/ida/ida_cli.c | 39 ++++++------ src/idas/idas_cli.c | 41 +++++++------ src/kinsol/kinsol_cli.c | 32 +++++----- .../soderlind/sunadaptcontroller_soderlind.c | 9 +-- src/sundials/sundials_cli.c | 60 ++++++++++--------- src/sundials/sundials_cli.h | 32 +++++----- 11 files changed, 175 insertions(+), 171 deletions(-) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 0104c464dc..48f036b80d 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -643,11 +643,10 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); - static const struct sunKeyActionPair action_pairs[] = {{"set_explicit", - ARKStepSetExplicit}, - {"set_implicit", - ARKStepSetImplicit}, - {"set_imex", ARKStepSetImEx}}; + static const struct sunKeyActionPair action_pairs[] = + {{"set_explicit", ARKStepSetExplicit}, + {"set_implicit", ARKStepSetImplicit}, + {"set_imex", ARKStepSetImEx}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); /* check all "twochar" command-line options */ diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index f8bf5df11e..cbcbf27ccb 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -63,9 +63,9 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static const struct sunKeyLongPair long_pairs[] = {{"max_num_steps", - ARKodeSetMaxNumSteps}, - {"jac_eval_frequency", - ARKodeSetJacEvalFrequency}}; + ARKodeSetMaxNumSteps}, + {"jac_eval_frequency", + ARKodeSetJacEvalFrequency}}; static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static const struct sunKeyRealPair real_pairs[] = @@ -93,11 +93,10 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"mass_ls_norm_factor", ARKodeSetMassLSNormFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"scalar_tolerances", - ARKodeSStolerances}, - {"fixed_step_bounds", - ARKodeSetFixedStepBounds}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static const struct sunKeyTwoRealPair tworeal_pairs[] = + {{"scalar_tolerances", ARKodeSStolerances}, + {"fixed_step_bounds", ARKodeSetFixedStepBounds}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); static const struct sunKeyActionPair action_pairs[] = @@ -133,8 +132,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, for (j = 0; j < num_int_keys; j++) { sunretval = sunCheckAndSetIntArg(arkode_mem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; @@ -151,8 +150,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, for (j = 0; j < num_long_keys; j++) { sunretval = sunCheckAndSetLongArg(arkode_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; @@ -169,8 +168,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, for (j = 0; j < num_real_keys; j++) { sunretval = sunCheckAndSetRealArg(arkode_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; @@ -187,8 +186,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, for (j = 0; j < num_tworeal_keys; j++) { sunretval = sunCheckAndSetTwoRealArg(arkode_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; @@ -205,8 +204,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, for (j = 0; j < num_action_keys; j++) { sunretval = sunCheckAndSetActionArg(arkode_mem, &idx, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); + action_pairs[j].key, + action_pairs[j].set, &arg_used); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index f099b09063..a05067bdda 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -501,10 +501,9 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], size_t offset, sunbooleantype* arg_used) { /* Set lists of command-line arguments, and the corresponding set routines */ - static const struct sunKeyCharPair char_pairs[] = {{"sts_method", - LSRKStepSetSTSMethodByName}, - {"ssp_method", - LSRKStepSetSSPMethodByName}}; + static const struct sunKeyCharPair char_pairs[] = + {{"sts_method", LSRKStepSetSTSMethodByName}, + {"ssp_method", LSRKStepSetSSPMethodByName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); static const struct sunKeyLongPair long_pairs[] = { @@ -512,9 +511,9 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static const struct sunKeyIntPair int_pairs[] = {{"max_num_stages", - LSRKStepSetMaxNumStages}, - {"num_ssp_stages", - LSRKStepSetNumSSPStages}}; + LSRKStepSetMaxNumStages}, + {"num_ssp_stages", + LSRKStepSetNumSSPStages}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static const struct sunKeyRealPair real_pairs[] = { diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index c528e4fe6c..6c589a8b6a 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -88,17 +88,15 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"proj_fail_eta", CVodeSetProjFailEta}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", - CVodeSetEtaFixedStepBounds}, - {"scalar_tolerances", - CVodeSStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static const struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_fixed_step_bounds", CVodeSetEtaFixedStepBounds}, + {"scalar_tolerances", CVodeSStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static const struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", - CVodeClearStopTime}, - {"no_inactive_root_warn", - CVodeSetNoInactiveRootWarn}}; + static const struct sunKeyActionPair action_pairs[] = + {{"clear_stop_time", CVodeClearStopTime}, + {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); SUNErrCode sunretval; @@ -125,8 +123,9 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -143,8 +142,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_long_keys; j++) { sunretval = sunCheckAndSetLongArg(cvode_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -161,8 +160,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_real_keys; j++) { sunretval = sunCheckAndSetRealArg(cvode_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -179,8 +178,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_tworeal_keys; j++) { sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -197,8 +196,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_action_keys; j++) { sunretval = sunCheckAndSetActionArg(cvode_mem, &idx, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); + action_pairs[j].key, + action_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 13dabc4b33..02f702a69f 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -155,8 +155,9 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -173,8 +174,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_long_keys; j++) { sunretval = sunCheckAndSetLongArg(cvode_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -191,8 +192,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_real_keys; j++) { sunretval = sunCheckAndSetRealArg(cvode_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -209,8 +210,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_twoint_keys; j++) { sunretval = sunCheckAndSetTwoIntArg(cvode_mem, &idx, argv, offset, - twoint_pairs[j].key, twoint_pairs[j].set, - &arg_used); + twoint_pairs[j].key, + twoint_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -227,8 +228,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_tworeal_keys; j++) { sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -245,8 +246,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_action_keys; j++) { sunretval = sunCheckAndSetActionArg(cvode_mem, &idx, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); + action_pairs[j].key, + action_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -263,8 +264,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_int_real_keys; j++) { sunretval = sunCheckAndSetIntRealArg(cvode_mem, &idx, argv, offset, - int_real_pairs[j].key, - int_real_pairs[j].set, &arg_used); + int_real_pairs[j].key, + int_real_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -281,8 +282,8 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_int_long_keys; j++) { sunretval = sunCheckAndSetIntLongArg(cvode_mem, &idx, argv, offset, - int_long_pairs[j].key, - int_long_pairs[j].set, &arg_used); + int_long_pairs[j].key, + int_long_pairs[j].set, &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; @@ -299,9 +300,9 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, for (j = 0; j < num_int_real_real_keys; j++) { sunretval = sunCheckAndSetIntRealRealArg(cvode_mem, &idx, argv, offset, - int_real_real_pairs[j].key, - int_real_real_pairs[j].set, - &arg_used); + int_real_real_pairs[j].key, + int_real_real_pairs[j].set, + &arg_used); if (sunretval != CV_SUCCESS) { retval = CV_ILL_INPUT; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 1825d6f4c7..8a1e546adf 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -79,17 +79,15 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"increment_factor", IDASetIncrementFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - static const struct sunKeyTwoRealPair tworeal_pairs[] = {{"eta_fixed_step_bounds", - IDASetEtaFixedStepBounds}, - {"scalar_tolerances", - IDASStolerances}}; - static const int num_tworeal_keys = sizeof(tworeal_pairs) / + static const struct sunKeyTwoRealPair tworeal_pairs[] = + {{"eta_fixed_step_bounds", IDASetEtaFixedStepBounds}, + {"scalar_tolerances", IDASStolerances}}; + static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - static const struct sunKeyActionPair action_pairs[] = {{"clear_stop_time", - IDAClearStopTime}, - {"no_inactive_root_warn", - IDASetNoInactiveRootWarn}}; + static const struct sunKeyActionPair action_pairs[] = + {{"clear_stop_time", IDAClearStopTime}, + {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); SUNErrCode sunretval; @@ -116,8 +114,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -133,8 +132,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -150,8 +150,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -168,8 +169,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_tworeal_keys; j++) { sunretval = sunCheckAndSetTwoRealArg(ida_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -186,8 +187,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_action_keys; j++) { sunretval = sunCheckAndSetActionArg(ida_mem, &idx, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); + action_pairs[j].key, + action_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 9b5a923a85..9ca397d50e 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -149,8 +149,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -166,8 +167,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -183,8 +185,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -201,8 +204,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_twoint_keys; j++) { sunretval = sunCheckAndSetTwoIntArg(ida_mem, &idx, argv, offset, - twoint_pairs[j].key, twoint_pairs[j].set, - &arg_used); + twoint_pairs[j].key, + twoint_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -219,8 +222,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_tworeal_keys; j++) { sunretval = sunCheckAndSetTwoRealArg(ida_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -237,8 +240,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_action_keys; j++) { sunretval = sunCheckAndSetActionArg(ida_mem, &idx, argv, offset, - action_pairs[j].key, action_pairs[j].set, - &arg_used); + action_pairs[j].key, + action_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -255,8 +258,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_int_real_keys; j++) { sunretval = sunCheckAndSetIntRealArg(ida_mem, &idx, argv, offset, - int_real_pairs[j].key, - int_real_pairs[j].set, &arg_used); + int_real_pairs[j].key, + int_real_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -273,8 +276,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_int_long_keys; j++) { sunretval = sunCheckAndSetIntLongArg(ida_mem, &idx, argv, offset, - int_long_pairs[j].key, - int_long_pairs[j].set, &arg_used); + int_long_pairs[j].key, + int_long_pairs[j].set, &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; @@ -291,9 +294,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, for (j = 0; j < num_int_real_real_keys; j++) { sunretval = sunCheckAndSetIntRealRealArg(ida_mem, &idx, argv, offset, - int_real_real_pairs[j].key, - int_real_real_pairs[j].set, - &arg_used); + int_real_real_pairs[j].key, + int_real_real_pairs[j].set, + &arg_used); if (sunretval != IDA_SUCCESS) { retval = IDA_ILL_INPUT; diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index f510b42daa..d0aa3e01d4 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -41,12 +41,13 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ kin_mem = (KINMem)kinmem; /* Set lists of command-line arguments, and the corresponding set routines */ - static const struct sunKeyIntPair int_pairs[] = {{"orth_aa", KINSetOrthAA}, - {"return_newest", KINSetReturnNewest}, - {"no_init_setup", KINSetNoInitSetup}, - {"no_res_mon", KINSetNoResMon}, - {"eta_form", KINSetEtaForm}, - {"no_min_eps", KINSetNoMinEps}}; + static const struct sunKeyIntPair int_pairs[] = + {{"orth_aa", KINSetOrthAA}, + {"return_newest", KINSetReturnNewest}, + {"no_init_setup", KINSetNoInitSetup}, + {"no_res_mon", KINSetNoResMon}, + {"eta_form", KINSetEtaForm}, + {"no_min_eps", KINSetNoMinEps}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static const struct sunKeyLongPair long_pairs[] = @@ -98,8 +99,9 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all "int" command-line options */ for (j = 0; j < num_int_keys; j++) { - sunretval = sunCheckAndSetIntArg(kinmem, &idx, argv, offset, int_pairs[j].key, - int_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetIntArg(kinmem, &idx, argv, offset, + int_pairs[j].key, int_pairs[j].set, + &arg_used); if (sunretval != KIN_SUCCESS) { retval = KIN_ILL_INPUT; @@ -115,8 +117,9 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all long int command-line options */ for (j = 0; j < num_long_keys; j++) { - sunretval = sunCheckAndSetLongArg(kinmem, &idx, argv, offset, long_pairs[j].key, - long_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetLongArg(kinmem, &idx, argv, offset, + long_pairs[j].key, long_pairs[j].set, + &arg_used); if (sunretval != KIN_SUCCESS) { retval = KIN_ILL_INPUT; @@ -132,8 +135,9 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* check all real command-line options */ for (j = 0; j < num_real_keys; j++) { - sunretval = sunCheckAndSetRealArg(kinmem, &idx, argv, offset, real_pairs[j].key, - real_pairs[j].set, &arg_used); + sunretval = sunCheckAndSetRealArg(kinmem, &idx, argv, offset, + real_pairs[j].key, real_pairs[j].set, + &arg_used); if (sunretval != KIN_SUCCESS) { retval = KIN_ILL_INPUT; @@ -150,8 +154,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ for (j = 0; j < num_tworeal_keys; j++) { sunretval = sunCheckAndSetTwoRealArg(kinmem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); + tworeal_pairs[j].key, + tworeal_pairs[j].set, &arg_used); if (sunretval != KIN_SUCCESS) { retval = KIN_ILL_INPUT; diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 491bc0ac0b..008b5fa12e 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -135,15 +135,12 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t SOffset, PIDOffset, PIOffset, IOffset, ExpGusOffset, ImpGusOffset; - const char* SPrefix = (Cid != NULL) ? Cid - : "sunadaptcontroller_soderlind."; + const char* SPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_soderlind."; const char* PIDPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_pid."; const char* PIPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_pi."; const char* IPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_i."; - const char* ExpGusPrefix = (Cid != NULL) ? Cid - : "sunadaptcontroller_expgus."; - const char* ImpGusPrefix = (Cid != NULL) ? Cid - : "sunadaptcontroller_impgus."; + const char* ExpGusPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_expgus."; + const char* ImpGusPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_impgus."; if (Cid != NULL) { SOffset = PIDOffset = PIOffset = IOffset = ExpGusOffset = ImpGusOffset = diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index b75212c938..c27204ae27 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -19,16 +19,16 @@ #include #include #include -#include #include +#include /*=============================================================== Command-line input utility routines ===============================================================*/ -SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], const size_t offset, - const char* argtest, sunIntSetFn fname, - sunbooleantype* arg_used) +SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -43,8 +43,8 @@ SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], const size } SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunTwoIntSetFn fname, sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunTwoIntSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -60,9 +60,9 @@ SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], const size_t offset, - const char* argtest, sunLongSetFn fname, - sunbooleantype* arg_used) +SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunLongSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -77,8 +77,9 @@ SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], const siz } SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntRealSetFn fname, sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunIntRealSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -95,9 +96,9 @@ SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], } SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntRealRealSetFn fname, - sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunIntRealRealSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -116,8 +117,9 @@ SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], } SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntLongSetFn fname, sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunIntLongSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -133,9 +135,9 @@ SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], const size_t offset, - const char* argtest, sunRealSetFn fname, - sunbooleantype* arg_used) +SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunRealSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -150,8 +152,9 @@ SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], const siz } SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunTwoRealSetFn fname, sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunTwoRealSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -167,9 +170,9 @@ SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], const size_t offset, - const char* argtest, sunCharSetFn fname, - sunbooleantype* arg_used) +SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunCharSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -183,8 +186,9 @@ SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], const siz } SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunTwoCharSetFn fname, sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunTwoCharSetFn fname, + sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) @@ -198,8 +202,8 @@ SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], } SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunActionSetFn fname, sunbooleantype* arg_used) + const size_t offset, const char* argtest, + sunActionSetFn fname, sunbooleantype* arg_used) { *arg_used = SUNFALSE; if (strcmp(argv[*argidx] + offset, argtest) == 0) diff --git a/src/sundials/sundials_cli.h b/src/sundials/sundials_cli.h index 8cb0ee0665..27fd1fc976 100644 --- a/src/sundials/sundials_cli.h +++ b/src/sundials/sundials_cli.h @@ -48,8 +48,8 @@ struct sunKeyTwoIntPair sunTwoIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], - const size_t offset, +SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* argidx, + char* argv[], const size_t offset, const char* argtest, sunTwoIntSetFn fname, sunbooleantype* arg_used); @@ -77,8 +77,8 @@ struct sunKeyIntRealPair sunIntRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, +SUNDIALS_EXPORT int sunCheckAndSetIntRealArg(void* mem, int* argidx, + char* argv[], const size_t offset, const char* argtest, sunIntRealSetFn fname, sunbooleantype* arg_used); @@ -92,11 +92,9 @@ struct sunKeyIntRealRealPair sunIntRealRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, - const char* argtest, - sunIntRealRealSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT int sunCheckAndSetIntRealRealArg( + void* mem, int* argidx, char* argv[], const size_t offset, + const char* argtest, sunIntRealRealSetFn fname, sunbooleantype* arg_used); /* utilities for pair int/long int "set" routines */ typedef int (*sunIntLongSetFn)(void*, int, long int); @@ -107,8 +105,8 @@ struct sunKeyIntLongPair sunIntLongSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], - const size_t offset, +SUNDIALS_EXPORT int sunCheckAndSetIntLongArg(void* mem, int* argidx, + char* argv[], const size_t offset, const char* argtest, sunIntLongSetFn fname, sunbooleantype* arg_used); @@ -136,8 +134,8 @@ struct sunKeyTwoRealPair sunTwoRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, +SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* argidx, + char* argv[], const size_t offset, const char* argtest, sunTwoRealSetFn fname, sunbooleantype* arg_used); @@ -165,8 +163,8 @@ struct sunKeyTwoCharPair sunTwoCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], - const size_t offset, +SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* argidx, + char* argv[], const size_t offset, const char* argtest, sunTwoCharSetFn fname, sunbooleantype* arg_used); @@ -180,8 +178,8 @@ struct sunKeyActionPair sunActionSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], - const size_t offset, +SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* argidx, + char* argv[], const size_t offset, const char* argtest, sunActionSetFn fname, sunbooleantype* arg_used); From 297a31efe27d5e6c2ac029e23fedc9e17295711c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 11 Jun 2025 01:31:37 -0500 Subject: [PATCH 069/114] Fixed merge issue --- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index d722bf6e55..f358b9186e 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -234,7 +234,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (LSid != __DARWIN_NULL) + if (LSid != NULL) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; From e2fbeb8922550a9d48a86f0c45ef496544565a93 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 30 Jun 2025 14:42:39 -0400 Subject: [PATCH 070/114] Added utility routines to loop through lists of arguments to call set routines, to simplify package interfaces --- src/arkode/arkode_arkstep_io.c | 41 +++--- src/arkode/arkode_cli.c | 110 +++++++-------- src/arkode/arkode_erkstep_io.c | 20 ++- src/arkode/arkode_lsrkstep_io.c | 81 +++++------ src/arkode/arkode_sprkstep_io.c | 39 +++--- src/cvode/cvode_cli.c | 110 +++++++-------- src/cvodes/cvodes_cli.c | 199 +++++++++++---------------- src/ida/ida_cli.c | 110 +++++++-------- src/idas/idas_cli.c | 199 +++++++++++---------------- src/kinsol/kinsol_cli.c | 88 +++++------- src/sundials/sundials_cli.c | 231 ++++++++++++++++++++++++++++++++ src/sundials/sundials_cli.h | 174 +++++++++++++++++------- 12 files changed, 764 insertions(+), 638 deletions(-) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 48f036b80d..cf34243225 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -651,35 +651,28 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "twochar" command-line options */ int j, retval; - for (j = 0; j < num_twochar_keys; j++) + retval = sunCheckAndSetTwoCharArgs((void*)ark_mem, argidx, argv, offset, + twochar_pairs, num_twochar_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetTwoCharArg((void*)ark_mem, argidx, argv, offset, - twochar_pairs[j].key, - twochar_pairs[j].set, arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - twochar_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + twochar_pairs[j].key); + return retval; } + if (*arg_used) { return ARK_SUCCESS; } /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + retval = sunCheckAndSetActionArgs((void*)ark_mem, argidx, argv, offset, + action_pairs, num_action_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetActionArg((void*)ark_mem, argidx, argv, offset, - action_pairs[j].key, action_pairs[j].set, - arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } return (ARK_SUCCESS); diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index cbcbf27ccb..0b1fb2877e 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -129,92 +129,72 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + sunretval = sunCheckAndSetIntArgs(arkode_mem, &idx, argv, offset, + int_pairs, num_int_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntArg(arkode_mem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); - if (sunretval != SUN_SUCCESS) - { - retval = ARK_ILL_INPUT; - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = ARK_ILL_INPUT; + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } if (arg_used) continue; /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + sunretval = sunCheckAndSetLongArgs(arkode_mem, &idx, argv, offset, + long_pairs, num_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetLongArg(arkode_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); - if (sunretval != SUN_SUCCESS) - { - retval = ARK_ILL_INPUT; - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = ARK_ILL_INPUT; + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + sunretval = sunCheckAndSetRealArgs(arkode_mem, &idx, argv, offset, + real_pairs, num_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetRealArg(arkode_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); - if (sunretval != SUN_SUCCESS) - { - retval = ARK_ILL_INPUT; - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = ARK_ILL_INPUT; + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + sunretval = sunCheckAndSetTwoRealArgs(arkode_mem, &idx, argv, offset, + tworeal_pairs, num_tworeal_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoRealArg(arkode_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (sunretval != SUN_SUCCESS) - { - retval = ARK_ILL_INPUT; - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = ARK_ILL_INPUT; + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } if (arg_used) continue; /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + sunretval = sunCheckAndSetActionArgs(arkode_mem, &idx, argv, offset, + action_pairs, num_action_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetActionArg(arkode_mem, &idx, argv, offset, - action_pairs[j].key, - action_pairs[j].set, &arg_used); - if (sunretval != SUN_SUCCESS) - { - retval = ARK_ILL_INPUT; - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = ARK_ILL_INPUT; + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } if (arg_used) continue; diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 46ed6bd9d6..609a09e27e 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -271,19 +271,15 @@ int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "char" command-line options */ int j, retval; - for (j = 0; j < num_char_keys; j++) + retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, + char_pairs, num_char_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetCharArg((void*)ark_mem, argidx, argv, offset, - char_pairs[j].key, char_pairs[j].set, - arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - char_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + char_pairs[j].key); + return retval; } return (ARK_SUCCESS); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index a05067bdda..15595afd58 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -522,66 +522,53 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "char" command-line options */ int j, retval; - for (j = 0; j < num_char_keys; j++) + retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, + char_pairs, num_char_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetCharArg((void*)ark_mem, argidx, argv, offset, - char_pairs[j].key, char_pairs[j].set, - arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - char_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + char_pairs[j].key); + return retval; } + if (*arg_used) { return ARK_SUCCESS; } /* check all "long int" command-line options */ - for (j = 0; j < num_long_keys; j++) + retval = sunCheckAndSetLongArgs((void*)ark_mem, argidx, argv, offset, + long_pairs, num_long_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetLongArg((void*)ark_mem, argidx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } + if (*arg_used) { return ARK_SUCCESS; } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + retval = sunCheckAndSetIntArgs((void*)ark_mem, argidx, argv, offset, + int_pairs, num_int_keys, arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetIntArg((void*)ark_mem, argidx, argv, offset, - int_pairs[j].key, int_pairs[j].set, arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } + if (*arg_used) { return ARK_SUCCESS; } /* check all "real" command-line options */ - for (j = 0; j < num_real_keys; j++) + retval = sunCheckAndSetRealArgs((void*)ark_mem, argidx, argv, offset, + real_pairs, num_real_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetRealArg((void*)ark_mem, argidx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } return (ARK_SUCCESS); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index c4c4f4e2f5..0f12b4d2d6 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -228,34 +228,27 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "char" command-line options */ int j, retval; - for (j = 0; j < num_char_keys; j++) + retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, + char_pairs, num_char_keys, + arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetCharArg((void*)ark_mem, argidx, argv, offset, - char_pairs[j].key, char_pairs[j].set, - arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - char_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + char_pairs[j].key); + return retval; } + if (*arg_used) { return ARK_SUCCESS; } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + retval = sunCheckAndSetIntArgs((void*)ark_mem, argidx, argv, offset, + int_pairs, num_int_keys, arg_used, &j); + if (retval != SUN_SUCCESS) { - retval = sunCheckAndSetIntArg((void*)ark_mem, argidx, argv, offset, - int_pairs[j].key, int_pairs[j].set, arg_used); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (*arg_used) { return ARK_SUCCESS; } + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } return (ARK_SUCCESS); diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 6c589a8b6a..155d3d8e9c 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -121,92 +121,72 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, + int_pairs, num_int_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } if (arg_used) continue; /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + sunretval = sunCheckAndSetLongArgs(cvode_mem, &idx, argv, offset, + long_pairs, num_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetLongArg(cvode_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + sunretval = sunCheckAndSetRealArgs(cvode_mem, &idx, argv, offset, + real_pairs, num_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetRealArg(cvode_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + sunretval = sunCheckAndSetTwoRealArgs(cvode_mem, &idx, argv, offset, + tworeal_pairs, num_tworeal_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } if (arg_used) continue; /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + sunretval = sunCheckAndSetActionArgs(cvode_mem, &idx, argv, offset, + action_pairs, num_action_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetActionArg(cvode_mem, &idx, argv, offset, - action_pairs[j].key, - action_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } if (arg_used) continue; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 02f702a69f..b2c876cc31 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -153,165 +153,128 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, + int_pairs, num_int_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntArg(cvode_mem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } if (arg_used) continue; /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + sunretval = sunCheckAndSetLongArgs(cvode_mem, &idx, argv, offset, + long_pairs, num_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetLongArg(cvode_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + sunretval = sunCheckAndSetRealArgs(cvode_mem, &idx, argv, offset, + real_pairs, num_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetRealArg(cvode_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-int command-line options */ - for (j = 0; j < num_twoint_keys; j++) + sunretval = sunCheckAndSetTwoIntArgs(cvode_mem, &idx, argv, offset, + twoint_pairs, num_twoint_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoIntArg(cvode_mem, &idx, argv, offset, - twoint_pairs[j].key, - twoint_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - twoint_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + twoint_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + sunretval = sunCheckAndSetTwoRealArgs(cvode_mem, &idx, argv, offset, + tworeal_pairs, num_tworeal_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoRealArg(cvode_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } if (arg_used) continue; /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + sunretval = sunCheckAndSetActionArgs(cvode_mem, &idx, argv, offset, + action_pairs, num_action_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetActionArg(cvode_mem, &idx, argv, offset, - action_pairs[j].key, - action_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } if (arg_used) continue; /* check all int+real command-line options */ - for (j = 0; j < num_int_real_keys; j++) + sunretval = sunCheckAndSetIntRealArgs(cvode_mem, &idx, argv, offset, + int_real_pairs, num_int_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntRealArg(cvode_mem, &idx, argv, offset, - int_real_pairs[j].key, - int_real_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all int+long command-line options */ - for (j = 0; j < num_int_long_keys; j++) + sunretval = sunCheckAndSetIntLongArgs(cvode_mem, &idx, argv, offset, + int_long_pairs, num_int_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntLongArg(cvode_mem, &idx, argv, offset, - int_long_pairs[j].key, - int_long_pairs[j].set, &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all int+real+real command-line options */ - for (j = 0; j < num_int_real_real_keys; j++) + sunretval = sunCheckAndSetIntRealRealArgs(cvode_mem, &idx, argv, offset, + int_real_real_pairs, num_int_real_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntRealRealArg(cvode_mem, &idx, argv, offset, - int_real_real_pairs[j].key, - int_real_real_pairs[j].set, - &arg_used); - if (sunretval != CV_SUCCESS) - { - retval = CV_ILL_INPUT; - cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_real_real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = CV_ILL_INPUT; + cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_real_pairs[j].key); + return retval; } if (arg_used) continue; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 8a1e546adf..5c0123344d 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -112,92 +112,72 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, + int_pairs, num_int_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } if (arg_used) continue; /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + sunretval = sunCheckAndSetLongArgs(ida_mem, &idx, argv, offset, + long_pairs, num_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + sunretval = sunCheckAndSetRealArgs(ida_mem, &idx, argv, offset, + real_pairs, num_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + sunretval = sunCheckAndSetTwoRealArgs(ida_mem, &idx, argv, offset, + tworeal_pairs, num_tworeal_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoRealArg(ida_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } if (arg_used) continue; /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + sunretval = sunCheckAndSetActionArgs(ida_mem, &idx, argv, offset, + action_pairs, num_action_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetActionArg(ida_mem, &idx, argv, offset, - action_pairs[j].key, - action_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } if (arg_used) continue; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 9ca397d50e..4f7a9ca8d5 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -147,165 +147,128 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, + int_pairs, num_int_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntArg(ida_mem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } if (arg_used) continue; /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + sunretval = sunCheckAndSetLongArgs(ida_mem, &idx, argv, offset, + long_pairs, num_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetLongArg(ida_mem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + sunretval = sunCheckAndSetRealArgs(ida_mem, &idx, argv, offset, + real_pairs, num_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetRealArg(ida_mem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-int command-line options */ - for (j = 0; j < num_twoint_keys; j++) + sunretval = sunCheckAndSetTwoIntArgs(ida_mem, &idx, argv, offset, + twoint_pairs, num_twoint_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoIntArg(ida_mem, &idx, argv, offset, - twoint_pairs[j].key, - twoint_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - twoint_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + twoint_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + sunretval = sunCheckAndSetTwoRealArgs(ida_mem, &idx, argv, offset, + tworeal_pairs, num_tworeal_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoRealArg(ida_mem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } if (arg_used) continue; /* check all action command-line options */ - for (j = 0; j < num_action_keys; j++) + sunretval = sunCheckAndSetActionArgs(ida_mem, &idx, argv, offset, + action_pairs, num_action_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetActionArg(ida_mem, &idx, argv, offset, - action_pairs[j].key, - action_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - action_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + action_pairs[j].key); + return retval; } if (arg_used) continue; /* check all int+real command-line options */ - for (j = 0; j < num_int_real_keys; j++) + sunretval = sunCheckAndSetIntRealArgs(ida_mem, &idx, argv, offset, + int_real_pairs, num_int_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntRealArg(ida_mem, &idx, argv, offset, - int_real_pairs[j].key, - int_real_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all int+long command-line options */ - for (j = 0; j < num_int_long_keys; j++) + sunretval = sunCheckAndSetIntLongArgs(ida_mem, &idx, argv, offset, + int_long_pairs, num_int_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntLongArg(ida_mem, &idx, argv, offset, - int_long_pairs[j].key, - int_long_pairs[j].set, &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all int+real+real command-line options */ - for (j = 0; j < num_int_real_real_keys; j++) + sunretval = sunCheckAndSetIntRealRealArgs(ida_mem, &idx, argv, offset, + int_real_real_pairs, num_int_real_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntRealRealArg(ida_mem, &idx, argv, offset, - int_real_real_pairs[j].key, - int_real_real_pairs[j].set, - &arg_used); - if (sunretval != IDA_SUCCESS) - { - retval = IDA_ILL_INPUT; - IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_real_real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = IDA_ILL_INPUT; + IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_real_real_pairs[j].key); + return retval; } if (arg_used) continue; diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index d0aa3e01d4..206e402f02 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -97,74 +97,58 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ } /* check all "int" command-line options */ - for (j = 0; j < num_int_keys; j++) + sunretval = sunCheckAndSetIntArgs(kinmem, &idx, argv, offset, + int_pairs, num_int_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetIntArg(kinmem, &idx, argv, offset, - int_pairs[j].key, int_pairs[j].set, - &arg_used); - if (sunretval != KIN_SUCCESS) - { - retval = KIN_ILL_INPUT; - KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = KIN_ILL_INPUT; + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + int_pairs[j].key); + return retval; } if (arg_used) continue; /* check all long int command-line options */ - for (j = 0; j < num_long_keys; j++) + sunretval = sunCheckAndSetLongArgs(kinmem, &idx, argv, offset, + long_pairs, num_long_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetLongArg(kinmem, &idx, argv, offset, - long_pairs[j].key, long_pairs[j].set, - &arg_used); - if (sunretval != KIN_SUCCESS) - { - retval = KIN_ILL_INPUT; - KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = KIN_ILL_INPUT; + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + long_pairs[j].key); + return retval; } if (arg_used) continue; /* check all real command-line options */ - for (j = 0; j < num_real_keys; j++) + sunretval = sunCheckAndSetRealArgs(kinmem, &idx, argv, offset, + real_pairs, num_real_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetRealArg(kinmem, &idx, argv, offset, - real_pairs[j].key, real_pairs[j].set, - &arg_used); - if (sunretval != KIN_SUCCESS) - { - retval = KIN_ILL_INPUT; - KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = KIN_ILL_INPUT; + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + real_pairs[j].key); + return retval; } if (arg_used) continue; /* check all pair-of-real command-line options */ - for (j = 0; j < num_tworeal_keys; j++) + sunretval = sunCheckAndSetTwoRealArgs(kinmem, &idx, argv, offset, + tworeal_pairs, num_tworeal_keys, + &arg_used, &j); + if (sunretval != SUN_SUCCESS) { - sunretval = sunCheckAndSetTwoRealArg(kinmem, &idx, argv, offset, - tworeal_pairs[j].key, - tworeal_pairs[j].set, &arg_used); - if (sunretval != KIN_SUCCESS) - { - retval = KIN_ILL_INPUT; - KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - tworeal_pairs[j].key); - return retval; - } - if (arg_used) break; + retval = KIN_ILL_INPUT; + KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, + "error setting command-line argument: %s", + tworeal_pairs[j].key); + return retval; } if (arg_used) continue; diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index c27204ae27..3266650b83 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -42,6 +42,27 @@ SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetIntArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoIntSetFn fname, sunbooleantype* arg_used) @@ -60,6 +81,27 @@ SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyTwoIntPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetTwoIntArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunLongSetFn fname, sunbooleantype* arg_used) @@ -76,6 +118,27 @@ SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyLongPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetLongArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntRealSetFn fname, @@ -95,6 +158,27 @@ SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetIntRealArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntRealRealSetFn fname, @@ -116,6 +200,27 @@ SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntRealRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetIntRealRealArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunIntLongSetFn fname, @@ -135,6 +240,27 @@ SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntLongPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetIntLongArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunRealSetFn fname, sunbooleantype* arg_used) @@ -151,6 +277,27 @@ SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetRealArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoRealSetFn fname, @@ -170,6 +317,27 @@ SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyTwoRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetTwoRealArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunCharSetFn fname, sunbooleantype* arg_used) @@ -185,6 +353,27 @@ SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyCharPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetCharArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunTwoCharSetFn fname, @@ -201,6 +390,27 @@ SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], return SUN_SUCCESS; } +SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyTwoCharPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetTwoCharArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} + SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], const size_t offset, const char* argtest, sunActionSetFn fname, sunbooleantype* arg_used) @@ -214,3 +424,24 @@ SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], } return SUN_SUCCESS; } + +SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyActionPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg) +{ + for (int j = 0; j < numpairs; j++) + { + int retval = sunCheckAndSetActionArg(mem, argidx, argv, offset, + testpairs[j].key, testpairs[j].set, + arg_used); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + if (*arg_used) { return SUN_SUCCESS; } + } + return SUN_SUCCESS; +} diff --git a/src/sundials/sundials_cli.h b/src/sundials/sundials_cli.h index 27fd1fc976..a990ab21ec 100644 --- a/src/sundials/sundials_cli.h +++ b/src/sundials/sundials_cli.h @@ -34,10 +34,17 @@ struct sunKeyIntPair sunIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], - const size_t offset, - const char* argtest, sunIntSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, sunIntSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for pair-of-integer "set" routines */ typedef int (*sunTwoIntSetFn)(void*, int, int); @@ -48,11 +55,18 @@ struct sunKeyTwoIntPair sunTwoIntSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoIntArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunTwoIntSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, + sunTwoIntSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyTwoIntPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for long int "set" routines */ typedef int (*sunLongSetFn)(void*, long int); @@ -63,10 +77,17 @@ struct sunKeyLongPair sunLongSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], - const size_t offset, - const char* argtest, sunLongSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], + const size_t offset, + const char* argtest, sunLongSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyLongPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for pair int/sunrealtype "set" routines */ typedef int (*sunIntRealSetFn)(void*, int, sunrealtype); @@ -77,11 +98,18 @@ struct sunKeyIntRealPair sunIntRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntRealArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunIntRealSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, + sunIntRealSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for triplet int/sunrealtype/sunrealtype "set" routines */ typedef int (*sunIntRealRealSetFn)(void*, int, sunrealtype, sunrealtype); @@ -92,9 +120,17 @@ struct sunKeyIntRealRealPair sunIntRealRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntRealRealArg( - void* mem, int* argidx, char* argv[], const size_t offset, - const char* argtest, sunIntRealRealSetFn fname, sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunIntRealRealSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntRealRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for pair int/long int "set" routines */ typedef int (*sunIntLongSetFn)(void*, int, long int); @@ -105,11 +141,18 @@ struct sunKeyIntLongPair sunIntLongSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetIntLongArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunIntLongSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, + sunIntLongSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyIntLongPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for sunrealtype "set" routines */ typedef int (*sunRealSetFn)(void*, sunrealtype); @@ -120,10 +163,16 @@ struct sunKeyRealPair sunRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, - const char* argtest, sunRealSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunRealSetFn fname, sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for pair-of-sunrealtype "set" routines */ typedef int (*sunTwoRealSetFn)(void*, sunrealtype, sunrealtype); @@ -134,11 +183,18 @@ struct sunKeyTwoRealPair sunTwoRealSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoRealArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunTwoRealSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, + sunTwoRealSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyTwoRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for char* "set" routines */ typedef int (*sunCharSetFn)(void*, const char*); @@ -149,10 +205,16 @@ struct sunKeyCharPair sunCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], - const size_t offset, - const char* argtest, sunCharSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], + const size_t offset, const char* argtest, + sunCharSetFn fname, sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyCharPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for pair-of-char* "set" routines */ typedef int (*sunTwoCharSetFn)(void*, const char*, const char*); @@ -163,11 +225,18 @@ struct sunKeyTwoCharPair sunTwoCharSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetTwoCharArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunTwoCharSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, + sunTwoCharSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyTwoCharPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); /* utilities for action "set" routines */ typedef int (*sunActionSetFn)(void*); @@ -178,11 +247,18 @@ struct sunKeyActionPair sunActionSetFn set; }; -SUNDIALS_EXPORT int sunCheckAndSetActionArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunActionSetFn fname, - sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, + char* argv[], const size_t offset, + const char* argtest, + sunActionSetFn fname, + sunbooleantype* arg_used); +SUNDIALS_EXPORT +SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, + char* argv[], const size_t offset, + const struct sunKeyActionPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int *failedarg); #ifdef __cplusplus } From a1b96ef75076d6a6e82793364df65368b86eaba9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 30 Jun 2025 14:43:02 -0400 Subject: [PATCH 071/114] Added more CI tests for command-line arguments --- examples/arkode/C_serial/CMakeLists.txt | 1 + examples/cvode/CXX_serial/CMakeLists.txt | 3 ++- examples/cvodes/serial/CMakeLists.txt | 1 + examples/ida/serial/CMakeLists.txt | 1 + examples/idas/serial/CMakeLists.txt | 1 + examples/kinsol/serial/CMakeLists.txt | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index e1956028cd..cf667eab9b 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -23,6 +23,7 @@ set(ARKODE_examples # tests that are always run "ark_analytic\;\;" # develop tests + "ark_analytic\;arkode.scalar_tolerances 1e-6 1e-8 arkode.table_names ARKODE_ESDIRK547L2SA_7_4_5 ARKODE_ERK_NONE\;" "ark_advection_diffusion_reaction_splitting\;\;develop" "ark_analytic_lsrk\;\;develop" "ark_analytic_lsrk_varjac\;\;develop" diff --git a/examples/cvode/CXX_serial/CMakeLists.txt b/examples/cvode/CXX_serial/CMakeLists.txt index 79fa83a66a..3ae3fd9f4f 100644 --- a/examples/cvode/CXX_serial/CMakeLists.txt +++ b/examples/cvode/CXX_serial/CMakeLists.txt @@ -19,7 +19,8 @@ # Examples using SUNDIALS linear solvers set(CVODE_examples "cv_heat2D.cpp\;\;\;\;exclude-single" - "cv_kpr.cpp\;\;\;\;develop") + "cv_kpr.cpp\;\;\;\;develop" + "cv_kpr.cpp\;cvode.init_step 0.01\;\;\;develop") # Add the build and install targets for each example foreach(example_tuple ${CVODE_examples}) diff --git a/examples/cvodes/serial/CMakeLists.txt b/examples/cvodes/serial/CMakeLists.txt index ae7921ea1b..5fa2b0c1cc 100644 --- a/examples/cvodes/serial/CMakeLists.txt +++ b/examples/cvodes/serial/CMakeLists.txt @@ -25,6 +25,7 @@ set(CVODES_examples "cvsAdvDiff_FSA_non\;-sensi stg t\;exclude-single" "cvsAdvDiff_bnd\;\;develop" "cvsAnalytic_mels\;\;develop" + "cvsAnalytic_mels\;cvodes.max_order 3\;develop" "cvsDirectDemo_ls\;\;develop" "cvsDiurnal_FSA_kry\;-sensi sim t\;exclude-single" "cvsDiurnal_FSA_kry\;-sensi stg t\;exclude-single" diff --git a/examples/ida/serial/CMakeLists.txt b/examples/ida/serial/CMakeLists.txt index aed347ecd7..9dc4e17d71 100644 --- a/examples/ida/serial/CMakeLists.txt +++ b/examples/ida/serial/CMakeLists.txt @@ -21,6 +21,7 @@ # Examples using SUNDIALS linear solvers set(IDA_examples "idaAnalytic_mels\;\;exclude-single" + "idaAnalytic_mels\;ida.scalar_tolerances 1e-3 1e-8\;exclude-single" "idaFoodWeb_bnd\;\;develop" "idaFoodWeb_kry\;\;develop" "idaHeat2D_bnd\;\;develop" diff --git a/examples/idas/serial/CMakeLists.txt b/examples/idas/serial/CMakeLists.txt index d2cd02e5a7..e28465b1fc 100644 --- a/examples/idas/serial/CMakeLists.txt +++ b/examples/idas/serial/CMakeLists.txt @@ -23,6 +23,7 @@ set(IDAS_examples "idasAkzoNob_ASAi_dns\;\;exclude-single" "idasAkzoNob_dns\;\;exclude-single" "idasAnalytic_mels\;\;exclude-single" + "idasAnalytic_mels\;idas.init_step 1e-5\;exclude-single" "idasFoodWeb_bnd\;\;develop" "idasHeat2D_bnd\;\;exclude-single" "idasHeat2D_kry\;\;exclude-single" diff --git a/examples/kinsol/serial/CMakeLists.txt b/examples/kinsol/serial/CMakeLists.txt index ea80e0acad..10ef0c0425 100644 --- a/examples/kinsol/serial/CMakeLists.txt +++ b/examples/kinsol/serial/CMakeLists.txt @@ -38,6 +38,7 @@ set(KINSOL_examples "kinLaplace_picard_bnd\;\;exclude-single" "kinLaplace_picard_kry\;\;exclude-single" "kinRoberts_fp\;\;develop" + "kinRoberts_fp\;kinsol.m_aa 1\;develop" "kinRoboKin_dns\;\;exclude-single") # Examples using LAPACK linear solvers From 59047806ff517cd2192a3da346476260e7503f96 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Jul 2025 23:25:29 -0400 Subject: [PATCH 072/114] Added documentation for command-line processing to the developer guide --- .../source/developers/commandline/Options.rst | 622 ++++++++++++++++++ .../source/developers/commandline/index.rst | 25 + doc/superbuild/source/developers/index.rst | 1 + 3 files changed, 648 insertions(+) create mode 100644 doc/superbuild/source/developers/commandline/Options.rst create mode 100644 doc/superbuild/source/developers/commandline/index.rst diff --git a/doc/superbuild/source/developers/commandline/Options.rst b/doc/superbuild/source/developers/commandline/Options.rst new file mode 100644 index 0000000000..ccc945889d --- /dev/null +++ b/doc/superbuild/source/developers/commandline/Options.rst @@ -0,0 +1,622 @@ +.. + Author(s): Daniel R. Reynolds @ UMBC + ----------------------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ----------------------------------------------------------------------------- + +.. _Infrastructure: + +Infrastructure +============== + +SUNDIALS provides support for parsing command-line arguments to control SUNDIALS "Set" +routines through a set of data structures and utility routines that compare a given +command-line argument against a list of reserved keywords. If the given argument is +matched to a relevant key, then the associated "Set" routine is called with the +argument(s) that follow the key on the command line. This allows users to set SUNDIALS +options at runtime, without needing to modify the source code or recompile the library. + +Prototypes for the SUNDIALS-provided infrastructure routines and corresponding data +structures for command-line support are in the ``src/sundials/sundials_cli.h`` +header file. Their implementations are found in ``src/sundials/sundials_cli.c``. +These routines assume that each SUNDIALS module provides a suite of +"Set" routines of the form ``(void* mem, arg1, arg2, ...)``, where +```` is the name of the set routine (e.g., :c:func:`ARKodeSetOrder`), ``mem`` +is an opaque pointer to the SUNDIALS module (e.g., the pointer returned by +:c:func:`CVodeCreate`), and ``arg1``, ..., are the input arguments for the set routine. +The SUNDIALS-provided command-line processing routines and structures are grouped +according to the number and type of these arguments, as elaborated in the +following sections: + +* :ref:`IntArg` - single ``int`` argument +* :ref:`TwoIntArgs` - two ``int`` arguments +* :ref:`LongArg` - single ``long`` argument +* :ref:`IntRealArgs` - a single ``int`` followed by a single ``sunrealtype`` argument +* :ref:`IntRealRealArgs` - a single ``int`` followed by two ``sunrealtype`` arguments +* :ref:`IntLongArgs` - a single ``int`` followed by a single ``long`` argument +* :ref:`RealArg` - single ``sunrealtype`` argument +* :ref:`TwoRealArgs` - two ``sunrealtype`` arguments +* :ref:`CharArg` - single ``char*`` argument +* :ref:`TwoCharArgs` - two ``char*`` arguments +* :ref:`ActionArg` - perform a given action + +.. _IntArg: + +One ``int`` argument +-------------------- + +.. c:type:: int (*sunIntSetFn)(void* mem, int arg1) + + These functions set a single integer option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the integer value to set. + + :return: An *sunIntSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyIntPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunIntSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyIntPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _TwoIntArgs: + +Two ``int`` arguments +--------------------- + +.. c:type:: int (*sunTwoIntSetFn)(void* mem, int arg1, int arg2) + + These functions set two integer options for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the first integer value to set. + :param arg2: the second integer value to set. + + :return: An *sunTwoIntSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyTwoIntPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunTwoIntSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyTwoIntPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _LongArg: + +One ``long int`` argument +------------------------- + +.. c:type:: int (*sunLongSetFn)(void* mem, long int arg1) + + These functions set a single long integer option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the long integer value to set. + + :return: An *sunLongSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyLongPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunLongSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyLongPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _IntRealArgs: + +One ``int`` and one ``sunrealtype`` argument +-------------------------------------------- + +.. c:type:: int (*sunIntRealSetFn)(void* mem, int arg1, sunrealtype arg2) + + These functions set a single integer option and a single real option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the integer value to set. + :param arg2: the real value to set. + + :return: An *sunIntRealSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyIntRealPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunIntRealSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyIntRealPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _IntRealRealArgs: + +One ``int`` and two ``sunrealtype`` arguments +--------------------------------------------- + +.. c:type:: int (*sunIntRealRealSetFn)(void* mem, int arg1, sunrealtype arg2, sunrealtype arg3) + + These functions set a single integer option and two real options for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the integer value to set. + :param arg2: the first real value to set. + :param arg3: the second real value to set. + + :return: An *sunIntRealRealSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyIntRealRealPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunIntRealRealSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyIntRealRealPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _IntLongArgs: + +One ``int`` and one ``long int`` argument +----------------------------------------- + +.. c:type:: int (*sunIntLongSetFn)(void* mem, int arg1, long int arg2) + + These functions set a single integer option and a long integer option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the integer value to set. + :param arg2: the long integer value to set. + + :return: An *sunIntLongSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyIntLongPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunIntLongSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyIntLongPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _RealArg: + +One ``sunrealtype`` argument +---------------------------- + +.. c:type:: int (*sunRealSetFn)(void* mem, sunrealtype arg1) + + These functions set a single real option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the real value to set. + + :return: An *sunRealSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyRealPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunRealSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyRealPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _TwoRealArgs: + +Two ``sunrealtype`` arguments +----------------------------- + +.. c:type:: int (*sunTwoRealSetFn)(void* mem, sunrealtype arg1, sunrealtype arg2) + + These functions set two real options for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the first real value to set. + :param arg2: the second real value to set. + + :return: An *sunTwoRealSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyTwoRealPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunTwoRealSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyTwoRealPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _CharArg: + +One ``char*`` argument +---------------------- + +.. c:type:: int (*sunCharSetFn)(void* mem, const char* arg1) + + These functions set a single string option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the string value to set. + + :return: An *sunCharSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyCharPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunCharSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyCharPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _TwoCharArgs: + +Two ``char*`` arguments +----------------------- + +.. c:type:: int (*sunTwoCharSetFn)(void* mem, const char* arg1, const char* arg2) + + These functions set two string options for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + :param arg1: the first string value to set. + :param arg2: the second string value to set. + + :return: An *sunTwoCharSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyTwoCharPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunTwoCharSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyTwoCharPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + +.. _ActionArg: + +No arguments (action only) +-------------------------- + +.. c:type:: int (*sunActionSetFn)(void* mem) + + These functions set a single integer option for a SUNDIALS module. + + :param mem: an opaque pointer to the SUNDIALS module. + + :return: An *sunActionSetFn* should return 0 if successful, or a nonzero value on failure. + + .. versionadded:: x.y.z + +.. c:struct:: sunKeyActionPair + + This is a structure that contains + + .. c:member:: const char* key; + + The command-line key to match. + + .. c:member:: sunActionSetFn set; + + The function to call if the key is matched. + + .. versionadded:: x.y.z + +.. c:function:: SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyActionPair* testpairs, int numpairs, sunbooleantype* arg_used, int *failedarg) + + This function loops over an array of potential key/function pairs to check whether any match ``argv[*argidx]``, and if so it calls the corresponding set routine. + + :param mem: an opaque pointer to the SUNDIALS module. + :param argidx: a pointer to the index of the current command-line argument. If the argument is found and set, this will be incremented by the number of arguments consumed (e.g., 1 for a single argument, 2 for two arguments, etc.). + :param argv: the command-line argument vector. + :param offset: the offset width to ignore (stores a module-specific prefix for the key). + :param testpairs: an array of key-value pairs to test against. + :param numpairs: the number of key-value pairs in ``testpairs``. + :param arg_used: a pointer to a boolean indicating if the argument was used. + :param failedarg: a pointer to an integer indicating the failed argument index (if any). + + :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. + + .. versionadded:: x.y.z + + + +Package-specific Command-line Support +===================================== + +Each SUNDIALS module that wishes to support command-line options should provide a +routine of the form +``SetFromCommandLine(void* mem, const char* moduleid, int argc, char* argv[])``. +This routine can then be called by users to indicate that they wish to use +command-line options to control the corresponding SUNDIALS module. The arguments to +this function are: + +* ``mem``: an opaque pointer to the SUNDIALS module (e.g., the pointer returned by + :c:func:`CVodeCreate`). +* ``moduleid``: a desired string identifier for arguments to that module (e.g., "arkode"). + Note that each module should specify a default string identifier, that would be + used if the user specifies ``NULL`` for this argument. However, users can supply + non-default identifiers so that they can control multiple instances of the same module + to be independently (e.g., when using multiple ARKode integrators in the + same program). +* ``argc``: the number of command-line arguments. +* ``argv``: the command-line argument vector. + +Within this module-provided routine, arrays of key-value pairs having the correct type +for the corresponding "Set" routine should be defined (e.g., see the file +``src/arkode/arkode_cli.c``). + +.. note:: + When adding new "Set" routines to an existing SUNDIALS module, developers should + attempt to add a corresponding entry in the appropriate key-value pair array, and note + the new key in the module's documentation. + +After defining the allowable command-line arguments (and their corresponding "Set" +routines), the module-provided routine should loop over all ``argc`` command-line +arguments, and perform the following steps: + +#. Check whether the prefix for the current command-line argument matches the module's + identifier (e.g., "arkode"). If it does not match, then skip to the next argument. +#. If the prefix matches, then call each of the SUNDIALS-provided command-line processing + routines above (e.g., :c:func:`sunCheckAndSetActionArgs`) to attempt processing of that + command-line arguent. If that routine indicates that the argument was used, then + continue to the next command-line argument; else the next SUNDIALS-provided + command-line processing routine should be called. +#. If no SUNDIALS-provided command-line processing routine indicates that the argument + was used, then the module routine can process additional arguments that fall outside + the expertise of the SUNDIALS-provided routines. +#. By the end of the loop body, if a given argument that has the correct prefix has + still not been processed, then the routine should print a warning that the argument + was not handled. \ No newline at end of file diff --git a/doc/superbuild/source/developers/commandline/index.rst b/doc/superbuild/source/developers/commandline/index.rst new file mode 100644 index 0000000000..b61a87f32d --- /dev/null +++ b/doc/superbuild/source/developers/commandline/index.rst @@ -0,0 +1,25 @@ +.. + Author(s): Daniel R. Reynolds @ UMBC + ----------------------------------------------------------------------------- + SUNDIALS Copyright Start + Copyright (c) 2002-2025, Lawrence Livermore National Security + and Southern Methodist University. + All rights reserved. + + See the top-level LICENSE and NOTICE files for details. + + SPDX-License-Identifier: BSD-3-Clause + SUNDIALS Copyright End + ----------------------------------------------------------------------------- + +.. _CommandLineOptions: + +Setting SUNDIALS Options through the Command Line +================================================= + +This chapter discusses how to enable command-line control over SUNDIALS options. + +.. toctree:: + :maxdepth: 1 + + Options diff --git a/doc/superbuild/source/developers/index.rst b/doc/superbuild/source/developers/index.rst index caa866cb48..0f47be6d87 100644 --- a/doc/superbuild/source/developers/index.rst +++ b/doc/superbuild/source/developers/index.rst @@ -35,6 +35,7 @@ meant for SUNDIALS developers. History getting_started/index source_code/index + commandline/index documentation/index testing/index benchmarks/index From 946ce32fe29daecfefdb6eb4db1697c9f4c3bef5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Jul 2025 23:25:59 -0400 Subject: [PATCH 073/114] Removed unused CLI utility routines --- src/sundials/sundials_cli.c | 405 +++++++++++++----------------------- src/sundials/sundials_cli.h | 59 ------ 2 files changed, 139 insertions(+), 325 deletions(-) diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index 3266650b83..46d1f180b6 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -26,22 +26,6 @@ Command-line input utility routines ===============================================================*/ -SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - int iarg = atoi(argv[*argidx]); - int retval = fname(mem, iarg); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; - } - return SUN_SUCCESS; -} - SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, char* argv[], const size_t offset, const struct sunKeyIntPair* testpairs, @@ -50,33 +34,20 @@ SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetIntArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + int retval = testpairs[j].set(mem, iarg); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunTwoIntSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - int iarg1 = atoi(argv[*argidx]); - (*argidx) += 1; - int iarg2 = atoi(argv[*argidx]); - int retval = fname(mem, iarg1, iarg2); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -89,31 +60,22 @@ SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetTwoIntArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + int iarg1 = atoi(argv[*argidx]); + (*argidx) += 1; + int iarg2 = atoi(argv[*argidx]); + int retval = testpairs[j].set(mem, iarg1, iarg2); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunLongSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - long int iarg = atol(argv[*argidx]); - int retval = fname(mem, iarg); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -126,34 +88,20 @@ SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetLongArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + long int iarg = atol(argv[*argidx]); + int retval = testpairs[j].set(mem, iarg); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntRealSetFn fname, - sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - int iarg = atoi(argv[*argidx]); - (*argidx) += 1; - sunrealtype rarg = SUNStrToReal(argv[*argidx]); - int retval = fname(mem, iarg, rarg); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -166,36 +114,21 @@ SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetIntRealArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg = SUNStrToReal(argv[*argidx]); + int retval = testpairs[j].set(mem, iarg, rarg); + if (retval != SUN_SUCCESS) { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntRealRealSetFn fname, - sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - int iarg = atoi(argv[*argidx]); - (*argidx) += 1; - sunrealtype rarg1 = SUNStrToReal(argv[*argidx]); - (*argidx) += 1; - sunrealtype rarg2 = SUNStrToReal(argv[*argidx]); - int retval = fname(mem, iarg, rarg1, rarg2); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -208,34 +141,24 @@ SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetIntRealRealArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg1 = SUNStrToReal(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg2 = SUNStrToReal(argv[*argidx]); + int retval = testpairs[j].set(mem, iarg, rarg1, rarg2); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntLongSetFn fname, - sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - int iarg = atoi(argv[*argidx]); - (*argidx) += 1; - long int large = atol(argv[*argidx]); - int retval = fname(mem, iarg, large); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -248,31 +171,22 @@ SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetIntLongArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + int iarg = atoi(argv[*argidx]); + (*argidx) += 1; + long int large = atol(argv[*argidx]); + int retval = testpairs[j].set(mem, iarg, large); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunRealSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - sunrealtype rarg = SUNStrToReal(argv[*argidx]); - int retval = fname(mem, rarg); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -285,34 +199,20 @@ SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetRealArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + sunrealtype rarg = SUNStrToReal(argv[*argidx]); + int retval = testpairs[j].set(mem, rarg); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunTwoRealSetFn fname, - sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - sunrealtype rarg1 = SUNStrToReal(argv[*argidx]); - (*argidx) += 1; - sunrealtype rarg2 = SUNStrToReal(argv[*argidx]); - int retval = fname(mem, rarg1, rarg2); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -325,30 +225,22 @@ SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetTwoRealArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + sunrealtype rarg1 = SUNStrToReal(argv[*argidx]); + (*argidx) += 1; + sunrealtype rarg2 = SUNStrToReal(argv[*argidx]); + int retval = testpairs[j].set(mem, rarg1, rarg2); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunCharSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - (*argidx) += 1; - int retval = fname(mem, argv[*argidx]); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -361,31 +253,19 @@ SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetCharArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + (*argidx) += 1; + int retval = testpairs[j].set(mem, argv[*argidx]); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunTwoCharSetFn fname, - sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - int retval = fname(mem, argv[*argidx + 1], argv[*argidx + 2]); - (*argidx) += 2; - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -398,29 +278,19 @@ SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetTwoCharArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + int retval = testpairs[j].set(mem, argv[*argidx + 1], argv[*argidx + 2]); + (*argidx) += 2; + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } - } - return SUN_SUCCESS; -} - -SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunActionSetFn fname, sunbooleantype* arg_used) -{ - *arg_used = SUNFALSE; - if (strcmp(argv[*argidx] + offset, argtest) == 0) - { - int retval = fname(mem); - if (retval != SUN_SUCCESS) { return retval; } - *arg_used = SUNTRUE; } return SUN_SUCCESS; } @@ -433,15 +303,18 @@ SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, { for (int j = 0; j < numpairs; j++) { - int retval = sunCheckAndSetActionArg(mem, argidx, argv, offset, - testpairs[j].key, testpairs[j].set, - arg_used); - if (retval != SUN_SUCCESS) + *arg_used = SUNFALSE; + if (strcmp(argv[*argidx] + offset, testpairs[j].key) == 0) { - *failedarg = j; - return retval; + int retval = testpairs[j].set(mem); + if (retval != SUN_SUCCESS) + { + *failedarg = j; + return retval; + } + *arg_used = SUNTRUE; + return SUN_SUCCESS; } - if (*arg_used) { return SUN_SUCCESS; } } return SUN_SUCCESS; } diff --git a/src/sundials/sundials_cli.h b/src/sundials/sundials_cli.h index a990ab21ec..8cb08e0588 100644 --- a/src/sundials/sundials_cli.h +++ b/src/sundials/sundials_cli.h @@ -34,11 +34,6 @@ struct sunKeyIntPair sunIntSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, sunIntSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -55,12 +50,6 @@ struct sunKeyTwoIntPair sunTwoIntSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetTwoIntArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunTwoIntSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -77,11 +66,6 @@ struct sunKeyLongPair sunLongSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetLongArg(void* mem, int* argidx, char* argv[], - const size_t offset, - const char* argtest, sunLongSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -98,12 +82,6 @@ struct sunKeyIntRealPair sunIntRealSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntRealArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunIntRealSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -120,11 +98,6 @@ struct sunKeyIntRealRealPair sunIntRealRealSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntRealRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunIntRealRealSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -141,12 +114,6 @@ struct sunKeyIntLongPair sunIntLongSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntLongArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunIntLongSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -163,10 +130,6 @@ struct sunKeyRealPair sunRealSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetRealArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunRealSetFn fname, sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -183,12 +146,6 @@ struct sunKeyTwoRealPair sunTwoRealSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetTwoRealArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunTwoRealSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -205,10 +162,6 @@ struct sunKeyCharPair sunCharSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetCharArg(void* mem, int* argidx, char* argv[], - const size_t offset, const char* argtest, - sunCharSetFn fname, sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -225,12 +178,6 @@ struct sunKeyTwoCharPair sunTwoCharSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetTwoCharArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunTwoCharSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, char* argv[], const size_t offset, @@ -247,12 +194,6 @@ struct sunKeyActionPair sunActionSetFn set; }; -SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetActionArg(void* mem, int* argidx, - char* argv[], const size_t offset, - const char* argtest, - sunActionSetFn fname, - sunbooleantype* arg_used); SUNDIALS_EXPORT SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, char* argv[], const size_t offset, From b4f8c88569ecf0f3f15a7eb41b459bfa6736b84a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Jul 2025 23:47:22 -0400 Subject: [PATCH 074/114] Added additional notes to the SUNAdaptController documentation --- .../SUNAdaptController_Soderlind.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index dc3404751c..5e0a3c399f 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -423,6 +423,12 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_H0321(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_soderlind". + .. c:function:: SUNAdaptController SUNAdaptController_H211(SUNContext sunctx) This constructor creates and allocates memory for a @@ -442,6 +448,12 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_H211(sunctx); + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_soderlind". + .. c:function:: SUNAdaptController SUNAdaptController_H312(SUNContext sunctx) This constructor creates and allocates memory for a @@ -460,3 +472,9 @@ also provides the following additional user-callable routines: .. code-block:: c SUNAdaptController C = SUNAdaptController_H312(sunctx); + + .. note:: + + This SUNAdaptController implementation sets the default prefix for command-line + arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` + to be "sunadaptcontroller_soderlind". \ No newline at end of file From 8174b555acb362095c7f18034546483f1715ac94 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 4 Jul 2025 23:51:23 -0400 Subject: [PATCH 075/114] Added note on command-line options to the developer guide checklist --- .../source/developers/getting_started/Checklist.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/superbuild/source/developers/getting_started/Checklist.rst b/doc/superbuild/source/developers/getting_started/Checklist.rst index c480f3813c..e0df4375c1 100644 --- a/doc/superbuild/source/developers/getting_started/Checklist.rst +++ b/doc/superbuild/source/developers/getting_started/Checklist.rst @@ -60,6 +60,10 @@ system, etc. developers should adhere to the following checklist. * For any problems that now fail when running ``make test``, verify that your updates either made only cosmetic changes or improved the results, and update test output in the ``examples/`` directory. + * Add command-line options to control any scalar-valued parameters that you + introduced (e.g., tolerances, maximum number of iterations, etc.). + Information on how to do this can be found in the + :ref:`CommandLineOptions` section of the developer guide. #. When adding new test or example problems to the ``examples/`` directory: @@ -68,7 +72,7 @@ system, etc. developers should adhere to the following checklist. directory and ensure that ``make`` succeeds, since the CMake-generated Makefile system differs from how the examples are built within SUNDIALS. * Ensure that the reference output is included e.g., if a file ``foo.c`` is - added, also add ``foo.out``. + added, also add ``foo.out``. * Update the example problem documentation for to include a description of the new problem. @@ -77,7 +81,7 @@ system, etc. developers should adhere to the following checklist. #. If answer files changed, and it is expected/desired, then update the `.out` files that are embedded in the `examples/` directory AND the - `"answers" repository `_. + `"answers" repository `_. #. If you changed any header files, re-run SWIG to generate updated fortran interfaces. This is done by navigating to the `swig/` directory and running `make all32 all64`. From ddf872fa3cc5063b31b6888111a722d40a2b6a75 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 5 Jul 2025 11:54:54 -0700 Subject: [PATCH 076/114] fix spelling --- doc/superbuild/source/developers/commandline/Options.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/superbuild/source/developers/commandline/Options.rst b/doc/superbuild/source/developers/commandline/Options.rst index ccc945889d..6adfbd9d21 100644 --- a/doc/superbuild/source/developers/commandline/Options.rst +++ b/doc/superbuild/source/developers/commandline/Options.rst @@ -611,7 +611,7 @@ arguments, and perform the following steps: identifier (e.g., "arkode"). If it does not match, then skip to the next argument. #. If the prefix matches, then call each of the SUNDIALS-provided command-line processing routines above (e.g., :c:func:`sunCheckAndSetActionArgs`) to attempt processing of that - command-line arguent. If that routine indicates that the argument was used, then + command-line argument. If that routine indicates that the argument was used, then continue to the next command-line argument; else the next SUNDIALS-provided command-line processing routine should be called. #. If no SUNDIALS-provided command-line processing routine indicates that the argument From 49232f7ca64785648055a6e9bbaee4156c7fc463 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 5 Jul 2025 12:07:05 -0700 Subject: [PATCH 077/114] apply formatting --- examples/cvode/CXX_serial/CMakeLists.txt | 6 +- src/arkode/arkode_arkstep_io.c | 7 +-- src/arkode/arkode_cli.c | 11 ++-- src/arkode/arkode_erkstep_io.c | 6 +- src/arkode/arkode_lsrkstep_io.c | 21 +++---- src/arkode/arkode_sprkstep_io.c | 9 +-- src/cvode/cvode_cli.c | 14 ++--- src/cvodes/cvodes_cli.c | 19 +++--- src/ida/ida_cli.c | 15 ++--- src/idas/idas_cli.c | 24 ++++---- src/kinsol/kinsol_cli.c | 15 ++--- src/sundials/sundials_cli.c | 72 +++++++++++------------ src/sundials/sundials_cli.h | 73 ++++++++++++------------ 13 files changed, 130 insertions(+), 162 deletions(-) diff --git a/examples/cvode/CXX_serial/CMakeLists.txt b/examples/cvode/CXX_serial/CMakeLists.txt index 3ae3fd9f4f..08be9b5d39 100644 --- a/examples/cvode/CXX_serial/CMakeLists.txt +++ b/examples/cvode/CXX_serial/CMakeLists.txt @@ -18,9 +18,9 @@ # develop for examples excluded from 'make test' in releases # Examples using SUNDIALS linear solvers -set(CVODE_examples "cv_heat2D.cpp\;\;\;\;exclude-single" - "cv_kpr.cpp\;\;\;\;develop" - "cv_kpr.cpp\;cvode.init_step 0.01\;\;\;develop") +set(CVODE_examples + "cv_heat2D.cpp\;\;\;\;exclude-single" "cv_kpr.cpp\;\;\;\;develop" + "cv_kpr.cpp\;cvode.init_step 0.01\;\;\;develop") # Add the build and install targets for each example foreach(example_tuple ${CVODE_examples}) diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index cf34243225..aae379d7ee 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -652,8 +652,8 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "twochar" command-line options */ int j, retval; retval = sunCheckAndSetTwoCharArgs((void*)ark_mem, argidx, argv, offset, - twochar_pairs, num_twochar_keys, - arg_used, &j); + twochar_pairs, num_twochar_keys, arg_used, + &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -665,8 +665,7 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all action command-line options */ retval = sunCheckAndSetActionArgs((void*)ark_mem, argidx, argv, offset, - action_pairs, num_action_keys, - arg_used, &j); + action_pairs, num_action_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 0b1fb2877e..f27ab01c97 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -129,9 +129,8 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, } /* check all "int" command-line options */ - sunretval = sunCheckAndSetIntArgs(arkode_mem, &idx, argv, offset, - int_pairs, num_int_keys, - &arg_used, &j); + sunretval = sunCheckAndSetIntArgs(arkode_mem, &idx, argv, offset, int_pairs, + num_int_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; @@ -144,8 +143,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all long int command-line options */ sunretval = sunCheckAndSetLongArgs(arkode_mem, &idx, argv, offset, - long_pairs, num_long_keys, - &arg_used, &j); + long_pairs, num_long_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; @@ -158,8 +156,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* check all real command-line options */ sunretval = sunCheckAndSetRealArgs(arkode_mem, &idx, argv, offset, - real_pairs, num_real_keys, - &arg_used, &j); + real_pairs, num_real_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = ARK_ILL_INPUT; diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 609a09e27e..bc530a1535 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -272,13 +272,11 @@ int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "char" command-line options */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, - char_pairs, num_char_keys, - arg_used, &j); + char_pairs, num_char_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - char_pairs[j].key); + "error setting command-line argument: %s", char_pairs[j].key); return retval; } diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 15595afd58..21d68257b4 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -523,26 +523,22 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "char" command-line options */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, - char_pairs, num_char_keys, - arg_used, &j); + char_pairs, num_char_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - char_pairs[j].key); + "error setting command-line argument: %s", char_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } /* check all "long int" command-line options */ retval = sunCheckAndSetLongArgs((void*)ark_mem, argidx, argv, offset, - long_pairs, num_long_keys, - arg_used, &j); + long_pairs, num_long_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - long_pairs[j].key); + "error setting command-line argument: %s", long_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } @@ -553,21 +549,18 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); + "error setting command-line argument: %s", int_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } /* check all "real" command-line options */ retval = sunCheckAndSetRealArgs((void*)ark_mem, argidx, argv, offset, - real_pairs, num_real_keys, - arg_used, &j); + real_pairs, num_real_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - real_pairs[j].key); + "error setting command-line argument: %s", real_pairs[j].key); return retval; } diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index 8f2a59bea6..b1cc097b3b 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -215,13 +215,11 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], /* check all "char" command-line options */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, - char_pairs, num_char_keys, - arg_used, &j); + char_pairs, num_char_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - char_pairs[j].key); + "error setting command-line argument: %s", char_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } @@ -232,8 +230,7 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); + "error setting command-line argument: %s", int_pairs[j].key); return retval; } diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 155d3d8e9c..9366a332c1 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -121,23 +121,20 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, } /* check all "int" command-line options */ - sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, - int_pairs, num_int_keys, - &arg_used, &j); + sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, int_pairs, + num_int_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); + "error setting command-line argument: %s", int_pairs[j].key); return retval; } if (arg_used) continue; /* check all long int command-line options */ sunretval = sunCheckAndSetLongArgs(cvode_mem, &idx, argv, offset, - long_pairs, num_long_keys, - &arg_used, &j); + long_pairs, num_long_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; @@ -150,8 +147,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all real command-line options */ sunretval = sunCheckAndSetRealArgs(cvode_mem, &idx, argv, offset, - real_pairs, num_real_keys, - &arg_used, &j); + real_pairs, num_real_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index b2c876cc31..c2f5b51806 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -153,23 +153,20 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, } /* check all "int" command-line options */ - sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, - int_pairs, num_int_keys, - &arg_used, &j); + sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, int_pairs, + num_int_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", - int_pairs[j].key); + "error setting command-line argument: %s", int_pairs[j].key); return retval; } if (arg_used) continue; /* check all long int command-line options */ sunretval = sunCheckAndSetLongArgs(cvode_mem, &idx, argv, offset, - long_pairs, num_long_keys, - &arg_used, &j); + long_pairs, num_long_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; @@ -182,8 +179,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all real command-line options */ sunretval = sunCheckAndSetRealArgs(cvode_mem, &idx, argv, offset, - real_pairs, num_real_keys, - &arg_used, &j); + real_pairs, num_real_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; @@ -266,8 +262,9 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* check all int+real+real command-line options */ sunretval = sunCheckAndSetIntRealRealArgs(cvode_mem, &idx, argv, offset, - int_real_real_pairs, num_int_real_real_keys, - &arg_used, &j); + int_real_real_pairs, + num_int_real_real_keys, &arg_used, + &j); if (sunretval != SUN_SUCCESS) { retval = CV_ILL_INPUT; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 5c0123344d..94759786d7 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -112,9 +112,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, } /* check all "int" command-line options */ - sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, - int_pairs, num_int_keys, - &arg_used, &j); + sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, int_pairs, + num_int_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; @@ -126,9 +125,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, if (arg_used) continue; /* check all long int command-line options */ - sunretval = sunCheckAndSetLongArgs(ida_mem, &idx, argv, offset, - long_pairs, num_long_keys, - &arg_used, &j); + sunretval = sunCheckAndSetLongArgs(ida_mem, &idx, argv, offset, long_pairs, + num_long_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; @@ -140,9 +138,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, if (arg_used) continue; /* check all real command-line options */ - sunretval = sunCheckAndSetRealArgs(ida_mem, &idx, argv, offset, - real_pairs, num_real_keys, - &arg_used, &j); + sunretval = sunCheckAndSetRealArgs(ida_mem, &idx, argv, offset, real_pairs, + num_real_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 4f7a9ca8d5..0de6064371 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -147,9 +147,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, } /* check all "int" command-line options */ - sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, - int_pairs, num_int_keys, - &arg_used, &j); + sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, int_pairs, + num_int_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; @@ -161,9 +160,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, if (arg_used) continue; /* check all long int command-line options */ - sunretval = sunCheckAndSetLongArgs(ida_mem, &idx, argv, offset, - long_pairs, num_long_keys, - &arg_used, &j); + sunretval = sunCheckAndSetLongArgs(ida_mem, &idx, argv, offset, long_pairs, + num_long_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; @@ -175,9 +173,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, if (arg_used) continue; /* check all real command-line options */ - sunretval = sunCheckAndSetRealArgs(ida_mem, &idx, argv, offset, - real_pairs, num_real_keys, - &arg_used, &j); + sunretval = sunCheckAndSetRealArgs(ida_mem, &idx, argv, offset, real_pairs, + num_real_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; @@ -232,8 +229,8 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+real command-line options */ sunretval = sunCheckAndSetIntRealArgs(ida_mem, &idx, argv, offset, - int_real_pairs, num_int_real_keys, - &arg_used, &j); + int_real_pairs, num_int_real_keys, + &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; @@ -260,8 +257,9 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* check all int+real+real command-line options */ sunretval = sunCheckAndSetIntRealRealArgs(ida_mem, &idx, argv, offset, - int_real_real_pairs, num_int_real_real_keys, - &arg_used, &j); + int_real_real_pairs, + num_int_real_real_keys, &arg_used, + &j); if (sunretval != SUN_SUCCESS) { retval = IDA_ILL_INPUT; diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 206e402f02..a2f68ece26 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -97,9 +97,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ } /* check all "int" command-line options */ - sunretval = sunCheckAndSetIntArgs(kinmem, &idx, argv, offset, - int_pairs, num_int_keys, - &arg_used, &j); + sunretval = sunCheckAndSetIntArgs(kinmem, &idx, argv, offset, int_pairs, + num_int_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = KIN_ILL_INPUT; @@ -111,9 +110,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ if (arg_used) continue; /* check all long int command-line options */ - sunretval = sunCheckAndSetLongArgs(kinmem, &idx, argv, offset, - long_pairs, num_long_keys, - &arg_used, &j); + sunretval = sunCheckAndSetLongArgs(kinmem, &idx, argv, offset, long_pairs, + num_long_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = KIN_ILL_INPUT; @@ -125,9 +123,8 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ if (arg_used) continue; /* check all real command-line options */ - sunretval = sunCheckAndSetRealArgs(kinmem, &idx, argv, offset, - real_pairs, num_real_keys, - &arg_used, &j); + sunretval = sunCheckAndSetRealArgs(kinmem, &idx, argv, offset, real_pairs, + num_real_keys, &arg_used, &j); if (sunretval != SUN_SUCCESS) { retval = KIN_ILL_INPUT; diff --git a/src/sundials/sundials_cli.c b/src/sundials/sundials_cli.c index 46d1f180b6..d9b2974b34 100644 --- a/src/sundials/sundials_cli.c +++ b/src/sundials/sundials_cli.c @@ -26,11 +26,11 @@ Command-line input utility routines ===============================================================*/ -SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyIntPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -52,11 +52,11 @@ SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyTwoIntPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -80,11 +80,11 @@ SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyLongPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -106,11 +106,11 @@ SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyIntRealPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -122,7 +122,8 @@ SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, (*argidx) += 1; sunrealtype rarg = SUNStrToReal(argv[*argidx]); int retval = testpairs[j].set(mem, iarg, rarg); - if (retval != SUN_SUCCESS) { + if (retval != SUN_SUCCESS) + { *failedarg = j; return retval; } @@ -133,11 +134,10 @@ SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, - const struct sunKeyIntRealRealPair* testpairs, - int numpairs, sunbooleantype* arg_used, - int *failedarg) +SUNErrCode sunCheckAndSetIntRealRealArgs( + void* mem, int* argidx, char* argv[], const size_t offset, + const struct sunKeyIntRealRealPair* testpairs, int numpairs, + sunbooleantype* arg_used, int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -163,11 +163,11 @@ SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyIntLongPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -191,11 +191,11 @@ SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyRealPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -217,11 +217,11 @@ SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyTwoRealPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -245,11 +245,11 @@ SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyCharPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -270,11 +270,11 @@ SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyTwoCharPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { @@ -295,11 +295,11 @@ SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, return SUN_SUCCESS; } -SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyActionPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg) + int* failedarg) { for (int j = 0; j < numpairs; j++) { diff --git a/src/sundials/sundials_cli.h b/src/sundials/sundials_cli.h index 8cb08e0588..1b159b113a 100644 --- a/src/sundials/sundials_cli.h +++ b/src/sundials/sundials_cli.h @@ -35,11 +35,11 @@ struct sunKeyIntPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyIntPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for pair-of-integer "set" routines */ typedef int (*sunTwoIntSetFn)(void*, int, int); @@ -51,11 +51,11 @@ struct sunKeyTwoIntPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetTwoIntArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyTwoIntPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for long int "set" routines */ typedef int (*sunLongSetFn)(void*, long int); @@ -67,11 +67,11 @@ struct sunKeyLongPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetLongArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyLongPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for pair int/sunrealtype "set" routines */ typedef int (*sunIntRealSetFn)(void*, int, sunrealtype); @@ -83,11 +83,11 @@ struct sunKeyIntRealPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntRealArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyIntRealPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for triplet int/sunrealtype/sunrealtype "set" routines */ typedef int (*sunIntRealRealSetFn)(void*, int, sunrealtype, sunrealtype); @@ -99,11 +99,10 @@ struct sunKeyIntRealRealPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntRealRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, - const struct sunKeyIntRealRealPair* testpairs, - int numpairs, sunbooleantype* arg_used, - int *failedarg); +SUNErrCode sunCheckAndSetIntRealRealArgs( + void* mem, int* argidx, char* argv[], const size_t offset, + const struct sunKeyIntRealRealPair* testpairs, int numpairs, + sunbooleantype* arg_used, int* failedarg); /* utilities for pair int/long int "set" routines */ typedef int (*sunIntLongSetFn)(void*, int, long int); @@ -115,11 +114,11 @@ struct sunKeyIntLongPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetIntLongArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyIntLongPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for sunrealtype "set" routines */ typedef int (*sunRealSetFn)(void*, sunrealtype); @@ -131,11 +130,11 @@ struct sunKeyRealPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetRealArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyRealPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for pair-of-sunrealtype "set" routines */ typedef int (*sunTwoRealSetFn)(void*, sunrealtype, sunrealtype); @@ -147,11 +146,11 @@ struct sunKeyTwoRealPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, - char* argv[], const size_t offset, - const struct sunKeyTwoRealPair* testpairs, - int numpairs, sunbooleantype* arg_used, - int *failedarg); +SUNErrCode sunCheckAndSetTwoRealArgs(void* mem, int* argidx, char* argv[], + const size_t offset, + const struct sunKeyTwoRealPair* testpairs, + int numpairs, sunbooleantype* arg_used, + int* failedarg); /* utilities for char* "set" routines */ typedef int (*sunCharSetFn)(void*, const char*); @@ -163,11 +162,11 @@ struct sunKeyCharPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetCharArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyCharPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for pair-of-char* "set" routines */ typedef int (*sunTwoCharSetFn)(void*, const char*, const char*); @@ -179,11 +178,11 @@ struct sunKeyTwoCharPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetTwoCharArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyTwoCharPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); /* utilities for action "set" routines */ typedef int (*sunActionSetFn)(void*); @@ -195,11 +194,11 @@ struct sunKeyActionPair }; SUNDIALS_EXPORT -SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, - char* argv[], const size_t offset, +SUNErrCode sunCheckAndSetActionArgs(void* mem, int* argidx, char* argv[], + const size_t offset, const struct sunKeyActionPair* testpairs, int numpairs, sunbooleantype* arg_used, - int *failedarg); + int* failedarg); #ifdef __cplusplus } From 97b61b6854d8cb9913830ddb3a9828d6092deb94 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 5 Jul 2025 14:41:21 -0700 Subject: [PATCH 078/114] include errors impl header, remove unused variables --- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index eacccc5049..1fcb9efe12 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -15,9 +15,12 @@ #include #include #include + +#include #include #include #include + #include "sundials_cli.h" /* Interfaces to match 'sunrealtype' with the correct MAGMA functions */ @@ -248,14 +251,9 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { - SUNFunctionBegin(S->sunctx); - - int idx, j; SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + for (int idx = 1; idx < argc; idx++) { - sunbooleantype arg_used = SUNFALSE; - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; @@ -278,7 +276,6 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, int iarg = atoi(argv[idx]); retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); if (retval != SUN_SUCCESS) { return retval; } - arg_used = SUNTRUE; continue; } } From a0a97d16fc2816b812b0c4ed8f512fd0b6c7f0c1 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 5 Jul 2025 17:16:38 -0700 Subject: [PATCH 079/114] add missing output file --- ...DE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out diff --git a/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out b/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out new file mode 100644 index 0000000000..90197d4fbd --- /dev/null +++ b/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out @@ -0,0 +1,30 @@ + +Analytical ODE test problem: + lambda = -100 + reltol = 1.0e-05 + abstol = 1.0e-10 + + t u + --------------------- + 1.000000 0.785397 + 2.000000 1.107146 + 3.000000 1.249043 + 4.000000 1.325815 + 5.000000 1.373394 + 6.000000 1.405640 + 7.000000 1.428899 + 8.000000 1.446438 + 9.000000 1.460130 + 10.000000 1.471113 + --------------------- + +Final Solver Statistics: + Internal solver steps = 81 (attempted = 82) + Total RHS evals: Fe = 0, Fi = 997 + Total linear solver setups = 82 + Total RHS evals for setting up the linear system = 0 + Total number of Jacobian evaluations = 3 + Total number of Newton iterations = 492 + Total number of linear solver convergence failures = 0 + Total number of error test failures = 1 + From ad8c547990eedaca8e5dfe6767ae86fc2aca6bcb Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 5 Jul 2025 19:03:22 -0700 Subject: [PATCH 080/114] add new output files --- .../cv_kpr_cvode.init_step_0.01.out | 41 +++++++++++++++++++ .../cvsAnalytic_mels_cvodes.max_order_3.out | 30 ++++++++++++++ ...c_mels_ida.scalar_tolerances_1e-3_1e-8.out | 27 ++++++++++++ .../idasAnalytic_mels_idas.init_step_1e-5.out | 27 ++++++++++++ .../serial/kinRoberts_fp_kinsol.m_aa_1.out | 17 ++++++++ 5 files changed, 142 insertions(+) create mode 100644 examples/cvode/CXX_serial/cv_kpr_cvode.init_step_0.01.out create mode 100644 examples/cvodes/serial/cvsAnalytic_mels_cvodes.max_order_3.out create mode 100644 examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out create mode 100644 examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out create mode 100644 examples/kinsol/serial/kinRoberts_fp_kinsol.m_aa_1.out diff --git a/examples/cvode/CXX_serial/cv_kpr_cvode.init_step_0.01.out b/examples/cvode/CXX_serial/cv_kpr_cvode.init_step_0.01.out new file mode 100644 index 0000000000..418fe45124 --- /dev/null +++ b/examples/cvode/CXX_serial/cv_kpr_cvode.init_step_0.01.out @@ -0,0 +1,41 @@ + t u v u err v err +------------------------------------------------------------------------------------------------------------------------------ + 0.000000000000000e+00 1.224744871391589e+00 1.732050807568877e+00 0.000000000000000e+00 0.000000000000000e+00 + 1.000000000000000e+00 1.127014638040228e+00 1.551828197540909e+00 4.809807097494456e-06 2.857716030302271e-05 + 2.000000000000000e+00 8.899098025069805e-01 1.154613590840174e+00 7.233836438413910e-06 3.057591758404143e-05 + 3.000000000000000e+00 7.106429540476901e-01 1.023558794848728e+00 6.794188246006527e-06 4.180935955488962e-05 + 4.000000000000000e+00 8.204790679895503e-01 1.374646244985154e+00 4.699366011773343e-06 1.438293591671247e-05 + 5.000000000000000e+00 1.068571619252992e+00 1.691864906635008e+00 6.650366395577478e-06 2.600405365305036e-05 + 6.000000000000000e+00 1.216591927093313e+00 1.677545746327620e+00 4.427845855303758e-06 6.330517257735480e-06 + 7.000000000000000e+00 1.173432274159855e+00 1.342436925742140e+00 3.334287260958746e-06 1.844632641834210e-05 + 8.000000000000000e+00 9.629304026471480e-01 1.012056718876652e+00 7.800508014632612e-06 5.527453354536860e-05 + 9.000000000000000e+00 7.378507499263514e-01 1.183845790391851e+00 7.548839517035333e-06 2.072697492594422e-05 + 1.000000000000000e+01 7.618772869860075e-01 1.577065138539934e+00 4.748149205369145e-06 1.687423143925670e-05 +------------------------------------------------------------------------------------------------------------------------------ +Current time = 10.0020756826936 +Steps = 1572 +Error test fails = 144 +NLS step fails = 0 +Initial step size = 0.01 +Last step size = 0.00671233385398068 +Current step size = 0.00671233385398068 +Last method order = 5 +Current method order = 5 +Stab. lim. order reductions = 0 +RHS fn evals = 2169 +NLS iters = 2168 +NLS fails = 0 +NLS iters per step = 1.37913486005089 +LS setups = 255 +Jac fn evals = 30 +LS RHS fn evals = 0 +Prec setup evals = 0 +Prec solves = 0 +LS iters = 0 +LS fails = 0 +Jac-times setups = 0 +Jac-times evals = 0 +LS iters per NLS iter = 0 +Jac evals per NLS iter = 0.0138376383763838 +Prec evals per NLS iter = 0 +Root fn evals = 0 diff --git a/examples/cvodes/serial/cvsAnalytic_mels_cvodes.max_order_3.out b/examples/cvodes/serial/cvsAnalytic_mels_cvodes.max_order_3.out new file mode 100644 index 0000000000..50f9527864 --- /dev/null +++ b/examples/cvodes/serial/cvsAnalytic_mels_cvodes.max_order_3.out @@ -0,0 +1,30 @@ + +Analytical ODE test problem: + lambda = -100 + reltol = 1.0e-06 + abstol = 1.0e-10 + + t u + --------------------- + 1.000000 0.785398 + 2.000000 1.107149 + 3.000000 1.249046 + 4.000000 1.325818 + 5.000000 1.373401 + 6.000000 1.405648 + 7.000000 1.428899 + 8.000000 1.446441 + 9.000000 1.460139 + 10.000000 1.471128 + --------------------- + +Final Solver Statistics: + Internal solver steps = 170 + Total RHS evals = 263 + Total linear solver setups = 0 + Total RHS evals for setting up the linear system = 0 + Total number of Jacobian evaluations = 0 + Total number of Newton iterations = 260 + Total number of linear solver convergence failures = 0 + Total number of error test failures = 3 + diff --git a/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out b/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out new file mode 100644 index 0000000000..5e9a489028 --- /dev/null +++ b/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out @@ -0,0 +1,27 @@ + +Analytical DAE test problem: + alpha = 10 + reltol = 1.0e-04 + abstol = 1.0e-09 + + t x1 x2 + ---------------------------------- + 0.100000 1.105172 -0.582138 + 0.200000 1.221414 -0.679309 + 0.300000 1.349860 -0.795050 + 0.400000 1.491840 -0.932619 + 0.500000 1.648742 -1.100248 + 0.600000 1.822120 -1.302063 + 0.700000 2.013753 -1.549072 + 0.800000 2.225550 -1.854848 + 0.900000 2.459613 -2.236265 + 1.000000 2.718282 -2.718347 + ---------------------------------- + +Final Solver Statistics: + +Number of steps = 62 +Number of residual evaluations = 71 +Number of nonlinear iterations = 71 +Number of error test failures = 8 +Number of nonlinear conv. failures = 0 diff --git a/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out b/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out new file mode 100644 index 0000000000..e4b6e81f6c --- /dev/null +++ b/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out @@ -0,0 +1,27 @@ + +Analytical DAE test problem: + alpha = 10 + reltol = 1.0e-04 + abstol = 1.0e-09 + + t x1 x2 + ---------------------------------- + 0.100000 1.105171 -0.581835 + 0.200000 1.221404 -0.678748 + 0.300000 1.349859 -0.794251 + 0.400000 1.491826 -0.932637 + 0.500000 1.648723 -1.099429 + 0.600000 1.822120 -1.301831 + 0.700000 2.013754 -1.549369 + 0.800000 2.225541 -1.854629 + 0.900000 2.459604 -2.236335 + 1.000000 2.718284 -2.718654 + ---------------------------------- + +Final Solver Statistics: + +Number of steps = 345 +Number of residual evaluations = 578 +Number of nonlinear iterations = 578 +Number of error test failures = 232 +Number of nonlinear conv. failures = 0 diff --git a/examples/kinsol/serial/kinRoberts_fp_kinsol.m_aa_1.out b/examples/kinsol/serial/kinRoberts_fp_kinsol.m_aa_1.out new file mode 100644 index 0000000000..303534e6a6 --- /dev/null +++ b/examples/kinsol/serial/kinRoberts_fp_kinsol.m_aa_1.out @@ -0,0 +1,17 @@ +Example problem from chemical kinetics solving +the first time step in a Backward Euler solution for the +following three rate equations: + dy1/dt = -.04*y1 + 1.e4*y2*y3 + dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e2*(y2)^2 + dy3/dt = 3.e2*(y2)^2 +on the interval from t = 0.0 to t = 0.1, with initial +conditions: y1 = 1.0, y2 = y3 = 0. +Solution method: Anderson accelerated fixed point iteration. + +Computed solution (||F|| = 1.40454e-12): + +y = 9.967854e-01 2.953006e-03 2.616073e-04 + +Final Statistics.. + +nni = 11 nfe = 11 From 87d9f17f946e62f75210cc98a92692279e9e93eb Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 5 Jul 2025 21:53:53 -0700 Subject: [PATCH 081/114] update answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 9193ddcb1c..0444665e65 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 9193ddcb1c8d7c26d122c0f7608285d24b2d1646 +Subproject commit 0444665e6555e323eaa9d054c4f1ea06dc338fd5 From b0ba5537e8e2db6297cd8110f6f973d15854e42d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 10 Jul 2025 09:04:50 -0700 Subject: [PATCH 082/114] update answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 03349d70f3..47632dbcb5 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 03349d70f373d474a6d8d5adf61e8f2a4064cd17 +Subproject commit 47632dbcb53547823caadbe29b97c8e13c978a24 From ce0b02010e55fd520a8c78da3389943f9f8cd935 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 10 Jul 2025 09:24:44 -0700 Subject: [PATCH 083/114] update answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 47632dbcb5..633c3743af 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 47632dbcb53547823caadbe29b97c8e13c978a24 +Subproject commit 633c3743afc27c6d5aa24f6faa807d1c4594a2fc From 534c4d9f0e8fd8da2b89272e235a2a8e752c8032 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 10 Jul 2025 09:25:15 -0700 Subject: [PATCH 084/114] apply formatting --- src/kinsol/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kinsol/CMakeLists.txt b/src/kinsol/CMakeLists.txt index 83d86ea0f4..bea722d267 100644 --- a/src/kinsol/CMakeLists.txt +++ b/src/kinsol/CMakeLists.txt @@ -18,8 +18,14 @@ install(CODE "MESSAGE(\"\nInstall KINSOL\n\")") # Add variable kinsol_SOURCES with the sources for the KINSOL library -set(kinsol_SOURCES kinsol_aa.c kinsol_bbdpre.c kinsol_cli.c kinsol_io.c - kinsol_ls.c kinsol_orth.c kinsol.c) +set(kinsol_SOURCES + kinsol_aa.c + kinsol_bbdpre.c + kinsol_cli.c + kinsol_io.c + kinsol_ls.c + kinsol_orth.c + kinsol.c) # Add variable kinsol_HEADERS with the exported KINSOL header files set(kinsol_HEADERS kinsol.h kinsol_bbdpre.h kinsol_ls.h) From 619d5e281293172767d60d9d50a3a3484557f0ea Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 10 Jul 2025 15:40:44 -0700 Subject: [PATCH 085/114] update answers submodule --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 633c3743af..8f806b94ad 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 633c3743afc27c6d5aa24f6faa807d1c4594a2fc +Subproject commit 8f806b94ad4cf2208955d45e3336566003efbab1 From 4ff427396348b753516c155b9382cf82d1be9a3b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 15 Jul 2025 16:38:41 -0400 Subject: [PATCH 086/114] Applied some minor recommendations --- doc/cvodes/guide/source/Usage/SIM.rst | 3 --- doc/superbuild/source/developers/commandline/Options.rst | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index b7898c2761..7cb6504314 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -2314,9 +2314,6 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eps_lin". - This routine will be called by :c:func:`CVodeSetFromCommandLine` when using the command-line option "cvid.eps_proj". diff --git a/doc/superbuild/source/developers/commandline/Options.rst b/doc/superbuild/source/developers/commandline/Options.rst index 6adfbd9d21..000b617eb6 100644 --- a/doc/superbuild/source/developers/commandline/Options.rst +++ b/doc/superbuild/source/developers/commandline/Options.rst @@ -22,7 +22,7 @@ routines through a set of data structures and utility routines that compare a gi command-line argument against a list of reserved keywords. If the given argument is matched to a relevant key, then the associated "Set" routine is called with the argument(s) that follow the key on the command line. This allows users to set SUNDIALS -options at runtime, without needing to modify the source code or recompile the library. +options at runtime, without needing to modify the source code. Prototypes for the SUNDIALS-provided infrastructure routines and corresponding data structures for command-line support are in the ``src/sundials/sundials_cli.h`` From e72d741ce3ffea51263bb83bab96cbddb360c264 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 15 Jul 2025 16:39:34 -0400 Subject: [PATCH 087/114] Applied some minor recommendations to the ARKODE docs, and made some larger changes that were requested in the PR review. --- .../guide/source/Usage/User_callable.rst | 72 ++++++++++++++----- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index e5a7d77d5d..86abb35f35 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -914,33 +914,70 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec .. c:function:: int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, char* argv[]) - Passes command-line arguments to ARKODE to set options. + Sets ARKODE options from an array of strings. :param arkode_mem: pointer to the ARKODE memory block. - :param arkid: String to use as prefix for ARKODE command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param arkid: the prefix for options to read. The default is "arkode". + :param argc: the number of options provided. + :param argv: an array of strings containing the options to set and their values. :retval ARK_SUCCESS: the function exited successfully. :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. :retval other: error return value from relevant ARKODE "set" routine. + **Example usage:** + + In a C or C++ program, the following will enable command-line processing: + + .. code-block:: C + + /* Create ARKODE memory block */ + void* arkode_mem = ARKStepCreate(fe, fi, T0, y, ctx); + + /* Configure ARKODE as normal */ + ... + + /* Override settings with command-line options using default "arkode" prefix */ + flag = ARKodeSetFromCommandLine(arkode_mem, NULL, argc, argv); + + Then when running the program, the user can specify desired options, e.g., + + .. code-block:: console + + $ ./a.out arkode.order 3 arkode.interpolant_type ARK_INTERP_LAGRANGE + .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These - are left unchanged by :c:func:`ARKodeSetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`ARKodeSetFromCommandLine`. + + If the ``arkid`` argument is ``NULL``, then the default prefix, ``arkode``, must + be used for all ARKODE options. For example, the option ``arkode.order`` followed + by the value can be used to set the method order of accuracy. - If the *arkid* argument is ``NULL`` then ``arkode.`` will be used for all ARKODE command-line - options, e.g., to set the integrator order of accuracy the default command-line option would be "arkode.order". - When using a combination of ARKODE integrators (e.g., via MRIStep, SplittingStep or - ForcingStep), it is recommended that users call :c:func:`ARKodeSetFromCommandLine` for each - ARKODE integrator using distinct *arkid* inputs, so that each ARKODE integrator can be controlled - separately. + When using a combination of ARKODE integrators (e.g., via MRIStep, SplittingStep, + or ForcingStep), it is recommended that users call + :c:func:`ARKodeSetFromCommandLine` for each ARKODE integrator using a distinct + ``arkid`` so they can be controlled separately. For example, "fast" and "slow" + option prefixes can be used to differentiate between options for the slow and + fast integrators in an MRI method (i.e., ``fast.order`` and ``slow.order`` + followed by the desired values to set the method order for the fast and slow time + scales, respectively). - ARKODE options set via command-line arguments to :c:func:`ARKodeSetFromCommandLine` will overwrite + ARKODE options set via :c:func:`ARKodeSetFromCommandLine` will overwrite any previously-set values. - The supported command-line options are documented within each ARKODE "set" routine. + The supported option names are noted within the documentation for the + corresponding ARKODE "set" function. + + One additional option is ``write_parameters`` -- after all ARKODE command-line + options have been processed, this will print all current ARKODE parameters to + the standard output stream. + + .. warning:: + + This function is not available in the Fortran interface. .. versionadded:: x.y.z @@ -1422,9 +1459,6 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec this function must be made *before* any calls to :c:func:`ARKodeSetLinearSolver` and/or :c:func:`ARKodeSetMassLinearSolver`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.linear". - .. versionadded:: 6.1.0 @@ -1566,8 +1600,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec Currently, all ARKODE modules support compensated summation for accumulating time. SPRKStep also supports an alternative stepping algorithm based on compensated - summation which will be enabled/disabled by this function. This increases the - computational cost by 2 extra vector operations per stage and an additional + summation which will be enabled/disabled by this function. This increases the + computational cost by 2 extra vector operations per stage and an additional 5 per time step. It also requires one extra vector to be stored. However, it is significantly more robust to roundoff error accumulation. From 7b11a0c9316bfedb178494a70f0105648acb06ab Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Tue, 15 Jul 2025 17:31:21 -0400 Subject: [PATCH 088/114] Applied multiple minor recommendations from PR review --- doc/cvode/guide/source/Usage/index.rst | 5 ++++- doc/cvodes/guide/source/Usage/SIM.rst | 4 ++-- doc/superbuild/source/developers/commandline/Options.rst | 3 ++- doc/superbuild/source/developers/commandline/index.rst | 2 +- src/cvode/cvode_cli.c | 4 ++-- src/cvodes/cvodes_cli.c | 4 ++-- src/sunlinsol/klu/sunlinsol_klu.c | 2 +- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 2 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 2 +- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 2 +- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- 11 files changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/cvode/guide/source/Usage/index.rst b/doc/cvode/guide/source/Usage/index.rst index 93f6b177c0..f2228abcee 100644 --- a/doc/cvode/guide/source/Usage/index.rst +++ b/doc/cvode/guide/source/Usage/index.rst @@ -1340,7 +1340,7 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function **Notes:** This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.dgmax_lsetup". + when using the command-line option "cvid.delta_gamma_max_lsetup". .. versionadded:: 6.2.0 @@ -2134,6 +2134,9 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_ef}}` can be set with :c:func:`CVodeSetEtaMaxErrFail`. + This routine will be called by :c:func:`CVodeSetFromCommandLine` + when using the command-line option "cvid.num_fails_eta_max_err_fail". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaConvFail(void* cvode_mem, sunrealtype eta_cf) diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index 7cb6504314..7e920708ee 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -1334,7 +1334,7 @@ using the current :math:`\gamma` value. **Notes:** This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.dgmax_lsetup". + when using the command-line option "cvid.delta_gamma_max_lsetup". .. versionadded:: 6.2.0 @@ -2126,7 +2126,7 @@ step size adaptivity. :c:func:`CVodeSetEtaMaxErrFail`. This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.num_efails_eta_max_err_fail". + when using the command-line option "cvid.num_fails_eta_max_err_fail". .. versionadded:: 6.2.0 diff --git a/doc/superbuild/source/developers/commandline/Options.rst b/doc/superbuild/source/developers/commandline/Options.rst index 000b617eb6..daabdf3045 100644 --- a/doc/superbuild/source/developers/commandline/Options.rst +++ b/doc/superbuild/source/developers/commandline/Options.rst @@ -589,7 +589,7 @@ this function are: Note that each module should specify a default string identifier, that would be used if the user specifies ``NULL`` for this argument. However, users can supply non-default identifiers so that they can control multiple instances of the same module - to be independently (e.g., when using multiple ARKode integrators in the + independently (e.g., when using multiple ARKode integrators in the same program). * ``argc``: the number of command-line arguments. * ``argv``: the command-line argument vector. @@ -599,6 +599,7 @@ for the corresponding "Set" routine should be defined (e.g., see the file ``src/arkode/arkode_cli.c``). .. note:: + When adding new "Set" routines to an existing SUNDIALS module, developers should attempt to add a corresponding entry in the appropriate key-value pair array, and note the new key in the module's documentation. diff --git a/doc/superbuild/source/developers/commandline/index.rst b/doc/superbuild/source/developers/commandline/index.rst index b61a87f32d..0a5ad0a4ca 100644 --- a/doc/superbuild/source/developers/commandline/index.rst +++ b/doc/superbuild/source/developers/commandline/index.rst @@ -14,7 +14,7 @@ .. _CommandLineOptions: -Setting SUNDIALS Options through the Command Line +Command Line Options ================================================= This chapter discusses how to enable command-line control over SUNDIALS options. diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 9366a332c1..666a68828e 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -52,7 +52,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"stab_lim_det", CVodeSetStabLimDet}, {"interpolate_stop_time", CVodeSetInterpolateStopTime}, {"use_integrator_fused_kernels", CVodeSetUseIntegratorFusedKernels}, - {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"num_fails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, {"linear_solution_scaling", CVodeSetLinearSolutionScaling}, {"proj_err_est", CVodeSetProjErrEst}, {"max_num_proj_fails", CVodeSetMaxNumProjFails}}; @@ -68,7 +68,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static const struct sunKeyRealPair real_pairs[] = - {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {{"delta_gamma_max_lsetup", CVodeSetDeltaGammaMaxLSetup}, {"init_step", CVodeSetInitStep}, {"max_step", CVodeSetMaxStep}, {"min_step", CVodeSetMinStep}, diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index c2f5b51806..629c34e84d 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -51,7 +51,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"max_order", CVodeSetMaxOrd}, {"stab_lim_det", CVodeSetStabLimDet}, {"interpolate_stop_time", CVodeSetInterpolateStopTime}, - {"num_efails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, + {"num_fails_eta_max_err_fail", CVodeSetNumFailsEtaMaxErrFail}, {"quad_err_con", CVodeSetQuadErrCon}, {"sens_err_con", CVodeSetSensErrCon}, {"sens_max_nonlin_iters", CVodeSetSensMaxNonlinIters}, @@ -70,7 +70,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_long_keys = sizeof(long_pairs) / sizeof(*long_pairs); static const struct sunKeyRealPair real_pairs[] = - {{"dgmax_lsetup", CVodeSetDeltaGammaMaxLSetup}, + {{"delta_gamma_max_lsetup", CVodeSetDeltaGammaMaxLSetup}, {"init_step", CVodeSetInitStep}, {"max_step", CVodeSetMaxStep}, {"min_step", CVodeSetMinStep}, diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 049fac491c..88a43be64c 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -195,7 +195,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spbcgs." */ + else, skip command-line arguments that do not begin with "klu." */ size_t offset; if (LSid != NULL) { diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 1fcb9efe12..5f0c4586d3 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -255,7 +255,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, for (int idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spbcgs." */ + else, skip command-line arguments that do not begin with "magmadense." */ size_t offset; if (LSid != NULL) { diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 8b77e08b0e..f54e1b25d9 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -153,7 +153,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spbcgs." */ + else, skip command-line arguments that do not begin with "pcg." */ size_t offset; if (LSid != NULL) { diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index edb5e321b7..d0a5c45e2b 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -177,7 +177,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spbcgs." */ + else, skip command-line arguments that do not begin with "sptfqmr." */ size_t offset; if (LSid != NULL) { diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index f358b9186e..11d28be09a 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -232,7 +232,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spbcgs." */ + else, skip command-line arguments that do not begin with "superlumt." */ size_t offset; if (LSid != NULL) { From 57d88e774031bc575f33861093fb44d94a7037f4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 16:56:40 -0400 Subject: [PATCH 089/114] Converted *SetFromCommandLine routines into *SetOptions routines (as requested in PR review); addressed multiple PR requests; simplified keys for SUNAdaptController and SUNLinearSolver implementations; added command-line control over SUNNonlinearSolvers. --- .../source/Usage/ARKStep/User_callable.rst | 22 +- .../source/Usage/ERKStep/User_callable.rst | 10 +- .../source/Usage/LSRKStep/User_callable.rst | 24 +- .../source/Usage/MRIStep/User_callable.rst | 4 +- .../source/Usage/SPRKStep/User_callable.rst | 8 +- .../guide/source/Usage/User_callable.rst | 217 ++++++++--------- doc/cvode/guide/source/Usage/index.rst | 222 ++++++++++-------- doc/cvodes/guide/source/Usage/ADJ.rst | 31 ++- doc/cvodes/guide/source/Usage/FSA.rst | 16 +- doc/cvodes/guide/source/Usage/SIM.rst | 217 +++++++++-------- doc/ida/guide/source/Usage/index.rst | 192 ++++++++------- doc/idas/guide/source/Usage/ADJ.rst | 33 ++- doc/idas/guide/source/Usage/FSA.rst | 20 +- doc/idas/guide/source/Usage/SIM.rst | 196 +++++++++------- doc/kinsol/guide/source/Usage/index.rst | 139 ++++++----- .../SUNAdaptController_Description.rst | 58 +++-- .../SUNAdaptController_ImExGus.rst | 10 +- .../SUNAdaptController_MRIHTol.rst | 10 +- .../SUNAdaptController_Soderlind.rst | 76 +----- doc/shared/sunlinsol/SUNLinSol_API.rst | 42 ++-- doc/shared/sunlinsol/SUNLinSol_KLU.rst | 8 +- doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst | 9 +- doc/shared/sunlinsol/SUNLinSol_PCG.rst | 12 +- doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst | 12 +- doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst | 16 +- doc/shared/sunlinsol/SUNLinSol_SPGMR.rst | 15 +- doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst | 12 +- doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst | 8 +- doc/shared/sunnonlinsol/SUNNonlinSol_API.rst | 43 ++++ .../source/developers/commandline/Options.rst | 194 +++++++++------ examples/arkode/C_serial/ark_analytic.c | 4 +- examples/arkode/C_serial/ark_heat1D.c | 8 +- examples/arkode/C_serial/ark_kpr_mri.c | 8 +- examples/cvode/CXX_serial/cv_kpr.cpp | 4 +- examples/cvodes/serial/cvsAnalytic_mels.c | 4 +- examples/ida/serial/idaAnalytic_mels.c | 4 +- examples/idas/serial/idasAnalytic_mels.c | 4 +- examples/kinsol/serial/kinRoberts_fp.c | 4 +- include/arkode/arkode.h | 4 +- include/cvode/cvode.h | 4 +- include/cvodes/cvodes.h | 4 +- include/ida/ida.h | 4 +- include/idas/idas.h | 4 +- include/kinsol/kinsol.h | 4 +- .../sunadaptcontroller_imexgus.h | 6 + .../sunadaptcontroller_mrihtol.h | 6 + .../sunadaptcontroller_soderlind.h | 7 + include/sundials/sundials_adaptcontroller.h | 11 +- include/sundials/sundials_linearsolver.h | 8 +- include/sundials/sundials_nonlinearsolver.h | 6 + include/sunlinsol/sunlinsol_klu.h | 4 + include/sunlinsol/sunlinsol_magmadense.h | 4 + include/sunlinsol/sunlinsol_pcg.h | 4 + include/sunlinsol/sunlinsol_spbcgs.h | 4 + include/sunlinsol/sunlinsol_spfgmr.h | 3 + include/sunlinsol/sunlinsol_spgmr.h | 4 + include/sunlinsol/sunlinsol_sptfqmr.h | 4 + include/sunlinsol/sunlinsol_superlumt.h | 4 + .../sunnonlinsol/sunnonlinsol_fixedpoint.h | 6 + include/sunnonlinsol/sunnonlinsol_newton.h | 6 + src/arkode/arkode.c | 2 +- src/arkode/arkode_arkstep.c | 2 +- src/arkode/arkode_arkstep_impl.h | 4 +- src/arkode/arkode_arkstep_io.c | 18 +- src/arkode/arkode_cli.c | 61 +++-- src/arkode/arkode_erkstep.c | 2 +- src/arkode/arkode_erkstep_impl.h | 4 +- src/arkode/arkode_erkstep_io.c | 14 +- src/arkode/arkode_impl.h | 8 +- src/arkode/arkode_lsrkstep.c | 2 +- src/arkode/arkode_lsrkstep_impl.h | 4 +- src/arkode/arkode_lsrkstep_io.c | 30 +-- src/arkode/arkode_mristep.c | 2 +- src/arkode/arkode_mristep_impl.h | 4 +- src/arkode/arkode_mristep_io.c | 14 +- src/arkode/arkode_sprkstep.c | 2 +- src/arkode/arkode_sprkstep_impl.h | 4 +- src/arkode/arkode_sprkstep_io.c | 19 +- src/cvode/cvode_cli.c | 49 +++- src/cvodes/cvodes_cli.c | 57 +++-- src/ida/ida_cli.c | 51 +++- src/idas/idas_cli.c | 59 +++-- src/kinsol/kinsol_cli.c | 46 +++- .../imexgus/sunadaptcontroller_imexgus.c | 58 +++-- .../mrihtol/sunadaptcontroller_mrihtol.c | 58 +++-- .../soderlind/sunadaptcontroller_soderlind.c | 119 +++++----- src/sundials/sundials_adaptcontroller.c | 35 +-- src/sundials/sundials_linearsolver.c | 44 ++-- src/sundials/sundials_nonlinearsolver.c | 11 + src/sunlinsol/klu/sunlinsol_klu.c | 52 ++-- .../magmadense/sunlinsol_magmadense.cpp | 51 ++-- src/sunlinsol/pcg/sunlinsol_pcg.c | 74 ++++-- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 66 ++++-- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 66 ++++-- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 66 ++++-- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 70 ++++-- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 57 +++-- .../fixedpoint/sunnonlinsol_fixedpoint.c | 68 ++++++ src/sunnonlinsol/newton/sunnonlinsol_newton.c | 68 ++++++ 99 files changed, 2114 insertions(+), 1334 deletions(-) diff --git a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst index d6c6f26128..d5ecfbef79 100644 --- a/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ARKStep/User_callable.rst @@ -1255,8 +1255,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int pointers *fe* or *fi* passed to :c:func:`ARKStepCreate` are ``NULL``, but may be set directly by the user if desired. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.set_imex". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.imex". .. c:function:: int ARKStepSetExplicit(void* arkode_mem) @@ -1281,8 +1281,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int f(t,y)`, then we recommend that the ERKStep time-stepper module be used instead. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.set_explicit". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.explicit". .. c:function:: int ARKStepSetImplicit(void* arkode_mem) @@ -1302,8 +1302,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int passed to :c:func:`ARKStepCreate` is ``NULL``, but may be set directly by the user if desired. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.set_implicit". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.implicit". @@ -1444,8 +1444,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int In all cases, error-checking is performed to ensure that the tables exist. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.table_names". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.table_names". **Warning:** @@ -1634,7 +1634,7 @@ Optional inputs for time step adaptivity .. deprecated:: 5.7.0 Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). - + .. versionchanged:: 6.3.0 The default value was changed from 1.5 to 1.0 @@ -1660,7 +1660,7 @@ Optional inputs for time step adaptivity .. deprecated:: 6.1.0 Use :c:func:`ARKodeSetFixedStepBounds` instead. - + .. versionchanged:: 6.3.0 The default upper bound was changed from 1.5 to 1.0 @@ -1804,7 +1804,7 @@ Optional inputs for time step adaptivity .. deprecated:: 6.1.0 Use :c:func:`ARKodeSetSafetyFactor` instead. - + .. versionchanged:: 6.3.0 The default default was changed from 0.96 to 0.9. The maximum value is now diff --git a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst index 079827fc16..1014b3f843 100644 --- a/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep/User_callable.rst @@ -936,8 +936,8 @@ Optional inputs for IVP method selection .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.table_name". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.table_name". .. _ARKODE.Usage.ERKStep.ERKStepAdaptivityInput: @@ -1125,7 +1125,7 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. .. deprecated:: 5.7.0 Use the SUNAdaptController infrastructure instead (see :numref:`SUNAdaptController.Description`). - + .. versionchanged:: 6.3.0 The default value was changed from 1.5 to 1.0 @@ -1152,7 +1152,7 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. .. deprecated:: 6.1.0 Use :c:func:`ARKodeSetFixedStepBounds` instead. - + .. versionchanged:: 6.3.0 The default upper bound was changed from 1.5 to 1.0 @@ -1277,7 +1277,7 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. .. deprecated:: 6.1.0 Use :c:func:`ARKodeSetSafetyFactor` instead. - + .. versionchanged:: 6.3.0 The default default was changed from 0.96 to 0.9. The maximum value is now diff --git a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst index 5a143a5d5a..76912c77d3 100644 --- a/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/LSRKStep/User_callable.rst @@ -158,8 +158,8 @@ Allowable Method Families .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.sts_method". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.sts_method_name". .. c:function:: int LSRKStepSetSSPMethodByName(void* arkode_mem, const char* emethod); @@ -177,8 +177,8 @@ Allowable Method Families .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.ssp_method". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.ssp_method_name". .. c:function:: int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); @@ -221,8 +221,8 @@ Allowable Method Families Calling this function with ``nsteps < 0`` resets the default value while ``nsteps = 0`` refers to constant dominant eigenvalue. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.dom_eig_frequency". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.dom_eig_frequency". .. c:function:: int LSRKStepSetMaxNumStages(void* arkode_mem, int stage_max_limit); @@ -247,8 +247,8 @@ Allowable Method Families :math:`s^2 \sim - h\lambda`, where :math:`s` is the number of stages used, :math:`h` is the current step size and :math:`\lambda` is the dominant eigenvalue. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_num_stages". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_num_stages". .. c:function:: int LSRKStepSetDomEigSafetyFactor(void* arkode_mem, sunrealtype dom_eig_safety); @@ -272,8 +272,8 @@ Allowable Method Families ``dom_eig_safety`` is set to :math:`1.01`. Calling this function with ``dom_eig_safety < 1`` resets the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.dom_eig_safety_factor". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.dom_eig_safety_factor". .. c:function:: int LSRKStepSetNumSSPStages(void* arkode_mem, int num_of_stages); @@ -302,8 +302,8 @@ Allowable Method Families * ``num_of_stages = 9`` for :c:enumerator:`ARKODE_LSRK_SSP_S_3` * ``num_of_stages = 10`` for :c:enumerator:`ARKODE_LSRK_SSP_10_4` - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.num_ssp_stages". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.num_ssp_stages". .. _ARKODE.Usage.LSRKStep.OptionalOutputs: diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index fb4622a816..c9153b3c2c 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -800,8 +800,8 @@ Optional inputs for IVP method selection For a description of the :c:type:`MRIStepCoupling` type and related functions for creating Butcher tables see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.coupling_table", where *C* + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.coupling_table_name", where *C* is itself constructed by passing the command-line option to :c:func:`MRIStepCoupling_LoadTableByName`. diff --git a/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst index 5fc5a72cd9..f1f18346e0 100644 --- a/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst @@ -481,8 +481,8 @@ Optional inputs for IVP method selection .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.method_name". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.method_name". .. warning:: @@ -508,8 +508,8 @@ Optional inputs for IVP method selection .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.use_compensated_sums". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.use_compensated_sums". .. deprecated:: 6.4.0 diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 86abb35f35..1330571aad 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -135,8 +135,8 @@ Alternatively, the user may supply a custom function to supply the .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.scalar_tolerances". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.scalar_tolerances". .. versionadded:: 6.1.0 @@ -887,7 +887,7 @@ Optional inputs for ARKODE ================================================= ========================================== ======================= Optional input Function name Default ================================================= ========================================== ======================= -Set ARKODE options from the command line :c:func:`ARKodeSetFromCommandLine` internal +Set ARKODE options from the command line or file :c:func:`ARKodeSetOptions` internal Return ARKODE parameters to their defaults :c:func:`ARKodeSetDefaults` internal Set integrator method order :c:func:`ARKodeSetOrder` 4 Set dense output interpolation type :c:func:`ARKodeSetInterpolantType` stepper-specific @@ -912,13 +912,15 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec -.. c:function:: int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, char* argv[]) +.. c:function:: int ARKodeSetOptions(void* arkode_mem, const char* arkid, const char* file_name, int argc, char* argv[]) - Sets ARKODE options from an array of strings. + Sets ARKODE options from an array of strings or a file. :param arkode_mem: pointer to the ARKODE memory block. :param arkid: the prefix for options to read. The default is "arkode". - :param argc: the number of options provided. + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: length of the ``argv`` array. :param argv: an array of strings containing the options to set and their values. :retval ARK_SUCCESS: the function exited successfully. @@ -938,7 +940,7 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec ... /* Override settings with command-line options using default "arkode" prefix */ - flag = ARKodeSetFromCommandLine(arkode_mem, NULL, argc, argv); + flag = ARKodeSetOptions(arkode_mem, NULL, NULL, argc, argv); Then when running the program, the user can specify desired options, e.g., @@ -950,7 +952,7 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec The ``argc`` and ``argv`` arguments are typically those supplied to the user's ``main`` routine however, this is not required. The inputs are left unchanged by - :c:func:`ARKodeSetFromCommandLine`. + :c:func:`ARKodeSetOptions`. If the ``arkid`` argument is ``NULL``, then the default prefix, ``arkode``, must be used for all ARKODE options. For example, the option ``arkode.order`` followed @@ -958,27 +960,26 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec When using a combination of ARKODE integrators (e.g., via MRIStep, SplittingStep, or ForcingStep), it is recommended that users call - :c:func:`ARKodeSetFromCommandLine` for each ARKODE integrator using a distinct + :c:func:`ARKodeSetOptions` for each ARKODE integrator using a distinct ``arkid`` so they can be controlled separately. For example, "fast" and "slow" option prefixes can be used to differentiate between options for the slow and fast integrators in an MRI method (i.e., ``fast.order`` and ``slow.order`` followed by the desired values to set the method order for the fast and slow time scales, respectively). - ARKODE options set via :c:func:`ARKodeSetFromCommandLine` will overwrite + ARKODE options set via :c:func:`ARKodeSetOptions` will overwrite any previously-set values. The supported option names are noted within the documentation for the corresponding ARKODE "set" function. - One additional option is ``write_parameters`` -- after all ARKODE command-line - options have been processed, this will print all current ARKODE parameters to - the standard output stream. - .. warning:: This function is not available in the Fortran interface. + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. + .. versionadded:: x.y.z @@ -1028,8 +1029,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec ARKODE memory block, it cannot be changed after the first call to :c:func:`ARKodeEvolve`, unless ``*StepReInit`` is called. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.order". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.order". .. versionadded:: 6.1.0 @@ -1080,8 +1081,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.interpolant_type". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.interpolant_type". .. versionchanged:: 6.1.0 @@ -1130,8 +1131,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec obtained by the integrator are returned at the ends of the time interval. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.interpolant_degree". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.interpolant_degree". .. versionadded:: 6.1.0 @@ -1190,8 +1191,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec routines will provide no useful information to the solver, and at worst they may interfere with the desired fixed step size. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.fixed_step". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.fixed_step". .. versionadded:: 6.1.0 @@ -1222,8 +1223,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec estimated at the next call to :c:func:`ARKodeEvolve` or can be specified with :c:func:`ARKodeSetInitStep`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.step_direction". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.step_direction". .. versionadded:: 6.2.0 @@ -1253,8 +1254,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec This routine will also reset the step size and error history. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.init_step". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.init_step". .. versionadded:: 6.1.0 @@ -1284,8 +1285,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec A negative value indicates that no warning messages should be issued. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_hnil_warns". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_hnil_warns". .. versionadded:: 6.1.0 @@ -1311,8 +1312,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec Passing *mxsteps* < 0 disables the test (not recommended). - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_num_steps". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_num_steps". .. versionadded:: 6.1.0 @@ -1336,8 +1337,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_step". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_step". .. versionadded:: 6.1.0 @@ -1361,8 +1362,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec Pass *hmin* :math:`\le 0.0` to set the default value of 0. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.min_step". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.min_step". .. versionadded:: 6.1.0 @@ -1391,8 +1392,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec :c:func:`ARKodeReset` will remain active but can be disabled by calling :c:func:`ARKodeClearStopTime`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.stop_time". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.stop_time". .. versionadded:: 6.1.0 @@ -1411,8 +1412,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.interpolate_stop_time". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.interpolate_stop_time". .. versionadded:: 6.1.0 @@ -1431,8 +1432,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec The stop time can be re-enabled though a new call to :c:func:`ARKodeSetStopTime`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.clear_stop_time". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.clear_stop_time". .. versionadded:: 6.1.0 @@ -1483,8 +1484,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec The default value is 7; set *maxnef* :math:`\le 0` to specify this default. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_err_test_fails". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_err_test_fails". .. versionadded:: 6.1.0 @@ -1557,8 +1558,8 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec Passing *maxfails* <= 0 results in ARKODE using the default value (10). - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_num_constr_fails". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_num_constr_fails". .. versionadded:: 6.1.0 @@ -1734,8 +1735,8 @@ Reset accumulated error :c:func:`ARKodeReset This should be called prior to calling :c:func:`ARKodeEvolve`, and can only be reset following a call to ``*StepReInit``. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.adaptivity_adjustment". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.adaptivity_adjustment". .. versionadded:: 6.1.0 @@ -1764,8 +1765,8 @@ Reset accumulated error :c:func:`ARKodeReset Any non-positive parameter will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.cfl_fraction". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.cfl_fraction". .. versionadded:: 6.1.0 @@ -1799,8 +1800,8 @@ Reset accumulated error :c:func:`ARKodeReset :c:func:`ARKodeSetAdaptController` will be called, then this routine must be called *second*. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.error_bias". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.error_bias". .. versionadded:: 6.1.0 @@ -1829,8 +1830,8 @@ Reset accumulated error :c:func:`ARKodeReset Any interval *not* containing 1.0 will imply a reset to the default values. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.fixed_step_bounds". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.fixed_step_bounds". .. versionadded:: 6.1.0 @@ -1861,8 +1862,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value outside the interval :math:`(0,1]` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_cfail_growth". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_cfail_growth". .. versionadded:: 6.1.0 @@ -1887,8 +1888,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value outside the interval :math:`(0,1]` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_efail_growth". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_efail_growth". .. versionadded:: 6.1.0 @@ -1914,8 +1915,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 1.0` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_first_growth". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_first_growth". .. versionadded:: 6.1.0 @@ -1941,8 +1942,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 1.0` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_growth". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_growth". .. versionadded:: 6.1.0 @@ -1970,8 +1971,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value outside the interval :math:`(0,1)` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.min_reduction". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.min_reduction". .. versionadded:: 6.1.0 @@ -1997,8 +1998,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 0` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.safety_factor". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.safety_factor". .. versionadded:: 6.1.0 @@ -2029,8 +2030,8 @@ Reset accumulated error :c:func:`ARKodeReset Any value :math:`\le 0` will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.small_num_efails". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.small_num_efails". .. versionadded:: 6.1.0 @@ -2118,8 +2119,8 @@ tolerance. .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.accum_error_type". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.accumulated_error_type". :param arkode_mem: pointer to the ARKODE memory block. :param accum_type: accumulation strategy. @@ -2146,8 +2147,8 @@ tolerance. .. note:: - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.reset_accumulated_error". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.reset_accumulated_error". .. versionadded:: 6.2.0 @@ -2242,8 +2243,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS :c:func:`ARKodeSetDeltaGammaMax` to reset the step size ratio threshold to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.nonlinear". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.nonlinear". .. versionadded:: 6.1.0 @@ -2297,8 +2298,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS evaluation but instead evaluate the necessary quantities within the preconditioner setup function using the input values. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.autonomous". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.autonomous". .. versionadded:: 6.1.0 @@ -2335,8 +2336,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS The default value is 0. If *method* is set to an undefined value, this default predictor will be used. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.predictor_method". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.predictor_method". .. versionadded:: 6.1.0 @@ -2416,8 +2417,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS The default value is 3; set *maxcor* :math:`\le 0` to specify this default. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_nonlin_iters". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_nonlin_iters". .. versionadded:: 6.1.0 @@ -2443,8 +2444,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS The default value is 0.1; set *nlscoef* :math:`\le 0` to specify this default. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.nonlin_conv_coef". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.nonlin_conv_coef". .. versionadded:: 6.1.0 @@ -2468,8 +2469,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS Any non-positive parameter will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.nonlin_crdown". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.nonlin_crdown". .. versionadded:: 6.1.0 @@ -2495,8 +2496,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS Any non-positive parameter will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.nonlin_rdiv". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.nonlin_rdiv". .. versionadded:: 6.1.0 @@ -2530,8 +2531,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS convergence failure still occurs, the time step size is reduced by the factor *etacf* (set within :c:func:`ARKodeSetMaxCFailGrowth`). - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.max_conv_fails". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.max_conv_fails". .. versionadded:: 6.1.0 @@ -2556,8 +2557,8 @@ Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeS This is only compatible with time-stepping modules that support implicit algebraic solvers. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.deduce_implicit_rhs". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.deduce_implicit_rhs". .. versionadded:: 6.1.0 @@ -2666,8 +2667,8 @@ is recomputed using the current :math:`\gamma` value. Any non-positive parameter will imply a reset to the default value. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.delta_gamma_max". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.delta_gamma_max". .. versionadded:: 6.1.0 @@ -2697,8 +2698,8 @@ is recomputed using the current :math:`\gamma` value. step. If **msbp** is 0, the default value of 20 will be used. A negative value forces a linear solver step at each implicit stage. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.lsetup_frequency". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.lsetup_frequency". .. versionadded:: 6.1.0 @@ -2742,8 +2743,8 @@ is recomputed using the current :math:`\gamma` value. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKodeSetLinearSolver`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.jac_eval_frequency". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.jac_eval_frequency". .. versionadded:: 6.1.0 @@ -2932,8 +2933,8 @@ data in the program. The user data pointer may be specified through Linear solution scaling is enabled by default when a matrix-based linear solver is attached. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.linear_solution_scaling". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.linear_solution_scaling". .. versionadded:: 6.1.0 @@ -3272,8 +3273,8 @@ the user through the :c:func:`ARKodeSetEpsLin` function. interface has been initialized through a call to :c:func:`ARKodeSetLinearSolver`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.eps_lin". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.eps_lin". .. versionadded:: 6.1.0 @@ -3305,8 +3306,8 @@ the user through the :c:func:`ARKodeSetEpsLin` function. Passing a value *eplifac* :math:`\le 0` indicates to use the default value of 0.05. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.mass_eps_lin". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.mass_eps_lin". .. versionadded:: 6.1.0 @@ -3356,8 +3357,8 @@ allow for additional user control over these conversion factors. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKodeSetLinearSolver`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.ls_norm_factor". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.ls_norm_factor". .. versionadded:: 6.1.0 @@ -3392,8 +3393,8 @@ allow for additional user control over these conversion factors. This function must be called *after* the ARKLS mass matrix solver interface has been initialized through a call to :c:func:`ARKodeSetMassLinearSolver`. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.mass_ls_norm_factor". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.mass_ls_norm_factor". .. versionadded:: 6.1.0 @@ -3465,8 +3466,8 @@ Disable inactive root warnings :c:func:`ARKodeSetNoInactiveRootWarn` e first step), ARKODE will issue a warning which can be disabled with this optional input function. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.no_inactive_root_warn". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.no_inactive_root_warn". .. versionadded:: 6.1.0 @@ -5050,8 +5051,8 @@ Output all ARKODE solver parameters :c:func:`ARKodeWriteParameters` for this pointer, since parameters for all processes would be identical. - This routine will be called by :c:func:`ARKodeSetFromCommandLine` - when using the command-line option "arkid.write_parameters". + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.write_parameters". .. versionadded:: 6.1.0 diff --git a/doc/cvode/guide/source/Usage/index.rst b/doc/cvode/guide/source/Usage/index.rst index f2228abcee..683a4c8487 100644 --- a/doc/cvode/guide/source/Usage/index.rst +++ b/doc/cvode/guide/source/Usage/index.rst @@ -387,8 +387,8 @@ the call to :c:func:`CVodeInit` * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.scalar_tolerances". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.scalar_tolerances". .. c:function:: int CVodeSVtolerances(void* cvode_mem, sunrealtype reltol, N_Vector abstol) @@ -829,8 +829,8 @@ Main solver optional input functions +-------------------------------+---------------------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +===============================+=============================================+================+ - | Set CVODE optional inputs | :c:func:`CVodeSetFromCommandLine` | | - | from the command line | | | + | Set CVODE options from the | :c:func:`CVodeSetOptions`. | | + | command line or file | | | +-------------------------------+---------------------------------------------+----------------+ | User data | :c:func:`CVodeSetUserData` | ``NULL`` | +-------------------------------+---------------------------------------------+----------------+ @@ -872,32 +872,64 @@ Main solver optional input functions +-------------------------------+---------------------------------------------+----------------+ -.. c:function:: int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, char* argv[]) +.. c:function:: int CVodeSetOptions(void* cvode_mem, const char* cvid, const char* file_name, int argc, char* argv[]) - Passes command-line arguments to CVODE to set options. + Sets CVODE options from an array of strings or a file. :param cvode_mem: pointer to the CVODE memory block. - :param cvid: String to use as prefix for CVODE command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param cvid: the prefix for options to read. The default is "cvode". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: number of command-line arguments passed to executable. + :param argv: an array of strings containing the options to set and their values. :retval CV_SUCCESS: the function exited successfully. :retval CV_MEM_NULL: ``cvode_mem`` was ``NULL``. :retval other: error return value from relevant CVODE "set" routine. + **Example usage:** + + In a C or C++ program, the following will enable command-line processing: + + .. code-block:: C + + /* Create CVODE memory block */ + void* cvode_mem = CVodeCreate(CV_BDF, ctx); + + /* Configure CVODE as normal */ + ... + + /* Override settings with command-line options using default "cvode" prefix */ + flag = CVodeSetOptions(cvode_mem, NULL, NULL, argc, argv); + + Then when running the program, the user can specify desired options, e.g., + + .. code-block:: console + + $ ./a.out cvode.max_order 3 cvode.max_num_steps 10000 + .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. - These are left unchanged by :c:func:`CVodeSetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`CVodeSetOptions`. + + If the ``cvid`` argument is ``NULL``, then the default prefix, ``cvode``, must + be used for all CVODE options. For example, the option ``cvode.max_order`` followed + by the value can be used to set the maximum method order of accuracy. - If the *cvid* argument is ``NULL`` then ``cvode.`` will be used for all CVODE command-line - options, e.g., to set the maximum order of accuracy the default command-line option would - be "cvode.max_order". + CVODE options set via :c:func:`CVodeSetOptions` will overwrite + any previously-set values. + + The supported option names are noted within the documentation for the + corresponding CVODE "set" function. + + .. warning:: - CVODE options set via command-line arguments to :c:func:`CVodeSetFromCommandLine` will - overwrite any previously-set values. + This function is not available in the Fortran interface. - The supported command-line options are documented within each CVODE "set" routine. + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. .. versionadded:: x.y.z @@ -954,8 +986,8 @@ Main solver optional input functions **Notes:** The monitor function that will be called can be set with ``CVodeSetMonitorFn``. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.monitor_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.monitor_frequency". .. warning:: @@ -979,8 +1011,8 @@ Main solver optional input functions An input value greater than the default will result in the default value. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_order". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_order". .. c:function:: int CVodeSetMaxNumSteps(void* cvode_mem, long int mxsteps) @@ -999,8 +1031,8 @@ Main solver optional input functions Passing ``mxsteps`` < 0 disables the test (not recommended). - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_num_steps". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_num_steps". .. c:function:: int CVodeSetMaxHnilWarns(void* cvode_mem, int mxhnil) @@ -1017,8 +1049,8 @@ Main solver optional input functions **Notes:** The default value is 10. A negative value for ``mxhnil`` indicates that no warning messages should be issued. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_hnil_warns". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_hnil_warns". .. c:function:: int CVodeSetStabLimDet(void* cvode_mem, sunbooleantype stldet) @@ -1036,8 +1068,8 @@ Main solver optional input functions **Notes:** The default value is ``SUNFALSE``. If ``stldet = SUNTRUE`` when BDF is used and the method order is greater than or equal to 3, then an internal function, ``CVsldet``, is called to detect a possible stability limit. If such a limit is detected, then the order is reduced. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.stab_lim_det". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.stab_lim_det". .. c:function:: int CVodeSetInitStep(void* cvode_mem, sunrealtype hin) @@ -1054,8 +1086,8 @@ Main solver optional input functions **Notes:** By default, CVODE estimates the initial step size to be the solution :math:`h` of the equation :math:`0.5 h^2 \ddot{y} = 1`, where :math:`\ddot{y}` is an estimated second derivative of the solution at :math:`t_0`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.init_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.init_step". .. c:function:: int CVodeSetMinStep(void* cvode_mem, sunrealtype hmin) @@ -1073,8 +1105,8 @@ Main solver optional input functions **Notes:** The default value is 0.0. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.min_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.min_step". .. c:function:: int CVodeSetMaxStep(void* cvode_mem, sunrealtype hmax) @@ -1092,8 +1124,8 @@ Main solver optional input functions **Notes:** Pass ``hmax`` = 0.0 to obtain the default value :math:`\infty`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_step". .. c:function:: int CVodeSetStopTime(void* cvode_mem, sunrealtype tstop) @@ -1116,8 +1148,8 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`CVodeReInit` will remain active but can be disabled by calling :c:func:`CVodeClearStopTime`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.stop_time". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.stop_time". .. c:function:: int CVodeSetInterpolateStopTime(void* cvode_mem, sunbooleantype interp) @@ -1134,8 +1166,8 @@ Main solver optional input functions * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.interpolate_stop_time". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.interpolate_stop_time". .. versionadded:: 6.6.0 @@ -1155,8 +1187,8 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`CVodeSetStopTime`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.clear_stop_time". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.clear_stop_time". .. versionadded:: 6.5.1 @@ -1175,8 +1207,8 @@ Main solver optional input functions **Notes:** The default value is 7. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_err_test_fails". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_err_test_fails". .. c:function:: int CVodeSetConstraints(void* cvode_mem, N_Vector constraints) @@ -1217,8 +1249,8 @@ Main solver optional input functions ``ON`` when SUNDIALS is compiled. See the entry for this option in :numref:`Installation.Options` for more information. Currently, the fused kernels are only supported when using CVODE with the :ref:`NVECTOR_CUDA ` and :ref:`NVECTOR_HIP ` implementations of the ``N_Vector``. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.use_integrator_fused_kernels". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.use_integrator_fused_kernels". .. _CVODE.Usage.CC.optional_input.optin_ls: @@ -1339,8 +1371,8 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.delta_gamma_max_lsetup". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.delta_gamma_max_lsetup". .. versionadded:: 6.2.0 @@ -1364,8 +1396,8 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.delta_gamma_max_bad_jac". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.delta_gamma_max_bad_jac". .. versionadded:: 6.2.0 @@ -1385,8 +1417,8 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function **Notes:** Positive values of ``msbp`` specify the linear solver setup frequency. For example, an input of ``1`` means the setup function will be called every time step while an input of ``2`` means it will be called called every other time step. If ``msbp = 0``, the default value of 20 will be used. Otherwise an error is returned. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.lsetup_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.lsetup_frequency". .. c:function:: int CVodeSetJacEvalFrequency(void* cvode_mem, long int msbj) @@ -1422,8 +1454,8 @@ difference approximation or a call to the :ref:`user-supplied Jacobian function This function must be called after the CVLS linear solver interface has been initialized through a call to :c:func:`CVodeSetLinearSolver`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.jac_eval_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.jac_eval_frequency". When using matrix-based linear solver modules, the CVLS solver interface needs a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or @@ -1526,8 +1558,8 @@ using the current :math:`\gamma` as part of the solve. By default scaling is enabled with matrix-based linear solvers when using BDF methods. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.linear_solution_scaling". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.linear_solution_scaling". When using matrix-free linear solver modules, the CVLS solver interface requires a function to compute an approximation to the @@ -1684,8 +1716,8 @@ the :c:func:`CVodeSetEpsLin` function. If ``eplifac`` = 0.0 is passed, the default value is used. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eps_lin". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eps_lin". .. versionadded:: 4.0.0 @@ -1713,8 +1745,8 @@ the :c:func:`CVodeSetEpsLin` function. Prior to the introduction of ``N_VGetLength`` in SUNDIALS v5.0.0 (CVODE v5.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.ls_norm_factor". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.ls_norm_factor". .. _CVODE.Usage.CC.optional_input.optin_nls: @@ -1761,8 +1793,8 @@ nonlinear solver. **Notes:** The default value is 3. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_nonlin_iters". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_nonlin_iters". .. c:function:: int CVodeSetMaxConvFails(void* cvode_mem, int maxncf) @@ -1779,8 +1811,8 @@ nonlinear solver. **Notes:** The default value is 10. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_conv_fails". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_conv_fails". .. c:function:: int CVodeSetNonlinConvCoef(void* cvode_mem, sunrealtype nlscoef) @@ -1797,8 +1829,8 @@ nonlinear solver. **Notes:** The default value is 0.1. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.nonlin_conv_coef". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.nonlin_conv_coef". .. c:function:: int CVodeSetNlsRhsFn(void* cvode_mem, CVRhsFn f) @@ -1908,8 +1940,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_fixed_step_bounds". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_fixed_step_bounds". .. versionadded:: 6.2.0 @@ -1935,8 +1967,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max_first_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max_first_step". .. versionadded:: 6.2.0 @@ -1968,8 +2000,8 @@ step size adaptivity. factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetNumStepsEtaMaxEarlyStep`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max_early_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max_early_step". .. versionadded:: 6.2.0 @@ -1998,8 +2030,8 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetEtaMaxEarlyStep`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.num_steps_eta_max_early_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.num_steps_eta_max_early_step". .. versionadded:: 6.2.0 @@ -2028,8 +2060,8 @@ step size adaptivity. The factor for steps early in the integration is set by :c:func:`CVodeSetEtaMaxEarlyStep`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max". .. versionadded:: 6.2.0 @@ -2051,8 +2083,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_min". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_min". .. versionadded:: 6.2.0 @@ -2075,8 +2107,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_min_err_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_min_err_fail". .. versionadded:: 6.2.0 @@ -2104,8 +2136,8 @@ step size adaptivity. size factor :math:`\eta_{\mathrm{min\_ef}}` can be set with :c:func:`CVodeSetNumFailsEtaMaxErrFail`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max_err_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max_err_fail". .. versionadded:: 6.2.0 @@ -2134,8 +2166,8 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_ef}}` can be set with :c:func:`CVodeSetEtaMaxErrFail`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.num_fails_eta_max_err_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.num_fails_eta_max_err_fail". .. versionadded:: 6.2.0 @@ -2158,8 +2190,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_conv_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_conv_fail". .. versionadded:: 6.2.0 @@ -2215,8 +2247,8 @@ the rootfinding algorithm. **Notes:** CVODE will not report the initial conditions as a possible zero-crossing (assuming that one or more components :math:`g_i` are zero at the initial time). However, if it appears that some :math:`g_i` is identically zero at the initial time (i.e., :math:`g_i` is zero at the initial time and after the first step), CVODE will issue a warning which can be disabled with this optional input function. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.no_inactive_root_warn". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.no_inactive_root_warn". .. _CVODE.Usage.CC.optional_input.optin_proj: @@ -2262,8 +2294,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.proj_err_est". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.proj_err_est". .. versionadded:: 5.3.0 @@ -2281,8 +2313,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.proj_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.proj_frequency". .. versionadded:: 5.3.0 @@ -2300,8 +2332,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_num_proj_fails". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_num_proj_fails". .. versionadded:: 5.3.0 @@ -2319,8 +2351,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eps_proj". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eps_proj". .. versionadded:: 5.3.0 @@ -2338,8 +2370,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.proj_fail_eta". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.proj_fail_eta". .. versionadded:: 5.3.0 diff --git a/doc/cvodes/guide/source/Usage/ADJ.rst b/doc/cvodes/guide/source/Usage/ADJ.rst index fd291c2202..b2bec2ba84 100644 --- a/doc/cvodes/guide/source/Usage/ADJ.rst +++ b/doc/cvodes/guide/source/Usage/ADJ.rst @@ -585,8 +585,8 @@ call to :c:func:`CVodeInitB` or :c:func:`CVodeInitBS`. * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.scalar_tolerances_b". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.scalar_tolerances_b". .. c:function:: int CVodeSVtolerancesB(void * cvode_mem, int which, sunrealtype reltolB, N_Vector abstolB) @@ -837,8 +837,8 @@ function: * ``CV_NO_ADJ`` -- The function :c:func:`CVodeAdjInit` has not been previously called. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.adj_no_sensi". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.adj_no_sensi". .. _CVODES.Usage.ADJ.user_callable.optional_input_b: @@ -885,10 +885,9 @@ The optional input functions defined for the backward problem are: Their return value ``flag`` (of type ``int``) can have any of the return values of their counterparts, but it can also be ``CV_NO_ADJ`` if :c:func:`CVodeAdjInit` has not been called, or ``CV_ILL_INPUT`` if ``which`` was -an invalid identifier. The above routines may be controlled using command-line -options via :c:func:`CVodeSetFromCommandLine`, where the command-line argument is -appended with the suffix "_b", e.g., ``CVodeSetMaxOrdB`` can be controlled by the -command-line option "cvid.max_order_b". +an invalid identifier. The above routines may be controlled using +:c:func:`CVodeSetOptions`, where the keys are appended with the suffix "_b", +e.g., ``CVodeSetMaxOrdB`` can be controlled by the key "cvid.max_order_b". Linear solver interface optional input functions """""""""""""""""""""""""""""""""""""""""""""""" @@ -1007,8 +1006,8 @@ disable solution scaling when using a matrix-based linear solver. By default scaling is enabled with matrix-based linear solvers when using BDF methods. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.linear_solution_scaling_b". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.linear_solution_scaling_b". .. c:function:: int CVodeSetJacTimesB(void * cvode_mem, int which, CVLsJacTimesSetupFnB jsetupB, CVLsJacTimesVecFnB jtvB) @@ -1173,8 +1172,8 @@ potentially non-differentiable factor. The default value is :math:`0.05`. Passing a value ``eplifacB = 0.0`` also indicates using the default value. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eps_lin_b". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eps_lin_b". .. versionadded:: 4.0.0 @@ -1208,8 +1207,8 @@ potentially non-differentiable factor. v5.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.ls_norm_factor_b". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.ls_norm_factor_b". .. _CVODES.Usage.ADJ.user_callable.optional_output_b: @@ -1459,8 +1458,8 @@ Their return value ``flag`` (of type ``int``) can have any of the return values of its counterparts, but it can also be ``CV_NO_ADJ`` if the function :c:func:`CVodeAdjInit` has not been previously called or ``CV_ILL_INPUT`` if the parameter ``which`` was an invalid identifier. The first two routines above may -be controlled using command-line options "cvid.quad_err_con_b" and -"cvid.quad_scalar_tolerances_b" when using :c:func:`CVodeSetFromCommandLine`. +be controlled using the keys "cvid.quad_err_con_b" and +"cvid.quad_scalar_tolerances_b" when using :c:func:`CVodeSetOptions`. Access to optional outputs related to backward quadrature integration can be obtained by calling the corresponding ``CVodeGetQuad*`` functions (see diff --git a/doc/cvodes/guide/source/Usage/FSA.rst b/doc/cvodes/guide/source/Usage/FSA.rst index e3bb48b2a4..3f665db730 100644 --- a/doc/cvodes/guide/source/Usage/FSA.rst +++ b/doc/cvodes/guide/source/Usage/FSA.rst @@ -804,8 +804,8 @@ time and, if successful, takes effect immediately. The default value are ``DQtype == CV_CENTERED`` and ``DQrhomax=0.0``. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.sens_dq_method". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.sens_dq_method". .. c:function:: int CVodeSetSensErrCon(void * cvode_mem, sunbooleantype errconS) @@ -828,8 +828,8 @@ time and, if successful, takes effect immediately. variables are excluded from the error tests. Note that, in any event, all variables are considered in the convergence tests. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.sens_err_con". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.sens_err_con". .. c:function:: int CVodeSetSensMaxNonlinIters(void * cvode_mem, int maxcorS) @@ -849,8 +849,8 @@ time and, if successful, takes effect immediately. **Notes:** The default value is 3. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.sens_max_nonlin_iters". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.sens_max_nonlin_iters". .. _CVODES.Usage.FSA.user_callable.optional_output: @@ -1604,8 +1604,8 @@ integration of sensitivity-dependent quadrature equations. **Notes:** By default, ``errconQS`` is set to ``SUNFALSE``. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.quad_sens_err_con". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.quad_sens_err_con". .. warning:: It is illegal to call :c:func:`CVodeSetQuadSensErrCon` before a call diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index 7e920708ee..a20df21801 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -390,8 +390,8 @@ the call to :c:func:`CVodeInit`. * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.scalar_tolerances". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.scalar_tolerances". .. c:function:: int CVodeSVtolerances(void* cvode_mem, sunrealtype reltol, N_Vector abstol) @@ -838,8 +838,8 @@ Main solver optional input functions +---------------------------------+---------------------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +=================================+=============================================+================+ - | Set CVODES optional inputs | :c:func:`CVodeSetFromCommandLine` | | - | from the command line | | | + | Set CVODES options from the | :c:func:`CVodeSetOptions` | | + | command line or a file | | | +---------------------------------+---------------------------------------------+----------------+ | User data | :c:func:`CVodeSetUserData` | ``NULL`` | +---------------------------------+---------------------------------------------+----------------+ @@ -877,33 +877,64 @@ Main solver optional input functions +---------------------------------+---------------------------------------------+----------------+ -.. c:function:: int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, char* argv[]) +.. c:function:: int CVodeSetOptions(void* cvode_mem, const char* cvid, const char* file_name, int argc, char* argv[]) - Passes command-line arguments to CVODES to set options. + Sets CVODES options from an array of strings. :param cvode_mem: pointer to the CVODES memory block. - :param cvid: String to use as prefix for CVODES command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param cvid: the prefix for options to read. The default is "cvodes". + :param file_name: the name of the file to read options from. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: number of command-line arguments passed to executable. + :param argv: an array of strings containing the options to set and their values. :retval CV_SUCCESS: the function exited successfully. :retval CV_MEM_NULL: ``cvode_mem`` was ``NULL``. :retval other: error return value from relevant CVODES "set" routine. + **Example usage:** + + In a C or C++ program, the following will enable command-line processing: + + .. code-block:: C + + /* Create CVODES memory block */ + void* cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON); + + /* Configure CVODES as normal */ + ... + + /* Override settings with command-line options using default "cvodes" prefix */ + flag = CVodeSetOptions(cvode_mem, NULL, NULL, argc, argv); + + Then when running the program, the user can specify desired options, e.g., + + .. code-block:: console + + $ ./a.out cvodes.max_order 3 cvodes.max_step 0.1 + .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. - These are left unchanged by :c:func:`CVodeSetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + These are left unchanged by :c:func:`CVodeSetOptions`. - If the *cvid* argument is ``NULL`` then ``cvodes.`` will be used for all CVODES command-line - options, e.g., to set the maximum order of accuracy the default command-line option would - be "cvodes.max_order". + If the *cvid* argument is ``NULL``, then the default prefix, ``cvodes``, must + be used for all CVODES options. For example, the option ``cvodes.max_order`` can + be used to set the maximum order of accuracy. - CVODES options set via command-line arguments to :c:func:`CVodeSetFromCommandLine` will + CVODES options set via command-line arguments to :c:func:`CVodeSetOptions` will overwrite any previously-set values. The supported command-line options are documented within each CVODES "set" routine. + .. warning:: + + This function is not available in the Fortran interface. + + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. + .. versionadded:: x.y.z @@ -960,8 +991,8 @@ Main solver optional input functions **Notes:** The monitor function that will be called can be set with ``CVodeSetMonitorFn``. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.monitor_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.monitor_frequency". .. warning:: @@ -985,8 +1016,8 @@ Main solver optional input functions An input value greater than the default will result in the default value. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_order". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_order". .. c:function:: int CVodeSetMaxNumSteps(void* cvode_mem, long int mxsteps) @@ -1005,8 +1036,8 @@ Main solver optional input functions Passing ``mxsteps`` < 0 disables the test (not recommended). - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_num_steps". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_num_steps". .. c:function:: int CVodeSetMaxHnilWarns(void* cvode_mem, int mxhnil) @@ -1023,8 +1054,8 @@ Main solver optional input functions **Notes:** The default value is 10. A negative value for ``mxhnil`` indicates that no warning messages should be issued. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_hnil_warns". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_hnil_warns". .. c:function:: int CVodeSetStabLimDet(void* cvode_mem, sunbooleantype stldet) @@ -1042,8 +1073,8 @@ Main solver optional input functions **Notes:** The default value is ``SUNFALSE``. If ``stldet = SUNTRUE`` when BDF is used and the method order is greater than or equal to 3, then an internal function, ``CVsldet``, is called to detect a possible stability limit. If such a limit is detected, then the order is reduced. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.stab_lim_det". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.stab_lim_det". .. c:function:: int CVodeSetInitStep(void* cvode_mem, sunrealtype hin) @@ -1060,8 +1091,8 @@ Main solver optional input functions **Notes:** By default, CVODES estimates the initial step size to be the solution :math:`h` of the equation :math:`0.5 h^2 \ddot{y} = 1`, where :math:`\ddot{y}` is an estimated second derivative of the solution at :math:`t_0`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.init_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.init_step". .. c:function:: int CVodeSetMinStep(void* cvode_mem, sunrealtype hmin) @@ -1079,8 +1110,8 @@ Main solver optional input functions **Notes:** The default value is 0.0. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.min_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.min_step". .. c:function:: int CVodeSetMaxStep(void* cvode_mem, sunrealtype hmax) @@ -1098,8 +1129,8 @@ Main solver optional input functions **Notes:** Pass ``hmax`` = 0.0 to obtain the default value :math:`\infty`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_step". .. c:function:: int CVodeSetStopTime(void* cvode_mem, sunrealtype tstop) @@ -1122,8 +1153,8 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`CVodeReInit` will remain active but can be disabled by calling :c:func:`CVodeClearStopTime`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.stop_time". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.stop_time". .. c:function:: int CVodeSetInterpolateStopTime(void* cvode_mem, sunbooleantype interp) @@ -1140,8 +1171,8 @@ Main solver optional input functions * ``CV_MEM_NULL`` -- The CVODES memory block was not initialized through a previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.interpolate_stop_time". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.interpolate_stop_time". .. versionadded:: 6.6.0 @@ -1160,8 +1191,8 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`CVodeSetStopTime`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.clear_stop_time". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.clear_stop_time". .. versionadded:: 6.5.1 @@ -1180,8 +1211,8 @@ Main solver optional input functions **Notes:** The default value is 7. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_err_test_fails". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_err_test_fails". .. c:function:: int CVodeSetConstraints(void* cvode_mem, N_Vector constraints) @@ -1333,8 +1364,8 @@ using the current :math:`\gamma` value. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.delta_gamma_max_lsetup". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.delta_gamma_max_lsetup". .. versionadded:: 6.2.0 @@ -1358,8 +1389,8 @@ using the current :math:`\gamma` value. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.delta_gamma_max_bad_jac". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.delta_gamma_max_bad_jac". .. versionadded:: 6.2.0 @@ -1379,8 +1410,8 @@ using the current :math:`\gamma` value. **Notes:** Positive values of ``msbp`` specify the linear solver setup frequency. For example, an input of ``1`` means the setup function will be called every time step while an input of ``2`` means it will be called called every other time step. If ``msbp = 0``, the default value of 20 will be used. Otherwise an error is returned. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.lsetup_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.lsetup_frequency". .. c:function:: int CVodeSetJacEvalFrequency(void* cvode_mem, long int msbj) @@ -1416,8 +1447,8 @@ using the current :math:`\gamma` value. This function must be called after the CVLS linear solver interface has been initialized through a call to :c:func:`CVodeSetLinearSolver`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.jac_eval_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.jac_eval_frequency". When using matrix-based linear solver modules, the CVLS solver interface needs a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or @@ -1520,8 +1551,8 @@ using the current :math:`\gamma` as part of the solve. By default scaling is enabled with matrix-based linear solvers when using BDF methods. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.linear_solution_scaling". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.linear_solution_scaling". When using matrix-free linear solver modules, the CVLS solver interface requires a function to compute an approximation to the @@ -1678,8 +1709,8 @@ the :c:func:`CVodeSetEpsLin` function. If ``eplifac`` = 0.0 is passed, the default value is used. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eps_lin". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eps_lin". .. versionadded:: 4.0.0 @@ -1707,8 +1738,8 @@ the :c:func:`CVodeSetEpsLin` function. Prior to the introduction of ``N_VGetLength`` in SUNDIALS v5.0.0 (CVODES v5.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.ls_norm_factor". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.ls_norm_factor". .. _CVODES.Usage.SIM.optional_input.optin_nls: @@ -1755,8 +1786,8 @@ nonlinear solver. **Notes:** The default value is 3. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_nonlin_iters". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_nonlin_iters". .. c:function:: int CVodeSetMaxConvFails(void* cvode_mem, int maxncf) @@ -1773,8 +1804,8 @@ nonlinear solver. **Notes:** The default value is 10. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_conv_fails". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_conv_fails". .. c:function:: int CVodeSetNonlinConvCoef(void* cvode_mem, sunrealtype nlscoef) @@ -1791,8 +1822,8 @@ nonlinear solver. **Notes:** The default value is 0.1. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.nonlin_conv_coef". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.nonlin_conv_coef". .. c:function:: int CVodeSetNlsRhsFn(void* cvode_mem, CVRhsFn f) @@ -1902,8 +1933,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_fixed_step_bounds". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_fixed_step_bounds". .. versionadded:: 6.2.0 @@ -1929,8 +1960,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max_first_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max_first_step". .. versionadded:: 6.2.0 @@ -1962,8 +1993,8 @@ step size adaptivity. factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetNumStepsEtaMaxEarlyStep`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max_early_step". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max_early_step". .. versionadded:: 6.2.0 @@ -2019,8 +2050,8 @@ step size adaptivity. The factor for steps early in the integration is set by :c:func:`CVodeSetEtaMaxEarlyStep`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max". .. versionadded:: 6.2.0 @@ -2042,8 +2073,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_min". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_min". .. versionadded:: 6.2.0 @@ -2066,8 +2097,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_min_err_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_min_err_fail". .. versionadded:: 6.2.0 @@ -2095,8 +2126,8 @@ step size adaptivity. size factor :math:`\eta_{\mathrm{min\_ef}}` can be set with :c:func:`CVodeSetNumFailsEtaMaxErrFail`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_max_err_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_max_err_fail". .. versionadded:: 6.2.0 @@ -2125,8 +2156,8 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_ef}}` can be set with :c:func:`CVodeSetEtaMaxErrFail`. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.num_fails_eta_max_err_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.num_fails_eta_max_err_fail". .. versionadded:: 6.2.0 @@ -2149,8 +2180,8 @@ step size adaptivity. previous call to :c:func:`CVodeCreate`. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eta_conv_fail". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eta_conv_fail". .. versionadded:: 6.2.0 @@ -2211,8 +2242,8 @@ the rootfinding algorithm. CVODES will issue a warning which can be disabled with this optional input function. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.no_inactive_root_warn". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.no_inactive_root_warn". .. _CVODES.Usage.SIM.optional_input.optin_proj: @@ -2257,8 +2288,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.proj_err_est". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.proj_err_est". .. versionadded:: 6.2.0 @@ -2276,8 +2307,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.proj_frequency". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.proj_frequency". .. versionadded:: 6.2.0 @@ -2295,8 +2326,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.max_num_proj_fails". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.max_num_proj_fails". .. versionadded:: 6.2.0 @@ -2314,8 +2345,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.eps_proj". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.eps_proj". .. versionadded:: 6.2.0 @@ -2333,8 +2364,8 @@ the projection when solving an IVP with constraints. * ``CV_PROJ_MEM_NULL`` -- The projection memory is ``NULL`` i.e., the projection functionality has not been enabled. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.proj_fail_eta". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.proj_fail_eta". .. versionadded:: 6.2.0 @@ -4344,8 +4375,8 @@ of quadrature equations. **Notes:** By default, ``errconQ`` is set to ``SUNFALSE``. - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.quad_err_con". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.quad_err_con". .. warning:: @@ -4372,8 +4403,8 @@ integration tolerances for quadrature variables. * ``CV_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`CVodeSetFromCommandLine` - when using the command-line option "cvid.quad_scalar_tolerances". + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.quad_scalar_tolerances". .. c:function:: int CVodeQuadSVtolerances(void * cvode_mem, sunrealtype reltolQ, N_Vector abstolQ) diff --git a/doc/ida/guide/source/Usage/index.rst b/doc/ida/guide/source/Usage/index.rst index ae547c8866..adcf2ec286 100644 --- a/doc/ida/guide/source/Usage/index.rst +++ b/doc/ida/guide/source/Usage/index.rst @@ -384,8 +384,8 @@ norms). Note that this call must be made after the call to :c:func:`IDAInit`. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.scalar_tolerances". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.scalar_tolerances". .. c:function:: int IDASVtolerances(void* ida_mem, sunrealtype reltol, N_Vector abstol) @@ -910,7 +910,7 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +--------------------------------------------------------------------+---------------------------------+----------------+ - | Set IDA optional inputs from the command line | :c:func:`IDASetFromCommandLine` | | + | Set IDA options from the command line or file | :c:func:`IDASetOptions` | | +--------------------------------------------------------------------+---------------------------------+----------------+ | User data | :c:func:`IDASetUserData` | NULL | +--------------------------------------------------------------------+---------------------------------+----------------+ @@ -938,32 +938,64 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ -.. c:function:: int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, char* argv[]) +.. c:function:: int IDASetOptions(void* ida_mem, const char* idaid, const char* file_name, int argc, char* argv[]) - Passes command-line arguments to IDA to set options. + Sets IDA options from an array of strings or a file. - :param ida_mem: pointer to the IDA solver objectd. - :param idaid: String to use as prefix for IDA command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param ida_mem: pointer to the IDA memory block. + :param idaid: the prefix for options to read. The default is "ida". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: number of command-line arguments passed to executable. + :param argv: an array of strings containing the options to set and their values. :retval IDA_SUCCESS: the function exited successfully. :retval IDA_MEM_NULL: ``ida_mem`` was ``NULL``. :retval other: error return value from relevant IDA "set" routine. + **Example usage:** + + In a C or C++ program, the following will enable command-line processing: + + .. code-block:: C + + /* Create IDA memory block */ + void* ida_mem = IDACreate(ctx); + + /* Configure IDA as normal */ + ... + + /* Override settings with command-line options using default "ida" prefix */ + flag = IDASetOptions(ida_mem, NULL, NULL, argc, argv); + + Then when running the program, the user can specify desired options, e.g., + + .. code-block:: console + + $ ./a.out ida.max_order 3 ida.max_step 0.1 + .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. - These are left unchanged by :c:func:`IDASetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`IDASetOptions`. - If the *idaid* argument is ``NULL`` then ``ida.`` will be used for all IDA command-line - options, e.g., to set the maximum order of accuracy the default command-line option would - be "ida.max_order". + If the ``idaid`` argument is ``NULL``, then the default prefix, ``ida``, must + be used for all IDA options. For example, the option ``ida.max_order`` followed + by the value can be used to set the maximum method order of accuracy. - IDA options set via command-line arguments to :c:func:`IDASetFromCommandLine` will - overwrite any previously-set values. + IDA options set via :c:func:`IDASetOptions` will overwrite + any previously-set values. - The supported command-line options are documented within each IDA "set" routine. + The supported option names are noted within the documentation for the + corresponding IDA "set" function. + + .. warning:: + + This function is not available in the Fortran interface. + + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. .. versionadded:: x.y.z @@ -1012,8 +1044,8 @@ Main solver optional input functions requirements for the internal IDA memory block and its value cannot be increased past the value set when :c:func:`IDAInit` was called. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_order". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_order". .. c:function:: int IDASetMaxNumSteps(void * ida_mem, long int mxsteps) @@ -1032,8 +1064,8 @@ Main solver optional input functions Passing ``mxsteps`` = 0 results in IDA using the default value (500). Passing ``mxsteps`` < 0 disables the test (not recommended). - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_steps". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_steps". .. c:function:: int IDASetInitStep(void * ida_mem, sunrealtype hin) @@ -1053,8 +1085,8 @@ Main solver optional input functions :math:`\|h \dot{y} \|_{{\scriptsize WRMS}} = 1/2`, with an added restriction that :math:`|h| \leq .001|t_{\text{out}} - t_0|`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.init_step". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.init_step". .. c:function:: int IDASetMinStep(void * ida_mem, sunrealtype hmin) @@ -1073,8 +1105,8 @@ Main solver optional input functions * ``IDA_ILL_INPUT`` -- ``hmin`` is negative. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.min_step". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.min_step". .. versionadded:: 6.2.0 @@ -1096,8 +1128,8 @@ Main solver optional input functions **Notes:** Pass ``hmax = 0`` to obtain the default value :math:`\infty`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_step". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_step". .. c:function:: int IDASetStopTime(void * ida_mem, sunrealtype tstop) @@ -1124,8 +1156,8 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`IDAReInit` will remain active but can be disabled by calling :c:func:`IDAClearStopTime`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.stop_time". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.stop_time". .. c:function:: int IDAClearStopTime(void* ida_mem) @@ -1142,8 +1174,8 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`IDASetStopTime`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.clear_stop_time". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.clear_stop_time". .. versionadded:: 6.5.1 @@ -1164,8 +1196,8 @@ Main solver optional input functions **Notes:** The default value is 10. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_err_test_fails". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_err_test_fails". .. c:function:: int IDASetSuppressAlg(void * ida_mem, sunbooleantype suppressalg) @@ -1189,8 +1221,8 @@ Main solver optional input functions 1, whereas it is generally *encouraged* for systems of index 2 or more. See pp. 146-147 of :cite:p:`BCP:96` for more on this issue. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.suppress_alg". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.suppress_alg". .. c:function:: int IDASetId(void * ida_mem, N_Vector id) @@ -1352,8 +1384,8 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.delta_cj_lsetup". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.delta_cj_lsetup". .. versionadded:: 6.2.0 @@ -1379,8 +1411,8 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. initialized through a call to :c:func:`IDASetLinearSolver`. By default scaling is enabled with matrix-based linear solvers. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.linear_solution_scaling". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.linear_solution_scaling". When using matrix-free linear solver modules, the IDALS solver interface @@ -1472,8 +1504,8 @@ finite-difference approximation, via a call to :c:func:`IDASetIncrementFactor`. linear solver interface has been initialized through a call to :c:func:`IDASetLinearSolver`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.increment_factor". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.increment_factor". .. versionadded:: 4.0.0 @@ -1595,8 +1627,8 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default :c:func:`IDASetLinearSolver`. If ``eplifac`` :math:`= 0.0` is passed, the default value is used. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eps_lin". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eps_lin". .. versionadded:: 4.0.0 @@ -1631,8 +1663,8 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default value of ``nrmfac`` was computed using :c:func:`N_VDotProd` i.e., the ``nrmfac < 0`` case. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.ls_norm_factor". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.ls_norm_factor". .. _IDA.Usage.CC.optional_input.optin_nls: @@ -1677,8 +1709,8 @@ nonlinear solver. **Notes:** The default value is 4. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_nonlin_iters". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_nonlin_iters". .. c:function:: int IDASetMaxConvFails(void * ida_mem, int maxncf) @@ -1698,8 +1730,8 @@ nonlinear solver. **Notes:** The default value is 10. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_conv_fails". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_conv_fails". .. c:function:: int IDASetNonlinConvCoef(void * ida_mem, sunrealtype nlscoef) @@ -1719,8 +1751,8 @@ nonlinear solver. **Notes:** The default value is 0.33. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.nonlin_conv_coef". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.nonlin_conv_coef". .. c:function:: int IDASetNlsResFn(void * ida_mem, IDAResFn res) @@ -1798,8 +1830,8 @@ to set optional inputs controlling the initial condition calculation. :math:`J^{-1}F(t_0, y, \dot{y})` must be :math:`\leq \mathtt{epiccon}`, where :math:`J` is the system Jacobian. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.nonlin_conv_coef_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.nonlin_conv_coef_ic". .. c:function:: int IDASetMaxNumStepsIC(void * ida_mem, int maxnh) @@ -1820,8 +1852,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`5`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_steps_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_steps_ic". .. c:function:: int IDASetMaxNumJacsIC(void * ida_mem, int maxnj) @@ -1842,8 +1874,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`4`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_jacs_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_jacs_ic". .. c:function:: int IDASetMaxNumItersIC(void * ida_mem, int maxnit) @@ -1863,8 +1895,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`10`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_iters_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_iters_ic". .. c:function:: int IDASetMaxBacksIC(void * ida_mem, int maxbacks) @@ -1873,7 +1905,7 @@ to set optional inputs controlling the initial condition calculation. conditions calculation problem. **Arguments:** - * ``ida_mem`` -- pointer to the IDA solver object. + when using the command-line option "idaid.line_search_off_ic". * ``maxbacks`` -- maximum number of linesearch backtracks per Newton step. **Return value:** @@ -1884,8 +1916,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`100`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_backs_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_backs_ic". .. c:function:: int IDASetLineSearchOffIC(void * ida_mem, sunbooleantype lsoff) @@ -1904,8 +1936,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is ``SUNFALSE``. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.linesearch_off_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.line_search_off_ic". .. c:function:: int IDASetStepToleranceIC(void * ida_mem, int steptol) @@ -1924,8 +1956,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`(\text{unit roundoff})^{2/3}`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.step_tolerance_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.step_tolerance_ic". .. _IDA.Usage.CC.optional_input.optin_step_adapt: @@ -1995,8 +2027,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_fixed_step_bounds". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_fixed_step_bounds". .. versionadded:: 6.2.0 @@ -2016,8 +2048,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_max". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_max". .. versionadded:: 6.2.0 @@ -2040,8 +2072,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_min". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_min". .. versionadded:: 6.2.0 @@ -2064,8 +2096,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_low". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_low". .. versionadded:: 6.2.0 @@ -2088,8 +2120,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_min_err_fail". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_min_err_fail". .. versionadded:: 6.2.0 @@ -2112,8 +2144,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_conv_fail". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_conv_fail". .. versionadded:: 6.2.0 @@ -2187,8 +2219,8 @@ rootfinding algorithm. first step), IDA will issue a warning which can be disabled with this optional input function. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.no_inactive_root_warn". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.no_inactive_root_warn". .. _IDA.Usage.CC.optional_dky: diff --git a/doc/idas/guide/source/Usage/ADJ.rst b/doc/idas/guide/source/Usage/ADJ.rst index 104816c3a6..2224dcb07e 100644 --- a/doc/idas/guide/source/Usage/ADJ.rst +++ b/doc/idas/guide/source/Usage/ADJ.rst @@ -399,8 +399,8 @@ function: * ``IDA_NO_ADJ`` -- The function :c:func:`IDAAdjInit` has not been previously called. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.adj_no_sensi". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.adj_no_sensi". .. _IDAS.Usage.ADJ.user_callable.idasolvef: @@ -631,8 +631,8 @@ call to :c:func:`IDAInitB` or :c:func:`IDAInitBS`. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.scalar_tolerances_b". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.scalar_tolerances_b". .. c:function:: int IDASVtolerancesB(void * ida_mem, int which, sunrealtype reltolB, N_Vector abstolB) @@ -973,9 +973,8 @@ Their return value ``flag`` (of type ``int``) can have any of the return values of their counterparts, but it can also be ``IDA_NO_ADJ`` if :c:func:`IDAAdjInit` has not been called, or ``IDA_ILL_INPUT`` if ``which`` was an invalid identifier. The above routines may be controlled using command-line options via -:c:func:`IDASetFromCommandLine`, where the command-line argument is -appended with the suffix "_b", e.g., ``IDASetMaxOrdB`` can be controlled by the -command-line option "idaid.max_order_b". +:c:func:`IDASetOptions`, where the argument keys are appended with the suffix "_b", +e.g., ``IDASetMaxOrdB`` can be controlled by the key "idaid.max_order_b". Linear solver interface optional input functions """""""""""""""""""""""""""""""""""""""""""""""" @@ -1060,8 +1059,8 @@ disable solution scaling when using a matrix-based linear solver. By default scaling is enabled with matrix-based linear solvers when using BDF methods. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.linear_solution_scaling_b". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.linear_solution_scaling_b". When using a matrix-free linear solver module for the backward problem, the IDALS linear solver interface requires a function to compute an @@ -1147,8 +1146,8 @@ setting increments for the finite-difference approximation, via a call to **Notes:** The default value is :math:`1.0`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.increment_factor_b". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.increment_factor_b". .. versionadded:: 3.0.0 @@ -1283,8 +1282,8 @@ These may be accomplished through calling the following functions: Passing a value ``eplifacB`` :math:`= 0.0` also indicates using the default value. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eps_lin_b". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eps_lin_b". .. versionadded:: 3.0.0 @@ -1322,8 +1321,8 @@ These may be accomplished through calling the following functions: v4.0.0) the value of ``nrmfac`` was computed using the vector dot product i.e., the ``nrmfac < 0`` case. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.ls_norm_factor_b". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.ls_norm_factor_b". .. _IDAS.Usage.ADJ.user_callable.optional_output_b: @@ -1616,8 +1615,8 @@ Their return value ``flag`` (of type ``int``) can have any of the return values of its counterparts, but it can also be ``IDA_NO_ADJ`` if the function :c:func:`IDAAdjInit` has not been previously called or ``IDA_ILL_INPUT`` if the parameter ``which`` was an invalid identifier. The first two routines above may -be controlled using command-line options "idaid.quad_err_con_b" and -"idaid.quad_scalar_tolerances_b" when using :c:func:`IDASetFromCommandLine`. +be controlled with the keys "idaid.quad_err_con_b" and +"idaid.quad_scalar_tolerances_b" when using :c:func:`IDASetOptions`. Access to optional outputs related to backward quadrature integration can be obtained by calling the corresponding ``IDAGetQuad*`` functions (see diff --git a/doc/idas/guide/source/Usage/FSA.rst b/doc/idas/guide/source/Usage/FSA.rst index 47feb40d1f..ce9e10b973 100644 --- a/doc/idas/guide/source/Usage/FSA.rst +++ b/doc/idas/guide/source/Usage/FSA.rst @@ -353,8 +353,8 @@ function is provided: Since sensitivity-related memory is not deallocated, sensitivities can be reactivated at a later time (using :c:func:`IDASensReInit`). - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.sens_toggle_off". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.sens_toggle_off". Forward sensitivity tolerance specification functions @@ -757,8 +757,8 @@ time and, if successful, takes effect immediately. The default value are ``DQtype == IDA_CENTERED`` and ``DQrhomax``:math:`=0.0`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.sens_dq_method". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.sens_dq_method". .. c:function:: int IDASetSensErrCon(void * ida_mem, sunbooleantype errconS) @@ -781,8 +781,8 @@ time and, if successful, takes effect immediately. variables are excluded from the error tests. Note that, in any event, all variables are considered in the convergence tests. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idas.sens_err_con". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idas.sens_err_con". .. c:function:: int IDASetSensMaxNonlinIters(void * ida_mem, int maxcorS) @@ -802,8 +802,8 @@ time and, if successful, takes effect immediately. **Notes:** The default value is 3. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idas.sens_max_nonlin_iters". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idas.sens_max_nonlin_iters". .. _IDAS.Usage.FSA.user_callable.optional_output: @@ -1441,8 +1441,8 @@ of sensitivity-dependent quadrature equations. **Notes:** By default, ``errconQS`` is set to ``SUNFALSE``. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idas.quad_sens_err_con". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idas.quad_sens_err_con". .. warning:: It is illegal to call :c:func:`IDASetQuadSensErrCon` before a call to :c:func:`IDAQuadSensInit`. diff --git a/doc/idas/guide/source/Usage/SIM.rst b/doc/idas/guide/source/Usage/SIM.rst index c61709a886..10961989f9 100644 --- a/doc/idas/guide/source/Usage/SIM.rst +++ b/doc/idas/guide/source/Usage/SIM.rst @@ -382,8 +382,8 @@ norms). Note that this call must be made after the call to :c:func:`IDAInit`. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.scalar_tolerances". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.scalar_tolerances". .. c:function:: int IDASVtolerances(void* ida_mem, sunrealtype reltol, N_Vector abstol) @@ -915,7 +915,7 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ | **Optional input** | **Function name** | **Default** | +====================================================================+=================================+================+ - | Set IDAS optional inputs from the command line | :c:func:`IDASetFromCommandLine` | | + | Set IDAS options from the command line or file | :c:func:`IDASetOptions` | | +--------------------------------------------------------------------+---------------------------------+----------------+ | User data | :c:func:`IDASetUserData` | NULL | +--------------------------------------------------------------------+---------------------------------+----------------+ @@ -943,32 +943,64 @@ Main solver optional input functions +--------------------------------------------------------------------+---------------------------------+----------------+ -.. c:function:: int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, char* argv[]) +.. c:function:: int IDASetOptions(void* ida_mem, const char* idaid, const char* file_name, int argc, char* argv[]) - Passes command-line arguments to IDAS to set options. + Sets IDAS options from an array of strings or a file. :param ida_mem: pointer to the IDAS memory block. - :param idaid: String to use as prefix for IDAS command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param idaid: the prefix for options to read. The default is "idas". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: number of command-line arguments passed to executable. + :param argv: an array of strings containing the options to set and their values. :retval IDA_SUCCESS: the function exited successfully. :retval IDA_MEM_NULL: ``ida_mem`` was ``NULL``. :retval other: error return value from relevant IDAS "set" routine. + **Example usage:** + + In a C or C++ program, the following will enable command-line processing: + + .. code-block:: C + + /* Create IDAS memory block */ + void* ida_mem = IDACreate(ctx); + + /* Configure IDAS as normal */ + ... + + /* Override settings with command-line options using default "idas" prefix */ + flag = IDASetOptions(ida_mem, NULL, NULL, argc, argv); + + Then when running the program, the user can specify desired options, e.g., + + .. code-block:: console + + $ ./a.out idas.max_order 3 idas.delta_cj_lsetup 0.1 + .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. - These are left unchanged by :c:func:`IDASetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`IDASetOptions`. + + If the ``idaid`` argument is ``NULL``, then the default prefix, ``idas``, must + be used for all IDAS options. For example, the option ``idas.max_order`` followed + by the value can be used to set the maximum method order of accuracy. - If the *idaid* argument is ``NULL`` then ``idas.`` will be used for all IDAS command-line - options, e.g., to set the maximum order of accuracy the default command-line option would - be "idaid.max_order". + IDAS options set via :c:func:`IDASetOptions` will overwrite + any previously-set values. + + The supported option names are noted within the documentation for the + corresponding IDAS "set" function. + + .. warning:: - IDAS options set via command-line arguments to :c:func:`IDASetFromCommandLine` will - overwrite any previously-set values. + This function is not available in the Fortran interface. - The supported command-line options are documented within each IDAS "set" routine. + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. .. versionadded:: x.y.z @@ -1018,8 +1050,8 @@ Main solver optional input functions requirements for the internal IDAS memory block and its value cannot be increased past the value set when :c:func:`IDAInit` was called. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_order". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_order". .. c:function:: int IDASetMaxNumSteps(void * ida_mem, long int mxsteps) @@ -1038,8 +1070,8 @@ Main solver optional input functions Passing ``mxsteps`` = 0 results in IDAS using the default value (500). Passing ``mxsteps`` < 0 disables the test (not recommended). - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_steps". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_steps". .. c:function:: int IDASetInitStep(void * ida_mem, sunrealtype hin) @@ -1059,8 +1091,8 @@ Main solver optional input functions :math:`\|h \dot{y} \|_{{\scriptsize WRMS}} = 1/2`, with an added restriction that :math:`|h| \leq .001|t_{\text{out}} - t_0|`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.init_step". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.init_step". .. c:function:: int IDASetMinStep(void * ida_mem, sunrealtype hmin) @@ -1079,8 +1111,8 @@ Main solver optional input functions * ``IDA_ILL_INPUT`` -- ``hmin`` is negative. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.min_step". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.min_step". .. versionadded:: 5.2.0 @@ -1102,8 +1134,8 @@ Main solver optional input functions **Notes:** Pass ``hmax = 0`` to obtain the default value :math:`\infty`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_step". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_step". .. c:function:: int IDASetStopTime(void * ida_mem, sunrealtype tstop) @@ -1130,8 +1162,8 @@ Main solver optional input functions A stop time not reached before a call to :c:func:`IDAReInit` will remain active but can be disabled by calling :c:func:`IDAClearStopTime`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.stop_time". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.stop_time". .. c:function:: int IDAClearStopTime(void* ida_mem) @@ -1148,8 +1180,8 @@ Main solver optional input functions The stop time can be re-enabled though a new call to :c:func:`IDASetStopTime`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.clear_stop_time". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.clear_stop_time". .. versionadded:: 6.5.1 @@ -1170,8 +1202,8 @@ Main solver optional input functions **Notes:** The default value is 10. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_err_test_fails". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_err_test_fails". .. c:function:: int IDASetSuppressAlg(void * ida_mem, sunbooleantype suppressalg) @@ -1195,8 +1227,8 @@ Main solver optional input functions 1, whereas it is generally *encouraged* for systems of index 2 or more. See pp. 146-147 of :cite:p:`BCP:96` for more on this issue. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.suppress_alg". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.suppress_alg". .. c:function:: int IDASetId(void * ida_mem, N_Vector id) @@ -1365,8 +1397,8 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.delta_cj_lsetup". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.delta_cj_lsetup". .. versionadded:: 5.2.0 @@ -1392,8 +1424,8 @@ that updates the matrix using the current :math:`\alpha` as part of the solve. initialized through a call to :c:func:`IDASetLinearSolver`. By default scaling is enabled with matrix-based linear solvers. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.linear_solution_scaling". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.linear_solution_scaling". When using matrix-free linear solver modules, the IDALS solver interface @@ -1485,8 +1517,8 @@ finite-difference approximation, via a call to :c:func:`IDASetIncrementFactor`. linear solver interface has been initialized through a call to :c:func:`IDASetLinearSolver`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.increment_factor". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.increment_factor". .. versionadded:: 3.0.0 @@ -1608,8 +1640,8 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default :c:func:`IDASetLinearSolver`. If ``eplifac`` :math:`= 0.0` is passed, the default value is used. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eps_lin". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eps_lin". .. versionadded:: 3.0.0 @@ -1644,8 +1676,8 @@ where :math:`\epsilon` is the nonlinear solver tolerance, and the default value of ``nrmfac`` was computed using :c:func:`N_VDotProd` i.e., the ``nrmfac < 0`` case. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.ls_norm_factor". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.ls_norm_factor". .. _IDAS.Usage.SIM.user_callable.optional_input.nls: @@ -1690,8 +1722,8 @@ nonlinear solver. **Notes:** The default value is 4. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_nonlin_iters". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_nonlin_iters". .. c:function:: int IDASetMaxConvFails(void * ida_mem, int maxncf) @@ -1711,8 +1743,8 @@ nonlinear solver. **Notes:** The default value is 10. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_conv_fails". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_conv_fails". .. c:function:: int IDASetNonlinConvCoef(void * ida_mem, sunrealtype nlscoef) @@ -1732,8 +1764,8 @@ nonlinear solver. **Notes:** The default value is 0.33. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.nonlin_conv_coef". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.nonlin_conv_coef". .. c:function:: int IDASetNlsResFn(void * ida_mem, IDAResFn res) @@ -1815,8 +1847,8 @@ to set optional inputs controlling the initial condition calculation. :math:`J^{-1}F(t_0, y, \dot{y})` must be :math:`\leq \mathtt{epiccon}`, where :math:`J` is the system Jacobian. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.nonlin_conv_coef_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.nonlin_conv_coef_ic". .. c:function:: int IDASetMaxNumStepsIC(void * ida_mem, int maxnh) @@ -1837,8 +1869,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`5`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_steps_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_steps_ic". .. c:function:: int IDASetMaxNumJacsIC(void * ida_mem, int maxnj) @@ -1859,8 +1891,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`4`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_jacs_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_jacs_ic". .. c:function:: int IDASetMaxNumItersIC(void * ida_mem, int maxnit) @@ -1880,8 +1912,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`10`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_num_iters_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_num_iters_ic". .. c:function:: int IDASetMaxBacksIC(void * ida_mem, int maxbacks) @@ -1905,8 +1937,8 @@ to set optional inputs controlling the initial condition calculation. the limit ``maxbacks`` applies in the calculation of both the initial state values and the initial sensitivities. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.max_backs_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.max_backs_ic". .. c:function:: int IDASetLineSearchOffIC(void * ida_mem, sunbooleantype lsoff) @@ -1927,8 +1959,8 @@ to set optional inputs controlling the initial condition calculation. The default value is ``SUNFALSE``. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.linesearch_off_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.line_search_off_ic". .. c:function:: int IDASetStepToleranceIC(void * ida_mem, int steptol) @@ -1947,8 +1979,8 @@ to set optional inputs controlling the initial condition calculation. **Notes:** The default value is :math:`(\text{unit roundoff})^{2/3}`. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.step_tolerance_ic". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.step_tolerance_ic". .. _IDAS.Usage.SIM.user_callable.optional_input.step_adapt: @@ -2018,8 +2050,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_fixed_step_bounds". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_fixed_step_bounds". .. versionadded:: 5.2.0 @@ -2039,8 +2071,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_max". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_max". .. versionadded:: 5.2.0 @@ -2063,8 +2095,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_min". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_min". .. versionadded:: 5.2.0 @@ -2087,8 +2119,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_low". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_low". .. versionadded:: 5.2.0 @@ -2111,8 +2143,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_min_err_fail". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_min_err_fail". .. versionadded:: 5.2.0 @@ -2135,8 +2167,8 @@ step size adaptivity. * ``IDA_MEM_NULL`` -- The ``ida_mem`` pointer is ``NULL``. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.eta_conv_fail". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.eta_conv_fail". .. versionadded:: 5.2.0 @@ -2210,8 +2242,8 @@ rootfinding algorithm. first step), IDAS will issue a warning which can be disabled with this optional input function. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.no_inactive_root_warn". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.no_inactive_root_warn". .. _IDAS.Usage.SIM.user_callable.optional_dky: @@ -4021,8 +4053,8 @@ of quadrature equations. **Notes:** By default, ``errconQ`` is set to ``SUNFALSE``. - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.quad_err_con". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.quad_err_con". .. warning:: It is illegal to call :c:func:`IDASetQuadErrCon` before a call to :c:func:`IDAQuadInit`. @@ -4047,8 +4079,8 @@ quadrature variables. * ``IDA_ILL_INPUT`` -- One of the input tolerances was negative. **Notes:** - This routine will be called by :c:func:`IDASetFromCommandLine` - when using the command-line option "idaid.quad_scalar_tolerances". + This routine will be called by :c:func:`IDASetOptions` + when using the key "idaid.quad_scalar_tolerances". .. c:function:: int IDAQuadSVtolerances(void * ida_mem, sunrealtype reltolQ, N_Vector abstolQ) diff --git a/doc/kinsol/guide/source/Usage/index.rst b/doc/kinsol/guide/source/Usage/index.rst index 69686c6e8d..1004c9b2bd 100644 --- a/doc/kinsol/guide/source/Usage/index.rst +++ b/doc/kinsol/guide/source/Usage/index.rst @@ -456,7 +456,7 @@ negative, so a test ``retval`` :math:`<0` will catch any error. +========================================================+==================================+==============================+ | **KINSOL main solver** | | | +--------------------------------------------------------+----------------------------------+------------------------------+ - | Set KINSOL optional inputs from the command line | :c:func:`KINSetFromCommandLine` | | + | Set KINSOL options from the command line or file | :c:func:`KINSetOptions` | | +--------------------------------------------------------+----------------------------------+------------------------------+ | Data for problem-defining function | :c:func:`KINSetUserData` | ``NULL`` | +--------------------------------------------------------+----------------------------------+------------------------------+ @@ -525,33 +525,64 @@ negative, so a test ``retval`` :math:`<0` will catch any error. +--------------------------------------------------------+----------------------------------+------------------------------+ -.. c:function:: int KINSetFromCommandLine(void* kin_mem, const char* kinid, int argc, char* argv[]) +.. c:function:: int KINSetOptions(void* kin_mem, const char* kinid, const char* file_name, int argc, char* argv[]) - Passes command-line arguments to KINSOL to set options. + Sets KINSOL options from an array of strings or a file. :param kin_mem: pointer to the KINSOL memory block. - :param kinid: String to use as prefix for KINSOL command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param kinid: the prefix for options to read. The default is "kinsol". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: number of command-line arguments passed to executable. + :param argv: an array of strings containing the options to set and their values. :retval KIN_SUCCESS: the function exited successfully. :retval KIN_MEM_NULL: ``kin_mem`` was ``NULL``. :retval other: error return value from relevant KINSOL "set" routine. + **Example usage:** + + In a C or C++ program, the following will enable command-line processing: + + .. code-block:: C + + /* Create KINSOL memory block */ + void* kin_mem = KINCreate(sunctx); + + /* Configure KINSOL as normal */ + ... + + /* Override settings with command-line options using default "kinsol" prefix */ + flag = KINSetOptions(kin_mem, NULL, NULL, argc, argv); + + Then when running the program, the user can specify desired options, e.g., + + .. code-block:: console + + $ ./a.out kinsol.num_max_iters 100 kinsol.kinid.eta_const_value 0.01 + .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. - These are left unchanged by :c:func:`KINSetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`KINSetOptions`. - If the *kinid* argument is ``NULL`` then ``kinsol.`` will be used for all KINSOL command-line - options, e.g., to set the maximum order of accuracy the default command-line option would - be "kinsol.max_order". + If the ``kinid`` argument is ``NULL``, then the default prefix, ``kinsol``, must + be used for all KINSOL options. For example, the option ``kinsol.num_max_iters`` followed + by the value can be used to set the maximum number of nonlinear solver iterations. - KINSOL options set via command-line arguments to :c:func:`KINSetFromCommandLine` will + KINSOL options set via :c:func:`KINSetOptions` will overwrite any previously-set values. The supported command-line options are documented within each KINSOL "set" routine. + .. warning:: + + This function is not available in the Fortran interface. + + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. + .. versionadded:: x.y.z .. c:function:: int KINSetUserData(void * kin_mem, void * user_data) @@ -595,8 +626,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``mxiter`` is ``MXITER_DEFAULT`` :math:`=200`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.num_max_iters". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.num_max_iters". .. c:function:: int KINSetNoInitSetup(void * kin_mem, sunbooleantype noInitSetup) @@ -621,8 +652,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. problems, in which the final preconditioner or Jacobian value from one problem is to be used initially for the next problem. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.no_init_setup". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.no_init_setup". .. c:function:: int KINSetNoResMon(void * kin_mem, sunbooleantype noNNIResMon) @@ -643,8 +674,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. When using a direct solver, the default value for ``noNNIResMon`` is ``SUNFALSE``, meaning that the nonlinear residual will be monitored. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.no_res_mon". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.no_res_mon". .. warning:: Residual monitoring is only available for use with matrix-based linear @@ -691,8 +722,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The value of ``msbset`` (see :c:func:`KINSetMaxSetupCalls`) should be a multiple of ``msbsetsub``. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.max_sub_setup_calls". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.max_sub_setup_calls". .. warning:: Residual monitoring is only available for use with matrix-based linear @@ -746,8 +777,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. where :math:`\eta_{\text{min}} = 10^{-4}` and :math:`\eta_{\text{max}} = 0.9`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.eta_form". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.eta_form". .. c:function:: int KINSetEtaConstValue(void * kin_mem, sunrealtype eta) @@ -768,8 +799,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The default value for ``eta`` is :math:`0.1`. The legal values are :math:`0.0 <` ``eta`` :math:`\le 1.0`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.eta_const_value". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.eta_const_value". .. c:function:: int KINSetEtaParams(void * kin_mem, sunrealtype egamma, sunrealtype ealpha) @@ -793,8 +824,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. :math:`2.0`, respectively. The legal values are :math:`0.0 <` ``egamma`` :math:`\le 1.0` and :math:`1.0<` ``ealpha`` :math:`\le 2.0`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.eta_params". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.eta_params". .. c:function:: int KINSetResMonConstValue(void * kin_mem, sunrealtype omegaconst) @@ -815,8 +846,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The default value for ``omegaconst`` is :math:`0.9`. The legal values are :math:`0.0 <` ``omegaconst`` :math:`< 1.0`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.res_mon_const_value". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.res_mon_const_value". .. c:function:: int KINSetResMonParams(void * kin_mem, sunrealtype omegamin, sunrealtype omegamax) @@ -840,8 +871,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. and :math:`0.9`, respectively. The legal values are :math:`0.0 <` ``omegamin`` :math:`<` ``omegamax`` :math:`< 1.0`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.res_mon_params". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.res_mon_params". .. warning:: Residual monitoring is only available for use with matrix-based linear @@ -867,8 +898,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. positive minimum value, equal to :math:`0.01`*``fnormtol``, is applied to :math:`\epsilon` (see :c:func:`KINSetFuncNormTol` below). - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.no_min_eps". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.no_min_eps". .. c:function:: int KINSetMaxNewtonStep(void * kin_mem, sunrealtype mxnewtstep) @@ -890,8 +921,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. The default value of ``mxnewtstep`` is :math:`1000\, \| u_0 \|_{D_u}`, where :math:`u_0` is the initial guess. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.max_newton_step". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.max_newton_step". .. c:function:: int KINSetMaxBetaFails(void * kin_mem, sunrealtype mxnbcf) @@ -912,8 +943,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value of ``mxnbcf`` is ``MXNBCF_DEFAULT`` :math:`=10`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.max_beta_fails". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.max_beta_fails". .. c:function:: int KINSetRelErrFunc(void * kin_mem, sunrealtype relfunc) @@ -937,8 +968,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``relfunc`` is :math:`U` = unit roundoff. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.rel_err_func". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.rel_err_func". .. c:function:: int KINSetFuncNormTol(void * kin_mem, sunrealtype fnormtol) @@ -960,8 +991,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``fnormtol`` is (unit roundoff) :math:`^{1/3}`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.func_norm_tol". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.func_norm_tol". .. c:function:: int KINSetScaledStepTol(void * kin_mem, sunrealtype scsteptol) @@ -982,8 +1013,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value for ``scsteptol`` is (unit roundoff) :math:`^{2/3}`. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.scaled_step_tol". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.scaled_step_tol". .. c:function:: int KINSetConstraints(void * kin_mem, N_Vector constraints) @@ -1054,8 +1085,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value of ``ret_newest`` is ``SUNFALSE``. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.return_newest". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.return_newest". .. c:function:: int KINSetDamping(void * kin_mem, sunrealtype beta) @@ -1084,8 +1115,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. ``beta`` is extremely small (close to zero), this can lead to an excessively tight tolerance. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.damping". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.damping". .. c:function:: int KINSetMAA(void * kin_mem, long int maa) @@ -1119,8 +1150,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. may have been limited in the last :c:func:`KINSol` call to enforce ``maa < mxiter``. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.m_aa". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.m_aa". .. versionchanged:: x.y.z @@ -1153,8 +1184,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. value provided to :c:func:`KINSetDampingAA` is applied to all iterations and any value provided to :c:func:`KINSetDamping` is ignored. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.damping_aa". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.damping_aa". .. c:function:: int KINSetDelayAA(void * kin_mem, long int delay) @@ -1174,8 +1205,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. **Notes:** The default value of ``delay`` is 0, indicating no delay. - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.delay_aa". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.delay_aa". .. c:function:: int KINSetOrthAA(void* kin_mem, int orthaa) @@ -1210,8 +1241,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. This function can now be called any time after :c:func:`KINCreate` (i.e., it no longer needs to be call before :c:func:`KINInit`). - This routine will be called by :c:func:`KINSetFromCommandLine` - when using the command-line option "kinid.orth_aa". + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.orth_aa". .. c:function:: int KINSetDampingFn(void* kin_mem, KINDampingFn damping_fn) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index 7c18c73b52..eefeb3d7e2 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -93,9 +93,9 @@ The virtual table structure is defined as The function implementing :c:func:`SUNAdaptController_Reset` - .. c:member:: SUNErrCode (*setfromcommandline)(SUNAdaptController C, const char* Cid, int argc, char* argv[]) + .. c:member:: SUNErrCode (*setoptions)(SUNAdaptController C, const char* Cid, const char* file_name, int argc, char* argv[]) - The function implementing :c:func:`SUNAdaptController_SetFromCommandLine` + The function implementing :c:func:`SUNAdaptController_SetOptions` .. versionadded:: x.y.z @@ -267,31 +267,43 @@ note these requirements below. Additionally, we note the behavior of the base SU :return: :c:type:`SUNErrCode` indicating success or failure. -.. c:function:: SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, const char* Cid, int argc, char* argv[]) +.. c:function:: SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, const char* Cid, const char* file_name, int argc, char* argv[]) - Passes command-line arguments to SUNAdaptController implementations. + Sets SUNAdaptController options from an array of strings or a file. :param C: the :c:type:`SUNAdaptController` object. - :param Cid: String to use as prefix for command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param Cid: the prefix for options to read. The default is "sunadaptcontroller". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: number of command-line arguments passed to executable. + :param argv: an array of strings containing the options to set and their values. :return: :c:type:`SUNErrCode` indicating success or failure. .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These - are left unchanged by :c:func:`SUNAdaptController_SetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`SUNAdaptController_SetOptions`. - If the *Cid* argument is ``NULL`` then an implementation-specific prefix will be used for the - relevant command-line options -- see each implementation for its default prefix value. - When using a combination of SUNAdaptController objects (e.g., within MRIStep, SplittingStep or - ForcingStep), it is recommended that users call :c:func:`SUNAdaptController_SetFromCommandLine` - for each controller using distinct *Cid* inputs, so that each controller can be configured - separately. + If the ``Cid`` argument is ``NULL`` then the default prefix, ``sunadaptcontroller``, must + be used for all SUNAdaptController options. When using a combination of SUNAdaptController + objects (e.g., within MRIStep, SplittingStep or ForcingStep), it is recommended that users + call :c:func:`SUNAdaptController_SetOptions` for each controller using distinct *Cid* inputs, + so that each controller can be configured separately. - SUNAdaptController options set via command-line arguments to - :c:func:`SUNAdaptController_SetFromCommandLine` will overwrite any previously-set values. + SUNAdaptController options set via :c:func:`SUNAdaptController_SetOptions` will overwrite + any previously-set values. + + The supported option names are noted within the documentation for the + corresponding SUNAdaptController functions. + + .. warning:: + + This function is not available in the Fortran interface. + + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. .. versionadded:: x.y.z @@ -305,8 +317,8 @@ note these requirements below. Additionally, we note the behavior of the base SU .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.defaults". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.defaults". .. c:function:: SUNErrCode SUNAdaptController_Write(SUNAdaptController C, FILE* fptr) @@ -319,8 +331,8 @@ note these requirements below. Additionally, we note the behavior of the base SU .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.write_parameters". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.write_parameters". .. c:function:: SUNErrCode SUNAdaptController_SetErrorBias(SUNAdaptController C, sunrealtype bias) @@ -336,8 +348,8 @@ note these requirements below. Additionally, we note the behavior of the base SU .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.error_bias". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.error_bias". .. c:function:: SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm) diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst index 08f60a9199..3ca0f48c24 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_ImExGus.rst @@ -106,12 +106,6 @@ routines: SUNAdaptController C = SUNAdaptController_ImExGus(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_imexgus". - .. c:function:: SUNErrCode SUNAdaptController_SetParams_ImExGus(SUNAdaptController C, sunrealtype k1e, sunrealtype k2e, sunrealtype k1i, sunrealtype k2i) This user-callable function provides control over the relevant parameters @@ -133,5 +127,5 @@ routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params". diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst index 7eaac23bcc..e3fb80f7ac 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_MRIHTol.rst @@ -142,12 +142,6 @@ also provides the following additional user-callable routines: :returns: if successful, a usable :c:type:`SUNAdaptController` object; otherwise it will return ``NULL``. - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_mrihtol". - .. c:function:: SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, sunrealtype inner_max_relch, sunrealtype inner_min_tolfac, sunrealtype inner_max_tolfac) @@ -165,8 +159,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params". Usage diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst index aaa4828aef..8429ff4c1e 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Soderlind.rst @@ -100,11 +100,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_Soderlind(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_soderlind". .. c:function:: SUNErrCode SUNAdaptController_SetParams_Soderlind(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3, sunrealtype k4, sunrealtype k5) @@ -129,8 +124,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params_soderlind". .. c:function:: SUNAdaptController SUNAdaptController_PID(SUNContext sunctx) @@ -149,11 +144,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_PID(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_pid". .. c:function:: SUNErrCode SUNAdaptController_SetParams_PID(SUNAdaptController C, sunrealtype k1, sunrealtype k2, sunrealtype k3) @@ -175,8 +165,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params_pid". .. c:function:: SUNAdaptController SUNAdaptController_PI(SUNContext sunctx) @@ -195,12 +185,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_PI(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_pi". - .. c:function:: SUNErrCode SUNAdaptController_SetParams_PI(SUNAdaptController C, sunrealtype k1, sunrealtype k2) @@ -221,8 +205,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params_pi". .. c:function:: SUNAdaptController SUNAdaptController_I(SUNContext sunctx) @@ -241,12 +225,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_I(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_i". - .. c:function:: SUNErrCode SUNAdaptController_SetParams_I(SUNAdaptController C, sunrealtype k1) @@ -266,8 +244,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params_i". .. c:function:: SUNAdaptController SUNAdaptController_ExpGus(SUNContext sunctx) @@ -287,12 +265,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ExpGus(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_expgus". - .. c:function:: SUNErrCode SUNAdaptController_SetParams_ExpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) @@ -324,8 +296,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params_expgus". .. c:function:: SUNAdaptController SUNAdaptController_ImpGus(SUNContext sunctx) @@ -345,12 +317,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_ImpGus(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_impgus". - .. c:function:: SUNErrCode SUNAdaptController_SetParams_ImpGus(SUNAdaptController C, sunrealtype k1_hat, sunrealtype k2_hat) @@ -382,8 +348,8 @@ also provides the following additional user-callable routines: .. note:: - This routine will be called by :c:func:`SUNAdaptController_SetFromCommandLine` - when using the command-line option "Cid.params". + This routine will be called by :c:func:`SUNAdaptController_SetOptions` + when using the key "Cid.params_impgus". .. c:function:: SUNAdaptController SUNAdaptController_H0211(SUNContext sunctx) @@ -423,12 +389,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_H0321(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_soderlind". - .. c:function:: SUNAdaptController SUNAdaptController_H211(SUNContext sunctx) This constructor creates and allocates memory for a @@ -448,12 +408,6 @@ also provides the following additional user-callable routines: SUNAdaptController C = SUNAdaptController_H211(sunctx); - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_soderlind". - .. c:function:: SUNAdaptController SUNAdaptController_H312(SUNContext sunctx) This constructor creates and allocates memory for a @@ -472,9 +426,3 @@ also provides the following additional user-callable routines: .. code-block:: c SUNAdaptController C = SUNAdaptController_H312(sunctx); - - .. note:: - - This SUNAdaptController implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNAdaptController_SetFromCommandLine` - to be "sunadaptcontroller_soderlind". \ No newline at end of file diff --git a/doc/shared/sunlinsol/SUNLinSol_API.rst b/doc/shared/sunlinsol/SUNLinSol_API.rst index 4fdd527683..cc05f03a92 100644 --- a/doc/shared/sunlinsol/SUNLinSol_API.rst +++ b/doc/shared/sunlinsol/SUNLinSol_API.rst @@ -240,31 +240,40 @@ the functionality for any optional routine should leave the corresponding function pointer ``NULL`` instead of supplying a dummy routine. -.. c:function:: SUNErrCode SUNLinSolSetFromCommandLine(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) +.. c:function:: SUNErrCode SUNLinSolSetOptions(SUNLinearSolver S, const char* LSid, const char* file_name, int argc, char* argv[]) - This *optional* routine allows command-line control over various options within a SUNLinearSolver implementation. + This *optional* routine sets SUNLinearSolver options from an array of strings or a file. :param S: the :c:type:`SUNLinearSolver` object. - :param LSid: String to use as prefix for command-line options. - :param argc: Number of command-line options provided to executable. - :param argv: Array of strings containing command-line options provided to executable. + :param LSid: the prefix for options to read. The default is "sunlinearsolver". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: length of the ``argv`` array. + :param argv: an array of strings containing the options to set and their values. :return: :c:type:`SUNErrCode` indicating success or failure. .. note:: - The *argc* and *argv* arguments should typically be those supplied to the user's ``main`` routine. These - are left unchanged by :c:func:`SUNLinSolSetFromCommandLine`. + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`SUNLinSolSetOptions`. - If the *LSid* argument is ``NULL`` then an implementation-specific prefix will be used for the - relevant command-line options -- see each implementation for its default prefix value. + If the ``LSid`` argument is ``NULL`` then an implementation-specific prefix will be used for the + relevant options -- see each implementation for its default prefix value. When using a combination of SUNLinearSolver objects (e.g., for system and mass matrices within - ARKStep), it is recommended that users call :c:func:`SUNLinSolSetFromCommandLine` - for each controller using distinct *LSid* inputs, so that each solver can be configured - separately. + ARKStep), it is recommended that users call :c:func:`SUNLinSolSetOptions` for each linear solver + using distinct *LSid* inputs, so that each solver can be configured separately. SUNLinearSolver options set via command-line arguments to - :c:func:`SUNLinSolSetFromCommandLine` will overwrite any previously-set values. + :c:func:`SUNLinSolSetOptions` will overwrite any previously-set values. + + .. warning:: + + This function is not available in the Fortran interface. + + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. .. versionadded:: x.y.z @@ -356,9 +365,8 @@ function pointer ``NULL`` instead of supplying a dummy routine. each of the SUNDIALS packages call :c:func:`SUNLinSolSetZeroGuess` prior to each call to :c:func:`SUNLinSolSolve`. - If supported by the SUNLinearSolver implementation, this routine will be called - by :c:func:`SUNLinSolSetFromCommandLine` when using the command-line option + by :c:func:`SUNLinSolSetOptions` when using the key "LSid.zero_guess". @@ -659,6 +667,10 @@ The virtual table structure is defined as The function implementing :c:func:`SUNLinSolSetScalingVectors` + .. c:member:: SUNErrCode (*setoptions)(SUNLinearSolver, const char* LSid, const char* file_name, int argc, char* argv[]) + + The function implementing :c:func:`SUNLinSolSetOptions` + .. c:member:: SUNErrCode (*setzeroguess)(SUNLinearSolver, sunbooleantype) The function implementing :c:func:`SUNLinSolSetZeroGuess` diff --git a/doc/shared/sunlinsol/SUNLinSol_KLU.rst b/doc/shared/sunlinsol/SUNLinSol_KLU.rst index 29b8ee5b02..9163352d2d 100644 --- a/doc/shared/sunlinsol/SUNLinSol_KLU.rst +++ b/doc/shared/sunlinsol/SUNLinSol_KLU.rst @@ -60,10 +60,6 @@ user-callable routines: SUNDIALS, these will be included within this compatibility check. - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "klu". - .. c:function:: SUNErrCode SUNLinSol_KLUReInit(SUNLinearSolver S, SUNMatrix A, sunindextype nnz, int reinit_type) @@ -120,8 +116,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.ordering". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.ordering". .. c:function:: sun_klu_symbolic* SUNLinSol_KLUGetSymbolic(SUNLinearSolver S) diff --git a/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst b/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst index 0b7459be6b..8091b29727 100644 --- a/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst +++ b/doc/shared/sunlinsol/SUNLinSol_MagmaDense.rst @@ -83,11 +83,6 @@ In addition, the module provides the following user-callable routines: the input matrix and vector to determine the linear system size and to assess compatibility with the solver. - **Notes:** - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "magmadense". - .. c:function:: SUNErrCode SUNLinSol_MagmaDense_SetAsync(SUNLinearSolver LS, sunbooleantype onoff) This function can be used to toggle the linear solver between asynchronous @@ -104,8 +99,8 @@ In addition, the module provides the following user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.async". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.async". SUNLinearSolver_MagmaDense Content diff --git a/doc/shared/sunlinsol/SUNLinSol_PCG.rst b/doc/shared/sunlinsol/SUNLinSol_PCG.rst index 7f373bf41a..8844fd5094 100644 --- a/doc/shared/sunlinsol/SUNLinSol_PCG.rst +++ b/doc/shared/sunlinsol/SUNLinSol_PCG.rst @@ -135,10 +135,6 @@ The module SUNLinSol_PCG provides the following user-callable routines: preconditioning should work appropriately even for packages designed with one-sided preconditioning in mind. - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "pcg". - .. c:function:: SUNErrCode SUNLinSol_PCGSetPrecType(SUNLinearSolver S, int pretype) @@ -161,8 +157,8 @@ The module SUNLinSol_PCG provides the following user-callable routines: ``SUN_PREC_RIGHT``, or ``SUN_PREC_BOTH`` will enable preconditioning; ``SUN_PREC_NONE`` disables preconditioning. - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.prec_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.prec_type". .. c:function:: SUNErrCode SUNLinSol_PCGSetMaxl(SUNLinearSolver S, int maxl) @@ -179,8 +175,8 @@ The module SUNLinSol_PCG provides the following user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.maxl". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.maxl". .. _SUNLinSol.PCG.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst b/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst index e206991bef..052007bdc5 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPBCGS.rst @@ -82,10 +82,6 @@ user-callable routines: With ``SUN_PREC_RIGHT`` or ``SUN_PREC_BOTH`` the initial guess must be zero (use :c:func:`SUNLinSolSetZeroGuess` to indicate the initial guess is zero). - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "spbcgs". - .. c:function:: SUNErrCode SUNLinSol_SPBCGSSetPrecType(SUNLinearSolver S, int pretype) @@ -105,8 +101,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.prec_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.prec_type". .. c:function:: SUNErrCode SUNLinSol_SPBCGSSetMaxl(SUNLinearSolver S, int maxl) @@ -123,8 +119,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.maxl". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.maxl". diff --git a/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst b/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst index 0c0f447c00..18b8ec7cc3 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPFGMR.rst @@ -84,10 +84,6 @@ user-callable routines: these packages, this use mode is not supported and may result in inferior performance. - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "spfgmr". - .. c:function:: SUNErrCode SUNLinSol_SPFGMRSetPrecType(SUNLinearSolver S, int pretype) @@ -112,8 +108,8 @@ user-callable routines: will result in use of ``SUN_PREC_RIGHT``; any other integer input will result in the default (no preconditioning). - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.prec_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.prec_type". .. c:function:: SUNErrCode SUNLinSol_SPFGMRSetGSType(SUNLinearSolver S, int gstype) @@ -132,8 +128,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.gs_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.gs_type". .. c:function:: SUNErrCode SUNLinSol_SPFGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) @@ -150,8 +146,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.max_restarts". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.max_restarts". diff --git a/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst b/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst index 6991da9db2..393a34e87e 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPGMR.rst @@ -77,9 +77,6 @@ user-callable routines: with these solvers, this use mode is not supported and may result in inferior performance. - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "spgmr". .. c:function:: SUNErrCode SUNLinSol_SPGMRSetPrecType(SUNLinearSolver S, int pretype) @@ -99,8 +96,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.prec_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.prec_type". .. c:function:: SUNErrCode SUNLinSol_SPGMRSetGSType(SUNLinearSolver S, int gstype) @@ -119,8 +116,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.gs_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.gs_type". .. c:function:: SUNErrCode SUNLinSol_SPGMRSetMaxRestarts(SUNLinearSolver S, int maxrs) @@ -137,8 +134,8 @@ user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.max_restarts". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.max_restarts". .. _SUNLinSol.SPGMR.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst b/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst index a8c1e4f8d4..3dddceea85 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SPTFQMR.rst @@ -81,10 +81,6 @@ The module SUNLinSol_SPTFQMR provides the following user-callable routines: With ``SUN_PREC_RIGHT`` or ``SUN_PREC_BOTH`` the initial guess must be zero (use :c:func:`SUNLinSolSetZeroGuess` to indicate the initial guess is zero). - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "sptfqmr". - .. c:function:: SUNErrCode SUNLinSol_SPTFQMRSetPrecType(SUNLinearSolver S, int pretype) @@ -104,8 +100,8 @@ The module SUNLinSol_SPTFQMR provides the following user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.prec_type". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.prec_type". .. c:function:: SUNErrCode SUNLinSol_SPTFQMRSetMaxl(SUNLinearSolver S, int maxl) @@ -122,8 +118,8 @@ The module SUNLinSol_SPTFQMR provides the following user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.maxl". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.maxl". .. _SUNLinSol.SPTFQMR.Description: diff --git a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst index 19cc70ad4d..de600b5fa0 100644 --- a/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst +++ b/doc/shared/sunlinsol/SUNLinSol_SuperLUMT.rst @@ -72,10 +72,6 @@ The module SUNLinSol_SuperLUMT provides the following user-callable routines: The ``num_threads`` argument is not checked and is passed directly to SuperLU_MT routines. - This SUNLinearSolver implementation sets the default prefix for command-line - arguments processed by :c:func:`SUNLinSolSetFromCommandLine` - to be "superlumt". - .. c:function:: SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice) @@ -101,8 +97,8 @@ The module SUNLinSol_SuperLUMT provides the following user-callable routines: **Notes:** - This routine will be called by :c:func:`SUNLinSolSetFromCommandLine` - when using the command-line option "LSid.ordering". + This routine will be called by :c:func:`SUNLinSolSetOptions` + when using the key "LSid.ordering". .. _SUNLinSol.SuperLUMT.Description: diff --git a/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst b/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst index 3f05511be2..9e614c7ead 100644 --- a/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst +++ b/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst @@ -154,6 +154,44 @@ parameters. Only the routine for setting the nonlinear system defining function (:c:func:`SUNNonlinSolSetSysFn`) is required. All other set functions are optional. +.. c:function:: SUNErrCode SUNNonlinSolSetOptions(SUNNonlinearSolver NLS, const char* NLSid, const char* file_name, int argc, char* argv[]) + + This *optional* routine sets SUNNonlinearSolver options from an array of strings or a file. + + :param NLS: the :c:type:`SUNNonlinearSolver` object. + :param NLSid: the prefix for options to read. The default is "sunnonlinearsolver". + :param file_name: the name of a file containing options to read. If this is + ``NULL`` or an empty string, ``""``, then no file is read. + :param argc: length of the ``argv`` array. + :param argv: an array of strings containing the options to set and their values. + + :return: :c:type:`SUNErrCode` indicating success or failure. + + .. note:: + + The ``argc`` and ``argv`` arguments are typically those supplied to the user's + ``main`` routine however, this is not required. The inputs are left unchanged by + :c:func:`SUNNonlinSolSetOptions`. + + If the ``LSid`` argument is ``NULL`` then an implementation-specific prefix will be used for the + relevant options -- see each implementation for its default prefix value. + When using a combination of SUNNonlinearSolver objects (e.g., when using MRIStep), it is recommended + that users call :c:func:`SUNNonlinSolSetOptions` for each nonlinear solver using distinct + *NLSid* inputs, so that each solver can be configured separately. + + SUNNonlinearSolver options set via command-line arguments to + :c:func:`SUNNonlinSolSetOptions` will overwrite any previously-set values. + + .. warning:: + + This function is not available in the Fortran interface. + + File-based options are not yet implemented, so the *file_name* argument + should be set to either ``NULL`` or the empty string ``""``. + + .. versionadded:: x.y.z + + .. c:function:: SUNErrCode SUNNonlinSolSetSysFn(SUNNonlinearSolver NLS, SUNNonlinSolSysFn SysFn) This *required* function is used to provide the nonlinear solver @@ -262,6 +300,11 @@ parameters. Only the routine for setting the nonlinear system defining function **Return value:** * A :c:type:`SUNErrCode` + **Notes:** + + If supported by the SUNNonlinearSolver implementation, this routine will be called + by :c:func:`SUNNonlinSolSetOptions` when using the key + "NLSid.max_iters". diff --git a/doc/superbuild/source/developers/commandline/Options.rst b/doc/superbuild/source/developers/commandline/Options.rst index daabdf3045..f07a9fe667 100644 --- a/doc/superbuild/source/developers/commandline/Options.rst +++ b/doc/superbuild/source/developers/commandline/Options.rst @@ -57,10 +57,14 @@ One ``int`` argument These functions set a single integer option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the integer value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the integer value to set. + + **Returns:** - :return: An *sunIntSetFn* should return 0 if successful, or a nonzero value on failure. + A :c:type:`sunIntSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -88,8 +92,8 @@ One ``int`` argument :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -104,11 +108,15 @@ Two ``int`` arguments These functions set two integer options for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the first integer value to set. - :param arg2: the second integer value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the first integer value to set. + * **arg2** -- the second integer value to set. - :return: An *sunTwoIntSetFn* should return 0 if successful, or a nonzero value on failure. + **Returns:** + + A :c:type:`sunTwoIntSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -136,8 +144,8 @@ Two ``int`` arguments :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -152,10 +160,14 @@ One ``long int`` argument These functions set a single long integer option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the long integer value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the long integer value to set. + + **Returns:** - :return: An *sunLongSetFn* should return 0 if successful, or a nonzero value on failure. + A :c:type:`sunLongSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -183,8 +195,8 @@ One ``long int`` argument :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -199,11 +211,15 @@ One ``int`` and one ``sunrealtype`` argument These functions set a single integer option and a single real option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the integer value to set. - :param arg2: the real value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the integer value to set. + * **arg2** -- the real value to set. - :return: An *sunIntRealSetFn* should return 0 if successful, or a nonzero value on failure. + **Returns:** + + A :c:type:`sunIntRealSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -231,8 +247,8 @@ One ``int`` and one ``sunrealtype`` argument :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -247,12 +263,16 @@ One ``int`` and two ``sunrealtype`` arguments These functions set a single integer option and two real options for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the integer value to set. - :param arg2: the first real value to set. - :param arg3: the second real value to set. + **Parameters:** - :return: An *sunIntRealRealSetFn* should return 0 if successful, or a nonzero value on failure. + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the integer value to set. + * **arg2** -- the first real value to set. + * **arg3** -- the second real value to set. + + **Returns:** + + A :c:type:`sunIntRealRealSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -280,8 +300,8 @@ One ``int`` and two ``sunrealtype`` arguments :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -296,11 +316,15 @@ One ``int`` and one ``long int`` argument These functions set a single integer option and a long integer option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the integer value to set. - :param arg2: the long integer value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the integer value to set. + * **arg2** -- the long integer value to set. - :return: An *sunIntLongSetFn* should return 0 if successful, or a nonzero value on failure. + **Returns:** + + A :c:type:`sunIntLongSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -328,8 +352,8 @@ One ``int`` and one ``long int`` argument :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -344,10 +368,14 @@ One ``sunrealtype`` argument These functions set a single real option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the real value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the real value to set. + + **Returns:** - :return: An *sunRealSetFn* should return 0 if successful, or a nonzero value on failure. + A :c:type:`sunRealSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -375,8 +403,8 @@ One ``sunrealtype`` argument :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -391,11 +419,15 @@ Two ``sunrealtype`` arguments These functions set two real options for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the first real value to set. - :param arg2: the second real value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the first real value to set. + * **arg2** -- the second real value to set. - :return: An *sunTwoRealSetFn* should return 0 if successful, or a nonzero value on failure. + **Returns:** + + A :c:type:`sunTwoRealSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -423,8 +455,8 @@ Two ``sunrealtype`` arguments :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -439,10 +471,14 @@ One ``char*`` argument These functions set a single string option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the string value to set. + **Parameters:** - :return: An *sunCharSetFn* should return 0 if successful, or a nonzero value on failure. + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the string value to set. + + **Returns:** + + A :c:type:`sunCharSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -470,8 +506,8 @@ One ``char*`` argument :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -486,11 +522,15 @@ Two ``char*`` arguments These functions set two string options for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. - :param arg1: the first string value to set. - :param arg2: the second string value to set. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + * **arg1** -- the first string value to set. + * **arg2** -- the second string value to set. - :return: An *sunTwoCharSetFn* should return 0 if successful, or a nonzero value on failure. + **Returns:** + + A :c:type:`sunTwoCharSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -518,8 +558,8 @@ Two ``char*`` arguments :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -534,9 +574,13 @@ No arguments (action only) These functions set a single integer option for a SUNDIALS module. - :param mem: an opaque pointer to the SUNDIALS module. + **Parameters:** + + * **mem** -- an opaque pointer to the SUNDIALS module. + + **Returns:** - :return: An *sunActionSetFn* should return 0 if successful, or a nonzero value on failure. + A :c:type:`sunActionSetFn` function should return 0 if successful, or a nonzero value on failure. .. versionadded:: x.y.z @@ -564,8 +608,8 @@ No arguments (action only) :param offset: the offset width to ignore (stores a module-specific prefix for the key). :param testpairs: an array of key-value pairs to test against. :param numpairs: the number of key-value pairs in ``testpairs``. - :param arg_used: a pointer to a boolean indicating if the argument was used. - :param failedarg: a pointer to an integer indicating the failed argument index (if any). + :param arg_used: a flag indicating if the argument was used. + :param failedarg: if an error occurs when setting an option, this is the index of the option in ``argv`` that resulted in an error. :return: SUN_SUCCESS if either the argument was not found, or if it was matched and set correctly. If it was found but the set routine failed, then this returns the value emanating from the module-specific set routine. @@ -578,21 +622,23 @@ Package-specific Command-line Support Each SUNDIALS module that wishes to support command-line options should provide a routine of the form -``SetFromCommandLine(void* mem, const char* moduleid, int argc, char* argv[])``. +``SetOptions(void* mem, const char* moduleid, const char* file_name, int argc, char* argv[])``. This routine can then be called by users to indicate that they wish to use -command-line options to control the corresponding SUNDIALS module. The arguments to +command-line or input file options to control the corresponding SUNDIALS module. The arguments to this function are: * ``mem``: an opaque pointer to the SUNDIALS module (e.g., the pointer returned by :c:func:`CVodeCreate`). -* ``moduleid``: a desired string identifier for arguments to that module (e.g., "arkode"). +* ``moduleid``: a desired string identifier prefix for arguments to that module (e.g., "arkode"). Note that each module should specify a default string identifier, that would be used if the user specifies ``NULL`` for this argument. However, users can supply non-default identifiers so that they can control multiple instances of the same module independently (e.g., when using multiple ARKode integrators in the same program). -* ``argc``: the number of command-line arguments. -* ``argv``: the command-line argument vector. +* ``file_name``: the name of a file containing options to read. If this is ``NULL`` or an + empty string, ``""``, then no file is read. +* ``argc``: the length of the ``argv`` array. +* ``argv``: an array of strings containing the options to set and their values. Within this module-provided routine, arrays of key-value pairs having the correct type for the corresponding "Set" routine should be defined (e.g., see the file @@ -600,9 +646,19 @@ for the corresponding "Set" routine should be defined (e.g., see the file .. note:: - When adding new "Set" routines to an existing SUNDIALS module, developers should - attempt to add a corresponding entry in the appropriate key-value pair array, and note - the new key in the module's documentation. + When adding new "Set" routines to an existing SUNDIALS module, developers + should add a corresponding entry in the appropriate key-value pair array, + and note the new key in the module's documentation. These keys should use + snake case, and should match the "set" function name with the "Set" prefix + removed (e.g., for the function :c:func:`ARKodeSetAccumulatedErrorType`, the + key would be "accumulated_error_type"). The keys should also be unique + within the module. While exceptions to this rule exist, those were chosen + so that they keys were more descriptive, since their corresponding "Set" + routines employed "older" SUNDIALS styles for abbreviated "Set" function + names (e.g., :c:func:`ARKodeSStolerances` uses the key + "scalar_tolerances"). Since future "Set" functions should no longer use + abbreviations, their keys should uniformly follow the convention described + above. After defining the allowable command-line arguments (and their corresponding "Set" routines), the module-provided routine should loop over all ``argc`` command-line diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index e11aa02103..c170ee987e 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -131,8 +131,8 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Override any current settings with command-line options */ - flag = ARKodeSetFromCommandLine(arkode_mem, NULL, argc, argv); - if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } + flag = ARKodeSetOptions(arkode_mem, NULL, NULL, argc, argv); + if (check_flag(&flag, "ARKodeSetOptions", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); diff --git a/examples/arkode/C_serial/ark_heat1D.c b/examples/arkode/C_serial/ark_heat1D.c index 3505db8bb9..59ba532caf 100644 --- a/examples/arkode/C_serial/ark_heat1D.c +++ b/examples/arkode/C_serial/ark_heat1D.c @@ -151,10 +151,10 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Override any current settings with command-line options */ - flag = ARKodeSetFromCommandLine(arkode_mem, NULL, argc, argv); - if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } - flag = SUNLinSolSetFromCommandLine(LS, NULL, argc, argv); - if (check_flag(&flag, "ARKodeSetFromCommandLine", 1)) { return 1; } + flag = ARKodeSetOptions(arkode_mem, NULL, NULL, argc, argv); + if (check_flag(&flag, "ARKodeSetOptions", 1)) { return 1; } + flag = SUNLinSolSetOptions(LS, NULL, NULL, argc, argv); + if (check_flag(&flag, "SUNLinSolSetOptions", 1)) { return 1; } /* output mesh to disk */ FID = fopen("heat_mesh.txt", "w"); diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index 738804270d..4d0a4bbd56 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -552,8 +552,8 @@ int main(int argc, char* argv[]) /* Override any current settings with command-line options -- enforce the prefix "inner" */ - retval = ARKodeSetFromCommandLine(inner_arkode_mem, "inner", argc, argv); - if (check_retval(&retval, "ARKodeSetFromCommandLine", 1)) { return 1; } + retval = ARKodeSetOptions(inner_arkode_mem, "inner", "", argc, argv); + if (check_retval(&retval, "ARKodeSetOptions", 1)) { return 1; } /* Create inner stepper */ retval = ARKodeCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -707,8 +707,8 @@ int main(int argc, char* argv[]) /* Override any current settings with command-line options -- enforce the prefix "outer" */ - retval = ARKodeSetFromCommandLine(arkode_mem, "outer", argc, argv); - if (check_retval(&retval, "ARKodeSetFromCommandLine", 1)) { return 1; } + retval = ARKodeSetOptions(arkode_mem, "outer", "", argc, argv); + if (check_retval(&retval, "ARKodeSetOptions", 1)) { return 1; } /* * Integrate ODE diff --git a/examples/cvode/CXX_serial/cv_kpr.cpp b/examples/cvode/CXX_serial/cv_kpr.cpp index fe150f2c22..a9cbbac61d 100644 --- a/examples/cvode/CXX_serial/cv_kpr.cpp +++ b/examples/cvode/CXX_serial/cv_kpr.cpp @@ -111,8 +111,8 @@ int main(int argc, char* argv[]) if (check_flag(flag, "CVodeSetUserData")) { return 1; } // Override any current settings with command-line options - flag = CVodeSetFromCommandLine(cvode_mem, NULL, argc, argv); - if (check_flag(flag, "CVodeSetFromCommandLine")) { return 1; } + flag = CVodeSetOptions(cvode_mem, NULL, NULL, argc, argv); + if (check_flag(flag, "CVodeSetOptions")) { return 1; } // Initial time and fist output time sunrealtype tret = ZERO; diff --git a/examples/cvodes/serial/cvsAnalytic_mels.c b/examples/cvodes/serial/cvsAnalytic_mels.c index 24f249a3e9..2be25357a8 100644 --- a/examples/cvodes/serial/cvsAnalytic_mels.c +++ b/examples/cvodes/serial/cvsAnalytic_mels.c @@ -128,8 +128,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "CVodeSetLinearSolver", 1)) { return 1; } /* Override any current settings with command-line options */ - retval = CVodeSetFromCommandLine(cvode_mem, NULL, argc, argv); - if (check_retval(&retval, "CVodeSetFromCommandLine", 1)) { return (1); } + retval = CVodeSetOptions(cvode_mem, NULL, NULL, argc, argv); + if (check_retval(&retval, "CVodeSetOptions", 1)) { return (1); } /* In loop, call CVode, print results, and test for error. Break out of loop when NOUT preset output times have been reached. */ diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index 8eda72316d..9d8a702fbb 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -125,8 +125,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDASetLinearSolver", 1)) { return (1); } /* Override any current settings with command-line options */ - retval = IDASetFromCommandLine(ida_mem, NULL, argc, argv); - if (check_retval(&retval, "IDASetFromCommandLine", 1)) { return 1; } + retval = IDASetOptions(ida_mem, NULL, NULL, argc, argv); + if (check_retval(&retval, "IDASetOptions", 1)) { return 1; } /* In loop, call IDASolve, print results, and test for error. Stops when the final time has been reached. */ diff --git a/examples/idas/serial/idasAnalytic_mels.c b/examples/idas/serial/idasAnalytic_mels.c index 8a981d68c2..c79a2d4f76 100644 --- a/examples/idas/serial/idasAnalytic_mels.c +++ b/examples/idas/serial/idasAnalytic_mels.c @@ -125,8 +125,8 @@ int main(int argc, char* argv[]) if (check_retval(&retval, "IDASetLinearSolver", 1)) { return (1); } /* Override any current settings with command-line options */ - retval = IDASetFromCommandLine(ida_mem, NULL, argc, argv); - if (check_retval(&retval, "IDASetFromCommandLine", 1)) { return 1; } + retval = IDASetOptions(ida_mem, NULL, NULL, argc, argv); + if (check_retval(&retval, "IDASetOptions", 1)) { return 1; } /* In loop, call IDASolve, print results, and test for error. Stops when the final time has been reached. */ diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c index de7a60d11a..f3cf6c654d 100644 --- a/examples/kinsol/serial/kinRoberts_fp.c +++ b/examples/kinsol/serial/kinRoberts_fp.c @@ -149,8 +149,8 @@ int main(int argc, char* argv[]) /* Override any current settings with command-line options */ - retval = KINSetFromCommandLine(kmem, NULL, argc, argv); - if (check_retval(&retval, "KINSetFromCommandLine", 1)) { return (1); } + retval = KINSetOptions(kmem, NULL, NULL, argc, argv); + if (check_retval(&retval, "KINSetOptions", 1)) { return (1); } /* ------------- * Initial guess diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index dd0b62a06d..7a9287ff4f 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -219,8 +219,8 @@ typedef enum * -------------------------- */ /* Command-line control over ARKODE options */ -SUNDIALS_EXPORT int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, - int argc, char* argv[]); +SUNDIALS_EXPORT int ARKodeSetOptions(void* arkode_mem, const char* arkid, + const char* file_name, int argc, char* argv[]); /* Resize and Reset functions */ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, diff --git a/include/cvode/cvode.h b/include/cvode/cvode.h index 56fcfaccf2..771eb51aa1 100644 --- a/include/cvode/cvode.h +++ b/include/cvode/cvode.h @@ -119,8 +119,8 @@ SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun); /* Optional input functions */ -SUNDIALS_EXPORT int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, - int argc, char* argv[]); +SUNDIALS_EXPORT int CVodeSetOptions(void* cvode_mem, const char* cvid, + const char* file_name, int argc, char* argv[]); SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints); SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem, sunrealtype dgmax_lsetup); diff --git a/include/cvodes/cvodes.h b/include/cvodes/cvodes.h index 3959f13849..1e856d322a 100644 --- a/include/cvodes/cvodes.h +++ b/include/cvodes/cvodes.h @@ -190,8 +190,8 @@ SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun); /* Optional input functions */ -SUNDIALS_EXPORT int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, - int argc, char* argv[]); +SUNDIALS_EXPORT int CVodeSetOptions(void* cvode_mem, const char* cvid, + const char* file_name, int argc, char* argv[]); SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints); SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem, sunrealtype dgmax_lsetup); diff --git a/include/ida/ida.h b/include/ida/ida.h index ab4d54431d..335b44085b 100644 --- a/include/ida/ida.h +++ b/include/ida/ida.h @@ -115,8 +115,8 @@ SUNDIALS_EXPORT int IDAWFtolerances(void* ida_mem, IDAEwtFn efun); SUNDIALS_EXPORT int IDACalcIC(void* ida_mem, int icopt, sunrealtype tout1); /* Command-line control over scalar-valued set routines */ -SUNDIALS_EXPORT int IDASetFromCommandLine(void* ida_mem, const char* idaid, - int argc, char* argv[]); +SUNDIALS_EXPORT int IDASetOptions(void* ida_mem, const char* idaid, + const char* file_name, int argc, char* argv[]); /* Initial condition calculation optional input functions */ SUNDIALS_EXPORT int IDASetNonlinConvCoefIC(void* ida_mem, sunrealtype epiccon); diff --git a/include/idas/idas.h b/include/idas/idas.h index 6e51761c51..c378ac56d9 100644 --- a/include/idas/idas.h +++ b/include/idas/idas.h @@ -179,8 +179,8 @@ SUNDIALS_EXPORT int IDAWFtolerances(void* ida_mem, IDAEwtFn efun); SUNDIALS_EXPORT int IDACalcIC(void* ida_mem, int icopt, sunrealtype tout1); /* Command-line control over scalar-valued set routines */ -SUNDIALS_EXPORT int IDASetFromCommandLine(void* ida_mem, const char* idaid, - int argc, char* argv[]); +SUNDIALS_EXPORT int IDASetOptions(void* ida_mem, const char* idaid, + const char* file_name, int argc, char* argv[]); /* Initial condition calculation optional input functions */ SUNDIALS_EXPORT int IDASetNonlinConvCoefIC(void* ida_mem, sunrealtype epiccon); diff --git a/include/kinsol/kinsol.h b/include/kinsol/kinsol.h index 684cd60214..f85e0b692c 100644 --- a/include/kinsol/kinsol.h +++ b/include/kinsol/kinsol.h @@ -108,8 +108,8 @@ SUNDIALS_EXPORT int KINSol(void* kinmem, N_Vector uu, int strategy, N_Vector u_scale, N_Vector f_scale); /* Optional input functions */ -SUNDIALS_EXPORT int KINSetFromCommandLine(void* kinmem, const char* kinid, - int argc, char* argv[]); +SUNDIALS_EXPORT int KINSetOptions(void* kinmem, const char* kinid, + const char* file_name, int argc, char* argv[]); SUNDIALS_EXPORT int KINSetUserData(void* kinmem, void* user_data); SUNDIALS_EXPORT int KINSetDamping(void* kinmem, sunrealtype beta); SUNDIALS_EXPORT int KINSetMAA(void* kinmem, long int maa); diff --git a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h index a35b998097..f85fedd088 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_imexgus.h +++ b/include/sunadaptcontroller/sunadaptcontroller_imexgus.h @@ -74,6 +74,12 @@ SUNErrCode SUNAdaptController_SetDefaults_ImExGus(SUNAdaptController C); SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetOptions_ImExGus(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController C, sunrealtype bias); diff --git a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h index 38e8affd9c..5fadfc9f0d 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h +++ b/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -73,6 +73,12 @@ int SUNAdaptController_EstimateStepTol_MRIHTol( SUNDIALS_EXPORT int SUNAdaptController_Reset_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetOptions_MRIHTol(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]); + SUNDIALS_EXPORT int SUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController C); diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index 5fcbb86828..568bcfe5b1 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -74,6 +74,13 @@ SUNErrCode SUNAdaptController_EstimateStep_Soderlind(SUNAdaptController C, SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Reset_Soderlind(SUNAdaptController C); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetOptions_Soderlind(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, + char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C); diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 82bf500773..746aea9958 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -73,8 +73,8 @@ struct _generic_SUNAdaptController_Ops /* OPTIONAL for all SUNAdaptController implementations. */ SUNErrCode (*destroy)(SUNAdaptController C); SUNErrCode (*reset)(SUNAdaptController C); - SUNErrCode (*setfromcommandline)(SUNAdaptController C, const char* Cid, - int argc, char* argv[]); + SUNErrCode (*setoptions)(SUNAdaptController C, const char* Cid, + const char* file_name, int argc, char* argv[]); SUNErrCode (*setdefaults)(SUNAdaptController C); SUNErrCode (*write)(SUNAdaptController C, FILE* fptr); SUNErrCode (*seterrorbias)(SUNAdaptController C, sunrealtype bias); @@ -151,9 +151,10 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C); /* Function to update internal controller parameters from the command line. */ SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, - const char* Cid, int argc, - char* argv[]); +SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]); /* Function to set the controller parameters to their default values. */ SUNDIALS_EXPORT diff --git a/include/sundials/sundials_linearsolver.h b/include/sundials/sundials_linearsolver.h index 48fbdda109..c3cd942c29 100644 --- a/include/sundials/sundials_linearsolver.h +++ b/include/sundials/sundials_linearsolver.h @@ -118,8 +118,8 @@ struct _generic_SUNLinearSolver_Ops SUNErrCode (*setpreconditioner)(SUNLinearSolver, void*, SUNPSetupFn, SUNPSolveFn); SUNErrCode (*setscalingvectors)(SUNLinearSolver, N_Vector, N_Vector); - SUNErrCode (*setfromcommandline)(SUNLinearSolver, const char* Cid, int argc, - char* argv[]); + SUNErrCode (*setoptions)(SUNLinearSolver, const char* LSid, + const char* file_name, int argc, char* argv[]); SUNErrCode (*setzeroguess)(SUNLinearSolver, sunbooleantype); SUNErrCode (*initialize)(SUNLinearSolver); int (*setup)(SUNLinearSolver, SUNMatrix); @@ -171,8 +171,8 @@ SUNErrCode SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1, N_Vector s2); SUNDIALS_EXPORT -SUNErrCode SUNLinSolSetFromCommandLine(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +SUNErrCode SUNLinSolSetOptions(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess(SUNLinearSolver S, sunbooleantype onoff); diff --git a/include/sundials/sundials_nonlinearsolver.h b/include/sundials/sundials_nonlinearsolver.h index 829ea26c2c..ca1566cd8e 100644 --- a/include/sundials/sundials_nonlinearsolver.h +++ b/include/sundials/sundials_nonlinearsolver.h @@ -109,6 +109,8 @@ struct _generic_SUNNonlinearSolver_Ops SUNErrCode (*setlsetupfn)(SUNNonlinearSolver, SUNNonlinSolLSetupFn); SUNErrCode (*setlsolvefn)(SUNNonlinearSolver, SUNNonlinSolLSolveFn); SUNErrCode (*setctestfn)(SUNNonlinearSolver, SUNNonlinSolConvTestFn, void*); + SUNErrCode (*setoptions)(SUNNonlinearSolver NLS, const char* NLSid, + const char* file_name, int argc, char* argv[]); SUNErrCode (*setmaxiters)(SUNNonlinearSolver, int); SUNErrCode (*getnumiters)(SUNNonlinearSolver, long int*); SUNErrCode (*getcuriter)(SUNNonlinearSolver, int*); @@ -170,6 +172,10 @@ SUNErrCode SUNNonlinSolSetConvTestFn(SUNNonlinearSolver NLS, SUNNonlinSolConvTestFn CTestFn, void* ctest_data); +SUNDIALS_EXPORT +SUNErrCode SUNNonlinSolSetOptions(SUNNonlinearSolver NLS, const char* NLSid, + const char* file_name, int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNNonlinSolSetMaxIters(SUNNonlinearSolver NLS, int maxiters); diff --git a/include/sunlinsol/sunlinsol_klu.h b/include/sunlinsol/sunlinsol_klu.h index 35591bc398..4b297530fd 100644 --- a/include/sunlinsol/sunlinsol_klu.h +++ b/include/sunlinsol/sunlinsol_klu.h @@ -130,6 +130,10 @@ SUNDIALS_EXPORT sun_klu_common* SUNLinSol_KLUGetCommon(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_KLU(SUNLinearSolver S); SUNDIALS_EXPORT SUNLinearSolver_ID SUNLinSolGetID_KLU(SUNLinearSolver S); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_KLU(SUNLinearSolver S, + const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolInitialize_KLU(SUNLinearSolver S); SUNDIALS_EXPORT int SUNLinSolSetup_KLU(SUNLinearSolver S, SUNMatrix A); SUNDIALS_EXPORT int SUNLinSolSolve_KLU(SUNLinearSolver S, SUNMatrix A, diff --git a/include/sunlinsol/sunlinsol_magmadense.h b/include/sunlinsol/sunlinsol_magmadense.h index f36ea680cc..b3089c7bb8 100644 --- a/include/sunlinsol/sunlinsol_magmadense.h +++ b/include/sunlinsol/sunlinsol_magmadense.h @@ -59,6 +59,10 @@ typedef struct _SUNLinearSolverContent_MagmaDense* SUNLinearSolverContent_MagmaD SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_MagmaDense(N_Vector y, SUNMatrix A, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_MagmaDense(SUNLinearSolver S, + const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT int SUNLinSol_MagmaDense_SetAsync(SUNLinearSolver S, sunbooleantype onoff); diff --git a/include/sunlinsol/sunlinsol_pcg.h b/include/sunlinsol/sunlinsol_pcg.h index bef14ab107..ba9684d13f 100644 --- a/include/sunlinsol/sunlinsol_pcg.h +++ b/include/sunlinsol/sunlinsol_pcg.h @@ -99,6 +99,10 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors_PCG(SUNLinearSolver S, N_Vector s, N_Vector nul); +SUNDIALS_EXPORT +SUNErrCode SUNLinSolSetOptions_PCG(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess_PCG(SUNLinearSolver S, sunbooleantype onoff); diff --git a/include/sunlinsol/sunlinsol_spbcgs.h b/include/sunlinsol/sunlinsol_spbcgs.h index dbebee6567..fbebf52919 100644 --- a/include/sunlinsol/sunlinsol_spbcgs.h +++ b/include/sunlinsol/sunlinsol_spbcgs.h @@ -93,6 +93,10 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetPreconditioner_SPBCGS(SUNLinearSolver S, SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors_SPBCGS(SUNLinearSolver S, N_Vector s1, N_Vector s2); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SPBCGS(SUNLinearSolver S, + const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess_SPBCGS(SUNLinearSolver S, sunbooleantype onoff); SUNDIALS_EXPORT int SUNLinSolSetup_SPBCGS(SUNLinearSolver S, SUNMatrix A); diff --git a/include/sunlinsol/sunlinsol_spfgmr.h b/include/sunlinsol/sunlinsol_spfgmr.h index f9ba1929ad..6132d2366c 100644 --- a/include/sunlinsol/sunlinsol_spfgmr.h +++ b/include/sunlinsol/sunlinsol_spfgmr.h @@ -103,6 +103,9 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetPreconditioner_SPFGMR(SUNLinearSolver S, SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver S, N_Vector s1, N_Vector s2); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SPFGMR(SUNLinearSolver S, const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess_SPFGMR(SUNLinearSolver S, sunbooleantype onoff); SUNDIALS_EXPORT int SUNLinSolSetup_SPFGMR(SUNLinearSolver S, SUNMatrix A); diff --git a/include/sunlinsol/sunlinsol_spgmr.h b/include/sunlinsol/sunlinsol_spgmr.h index 827afb0055..f79e6ccede 100644 --- a/include/sunlinsol/sunlinsol_spgmr.h +++ b/include/sunlinsol/sunlinsol_spgmr.h @@ -103,6 +103,10 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetPreconditioner_SPGMR(SUNLinearSolver S, SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors_SPGMR(SUNLinearSolver S, N_Vector s1, N_Vector s2); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SPGMR(SUNLinearSolver S, + const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess_SPGMR(SUNLinearSolver S, sunbooleantype onff); SUNDIALS_EXPORT int SUNLinSolSetup_SPGMR(SUNLinearSolver S, SUNMatrix A); diff --git a/include/sunlinsol/sunlinsol_sptfqmr.h b/include/sunlinsol/sunlinsol_sptfqmr.h index 437874fd15..5e67370244 100644 --- a/include/sunlinsol/sunlinsol_sptfqmr.h +++ b/include/sunlinsol/sunlinsol_sptfqmr.h @@ -95,6 +95,10 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetPreconditioner_SPTFQMR(SUNLinearSolver S, SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors_SPTFQMR(SUNLinearSolver S, N_Vector s1, N_Vector s2); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SPTFQMR(SUNLinearSolver S, + const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess_SPTFQMR(SUNLinearSolver S, sunbooleantype onoff); SUNDIALS_EXPORT int SUNLinSolSetup_SPTFQMR(SUNLinearSolver S, SUNMatrix A); diff --git a/include/sunlinsol/sunlinsol_superlumt.h b/include/sunlinsol/sunlinsol_superlumt.h index 4bdb08ef04..d71a213bcc 100644 --- a/include/sunlinsol/sunlinsol_superlumt.h +++ b/include/sunlinsol/sunlinsol_superlumt.h @@ -95,6 +95,10 @@ typedef struct _SUNLinearSolverContent_SuperLUMT* SUNLinearSolverContent_SuperLU SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, SUNContext sunctx); +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SuperLUMT(SUNLinearSolver S, + const char* LSid, + const char* file_name, + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, int ordering_choice); SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT(SUNLinearSolver S); diff --git a/include/sunnonlinsol/sunnonlinsol_fixedpoint.h b/include/sunnonlinsol/sunnonlinsol_fixedpoint.h index a8682d49b5..02351aefc6 100644 --- a/include/sunnonlinsol/sunnonlinsol_fixedpoint.h +++ b/include/sunnonlinsol/sunnonlinsol_fixedpoint.h @@ -103,6 +103,12 @@ SUNErrCode SUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver NLS, SUNNonlinSolConvTestFn CTestFn, void* ctest_data); +SUNDIALS_EXPORT +SUNErrCode SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver NLS, + const char* NLSid, + const char* file_name, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNNonlinSolSetMaxIters_FixedPoint(SUNNonlinearSolver NLS, int maxiters); diff --git a/include/sunnonlinsol/sunnonlinsol_newton.h b/include/sunnonlinsol/sunnonlinsol_newton.h index 0bdac3ccde..b99c7ffb17 100644 --- a/include/sunnonlinsol/sunnonlinsol_newton.h +++ b/include/sunnonlinsol/sunnonlinsol_newton.h @@ -100,6 +100,12 @@ SUNErrCode SUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver NLS, SUNNonlinSolConvTestFn CTestFn, void* ctest_data); +SUNDIALS_EXPORT +SUNErrCode SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver NLS, + const char* NLSid, + const char* file_name, + int argc, char* argv[]); + SUNDIALS_EXPORT SUNErrCode SUNNonlinSolSetMaxIters_Newton(SUNNonlinearSolver NLS, int maxiters); diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index e6d0575836..45a6b94170 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -1548,7 +1548,7 @@ ARKodeMem arkCreate(SUNContext sunctx) ark_mem->step_setstagepredictfn = NULL; ark_mem->step_getnumrhsevals = NULL; ark_mem->step_setstepdirection = NULL; - ark_mem->step_setfromcommandline = NULL; + ark_mem->step_setoption = NULL; ark_mem->step_getnumlinsolvsetups = NULL; ark_mem->step_setadaptcontroller = NULL; ark_mem->step_getestlocalerrors = NULL; diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 998b8a3a4f..9f5e6f312f 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -114,7 +114,7 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, ark_mem->step_printmem = arkStep_PrintMem; ark_mem->step_setdefaults = arkStep_SetDefaults; ark_mem->step_computestate = arkStep_ComputeState; - ark_mem->step_setfromcommandline = arkStep_SetFromCommandLine; + ark_mem->step_setoption = arkStep_SetOption; ark_mem->step_setrelaxfn = arkStep_SetRelaxFn; ark_mem->step_setorder = arkStep_SetOrder; ark_mem->step_setnonlinearsolver = arkStep_SetNonlinearSolver; diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index b3eca834e2..ba99f8dea3 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -195,8 +195,8 @@ int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int arkStep_TakeStep_ERK_Adjoint(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used); +int arkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used); int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int arkStep_SetDefaults(ARKodeMem ark_mem); int arkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index aae379d7ee..3e52332cc9 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -630,26 +630,26 @@ int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, ===============================================================*/ /*--------------------------------------------------------------- - arkStep_SetFromCommandLine: + arkStep_SetOption: - Provides command-line control over ARKStep-specific "set" routines. + Provides string-based control over ARKStep-specific "set" routines. ---------------------------------------------------------------*/ -int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used) +int arkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ + /* Set lists of keys, and the corresponding set routines */ static const struct sunKeyTwoCharPair twochar_pairs[] = { {"table_names", ARKStepSetTableName}}; static const int num_twochar_keys = sizeof(twochar_pairs) / sizeof(*twochar_pairs); static const struct sunKeyActionPair action_pairs[] = - {{"set_explicit", ARKStepSetExplicit}, - {"set_implicit", ARKStepSetImplicit}, + {{"explicit", ARKStepSetExplicit}, + {"implicit", ARKStepSetImplicit}, {"set_imex", ARKStepSetImEx}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - /* check all "twochar" command-line options */ + /* check all "twochar" keys */ int j, retval; retval = sunCheckAndSetTwoCharArgs((void*)ark_mem, argidx, argv, offset, twochar_pairs, num_twochar_keys, arg_used, @@ -663,7 +663,7 @@ int arkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], } if (*arg_used) { return ARK_SUCCESS; } - /* check all action command-line options */ + /* check all action keys */ retval = sunCheckAndSetActionArgs((void*)ark_mem, argidx, argv, offset, action_pairs, num_action_keys, arg_used, &j); if (retval != SUN_SUCCESS) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index f27ab01c97..9942a978a9 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -24,14 +24,42 @@ #include "arkode_impl.h" #include "sundials_cli.h" +static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, + int argc, char* argv[]); + + /*--------------------------------------------------------------- - ARKodeSetFromCommandLine: + ARKodeSetOptions: - Parses the command line to control scalar-valued ARKODE options. + Sets ARKODE options using strings. ---------------------------------------------------------------*/ -int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, - char* argv[]) +int ARKodeSetOptions(void* arkode_mem, const char* arkid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + int retval = ARK_ILL_INPUT; + arkProcessError(arkode_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; + } + + if (argc > 0 && argv != NULL) + { + int retval = arkSetFromCommandLine(arkode_mem, arkid, argc, argv); + if (retval != ARK_SUCCESS) { return retval; } + } + + return ARK_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to control ARKODE options from the command line + */ + +static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, + int argc, char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -116,7 +144,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* if arkid is supplied, skip command-line arguments that do not begin with arkid; else, skip command-line arguments that do not begin with "arkode." */ size_t offset; - if (arkid != NULL) + if (arkid != NULL && strlen(arkid) > 0) { if (strncmp(argv[idx], arkid, strlen(arkid)) != 0) { continue; } offset = strlen(arkid) + 1; @@ -135,7 +163,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_pairs[j].key); return retval; } @@ -148,7 +176,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", long_pairs[j].key); return retval; } @@ -161,7 +189,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", real_pairs[j].key); return retval; } @@ -175,7 +203,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", tworeal_pairs[j].key); return retval; } @@ -189,7 +217,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", action_pairs[j].key); return retval; } @@ -216,7 +244,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", + "error setting key: %s %s", argv[idx - 1], argv[idx]); return retval; } @@ -224,7 +252,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, continue; } - if (strcmp(argv[idx] + offset, "accum_error_type") == 0) + if (strcmp(argv[idx] + offset, "accumulated_error_type") == 0) { idx++; retval = ARK_ILL_INPUT; @@ -247,7 +275,7 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s %s", + "error setting key: %s %s", argv[idx - 1], argv[idx]); return retval; } @@ -264,17 +292,16 @@ int ARKodeSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* Call stepper-specific SetFromCommandLine routine (if supplied) to process this command-line argument */ - if (ark_mem->step_setfromcommandline) + if (ark_mem->step_setoption) { - retval = ark_mem->step_setfromcommandline(ark_mem, &idx, argv, offset, - &arg_used); + retval = ark_mem->step_setoption(ark_mem, &idx, argv, offset, &arg_used); if (retval != ARK_SUCCESS) { return retval; } if (arg_used) { continue; } } /* warn for uninterpreted arkid.X arguments */ arkProcessError(ark_mem, ARK_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[idx]); + "WARNING: key %s was not handled\n", argv[idx]); } /* Call ARKodeWriteParameters (if requested) now that all diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 62ddf56205..829011d398 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -99,7 +99,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) ark_mem->step_resize = erkStep_Resize; ark_mem->step_free = erkStep_Free; ark_mem->step_printmem = erkStep_PrintMem; - ark_mem->step_setfromcommandline = erkStep_SetFromCommandLine; + ark_mem->step_setoption = erkStep_SetOption; ark_mem->step_setdefaults = erkStep_SetDefaults; ark_mem->step_setrelaxfn = erkStep_SetRelaxFn; ark_mem->step_setorder = erkStep_SetOrder; diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index e3416ce247..5a87b0d32d 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -87,8 +87,8 @@ int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int erkStep_TakeStep_Adjoint(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used); +int erkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used); int erkStep_SetDefaults(ARKodeMem ark_mem); int erkStep_SetOrder(ARKodeMem ark_mem, int ord); int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index bc530a1535..01ee6ab2e6 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -257,26 +257,26 @@ int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, ===============================================================*/ /*--------------------------------------------------------------- - erkStep_SetFromCommandLine: + erkStep_SetOption: - Provides command-line control over ERKStep-specific "set" routines. + Provides string-based control over ERKStep-specific "set" routines. ---------------------------------------------------------------*/ -int erkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used) +int erkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ + /* Set lists of keys, and the corresponding set routines */ static const struct sunKeyCharPair char_pairs[] = { {"table_name", ERKStepSetTableName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); - /* check all "char" command-line options */ + /* check all "char" keys */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, char_pairs, num_char_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", char_pairs[j].key); + "error setting key: %s", char_pairs[j].key); return retval; } diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index c53b670087..6399ec13f1 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -222,9 +222,9 @@ typedef int (*ARKTimestepSetStepDirection)(ARKodeMem ark_mem, sunrealtype stepdir); typedef int (*ARKTimestepSetUseCompensatedSums)(ARKodeMem ark_mem, sunbooleantype onoff); -typedef int (*ARKTimestepSetFromCommandLine)(ARKodeMem ark_mem, int* argidx, - char* argv[], size_t offset, - sunbooleantype* arg_used); +typedef int (*ARKTimestepSetOption)(ARKodeMem ark_mem, int* argidx, + char* argv[], size_t offset, + sunbooleantype* arg_used); /* time stepper interface functions -- temporal adaptivity */ typedef int (*ARKTimestepGetEstLocalErrors)(ARKodeMem ark_mem, N_Vector ele); @@ -416,7 +416,7 @@ struct ARKodeMemRec ARKTimestepGetNumRhsEvals step_getnumrhsevals; ARKTimestepSetStepDirection step_setstepdirection; ARKTimestepSetUseCompensatedSums step_setusecompensatedsums; - ARKTimestepSetFromCommandLine step_setfromcommandline; + ARKTimestepSetOption step_setoption; /* Time stepper module -- temporal adaptivity */ sunbooleantype step_supports_adaptive; diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 01519c0543..19a7e505f6 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -173,7 +173,7 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, ark_mem->step_writeparameters = lsrkStep_WriteParameters; ark_mem->step_free = lsrkStep_Free; ark_mem->step_printmem = lsrkStep_PrintMem; - ark_mem->step_setfromcommandline = lsrkStep_SetFromCommandLine; + ark_mem->step_setoption = lsrkStep_SetOption; ark_mem->step_setdefaults = lsrkStep_SetDefaults; ark_mem->step_getnumrhsevals = lsrkStep_GetNumRhsEvals; ark_mem->step_getestlocalerrors = lsrkStep_GetEstLocalErrors; diff --git a/src/arkode/arkode_lsrkstep_impl.h b/src/arkode/arkode_lsrkstep_impl.h index bfea89f2d1..05d104388d 100644 --- a/src/arkode/arkode_lsrkstep_impl.h +++ b/src/arkode/arkode_lsrkstep_impl.h @@ -186,8 +186,8 @@ int lsrkStep_TakeStepSSPs3(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr int lsrkStep_TakeStepSSP43(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int lsrkStep_TakeStepSSP104(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used); +int lsrkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used); int lsrkStep_SetDefaults(ARKodeMem ark_mem); int lsrkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); int lsrkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); diff --git a/src/arkode/arkode_lsrkstep_io.c b/src/arkode/arkode_lsrkstep_io.c index 21d68257b4..6a61e6efda 100644 --- a/src/arkode/arkode_lsrkstep_io.c +++ b/src/arkode/arkode_lsrkstep_io.c @@ -493,17 +493,17 @@ int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max) ===============================================================*/ /*--------------------------------------------------------------- - lsrkStep_SetFromCommandLine: + lsrkStep_SetOption: - Provides command-line control over LSRKStep-specific "set" routines. + Provides string-based control over LSRKStep-specific "set" routines. ---------------------------------------------------------------*/ -int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used) +int lsrkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ + /* Set lists of keys, and the corresponding set routines */ static const struct sunKeyCharPair char_pairs[] = - {{"sts_method", LSRKStepSetSTSMethodByName}, - {"ssp_method", LSRKStepSetSSPMethodByName}}; + {{"sts_method_name", LSRKStepSetSTSMethodByName}, + {"ssp_method_name", LSRKStepSetSSPMethodByName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); static const struct sunKeyLongPair long_pairs[] = { @@ -520,47 +520,47 @@ int lsrkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], {"dom_eig_safety_factor", LSRKStepSetDomEigSafetyFactor}}; static const int num_real_keys = sizeof(real_pairs) / sizeof(*real_pairs); - /* check all "char" command-line options */ + /* check all "char" keys */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, char_pairs, num_char_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", char_pairs[j].key); + "error setting key: %s", char_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } - /* check all "long int" command-line options */ + /* check all "long int" keys */ retval = sunCheckAndSetLongArgs((void*)ark_mem, argidx, argv, offset, long_pairs, num_long_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } - /* check all "int" command-line options */ + /* check all "int" keys */ retval = sunCheckAndSetIntArgs((void*)ark_mem, argidx, argv, offset, int_pairs, num_int_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } - /* check all "real" command-line options */ + /* check all "real" keys */ retval = sunCheckAndSetRealArgs((void*)ark_mem, argidx, argv, offset, real_pairs, num_real_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 576714f437..2b7536a753 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -111,7 +111,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, ark_mem->step_printmem = mriStep_PrintMem; ark_mem->step_setdefaults = mriStep_SetDefaults; ark_mem->step_computestate = mriStep_ComputeState; - ark_mem->step_setfromcommandline = mriStep_SetFromCommandLine; + ark_mem->step_setoption = mriStep_SetOption; ark_mem->step_setorder = mriStep_SetOrder; ark_mem->step_setnonlinearsolver = mriStep_SetNonlinearSolver; ark_mem->step_setlinear = mriStep_SetLinear; diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 7a158c8327..df14e3dbd4 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -230,8 +230,8 @@ int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used); +int mriStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used); int mriStep_SetAdaptController(ARKodeMem ark_mem, SUNAdaptController C); int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); int mriStep_SetDefaults(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index e0c9c026ca..ffedd02311 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -250,26 +250,26 @@ int MRIStepGetNumInnerStepperFails(void* arkode_mem, long int* inner_fails) ===============================================================*/ /*--------------------------------------------------------------- - mriStep_SetFromCommandLine: + mriStep_SetOption: Provides command-line control over MRIStep-specific "set" routines. ---------------------------------------------------------------*/ -int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used) +int mriStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) { /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling table; however, these may be specified by name, so here we'll support - a command-line argument to specify the MRIStepCoupling table name, + a key to specify the MRIStepCoupling table name, create the table with that name, attach it to MRIStep (who copies its values), and then free the table. */ - if (strcmp(argv[*argidx] + offset, "mristep_coupling_table") == 0) + if (strcmp(argv[*argidx] + offset, "coupling_table_name") == 0) { (*argidx)++; MRIStepCoupling Coupling = MRIStepCoupling_LoadTableByName(argv[*argidx]); if (Coupling == NULL) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "error setting command-line argument %s %s (invalid table name)", + __FILE__, "error setting key %s %s (invalid table name)", argv[(*argidx) - 1], argv[*argidx]); return ARK_ILL_INPUT; } @@ -278,7 +278,7 @@ int mriStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, - __FILE__, "error setting command-line argument %s %s (SetCoupling failed)", + __FILE__, "error setting key %s %s (SetCoupling failed)", argv[(*argidx) - 1], argv[*argidx]); return retval; } diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index 35b18d6414..9c9431b701 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -114,7 +114,7 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, ark_mem->step_printallstats = sprkStep_PrintAllStats; ark_mem->step_writeparameters = sprkStep_WriteParameters; ark_mem->step_setusecompensatedsums = sprkStep_SetUseCompensatedSums; - ark_mem->step_setfromcommandline = sprkStep_SetFromCommandLine; + ark_mem->step_setoption = sprkStep_SetOption; ark_mem->step_resize = sprkStep_Resize; ark_mem->step_free = sprkStep_Free; ark_mem->step_setdefaults = sprkStep_SetDefaults; diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index 795777b035..d56f3c1c0a 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -73,8 +73,8 @@ int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); -int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used); +int sprkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used); int sprkStep_SetUserData(ARKodeMem ark_mem, void* user_data); int sprkStep_SetDefaults(ARKodeMem ark_mem); int sprkStep_SetOrder(ARKodeMem ark_mem, int ord); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index b1cc097b3b..dc34ab28e7 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -196,14 +196,15 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) ===============================================================*/ /*--------------------------------------------------------------- - sprkStep_SetFromCommandLine: + sprkStep_SetOption: - Provides command-line control over SPRKStep-specific "set" routines. + Provides string-based control over SPRKStep-specific "set" + routines. ---------------------------------------------------------------*/ -int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used) +int sprkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) { - /* Set lists of command-line arguments, and the corresponding set routines */ + /* Set lists of keys, and the corresponding set routines */ static const struct sunKeyCharPair char_pairs[] = { {"method_name", SPRKStepSetMethodName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); @@ -212,25 +213,25 @@ int sprkStep_SetFromCommandLine(ARKodeMem ark_mem, int* argidx, char* argv[], {"use_compensated_sums", SPRKStepSetUseCompensatedSums}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - /* check all "char" command-line options */ + /* check all "char" keys */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, char_pairs, num_char_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", char_pairs[j].key); + "error setting key: %s", char_pairs[j].key); return retval; } if (*arg_used) { return ARK_SUCCESS; } - /* check all "int" command-line options */ + /* check all "int" keys */ retval = sunCheckAndSetIntArgs((void*)ark_mem, argidx, argv, offset, int_pairs, num_int_keys, arg_used, &j); if (retval != SUN_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 666a68828e..279c9f935d 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -25,14 +25,41 @@ #include "cvode_impl.h" #include "sundials_cli.h" +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, + int argc, char* argv[]); + /*--------------------------------------------------------------- - CVodeSetFromCommandLine: + CVodeSetOptions: - Parses the command line to control scalar-valued CVODE options. + Sets CVODE options using strings. ---------------------------------------------------------------*/ -int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, - char* argv[]) +int CVodeSetOptions(void* cvode_mem, const char* cvid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + int retval = CV_ILL_INPUT; + cvProcessError(cvode_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; + } + + if (argc > 0 && argv != NULL) + { + int retval = cvSetFromCommandLine(cvode_mem, cvid, argc, argv); + if (retval != CV_SUCCESS) { return retval; } + } + + return CV_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to control CVODE options from the command line + */ + +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, + int argc, char* argv[]) { CVodeMem cv_mem; if (cvode_mem == NULL) @@ -108,7 +135,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* if cvid is supplied, skip command-line arguments that do not begin with cvid; else, skip command-line arguments that do not begin with "cvode." */ size_t offset; - if (cvid != NULL) + if (cvid != NULL && strlen(cvid) > 0) { if (strncmp(argv[idx], cvid, strlen(cvid)) != 0) { continue; } offset = strlen(cvid) + 1; @@ -127,7 +154,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (arg_used) continue; @@ -139,7 +166,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", long_pairs[j].key); return retval; } @@ -152,7 +179,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", real_pairs[j].key); return retval; } @@ -166,7 +193,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", tworeal_pairs[j].key); return retval; } @@ -180,7 +207,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", action_pairs[j].key); return retval; } @@ -188,7 +215,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* warn for uninterpreted cvid.X arguments */ cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[idx]); + "WARNING: key %s was not handled\n", argv[idx]); } return (CV_SUCCESS); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 629c34e84d..f4b9ffe3a7 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -25,14 +25,41 @@ #include "cvodes_impl.h" #include "sundials_cli.h" +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, + int argc, char* argv[]); + /*--------------------------------------------------------------- - CVodeSetFromCommandLine: + CVodeSetOptions: - Parses the command line to control scalar-valued CVODE options. + Sets CVODE options using strings. ---------------------------------------------------------------*/ -int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, - char* argv[]) +int CVodeSetOptions(void* cvode_mem, const char* cvid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + int retval = CV_ILL_INPUT; + cvProcessError(cvode_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; + } + + if (argc > 0 && argv != NULL) + { + int retval = cvSetFromCommandLine(cvode_mem, cvid, argc, argv); + if (retval != CV_SUCCESS) { return retval; } + } + + return CV_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to control CVODE options from the command line + */ + +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, + int argc, char* argv[]) { CVodeMem cv_mem; if (cvode_mem == NULL) @@ -140,7 +167,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* if cvid is supplied, skip command-line arguments that do not begin with cvid; else, skip command-line arguments that do not begin with "cvodes." */ size_t offset; - if (cvid != NULL) + if (cvid != NULL && strlen(cvid) > 0) { if (strncmp(argv[idx], cvid, strlen(cvid)) != 0) { continue; } offset = strlen(cvid) + 1; @@ -159,7 +186,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (arg_used) continue; @@ -171,7 +198,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", long_pairs[j].key); return retval; } @@ -184,7 +211,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", real_pairs[j].key); return retval; } @@ -198,7 +225,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", twoint_pairs[j].key); return retval; } @@ -212,7 +239,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", tworeal_pairs[j].key); return retval; } @@ -226,7 +253,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", action_pairs[j].key); return retval; } @@ -240,7 +267,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_real_pairs[j].key); return retval; } @@ -254,7 +281,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_long_pairs[j].key); return retval; } @@ -269,7 +296,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_real_real_pairs[j].key); return retval; } @@ -277,7 +304,7 @@ int CVodeSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* warn for uninterpreted cvid.X arguments */ cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[idx]); + "WARNING: key %s was not handled\n", argv[idx]); } return (CV_SUCCESS); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 94759786d7..e83fc6ee74 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -24,14 +24,41 @@ #include "ida_impl.h" #include "sundials_cli.h" +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, + int argc, char* argv[]); + /*--------------------------------------------------------------- - IDASetFromCommandLine: + IDASetOptions: - Parses the command line to control scalar-valued IDA options. + Sets IDA options using strings. ---------------------------------------------------------------*/ -int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, - char* argv[]) +int IDASetOptions(void* ida_mem, const char* idaid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + int retval = IDA_ILL_INPUT; + IDAProcessError(ida_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; + } + + if (argc > 0 && argv != NULL) + { + int retval = idaSetFromCommandLine(ida_mem, idaid, argc, argv); + if (retval != IDA_SUCCESS) { return retval; } + } + + return IDA_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to control IDA options from the command line + */ + +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, + int argc, char* argv[]) { IDAMem IDA_mem; if (ida_mem == NULL) @@ -46,7 +73,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {{"max_num_steps_ic", IDASetMaxNumStepsIC}, {"max_num_jacs_ic", IDASetMaxNumJacsIC}, {"max_num_iters_ic", IDASetMaxNumItersIC}, - {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"line_search_off_ic", IDASetLineSearchOffIC}, {"max_backs_ic", IDASetMaxBacksIC}, {"max_order", IDASetMaxOrd}, {"max_err_test_fails", IDASetMaxErrTestFails}, @@ -99,7 +126,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* if idaid is supplied, skip command-line arguments that do not begin with idaid; else, skip command-line arguments that do not begin with "ida." */ size_t offset; - if (idaid != NULL) + if (idaid != NULL && strlen(idaid) > 0) { if (strncmp(argv[idx], idaid, strlen(idaid)) != 0) { continue; } offset = strlen(idaid) + 1; @@ -118,7 +145,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_pairs[j].key); return retval; } @@ -131,7 +158,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", long_pairs[j].key); return retval; } @@ -144,7 +171,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", real_pairs[j].key); return retval; } @@ -158,7 +185,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", tworeal_pairs[j].key); return retval; } @@ -172,7 +199,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", action_pairs[j].key); return retval; } @@ -180,7 +207,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* warn for uninterpreted idaid.X arguments */ IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[idx]); + "WARNING: key %s was not handled\n", argv[idx]); } return (IDA_SUCCESS); diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 0de6064371..8003c14e67 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -24,14 +24,41 @@ #include "idas_impl.h" #include "sundials_cli.h" +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, + int argc, char* argv[]); + /*--------------------------------------------------------------- - IDASetFromCommandLine: + IDASetOptions: - Parses the command line to control scalar-valued IDA options. + Sets IDA options using strings. ---------------------------------------------------------------*/ -int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, - char* argv[]) +int IDASetOptions(void* ida_mem, const char* idaid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + int retval = IDA_ILL_INPUT; + IDAProcessError(ida_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; + } + + if (argc > 0 && argv != NULL) + { + int retval = idaSetFromCommandLine(ida_mem, idaid, argc, argv); + if (retval != IDA_SUCCESS) { return retval; } + } + + return IDA_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to control IDA options from the command line + */ + +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, + int argc, char* argv[]) { IDAMem IDA_mem; if (ida_mem == NULL) @@ -46,7 +73,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, {{"max_num_steps_ic", IDASetMaxNumStepsIC}, {"max_num_jacs_ic", IDASetMaxNumJacsIC}, {"max_num_iters_ic", IDASetMaxNumItersIC}, - {"linesearch_off_ic", IDASetLineSearchOffIC}, + {"line_search_off_ic", IDASetLineSearchOffIC}, {"max_backs_ic", IDASetMaxBacksIC}, {"max_order", IDASetMaxOrd}, {"max_err_test_fails", IDASetMaxErrTestFails}, @@ -134,7 +161,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* if idaid is supplied, skip command-line arguments that do not begin with idaid; else, skip command-line arguments that do not begin with "idas." */ size_t offset; - if (idaid != NULL) + if (idaid != NULL && strlen(idaid) > 0) { if (strncmp(argv[idx], idaid, strlen(idaid)) != 0) { continue; } offset = strlen(idaid) + 1; @@ -153,7 +180,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_pairs[j].key); return retval; } @@ -166,7 +193,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", long_pairs[j].key); return retval; } @@ -179,7 +206,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", real_pairs[j].key); return retval; } @@ -193,7 +220,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", twoint_pairs[j].key); return retval; } @@ -207,7 +234,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", tworeal_pairs[j].key); return retval; } @@ -221,7 +248,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", action_pairs[j].key); return retval; } @@ -235,7 +262,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_real_pairs[j].key); return retval; } @@ -249,7 +276,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_long_pairs[j].key); return retval; } @@ -264,7 +291,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_real_real_pairs[j].key); return retval; } @@ -272,7 +299,7 @@ int IDASetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* warn for uninterpreted idaid.X arguments */ IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[idx]); + "WARNING: key %s was not handled\n", argv[idx]); } return (IDA_SUCCESS); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index a2f68ece26..083d3cea3a 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -24,13 +24,41 @@ #include "kinsol_impl.h" #include "sundials_cli.h" +static int kinSetFromCommandLine(void* kinmem, const char* kinid, + int argc, char* argv[]); + /*--------------------------------------------------------------- - KINSetFromCommandLine: + KINSetOptions: - Parses the command line to control scalar-valued KINSOL options. + Sets KINSOL options using strings. ---------------------------------------------------------------*/ -int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[]) +int KINSetOptions(void* kinmem, const char* kinid, const char* file_name, + int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + int retval = KIN_ILL_INPUT; + KINProcessError(kinmem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; + } + + if (argc > 0 && argv != NULL) + { + int retval = kinSetFromCommandLine(kinmem, kinid, argc, argv); + if (retval != KIN_SUCCESS) { return retval; } + } + + return KIN_SUCCESS; +} + +/* ----------------------------------------------------------------- + * Function to control KINSOL options from the command line + */ + +static int kinSetFromCommandLine(void* kinmem, const char* kinid, + int argc, char* argv[]) { KINMem kin_mem; if (kinmem == NULL) @@ -84,7 +112,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* if kinid is supplied, skip command-line arguments that do not begin with kinid; else, skip command-line arguments that do not begin with "kinsol." */ size_t offset; - if (kinid != NULL) + if (kinid != NULL && strlen(kinid) > 0) { if (strncmp(argv[idx], kinid, strlen(kinid)) != 0) { continue; } offset = strlen(kinid) + 1; @@ -103,7 +131,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", int_pairs[j].key); return retval; } @@ -116,7 +144,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", long_pairs[j].key); return retval; } @@ -129,7 +157,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", real_pairs[j].key); return retval; } @@ -143,7 +171,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting command-line argument: %s", + "error setting key: %s", tworeal_pairs[j].key); return retval; } @@ -151,7 +179,7 @@ int KINSetFromCommandLine(void* kinmem, const char* kinid, int argc, char* argv[ /* warn for uninterpreted kinid.X arguments */ KINProcessError(kin_mem, KIN_WARNING, __LINE__, __func__, __FILE__, - "WARNING: argument %s was not handled\n", argv[idx]); + "WARNING: key %s was not handled\n", argv[idx]); } return (KIN_SUCCESS); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index cd77a2a232..5b3b903c83 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -57,9 +57,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); /* ----------------------------------------------------------------- * exported functions @@ -82,15 +82,15 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) SUNCheckLastErrNull(); /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_ImExGus; - C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; - C->ops->reset = SUNAdaptController_Reset_ImExGus; - C->ops->setfromcommandline = SUNAdaptController_SetFromCommandLine_ImExGus; - C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; - C->ops->write = SUNAdaptController_Write_ImExGus; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; - C->ops->updateh = SUNAdaptController_UpdateH_ImExGus; - C->ops->space = SUNAdaptController_Space_ImExGus; + C->ops->gettype = SUNAdaptController_GetType_ImExGus; + C->ops->estimatestep = SUNAdaptController_EstimateStep_ImExGus; + C->ops->reset = SUNAdaptController_Reset_ImExGus; + C->ops->setoptions = SUNAdaptController_SetOptions_ImExGus; + C->ops->setdefaults = SUNAdaptController_SetDefaults_ImExGus; + C->ops->write = SUNAdaptController_Write_ImExGus; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_ImExGus; + C->ops->updateh = SUNAdaptController_UpdateH_ImExGus; + C->ops->space = SUNAdaptController_Space_ImExGus; /* Create content */ content = NULL; @@ -107,13 +107,37 @@ SUNAdaptController SUNAdaptController_ImExGus(SUNContext sunctx) return (C); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNAdaptController_SetOptions_ImExGus(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_ImExGus(C, Cid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ----------------------------------------------------------------- * Function to control ImExGus parameters from the command line */ -SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) { SUNFunctionBegin(C->sunctx); @@ -125,14 +149,14 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_ImExGus(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; - if (Cid != NULL) + if (Cid != NULL && strlen(Cid) > 0) { if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } offset = strlen(Cid) + 1; } else { - static const char* prefix = "sunadaptcontroller_imexgus."; + static const char* prefix = "sunadaptcontroller."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 18d6dba04c..39cd52e25f 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -55,9 +55,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]); /* ----------------------------------------------------------------- * exported functions @@ -88,15 +88,15 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, SUNCheckLastErrNull(); /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_MRIHTol; - C->ops->estimatesteptol = SUNAdaptController_EstimateStepTol_MRIHTol; - C->ops->reset = SUNAdaptController_Reset_MRIHTol; - C->ops->setfromcommandline = SUNAdaptController_SetFromCommandLine_MRIHTol; - C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; - C->ops->write = SUNAdaptController_Write_MRIHTol; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; - C->ops->updatemrihtol = SUNAdaptController_UpdateMRIHTol_MRIHTol; - C->ops->space = SUNAdaptController_Space_MRIHTol; + C->ops->gettype = SUNAdaptController_GetType_MRIHTol; + C->ops->estimatesteptol = SUNAdaptController_EstimateStepTol_MRIHTol; + C->ops->reset = SUNAdaptController_Reset_MRIHTol; + C->ops->setoptions = SUNAdaptController_SetOptions_MRIHTol; + C->ops->setdefaults = SUNAdaptController_SetDefaults_MRIHTol; + C->ops->write = SUNAdaptController_Write_MRIHTol; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_MRIHTol; + C->ops->updatemrihtol = SUNAdaptController_UpdateMRIHTol_MRIHTol; + C->ops->space = SUNAdaptController_Space_MRIHTol; /* Create content */ content = NULL; @@ -118,13 +118,37 @@ SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, return C; } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNAdaptController_SetOptions_MRIHTol(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_MRIHTol(C, Cid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ----------------------------------------------------------------- * Function to control MRIHTol parameters from the command line */ -SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) { SUNFunctionBegin(C->sunctx); @@ -136,14 +160,14 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_MRIHTol(SUNAdaptController C, /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ size_t offset; - if (Cid != NULL) + if (Cid != NULL && strlen(Cid) > 0) { if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } offset = strlen(Cid) + 1; } else { - static const char* prefix = "sunadaptcontroller_mrihtol."; + static const char* prefix = "sunadaptcontroller."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 008b5fa12e..0740d3cef4 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -72,10 +72,10 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, - const char* Cid, - int argc, - char* argv[]); +static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, + const char* Cid, + int argc, + char* argv[]); /* ----------------------------------------------------------------- * exported functions @@ -95,15 +95,15 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) SUNAdaptControllerContent_Soderlind content = NULL; /* Attach operations */ - C->ops->gettype = SUNAdaptController_GetType_Soderlind; - C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; - C->ops->reset = SUNAdaptController_Reset_Soderlind; - C->ops->setfromcommandline = SUNAdaptController_SetFromCommandLine_Soderlind; - C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; - C->ops->write = SUNAdaptController_Write_Soderlind; - C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; - C->ops->updateh = SUNAdaptController_UpdateH_Soderlind; - C->ops->space = SUNAdaptController_Space_Soderlind; + C->ops->gettype = SUNAdaptController_GetType_Soderlind; + C->ops->estimatestep = SUNAdaptController_EstimateStep_Soderlind; + C->ops->reset = SUNAdaptController_Reset_Soderlind; + C->ops->setoptions = SUNAdaptController_SetOptions_Soderlind; + C->ops->setdefaults = SUNAdaptController_SetDefaults_Soderlind; + C->ops->write = SUNAdaptController_Write_Soderlind; + C->ops->seterrorbias = SUNAdaptController_SetErrorBias_Soderlind; + C->ops->updateh = SUNAdaptController_UpdateH_Soderlind; + C->ops->space = SUNAdaptController_Space_Soderlind; /* Create content */ content = (SUNAdaptControllerContent_Soderlind)malloc(sizeof(*content)); @@ -117,13 +117,38 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) return (C); } + +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNAdaptController_SetOptions_Soderlind(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_Soderlind(C, Cid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ----------------------------------------------------------------- * Function to control Soderlind parameters from the command line */ -SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, + const char* Cid, + int argc, char* argv[]) { SUNFunctionBegin(C->sunctx); @@ -134,31 +159,21 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, { /* if Cid is supplied, skip command-line arguments that do not begin with Cid; else, skip command-line arguments that do not begin with "sunadaptcontroller." */ - size_t SOffset, PIDOffset, PIOffset, IOffset, ExpGusOffset, ImpGusOffset; - const char* SPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_soderlind."; - const char* PIDPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_pid."; - const char* PIPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_pi."; - const char* IPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_i."; - const char* ExpGusPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_expgus."; - const char* ImpGusPrefix = (Cid != NULL) ? Cid : "sunadaptcontroller_impgus."; - if (Cid != NULL) + size_t offset; + if (Cid != NULL && strlen(Cid) > 0) { - SOffset = PIDOffset = PIOffset = IOffset = ExpGusOffset = ImpGusOffset = - strlen(Cid) + 1; + if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } + offset = strlen(Cid) + 1; } else { - SOffset = strlen(SPrefix); - PIDOffset = strlen(PIDPrefix); - PIOffset = strlen(PIPrefix); - IOffset = strlen(IPrefix); - ExpGusOffset = strlen(ExpGusPrefix); - ImpGusOffset = strlen(ImpGusPrefix); + static const char* prefix = "sunadaptcontroller."; + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); } /* control over SetParams_Soderlind function */ - if ((strncmp(argv[idx], SPrefix, strlen(SPrefix)) == 0) && - (strcmp(argv[idx] + SOffset, "params") == 0)) + if (strcmp(argv[idx] + offset, "params") == 0) { idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); @@ -177,8 +192,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_PID function */ - if ((strncmp(argv[idx], PIDPrefix, strlen(PIDPrefix)) == 0) && - (strcmp(argv[idx] + PIDOffset, "params") == 0)) + if (strcmp(argv[idx] + offset, "params_pid") == 0) { idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); @@ -192,8 +206,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_PI function */ - if ((strncmp(argv[idx], PIPrefix, strlen(PIPrefix)) == 0) && - (strcmp(argv[idx] + PIOffset, "params") == 0)) + if (strcmp(argv[idx] + offset, "params_pi") == 0) { idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); @@ -205,8 +218,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_I function */ - if ((strncmp(argv[idx], IPrefix, strlen(IPrefix)) == 0) && - (strcmp(argv[idx] + IOffset, "params") == 0)) + if (strcmp(argv[idx] + offset, "params_i") == 0) { idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); @@ -216,8 +228,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_ExpGus function */ - if ((strncmp(argv[idx], ExpGusPrefix, strlen(ExpGusPrefix)) == 0) && - (strcmp(argv[idx] + ExpGusOffset, "params") == 0)) + if (strcmp(argv[idx] + offset, "params_expgus") == 0) { idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); @@ -229,8 +240,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetParams_ImpGus function */ - if ((strncmp(argv[idx], ImpGusPrefix, strlen(ImpGusPrefix)) == 0) && - (strcmp(argv[idx] + ImpGusOffset, "params") == 0)) + if (strcmp(argv[idx] + offset, "params_impgus") == 0) { idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); @@ -242,12 +252,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetDefaults_Soderlind function */ - if ((strcmp(argv[idx] + SOffset, "defaults") == 0) || - (strcmp(argv[idx] + PIDOffset, "defaults") == 0) || - (strcmp(argv[idx] + PIOffset, "defaults") == 0) || - (strcmp(argv[idx] + IOffset, "defaults") == 0) || - (strcmp(argv[idx] + ExpGusOffset, "defaults") == 0) || - (strcmp(argv[idx] + ImpGusOffset, "defaults") == 0)) + if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_Soderlind(C); if (retval != SUN_SUCCESS) { return retval; } @@ -255,12 +260,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* control over SetErrorBias_Soderlind function */ - if ((strcmp(argv[idx] + SOffset, "error_bias") == 0) || - (strcmp(argv[idx] + PIDOffset, "error_bias") == 0) || - (strcmp(argv[idx] + PIOffset, "error_bias") == 0) || - (strcmp(argv[idx] + IOffset, "error_bias") == 0) || - (strcmp(argv[idx] + ExpGusOffset, "error_bias") == 0) || - (strcmp(argv[idx] + ImpGusOffset, "error_bias") == 0)) + if (strcmp(argv[idx] + offset, "error_bias") == 0) { idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); @@ -270,12 +270,7 @@ SUNErrCode SUNAdaptController_SetFromCommandLine_Soderlind(SUNAdaptController C, } /* check whether it was requested that all parameters be printed to screen */ - if ((strcmp(argv[idx] + SOffset, "write_parameters") == 0) || - (strcmp(argv[idx] + PIDOffset, "write_parameters") == 0) || - (strcmp(argv[idx] + PIOffset, "write_parameters") == 0) || - (strcmp(argv[idx] + IOffset, "write_parameters") == 0) || - (strcmp(argv[idx] + ExpGusOffset, "write_parameters") == 0) || - (strcmp(argv[idx] + ImpGusOffset, "write_parameters") == 0)) + if (strcmp(argv[idx] + offset, "write_parameters") == 0) { write_parameters = SUNTRUE; continue; diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 463e822e52..335a7c61ff 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -47,18 +47,18 @@ SUNAdaptController SUNAdaptController_NewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->destroy = NULL; - ops->reset = NULL; - ops->estimatestep = NULL; - ops->estimatesteptol = NULL; - ops->setfromcommandline = NULL; - ops->setdefaults = NULL; - ops->write = NULL; - ops->seterrorbias = NULL; - ops->updateh = NULL; - ops->updatemrihtol = NULL; - ops->space = NULL; + ops->gettype = NULL; + ops->destroy = NULL; + ops->reset = NULL; + ops->estimatestep = NULL; + ops->estimatesteptol = NULL; + ops->setoptions = NULL; + ops->setdefaults = NULL; + ops->write = NULL; + ops->seterrorbias = NULL; + ops->updateh = NULL; + ops->updatemrihtol = NULL; + ops->space = NULL; /* attach ops and initialize content to NULL */ C->ops = ops; @@ -173,16 +173,17 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) return (ier); } -SUNErrCode SUNAdaptController_SetFromCommandLine(SUNAdaptController C, - const char* Cid, int argc, - char* argv[]) +SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, + const char* Cid, + const char* file_name, + int argc, char* argv[]) { SUNErrCode ier = SUN_SUCCESS; if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } SUNFunctionBegin(C->sunctx); - if (C->ops->setfromcommandline) + if (C->ops->setoptions) { - ier = C->ops->setfromcommandline(C, Cid, argc, argv); + ier = C->ops->setoptions(C, Cid, file_name, argc, argv); } return (ier); } diff --git a/src/sundials/sundials_linearsolver.c b/src/sundials/sundials_linearsolver.c index cbe73f9c7d..1fee662686 100644 --- a/src/sundials/sundials_linearsolver.c +++ b/src/sundials/sundials_linearsolver.c @@ -57,22 +57,22 @@ SUNLinearSolver SUNLinSolNewEmpty(SUNContext sunctx) SUNAssertNull(ops, SUN_ERR_MALLOC_FAIL); /* initialize operations to NULL */ - ops->gettype = NULL; - ops->getid = NULL; - ops->setatimes = NULL; - ops->setpreconditioner = NULL; - ops->setscalingvectors = NULL; - ops->setfromcommandline = NULL; - ops->setzeroguess = NULL; - ops->initialize = NULL; - ops->setup = NULL; - ops->solve = NULL; - ops->numiters = NULL; - ops->resnorm = NULL; - ops->resid = NULL; - ops->lastflag = NULL; - ops->space = NULL; - ops->free = NULL; + ops->gettype = NULL; + ops->getid = NULL; + ops->setatimes = NULL; + ops->setpreconditioner = NULL; + ops->setscalingvectors = NULL; + ops->setoptions = NULL; + ops->setzeroguess = NULL; + ops->initialize = NULL; + ops->setup = NULL; + ops->solve = NULL; + ops->numiters = NULL; + ops->resnorm = NULL; + ops->resid = NULL; + ops->lastflag = NULL; + ops->space = NULL; + ops->free = NULL; /* attach ops and initialize content and context to NULL */ LS->ops = ops; @@ -148,16 +148,16 @@ SUNErrCode SUNLinSolSetScalingVectors(SUNLinearSolver S, N_Vector s1, N_Vector s return (ier); } -SUNErrCode SUNLinSolSetFromCommandLine(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]) +SUNErrCode SUNLinSolSetOptions(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) { SUNErrCode ier = SUN_SUCCESS; - if (S == NULL) { return SUN_ERR_ARG_CORRUPT; } - SUNFunctionBegin(S->sunctx); - if (S->ops->setfromcommandline) + SUNDIALS_MARK_FUNCTION_BEGIN(getSUNProfiler(S)); + if (S->ops->setoptions) { - return (S->ops->setfromcommandline(S, LSid, argc, argv)); + return (S->ops->setoptions(S, LSid, file_name, argc, argv)); } + SUNDIALS_MARK_FUNCTION_END(getSUNProfiler(S)); return (ier); } diff --git a/src/sundials/sundials_nonlinearsolver.c b/src/sundials/sundials_nonlinearsolver.c index 6b4fee01f0..a8f0c50f71 100644 --- a/src/sundials/sundials_nonlinearsolver.c +++ b/src/sundials/sundials_nonlinearsolver.c @@ -63,6 +63,7 @@ SUNNonlinearSolver SUNNonlinSolNewEmpty(SUNContext sunctx) ops->setlsetupfn = NULL; ops->setlsolvefn = NULL; ops->setctestfn = NULL; + ops->setoptions = NULL; ops->setmaxiters = NULL; ops->getnumiters = NULL; ops->getcuriter = NULL; @@ -198,6 +199,16 @@ SUNErrCode SUNNonlinSolSetConvTestFn(SUNNonlinearSolver NLS, else { return (SUN_SUCCESS); } } +SUNErrCode SUNNonlinSolSetOptions(SUNNonlinearSolver NLS, const char* NLSid, + const char* file_name, int argc, char* argv[]) +{ + if (NLS->ops->setoptions) + { + return (NLS->ops->setoptions(NLS, NLSid, file_name, argc, argv)); + } + else { return (SUN_SUCCESS); } +} + SUNErrCode SUNNonlinSolSetMaxIters(SUNNonlinearSolver NLS, int maxiters) { if (NLS->ops->setmaxiters) { return (NLS->ops->setmaxiters(NLS, maxiters)); } diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 88a43be64c..d2fcd125ba 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -52,8 +52,8 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -91,15 +91,15 @@ SUNLinearSolver SUNLinSol_KLU(N_Vector y, SUNMatrix A, SUNContext sunctx) if (S == NULL) { return (NULL); } /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_KLU; - S->ops->getid = SUNLinSolGetID_KLU; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_KLU; - S->ops->initialize = SUNLinSolInitialize_KLU; - S->ops->setup = SUNLinSolSetup_KLU; - S->ops->solve = SUNLinSolSolve_KLU; - S->ops->lastflag = SUNLinSolLastFlag_KLU; - S->ops->space = SUNLinSolSpace_KLU; - S->ops->free = SUNLinSolFree_KLU; + S->ops->gettype = SUNLinSolGetType_KLU; + S->ops->getid = SUNLinSolGetID_KLU; + S->ops->setoptions = SUNLinSolSetOptions_KLU; + S->ops->initialize = SUNLinSolInitialize_KLU; + S->ops->setup = SUNLinSolSetup_KLU; + S->ops->solve = SUNLinSolSolve_KLU; + S->ops->lastflag = SUNLinSolLastFlag_KLU; + S->ops->space = SUNLinSolSpace_KLU; + S->ops->free = SUNLinSolFree_KLU; /* Create content */ content = NULL; @@ -181,12 +181,34 @@ SUNErrCode SUNLinSol_KLUReInit(SUNLinearSolver S, SUNMatrix A, sunindextype nnz, return SUN_SUCCESS; } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_KLU(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_KLU(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -197,14 +219,14 @@ SUNErrCode SUNLinSolSetFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "klu." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "klu."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 5f0c4586d3..1e40b87504 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -65,9 +65,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]); +static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]); /* * ---------------------------------------------------------------------------- @@ -120,15 +120,15 @@ SUNLinearSolver SUNLinSol_MagmaDense(N_Vector y, SUNMatrix Amat, SUNContext sunc if (S == NULL) { return (NULL); } /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_MagmaDense; - S->ops->getid = SUNLinSolGetID_MagmaDense; - S->ops->initialize = SUNLinSolInitialize_MagmaDense; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_MagmaDense; - S->ops->setup = SUNLinSolSetup_MagmaDense; - S->ops->solve = SUNLinSolSolve_MagmaDense; - S->ops->lastflag = SUNLinSolLastFlag_MagmaDense; - S->ops->space = SUNLinSolSpace_MagmaDense; - S->ops->free = SUNLinSolFree_MagmaDense; + S->ops->gettype = SUNLinSolGetType_MagmaDense; + S->ops->getid = SUNLinSolGetID_MagmaDense; + S->ops->initialize = SUNLinSolInitialize_MagmaDense; + S->ops->setoptions = SUNLinSolSetOptions_MagmaDense; + S->ops->setup = SUNLinSolSetup_MagmaDense; + S->ops->solve = SUNLinSolSolve_MagmaDense; + S->ops->lastflag = SUNLinSolLastFlag_MagmaDense; + S->ops->space = SUNLinSolSpace_MagmaDense; + S->ops->free = SUNLinSolFree_MagmaDense; /* Create content */ content = NULL; @@ -247,9 +247,28 @@ SUNErrCode SUNLinSolInitialize_MagmaDense(SUNLinearSolver S) return SUN_SUCCESS; } -SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]) +SUNErrCode SUNLinSolSetOptions_MagmaDense(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, + char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_MagmaDense(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + +static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]) { SUNErrCode retval; for (int idx = 1; idx < argc; idx++) @@ -264,7 +283,7 @@ SUNErrCode SUNLinSolSetFromCommandLine_MagmaDense(SUNLinearSolver S, } else { - static const char* prefix = "magmadense."; + static const char* prefix = "sunlinsol."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index f54e1b25d9..52bbffcfbe 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -42,13 +42,13 @@ #define LASTFLAG(S) (PCG_CONTENT(S)->last_flag) /* - * ---------------------------------------------------------------------------- - * Un-exported implementation specific routines - * ---------------------------------------------------------------------------- + * ----------------------------------------------------------------- + * unexported functions + * ----------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -80,22 +80,22 @@ SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl, SUNContext sunc SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_PCG; - S->ops->getid = SUNLinSolGetID_PCG; - S->ops->setatimes = SUNLinSolSetATimes_PCG; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_PCG; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_PCG; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_PCG; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_PCG; - S->ops->initialize = SUNLinSolInitialize_PCG; - S->ops->setup = SUNLinSolSetup_PCG; - S->ops->solve = SUNLinSolSolve_PCG; - S->ops->numiters = SUNLinSolNumIters_PCG; - S->ops->resnorm = SUNLinSolResNorm_PCG; - S->ops->resid = SUNLinSolResid_PCG; - S->ops->lastflag = SUNLinSolLastFlag_PCG; - S->ops->space = SUNLinSolSpace_PCG; - S->ops->free = SUNLinSolFree_PCG; + S->ops->gettype = SUNLinSolGetType_PCG; + S->ops->getid = SUNLinSolGetID_PCG; + S->ops->setatimes = SUNLinSolSetATimes_PCG; + S->ops->setoptions = SUNLinSolSetOptions_PCG; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_PCG; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_PCG; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_PCG; + S->ops->initialize = SUNLinSolInitialize_PCG; + S->ops->setup = SUNLinSolSetup_PCG; + S->ops->solve = SUNLinSolSolve_PCG; + S->ops->numiters = SUNLinSolNumIters_PCG; + S->ops->resnorm = SUNLinSolResNorm_PCG; + S->ops->resid = SUNLinSolResid_PCG; + S->ops->lastflag = SUNLinSolLastFlag_PCG; + S->ops->space = SUNLinSolSpace_PCG; + S->ops->free = SUNLinSolFree_PCG; /* Create content */ content = NULL; @@ -139,12 +139,34 @@ SUNLinearSolver SUNLinSol_PCG(N_Vector y, int pretype, int maxl, SUNContext sunc return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_PCG(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_PCG(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -153,16 +175,16 @@ SUNErrCode SUNLinSolSetFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, for (idx = 1; idx < argc; idx++) { /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "pcg." */ + else, skip command-line arguments that do not begin with "sunlinearsolver." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "pcg."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index dac0b4ff72..19c42e9b4f 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -49,8 +49,8 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -89,22 +89,22 @@ SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPBCGS; - S->ops->getid = SUNLinSolGetID_SPBCGS; - S->ops->setatimes = SUNLinSolSetATimes_SPBCGS; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPBCGS; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPBCGS; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPBCGS; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPBCGS; - S->ops->initialize = SUNLinSolInitialize_SPBCGS; - S->ops->setup = SUNLinSolSetup_SPBCGS; - S->ops->solve = SUNLinSolSolve_SPBCGS; - S->ops->numiters = SUNLinSolNumIters_SPBCGS; - S->ops->resnorm = SUNLinSolResNorm_SPBCGS; - S->ops->resid = SUNLinSolResid_SPBCGS; - S->ops->lastflag = SUNLinSolLastFlag_SPBCGS; - S->ops->space = SUNLinSolSpace_SPBCGS; - S->ops->free = SUNLinSolFree_SPBCGS; + S->ops->gettype = SUNLinSolGetType_SPBCGS; + S->ops->getid = SUNLinSolGetID_SPBCGS; + S->ops->setatimes = SUNLinSolSetATimes_SPBCGS; + S->ops->setoptions = SUNLinSolSetOptions_SPBCGS; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPBCGS; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPBCGS; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPBCGS; + S->ops->initialize = SUNLinSolInitialize_SPBCGS; + S->ops->setup = SUNLinSolSetup_SPBCGS; + S->ops->solve = SUNLinSolSolve_SPBCGS; + S->ops->numiters = SUNLinSolNumIters_SPBCGS; + S->ops->resnorm = SUNLinSolResNorm_SPBCGS; + S->ops->resid = SUNLinSolResid_SPBCGS; + S->ops->lastflag = SUNLinSolLastFlag_SPBCGS; + S->ops->space = SUNLinSolSpace_SPBCGS; + S->ops->free = SUNLinSolFree_SPBCGS; /* Create content */ content = NULL; @@ -161,12 +161,34 @@ SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_SPBCGS(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_SPBCGS(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -177,14 +199,14 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSi /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spbcgs." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "spbcgs."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index e8cd642299..cc081ffbe9 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -47,8 +47,8 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -89,22 +89,22 @@ SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPFGMR; - S->ops->getid = SUNLinSolGetID_SPFGMR; - S->ops->setatimes = SUNLinSolSetATimes_SPFGMR; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPFGMR; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPFGMR; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPFGMR; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPFGMR; - S->ops->initialize = SUNLinSolInitialize_SPFGMR; - S->ops->setup = SUNLinSolSetup_SPFGMR; - S->ops->solve = SUNLinSolSolve_SPFGMR; - S->ops->numiters = SUNLinSolNumIters_SPFGMR; - S->ops->resnorm = SUNLinSolResNorm_SPFGMR; - S->ops->resid = SUNLinSolResid_SPFGMR; - S->ops->lastflag = SUNLinSolLastFlag_SPFGMR; - S->ops->space = SUNLinSolSpace_SPFGMR; - S->ops->free = SUNLinSolFree_SPFGMR; + S->ops->gettype = SUNLinSolGetType_SPFGMR; + S->ops->getid = SUNLinSolGetID_SPFGMR; + S->ops->setatimes = SUNLinSolSetATimes_SPFGMR; + S->ops->setoptions = SUNLinSolSetOptions_SPFGMR; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPFGMR; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPFGMR; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPFGMR; + S->ops->initialize = SUNLinSolInitialize_SPFGMR; + S->ops->setup = SUNLinSolSetup_SPFGMR; + S->ops->solve = SUNLinSolSolve_SPFGMR; + S->ops->numiters = SUNLinSolNumIters_SPFGMR; + S->ops->resnorm = SUNLinSolResNorm_SPFGMR; + S->ops->resid = SUNLinSolResid_SPFGMR; + S->ops->lastflag = SUNLinSolLastFlag_SPFGMR; + S->ops->space = SUNLinSolSpace_SPFGMR; + S->ops->free = SUNLinSolFree_SPFGMR; /* Create content */ content = NULL; @@ -149,12 +149,34 @@ SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_SPFGMR(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_SPFGMR(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -165,14 +187,14 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSi /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spfgmr." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "spfgmr."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 8f9471ab1c..183d92860a 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -47,8 +47,8 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -87,22 +87,22 @@ SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPGMR; - S->ops->getid = SUNLinSolGetID_SPGMR; - S->ops->setatimes = SUNLinSolSetATimes_SPGMR; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPGMR; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPGMR; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPGMR; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPGMR; - S->ops->initialize = SUNLinSolInitialize_SPGMR; - S->ops->setup = SUNLinSolSetup_SPGMR; - S->ops->solve = SUNLinSolSolve_SPGMR; - S->ops->numiters = SUNLinSolNumIters_SPGMR; - S->ops->resnorm = SUNLinSolResNorm_SPGMR; - S->ops->resid = SUNLinSolResid_SPGMR; - S->ops->lastflag = SUNLinSolLastFlag_SPGMR; - S->ops->space = SUNLinSolSpace_SPGMR; - S->ops->free = SUNLinSolFree_SPGMR; + S->ops->gettype = SUNLinSolGetType_SPGMR; + S->ops->getid = SUNLinSolGetID_SPGMR; + S->ops->setatimes = SUNLinSolSetATimes_SPGMR; + S->ops->setoptions = SUNLinSolSetOptions_SPGMR; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPGMR; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPGMR; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPGMR; + S->ops->initialize = SUNLinSolInitialize_SPGMR; + S->ops->setup = SUNLinSolSetup_SPGMR; + S->ops->solve = SUNLinSolSolve_SPGMR; + S->ops->numiters = SUNLinSolNumIters_SPGMR; + S->ops->resnorm = SUNLinSolResNorm_SPGMR; + S->ops->resid = SUNLinSolResid_SPGMR; + S->ops->lastflag = SUNLinSolLastFlag_SPGMR; + S->ops->space = SUNLinSolSpace_SPGMR; + S->ops->free = SUNLinSolFree_SPGMR; /* Create content */ content = NULL; @@ -146,12 +146,34 @@ SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_SPGMR(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_SPGMR(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -162,14 +184,14 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "spgmr." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "spgmr."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index d0a5c45e2b..61a9ea0899 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -46,9 +46,9 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]); +static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]); /* * ----------------------------------------------------------------- @@ -87,22 +87,22 @@ SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, SUNCheckLastErrNull(); /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SPTFQMR; - S->ops->getid = SUNLinSolGetID_SPTFQMR; - S->ops->setatimes = SUNLinSolSetATimes_SPTFQMR; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SPTFQMR; - S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPTFQMR; - S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPTFQMR; - S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPTFQMR; - S->ops->initialize = SUNLinSolInitialize_SPTFQMR; - S->ops->setup = SUNLinSolSetup_SPTFQMR; - S->ops->solve = SUNLinSolSolve_SPTFQMR; - S->ops->numiters = SUNLinSolNumIters_SPTFQMR; - S->ops->resnorm = SUNLinSolResNorm_SPTFQMR; - S->ops->resid = SUNLinSolResid_SPTFQMR; - S->ops->lastflag = SUNLinSolLastFlag_SPTFQMR; - S->ops->space = SUNLinSolSpace_SPTFQMR; - S->ops->free = SUNLinSolFree_SPTFQMR; + S->ops->gettype = SUNLinSolGetType_SPTFQMR; + S->ops->getid = SUNLinSolGetID_SPTFQMR; + S->ops->setatimes = SUNLinSolSetATimes_SPTFQMR; + S->ops->setoptions = SUNLinSolSetOptions_SPTFQMR; + S->ops->setpreconditioner = SUNLinSolSetPreconditioner_SPTFQMR; + S->ops->setscalingvectors = SUNLinSolSetScalingVectors_SPTFQMR; + S->ops->setzeroguess = SUNLinSolSetZeroGuess_SPTFQMR; + S->ops->initialize = SUNLinSolInitialize_SPTFQMR; + S->ops->setup = SUNLinSolSetup_SPTFQMR; + S->ops->solve = SUNLinSolSolve_SPTFQMR; + S->ops->numiters = SUNLinSolNumIters_SPTFQMR; + S->ops->resnorm = SUNLinSolResNorm_SPTFQMR; + S->ops->resid = SUNLinSolResid_SPTFQMR; + S->ops->lastflag = SUNLinSolLastFlag_SPTFQMR; + S->ops->space = SUNLinSolSpace_SPTFQMR; + S->ops->free = SUNLinSolFree_SPTFQMR; /* Create content */ content = NULL; @@ -162,13 +162,35 @@ SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_SPTFQMR(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_SPTFQMR(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]) +static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -179,14 +201,14 @@ SUNErrCode SUNLinSolSetFromCommandLine_SPTFQMR(SUNLinearSolver S, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "sptfqmr." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "sptfqmr."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 11d28be09a..7542f25972 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -62,9 +62,8 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]); +SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -104,15 +103,15 @@ SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, if (S == NULL) { return (NULL); } /* Attach operations */ - S->ops->gettype = SUNLinSolGetType_SuperLUMT; - S->ops->getid = SUNLinSolGetID_SuperLUMT; - S->ops->initialize = SUNLinSolInitialize_SuperLUMT; - S->ops->setfromcommandline = SUNLinSolSetFromCommandLine_SuperLUMT; - S->ops->setup = SUNLinSolSetup_SuperLUMT; - S->ops->solve = SUNLinSolSolve_SuperLUMT; - S->ops->lastflag = SUNLinSolLastFlag_SuperLUMT; - S->ops->space = SUNLinSolSpace_SuperLUMT; - S->ops->free = SUNLinSolFree_SuperLUMT; + S->ops->gettype = SUNLinSolGetType_SuperLUMT; + S->ops->getid = SUNLinSolGetID_SuperLUMT; + S->ops->initialize = SUNLinSolInitialize_SuperLUMT; + S->ops->setoptions = SUNLinSolSetOptions_SuperLUMT; + S->ops->setup = SUNLinSolSetup_SuperLUMT; + S->ops->solve = SUNLinSolSolve_SuperLUMT; + S->ops->lastflag = SUNLinSolLastFlag_SuperLUMT; + S->ops->space = SUNLinSolSpace_SuperLUMT; + S->ops->free = SUNLinSolFree_SuperLUMT; /* Create content */ content = NULL; @@ -217,13 +216,35 @@ SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, return (S); } +/* ---------------------------------------------------------------------------- + * Function to control set routines via the command line or file + */ + +SUNErrCode SUNLinSolSetOptions_SuperLUMT(SUNLinearSolver S, const char* LSid, + const char* file_name, int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_SuperLUMT(S, LSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + /* ---------------------------------------------------------------------------- * Function to control set routines via the command line */ -SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]) +static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]) { SUNFunctionBegin(S->sunctx); @@ -234,19 +255,19 @@ SUNErrCode SUNLinSolSetFromCommandLine_SuperLUMT(SUNLinearSolver S, /* if LSid is supplied, skip command-line arguments that do not begin with LSid; else, skip command-line arguments that do not begin with "superlumt." */ size_t offset; - if (LSid != NULL) + if (LSid != NULL && strlen(LSid) > 0) { if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } offset = strlen(LSid) + 1; } else { - static const char* prefix = "superlumt."; + static const char* prefix = "sunlinearsolver."; if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } offset = strlen(prefix); } - /* control over PrecType function */ + /* control over SetOrdering function */ if (strcmp(argv[idx] + offset, "ordering") == 0) { idx += 1; diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index f53b03cf23..cbeb62870c 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -40,6 +40,16 @@ static void FreeContent(SUNNonlinearSolver NLS); #define ONE SUN_RCONST(1.0) #define ZERO SUN_RCONST(0.0) +/* + * ----------------------------------------------------------------- + * unexported functions + * ----------------------------------------------------------------- + */ + +static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, + const char* NLSid, + int argc, char* argv[]); + /*============================================================================== Constructor to create a new fixed point solver ============================================================================*/ @@ -66,6 +76,7 @@ SUNNonlinearSolver SUNNonlinSol_FixedPoint(N_Vector y, int m, SUNContext sunctx) NLS->ops->free = SUNNonlinSolFree_FixedPoint; NLS->ops->setsysfn = SUNNonlinSolSetSysFn_FixedPoint; NLS->ops->setctestfn = SUNNonlinSolSetConvTestFn_FixedPoint; + NLS->ops->setoptions = SUNNonlinSolSetOptions_FixedPoint; NLS->ops->setmaxiters = SUNNonlinSolSetMaxIters_FixedPoint; NLS->ops->getnumiters = SUNNonlinSolGetNumIters_FixedPoint; NLS->ops->getcuriter = SUNNonlinSolGetCurIter_FixedPoint; @@ -333,6 +344,63 @@ SUNErrCode SUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver NLS, return SUN_SUCCESS; } +SUNErrCode SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver NLS, + const char* NLSid, + const char* file_name, + int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_FixedPoint(NLS, NLSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + +static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, const char* NLSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(NLS->sunctx); + + int idx; + SUNErrCode retval; + for (idx = 1; idx < argc; idx++) + { + /* if NLSid is supplied, skip command-line arguments that do not begin with NLSid; + else, skip command-line arguments that do not begin with "sunnonlinearsolver." */ + size_t offset; + if (NLSid != NULL && strlen(NLSid) > 0) + { + if (strncmp(argv[idx], NLSid, strlen(NLSid)) != 0) { continue; } + offset = strlen(NLSid) + 1; + } + else + { + static const char* prefix = "sunnonlinearsolver."; + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over MaxIters function */ + if (strcmp(argv[idx] + offset, "max_iters") == 0) + { + idx += 1; + int iarg = atoi(argv[idx]); + retval = SUNNonlinSolSetMaxIters_FixedPoint(NLS, iarg); + if (retval != SUN_SUCCESS) { return retval; } + continue; + } + } + return SUN_SUCCESS; +} + SUNErrCode SUNNonlinSolSetMaxIters_FixedPoint(SUNNonlinearSolver NLS, int maxiters) { SUNFunctionBegin(NLS->sunctx); diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 6a9a1b5627..948bad7fb2 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -34,6 +34,16 @@ #define ZERO SUN_RCONST(0.0) /* real 0.0 */ #define ONE SUN_RCONST(1.0) /* real 1.0 */ +/* + * ----------------------------------------------------------------- + * unexported functions + * ----------------------------------------------------------------- + */ + +static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, + const char* NLSid, + int argc, char* argv[]); + /*============================================================================== Constructor to create a new Newton solver ============================================================================*/ @@ -62,6 +72,7 @@ SUNNonlinearSolver SUNNonlinSol_Newton(N_Vector y, SUNContext sunctx) NLS->ops->setlsetupfn = SUNNonlinSolSetLSetupFn_Newton; NLS->ops->setlsolvefn = SUNNonlinSolSetLSolveFn_Newton; NLS->ops->setctestfn = SUNNonlinSolSetConvTestFn_Newton; + NLS->ops->setoptions = SUNNonlinSolSetOptions_Newton; NLS->ops->setmaxiters = SUNNonlinSolSetMaxIters_Newton; NLS->ops->getnumiters = SUNNonlinSolGetNumIters_Newton; NLS->ops->getcuriter = SUNNonlinSolGetCurIter_Newton; @@ -397,6 +408,63 @@ SUNErrCode SUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver NLS, return SUN_SUCCESS; } +SUNErrCode SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver NLS, + const char* NLSid, + const char* file_name, + int argc, char* argv[]) +{ + if (file_name != NULL && strlen(file_name) > 0) + { + /* File-based option control is currently unimplemented */ + return SUN_ERR_NOT_IMPLEMENTED; + } + + if (argc > 0 && argv != NULL) + { + int retval = setFromCommandLine_Newton(NLS, NLSid, argc, argv); + if (retval != SUN_SUCCESS) { return retval; } + } + + return SUN_SUCCESS; +} + +static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, const char* NLSid, + int argc, char* argv[]) +{ + SUNFunctionBegin(NLS->sunctx); + + int idx; + SUNErrCode retval; + for (idx = 1; idx < argc; idx++) + { + /* if NLSid is supplied, skip command-line arguments that do not begin with NLSid; + else, skip command-line arguments that do not begin with "sunnonlinearsolver." */ + size_t offset; + if (NLSid != NULL && strlen(NLSid) > 0) + { + if (strncmp(argv[idx], NLSid, strlen(NLSid)) != 0) { continue; } + offset = strlen(NLSid) + 1; + } + else + { + static const char* prefix = "sunnonlinearsolver."; + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } + offset = strlen(prefix); + } + + /* control over MaxIters function */ + if (strcmp(argv[idx] + offset, "max_iters") == 0) + { + idx += 1; + int iarg = atoi(argv[idx]); + retval = SUNNonlinSolSetMaxIters_Newton(NLS, iarg); + if (retval != SUN_SUCCESS) { return retval; } + continue; + } + } + return SUN_SUCCESS; +} + SUNErrCode SUNNonlinSolSetMaxIters_Newton(SUNNonlinearSolver NLS, int maxiters) { SUNFunctionBegin(NLS->sunctx); From e2e8cfc21fe3bb99a6a50fd7765607e3fa745a0c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 17:09:52 -0400 Subject: [PATCH 090/114] formatting --- include/arkode/arkode.h | 3 +- include/cvode/cvode.h | 3 +- include/cvodes/cvodes.h | 3 +- .../sunadaptcontroller_soderlind.h | 3 +- include/sundials/sundials_adaptcontroller.h | 7 ++- include/sunlinsol/sunlinsol_spfgmr.h | 3 +- .../sunnonlinsol/sunnonlinsol_fixedpoint.h | 4 +- include/sunnonlinsol/sunnonlinsol_newton.h | 3 +- src/arkode/arkode_cli.c | 42 +++++++---------- src/arkode/arkode_impl.h | 5 +- src/arkode/arkode_lsrkstep.c | 26 +++++----- src/arkode/arkode_mristep_io.c | 8 ++-- src/cvode/cvode_cli.c | 32 ++++++------- src/cvodes/cvodes_cli.c | 44 +++++++---------- src/ida/ida_cli.c | 35 ++++++-------- src/idas/idas_cli.c | 47 ++++++++----------- src/kinsol/kinsol_cli.c | 28 +++++------ .../imexgus/sunadaptcontroller_imexgus.c | 8 ++-- .../mrihtol/sunadaptcontroller_mrihtol.c | 8 ++-- .../soderlind/sunadaptcontroller_soderlind.c | 8 ++-- src/sundials/sundials_adaptcontroller.c | 7 ++- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 3 +- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 3 +- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 3 +- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 13 +++-- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 3 +- .../fixedpoint/sunnonlinsol_fixedpoint.c | 13 ++--- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 12 ++--- 28 files changed, 170 insertions(+), 207 deletions(-) diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index 7a9287ff4f..90d702c184 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -220,7 +220,8 @@ typedef enum /* Command-line control over ARKODE options */ SUNDIALS_EXPORT int ARKodeSetOptions(void* arkode_mem, const char* arkid, - const char* file_name, int argc, char* argv[]); + const char* file_name, int argc, + char* argv[]); /* Resize and Reset functions */ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, diff --git a/include/cvode/cvode.h b/include/cvode/cvode.h index 771eb51aa1..ec5a621340 100644 --- a/include/cvode/cvode.h +++ b/include/cvode/cvode.h @@ -120,7 +120,8 @@ SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun); /* Optional input functions */ SUNDIALS_EXPORT int CVodeSetOptions(void* cvode_mem, const char* cvid, - const char* file_name, int argc, char* argv[]); + const char* file_name, int argc, + char* argv[]); SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints); SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem, sunrealtype dgmax_lsetup); diff --git a/include/cvodes/cvodes.h b/include/cvodes/cvodes.h index 1e856d322a..03676006a7 100644 --- a/include/cvodes/cvodes.h +++ b/include/cvodes/cvodes.h @@ -191,7 +191,8 @@ SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun); /* Optional input functions */ SUNDIALS_EXPORT int CVodeSetOptions(void* cvode_mem, const char* cvid, - const char* file_name, int argc, char* argv[]); + const char* file_name, int argc, + char* argv[]); SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints); SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem, sunrealtype dgmax_lsetup); diff --git a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h index 568bcfe5b1..0d09d8b40e 100644 --- a/include/sunadaptcontroller/sunadaptcontroller_soderlind.h +++ b/include/sunadaptcontroller/sunadaptcontroller_soderlind.h @@ -78,8 +78,7 @@ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetOptions_Soderlind(SUNAdaptController C, const char* Cid, const char* file_name, - int argc, - char* argv[]); + int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNAdaptController_SetDefaults_Soderlind(SUNAdaptController C); diff --git a/include/sundials/sundials_adaptcontroller.h b/include/sundials/sundials_adaptcontroller.h index 746aea9958..86eb1a5ece 100644 --- a/include/sundials/sundials_adaptcontroller.h +++ b/include/sundials/sundials_adaptcontroller.h @@ -151,10 +151,9 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C); /* Function to update internal controller parameters from the command line. */ SUNDIALS_EXPORT -SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, - const char* Cid, - const char* file_name, - int argc, char* argv[]); +SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, const char* Cid, + const char* file_name, int argc, + char* argv[]); /* Function to set the controller parameters to their default values. */ SUNDIALS_EXPORT diff --git a/include/sunlinsol/sunlinsol_spfgmr.h b/include/sunlinsol/sunlinsol_spfgmr.h index 6132d2366c..b3d44e5f45 100644 --- a/include/sunlinsol/sunlinsol_spfgmr.h +++ b/include/sunlinsol/sunlinsol_spfgmr.h @@ -103,7 +103,8 @@ SUNDIALS_EXPORT SUNErrCode SUNLinSolSetPreconditioner_SPFGMR(SUNLinearSolver S, SUNDIALS_EXPORT SUNErrCode SUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver S, N_Vector s1, N_Vector s2); -SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SPFGMR(SUNLinearSolver S, const char* LSid, +SUNDIALS_EXPORT SUNErrCode SUNLinSolSetOptions_SPFGMR(SUNLinearSolver S, + const char* LSid, const char* file_name, int argc, char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNLinSolSetZeroGuess_SPFGMR(SUNLinearSolver S, diff --git a/include/sunnonlinsol/sunnonlinsol_fixedpoint.h b/include/sunnonlinsol/sunnonlinsol_fixedpoint.h index 02351aefc6..0102202aa1 100644 --- a/include/sunnonlinsol/sunnonlinsol_fixedpoint.h +++ b/include/sunnonlinsol/sunnonlinsol_fixedpoint.h @@ -106,8 +106,8 @@ SUNErrCode SUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver NLS, SUNDIALS_EXPORT SUNErrCode SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver NLS, const char* NLSid, - const char* file_name, - int argc, char* argv[]); + const char* file_name, int argc, + char* argv[]); SUNDIALS_EXPORT SUNErrCode SUNNonlinSolSetMaxIters_FixedPoint(SUNNonlinearSolver NLS, diff --git a/include/sunnonlinsol/sunnonlinsol_newton.h b/include/sunnonlinsol/sunnonlinsol_newton.h index b99c7ffb17..91ebb72683 100644 --- a/include/sunnonlinsol/sunnonlinsol_newton.h +++ b/include/sunnonlinsol/sunnonlinsol_newton.h @@ -102,8 +102,7 @@ SUNErrCode SUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver NLS, SUNDIALS_EXPORT SUNErrCode SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver NLS, - const char* NLSid, - const char* file_name, + const char* NLSid, const char* file_name, int argc, char* argv[]); SUNDIALS_EXPORT diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 9942a978a9..514fd5dc04 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -24,9 +24,8 @@ #include "arkode_impl.h" #include "sundials_cli.h" -static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, - int argc, char* argv[]); - +static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, + char* argv[]); /*--------------------------------------------------------------- ARKodeSetOptions: @@ -34,15 +33,15 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, Sets ARKODE options using strings. ---------------------------------------------------------------*/ -int ARKodeSetOptions(void* arkode_mem, const char* arkid, - const char* file_name, int argc, char* argv[]) +int ARKodeSetOptions(void* arkode_mem, const char* arkid, const char* file_name, + int argc, char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { - int retval = ARK_ILL_INPUT; - arkProcessError(arkode_mem, retval, __LINE__, __func__, __FILE__, - "file-based options are not currently supported."); - return retval; + int retval = ARK_ILL_INPUT; + arkProcessError(arkode_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; } if (argc > 0 && argv != NULL) @@ -58,8 +57,8 @@ int ARKodeSetOptions(void* arkode_mem, const char* arkid, * Function to control ARKODE options from the command line */ -static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, - int argc, char* argv[]) +static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, + char* argv[]) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -163,8 +162,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (arg_used) continue; @@ -176,8 +174,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (arg_used) continue; @@ -189,8 +186,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } if (arg_used) continue; @@ -203,8 +199,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - tworeal_pairs[j].key); + "error setting key: %s", tworeal_pairs[j].key); return retval; } if (arg_used) continue; @@ -217,8 +212,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, { retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - action_pairs[j].key); + "error setting key: %s", action_pairs[j].key); return retval; } if (arg_used) continue; @@ -244,8 +238,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s %s", - argv[idx - 1], argv[idx]); + "error setting key: %s %s", argv[idx - 1], argv[idx]); return retval; } arg_used = SUNTRUE; @@ -275,8 +268,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s %s", - argv[idx - 1], argv[idx]); + "error setting key: %s %s", argv[idx - 1], argv[idx]); return retval; } arg_used = SUNTRUE; diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 6399ec13f1..9d39d37b81 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -222,9 +222,8 @@ typedef int (*ARKTimestepSetStepDirection)(ARKodeMem ark_mem, sunrealtype stepdir); typedef int (*ARKTimestepSetUseCompensatedSums)(ARKodeMem ark_mem, sunbooleantype onoff); -typedef int (*ARKTimestepSetOption)(ARKodeMem ark_mem, int* argidx, - char* argv[], size_t offset, - sunbooleantype* arg_used); +typedef int (*ARKTimestepSetOption)(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used); /* time stepper interface functions -- temporal adaptivity */ typedef int (*ARKTimestepGetEstLocalErrors)(ARKodeMem ark_mem, N_Vector ele); diff --git a/src/arkode/arkode_lsrkstep.c b/src/arkode/arkode_lsrkstep.c index 19a7e505f6..66cfbc5645 100644 --- a/src/arkode/arkode_lsrkstep.c +++ b/src/arkode/arkode_lsrkstep.c @@ -166,19 +166,19 @@ void* lsrkStep_Create_Commons(ARKRhsFn rhs, sunrealtype t0, N_Vector y0, } /* Attach step_mem structure and function pointers to ark_mem */ - ark_mem->step_init = lsrkStep_Init; - ark_mem->step_fullrhs = lsrkStep_FullRHS; - ark_mem->step = lsrkStep_TakeStepRKC; - ark_mem->step_printallstats = lsrkStep_PrintAllStats; - ark_mem->step_writeparameters = lsrkStep_WriteParameters; - ark_mem->step_free = lsrkStep_Free; - ark_mem->step_printmem = lsrkStep_PrintMem; - ark_mem->step_setoption = lsrkStep_SetOption; - ark_mem->step_setdefaults = lsrkStep_SetDefaults; - ark_mem->step_getnumrhsevals = lsrkStep_GetNumRhsEvals; - ark_mem->step_getestlocalerrors = lsrkStep_GetEstLocalErrors; - ark_mem->step_mem = (void*)step_mem; - ark_mem->step_supports_adaptive = SUNTRUE; + ark_mem->step_init = lsrkStep_Init; + ark_mem->step_fullrhs = lsrkStep_FullRHS; + ark_mem->step = lsrkStep_TakeStepRKC; + ark_mem->step_printallstats = lsrkStep_PrintAllStats; + ark_mem->step_writeparameters = lsrkStep_WriteParameters; + ark_mem->step_free = lsrkStep_Free; + ark_mem->step_printmem = lsrkStep_PrintMem; + ark_mem->step_setoption = lsrkStep_SetOption; + ark_mem->step_setdefaults = lsrkStep_SetDefaults; + ark_mem->step_getnumrhsevals = lsrkStep_GetNumRhsEvals; + ark_mem->step_getestlocalerrors = lsrkStep_GetEstLocalErrors; + ark_mem->step_mem = (void*)step_mem; + ark_mem->step_supports_adaptive = SUNTRUE; /* Set default values for optional inputs */ retval = lsrkStep_SetDefaults((void*)ark_mem); diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index ffedd02311..0ebb71c7c1 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -268,8 +268,8 @@ int mriStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], MRIStepCoupling Coupling = MRIStepCoupling_LoadTableByName(argv[*argidx]); if (Coupling == NULL) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, - __FILE__, "error setting key %s %s (invalid table name)", + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting key %s %s (invalid table name)", argv[(*argidx) - 1], argv[*argidx]); return ARK_ILL_INPUT; } @@ -277,8 +277,8 @@ int mriStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], MRIStepCoupling_Free(Coupling); if (retval != ARK_SUCCESS) { - arkProcessError(ark_mem, retval, __LINE__, __func__, - __FILE__, "error setting key %s %s (SetCoupling failed)", + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting key %s %s (SetCoupling failed)", argv[(*argidx) - 1], argv[*argidx]); return retval; } diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 279c9f935d..90a78a0f99 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -25,8 +25,8 @@ #include "cvode_impl.h" #include "sundials_cli.h" -static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, - int argc, char* argv[]); +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, + char* argv[]); /*--------------------------------------------------------------- CVodeSetOptions: @@ -34,15 +34,15 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, Sets CVODE options using strings. ---------------------------------------------------------------*/ -int CVodeSetOptions(void* cvode_mem, const char* cvid, - const char* file_name, int argc, char* argv[]) +int CVodeSetOptions(void* cvode_mem, const char* cvid, const char* file_name, + int argc, char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { - int retval = CV_ILL_INPUT; - cvProcessError(cvode_mem, retval, __LINE__, __func__, __FILE__, - "file-based options are not currently supported."); - return retval; + int retval = CV_ILL_INPUT; + cvProcessError(cvode_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; } if (argc > 0 && argv != NULL) @@ -58,8 +58,8 @@ int CVodeSetOptions(void* cvode_mem, const char* cvid, * Function to control CVODE options from the command line */ -static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, - int argc, char* argv[]) +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, + char* argv[]) { CVodeMem cv_mem; if (cvode_mem == NULL) @@ -166,8 +166,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (arg_used) continue; @@ -179,8 +178,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } if (arg_used) continue; @@ -193,8 +191,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - tworeal_pairs[j].key); + "error setting key: %s", tworeal_pairs[j].key); return retval; } if (arg_used) continue; @@ -207,8 +204,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - action_pairs[j].key); + "error setting key: %s", action_pairs[j].key); return retval; } if (arg_used) continue; diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index f4b9ffe3a7..7c9ce570b0 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -25,8 +25,8 @@ #include "cvodes_impl.h" #include "sundials_cli.h" -static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, - int argc, char* argv[]); +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, + char* argv[]); /*--------------------------------------------------------------- CVodeSetOptions: @@ -34,15 +34,15 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, Sets CVODE options using strings. ---------------------------------------------------------------*/ -int CVodeSetOptions(void* cvode_mem, const char* cvid, - const char* file_name, int argc, char* argv[]) +int CVodeSetOptions(void* cvode_mem, const char* cvid, const char* file_name, + int argc, char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { - int retval = CV_ILL_INPUT; - cvProcessError(cvode_mem, retval, __LINE__, __func__, __FILE__, - "file-based options are not currently supported."); - return retval; + int retval = CV_ILL_INPUT; + cvProcessError(cvode_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; } if (argc > 0 && argv != NULL) @@ -58,8 +58,8 @@ int CVodeSetOptions(void* cvode_mem, const char* cvid, * Function to control CVODE options from the command line */ -static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, - int argc, char* argv[]) +static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, + char* argv[]) { CVodeMem cv_mem; if (cvode_mem == NULL) @@ -198,8 +198,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (arg_used) continue; @@ -211,8 +210,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } if (arg_used) continue; @@ -225,8 +223,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - twoint_pairs[j].key); + "error setting key: %s", twoint_pairs[j].key); return retval; } if (arg_used) continue; @@ -239,8 +236,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - tworeal_pairs[j].key); + "error setting key: %s", tworeal_pairs[j].key); return retval; } if (arg_used) continue; @@ -253,8 +249,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - action_pairs[j].key); + "error setting key: %s", action_pairs[j].key); return retval; } if (arg_used) continue; @@ -267,8 +262,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_real_pairs[j].key); + "error setting key: %s", int_real_pairs[j].key); return retval; } if (arg_used) continue; @@ -281,8 +275,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_long_pairs[j].key); + "error setting key: %s", int_long_pairs[j].key); return retval; } if (arg_used) continue; @@ -296,8 +289,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, { retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_real_real_pairs[j].key); + "error setting key: %s", int_real_real_pairs[j].key); return retval; } if (arg_used) continue; diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index e83fc6ee74..d89143fe8b 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -24,8 +24,8 @@ #include "ida_impl.h" #include "sundials_cli.h" -static int idaSetFromCommandLine(void* ida_mem, const char* idaid, - int argc, char* argv[]); +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, + char* argv[]); /*--------------------------------------------------------------- IDASetOptions: @@ -33,15 +33,15 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, Sets IDA options using strings. ---------------------------------------------------------------*/ -int IDASetOptions(void* ida_mem, const char* idaid, - const char* file_name, int argc, char* argv[]) +int IDASetOptions(void* ida_mem, const char* idaid, const char* file_name, + int argc, char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { - int retval = IDA_ILL_INPUT; - IDAProcessError(ida_mem, retval, __LINE__, __func__, __FILE__, - "file-based options are not currently supported."); - return retval; + int retval = IDA_ILL_INPUT; + IDAProcessError(ida_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; } if (argc > 0 && argv != NULL) @@ -57,8 +57,8 @@ int IDASetOptions(void* ida_mem, const char* idaid, * Function to control IDA options from the command line */ -static int idaSetFromCommandLine(void* ida_mem, const char* idaid, - int argc, char* argv[]) +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, + char* argv[]) { IDAMem IDA_mem; if (ida_mem == NULL) @@ -145,8 +145,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (arg_used) continue; @@ -158,8 +157,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (arg_used) continue; @@ -171,8 +169,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } if (arg_used) continue; @@ -185,8 +182,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - tworeal_pairs[j].key); + "error setting key: %s", tworeal_pairs[j].key); return retval; } if (arg_used) continue; @@ -199,8 +195,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - action_pairs[j].key); + "error setting key: %s", action_pairs[j].key); return retval; } if (arg_used) continue; diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 8003c14e67..9179ea5fdb 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -24,8 +24,8 @@ #include "idas_impl.h" #include "sundials_cli.h" -static int idaSetFromCommandLine(void* ida_mem, const char* idaid, - int argc, char* argv[]); +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, + char* argv[]); /*--------------------------------------------------------------- IDASetOptions: @@ -33,15 +33,15 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, Sets IDA options using strings. ---------------------------------------------------------------*/ -int IDASetOptions(void* ida_mem, const char* idaid, - const char* file_name, int argc, char* argv[]) +int IDASetOptions(void* ida_mem, const char* idaid, const char* file_name, + int argc, char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { - int retval = IDA_ILL_INPUT; - IDAProcessError(ida_mem, retval, __LINE__, __func__, __FILE__, - "file-based options are not currently supported."); - return retval; + int retval = IDA_ILL_INPUT; + IDAProcessError(ida_mem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; } if (argc > 0 && argv != NULL) @@ -57,8 +57,8 @@ int IDASetOptions(void* ida_mem, const char* idaid, * Function to control IDA options from the command line */ -static int idaSetFromCommandLine(void* ida_mem, const char* idaid, - int argc, char* argv[]) +static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, + char* argv[]) { IDAMem IDA_mem; if (ida_mem == NULL) @@ -180,8 +180,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (arg_used) continue; @@ -193,8 +192,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (arg_used) continue; @@ -206,8 +204,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } if (arg_used) continue; @@ -220,8 +217,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - twoint_pairs[j].key); + "error setting key: %s", twoint_pairs[j].key); return retval; } if (arg_used) continue; @@ -234,8 +230,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - tworeal_pairs[j].key); + "error setting key: %s", tworeal_pairs[j].key); return retval; } if (arg_used) continue; @@ -248,8 +243,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - action_pairs[j].key); + "error setting key: %s", action_pairs[j].key); return retval; } if (arg_used) continue; @@ -262,8 +256,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_real_pairs[j].key); + "error setting key: %s", int_real_pairs[j].key); return retval; } if (arg_used) continue; @@ -276,8 +269,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_long_pairs[j].key); + "error setting key: %s", int_long_pairs[j].key); return retval; } if (arg_used) continue; @@ -291,8 +283,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, { retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_real_real_pairs[j].key); + "error setting key: %s", int_real_real_pairs[j].key); return retval; } if (arg_used) continue; diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 083d3cea3a..7f3670dfb4 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -24,8 +24,8 @@ #include "kinsol_impl.h" #include "sundials_cli.h" -static int kinSetFromCommandLine(void* kinmem, const char* kinid, - int argc, char* argv[]); +static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, + char* argv[]); /*--------------------------------------------------------------- KINSetOptions: @@ -38,10 +38,10 @@ int KINSetOptions(void* kinmem, const char* kinid, const char* file_name, { if (file_name != NULL && strlen(file_name) > 0) { - int retval = KIN_ILL_INPUT; - KINProcessError(kinmem, retval, __LINE__, __func__, __FILE__, - "file-based options are not currently supported."); - return retval; + int retval = KIN_ILL_INPUT; + KINProcessError(kinmem, retval, __LINE__, __func__, __FILE__, + "file-based options are not currently supported."); + return retval; } if (argc > 0 && argv != NULL) @@ -57,8 +57,8 @@ int KINSetOptions(void* kinmem, const char* kinid, const char* file_name, * Function to control KINSOL options from the command line */ -static int kinSetFromCommandLine(void* kinmem, const char* kinid, - int argc, char* argv[]) +static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, + char* argv[]) { KINMem kin_mem; if (kinmem == NULL) @@ -131,8 +131,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - int_pairs[j].key); + "error setting key: %s", int_pairs[j].key); return retval; } if (arg_used) continue; @@ -144,8 +143,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - long_pairs[j].key); + "error setting key: %s", long_pairs[j].key); return retval; } if (arg_used) continue; @@ -157,8 +155,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - real_pairs[j].key); + "error setting key: %s", real_pairs[j].key); return retval; } if (arg_used) continue; @@ -171,8 +168,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, { retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", - tworeal_pairs[j].key); + "error setting key: %s", tworeal_pairs[j].key); return retval; } if (arg_used) continue; diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 5b3b903c83..401ef0ab57 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -58,8 +58,8 @@ */ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); + const char* Cid, int argc, + char* argv[]); /* ----------------------------------------------------------------- * exported functions @@ -136,8 +136,8 @@ SUNErrCode SUNAdaptController_SetOptions_ImExGus(SUNAdaptController C, */ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) + const char* Cid, int argc, + char* argv[]) { SUNFunctionBegin(C->sunctx); diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 39cd52e25f..89fcef9e02 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -56,8 +56,8 @@ */ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]); + const char* Cid, int argc, + char* argv[]); /* ----------------------------------------------------------------- * exported functions @@ -147,8 +147,8 @@ SUNErrCode SUNAdaptController_SetOptions_MRIHTol(SUNAdaptController C, */ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) + const char* Cid, int argc, + char* argv[]) { SUNFunctionBegin(C->sunctx); diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 0740d3cef4..3da3df109b 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -73,8 +73,7 @@ */ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, - const char* Cid, - int argc, + const char* Cid, int argc, char* argv[]); /* ----------------------------------------------------------------- @@ -117,7 +116,6 @@ SUNAdaptController SUNAdaptController_Soderlind(SUNContext sunctx) return (C); } - /* ---------------------------------------------------------------------------- * Function to control set routines via the command line or file */ @@ -147,8 +145,8 @@ SUNErrCode SUNAdaptController_SetOptions_Soderlind(SUNAdaptController C, */ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, - const char* Cid, - int argc, char* argv[]) + const char* Cid, int argc, + char* argv[]) { SUNFunctionBegin(C->sunctx); diff --git a/src/sundials/sundials_adaptcontroller.c b/src/sundials/sundials_adaptcontroller.c index 335a7c61ff..049ea6f0af 100644 --- a/src/sundials/sundials_adaptcontroller.c +++ b/src/sundials/sundials_adaptcontroller.c @@ -173,10 +173,9 @@ SUNErrCode SUNAdaptController_Reset(SUNAdaptController C) return (ier); } -SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, - const char* Cid, - const char* file_name, - int argc, char* argv[]) +SUNErrCode SUNAdaptController_SetOptions(SUNAdaptController C, const char* Cid, + const char* file_name, int argc, + char* argv[]) { SUNErrCode ier = SUN_SUCCESS; if (C == NULL) { return SUN_ERR_ARG_CORRUPT; } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 19c42e9b4f..620f11d73a 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -166,7 +166,8 @@ SUNLinearSolver SUNLinSol_SPBCGS(N_Vector y, int pretype, int maxl, */ SUNErrCode SUNLinSolSetOptions_SPBCGS(SUNLinearSolver S, const char* LSid, - const char* file_name, int argc, char* argv[]) + const char* file_name, int argc, + char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index cc081ffbe9..fb3e97f7be 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -154,7 +154,8 @@ SUNLinearSolver SUNLinSol_SPFGMR(N_Vector y, int pretype, int maxl, */ SUNErrCode SUNLinSolSetOptions_SPFGMR(SUNLinearSolver S, const char* LSid, - const char* file_name, int argc, char* argv[]) + const char* file_name, int argc, + char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 183d92860a..540ce7c687 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -151,7 +151,8 @@ SUNLinearSolver SUNLinSol_SPGMR(N_Vector y, int pretype, int maxl, */ SUNErrCode SUNLinSolSetOptions_SPGMR(SUNLinearSolver S, const char* LSid, - const char* file_name, int argc, char* argv[]) + const char* file_name, int argc, + char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 61a9ea0899..f9e76f31f6 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -46,9 +46,8 @@ * ---------------------------------------------------------------------------- */ -static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]); +static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- @@ -167,7 +166,8 @@ SUNLinearSolver SUNLinSol_SPTFQMR(N_Vector y, int pretype, int maxl, */ SUNErrCode SUNLinSolSetOptions_SPTFQMR(SUNLinearSolver S, const char* LSid, - const char* file_name, int argc, char* argv[]) + const char* file_name, int argc, + char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { @@ -188,9 +188,8 @@ SUNErrCode SUNLinSolSetOptions_SPTFQMR(SUNLinearSolver S, const char* LSid, * Function to control set routines via the command line */ -static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, - const char* LSid, int argc, - char* argv[]) +static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]) { SUNFunctionBegin(S->sunctx); diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 7542f25972..f19c9bdb76 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -221,7 +221,8 @@ SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, SUNMatrix A, int num_threads, */ SUNErrCode SUNLinSolSetOptions_SuperLUMT(SUNLinearSolver S, const char* LSid, - const char* file_name, int argc, char* argv[]) + const char* file_name, int argc, + char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index cbeb62870c..002a5a2ca4 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -47,8 +47,8 @@ static void FreeContent(SUNNonlinearSolver NLS); */ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, - const char* NLSid, - int argc, char* argv[]); + const char* NLSid, int argc, + char* argv[]); /*============================================================================== Constructor to create a new fixed point solver @@ -346,8 +346,8 @@ SUNErrCode SUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver NLS, SUNErrCode SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver NLS, const char* NLSid, - const char* file_name, - int argc, char* argv[]) + const char* file_name, int argc, + char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) { @@ -364,8 +364,9 @@ SUNErrCode SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver NLS, return SUN_SUCCESS; } -static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, const char* NLSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, + const char* NLSid, int argc, + char* argv[]) { SUNFunctionBegin(NLS->sunctx); diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 948bad7fb2..3ac50060ed 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -41,8 +41,8 @@ */ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, - const char* NLSid, - int argc, char* argv[]); + const char* NLSid, int argc, + char* argv[]); /*============================================================================== Constructor to create a new Newton solver @@ -409,8 +409,7 @@ SUNErrCode SUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver NLS, } SUNErrCode SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver NLS, - const char* NLSid, - const char* file_name, + const char* NLSid, const char* file_name, int argc, char* argv[]) { if (file_name != NULL && strlen(file_name) > 0) @@ -428,8 +427,9 @@ SUNErrCode SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver NLS, return SUN_SUCCESS; } -static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, const char* NLSid, - int argc, char* argv[]) +static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, + const char* NLSid, int argc, + char* argv[]) { SUNFunctionBegin(NLS->sunctx); From 277e3ff2dcba0446adb24121ad8b8f3e8f88ce3c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 17:10:44 -0400 Subject: [PATCH 091/114] swig --- src/arkode/fmod_int32/farkode_mod.c | 27 +++- src/arkode/fmod_int32/farkode_mod.f90 | 105 +++++++++---- src/arkode/fmod_int64/farkode_mod.c | 27 +++- src/arkode/fmod_int64/farkode_mod.f90 | 105 +++++++++---- src/cvode/fmod_int32/fcvode_mod.c | 51 +++++++ src/cvode/fmod_int32/fcvode_mod.f90 | 79 +++++++++- src/cvode/fmod_int64/fcvode_mod.c | 51 +++++++ src/cvode/fmod_int64/fcvode_mod.f90 | 79 +++++++++- src/cvodes/fmod_int32/fcvodes_mod.c | 27 +++- src/cvodes/fmod_int32/fcvodes_mod.f90 | 87 +++++++++-- src/cvodes/fmod_int64/fcvodes_mod.c | 27 +++- src/cvodes/fmod_int64/fcvodes_mod.f90 | 87 +++++++++-- src/ida/fmod_int32/fida_mod.c | 51 +++++++ src/ida/fmod_int32/fida_mod.f90 | 79 +++++++++- src/ida/fmod_int64/fida_mod.c | 51 +++++++ src/ida/fmod_int64/fida_mod.f90 | 79 +++++++++- src/idas/fmod_int32/fidas_mod.c | 27 +++- src/idas/fmod_int32/fidas_mod.f90 | 87 +++++++++-- src/idas/fmod_int64/fidas_mod.c | 27 +++- src/idas/fmod_int64/fidas_mod.f90 | 87 +++++++++-- src/kinsol/fmod_int32/fkinsol_mod.c | 51 +++++++ src/kinsol/fmod_int32/fkinsol_mod.f90 | 79 +++++++++- src/kinsol/fmod_int64/fkinsol_mod.c | 51 +++++++ src/kinsol/fmod_int64/fkinsol_mod.f90 | 79 +++++++++- .../fsunadaptcontroller_imexgus_mod.c | 76 ++++++++++ .../fsunadaptcontroller_imexgus_mod.f90 | 75 +++++++++ .../fsunadaptcontroller_imexgus_mod.c | 76 ++++++++++ .../fsunadaptcontroller_imexgus_mod.f90 | 75 +++++++++ .../fsunadaptcontroller_mrihtol_mod.c | 35 +++++ .../fsunadaptcontroller_mrihtol_mod.f90 | 67 +++++++++ .../fsunadaptcontroller_mrihtol_mod.c | 35 +++++ .../fsunadaptcontroller_mrihtol_mod.f90 | 67 +++++++++ .../fsunadaptcontroller_soderlind_mod.c | 76 ++++++++++ .../fsunadaptcontroller_soderlind_mod.f90 | 75 +++++++++ .../fsunadaptcontroller_soderlind_mod.c | 76 ++++++++++ .../fsunadaptcontroller_soderlind_mod.f90 | 75 +++++++++ src/sundials/fmod_int32/fsundials_core_mod.c | 93 ++++++++++++ .../fmod_int32/fsundials_core_mod.f90 | 142 +++++++++++++++++- src/sundials/fmod_int64/fsundials_core_mod.c | 93 ++++++++++++ .../fmod_int64/fsundials_core_mod.f90 | 142 +++++++++++++++++- .../klu/fmod_int32/fsunlinsol_klu_mod.c | 55 +++++++ .../klu/fmod_int32/fsunlinsol_klu_mod.f90 | 67 +++++++++ .../klu/fmod_int64/fsunlinsol_klu_mod.c | 55 +++++++ .../klu/fmod_int64/fsunlinsol_klu_mod.f90 | 67 +++++++++ .../pcg/fmod_int32/fsunlinsol_pcg_mod.c | 76 ++++++++++ .../pcg/fmod_int32/fsunlinsol_pcg_mod.f90 | 75 +++++++++ .../pcg/fmod_int64/fsunlinsol_pcg_mod.c | 76 ++++++++++ .../pcg/fmod_int64/fsunlinsol_pcg_mod.f90 | 75 +++++++++ .../spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c | 76 ++++++++++ .../fmod_int32/fsunlinsol_spbcgs_mod.f90 | 75 +++++++++ .../spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c | 76 ++++++++++ .../fmod_int64/fsunlinsol_spbcgs_mod.f90 | 75 +++++++++ .../spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c | 76 ++++++++++ .../fmod_int32/fsunlinsol_spfgmr_mod.f90 | 75 +++++++++ .../spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c | 76 ++++++++++ .../fmod_int64/fsunlinsol_spfgmr_mod.f90 | 75 +++++++++ .../spgmr/fmod_int32/fsunlinsol_spgmr_mod.c | 76 ++++++++++ .../spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 | 75 +++++++++ .../spgmr/fmod_int64/fsunlinsol_spgmr_mod.c | 76 ++++++++++ .../spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 | 75 +++++++++ .../fmod_int32/fsunlinsol_sptfqmr_mod.c | 76 ++++++++++ .../fmod_int32/fsunlinsol_sptfqmr_mod.f90 | 75 +++++++++ .../fmod_int64/fsunlinsol_sptfqmr_mod.c | 76 ++++++++++ .../fmod_int64/fsunlinsol_sptfqmr_mod.f90 | 75 +++++++++ .../fmod_int32/fsunnonlinsol_fixedpoint_mod.c | 76 ++++++++++ .../fsunnonlinsol_fixedpoint_mod.f90 | 75 +++++++++ .../fmod_int64/fsunnonlinsol_fixedpoint_mod.c | 76 ++++++++++ .../fsunnonlinsol_fixedpoint_mod.f90 | 75 +++++++++ .../fmod_int32/fsunnonlinsol_newton_mod.c | 76 ++++++++++ .../fmod_int32/fsunnonlinsol_newton_mod.f90 | 75 +++++++++ .../fmod_int64/fsunnonlinsol_newton_mod.c | 76 ++++++++++ .../fmod_int64/fsunnonlinsol_newton_mod.f90 | 75 +++++++++ 72 files changed, 4982 insertions(+), 154 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index e37559cad2..d74f3058e9 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -267,9 +267,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -284,6 +281,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,6 +315,27 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } +SWIGEXPORT int _wrap_FARKodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "ARKodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)ARKodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index bc95869214..0305e1562a 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -118,6 +118,22 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FARKodeSetOptions public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -159,10 +175,6 @@ module farkode_mod public :: FARKodeSetNonlinConvCoef public :: FARKodeSetStagePredictFn public :: FARKodeSetAdaptController - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FARKodeSetAdaptControllerByName public :: FARKodeSetAdaptivityAdjustment public :: FARKodeSetCFLFraction @@ -275,14 +287,6 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -489,6 +493,20 @@ module farkode_mod ! WRAPPER DECLARATIONS interface +function swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FARKodeSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2509,6 +2527,51 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FARKodeSetOptions(arkode_mem, arkid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: arkid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = arkode_mem +call SWIG_string_to_chararray(arkid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3177,24 +3240,6 @@ function FARKodeSetAdaptController(arkode_mem, c) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - function FARKodeSetAdaptControllerByName(arkode_mem, cname) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 2a73314fba..4e113b1361 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -267,9 +267,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -284,6 +281,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,6 +315,27 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } +SWIGEXPORT int _wrap_FARKodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "ARKodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)ARKodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index 5a67e90489..ffa65919df 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -118,6 +118,22 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FARKodeSetOptions public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -159,10 +175,6 @@ module farkode_mod public :: FARKodeSetNonlinConvCoef public :: FARKodeSetStagePredictFn public :: FARKodeSetAdaptController - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FARKodeSetAdaptControllerByName public :: FARKodeSetAdaptivityAdjustment public :: FARKodeSetCFLFraction @@ -275,14 +287,6 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -489,6 +493,20 @@ module farkode_mod ! WRAPPER DECLARATIONS interface +function swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FARKodeSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2509,6 +2527,51 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FARKodeSetOptions(arkode_mem, arkid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: arkid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = arkode_mem +call SWIG_string_to_chararray(arkid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3177,24 +3240,6 @@ function FARKodeSetAdaptController(arkode_mem, c) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - function FARKodeSetAdaptControllerByName(arkode_mem, cname) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int32/fcvode_mod.c b/src/cvode/fmod_int32/fcvode_mod.c index bfd166d327..6fc3f3f2d2 100644 --- a/src/cvode/fmod_int32/fcvode_mod.c +++ b/src/cvode/fmod_int32/fcvode_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -236,6 +252,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -354,6 +384,27 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int32/fcvode_mod.f90 b/src/cvode/fmod_int32/fcvode_mod.f90 index 4666447bf0..15ecd0d41d 100644 --- a/src/cvode/fmod_int32/fcvode_mod.f90 +++ b/src/cvode/fmod_int32/fcvode_mod.f90 @@ -70,6 +70,22 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -136,10 +152,6 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -281,6 +293,20 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FCVodeSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1502,6 +1528,51 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int64/fcvode_mod.c b/src/cvode/fmod_int64/fcvode_mod.c index 199e1ae5da..fc40b78d90 100644 --- a/src/cvode/fmod_int64/fcvode_mod.c +++ b/src/cvode/fmod_int64/fcvode_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -236,6 +252,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -354,6 +384,27 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int64/fcvode_mod.f90 b/src/cvode/fmod_int64/fcvode_mod.f90 index 9e9b4d1f63..24a6cef237 100644 --- a/src/cvode/fmod_int64/fcvode_mod.f90 +++ b/src/cvode/fmod_int64/fcvode_mod.f90 @@ -70,6 +70,22 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -136,10 +152,6 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -281,6 +293,20 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FCVodeSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1502,6 +1528,51 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int32/fcvodes_mod.c b/src/cvodes/fmod_int32/fcvodes_mod.c index fe19fb2fcb..7e74f76247 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.c +++ b/src/cvodes/fmod_int32/fcvodes_mod.c @@ -264,9 +264,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -281,6 +278,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -428,6 +428,27 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int32/fcvodes_mod.f90 b/src/cvodes/fmod_int32/fcvodes_mod.f90 index 6dfbe9bd7a..a47973879d 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int32/fcvodes_mod.f90 @@ -101,6 +101,22 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -171,10 +187,6 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -269,14 +281,6 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -456,6 +460,20 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FCVodeSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2909,6 +2927,51 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int64/fcvodes_mod.c b/src/cvodes/fmod_int64/fcvodes_mod.c index 9f76cd3e89..82a7ae207d 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.c +++ b/src/cvodes/fmod_int64/fcvodes_mod.c @@ -264,9 +264,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -281,6 +278,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -428,6 +428,27 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } +SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int64/fcvodes_mod.f90 b/src/cvodes/fmod_int64/fcvodes_mod.f90 index 345d17dc55..594d1f56fb 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int64/fcvodes_mod.f90 @@ -101,6 +101,22 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -171,10 +187,6 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -269,14 +281,6 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -456,6 +460,20 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FCVodeSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2909,6 +2927,51 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: cvode_mem +character(kind=C_CHAR, len=*), target :: cvid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = cvode_mem +call SWIG_string_to_chararray(cvid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int32/fida_mod.c b/src/ida/fmod_int32/fida_mod.c index 68dfeea91f..1fa5cbf98e 100644 --- a/src/ida/fmod_int32/fida_mod.c +++ b/src/ida/fmod_int32/fida_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -347,6 +377,27 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int32/fida_mod.f90 b/src/ida/fmod_int32/fida_mod.f90 index 136521893f..f613188c49 100644 --- a/src/ida/fmod_int32/fida_mod.f90 +++ b/src/ida/fmod_int32/fida_mod.f90 @@ -68,6 +68,22 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -135,10 +151,6 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -252,6 +264,20 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FIDASetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1307,6 +1333,51 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int64/fida_mod.c b/src/ida/fmod_int64/fida_mod.c index 02def580d4..53f1638a39 100644 --- a/src/ida/fmod_int64/fida_mod.c +++ b/src/ida/fmod_int64/fida_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -347,6 +377,27 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int64/fida_mod.f90 b/src/ida/fmod_int64/fida_mod.f90 index 5e3fee8ae6..c3a3ffcbf3 100644 --- a/src/ida/fmod_int64/fida_mod.f90 +++ b/src/ida/fmod_int64/fida_mod.f90 @@ -68,6 +68,22 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -135,10 +151,6 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -252,6 +264,20 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FIDASetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1307,6 +1333,51 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int32/fidas_mod.c b/src/idas/fmod_int32/fidas_mod.c index c39dff4a1f..5c9e1b2ada 100644 --- a/src/idas/fmod_int32/fidas_mod.c +++ b/src/idas/fmod_int32/fidas_mod.c @@ -262,9 +262,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -279,6 +276,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,6 +422,27 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int32/fidas_mod.f90 b/src/idas/fmod_int32/fidas_mod.f90 index db6f376bfc..549e186d98 100644 --- a/src/idas/fmod_int32/fidas_mod.f90 +++ b/src/idas/fmod_int32/fidas_mod.f90 @@ -93,6 +93,22 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -165,10 +181,6 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -261,14 +273,6 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -424,6 +428,20 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FIDASetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2756,6 +2774,51 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int64/fidas_mod.c b/src/idas/fmod_int64/fidas_mod.c index 196fd9f52b..1eed701d11 100644 --- a/src/idas/fmod_int64/fidas_mod.c +++ b/src/idas/fmod_int64/fidas_mod.c @@ -262,9 +262,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -#include - - typedef struct { void* cptr; int cmemflags; @@ -279,6 +276,9 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } +#include + + SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,6 +422,27 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } +SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int64/fidas_mod.f90 b/src/idas/fmod_int64/fidas_mod.f90 index b379e13d36..0255d9fae5 100644 --- a/src/idas/fmod_int64/fidas_mod.f90 +++ b/src/idas/fmod_int64/fidas_mod.f90 @@ -93,6 +93,22 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -165,10 +181,6 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -261,14 +273,6 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -424,6 +428,20 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FIDASetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2756,6 +2774,51 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: ida_mem +character(kind=C_CHAR, len=*), target :: idaid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = ida_mem +call SWIG_string_to_chararray(idaid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int32/fkinsol_mod.c b/src/kinsol/fmod_int32/fkinsol_mod.c index 82121bdb1a..3faa3c1951 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.c +++ b/src/kinsol/fmod_int32/fkinsol_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -283,6 +313,27 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } +SWIGEXPORT int _wrap_FKINSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "KINSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)KINSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int32/fkinsol_mod.f90 b/src/kinsol/fmod_int32/fkinsol_mod.f90 index 15a5083d9b..9c9ae157b1 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int32/fkinsol_mod.f90 @@ -62,6 +62,22 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FKINSetOptions public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -98,10 +114,6 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -169,6 +181,20 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function +function swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FKINSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -770,6 +796,51 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FKINSetOptions(kinmem, kinid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: kinmem +character(kind=C_CHAR, len=*), target :: kinid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = kinmem +call SWIG_string_to_chararray(kinid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int64/fkinsol_mod.c b/src/kinsol/fmod_int64/fkinsol_mod.c index e6d208fd6a..7a6e866cea 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.c +++ b/src/kinsol/fmod_int64/fkinsol_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -233,6 +249,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -283,6 +313,27 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } +SWIGEXPORT int _wrap_FKINSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "KINSetOptions(void *,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (int)KINSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int64/fkinsol_mod.f90 b/src/kinsol/fmod_int64/fkinsol_mod.f90 index e22feeb1f7..43c0c633a2 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int64/fkinsol_mod.f90 @@ -62,6 +62,22 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FKINSetOptions public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -98,10 +114,6 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -169,6 +181,20 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function +function swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FKINSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -770,6 +796,51 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FKINSetOptions(kinmem, kinid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: kinmem +character(kind=C_CHAR, len=*), target :: kinid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = kinmem +call SWIG_string_to_chararray(kinid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c index 9d4e4a3afd..311802cc0e 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -310,6 +365,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImExGus(SUNAdaptController farg1, } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions_ImExGus(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions_ImExGus(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions_ImExGus(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 index 4dc30dc6a1..4399db762a 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod_int32/fsunadaptcontroller_imexgus_mod.f90 @@ -32,6 +32,22 @@ module fsunadaptcontroller_imexgus_mod public :: FSUNAdaptController_Reset_ImExGus public :: FSUNAdaptController_SetDefaults_ImExGus public :: FSUNAdaptController_Write_ImExGus + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetOptions_ImExGus public :: FSUNAdaptController_SetErrorBias_ImExGus public :: FSUNAdaptController_UpdateH_ImExGus public :: FSUNAdaptController_Space_ImExGus @@ -103,6 +119,20 @@ function swigc_FSUNAdaptController_Write_ImExGus(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions_ImExGus(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImExGus") & result(fresult) @@ -255,6 +285,51 @@ function FSUNAdaptController_Write_ImExGus(c, fptr) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetOptions_ImExGus(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions_ImExGus(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetErrorBias_ImExGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c index 9d4e4a3afd..311802cc0e 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c +++ b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_imexgus.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_ImExGus(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -310,6 +365,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Write_ImExGus(SUNAdaptController farg1, } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions_ImExGus(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions_ImExGus(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions_ImExGus(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetErrorBias_ImExGus(SUNAdaptController farg1, double const *farg2) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 index 4dc30dc6a1..4399db762a 100644 --- a/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 +++ b/src/sunadaptcontroller/imexgus/fmod_int64/fsunadaptcontroller_imexgus_mod.f90 @@ -32,6 +32,22 @@ module fsunadaptcontroller_imexgus_mod public :: FSUNAdaptController_Reset_ImExGus public :: FSUNAdaptController_SetDefaults_ImExGus public :: FSUNAdaptController_Write_ImExGus + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetOptions_ImExGus public :: FSUNAdaptController_SetErrorBias_ImExGus public :: FSUNAdaptController_UpdateH_ImExGus public :: FSUNAdaptController_Space_ImExGus @@ -103,6 +119,20 @@ function swigc_FSUNAdaptController_Write_ImExGus(farg1, farg2) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions_ImExGus(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions_ImExGus") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetErrorBias_ImExGus(farg1, farg2) & bind(C, name="_wrap_FSUNAdaptController_SetErrorBias_ImExGus") & result(fresult) @@ -255,6 +285,51 @@ function FSUNAdaptController_Write_ImExGus(c, fptr) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetOptions_ImExGus(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions_ImExGus(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetErrorBias_ImExGus(c, bias) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c index 41ec1e1d1c..7442db50ad 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.c @@ -297,6 +297,20 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; @@ -560,6 +574,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIHTol(SUNAdaptController farg1) } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions_MRIHTol(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions_MRIHTol(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions_MRIHTol(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 index e7afddd833..4406f0a4e3 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int32/fsunadaptcontroller_mrihtol_mod.f90 @@ -61,6 +61,14 @@ module fsunadaptcontroller_mrihtol_mod public :: FSUNAdaptController_GetType_MRIHTol public :: FSUNAdaptController_EstimateStepTol_MRIHTol public :: FSUNAdaptController_Reset_MRIHTol + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetOptions_MRIHTol public :: FSUNAdaptController_SetDefaults_MRIHTol public :: FSUNAdaptController_Write_MRIHTol public :: FSUNAdaptController_SetErrorBias_MRIHTol @@ -247,6 +255,20 @@ function swigc_FSUNAdaptController_Reset_MRIHTol(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions_MRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults_MRIHTol(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIHTol") & result(fresult) @@ -595,6 +617,51 @@ function FSUNAdaptController_Reset_MRIHTol(c) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetOptions_MRIHTol(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions_MRIHTol(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults_MRIHTol(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c index 41ec1e1d1c..7442db50ad 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.c @@ -297,6 +297,20 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT void _wrap_SUNAdaptControllerContent_MRIHTol__HControl_set(SwigClassWrapper const *farg1, SUNAdaptController farg2) { struct SUNAdaptControllerContent_MRIHTol_ *arg1 = (struct SUNAdaptControllerContent_MRIHTol_ *) 0 ; SUNAdaptController arg2 = (SUNAdaptController) 0 ; @@ -560,6 +574,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset_MRIHTol(SUNAdaptController farg1) } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions_MRIHTol(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions_MRIHTol(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions_MRIHTol(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 index e7afddd833..4406f0a4e3 100644 --- a/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 +++ b/src/sunadaptcontroller/mrihtol/fmod_int64/fsunadaptcontroller_mrihtol_mod.f90 @@ -61,6 +61,14 @@ module fsunadaptcontroller_mrihtol_mod public :: FSUNAdaptController_GetType_MRIHTol public :: FSUNAdaptController_EstimateStepTol_MRIHTol public :: FSUNAdaptController_Reset_MRIHTol + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetOptions_MRIHTol public :: FSUNAdaptController_SetDefaults_MRIHTol public :: FSUNAdaptController_Write_MRIHTol public :: FSUNAdaptController_SetErrorBias_MRIHTol @@ -247,6 +255,20 @@ function swigc_FSUNAdaptController_Reset_MRIHTol(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions_MRIHTol(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions_MRIHTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults_MRIHTol(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults_MRIHTol") & result(fresult) @@ -595,6 +617,51 @@ function FSUNAdaptController_Reset_MRIHTol(c) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetOptions_MRIHTol(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions_MRIHTol(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults_MRIHTol(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c index 14d6914974..bbd541c121 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -286,6 +341,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset_Soderlind(SUNAdaptController farg } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions_Soderlind(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions_Soderlind(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions_Soderlind(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_Soderlind(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 index e0f391f7ef..fabefd94e4 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod_int32/fsunadaptcontroller_soderlind_mod.f90 @@ -30,6 +30,22 @@ module fsunadaptcontroller_soderlind_mod public :: FSUNAdaptController_GetType_Soderlind public :: FSUNAdaptController_EstimateStep_Soderlind public :: FSUNAdaptController_Reset_Soderlind + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetOptions_Soderlind public :: FSUNAdaptController_SetDefaults_Soderlind public :: FSUNAdaptController_Write_Soderlind public :: FSUNAdaptController_SetErrorBias_Soderlind @@ -101,6 +117,20 @@ function swigc_FSUNAdaptController_Reset_Soderlind(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions_Soderlind(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults_Soderlind(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults_Soderlind") & result(fresult) @@ -366,6 +396,51 @@ function FSUNAdaptController_Reset_Soderlind(c) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetOptions_Soderlind(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions_Soderlind(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults_Soderlind(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c index 14d6914974..bbd541c121 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c +++ b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunadaptcontroller/sunadaptcontroller_soderlind.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNAdaptController _wrap_FSUNAdaptController_Soderlind(void *farg1) { SUNAdaptController fresult ; SUNContext arg1 = (SUNContext) 0 ; @@ -286,6 +341,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset_Soderlind(SUNAdaptController farg } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions_Soderlind(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions_Soderlind(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions_Soderlind(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults_Soderlind(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 index e0f391f7ef..fabefd94e4 100644 --- a/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 +++ b/src/sunadaptcontroller/soderlind/fmod_int64/fsunadaptcontroller_soderlind_mod.f90 @@ -30,6 +30,22 @@ module fsunadaptcontroller_soderlind_mod public :: FSUNAdaptController_GetType_Soderlind public :: FSUNAdaptController_EstimateStep_Soderlind public :: FSUNAdaptController_Reset_Soderlind + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNAdaptController_SetOptions_Soderlind public :: FSUNAdaptController_SetDefaults_Soderlind public :: FSUNAdaptController_Write_Soderlind public :: FSUNAdaptController_SetErrorBias_Soderlind @@ -101,6 +117,20 @@ function swigc_FSUNAdaptController_Reset_Soderlind(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions_Soderlind(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions_Soderlind") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults_Soderlind(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults_Soderlind") & result(fresult) @@ -366,6 +396,51 @@ function FSUNAdaptController_Reset_Soderlind(c) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNAdaptController_SetOptions_Soderlind(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions_Soderlind(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults_Soderlind(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index 9b579ade0f..c17c16c671 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -193,6 +193,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -286,6 +302,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include "sundials/sundials_nonlinearsolver.h" @@ -2173,6 +2203,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; @@ -2463,6 +2514,27 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn(SUNNonlinearSolver farg1, SUNNon } +SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNNonlinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNNonlinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; @@ -2621,6 +2693,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 3871ac3360..594070de0e 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -425,7 +425,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: setatimes type(C_FUNPTR), public :: setpreconditioner type(C_FUNPTR), public :: setscalingvectors - type(C_FUNPTR), public :: setfromcommandline + type(C_FUNPTR), public :: setoptions type(C_FUNPTR), public :: setzeroguess type(C_FUNPTR), public :: initialize type(C_FUNPTR), public :: setup @@ -450,6 +450,18 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FSUNLinSolSetOptions public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -494,6 +506,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: setlsetupfn type(C_FUNPTR), public :: setlsolvefn type(C_FUNPTR), public :: setctestfn + type(C_FUNPTR), public :: setoptions type(C_FUNPTR), public :: setmaxiters type(C_FUNPTR), public :: getnumiters type(C_FUNPTR), public :: getcuriter @@ -516,6 +529,7 @@ module fsundials_core_mod public :: FSUNNonlinSolSetLSetupFn public :: FSUNNonlinSolSetLSolveFn public :: FSUNNonlinSolSetConvTestFn + public :: FSUNNonlinSolSetOptions public :: FSUNNonlinSolSetMaxIters public :: FSUNNonlinSolGetNumIters public :: FSUNNonlinSolGetCurIter @@ -537,7 +551,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset - type(C_FUNPTR), public :: setfromcommandline + type(C_FUNPTR), public :: setoptions type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias @@ -558,6 +572,7 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset + public :: FSUNAdaptController_SetOptions public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -1853,6 +1868,20 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -2040,6 +2069,20 @@ function swigc_FSUNNonlinSolSetConvTestFn(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNNonlinSolSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNNonlinSolSetMaxIters(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters") & result(fresult) @@ -2141,6 +2184,20 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -5031,6 +5088,33 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function +function FSUNLinSolSetOptions(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5363,6 +5447,33 @@ function FSUNNonlinSolSetConvTestFn(nls, ctestfn, ctest_data) & swig_result = fresult end function +function FSUNNonlinSolSetOptions(nls, nlsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNNonlinearSolver), target, intent(inout) :: nls +character(kind=C_CHAR, len=*), target :: nlsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(nls) +call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNNonlinSolSetMaxIters(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5547,6 +5658,33 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function +function FSUNAdaptController_SetOptions(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index f1558f4027..7f3a59566b 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -193,6 +193,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -286,6 +302,20 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + + #include "sundials/sundials_nonlinearsolver.h" @@ -2173,6 +2203,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; @@ -2463,6 +2514,27 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn(SUNNonlinearSolver farg1, SUNNon } +SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNNonlinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNNonlinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; @@ -2621,6 +2693,27 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } +SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNAdaptController arg1 = (SUNAdaptController) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNAdaptController)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions(SUNAdaptController,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNAdaptController_SetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 583fc47cd8..6b5997884b 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -425,7 +425,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: setatimes type(C_FUNPTR), public :: setpreconditioner type(C_FUNPTR), public :: setscalingvectors - type(C_FUNPTR), public :: setfromcommandline + type(C_FUNPTR), public :: setoptions type(C_FUNPTR), public :: setzeroguess type(C_FUNPTR), public :: initialize type(C_FUNPTR), public :: setup @@ -450,6 +450,18 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + public :: FSUNLinSolSetOptions public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -494,6 +506,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: setlsetupfn type(C_FUNPTR), public :: setlsolvefn type(C_FUNPTR), public :: setctestfn + type(C_FUNPTR), public :: setoptions type(C_FUNPTR), public :: setmaxiters type(C_FUNPTR), public :: getnumiters type(C_FUNPTR), public :: getcuriter @@ -516,6 +529,7 @@ module fsundials_core_mod public :: FSUNNonlinSolSetLSetupFn public :: FSUNNonlinSolSetLSolveFn public :: FSUNNonlinSolSetConvTestFn + public :: FSUNNonlinSolSetOptions public :: FSUNNonlinSolSetMaxIters public :: FSUNNonlinSolGetNumIters public :: FSUNNonlinSolGetCurIter @@ -537,7 +551,7 @@ module fsundials_core_mod type(C_FUNPTR), public :: estimatesteptol type(C_FUNPTR), public :: destroy type(C_FUNPTR), public :: reset - type(C_FUNPTR), public :: setfromcommandline + type(C_FUNPTR), public :: setoptions type(C_FUNPTR), public :: setdefaults type(C_FUNPTR), public :: write type(C_FUNPTR), public :: seterrorbias @@ -558,6 +572,7 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset + public :: FSUNAdaptController_SetOptions public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -1853,6 +1868,20 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -2040,6 +2069,20 @@ function swigc_FSUNNonlinSolSetConvTestFn(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNNonlinSolSetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNNonlinSolSetMaxIters(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters") & result(fresult) @@ -2141,6 +2184,20 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNAdaptController_SetOptions") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -5031,6 +5088,33 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function +function FSUNLinSolSetOptions(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5363,6 +5447,33 @@ function FSUNNonlinSolSetConvTestFn(nls, ctestfn, ctest_data) & swig_result = fresult end function +function FSUNNonlinSolSetOptions(nls, nlsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNNonlinearSolver), target, intent(inout) :: nls +character(kind=C_CHAR, len=*), target :: nlsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(nls) +call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNNonlinSolSetMaxIters(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5547,6 +5658,33 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function +function FSUNAdaptController_SetOptions(c, cid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNAdaptController), target, intent(inout) :: c +character(kind=C_CHAR, len=*), target :: cid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(c) +call SWIG_string_to_chararray(cid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c index 504612c0e0..0043d2fdfb 100644 --- a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c +++ b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.c @@ -185,6 +185,15 @@ enum { }; +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -229,6 +238,31 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { return result; } + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_KLU(N_Vector farg1, SUNMatrix farg2, void *farg3) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +374,27 @@ SWIGEXPORT int _wrap_FSUNLinSolGetID_KLU(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_KLU(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_KLU(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_KLU(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolInitialize_KLU(SUNLinearSolver farg1) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 index bbd312f674..5787b6c367 100644 --- a/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 +++ b/src/sunlinsol/klu/fmod_int32/fsunlinsol_klu_mod.f90 @@ -53,6 +53,14 @@ module fsunlinsol_klu_mod public :: FSUNLinSol_KLUGetCommon public :: FSUNLinSolGetType_KLU public :: FSUNLinSolGetID_KLU + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_KLU public :: FSUNLinSolInitialize_KLU public :: FSUNLinSolSetup_KLU public :: FSUNLinSolSolve_KLU @@ -135,6 +143,20 @@ function swigc_FSUNLinSolGetID_KLU(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_KLU(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_KLU") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolInitialize_KLU(farg1) & bind(C, name="_wrap_FSUNLinSolInitialize_KLU") & result(fresult) @@ -317,6 +339,51 @@ function FSUNLinSolGetID_KLU(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_KLU(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_KLU(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolInitialize_KLU(s) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c index 3e7b8d0614..59ee503e92 100644 --- a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c +++ b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.c @@ -185,6 +185,15 @@ enum { }; +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -229,6 +238,31 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { return result; } + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_KLU(N_Vector farg1, SUNMatrix farg2, void *farg3) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +374,27 @@ SWIGEXPORT int _wrap_FSUNLinSolGetID_KLU(SUNLinearSolver farg1) { } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_KLU(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_KLU(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_KLU(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolInitialize_KLU(SUNLinearSolver farg1) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 index f836c8b140..542c26051d 100644 --- a/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 +++ b/src/sunlinsol/klu/fmod_int64/fsunlinsol_klu_mod.f90 @@ -53,6 +53,14 @@ module fsunlinsol_klu_mod public :: FSUNLinSol_KLUGetCommon public :: FSUNLinSolGetType_KLU public :: FSUNLinSolGetID_KLU + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_KLU public :: FSUNLinSolInitialize_KLU public :: FSUNLinSolSetup_KLU public :: FSUNLinSolSolve_KLU @@ -135,6 +143,20 @@ function swigc_FSUNLinSolGetID_KLU(farg1) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_KLU(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_KLU") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolInitialize_KLU(farg1) & bind(C, name="_wrap_FSUNLinSolInitialize_KLU") & result(fresult) @@ -317,6 +339,51 @@ function FSUNLinSolGetID_KLU(s) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_KLU(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_KLU(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolInitialize_KLU(s) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c index 9c2f9bcb44..4936817057 100644 --- a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c +++ b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_pcg.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_PCG(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +395,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_PCG(SUNLinearSolver farg1, N_Ve } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_PCG(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_PCG(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_PCG(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_PCG(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 index 5a38ae2960..7c2461c7a1 100644 --- a/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 +++ b/src/sunlinsol/pcg/fmod_int32/fsunlinsol_pcg_mod.f90 @@ -35,6 +35,22 @@ module fsunlinsol_pcg_mod public :: FSUNLinSolSetATimes_PCG public :: FSUNLinSolSetPreconditioner_PCG public :: FSUNLinSolSetScalingVectors_PCG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_PCG public :: FSUNLinSolSetZeroGuess_PCG public :: FSUNLinSolSetup_PCG public :: FSUNLinSolSolve_PCG @@ -131,6 +147,20 @@ function swigc_FSUNLinSolSetScalingVectors_PCG(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_PCG(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_PCG") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_PCG(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_PCG") & result(fresult) @@ -369,6 +399,51 @@ function FSUNLinSolSetScalingVectors_PCG(s, s1, nul) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_PCG(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_PCG(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_PCG(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c index 6173f11b75..a3f2dcb411 100644 --- a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c +++ b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_pcg.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_PCG(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +395,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_PCG(SUNLinearSolver farg1, N_Ve } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_PCG(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_PCG(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_PCG(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_PCG(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 index b6f5851f0e..609f1b91b1 100644 --- a/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 +++ b/src/sunlinsol/pcg/fmod_int64/fsunlinsol_pcg_mod.f90 @@ -35,6 +35,22 @@ module fsunlinsol_pcg_mod public :: FSUNLinSolSetATimes_PCG public :: FSUNLinSolSetPreconditioner_PCG public :: FSUNLinSolSetScalingVectors_PCG + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_PCG public :: FSUNLinSolSetZeroGuess_PCG public :: FSUNLinSolSetup_PCG public :: FSUNLinSolSolve_PCG @@ -131,6 +147,20 @@ function swigc_FSUNLinSolSetScalingVectors_PCG(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_PCG(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_PCG") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_PCG(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_PCG") & result(fresult) @@ -369,6 +399,51 @@ function FSUNLinSolSetScalingVectors_PCG(s, s1, nul) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_PCG(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_PCG(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_PCG(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c index 1a864f19a6..184a3fd1e4 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c +++ b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spbcgs.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPBCGS(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +395,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPBCGS(SUNLinearSolver farg1, N } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPBCGS(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPBCGS(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPBCGS(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPBCGS(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 index b83fe50880..438b7891c2 100644 --- a/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 +++ b/src/sunlinsol/spbcgs/fmod_int32/fsunlinsol_spbcgs_mod.f90 @@ -35,6 +35,22 @@ module fsunlinsol_spbcgs_mod public :: FSUNLinSolSetATimes_SPBCGS public :: FSUNLinSolSetPreconditioner_SPBCGS public :: FSUNLinSolSetScalingVectors_SPBCGS + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPBCGS public :: FSUNLinSolSetZeroGuess_SPBCGS public :: FSUNLinSolSetup_SPBCGS public :: FSUNLinSolSolve_SPBCGS @@ -131,6 +147,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPBCGS(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPBCGS(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPBCGS") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPBCGS(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPBCGS") & result(fresult) @@ -369,6 +399,51 @@ function FSUNLinSolSetScalingVectors_SPBCGS(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPBCGS(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPBCGS(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPBCGS(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c index 731012db16..b553657138 100644 --- a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c +++ b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spbcgs.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPBCGS(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +395,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPBCGS(SUNLinearSolver farg1, N } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPBCGS(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPBCGS(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPBCGS(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPBCGS(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 index 3530bf5bf3..bcb57a83dd 100644 --- a/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 +++ b/src/sunlinsol/spbcgs/fmod_int64/fsunlinsol_spbcgs_mod.f90 @@ -35,6 +35,22 @@ module fsunlinsol_spbcgs_mod public :: FSUNLinSolSetATimes_SPBCGS public :: FSUNLinSolSetPreconditioner_SPBCGS public :: FSUNLinSolSetScalingVectors_SPBCGS + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPBCGS public :: FSUNLinSolSetZeroGuess_SPBCGS public :: FSUNLinSolSetup_SPBCGS public :: FSUNLinSolSolve_SPBCGS @@ -131,6 +147,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPBCGS(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPBCGS(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPBCGS") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPBCGS(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPBCGS") & result(fresult) @@ -369,6 +399,51 @@ function FSUNLinSolSetScalingVectors_SPBCGS(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPBCGS(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPBCGS(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPBCGS(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c index 9cb339ae7c..fa9b3583fb 100644 --- a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c +++ b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spfgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -354,6 +409,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver farg1, N } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPFGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPFGMR(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPFGMR(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPFGMR(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 index 6a8f7896e8..5ce94e77db 100644 --- a/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 +++ b/src/sunlinsol/spfgmr/fmod_int32/fsunlinsol_spfgmr_mod.f90 @@ -37,6 +37,22 @@ module fsunlinsol_spfgmr_mod public :: FSUNLinSolSetATimes_SPFGMR public :: FSUNLinSolSetPreconditioner_SPFGMR public :: FSUNLinSolSetScalingVectors_SPFGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPFGMR public :: FSUNLinSolSetZeroGuess_SPFGMR public :: FSUNLinSolSetup_SPFGMR public :: FSUNLinSolSolve_SPFGMR @@ -142,6 +158,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPFGMR(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPFGMR(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPFGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPFGMR(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPFGMR") & result(fresult) @@ -396,6 +426,51 @@ function FSUNLinSolSetScalingVectors_SPFGMR(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPFGMR(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPFGMR(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPFGMR(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c index 7c30b5166d..7fb251a200 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c +++ b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spfgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPFGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -354,6 +409,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPFGMR(SUNLinearSolver farg1, N } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPFGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPFGMR(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPFGMR(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPFGMR(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 index 88ae7451b5..ca1e8ec7fc 100644 --- a/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 +++ b/src/sunlinsol/spfgmr/fmod_int64/fsunlinsol_spfgmr_mod.f90 @@ -37,6 +37,22 @@ module fsunlinsol_spfgmr_mod public :: FSUNLinSolSetATimes_SPFGMR public :: FSUNLinSolSetPreconditioner_SPFGMR public :: FSUNLinSolSetScalingVectors_SPFGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPFGMR public :: FSUNLinSolSetZeroGuess_SPFGMR public :: FSUNLinSolSetup_SPFGMR public :: FSUNLinSolSolve_SPFGMR @@ -142,6 +158,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPFGMR(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPFGMR(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPFGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPFGMR(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPFGMR") & result(fresult) @@ -396,6 +426,51 @@ function FSUNLinSolSetScalingVectors_SPFGMR(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPFGMR(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPFGMR(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPFGMR(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c index 2be19f50fe..97ee578840 100644 --- a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c +++ b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -354,6 +409,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPGMR(SUNLinearSolver farg1, N_ } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPGMR(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPGMR(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPGMR(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 index b71379bbb2..ee9c7d8299 100644 --- a/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 +++ b/src/sunlinsol/spgmr/fmod_int32/fsunlinsol_spgmr_mod.f90 @@ -37,6 +37,22 @@ module fsunlinsol_spgmr_mod public :: FSUNLinSolSetATimes_SPGMR public :: FSUNLinSolSetPreconditioner_SPGMR public :: FSUNLinSolSetScalingVectors_SPGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPGMR public :: FSUNLinSolSetZeroGuess_SPGMR public :: FSUNLinSolSetup_SPGMR public :: FSUNLinSolSolve_SPGMR @@ -142,6 +158,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPGMR(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPGMR(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPGMR(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPGMR") & result(fresult) @@ -396,6 +426,51 @@ function FSUNLinSolSetScalingVectors_SPGMR(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPGMR(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPGMR(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPGMR(s, onff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c index 8063348bb1..6247fa891e 100644 --- a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c +++ b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_spgmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPGMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -354,6 +409,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPGMR(SUNLinearSolver farg1, N_ } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPGMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPGMR(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPGMR(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPGMR(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 index 950e7ee8a7..536a68f0fd 100644 --- a/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 +++ b/src/sunlinsol/spgmr/fmod_int64/fsunlinsol_spgmr_mod.f90 @@ -37,6 +37,22 @@ module fsunlinsol_spgmr_mod public :: FSUNLinSolSetATimes_SPGMR public :: FSUNLinSolSetPreconditioner_SPGMR public :: FSUNLinSolSetScalingVectors_SPGMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPGMR public :: FSUNLinSolSetZeroGuess_SPGMR public :: FSUNLinSolSetup_SPGMR public :: FSUNLinSolSolve_SPGMR @@ -142,6 +158,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPGMR(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPGMR(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPGMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPGMR(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPGMR") & result(fresult) @@ -396,6 +426,51 @@ function FSUNLinSolSetScalingVectors_SPGMR(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPGMR(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPGMR(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPGMR(s, onff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c index f16ec912e2..dd4f2ec1da 100644 --- a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c +++ b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_sptfqmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPTFQMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +395,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPTFQMR(SUNLinearSolver farg1, } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPTFQMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPTFQMR(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPTFQMR(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPTFQMR(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 index e34a320d20..9c77b77a3c 100644 --- a/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 +++ b/src/sunlinsol/sptfqmr/fmod_int32/fsunlinsol_sptfqmr_mod.f90 @@ -35,6 +35,22 @@ module fsunlinsol_sptfqmr_mod public :: FSUNLinSolSetATimes_SPTFQMR public :: FSUNLinSolSetPreconditioner_SPTFQMR public :: FSUNLinSolSetScalingVectors_SPTFQMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPTFQMR public :: FSUNLinSolSetZeroGuess_SPTFQMR public :: FSUNLinSolSetup_SPTFQMR public :: FSUNLinSolSolve_SPTFQMR @@ -131,6 +147,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPTFQMR(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPTFQMR(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPTFQMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPTFQMR(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPTFQMR") & result(fresult) @@ -369,6 +399,51 @@ function FSUNLinSolSetScalingVectors_SPTFQMR(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPTFQMR(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPTFQMR(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPTFQMR(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c index b5fee5a458..af74d376b0 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c +++ b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunlinsol/sunlinsol_sptfqmr.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_SPTFQMR(N_Vector farg1, int const *farg2, int const *farg3, void *farg4) { SUNLinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -340,6 +395,27 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors_SPTFQMR(SUNLinearSolver farg1, } +SWIGEXPORT int _wrap_FSUNLinSolSetOptions_SPTFQMR(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions_SPTFQMR(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNLinSolSetOptions_SPTFQMR(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess_SPTFQMR(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; diff --git a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 index ffc1fc0626..6f9a720498 100644 --- a/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 +++ b/src/sunlinsol/sptfqmr/fmod_int64/fsunlinsol_sptfqmr_mod.f90 @@ -35,6 +35,22 @@ module fsunlinsol_sptfqmr_mod public :: FSUNLinSolSetATimes_SPTFQMR public :: FSUNLinSolSetPreconditioner_SPTFQMR public :: FSUNLinSolSetScalingVectors_SPTFQMR + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNLinSolSetOptions_SPTFQMR public :: FSUNLinSolSetZeroGuess_SPTFQMR public :: FSUNLinSolSetup_SPTFQMR public :: FSUNLinSolSolve_SPTFQMR @@ -131,6 +147,20 @@ function swigc_FSUNLinSolSetScalingVectors_SPTFQMR(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNLinSolSetOptions_SPTFQMR(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSetOptions_SPTFQMR") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNLinSolSetZeroGuess_SPTFQMR(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess_SPTFQMR") & result(fresult) @@ -369,6 +399,51 @@ function FSUNLinSolSetScalingVectors_SPTFQMR(s, s1, s2) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNLinSolSetOptions_SPTFQMR(s, lsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +character(kind=C_CHAR, len=*), target :: lsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(s) +call SWIG_string_to_chararray(lsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNLinSolSetOptions_SPTFQMR(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNLinSolSetZeroGuess_SPTFQMR(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.c b/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.c index b2458a2ee2..204b2747bb 100644 --- a/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.c +++ b/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNNonlinearSolver _wrap_FSUNNonlinSol_FixedPoint(N_Vector farg1, int const *farg2, void *farg3) { SUNNonlinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -332,6 +387,27 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver fa } +SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNNonlinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNNonlinSolSetOptions_FixedPoint(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters_FixedPoint(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; diff --git a/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.f90 b/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.f90 index 2e996b26f9..6835241760 100644 --- a/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.f90 +++ b/src/sunnonlinsol/fixedpoint/fmod_int32/fsunnonlinsol_fixedpoint_mod.f90 @@ -33,6 +33,22 @@ module fsunnonlinsol_fixedpoint_mod public :: FSUNNonlinSolFree_FixedPoint public :: FSUNNonlinSolSetSysFn_FixedPoint public :: FSUNNonlinSolSetConvTestFn_FixedPoint + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNNonlinSolSetOptions_FixedPoint public :: FSUNNonlinSolSetMaxIters_FixedPoint public :: FSUNNonlinSolSetDamping_FixedPoint public :: FSUNNonlinSolGetNumIters_FixedPoint @@ -120,6 +136,20 @@ function swigc_FSUNNonlinSolSetConvTestFn_FixedPoint(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNNonlinSolSetOptions_FixedPoint(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNNonlinSolSetOptions_FixedPoint") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNNonlinSolSetMaxIters_FixedPoint(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters_FixedPoint") & result(fresult) @@ -325,6 +355,51 @@ function FSUNNonlinSolSetConvTestFn_FixedPoint(nls, ctestfn, ctest_data) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNNonlinSolSetOptions_FixedPoint(nls, nlsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNNonlinearSolver), target, intent(inout) :: nls +character(kind=C_CHAR, len=*), target :: nlsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(nls) +call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNNonlinSolSetOptions_FixedPoint(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNNonlinSolSetMaxIters_FixedPoint(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.c b/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.c index b2458a2ee2..204b2747bb 100644 --- a/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.c +++ b/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunnonlinsol/sunnonlinsol_fixedpoint.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNNonlinearSolver _wrap_FSUNNonlinSol_FixedPoint(N_Vector farg1, int const *farg2, void *farg3) { SUNNonlinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -332,6 +387,27 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn_FixedPoint(SUNNonlinearSolver fa } +SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNNonlinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions_FixedPoint(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNNonlinSolSetOptions_FixedPoint(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters_FixedPoint(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; diff --git a/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.f90 b/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.f90 index 2e996b26f9..6835241760 100644 --- a/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.f90 +++ b/src/sunnonlinsol/fixedpoint/fmod_int64/fsunnonlinsol_fixedpoint_mod.f90 @@ -33,6 +33,22 @@ module fsunnonlinsol_fixedpoint_mod public :: FSUNNonlinSolFree_FixedPoint public :: FSUNNonlinSolSetSysFn_FixedPoint public :: FSUNNonlinSolSetConvTestFn_FixedPoint + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNNonlinSolSetOptions_FixedPoint public :: FSUNNonlinSolSetMaxIters_FixedPoint public :: FSUNNonlinSolSetDamping_FixedPoint public :: FSUNNonlinSolGetNumIters_FixedPoint @@ -120,6 +136,20 @@ function swigc_FSUNNonlinSolSetConvTestFn_FixedPoint(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNNonlinSolSetOptions_FixedPoint(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNNonlinSolSetOptions_FixedPoint") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNNonlinSolSetMaxIters_FixedPoint(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters_FixedPoint") & result(fresult) @@ -325,6 +355,51 @@ function FSUNNonlinSolSetConvTestFn_FixedPoint(nls, ctestfn, ctest_data) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNNonlinSolSetOptions_FixedPoint(nls, nlsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNNonlinearSolver), target, intent(inout) :: nls +character(kind=C_CHAR, len=*), target :: nlsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(nls) +call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNNonlinSolSetOptions_FixedPoint(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNNonlinSolSetMaxIters_FixedPoint(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.c b/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.c index 0aaa91280f..17fc2e25b0 100644 --- a/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.c +++ b/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunnonlinsol/sunnonlinsol_newton.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNNonlinearSolver _wrap_FSUNNonlinSol_Newton(N_Vector farg1, void *farg2) { SUNNonlinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -356,6 +411,27 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver farg1, } +SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions_Newton(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNNonlinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNNonlinSolSetOptions_Newton(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters_Newton(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; diff --git a/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.f90 b/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.f90 index 79d2a4ae10..ed326cade7 100644 --- a/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.f90 +++ b/src/sunnonlinsol/newton/fmod_int32/fsunnonlinsol_newton_mod.f90 @@ -35,6 +35,22 @@ module fsunnonlinsol_newton_mod public :: FSUNNonlinSolSetLSetupFn_Newton public :: FSUNNonlinSolSetLSolveFn_Newton public :: FSUNNonlinSolSetConvTestFn_Newton + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNNonlinSolSetOptions_Newton public :: FSUNNonlinSolSetMaxIters_Newton public :: FSUNNonlinSolGetNumIters_Newton public :: FSUNNonlinSolGetCurIter_Newton @@ -137,6 +153,20 @@ function swigc_FSUNNonlinSolSetConvTestFn_Newton(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNNonlinSolSetOptions_Newton(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNNonlinSolSetOptions_Newton") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNNonlinSolSetMaxIters_Newton(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters_Newton") & result(fresult) @@ -359,6 +389,51 @@ function FSUNNonlinSolSetConvTestFn_Newton(nls, ctestfn, ctest_data) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNNonlinSolSetOptions_Newton(nls, nlsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNNonlinearSolver), target, intent(inout) :: nls +character(kind=C_CHAR, len=*), target :: nlsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(nls) +call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNNonlinSolSetOptions_Newton(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNNonlinSolSetMaxIters_Newton(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.c b/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.c index 0aaa91280f..17fc2e25b0 100644 --- a/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.c +++ b/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.c @@ -178,6 +178,22 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } +enum { + SWIG_MEM_OWN = 0x01, + SWIG_MEM_RVALUE = 0x02, + SWIG_MEM_CONST = 0x04 +}; + + +#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ + if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ + SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ + "Cannot pass const " TYPENAME " (class " FNAME ") " \ + "as a mutable reference", \ + RETURNNULL); \ + } + + #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -208,6 +224,45 @@ #include "sunnonlinsol/sunnonlinsol_newton.h" + +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +typedef struct { + void* cptr; + int cmemflags; +} SwigClassWrapper; + + +SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { + SwigClassWrapper result; + result.cptr = NULL; + result.cmemflags = 0; + return result; +} + SWIGEXPORT SUNNonlinearSolver _wrap_FSUNNonlinSol_Newton(N_Vector farg1, void *farg2) { SUNNonlinearSolver fresult ; N_Vector arg1 = (N_Vector) 0 ; @@ -356,6 +411,27 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn_Newton(SUNNonlinearSolver farg1, } +SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions_Newton(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { + int fresult ; + SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + char **arg5 ; + SUNErrCode result; + + arg1 = (SUNNonlinearSolver)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + arg4 = (int)(*farg4); + SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions_Newton(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); + arg5 = (char **)(farg5->cptr); + result = (SUNErrCode)SUNNonlinSolSetOptions_Newton(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); + fresult = (SUNErrCode)(result); + return fresult; +} + + SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters_Newton(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; diff --git a/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.f90 b/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.f90 index 79d2a4ae10..ed326cade7 100644 --- a/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.f90 +++ b/src/sunnonlinsol/newton/fmod_int64/fsunnonlinsol_newton_mod.f90 @@ -35,6 +35,22 @@ module fsunnonlinsol_newton_mod public :: FSUNNonlinSolSetLSetupFn_Newton public :: FSUNNonlinSolSetLSolveFn_Newton public :: FSUNNonlinSolSetConvTestFn_Newton + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type + type, public :: SWIGTYPE_p_p_char + type(SwigClassWrapper), public :: swigdata + end type + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FSUNNonlinSolSetOptions_Newton public :: FSUNNonlinSolSetMaxIters_Newton public :: FSUNNonlinSolGetNumIters_Newton public :: FSUNNonlinSolGetCurIter_Newton @@ -137,6 +153,20 @@ function swigc_FSUNNonlinSolSetConvTestFn_Newton(farg1, farg2, farg3) & integer(C_INT) :: fresult end function +function swigc_FSUNNonlinSolSetOptions_Newton(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNNonlinSolSetOptions_Newton") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +import :: swigclasswrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT), intent(in) :: farg4 +type(SwigClassWrapper) :: farg5 +integer(C_INT) :: fresult +end function + function swigc_FSUNNonlinSolSetMaxIters_Newton(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters_Newton") & result(fresult) @@ -359,6 +389,51 @@ function FSUNNonlinSolSetConvTestFn_Newton(nls, ctestfn, ctest_data) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSUNNonlinSolSetOptions_Newton(nls, nlsid, file_name, argc, argv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNNonlinearSolver), target, intent(inout) :: nls +character(kind=C_CHAR, len=*), target :: nlsid +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: file_name +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT), intent(in) :: argc +class(SWIGTYPE_p_p_char), intent(in) :: argv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: farg4 +type(SwigClassWrapper) :: farg5 + +farg1 = c_loc(nls) +call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) +call SWIG_string_to_chararray(file_name, farg3_chars, farg3) +farg4 = argc +farg5 = argv%swigdata +fresult = swigc_FSUNNonlinSolSetOptions_Newton(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + function FSUNNonlinSolSetMaxIters_Newton(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 86798abe0b1b9ecbc602f6a6ec2a7527b9f2143f Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 17:20:40 -0400 Subject: [PATCH 092/114] Fixed swig ignores for new function names --- swig/arkode/farkode_mod.i | 2 +- swig/cvode/fcvode_mod.i | 2 +- swig/cvodes/fcvodes_mod.i | 2 +- swig/ida/fida_mod.i | 2 +- swig/idas/fidas_mod.i | 2 +- swig/kinsol/fkinsol_mod.i | 2 +- swig/sundials/fsundials_adaptcontroller.i | 2 +- swig/sundials/fsundials_linearsolver.i | 2 +- swig/sundials/fsundials_nonlinearsolver.i | 4 ++++ 9 files changed, 12 insertions(+), 8 deletions(-) diff --git a/swig/arkode/farkode_mod.i b/swig/arkode/farkode_mod.i index 5b607134dd..e3b63c3a08 100644 --- a/swig/arkode/farkode_mod.i +++ b/swig/arkode/farkode_mod.i @@ -19,7 +19,7 @@ %include "../sundials/fsundials.i" // Ignore command-line processing functions since they are not supported in Fortran -%ignore ARKodeSetFromCommandLine; +%ignore ARKodeSetOptions; %{ #include "arkode/arkode.h" diff --git a/swig/cvode/fcvode_mod.i b/swig/cvode/fcvode_mod.i index d14082dc36..c4d7805445 100644 --- a/swig/cvode/fcvode_mod.i +++ b/swig/cvode/fcvode_mod.i @@ -19,7 +19,7 @@ %include "../sundials/fsundials.i" // Ignore command-line processing functions since they are not supported in Fortran -%ignore CVodeSetFromCommandLine; +%ignore CVodeSetOptions; %{ #include "cvode/cvode.h" diff --git a/swig/cvodes/fcvodes_mod.i b/swig/cvodes/fcvodes_mod.i index 97de9b20b3..b13e655be3 100644 --- a/swig/cvodes/fcvodes_mod.i +++ b/swig/cvodes/fcvodes_mod.i @@ -19,7 +19,7 @@ %include "../sundials/fsundials.i" // Ignore command-line processing functions since they are not supported in Fortran -%ignore CVodeSetFromCommandLine; +%ignore CVodeSetOptions; %{ #include "cvodes/cvodes.h" diff --git a/swig/ida/fida_mod.i b/swig/ida/fida_mod.i index db5c52270f..6e944ebdbc 100644 --- a/swig/ida/fida_mod.i +++ b/swig/ida/fida_mod.i @@ -19,7 +19,7 @@ %include "../sundials/fsundials.i" // Ignore command-line processing functions since they are not supported in Fortran -%ignore IDASetFromCommandLine; +%ignore IDASetOptions; %{ #include "ida/ida.h" diff --git a/swig/idas/fidas_mod.i b/swig/idas/fidas_mod.i index 7c543c53f0..9658542924 100644 --- a/swig/idas/fidas_mod.i +++ b/swig/idas/fidas_mod.i @@ -19,7 +19,7 @@ %include "../sundials/fsundials.i" // Ignore command-line processing functions since they are not supported in Fortran -%ignore IDASetFromCommandLine; +%ignore IDASetOptions; %{ #include "idas/idas.h" diff --git a/swig/kinsol/fkinsol_mod.i b/swig/kinsol/fkinsol_mod.i index 864a7772ee..bc19452160 100644 --- a/swig/kinsol/fkinsol_mod.i +++ b/swig/kinsol/fkinsol_mod.i @@ -19,7 +19,7 @@ %include "../sundials/fsundials.i" // Ignore command-line processing functions since they are not supported in Fortran -%ignore KINSetFromCommandLine; +%ignore KINSetOptions; %{ #include "kinsol/kinsol.h" diff --git a/swig/sundials/fsundials_adaptcontroller.i b/swig/sundials/fsundials_adaptcontroller.i index 74d8eea519..c1f46d29e3 100644 --- a/swig/sundials/fsundials_adaptcontroller.i +++ b/swig/sundials/fsundials_adaptcontroller.i @@ -15,7 +15,7 @@ // --------------------------------------------------------------- // Ignore command-line processing functions since they are not supported in Fortran -%ignore SUNAdaptController_SetFromCommandLine; +%ignore SUNAdaptController_SetOptions; %{ #include "sundials/sundials_adaptcontroller.h" diff --git a/swig/sundials/fsundials_linearsolver.i b/swig/sundials/fsundials_linearsolver.i index 1027ed45b8..e6ade65c35 100644 --- a/swig/sundials/fsundials_linearsolver.i +++ b/swig/sundials/fsundials_linearsolver.i @@ -15,7 +15,7 @@ // --------------------------------------------------------------- // Ignore command-line processing functions since they are not supported in Fortran -%ignore SUNLinSolSetFromCommandLine; +%ignore SUNLinSolSetOptions; // insert the include into the swig wrapper %{ diff --git a/swig/sundials/fsundials_nonlinearsolver.i b/swig/sundials/fsundials_nonlinearsolver.i index 949c1b949c..83013216d7 100644 --- a/swig/sundials/fsundials_nonlinearsolver.i +++ b/swig/sundials/fsundials_nonlinearsolver.i @@ -14,6 +14,10 @@ // Swig interface file // --------------------------------------------------------------- +// Ignore command-line processing functions since they are not supported in Fortran +%ignore SUNNonlinSolSetOptions; + +// insert the include into the swig wrapper %{ #include "sundials/sundials_nonlinearsolver.h" %} From c4080f9bb5ffe17b5e3382c7c7ed97ee00d1cd4e Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 17:57:50 -0400 Subject: [PATCH 093/114] Swig --- src/arkode/fmod_int32/farkode_mod.c | 27 +--- src/arkode/fmod_int32/farkode_mod.f90 | 105 ++++---------- src/arkode/fmod_int64/farkode_mod.c | 27 +--- src/arkode/fmod_int64/farkode_mod.f90 | 105 ++++---------- src/cvode/fmod_int32/fcvode_mod.c | 51 ------- src/cvode/fmod_int32/fcvode_mod.f90 | 79 +--------- src/cvode/fmod_int64/fcvode_mod.c | 51 ------- src/cvode/fmod_int64/fcvode_mod.f90 | 79 +--------- src/cvodes/fmod_int32/fcvodes_mod.c | 27 +--- src/cvodes/fmod_int32/fcvodes_mod.f90 | 87 ++--------- src/cvodes/fmod_int64/fcvodes_mod.c | 27 +--- src/cvodes/fmod_int64/fcvodes_mod.f90 | 87 ++--------- src/ida/fmod_int32/fida_mod.c | 51 ------- src/ida/fmod_int32/fida_mod.f90 | 79 +--------- src/ida/fmod_int64/fida_mod.c | 51 ------- src/ida/fmod_int64/fida_mod.f90 | 79 +--------- src/idas/fmod_int32/fidas_mod.c | 27 +--- src/idas/fmod_int32/fidas_mod.f90 | 87 ++--------- src/idas/fmod_int64/fidas_mod.c | 27 +--- src/idas/fmod_int64/fidas_mod.f90 | 87 ++--------- src/kinsol/fmod_int32/fkinsol_mod.c | 51 ------- src/kinsol/fmod_int32/fkinsol_mod.f90 | 79 +--------- src/kinsol/fmod_int64/fkinsol_mod.c | 51 ------- src/kinsol/fmod_int64/fkinsol_mod.f90 | 79 +--------- src/sundials/fmod_int32/fsundials_core_mod.c | 93 ------------ .../fmod_int32/fsundials_core_mod.f90 | 137 ------------------ src/sundials/fmod_int64/fsundials_core_mod.c | 93 ------------ .../fmod_int64/fsundials_core_mod.f90 | 137 ------------------ 28 files changed, 150 insertions(+), 1810 deletions(-) diff --git a/src/arkode/fmod_int32/farkode_mod.c b/src/arkode/fmod_int32/farkode_mod.c index d74f3058e9..e37559cad2 100644 --- a/src/arkode/fmod_int32/farkode_mod.c +++ b/src/arkode/fmod_int32/farkode_mod.c @@ -267,6 +267,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -281,9 +284,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,27 +315,6 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } -SWIGEXPORT int _wrap_FARKodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "ARKodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)ARKodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int32/farkode_mod.f90 b/src/arkode/fmod_int32/farkode_mod.f90 index 0305e1562a..bc95869214 100644 --- a/src/arkode/fmod_int32/farkode_mod.f90 +++ b/src/arkode/fmod_int32/farkode_mod.f90 @@ -118,22 +118,6 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FARKodeSetOptions public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -175,6 +159,10 @@ module farkode_mod public :: FARKodeSetNonlinConvCoef public :: FARKodeSetStagePredictFn public :: FARKodeSetAdaptController + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FARKodeSetAdaptControllerByName public :: FARKodeSetAdaptivityAdjustment public :: FARKodeSetCFLFraction @@ -287,6 +275,14 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -493,20 +489,6 @@ module farkode_mod ! WRAPPER DECLARATIONS interface -function swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FARKodeSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2527,51 +2509,6 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FARKodeSetOptions(arkode_mem, arkid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: arkid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = arkode_mem -call SWIG_string_to_chararray(arkid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3240,6 +3177,24 @@ function FARKodeSetAdaptController(arkode_mem, c) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + function FARKodeSetAdaptControllerByName(arkode_mem, cname) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod_int64/farkode_mod.c b/src/arkode/fmod_int64/farkode_mod.c index 4e113b1361..2a73314fba 100644 --- a/src/arkode/fmod_int64/farkode_mod.c +++ b/src/arkode/fmod_int64/farkode_mod.c @@ -267,6 +267,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -281,9 +284,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -315,27 +315,6 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { } } -SWIGEXPORT int _wrap_FARKodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "ARKodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)ARKodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod_int64/farkode_mod.f90 b/src/arkode/fmod_int64/farkode_mod.f90 index ffa65919df..5a67e90489 100644 --- a/src/arkode/fmod_int64/farkode_mod.f90 +++ b/src/arkode/fmod_int64/farkode_mod.f90 @@ -118,22 +118,6 @@ module farkode_mod end enum integer, parameter, public :: ARKAccumError = kind(ARK_ACCUMERROR_NONE) public :: ARK_ACCUMERROR_NONE, ARK_ACCUMERROR_MAX, ARK_ACCUMERROR_SUM, ARK_ACCUMERROR_AVG - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FARKodeSetOptions public :: FARKodeResize public :: FARKodeReset public :: FARKodeCreateMRIStepInnerStepper @@ -175,6 +159,10 @@ module farkode_mod public :: FARKodeSetNonlinConvCoef public :: FARKodeSetStagePredictFn public :: FARKodeSetAdaptController + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FARKodeSetAdaptControllerByName public :: FARKodeSetAdaptivityAdjustment public :: FARKodeSetCFLFraction @@ -287,6 +275,14 @@ module farkode_mod public :: FARKBBDPrecReInit public :: FARKBBDPrecGetWorkSpace public :: FARKBBDPrecGetNumGfnEvals + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct struct ARKodeButcherTableMem type, public :: ARKodeButcherTableMem type(SwigClassWrapper), public :: swigdata @@ -493,20 +489,6 @@ module farkode_mod ! WRAPPER DECLARATIONS interface -function swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FARKodeSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FARKodeResize") & result(fresult) @@ -2527,51 +2509,6 @@ function swigc_FARKodeSetLinSysFn(farg1, farg2) & contains ! MODULE SUBPROGRAMS - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FARKodeSetOptions(arkode_mem, arkid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: arkid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = arkode_mem -call SWIG_string_to_chararray(arkid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FARKodeSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3240,6 +3177,24 @@ function FARKodeSetAdaptController(arkode_mem, c) & swig_result = fresult end function + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + function FARKodeSetAdaptControllerByName(arkode_mem, cname) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int32/fcvode_mod.c b/src/cvode/fmod_int32/fcvode_mod.c index 6fc3f3f2d2..bfd166d327 100644 --- a/src/cvode/fmod_int32/fcvode_mod.c +++ b/src/cvode/fmod_int32/fcvode_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -252,20 +236,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -384,27 +354,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int32/fcvode_mod.f90 b/src/cvode/fmod_int32/fcvode_mod.f90 index 15ecd0d41d..4666447bf0 100644 --- a/src/cvode/fmod_int32/fcvode_mod.f90 +++ b/src/cvode/fmod_int32/fcvode_mod.f90 @@ -70,22 +70,6 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -152,6 +136,10 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -293,20 +281,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FCVodeSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1528,51 +1502,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvode/fmod_int64/fcvode_mod.c b/src/cvode/fmod_int64/fcvode_mod.c index fc40b78d90..199e1ae5da 100644 --- a/src/cvode/fmod_int64/fcvode_mod.c +++ b/src/cvode/fmod_int64/fcvode_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -252,20 +236,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FCVodeCreate(int const *farg1, void *farg2) { @@ -384,27 +354,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvode/fmod_int64/fcvode_mod.f90 b/src/cvode/fmod_int64/fcvode_mod.f90 index 24a6cef237..9e9b4d1f63 100644 --- a/src/cvode/fmod_int64/fcvode_mod.f90 +++ b/src/cvode/fmod_int64/fcvode_mod.f90 @@ -70,22 +70,6 @@ module fcvode_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -152,6 +136,10 @@ module fcvode_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -293,20 +281,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FCVodeSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -1528,51 +1502,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int32/fcvodes_mod.c b/src/cvodes/fmod_int32/fcvodes_mod.c index 7e74f76247..fe19fb2fcb 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.c +++ b/src/cvodes/fmod_int32/fcvodes_mod.c @@ -264,6 +264,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -278,9 +281,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -428,27 +428,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int32/fcvodes_mod.f90 b/src/cvodes/fmod_int32/fcvodes_mod.f90 index a47973879d..6dfbe9bd7a 100644 --- a/src/cvodes/fmod_int32/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int32/fcvodes_mod.f90 @@ -101,22 +101,6 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -187,6 +171,10 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -281,6 +269,14 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -460,20 +456,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FCVodeSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2927,51 +2909,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/cvodes/fmod_int64/fcvodes_mod.c b/src/cvodes/fmod_int64/fcvodes_mod.c index 82a7ae207d..9f76cd3e89 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.c +++ b/src/cvodes/fmod_int64/fcvodes_mod.c @@ -264,6 +264,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -278,9 +281,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -428,27 +428,6 @@ SWIGEXPORT int _wrap_FCVodeWFtolerances(void *farg1, CVEwtFn farg2) { } -SWIGEXPORT int _wrap_FCVodeSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "CVodeSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)CVodeSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FCVodeSetConstraints(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/cvodes/fmod_int64/fcvodes_mod.f90 b/src/cvodes/fmod_int64/fcvodes_mod.f90 index 594d1f56fb..345d17dc55 100644 --- a/src/cvodes/fmod_int64/fcvodes_mod.f90 +++ b/src/cvodes/fmod_int64/fcvodes_mod.f90 @@ -101,22 +101,6 @@ module fcvodes_mod public :: FCVodeSStolerances public :: FCVodeSVtolerances public :: FCVodeWFtolerances - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FCVodeSetOptions public :: FCVodeSetConstraints public :: FCVodeSetDeltaGammaMaxLSetup public :: FCVodeSetInitStep @@ -187,6 +171,10 @@ module fcvodes_mod public :: FCVodeGetNumStepSolveFails public :: FCVodeGetUserData public :: FCVodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FCVodeGetReturnFlagName public :: FCVodeFree public :: FCVodeSetJacTimesRhsFn @@ -281,6 +269,14 @@ module fcvodes_mod public :: FCVodeGetQuadB public :: FCVodeGetAdjCVodeBmem public :: FCVodeGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct CVadjCheckPointRec type, public :: CVadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -460,20 +456,6 @@ function swigc_FCVodeWFtolerances(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FCVodeSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FCVodeSetConstraints(farg1, farg2) & bind(C, name="_wrap_FCVodeSetConstraints") & result(fresult) @@ -2927,51 +2909,6 @@ function FCVodeWFtolerances(cvode_mem, efun) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FCVodeSetOptions(cvode_mem, cvid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: cvode_mem -character(kind=C_CHAR, len=*), target :: cvid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = cvode_mem -call SWIG_string_to_chararray(cvid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FCVodeSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FCVodeSetConstraints(cvode_mem, constraints) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int32/fida_mod.c b/src/ida/fmod_int32/fida_mod.c index 1fa5cbf98e..68dfeea91f 100644 --- a/src/ida/fmod_int32/fida_mod.c +++ b/src/ida/fmod_int32/fida_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -377,27 +347,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int32/fida_mod.f90 b/src/ida/fmod_int32/fida_mod.f90 index f613188c49..136521893f 100644 --- a/src/ida/fmod_int32/fida_mod.f90 +++ b/src/ida/fmod_int32/fida_mod.f90 @@ -68,22 +68,6 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -151,6 +135,10 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -264,20 +252,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FIDASetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1333,51 +1307,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/ida/fmod_int64/fida_mod.c b/src/ida/fmod_int64/fida_mod.c index 53f1638a39..02def580d4 100644 --- a/src/ida/fmod_int64/fida_mod.c +++ b/src/ida/fmod_int64/fida_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FIDACreate(void *farg1) { @@ -377,27 +347,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/ida/fmod_int64/fida_mod.f90 b/src/ida/fmod_int64/fida_mod.f90 index c3a3ffcbf3..5e3fee8ae6 100644 --- a/src/ida/fmod_int64/fida_mod.f90 +++ b/src/ida/fmod_int64/fida_mod.f90 @@ -68,22 +68,6 @@ module fida_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -151,6 +135,10 @@ module fida_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -264,20 +252,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FIDASetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -1333,51 +1307,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int32/fidas_mod.c b/src/idas/fmod_int32/fidas_mod.c index 5c9e1b2ada..c39dff4a1f 100644 --- a/src/idas/fmod_int32/fidas_mod.c +++ b/src/idas/fmod_int32/fidas_mod.c @@ -262,6 +262,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -276,9 +279,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,27 +422,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int32/fidas_mod.f90 b/src/idas/fmod_int32/fidas_mod.f90 index 549e186d98..db6f376bfc 100644 --- a/src/idas/fmod_int32/fidas_mod.f90 +++ b/src/idas/fmod_int32/fidas_mod.f90 @@ -93,22 +93,6 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -181,6 +165,10 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -273,6 +261,14 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -428,20 +424,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FIDASetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2774,51 +2756,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/idas/fmod_int64/fidas_mod.c b/src/idas/fmod_int64/fidas_mod.c index 1eed701d11..196fd9f52b 100644 --- a/src/idas/fmod_int64/fidas_mod.c +++ b/src/idas/fmod_int64/fidas_mod.c @@ -262,6 +262,9 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } +#include + + typedef struct { void* cptr; int cmemflags; @@ -276,9 +279,6 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include - - SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { if (self->cptr == NULL) { /* LHS is unassigned */ @@ -422,27 +422,6 @@ SWIGEXPORT int _wrap_FIDACalcIC(void *farg1, int const *farg2, double const *far } -SWIGEXPORT int _wrap_FIDASetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "IDASetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)IDASetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FIDASetNonlinConvCoefIC(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/idas/fmod_int64/fidas_mod.f90 b/src/idas/fmod_int64/fidas_mod.f90 index 0255d9fae5..b379e13d36 100644 --- a/src/idas/fmod_int64/fidas_mod.f90 +++ b/src/idas/fmod_int64/fidas_mod.f90 @@ -93,22 +93,6 @@ module fidas_mod public :: FIDASVtolerances public :: FIDAWFtolerances public :: FIDACalcIC - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FIDASetOptions public :: FIDASetNonlinConvCoefIC public :: FIDASetMaxNumStepsIC public :: FIDASetMaxNumJacsIC @@ -181,6 +165,10 @@ module fidas_mod public :: FIDAGetNumStepSolveFails public :: FIDAGetUserData public :: FIDAPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FIDAGetReturnFlagName public :: FIDAFree public :: FIDASetJacTimesResFn @@ -273,6 +261,14 @@ module fidas_mod public :: FIDAGetAdjIDABmem public :: FIDAGetConsistentICB public :: FIDAGetAdjY + + integer, parameter :: swig_cmem_own_bit = 0 + integer, parameter :: swig_cmem_rvalue_bit = 1 + integer, parameter :: swig_cmem_const_bit = 2 + type, bind(C) :: SwigClassWrapper + type(C_PTR), public :: cptr = C_NULL_PTR + integer(C_INT), public :: cmemflags = 0 + end type ! struct IDAadjCheckPointRec type, public :: IDAadjCheckPointRec type(SwigClassWrapper), public :: swigdata @@ -428,20 +424,6 @@ function swigc_FIDACalcIC(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FIDASetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FIDASetNonlinConvCoefIC(farg1, farg2) & bind(C, name="_wrap_FIDASetNonlinConvCoefIC") & result(fresult) @@ -2774,51 +2756,6 @@ function FIDACalcIC(ida_mem, icopt, tout1) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FIDASetOptions(ida_mem, idaid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: ida_mem -character(kind=C_CHAR, len=*), target :: idaid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = ida_mem -call SWIG_string_to_chararray(idaid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FIDASetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FIDASetNonlinConvCoefIC(ida_mem, epiccon) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int32/fkinsol_mod.c b/src/kinsol/fmod_int32/fkinsol_mod.c index 3faa3c1951..82121bdb1a 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.c +++ b/src/kinsol/fmod_int32/fkinsol_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -313,27 +283,6 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } -SWIGEXPORT int _wrap_FKINSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "KINSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)KINSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int32/fkinsol_mod.f90 b/src/kinsol/fmod_int32/fkinsol_mod.f90 index 9c9ae157b1..15a5083d9b 100644 --- a/src/kinsol/fmod_int32/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int32/fkinsol_mod.f90 @@ -62,22 +62,6 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FKINSetOptions public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -114,6 +98,10 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -181,20 +169,6 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function -function swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FKINSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -796,51 +770,6 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FKINSetOptions(kinmem, kinid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: kinmem -character(kind=C_CHAR, len=*), target :: kinid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = kinmem -call SWIG_string_to_chararray(kinid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/kinsol/fmod_int64/fkinsol_mod.c b/src/kinsol/fmod_int64/fkinsol_mod.c index 7a6e866cea..e6d208fd6a 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.c +++ b/src/kinsol/fmod_int64/fkinsol_mod.c @@ -178,22 +178,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -249,20 +233,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { } -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include SWIGEXPORT void * _wrap_FKINCreate(void *farg1) { @@ -313,27 +283,6 @@ SWIGEXPORT int _wrap_FKINSol(void *farg1, N_Vector farg2, int const *farg3, N_Ve } -SWIGEXPORT int _wrap_FKINSetOptions(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "KINSetOptions(void *,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (int)KINSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FKINSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/kinsol/fmod_int64/fkinsol_mod.f90 b/src/kinsol/fmod_int64/fkinsol_mod.f90 index 43c0c633a2..e22feeb1f7 100644 --- a/src/kinsol/fmod_int64/fkinsol_mod.f90 +++ b/src/kinsol/fmod_int64/fkinsol_mod.f90 @@ -62,22 +62,6 @@ module fkinsol_mod public :: FKINCreate public :: FKINInit public :: FKINSol - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FKINSetOptions public :: FKINSetUserData public :: FKINSetDamping public :: FKINSetMAA @@ -114,6 +98,10 @@ module fkinsol_mod public :: FKINGetStepLength public :: FKINGetUserData public :: FKINPrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type public :: FKINGetReturnFlagName public :: FKINFree public :: FKINSetJacTimesVecSysFn @@ -181,20 +169,6 @@ function swigc_FKINSol(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function -function swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FKINSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FKINSetUserData(farg1, farg2) & bind(C, name="_wrap_FKINSetUserData") & result(fresult) @@ -796,51 +770,6 @@ function FKINSol(kinmem, uu, strategy, u_scale, f_scale) & swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FKINSetOptions(kinmem, kinid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: kinmem -character(kind=C_CHAR, len=*), target :: kinid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = kinmem -call SWIG_string_to_chararray(kinid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FKINSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FKINSetUserData(kinmem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int32/fsundials_core_mod.c b/src/sundials/fmod_int32/fsundials_core_mod.c index c17c16c671..9b579ade0f 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.c +++ b/src/sundials/fmod_int32/fsundials_core_mod.c @@ -193,22 +193,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -302,20 +286,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include "sundials/sundials_nonlinearsolver.h" @@ -2203,27 +2173,6 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } -SWIGEXPORT int _wrap_FSUNLinSolSetOptions(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (SUNErrCode)SUNLinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; @@ -2514,27 +2463,6 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn(SUNNonlinearSolver farg1, SUNNon } -SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - SUNErrCode result; - - arg1 = (SUNNonlinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (SUNErrCode)SUNNonlinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; @@ -2693,27 +2621,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions(SUNAdaptController,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (SUNErrCode)SUNAdaptController_SetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int32/fsundials_core_mod.f90 b/src/sundials/fmod_int32/fsundials_core_mod.f90 index 594070de0e..01122dbe4e 100644 --- a/src/sundials/fmod_int32/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int32/fsundials_core_mod.f90 @@ -450,18 +450,6 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - public :: FSUNLinSolSetOptions public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -529,7 +517,6 @@ module fsundials_core_mod public :: FSUNNonlinSolSetLSetupFn public :: FSUNNonlinSolSetLSolveFn public :: FSUNNonlinSolSetConvTestFn - public :: FSUNNonlinSolSetOptions public :: FSUNNonlinSolSetMaxIters public :: FSUNNonlinSolGetNumIters public :: FSUNNonlinSolGetCurIter @@ -572,7 +559,6 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset - public :: FSUNAdaptController_SetOptions public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -1868,20 +1854,6 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNLinSolSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -2069,20 +2041,6 @@ function swigc_FSUNNonlinSolSetConvTestFn(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNNonlinSolSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNNonlinSolSetMaxIters(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters") & result(fresult) @@ -2184,20 +2142,6 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_SetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -5088,33 +5032,6 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function -function FSUNLinSolSetOptions(s, lsid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5447,33 +5364,6 @@ function FSUNNonlinSolSetConvTestFn(nls, ctestfn, ctest_data) & swig_result = fresult end function -function FSUNNonlinSolSetOptions(nls, nlsid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNNonlinearSolver), target, intent(inout) :: nls -character(kind=C_CHAR, len=*), target :: nlsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = c_loc(nls) -call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FSUNNonlinSolSetMaxIters(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5658,33 +5548,6 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function -function FSUNAdaptController_SetOptions(c, cid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/sundials/fmod_int64/fsundials_core_mod.c b/src/sundials/fmod_int64/fsundials_core_mod.c index 7f3a59566b..f1558f4027 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.c +++ b/src/sundials/fmod_int64/fsundials_core_mod.c @@ -193,22 +193,6 @@ { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } -enum { - SWIG_MEM_OWN = 0x01, - SWIG_MEM_RVALUE = 0x02, - SWIG_MEM_CONST = 0x04 -}; - - -#define SWIG_check_mutable(SWIG_CLASS_WRAPPER, TYPENAME, FNAME, FUNCNAME, RETURNNULL) \ - if ((SWIG_CLASS_WRAPPER).cmemflags & SWIG_MEM_CONST) { \ - SWIG_exception_impl(FUNCNAME, SWIG_TypeError, \ - "Cannot pass const " TYPENAME " (class " FNAME ") " \ - "as a mutable reference", \ - RETURNNULL); \ - } - - #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf @@ -302,20 +286,6 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { #include "sundials/sundials_linearsolver.h" -typedef struct { - void* cptr; - int cmemflags; -} SwigClassWrapper; - - -SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { - SwigClassWrapper result; - result.cptr = NULL; - result.cmemflags = 0; - return result; -} - - #include "sundials/sundials_nonlinearsolver.h" @@ -2203,27 +2173,6 @@ SWIGEXPORT int _wrap_FSUNLinSolSetScalingVectors(SUNLinearSolver farg1, N_Vector } -SWIGEXPORT int _wrap_FSUNLinSolSetOptions(SUNLinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - SUNErrCode result; - - arg1 = (SUNLinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNLinSolSetOptions(SUNLinearSolver,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (SUNErrCode)SUNLinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNLinSolSetZeroGuess(SUNLinearSolver farg1, int const *farg2) { int fresult ; SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; @@ -2514,27 +2463,6 @@ SWIGEXPORT int _wrap_FSUNNonlinSolSetConvTestFn(SUNNonlinearSolver farg1, SUNNon } -SWIGEXPORT int _wrap_FSUNNonlinSolSetOptions(SUNNonlinearSolver farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - SUNErrCode result; - - arg1 = (SUNNonlinearSolver)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNNonlinSolSetOptions(SUNNonlinearSolver,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (SUNErrCode)SUNNonlinSolSetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNNonlinSolSetMaxIters(SUNNonlinearSolver farg1, int const *farg2) { int fresult ; SUNNonlinearSolver arg1 = (SUNNonlinearSolver) 0 ; @@ -2693,27 +2621,6 @@ SWIGEXPORT int _wrap_FSUNAdaptController_Reset(SUNAdaptController farg1) { } -SWIGEXPORT int _wrap_FSUNAdaptController_SetOptions(SUNAdaptController farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3, int const *farg4, SwigClassWrapper const *farg5) { - int fresult ; - SUNAdaptController arg1 = (SUNAdaptController) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - char **arg5 ; - SUNErrCode result; - - arg1 = (SUNAdaptController)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - arg4 = (int)(*farg4); - SWIG_check_mutable(*farg5, "char **", "SWIGTYPE_p_p_char", "SUNAdaptController_SetOptions(SUNAdaptController,char const *,char const *,int,char *[])", return 0); - arg5 = (char **)(farg5->cptr); - result = (SUNErrCode)SUNAdaptController_SetOptions(arg1,(char const *)arg2,(char const *)arg3,arg4,arg5); - fresult = (SUNErrCode)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSUNAdaptController_SetDefaults(SUNAdaptController farg1) { int fresult ; SUNAdaptController arg1 = (SUNAdaptController) 0 ; diff --git a/src/sundials/fmod_int64/fsundials_core_mod.f90 b/src/sundials/fmod_int64/fsundials_core_mod.f90 index 6b5997884b..5fe95dd47c 100644 --- a/src/sundials/fmod_int64/fsundials_core_mod.f90 +++ b/src/sundials/fmod_int64/fsundials_core_mod.f90 @@ -450,18 +450,6 @@ module fsundials_core_mod public :: FSUNLinSolSetATimes public :: FSUNLinSolSetPreconditioner public :: FSUNLinSolSetScalingVectors - - integer, parameter :: swig_cmem_own_bit = 0 - integer, parameter :: swig_cmem_rvalue_bit = 1 - integer, parameter :: swig_cmem_const_bit = 2 - type, bind(C) :: SwigClassWrapper - type(C_PTR), public :: cptr = C_NULL_PTR - integer(C_INT), public :: cmemflags = 0 - end type - type, public :: SWIGTYPE_p_p_char - type(SwigClassWrapper), public :: swigdata - end type - public :: FSUNLinSolSetOptions public :: FSUNLinSolSetZeroGuess public :: FSUNLinSolInitialize public :: FSUNLinSolSetup @@ -529,7 +517,6 @@ module fsundials_core_mod public :: FSUNNonlinSolSetLSetupFn public :: FSUNNonlinSolSetLSolveFn public :: FSUNNonlinSolSetConvTestFn - public :: FSUNNonlinSolSetOptions public :: FSUNNonlinSolSetMaxIters public :: FSUNNonlinSolGetNumIters public :: FSUNNonlinSolGetCurIter @@ -572,7 +559,6 @@ module fsundials_core_mod public :: FSUNAdaptController_EstimateStep public :: FSUNAdaptController_EstimateStepTol public :: FSUNAdaptController_Reset - public :: FSUNAdaptController_SetOptions public :: FSUNAdaptController_SetDefaults public :: FSUNAdaptController_Write public :: FSUNAdaptController_SetErrorBias @@ -1868,20 +1854,6 @@ function swigc_FSUNLinSolSetScalingVectors(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNLinSolSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNLinSolSetZeroGuess(farg1, farg2) & bind(C, name="_wrap_FSUNLinSolSetZeroGuess") & result(fresult) @@ -2069,20 +2041,6 @@ function swigc_FSUNNonlinSolSetConvTestFn(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNNonlinSolSetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNNonlinSolSetMaxIters(farg1, farg2) & bind(C, name="_wrap_FSUNNonlinSolSetMaxIters") & result(fresult) @@ -2184,20 +2142,6 @@ function swigc_FSUNAdaptController_Reset(farg1) & integer(C_INT) :: fresult end function -function swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FSUNAdaptController_SetOptions") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -import :: swigclasswrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT), intent(in) :: farg4 -type(SwigClassWrapper) :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FSUNAdaptController_SetDefaults(farg1) & bind(C, name="_wrap_FSUNAdaptController_SetDefaults") & result(fresult) @@ -5088,33 +5032,6 @@ function FSUNLinSolSetScalingVectors(s, s1, s2) & swig_result = fresult end function -function FSUNLinSolSetOptions(s, lsid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNLinearSolver), target, intent(inout) :: s -character(kind=C_CHAR, len=*), target :: lsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = c_loc(s) -call SWIG_string_to_chararray(lsid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FSUNLinSolSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FSUNLinSolSetZeroGuess(s, onoff) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5447,33 +5364,6 @@ function FSUNNonlinSolSetConvTestFn(nls, ctestfn, ctest_data) & swig_result = fresult end function -function FSUNNonlinSolSetOptions(nls, nlsid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNNonlinearSolver), target, intent(inout) :: nls -character(kind=C_CHAR, len=*), target :: nlsid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = c_loc(nls) -call SWIG_string_to_chararray(nlsid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FSUNNonlinSolSetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FSUNNonlinSolSetMaxIters(nls, maxiters) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -5658,33 +5548,6 @@ function FSUNAdaptController_Reset(c) & swig_result = fresult end function -function FSUNAdaptController_SetOptions(c, cid, file_name, argc, argv) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(SUNAdaptController), target, intent(inout) :: c -character(kind=C_CHAR, len=*), target :: cid -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: file_name -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT), intent(in) :: argc -class(SWIGTYPE_p_p_char), intent(in) :: argv -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: farg4 -type(SwigClassWrapper) :: farg5 - -farg1 = c_loc(c) -call SWIG_string_to_chararray(cid, farg2_chars, farg2) -call SWIG_string_to_chararray(file_name, farg3_chars, farg3) -farg4 = argc -farg5 = argv%swigdata -fresult = swigc_FSUNAdaptController_SetOptions(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FSUNAdaptController_SetDefaults(c) & result(swig_result) use, intrinsic :: ISO_C_BINDING From 522a9602005161f38d52fdc706928688bfce2564 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 22:40:27 -0400 Subject: [PATCH 094/114] Fixed missing 'static' --- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index f19c9bdb76..75aba5781d 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -62,8 +62,8 @@ * ---------------------------------------------------------------------------- */ -SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, const char* LSid, + int argc, char* argv[]); /* * ----------------------------------------------------------------- From a8241f268f61b1c4331ec554db2ba44773bbe70b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 16 Jul 2025 22:59:31 -0400 Subject: [PATCH 095/114] formatting --- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 75aba5781d..58a24ad8b2 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -62,8 +62,9 @@ * ---------------------------------------------------------------------------- */ -static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, const char* LSid, - int argc, char* argv[]); +static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, + const char* LSid, int argc, + char* argv[]); /* * ----------------------------------------------------------------- From f733ef14102f7f910c000936f0f8b3929f7ab785 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 16:18:51 -0400 Subject: [PATCH 096/114] Moved logic to set command-line prefixes outside of argument loop --- doc/cvodes/guide/source/Usage/SIM.rst | 3 ++ doc/kinsol/guide/source/Usage/index.rst | 2 + src/arkode/arkode_cli.c | 42 ++++++++------- src/cvode/cvode_cli.c | 37 ++++++------- src/cvodes/cvodes_cli.c | 42 ++++++++------- src/ida/ida_cli.c | 37 ++++++------- src/idas/idas_cli.c | 41 ++++++++------- src/kinsol/kinsol_cli.c | 36 ++++++------- .../imexgus/sunadaptcontroller_imexgus.c | 42 +++++++-------- .../mrihtol/sunadaptcontroller_mrihtol.c | 42 +++++++-------- .../soderlind/sunadaptcontroller_soderlind.c | 52 +++++++++---------- src/sunlinsol/klu/sunlinsol_klu.c | 35 ++++++------- .../magmadense/sunlinsol_magmadense.cpp | 34 ++++++------ src/sunlinsol/pcg/sunlinsol_pcg.c | 39 +++++++------- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 39 +++++++------- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 41 +++++++-------- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 41 +++++++-------- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 39 +++++++------- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 35 ++++++------- .../fixedpoint/sunnonlinsol_fixedpoint.c | 35 ++++++------- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 35 ++++++------- 21 files changed, 383 insertions(+), 366 deletions(-) diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index a20df21801..cc2b361cf2 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -2023,6 +2023,9 @@ step size adaptivity. The factor :math:`\eta_{\mathrm{max\_es}}` can be set with :c:func:`CVodeSetEtaMaxEarlyStep`. + This routine will be called by :c:func:`CVodeSetOptions` + when using the key "cvid.num_steps_eta_max_early_step". + .. versionadded:: 6.2.0 .. c:function:: int CVodeSetEtaMax(void* cvode_mem, sunrealtype eta_max_gs) diff --git a/doc/kinsol/guide/source/Usage/index.rst b/doc/kinsol/guide/source/Usage/index.rst index 1004c9b2bd..f96066b784 100644 --- a/doc/kinsol/guide/source/Usage/index.rst +++ b/doc/kinsol/guide/source/Usage/index.rst @@ -702,6 +702,8 @@ negative, so a test ``retval`` :math:`<0` will catch any error. value of ``msbset`` should be a multiple of ``msbsetsub`` (see :c:func:`KINSetMaxSubSetupCalls`). + This routine will be called by :c:func:`KINSetOptions` + when using the key "kinid.max_setup_calls". .. c:function:: int KINSetMaxSubSetupCalls(void * kin_mem, long int msbsetsub) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 514fd5dc04..fe3e03da42 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -133,27 +133,24 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"reset_accumulated_error", ARKodeResetAccumulatedError}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - int idx, j, retval; - SUNErrCode sunretval; + /* Prefix for options to set */ + const char* default_id = "arkode"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(arkid)+1,strlen(default_id)+1)); + if (arkid != NULL && strlen(arkid) > 0) { strcpy(prefix, arkid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + sunbooleantype write_parameters = SUNFALSE; - for (idx = 1; idx < argc; idx++) + int retval; + for (int idx = 1; idx < argc; idx++) { + SUNErrCode sunretval; + int j; sunbooleantype arg_used = SUNFALSE; - /* if arkid is supplied, skip command-line arguments that do not begin with arkid; - else, skip command-line arguments that do not begin with "arkode." */ - size_t offset; - if (arkid != NULL && strlen(arkid) > 0) - { - if (strncmp(argv[idx], arkid, strlen(arkid)) != 0) { continue; } - offset = strlen(arkid) + 1; - } - else - { - static const char* prefix = "arkode."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ sunretval = sunCheckAndSetIntArgs(arkode_mem, &idx, argv, offset, int_pairs, @@ -163,6 +160,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -175,6 +173,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -187,6 +186,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -200,6 +200,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", tworeal_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -213,6 +214,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, retval = ARK_ILL_INPUT; arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", action_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -239,6 +241,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s %s", argv[idx - 1], argv[idx]); + free(prefix); return retval; } arg_used = SUNTRUE; @@ -269,6 +272,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s %s", argv[idx - 1], argv[idx]); + free(prefix); return retval; } arg_used = SUNTRUE; @@ -287,7 +291,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, if (ark_mem->step_setoption) { retval = ark_mem->step_setoption(ark_mem, &idx, argv, offset, &arg_used); - if (retval != ARK_SUCCESS) { return retval; } + if (retval != ARK_SUCCESS) { free(prefix); return retval; } if (arg_used) { continue; } } @@ -307,10 +311,12 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "error writing parameters to stdout"); + free(prefix); return retval; } } + free(prefix); return (ARK_SUCCESS); } diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 90a78a0f99..91f70de2e1 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -126,26 +126,22 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, {"no_inactive_root_warn", CVodeSetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - SUNErrCode sunretval; - int idx, j, retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "cvode"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(cvid)+1,strlen(default_id)+1)); + if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { + SUNErrCode sunretval; + int j, retval; sunbooleantype arg_used = SUNFALSE; - /* if cvid is supplied, skip command-line arguments that do not begin with cvid; - else, skip command-line arguments that do not begin with "cvode." */ - size_t offset; - if (cvid != NULL && strlen(cvid) > 0) - { - if (strncmp(argv[idx], cvid, strlen(cvid)) != 0) { continue; } - offset = strlen(cvid) + 1; - } - else - { - static const char* prefix = "cvode."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, int_pairs, @@ -155,6 +151,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -167,6 +164,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -179,6 +177,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -192,6 +191,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", tworeal_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -205,6 +205,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", action_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -213,7 +214,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, "WARNING: key %s was not handled\n", argv[idx]); } - + free(prefix); return (CV_SUCCESS); } diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index 7c9ce570b0..ce8fbec0f4 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -91,6 +91,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const struct sunKeyLongPair long_pairs[] = {{"lsetup_frequency", CVodeSetLSetupFrequency}, {"max_num_steps", CVodeSetMaxNumSteps}, + {"num_steps_eta_max_early_step", CVodeSetNumStepsEtaMaxEarlyStep}, {"monitor_frequency", CVodeSetMonitorFrequency}, {"jac_eval_frequency", CVodeSetJacEvalFrequency}, {"proj_frequency", CVodeSetProjFrequency}}; @@ -158,26 +159,22 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); - SUNErrCode sunretval; - int idx, j, retval; - for (idx = 1; idx < argc; idx++) +/* Prefix for options to set */ + const char* default_id = "cvodes"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(cvid)+1,strlen(default_id)+1)); + if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { + SUNErrCode sunretval; + int j, retval; sunbooleantype arg_used = SUNFALSE; - /* if cvid is supplied, skip command-line arguments that do not begin with cvid; - else, skip command-line arguments that do not begin with "cvodes." */ - size_t offset; - if (cvid != NULL && strlen(cvid) > 0) - { - if (strncmp(argv[idx], cvid, strlen(cvid)) != 0) { continue; } - offset = strlen(cvid) + 1; - } - else - { - static const char* prefix = "cvodes."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ sunretval = sunCheckAndSetIntArgs(cvode_mem, &idx, argv, offset, int_pairs, @@ -187,6 +184,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -199,6 +197,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -211,6 +210,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -224,6 +224,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", twoint_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -237,6 +238,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", tworeal_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -250,6 +252,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", action_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -263,6 +266,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -276,6 +280,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -290,6 +295,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, retval = CV_ILL_INPUT; cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_real_real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -298,7 +304,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, cvProcessError(cv_mem, CV_WARNING, __LINE__, __func__, __FILE__, "WARNING: key %s was not handled\n", argv[idx]); } - + free(prefix); return (CV_SUCCESS); } diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index d89143fe8b..830c555325 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -117,26 +117,22 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, {"no_inactive_root_warn", IDASetNoInactiveRootWarn}}; static const int num_action_keys = sizeof(action_pairs) / sizeof(*action_pairs); - SUNErrCode sunretval; - int idx, j, retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "ida"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(idaid)+1,strlen(default_id)+1)); + if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { + SUNErrCode sunretval; + int j, retval; sunbooleantype arg_used = SUNFALSE; - /* if idaid is supplied, skip command-line arguments that do not begin with idaid; - else, skip command-line arguments that do not begin with "ida." */ - size_t offset; - if (idaid != NULL && strlen(idaid) > 0) - { - if (strncmp(argv[idx], idaid, strlen(idaid)) != 0) { continue; } - offset = strlen(idaid) + 1; - } - else - { - static const char* prefix = "ida."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, int_pairs, @@ -146,6 +142,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -158,6 +155,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -170,6 +168,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -183,6 +182,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", tworeal_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -196,6 +196,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", action_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -204,7 +205,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, "WARNING: key %s was not handled\n", argv[idx]); } - + free(prefix); return (IDA_SUCCESS); } diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 9179ea5fdb..97184a3364 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -152,26 +152,22 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); - SUNErrCode sunretval; - int idx, j, retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "idas"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(idaid)+1,strlen(default_id)+1)); + if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { + SUNErrCode sunretval; + int j, retval; sunbooleantype arg_used = SUNFALSE; - /* if idaid is supplied, skip command-line arguments that do not begin with idaid; - else, skip command-line arguments that do not begin with "idas." */ - size_t offset; - if (idaid != NULL && strlen(idaid) > 0) - { - if (strncmp(argv[idx], idaid, strlen(idaid)) != 0) { continue; } - offset = strlen(idaid) + 1; - } - else - { - static const char* prefix = "idas."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ sunretval = sunCheckAndSetIntArgs(ida_mem, &idx, argv, offset, int_pairs, @@ -181,6 +177,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -193,6 +190,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -205,6 +203,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -218,6 +217,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", twoint_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -231,6 +231,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", tworeal_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -244,6 +245,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", action_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -257,6 +259,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -270,6 +273,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -284,6 +288,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, retval = IDA_ILL_INPUT; IDAProcessError(IDA_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_real_real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -292,7 +297,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, IDAProcessError(IDA_mem, IDA_WARNING, __LINE__, __func__, __FILE__, "WARNING: key %s was not handled\n", argv[idx]); } - + free(prefix); return (IDA_SUCCESS); } diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 7f3670dfb4..984f5ddc34 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -103,26 +103,22 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, static const int num_tworeal_keys = sizeof(tworeal_pairs) / sizeof(*tworeal_pairs); - SUNErrCode sunretval; - int idx, j, retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "kinsol"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(kinid)+1,strlen(default_id)+1)); + if (kinid != NULL && strlen(kinid) > 0) { strcpy(prefix, kinid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { + SUNErrCode sunretval; + int j, retval; sunbooleantype arg_used = SUNFALSE; - /* if kinid is supplied, skip command-line arguments that do not begin with kinid; - else, skip command-line arguments that do not begin with "kinsol." */ - size_t offset; - if (kinid != NULL && strlen(kinid) > 0) - { - if (strncmp(argv[idx], kinid, strlen(kinid)) != 0) { continue; } - offset = strlen(kinid) + 1; - } - else - { - static const char* prefix = "kinsol."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* check all "int" command-line options */ sunretval = sunCheckAndSetIntArgs(kinmem, &idx, argv, offset, int_pairs, @@ -132,6 +128,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", int_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -144,6 +141,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", long_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -156,6 +154,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", real_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -169,6 +168,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, retval = KIN_ILL_INPUT; KINProcessError(kin_mem, retval, __LINE__, __func__, __FILE__, "error setting key: %s", tworeal_pairs[j].key); + free(prefix); return retval; } if (arg_used) continue; @@ -177,7 +177,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, KINProcessError(kin_mem, KIN_WARNING, __LINE__, __func__, __FILE__, "WARNING: key %s was not handled\n", argv[idx]); } - + free(prefix); return (KIN_SUCCESS); } diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 401ef0ab57..70c8da01a2 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -141,25 +141,24 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int idx; - SUNErrCode retval; + /* Prefix for options to set */ + const char* default_id = "sunadaptcontroller"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(Cid)+1,strlen(default_id)+1)); + if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + int retval; sunbooleantype write_parameters = SUNFALSE; - for (idx = 1; idx < argc; idx++) + for (int idx = 1; idx < argc; idx++) { - /* if Cid is supplied, skip command-line arguments that do not begin with Cid; - else, skip command-line arguments that do not begin with "sunadaptcontroller." */ - size_t offset; - if (Cid != NULL && strlen(Cid) > 0) - { - if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } - offset = strlen(Cid) + 1; - } - else - { - static const char* prefix = "sunadaptcontroller."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over SetParams function */ if (strcmp(argv[idx] + offset, "params") == 0) @@ -174,7 +173,7 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, sunrealtype rarg4 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -182,7 +181,7 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_ImExGus(C); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -192,7 +191,7 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -211,9 +210,10 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, if (write_parameters) { retval = SUNAdaptController_Write_ImExGus(C, stdout); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 89fcef9e02..b61cd2036b 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -152,25 +152,24 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int idx; - SUNErrCode retval; + /* Prefix for options to set */ + const char* default_id = "sunadaptcontroller"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(Cid)+1,strlen(default_id)+1)); + if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + int retval; sunbooleantype write_parameters = SUNFALSE; - for (idx = 1; idx < argc; idx++) + for (int idx = 1; idx < argc; idx++) { - /* if Cid is supplied, skip command-line arguments that do not begin with Cid; - else, skip command-line arguments that do not begin with "sunadaptcontroller." */ - size_t offset; - if (Cid != NULL && strlen(Cid) > 0) - { - if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } - offset = strlen(Cid) + 1; - } - else - { - static const char* prefix = "sunadaptcontroller."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over SetParams function */ if (strcmp(argv[idx] + offset, "params") == 0) @@ -182,7 +181,7 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, idx += 1; sunrealtype rarg3 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_MRIHTol(C, rarg1, rarg2, rarg3); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -190,7 +189,7 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_MRIHTol(C); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -200,7 +199,7 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -219,9 +218,10 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, if (write_parameters) { retval = SUNAdaptController_Write_MRIHTol(C, stdout); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 3da3df109b..150c8d0a95 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -150,25 +150,24 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, { SUNFunctionBegin(C->sunctx); - int idx; - SUNErrCode retval; + /* Prefix for options to set */ + const char* default_id = "sunadaptcontroller"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(Cid)+1,strlen(default_id)+1)); + if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + int retval; sunbooleantype write_parameters = SUNFALSE; - for (idx = 1; idx < argc; idx++) + for (int idx = 1; idx < argc; idx++) { - /* if Cid is supplied, skip command-line arguments that do not begin with Cid; - else, skip command-line arguments that do not begin with "sunadaptcontroller." */ - size_t offset; - if (Cid != NULL && strlen(Cid) > 0) - { - if (strncmp(argv[idx], Cid, strlen(Cid)) != 0) { continue; } - offset = strlen(Cid) + 1; - } - else - { - static const char* prefix = "sunadaptcontroller."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over SetParams_Soderlind function */ if (strcmp(argv[idx] + offset, "params") == 0) @@ -185,7 +184,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg5 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, rarg4, rarg5); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -199,7 +198,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg3 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_PID(C, rarg1, rarg2, rarg3); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -211,7 +210,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -221,7 +220,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_I(C, rarg1); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -233,7 +232,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -245,7 +244,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -253,7 +252,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_Soderlind(C); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -263,7 +262,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -282,9 +281,10 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, if (write_parameters) { retval = SUNAdaptController_Write_Soderlind(C, stdout); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index d2fcd125ba..803a3e20ea 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -212,24 +212,22 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "klu." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over SetOrdering function */ if (strcmp(argv[idx] + offset, "ordering") == 0) @@ -237,10 +235,11 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_KLUSetOrdering(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 1e40b87504..059e79d220 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -270,23 +270,24 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, const char* LSid, int argc, char* argv[]) { - SUNErrCode retval; + SUNFunctionBegin(S->sunctx); + + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "magmadense." */ - size_t offset; - if (LSid != NULL) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinsol."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over SetAsync function */ if (strcmp(argv[idx] + offset, "async") == 0) @@ -294,10 +295,11 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 52bbffcfbe..03b302ab53 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -170,24 +170,22 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "sunlinearsolver." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over PrecType function */ if (strcmp(argv[idx] + offset, "prec_type") == 0) @@ -195,7 +193,7 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_PCGSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -205,7 +203,7 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_PCGSetMaxl(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -215,10 +213,11 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_PCG(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 620f11d73a..4f272965ca 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -193,24 +193,22 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spbcgs." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over PrecType function */ if (strcmp(argv[idx] + offset, "prec_type") == 0) @@ -218,7 +216,7 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -228,7 +226,7 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -238,10 +236,11 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index fb3e97f7be..cd177a81aa 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -181,24 +181,22 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spfgmr." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over PrecType function */ if (strcmp(argv[idx] + offset, "prec_type") == 0) @@ -206,7 +204,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -216,7 +214,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetGSType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -226,7 +224,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -236,10 +234,11 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 540ce7c687..195aff456f 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -178,24 +178,22 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "spgmr." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over PrecType function */ if (strcmp(argv[idx] + offset, "prec_type") == 0) @@ -203,7 +201,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -213,7 +211,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetGSType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -223,7 +221,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -233,10 +231,11 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index f9e76f31f6..a2c5daa302 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -193,24 +193,22 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "sptfqmr." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over PrecType function */ if (strcmp(argv[idx] + offset, "prec_type") == 0) @@ -218,7 +216,7 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -228,7 +226,7 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } @@ -238,10 +236,11 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 58a24ad8b2..5e641032b9 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -250,24 +250,22 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, { SUNFunctionBegin(S->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if LSid is supplied, skip command-line arguments that do not begin with LSid; - else, skip command-line arguments that do not begin with "superlumt." */ - size_t offset; - if (LSid != NULL && strlen(LSid) > 0) - { - if (strncmp(argv[idx], LSid, strlen(LSid)) != 0) { continue; } - offset = strlen(LSid) + 1; - } - else - { - static const char* prefix = "sunlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over SetOrdering function */ if (strcmp(argv[idx] + offset, "ordering") == 0) @@ -275,10 +273,11 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 002a5a2ca4..1ca4ab5ae7 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -370,24 +370,22 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, { SUNFunctionBegin(NLS->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunnonlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(NLSid)+1,strlen(default_id)+1)); + if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if NLSid is supplied, skip command-line arguments that do not begin with NLSid; - else, skip command-line arguments that do not begin with "sunnonlinearsolver." */ - size_t offset; - if (NLSid != NULL && strlen(NLSid) > 0) - { - if (strncmp(argv[idx], NLSid, strlen(NLSid)) != 0) { continue; } - offset = strlen(NLSid) + 1; - } - else - { - static const char* prefix = "sunnonlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over MaxIters function */ if (strcmp(argv[idx] + offset, "max_iters") == 0) @@ -395,10 +393,11 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, idx += 1; int iarg = atoi(argv[idx]); retval = SUNNonlinSolSetMaxIters_FixedPoint(NLS, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 3ac50060ed..573c929a67 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -433,24 +433,22 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, { SUNFunctionBegin(NLS->sunctx); - int idx; - SUNErrCode retval; - for (idx = 1; idx < argc; idx++) + /* Prefix for options to set */ + const char* default_id = "sunnonlinearsolver"; + char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(NLSid)+1,strlen(default_id)+1)); + if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } + else { strcpy(prefix, default_id); } + strcat(prefix, "."); + size_t offset = strlen(prefix); + + for (int idx = 1; idx < argc; idx++) { - /* if NLSid is supplied, skip command-line arguments that do not begin with NLSid; - else, skip command-line arguments that do not begin with "sunnonlinearsolver." */ - size_t offset; - if (NLSid != NULL && strlen(NLSid) > 0) - { - if (strncmp(argv[idx], NLSid, strlen(NLSid)) != 0) { continue; } - offset = strlen(NLSid) + 1; - } - else - { - static const char* prefix = "sunnonlinearsolver."; - if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } - offset = strlen(prefix); - } + SUNErrCode sunretval; + int j, retval; + sunbooleantype arg_used = SUNFALSE; + + /* skip command-line arguments that do not begin with correct prefix */ + if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } /* control over MaxIters function */ if (strcmp(argv[idx] + offset, "max_iters") == 0) @@ -458,10 +456,11 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, idx += 1; int iarg = atoi(argv[idx]); retval = SUNNonlinSolSetMaxIters_Newton(NLS, iarg); - if (retval != SUN_SUCCESS) { return retval; } + if (retval != SUN_SUCCESS) { free(prefix); return retval; } continue; } } + free(prefix); return SUN_SUCCESS; } From b1f3438af7dcfdccc9d12c2fd9e27b2ae7730a76 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 16:41:43 -0400 Subject: [PATCH 097/114] formatting --- src/arkode/arkode_cli.c | 9 ++- src/cvode/cvode_cli.c | 3 +- src/cvodes/cvodes_cli.c | 5 +- src/ida/ida_cli.c | 3 +- src/idas/idas_cli.c | 3 +- src/kinsol/kinsol_cli.c | 3 +- .../imexgus/sunadaptcontroller_imexgus.c | 27 +++++++-- .../mrihtol/sunadaptcontroller_mrihtol.c | 27 +++++++-- .../soderlind/sunadaptcontroller_soderlind.c | 57 +++++++++++++++---- src/sunlinsol/klu/sunlinsol_klu.c | 9 ++- .../magmadense/sunlinsol_magmadense.cpp | 9 ++- src/sunlinsol/pcg/sunlinsol_pcg.c | 21 +++++-- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 21 +++++-- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 27 +++++++-- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 27 +++++++-- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 21 +++++-- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 9 ++- .../fixedpoint/sunnonlinsol_fixedpoint.c | 9 ++- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 9 ++- 19 files changed, 239 insertions(+), 60 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index fe3e03da42..8eab27b37f 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -135,7 +135,8 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* Prefix for options to set */ const char* default_id = "arkode"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(arkid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(arkid) + 1, strlen(default_id) + 1)); if (arkid != NULL && strlen(arkid) > 0) { strcpy(prefix, arkid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -291,7 +292,11 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, if (ark_mem->step_setoption) { retval = ark_mem->step_setoption(ark_mem, &idx, argv, offset, &arg_used); - if (retval != ARK_SUCCESS) { free(prefix); return retval; } + if (retval != ARK_SUCCESS) + { + free(prefix); + return retval; + } if (arg_used) { continue; } } diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 91f70de2e1..a876bb3aff 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -128,7 +128,8 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* Prefix for options to set */ const char* default_id = "cvode"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(cvid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(cvid) + 1, strlen(default_id) + 1)); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index ce8fbec0f4..f09baf0666 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -159,9 +159,10 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, static const int num_int_long_keys = sizeof(int_long_pairs) / sizeof(*int_long_pairs); -/* Prefix for options to set */ + /* Prefix for options to set */ const char* default_id = "cvodes"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(cvid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(cvid) + 1, strlen(default_id) + 1)); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 830c555325..b3740c5972 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -119,7 +119,8 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* Prefix for options to set */ const char* default_id = "ida"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(idaid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(idaid) + 1, strlen(default_id) + 1)); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 97184a3364..683604ca69 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -154,7 +154,8 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* Prefix for options to set */ const char* default_id = "idas"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(idaid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(idaid) + 1, strlen(default_id) + 1)); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 984f5ddc34..d8b0146401 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -105,7 +105,8 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, /* Prefix for options to set */ const char* default_id = "kinsol"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(kinid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(kinid) + 1, strlen(default_id) + 1)); if (kinid != NULL && strlen(kinid) > 0) { strcpy(prefix, kinid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 70c8da01a2..bc8d797561 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -143,7 +143,8 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(Cid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc(sizeof(char) * + SUNMAX(strlen(Cid) + 1, strlen(default_id) + 1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -173,7 +174,11 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, sunrealtype rarg4 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ImExGus(C, rarg1, rarg2, rarg3, rarg4); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -181,7 +186,11 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_ImExGus(C); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -191,7 +200,11 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_ImExGus(C, rarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -210,7 +223,11 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, if (write_parameters) { retval = SUNAdaptController_Write_ImExGus(C, stdout); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } } free(prefix); diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index b61cd2036b..24ddcb7c09 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -154,7 +154,8 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(Cid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc(sizeof(char) * + SUNMAX(strlen(Cid) + 1, strlen(default_id) + 1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -181,7 +182,11 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, idx += 1; sunrealtype rarg3 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_MRIHTol(C, rarg1, rarg2, rarg3); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -189,7 +194,11 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_MRIHTol(C); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -199,7 +208,11 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_MRIHTol(C, rarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -218,7 +231,11 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, if (write_parameters) { retval = SUNAdaptController_Write_MRIHTol(C, stdout); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } } free(prefix); diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 150c8d0a95..f7132002db 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -152,7 +152,8 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(Cid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc(sizeof(char) * + SUNMAX(strlen(Cid) + 1, strlen(default_id) + 1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -184,7 +185,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, sunrealtype rarg5 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_Soderlind(C, rarg1, rarg2, rarg3, rarg4, rarg5); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -198,7 +203,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg3 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_PID(C, rarg1, rarg2, rarg3); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -210,7 +219,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_PI(C, rarg1, rarg2); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -220,7 +233,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg1 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_I(C, rarg1); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -232,7 +249,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ExpGus(C, rarg1, rarg2); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -244,7 +265,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg2 = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetParams_ImpGus(C, rarg1, rarg2); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -252,7 +277,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, if (strcmp(argv[idx] + offset, "defaults") == 0) { retval = SUNAdaptController_SetDefaults_Soderlind(C); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -262,7 +291,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, idx += 1; sunrealtype rarg = SUNStrToReal(argv[idx]); retval = SUNAdaptController_SetErrorBias_Soderlind(C, rarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -281,7 +314,11 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, if (write_parameters) { retval = SUNAdaptController_Write_Soderlind(C, stdout); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } } free(prefix); diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 803a3e20ea..bdb4846916 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -214,7 +214,8 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -235,7 +236,11 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_KLUSetOrdering(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 059e79d220..4a11407704 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -274,7 +274,8 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -295,7 +296,11 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_MagmaDense_SetAsync(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 03b302ab53..bfc23cd94a 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -172,7 +172,8 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -193,7 +194,11 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_PCGSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -203,7 +208,11 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_PCGSetMaxl(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -213,7 +222,11 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_PCG(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 4f272965ca..f868625195 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -195,7 +195,8 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -216,7 +217,11 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPBCGSSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -226,7 +231,11 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPBCGSSetMaxl(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -236,7 +245,11 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPBCGS(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index cd177a81aa..178cdb1f5e 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -183,7 +183,8 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -204,7 +205,11 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -214,7 +219,11 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetGSType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -224,7 +233,11 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPFGMRSetMaxRestarts(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -234,7 +247,11 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPFGMR(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 195aff456f..9b0463990a 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -180,7 +180,8 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -201,7 +202,11 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -211,7 +216,11 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetGSType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -221,7 +230,11 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPGMRSetMaxRestarts(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -231,7 +244,11 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPGMR(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index a2c5daa302..242dc0d1a7 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -195,7 +195,8 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -216,7 +217,11 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPTFQMRSetPrecType(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -226,7 +231,11 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SPTFQMRSetMaxl(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } @@ -236,7 +245,11 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSolSetZeroGuess_SPTFQMR(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 5e641032b9..5321fcde07 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -252,7 +252,8 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(LSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -273,7 +274,11 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, idx += 1; int iarg = atoi(argv[idx]); retval = SUNLinSol_SuperLUMTSetOrdering(S, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 1ca4ab5ae7..62fd6fe527 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -372,7 +372,8 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, /* Prefix for options to set */ const char* default_id = "sunnonlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(NLSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(NLSid) + 1, strlen(default_id) + 1)); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -393,7 +394,11 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, idx += 1; int iarg = atoi(argv[idx]); retval = SUNNonlinSolSetMaxIters_FixedPoint(NLS, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 573c929a67..c851f5a9c0 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -435,7 +435,8 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, /* Prefix for options to set */ const char* default_id = "sunnonlinearsolver"; - char* prefix = (char*) malloc(sizeof(char) * SUNMAX(strlen(NLSid)+1,strlen(default_id)+1)); + char* prefix = (char*)malloc( + sizeof(char) * SUNMAX(strlen(NLSid) + 1, strlen(default_id) + 1)); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); @@ -456,7 +457,11 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, idx += 1; int iarg = atoi(argv[idx]); retval = SUNNonlinSolSetMaxIters_Newton(NLS, iarg); - if (retval != SUN_SUCCESS) { free(prefix); return retval; } + if (retval != SUN_SUCCESS) + { + free(prefix); + return retval; + } continue; } } From 4cebebc6810b7e631887ec279c0ae5f22f861fb4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 17:01:25 -0400 Subject: [PATCH 098/114] removed unused variables --- src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c | 4 ---- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 4 ---- .../soderlind/sunadaptcontroller_soderlind.c | 4 ---- src/sunlinsol/pcg/sunlinsol_pcg.c | 4 +--- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 4 +--- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 4 +--- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 4 +--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 4 +--- src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c | 4 +--- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 4 +--- 10 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index bc8d797561..a88bbfab2c 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -154,10 +154,6 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, sunbooleantype write_parameters = SUNFALSE; for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j; - sunbooleantype arg_used = SUNFALSE; - /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 24ddcb7c09..40ef1342aa 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -165,10 +165,6 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, sunbooleantype write_parameters = SUNFALSE; for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j; - sunbooleantype arg_used = SUNFALSE; - /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index f7132002db..96402869b4 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -163,10 +163,6 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, sunbooleantype write_parameters = SUNFALSE; for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j; - sunbooleantype arg_used = SUNFALSE; - /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index bfc23cd94a..7c99eba31b 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -181,9 +181,7 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index f868625195..8b5d2ec218 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -204,9 +204,7 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 178cdb1f5e..cf82436d14 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -192,9 +192,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 9b0463990a..44c9aed19e 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -189,9 +189,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 242dc0d1a7..8490538131 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -204,9 +204,7 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 62fd6fe527..647a128091 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -381,9 +381,7 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index c851f5a9c0..18df3abd91 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -444,9 +444,7 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } From 827e9c4f6dc2db6c148d3fbdd11df130b0ffa968 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 20:19:23 -0400 Subject: [PATCH 099/114] removed unused variables --- src/sunlinsol/klu/sunlinsol_klu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index bdb4846916..ef915fd65d 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -223,9 +223,7 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } From ec435bbf5ce0fc2265e696f3c3f26868405603d4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 21:37:31 -0400 Subject: [PATCH 100/114] Updated handling of command-line prefixes --- src/arkode/arkode_cli.c | 6 +++--- src/cvode/cvode_cli.c | 6 +++--- src/cvodes/cvodes_cli.c | 6 +++--- src/ida/ida_cli.c | 6 +++--- src/idas/idas_cli.c | 6 +++--- src/kinsol/kinsol_cli.c | 6 +++--- src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c | 6 +++--- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 6 +++--- .../soderlind/sunadaptcontroller_soderlind.c | 6 +++--- src/sunlinsol/klu/sunlinsol_klu.c | 6 +++--- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 6 +++--- src/sunlinsol/pcg/sunlinsol_pcg.c | 6 +++--- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 6 +++--- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 6 +++--- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 6 +++--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 6 +++--- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 6 +++--- src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c | 6 +++--- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 6 +++--- 19 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 8eab27b37f..af006a5022 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -135,12 +135,12 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* Prefix for options to set */ const char* default_id = "arkode"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(arkid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (arkid != NULL) { offset = SUNMAX(strlen(arkid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (arkid != NULL && strlen(arkid) > 0) { strcpy(prefix, arkid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); sunbooleantype write_parameters = SUNFALSE; int retval; diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index a876bb3aff..43a24657fd 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -128,12 +128,12 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* Prefix for options to set */ const char* default_id = "cvode"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(cvid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index f09baf0666..ddf1f95d98 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -161,12 +161,12 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* Prefix for options to set */ const char* default_id = "cvodes"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(cvid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index b3740c5972..d39f53ffc1 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -119,12 +119,12 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* Prefix for options to set */ const char* default_id = "ida"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(idaid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 683604ca69..5f6a6bf314 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -154,12 +154,12 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* Prefix for options to set */ const char* default_id = "idas"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(idaid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index d8b0146401..41ded7e870 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -105,12 +105,12 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, /* Prefix for options to set */ const char* default_id = "kinsol"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(kinid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (kinid != NULL) { offset = SUNMAX(strlen(kinid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (kinid != NULL && strlen(kinid) > 0) { strcpy(prefix, kinid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index a88bbfab2c..1489a920c8 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -143,12 +143,12 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - char* prefix = (char*)malloc(sizeof(char) * - SUNMAX(strlen(Cid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); int retval; sunbooleantype write_parameters = SUNFALSE; diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 40ef1342aa..41c246d116 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -154,12 +154,12 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - char* prefix = (char*)malloc(sizeof(char) * - SUNMAX(strlen(Cid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); int retval; sunbooleantype write_parameters = SUNFALSE; diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 96402869b4..c5b1be0238 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -152,12 +152,12 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - char* prefix = (char*)malloc(sizeof(char) * - SUNMAX(strlen(Cid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); int retval; sunbooleantype write_parameters = SUNFALSE; diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index ef915fd65d..304ef5266f 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -214,12 +214,12 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 4a11407704..9b1ec46b7f 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -274,12 +274,12 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 7c99eba31b..8666926b4a 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -172,12 +172,12 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 8b5d2ec218..b754da5d9d 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -195,12 +195,12 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index cf82436d14..d34a11e07b 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -183,12 +183,12 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 44c9aed19e..a8b3953d02 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -180,12 +180,12 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 8490538131..38875f455c 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -195,12 +195,12 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 5321fcde07..8eff825b4d 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -252,12 +252,12 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(LSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 647a128091..e59437049c 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -372,12 +372,12 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, /* Prefix for options to set */ const char* default_id = "sunnonlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(NLSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 18df3abd91..4301b81ccf 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -435,12 +435,12 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, /* Prefix for options to set */ const char* default_id = "sunnonlinearsolver"; - char* prefix = (char*)malloc( - sizeof(char) * SUNMAX(strlen(NLSid) + 1, strlen(default_id) + 1)); + size_t offset = strlen(default_id) + 1; + if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } + char* prefix = (char*)malloc(sizeof(char) * offset); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); - size_t offset = strlen(prefix); for (int idx = 1; idx < argc; idx++) { From 887967ee66f2bcf935070b1d422d66540ee0e71c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 21:42:08 -0400 Subject: [PATCH 101/114] formatting --- src/arkode/arkode_cli.c | 2 +- src/cvode/cvode_cli.c | 2 +- src/cvodes/cvodes_cli.c | 2 +- src/ida/ida_cli.c | 2 +- src/idas/idas_cli.c | 2 +- src/kinsol/kinsol_cli.c | 2 +- src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c | 2 +- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 2 +- src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c | 2 +- src/sunlinsol/klu/sunlinsol_klu.c | 2 +- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 2 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 2 +- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 2 +- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 2 +- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 2 +- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 2 +- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c | 2 +- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index af006a5022..c1fed96931 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -135,7 +135,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, /* Prefix for options to set */ const char* default_id = "arkode"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (arkid != NULL) { offset = SUNMAX(strlen(arkid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (arkid != NULL && strlen(arkid) > 0) { strcpy(prefix, arkid); } diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 43a24657fd..71707ee85a 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -128,7 +128,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* Prefix for options to set */ const char* default_id = "cvode"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index ddf1f95d98..eddc727179 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -161,7 +161,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, /* Prefix for options to set */ const char* default_id = "cvodes"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index d39f53ffc1..0773e8549f 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -119,7 +119,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* Prefix for options to set */ const char* default_id = "ida"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 5f6a6bf314..c320503f7e 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -154,7 +154,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, /* Prefix for options to set */ const char* default_id = "idas"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 41ded7e870..1f004e0e60 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -105,7 +105,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, /* Prefix for options to set */ const char* default_id = "kinsol"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (kinid != NULL) { offset = SUNMAX(strlen(kinid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (kinid != NULL && strlen(kinid) > 0) { strcpy(prefix, kinid); } diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 1489a920c8..42da65143e 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -143,7 +143,7 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 41c246d116..f31607222b 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -154,7 +154,7 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index c5b1be0238..3f5c1a06cf 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -152,7 +152,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, /* Prefix for options to set */ const char* default_id = "sunadaptcontroller"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 304ef5266f..228d3a2094 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -214,7 +214,7 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index 9b1ec46b7f..e780d35145 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -274,7 +274,7 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 8666926b4a..1b84d84615 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -172,7 +172,7 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index b754da5d9d..f135120865 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -195,7 +195,7 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index d34a11e07b..13ee3bd00f 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -183,7 +183,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index a8b3953d02..104696e839 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -180,7 +180,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 38875f455c..5d495edcc9 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -195,7 +195,7 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 8eff825b4d..b2f2be055c 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -252,7 +252,7 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, /* Prefix for options to set */ const char* default_id = "sunlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index e59437049c..72529202b3 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -372,7 +372,7 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, /* Prefix for options to set */ const char* default_id = "sunnonlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 4301b81ccf..a98197a381 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -435,7 +435,7 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, /* Prefix for options to set */ const char* default_id = "sunnonlinearsolver"; - size_t offset = strlen(default_id) + 1; + size_t offset = strlen(default_id) + 1; if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } char* prefix = (char*)malloc(sizeof(char) * offset); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } From e573a0e0518d9db455cfb3d5f45e337607f1b89a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 22:46:12 -0400 Subject: [PATCH 102/114] Updated documentation to clarify the role of the '.' separator between prefix and keys for SetOption routines --- doc/arkode/guide/source/Usage/User_callable.rst | 6 ++++-- doc/cvode/guide/source/Usage/index.rst | 6 ++++-- doc/cvodes/guide/source/Usage/SIM.rst | 10 ++++++---- doc/ida/guide/source/Usage/index.rst | 6 ++++-- doc/idas/guide/source/Usage/SIM.rst | 6 ++++-- doc/kinsol/guide/source/Usage/index.rst | 4 +++- .../SUNAdaptController_Description.rst | 7 +++++-- doc/shared/sunlinsol/SUNLinSol_API.rst | 11 ++++++++--- doc/shared/sunnonlinsol/SUNNonlinSol_API.rst | 9 ++++++--- .../source/developers/commandline/Options.rst | 5 +++-- 10 files changed, 47 insertions(+), 23 deletions(-) diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 1330571aad..7a21ab293e 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -955,8 +955,10 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec :c:func:`ARKodeSetOptions`. If the ``arkid`` argument is ``NULL``, then the default prefix, ``arkode``, must - be used for all ARKODE options. For example, the option ``arkode.order`` followed - by the value can be used to set the method order of accuracy. + be used for all ARKODE options. Whether ``arkid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``arkid``, the option ``arkode.order`` followed by the value + can be used to set the method order of accuracy. When using a combination of ARKODE integrators (e.g., via MRIStep, SplittingStep, or ForcingStep), it is recommended that users call diff --git a/doc/cvode/guide/source/Usage/index.rst b/doc/cvode/guide/source/Usage/index.rst index 683a4c8487..a64d0316d4 100644 --- a/doc/cvode/guide/source/Usage/index.rst +++ b/doc/cvode/guide/source/Usage/index.rst @@ -915,8 +915,10 @@ Main solver optional input functions :c:func:`CVodeSetOptions`. If the ``cvid`` argument is ``NULL``, then the default prefix, ``cvode``, must - be used for all CVODE options. For example, the option ``cvode.max_order`` followed - by the value can be used to set the maximum method order of accuracy. + be used for all CVODE options. Whether ``cvid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``cvid``, the option ``cvodes.max_order`` followed by the value + can be used to set the maximum method order of accuracy. CVODE options set via :c:func:`CVodeSetOptions` will overwrite any previously-set values. diff --git a/doc/cvodes/guide/source/Usage/SIM.rst b/doc/cvodes/guide/source/Usage/SIM.rst index cc2b361cf2..ad5850f929 100644 --- a/doc/cvodes/guide/source/Usage/SIM.rst +++ b/doc/cvodes/guide/source/Usage/SIM.rst @@ -919,14 +919,16 @@ Main solver optional input functions ``main`` routine however, this is not required. The inputs are left unchanged by These are left unchanged by :c:func:`CVodeSetOptions`. - If the *cvid* argument is ``NULL``, then the default prefix, ``cvodes``, must - be used for all CVODES options. For example, the option ``cvodes.max_order`` can - be used to set the maximum order of accuracy. + If the ``cvid`` argument is ``NULL``, then the default prefix, ``cvodes``, must + be used for all CVODES options. Whether ``cvid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``cvid``, the option ``cvodes.max_order`` followed by the value + can be used to set the maximum method order of accuracy. CVODES options set via command-line arguments to :c:func:`CVodeSetOptions` will overwrite any previously-set values. - The supported command-line options are documented within each CVODES "set" routine. + The supported options are documented within each CVODES "set" routine. .. warning:: diff --git a/doc/ida/guide/source/Usage/index.rst b/doc/ida/guide/source/Usage/index.rst index adcf2ec286..5b39b07282 100644 --- a/doc/ida/guide/source/Usage/index.rst +++ b/doc/ida/guide/source/Usage/index.rst @@ -981,8 +981,10 @@ Main solver optional input functions :c:func:`IDASetOptions`. If the ``idaid`` argument is ``NULL``, then the default prefix, ``ida``, must - be used for all IDA options. For example, the option ``ida.max_order`` followed - by the value can be used to set the maximum method order of accuracy. + be used for all IDA options. Whether ``idaid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``idaid``, the option ``ida.max_order`` followed by the value + can be used to set the maximum method order of accuracy. IDA options set via :c:func:`IDASetOptions` will overwrite any previously-set values. diff --git a/doc/idas/guide/source/Usage/SIM.rst b/doc/idas/guide/source/Usage/SIM.rst index 10961989f9..dee7c44f16 100644 --- a/doc/idas/guide/source/Usage/SIM.rst +++ b/doc/idas/guide/source/Usage/SIM.rst @@ -986,8 +986,10 @@ Main solver optional input functions :c:func:`IDASetOptions`. If the ``idaid`` argument is ``NULL``, then the default prefix, ``idas``, must - be used for all IDAS options. For example, the option ``idas.max_order`` followed - by the value can be used to set the maximum method order of accuracy. + be used for all IDAS options. Whether ``idaid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``idaid``, the option ``idas.max_order`` followed by the value + can be used to set the maximum method order of accuracy. IDAS options set via :c:func:`IDASetOptions` will overwrite any previously-set values. diff --git a/doc/kinsol/guide/source/Usage/index.rst b/doc/kinsol/guide/source/Usage/index.rst index f96066b784..1b32d78b50 100644 --- a/doc/kinsol/guide/source/Usage/index.rst +++ b/doc/kinsol/guide/source/Usage/index.rst @@ -568,7 +568,9 @@ negative, so a test ``retval`` :math:`<0` will catch any error. :c:func:`KINSetOptions`. If the ``kinid`` argument is ``NULL``, then the default prefix, ``kinsol``, must - be used for all KINSOL options. For example, the option ``kinsol.num_max_iters`` followed + be used for all KINSOL options. Whether ``kinid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``kinsol``, the option ``kinsol.num_max_iters`` followed by the value can be used to set the maximum number of nonlinear solver iterations. KINSOL options set via :c:func:`KINSetOptions` will diff --git a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst index eefeb3d7e2..be97eea356 100644 --- a/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst +++ b/doc/shared/sunadaptcontroller/SUNAdaptController_Description.rst @@ -287,9 +287,12 @@ note these requirements below. Additionally, we note the behavior of the base SU :c:func:`SUNAdaptController_SetOptions`. If the ``Cid`` argument is ``NULL`` then the default prefix, ``sunadaptcontroller``, must - be used for all SUNAdaptController options. When using a combination of SUNAdaptController + be used for all SUNAdaptController options. Whether ``Cid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``Cid``, the option ``sunadaptcontroller.error_bias`` followed by the value + can be used to set the error bias factor. When using a combination of SUNAdaptController objects (e.g., within MRIStep, SplittingStep or ForcingStep), it is recommended that users - call :c:func:`SUNAdaptController_SetOptions` for each controller using distinct *Cid* inputs, + call :c:func:`SUNAdaptController_SetOptions` for each controller using distinct ``Cid`` inputs, so that each controller can be configured separately. SUNAdaptController options set via :c:func:`SUNAdaptController_SetOptions` will overwrite diff --git a/doc/shared/sunlinsol/SUNLinSol_API.rst b/doc/shared/sunlinsol/SUNLinSol_API.rst index cc05f03a92..bbd07878ec 100644 --- a/doc/shared/sunlinsol/SUNLinSol_API.rst +++ b/doc/shared/sunlinsol/SUNLinSol_API.rst @@ -259,15 +259,20 @@ function pointer ``NULL`` instead of supplying a dummy routine. ``main`` routine however, this is not required. The inputs are left unchanged by :c:func:`SUNLinSolSetOptions`. - If the ``LSid`` argument is ``NULL`` then an implementation-specific prefix will be used for the - relevant options -- see each implementation for its default prefix value. + If the ``LSid`` argument is ``NULL``, then the default prefix, ``sunlinearsolver``, must + be used for all SUNLinearSolver options. Whether ``LSid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``LSid``, the option ``sunlinearsolver.zero_guess`` + can be used to inform an iterative linear solver to use a zero-valued initial guess. When using a combination of SUNLinearSolver objects (e.g., for system and mass matrices within ARKStep), it is recommended that users call :c:func:`SUNLinSolSetOptions` for each linear solver - using distinct *LSid* inputs, so that each solver can be configured separately. + using distinct ``LSid`` inputs, so that each solver object can be configured separately. SUNLinearSolver options set via command-line arguments to :c:func:`SUNLinSolSetOptions` will overwrite any previously-set values. + The supported options are documented within each SUNLinearSolver "set" routine. + .. warning:: This function is not available in the Fortran interface. diff --git a/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst b/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst index 9e614c7ead..ebc801af5b 100644 --- a/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst +++ b/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst @@ -173,11 +173,14 @@ parameters. Only the routine for setting the nonlinear system defining function ``main`` routine however, this is not required. The inputs are left unchanged by :c:func:`SUNNonlinSolSetOptions`. - If the ``LSid`` argument is ``NULL`` then an implementation-specific prefix will be used for the - relevant options -- see each implementation for its default prefix value. + If the ``NLSid`` argument is ``NULL``, then the default prefix, ``sunnonlinearsolver``, must + be used for all SUNNonlinearSolver options. Whether ``NLSid`` is supplied or not, a ``"."`` + will be used to separate all option keys from this identifier. For example, when + using the default ``NLSid``, the option ``sunnonlinearsolver.max_iters`` followed by the value + can be used to set the maximum number of nonlinear solver iterations. When using a combination of SUNNonlinearSolver objects (e.g., when using MRIStep), it is recommended that users call :c:func:`SUNNonlinSolSetOptions` for each nonlinear solver using distinct - *NLSid* inputs, so that each solver can be configured separately. + *NLSid* inputs, so that each solver object can be configured separately. SUNNonlinearSolver options set via command-line arguments to :c:func:`SUNNonlinSolSetOptions` will overwrite any previously-set values. diff --git a/doc/superbuild/source/developers/commandline/Options.rst b/doc/superbuild/source/developers/commandline/Options.rst index f07a9fe667..9155ab7e25 100644 --- a/doc/superbuild/source/developers/commandline/Options.rst +++ b/doc/superbuild/source/developers/commandline/Options.rst @@ -631,10 +631,11 @@ this function are: :c:func:`CVodeCreate`). * ``moduleid``: a desired string identifier prefix for arguments to that module (e.g., "arkode"). Note that each module should specify a default string identifier, that would be - used if the user specifies ``NULL`` for this argument. However, users can supply + used if the user specifies ``NULL`` or ``""``for this argument. However, users can supply non-default identifiers so that they can control multiple instances of the same module independently (e.g., when using multiple ARKode integrators in the - same program). + same program). Whatever identifier is used, it should be unique to the module, and should be + separated from the key by a period, e.g., "arkode.order" or "cvode.max_steps". * ``file_name``: the name of a file containing options to read. If this is ``NULL`` or an empty string, ``""``, then no file is read. * ``argc``: the length of the ``argv`` array. From 2e3660bc7cbb77d0cbc74fa1af5df325736cda2b Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 22:54:46 -0400 Subject: [PATCH 103/114] Updated ark_analytic.c example to output solver parameters _after_ configuration --- examples/arkode/C_serial/ark_analytic.c | 8 ++-- examples/arkode/C_serial/ark_analytic.out | 43 ++++++++++++++++++- ...DE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out | 43 ++++++++++++++++++- 3 files changed, 87 insertions(+), 7 deletions(-) diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index c170ee987e..b98d679b4b 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -90,9 +90,7 @@ int main(int argc, char* argv[]) /* Initial diagnostics output */ printf("\nAnalytical ODE test problem:\n"); - printf(" lambda = %" GSYM "\n", lambda); - printf(" reltol = %.1" ESYM "\n", reltol); - printf(" abstol = %.1" ESYM "\n\n", abstol); + printf(" lambda = %" GSYM "\n\n", lambda); /* Initialize data structures */ y = N_VNew_Serial(NEQ, ctx); /* Create serial vector for solution */ @@ -134,6 +132,10 @@ int main(int argc, char* argv[]) flag = ARKodeSetOptions(arkode_mem, NULL, NULL, argc, argv); if (check_flag(&flag, "ARKodeSetOptions", 1)) { return 1; } + /* Output current ARKODE options */ + flag = ARKodeWriteParameters(arkode_mem, stdout); + if (check_flag(&flag, "ARKodeWriteParameters", 1)) { return 1; } + /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); fprintf(UFID, "# t u\n"); diff --git a/examples/arkode/C_serial/ark_analytic.out b/examples/arkode/C_serial/ark_analytic.out index f1d85e8e42..f822f3862f 100644 --- a/examples/arkode/C_serial/ark_analytic.out +++ b/examples/arkode/C_serial/ark_analytic.out @@ -1,8 +1,47 @@ Analytical ODE test problem: lambda = -100 - reltol = 1.0e-05 - abstol = 1.0e-10 + +ARKODE solver parameters: + Solver relative tolerance = 1e-05 + Solver absolute tolerance = 1e-10 + + Maximum step increase (first step) = 10000 + Step reduction factor on multiple error fails = 0.3 + Minimum error fails before above factor is used = 2 + Step reduction factor on nonlinear convergence failure = 0.25 + Explicit safety factor = 0.5 + Safety factor = 0.9 + Growth factor = 20 + Step growth lower bound = 1 + Step growth upper bound = 1 + No explicit stability function supplied +Soderlind SUNAdaptController module: + k1 = 1 + k2 = 0 + k3 = 0 + k4 = 0 + k5 = 0 + bias factor = 1 + previous error = 1 + previous-previous error = 1 + previous step = 1 + previous-previous step = 1 + firststeps = 0 + historysize = 0 + Maximum number of error test failures = 7 + Maximum number of convergence test failures = 10 +ARKStep time step module parameters: + Method order 4 + Linear implicit problem (time-independent Jacobian) + Implicit integrator + Implicit predictor method = 0 + Implicit solver tolerance coefficient = 0.1 + Maximum number of nonlinear corrections = 3 + Nonlinear convergence rate constant = 0.3 + Nonlinear divergence tolerance = 2.3 + Gamma factor LSetup tolerance = 2.22044604925031e-14 + Number of steps between LSetup calls = 20 t u --------------------- diff --git a/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out b/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out index 90197d4fbd..78af88676a 100644 --- a/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out +++ b/examples/arkode/C_serial/ark_analytic_arkode.scalar_tolerances_1e-6_1e-8_arkode.table_names_ARKODE_ESDIRK547L2SA_7_4_5_ARKODE_ERK_NONE.out @@ -1,8 +1,47 @@ Analytical ODE test problem: lambda = -100 - reltol = 1.0e-05 - abstol = 1.0e-10 + +ARKODE solver parameters: + Solver relative tolerance = 1e-06 + Solver absolute tolerance = 1e-08 + + Maximum step increase (first step) = 10000 + Step reduction factor on multiple error fails = 0.3 + Minimum error fails before above factor is used = 2 + Step reduction factor on nonlinear convergence failure = 0.25 + Explicit safety factor = 0.5 + Safety factor = 0.9 + Growth factor = 20 + Step growth lower bound = 1 + Step growth upper bound = 1 + No explicit stability function supplied +Soderlind SUNAdaptController module: + k1 = 1 + k2 = 0 + k3 = 0 + k4 = 0 + k5 = 0 + bias factor = 1 + previous error = 1 + previous-previous error = 1 + previous step = 1 + previous-previous step = 1 + firststeps = 0 + historysize = 0 + Maximum number of error test failures = 7 + Maximum number of convergence test failures = 10 +ARKStep time step module parameters: + Method order 5 + Linear implicit problem (time-independent Jacobian) + Implicit integrator + Implicit predictor method = 0 + Implicit solver tolerance coefficient = 0.1 + Maximum number of nonlinear corrections = 3 + Nonlinear convergence rate constant = 0.3 + Nonlinear divergence tolerance = 2.3 + Gamma factor LSetup tolerance = 2.22044604925031e-14 + Number of steps between LSetup calls = 20 t u --------------------- From 78c704026a1aa0b5295e936c8533610e9ba21b06 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 23:05:26 -0400 Subject: [PATCH 104/114] Updated idaAnalytic.c example to omit output of tolerances --- examples/ida/serial/idaAnalytic_mels.c | 4 +--- examples/ida/serial/idaAnalytic_mels.out | 2 -- .../idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index 9d8a702fbb..8fdaf9d220 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -89,9 +89,7 @@ int main(int argc, char* argv[]) /* Initial diagnostics output */ printf("\nAnalytical DAE test problem:\n"); - printf(" alpha = %" GSYM "\n", alpha); - printf(" reltol = %.1" ESYM "\n", reltol); - printf(" abstol = %.1" ESYM "\n\n", abstol); + printf(" alpha = %" GSYM "\n\n", alpha); /* Create the SUNDIALS context object for this simulation */ retval = SUNContext_Create(SUN_COMM_NULL, &ctx); diff --git a/examples/ida/serial/idaAnalytic_mels.out b/examples/ida/serial/idaAnalytic_mels.out index b904aa22e9..ef03bf58a7 100644 --- a/examples/ida/serial/idaAnalytic_mels.out +++ b/examples/ida/serial/idaAnalytic_mels.out @@ -1,8 +1,6 @@ Analytical DAE test problem: alpha = 10 - reltol = 1.0e-04 - abstol = 1.0e-09 t x1 x2 ---------------------------------- diff --git a/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out b/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out index 5e9a489028..badd9fd276 100644 --- a/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out +++ b/examples/ida/serial/idaAnalytic_mels_ida.scalar_tolerances_1e-3_1e-8.out @@ -1,8 +1,6 @@ Analytical DAE test problem: alpha = 10 - reltol = 1.0e-04 - abstol = 1.0e-09 t x1 x2 ---------------------------------- From b5c12591fe675286eae257b603e7d00a54b50a63 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 23:09:29 -0400 Subject: [PATCH 105/114] Updated idasAnalytic_mels to output the initial time step size taken --- examples/idas/serial/idasAnalytic_mels.c | 5 ++++- examples/idas/serial/idasAnalytic_mels.out | 1 + .../idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/idas/serial/idasAnalytic_mels.c b/examples/idas/serial/idasAnalytic_mels.c index c79a2d4f76..d4eef73a02 100644 --- a/examples/idas/serial/idasAnalytic_mels.c +++ b/examples/idas/serial/idasAnalytic_mels.c @@ -84,7 +84,7 @@ int main(int argc, char* argv[]) N_Vector yp = NULL; /* empty vector for storing solution derivative */ SUNLinearSolver LS = NULL; /* empty linear solver object */ void* ida_mem = NULL; /* empty IDA memory structure */ - sunrealtype t, tout; + sunrealtype t, tout, h0; long int nst, nre, nni, netf, ncfn, nreLS; /* Initial diagnostics output */ @@ -154,6 +154,8 @@ int main(int argc, char* argv[]) printf(" ----------------------------------\n"); /* Get/print some final statistics on how the solve progressed */ + retval = IDAGetActualInitStep(ida_mem, &h0); + check_retval(&retval, "IDAGetActualInitStep", 1); retval = IDAGetNumSteps(ida_mem, &nst); check_retval(&retval, "IDAGetNumSteps", 1); retval = IDAGetNumResEvals(ida_mem, &nre); @@ -168,6 +170,7 @@ int main(int argc, char* argv[]) check_retval(&retval, "IDAGetNumLinResEvals", 1); printf("\nFinal Solver Statistics: \n\n"); + printf("Initial time step = %8.6" FSYM "\n", h0); printf("Number of steps = %ld\n", nst); printf("Number of residual evaluations = %ld\n", nre + nreLS); printf("Number of nonlinear iterations = %ld\n", nni); diff --git a/examples/idas/serial/idasAnalytic_mels.out b/examples/idas/serial/idasAnalytic_mels.out index b904aa22e9..7d19c8b557 100644 --- a/examples/idas/serial/idasAnalytic_mels.out +++ b/examples/idas/serial/idasAnalytic_mels.out @@ -20,6 +20,7 @@ Analytical DAE test problem: Final Solver Statistics: +Initial time step = 0.000039 Number of steps = 343 Number of residual evaluations = 576 Number of nonlinear iterations = 576 diff --git a/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out b/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out index e4b6e81f6c..1acb932460 100644 --- a/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out +++ b/examples/idas/serial/idasAnalytic_mels_idas.init_step_1e-5.out @@ -20,6 +20,7 @@ Analytical DAE test problem: Final Solver Statistics: +Initial time step = 0.000010 Number of steps = 345 Number of residual evaluations = 578 Number of nonlinear iterations = 578 From e5f9b48874c224539a23acc53c1cb68550e4fd1c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 23:54:13 -0400 Subject: [PATCH 106/114] Removed command-line control over deprecated SPRKStepUseCompensatedSums, and added control over ARKodeUseCompensatedSums --- .../guide/source/Usage/SPRKStep/User_callable.rst | 5 ----- doc/arkode/guide/source/Usage/User_callable.rst | 4 ++++ src/arkode/arkode_cli.c | 3 ++- src/arkode/arkode_sprkstep_io.c | 14 -------------- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst b/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst index f1f18346e0..c1d737f24b 100644 --- a/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/SPRKStep/User_callable.rst @@ -506,11 +506,6 @@ Optional inputs for IVP method selection :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument had an illegal value - .. note:: - - This routine will be called by :c:func:`ARKodeSetOptions` - when using the key "arkid.use_compensated_sums". - .. deprecated:: 6.4.0 Use :c:func:`ARKodeSetUseCompensatedSums` instead. diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst index 7a21ab293e..d220f812ad 100644 --- a/doc/arkode/guide/source/Usage/User_callable.rst +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -1615,6 +1615,10 @@ Set the checkpointing step index (for adjoint) :c:func:`ARKodeSetAdjointChec :retval ARK_MEM_NULL: if the ARKODE memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument had an illegal value + .. note:: + + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.use_compensated_sums". .. _ARKODE.Usage.ARKodeAdaptivityInputTable: diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index c1fed96931..4d978ddcee 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -86,7 +86,8 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, {"small_num_efails", ARKodeSetSmallNumEFails}, {"max_err_test_fails", ARKodeSetMaxErrTestFails}, {"max_conv_fails", ARKodeSetMaxConvFails}, - {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}}; + {"linear_solution_scaling", ARKodeSetLinearSolutionScaling}, + {"use_compensated_sums", ARKodeSetUseCompensatedSums}}; static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); static const struct sunKeyLongPair long_pairs[] = {{"max_num_steps", diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index dc34ab28e7..fe10b4b911 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -209,10 +209,6 @@ int sprkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], {"method_name", SPRKStepSetMethodName}}; static const int num_char_keys = sizeof(char_pairs) / sizeof(*char_pairs); - static const struct sunKeyIntPair int_pairs[] = { - {"use_compensated_sums", SPRKStepSetUseCompensatedSums}}; - static const int num_int_keys = sizeof(int_pairs) / sizeof(*int_pairs); - /* check all "char" keys */ int j, retval; retval = sunCheckAndSetCharArgs((void*)ark_mem, argidx, argv, offset, @@ -225,16 +221,6 @@ int sprkStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], } if (*arg_used) { return ARK_SUCCESS; } - /* check all "int" keys */ - retval = sunCheckAndSetIntArgs((void*)ark_mem, argidx, argv, offset, - int_pairs, num_int_keys, arg_used, &j); - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "error setting key: %s", int_pairs[j].key); - return retval; - } - return (ARK_SUCCESS); } From 35b1f5d8ef21979514a1a0fec92df4cd3c4b0178 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 23:54:47 -0400 Subject: [PATCH 107/114] Added command-line control over the SplittingStep coefficients by name --- .../source/Usage/MRIStep/User_callable.rst | 2 +- .../Usage/SplittingStep/User_callable.rst | 13 ++++-- src/arkode/arkode_splittingstep.c | 40 +++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst index c9153b3c2c..889f187bbb 100644 --- a/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep/User_callable.rst @@ -801,7 +801,7 @@ Optional inputs for IVP method selection functions for creating Butcher tables see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. This routine will be called by :c:func:`ARKodeSetOptions` - when using the key "arkid.coupling_table_name", where *C* + when using the key "arkid.coupling_table_name", where ``C`` is itself constructed by passing the command-line option to :c:func:`MRIStepCoupling_LoadTableByName`. diff --git a/doc/arkode/guide/source/Usage/SplittingStep/User_callable.rst b/doc/arkode/guide/source/Usage/SplittingStep/User_callable.rst index 9a76dff675..43dd7d93be 100644 --- a/doc/arkode/guide/source/Usage/SplittingStep/User_callable.rst +++ b/doc/arkode/guide/source/Usage/SplittingStep/User_callable.rst @@ -82,7 +82,7 @@ SplittingStep initialization functions **Example codes:** * ``examples/arkode/C_serial/ark_advection_diffusion_reaction_splitting.c`` * ``examples/arkode/C_serial/ark_analytic_partitioned.c`` - + .. versionadded:: 6.2.0 @@ -106,10 +106,15 @@ Optional inputs for IVP method selection related functions for creating splitting coefficients see :numref:`ARKODE.Usage.SplittingStep.SplittingStepCoefficients`. + This routine will be called by :c:func:`ARKodeSetOptions` + when using the key "arkid.coefficients_name", where ``coefficients`` + is itself constructed by passing the command-line option to + :c:func:`SplittingStepCoefficients_LoadCoefficientsByName`. + .. warning:: This should not be used with :c:func:`ARKodeSetOrder`. - + .. versionadded:: 6.2.0 @@ -133,7 +138,7 @@ Optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SplittingStep memory was ``NULL`` :retval ARK_ILL_INPUT: if *partition* was out of bounds - + .. versionadded:: 6.2.0 @@ -208,5 +213,5 @@ the ODE and the :c:type:`SUNStepper` objects used to evolve each partition. will be reset since they are no longer compatible. Otherwise, all previously set options are retained but may be updated by calling the appropriate "Set" functions. - + .. versionadded:: 6.2.0 diff --git a/src/arkode/arkode_splittingstep.c b/src/arkode/arkode_splittingstep.c index 81995ec82f..3c87b5cb8c 100644 --- a/src/arkode/arkode_splittingstep.c +++ b/src/arkode/arkode_splittingstep.c @@ -449,6 +449,45 @@ static int splittingStep_SetOrder(ARKodeMem ark_mem, int order) return ARK_SUCCESS; } +/*------------------------------------------------------------------------------ + Routine to set SplittingStep options + ----------------------------------------------------------------------------*/ +int splittingStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) +{ + /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling + table; however, these may be specified by name, so here we'll support + a key to specify the MRIStepCoupling table name, + create the table with that name, attach it to MRIStep (who copies its + values), and then free the table. */ + if (strcmp(argv[*argidx] + offset, "coefficients_name") == 0) + { + (*argidx)++; + SplittingStepCoefficients Coefficients = + SplittingStepCoefficients_LoadCoefficientsByName(argv[*argidx]); + if (Coefficients == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "error setting key %s %s (invalid coefficients name)", + argv[(*argidx) - 1], argv[*argidx]); + return ARK_ILL_INPUT; + } + int retval = SplittingStepSetCoefficients(ark_mem, Coefficients); + SplittingStepCoefficients_Destroy(&Coefficients); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "error setting key %s %s (SetCoefficients failed)", + argv[(*argidx) - 1], argv[*argidx]); + return retval; + } + *arg_used = SUNTRUE; + return ARK_SUCCESS; + } + + return ARK_SUCCESS; +} + /*------------------------------------------------------------------------------ Resets all SplittingStep optional inputs to their default values. Does not change problem-defining function pointers or user_data pointer. @@ -613,6 +652,7 @@ void* SplittingStepCreate(SUNStepper* steppers, int partitions, sunrealtype t0, ark_mem->step_writeparameters = splittingStep_WriteParameters; ark_mem->step_free = splittingStep_Free; ark_mem->step_printmem = splittingStep_PrintMem; + ark_mem->step_setoption = splittingStep_SetOption; ark_mem->step_setdefaults = splittingStep_SetDefaults; ark_mem->step_setorder = splittingStep_SetOrder; ark_mem->step_mem = (void*)step_mem; From 4abe7378eaad384490a477030efc0d456c567b9a Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Thu, 17 Jul 2025 23:57:14 -0400 Subject: [PATCH 108/114] More unused variables --- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index b2f2be055c..17afab6e2b 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -261,9 +261,7 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; } From 5390b7758e9658d20ade9a00cd18f9e2d88043bf Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 18 Jul 2025 00:06:43 -0400 Subject: [PATCH 109/114] Fixed unused macro (I didn't even realize that was now cause for errors) --- examples/ida/serial/idaAnalytic_mels.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/ida/serial/idaAnalytic_mels.c b/examples/ida/serial/idaAnalytic_mels.c index 8fdaf9d220..3db29c1db8 100644 --- a/examples/ida/serial/idaAnalytic_mels.c +++ b/examples/ida/serial/idaAnalytic_mels.c @@ -36,11 +36,9 @@ #if defined(SUNDIALS_EXTENDED_PRECISION) #define GSYM "Lg" -#define ESYM "Le" #define FSYM "Lf" #else #define GSYM "g" -#define ESYM "e" #define FSYM "f" #endif From d54f74f8728c6e969be700adf9ab354edd674f24 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 18 Jul 2025 00:10:54 -0400 Subject: [PATCH 110/114] Added missing static --- src/arkode/arkode_splittingstep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_splittingstep.c b/src/arkode/arkode_splittingstep.c index 3c87b5cb8c..6394a932c9 100644 --- a/src/arkode/arkode_splittingstep.c +++ b/src/arkode/arkode_splittingstep.c @@ -452,8 +452,8 @@ static int splittingStep_SetOrder(ARKodeMem ark_mem, int order) /*------------------------------------------------------------------------------ Routine to set SplittingStep options ----------------------------------------------------------------------------*/ -int splittingStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], - size_t offset, sunbooleantype* arg_used) +static int splittingStep_SetOption(ARKodeMem ark_mem, int* argidx, char* argv[], + size_t offset, sunbooleantype* arg_used) { /* The only MRIStep-specific "Set" routine takes a custom MRIStepCoupling table; however, these may be specified by name, so here we'll support From 729e4ed5097621d273dc5b963360e0881f16dc0c Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 18 Jul 2025 12:42:58 -0400 Subject: [PATCH 111/114] Updated answers submodule commit --- test/answers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/answers b/test/answers index 8f806b94ad..ad580b0574 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 8f806b94ad4cf2208955d45e3336566003efbab1 +Subproject commit ad580b0574996ba1041e2306dfbace470b9f9759 From 3f3c48410310e13340591ba10fd17d7221c69624 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 18 Jul 2025 16:37:49 -0400 Subject: [PATCH 112/114] Fixed sanitizer CI issues --- src/arkode/arkode_cli.c | 2 +- src/cvode/cvode_cli.c | 2 +- src/cvodes/cvodes_cli.c | 2 +- src/ida/ida_cli.c | 2 +- src/idas/idas_cli.c | 2 +- src/kinsol/kinsol_cli.c | 2 +- src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c | 2 +- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 2 +- src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c | 2 +- src/sunlinsol/klu/sunlinsol_klu.c | 2 +- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 2 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 2 +- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 2 +- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 2 +- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 2 +- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 2 +- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c | 2 +- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index 4d978ddcee..a6874be789 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -138,7 +138,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, const char* default_id = "arkode"; size_t offset = strlen(default_id) + 1; if (arkid != NULL) { offset = SUNMAX(strlen(arkid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (arkid != NULL && strlen(arkid) > 0) { strcpy(prefix, arkid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index 71707ee85a..a2e0c16478 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -130,7 +130,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, const char* default_id = "cvode"; size_t offset = strlen(default_id) + 1; if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index eddc727179..c632e15985 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -163,7 +163,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, const char* default_id = "cvodes"; size_t offset = strlen(default_id) + 1; if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index 0773e8549f..a2aca8ff60 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -121,7 +121,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, const char* default_id = "ida"; size_t offset = strlen(default_id) + 1; if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index c320503f7e..798595fbc9 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -156,7 +156,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, const char* default_id = "idas"; size_t offset = strlen(default_id) + 1; if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index 1f004e0e60..b97058581c 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -107,7 +107,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, const char* default_id = "kinsol"; size_t offset = strlen(default_id) + 1; if (kinid != NULL) { offset = SUNMAX(strlen(kinid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (kinid != NULL && strlen(kinid) > 0) { strcpy(prefix, kinid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 42da65143e..42a4f1b426 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -145,7 +145,7 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, const char* default_id = "sunadaptcontroller"; size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index f31607222b..641a150200 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -156,7 +156,7 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, const char* default_id = "sunadaptcontroller"; size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 3f5c1a06cf..0b6ea63c42 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -154,7 +154,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, const char* default_id = "sunadaptcontroller"; size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 228d3a2094..635eb030ec 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -216,7 +216,7 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index e780d35145..b7ffc70a6c 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -276,7 +276,7 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 1b84d84615..92055f04b1 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -174,7 +174,7 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index f135120865..2afb436344 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -197,7 +197,7 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 13ee3bd00f..00b010aff1 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -185,7 +185,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 104696e839..3ea31884d6 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -182,7 +182,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 5d495edcc9..492047fd88 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -197,7 +197,7 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 17afab6e2b..31450d447f 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -254,7 +254,7 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 72529202b3..3596e84d3c 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -374,7 +374,7 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, const char* default_id = "sunnonlinearsolver"; size_t offset = strlen(default_id) + 1; if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index a98197a381..590430331b 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -437,7 +437,7 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, const char* default_id = "sunnonlinearsolver"; size_t offset = strlen(default_id) + 1; if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * offset); + char* prefix = (char*)malloc(sizeof(char) * (offset+1)); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); From a9b451d428600e68ffea9dbc776db5736403c1a4 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Fri, 18 Jul 2025 16:47:28 -0400 Subject: [PATCH 113/114] formatting --- src/arkode/arkode_cli.c | 2 +- src/cvode/cvode_cli.c | 2 +- src/cvodes/cvodes_cli.c | 2 +- src/ida/ida_cli.c | 2 +- src/idas/idas_cli.c | 2 +- src/kinsol/kinsol_cli.c | 2 +- src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c | 2 +- src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c | 2 +- src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c | 2 +- src/sunlinsol/klu/sunlinsol_klu.c | 2 +- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 2 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 2 +- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 2 +- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 2 +- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 2 +- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 2 +- src/sunlinsol/superlumt/sunlinsol_superlumt.c | 2 +- src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c | 2 +- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/arkode/arkode_cli.c b/src/arkode/arkode_cli.c index a6874be789..abdb22f13c 100644 --- a/src/arkode/arkode_cli.c +++ b/src/arkode/arkode_cli.c @@ -138,7 +138,7 @@ static int arkSetFromCommandLine(void* arkode_mem, const char* arkid, int argc, const char* default_id = "arkode"; size_t offset = strlen(default_id) + 1; if (arkid != NULL) { offset = SUNMAX(strlen(arkid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (arkid != NULL && strlen(arkid) > 0) { strcpy(prefix, arkid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/cvode/cvode_cli.c b/src/cvode/cvode_cli.c index a2e0c16478..67843ec52a 100644 --- a/src/cvode/cvode_cli.c +++ b/src/cvode/cvode_cli.c @@ -130,7 +130,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, const char* default_id = "cvode"; size_t offset = strlen(default_id) + 1; if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/cvodes/cvodes_cli.c b/src/cvodes/cvodes_cli.c index c632e15985..559c5479f3 100644 --- a/src/cvodes/cvodes_cli.c +++ b/src/cvodes/cvodes_cli.c @@ -163,7 +163,7 @@ static int cvSetFromCommandLine(void* cvode_mem, const char* cvid, int argc, const char* default_id = "cvodes"; size_t offset = strlen(default_id) + 1; if (cvid != NULL) { offset = SUNMAX(strlen(cvid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (cvid != NULL && strlen(cvid) > 0) { strcpy(prefix, cvid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/ida/ida_cli.c b/src/ida/ida_cli.c index a2aca8ff60..99bea911c2 100644 --- a/src/ida/ida_cli.c +++ b/src/ida/ida_cli.c @@ -121,7 +121,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, const char* default_id = "ida"; size_t offset = strlen(default_id) + 1; if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/idas/idas_cli.c b/src/idas/idas_cli.c index 798595fbc9..457f979a73 100644 --- a/src/idas/idas_cli.c +++ b/src/idas/idas_cli.c @@ -156,7 +156,7 @@ static int idaSetFromCommandLine(void* ida_mem, const char* idaid, int argc, const char* default_id = "idas"; size_t offset = strlen(default_id) + 1; if (idaid != NULL) { offset = SUNMAX(strlen(idaid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (idaid != NULL && strlen(idaid) > 0) { strcpy(prefix, idaid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/kinsol/kinsol_cli.c b/src/kinsol/kinsol_cli.c index b97058581c..828b676988 100644 --- a/src/kinsol/kinsol_cli.c +++ b/src/kinsol/kinsol_cli.c @@ -107,7 +107,7 @@ static int kinSetFromCommandLine(void* kinmem, const char* kinid, int argc, const char* default_id = "kinsol"; size_t offset = strlen(default_id) + 1; if (kinid != NULL) { offset = SUNMAX(strlen(kinid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (kinid != NULL && strlen(kinid) > 0) { strcpy(prefix, kinid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index 42a4f1b426..3d00a81853 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -145,7 +145,7 @@ static SUNErrCode setFromCommandLine_ImExGus(SUNAdaptController C, const char* default_id = "sunadaptcontroller"; size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c index 641a150200..5acd349f3e 100644 --- a/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c +++ b/src/sunadaptcontroller/mrihtol/sunadaptcontroller_mrihtol.c @@ -156,7 +156,7 @@ static SUNErrCode setFromCommandLine_MRIHTol(SUNAdaptController C, const char* default_id = "sunadaptcontroller"; size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index 0b6ea63c42..e4dba2fc70 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -154,7 +154,7 @@ static SUNErrCode setFromCommandLine_Soderlind(SUNAdaptController C, const char* default_id = "sunadaptcontroller"; size_t offset = strlen(default_id) + 1; if (Cid != NULL) { offset = SUNMAX(strlen(Cid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (Cid != NULL && strlen(Cid) > 0) { strcpy(prefix, Cid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/klu/sunlinsol_klu.c b/src/sunlinsol/klu/sunlinsol_klu.c index 635eb030ec..9674ee3ecb 100644 --- a/src/sunlinsol/klu/sunlinsol_klu.c +++ b/src/sunlinsol/klu/sunlinsol_klu.c @@ -216,7 +216,7 @@ static SUNErrCode setFromCommandLine_KLU(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index b7ffc70a6c..d1ad259727 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -276,7 +276,7 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 92055f04b1..642d8f2cfb 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -174,7 +174,7 @@ static SUNErrCode setFromCommandLine_PCG(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 2afb436344..a9c8e61f3a 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -197,7 +197,7 @@ static SUNErrCode setFromCommandLine_SPBCGS(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 00b010aff1..fa490d5426 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -185,7 +185,7 @@ static SUNErrCode setFromCommandLine_SPFGMR(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 3ea31884d6..e62ca6449a 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -182,7 +182,7 @@ static SUNErrCode setFromCommandLine_SPGMR(SUNLinearSolver S, const char* LSid, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 492047fd88..297ea476f7 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -197,7 +197,7 @@ static SUNErrCode setFromCommandLine_SPTFQMR(SUNLinearSolver S, const char* LSid const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunlinsol/superlumt/sunlinsol_superlumt.c b/src/sunlinsol/superlumt/sunlinsol_superlumt.c index 31450d447f..7895e62b2c 100644 --- a/src/sunlinsol/superlumt/sunlinsol_superlumt.c +++ b/src/sunlinsol/superlumt/sunlinsol_superlumt.c @@ -254,7 +254,7 @@ static SUNErrCode setFromCommandLine_SuperLUMT(SUNLinearSolver S, const char* default_id = "sunlinearsolver"; size_t offset = strlen(default_id) + 1; if (LSid != NULL) { offset = SUNMAX(strlen(LSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (LSid != NULL && strlen(LSid) > 0) { strcpy(prefix, LSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 3596e84d3c..6b9efbff71 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -374,7 +374,7 @@ static SUNErrCode setFromCommandLine_FixedPoint(SUNNonlinearSolver NLS, const char* default_id = "sunnonlinearsolver"; size_t offset = strlen(default_id) + 1; if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 590430331b..c437029e19 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -437,7 +437,7 @@ static SUNErrCode setFromCommandLine_Newton(SUNNonlinearSolver NLS, const char* default_id = "sunnonlinearsolver"; size_t offset = strlen(default_id) + 1; if (NLSid != NULL) { offset = SUNMAX(strlen(NLSid) + 1, offset); } - char* prefix = (char*)malloc(sizeof(char) * (offset+1)); + char* prefix = (char*)malloc(sizeof(char) * (offset + 1)); if (NLSid != NULL && strlen(NLSid) > 0) { strcpy(prefix, NLSid); } else { strcpy(prefix, default_id); } strcat(prefix, "."); From 1cc17fdac726c30a2cbfdc6b52c890682f3a3c80 Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Mon, 21 Jul 2025 08:48:12 -0400 Subject: [PATCH 114/114] Removed unused variables --- src/sunlinsol/magmadense/sunlinsol_magmadense.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp index d1ad259727..21e6075762 100644 --- a/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp +++ b/src/sunlinsol/magmadense/sunlinsol_magmadense.cpp @@ -283,9 +283,7 @@ static SUNErrCode setFromCommandLine_MagmaDense(SUNLinearSolver S, for (int idx = 1; idx < argc; idx++) { - SUNErrCode sunretval; - int j, retval; - sunbooleantype arg_used = SUNFALSE; + int retval; /* skip command-line arguments that do not begin with correct prefix */ if (strncmp(argv[idx], prefix, strlen(prefix)) != 0) { continue; }