From d0b6976c3ec055288d9d6805862010fad91fc840 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 19:34:33 -0700 Subject: [PATCH 001/235] update for begin-end labels --- scripts/sundialsdev/logs.py | 41 ++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 7965555d1c..ae67e939aa 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -19,6 +19,16 @@ import re import numpy as np +def convert_to_num(s): + """Try to convert a string to an int or float""" + + try: + return np.longlong(s) + except ValueError: + try: + return np.double(s) + except ValueError: + return s def parse_logfile_payload(payload, line_number, all_lines, array_indicator="(:)"): """ @@ -63,7 +73,7 @@ def parse_logfile_line(line, line_number, all_lines): line_dict = {} if matches: line_dict["loglvl"] = matches[0][0] - line_dict["rank"] = matches[0][1] + line_dict["rank"] = convert_to_num(matches[0][1].split()[1]) line_dict["scope"] = matches[0][2] line_dict["label"] = matches[0][3] line_dict["payload"] = parse_logfile_payload( @@ -98,20 +108,27 @@ def log_file_to_list(filename, step_scope_txt): line_dict = parse_logfile_line(line.rstrip(), line_number, all_lines) if not line_dict: continue - if ( - line_dict["scope"] == step_scope_txt - and line_dict["label"] == "enter-step-attempt-loop" - ): - if lines_for_this_step is None: - lines_for_this_step = [line_dict] - else: - log.append(lines_for_this_step) - lines_for_this_step = [line_dict] - else: - lines_for_this_step.append(line_dict) + if (line_dict["label"] == "begin-step-attempt"): + log.append(line_dict) + elif (line_dict["label"] == "end-step-attempt"): + log[-1]["payload"].update(line_dict["payload"]) return log +def get_history(log, key, step_status = "success"): + + steps = [] + times = [] + values = [] + + for l in log: + if (step_status in l["payload"]['status']): + steps.append(np.longlong(l["payload"]['step'])) + times.append(np.double(l["payload"]['t_n'])) + values.append(convert_to_num(l["payload"][key])) + + return steps, times, values + def cvode_debug_file_to_list(filename): """ This function takes a debug log file from CVODE and creates a list where From b0b56fc08118c021bf5817df9e6b7514bf6d8206 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 21:10:50 -0700 Subject: [PATCH 002/235] use raw string --- scripts/sundialsdev/logs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index ae67e939aa..0b9ade9d68 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -68,7 +68,7 @@ def parse_logfile_line(line, line_number, all_lines): y_2 ... """ - pattern = re.compile(r"\[(\w+)\]\[(rank \d+)\]\[(.*)\]\[(.*)\](.*)") + pattern = re.compile(r'\[(\w+)\]\[(rank \d+)\]\[(.*)\]\[(.*)\](.*)') matches = pattern.findall(line) line_dict = {} if matches: From a3a591510e0da58351ded5c2510049ee0f016a22 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 21:11:15 -0700 Subject: [PATCH 003/235] get history ranges --- scripts/sundialsdev/logs.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 0b9ade9d68..585e3510db 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -115,16 +115,32 @@ def log_file_to_list(filename, step_scope_txt): return log -def get_history(log, key, step_status = "success"): +def get_history(log, key, step_status = "success", time_range = None, + step_range = None): + """ + This function extracts the step/time series of the requested value. + """ steps = [] times = [] values = [] for l in log: + + step = np.longlong(l["payload"]['step']) + time = np.double(l["payload"]['t_n']) + + if (time_range is not None): + if (time > time_range[1] or time < time_range[0]): + continue + + if (step_range is not None): + if (step > step_range[1] or step < step_range[0]): + continue + if (step_status in l["payload"]['status']): - steps.append(np.longlong(l["payload"]['step'])) - times.append(np.double(l["payload"]['t_n'])) + steps.append(step) + times.append(time) values.append(convert_to_num(l["payload"][key])) return steps, times, values From c434b2acfdf868851906ea2b80dfdd26b4e2e730 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 21:51:50 -0700 Subject: [PATCH 004/235] add log function example --- scripts/sundialsdev/log_example.py | 108 +++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100755 scripts/sundialsdev/log_example.py diff --git a/scripts/sundialsdev/log_example.py b/scripts/sundialsdev/log_example.py new file mode 100755 index 0000000000..3c840fe76e --- /dev/null +++ b/scripts/sundialsdev/log_example.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +# ----------------------------------------------------------------------------- +# Programmer(s): David J. Gardner @ LLNL +# ----------------------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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 +# ----------------------------------------------------------------------------- +# Example script demonstrating how to use Python functions to extract and plot +# logs produced by SUNLogger. +# ----------------------------------------------------------------------------- + +def main(): + + import argparse + import numpy as np + import matplotlib.pyplot as plt + import matplotlib.ticker as tik + + import logs as sunlog + + parser = argparse.ArgumentParser(description='Plots') + + parser.add_argument('logfile', type=str, + help='Log file to plot') + + parser.add_argument('--val', type=str, default='h', + choices=['h', 'q', 'dsm'], + help='Value to plot') + + parser.add_argument('--step-number', action='store_true', + help='Plot value vs step number') + + parser.add_argument('--step-range', type=int, nargs=2, + default=None, help='Step range to plot') + + parser.add_argument('--time-range', type=float, nargs=2, + default=None, help='Time range to plot') + + parser.add_argument('--save', type=str, nargs='?', + const='fig.pdf', default=None, + help='''Save figure to file''') + + # parse command line args + args = parser.parse_args() + + # parse log file + log = sunlog.cvode_debug_file_to_list(args.logfile) + + # plot log data + steps_s, times_s, vals_s = sunlog.get_history(log, args.val, + step_range=args.step_range, + time_range=args.time_range) + + steps_f, times_f, vals_f = sunlog.get_history(log, args.val, 'failed', + step_range=args.step_range, + time_range=args.time_range) + + if args.step_number: + x_s = steps_s + x_f = steps_f + else: + x_s = times_s + x_f = times_f + + fig, ax = plt.subplots() + + ax.scatter(x_s, vals_s, color='green', marker='o', label='successful', + zorder=0.1) + + ax.scatter(x_f, vals_f, color='red', marker='x', label='failed', + zorder=0.2) + + if args.step_number: + ax.set_xlabel("step") + else: + ax.set_xlabel("time") + + if args.val == 'h': + ax.set_ylabel("step size") + elif args.val == 'q': + ax.set_ylabel("order") + ax.yaxis.set_major_locator(tik.MaxNLocator(integer=True)) + elif args.val == 'dsm': + ax.set_ylabel("LTE estimate") + + ax.legend(loc='best') + + ax.grid(alpha=0.3, linestyle='--') + + if args.save: + plt.savefig(args.save, bbox_inches='tight') + else: + plt.show() + +# ----------------------------------------------------------------------------- +# run the main routine +# ----------------------------------------------------------------------------- + +if __name__ == '__main__': + import sys + sys.exit(main()) From bae1c0ce6ba78bd4e08b0f50cb04656c747a6b5f Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 22:04:39 -0700 Subject: [PATCH 005/235] update logging output --- src/cvode/cvode.c | 61 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index 3dc22b9a40..d350f09945 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2353,12 +2353,12 @@ static int cvStep(CVodeMem cv_mem) for (;;) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvStep", - "enter-step-attempt-loop", - "step = %li, h = %.16g, q = %d, t_n = %.16g", - cv_mem->cv_nst, cv_mem->cv_next_h, cv_mem->cv_next_q, - cv_mem->cv_tn); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "begin-step-attempt", + "step = %li, t_n = %.16g, h = %.16g, q = %d", + cv_mem->cv_nst + 1, cv_mem->cv_tn, cv_mem->cv_h, + cv_mem->cv_q); #endif cvPredict(cv_mem); @@ -2367,6 +2367,15 @@ static int cvStep(CVodeMem cv_mem) nflag = cvNls(cv_mem, nflag); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed solve, kflag = %i", kflag); + } +#endif + /* Go back in loop if we need to predict again (nflag=PREV_CONV_FAIL) */ if (kflag == PREDICT_AGAIN) { continue; } @@ -2381,6 +2390,15 @@ static int cvStep(CVodeMem cv_mem) /* Perform projection (nflag=CV_SUCCESS) */ pflag = cvDoProjection(cv_mem, &nflag, saved_t, &npf); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (pflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed projection, pflag = %i", pflag); + } +#endif + /* Go back in loop if we need to predict again (nflag=PREV_PROJ_FAIL) */ if (pflag == PREDICT_AGAIN) { continue; } @@ -2391,6 +2409,16 @@ static int cvStep(CVodeMem cv_mem) /* Perform error test (nflag=CV_SUCCESS) */ eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, &nef, &dsm); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (eflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed error-test, dsm = %.16g, eflag = %i", + dsm, eflag); + } +#endif + /* Go back in loop if we need to predict again (nflag=PREV_ERR_FAIL) */ if (eflag == TRY_AGAIN) { continue; } @@ -2401,6 +2429,11 @@ static int cvStep(CVodeMem cv_mem) break; } +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__", + "end-step-attempt", "status = success, dsm = %.16g", dsm); +#endif + /* Nonlinear system solve and error test were both successful. Update data, and consider change of step and/or order. */ @@ -2703,7 +2736,7 @@ static void cvPredict(CVodeMem cv_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvPredict", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", "zn_0(:) =", ""); N_VPrintFile(cv_mem->cv_zn[0], CV_LOGGER->debug_fp); #endif @@ -3293,7 +3326,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, dsm = cv_mem->cv_acnrm * cv_mem->cv_tq[2]; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", "step = %li, h = %.16g, dsm = %.16g", cv_mem->cv_nst, cv_mem->cv_h, dsm); #endif @@ -3333,7 +3366,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cvRescale(cv_mem); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta", "eta = %.16g", cv_mem->cv_eta); #endif @@ -3351,7 +3384,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cv_mem->cv_qwait = cv_mem->cv_L; cvRescale(cv_mem); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta-mxnef1", "eta = %.16g", cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -3376,7 +3409,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, N_VScale(cv_mem->cv_h, cv_mem->cv_tempv, cv_mem->cv_zn[1]); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta-mxnef1-q1", "eta = %.16g", cv_mem->cv_eta); #endif @@ -3450,7 +3483,7 @@ static void cvCompleteStep(CVodeMem cv_mem) #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvCompleteStep", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", "nst = %d, nscon = %d", cv_mem->cv_nst, cv_mem->cv_nscon); #endif @@ -3501,9 +3534,9 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvPrepareNextStep", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d\n", + "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d", cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, cv_mem->cv_qwait); #endif From 2c7f5d25d6fc722c8a2720c058e83d0cd712d9e2 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 22:36:31 -0700 Subject: [PATCH 006/235] fix typo --- src/cvode/cvode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index d350f09945..4f31cb6bce 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2430,7 +2430,7 @@ static int cvStep(CVodeMem cv_mem) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", "status = success, dsm = %.16g", dsm); #endif From 271306cc2fe5c4d6d33c292cf97254ce1d5476eb Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 22:42:34 -0700 Subject: [PATCH 007/235] update cvodes logging --- src/cvodes/cvodes.c | 137 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 119 insertions(+), 18 deletions(-) diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index 5350674269..57b19e5bb7 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -5857,12 +5857,12 @@ static int cvStep(CVodeMem cv_mem) for (;;) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvStep", - "enter-step-attempt-loop", - "step = %li, h = %.16g, q = %d, t_n = %.16g", - cv_mem->cv_nst, cv_mem->cv_next_h, cv_mem->cv_next_q, - cv_mem->cv_tn); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "begin-step-attempt", + "step = %li, t_n = %.16g, h = %.16g, q = %d", + cv_mem->cv_nst + 1, cv_mem->cv_tn, cv_mem->cv_h, + cv_mem->cv_q); #endif cvPredict(cv_mem); @@ -5873,6 +5873,15 @@ static int cvStep(CVodeMem cv_mem) nflag = cvNls(cv_mem, nflag); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed solve, kflag = %i", kflag); + } +#endif + /* Go back in loop if we need to predict again (nflag=PREV_CONV_FAIL) */ if (kflag == PREDICT_AGAIN) { continue; } @@ -5887,6 +5896,15 @@ static int cvStep(CVodeMem cv_mem) /* Perform projection (nflag=CV_SUCCESS) */ pflag = cvDoProjection(cv_mem, &nflag, saved_t, &npf); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (pflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed projection, pflag = %i", pflag); + } +#endif + /* Go back in loop if we need to predict again (nflag=PREV_PROJ_FAIL) */ if (pflag == PREDICT_AGAIN) { continue; } @@ -5898,6 +5916,16 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrm, &nef, &(cv_mem->cv_netf), &dsm); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (eflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed error test, dsm = %.16g, eflag = %i", + dsm, eflag); + } +#endif + /* Go back in loop if we need to predict again (nflag=PREV_ERR_FAIL) */ if (eflag == TRY_AGAIN) { continue; } @@ -5915,6 +5943,15 @@ static int cvStep(CVodeMem cv_mem) nflag = cvQuadNls(cv_mem); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad solve, kflag = %i", kflag); + } +#endif + if (kflag == PREDICT_AGAIN) { continue; } if (kflag != DO_ERROR_TEST) { return (kflag); } @@ -5925,6 +5962,16 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmQ, &nefQ, &(cv_mem->cv_netfQ), &dsmQ); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (eflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad error test, dsmQ = %.16g, eflag = %i", + dsmQ, eflag); + } +#endif + if (eflag == TRY_AGAIN) { continue; } if (eflag != CV_SUCCESS) { return (eflag); } @@ -5947,6 +5994,16 @@ static int cvStep(CVodeMem cv_mem) retval = cv_mem->cv_f(cv_mem->cv_tn, cv_mem->cv_y, cv_mem->cv_ftemp, cv_mem->cv_user_data); cv_mem->cv_nfe++; + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (retval != 0) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed rhs eval, retval = %i", retval); + } +#endif + if (retval < 0) { return (CV_RHSFUNC_FAIL); } if (retval > 0) { @@ -5967,13 +6024,23 @@ static int cvStep(CVodeMem cv_mem) for (is = 0; is < cv_mem->cv_Ns; is++) { cv_mem->sens_solve_idx = is; - nflag = cvStgr1Nls(cv_mem, is); + + nflag = cvStgr1Nls(cv_mem, is); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &(cv_mem->cv_ncfS1[is]), &(cv_mem->cv_ncfnS1[is])); if (kflag != DO_ERROR_TEST) { break; } } } +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed sens solve, kflag = %i", kflag); + } +#endif + if (kflag == PREDICT_AGAIN) { continue; } if (kflag != DO_ERROR_TEST) { return (kflag); } @@ -5989,6 +6056,16 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmS, &nefS, &(cv_mem->cv_netfS), &dsmS); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (eflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed sens error test, dsmS = %.16g, eflag = %i", + dsmS, eflag); + } +#endif + if (eflag == TRY_AGAIN) { continue; } if (eflag != CV_SUCCESS) { return (eflag); } @@ -6017,6 +6094,15 @@ static int cvStep(CVodeMem cv_mem) nflag = cvQuadSensNls(cv_mem); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad sens solve, kflag = %i", kflag); + } +#endif + if (kflag == PREDICT_AGAIN) { continue; } if (kflag != DO_ERROR_TEST) { return (kflag); } @@ -6028,6 +6114,16 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmQS, &nefQS, &(cv_mem->cv_netfQS), &dsmQS); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (eflag != CV_SUCCESS) + { + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad sens error test, dsmQS = %.16g, eflag = %i", + dsmQS, eflag); + } +#endif + if (eflag == TRY_AGAIN) { continue; } if (eflag != CV_SUCCESS) { return (eflag); } @@ -6040,6 +6136,11 @@ static int cvStep(CVodeMem cv_mem) break; } +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", "status = success, dsm = %.16g", dsm); +#endif + /* Nonlinear system solve and error test were both successful. Update data, and consider change of step and/or order. */ @@ -6530,7 +6631,7 @@ static void cvPredict(CVodeMem cv_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvPredict", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "forward", "zn_0(:) =", ""); N_VPrintFile(cv_mem->cv_zn[0], CV_LOGGER->debug_fp); #endif @@ -6547,7 +6648,7 @@ static void cvPredict(CVodeMem cv_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvPredict", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "quad", "znQ_0(:) =", ""); N_VPrintFile(cv_mem->cv_znQ[0], CV_LOGGER->debug_fp); #endif @@ -6565,7 +6666,7 @@ static void cvPredict(CVodeMem cv_mem) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG for (i = 0; i < cv_mem->cv_Ns; i++) { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvPredict", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "sensi", " i = %d, znS_i(:) = ", i); N_VPrintFile(cv_mem->cv_znS[0][i], CV_LOGGER->debug_fp); } @@ -6586,7 +6687,7 @@ static void cvPredict(CVodeMem cv_mem) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG for (i = 0; i < cv_mem->cv_Ns; i++) { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvPredict", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "quad-sensi", " i = %d, znQS_i(:) = ", i); N_VPrintFile(cv_mem->cv_znQS[0][i], CV_LOGGER->debug_fp); } @@ -7469,7 +7570,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, dsm = acor_nrm * cv_mem->cv_tq[2]; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", "step = %li, h = %.16g, dsm = %.16g", cv_mem->cv_nst, cv_mem->cv_h, dsm); #endif @@ -7509,7 +7610,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cvRescale(cv_mem); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta", "eta = %.16g", cv_mem->cv_eta); #endif @@ -7527,7 +7628,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cv_mem->cv_qwait = cv_mem->cv_L; cvRescale(cv_mem); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta-mxnef1", "eta = %.16g", cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -7552,7 +7653,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, N_VScale(cv_mem->cv_h, cv_mem->cv_tempv, cv_mem->cv_zn[1]); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta-mxnef1-q1", "eta = %.16g", cv_mem->cv_eta); #endif @@ -7729,7 +7830,7 @@ static void cvCompleteStep(CVodeMem cv_mem) #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvCompleteStep", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", "nst = %d, nscon = %d", cv_mem->cv_nst, cv_mem->cv_nscon); #endif @@ -7780,9 +7881,9 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvPrepareNextStep", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d\n", + "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d", cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, cv_mem->cv_qwait); #endif From 5cb40feaf96795c206cd915a6bd5a568bb4da901 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 22:43:10 -0700 Subject: [PATCH 008/235] fix typo --- src/cvode/cvode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index 4f31cb6bce..540b466768 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2414,7 +2414,7 @@ static int cvStep(CVodeMem cv_mem) { SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", - "status = failed error-test, dsm = %.16g, eflag = %i", + "status = failed error test, dsm = %.16g, eflag = %i", dsm, eflag); } #endif From 2db2dee2b363b4923c254663bb4a686f09794a6f Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 22:49:48 -0700 Subject: [PATCH 009/235] use __func__ in IDA logging --- src/ida/ida.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ida/ida.c b/src/ida/ida.c index a349b63bb0..d92bab4e5a 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2505,7 +2505,7 @@ static int IDAStep(IDAMem IDA_mem) for (;;) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAStep", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "start-step-attempt", "step = %li, h = %" RSYM, IDA_mem->ida_nst, IDA_mem->ida_hh); #endif @@ -2749,7 +2749,7 @@ static int IDANls(IDAMem IDA_mem) IDA_mem->ida_nnf += nnf_inc; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDANls", "nls-return", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "nls-return", "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); #endif @@ -2866,7 +2866,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_k = (IDA_mem->ida_kk + 1) * (*err_k); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "estimate-error-order-k", "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); #endif @@ -2884,7 +2884,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_km1 = IDA_mem->ida_kk * (*err_km1); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "estimate-error-order-km1", "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, terr_km1); @@ -2901,7 +2901,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_km2 = (IDA_mem->ida_kk - 1) * err_km2; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "estimate-error-order-km2", "err_km2 = %" RSYM ", terr_km2 = %" RSYM, err_km2, terr_km2); @@ -2924,11 +2924,11 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "new-order", "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); #endif @@ -3088,7 +3088,7 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAHandleNFlag", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "first-error-test_fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -3107,7 +3107,7 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAHandleNFlag", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "second-error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -3125,7 +3125,7 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAHandleNFlag", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -3248,7 +3248,7 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, - "IDA::IDACompleteStep", "order-selection-raise", + __func__, "order-selection-raise", "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); #endif @@ -3261,7 +3261,7 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else { action = RAISE; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDACompleteStep", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "order-selection-rasie-or-lower", "terr_km1 = %" RSYM ", terr_k = %" RSYM ", terr_kp1 = %" RSYM, @@ -3313,7 +3313,7 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDACompleteStep", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "new-step-and-order", "knew = %i, err_knew = %" RSYM ", eta = %" RSYM ", hnew = %" RSYM, From 9fce7ece65eb77c53893807e6ee332196e3e8920 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 22:51:59 -0700 Subject: [PATCH 010/235] use __func__ in IDAS logging --- src/idas/idas.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/idas/idas.c b/src/idas/idas.c index 3702dc6963..1d03cdf397 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -5911,7 +5911,7 @@ static int IDAStep(IDAMem IDA_mem) for (;;) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAStep", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "start-step-attempt", "step = %li, h = %" RSYM, IDA_mem->ida_nst, IDA_mem->ida_hh); #endif @@ -6357,7 +6357,7 @@ static int IDANls(IDAMem IDA_mem) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDANls", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "nls-return", "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); #endif @@ -6676,7 +6676,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_k = (IDA_mem->ida_kk + 1) * (*err_k); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "estimate-error-order-k", "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); #endif @@ -6694,7 +6694,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_km1 = IDA_mem->ida_kk * (*err_km1); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "estimate-error-order-km1", "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, terr_km1); @@ -6711,7 +6711,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_km2 = (IDA_mem->ida_kk - 1) * (*err_km2); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "estimate-error-order-km2", "err_km2 = %" RSYM ", terr_km2 = %" RSYM, *err_km2, terr_km2); @@ -6734,11 +6734,11 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "new-order", "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDATestError", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); #endif @@ -7252,7 +7252,7 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAHandleNFlag", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "first-error-test_fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -7271,7 +7271,7 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAHandleNFlag", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "second-error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -7289,7 +7289,7 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAHandleNFlag", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -7473,7 +7473,7 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, - "IDAS::IDACompleteStep", "order-selection-raise", + __func__, "order-selection-raise", "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); #endif @@ -7486,7 +7486,7 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else { action = RAISE; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDACompleteStep", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "order-selection-rasie-or-lower", "terr_km1 = %" RSYM ", terr_k = %" RSYM ", terr_kp1 = %" RSYM, @@ -7538,7 +7538,7 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k IDA_mem->ida_hh *= IDA_mem->ida_eta; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDACompleteStep", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "new-step-and-order", "knew = %i, err_knew = %" RSYM ", eta = %" RSYM ", hnew = %" RSYM, From a7d021b188ab4ed3699e916f3a8f8a7de9c4dadd Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 7 Jun 2024 23:29:35 -0700 Subject: [PATCH 011/235] add begin-end step logging IDA --- src/ida/ida.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/ida/ida.c b/src/ida/ida.c index d92bab4e5a..dc4dc01663 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2506,8 +2506,10 @@ static int IDAStep(IDAMem IDA_mem) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "start-step-attempt", "step = %li, h = %" RSYM, - IDA_mem->ida_nst, IDA_mem->ida_hh); + "begin-step-attempt", + "step = %li, t_n = %.16g, h = %.16g, q = %d", + IDA_mem->ida_nst + 1, IDA_mem->ida_tn, IDA_mem->ida_hh, + IDA_mem->ida_kk); #endif /*----------------------- @@ -2555,6 +2557,23 @@ static int IDAStep(IDAMem IDA_mem) kflag = IDAHandleNFlag(IDA_mem, nflag, err_k, err_km1, &(IDA_mem->ida_ncfn), &ncf, &(IDA_mem->ida_netf), &nef); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (nflag == ERROR_TEST_FAIL) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed error test, dsm = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], + kflag); + } + else if (kflag != IDA_SUCCESS) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed solve, kflag = %i", kflag); + } +#endif + /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -2568,6 +2587,12 @@ static int IDAStep(IDAMem IDA_mem) } /* end loop */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", "status = success, dsm = %.16g", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk]); +#endif + /* Nonlinear system solve and error test were both successful; update data, and consider change of step and/or order */ From 22231016ff69a460acb3ca428233842c998a6339 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 08:03:15 -0700 Subject: [PATCH 012/235] add begin-end step logging IDAS --- src/idas/idas.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/src/idas/idas.c b/src/idas/idas.c index 1d03cdf397..38c57c538f 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -5912,8 +5912,10 @@ static int IDAStep(IDAMem IDA_mem) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "start-step-attempt", "step = %li, h = %" RSYM, - IDA_mem->ida_nst, IDA_mem->ida_hh); + "begin-step-attempt", + "step = %li, t_n = %.16g, h = %.16g, q = %d", + IDA_mem->ida_nst + 1, IDA_mem->ida_tn, IDA_mem->ida_hh, + IDA_mem->ida_kk); #endif /*----------------------- @@ -5967,6 +5969,23 @@ static int IDAStep(IDAMem IDA_mem) kflag = IDAHandleNFlag(IDA_mem, nflag, err_k, err_km1, &(IDA_mem->ida_ncfn), &ncf, &(IDA_mem->ida_netf), &nef); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (nflag == ERROR_TEST_FAIL) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed error test, dsm = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], + kflag); + } + else if (kflag != IDA_SUCCESS) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed solve, kflag = %i", kflag); + } +#endif + /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -5997,6 +6016,23 @@ static int IDAStep(IDAMem IDA_mem) &(IDA_mem->ida_ncfnQ), &ncf, &(IDA_mem->ida_netfQ), &nef); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (nflag == ERROR_TEST_FAIL) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad error test, dsmQ = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], + kflag); + } + else if (kflag != IDA_SUCCESS) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad solve, kflag = %i", kflag); + } +#endif + /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -6018,6 +6054,15 @@ static int IDAStep(IDAMem IDA_mem) retval = IDA_mem->ida_res(IDA_mem->ida_tn, IDA_mem->ida_yy, IDA_mem->ida_yp, IDA_mem->ida_delta, IDA_mem->ida_user_data); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (retval != 0) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed res eval, retval = %i", retval); + } +#endif + if (retval < 0) { return (IDA_RES_FAIL); } if (retval > 0) { continue; } @@ -6042,6 +6087,23 @@ static int IDAStep(IDAMem IDA_mem) &(IDA_mem->ida_ncfnQ), &ncf, &(IDA_mem->ida_netfQ), &nef); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (nflag == ERROR_TEST_FAIL) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed sens error test, dsmS = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], + kflag); + } + else if (kflag != IDA_SUCCESS) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed sens solve, kflag = %i", kflag); + } +#endif + /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -6073,6 +6135,23 @@ static int IDAStep(IDAMem IDA_mem) &(IDA_mem->ida_ncfnQ), &ncf, &(IDA_mem->ida_netfQ), &nef); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (nflag == ERROR_TEST_FAIL) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad sens error test, dsmQS = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], + kflag); + } + else if (kflag != IDA_SUCCESS) + { + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed quad sens solve, kflag = %i", kflag); + } +#endif + /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -6087,6 +6166,12 @@ static int IDAStep(IDAMem IDA_mem) } /* end loop */ +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", "status = success, dsm = %.16g", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk]); +#endif + /* Nonlinear system solve and error test were both successful; update data, and consider change of step and/or order */ From 15bc36d5b3643c1cc410a7660d39f285eaafed92 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 08:27:27 -0700 Subject: [PATCH 013/235] make logging levels more consistent --- src/arkode/arkode_adapt.c | 8 ++-- src/arkode/arkode_arkstep.c | 11 +---- src/ida/ida.c | 46 +++++++++---------- src/idas/idas.c | 46 +++++++++---------- src/sunlinsol/pcg/sunlinsol_pcg.c | 8 ++-- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 8 ++-- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 8 ++-- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 8 ++-- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 8 ++-- .../fixedpoint/sunnonlinsol_fixedpoint.c | 8 ++-- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 22 ++++----- 11 files changed, 87 insertions(+), 94 deletions(-) diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 7fef0ec2ae..d6c1a219af 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -133,8 +133,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, } if (h_cfl <= ZERO) { h_cfl = SUN_RCONST(1.0e30) * SUNRabs(hcur); } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt", +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkAdapt", "new-step-before-bounds", "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); #endif @@ -149,8 +149,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, /* enforce minimum bound time step reduction */ h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamin * hcur)); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt", +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkAdapt", "new-step-after-max-min-bounds", "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); #endif diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 4f6e403ccf..05123feb9c 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1826,10 +1826,10 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG if (is_start == 1) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "start-stage", "step = %li, stage = %i, implicit = %i, h = %" RSYM ", tcur = %" RSYM, @@ -2090,13 +2090,6 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, - "ARKODE::arkStep_TakeStep_Z", "end-step", - "step = %li, h = %" RSYM ", dsm = %" RSYM ", nflag = %d", - ark_mem->nst, ark_mem->h, *dsmPtr, *nflagPtr); -#endif - return (ARK_SUCCESS); } diff --git a/src/ida/ida.c b/src/ida/ida.c index dc4dc01663..b64b33bb5f 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2773,8 +2773,8 @@ static int IDANls(IDAMem IDA_mem) (void)SUNNonlinSolGetNumConvFails(IDA_mem->NLS, &nnf_inc); IDA_mem->ida_nnf += nnf_inc; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "nls-return", +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); #endif @@ -2890,8 +2890,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_k = IDA_mem->ida_sigma[IDA_mem->ida_kk] * enorm_k; terr_k = (IDA_mem->ida_kk + 1) * (*err_k); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-k", "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); #endif @@ -2908,8 +2908,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_km1 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 1] * enorm_km1; terr_km1 = IDA_mem->ida_kk * (*err_km1); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-km1", "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, terr_km1); @@ -2925,8 +2925,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, err_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * enorm_km2; terr_km2 = (IDA_mem->ida_kk - 1) * err_km2; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-km2", "err_km2 = %" RSYM ", terr_km2 = %" RSYM, err_km2, terr_km2); @@ -2948,12 +2948,12 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-order", "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); #endif @@ -3112,8 +3112,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "first-error-test_fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -3131,8 +3131,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "second-error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -3149,8 +3149,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -3271,8 +3271,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k if (terr_kp1 >= HALF * terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "order-selection-raise", "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); @@ -3285,8 +3285,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else if (terr_kp1 >= terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "order-selection-rasie-or-lower", "terr_km1 = %" RSYM ", terr_k = %" RSYM ", terr_kp1 = %" RSYM, @@ -3337,8 +3337,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k } IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-and-order", "knew = %i, err_knew = %" RSYM ", eta = %" RSYM ", hnew = %" RSYM, diff --git a/src/idas/idas.c b/src/idas/idas.c index 38c57c538f..5be3d440e3 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -6441,8 +6441,8 @@ static int IDANls(IDAMem IDA_mem) IDA_mem->ida_nnf += nnf_inc; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); #endif @@ -6760,8 +6760,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_k = IDA_mem->ida_sigma[IDA_mem->ida_kk] * enorm_k; terr_k = (IDA_mem->ida_kk + 1) * (*err_k); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-k", "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); #endif @@ -6778,8 +6778,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_km1 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 1] * enorm_km1; terr_km1 = IDA_mem->ida_kk * (*err_km1); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-km1", "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, terr_km1); @@ -6795,8 +6795,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * enorm_km2; terr_km2 = (IDA_mem->ida_kk - 1) * (*err_km2); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-km2", "err_km2 = %" RSYM ", terr_km2 = %" RSYM, *err_km2, terr_km2); @@ -6818,12 +6818,12 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-order", "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); #endif @@ -7336,8 +7336,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "first-error-test_fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -7355,8 +7355,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "second-error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -7373,8 +7373,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test-fail", "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); @@ -7556,8 +7556,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k if (terr_kp1 >= HALF * terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "order-selection-raise", "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); @@ -7570,8 +7570,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else if (terr_kp1 >= terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "order-selection-rasie-or-lower", "terr_km1 = %" RSYM ", terr_k = %" RSYM ", terr_kp1 = %" RSYM, @@ -7622,8 +7622,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k } IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-and-order", "knew = %i, err_knew = %" RSYM ", eta = %" RSYM ", hnew = %" RSYM, diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 30a7647a1d..38c10d1caf 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -346,8 +346,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, SUNCheckLastErr(); *res_norm = r0_norm = rho = SUNRsqrt(rho); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_PCG", +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_PCG", "initial-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif @@ -437,8 +437,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, SUNCheckLastErr(); *res_norm = rho = SUNRsqrt(rho); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_PCG", "iterate-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index daa873987c..09e9874640 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -423,8 +423,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_norm = rho = SUNRsqrt(beta_denom); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPBCGS", "initial-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif @@ -654,8 +654,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = rho = SUNRsqrt(N_VDotProd(r, r)); SUNCheckLastErr(); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPBCGS", "iterate-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 63a2c2940a..6f3bd0899c 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -463,8 +463,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); *res_norm = r_norm = beta = SUNRsqrt(r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPFGMR", "initial-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif @@ -574,8 +574,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPFGMR", "iterate-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 221a2f5660..04bec6cd38 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -467,8 +467,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); *res_norm = r_norm = beta = SUNRsqrt(r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPGMR", "initial-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif @@ -599,8 +599,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPGMR", "iterate-residual", "nli = %li, resnorm = %.16g", (long int)*nli, *res_norm); #endif diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 247b2548cf..e21d03d721 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -425,8 +425,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, to do anything */ *res_norm = r_init_norm = SUNRsqrt(rho[0]); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPFTQMR", "initial-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif @@ -654,8 +654,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* NOTE: just use approximation to norm of residual, if possible */ *res_norm = r_curr_norm = tau * SUNRsqrt(m + 1); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFOs - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_SPTFQMR", "iterate-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index ff1d45a2c9..15f8d34194 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -191,8 +191,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, FP_CONTENT(NLS)->niters = 0; FP_CONTENT(NLS)->nconvfails = 0; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNNonlinSolSolve_FixedPoint", "begin-iteration", "iter = %ld, nni = %ld", (long int)0, FP_CONTENT(NLS)->niters); @@ -240,8 +240,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, retval = FP_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, FP_CONTENT(NLS)->ctest_data); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNNonlinSolSolve_FixedPoint", "end-of-iterate", "iter = %ld, nni = %ld, wrmsnorm = %.16g", (long int)FP_CONTENT(NLS)->curiter, diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 94364f20ac..5ca055555e 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -210,12 +210,12 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* initialize current iteration counter for this solve attempt */ NEWTON_CONTENT(NLS)->curiter = 0; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "begin-attempt", "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "start-iterate", "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); @@ -255,8 +255,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, retval = NEWTON_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, NEWTON_CONTENT(NLS)->ctest_data); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "end-iterate", "iter = %ld, nni = %ld, wrmsnorm = %.16g", NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, N_VWrmsNorm(delta, w)); @@ -268,8 +268,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* if successful update Jacobian status and return */ if (retval == SUN_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "end-attempt", "success, iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); @@ -288,8 +288,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, break; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "start-iterate", "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); @@ -303,8 +303,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* all errors go here */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "end-attempt", "failure, iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); From 59bf5a05b748b168e1d49ea1cdfacc9f8e246728 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 12:04:20 -0700 Subject: [PATCH 014/235] add begin-end step logging ARKODE --- src/arkode/arkode.c | 80 +++++++++++++++++++++++++++++++++---- src/arkode/arkode_mristep.c | 19 +++++++++ 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 1473b8f204..a9a97845df 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -874,12 +874,11 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, attempts++; ark_mem->nst_attempts++; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::ARKodeEvolve", - "start-step", - "step = %li, attempt = %i, h = %" RSYM - ", tcur = %" RSYM, - ark_mem->nst, attempts, ark_mem->h, ark_mem->tcur); +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "begin-step-attempt", + "step = %li, t_n = %.16g, h = %.16g", + ark_mem->nst + 1, ark_mem->tn, ark_mem->h); #endif /* Call time stepper module to attempt a step: @@ -887,10 +886,29 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, >0 => step encountered recoverable failure; reduce step if possible <0 => step encountered unrecoverable failure */ kflag = ark_mem->step((void*)ark_mem, &dsm, &nflag); - if (kflag < 0) { break; } + if (kflag < 0) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + /* Only log fatal error here other returns handled below */ + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed step, kflag = %i", kflag); +#endif + break; + } /* handle solver convergence failures */ kflag = arkCheckConvergence(ark_mem, &nflag, &ncf); + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag != ARK_SUCCESS) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed solve, kflag = %i", kflag); + } +#endif + if (kflag < 0) { break; } /* Perform relaxation: @@ -901,6 +919,16 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, if (ark_mem->relax_enabled && (kflag == ARK_SUCCESS)) { kflag = arkRelax(ark_mem, &relax_fails, &dsm); + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag != ARK_SUCCESS) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed relaxtion, kflag = %i", kflag); + } +#endif + if (kflag < 0) { break; } } @@ -908,6 +936,16 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, if (ark_mem->constraintsSet && (kflag == ARK_SUCCESS)) { kflag = arkCheckConstraints(ark_mem, &constrfails, &nflag); + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag != ARK_SUCCESS) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed constraints, kflag = %i", kflag); + } +#endif + if (kflag < 0) { break; } } @@ -916,6 +954,10 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, if (ark_mem->fixedstep) { ark_mem->eta = ONE; +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", "status = success"); +#endif break; } @@ -923,6 +965,17 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, if (kflag == ARK_SUCCESS) { kflag = arkCheckTemporalError(ark_mem, &nflag, &nef, dsm); + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (kflag != ARK_SUCCESS) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", + "status = failed error test, dsm = %.16g, kflag = %i", + dsm, kflag); + } +#endif + if (kflag < 0) { break; } } @@ -931,11 +984,22 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { ark_mem->last_kflag = kflag; kflag = ARK_SUCCESS; +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", "status = success"); +#endif break; } /* break attempt loop on successful step */ - if (kflag == ARK_SUCCESS) { break; } + if (kflag == ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-step-attempt", "status = success, dsm = %.16g", dsm); +#endif + break; + } /* unsuccessful step, if |h| = hmin, return ARK_ERR_FAILURE */ if (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 0989e43a7c..7d59f4d3e1 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -2037,9 +2037,28 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) if (retval != 0) { return (ARK_OUTERTOINNER_FAIL); } } +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "begin-fast-steps", ""); +#endif + /* advance inner method in time */ retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, ark_mem->tcur, ark_mem->ycur); + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-fast-steps", "status = failed, retval = %i", retval); + } + else + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, + "end-fast-steps", "status = success"); + } +#endif + if (retval != 0) { return (ARK_INNERSTEP_FAIL); } /* post inner evolve function (if supplied) */ From 2c0c4886ae4d32d28892713a0fd65e6838c5b1d1 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 12:16:56 -0700 Subject: [PATCH 015/235] get mri history and add example --- scripts/sundialsdev/log_example.py | 6 +- scripts/sundialsdev/log_example_mri.py | 85 +++++++++++++++++++++++++ scripts/sundialsdev/logs.py | 86 +++++++++++++++++--------- 3 files changed, 146 insertions(+), 31 deletions(-) create mode 100755 scripts/sundialsdev/log_example_mri.py diff --git a/scripts/sundialsdev/log_example.py b/scripts/sundialsdev/log_example.py index 3c840fe76e..9327c29a10 100755 --- a/scripts/sundialsdev/log_example.py +++ b/scripts/sundialsdev/log_example.py @@ -13,7 +13,7 @@ # SUNDIALS Copyright End # ----------------------------------------------------------------------------- # Example script demonstrating how to use Python functions to extract and plot -# logs produced by SUNLogger. +# logs produced by the SUNLogger for adaptive integrators. # ----------------------------------------------------------------------------- def main(): @@ -51,10 +51,10 @@ def main(): args = parser.parse_args() # parse log file - log = sunlog.cvode_debug_file_to_list(args.logfile) + log = sunlog.log_file_to_list(args.logfile) # plot log data - steps_s, times_s, vals_s = sunlog.get_history(log, args.val, + steps_s, times_s, vals_s = sunlog.get_history(log, args.val, 'success', step_range=args.step_range, time_range=args.time_range) diff --git a/scripts/sundialsdev/log_example_mri.py b/scripts/sundialsdev/log_example_mri.py new file mode 100755 index 0000000000..6e50fef6f8 --- /dev/null +++ b/scripts/sundialsdev/log_example_mri.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# ----------------------------------------------------------------------------- +# Programmer(s): David J. Gardner @ LLNL +# ----------------------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, 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 +# ----------------------------------------------------------------------------- +# Example script demonstrating how to use Python functions to extract and plot +# logs produced by the SUNLogger with an MRI method. +# ----------------------------------------------------------------------------- + +def main(): + + import argparse + import numpy as np + import matplotlib.pyplot as plt + import matplotlib.ticker as tik + + import logs as sunlog + + parser = argparse.ArgumentParser(description='Plots') + + parser.add_argument('logfile', type=str, + help='Log file to plot') + + parser.add_argument('--step-number', action='store_true', + help='Plot value vs step number') + + parser.add_argument('--step-range', type=int, nargs=2, + default=None, help='Step range to plot') + + parser.add_argument('--time-range', type=float, nargs=2, + default=None, help='Time range to plot') + + parser.add_argument('--save', type=str, nargs='?', + const='fig.pdf', default=None, + help='''Save figure to file''') + + # parse command line args + args = parser.parse_args() + + # parse log file + log = sunlog.log_file_to_list(args.logfile) + + # plot log data + steps, times, vals = sunlog.get_history(log, 'h', + step_range=args.step_range, + time_range=args.time_range) + + if args.step_number: + x = steps + else: + x = times + + fig, ax = plt.subplots() + + ax.scatter(x, vals, color='green', marker='o') + + if args.step_number: + ax.set_xlabel("step") + else: + ax.set_xlabel("time") + + ax.set_ylabel("step size") + ax.grid(alpha=0.3, linestyle='--') + + if args.save: + plt.savefig(args.save, bbox_inches='tight') + else: + plt.show() + +# ----------------------------------------------------------------------------- +# run the main routine +# ----------------------------------------------------------------------------- + +if __name__ == '__main__': + import sys + sys.exit(main()) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 585e3510db..176eaada30 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # ----------------------------------------------------------------------------- -# Programmer(s): Cody Balos @ LLNL +# Programmer(s): Cody Balos and David J. Gardner @ LLNL # ----------------------------------------------------------------------------- # SUNDIALS Copyright Start # Copyright (c) 2002-2024, Lawrence Livermore National Security @@ -82,13 +82,12 @@ def parse_logfile_line(line, line_number, all_lines): return line_dict -def log_file_to_list(filename, step_scope_txt): +def log_file_to_list(filename): """ - This function takes a debug log file from a SUNDIALS log file and creates a list where - each list element represents an integrator step attempt. + This function takes a SUNDIALS log file and creates a list where each list + element represents an integrator step attempt. E.g., - [ [ { "loglvl": "DEBUG", @@ -97,25 +96,52 @@ def log_file_to_list(filename, step_scope_txt): "label": "enter-step-attempt-loop", "payload": {"step": "0", "h": "1e-06", "q": "1", "t_n": "0"}, }, ... - ], ... - ] + ] """ with open(filename, "r") as logfile: + + # List of dictionaries one for each step attempt log = [] - lines_for_this_step = None + + # Stack of logs for integrators composed of other integrators e.g., MRI + # methods or splitting methods + log_stack = [] + log_stack.append(log) + + # Level for nested integrators e.g., MRI methods + level = 0 + all_lines = logfile.readlines() for line_number, line in enumerate(all_lines): line_dict = parse_logfile_line(line.rstrip(), line_number, all_lines) if not line_dict: continue - if (line_dict["label"] == "begin-step-attempt"): - log.append(line_dict) - elif (line_dict["label"] == "end-step-attempt"): - log[-1]["payload"].update(line_dict["payload"]) + + line_dict["level"] = level + + if (line_dict["label"] == "begin-fast-steps"): + level += 1 + # Possibly multiple fast integrations per step so check if a + # list already exists + key = f"time-level-{level}" + if key not in log_stack[-1][-1]: + log_stack[-1][-1][key] = [] + log_stack.append(log_stack[-1][-1][key]) + continue + elif (line_dict["label"] == "end-fast-steps"): + level -= 1 + log_stack.pop() + continue + + if line_dict["label"] == "begin-step-attempt": + log_stack[-1].append(line_dict) + elif line_dict["label"] == "end-step-attempt": + log_stack[-1][-1]["payload"].update(line_dict["payload"]) + return log -def get_history(log, key, step_status = "success", time_range = None, +def get_history(log, key, step_status = None, time_range = None, step_range = None): """ This function extracts the step/time series of the requested value. @@ -130,24 +156,28 @@ def get_history(log, key, step_status = "success", time_range = None, step = np.longlong(l["payload"]['step']) time = np.double(l["payload"]['t_n']) - if (time_range is not None): - if (time > time_range[1] or time < time_range[0]): + if time_range is not None: + if time > time_range[1] or time < time_range[0]: continue - if (step_range is not None): - if (step > step_range[1] or step < step_range[0]): + if step_range is not None: + if step > step_range[1] or step < step_range[0]: continue - if (step_status in l["payload"]['status']): - steps.append(step) - times.append(time) - values.append(convert_to_num(l["payload"][key])) + if step_status is not None: + if step_status not in l["payload"]['status']: + continue - return steps, times, values + steps.append(step) + times.append(time) + values.append(convert_to_num(l["payload"][key])) -def cvode_debug_file_to_list(filename): - """ - This function takes a debug log file from CVODE and creates a list where - each list entry is a step attempt. See log_file_to_list. - """ - return log_file_to_list(filename, "CVODE::cvStep") + next_level_key = f'time-level-{l["level"] + 1}' + + if next_level_key in l: + sub_steps, sub_times, sub_values = get_history(l[next_level_key], key) + steps.extend(sub_steps) + times.extend(sub_times) + values.extend(sub_values) + + return steps, times, values From 7d558eba0863f866e13d5a0f175ce33ff1dda91a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 13:06:59 -0700 Subject: [PATCH 016/235] clean up --- src/arkode/arkode.c | 6 +- src/arkode/arkode_adapt.c | 6 +- src/arkode/arkode_arkstep.c | 59 ++++++-------- src/arkode/arkode_arkstep_nls.c | 2 +- src/arkode/arkode_erkstep.c | 26 +++--- src/arkode/arkode_interp.c | 6 +- src/arkode/arkode_ls.c | 6 +- src/arkode/arkode_mristep.c | 80 +++++-------------- src/arkode/arkode_relaxation.c | 20 ++--- src/cvode/cvode.c | 3 +- src/cvode/cvode_ls.c | 2 +- src/cvodes/cvodes.c | 17 ++-- src/cvodes/cvodes_ls.c | 2 +- src/kinsol/kinsol.c | 54 ++++++------- src/kinsol/kinsol_impl.h | 36 ++++----- src/kinsol/kinsol_ls.c | 4 +- src/sunlinsol/pcg/sunlinsol_pcg.c | 8 +- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 12 +-- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 12 +-- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 12 +-- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 12 +-- .../fixedpoint/sunnonlinsol_fixedpoint.c | 9 +-- 22 files changed, 160 insertions(+), 234 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index a9a97845df..bd41474b5d 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2580,9 +2580,9 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkCompleteStep", - "end-step", "step = %li, h = %" RSYM ", tcur = %" RSYM, - ark_mem->nst, ark_mem->h, ark_mem->tcur); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-step", + "step = %li, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, + ark_mem->h, ark_mem->tcur); #endif /* apply user-supplied step postprocessing function (if supplied) */ diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index d6c1a219af..2780a1cbb4 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -134,7 +134,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, if (h_cfl <= ZERO) { h_cfl = SUN_RCONST(1.0e30) * SUNRabs(hcur); } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkAdapt", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-before-bounds", "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); #endif @@ -150,7 +150,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamin * hcur)); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkAdapt", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-after-max-min-bounds", "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); #endif @@ -180,7 +180,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, ark_mem->eta /= SUNMAX(ONE, SUNRabs(hcur) * ark_mem->hmax_inv * ark_mem->eta); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkAdapt", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ARKODE::arkAdapt", "new-step-eta", "eta = %" RSYM, ark_mem->eta); #endif diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 05123feb9c..00ce35069d 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1829,29 +1829,25 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG if (is_start == 1) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "start-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", "step = %li, stage = %i, implicit = %i, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, 0, implicit_stage, ark_mem->h, ark_mem->tcur); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "explicit stage", - "z_%i(:) =", 0); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "explicit stage", "z_%i(:) =", 0); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); if (step_mem->implicit) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "implicit RHS", - "Fi_%i(:) =", 0); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "implicit RHS", "Fi_%i(:) =", 0); N_VPrintFile(step_mem->Fi[0], ARK_LOGGER->debug_fp); } if (step_mem->explicit) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "explicit RHS", - "Fe_%i(:) =", 0); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "explicit RHS", "Fe_%i(:) =", 0); N_VPrintFile(step_mem->Fe[0], ARK_LOGGER->debug_fp); } #endif @@ -1882,8 +1878,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) else { ark_mem->tcur = ark_mem->tn + step_mem->Be->c[is] * ark_mem->h; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "start-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", "step = %li, stage = %i, implicit = %i, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, is, implicit_stage, ark_mem->h, @@ -1918,8 +1913,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "predictor", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "predictor", "zpred(:) =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -1929,8 +1923,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval != ARK_SUCCESS) { return (retval); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "rhs data", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "rhs data", "sdata(:) =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -1944,9 +1937,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "implicit stage", - "z_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "implicit stage", "z_%i(:) =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -1968,9 +1960,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) N_VLinearSum(ONE, ark_mem->yn, ONE, step_mem->sdata, ark_mem->ycur); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "explicit stage", - "z_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "explicit stage", "z_%i(:) =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif } @@ -2013,9 +2004,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "implicit RHS", - "Fi_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "implicit RHS", "Fi_%i(:) =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif @@ -2031,9 +2021,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nfe++; #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "explicit RHS", - "Fe_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "explicit RHS", "Fe_%i(:) =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif @@ -2050,9 +2039,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) *nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fi[is], step_mem->nlscoef); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "M^{-1} implicit RHS", - "Fi_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "M^{-1} implicit RHS", "Fi_%i(:) =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } @@ -2062,9 +2050,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) *nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fe[is], step_mem->nlscoef); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "M^{-1} explicit RHS", - "Fe_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "M^{-1} explicit RHS", "Fe_%i(:) =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } @@ -2085,7 +2072,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr > 0) { return (TRY_AGAIN); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 939a82ad02..4a581da6e2 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -424,7 +424,7 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) ark_mem); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_Nls", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "correction", "zcor(:) =", ""); N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); #endif diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 5cc09d2390..83105f14f3 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -627,18 +627,17 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) Xvecs = step_mem->Xvecs; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "start-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", "step = %li, stage = 0, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, ark_mem->h, ark_mem->tcur); #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "stage", "z_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage", + "z_0(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "stage RHS", "F_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage RHS", + "F_0(:) =", ""); N_VPrintFile(step_mem->F[0], ARK_LOGGER->debug_fp); #endif @@ -665,8 +664,7 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tcur = ark_mem->tn + step_mem->B->c[is] * ark_mem->h; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::erkStep_TakeStep", "start-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", "step = %li, stage = %i, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, is, ark_mem->h, ark_mem->tcur); #endif @@ -703,8 +701,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::erkStep_TakeStep", "stage RHS", "F_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage RHS", + "F_%i(:) =", is); N_VPrintFile(step_mem->F[is], ARK_LOGGER->debug_fp); #endif @@ -715,15 +713,15 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (retval); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", - "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, - ark_mem->nst, ark_mem->h, *dsmPtr); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", + "step = %li, h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, + ark_mem->h, *dsmPtr); #endif return (ARK_SUCCESS); diff --git a/src/arkode/arkode_interp.c b/src/arkode/arkode_interp.c index daf42de479..21ad9fa620 100644 --- a/src/arkode/arkode_interp.c +++ b/src/arkode/arkode_interp.c @@ -461,8 +461,7 @@ int arkInterpEvaluate_Hermite(ARKodeMem ark_mem, ARKInterp interp, q = SUNMIN(q, HINT_DEGREE(interp)); /* respect max possible */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkInterpEvaluate_Hermite", "interp-eval", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "interp-eval", "tau = %" RSYM ", d = %i, q = %i", tau, d, q); #endif @@ -1204,8 +1203,7 @@ int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tau, q = SUNMIN(q, nhist - 1); /* respect max possible */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkInterpEvaluate_Lagrange", "interp-eval", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "interp-eval", "tau = %" RSYM ", d = %i, q = %i", tau, deriv, q); #endif diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index 1ed0939246..dce97a8fe8 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -3424,8 +3424,7 @@ int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, /* Log solver statistics to diagnostics file (if requested) */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkLsSolve", - "ls-stats", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ls-stats", "bnorm = %" RSYM ", resnorm = %" RSYM ", ls_iters = %i, prec_solves = %i", bnorm, resnorm, nli_inc, (int)(arkls_mem->nps - nps_inc)); @@ -3852,8 +3851,7 @@ int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef) /* Log solver statistics to diagnostics file (if requested) */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkLsMassSolve", - "mass-ls-stats", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "mass-ls-stats", "resnorm = %" RSYM ", ls_iters = %i, prec_solves = %i", resnorm, nli_inc, (int)(arkls_mem->nps - nps_inc)); #else diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 7d59f4d3e1..2cdc3a4fd4 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1490,25 +1490,20 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->fn_is_current = SUNTRUE; } -#ifdef SUNDIALS_DEBUG - printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", - ark_mem->nst, ark_mem->h, ark_mem->tcur); -#endif - #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "slow stage", "z_0(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "slow stage", + "z_0(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "slow explicit RHS", "Fse_0(:) =", ""); N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); } if (step_mem->implicit_rhs) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "slow implicit RHS", "Fsi_0(:) =", ""); N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); } @@ -1525,8 +1520,7 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "start-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", "step = %li, stage = %i, stage type = %d, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, @@ -1554,8 +1548,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval != ARK_SUCCESS) { return (retval); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow stage", "z_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "slow stage", + "z_%i(:) =", is); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif @@ -1591,9 +1585,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow explicit RHS", - "Fse_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "slow explicit RHS", "Fse_%i(:) =", is); N_VPrintFile(step_mem->Fse[step_mem->stage_map[is]], ARK_LOGGER->debug_fp); #endif @@ -1621,9 +1614,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStep", "slow implicit RHS", - "Fsi_%i(:) =", is); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "slow implicit RHS", "Fsi_%i(:) =", is); N_VPrintFile(step_mem->Fsi[step_mem->stage_map[is]], ARK_LOGGER->debug_fp); #endif @@ -1632,16 +1624,16 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } /* loop over stages */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "updated solution", "ycur(:) =", ""); N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", - "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, - ark_mem->nst, ark_mem->h, *dsmPtr); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", + "step = %li, h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, + ark_mem->h, *dsmPtr); #endif return (ARK_SUCCESS); @@ -2012,10 +2004,6 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) sunrealtype t0; /* start time for stage */ int retval; /* reusable return flag */ -#ifdef SUNDIALS_DEBUG - printf(" MRIStep ERK fast stage\n"); -#endif - /* Set initial time for fast evolution */ t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; @@ -2083,10 +2071,6 @@ int mriStep_StageERKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) { int retval, j, nvec; -#ifdef SUNDIALS_DEBUG - printf(" MRIStep ERK stage\n"); -#endif - /* determine effective ERK coefficients (store in cvals) */ retval = mriStep_RKCoeffs(step_mem->MRIC, is, step_mem->stage_map, step_mem->Ae_row, step_mem->Ai_row); @@ -2134,10 +2118,6 @@ int mriStep_StageDIRKFast(ARKodeMem ark_mem, SUNDIALS_MAYBE_UNUSED int is, SUNDIALS_MAYBE_UNUSED int* nflagPtr) { -#ifdef SUNDIALS_DEBUG - printf(" MRIStep DIRK fast stage\n"); -#endif - /* this is not currently implemented */ arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, "This routine is not yet implemented."); @@ -2155,10 +2135,6 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, { int retval; -#ifdef SUNDIALS_DEBUG - printf(" MRIStep DIRK stage\n"); -#endif - /* store current stage index */ step_mem->istage = is; @@ -2178,8 +2154,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_StageDIRKNoFast", "predictor", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "predictor", "zpred(:) =", ""); N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); #endif @@ -2194,8 +2169,7 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, if (retval != ARK_SUCCESS) { return (retval); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_StageDIRKNoFast", "rhs data", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "rhs data", "sdata(:) =", ""); N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); #endif @@ -2333,8 +2307,7 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG for (k = 0; k < nmat; k++) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_ComputeInnerForcing", "forcing", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "forcing", "forcing_%i(:) =", k); N_VPrintFile(step_mem->stepper->forcing[k], ARK_LOGGER->debug_fp); } @@ -2827,20 +2800,8 @@ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, if (stepper->ops == NULL) { return ARK_ILL_INPUT; } if (stepper->ops->evolve == NULL) { return ARK_ILL_INPUT; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, - "ARKODE::mriStepInnerStepper_Evolve", "start-inner-evolve", - "t0 = %" RSYM ", tout = %" RSYM, t0, tout); -#endif - stepper->last_flag = stepper->ops->evolve(stepper, t0, tout, y); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, - "ARKODE::mriStepInnerStepper_Evolve", "end-inner-evolve", - "flag = %i", stepper->last_flag); -#endif - return stepper->last_flag; } @@ -2866,9 +2827,8 @@ int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, if (stepper->ops == NULL) { return ARK_ILL_INPUT; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, - "ARKODE::mriStepInnerStepper_Reset", "reset-inner-state", - "tR = %" RSYM, tR); + SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, + "reset-inner-state", "tR = %" RSYM, tR); #endif if (stepper->ops->reset) diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index c911077580..2912feda00 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -123,8 +123,7 @@ static int arkRelaxNewtonSolve(ARKodeMem ark_mem) if (retval) { return retval; } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkRelaxNewtonSolve", "residual", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "residual", "iter = %i, relax_param = %" RSYM ", residual = %" RSYM, i, relax_mem->relax_param, relax_mem->res); #endif @@ -348,7 +347,7 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, if (retval) { return retval; } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "compute delta e", "delta_e = %" RSYM, relax_mem->delta_e); #endif @@ -356,7 +355,7 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->yn, ark_mem->tempv2); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "compute delta y", "delta_y(:) =", ""); N_VPrintFile(ark_mem->tempv2, ARK_LOGGER->debug_fp); #endif @@ -369,8 +368,8 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, if (retval > 0) { return ARK_RELAX_FUNC_RECV; } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", - "compute old e", "e_old = %" RSYM, relax_mem->e_old); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "compute old e", + "e_old = %" RSYM, relax_mem->e_old); #endif /* Initial guess for relaxation parameter */ @@ -895,12 +894,6 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout) /* Cut step size and try again */ ark_mem->eta = relax_mem->eta_fail; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "relaxation", - "relaxation failed"); -#endif - return TRY_AGAIN; } @@ -913,8 +906,7 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout) ark_mem->ycur); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::arkStep_TakeStep_Z", "relaxation", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "relaxation", "relaxation parameter = %" RSYM ", relaxed h = %" RSYM ", relaxed error = %" RSYM, relax_val, ark_mem->h, *dsm_inout); diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index 540b466768..89cf31f854 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -3534,8 +3534,7 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "return", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d", cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, cv_mem->cv_qwait); diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index c5b7755151..80556703d1 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -1781,7 +1781,7 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, cvls_mem->last_flag = retval; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvLsSolve", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ls-stats", "bnorm = %.16g, resnorm = %.16g, ls_iters = %i, prec_solves = %i", bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); #endif diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index 57b19e5bb7..2b8819ce51 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -6118,8 +6118,7 @@ static int cvStep(CVodeMem cv_mem) if (eflag != CV_SUCCESS) { SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad sens error test, dsmQS = %.16g, eflag = %i", + "end-step-attempt", "status = failed quad sens error test, dsmQS = %.16g, eflag = %i", dsmQS, eflag); } #endif @@ -6607,9 +6606,6 @@ void cvRescale(CVodeMem cv_mem) static void cvPredict(CVodeMem cv_mem) { -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - int i; -#endif int j, k; cv_mem->cv_tn += cv_mem->cv_h; @@ -6664,10 +6660,10 @@ static void cvPredict(CVodeMem cv_mem) ONE, cv_mem->cv_znS[j], cv_mem->cv_znS[j - 1]); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - for (i = 0; i < cv_mem->cv_Ns; i++) + for (int i = 0; i < cv_mem->cv_Ns; i++) { SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "sensi", " i = %d, znS_i(:) = ", i); + "sensi", "znS_%d(:) = ", i); N_VPrintFile(cv_mem->cv_znS[0][i], CV_LOGGER->debug_fp); } #endif @@ -6685,10 +6681,10 @@ static void cvPredict(CVodeMem cv_mem) ONE, cv_mem->cv_znQS[j], cv_mem->cv_znQS[j - 1]); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - for (i = 0; i < cv_mem->cv_Ns; i++) + for (int i = 0; i < cv_mem->cv_Ns; i++) { SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "quad-sensi", " i = %d, znQS_i(:) = ", i); + "quad-sensi", "znQS_%d(:) = ", i); N_VPrintFile(cv_mem->cv_znQS[0][i], CV_LOGGER->debug_fp); } #endif @@ -7881,8 +7877,7 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "return", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d", cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, cv_mem->cv_qwait); diff --git a/src/cvodes/cvodes_ls.c b/src/cvodes/cvodes_ls.c index 0e3d550499..26bfd13e99 100644 --- a/src/cvodes/cvodes_ls.c +++ b/src/cvodes/cvodes_ls.c @@ -1877,7 +1877,7 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, cvls_mem->last_flag = retval; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvLsSolve", + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ls-stats", "bnorm = %.16g, resnorm = %.16g, ls_iters = %i, prec_solves = %i", bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); #endif diff --git a/src/kinsol/kinsol.c b/src/kinsol/kinsol.c index d35c9b3393..b046bb04fd 100644 --- a/src/kinsol/kinsol.c +++ b/src/kinsol/kinsol.c @@ -537,7 +537,7 @@ int KINSol(void* kinmem, N_Vector u, int strategy_in, N_Vector u_scale, } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_TOL, "KINSOL", "KINSol", INFO_TOL, + KINPrintInfo(kin_mem, PRNT_TOL, "KINSOL", __func__, INFO_TOL, kin_mem->kin_scsteptol, kin_mem->kin_fnormtol); #endif @@ -709,7 +709,7 @@ int KINSol(void* kinmem, N_Vector u, int strategy_in, N_Vector u_scale, /* print the current nni, fnorm, and nfe values */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINSol", INFO_NNI, + KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", __func__, INFO_NNI, kin_mem->kin_nni, kin_mem->kin_nfe, kin_mem->kin_fnorm); #endif @@ -718,7 +718,7 @@ int KINSol(void* kinmem, N_Vector u, int strategy_in, N_Vector u_scale, } /* end of loop; return */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", "KINSol", INFO_RETVAL, ret); + KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", __func__, INFO_RETVAL, ret); #endif switch (ret) @@ -1521,7 +1521,7 @@ static int KINSolInit(KINMem kin_mem) /* all error checking is complete at this point */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_TOL, "KINSOL", "KINSolInit", INFO_TOL, + KINPrintInfo(kin_mem, PRNT_TOL, "KINSOL", __func__, INFO_TOL, kin_mem->kin_scsteptol, kin_mem->kin_fnormtol); #endif @@ -1593,7 +1593,7 @@ static int KINSolInit(KINMem kin_mem) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINSolInit", INFO_FMAX, fmax); + KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", __func__, INFO_FMAX, fmax); #endif /* initialize the linear solver if linit != NULL */ @@ -1615,7 +1615,7 @@ static int KINSolInit(KINMem kin_mem) kin_mem->kin_f1norm = HALF * kin_mem->kin_fnorm * kin_mem->kin_fnorm; kin_mem->kin_fnorm_sub = kin_mem->kin_fnorm; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINSolInit", INFO_NNI, + KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", __func__, INFO_NNI, kin_mem->kin_nni, kin_mem->kin_nfe, kin_mem->kin_fnorm); #endif @@ -1718,7 +1718,7 @@ static int KINFullNewton(KINMem kin_mem, sunrealtype* fnormp, pnorm = kin_mem->kin_mxnewtstep; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_PNORM, "KINSOL", "KINFullNewton", INFO_PNORM, pnorm); + KINPrintInfo(kin_mem, PRNT_PNORM, "KINSOL", __func__, INFO_PNORM, pnorm); #endif /* If constraints are active, then constrain the step accordingly */ @@ -1736,7 +1736,7 @@ static int KINFullNewton(KINMem kin_mem, sunrealtype* fnormp, pnorm *= kin_mem->kin_stepmul; kin_mem->kin_stepl = pnorm; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_PNORM, "KINSOL", "KINFullNewton", INFO_PNORM, + KINPrintInfo(kin_mem, PRNT_PNORM, "KINSOL", __func__, INFO_PNORM, pnorm); #endif if (pnorm <= kin_mem->kin_scsteptol) @@ -1794,7 +1794,7 @@ static int KINFullNewton(KINMem kin_mem, sunrealtype* fnormp, kin_mem->kin_sJpnorm *= ratio; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_FNORM, "KINSOL", "KINFullNewton", INFO_FNORM, + KINPrintInfo(kin_mem, PRNT_FNORM, "KINSOL", __func__, INFO_FNORM, *fnormp); #endif @@ -1904,7 +1904,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, rlmax = ONE; kin_mem->kin_stepl = pnorm; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_PNORM1, "KINSOL", "KINLineSearch", INFO_PNORM1, + KINPrintInfo(kin_mem, PRNT_PNORM1, "KINSOL", __func__, INFO_PNORM1, pnorm); #endif if (pnorm <= kin_mem->kin_scsteptol) @@ -1965,7 +1965,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, rl = ONE; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_LAM, "KINSOL", "KINLineSearch", INFO_LAM, rlmin, + KINPrintInfo(kin_mem, PRNT_LAM, "KINSOL", __func__, INFO_LAM, rlmin, kin_mem->kin_f1norm, pnorm); #endif @@ -1978,7 +1978,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, alpha_cond = kin_mem->kin_f1norm + (alpha * slpi * rl); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_ALPHA, "KINSOL", "KINLinesearch", INFO_ALPHA, + KINPrintInfo(kin_mem, PRNT_ALPHA, "KINSOL", __func__, INFO_ALPHA, *fnormp, *f1normp, alpha_cond, rl); #endif @@ -2077,7 +2077,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, beta_cond = kin_mem->kin_f1norm + (beta * slpi * rl); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_BETA, "KINSOL", "KINLineSearch", INFO_BETA, + KINPrintInfo(kin_mem, PRNT_BETA, "KINSOL", __func__, INFO_BETA, *f1normp, beta_cond, rl); #endif } @@ -2109,7 +2109,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, beta_cond = kin_mem->kin_f1norm + (beta * slpi * rl); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_ALPHABETA, "KINSOL", "KINLineSearch", + KINPrintInfo(kin_mem, PRNT_ALPHABETA, "KINSOL", __func__, INFO_ALPHABETA, *f1normp, alpha_cond, beta_cond, rl); #endif @@ -2152,7 +2152,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, kin_mem->kin_nbktrk += nbktrk_l; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_ADJ, "KINSOL", "KINLineSearch", INFO_ADJ, nbktrk_l); + KINPrintInfo(kin_mem, PRNT_ADJ, "KINSOL", __func__, INFO_ADJ, nbktrk_l); #endif /* scale sFdotJp and sJpnorm by rl * ratio for later use in KINForcingTerm */ @@ -2255,7 +2255,7 @@ static int KINStop(KINMem kin_mem, sunbooleantype maxStepTaken, int sflag) fmax = KINScFNorm(kin_mem, kin_mem->kin_fval, kin_mem->kin_fscale); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINStop", INFO_FMAX, fmax); + KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", __func__, INFO_FMAX, fmax); #endif if (fmax <= kin_mem->kin_fnormtol) { return (KIN_SUCCESS); } @@ -2725,13 +2725,13 @@ static int KINPicardAA(KINMem kin_mem) kin_mem->kin_fscale); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINPicardAA", INFO_FMAX, + KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", __func__, INFO_FMAX, kin_mem->kin_fnorm); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO /* print the current iter, fnorm, and nfe values */ - KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINPicardAA", INFO_NNI, + KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", __func__, INFO_NNI, kin_mem->kin_nni, kin_mem->kin_nfe, kin_mem->kin_fnorm); #endif @@ -2752,7 +2752,7 @@ static int KINPicardAA(KINMem kin_mem) } /* end of loop; return */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", "KINPicardAA", INFO_RETVAL, ret); + KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", __func__, INFO_RETVAL, ret); #endif return (ret); @@ -2841,7 +2841,7 @@ static int KINFP(KINMem kin_mem) tolfac = ONE; #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, "KINSOL::KINFP", "begin", + SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin", "%s", "u_0(:) ="); N_VPrintFile(kin_mem->kin_uu, KIN_LOGGER->debug_fp); #endif @@ -2860,7 +2860,7 @@ static int KINFP(KINMem kin_mem) kin_mem->kin_nfe++; #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, "KINSOL::KINFP", + SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "while-loop-before-compute-new", "G_%ld(:) =", kin_mem->kin_nni - 1); N_VPrintFile(kin_mem->kin_fval, KIN_LOGGER->debug_fp); @@ -2916,9 +2916,9 @@ static int KINFP(KINMem kin_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, "KINSOL::KINFP", - "while-loop-after-compute-new", - "u_%ld(:) =", kin_mem->kin_nni); + SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "while-loop-after-compute-new", "u_%ld(:) =", + kin_mem->kin_nni); N_VPrintFile(kin_mem->kin_unew, KIN_LOGGER->debug_fp); #endif @@ -2929,13 +2929,13 @@ static int KINFP(KINMem kin_mem) kin_mem->kin_fnorm = KINScFNorm(kin_mem, delta, kin_mem->kin_fscale); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINFP", INFO_FMAX, + KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", __func__, INFO_FMAX, kin_mem->kin_fnorm); #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO /* print the current iter, fnorm, and nfe values */ - KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINFP", INFO_NNI, + KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", __func__, INFO_NNI, kin_mem->kin_nni, kin_mem->kin_nfe, kin_mem->kin_fnorm); #endif @@ -2957,7 +2957,7 @@ static int KINFP(KINMem kin_mem) } /* end of loop; return */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", "KINFP", INFO_RETVAL, ret); + KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", __func__, INFO_RETVAL, ret); #endif return (ret); diff --git a/src/kinsol/kinsol_impl.h b/src/kinsol/kinsol_impl.h index 117bf003f5..0e16581223 100644 --- a/src/kinsol/kinsol_impl.h +++ b/src/kinsol/kinsol_impl.h @@ -475,50 +475,50 @@ void KINInfoHandler(const char* module, const char* function, char* msg, #if defined(SUNDIALS_EXTENDED_PRECISION) #define INFO_RVAR "%s = %26.16Lg" -#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = %26.16Lg" -#define INFO_TOL "scsteptol = %12.3Lg fnormtol = %12.3Lg" +#define INFO_NNI "nni = %4ld, nfe = %6ld, fnorm = %26.16Lg" +#define INFO_TOL "scsteptol = %12.3Lg, fnormtol = %12.3Lg" #define INFO_FMAX "scaled f norm (for stopping) = %12.3Lg" #define INFO_PNORM "pnorm = %12.4Le" #define INFO_PNORM1 "(ivio=1) pnorm = %12.4Le" #define INFO_FNORM "fnorm(L2) = %20.8Le" -#define INFO_LAM "min_lam = %11.4Le f1norm = %11.4Le pnorm = %11.4Le" +#define INFO_LAM "min_lam = %11.4Le, f1norm = %11.4Le, pnorm = %11.4Le" #define INFO_ALPHA \ - "fnorm = %15.8Le f1norm = %15.8Le alpha_cond = %15.8Le lam = %15.8Le" -#define INFO_BETA "f1norm = %15.8Le beta_cond = %15.8Le lam = %15.8Le" + "fnorm = %15.8Le, f1norm = %15.8Le, alpha_cond = %15.8Le, lam = %15.8Le" +#define INFO_BETA "f1norm = %15.8Le, beta_cond = %15.8Le, lam = %15.8Le" #define INFO_ALPHABETA \ - "f1norm = %15.8Le alpha_cond = %15.8Le beta_cond = %15.8Le lam = %15.8Le" + "f1norm = %15.8Le, alpha_cond = %15.8Le, beta_cond = %15.8Le, lam = %15.8Le" #elif defined(SUNDIALS_DOUBLE_PRECISION) #define INFO_RVAR "%s = %26.16lg" -#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = %26.16lg" -#define INFO_TOL "scsteptol = %12.3lg fnormtol = %12.3lg" +#define INFO_NNI "nni = %4ld, nfe = %6ld, fnorm = %26.16lg" +#define INFO_TOL "scsteptol = %12.3lg, fnormtol = %12.3lg" #define INFO_FMAX "scaled f norm (for stopping) = %12.3lg" #define INFO_PNORM "pnorm = %12.4le" #define INFO_PNORM1 "(ivio=1) pnorm = %12.4le" #define INFO_FNORM "fnorm(L2) = %20.8le" -#define INFO_LAM "min_lam = %11.4le f1norm = %11.4le pnorm = %11.4le" +#define INFO_LAM "min_lam = %11.4le, f1norm = %11.4le, pnorm = %11.4le" #define INFO_ALPHA \ - "fnorm = %15.8le f1norm = %15.8le alpha_cond = %15.8le lam = %15.8le" -#define INFO_BETA "f1norm = %15.8le beta_cond = %15.8le lam = %15.8le" + "fnorm = %15.8le, f1norm = %15.8le, alpha_cond = %15.8le,lam = %15.8le" +#define INFO_BETA "f1norm = %15.8le, beta_cond = %15.8le, lam = %15.8le" #define INFO_ALPHABETA \ - "f1norm = %15.8le alpha_cond = %15.8le beta_cond = %15.8le lam = %15.8le" + "f1norm = %15.8le, alpha_cond = %15.8le, beta_cond = %15.8le, lam = %15.8le" #else #define INFO_RVAR "%s = %26.16g" -#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = %26.16g" -#define INFO_TOL "scsteptol = %12.3g fnormtol = %12.3g" +#define INFO_NNI "nni = %4ld, nfe = %6ld, fnorm = %26.16g" +#define INFO_TOL "scsteptol = %12.3g, fnormtol = %12.3g" #define INFO_FMAX "scaled f norm (for stopping) = %12.3g" #define INFO_PNORM "pnorm = %12.4e" #define INFO_PNORM1 "(ivio=1) pnorm = %12.4e" #define INFO_FNORM "fnorm(L2) = %20.8e" -#define INFO_LAM "min_lam = %11.4e f1norm = %11.4e pnorm = %11.4e" +#define INFO_LAM "min_lam = %11.4e, f1norm = %11.4e, pnorm = %11.4e" #define INFO_ALPHA \ - "fnorm = %15.8e f1norm = %15.8e alpha_cond = %15.8e lam = %15.8e" -#define INFO_BETA "f1norm = %15.8e beta_cond = %15.8e lam = %15.8e" + "fnorm = %15.8e, f1norm = %15.8e, alpha_cond = %15.8e, lam = %15.8e" +#define INFO_BETA "f1norm = %15.8e, beta_cond = %15.8e, lam = %15.8e" #define INFO_ALPHABETA \ - "f1norm = %15.8e alpha_cond = %15.8e beta_cond = %15.8e lam = %15.8e" + "f1norm = %15.8e, alpha_cond = %15.8e, beta_cond = %15.8e, lam = %15.8e" #endif diff --git a/src/kinsol/kinsol_ls.c b/src/kinsol/kinsol_ls.c index 750c713c3b..a13fef09f8 100644 --- a/src/kinsol/kinsol_ls.c +++ b/src/kinsol/kinsol_ls.c @@ -1252,7 +1252,7 @@ int kinLsSolve(KINMem kin_mem, N_Vector xx, N_Vector bb, sunrealtype* sJpnorm, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO if (kinls_mem->iterative) { - KINPrintInfo(kin_mem, PRNT_NLI, "KINLS", "kinLsSolve", INFO_NLI, nli_inc); + KINPrintInfo(kin_mem, PRNT_NLI, "KINLS", __func__, INFO_NLI, nli_inc); } #endif @@ -1336,7 +1336,7 @@ int kinLsSolve(KINMem kin_mem, N_Vector xx, N_Vector bb, sunrealtype* sJpnorm, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO if (kin_mem->kin_inexact_ls) { - KINPrintInfo(kin_mem, PRNT_EPS, "KINLS", "kinLsSolve", INFO_EPS, res_norm, + KINPrintInfo(kin_mem, PRNT_EPS, "KINLS", __func__, INFO_EPS, res_norm, kin_mem->kin_eps); } #endif diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 38c10d1caf..182de66d7f 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -347,7 +347,7 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, *res_norm = r0_norm = rho = SUNRsqrt(rho); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, "SUNLinSolSolve_PCG", + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, "initial-residual", "nli = %li, resnorm = %.16g", (long int)0, *res_norm); #endif @@ -438,9 +438,9 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, *res_norm = rho = SUNRsqrt(rho); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_PCG", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "iterate-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (rho <= delta) diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 09e9874640..a3f692e3b6 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -424,9 +424,9 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_norm = rho = SUNRsqrt(beta_denom); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPBCGS", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "initial-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (r_norm <= delta) @@ -655,9 +655,9 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPBCGS", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "iterate-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (rho <= delta) diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index 6f3bd0899c..f62775d254 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -464,9 +464,9 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_norm = beta = SUNRsqrt(r_norm); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPFGMR", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "initial-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (r_norm <= delta) @@ -575,9 +575,9 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = rho = SUNRabs(rotation_product * r_norm); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPFGMR", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "iterate-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (rho <= delta) diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 04bec6cd38..0b60c2b7dc 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -468,9 +468,9 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_norm = beta = SUNRsqrt(r_norm); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPGMR", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "initial-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (r_norm <= delta) @@ -600,9 +600,9 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = rho = SUNRabs(rotation_product * r_norm); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPGMR", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)*nli, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "iterate-residual", "nli = %li, resnorm = %.16g", + (long int)*nli, *res_norm); #endif if (rho <= delta) diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index e21d03d721..39ee78abd0 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -426,9 +426,9 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_init_norm = SUNRsqrt(rho[0]); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPFTQMR", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "initial-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif if (r_init_norm <= delta) @@ -655,9 +655,9 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_curr_norm = tau * SUNRsqrt(m + 1); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNLinSolSolve_SPTFQMR", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "iterate-residual", "nli = %li, resnorm = %.16g", + (long int)0, *res_norm); #endif /* Exit inner loop if iteration has converged based upon approximation diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 15f8d34194..4f4ad51e1e 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -192,9 +192,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, FP_CONTENT(NLS)->nconvfails = 0; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNNonlinSolSolve_FixedPoint", "begin-iteration", - "iter = %ld, nni = %ld", (long int)0, + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "begin-iteration", "iter = %ld, nni = %ld", (long int)0, FP_CONTENT(NLS)->niters); #endif @@ -241,8 +240,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, FP_CONTENT(NLS)->ctest_data); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, - "SUNNonlinSolSolve_FixedPoint", "end-of-iterate", + SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, + "end-of-iterate", "iter = %ld, nni = %ld, wrmsnorm = %.16g", (long int)FP_CONTENT(NLS)->curiter, FP_CONTENT(NLS)->niters, N_VWrmsNorm(delta, w)); From c77782f1ff6754502e4b0ff0b0c55e1abd675911 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 13:18:40 -0700 Subject: [PATCH 017/235] formatting --- src/arkode/arkode.c | 10 ++++----- src/arkode/arkode_arkstep_nls.c | 4 ++-- src/cvode/cvode.c | 23 ++++++++++---------- src/cvodes/cvodes.c | 37 +++++++++++++++------------------ src/ida/ida.c | 20 ++++++++---------- src/idas/idas.c | 34 +++++++++++++----------------- src/kinsol/kinsol.c | 21 ++++++++----------- 7 files changed, 68 insertions(+), 81 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index bd41474b5d..2c180899d6 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -877,8 +877,8 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, "begin-step-attempt", - "step = %li, t_n = %.16g, h = %.16g", - ark_mem->nst + 1, ark_mem->tn, ark_mem->h); + "step = %li, t_n = %.16g, h = %.16g", ark_mem->nst + 1, + ark_mem->tn, ark_mem->h); #endif /* Call time stepper module to attempt a step: @@ -970,8 +970,7 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, if (kflag != ARK_SUCCESS) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed error test, dsm = %.16g, kflag = %i", + "end-step-attempt", "status = failed error test, dsm = %.16g, kflag = %i", dsm, kflag); } #endif @@ -996,7 +995,8 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success, dsm = %.16g", dsm); + "end-step-attempt", "status = success, dsm = %.16g", + dsm); #endif break; } diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 4a581da6e2..19d3f9576c 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -424,8 +424,8 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) ark_mem); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "correction", "zcor(:) =", ""); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "correction", + "zcor(:) =", ""); N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); #endif diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index 89cf31f854..f416a164a3 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2430,8 +2430,8 @@ static int cvStep(CVodeMem cv_mem) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success, dsm = %.16g", dsm); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", + "status = success, dsm = %.16g", dsm); #endif /* Nonlinear system solve and error test were both successful. @@ -2736,8 +2736,8 @@ static void cvPredict(CVodeMem cv_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "return", "zn_0(:) =", ""); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", + "zn_0(:) =", ""); N_VPrintFile(cv_mem->cv_zn[0], CV_LOGGER->debug_fp); #endif } @@ -3326,9 +3326,9 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, dsm = cv_mem->cv_acnrm * cv_mem->cv_tq[2]; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "error-test", "step = %li, h = %.16g, dsm = %.16g", - cv_mem->cv_nst, cv_mem->cv_h, dsm); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", + "step = %li, h = %.16g, dsm = %.16g", cv_mem->cv_nst, + cv_mem->cv_h, dsm); #endif /* If est. local error norm dsm passes test, return CV_SUCCESS */ @@ -3366,8 +3366,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cvRescale(cv_mem); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-eta", "eta = %.16g", cv_mem->cv_eta); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta", + "eta = %.16g", cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -3483,9 +3483,8 @@ static void cvCompleteStep(CVodeMem cv_mem) #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "return", "nst = %d, nscon = %d", cv_mem->cv_nst, - cv_mem->cv_nscon); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", + "nst = %d, nscon = %d", cv_mem->cv_nst, cv_mem->cv_nscon); #endif } diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index 2b8819ce51..70910eca31 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -5966,8 +5966,7 @@ static int cvStep(CVodeMem cv_mem) if (eflag != CV_SUCCESS) { SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad error test, dsmQ = %.16g, eflag = %i", + "end-step-attempt", "status = failed quad error test, dsmQ = %.16g, eflag = %i", dsmQ, eflag); } #endif @@ -6060,8 +6059,7 @@ static int cvStep(CVodeMem cv_mem) if (eflag != CV_SUCCESS) { SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed sens error test, dsmS = %.16g, eflag = %i", + "end-step-attempt", "status = failed sens error test, dsmS = %.16g, eflag = %i", dsmS, eflag); } #endif @@ -6136,8 +6134,8 @@ static int cvStep(CVodeMem cv_mem) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success, dsm = %.16g", dsm); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", + "status = success, dsm = %.16g", dsm); #endif /* Nonlinear system solve and error test were both successful. @@ -6627,8 +6625,8 @@ static void cvPredict(CVodeMem cv_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "forward", "zn_0(:) =", ""); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "forward", + "zn_0(:) =", ""); N_VPrintFile(cv_mem->cv_zn[0], CV_LOGGER->debug_fp); #endif @@ -6644,8 +6642,8 @@ static void cvPredict(CVodeMem cv_mem) } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "quad", "znQ_0(:) =", ""); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "quad", + "znQ_0(:) =", ""); N_VPrintFile(cv_mem->cv_znQ[0], CV_LOGGER->debug_fp); #endif } @@ -6662,8 +6660,8 @@ static void cvPredict(CVodeMem cv_mem) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG for (int i = 0; i < cv_mem->cv_Ns; i++) { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "sensi", "znS_%d(:) = ", i); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "sensi", + "znS_%d(:) = ", i); N_VPrintFile(cv_mem->cv_znS[0][i], CV_LOGGER->debug_fp); } #endif @@ -7566,9 +7564,9 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, dsm = acor_nrm * cv_mem->cv_tq[2]; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "error-test", "step = %li, h = %.16g, dsm = %.16g", - cv_mem->cv_nst, cv_mem->cv_h, dsm); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", + "step = %li, h = %.16g, dsm = %.16g", cv_mem->cv_nst, + cv_mem->cv_h, dsm); #endif /* If est. local error norm dsm passes test, return CV_SUCCESS */ @@ -7606,8 +7604,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cvRescale(cv_mem); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-eta", "eta = %.16g", cv_mem->cv_eta); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta", + "eta = %.16g", cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -7826,9 +7824,8 @@ static void cvCompleteStep(CVodeMem cv_mem) #endif #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "return", "nst = %d, nscon = %d", cv_mem->cv_nst, - cv_mem->cv_nscon); + SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", + "nst = %d, nscon = %d", cv_mem->cv_nst, cv_mem->cv_nscon); #endif } diff --git a/src/ida/ida.c b/src/ida/ida.c index b64b33bb5f..9af1538a84 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2561,8 +2561,7 @@ static int IDAStep(IDAMem IDA_mem) if (nflag == ERROR_TEST_FAIL) { SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed error test, dsm = %.16g, kflag = %i", + "end-step-attempt", "status = failed error test, dsm = %.16g, kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); } @@ -2774,7 +2773,7 @@ static int IDANls(IDAMem IDA_mem) IDA_mem->ida_nnf += nnf_inc; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); #endif @@ -2891,7 +2890,7 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, terr_k = (IDA_mem->ida_kk + 1) * (*err_k); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "estimate-error-order-k", "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); #endif @@ -2949,12 +2948,11 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-order", "kk = %i, knew = %i", IDA_mem->ida_kk, - IDA_mem->ida_knew); + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-order", + "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-estimate", + "ck_enorm_k = %" RSYM, ck * enorm_k); #endif /* Perform error test */ @@ -3272,8 +3270,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else { action = RAISE; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, - __func__, "order-selection-raise", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "order-selection-raise", "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); #endif diff --git a/src/idas/idas.c b/src/idas/idas.c index 5be3d440e3..ae67b19f4b 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -5973,8 +5973,7 @@ static int IDAStep(IDAMem IDA_mem) if (nflag == ERROR_TEST_FAIL) { SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed error test, dsm = %.16g, kflag = %i", + "end-step-attempt", "status = failed error test, dsm = %.16g, kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); } @@ -6020,8 +6019,7 @@ static int IDAStep(IDAMem IDA_mem) if (nflag == ERROR_TEST_FAIL) { SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad error test, dsmQ = %.16g, kflag = %i", + "end-step-attempt", "status = failed quad error test, dsmQ = %.16g, kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); } @@ -6091,8 +6089,7 @@ static int IDAStep(IDAMem IDA_mem) if (nflag == ERROR_TEST_FAIL) { SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed sens error test, dsmS = %.16g, kflag = %i", + "end-step-attempt", "status = failed sens error test, dsmS = %.16g, kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); } @@ -6139,8 +6136,7 @@ static int IDAStep(IDAMem IDA_mem) if (nflag == ERROR_TEST_FAIL) { SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad sens error test, dsmQS = %.16g, kflag = %i", + "end-step-attempt", "status = failed quad sens error test, dsmQS = %.16g, kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); } @@ -6148,7 +6144,8 @@ static int IDAStep(IDAMem IDA_mem) { SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", - "status = failed quad sens solve, kflag = %i", kflag); + "status = failed quad sens solve, kflag = %i", + kflag); } #endif @@ -6442,9 +6439,9 @@ static int IDANls(IDAMem IDA_mem) } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "nls-return", "flag = %i, iters = %li, fails = %li", - retval, nni_inc, nnf_inc); + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", + "flag = %i, iters = %li, fails = %li", retval, nni_inc, + nnf_inc); #endif /* return if nonlinear solver failed */ @@ -6819,12 +6816,11 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-order", "kk = %i, knew = %i", IDA_mem->ida_kk, - IDA_mem->ida_knew); + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-order", + "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-estimate", + "ck_enorm_k = %" RSYM, ck * enorm_k); #endif /* Perform error test */ @@ -7557,8 +7553,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else { action = RAISE; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, - __func__, "order-selection-raise", + SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "order-selection-raise", "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); #endif diff --git a/src/kinsol/kinsol.c b/src/kinsol/kinsol.c index b046bb04fd..8c2e08fc33 100644 --- a/src/kinsol/kinsol.c +++ b/src/kinsol/kinsol.c @@ -1736,8 +1736,7 @@ static int KINFullNewton(KINMem kin_mem, sunrealtype* fnormp, pnorm *= kin_mem->kin_stepmul; kin_mem->kin_stepl = pnorm; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_PNORM, "KINSOL", __func__, INFO_PNORM, - pnorm); + KINPrintInfo(kin_mem, PRNT_PNORM, "KINSOL", __func__, INFO_PNORM, pnorm); #endif if (pnorm <= kin_mem->kin_scsteptol) { @@ -1794,8 +1793,7 @@ static int KINFullNewton(KINMem kin_mem, sunrealtype* fnormp, kin_mem->kin_sJpnorm *= ratio; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_FNORM, "KINSOL", __func__, INFO_FNORM, - *fnormp); + KINPrintInfo(kin_mem, PRNT_FNORM, "KINSOL", __func__, INFO_FNORM, *fnormp); #endif if (pnorm > (POINT99 * kin_mem->kin_mxnewtstep)) { *maxStepTaken = SUNTRUE; } @@ -1904,8 +1902,7 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, rlmax = ONE; kin_mem->kin_stepl = pnorm; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_PNORM1, "KINSOL", __func__, INFO_PNORM1, - pnorm); + KINPrintInfo(kin_mem, PRNT_PNORM1, "KINSOL", __func__, INFO_PNORM1, pnorm); #endif if (pnorm <= kin_mem->kin_scsteptol) { @@ -1978,8 +1975,8 @@ static int KINLineSearch(KINMem kin_mem, sunrealtype* fnormp, alpha_cond = kin_mem->kin_f1norm + (alpha * slpi * rl); #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGLEVEL_INFO - KINPrintInfo(kin_mem, PRNT_ALPHA, "KINSOL", __func__, INFO_ALPHA, - *fnormp, *f1normp, alpha_cond, rl); + KINPrintInfo(kin_mem, PRNT_ALPHA, "KINSOL", __func__, INFO_ALPHA, *fnormp, + *f1normp, alpha_cond, rl); #endif /* If ALPHA condition is satisfied, break out from loop */ @@ -2841,8 +2838,8 @@ static int KINFP(KINMem kin_mem) tolfac = ONE; #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin", - "%s", "u_0(:) ="); + SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin", "%s", + "u_0(:) ="); N_VPrintFile(kin_mem->kin_uu, KIN_LOGGER->debug_fp); #endif @@ -2917,8 +2914,8 @@ static int KINFP(KINMem kin_mem) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "while-loop-after-compute-new", "u_%ld(:) =", - kin_mem->kin_nni); + "while-loop-after-compute-new", + "u_%ld(:) =", kin_mem->kin_nni); N_VPrintFile(kin_mem->kin_unew, KIN_LOGGER->debug_fp); #endif From 52f4e5c73ca6366eab381670f6f7dcae643ba9d9 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 14:39:02 -0700 Subject: [PATCH 018/235] guard against non-existant keys --- scripts/sundialsdev/logs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 176eaada30..dc6d5a04d4 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -168,6 +168,9 @@ def get_history(log, key, step_status = None, time_range = None, if step_status not in l["payload"]['status']: continue + if key not in l["payload"]: + continue + steps.append(step) times.append(time) values.append(convert_to_num(l["payload"][key])) From 9e49090f5a4a68fa7c16351d7089ce64ca393342 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 16:03:11 -0700 Subject: [PATCH 019/235] plot multiple files --- scripts/sundialsdev/log_example.py | 99 ++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 27 deletions(-) diff --git a/scripts/sundialsdev/log_example.py b/scripts/sundialsdev/log_example.py index 9327c29a10..ad2bcc4594 100755 --- a/scripts/sundialsdev/log_example.py +++ b/scripts/sundialsdev/log_example.py @@ -27,8 +27,8 @@ def main(): parser = argparse.ArgumentParser(description='Plots') - parser.add_argument('logfile', type=str, - help='Log file to plot') + parser.add_argument('logfiles', type=str, nargs='+', + help='Log files to plot') parser.add_argument('--val', type=str, default='h', choices=['h', 'q', 'dsm'], @@ -43,6 +43,12 @@ def main(): parser.add_argument('--time-range', type=float, nargs=2, default=None, help='Time range to plot') + parser.add_argument('--scatter', action='store_true', + help='Create scatter plot') + + parser.add_argument('--labels', type=str, nargs='+', + help='Plot labels') + parser.add_argument('--save', type=str, nargs='?', const='fig.pdf', default=None, help='''Save figure to file''') @@ -50,32 +56,71 @@ def main(): # parse command line args args = parser.parse_args() - # parse log file - log = sunlog.log_file_to_list(args.logfile) - - # plot log data - steps_s, times_s, vals_s = sunlog.get_history(log, args.val, 'success', - step_range=args.step_range, - time_range=args.time_range) - - steps_f, times_f, vals_f = sunlog.get_history(log, args.val, 'failed', - step_range=args.step_range, - time_range=args.time_range) - - if args.step_number: - x_s = steps_s - x_f = steps_f - else: - x_s = times_s - x_f = times_f - fig, ax = plt.subplots() - - ax.scatter(x_s, vals_s, color='green', marker='o', label='successful', - zorder=0.1) - - ax.scatter(x_f, vals_f, color='red', marker='x', label='failed', - zorder=0.2) + colors = plt.get_cmap("tab10") + + for idx, lf in enumerate(args.logfiles): + + # parse log file + log = sunlog.log_file_to_list(lf) + + # get successful step data + steps_s, times_s, vals_s = sunlog.get_history(log, args.val, 'success', + step_range=args.step_range, + time_range=args.time_range) + + # get data for error test failures + steps_etf, times_etf, vals_etf = sunlog.get_history(log, args.val, 'failed error test', + step_range=args.step_range, + time_range=args.time_range) + + # get data for solver failures + steps_sf, times_sf, vals_sf = sunlog.get_history(log, args.val, 'failed solve', + step_range=args.step_range, + time_range=args.time_range) + + # plot log data + if args.step_number: + x_s = steps_s + x_etf = steps_etf + x_sf = steps_sf + else: + x_s = times_s + x_etf = times_etf + x_sf = times_sf + + if len(args.logfiles) == 1: + s_color = 'green' + etf_color = 'red' + sf_color = 'darkorange' + else: + s_color = colors(idx) + etf_color = s_color + sf_color = s_color + + if args.labels: + s_label = f'{args.labels[idx]} successful' + etf_label = f'{args.labels[idx]} error test failed' + sf_label = f'{args.labels[idx]} solver failed' + else: + s_label = 'successful' + etf_label = 'error test failed' + sf_label = 'solver failed' + + # plot successful data + if args.scatter: + ax.scatter(x_s, vals_s, color=s_color, marker='o', label=s_label, + zorder=0.1) + else: + ax.plot(x_s, vals_s, color=s_color, marker='.', label=s_label, + zorder=0.1) + + # always add failures as scatter plot + ax.scatter(x_etf, vals_etf, color=etf_color, marker='x', label=etf_label, + zorder=0.2) + + ax.scatter(x_sf, vals_sf, color=sf_color, marker='d', label=sf_label, + zorder=0.2) if args.step_number: ax.set_xlabel("step") From 847e562b84ed08cc4f89e14959c7fbf7ef23c023 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 16:21:08 -0700 Subject: [PATCH 020/235] update help docs in examples --- scripts/sundialsdev/log_example.py | 17 ++++++++--------- scripts/sundialsdev/log_example_mri.py | 16 +++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/scripts/sundialsdev/log_example.py b/scripts/sundialsdev/log_example.py index ad2bcc4594..b2e3670ca0 100755 --- a/scripts/sundialsdev/log_example.py +++ b/scripts/sundialsdev/log_example.py @@ -19,7 +19,6 @@ def main(): import argparse - import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as tik @@ -32,16 +31,18 @@ def main(): parser.add_argument('--val', type=str, default='h', choices=['h', 'q', 'dsm'], - help='Value to plot') + help='Value to plot (default: %(default)s)') parser.add_argument('--step-number', action='store_true', help='Plot value vs step number') parser.add_argument('--step-range', type=int, nargs=2, - default=None, help='Step range to plot') + default=None, metavar=('LOWER_BOUND', 'UPPER_BOUND'), + help='Step range to plot') parser.add_argument('--time-range', type=float, nargs=2, - default=None, help='Time range to plot') + default=None, metavar=('LOWER_BOUND', 'UPPER_BOUND'), + help='Time range to plot') parser.add_argument('--scatter', action='store_true', help='Create scatter plot') @@ -49,8 +50,8 @@ def main(): parser.add_argument('--labels', type=str, nargs='+', help='Plot labels') - parser.add_argument('--save', type=str, nargs='?', - const='fig.pdf', default=None, + parser.add_argument('--save', type=str, nargs='?', const='fig.pdf', + default=None, metavar='FILE_NAME', help='''Save figure to file''') # parse command line args @@ -144,10 +145,8 @@ def main(): else: plt.show() -# ----------------------------------------------------------------------------- -# run the main routine -# ----------------------------------------------------------------------------- +# run the main routine if __name__ == '__main__': import sys sys.exit(main()) diff --git a/scripts/sundialsdev/log_example_mri.py b/scripts/sundialsdev/log_example_mri.py index 6e50fef6f8..cfd624178a 100755 --- a/scripts/sundialsdev/log_example_mri.py +++ b/scripts/sundialsdev/log_example_mri.py @@ -19,9 +19,7 @@ def main(): import argparse - import numpy as np import matplotlib.pyplot as plt - import matplotlib.ticker as tik import logs as sunlog @@ -34,13 +32,15 @@ def main(): help='Plot value vs step number') parser.add_argument('--step-range', type=int, nargs=2, - default=None, help='Step range to plot') + default=None, metavar=('LOWER_BOUND', 'UPPER_BOUND'), + help='Step range to plot') parser.add_argument('--time-range', type=float, nargs=2, - default=None, help='Time range to plot') + default=None, metavar=('LOWER_BOUND', 'UPPER_BOUND'), + help='Time range to plot') - parser.add_argument('--save', type=str, nargs='?', - const='fig.pdf', default=None, + parser.add_argument('--save', type=str, nargs='?', const='fig.pdf', + default=None, metavar='FILE_NAME', help='''Save figure to file''') # parse command line args @@ -76,10 +76,8 @@ def main(): else: plt.show() -# ----------------------------------------------------------------------------- -# run the main routine -# ----------------------------------------------------------------------------- +# run the main routine if __name__ == '__main__': import sys sys.exit(main()) From 863b51f03b060d4a840eb1b018e053637ff0d06d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 16:37:28 -0700 Subject: [PATCH 021/235] remove end-step log entry --- src/arkode/arkode.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 2c180899d6..8d0d2be7cb 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -2579,12 +2579,6 @@ int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm) } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-step", - "step = %li, h = %" RSYM ", tcur = %" RSYM, ark_mem->nst, - ark_mem->h, ark_mem->tcur); -#endif - /* apply user-supplied step postprocessing function (if supplied) */ if (ark_mem->ProcessStep != NULL) { From 23d1b82667eee9e33f162dfaa1b731398574d38c Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 17:02:53 -0700 Subject: [PATCH 022/235] update arkstep stage logging --- src/arkode/arkode_arkstep.c | 120 ++++++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 18 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 00ce35069d..338dda74c0 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1829,11 +1829,9 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG if (is_start == 1) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", - "step = %li, stage = %i, implicit = %i, h = %" RSYM - ", tcur = %" RSYM, - ark_mem->nst, 0, implicit_stage, ark_mem->h, - ark_mem->tcur); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", + "stage = %i, implicit = %i, tcur = %" RSYM, 0, + implicit_stage, ark_mem->tcur); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "explicit stage", "z_%i(:) =", 0); @@ -1851,6 +1849,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) N_VPrintFile(step_mem->Fe[0], ARK_LOGGER->debug_fp); } #endif + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", ""); } #endif @@ -1878,11 +1877,9 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) else { ark_mem->tcur = ark_mem->tn + step_mem->Be->c[is] * ark_mem->h; } #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", - "step = %li, stage = %i, implicit = %i, h = %" RSYM - ", tcur = %" RSYM, - ark_mem->nst, is, implicit_stage, ark_mem->h, - ark_mem->tcur); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", + "stage = %i, implicit = %i, tcur = %" RSYM, is, + implicit_stage, ark_mem->tcur); #endif /* setup time-dependent mass matrix */ @@ -1890,7 +1887,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { retval = step_mem->msetup((void*)ark_mem, ark_mem->tcur, ark_mem->tempv1, ark_mem->tempv2, ark_mem->tempv3); - if (retval != ARK_SUCCESS) { return (ARK_MASSSETUP_FAIL); } + if (retval != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed mass setup, retval = %i", retval); +#endif + return (ARK_MASSSETUP_FAIL); + } } /* if implicit, call built-in and user-supplied predictors @@ -1907,6 +1911,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { retval = step_mem->stage_predict(ark_mem->tcur, step_mem->zpred, ark_mem->user_data); + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "end-stage", + "status = failed predict, retval = %i", retval); + } +#endif + if (retval < 0) { return (ARK_USER_PREDICT_FAIL); } if (retval > 0) { return (TRY_AGAIN); } } @@ -1920,7 +1934,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* set up explicit data for evaluation of ARK stage (store in sdata) */ retval = arkStep_StageSetup(ark_mem, implicit_stage); - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed stage setup, retval = %i", retval); +#endif + return (retval); + } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "rhs data", @@ -1934,7 +1955,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* implicit solve result is stored in ark_mem->ycur; return with positive value on anything but success */ *nflagPtr = arkStep_Nls(ark_mem, *nflagPtr); - if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } + if (*nflagPtr != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed solve, nflag = %i", *nflagPtr); +#endif + return (TRY_AGAIN); + } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, @@ -1952,7 +1980,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* perform solve; return with positive value on anything but success */ *nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->sdata, step_mem->nlscoef); - if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } + if (*nflagPtr != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); +#endif + return (TRY_AGAIN); + } } /* set y to be yn + sdata (either computed in arkStep_StageSetup, @@ -1973,7 +2008,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, ark_mem->user_data); - if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } + if (retval != 0) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); +#endif + return (ARK_POSTPROCESS_STAGE_FAIL); + } } /* successful stage solve */ @@ -1989,11 +2031,26 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fi(ark_mem->tcur, ark_mem->ycur, step_mem->Fi[is], ark_mem->user_data); step_mem->nfi++; +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed implicit rhs eval, retval = %i", retval); + } +#endif } else if (step_mem->mass_type == MASS_FIXED) { retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1); - if (retval != ARK_SUCCESS) { return (ARK_MASSMULT_FAIL); } + if (retval != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed mass mult, retval = %i", retval); +#endif + return (ARK_MASSMULT_FAIL); + } + N_VLinearSum(ONE / step_mem->gamma, ark_mem->tempv1, -ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]); } @@ -2020,6 +2077,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->ycur, step_mem->Fe[is], ark_mem->user_data); step_mem->nfe++; +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", retval); + } +#endif + #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "explicit RHS", "Fe_%i(:) =", is); @@ -2043,7 +2108,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "M^{-1} implicit RHS", "Fi_%i(:) =", is); N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); #endif - if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } + if (*nflagPtr != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); +#endif + return (TRY_AGAIN); + } } if (step_mem->explicit) { @@ -2054,10 +2126,22 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "M^{-1} explicit RHS", "Fe_%i(:) =", is); N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); #endif - if (*nflagPtr != ARK_SUCCESS) { return (TRY_AGAIN); } + if (*nflagPtr != ARK_SUCCESS) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); +#endif + return (TRY_AGAIN); + } } } +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = success", ""); +#endif + } /* loop over stages */ /* compute time-evolved solution (in ark_ycur), error estimate (in dsm). From dcd1b358588abc4a556d66e4f40c0692e45f618d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 17:09:21 -0700 Subject: [PATCH 023/235] formatting --- src/arkode/arkode_arkstep.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 338dda74c0..a3ea80023d 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1983,7 +1983,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr != ARK_SUCCESS) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "end-stage", "status = failed mass solve, nflag = %i", *nflagPtr); #endif return (TRY_AGAIN); @@ -2012,7 +2013,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed postprocess stage, retval = %i", retval); + "status = failed postprocess stage, retval = %i", + retval); #endif return (ARK_POSTPROCESS_STAGE_FAIL); } @@ -2034,8 +2036,10 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG if (retval != 0) { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed implicit rhs eval, retval = %i", retval); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "end-stage", + "status = failed implicit rhs eval, retval = %i", + retval); } #endif } @@ -2045,7 +2049,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval != ARK_SUCCESS) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "end-stage", "status = failed mass mult, retval = %i", retval); #endif return (ARK_MASSMULT_FAIL); @@ -2078,11 +2083,12 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nfe++; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed explicit rhs eval, retval = %i", retval); - } + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", + retval); + } #endif #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG @@ -2111,7 +2117,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr != ARK_SUCCESS) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "end-stage", "status = failed mass solve, nflag = %i", *nflagPtr); #endif return (TRY_AGAIN); @@ -2129,7 +2136,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr != ARK_SUCCESS) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, + "end-stage", "status = failed mass solve, nflag = %i", *nflagPtr); #endif return (TRY_AGAIN); From a8a68dc5cf1de0c668de8f67db649dc9c4ae9e6e Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 8 Jun 2024 17:27:24 -0700 Subject: [PATCH 024/235] update erkstep stage logging --- src/arkode/arkode_erkstep.c | 55 ++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 83105f14f3..6cdad9b278 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -627,11 +627,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) Xvecs = step_mem->Xvecs; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", - "step = %li, stage = 0, h = %" RSYM ", tcur = %" RSYM, - ark_mem->nst, ark_mem->h, ark_mem->tcur); -#endif - + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", + "stage = 0, tcur = %" RSYM, ark_mem->tcur); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage", "z_0(:) =", ""); @@ -640,6 +637,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "F_0(:) =", ""); N_VPrintFile(step_mem->F[0], ARK_LOGGER->debug_fp); #endif + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", ""); +#endif /* Call the full RHS if needed. If this is the first step then we may need to evaluate or copy the RHS values from an earlier evaluation (e.g., to @@ -664,9 +663,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tcur = ark_mem->tn + step_mem->B->c[is] * ark_mem->h; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", - "step = %li, stage = %i, h = %" RSYM ", tcur = %" RSYM, - ark_mem->nst, is, ark_mem->h, ark_mem->tcur); + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", + "stage = %i, tcur = %" RSYM, is, ark_mem->tcur); #endif /* Set ycur to current stage solution */ @@ -683,20 +681,44 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* call fused vector operation to do the work */ retval = N_VLinearCombination(nvec, cvals, Xvecs, ark_mem->ycur); - if (retval != 0) { return (ARK_VECTOROP_ERR); } + if (retval != 0) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed vector op, retval = %i", retval); +#endif + return (ARK_VECTOROP_ERR); + } /* apply user-supplied stage postprocessing function (if supplied) */ if (ark_mem->ProcessStage != NULL) { retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, ark_mem->user_data); - if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } + if (retval != 0) + { +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", + retval); +#endif + return (ARK_POSTPROCESS_STAGE_FAIL); + } } /* compute updated RHS */ retval = step_mem->f(ark_mem->tcur, ark_mem->ycur, step_mem->F[is], ark_mem->user_data); step_mem->nfe++; + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = failed rhs eval, retval = %i", retval); + } +#endif + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -706,6 +728,13 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) N_VPrintFile(step_mem->F[is], ARK_LOGGER->debug_fp); #endif +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG + if (retval != 0) + { + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", + "status = success", ""); + } +#endif } /* loop over stages */ /* compute time-evolved solution (in ark_ycur), error estimate (in dsm) */ @@ -718,12 +747,6 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); #endif -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", - "step = %li, h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, - ark_mem->h, *dsmPtr); -#endif - return (ARK_SUCCESS); } From 9940dc26a0352c6a6187b96066f02b2908331708 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 13 Jun 2024 22:20:39 -0700 Subject: [PATCH 025/235] add logging macros --- src/sundials/sundials_logger_impl.h | 109 ++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/src/sundials/sundials_logger_impl.h b/src/sundials/sundials_logger_impl.h index b6f93eeeae..3bd60d3283 100644 --- a/src/sundials/sundials_logger_impl.h +++ b/src/sundials/sundials_logger_impl.h @@ -32,6 +32,115 @@ #define SUNDIALS_LOGGING_EXTRA_DEBUG #endif +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_ERROR +#define SUNLogError(logger, scope, label, msg_txt, ...) \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_ERROR, scope, label, msg_txt, \ + __VA_ARGS__) +#define SUNLogErrorIf(condition, logger, scope, label, msg_txt, ...) \ + do { \ + if ((condition)) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_ERROR, scope, label, msg_txt, \ + __VA_ARGS__); \ + } \ + } \ + while (0) +#else +#define SUNLogError(logger, scope, label, msg_txt, ...) +#define SUNLogErrorIf(condition, logger, scope, label, msg_txt, ...) +#endif + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_WARNING +#define SUNLogWarning(logger, scope, label, msg_txt, ...) \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_WARNING, scope, label, msg_txt, \ + __VA_ARGS__) +#define SUNLogWarningIf(condition, logger, scope, label, msg_txt, ...) \ + do { \ + if ((condition)) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_WARNING, scope, label, msg_txt, \ + __VA_ARGS__); \ + } \ + } \ + while (0) +#else +#define SUNLogWarning(logger, scope, label, msg_txt, ...) +#define SUNLogWarningIf(condition, logger, scope, label, msg_txt, ...) +#endif + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO +#define SUNLogInfo(logger, scope, label, msg_txt, ...) \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_INFO, scope, label, msg_txt, \ + __VA_ARGS__) +#define SUNLogInfoIf(condition, logger, scope, label, msg_txt, ...) \ + do { \ + if ((condition)) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_INFO, scope, label, msg_txt, \ + __VA_ARGS__); \ + } \ + } \ + while (0) +#else +#define SUNLogInfo(logger, scope, label, msg_txt, ...) +#define SUNLogInfoIf(condition, logger, scope, label, msg_txt, ...) +#endif + +#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG +#define SUNLogDebug(logger, scope, label, msg_txt, ...) \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, \ + __VA_ARGS__) +#define SUNLogDebugIf(condition, logger, scope, label, msg_txt, ...) \ + do { \ + if ((condition)) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, \ + __VA_ARGS__); \ + } \ + } \ + while (0) +#else +#define SUNLogDebug(logger, scope, label, msg_txt, ...) +#define SUNLogDebugIf(condition, logger, scope, label, msg_txt, ...) +#endif + +#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG +#define SUNLogExtraDebug(logger, scope, label, msg_txt, ...) \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, \ + __VA_ARGS__) +#define SUNLogExtraDebugIf(condition, logger, scope, label, msg_txt, ...) \ + do { \ + if ((condition)) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, \ + __VA_ARGS__); \ + } \ + } \ + while (0) +#define SUNLogExtraDebugVec(logger, scope, label, msg_txt, vec, ...) \ + do { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, \ + __VA_ARGS__); \ + N_VPrintFile(vec, logger->debug_fp); \ + } \ + while (0) +#define SUNLogExtraDebugVecIf(condition, logger, scope, label, msg_txt, vec, ...) \ + do { \ + if ((condition)) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, \ + __VA_ARGS__); \ + N_VPrintFile(vec, logger->debug_fp); \ + } \ + } \ + while (0) +#else +#define SUNLogExtraDebug(logger, scope, label, msg_txt, ...) +#define SUNLogExtraDebugIf(condition, logger, scope, label, msg_txt, ...) +#define SUNLogExtraDebugVec(logger, scope, label, msg_txt, vec, ...) +#define SUNLogExtraDebugVecIf(condition, logger, scope, label, msg_txt, vec, ...) +#endif + struct SUNLogger_ { /* MPI information */ From 525c511684693fa07d2cff03bb61e5466aa3142e Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 13 Jun 2024 22:56:58 -0700 Subject: [PATCH 026/235] update some ARKODE logging --- src/arkode/arkode_adapt.c | 20 +--- src/arkode/arkode_arkstep.c | 200 +++++++++----------------------- src/arkode/arkode_interp.c | 12 +- src/arkode/arkode_mristep_nls.c | 7 +- 4 files changed, 68 insertions(+), 171 deletions(-) diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 2780a1cbb4..8f0e79e6d2 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -133,11 +133,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, } if (h_cfl <= ZERO) { h_cfl = SUN_RCONST(1.0e30) * SUNRabs(hcur); } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-before-bounds", - "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "new-step-before-bounds", + "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); /* enforce safety factors */ h_acc *= hadapt_mem->safety; @@ -149,11 +146,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, /* enforce minimum bound time step reduction */ h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(hadapt_mem->etamin * hcur)); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-after-max-min-bounds", - "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "new-step-after-max-min-bounds", + "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); /* increment the relevant step counter, set desired step */ if (SUNRabs(h_acc) < SUNRabs(h_cfl)) { hadapt_mem->nst_acc++; } @@ -179,10 +173,8 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, /* enforce maximum time step size */ ark_mem->eta /= SUNMAX(ONE, SUNRabs(hcur) * ark_mem->hmax_inv * ark_mem->eta); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ARKODE::arkAdapt", - "new-step-eta", "eta = %" RSYM, ark_mem->eta); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "new-step-eta", + "eta = %" RSYM, ark_mem->eta); return (retval); } diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index a3ea80023d..ad7a7b31f6 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1826,32 +1826,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (is_start == 1) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", - "stage = %i, implicit = %i, tcur = %" RSYM, 0, - implicit_stage, ark_mem->tcur); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "explicit stage", "z_%i(:) =", 0); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); - if (step_mem->implicit) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "implicit RHS", "Fi_%i(:) =", 0); - N_VPrintFile(step_mem->Fi[0], ARK_LOGGER->debug_fp); - } - if (step_mem->explicit) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "explicit RHS", "Fe_%i(:) =", 0); - N_VPrintFile(step_mem->Fe[0], ARK_LOGGER->debug_fp); - } -#endif - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", ""); - } -#endif + SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "begin-stage", + "stage = %i, implicit = %i, tcur = %" RSYM, 0, implicit_stage, + ark_mem->tcur); + SUNLogExtraDebugVecIf(is_start == 1, ARK_LOGGER, __func__, "explicit stage", + "z_%i(:) =", ark_mem->ycur, 0); + SUNLogExtraDebugVecIf(is_start == 1 && step_mem->implicit, ARK_LOGGER, __func__, + "implicit RHS", "Fi_%i(:) =", step_mem->Fi[0], 0); + SUNLogExtraDebugVecIf(is_start == 1 && step_mem->explicit, ARK_LOGGER, __func__, + "explicit RHS", "Fe_%i(:) =", step_mem->Fe[0], 0); + SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "end-stage", "", ""); /* loop over internal stages to the step */ for (is = is_start; is < step_mem->stages; is++) @@ -1876,11 +1860,9 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } else { ark_mem->tcur = ark_mem->tn + step_mem->Be->c[is] * ark_mem->h; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", - "stage = %i, implicit = %i, tcur = %" RSYM, is, - implicit_stage, ark_mem->tcur); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", + "stage = %i, implicit = %i, tcur = %" RSYM, is, implicit_stage, + ark_mem->tcur); /* setup time-dependent mass matrix */ if ((step_mem->mass_type == MASS_TIMEDEP) && (step_mem->msetup != NULL)) @@ -1889,10 +1871,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tempv2, ark_mem->tempv3); if (retval != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed mass setup, retval = %i", retval); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed mass setup, retval = %i", retval); return (ARK_MASSSETUP_FAIL); } } @@ -1912,42 +1892,27 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->stage_predict(ark_mem->tcur, step_mem->zpred, ark_mem->user_data); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "end-stage", - "status = failed predict, retval = %i", retval); - } -#endif - + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed predict, retval = %i", retval); if (retval < 0) { return (ARK_USER_PREDICT_FAIL); } if (retval > 0) { return (TRY_AGAIN); } } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "predictor", - "zpred(:) =", ""); - N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "predictor", + "zpred(:) =", step_mem->zpred, ""); /* set up explicit data for evaluation of ARK stage (store in sdata) */ retval = arkStep_StageSetup(ark_mem, implicit_stage); if (retval != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed stage setup, retval = %i", retval); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed stage setup, retval = %i", retval); return (retval); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "rhs data", - "sdata(:) =", ""); - N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "rhs data", + "sdata(:) =", step_mem->sdata, ""); /* perform implicit solve if required */ if (implicit_stage) @@ -1957,18 +1922,13 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) *nflagPtr = arkStep_Nls(ark_mem, *nflagPtr); if (*nflagPtr != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed solve, nflag = %i", *nflagPtr); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "implicit stage", "z_%i(:) =", is); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit stage", + "z_%i(:) =", ark_mem->ycur, is); /* otherwise no implicit solve is needed */ } @@ -1982,11 +1942,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nlscoef); if (*nflagPtr != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "end-stage", - "status = failed mass solve, nflag = %i", *nflagPtr); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } } @@ -1995,11 +1952,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) or updated in prev. block) */ N_VLinearSum(ONE, ark_mem->yn, ONE, step_mem->sdata, ark_mem->ycur); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "explicit stage", "z_%i(:) =", is); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "explicit stage", + "z_%i(:) =", ark_mem->ycur, is); } /* apply user-supplied stage postprocessing function (if supplied) */ @@ -2011,11 +1965,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); if (retval != 0) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed postprocess stage, retval = %i", - retval); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -2033,26 +1984,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fi(ark_mem->tcur, ark_mem->ycur, step_mem->Fi[is], ark_mem->user_data); step_mem->nfi++; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "end-stage", - "status = failed implicit rhs eval, retval = %i", - retval); - } -#endif + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed implicit rhs eval, retval = %i", retval); } else if (step_mem->mass_type == MASS_FIXED) { retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1); if (retval != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "end-stage", - "status = failed mass mult, retval = %i", retval); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed mass mult, retval = %i", retval); return (ARK_MASSMULT_FAIL); } @@ -2065,11 +2006,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) -ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "implicit RHS", "Fi_%i(:) =", is); - N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit RHS", + "Fi_%i(:) =", step_mem->Fi[is], is); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -2081,21 +2019,11 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fe(ark_mem->tn + step_mem->Be->c[is] * ark_mem->h, ark_mem->ycur, step_mem->Fe[is], ark_mem->user_data); step_mem->nfe++; + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", retval); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed explicit rhs eval, retval = %i", - retval); - } -#endif - -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "explicit RHS", "Fe_%i(:) =", is); - N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebug(ARK_LOGGER, __func__, "explicit RHS", + "Fe_%i(:) =", step_mem->Fe[is], is); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -2109,18 +2037,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { *nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fi[is], step_mem->nlscoef); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "M^{-1} implicit RHS", "Fi_%i(:) =", is); - N_VPrintFile(step_mem->Fi[is], ARK_LOGGER->debug_fp); -#endif + + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "M^{-1} implicit RHS", + "Fi_%i(:) =", step_mem->Fi[is], is); + if (*nflagPtr != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "end-stage", - "status = failed mass solve, nflag = %i", *nflagPtr); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } } @@ -2128,27 +2052,18 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { *nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fe[is], step_mem->nlscoef); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "M^{-1} explicit RHS", "Fe_%i(:) =", is); - N_VPrintFile(step_mem->Fe[is], ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, + "M^{-1} explicit RHS", "Fe_%i(:) =", step_mem->Fe[is], is); if (*nflagPtr != ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "end-stage", - "status = failed mass solve, nflag = %i", *nflagPtr); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = success", ""); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); } /* loop over stages */ @@ -2163,11 +2078,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr < 0) { return (*nflagPtr); } if (*nflagPtr > 0) { return (TRY_AGAIN); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "updated solution", "ycur(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "updated solution", + "ycur(:) =", ark_mem->ycur, ""); return (ARK_SUCCESS); } diff --git a/src/arkode/arkode_interp.c b/src/arkode/arkode_interp.c index 21ad9fa620..70c5a67837 100644 --- a/src/arkode/arkode_interp.c +++ b/src/arkode/arkode_interp.c @@ -460,10 +460,8 @@ int arkInterpEvaluate_Hermite(ARKodeMem ark_mem, ARKInterp interp, q = SUNMAX(order, 0); /* respect lower bound */ q = SUNMIN(q, HINT_DEGREE(interp)); /* respect max possible */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "interp-eval", - "tau = %" RSYM ", d = %i, q = %i", tau, d, q); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "interp-eval", + "tau = %" RSYM ", d = %i, q = %i", tau, d, q); /* call full RHS if needed -- called just AFTER the end of a step, so yn has been updated to ycur */ @@ -1202,10 +1200,8 @@ int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tau, q = SUNMAX(degree, 0); /* respect lower bound */ q = SUNMIN(q, nhist - 1); /* respect max possible */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "interp-eval", - "tau = %" RSYM ", d = %i, q = %i", tau, deriv, q); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "interp-eval", + "tau = %" RSYM ", d = %i, q = %i", tau, deriv, q); /* error on illegal deriv */ if ((deriv < 0) || (deriv > 3)) diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index 882eedad75..d9b55a11b1 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -326,11 +326,8 @@ int mriStep_Nls(ARKodeMem ark_mem, int nflag) ark_mem->ewt, step_mem->nlscoef, callLSetup, ark_mem); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_Nls", - "correction", "zcor(:) =", ""); - N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebug(ARK_LOGGER, "ARKODE::mriStep_Nls", + "correction", "zcor(:) =", step_mem->zcor, ""); /* increment counters */ (void)SUNNonlinSolGetNumIters(step_mem->NLS, &nls_iters_inc); From d62b72ff8849dc054b0373a60066cddc96da79ac Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 09:21:01 -0700 Subject: [PATCH 027/235] more ARKODE logging updates --- src/arkode/arkode_erkstep.c | 72 ++++++++++++------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 6cdad9b278..41171830b3 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -626,19 +626,13 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) cvals = step_mem->cvals; Xvecs = step_mem->Xvecs; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", - "stage = 0, tcur = %" RSYM, ark_mem->tcur); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage", - "z_0(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage RHS", - "F_0(:) =", ""); - N_VPrintFile(step_mem->F[0], ARK_LOGGER->debug_fp); -#endif - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", ""); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, + ark_mem->tcur); + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage", + "z_0(:) =", ark_mem->ycur, ""); + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", + "F_0(:) =", step_mem->F[0], ""); + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "", ""); /* Call the full RHS if needed. If this is the first step then we may need to evaluate or copy the RHS values from an earlier evaluation (e.g., to @@ -662,10 +656,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage time(s) */ ark_mem->tcur = ark_mem->tn + step_mem->B->c[is] * ark_mem->h; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin-stage", - "stage = %i, tcur = %" RSYM, is, ark_mem->tcur); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", + "stage = %i, tcur = %" RSYM, is, ark_mem->tcur); /* Set ycur to current stage solution */ nvec = 0; @@ -683,10 +675,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = N_VLinearCombination(nvec, cvals, Xvecs, ark_mem->ycur); if (retval != 0) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed vector op, retval = %i", retval); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed vector op, retval = %i", retval); return (ARK_VECTOROP_ERR); } @@ -697,11 +687,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); if (retval != 0) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed postprocess stage, retval = %i", - retval); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -711,41 +698,26 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); step_mem->nfe++; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = failed rhs eval, retval = %i", retval); - } -#endif + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "stage RHS", - "F_%i(:) =", is); - N_VPrintFile(step_mem->F[is], ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", + "F_%i(:) =", step_mem->F[is], is); + + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = success", ""); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "end-stage", - "status = success", ""); - } -#endif } /* loop over stages */ /* compute time-evolved solution (in ark_ycur), error estimate (in dsm) */ retval = erkStep_ComputeSolutions(ark_mem, dsmPtr); if (retval < 0) { return (retval); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "updated solution", "ycur(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "updated solution", + "ycur(:) =", ark_mem->ycur, ""); return (ARK_SUCCESS); } From 5fe43c2a2125615e8d324d86cc470825c2bdc85d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 09:43:14 -0700 Subject: [PATCH 028/235] log vector array macro --- src/sundials/sundials_logger_impl.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sundials/sundials_logger_impl.h b/src/sundials/sundials_logger_impl.h index 3bd60d3283..27a0fe2c0e 100644 --- a/src/sundials/sundials_logger_impl.h +++ b/src/sundials/sundials_logger_impl.h @@ -134,11 +134,21 @@ } \ } \ while (0) +#define SUNLogExtraDebugVecArray(logger, scope, label, msg_txt, vecs, nvecs) \ + do { \ + for (int vi = 0; vi < (nvecs); ++vi) \ + { \ + SUNLogger_QueueMsg(logger, SUN_LOGLEVEL_DEBUG, scope, label, msg_txt, vi); \ + N_VPrintFile(vecs[vi], logger->debug_fp); \ + } \ + } \ + while (0) #else #define SUNLogExtraDebug(logger, scope, label, msg_txt, ...) #define SUNLogExtraDebugIf(condition, logger, scope, label, msg_txt, ...) #define SUNLogExtraDebugVec(logger, scope, label, msg_txt, vec, ...) #define SUNLogExtraDebugVecIf(condition, logger, scope, label, msg_txt, vec, ...) +#define SUNLogExtraDebugVecArray(logger, scope, label, msg_txt, vecs, nvecs) #endif struct SUNLogger_ From f602a12455e636f576cdc7fb0dd587a31392b0d7 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 09:47:19 -0700 Subject: [PATCH 029/235] more ARKODE logging updates --- src/arkode/arkode.c | 80 ++++++-------------- src/arkode/arkode_arkstep_nls.c | 7 +- src/arkode/arkode_mristep.c | 129 +++++++++----------------------- src/arkode/arkode_relaxation.c | 37 ++++----- 4 files changed, 75 insertions(+), 178 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 8d0d2be7cb..d9044ad6df 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -874,12 +874,9 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, attempts++; ark_mem->nst_attempts++; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "begin-step-attempt", - "step = %li, t_n = %.16g, h = %.16g", ark_mem->nst + 1, - ark_mem->tn, ark_mem->h); -#endif + SUNLogInfo(ARK_LOGGER, __func__, "begin-step-attempt", + "step = %li, t_n = %" RSYM ", h = %" RSYM, ark_mem->nst + 1, + ark_mem->tn, ark_mem->h); /* Call time stepper module to attempt a step: 0 => step completed successfully @@ -888,26 +885,17 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, kflag = ark_mem->step((void*)ark_mem, &dsm, &nflag); if (kflag < 0) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - /* Only log fatal error here other returns handled below */ - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed step, kflag = %i", kflag); -#endif + /* Log fatal errors here, other returns handled below */ + SUNLogInfo(ARK_LOGGER, __func__, "end-step-attempt", + "status = failed step, kflag = %i", kflag); break; } /* handle solver convergence failures */ kflag = arkCheckConvergence(ark_mem, &nflag, &ncf); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag != ARK_SUCCESS) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag != ARK_SUCCESS, ARK_LOGGER, __func__, "end-step-attempt", + "status = failed solve, kflag = %i", kflag); if (kflag < 0) { break; } @@ -920,14 +908,9 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { kflag = arkRelax(ark_mem, &relax_fails, &dsm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag != ARK_SUCCESS) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed relaxtion, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag != ARK_SUCCESS, ARK_LOGGER, __func__, + "end-step-attempt", + "status = failed relaxtion, kflag = %i", kflag); if (kflag < 0) { break; } } @@ -937,14 +920,9 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { kflag = arkCheckConstraints(ark_mem, &constrfails, &nflag); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag != ARK_SUCCESS) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed constraints, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag != ARK_SUCCESS, ARK_LOGGER, __func__, + "end-step-attempt", + "status = failed constraints, kflag = %i", kflag); if (kflag < 0) { break; } } @@ -954,10 +932,8 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, if (ark_mem->fixedstep) { ark_mem->eta = ONE; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success"); -#endif + SUNLogInfo(ARK_LOGGER, __func__, "end-step-attempt", "status = success", + ""); break; } @@ -966,14 +942,10 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { kflag = arkCheckTemporalError(ark_mem, &nflag, &nef, dsm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag != ARK_SUCCESS) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed error test, dsm = %.16g, kflag = %i", - dsm, kflag); - } -#endif + SUNLogInfoIf(kflag != ARK_SUCCESS, ARK_LOGGER, __func__, + "end-step-attempt", + "status = failed error test, dsm = %" RSYM ", kflag = %i", + dsm, kflag); if (kflag < 0) { break; } } @@ -983,21 +955,15 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { ark_mem->last_kflag = kflag; kflag = ARK_SUCCESS; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success"); -#endif + SUNLogInfo(ARK_LOGGER, __func__, "end-step-attempt", "status = success", ""); break; } /* break attempt loop on successful step */ if (kflag == ARK_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success, dsm = %.16g", - dsm); -#endif + SUNLogInfo(ARK_LOGGER, __func__, "end-step-attempt", + "status = success, dsm = %" RSYM, dsm); break; } diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 19d3f9576c..fb229d8931 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -423,11 +423,8 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) ark_mem->ewt, step_mem->nlscoef, callLSetup, ark_mem); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "correction", - "zcor(:) =", ""); - N_VPrintFile(step_mem->zcor, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "correction", + "zcor(:) =", step_mem->zcor, ""); /* increment counters */ (void)SUNNonlinSolGetNumIters(step_mem->NLS, &nls_iters_inc); diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 2cdc3a4fd4..662f014cd7 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1490,24 +1490,12 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->fn_is_current = SUNTRUE; } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "slow stage", - "z_0(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); - - if (step_mem->explicit_rhs) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "slow explicit RHS", "Fse_0(:) =", ""); - N_VPrintFile(step_mem->Fse[0], ARK_LOGGER->debug_fp); - } - if (step_mem->implicit_rhs) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "slow implicit RHS", "Fsi_0(:) =", ""); - N_VPrintFile(step_mem->Fsi[0], ARK_LOGGER->debug_fp); - } -#endif + SUNLogExtraDebug(ARK_LOGGER, __func__, "slow stage", + "z_0(:) =", ark_mem->ycur, ""); + SUNLogExtraDebugVecIf(step_mem->explicit_rhs, ARK_LOGGER, __func__, + "slow explicit RHS", "Fse_0(:) =", step_mem->Fse[0], ""); + SUNLogExtraDebugVecIf(step_mem->implicit_rhs, ARK_LOGGER, __func__, + "slow implicit RHS", "Fsi_0(:) =", step_mem->Fsi[0], ""); /* The first stage is the previous time-step solution, so its RHS is the [already-computed] slow RHS from the start of the step */ @@ -1518,14 +1506,11 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage time */ ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; - /* Solver diagnostics reporting */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "start-stage", - "step = %li, stage = %i, stage type = %d, h = %" RSYM - ", tcur = %" RSYM, - ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, - ark_mem->tcur); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "start-stage", + "step = %li, stage = %i, stage type = %d, h = %" RSYM + ", tcur = %" RSYM, + ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, + ark_mem->tcur); /* Determine current stage type, and call corresponding routine; the vector ark_mem->ycur stores the previous stage solution on input, and @@ -1547,11 +1532,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } if (retval != ARK_SUCCESS) { return (retval); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "slow stage", - "z_%i(:) =", is); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow stage", + "z_%i(:) =", ark_mem->ycur, is); /* apply user-supplied stage postprocessing function (if supplied) */ if (ark_mem->ProcessStage != NULL) @@ -1584,12 +1566,9 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "slow explicit RHS", "Fse_%i(:) =", is); - N_VPrintFile(step_mem->Fse[step_mem->stage_map[is]], - ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow explicit RHS", + "Fse_%i(:) =", step_mem->Fse[step_mem->stage_map[is]], + is); } /* store implicit slow rhs */ @@ -1613,28 +1592,19 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "slow implicit RHS", "Fsi_%i(:) =", is); - N_VPrintFile(step_mem->Fsi[step_mem->stage_map[is]], - ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow implicit RHS", + "Fsi_%i(:) =", step_mem->Fsi[step_mem->stage_map[is]], + is); } } /* compute slow RHS */ } /* loop over stages */ -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "updated solution", "ycur(:) =", ""); - N_VPrintFile(ark_mem->ycur, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "updated solution", + "ycur(:) =", ark_mem->ycur, ""); - /* Solver diagnostics reporting */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", - "step = %li, h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, - ark_mem->h, *dsmPtr); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "error-test", + "step = %li, h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, + ark_mem->h, *dsmPtr); return (ARK_SUCCESS); } @@ -2025,27 +1995,16 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is) if (retval != 0) { return (ARK_OUTERTOINNER_FAIL); } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "begin-fast-steps", ""); -#endif + SUNLogInfo(ARK_LOGGER, __func__, "begin-fast-steps", "", ""); /* advance inner method in time */ retval = mriStepInnerStepper_Evolve(step_mem->stepper, t0, ark_mem->tcur, ark_mem->ycur); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (retval != 0) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-fast-steps", "status = failed, retval = %i", retval); - } - else - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-fast-steps", "status = success"); - } -#endif + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-fast-steps", + "status = failed, retval = %i", retval); + SUNLogInfoIf(retval == 0, ARK_LOGGER, __func__, "end-fast-steps", + "status = success", ""); if (retval != 0) { return (ARK_INNERSTEP_FAIL); } @@ -2153,11 +2112,8 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, if (retval > 0) { return (TRY_AGAIN); } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "predictor", - "zpred(:) =", ""); - N_VPrintFile(step_mem->zpred, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "predictor", + "zpred(:) =", step_mem->zpred, ""); /* determine effective DIRK coefficients (store in cvals) */ retval = mriStep_RKCoeffs(step_mem->MRIC, is, step_mem->stage_map, @@ -2168,11 +2124,8 @@ int mriStep_StageDIRKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, retval = mriStep_StageSetup(ark_mem); if (retval != ARK_SUCCESS) { return (retval); } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "rhs data", - "sdata(:) =", ""); - N_VPrintFile(step_mem->sdata, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "rhs data", + "sdata(:) =", step_mem->sdata, ""); /* perform implicit solve (result is stored in ark_mem->ycur); return with positive value on anything but success */ @@ -2304,14 +2257,8 @@ int mriStep_ComputeInnerForcing(SUNDIALS_MAYBE_UNUSED ARKodeMem ark_mem, if (retval != 0) { return (ARK_VECTOROP_ERR); } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - for (k = 0; k < nmat; k++) - { - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "forcing", - "forcing_%i(:) =", k); - N_VPrintFile(step_mem->stepper->forcing[k], ARK_LOGGER->debug_fp); - } -#endif + SUNLogExtraDebugVecArray(ARK_LOGGER, __func__, "forcing", + "forcing_%i(:) =", step_mem->stepper->forcing, nmat); return (ARK_SUCCESS); } @@ -2826,10 +2773,8 @@ int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, if (stepper == NULL) { return ARK_ILL_INPUT; } if (stepper->ops == NULL) { return ARK_ILL_INPUT; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, - "reset-inner-state", "tR = %" RSYM, tR); -#endif + SUNLogDebug(stepper->sunctx->logger, __func__, "reset-inner-state", + "tR = %" RSYM, tR); if (stepper->ops->reset) { diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index 2912feda00..7de1f83f25 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -122,11 +122,9 @@ static int arkRelaxNewtonSolve(ARKodeMem ark_mem) retval = arkRelaxResidual(relax_mem->relax_param, &(relax_mem->res), ark_mem); if (retval) { return retval; } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "residual", - "iter = %i, relax_param = %" RSYM ", residual = %" RSYM, - i, relax_mem->relax_param, relax_mem->res); -#endif + SUNLogExtraDebug(ARK_LOGGER, __func__, "residual", + "iter = %i, relax_param = %" RSYM ", residual = %" RSYM, i, + relax_mem->relax_param, relax_mem->res); /* Check for convergence */ if (SUNRabs(relax_mem->res) < relax_mem->res_tol) { return ARK_SUCCESS; } @@ -346,19 +344,14 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, &(relax_mem->delta_e)); if (retval) { return retval; } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "compute delta e", "delta_e = %" RSYM, relax_mem->delta_e); -#endif + SUNLogExtraDebug(ARK_LOGGER, __func__, "compute delta e", "delta_e = %" RSYM, + relax_mem->delta_e); /* Get the change in state (delta_y = tempv2) */ N_VLinearSum(ONE, ark_mem->ycur, -ONE, ark_mem->yn, ark_mem->tempv2); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "compute delta y", "delta_y(:) =", ""); - N_VPrintFile(ark_mem->tempv2, ARK_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "compute delta y", + "delta_y(:) =", ark_mem->tempv2, ""); /* Store the current relaxation function value */ retval = relax_mem->relax_fn(ark_mem->yn, &(relax_mem->e_old), @@ -367,10 +360,8 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, if (retval < 0) { return ARK_RELAX_FUNC_FAIL; } if (retval > 0) { return ARK_RELAX_FUNC_RECV; } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "compute old e", - "e_old = %" RSYM, relax_mem->e_old); -#endif + SUNLogExtraDebug(ARK_LOGGER, __func__, "compute old e", "e_old = %" RSYM, + relax_mem->e_old); /* Initial guess for relaxation parameter */ relax_mem->relax_param = relax_mem->relax_param_prev; @@ -905,12 +896,10 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout) N_VLinearSum(relax_val, ark_mem->ycur, (ONE - relax_val), ark_mem->yn, ark_mem->ycur); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "relaxation", - "relaxation parameter = %" RSYM ", relaxed h = %" RSYM - ", relaxed error = %" RSYM, - relax_val, ark_mem->h, *dsm_inout); -#endif + SUNLogDebug(ARK_LOGGER, __func__, "relaxation", + "relaxation parameter = %" RSYM ", relaxed h = %" RSYM + ", relaxed error = %" RSYM, + relax_val, ark_mem->h, *dsm_inout); return ARK_SUCCESS; } From a60bdcfcffb09c610ee98643733a1fdfacee882b Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 10:12:56 -0700 Subject: [PATCH 030/235] formatting --- src/arkode/arkode.c | 3 ++- src/arkode/arkode_adapt.c | 3 +-- src/arkode/arkode_arkstep.c | 4 ++-- src/arkode/arkode_erkstep.c | 4 ++-- src/arkode/arkode_mristep_nls.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index d9044ad6df..07f7d05bbd 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -955,7 +955,8 @@ int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, { ark_mem->last_kflag = kflag; kflag = ARK_SUCCESS; - SUNLogInfo(ARK_LOGGER, __func__, "end-step-attempt", "status = success", ""); + SUNLogInfo(ARK_LOGGER, __func__, "end-step-attempt", "status = success", + ""); break; } diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 8f0e79e6d2..cab3900b3f 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -173,8 +173,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, /* enforce maximum time step size */ ark_mem->eta /= SUNMAX(ONE, SUNRabs(hcur) * ark_mem->hmax_inv * ark_mem->eta); - SUNLogDebug(ARK_LOGGER, __func__, "new-step-eta", - "eta = %" RSYM, ark_mem->eta); + SUNLogDebug(ARK_LOGGER, __func__, "new-step-eta", "eta = %" RSYM, ark_mem->eta); return (retval); } diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index ad7a7b31f6..2934194f60 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -2052,8 +2052,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { *nflagPtr = step_mem->msolve((void*)ark_mem, step_mem->Fe[is], step_mem->nlscoef); - SUNLogExtraDebugVec(ARK_LOGGER, __func__, - "M^{-1} explicit RHS", "Fe_%i(:) =", step_mem->Fe[is], is); + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "M^{-1} explicit RHS", + "Fe_%i(:) =", step_mem->Fe[is], is); if (*nflagPtr != ARK_SUCCESS) { SUNLogDebug(ARK_LOGGER, __func__, "end-stage", diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 41171830b3..e503c4921d 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -628,8 +628,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, ark_mem->tcur); - SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage", - "z_0(:) =", ark_mem->ycur, ""); + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage", "z_0(:) =", ark_mem->ycur, + ""); SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", "F_0(:) =", step_mem->F[0], ""); SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "", ""); diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index d9b55a11b1..f45d5fcad2 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -326,8 +326,8 @@ int mriStep_Nls(ARKodeMem ark_mem, int nflag) ark_mem->ewt, step_mem->nlscoef, callLSetup, ark_mem); - SUNLogExtraDebug(ARK_LOGGER, "ARKODE::mriStep_Nls", - "correction", "zcor(:) =", step_mem->zcor, ""); + SUNLogExtraDebug(ARK_LOGGER, "ARKODE::mriStep_Nls", "correction", + "zcor(:) =", step_mem->zcor, ""); /* increment counters */ (void)SUNNonlinSolGetNumIters(step_mem->NLS, &nls_iters_inc); From a91d314b151f6399c45b9bb4d6065fe5083b3da3 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 10:30:15 -0700 Subject: [PATCH 031/235] update ARKODE LS logging --- src/arkode/arkode_ls.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index dce97a8fe8..c4de598b01 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -3290,13 +3290,16 @@ int arkLsSetup(ARKodeMem ark_mem, int convfail, sunrealtype tpred, int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, N_Vector fnow, sunrealtype eRNrm, int mnewt) { - sunrealtype bnorm, resnorm; + sunrealtype bnorm; ARKLsMem arkls_mem; sunrealtype gamma, gamrat, delta, deltar, rwt_mean; sunbooleantype dgamma_fail, *jcur; - long int nps_inc; int nli_inc, retval; + /* used when logging is enabled */ + SUNDIALS_MAYBE_UNUSED long int nps_inc; + SUNDIALS_MAYBE_UNUSED sunrealtype resnorm; + /* access ARKLsMem structure */ retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } @@ -3422,17 +3425,10 @@ int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, arkls_mem->nli += nli_inc; if (retval != SUN_SUCCESS) { arkls_mem->ncfl++; } - /* Log solver statistics to diagnostics file (if requested) */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "ls-stats", - "bnorm = %" RSYM ", resnorm = %" RSYM - ", ls_iters = %i, prec_solves = %i", - bnorm, resnorm, nli_inc, (int)(arkls_mem->nps - nps_inc)); -#else - /* Suppress warning about set but unused variables due to logging ifdef. */ - (void)nps_inc; - (void)resnorm; -#endif + SUNLogDebug(ARK_LOGGER, __func__, "ls-stats", + "bnorm = %" RSYM ", resnorm = %" RSYM + ", ls_iters = %i, prec_solves = %i", + bnorm, resnorm, nli_inc, (int)(arkls_mem->nps - nps_inc)); /* Interpret solver return value */ arkls_mem->last_flag = retval; @@ -3761,11 +3757,14 @@ int arkLsMassSetup(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, ---------------------------------------------------------------*/ int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef) { - sunrealtype resnorm, delta, rwt_mean; + sunrealtype delta, rwt_mean; ARKLsMassMem arkls_mem; - long int nps_inc; int nli_inc, retval; + /* used when logging is enabled */ + SUNDIALS_MAYBE_UNUSED long int nps_inc; + SUNDIALS_MAYBE_UNUSED sunrealtype resnorm; + /* access ARKLsMassMem structure */ retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } @@ -3849,16 +3848,9 @@ int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef) arkls_mem->nli += nli_inc; if (retval != SUN_SUCCESS) { arkls_mem->ncfl++; } - /* Log solver statistics to diagnostics file (if requested) */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "mass-ls-stats", - "resnorm = %" RSYM ", ls_iters = %i, prec_solves = %i", - resnorm, nli_inc, (int)(arkls_mem->nps - nps_inc)); -#else - /* Suppress warning about set but unused variables due to logging ifdef. */ - (void)nps_inc; - (void)resnorm; -#endif + SUNLogDebug(ARK_LOGGER, __func__, "mass-ls-stats", + "resnorm = %" RSYM ", ls_iters = %i, prec_solves = %i", resnorm, + nli_inc, (int)(arkls_mem->nps - nps_inc)); /* Interpret solver return value */ arkls_mem->last_flag = retval; From 6fed1e6e4b3dceab5244969d1cb00eeaaa44c75c Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 10:37:43 -0700 Subject: [PATCH 032/235] update CVODE logging --- src/cvode/cvode.c | 98 ++++++++++++++------------------------------ src/cvode/cvode_ls.c | 9 ++-- 2 files changed, 34 insertions(+), 73 deletions(-) diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index f416a164a3..ea54aab932 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2353,13 +2353,9 @@ static int cvStep(CVodeMem cv_mem) for (;;) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "begin-step-attempt", - "step = %li, t_n = %.16g, h = %.16g, q = %d", - cv_mem->cv_nst + 1, cv_mem->cv_tn, cv_mem->cv_h, - cv_mem->cv_q); -#endif + SUNLogInfo(CV_LOGGER, __func__, "begin-step-attempt", + "step = %li, t_n = %" RSYM ", h = %" RSYM ", q = %d", + cv_mem->cv_nst + 1, cv_mem->cv_tn, cv_mem->cv_h, cv_mem->cv_q); cvPredict(cv_mem); cvSet(cv_mem); @@ -2367,14 +2363,9 @@ static int cvStep(CVodeMem cv_mem) nflag = cvNls(cv_mem, nflag); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, + __func__, "end-step-attempt", + "status = failed solve, kflag = %i", kflag); /* Go back in loop if we need to predict again (nflag=PREV_CONV_FAIL) */ if (kflag == PREDICT_AGAIN) { continue; } @@ -2390,14 +2381,8 @@ static int cvStep(CVodeMem cv_mem) /* Perform projection (nflag=CV_SUCCESS) */ pflag = cvDoProjection(cv_mem, &nflag, saved_t, &npf); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (pflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed projection, pflag = %i", pflag); - } -#endif + SUNLogInfoIf(pflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed projection, pflag = %i", pflag); /* Go back in loop if we need to predict again (nflag=PREV_PROJ_FAIL) */ if (pflag == PREDICT_AGAIN) { continue; } @@ -2409,15 +2394,9 @@ static int cvStep(CVodeMem cv_mem) /* Perform error test (nflag=CV_SUCCESS) */ eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, &nef, &dsm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (eflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed error test, dsm = %.16g, eflag = %i", - dsm, eflag); - } -#endif + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed error test, dsm = %" RSYM ", eflag = %i", dsm, + eflag); /* Go back in loop if we need to predict again (nflag=PREV_ERR_FAIL) */ if (eflag == TRY_AGAIN) { continue; } @@ -2429,10 +2408,8 @@ static int cvStep(CVodeMem cv_mem) break; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", - "status = success, dsm = %.16g", dsm); -#endif + SUNLogInfo(CV_LOGGER, __func__, "end-step-attempt", + "status = success, dsm = %" RSYM, dsm); /* Nonlinear system solve and error test were both successful. Update data, and consider change of step and/or order. */ @@ -2735,11 +2712,8 @@ static void cvPredict(CVodeMem cv_mem) } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "zn_0(:) =", ""); - N_VPrintFile(cv_mem->cv_zn[0], CV_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(CV_LOGGER, __func__, "return", + "zn_0(:) =", cv_mem->cv_zn[0], ""); } /* @@ -3325,11 +3299,9 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, dsm = cv_mem->cv_acnrm * cv_mem->cv_tq[2]; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", - "step = %li, h = %.16g, dsm = %.16g", cv_mem->cv_nst, - cv_mem->cv_h, dsm); -#endif + SUNLogDebug(CV_LOGGER, __func__, "error-test", + "step = %li, h = %" RSYM ", dsm = %" RSYM, cv_mem->cv_nst, + cv_mem->cv_h, dsm); /* If est. local error norm dsm passes test, return CV_SUCCESS */ *dsmPtr = dsm; @@ -3365,10 +3337,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cvRescale(cv_mem); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta", - "eta = %.16g", cv_mem->cv_eta); -#endif + SUNLogDebug(CV_LOGGER, __func__, "new-step-eta", "eta = %" RSYM, + cv_mem->cv_eta); return (TRY_AGAIN); } @@ -3383,10 +3353,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cv_mem->cv_q--; cv_mem->cv_qwait = cv_mem->cv_L; cvRescale(cv_mem); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-eta-mxnef1", "eta = %.16g", cv_mem->cv_eta); -#endif + SUNLogDebug(CV_LOGGER, __func__, "new-step-eta-mxnef1", "eta = %" RSYM, + cv_mem->cv_eta); return (TRY_AGAIN); } @@ -3408,10 +3376,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, N_VScale(cv_mem->cv_h, cv_mem->cv_tempv, cv_mem->cv_zn[1]); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-eta-mxnef1-q1", "eta = %.16g", cv_mem->cv_eta); -#endif + SUNLogDebug(CV_LOGGER, __func__, "new-step-eta-mxnef1-q1", "eta = %" RSYM, + cv_mem->cv_eta); return (TRY_AGAIN); } @@ -3482,10 +3448,8 @@ static void cvCompleteStep(CVodeMem cv_mem) } #endif -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "nst = %d, nscon = %d", cv_mem->cv_nst, cv_mem->cv_nscon); -#endif + SUNLogDebug(CV_LOGGER, __func__, "return", "nst = %d, nscon = %d", + cv_mem->cv_nst, cv_mem->cv_nscon); } /* @@ -3532,12 +3496,10 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d", - cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, - cv_mem->cv_qwait); -#endif + SUNLogDebug(CV_LOGGER, __func__, "return", + "eta = %" RSYM ", hprime = %" RSYM ", qprime = %d, qwait = %d", + cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, + cv_mem->cv_qwait); } /* diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index 80556703d1..a8daa6c043 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -1780,11 +1780,10 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, /* Interpret solver return value */ cvls_mem->last_flag = retval; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "ls-stats", "bnorm = %.16g, resnorm = %.16g, ls_iters = %i, prec_solves = %i", - bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); -#endif + SUNLogDebug(CV_LOGGER, __func__, "ls-stats", + "bnorm = %" RSYM ", resnorm = %" RSYM + ", ls_iters = %i, prec_solves = %i", + bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); switch (retval) { From 8c750f0e0a1ff4a8e7cc84243c010c0dea1337cd Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 10:57:04 -0700 Subject: [PATCH 033/235] update CVODES logging --- src/cvodes/cvodes.c | 203 ++++++++++++----------------------------- src/cvodes/cvodes_ls.c | 9 +- 2 files changed, 62 insertions(+), 150 deletions(-) diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index 70910eca31..f1c7b13c59 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -5857,13 +5857,9 @@ static int cvStep(CVodeMem cv_mem) for (;;) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "begin-step-attempt", - "step = %li, t_n = %.16g, h = %.16g, q = %d", - cv_mem->cv_nst + 1, cv_mem->cv_tn, cv_mem->cv_h, - cv_mem->cv_q); -#endif + SUNLogInfo(CV_LOGGER, __func__, "begin-step-attempt", + "step = %li, t_n = %" RSYM ", h = %" RSYM ", q = %d", + cv_mem->cv_nst + 1, cv_mem->cv_tn, cv_mem->cv_h, cv_mem->cv_q); cvPredict(cv_mem); cvSet(cv_mem); @@ -5873,14 +5869,9 @@ static int cvStep(CVodeMem cv_mem) nflag = cvNls(cv_mem, nflag); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, + __func__, "end-step-attempt", + "status = failed solve, kflag = %i", kflag); /* Go back in loop if we need to predict again (nflag=PREV_CONV_FAIL) */ if (kflag == PREDICT_AGAIN) { continue; } @@ -5896,14 +5887,8 @@ static int cvStep(CVodeMem cv_mem) /* Perform projection (nflag=CV_SUCCESS) */ pflag = cvDoProjection(cv_mem, &nflag, saved_t, &npf); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (pflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed projection, pflag = %i", pflag); - } -#endif + SUNLogInfoIf(pflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed projection, pflag = %i", pflag); /* Go back in loop if we need to predict again (nflag=PREV_PROJ_FAIL) */ if (pflag == PREDICT_AGAIN) { continue; } @@ -5916,15 +5901,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrm, &nef, &(cv_mem->cv_netf), &dsm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (eflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed error test, dsm = %.16g, eflag = %i", - dsm, eflag); - } -#endif + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed error test, dsm = %" RSYM ", eflag = %i", dsm, + eflag); /* Go back in loop if we need to predict again (nflag=PREV_ERR_FAIL) */ if (eflag == TRY_AGAIN) { continue; } @@ -5943,14 +5922,9 @@ static int cvStep(CVodeMem cv_mem) nflag = cvQuadNls(cv_mem); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, + __func__, "end-step-attempt", + "status = failed quad solve, kflag = %i", kflag); if (kflag == PREDICT_AGAIN) { continue; } if (kflag != DO_ERROR_TEST) { return (kflag); } @@ -5962,14 +5936,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmQ, &nefQ, &(cv_mem->cv_netfQ), &dsmQ); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (eflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed quad error test, dsmQ = %.16g, eflag = %i", - dsmQ, eflag); - } -#endif + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, + "end-step-attempt", "status = failed quad error test, dsmQ = %" RSYM ", eflag = %i", + dsmQ, eflag); if (eflag == TRY_AGAIN) { continue; } if (eflag != CV_SUCCESS) { return (eflag); } @@ -5994,14 +5963,8 @@ static int cvStep(CVodeMem cv_mem) cv_mem->cv_user_data); cv_mem->cv_nfe++; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (retval != 0) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed rhs eval, retval = %i", retval); - } -#endif + SUNLogInfoIf(retval != 0, CV_LOGGER, __func__, "end-step-attempt", + "status = failed rhs eval, retval = %i", retval); if (retval < 0) { return (CV_RHSFUNC_FAIL); } if (retval > 0) @@ -6031,14 +5994,9 @@ static int cvStep(CVodeMem cv_mem) } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed sens solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, + __func__, "end-step-attempt", + "status = failed sens solve, kflag = %i", kflag); if (kflag == PREDICT_AGAIN) { continue; } if (kflag != DO_ERROR_TEST) { return (kflag); } @@ -6055,14 +6013,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmS, &nefS, &(cv_mem->cv_netfS), &dsmS); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (eflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed sens error test, dsmS = %.16g, eflag = %i", - dsmS, eflag); - } -#endif + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, + "end-step-attempt", "status = failed sens error test, dsmS = %" RSYM ", eflag = %i", + dsmS, eflag); if (eflag == TRY_AGAIN) { continue; } if (eflag != CV_SUCCESS) { return (eflag); } @@ -6092,14 +6045,9 @@ static int cvStep(CVodeMem cv_mem) nflag = cvQuadSensNls(cv_mem); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad sens solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, __func__, + "end-step-attempt", + "status = failed quad sens solve, kflag = %i", kflag); if (kflag == PREDICT_AGAIN) { continue; } if (kflag != DO_ERROR_TEST) { return (kflag); } @@ -6112,14 +6060,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmQS, &nefQS, &(cv_mem->cv_netfQS), &dsmQS); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (eflag != CV_SUCCESS) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed quad sens error test, dsmQS = %.16g, eflag = %i", - dsmQS, eflag); - } -#endif + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, + "end-step-attempt", "status = failed quad sens error test, dsmQS = %" RSYM ", eflag = %i", + dsmQS, eflag); if (eflag == TRY_AGAIN) { continue; } if (eflag != CV_SUCCESS) { return (eflag); } @@ -6133,10 +6076,8 @@ static int cvStep(CVodeMem cv_mem) break; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_INFO, __func__, "end-step-attempt", - "status = success, dsm = %.16g", dsm); -#endif + SUNLogInfo(CV_LOGGER, __func__, "end-step-attempt", + "status = success, dsm = %" RSYM , dsm); /* Nonlinear system solve and error test were both successful. Update data, and consider change of step and/or order. */ @@ -6624,11 +6565,8 @@ static void cvPredict(CVodeMem cv_mem) } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "forward", - "zn_0(:) =", ""); - N_VPrintFile(cv_mem->cv_zn[0], CV_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(CV_LOGGER, __func__, "forward", + "zn_0(:) =", cv_mem->cv_zn[0], ""); if (cv_mem->cv_quadr) { @@ -6641,11 +6579,8 @@ static void cvPredict(CVodeMem cv_mem) } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "quad", - "znQ_0(:) =", ""); - N_VPrintFile(cv_mem->cv_znQ[0], CV_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(CV_LOGGER, __func__, "quad", + "znQ_0(:) =", cv_mem->cv_znQ[0], ""); } if (cv_mem->cv_sensi) @@ -6657,14 +6592,9 @@ static void cvPredict(CVodeMem cv_mem) (void)N_VLinearSumVectorArray(cv_mem->cv_Ns, ONE, cv_mem->cv_znS[j - 1], ONE, cv_mem->cv_znS[j], cv_mem->cv_znS[j - 1]); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - for (int i = 0; i < cv_mem->cv_Ns; i++) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "sensi", - "znS_%d(:) = ", i); - N_VPrintFile(cv_mem->cv_znS[0][i], CV_LOGGER->debug_fp); - } -#endif + SUNLogExtraDebugVecArray(CV_LOGGER, __func__, "sensi", + "znS_%d(:) = ", cv_mem->cv_znS[0], + cv_mem->cv_Ns); } } } @@ -6678,14 +6608,9 @@ static void cvPredict(CVodeMem cv_mem) (void)N_VLinearSumVectorArray(cv_mem->cv_Ns, ONE, cv_mem->cv_znQS[j - 1], ONE, cv_mem->cv_znQS[j], cv_mem->cv_znQS[j - 1]); -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - for (int i = 0; i < cv_mem->cv_Ns; i++) - { - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "quad-sensi", "znQS_%d(:) = ", i); - N_VPrintFile(cv_mem->cv_znQS[0][i], CV_LOGGER->debug_fp); - } -#endif + SUNLogExtraDebugVecArray(CV_LOGGER, __func__, "quad-sensi", + "znQS_%d(:) = ", cv_mem->cv_znQS[0], + cv_mem->cv_Ns); } } } @@ -7563,11 +7488,9 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, dsm = acor_nrm * cv_mem->cv_tq[2]; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-test", - "step = %li, h = %.16g, dsm = %.16g", cv_mem->cv_nst, - cv_mem->cv_h, dsm); -#endif + SUNLogDebug(CV_LOGGER, __func__, "error-test", + "step = %li, h = %" RSYM ", dsm = %" RSYM, cv_mem->cv_nst, + cv_mem->cv_h, dsm); /* If est. local error norm dsm passes test, return CV_SUCCESS */ *dsmPtr = dsm; @@ -7603,10 +7526,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cvRescale(cv_mem); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-step-eta", - "eta = %.16g", cv_mem->cv_eta); -#endif + SUNLogDebug(CV_LOGGER, __func__, "new-step-eta", "eta = %" RSYM, + cv_mem->cv_eta); return (TRY_AGAIN); } @@ -7621,10 +7542,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, cv_mem->cv_q--; cv_mem->cv_qwait = cv_mem->cv_L; cvRescale(cv_mem); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-eta-mxnef1", "eta = %.16g", cv_mem->cv_eta); -#endif + SUNLogDebug(CV_LOGGER, __func__, "new-step-eta-mxnef1", "eta = %" RSYM, + cv_mem->cv_eta); return (TRY_AGAIN); } @@ -7646,10 +7565,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, N_VScale(cv_mem->cv_h, cv_mem->cv_tempv, cv_mem->cv_zn[1]); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-eta-mxnef1-q1", "eta = %.16g", cv_mem->cv_eta); -#endif + SUNLogDebug(CV_LOGGER, __func__, "new-step-eta-mxnef1-q1", "eta = %" RSYM, + cv_mem->cv_eta); if (cv_mem->cv_quadr) { @@ -7823,10 +7740,8 @@ static void cvCompleteStep(CVodeMem cv_mem) } #endif -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "nst = %d, nscon = %d", cv_mem->cv_nst, cv_mem->cv_nscon); -#endif + SUNLogDebug(CV_LOGGER, __func__, "return", "nst = %d, nscon = %d", + cv_mem->cv_nst, cv_mem->cv_nscon); } /* @@ -7873,12 +7788,10 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "return", - "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d", - cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, - cv_mem->cv_qwait); -#endif + SUNLogDebug(CV_LOGGER, __func__, "return", + "eta = %" RSYM ", hprime = %" RSYM ", qprime = %d, qwait = %d", + cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, + cv_mem->cv_qwait); } /* diff --git a/src/cvodes/cvodes_ls.c b/src/cvodes/cvodes_ls.c index 26bfd13e99..f58ffa6139 100644 --- a/src/cvodes/cvodes_ls.c +++ b/src/cvodes/cvodes_ls.c @@ -1876,11 +1876,10 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, /* Interpret solver return value */ cvls_mem->last_flag = retval; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "ls-stats", "bnorm = %.16g, resnorm = %.16g, ls_iters = %i, prec_solves = %i", - bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); -#endif + SUNLogDebug(CV_LOGGER, __func__, "ls-stats", + "bnorm = %" RSYM ", resnorm = %" RSYM + ", ls_iters = %i, prec_solves = %i", + bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); switch (retval) { From 64e58e1356d6983cf03d13d0311c015fd79321c4 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 11:02:46 -0700 Subject: [PATCH 034/235] formatting --- src/cvodes/cvodes.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c index f1c7b13c59..5aaa90547a 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -5936,8 +5936,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmQ, &nefQ, &(cv_mem->cv_netfQ), &dsmQ); - SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, - "end-step-attempt", "status = failed quad error test, dsmQ = %" RSYM ", eflag = %i", + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed quad error test, dsmQ = %" RSYM + ", eflag = %i", dsmQ, eflag); if (eflag == TRY_AGAIN) { continue; } @@ -6013,8 +6014,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmS, &nefS, &(cv_mem->cv_netfS), &dsmS); - SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, - "end-step-attempt", "status = failed sens error test, dsmS = %" RSYM ", eflag = %i", + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed sens error test, dsmS = %" RSYM + ", eflag = %i", dsmS, eflag); if (eflag == TRY_AGAIN) { continue; } @@ -6045,8 +6047,8 @@ static int cvStep(CVodeMem cv_mem) nflag = cvQuadSensNls(cv_mem); kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf, &(cv_mem->cv_ncfn)); - SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, __func__, - "end-step-attempt", + SUNLogInfoIf(kflag == PREDICT_AGAIN || kflag != DO_ERROR_TEST, CV_LOGGER, + __func__, "end-step-attempt", "status = failed quad sens solve, kflag = %i", kflag); if (kflag == PREDICT_AGAIN) { continue; } @@ -6060,8 +6062,9 @@ static int cvStep(CVodeMem cv_mem) eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, cv_mem->cv_acnrmQS, &nefQS, &(cv_mem->cv_netfQS), &dsmQS); - SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, - "end-step-attempt", "status = failed quad sens error test, dsmQS = %" RSYM ", eflag = %i", + SUNLogInfoIf(eflag != CV_SUCCESS, CV_LOGGER, __func__, "end-step-attempt", + "status = failed quad sens error test, dsmQS = %" RSYM + ", eflag = %i", dsmQS, eflag); if (eflag == TRY_AGAIN) { continue; } @@ -6077,7 +6080,7 @@ static int cvStep(CVodeMem cv_mem) } SUNLogInfo(CV_LOGGER, __func__, "end-step-attempt", - "status = success, dsm = %" RSYM , dsm); + "status = success, dsm = %" RSYM, dsm); /* Nonlinear system solve and error test were both successful. Update data, and consider change of step and/or order. */ From 3ec669d33cce580cbc92dcc30d69c8aa563f2dda Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 18:03:01 -0700 Subject: [PATCH 035/235] update IDA logging --- src/ida/ida.c | 139 ++++++++++++++++---------------------------------- 1 file changed, 45 insertions(+), 94 deletions(-) diff --git a/src/ida/ida.c b/src/ida/ida.c index 9af1538a84..105113bdc0 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2504,13 +2504,10 @@ static int IDAStep(IDAMem IDA_mem) for (;;) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "begin-step-attempt", - "step = %li, t_n = %.16g, h = %.16g, q = %d", - IDA_mem->ida_nst + 1, IDA_mem->ida_tn, IDA_mem->ida_hh, - IDA_mem->ida_kk); -#endif + SUNLogInfo(IDA_LOGGER, __func__, "begin-step-attempt", + "step = %li, t_n = %" RSYM ", h = %" RSYM ", q = %d", + IDA_mem->ida_nst + 1, IDA_mem->ida_tn, IDA_mem->ida_hh, + IDA_mem->ida_kk); /*----------------------- Set method coefficients @@ -2557,21 +2554,13 @@ static int IDAStep(IDAMem IDA_mem) kflag = IDAHandleNFlag(IDA_mem, nflag, err_k, err_km1, &(IDA_mem->ida_ncfn), &ncf, &(IDA_mem->ida_netf), &nef); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (nflag == ERROR_TEST_FAIL) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed error test, dsm = %.16g, kflag = %i", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], - kflag); - } - else if (kflag != IDA_SUCCESS) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(nflag == ERROR_TEST_FAIL, IDA_LOGGER, __func__, + "end-step-attempt", + "status = failed error test, dsm = %" RSYM ", kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, IDA_LOGGER, + __func__, "end-step-attempt", + "status = failed solve, kflag = %i", kflag); /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -2586,11 +2575,9 @@ static int IDAStep(IDAMem IDA_mem) } /* end loop */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success, dsm = %.16g", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk]); -#endif + SUNLogInfo(IDA_LOGGER, __func__, "end-step-attempt", + "status = success, dsm = %" RSYM, + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk]); /* Nonlinear system solve and error test were both successful; update data, and consider change of step and/or order */ @@ -2772,11 +2759,8 @@ static int IDANls(IDAMem IDA_mem) (void)SUNNonlinSolGetNumConvFails(IDA_mem->NLS, &nnf_inc); IDA_mem->ida_nnf += nnf_inc; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", - "flag = %i, iters = %li, fails = %li", retval, nni_inc, - nnf_inc); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "nls-return", + "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); /* return if nonlinear solver failed */ if (retval != SUN_SUCCESS) { return (retval); } @@ -2889,11 +2873,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_k = IDA_mem->ida_sigma[IDA_mem->ida_kk] * enorm_k; terr_k = (IDA_mem->ida_kk + 1) * (*err_k); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "estimate-error-order-k", - "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "estimate-error-order-k", + "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); IDA_mem->ida_knew = IDA_mem->ida_kk; @@ -2907,12 +2888,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_km1 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 1] * enorm_km1; terr_km1 = IDA_mem->ida_kk * (*err_km1); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "estimate-error-order-km1", - "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, - terr_km1); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "estimate-error-order-km1", + "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, terr_km1); if (IDA_mem->ida_kk > 2) { @@ -2924,12 +2901,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, err_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * enorm_km2; terr_km2 = (IDA_mem->ida_kk - 1) * err_km2; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "estimate-error-order-km2", - "err_km2 = %" RSYM ", terr_km2 = %" RSYM, err_km2, - terr_km2); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "estimate-error-order-km2", + "err_km2 = %" RSYM ", terr_km2 = %" RSYM, err_km2, terr_km2); /* Decrease order if errors are reduced */ if (SUNMAX(terr_km1, terr_km2) <= terr_k) @@ -2947,13 +2920,11 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-order", - "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); + SUNLogDebug(IDA_LOGGER, __func__, "new-order", "kk = %i, knew = %i", + IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-estimate", - "ck_enorm_k = %" RSYM, ck * enorm_k); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "error-estimate", "ck_enorm_k = %" RSYM, + ck * enorm_k); /* Perform error test */ if (ck * enorm_k > ONE) { return (ERROR_TEST_FAIL); } @@ -3110,12 +3081,9 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "first-error-test_fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, - IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "first-error-test_fail", + "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, + IDA_mem->ida_eta, IDA_mem->ida_hh); return (PREDICT_AGAIN); } @@ -3129,12 +3097,9 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "second-error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, - IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "second-error-test-fail", + "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, + IDA_mem->ida_eta, IDA_mem->ida_hh); return (PREDICT_AGAIN); } @@ -3147,12 +3112,9 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, - IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "error-test-fail", + "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, + IDA_mem->ida_eta, IDA_mem->ida_hh); return (PREDICT_AGAIN); } @@ -3269,12 +3231,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k if (terr_kp1 >= HALF * terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "order-selection-raise", - "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, - terr_kp1); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "order-selection-raise", + "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); } else { @@ -3283,13 +3241,10 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else if (terr_kp1 >= terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "order-selection-rasie-or-lower", - "terr_km1 = %" RSYM ", terr_k = %" RSYM - ", terr_kp1 = %" RSYM, - terr_km1, terr_k, terr_kp1); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "order-selection-rasie-or-lower", + "terr_km1 = %" RSYM ", terr_k = %" RSYM + ", terr_kp1 = %" RSYM, + terr_km1, terr_k, terr_kp1); } } @@ -3335,14 +3290,10 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k } IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-and-order", - "knew = %i, err_knew = %" RSYM ", eta = %" RSYM - ", hnew = %" RSYM, - IDA_mem->ida_kk, err_knew, IDA_mem->ida_eta, - IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "new-step-and-order", + "knew = %i, err_knew = %" RSYM ", eta = %" RSYM + ", hnew = %" RSYM, + IDA_mem->ida_kk, err_knew, IDA_mem->ida_eta, IDA_mem->ida_hh); } /* end of phase if block */ From 94126942778666d4519e851c8153eb6e4a283efa Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 18:09:02 -0700 Subject: [PATCH 036/235] update some IDAS logging --- src/idas/idas.c | 139 ++++++++++++++++-------------------------------- 1 file changed, 45 insertions(+), 94 deletions(-) diff --git a/src/idas/idas.c b/src/idas/idas.c index ae67b19f4b..1389264253 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -5910,13 +5910,10 @@ static int IDAStep(IDAMem IDA_mem) for (;;) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "begin-step-attempt", - "step = %li, t_n = %.16g, h = %.16g, q = %d", - IDA_mem->ida_nst + 1, IDA_mem->ida_tn, IDA_mem->ida_hh, - IDA_mem->ida_kk); -#endif + SUNLogInfo(IDA_LOGGER, __func__, "begin-step-attempt", + "step = %li, t_n = %" RSYM ", h = %" RSYM ", q = %d", + IDA_mem->ida_nst + 1, IDA_mem->ida_tn, IDA_mem->ida_hh, + IDA_mem->ida_kk); /*----------------------- Set method coefficients @@ -5969,21 +5966,13 @@ static int IDAStep(IDAMem IDA_mem) kflag = IDAHandleNFlag(IDA_mem, nflag, err_k, err_km1, &(IDA_mem->ida_ncfn), &ncf, &(IDA_mem->ida_netf), &nef); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (nflag == ERROR_TEST_FAIL) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed error test, dsm = %.16g, kflag = %i", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], - kflag); - } - else if (kflag != IDA_SUCCESS) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(nflag == ERROR_TEST_FAIL, IDA_LOGGER, __func__, + "end-step-attempt", + "status = failed error test, dsm = %" RSYM ", kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, IDA_LOGGER, + __func__, "end-step-attempt", + "status = failed solve, kflag = %i", kflag); /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -6163,11 +6152,9 @@ static int IDAStep(IDAMem IDA_mem) } /* end loop */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = success, dsm = %.16g", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk]); -#endif + SUNLogInfo(IDA_LOGGER, __func__, "end-step-attempt", + "status = success, dsm = %" RSYM, + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk]); /* Nonlinear system solve and error test were both successful; update data, and consider change of step and/or order */ @@ -6438,11 +6425,8 @@ static int IDANls(IDAMem IDA_mem) IDA_mem->ida_nnf += nnf_inc; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "nls-return", - "flag = %i, iters = %li, fails = %li", retval, nni_inc, - nnf_inc); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "nls-return", + "flag = %i, iters = %li, fails = %li", retval, nni_inc, nnf_inc); /* return if nonlinear solver failed */ if (retval != SUN_SUCCESS) { return (retval); } @@ -6757,11 +6741,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_k = IDA_mem->ida_sigma[IDA_mem->ida_kk] * enorm_k; terr_k = (IDA_mem->ida_kk + 1) * (*err_k); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "estimate-error-order-k", - "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "estimate-error-order-k", + "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); IDA_mem->ida_knew = IDA_mem->ida_kk; @@ -6775,12 +6756,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_km1 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 1] * enorm_km1; terr_km1 = IDA_mem->ida_kk * (*err_km1); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "estimate-error-order-km1", - "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, - terr_km1); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "estimate-error-order-km1", + "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, terr_km1); if (IDA_mem->ida_kk > 2) { @@ -6792,12 +6769,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, *err_km2 = IDA_mem->ida_sigma[IDA_mem->ida_kk - 2] * enorm_km2; terr_km2 = (IDA_mem->ida_kk - 1) * (*err_km2); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "estimate-error-order-km2", - "err_km2 = %" RSYM ", terr_km2 = %" RSYM, *err_km2, - terr_km2); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "estimate-error-order-km2", + "err_km2 = %" RSYM ", terr_km2 = %" RSYM, err_km2, terr_km2); /* Decrease order if errors are reduced */ if (SUNMAX(terr_km1, terr_km2) <= terr_k) @@ -6815,13 +6788,11 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, } } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "new-order", - "kk = %i, knew = %i", IDA_mem->ida_kk, IDA_mem->ida_knew); + SUNLogDebug(IDA_LOGGER, __func__, "new-order", "kk = %i, knew = %i", + IDA_mem->ida_kk, IDA_mem->ida_knew); - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "error-estimate", - "ck_enorm_k = %" RSYM, ck * enorm_k); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "error-estimate", "ck_enorm_k = %" RSYM, + ck * enorm_k); /* Perform error test */ if (ck * enorm_k > ONE) { return (ERROR_TEST_FAIL); } @@ -7332,12 +7303,9 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "first-error-test_fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, - IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "first-error-test_fail", + "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, + IDA_mem->ida_eta, IDA_mem->ida_hh); return (PREDICT_AGAIN); } @@ -7351,12 +7319,9 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "second-error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, - IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "second-error-test-fail", + "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, + IDA_mem->ida_eta, IDA_mem->ida_hh); return (PREDICT_AGAIN); } @@ -7369,12 +7334,9 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, IDA_mem->ida_hmin / SUNRabs(IDA_mem->ida_hh)); IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, - IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "error-test-fail", + "kk = %i, eta = %" RSYM ", h = %" RSYM, IDA_mem->ida_kk, + IDA_mem->ida_eta, IDA_mem->ida_hh); return (PREDICT_AGAIN); } @@ -7552,12 +7514,8 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k if (terr_kp1 >= HALF * terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "order-selection-raise", - "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, - terr_kp1); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "order-selection-raise", + "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, terr_kp1); } else { @@ -7566,13 +7524,10 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k else if (terr_kp1 >= terr_k) { action = MAINTAIN; } else { action = RAISE; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "order-selection-rasie-or-lower", - "terr_km1 = %" RSYM ", terr_k = %" RSYM - ", terr_kp1 = %" RSYM, - terr_km1, terr_k, terr_kp1); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "order-selection-rasie-or-lower", + "terr_km1 = %" RSYM ", terr_k = %" RSYM + ", terr_kp1 = %" RSYM, + terr_km1, terr_k, terr_kp1); } } @@ -7618,14 +7573,10 @@ static void IDACompleteStep(IDAMem IDA_mem, sunrealtype err_k, sunrealtype err_k } IDA_mem->ida_hh *= IDA_mem->ida_eta; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "new-step-and-order", - "knew = %i, err_knew = %" RSYM ", eta = %" RSYM - ", hnew = %" RSYM, - IDA_mem->ida_kk, err_knew, IDA_mem->ida_eta, - IDA_mem->ida_hh); -#endif + SUNLogDebug(IDA_LOGGER, __func__, "new-step-and-order", + "knew = %i, err_knew = %" RSYM ", eta = %" RSYM + ", hnew = %" RSYM, + IDA_mem->ida_kk, err_knew, IDA_mem->ida_eta, IDA_mem->ida_hh); } /* end of phase if block */ From 8d4857a2a45f877334effc9a6d45be788032ffa3 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 20:43:51 -0700 Subject: [PATCH 037/235] more IDAS logging updates --- src/ida/ida.c | 1 + src/idas/idas.c | 78 +++++++++++++++---------------------------------- 2 files changed, 25 insertions(+), 54 deletions(-) diff --git a/src/ida/ida.c b/src/ida/ida.c index 105113bdc0..5a50de3fb1 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2558,6 +2558,7 @@ static int IDAStep(IDAMem IDA_mem) "end-step-attempt", "status = failed error test, dsm = %" RSYM ", kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, IDA_LOGGER, __func__, "end-step-attempt", "status = failed solve, kflag = %i", kflag); diff --git a/src/idas/idas.c b/src/idas/idas.c index 1389264253..2d5eecf5d2 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -5970,6 +5970,7 @@ static int IDAStep(IDAMem IDA_mem) "end-step-attempt", "status = failed error test, dsm = %" RSYM ", kflag = %i", ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, IDA_LOGGER, __func__, "end-step-attempt", "status = failed solve, kflag = %i", kflag); @@ -6004,21 +6005,13 @@ static int IDAStep(IDAMem IDA_mem) &(IDA_mem->ida_ncfnQ), &ncf, &(IDA_mem->ida_netfQ), &nef); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (nflag == ERROR_TEST_FAIL) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed quad error test, dsmQ = %.16g, kflag = %i", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], - kflag); - } - else if (kflag != IDA_SUCCESS) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(nflag == ERROR_TEST_FAIL, IDA_LOGGER, __func__, + "end-step-attempt", "status = failed quad error test, dsmQ = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, + IDA_LOGGER, __func__, "end-step-attempt", + "status = failed quad solve, kflag = %i", kflag); /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -6041,14 +6034,8 @@ static int IDAStep(IDAMem IDA_mem) retval = IDA_mem->ida_res(IDA_mem->ida_tn, IDA_mem->ida_yy, IDA_mem->ida_yp, IDA_mem->ida_delta, IDA_mem->ida_user_data); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (retval != 0) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed res eval, retval = %i", retval); - } -#endif + SUNLogInfoIf(retval != 0, IDA_LOGGER, __func__, "end-step-attempt", + "status = failed res eval, retval = %i", retval); if (retval < 0) { return (IDA_RES_FAIL); } if (retval > 0) { continue; } @@ -6074,21 +6061,13 @@ static int IDAStep(IDAMem IDA_mem) &(IDA_mem->ida_ncfnQ), &ncf, &(IDA_mem->ida_netfQ), &nef); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (nflag == ERROR_TEST_FAIL) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed sens error test, dsmS = %.16g, kflag = %i", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], - kflag); - } - else if (kflag != IDA_SUCCESS) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed sens solve, kflag = %i", kflag); - } -#endif + SUNLogInfoIf(nflag == ERROR_TEST_FAIL, IDA_LOGGER, __func__, + "end-step-attempt", "status = failed sens error test, dsmS = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, + IDA_LOGGER, __func__, "end-step-attempt", + "status = failed sens solve, kflag = %i", kflag); /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } @@ -6121,22 +6100,13 @@ static int IDAStep(IDAMem IDA_mem) &(IDA_mem->ida_ncfnQ), &ncf, &(IDA_mem->ida_netfQ), &nef); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - if (nflag == ERROR_TEST_FAIL) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", "status = failed quad sens error test, dsmQS = %.16g, kflag = %i", - ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], - kflag); - } - else if (kflag != IDA_SUCCESS) - { - SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, __func__, - "end-step-attempt", - "status = failed quad sens solve, kflag = %i", - kflag); - } -#endif + SUNLogInfoIf(nflag == ERROR_TEST_FAIL, IDA_LOGGER, __func__, + "end-step-attempt", "status = failed quad sens error test, dsmQS = %.16g, kflag = %i", + ck * err_k / IDA_mem->ida_sigma[IDA_mem->ida_kk], kflag); + + SUNLogInfoIf(nflag != ERROR_TEST_FAIL && kflag != IDA_SUCCESS, + IDA_LOGGER, __func__, "end-step-attempt", + "status = failed quad sens solve, kflag = %i", kflag); /* exit on nonrecoverable failure */ if (kflag != PREDICT_AGAIN) { return (kflag); } From 4be8aaa6cafca43c9d242f950b849a24d81b8715 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 21:15:23 -0700 Subject: [PATCH 038/235] update KINSOL logging --- src/kinsol/kinsol.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/kinsol/kinsol.c b/src/kinsol/kinsol.c index 8c2e08fc33..7a80e3bae9 100644 --- a/src/kinsol/kinsol.c +++ b/src/kinsol/kinsol.c @@ -2542,9 +2542,7 @@ void KINPrintInfo(SUNDIALS_MAYBE_UNUSED KINMem kin_mem, int info_code, vsnprintf(msg, sizeof msg, msgfmt, ap); } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_INFO, "KINSOL", fname, "%s", msg); -#endif + SUNLogInfo(KIN_LOGGER, "KINSOL", fname, "%s", msg); /* finalize argument processing */ @@ -2837,11 +2835,8 @@ static int KINFP(KINMem kin_mem) ret = CONTINUE_ITERATIONS; tolfac = ONE; -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, "begin", "%s", - "u_0(:) ="); - N_VPrintFile(kin_mem->kin_uu, KIN_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(KIN_LOGGER, __func__, "begin", + "u_0(:) =", kin_mem->kin_uu, ""); /* initialize iteration count */ kin_mem->kin_nni = 0; @@ -2856,12 +2851,8 @@ static int KINFP(KINMem kin_mem) kin_mem->kin_user_data); kin_mem->kin_nfe++; -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "while-loop-before-compute-new", - "G_%ld(:) =", kin_mem->kin_nni - 1); - N_VPrintFile(kin_mem->kin_fval, KIN_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(KIN_LOGGER, __func__, "while-loop-before-compute-new", + "G_%ld(:) =", kin_mem->kin_fval, kin_mem->kin_nni - 1); if (retval < 0) { @@ -2912,12 +2903,8 @@ static int KINFP(KINMem kin_mem) else { tolfac = ONE; } } -#ifdef SUNDIALS_LOGGING_EXTRA_DEBUG - SUNLogger_QueueMsg(KIN_LOGGER, SUN_LOGLEVEL_DEBUG, __func__, - "while-loop-after-compute-new", - "u_%ld(:) =", kin_mem->kin_nni); - N_VPrintFile(kin_mem->kin_unew, KIN_LOGGER->debug_fp); -#endif + SUNLogExtraDebugVec(KIN_LOGGER, __func__, "while-loop-after-compute-new", + "u_%ld(:) =", kin_mem->kin_unew, kin_mem->kin_nni); /* compute change between iterations */ N_VLinearSum(ONE, kin_mem->kin_unew, -ONE, kin_mem->kin_uu, delta); From e4918cd289e6b07ab49ea81849a1b4fd6147cd44 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 21:23:53 -0700 Subject: [PATCH 039/235] update LS and NLS logging --- src/sunlinsol/pcg/sunlinsol_pcg.c | 14 ++--- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 14 ++--- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 14 ++--- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 14 ++--- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 14 ++--- .../fixedpoint/sunnonlinsol_fixedpoint.c | 18 ++---- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 56 ++++++++----------- 7 files changed, 48 insertions(+), 96 deletions(-) diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 182de66d7f..1e6b30d4d8 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -346,11 +346,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, SUNCheckLastErr(); *res_norm = r0_norm = rho = SUNRsqrt(rho); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "initial-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (rho <= delta) { @@ -437,11 +434,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, SUNCheckLastErr(); *res_norm = rho = SUNRsqrt(rho); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "iterate-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (rho <= delta) { diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index a3f692e3b6..e5219a5897 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -423,11 +423,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_norm = rho = SUNRsqrt(beta_denom); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "initial-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (r_norm <= delta) { @@ -654,11 +651,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = rho = SUNRsqrt(N_VDotProd(r, r)); SUNCheckLastErr(); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "iterate-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (rho <= delta) { diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index f62775d254..c6375b2513 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -463,11 +463,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); *res_norm = r_norm = beta = SUNRsqrt(r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "initial-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (r_norm <= delta) { @@ -574,11 +571,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "iterate-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (rho <= delta) { diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 0b60c2b7dc..89728f46f0 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -467,11 +467,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); *res_norm = r_norm = beta = SUNRsqrt(r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "initial-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (r_norm <= delta) { @@ -599,11 +596,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "iterate-residual", "nli = %li, resnorm = %.16g", - (long int)*nli, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", + "nli = %li, resnorm = %.16g", (long int)*nli, *res_norm); if (rho <= delta) { diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index 39ee78abd0..f5827ce73b 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -425,11 +425,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, to do anything */ *res_norm = r_init_norm = SUNRsqrt(rho[0]); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "initial-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); if (r_init_norm <= delta) { @@ -654,11 +651,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* NOTE: just use approximation to norm of residual, if possible */ *res_norm = r_curr_norm = tau * SUNRsqrt(m + 1); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "iterate-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); -#endif + SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", + "nli = %li, resnorm = %.16g", (long int)0, *res_norm); /* Exit inner loop if iteration has converged based upon approximation to norm of current residual */ diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 4f4ad51e1e..0e9eee0884 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -191,11 +191,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, FP_CONTENT(NLS)->niters = 0; FP_CONTENT(NLS)->nconvfails = 0; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "begin-iteration", "iter = %ld, nni = %ld", (long int)0, - FP_CONTENT(NLS)->niters); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "begin-iteration", + "iter = %ld, nni = %ld", (long int)0, FP_CONTENT(NLS)->niters); /* Looping point for attempts at solution of the nonlinear system: Evaluate fixed-point function (store in gy). @@ -239,13 +236,10 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, retval = FP_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, FP_CONTENT(NLS)->ctest_data); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "end-of-iterate", - "iter = %ld, nni = %ld, wrmsnorm = %.16g", - (long int)FP_CONTENT(NLS)->curiter, - FP_CONTENT(NLS)->niters, N_VWrmsNorm(delta, w)); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "end-of-iterate", + "iter = %ld, nni = %ld, wrmsnorm = %.16g", + (long int)FP_CONTENT(NLS)->curiter, FP_CONTENT(NLS)->niters, + N_VWrmsNorm(delta, w)); /* return if successful */ if (retval == 0) { return SUN_SUCCESS; } diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 5ca055555e..ae90e5123c 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -210,16 +210,13 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* initialize current iteration counter for this solve attempt */ NEWTON_CONTENT(NLS)->curiter = 0; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "begin-attempt", "iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "start-iterate", "iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "begin-attempt", + "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); + + SUNLogDebug(NLS->sunctx->logger, __func__, "start-iterate", + "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); @@ -255,12 +252,10 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, retval = NEWTON_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, NEWTON_CONTENT(NLS)->ctest_data); -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "end-iterate", "iter = %ld, nni = %ld, wrmsnorm = %.16g", - NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters - 1, N_VWrmsNorm(delta, w)); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "end-iterate", + "iter = %ld, nni = %ld, wrmsnorm = %.16g", + NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, + N_VWrmsNorm(delta, w)); /* Update here so begin/end logging iterations match */ NEWTON_CONTENT(NLS)->curiter++; @@ -268,12 +263,10 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* if successful update Jacobian status and return */ if (retval == SUN_SUCCESS) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "end-attempt", "success, iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "end-attempt", + "success, iter = %ld, nni = %ld", + (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); NEWTON_CONTENT(NLS)->jcur = SUNFALSE; return SUN_SUCCESS; } @@ -288,12 +281,9 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, break; } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "start-iterate", "iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "start-iterate", + "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); @@ -303,12 +293,10 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* all errors go here */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_DEBUG, __func__, - "end-attempt", "failure, iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); -#endif + SUNLogDebug(NLS->sunctx->logger, __func__, "end-attempt", + "failure, iter = %ld, nni = %ld", + (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); /* If there is a recoverable convergence failure and the Jacobian-related data appears not to be current, increment the convergence failure count, From 9647499845085185afeb486244e9f00faef47e95 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 14 Jun 2024 23:00:34 -0700 Subject: [PATCH 040/235] logging fixes --- src/arkode/arkode_arkstep.c | 3 ++- src/arkode/arkode_erkstep.c | 5 ++-- src/arkode/arkode_mristep.c | 49 +++++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 2934194f60..f68c4e7a26 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1835,7 +1835,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "implicit RHS", "Fi_%i(:) =", step_mem->Fi[0], 0); SUNLogExtraDebugVecIf(is_start == 1 && step_mem->explicit, ARK_LOGGER, __func__, "explicit RHS", "Fe_%i(:) =", step_mem->Fe[0], 0); - SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "end-stage", "", ""); + SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "end-stage", + "status = success", ""); /* loop over internal stages to the step */ for (is = is_start; is < step_mem->stages; is++) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index e503c4921d..2bcd445ee8 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -632,7 +632,7 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ""); SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", "F_0(:) =", step_mem->F[0], ""); - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "", ""); + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); /* Call the full RHS if needed. If this is the first step then we may need to evaluate or copy the RHS values from an earlier evaluation (e.g., to @@ -707,8 +707,7 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", "F_%i(:) =", step_mem->F[is], is); - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = success", ""); + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); } /* loop over stages */ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 662f014cd7..e78621f188 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1490,12 +1490,15 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->fn_is_current = SUNTRUE; } + SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, + ark_mem->tcur); SUNLogExtraDebug(ARK_LOGGER, __func__, "slow stage", "z_0(:) =", ark_mem->ycur, ""); SUNLogExtraDebugVecIf(step_mem->explicit_rhs, ARK_LOGGER, __func__, "slow explicit RHS", "Fse_0(:) =", step_mem->Fse[0], ""); SUNLogExtraDebugVecIf(step_mem->implicit_rhs, ARK_LOGGER, __func__, "slow implicit RHS", "Fsi_0(:) =", step_mem->Fsi[0], ""); + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); /* The first stage is the previous time-step solution, so its RHS is the [already-computed] slow RHS from the start of the step */ @@ -1506,11 +1509,9 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage time */ ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; - SUNLogDebug(ARK_LOGGER, __func__, "start-stage", - "step = %li, stage = %i, stage type = %d, h = %" RSYM - ", tcur = %" RSYM, - ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, - ark_mem->tcur); + SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", + "stage = %i, stage type = %d, tcur = %" RSYM, is, + step_mem->stagetypes[is], ark_mem->tcur); /* Determine current stage type, and call corresponding routine; the vector ark_mem->ycur stores the previous stage solution on input, and @@ -1519,15 +1520,23 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { case (MRISTAGE_ERK_FAST): retval = mriStep_StageERKFast(ark_mem, step_mem, is); + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed fast ERK stage, retval = %i", retval); break; case (MRISTAGE_ERK_NOFAST): retval = mriStep_StageERKNoFast(ark_mem, step_mem, is); + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed ERK stage, retval = %i", retval); break; case (MRISTAGE_DIRK_NOFAST): retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, is, nflagPtr); + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed DIRK stage, retval = %i", retval); break; case (MRISTAGE_DIRK_FAST): retval = mriStep_StageDIRKFast(ark_mem, step_mem, is, nflagPtr); + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed fast DIRK stage, retval = %i", retval); break; } if (retval != ARK_SUCCESS) { return (retval); } @@ -1540,7 +1549,12 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { retval = ark_mem->ProcessStage(ark_mem->tcur, ark_mem->ycur, ark_mem->user_data); - if (retval != 0) { return (ARK_POSTPROCESS_STAGE_FAIL); } + if (retval != 0) + { + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); + return (ARK_POSTPROCESS_STAGE_FAIL); + } } /* conditionally reset the inner integrator with the modified stage solution */ @@ -1549,7 +1563,12 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { retval = mriStepInnerStepper_Reset(step_mem->stepper, ark_mem->tcur, ark_mem->ycur); - if (retval != ARK_SUCCESS) { return (ARK_INNERSTEP_FAIL); } + if (retval != ARK_SUCCESS) + { + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", + "status = failed reset, retval = %i", retval); + return (ARK_INNERSTEP_FAIL); + } } /* Compute updated slow RHS except at last stage which is the new solution. @@ -1563,6 +1582,10 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->Fse[step_mem->stage_map[is]], ark_mem->user_data); step_mem->nfse++; + + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", retval); + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -1589,6 +1612,9 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->Fsi[step_mem->stage_map[is]]); } + SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed implicit rhs eval, retval = %i", retval); + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -1596,15 +1622,12 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "Fsi_%i(:) =", step_mem->Fsi[step_mem->stage_map[is]], is); } + } /* compute slow RHS */ - } /* loop over stages */ - SUNLogExtraDebugVec(ARK_LOGGER, __func__, "updated solution", - "ycur(:) =", ark_mem->ycur, ""); + SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); - SUNLogDebug(ARK_LOGGER, __func__, "error-test", - "step = %li, h = %" RSYM ", dsm = %" RSYM, ark_mem->nst, - ark_mem->h, *dsmPtr); + } /* loop over stages */ return (ARK_SUCCESS); } From 8cf4c787587cb73825e707459fba9dda5c9fff9a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 15 Jun 2024 08:18:59 -0700 Subject: [PATCH 041/235] move stage logging to info level --- src/arkode/arkode_arkstep.c | 62 ++++++++++++++++++------------------- src/arkode/arkode_erkstep.c | 24 +++++++------- src/arkode/arkode_mristep.c | 46 +++++++++++++-------------- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index f68c4e7a26..fd8f6bc959 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1826,17 +1826,17 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } } - SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "begin-stage", - "stage = %i, implicit = %i, tcur = %" RSYM, 0, implicit_stage, - ark_mem->tcur); + SUNLogInfoIf(is_start == 1, ARK_LOGGER, __func__, "begin-stage", + "stage = %i, implicit = %i, tcur = %" RSYM, 0, implicit_stage, + ark_mem->tcur); SUNLogExtraDebugVecIf(is_start == 1, ARK_LOGGER, __func__, "explicit stage", "z_%i(:) =", ark_mem->ycur, 0); SUNLogExtraDebugVecIf(is_start == 1 && step_mem->implicit, ARK_LOGGER, __func__, "implicit RHS", "Fi_%i(:) =", step_mem->Fi[0], 0); SUNLogExtraDebugVecIf(is_start == 1 && step_mem->explicit, ARK_LOGGER, __func__, "explicit RHS", "Fe_%i(:) =", step_mem->Fe[0], 0); - SUNLogDebugIf(is_start == 1, ARK_LOGGER, __func__, "end-stage", - "status = success", ""); + SUNLogInfoIf(is_start == 1, ARK_LOGGER, __func__, "end-stage", + "status = success", ""); /* loop over internal stages to the step */ for (is = is_start; is < step_mem->stages; is++) @@ -1861,9 +1861,9 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } else { ark_mem->tcur = ark_mem->tn + step_mem->Be->c[is] * ark_mem->h; } - SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", - "stage = %i, implicit = %i, tcur = %" RSYM, is, implicit_stage, - ark_mem->tcur); + SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", + "stage = %i, implicit = %i, tcur = %" RSYM, is, implicit_stage, + ark_mem->tcur); /* setup time-dependent mass matrix */ if ((step_mem->mass_type == MASS_TIMEDEP) && (step_mem->msetup != NULL)) @@ -1872,8 +1872,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->tempv2, ark_mem->tempv3); if (retval != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed mass setup, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed mass setup, retval = %i", retval); return (ARK_MASSSETUP_FAIL); } } @@ -1893,8 +1893,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->stage_predict(ark_mem->tcur, step_mem->zpred, ark_mem->user_data); - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed predict, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed predict, retval = %i", retval); if (retval < 0) { return (ARK_USER_PREDICT_FAIL); } if (retval > 0) { return (TRY_AGAIN); } } @@ -1907,8 +1907,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = arkStep_StageSetup(ark_mem, implicit_stage); if (retval != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed stage setup, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed stage setup, retval = %i", retval); return (retval); } @@ -1923,8 +1923,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) *nflagPtr = arkStep_Nls(ark_mem, *nflagPtr); if (*nflagPtr != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed solve, nflag = %i", *nflagPtr); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } @@ -1943,8 +1943,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nlscoef); if (*nflagPtr != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed mass solve, nflag = %i", *nflagPtr); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } } @@ -1966,8 +1966,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); if (retval != 0) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed postprocess stage, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -1985,16 +1985,16 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fi(ark_mem->tcur, ark_mem->ycur, step_mem->Fi[is], ark_mem->user_data); step_mem->nfi++; - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed implicit rhs eval, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed implicit rhs eval, retval = %i", retval); } else if (step_mem->mass_type == MASS_FIXED) { retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1); if (retval != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed mass mult, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed mass mult, retval = %i", retval); return (ARK_MASSMULT_FAIL); } @@ -2020,8 +2020,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fe(ark_mem->tn + step_mem->Be->c[is] * ark_mem->h, ark_mem->ycur, step_mem->Fe[is], ark_mem->user_data); step_mem->nfe++; - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed explicit rhs eval, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", retval); SUNLogExtraDebug(ARK_LOGGER, __func__, "explicit RHS", "Fe_%i(:) =", step_mem->Fe[is], is); @@ -2044,8 +2044,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) if (*nflagPtr != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed mass solve, nflag = %i", *nflagPtr); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } } @@ -2057,14 +2057,14 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) "Fe_%i(:) =", step_mem->Fe[is], is); if (*nflagPtr != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed mass solve, nflag = %i", *nflagPtr); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed mass solve, nflag = %i", *nflagPtr); return (TRY_AGAIN); } } } - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", "status = success", ""); } /* loop over stages */ diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 2bcd445ee8..8921c3a1ef 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -626,13 +626,13 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) cvals = step_mem->cvals; Xvecs = step_mem->Xvecs; - SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, - ark_mem->tcur); + SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, + ark_mem->tcur); SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage", "z_0(:) =", ark_mem->ycur, ""); SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", "F_0(:) =", step_mem->F[0], ""); - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", "status = success", ""); /* Call the full RHS if needed. If this is the first step then we may need to evaluate or copy the RHS values from an earlier evaluation (e.g., to @@ -656,8 +656,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage time(s) */ ark_mem->tcur = ark_mem->tn + step_mem->B->c[is] * ark_mem->h; - SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", - "stage = %i, tcur = %" RSYM, is, ark_mem->tcur); + SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", + "stage = %i, tcur = %" RSYM, is, ark_mem->tcur); /* Set ycur to current stage solution */ nvec = 0; @@ -675,8 +675,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = N_VLinearCombination(nvec, cvals, Xvecs, ark_mem->ycur); if (retval != 0) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed vector op, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed vector op, retval = %i", retval); return (ARK_VECTOROP_ERR); } @@ -687,8 +687,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); if (retval != 0) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed postprocess stage, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -698,8 +698,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); step_mem->nfe++; - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed rhs eval, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -707,7 +707,7 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", "F_%i(:) =", step_mem->F[is], is); - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", "status = success", ""); } /* loop over stages */ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index e78621f188..163f87f193 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1490,15 +1490,15 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->fn_is_current = SUNTRUE; } - SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, - ark_mem->tcur); + SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", "stage = 0, tcur = %" RSYM, + ark_mem->tcur); SUNLogExtraDebug(ARK_LOGGER, __func__, "slow stage", "z_0(:) =", ark_mem->ycur, ""); SUNLogExtraDebugVecIf(step_mem->explicit_rhs, ARK_LOGGER, __func__, "slow explicit RHS", "Fse_0(:) =", step_mem->Fse[0], ""); SUNLogExtraDebugVecIf(step_mem->implicit_rhs, ARK_LOGGER, __func__, "slow implicit RHS", "Fsi_0(:) =", step_mem->Fsi[0], ""); - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", "status = success", ""); /* The first stage is the previous time-step solution, so its RHS is the [already-computed] slow RHS from the start of the step */ @@ -1509,9 +1509,9 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage time */ ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; - SUNLogDebug(ARK_LOGGER, __func__, "begin-stage", - "stage = %i, stage type = %d, tcur = %" RSYM, is, - step_mem->stagetypes[is], ark_mem->tcur); + SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", + "stage = %i, stage type = %d, tcur = %" RSYM, is, + step_mem->stagetypes[is], ark_mem->tcur); /* Determine current stage type, and call corresponding routine; the vector ark_mem->ycur stores the previous stage solution on input, and @@ -1520,23 +1520,23 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { case (MRISTAGE_ERK_FAST): retval = mriStep_StageERKFast(ark_mem, step_mem, is); - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed fast ERK stage, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed fast ERK stage, retval = %i", retval); break; case (MRISTAGE_ERK_NOFAST): retval = mriStep_StageERKNoFast(ark_mem, step_mem, is); - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed ERK stage, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed ERK stage, retval = %i", retval); break; case (MRISTAGE_DIRK_NOFAST): retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, is, nflagPtr); - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed DIRK stage, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed DIRK stage, retval = %i", retval); break; case (MRISTAGE_DIRK_FAST): retval = mriStep_StageDIRKFast(ark_mem, step_mem, is, nflagPtr); - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed fast DIRK stage, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed fast DIRK stage, retval = %i", retval); break; } if (retval != ARK_SUCCESS) { return (retval); } @@ -1551,8 +1551,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); if (retval != 0) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed postprocess stage, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed postprocess stage, retval = %i", retval); return (ARK_POSTPROCESS_STAGE_FAIL); } } @@ -1565,8 +1565,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->ycur); if (retval != ARK_SUCCESS) { - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", - "status = failed reset, retval = %i", retval); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed reset, retval = %i", retval); return (ARK_INNERSTEP_FAIL); } } @@ -1583,8 +1583,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); step_mem->nfse++; - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed explicit rhs eval, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -1612,8 +1612,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->Fsi[step_mem->stage_map[is]]); } - SUNLogDebugIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed implicit rhs eval, retval = %i", retval); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed implicit rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } @@ -1625,7 +1625,7 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } /* compute slow RHS */ - SUNLogDebug(ARK_LOGGER, __func__, "end-stage", "status = success", ""); + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", "status = success", ""); } /* loop over stages */ From 7602b41f18732d29256d6c4b82e09b35fbd998c3 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 15 Jun 2024 08:20:04 -0700 Subject: [PATCH 042/235] parse stage logging output --- scripts/sundialsdev/log_example.py | 17 +++++- scripts/sundialsdev/logs.py | 93 +++++++++++++++++++++--------- 2 files changed, 79 insertions(+), 31 deletions(-) diff --git a/scripts/sundialsdev/log_example.py b/scripts/sundialsdev/log_example.py index b2e3670ca0..926d995b42 100755 --- a/scripts/sundialsdev/log_example.py +++ b/scripts/sundialsdev/log_example.py @@ -33,9 +33,6 @@ def main(): choices=['h', 'q', 'dsm'], help='Value to plot (default: %(default)s)') - parser.add_argument('--step-number', action='store_true', - help='Plot value vs step number') - parser.add_argument('--step-range', type=int, nargs=2, default=None, metavar=('LOWER_BOUND', 'UPPER_BOUND'), help='Step range to plot') @@ -44,9 +41,18 @@ def main(): default=None, metavar=('LOWER_BOUND', 'UPPER_BOUND'), help='Time range to plot') + parser.add_argument('--step-number', action='store_true', + help='Plot value vs step number') + parser.add_argument('--scatter', action='store_true', help='Create scatter plot') + parser.add_argument('--logx', action='store_true', + help='Use log scale for x-axis') + + parser.add_argument('--logy', action='store_true', + help='Use log scale for y-axis') + parser.add_argument('--labels', type=str, nargs='+', help='Plot labels') @@ -123,6 +129,11 @@ def main(): ax.scatter(x_sf, vals_sf, color=sf_color, marker='d', label=sf_label, zorder=0.2) + if args.logx: + ax.set_xscale("log") + if args.logy: + ax.set_yscale("log") + if args.step_number: ax.set_xlabel("step") else: diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index dc6d5a04d4..ce24d5f49b 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -100,15 +100,17 @@ def log_file_to_list(filename): """ with open(filename, "r") as logfile: - # List of dictionaries one for each step attempt + # List of step attempt dictionaries, one entry for each step attempt log = [] - # Stack of logs for integrators composed of other integrators e.g., MRI - # methods or splitting methods + # Stack of logs for adding sublists (stage data, algebraic solver data, + # fast integrator data, etc.) to the current log entry log_stack = [] + + # Make step attempt list the active list log_stack.append(log) - # Level for nested integrators e.g., MRI methods + # Time level for nested integrators e.g., MRI methods level = 0 all_lines = logfile.readlines() @@ -117,30 +119,64 @@ def log_file_to_list(filename): if not line_dict: continue - line_dict["level"] = level + line_dict["payload"]["level"] = level + + if line_dict["label"] == "begin-step-attempt": + # Add new step attempt entry to the active list + log_stack[-1].append(line_dict["payload"]) + elif line_dict["label"] == "end-step-attempt": + # Update last step attempt entry + log_stack[-1][-1].update(line_dict["payload"]) + + if (line_dict["label"] == "begin-stage"): + # Add stage sublist to the last entry in the active list + if "stages" not in log_stack[-1][-1]: + log_stack[-1][-1]["stages"] = [] + # Make the stage list the active list + log_stack.append(log_stack[-1][-1]["stages"]) + # Add new stage entry to list + log_stack[-1].append(line_dict["payload"]) + continue + elif (line_dict["label"] == "end-stage"): + # Update last stage entry + log_stack[-1][-1].update(line_dict["payload"]) + # Deactivate stage list + log_stack.pop() + continue if (line_dict["label"] == "begin-fast-steps"): level += 1 - # Possibly multiple fast integrations per step so check if a - # list already exists key = f"time-level-{level}" + # Add fast step sublist to the last entry in the active list if key not in log_stack[-1][-1]: log_stack[-1][-1][key] = [] + # Make the fast step list the active list log_stack.append(log_stack[-1][-1][key]) continue elif (line_dict["label"] == "end-fast-steps"): level -= 1 + # Deactivate fast step list log_stack.pop() continue - if line_dict["label"] == "begin-step-attempt": - log_stack[-1].append(line_dict) - elif line_dict["label"] == "end-step-attempt": - log_stack[-1][-1]["payload"].update(line_dict["payload"]) - return log +def print_log(log, indent=0): + """ + This function prints the list of entries from a log file. + """ + + for entry in log: + for key in entry: + if type(entry[key]) is list: + subindent = indent + 2 + print_log(entry[key], indent=subindent) + else: + spaces = indent * " " + print(f"{spaces}{key} : {entry[key]}") + + def get_history(log, key, step_status = None, time_range = None, step_range = None): """ @@ -151,36 +187,37 @@ def get_history(log, key, step_status = None, time_range = None, times = [] values = [] - for l in log: + for entry in log: - step = np.longlong(l["payload"]['step']) - time = np.double(l["payload"]['t_n']) + step = np.longlong(entry['step']) + time = np.double(entry['t_n']) if time_range is not None: - if time > time_range[1] or time < time_range[0]: + if time < time_range[0] or time > time_range[1]: continue if step_range is not None: - if step > step_range[1] or step < step_range[0]: + if step < step_range[0] or step > step_range[1]: continue if step_status is not None: - if step_status not in l["payload"]['status']: + if step_status not in entry['status']: continue - if key not in l["payload"]: + if key not in entry: continue steps.append(step) times.append(time) - values.append(convert_to_num(l["payload"][key])) - - next_level_key = f'time-level-{l["level"] + 1}' - - if next_level_key in l: - sub_steps, sub_times, sub_values = get_history(l[next_level_key], key) - steps.extend(sub_steps) - times.extend(sub_times) - values.extend(sub_values) + values.append(convert_to_num(entry[key])) + + if "stages" in entry: + for s in entry["stages"]: + next_level_key = f'time-level-{entry["level"] + 1}' + if next_level_key in s: + sub_steps, sub_times, sub_values = get_history(s[next_level_key], key) + steps.extend(sub_steps) + times.extend(sub_times) + values.extend(sub_values) return steps, times, values From da8ea20ee5eb9905eba2937a5770e0d3a9b5b81d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 15 Jun 2024 08:39:53 -0700 Subject: [PATCH 043/235] formatting --- src/arkode/arkode_erkstep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 8921c3a1ef..a5acb1d416 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -656,8 +656,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Set current stage time(s) */ ark_mem->tcur = ark_mem->tn + step_mem->B->c[is] * ark_mem->h; - SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", - "stage = %i, tcur = %" RSYM, is, ark_mem->tcur); + SUNLogInfo(ARK_LOGGER, __func__, "begin-stage", "stage = %i, tcur = %" RSYM, + is, ark_mem->tcur); /* Set ycur to current stage solution */ nvec = 0; From 9a405eac8503625ffd183cace92c6000a9bf46c2 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 14:05:43 -0700 Subject: [PATCH 044/235] skip empty payload --- scripts/sundialsdev/logs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index ce24d5f49b..96d8e514a1 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -41,6 +41,9 @@ def parse_logfile_payload(payload, line_number, all_lines, array_indicator="(:)" for kvpstr in kvpstrs: kvp = kvpstr.split("=") if len(kvp) == 1: + # Check for empty payload + if not kvp[0].strip(): + continue kvp_dict[kvp[0].strip()] = "" else: key, value = kvp From bb39b759d55b54ceeba5da4d613fe52e3661d205 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 14:07:19 -0700 Subject: [PATCH 045/235] clean up vaiable names, comments --- scripts/sundialsdev/logs.py | 83 +++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 96d8e514a1..fcab5ba959 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -103,66 +103,77 @@ def log_file_to_list(filename): """ with open(filename, "r") as logfile: - # List of step attempt dictionaries, one entry for each step attempt - log = [] + # List of step attempts, each entry is a dictionary for one attempt + step_attempts = [] - # Stack of logs for adding sublists (stage data, algebraic solver data, - # fast integrator data, etc.) to the current log entry - log_stack = [] + # Stack of lists to handle sublists for different log scopes e.g., stage + # data, algebraic solver data, fast integrator data, etc. + # + # stack[-1] is the active list of dictionaries + # stage[-1][-1] is the active dictionary + stack = [] # Make step attempt list the active list - log_stack.append(log) + stack.append(step_attempts) # Time level for nested integrators e.g., MRI methods level = 0 + # Read the log file all_lines = logfile.readlines() + for line_number, line in enumerate(all_lines): + line_dict = parse_logfile_line(line.rstrip(), line_number, all_lines) + if not line_dict: continue - line_dict["payload"]["level"] = level - - if line_dict["label"] == "begin-step-attempt": - # Add new step attempt entry to the active list - log_stack[-1].append(line_dict["payload"]) - elif line_dict["label"] == "end-step-attempt": - # Update last step attempt entry - log_stack[-1][-1].update(line_dict["payload"]) - - if (line_dict["label"] == "begin-stage"): - # Add stage sublist to the last entry in the active list - if "stages" not in log_stack[-1][-1]: - log_stack[-1][-1]["stages"] = [] - # Make the stage list the active list - log_stack.append(log_stack[-1][-1]["stages"]) - # Add new stage entry to list - log_stack[-1].append(line_dict["payload"]) + label = line_dict["label"] + + if label == "begin-step-attempt": + # Set the current time level + line_dict["payload"]["level"] = level + # Add new step attempt dictionary to the active list + stack[-1].append(line_dict["payload"]) + continue + elif label == "end-step-attempt": + # Update active step attempt dictionary + stack[-1][-1].update(line_dict["payload"]) + continue + + if label == "begin-stage": + # Add stage sublist to the active dictionary + if "stages" not in stack[-1][-1]: + stack[-1][-1]["stages"] = [] + # Make the stage sublist the active list + stack.append(stack[-1][-1]["stages"]) + # Add new stage dictionary to the active list + stack[-1].append(line_dict["payload"]) continue - elif (line_dict["label"] == "end-stage"): - # Update last stage entry - log_stack[-1][-1].update(line_dict["payload"]) + elif label == "end-stage": + # Update the active stage dictionary + stack[-1][-1].update(line_dict["payload"]) # Deactivate stage list - log_stack.pop() + stack.pop() continue - if (line_dict["label"] == "begin-fast-steps"): + if label == "begin-fast-steps": level += 1 key = f"time-level-{level}" - # Add fast step sublist to the last entry in the active list - if key not in log_stack[-1][-1]: - log_stack[-1][-1][key] = [] - # Make the fast step list the active list - log_stack.append(log_stack[-1][-1][key]) + # Add fast step sublist to the active dictionary + if key not in stack[-1][-1]: + stack[-1][-1][key] = [] + # Make the fast step sublist the active list + stack.append(stack[-1][-1][key]) continue - elif (line_dict["label"] == "end-fast-steps"): + elif label == "end-fast-steps": level -= 1 # Deactivate fast step list - log_stack.pop() + stack.pop() continue - return log + return step_attempts def print_log(log, indent=0): From f58ab3f834eaf803f708704b64d051bbd9f75308 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 14:07:40 -0700 Subject: [PATCH 046/235] update print formatting --- scripts/sundialsdev/logs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index fcab5ba959..c03f39179f 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -181,15 +181,20 @@ def print_log(log, indent=0): This function prints the list of entries from a log file. """ + spaces = indent * " " + for entry in log: + print(f"{spaces}{{") for key in entry: if type(entry[key]) is list: + print(f"{spaces}{key} :") + print(f"{spaces}[") subindent = indent + 2 print_log(entry[key], indent=subindent) + print(f"{spaces}]") else: - spaces = indent * " " print(f"{spaces}{key} : {entry[key]}") - + print(f"{spaces}}}") def get_history(log, key, step_status = None, time_range = None, step_range = None): From 1d897d0ea134d864eed64a1f3501480ea33ef280 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 14:08:18 -0700 Subject: [PATCH 047/235] move Newton logging to info level --- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index ae90e5123c..8771fae8aa 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -191,6 +191,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, SUNAssert(!callLSetup || (callLSetup && NEWTON_CONTENT(NLS)->LSetup), SUN_ERR_ARG_CORRUPT); + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-solve", "", ""); + /* set local shortcut variables */ delta = NEWTON_CONTENT(NLS)->delta; @@ -210,13 +212,9 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* initialize current iteration counter for this solve attempt */ NEWTON_CONTENT(NLS)->curiter = 0; - SUNLogDebug(NLS->sunctx->logger, __func__, "begin-attempt", - "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); - - SUNLogDebug(NLS->sunctx->logger, __func__, "start-iterate", - "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-iterate", + "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); @@ -252,10 +250,10 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, retval = NEWTON_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, NEWTON_CONTENT(NLS)->ctest_data); - SUNLogDebug(NLS->sunctx->logger, __func__, "end-iterate", - "iter = %ld, nni = %ld, wrmsnorm = %.16g", - NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, - N_VWrmsNorm(delta, w)); + SUNLogInfo(NLS->sunctx->logger, __func__, "end-iterate", + "iter = %ld, nni = %ld, wrmsnorm = %.16g", + NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, + N_VWrmsNorm(delta, w)); /* Update here so begin/end logging iterations match */ NEWTON_CONTENT(NLS)->curiter++; @@ -263,10 +261,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* if successful update Jacobian status and return */ if (retval == SUN_SUCCESS) { - SUNLogDebug(NLS->sunctx->logger, __func__, "end-attempt", - "success, iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-solve", + "status = success, nni = %ld", NEWTON_CONTENT(NLS)->niters); NEWTON_CONTENT(NLS)->jcur = SUNFALSE; return SUN_SUCCESS; } @@ -281,9 +277,9 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, break; } - SUNLogDebug(NLS->sunctx->logger, __func__, "start-iterate", - "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-iterate", + "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); @@ -293,11 +289,6 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* all errors go here */ - SUNLogDebug(NLS->sunctx->logger, __func__, "end-attempt", - "failure, iter = %ld, nni = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); - /* If there is a recoverable convergence failure and the Jacobian-related data appears not to be current, increment the convergence failure count, reset the initial correction to zero, and loop again with a call to @@ -319,6 +310,9 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* increment number of convergence failures */ NEWTON_CONTENT(NLS)->nconvfails++; + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-solve", + "status = failure, nni = %ld", NEWTON_CONTENT(NLS)->niters); + /* all error returns exit here */ return (retval); } From aa301aeb3cfa85f46ee3eb160309596945e9e213 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 14:08:39 -0700 Subject: [PATCH 048/235] initial nonlinear solver parsing --- scripts/sundialsdev/logs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index c03f39179f..0f3866eaa6 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -173,6 +173,30 @@ def log_file_to_list(filename): stack.pop() continue + if label == "begin-nonlinear-solve": + # Add nonlinear solve sublist to the active dictionary + if "nonlinear-solve" not in stack[-1][-1]: + stack[-1][-1]["nonlinear-solve"] = [] + # Make the nonlinear solve sublist the active list + stack.append(stack[-1][-1]["nonlinear-solve"]) + continue + elif label == "end-nonlinear-solve": + # Deactivate nonlinear solve list + stack.pop() + continue + + if (label == "begin-iterate"): + # Add new solver iteration dictionary + stack[-1].append(line_dict["payload"]) + continue + elif (label == "end-iterate"): + # Update the active iteration dictionary + stack[-1][-1].update(line_dict["payload"]) + continue + + # Update current step attempt entry with intermediate output + stack[-1][-1].update(line_dict["payload"]) + return step_attempts From 211a7be0c2775434561d8613b12647da52553751 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 15:46:55 -0700 Subject: [PATCH 049/235] use dict for NLS data --- scripts/sundialsdev/logs.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 0f3866eaa6..bb2ec92477 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -174,24 +174,23 @@ def log_file_to_list(filename): continue if label == "begin-nonlinear-solve": - # Add nonlinear solve sublist to the active dictionary if "nonlinear-solve" not in stack[-1][-1]: - stack[-1][-1]["nonlinear-solve"] = [] - # Make the nonlinear solve sublist the active list - stack.append(stack[-1][-1]["nonlinear-solve"]) + stack[-1][-1]["nonlinear-solve"] = {} + stack[-1][-1]["nonlinear-solve"].update(line_dict["payload"]) continue elif label == "end-nonlinear-solve": - # Deactivate nonlinear solve list - stack.pop() + stack[-1][-1]["nonlinear-solve"].update(line_dict["payload"]) continue - if (label == "begin-iterate"): + if (label == "begin-nonlinear-iterate"): + if "iterations" not in stack[-1][-1]["nonlinear-solve"]: + stack[-1][-1]["nonlinear-solve"]["iterations"] = [] # Add new solver iteration dictionary - stack[-1].append(line_dict["payload"]) + stack[-1][-1]["nonlinear-solve"]["iterations"].append(line_dict["payload"]) continue - elif (label == "end-iterate"): + elif (label == "end-nonlinear-iterate"): # Update the active iteration dictionary - stack[-1][-1].update(line_dict["payload"]) + stack[-1][-1]["nonlinear-solve"]["iterations"][-1].update(line_dict["payload"]) continue # Update current step attempt entry with intermediate output @@ -216,10 +215,26 @@ def print_log(log, indent=0): subindent = indent + 2 print_log(entry[key], indent=subindent) print(f"{spaces}]") + elif type(entry[key]) is dict: + print(f"{spaces}{key} :") + print(f"{spaces}{{") + subindent = indent + 2 + subspaces = subindent * " " + for subkey in entry[key]: + if type(entry[key][subkey]) is list: + print(f"{subspaces}{subkey} :") + print(f"{subspaces}[") + subsubindent = subindent + 2 + print_log(entry[key][subkey], indent=subsubindent) + print(f"{subspaces}]") + else: + print(f"{subspaces}{subkey} : {entry[key][subkey]}") + print(f"{spaces}}}") else: print(f"{spaces}{key} : {entry[key]}") print(f"{spaces}}}") + def get_history(log, key, step_status = None, time_range = None, step_range = None): """ From bc853b7dc71177a5d18f877cd45ac56f1b62224b Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 15:47:44 -0700 Subject: [PATCH 050/235] update logging output --- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 8771fae8aa..64b26295f9 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -191,7 +191,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, SUNAssert(!callLSetup || (callLSetup && NEWTON_CONTENT(NLS)->LSetup), SUN_ERR_ARG_CORRUPT); - SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-solve", "", ""); + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-solve", + "tol = %.16g", tol); /* set local shortcut variables */ delta = NEWTON_CONTENT(NLS)->delta; @@ -212,8 +213,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, /* initialize current iteration counter for this solve attempt */ NEWTON_CONTENT(NLS)->curiter = 0; - SUNLogInfo(NLS->sunctx->logger, __func__, "begin-iterate", - "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", + "cur-iter = %ld, total-iters = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ @@ -250,8 +251,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, retval = NEWTON_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, NEWTON_CONTENT(NLS)->ctest_data); - SUNLogInfo(NLS->sunctx->logger, __func__, "end-iterate", - "iter = %ld, nni = %ld, wrmsnorm = %.16g", + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "cur-iter = %ld, total-iters = %ld, update-norm = %.16g", NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, N_VWrmsNorm(delta, w)); @@ -262,7 +263,7 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, if (retval == SUN_SUCCESS) { SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-solve", - "status = success, nni = %ld", NEWTON_CONTENT(NLS)->niters); + "status = success, iters = %ld", NEWTON_CONTENT(NLS)->niters); NEWTON_CONTENT(NLS)->jcur = SUNFALSE; return SUN_SUCCESS; } @@ -277,8 +278,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, break; } - SUNLogInfo(NLS->sunctx->logger, __func__, "begin-iterate", - "iter = %ld, nni = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", + "cur-iter = %ld, total-iters = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ @@ -311,7 +312,7 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, NEWTON_CONTENT(NLS)->nconvfails++; SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-solve", - "status = failure, nni = %ld", NEWTON_CONTENT(NLS)->niters); + "status = failure, iters = %ld", NEWTON_CONTENT(NLS)->niters); /* all error returns exit here */ return (retval); From c5d9fabc2c873b9d5c2b7235f34952d9a29f6232 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 18:45:16 -0700 Subject: [PATCH 051/235] initial linear solver parsing --- scripts/sundialsdev/logs.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index bb2ec92477..41dd32f76d 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -185,12 +185,38 @@ def log_file_to_list(filename): if (label == "begin-nonlinear-iterate"): if "iterations" not in stack[-1][-1]["nonlinear-solve"]: stack[-1][-1]["nonlinear-solve"]["iterations"] = [] + # Make the stage sublist the active list + stack.append(stack[-1][-1]["nonlinear-solve"]["iterations"]) # Add new solver iteration dictionary - stack[-1][-1]["nonlinear-solve"]["iterations"].append(line_dict["payload"]) + stack[-1].append(line_dict["payload"]) continue elif (label == "end-nonlinear-iterate"): # Update the active iteration dictionary - stack[-1][-1]["nonlinear-solve"]["iterations"][-1].update(line_dict["payload"]) + stack[-1][-1].update(line_dict["payload"]) + stack.pop() + continue + + if label == "begin-linear-solve": + if "linear-solve" not in stack[-1][-1]: + stack[-1][-1]["linear-solve"] = {} + stack[-1][-1]["linear-solve"].update(line_dict["payload"]) + continue + elif label == "end-linear-solve": + stack[-1][-1]["linear-solve"].update(line_dict["payload"]) + continue + + if (label == "begin-linear-iterate"): + if "iterations" not in stack[-1][-1]["linear-solve"]: + stack[-1][-1]["linear-solve"]["iterations"] = [] + # Make the stage sublist the active list + stack.append(stack[-1][-1]["linear-solve"]["iterations"]) + # Add new solver iteration dictionary + stack[-1].append(line_dict["payload"]) + continue + elif (label == "end-linear-iterate"): + # Update the active iteration dictionary + stack[-1][-1].update(line_dict["payload"]) + stack.pop() continue # Update current step attempt entry with intermediate output From 404fa4e0d36290587096d91bb56463c5b0b8d57d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 18:45:56 -0700 Subject: [PATCH 052/235] initial linear solver logging updates --- src/cvode/cvode_ls.c | 56 +++++++++++++------- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 75 +++++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 23 deletions(-) diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index a8daa6c043..a549eb59c7 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -1646,10 +1646,9 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, sunrealtype bnorm = ZERO; sunrealtype deltar, delta, w_mean; int curiter, nli_inc, retval; -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - sunrealtype resnorm; - long int nps_inc; -#endif + + /* only used with logging */ + SUNDIALS_MAYBE_UNUSED long int nps_inc; /* access CVLsMem structure */ if (cv_mem->cv_lmem == NULL) @@ -1670,16 +1669,31 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, { deltar = cvls_mem->eplifac * cv_mem->cv_tq[4]; bnorm = N_VWrmsNorm(b, weight); + + SUNLogInfo(CV_LOGGER, __func__, "begin-linear-solve", + "iterative = 1, b-norm = %.16g, b-tol = %.16g, res-tol = %.16g", + bnorm, deltar, deltar * cvls_mem->nrmfac); + if (bnorm <= deltar) { if (curiter > 0) { N_VConst(ZERO, b); } cvls_mem->last_flag = CVLS_SUCCESS; + + SUNLogInfo(CV_LOGGER, __func__, "end-linear-solve", + "status = success small rhs", ""); + return (cvls_mem->last_flag); } /* Adjust tolerance for 2-norm */ delta = deltar * cvls_mem->nrmfac; } - else { delta = ZERO; } + else + { + delta = ZERO; + + SUNLogInfo(CV_LOGGER, __func__, "begin-linear-solve", + "iterative = 0", ""); + } /* Set vectors ycur and fcur for use by the Atimes and Psolve interface routines */ @@ -1695,6 +1709,10 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, cvProcessError(cv_mem, CVLS_SUNLS_FAIL, __LINE__, __func__, __FILE__, "Error in calling SUNLinSolSetScalingVectors"); cvls_mem->last_flag = CVLS_SUNLS_FAIL; + + SUNLogInfo(CV_LOGGER, __func__, "end-linear-solve", + "status = failed set scaling vectors", ""); + return (cvls_mem->last_flag); } @@ -1725,12 +1743,15 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, /* Set zero initial guess flag */ retval = SUNLinSolSetZeroGuess(cvls_mem->LS, SUNTRUE); - if (retval != SUN_SUCCESS) { return (-1); } + if (retval != SUN_SUCCESS) + { + SUNLogInfo(CV_LOGGER, __func__, "end-linear-solve", + "status = failed set zero guess", ""); + return (-1); + } -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG /* Store previous nps value in nps_inc */ nps_inc = cvls_mem->nps; -#endif /* If a user-provided jtsetup routine is supplied, call that here */ if (cvls_mem->jtsetup) @@ -1742,6 +1763,9 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, { cvProcessError(cv_mem, retval, __LINE__, __func__, __FILE__, MSG_LS_JTSETUP_FAILED); + + SUNLogInfo(CV_LOGGER, __func__, "end-linear-solve", + "status = failed J-times setup", ""); return (cvls_mem->last_flag); } } @@ -1758,15 +1782,9 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, } /* Retrieve statistics from iterative linear solvers */ -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - resnorm = ZERO; -#endif nli_inc = 0; if (cvls_mem->iterative) { -#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - if (cvls_mem->LS->ops->resnorm) resnorm = SUNLinSolResNorm(cvls_mem->LS); -#endif if (cvls_mem->LS->ops->numiters) { nli_inc = SUNLinSolNumIters(cvls_mem->LS); @@ -1780,10 +1798,12 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, /* Interpret solver return value */ cvls_mem->last_flag = retval; - SUNLogDebug(CV_LOGGER, __func__, "ls-stats", - "bnorm = %" RSYM ", resnorm = %" RSYM - ", ls_iters = %i, prec_solves = %i", - bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); + SUNLogInfoIf(retval == SUN_SUCCESS, CV_LOGGER, __func__, "end-linear-solve", + "status = success, iters = %i, p-solves = %i", + nli_inc, (int)(cvls_mem->nps - nps_inc)); + SUNLogInfoIf(retval != SUN_SUCCESS, CV_LOGGER, __func__, "end-linear-solve", + "status = failed, retval = %i, iters = %i, p-solves = %i", retval, + nli_inc, (int)(cvls_mem->nps - nps_inc)); switch (retval) { diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 89728f46f0..189d37bc75 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -410,6 +410,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* If preconditioning, check if psolve has been set */ SUNAssert(!(preOnLeft || preOnRight) || psolve, SUN_ERR_ARG_CORRUPT); + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* Set vtemp and V[0] to initial (unscaled) residual r_0 = b - A*x_0 */ if (*zeroguess) { @@ -424,6 +426,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec", ""); + return (LASTFLAG(S)); } N_VLinearSum(ONE, b, -ONE, vtemp, vtemp); @@ -441,6 +447,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve", ""); + return (LASTFLAG(S)); } } @@ -467,16 +477,22 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); *res_norm = r_norm = beta = SUNRsqrt(r_norm); - SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); - if (r_norm <= delta) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = success", + *res_norm); + return (LASTFLAG(S)); } + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = continue", + *res_norm); + /* Initialize rho to avoid compiler warning message */ rho = beta; @@ -501,6 +517,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* Inner loop: generate Krylov sequence and Arnoldi basis */ for (l = 0; l < l_max; l++) { + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + (*nli)++; krydim = l_plus_1 = l + 1; @@ -529,6 +547,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve", ""); + return (LASTFLAG(S)); } } @@ -540,6 +562,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec", ""); + return (LASTFLAG(S)); } @@ -552,6 +578,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve", ""); + return (LASTFLAG(S)); } } @@ -589,6 +619,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, { *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_QRFACT_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed QR factorization", ""); + return (LASTFLAG(S)); } @@ -596,8 +630,9 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); - SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)*nli, *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, + "linear-iterate", "cur-iter = %i, total-iters = %i, res-norm = %.16g", + l + 1, *nli, *res_norm); if (rho <= delta) { @@ -608,6 +643,9 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* Normalize V[l+1] with norm value from the Gram-Schmidt routine */ N_VScale(ONE / Hes[l_plus_1][l], V[l_plus_1], V[l_plus_1]); SUNCheckLastErr(); + + SUNLogInfoIf(l < l_max - 1, S->sunctx->logger, __func__, + "end-linear-iterate", "status = continue", ""); } /* Inner loop is done. Compute the new correction vector xcor */ @@ -619,6 +657,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, { *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_QRSOL_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed QR solve", ""); + return (LASTFLAG(S)); } @@ -651,6 +693,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve", ""); + return (LASTFLAG(S)); } } @@ -674,6 +720,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = success", ""); + return (LASTFLAG(S)); } @@ -701,6 +751,9 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, Xv[k] = V[k]; } SUNCheckCall(N_VLinearCombination(krydim + 1, cv, Xv, V[0])); + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "status = continue", ""); } /* Failed to converge, even after allowed restarts. @@ -723,6 +776,10 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve", ""); + return (LASTFLAG(S)); } } @@ -746,11 +803,19 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_RES_REDUCED; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed residual reduced", ""); + return (LASTFLAG(S)); } *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_CONV_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed max iterations", ""); + return (LASTFLAG(S)); } From 3b790f32177ef91c7870f18ab4f2ad85753d5dfc Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 20:20:09 -0700 Subject: [PATCH 053/235] formatting --- src/cvode/cvode_ls.c | 11 +++++------ src/sunlinsol/spgmr/sunlinsol_spgmr.c | 12 ++++++------ src/sunnonlinsol/newton/sunnonlinsol_newton.c | 6 ++++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index a549eb59c7..a07c9be70c 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -1691,8 +1691,7 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, { delta = ZERO; - SUNLogInfo(CV_LOGGER, __func__, "begin-linear-solve", - "iterative = 0", ""); + SUNLogInfo(CV_LOGGER, __func__, "begin-linear-solve", "iterative = 0", ""); } /* Set vectors ycur and fcur for use by the Atimes and Psolve @@ -1799,11 +1798,11 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, cvls_mem->last_flag = retval; SUNLogInfoIf(retval == SUN_SUCCESS, CV_LOGGER, __func__, "end-linear-solve", - "status = success, iters = %i, p-solves = %i", - nli_inc, (int)(cvls_mem->nps - nps_inc)); + "status = success, iters = %i, p-solves = %i", nli_inc, + (int)(cvls_mem->nps - nps_inc)); SUNLogInfoIf(retval != SUN_SUCCESS, CV_LOGGER, __func__, "end-linear-solve", - "status = failed, retval = %i, iters = %i, p-solves = %i", retval, - nli_inc, (int)(cvls_mem->nps - nps_inc)); + "status = failed, retval = %i, iters = %i, p-solves = %i", + retval, nli_inc, (int)(cvls_mem->nps - nps_inc)); switch (retval) { diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 189d37bc75..cdc1b05594 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -630,9 +630,9 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); - SUNLogInfo(S->sunctx->logger, __func__, - "linear-iterate", "cur-iter = %i, total-iters = %i, res-norm = %.16g", - l + 1, *nli, *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, total-iters = %i, res-norm = %.16g", l + 1, + *nli, *res_norm); if (rho <= delta) { @@ -659,7 +659,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, LASTFLAG(S) = SUNLS_QRSOL_FAIL; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed QR solve", ""); + "status = failed QR solve", ""); return (LASTFLAG(S)); } @@ -752,8 +752,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, } SUNCheckCall(N_VLinearCombination(krydim + 1, cv, Xv, V[0])); - SUNLogInfo(S->sunctx->logger, __func__, - "end-linear-iterate", "status = continue", ""); + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = continue", ""); } /* Failed to converge, even after allowed restarts. diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 64b26295f9..c59e7ec267 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -214,7 +214,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, NEWTON_CONTENT(NLS)->curiter = 0; SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", - "cur-iter = %ld, total-iters = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + "cur-iter = %ld, total-iters = %ld", + (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ @@ -279,7 +280,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, } SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", - "cur-iter = %ld, total-iters = %ld", (long int)NEWTON_CONTENT(NLS)->curiter, + "cur-iter = %ld, total-iters = %ld", + (long int)NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters); /* compute the nonlinear residual, store in delta */ From d914757e65a5c91f82a5347bc4e2559ed440eac7 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 21:36:55 -0700 Subject: [PATCH 054/235] update nonlinear solver logging --- src/cvode/cvode.c | 14 +++++- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 45 +++++++++---------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index ea54aab932..d4e805e74c 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -3048,6 +3048,9 @@ static int cvNls(CVodeMem cv_mem, int nflag) if (flag > 0) { return (SUN_NLS_CONV_RECVR); } } + SUNLogInfo(CV_LOGGER, __func__, "begin-nonlinear-solve", + "tol = %.16g", cv_mem->cv_tq[4]); + /* solve the nonlinear system */ flag = SUNNonlinSolSolve(cv_mem->NLS, cv_mem->cv_zn[0], cv_mem->cv_acor, cv_mem->cv_ewt, cv_mem->cv_tq[4], callSetup, cv_mem); @@ -3060,7 +3063,13 @@ static int cvNls(CVodeMem cv_mem, int nflag) cv_mem->cv_nnf += nnf_inc; /* if the solve failed return */ - if (flag != SUN_SUCCESS) { return (flag); } + if (flag != SUN_SUCCESS) + { + SUNLogInfo(CV_LOGGER, __func__, "end-nonlinear-solve", + "status = failed, flag = %i, iters = %li", flag, nni_inc); + + return (flag); + } /* solve successful */ @@ -3073,6 +3082,9 @@ static int cvNls(CVodeMem cv_mem, int nflag) cv_mem->cv_acnrm = N_VWrmsNorm(cv_mem->cv_acor, cv_mem->cv_ewt); } + SUNLogInfo(CV_LOGGER, __func__, "end-nonlinear-solve", + "status = success, iters = %li", nni_inc); + /* update Jacobian status */ cv_mem->cv_jcur = SUNFALSE; diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index c59e7ec267..321c279453 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -191,9 +191,6 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, SUNAssert(!callLSetup || (callLSetup && NEWTON_CONTENT(NLS)->LSetup), SUN_ERR_ARG_CORRUPT); - SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-solve", - "tol = %.16g", tol); - /* set local shortcut variables */ delta = NEWTON_CONTENT(NLS)->delta; @@ -210,14 +207,11 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, Perform Newton iteration */ for (;;) { + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", "", ""); + /* initialize current iteration counter for this solve attempt */ NEWTON_CONTENT(NLS)->curiter = 0; - SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", - "cur-iter = %ld, total-iters = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); - /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); if (retval != SUN_SUCCESS) { break; } @@ -252,19 +246,18 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, retval = NEWTON_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, NEWTON_CONTENT(NLS)->ctest_data); - SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", - "cur-iter = %ld, total-iters = %ld, update-norm = %.16g", - NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, - N_VWrmsNorm(delta, w)); - - /* Update here so begin/end logging iterations match */ NEWTON_CONTENT(NLS)->curiter++; + SUNLogInfo(NLS->sunctx->logger, __func__, "nonlinear-iterate", + "cur-iter = %i, total-iters = %li, update-norm = %.16g", + NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters, + N_VWrmsNorm(delta, w)); + /* if successful update Jacobian status and return */ if (retval == SUN_SUCCESS) { - SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-solve", - "status = success, iters = %ld", NEWTON_CONTENT(NLS)->niters); + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = success", ""); NEWTON_CONTENT(NLS)->jcur = SUNFALSE; return SUN_SUCCESS; } @@ -279,10 +272,10 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, break; } + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = continue", ""); SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", - "cur-iter = %ld, total-iters = %ld", - (long int)NEWTON_CONTENT(NLS)->curiter, - NEWTON_CONTENT(NLS)->niters); + "", ""); /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); @@ -304,18 +297,24 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, jbad = SUNTRUE; N_VConst(ZERO, ycor); SUNCheckLastErr(); + + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = continue", ""); + continue; } - else { break; } + else + { + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = failure, retval = %i", retval); + break; + } } /* end of setup loop */ /* increment number of convergence failures */ NEWTON_CONTENT(NLS)->nconvfails++; - SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-solve", - "status = failure, iters = %ld", NEWTON_CONTENT(NLS)->niters); - /* all error returns exit here */ return (retval); } From cdccb581b11ad45f0d47b497d8e6cec27f4c47e8 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 21 Jun 2024 22:17:30 -0700 Subject: [PATCH 055/235] add empty dict when creating a new list --- scripts/sundialsdev/logs.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 41dd32f76d..fd8b4347f1 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -135,7 +135,8 @@ def log_file_to_list(filename): # Set the current time level line_dict["payload"]["level"] = level # Add new step attempt dictionary to the active list - stack[-1].append(line_dict["payload"]) + stack[-1].append({}) + stack[-1][-1].update(line_dict["payload"]) continue elif label == "end-step-attempt": # Update active step attempt dictionary @@ -149,7 +150,8 @@ def log_file_to_list(filename): # Make the stage sublist the active list stack.append(stack[-1][-1]["stages"]) # Add new stage dictionary to the active list - stack[-1].append(line_dict["payload"]) + stack[-1].append({}) + stack[-1][-1].update(line_dict["payload"]) continue elif label == "end-stage": # Update the active stage dictionary @@ -188,7 +190,8 @@ def log_file_to_list(filename): # Make the stage sublist the active list stack.append(stack[-1][-1]["nonlinear-solve"]["iterations"]) # Add new solver iteration dictionary - stack[-1].append(line_dict["payload"]) + stack[-1].append({}) + stack[-1][-1].update(line_dict["payload"]) continue elif (label == "end-nonlinear-iterate"): # Update the active iteration dictionary @@ -211,7 +214,8 @@ def log_file_to_list(filename): # Make the stage sublist the active list stack.append(stack[-1][-1]["linear-solve"]["iterations"]) # Add new solver iteration dictionary - stack[-1].append(line_dict["payload"]) + stack[-1].append({}) + stack[-1][-1].update(line_dict["payload"]) continue elif (label == "end-linear-iterate"): # Update the active iteration dictionary From d482e0c7a6a390f816ff7200ce2197fd435d1582 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 22 Jun 2024 01:09:47 -0700 Subject: [PATCH 056/235] update var names --- scripts/sundialsdev/logs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index fd8b4347f1..e9a5794d73 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -162,12 +162,12 @@ def log_file_to_list(filename): if label == "begin-fast-steps": level += 1 - key = f"time-level-{level}" + level_key = f"time-level-{level}" # Add fast step sublist to the active dictionary - if key not in stack[-1][-1]: - stack[-1][-1][key] = [] + if level_key not in stack[-1][-1]: + stack[-1][-1][level_key] = [] # Make the fast step sublist the active list - stack.append(stack[-1][-1][key]) + stack.append(stack[-1][-1][level_key]) continue elif label == "end-fast-steps": level -= 1 From cfd7c31862748f702d4417880fdc70e08688f6fa Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 24 Jun 2024 10:41:09 -0700 Subject: [PATCH 057/235] logging updates --- src/arkode/arkode_arkstep_nls.c | 11 +++++++++++ src/sunlinsol/spgmr/sunlinsol_spgmr.c | 2 ++ src/sunnonlinsol/newton/sunnonlinsol_newton.c | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index fb229d8931..70df6b3cac 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -418,6 +418,9 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) /* Reset the stored residual norm (for iterative linear solvers) */ step_mem->eRNrm = SUN_RCONST(0.1) * step_mem->nlscoef; + SUNLogInfo(ARK_LOGGER, __func__, "begin-nonlinear-solve", + "tol = %.16g", step_mem->nlscoef); + /* solve the nonlinear system for the actual correction */ retval = SUNNonlinSolSolve(step_mem->NLS, step_mem->zpred, step_mem->zcor, ark_mem->ewt, step_mem->nlscoef, callLSetup, @@ -438,9 +441,17 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) { step_mem->jcur = SUNFALSE; N_VLinearSum(ONE, step_mem->zcor, ONE, step_mem->zpred, ark_mem->ycur); + + SUNLogInfo(ARK_LOGGER, __func__, "end-nonlinear-solve", + "status = success, iters = %li", nls_iters_inc); + return (ARK_SUCCESS); } + SUNLogInfo(ARK_LOGGER, __func__, "end-nonlinear-solve", + "status = failed, retval = %i, iters = %li", retval, nls_iters_inc); + + /* check for recoverable failure, return ARKODE::CONV_FAIL */ if (retval == SUN_NLS_CONV_RECVR) { return (CONV_FAIL); } diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index cdc1b05594..06ac032b1a 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -410,6 +410,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* If preconditioning, check if psolve has been set */ SUNAssert(!(preOnLeft || preOnRight) || psolve, SUN_ERR_ARG_CORRUPT); + SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = spgmr", ""); + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); /* Set vtemp and V[0] to initial (unscaled) residual r_0 = b - A*x_0 */ diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 321c279453..33f4b07e6b 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -191,6 +191,9 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, SUNAssert(!callLSetup || (callLSetup && NEWTON_CONTENT(NLS)->LSetup), SUN_ERR_ARG_CORRUPT); + SUNLogInfo(NLS->sunctx->logger, __func__, "nonlinear-solver", + "solver = Newton", ""); + /* set local shortcut variables */ delta = NEWTON_CONTENT(NLS)->delta; From 3358d577923b16a706ae9fa3da1ac12cad5725ab Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 24 Jun 2024 10:40:48 -0700 Subject: [PATCH 058/235] Add class to help with parsing log data --- scripts/sundialsdev/logs.py | 194 +++++++++++++++++++++--------------- 1 file changed, 116 insertions(+), 78 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index e9a5794d73..bc44d09543 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -18,6 +18,7 @@ import re import numpy as np +from collections import ChainMap def convert_to_num(s): """Try to convert a string to an int or float""" @@ -85,6 +86,78 @@ def parse_logfile_line(line, line_number, all_lines): return line_dict +class StepData: + def __init__(self): + self.container = [ChainMap()] + self.parent_keys = ['main'] + self.open_dicts = 0 + self.open_lists = 0 + self.total_dicts = 0 + self.total_lists = 0 + + def __repr__(self): + tmp = "Container:" + for l in self.container: + tmp += f"\n {l}" + tmp += "\nParent Keys:" + for l in self.parent_keys: + tmp += f"\n {l}" + tmp += f"\nOpen dicts: {self.open_dicts}" + tmp += f"\nOpen lists: {self.open_lists}" + tmp += f"\nTotal dicts: {self.total_dicts}" + tmp += f"\nTotal lists: {self.total_lists}" + return tmp + + def update(self, data): + """Update the active dictionary""" + self.container[-1].update(data) + + def open_dict(self, key): + """Activate a dictionary""" + self.container[-1][key] = {} + self.container[-1] = self.container[-1].new_child(self.container[-1][key]) + self.open_dicts += 1 + self.total_dicts += 1 + + def close_dict(self): + """Deactivate the active dictionary""" + self.container[-1] = self.container[-1].parents + self.open_dicts -= 1 + + def open_list(self, key): + """Activate a list of dictionaries""" + if key in self.container[-1]: + self.container.append(ChainMap()) + else: + self.container[-1][key] = [] + self.container.append(ChainMap()) + self.parent_keys.append(key) + self.open_lists += 1 + self.total_lists += 1 + + def close_list(self): + """Deactivate a the active list""" + # I think should only ever have one entry. In which case we don't need + # a ChainMap and could just manage the dictionaries manually + tmp = self.container[-1].maps[0] + self.container[-2][self.parent_keys[-1]].append(tmp) + self.parent_keys.pop() + self.container.pop() + self.open_lists -= 1 + + def get_step(self): + """Get the step dictionary and reset the container""" + tmp = self.container.pop().maps[0] + self.container = [ChainMap()] + # At this point we should already be back to main, add sanity check + self.parent_keys = ['main'] + self.open_dicts = 0 + self.open_lists = 0 + self.total_dicts = 0 + self.total_lists = 0 + return tmp + + def log_file_to_list(filename): """ This function takes a SUNDIALS log file and creates a list where each list @@ -106,22 +179,14 @@ def log_file_to_list(filename): # List of step attempts, each entry is a dictionary for one attempt step_attempts = [] - # Stack of lists to handle sublists for different log scopes e.g., stage - # data, algebraic solver data, fast integrator data, etc. - # - # stack[-1] is the active list of dictionaries - # stage[-1][-1] is the active dictionary - stack = [] - - # Make step attempt list the active list - stack.append(step_attempts) - # Time level for nested integrators e.g., MRI methods level = 0 # Read the log file all_lines = logfile.readlines() + s = StepData() + for line_number, line in enumerate(all_lines): line_dict = parse_logfile_line(line.rstrip(), line_number, all_lines) @@ -132,99 +197,72 @@ def log_file_to_list(filename): label = line_dict["label"] if label == "begin-step-attempt": - # Set the current time level line_dict["payload"]["level"] = level - # Add new step attempt dictionary to the active list - stack[-1].append({}) - stack[-1][-1].update(line_dict["payload"]) + if level > 0: + s.open_list(f"time-level-{level}") + s.update(line_dict["payload"]) continue elif label == "end-step-attempt": - # Update active step attempt dictionary - stack[-1][-1].update(line_dict["payload"]) - continue - - if label == "begin-stage": - # Add stage sublist to the active dictionary - if "stages" not in stack[-1][-1]: - stack[-1][-1]["stages"] = [] - # Make the stage sublist the active list - stack.append(stack[-1][-1]["stages"]) - # Add new stage dictionary to the active list - stack[-1].append({}) - stack[-1][-1].update(line_dict["payload"]) - continue - elif label == "end-stage": - # Update the active stage dictionary - stack[-1][-1].update(line_dict["payload"]) - # Deactivate stage list - stack.pop() - continue - - if label == "begin-fast-steps": - level += 1 - level_key = f"time-level-{level}" - # Add fast step sublist to the active dictionary - if level_key not in stack[-1][-1]: - stack[-1][-1][level_key] = [] - # Make the fast step sublist the active list - stack.append(stack[-1][-1][level_key]) - continue - elif label == "end-fast-steps": - level -= 1 - # Deactivate fast step list - stack.pop() + s.update(line_dict["payload"]) + if level > 0: + s.close_list() + else: + step_attempts.append(s.get_step()) continue if label == "begin-nonlinear-solve": - if "nonlinear-solve" not in stack[-1][-1]: - stack[-1][-1]["nonlinear-solve"] = {} - stack[-1][-1]["nonlinear-solve"].update(line_dict["payload"]) + s.open_dict("nonlinear-solve") + s.update(line_dict["payload"]) continue elif label == "end-nonlinear-solve": - stack[-1][-1]["nonlinear-solve"].update(line_dict["payload"]) + s.update(line_dict["payload"]) + s.close_dict() continue if (label == "begin-nonlinear-iterate"): - if "iterations" not in stack[-1][-1]["nonlinear-solve"]: - stack[-1][-1]["nonlinear-solve"]["iterations"] = [] - # Make the stage sublist the active list - stack.append(stack[-1][-1]["nonlinear-solve"]["iterations"]) - # Add new solver iteration dictionary - stack[-1].append({}) - stack[-1][-1].update(line_dict["payload"]) + s.open_list('iterations') + s.update(line_dict["payload"]) continue elif (label == "end-nonlinear-iterate"): - # Update the active iteration dictionary - stack[-1][-1].update(line_dict["payload"]) - stack.pop() + s.update(line_dict["payload"]) + s.close_list() continue if label == "begin-linear-solve": - if "linear-solve" not in stack[-1][-1]: - stack[-1][-1]["linear-solve"] = {} - stack[-1][-1]["linear-solve"].update(line_dict["payload"]) + s.open_dict("linear-solve") + s.update(line_dict["payload"]) continue elif label == "end-linear-solve": - stack[-1][-1]["linear-solve"].update(line_dict["payload"]) + s.update(line_dict["payload"]) + s.close_dict() continue if (label == "begin-linear-iterate"): - if "iterations" not in stack[-1][-1]["linear-solve"]: - stack[-1][-1]["linear-solve"]["iterations"] = [] - # Make the stage sublist the active list - stack.append(stack[-1][-1]["linear-solve"]["iterations"]) - # Add new solver iteration dictionary - stack[-1].append({}) - stack[-1][-1].update(line_dict["payload"]) + s.open_list('iterations') + s.update(line_dict["payload"]) continue elif (label == "end-linear-iterate"): - # Update the active iteration dictionary - stack[-1][-1].update(line_dict["payload"]) - stack.pop() + s.update(line_dict["payload"]) + s.close_list() + continue + + if label == "begin-stage": + s.open_list('stages') + s.update(line_dict["payload"]) + continue + elif label == "end-stage": + s.update(line_dict["payload"]) + s.close_list() + continue + + if label == "begin-fast-steps": + level += 1 + continue + elif label == "end-fast-steps": + level -= 1 continue - # Update current step attempt entry with intermediate output - stack[-1][-1].update(line_dict["payload"]) + s.update(line_dict["payload"]) return step_attempts From 4ccc9330d77df9ac8676dea35c73a548620a8e56 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 24 Jun 2024 13:17:47 -0700 Subject: [PATCH 059/235] correct comment --- scripts/sundialsdev/logs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index bc44d09543..831ae41f5a 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -137,8 +137,8 @@ def open_list(self, key): def close_list(self): """Deactivate a the active list""" - # I think should only ever have one entry. In which case we don't need - # a ChainMap and could just manage the dictionaries manually + # I think the Chain map will only ever have one entry. In which case we + # don't need a ChainMap and could just manage the dictionaries manually tmp = self.container[-1].maps[0] self.container[-2][self.parent_keys[-1]].append(tmp) self.parent_keys.pop() From 9849d083dc8dddc91a8f7f2d295d900de1f8c9b4 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 24 Jun 2024 13:19:55 -0700 Subject: [PATCH 060/235] update comments --- scripts/sundialsdev/logs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index 831ae41f5a..b5cb6c5356 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -138,7 +138,9 @@ def open_list(self, key): def close_list(self): """Deactivate a the active list""" # I think the Chain map will only ever have one entry. In which case we - # don't need a ChainMap and could just manage the dictionaries manually + # don't need a ChainMap and could just manage the dictionaries manually. + # However, open and close dict still relies on the dict references to + # update nested dictionaries, so maybe not. tmp = self.container[-1].maps[0] self.container[-2][self.parent_keys[-1]].append(tmp) self.parent_keys.pop() From 246ce4562aa00612715f9aac1e3a901d3dfda457 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 24 Jun 2024 13:24:02 -0700 Subject: [PATCH 061/235] formatting --- src/arkode/arkode_arkstep_nls.c | 5 ++--- src/cvode/cvode.c | 4 ++-- src/sunnonlinsol/newton/sunnonlinsol_newton.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index 70df6b3cac..985d31f0bc 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -418,8 +418,8 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) /* Reset the stored residual norm (for iterative linear solvers) */ step_mem->eRNrm = SUN_RCONST(0.1) * step_mem->nlscoef; - SUNLogInfo(ARK_LOGGER, __func__, "begin-nonlinear-solve", - "tol = %.16g", step_mem->nlscoef); + SUNLogInfo(ARK_LOGGER, __func__, "begin-nonlinear-solve", "tol = %.16g", + step_mem->nlscoef); /* solve the nonlinear system for the actual correction */ retval = SUNNonlinSolSolve(step_mem->NLS, step_mem->zpred, step_mem->zcor, @@ -451,7 +451,6 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) SUNLogInfo(ARK_LOGGER, __func__, "end-nonlinear-solve", "status = failed, retval = %i, iters = %li", retval, nls_iters_inc); - /* check for recoverable failure, return ARKODE::CONV_FAIL */ if (retval == SUN_NLS_CONV_RECVR) { return (CONV_FAIL); } diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index d4e805e74c..9c5d2e4378 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -3048,8 +3048,8 @@ static int cvNls(CVodeMem cv_mem, int nflag) if (flag > 0) { return (SUN_NLS_CONV_RECVR); } } - SUNLogInfo(CV_LOGGER, __func__, "begin-nonlinear-solve", - "tol = %.16g", cv_mem->cv_tq[4]); + SUNLogInfo(CV_LOGGER, __func__, "begin-nonlinear-solve", "tol = %.16g", + cv_mem->cv_tq[4]); /* solve the nonlinear system */ flag = SUNNonlinSolSolve(cv_mem->NLS, cv_mem->cv_zn[0], cv_mem->cv_acor, diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index 33f4b07e6b..fb66660464 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -277,8 +277,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", "status = continue", ""); - SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", - "", ""); + SUNLogInfo(NLS->sunctx->logger, __func__, "begin-nonlinear-iterate", "", + ""); /* compute the nonlinear residual, store in delta */ retval = NEWTON_CONTENT(NLS)->Sys(ycor, delta, mem); From 5fe0efb4ddcccf22d95d288c52d8c3e0e889f3ac Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Mon, 24 Jun 2024 13:30:39 -0700 Subject: [PATCH 062/235] update function to print the log --- scripts/sundialsdev/logs.py | 49 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index b5cb6c5356..ea08317ad7 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -269,36 +269,57 @@ def log_file_to_list(filename): return step_attempts +def print_log_list(a_list, indent=0): + spaces = indent * " " + subspaces = (indent + 2) * " " + for entry in a_list: + if type(entry) is list: + print(f"{spaces}[") + print_list(entry, indent) + print(f"{spaces}]") + elif type(entry) is dict: + print(f"{subspaces}{{") + print_dict(entry, indent+2) + print(f"{subspaces}}}") + else: + print(f"{space}{entry}") + + +def print_log_dict(a_dict, indent=0): + spaces = indent * " " + for key in a_dict: + if type(a_dict[key]) is list: + print(f"{spaces}{key} :") + print(f"{spaces}[") + print_list(a_dict[key], indent=indent) + print(f"{spaces}]") + elif type(a_dict[key]) is dict: + print(f"{spaces}{key} :") + print(f"{spaces}{{") + print_dict(a_dict[key], indent=indent+2) + print(f"{spaces}}}") + else: + print(f"{spaces}{key} : {a_dict[key]}") + + def print_log(log, indent=0): """ This function prints the list of entries from a log file. """ spaces = indent * " " - for entry in log: print(f"{spaces}{{") for key in entry: if type(entry[key]) is list: print(f"{spaces}{key} :") print(f"{spaces}[") - subindent = indent + 2 - print_log(entry[key], indent=subindent) + print_log_list(entry[key], indent=indent) print(f"{spaces}]") elif type(entry[key]) is dict: print(f"{spaces}{key} :") print(f"{spaces}{{") - subindent = indent + 2 - subspaces = subindent * " " - for subkey in entry[key]: - if type(entry[key][subkey]) is list: - print(f"{subspaces}{subkey} :") - print(f"{subspaces}[") - subsubindent = subindent + 2 - print_log(entry[key][subkey], indent=subsubindent) - print(f"{subspaces}]") - else: - print(f"{subspaces}{subkey} : {entry[key][subkey]}") + print_log_dict(entry[key], indent=indent) print(f"{spaces}}}") else: print(f"{spaces}{key} : {entry[key]}") From 77ad8973a313e80747afc14cc0c7a9d4208f5e7a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 08:59:47 -0700 Subject: [PATCH 063/235] update PCG logging --- src/sunlinsol/pcg/sunlinsol_pcg.c | 66 +++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 1e6b30d4d8..3f64f5cac5 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -311,6 +311,10 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, /* If preconditioning, check if psolve has been set */ SUNAssert(!UsePrec || psolve, SUN_ERR_ARG_CORRUPT); + SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = pcg", ""); + + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* Set r to initial residual r_0 = b - A*x_0 */ if (*zeroguess) { @@ -325,6 +329,10 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec", ""); + return (LASTFLAG(S)); } N_VLinearSum(ONE, b, -ONE, r, r); @@ -346,13 +354,15 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, SUNCheckLastErr(); *res_norm = r0_norm = rho = SUNRsqrt(rho); - SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); - if (rho <= delta) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = success", + *res_norm); + return (LASTFLAG(S)); } @@ -365,6 +375,11 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = failed preconditioner solve", + *res_norm); + return (LASTFLAG(S)); } } @@ -382,9 +397,15 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, N_VScale(ONE, z, p); SUNCheckLastErr(); + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = continue", + *res_norm); + /* Begin main iteration loop */ for (l = 0; l < l_max; l++) { + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* increment counter */ (*nli)++; @@ -395,6 +416,10 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec", ""); + return (LASTFLAG(S)); } @@ -434,8 +459,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, SUNCheckLastErr(); *res_norm = rho = SUNRsqrt(rho); - SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, res-norm = %.16g", *nli, *res_norm); if (rho <= delta) { @@ -455,6 +480,10 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve", ""); + return (LASTFLAG(S)); } } @@ -475,13 +504,34 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, /* Update p = z + beta*p */ N_VLinearSum(ONE, z, beta, p, p); SUNCheckLastErr(); + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "status = continue", ""); } /* Main loop finished, return with result */ *zeroguess = SUNFALSE; - if (converged == SUNTRUE) { LASTFLAG(S) = SUN_SUCCESS; } - else if (rho < r0_norm) { LASTFLAG(S) = SUNLS_RES_REDUCED; } - else { LASTFLAG(S) = SUNLS_CONV_FAIL; } + if (converged == SUNTRUE) + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = success", ""); + + LASTFLAG(S) = SUN_SUCCESS; + } + else if (rho < r0_norm) + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed residual reduced", ""); + + LASTFLAG(S) = SUNLS_RES_REDUCED; + } + else + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed max iterations", ""); + + LASTFLAG(S) = SUNLS_CONV_FAIL; + } return (LASTFLAG(S)); } From 4d20fe996de390c47dbdfb84f81791882fd7ed53 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 09:17:14 -0700 Subject: [PATCH 064/235] update fixed-point logging --- .../fixedpoint/sunnonlinsol_fixedpoint.c | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 0e9eee0884..4e09214a94 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -182,6 +182,9 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, /* check that all required function pointers have been set */ SUNAssert(FP_CONTENT(NLS)->Sys && FP_CONTENT(NLS)->CTest, SUN_ERR_ARG_CORRUPT); + SUNLogInfo(NLS->sunctx->logger, __func__, "nonlinear-solver", + "solver = Fixed-Point", ""); + /* set local shortcut variables */ yprev = FP_CONTENT(NLS)->yprev; gy = FP_CONTENT(NLS)->gy; @@ -191,9 +194,6 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, FP_CONTENT(NLS)->niters = 0; FP_CONTENT(NLS)->nconvfails = 0; - SUNLogDebug(NLS->sunctx->logger, __func__, "begin-iteration", - "iter = %ld, nni = %ld", (long int)0, FP_CONTENT(NLS)->niters); - /* Looping point for attempts at solution of the nonlinear system: Evaluate fixed-point function (store in gy). Performs the accelerated fixed-point iteration. @@ -202,6 +202,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, FP_CONTENT(NLS)->curiter < FP_CONTENT(NLS)->maxiters; FP_CONTENT(NLS)->curiter++) { + SUNLogDebug(NLS->sunctx->logger, __func__, "begin-iteration", "", ""); + /* update previous solution guess */ N_VScale(ONE, ycor, yprev); SUNCheckLastErr(); @@ -211,7 +213,12 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, callback and returns integrator specific error values where 0 == success, < 0 is a failure, > 0 is recoverable error. */ retval = FP_CONTENT(NLS)->Sys(ycor, gy, mem); - if (retval != 0) { return retval; } + if (retval != 0) + { + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = failed nonlinear system evaluation, retval = %d", retval); + return retval; + } /* perform fixed point update, based on choice of acceleration or not */ if (FP_CONTENT(NLS)->m == 0) @@ -236,23 +243,36 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, retval = FP_CONTENT(NLS)->CTest(NLS, ycor, delta, tol, w, FP_CONTENT(NLS)->ctest_data); - SUNLogDebug(NLS->sunctx->logger, __func__, "end-of-iterate", - "iter = %ld, nni = %ld, wrmsnorm = %.16g", - (long int)FP_CONTENT(NLS)->curiter, FP_CONTENT(NLS)->niters, + SUNLogDebug(NLS->sunctx->logger, __func__, "nonlinear-iterate", + "cur-iter = %d, update-norm = %.16g", FP_CONTENT(NLS)->niters, N_VWrmsNorm(delta, w)); /* return if successful */ - if (retval == 0) { return SUN_SUCCESS; } + if (retval == 0) + { + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = success", ""); + return SUN_SUCCESS; + } /* check if the iterations should continue; otherwise increment the convergence failure count and return error flag */ if (retval != SUN_NLS_CONTINUE) { + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = failed, retval = %d", retval); FP_CONTENT(NLS)->nconvfails++; return (retval); } + + SUNLogInfoIf(FP_CONTENT(NLS)->curiter < FP_CONTENT(NLS)->maxiters - 1, + NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = continue", ""); } + SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", + "status = failed max iterations", ""); + /* if we've reached this point, then we exhausted the iteration limit; increment the convergence failure count and return */ FP_CONTENT(NLS)->nconvfails++; From 2a80714697b383e3c57d2ce481facee02640840b Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 10:08:28 -0700 Subject: [PATCH 065/235] update spbcgs logging --- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 85 +++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 7 deletions(-) diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index e5219a5897..0c5d59a7db 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -348,11 +348,19 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, scale_x = (sx != NULL); scale_b = (sb != NULL); + SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = spbcgs", ""); + + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* Check for unsupported use case */ if (preOnRight && !(*zeroguess)) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_ERR_ARG_INCOMPATIBLE; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed unsupported configuration", ""); + return SUN_ERR_ARG_INCOMPATIBLE; } @@ -377,6 +385,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } N_VLinearSum(ONE, b, -ONE, r_star, r_star); @@ -393,6 +405,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -423,16 +439,22 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = r_norm = rho = SUNRsqrt(beta_denom); - SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); - if (r_norm <= delta) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, res-norm = %.16g, status = success", + *res_norm); + return (LASTFLAG(S)); } + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, res-norm = %.16g, status = continue", + *res_norm); + /* Copy r_star to r and p */ N_VScale(ONE, r_star, r); @@ -451,6 +473,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, for (l = 0; l < l_max; l++) { + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + (*nli)++; /* Generate Ap = A-tilde p, where A-tilde = sb P1_inv A P2_inv sx_inv */ @@ -480,6 +504,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -492,6 +520,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = ", status); + return (LASTFLAG(S)); } @@ -505,6 +537,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -565,6 +601,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -577,6 +617,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } @@ -590,6 +634,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -651,8 +699,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *res_norm = rho = SUNRsqrt(N_VDotProd(r, r)); SUNCheckLastErr(); - SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, res-norm = %.16g", *nli, *res_norm); if (rho <= delta) { @@ -681,6 +729,9 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* update beta_denom for next iteration */ beta_denom = beta_num; + + SUNLogInfoIf(l < l_max - 1, S->sunctx->logger, __func__, + "end-linear-iterate", "status = continue", ""); } /* Main loop finished */ @@ -702,6 +753,10 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } N_VScale(ONE, vtemp, x); @@ -709,14 +764,30 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, } *zeroguess = SUNFALSE; - if (converged == SUNTRUE) { LASTFLAG(S) = SUN_SUCCESS; } - else { LASTFLAG(S) = SUNLS_RES_REDUCED; } + if (converged == SUNTRUE) + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = success", ""); + + LASTFLAG(S) = SUN_SUCCESS; + } + else + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed residual reduced", ""); + + LASTFLAG(S) = SUNLS_RES_REDUCED; + } return (LASTFLAG(S)); } else { *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_CONV_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed max iterations", ""); + return (LASTFLAG(S)); } } From 88db2b2950a433d0c6e33d4c2b5860424e40e37d Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 10:12:37 -0700 Subject: [PATCH 066/235] add retval to failed spgmr log --- src/sunlinsol/spgmr/sunlinsol_spgmr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sunlinsol/spgmr/sunlinsol_spgmr.c b/src/sunlinsol/spgmr/sunlinsol_spgmr.c index 06ac032b1a..e052f6e031 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -430,7 +430,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_ATIMES_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed matvec", ""); + "status = failed matvec, retval = %d", status); return (LASTFLAG(S)); } @@ -451,7 +451,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve", ""); + "status = failed preconditioner solve, retval = %d", status); return (LASTFLAG(S)); } @@ -551,7 +551,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve", ""); + "status = failed preconditioner solve, retval = %d", status); return (LASTFLAG(S)); } @@ -566,7 +566,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_ATIMES_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed matvec", ""); + "status = failed matvec, retval = %d", status); return (LASTFLAG(S)); } @@ -582,7 +582,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve", ""); + "status = failed preconditioner solve, retval = %d", status); return (LASTFLAG(S)); } @@ -697,7 +697,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve", ""); + "status = failed preconditioner solve, retval = %d", status); return (LASTFLAG(S)); } @@ -780,7 +780,7 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve", ""); + "status = failed preconditioner solve, retval = %d", status); return (LASTFLAG(S)); } From 22f2e5500cd39364c262d7b00b179ad87fac5806 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 10:36:22 -0700 Subject: [PATCH 067/235] update spfgmr logging --- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 62 +++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index c6375b2513..ca15296ffc 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -426,6 +426,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* If preconditioning, check if psolve has been set */ SUNAssert(!preOnRight || psolve, SUN_ERR_ARG_CORRUPT); + SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = spfgmr", ""); + + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* Set vtemp and V[0] to initial (unscaled) residual r_0 = b - A*x_0 */ if (*zeroguess) { @@ -440,6 +444,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } N_VLinearSum(ONE, b, -ONE, vtemp, vtemp); @@ -463,16 +471,23 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); *res_norm = r_norm = beta = SUNRsqrt(r_norm); - SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); - if (r_norm <= delta) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = success", + *res_norm); + return (LASTFLAG(S)); } + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = continue", + *res_norm); + /* Initialize rho to avoid compiler warning message */ rho = beta; @@ -496,6 +511,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* Inner loop: generate Krylov sequence and Arnoldi basis. */ for (l = 0; l < l_max; l++) { + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + (*nli)++; krydim = l + 1; @@ -525,6 +542,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -538,6 +559,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } @@ -564,6 +589,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, { *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_QRFACT_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed QR factorization", ""); + return (LASTFLAG(S)); } @@ -571,8 +600,9 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, rotation_product *= givens[2 * l + 1]; *res_norm = rho = SUNRabs(rotation_product * r_norm); - SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, total-iters = %i, res-norm = %.16g", l + 1, + *nli, *res_norm); if (rho <= delta) { @@ -583,6 +613,9 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* Normalize V[l+1] with norm value from the Gram-Schmidt routine. */ N_VScale(ONE / Hes[l + 1][l], V[l + 1], V[l + 1]); SUNCheckLastErr(); + + SUNLogInfoIf(l < l_max - 1, S->sunctx->logger, __func__, + "end-linear-iterate", "status = continue", ""); } /* Inner loop is done. Compute the new correction vector xcor. */ @@ -594,6 +627,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, { *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_QRSOL_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed QR solve", ""); + return (LASTFLAG(S)); } @@ -623,6 +660,10 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, } *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = success", ""); + return (LASTFLAG(S)); } @@ -650,6 +691,9 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, Xv[k] = V[k]; } SUNCheckCall(N_VLinearCombination(krydim + 1, cv, Xv, V[0])); + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = continue", ""); } /* Failed to converge, even after allowed restarts. @@ -669,11 +713,19 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, } *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_RES_REDUCED; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed residual reduced", ""); + return (LASTFLAG(S)); } *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_CONV_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed max iterations", ""); + return (LASTFLAG(S)); } From dd2660e5e376ca6fa08da9b401e57de24216d98a Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 12:04:57 -0700 Subject: [PATCH 068/235] update sptfqmr logging --- src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 127 ++++++++++++++++++++-- 1 file changed, 119 insertions(+), 8 deletions(-) diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index f5827ce73b..d520eab07a 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -350,11 +350,19 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, scale_x = (sx != NULL); scale_b = (sb != NULL); + SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = sptfqmr", ""); + + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* Check for unsupported use case */ if (preOnRight && !(*zeroguess)) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_ERR_ARG_INCOMPATIBLE; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed unsupported configuration", ""); + return SUN_ERR_ARG_INCOMPATIBLE; } @@ -379,6 +387,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } N_VLinearSum(ONE, b, -ONE, r_star, r_star); @@ -394,6 +406,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -425,16 +441,22 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, to do anything */ *res_norm = r_init_norm = SUNRsqrt(rho[0]); - SUNLogDebug(S->sunctx->logger, __func__, "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); - if (r_init_norm <= delta) { *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; + + SUNLogInfo(S->sunctx->logger, __func__, + "end-linear-iterate", "cur-iter = 0, res-norm = %.16g, status = success", + *res_norm); + return (LASTFLAG(S)); } + SUNLogInfo(S->sunctx->logger, __func__, + "linear-iterate", "cur-iter = 0, res-norm = %.16g", + *res_norm); + /* Set v = A*r_0 (preconditioned and scaled) */ if (scale_x) { @@ -457,6 +479,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -466,6 +492,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, { *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } @@ -477,6 +507,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -517,9 +551,14 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, tau = r_init_norm; v_bar = eta = ZERO; + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = continue", ""); + /* START outer loop */ for (n = 0; n < l_max; ++n) { + SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); + /* Increment linear iteration counter */ (*nli)++; @@ -553,6 +592,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -563,6 +606,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } @@ -574,6 +621,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -651,13 +702,14 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, /* NOTE: just use approximation to norm of residual, if possible */ *res_norm = r_curr_norm = tau * SUNRsqrt(m + 1); - SUNLogDebug(S->sunctx->logger, __func__, "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); - /* Exit inner loop if iteration has converged based upon approximation to norm of current residual */ if (r_curr_norm <= delta) { + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, res-norm = %.16g", n + 1, + *nli, *res_norm); + converged = SUNTRUE; break; } @@ -697,6 +749,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_UNREC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } N_VScale(ONE, vtemp2, vtemp1); @@ -709,6 +765,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } @@ -720,6 +780,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -752,6 +816,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -777,11 +845,19 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, (meaning exit if we have converged) */ if (r_curr_norm <= delta) { + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, res-norm = %.16g", n + 1, + *nli, *res_norm); + converged = SUNTRUE; break; } } + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = %i, res-norm = %.16g", n + 1, + *nli, *res_norm); + } /* END inner loop */ /* If converged, then exit outer loop as well */ @@ -832,6 +908,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -842,6 +922,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_ATIMES_FAIL_UNREC : SUNLS_ATIMES_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed matvec, retval = %d", status); + return (LASTFLAG(S)); } @@ -853,6 +937,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_REC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } } @@ -879,6 +967,9 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); rho[0] = rho[1]; + SUNLogInfoIf(n < l_max - 1, S->sunctx->logger, __func__, "end-linear-iterate", + "status = continue", ""); + } /* END outer loop */ /* Determine return value */ @@ -900,6 +991,10 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = (status < 0) ? SUNLS_PSOLVE_FAIL_UNREC : SUNLS_PSOLVE_FAIL_UNREC; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed preconditioner solve, retval = %d", status); + return (LASTFLAG(S)); } N_VScale(ONE, vtemp1, x); @@ -907,14 +1002,30 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, } *zeroguess = SUNFALSE; - if (converged == SUNTRUE) { LASTFLAG(S) = SUN_SUCCESS; } - else { LASTFLAG(S) = SUNLS_RES_REDUCED; } + if (converged == SUNTRUE) + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = success", ""); + + LASTFLAG(S) = SUN_SUCCESS; + } + else + { + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed residual reduced", ""); + + LASTFLAG(S) = SUNLS_RES_REDUCED; + } return (LASTFLAG(S)); } else { *zeroguess = SUNFALSE; LASTFLAG(S) = SUNLS_CONV_FAIL; + + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = failed max iterations", ""); + return (LASTFLAG(S)); } } From f73d83ea1fb5f98151109031622ddeb7ec8f29ff Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 12:14:15 -0700 Subject: [PATCH 069/235] formatting --- src/sunlinsol/pcg/sunlinsol_pcg.c | 4 +-- src/sunlinsol/spbcgs/sunlinsol_spbcgs.c | 10 +++--- src/sunlinsol/spfgmr/sunlinsol_spfgmr.c | 1 - src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c | 35 +++++++++---------- .../fixedpoint/sunnonlinsol_fixedpoint.c | 3 +- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 3f64f5cac5..0f9e0d3b66 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -505,8 +505,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, N_VLinearSum(ONE, z, beta, p, p); SUNCheckLastErr(); - SUNLogInfo(S->sunctx->logger, __func__, - "end-linear-iterate", "status = continue", ""); + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "status = continue", ""); } /* Main loop finished, return with result */ diff --git a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c index 0c5d59a7db..92ba902f3d 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -444,16 +444,14 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; - SUNLogInfo(S->sunctx->logger, __func__, - "end-linear-iterate", "cur-iter = 0, res-norm = %.16g, status = success", - *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "cur-iter = 0, res-norm = %.16g, status = success", *res_norm); return (LASTFLAG(S)); } - SUNLogInfo(S->sunctx->logger, __func__, - "end-linear-iterate", "cur-iter = 0, res-norm = %.16g, status = continue", - *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "cur-iter = 0, res-norm = %.16g, status = continue", *res_norm); /* Copy r_star to r and p */ diff --git a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c index ca15296ffc..a3fd8760ce 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -483,7 +483,6 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, return (LASTFLAG(S)); } - SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", "cur-iter = 0, total-iters = 0, res-norm = %.16g, status = continue", *res_norm); diff --git a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c index d520eab07a..283bfff7bb 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -350,7 +350,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, scale_x = (sx != NULL); scale_b = (sb != NULL); - SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = sptfqmr", ""); + SUNLogInfo(S->sunctx->logger, __func__, "linear-solver", "solver = sptfqmr", + ""); SUNLogInfo(S->sunctx->logger, __func__, "begin-linear-iterate", "", ""); @@ -446,16 +447,14 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, *zeroguess = SUNFALSE; LASTFLAG(S) = SUN_SUCCESS; - SUNLogInfo(S->sunctx->logger, __func__, - "end-linear-iterate", "cur-iter = 0, res-norm = %.16g, status = success", - *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", + "cur-iter = 0, res-norm = %.16g, status = success", *res_norm); return (LASTFLAG(S)); } - SUNLogInfo(S->sunctx->logger, __func__, - "linear-iterate", "cur-iter = 0, res-norm = %.16g", - *res_norm); + SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", + "cur-iter = 0, res-norm = %.16g", *res_norm); /* Set v = A*r_0 (preconditioned and scaled) */ if (scale_x) @@ -707,8 +706,7 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, if (r_curr_norm <= delta) { SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", - "cur-iter = %i, res-norm = %.16g", n + 1, - *nli, *res_norm); + "cur-iter = %i, res-norm = %.16g", n + 1, *nli, *res_norm); converged = SUNTRUE; break; @@ -751,7 +749,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_UNREC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve, retval = %d", status); + "status = failed preconditioner solve, retval = %d", + status); return (LASTFLAG(S)); } @@ -782,7 +781,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve, retval = %d", status); + "status = failed preconditioner solve, retval = %d", + status); return (LASTFLAG(S)); } @@ -818,7 +818,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, : SUNLS_PSOLVE_FAIL_REC; SUNLogInfo(S->sunctx->logger, __func__, "end-linear-iterate", - "status = failed preconditioner solve, retval = %d", status); + "status = failed preconditioner solve, retval = %d", + status); return (LASTFLAG(S)); } @@ -846,8 +847,7 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, if (r_curr_norm <= delta) { SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", - "cur-iter = %i, res-norm = %.16g", n + 1, - *nli, *res_norm); + "cur-iter = %i, res-norm = %.16g", n + 1, *nli, *res_norm); converged = SUNTRUE; break; @@ -855,8 +855,7 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, } SUNLogInfo(S->sunctx->logger, __func__, "linear-iterate", - "cur-iter = %i, res-norm = %.16g", n + 1, - *nli, *res_norm); + "cur-iter = %i, res-norm = %.16g", n + 1, *nli, *res_norm); } /* END inner loop */ @@ -967,8 +966,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, SUNCheckLastErr(); rho[0] = rho[1]; - SUNLogInfoIf(n < l_max - 1, S->sunctx->logger, __func__, "end-linear-iterate", - "status = continue", ""); + SUNLogInfoIf(n < l_max - 1, S->sunctx->logger, __func__, + "end-linear-iterate", "status = continue", ""); } /* END outer loop */ diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index 4e09214a94..9b4fca9b85 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -216,7 +216,8 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, if (retval != 0) { SUNLogInfo(NLS->sunctx->logger, __func__, "end-nonlinear-iterate", - "status = failed nonlinear system evaluation, retval = %d", retval); + "status = failed nonlinear system evaluation, retval = %d", + retval); return retval; } From 9a8be38a306002b72d61a43ec46d34654e9220de Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 25 Jun 2024 16:11:23 -0700 Subject: [PATCH 070/235] fix typos, apply formatting --- scripts/sundialsdev/logs.py | 61 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/scripts/sundialsdev/logs.py b/scripts/sundialsdev/logs.py index ea08317ad7..c97615ee97 100644 --- a/scripts/sundialsdev/logs.py +++ b/scripts/sundialsdev/logs.py @@ -20,6 +20,7 @@ import numpy as np from collections import ChainMap + def convert_to_num(s): """Try to convert a string to an int or float""" @@ -31,6 +32,7 @@ def convert_to_num(s): except ValueError: return s + def parse_logfile_payload(payload, line_number, all_lines, array_indicator="(:)"): """ This function parses the payload of in a SUNDIALS log file line @@ -62,17 +64,19 @@ def parse_logfile_payload(payload, line_number, all_lines, array_indicator="(:)" def parse_logfile_line(line, line_number, all_lines): """ - This function takes a line from a SUNDIALS log file and parses it into a dictionary. + This function takes a line from a SUNDIALS log file and parses it into a + dictionary. + A log file line has the form: [loglvl][rank][scope][label] key1 = value, key2 = value - Log file payloads can be multiline if they are an array/vector with one value per line. - I.e. + Log file payloads can be multiline if they are an array/vector with one + value per line: [loglvl][rank][scope][label] y(:) y_1 y_2 ... """ - pattern = re.compile(r'\[(\w+)\]\[(rank \d+)\]\[(.*)\]\[(.*)\](.*)') + pattern = re.compile(r"\[(\w+)\]\[(rank \d+)\]\[(.*)\]\[(.*)\](.*)") matches = pattern.findall(line) line_dict = {} if matches: @@ -89,7 +93,7 @@ def parse_logfile_line(line, line_number, all_lines): class StepData: def __init__(self): self.container = [ChainMap()] - self.parent_keys = ['main'] + self.parent_keys = ["main"] self.open_dicts = 0 self.open_lists = 0 self.total_dicts = 0 @@ -97,11 +101,11 @@ def __init__(self): def __repr__(self): tmp = "Container:" - for l in self.container: - tmp += f"\n {l}" + for entry in self.container: + tmp += f"\n {entry}" tmp += "\nParent Keys:" - for l in self.parent_keys: - tmp += f"\n {l}" + for entry in self.parent_keys: + tmp += f"\n {entry}" tmp += f"\nOpen dicts: {self.open_dicts}" tmp += f"\nOpen lists: {self.open_lists}" tmp += f"\nTotal dicts: {self.total_dicts}" @@ -152,7 +156,7 @@ def get_step(self): tmp = self.container.pop().maps[0] self.container = [ChainMap()] # At this point we should already be back to main, add sanity check - self.parent_keys = ['main'] + self.parent_keys = ["main"] self.open_dicts = 0 self.open_lists = 0 self.total_dicts = 0 @@ -221,11 +225,11 @@ def log_file_to_list(filename): s.close_dict() continue - if (label == "begin-nonlinear-iterate"): - s.open_list('iterations') + if label == "begin-nonlinear-iterate": + s.open_list("iterations") s.update(line_dict["payload"]) continue - elif (label == "end-nonlinear-iterate"): + elif label == "end-nonlinear-iterate": s.update(line_dict["payload"]) s.close_list() continue @@ -239,17 +243,17 @@ def log_file_to_list(filename): s.close_dict() continue - if (label == "begin-linear-iterate"): - s.open_list('iterations') + if label == "begin-linear-iterate": + s.open_list("iterations") s.update(line_dict["payload"]) continue - elif (label == "end-linear-iterate"): + elif label == "end-linear-iterate": s.update(line_dict["payload"]) s.close_list() continue if label == "begin-stage": - s.open_list('stages') + s.open_list("stages") s.update(line_dict["payload"]) continue elif label == "end-stage": @@ -275,14 +279,14 @@ def print_log_list(a_list, indent=0): for entry in a_list: if type(entry) is list: print(f"{spaces}[") - print_list(entry, indent) + print_log_list(entry, indent) print(f"{spaces}]") elif type(entry) is dict: print(f"{subspaces}{{") - print_dict(entry, indent+2) + print_log_dict(entry, indent + 2) print(f"{subspaces}}}") else: - print(f"{space}{entry}") + print(f"{spaces}{entry}") def print_log_dict(a_dict, indent=0): @@ -291,12 +295,12 @@ def print_log_dict(a_dict, indent=0): if type(a_dict[key]) is list: print(f"{spaces}{key} :") print(f"{spaces}[") - print_list(a_dict[key], indent=indent) + print_log_list(a_dict[key], indent=indent) print(f"{spaces}]") elif type(a_dict[key]) is dict: print(f"{spaces}{key} :") print(f"{spaces}{{") - print_dict(a_dict[key], indent=indent+2) + print_log_dict(a_dict[key], indent=indent + 2) print(f"{spaces}}}") else: print(f"{spaces}{key} : {a_dict[key]}") @@ -326,8 +330,7 @@ def print_log(log, indent=0): print(f"{spaces}}}") -def get_history(log, key, step_status = None, time_range = None, - step_range = None): +def get_history(log, key, step_status=None, time_range=None, step_range=None): """ This function extracts the step/time series of the requested value. """ @@ -338,8 +341,8 @@ def get_history(log, key, step_status = None, time_range = None, for entry in log: - step = np.longlong(entry['step']) - time = np.double(entry['t_n']) + step = np.longlong(entry["step"]) + time = np.double(entry["t_n"]) if time_range is not None: if time < time_range[0] or time > time_range[1]: @@ -350,7 +353,7 @@ def get_history(log, key, step_status = None, time_range = None, continue if step_status is not None: - if step_status not in entry['status']: + if step_status not in entry["status"]: continue if key not in entry: @@ -364,7 +367,9 @@ def get_history(log, key, step_status = None, time_range = None, for s in entry["stages"]: next_level_key = f'time-level-{entry["level"] + 1}' if next_level_key in s: - sub_steps, sub_times, sub_values = get_history(s[next_level_key], key) + sub_steps, sub_times, sub_values = get_history( + s[next_level_key], key + ) steps.extend(sub_steps) times.extend(sub_times) values.extend(sub_values) From cd5e5842eb522da471ffbe660208bad28959ed35 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 29 Jun 2024 20:22:07 -0700 Subject: [PATCH 071/235] move scripts --- {scripts/sundialsdev => tools}/log_example.py | 0 {scripts/sundialsdev => tools}/log_example_mri.py | 0 {scripts/sundialsdev => tools/suntools}/__init__.py | 0 scripts/sundials_csv.py => tools/suntools/csv.py | 0 {scripts/sundialsdev => tools/suntools}/logs.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {scripts/sundialsdev => tools}/log_example.py (100%) rename {scripts/sundialsdev => tools}/log_example_mri.py (100%) rename {scripts/sundialsdev => tools/suntools}/__init__.py (100%) rename scripts/sundials_csv.py => tools/suntools/csv.py (100%) rename {scripts/sundialsdev => tools/suntools}/logs.py (100%) diff --git a/scripts/sundialsdev/log_example.py b/tools/log_example.py similarity index 100% rename from scripts/sundialsdev/log_example.py rename to tools/log_example.py diff --git a/scripts/sundialsdev/log_example_mri.py b/tools/log_example_mri.py similarity index 100% rename from scripts/sundialsdev/log_example_mri.py rename to tools/log_example_mri.py diff --git a/scripts/sundialsdev/__init__.py b/tools/suntools/__init__.py similarity index 100% rename from scripts/sundialsdev/__init__.py rename to tools/suntools/__init__.py diff --git a/scripts/sundials_csv.py b/tools/suntools/csv.py similarity index 100% rename from scripts/sundials_csv.py rename to tools/suntools/csv.py diff --git a/scripts/sundialsdev/logs.py b/tools/suntools/logs.py similarity index 100% rename from scripts/sundialsdev/logs.py rename to tools/suntools/logs.py From fa1647c44246d96fa12203b635186df4c70a089c Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 29 Jun 2024 20:22:19 -0700 Subject: [PATCH 072/235] update imports --- tools/log_example.py | 2 +- tools/log_example_mri.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/log_example.py b/tools/log_example.py index 926d995b42..fdd8f131d9 100755 --- a/tools/log_example.py +++ b/tools/log_example.py @@ -22,7 +22,7 @@ def main(): import matplotlib.pyplot as plt import matplotlib.ticker as tik - import logs as sunlog + from suntools import logs as sunlog parser = argparse.ArgumentParser(description='Plots') diff --git a/tools/log_example_mri.py b/tools/log_example_mri.py index cfd624178a..ef138020c7 100755 --- a/tools/log_example_mri.py +++ b/tools/log_example_mri.py @@ -21,7 +21,7 @@ def main(): import argparse import matplotlib.pyplot as plt - import logs as sunlog + from suntools import logs as sunlog parser = argparse.ArgumentParser(description='Plots') From 7e4601b5dc96ea81ff043bf4d4aec3308e4a03e1 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Sat, 29 Jun 2024 21:03:35 -0700 Subject: [PATCH 073/235] ignore pycache --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3e9185713d..81d9f02e82 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,6 @@ uberenv_libs # swig /swig/swig + +# tools +/tools/suntools/__pycache__ From 8fe1b3e8d3106dc9892a74338de261545a147ff1 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 16 Jul 2024 15:53:28 +0800 Subject: [PATCH 074/235] clean up comments, remove debugging code --- tools/suntools/logs.py | 64 +++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/tools/suntools/logs.py b/tools/suntools/logs.py index c97615ee97..600f3b5049 100644 --- a/tools/suntools/logs.py +++ b/tools/suntools/logs.py @@ -23,7 +23,6 @@ def convert_to_num(s): """Try to convert a string to an int or float""" - try: return np.longlong(s) except ValueError: @@ -35,9 +34,8 @@ def convert_to_num(s): def parse_logfile_payload(payload, line_number, all_lines, array_indicator="(:)"): """ - This function parses the payload of in a SUNDIALS log file line - into a dictionary. The payload of a SUNDIALS log file line - is the part after all the [ ] brackets. + Parse the payload of a SUNDIALS log file line into a dictionary. The payload + of a SUNDIALS log file line is the part after all the [ ] brackets. """ kvpstrs = payload.split(",") kvp_dict = {} @@ -64,14 +62,13 @@ def parse_logfile_payload(payload, line_number, all_lines, array_indicator="(:)" def parse_logfile_line(line, line_number, all_lines): """ - This function takes a line from a SUNDIALS log file and parses it into a - dictionary. + Parse a line from a SUNDIALS log file it into a dictionary. A log file line has the form: [loglvl][rank][scope][label] key1 = value, key2 = value - Log file payloads can be multiline if they are an array/vector with one - value per line: - [loglvl][rank][scope][label] y(:) + The log line payload (everything after the brackets) can be multiline with + one value per line for keys corresponding to an array/vector: + [loglvl][rank][scope][label] y(:) = y_1 y_2 ... @@ -91,13 +88,14 @@ def parse_logfile_line(line, line_number, all_lines): class StepData: + """ + Helper class for parsing a step attempt from a SUNDIALS log file into a + hierarchical dictionary where entries may be lists of dictionaries. + """ + def __init__(self): self.container = [ChainMap()] self.parent_keys = ["main"] - self.open_dicts = 0 - self.open_lists = 0 - self.total_dicts = 0 - self.total_lists = 0 def __repr__(self): tmp = "Container:" @@ -106,10 +104,6 @@ def __repr__(self): tmp += "\nParent Keys:" for entry in self.parent_keys: tmp += f"\n {entry}" - tmp += f"\nOpen dicts: {self.open_dicts}" - tmp += f"\nOpen lists: {self.open_lists}" - tmp += f"\nTotal dicts: {self.total_dicts}" - tmp += f"\nTotal lists: {self.total_lists}" return tmp def update(self, data): @@ -120,13 +114,10 @@ def open_dict(self, key): """Activate a dictionary""" self.container[-1][key] = {} self.container[-1] = self.container[-1].new_child(self.container[-1][key]) - self.open_dicts += 1 - self.total_dicts += 1 def close_dict(self): """Deactivate the active dictionary""" self.container[-1] = self.container[-1].parents - self.open_dicts -= 1 def open_list(self, key): """Activate a list of dictionaries""" @@ -136,31 +127,19 @@ def open_list(self, key): self.container[-1][key] = [] self.container.append(ChainMap()) self.parent_keys.append(key) - self.open_lists += 1 - self.total_lists += 1 def close_list(self): """Deactivate a the active list""" - # I think the Chain map will only ever have one entry. In which case we - # don't need a ChainMap and could just manage the dictionaries manually. - # However, open and close dict still relies on the dict references to - # update nested dictionaries, so maybe not. tmp = self.container[-1].maps[0] self.container[-2][self.parent_keys[-1]].append(tmp) self.parent_keys.pop() self.container.pop() - self.open_lists -= 1 def get_step(self): """Get the step dictionary and reset the container""" tmp = self.container.pop().maps[0] self.container = [ChainMap()] - # At this point we should already be back to main, add sanity check self.parent_keys = ["main"] - self.open_dicts = 0 - self.open_lists = 0 - self.total_dicts = 0 - self.total_lists = 0 return tmp @@ -171,13 +150,12 @@ def log_file_to_list(filename): E.g., [ - { - "loglvl": "DEBUG", - "rank": "rank 0", - "scope": "", - "label": "enter-step-attempt-loop", - "payload": {"step": "0", "h": "1e-06", "q": "1", "t_n": "0"}, - }, ... + { + step : 1, + tn : 0.0, + stages : [ {stage : 1, tcur : 0.0, ...}, {stage : 2, tcur : 0.5, ...}, ...] + ... + }, ... ] """ with open(filename, "r") as logfile: @@ -191,6 +169,7 @@ def log_file_to_list(filename): # Read the log file all_lines = logfile.readlines() + # Create instance of helper class for building attempt dictionary s = StepData() for line_number, line in enumerate(all_lines): @@ -274,6 +253,7 @@ def log_file_to_list(filename): def print_log_list(a_list, indent=0): + """Print list value in step attempt dictionary""" spaces = indent * " " subspaces = (indent + 2) * " " for entry in a_list: @@ -290,6 +270,7 @@ def print_log_list(a_list, indent=0): def print_log_dict(a_dict, indent=0): + """Print dictionary value in step attempt dictionary""" spaces = indent * " " for key in a_dict: if type(a_dict[key]) is list: @@ -308,9 +289,8 @@ def print_log_dict(a_dict, indent=0): def print_log(log, indent=0): """ - This function prints the list of entries from a log file. + Print the entries entries from a log file list of step attempts. """ - spaces = indent * " " for entry in log: print(f"{spaces}{{") @@ -332,7 +312,7 @@ def print_log(log, indent=0): def get_history(log, key, step_status=None, time_range=None, step_range=None): """ - This function extracts the step/time series of the requested value. + Extract the step/time series of the requested value. """ steps = [] From d60223163081762b081a9e80d478c7145a0ca732 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 6 Aug 2024 16:13:59 -0500 Subject: [PATCH 075/235] reorder logging output --- src/arkode/arkode_arkstep.c | 48 +++++++++++++++++++++---------------- src/arkode/arkode_erkstep.c | 5 ++-- src/arkode/arkode_mristep.c | 14 +++++------ 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index fd8f6bc959..53f1064463 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1985,33 +1985,39 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fi(ark_mem->tcur, ark_mem->ycur, step_mem->Fi[is], ark_mem->user_data); step_mem->nfi++; + + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit RHS", + "Fi_%i(:) =", step_mem->Fi[is], is); SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", "status = failed implicit rhs eval, retval = %i", retval); - } - else if (step_mem->mass_type == MASS_FIXED) - { - retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1); - if (retval != ARK_SUCCESS) - { - SUNLogInfo(ARK_LOGGER, __func__, "end-stage", - "status = failed mass mult, retval = %i", retval); - return (ARK_MASSMULT_FAIL); - } - N_VLinearSum(ONE / step_mem->gamma, ark_mem->tempv1, - -ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]); + if (retval < 0) { return (ARK_RHSFUNC_FAIL); } + if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } } else { - N_VLinearSum(ONE / step_mem->gamma, step_mem->zcor, - -ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]); - } + if (step_mem->mass_type == MASS_FIXED) + { + retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1); + if (retval != ARK_SUCCESS) + { + SUNLogInfo(ARK_LOGGER, __func__, "end-stage", + "status = failed mass mult, retval = %i", retval); + return (ARK_MASSMULT_FAIL); + } - SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit RHS", - "Fi_%i(:) =", step_mem->Fi[is], is); + N_VLinearSum(ONE / step_mem->gamma, ark_mem->tempv1, + -ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]); + } + else + { + N_VLinearSum(ONE / step_mem->gamma, step_mem->zcor, + -ONE / step_mem->gamma, step_mem->sdata, step_mem->Fi[is]); + } - if (retval < 0) { return (ARK_RHSFUNC_FAIL); } - if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "implicit RHS", + "Fi_%i(:) =", step_mem->Fi[is], is); + } } /* store explicit RHS */ @@ -2020,11 +2026,11 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) retval = step_mem->fe(ark_mem->tn + step_mem->Be->c[is] * ark_mem->h, ark_mem->ycur, step_mem->Fe[is], ark_mem->user_data); step_mem->nfe++; - SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", - "status = failed explicit rhs eval, retval = %i", retval); SUNLogExtraDebug(ARK_LOGGER, __func__, "explicit RHS", "Fe_%i(:) =", step_mem->Fe[is], is); + SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", + "status = failed explicit rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index a5acb1d416..8c8c641e42 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -698,15 +698,14 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); step_mem->nfe++; + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", + "F_%i(:) =", step_mem->F[is], is); SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", "status = failed rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } - SUNLogExtraDebugVec(ARK_LOGGER, __func__, "stage RHS", - "F_%i(:) =", step_mem->F[is], is); - SUNLogInfo(ARK_LOGGER, __func__, "end-stage", "status = success", ""); } /* loop over stages */ diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 163f87f193..a565f6654d 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -1583,15 +1583,14 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) ark_mem->user_data); step_mem->nfse++; + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow explicit RHS", + "Fse_%i(:) =", step_mem->Fse[step_mem->stage_map[is]], + is); SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", "status = failed explicit rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } - - SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow explicit RHS", - "Fse_%i(:) =", step_mem->Fse[step_mem->stage_map[is]], - is); } /* store implicit slow rhs */ @@ -1612,15 +1611,14 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->Fsi[step_mem->stage_map[is]]); } + SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow implicit RHS", + "Fsi_%i(:) =", step_mem->Fsi[step_mem->stage_map[is]], + is); SUNLogInfoIf(retval != 0, ARK_LOGGER, __func__, "end-stage", "status = failed implicit rhs eval, retval = %i", retval); if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } - - SUNLogExtraDebugVec(ARK_LOGGER, __func__, "slow implicit RHS", - "Fsi_%i(:) =", step_mem->Fsi[step_mem->stage_map[is]], - is); } } /* compute slow RHS */ From e884166067e6ec6e61a6297a49b24ae832ed7641 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Wed, 7 Aug 2024 09:26:15 -0500 Subject: [PATCH 076/235] apply formatting --- src/arkode/arkode_arkstep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 53f1064463..4b09c752a5 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -1998,7 +1998,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { if (step_mem->mass_type == MASS_FIXED) { - retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, ark_mem->tempv1); + retval = step_mem->mmult((void*)ark_mem, step_mem->zcor, + ark_mem->tempv1); if (retval != ARK_SUCCESS) { SUNLogInfo(ARK_LOGGER, __func__, "end-stage", From eb5ae98c7193e2e25c56bd1d5593619aaf0e2aa4 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Fri, 23 Aug 2024 16:20:15 -0700 Subject: [PATCH 077/235] add labels option to sundials_add_test --- .cmake-format.py | 1 + cmake/macros/SundialsAddTest.cmake | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.cmake-format.py b/.cmake-format.py index c6d5938ef6..e54ca58d3a 100644 --- a/.cmake-format.py +++ b/.cmake-format.py @@ -59,6 +59,7 @@ 'EXTRA_ARGS': '+', 'FLOAT_PRECISION': 1, 'INTEGER_PRECISION': 1, + 'LABELS': '+', 'MPI_NPROCS': 1, 'TEST_ARGS': '+'}, 'pargs': {'flags': ['NODIFF'], 'nargs': '2+'}}, diff --git a/cmake/macros/SundialsAddTest.cmake b/cmake/macros/SundialsAddTest.cmake index a1eb373b67..a2a468cddb 100644 --- a/cmake/macros/SundialsAddTest.cmake +++ b/cmake/macros/SundialsAddTest.cmake @@ -21,7 +21,8 @@ # [ANSWER_DIR path] # [ANSWER_FIEL file] # [EXAMPLE_TYPE type] -# [TEST_ARGS arg1 arg2 ...]) +# [TEST_ARGS arg1 arg2 ...] +# [LABELS label1 label2 ...]) # ~~~ # # CMake macro to add a SUNDIALS regression test. Keyword input arguments can be @@ -46,6 +47,11 @@ # # The option EXAMPLE_TYPE set the example type i.e., release or develop examples # +# The option TEST_ARGS are command line arguments to pass to the executable +# +# The options LABELS are labels added to the test properties to easily run (or +# exclude) groups of test with ctest -L