diff --git a/include/sundials/sundials_linearsolver.h b/include/sundials/sundials_linearsolver.h index 6aa6c065f8..dad8a35772 100644 --- a/include/sundials/sundials_linearsolver.h +++ b/include/sundials/sundials_linearsolver.h @@ -226,18 +226,6 @@ SUNErrCode SUNLinSolFree(SUNLinearSolver S); #define SUNLS_QRFACT_FAIL 807 /* QRfact found singular matrix */ #define SUNLS_LUFACT_FAIL 808 /* LUfact found singular matrix */ -/* ----------------------------------------------------------------------------- - * SUNLinearSolver messages - * ---------------------------------------------------------------------------*/ - -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define SUNLS_MSG_RESIDUAL "\t\tlin. iteration %ld, lin. residual: %Lg\n" -#elif defined(SUNDIALS_DOUBLE_PRECISION) -#define SUNLS_MSG_RESIDUAL "\t\tlin. iteration %ld, lin. residual: %g\n" -#else -#define SUNLS_MSG_RESIDUAL "\t\tlin. iteration %ld, lin. residual: %g\n" -#endif - #ifdef __cplusplus } #endif diff --git a/include/sundials/sundials_nonlinearsolver.h b/include/sundials/sundials_nonlinearsolver.h index a4b2e1591a..e78bd327fd 100644 --- a/include/sundials/sundials_nonlinearsolver.h +++ b/include/sundials/sundials_nonlinearsolver.h @@ -192,18 +192,6 @@ SUNErrCode SUNNonlinSolGetNumConvFails(SUNNonlinearSolver NLS, #define SUN_NLS_CONTINUE +901 /* not converged, keep iterating */ #define SUN_NLS_CONV_RECVR +902 /* convergece failure, try to recover */ -/* ----------------------------------------------------------------------------- - * SUNNonlinearSolver messages - * ---------------------------------------------------------------------------*/ - -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define SUN_NLS_MSG_RESIDUAL "\tnonlin. iteration %ld, nonlin. residual: %Lg\n" -#elif defined(SUNDIALS_DOUBLE_PRECISION) -#define SUN_NLS_MSG_RESIDUAL "\tnonlin. iteration %ld, nonlin. residual: %g\n" -#else -#define SUN_NLS_MSG_RESIDUAL "\tnonlin. iteration %ld, nonlin. residual: %g\n" -#endif - #ifdef __cplusplus } #endif diff --git a/include/sundials/sundials_types.h b/include/sundials/sundials_types.h index c959b6fe33..7ec0bc37b4 100644 --- a/include/sundials/sundials_types.h +++ b/include/sundials/sundials_types.h @@ -84,6 +84,9 @@ extern "C" { *------------------------------------------------------------------ */ +#define SUN_STRING_HELPER(x) #x +#define SUN_STRING(x) SUN_STRING_HELPER(x) + #if defined(SUNDIALS_SINGLE_PRECISION) typedef float sunrealtype; @@ -91,6 +94,8 @@ typedef float sunrealtype; #define SUN_BIG_REAL FLT_MAX #define SUN_SMALL_REAL FLT_MIN #define SUN_UNIT_ROUNDOFF FLT_EPSILON +#define SUN_REAL_FORMAT_E "%." SUN_STRING(FLT_DIG) "e" +#define SUN_REAL_FORMAT_G "%." SUN_STRING(FLT_DIG) "g" #elif defined(SUNDIALS_DOUBLE_PRECISION) @@ -99,6 +104,8 @@ typedef double sunrealtype; #define SUN_BIG_REAL DBL_MAX #define SUN_SMALL_REAL DBL_MIN #define SUN_UNIT_ROUNDOFF DBL_EPSILON +#define SUN_REAL_FORMAT_E "%." SUN_STRING(DBL_DIG) "e" +#define SUN_REAL_FORMAT_G "%." SUN_STRING(DBL_DIG) "g" #elif defined(SUNDIALS_EXTENDED_PRECISION) @@ -107,6 +114,8 @@ typedef long double sunrealtype; #define SUN_BIG_REAL LDBL_MAX #define SUN_SMALL_REAL LDBL_MIN #define SUN_UNIT_ROUNDOFF LDBL_EPSILON +#define SUN_REAL_FORMAT_E "% ." SUN_STRING(LDBL_DIG) "Le" +#define SUN_REAL_FORMAT_G "% ." SUN_STRING(LDBL_DIG) "Lg" #endif diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index f21c51d46e..39e517b389 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_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::ARKodeEvolve", "start-step", - "step = %li, attempt = %i, h = %" RSYM - ", tcur = %" RSYM, + "step = %li, attempt = %i, h = " SUN_REAL_FORMAT_G + ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, attempts, ark_mem->h, ark_mem->tcur); #endif @@ -1259,17 +1259,17 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile) fprintf(outfile, "user_efun = %i\n", ark_mem->user_efun); fprintf(outfile, "tstopset = %i\n", ark_mem->tstopset); fprintf(outfile, "tstopinterp = %i\n", ark_mem->tstopinterp); - fprintf(outfile, "tstop = %" RSYM "\n", ark_mem->tstop); + fprintf(outfile, "tstop = " SUN_REAL_FORMAT_G "\n", ark_mem->tstop); fprintf(outfile, "VabstolMallocDone = %i\n", ark_mem->VabstolMallocDone); fprintf(outfile, "MallocDone = %i\n", ark_mem->MallocDone); fprintf(outfile, "initsetup = %i\n", ark_mem->initsetup); fprintf(outfile, "init_type = %i\n", ark_mem->init_type); fprintf(outfile, "firststage = %i\n", ark_mem->firststage); - fprintf(outfile, "uround = %" RSYM "\n", ark_mem->uround); - fprintf(outfile, "reltol = %" RSYM "\n", ark_mem->reltol); - fprintf(outfile, "Sabstol = %" RSYM "\n", ark_mem->Sabstol); + fprintf(outfile, "uround = " SUN_REAL_FORMAT_G "\n", ark_mem->uround); + fprintf(outfile, "reltol = " SUN_REAL_FORMAT_G "\n", ark_mem->reltol); + fprintf(outfile, "Sabstol = " SUN_REAL_FORMAT_G "\n", ark_mem->Sabstol); fprintf(outfile, "fixedstep = %i\n", ark_mem->fixedstep); - fprintf(outfile, "tolsf = %" RSYM "\n", ark_mem->tolsf); + fprintf(outfile, "tolsf = " SUN_REAL_FORMAT_G "\n", ark_mem->tolsf); fprintf(outfile, "call_fullrhs = %i\n", ark_mem->call_fullrhs); /* output counters */ @@ -1280,18 +1280,18 @@ void ARKodePrintMem(void* arkode_mem, FILE* outfile) fprintf(outfile, "netf = %li\n", ark_mem->netf); /* output time-stepping values */ - fprintf(outfile, "hin = %" RSYM "\n", ark_mem->hin); - fprintf(outfile, "h = %" RSYM "\n", ark_mem->h); - fprintf(outfile, "hprime = %" RSYM "\n", ark_mem->hprime); - fprintf(outfile, "next_h = %" RSYM "\n", ark_mem->next_h); - fprintf(outfile, "eta = %" RSYM "\n", ark_mem->eta); - fprintf(outfile, "tcur = %" RSYM "\n", ark_mem->tcur); - fprintf(outfile, "tretlast = %" RSYM "\n", ark_mem->tretlast); - fprintf(outfile, "hmin = %" RSYM "\n", ark_mem->hmin); - fprintf(outfile, "hmax_inv = %" RSYM "\n", ark_mem->hmax_inv); - fprintf(outfile, "h0u = %" RSYM "\n", ark_mem->h0u); - fprintf(outfile, "tn = %" RSYM "\n", ark_mem->tn); - fprintf(outfile, "hold = %" RSYM "\n", ark_mem->hold); + fprintf(outfile, "hin = " SUN_REAL_FORMAT_G "\n", ark_mem->hin); + fprintf(outfile, "h = " SUN_REAL_FORMAT_G "\n", ark_mem->h); + fprintf(outfile, "hprime = " SUN_REAL_FORMAT_G "\n", ark_mem->hprime); + fprintf(outfile, "next_h = " SUN_REAL_FORMAT_G "\n", ark_mem->next_h); + fprintf(outfile, "eta = " SUN_REAL_FORMAT_G "\n", ark_mem->eta); + fprintf(outfile, "tcur = " SUN_REAL_FORMAT_G "\n", ark_mem->tcur); + fprintf(outfile, "tretlast = " SUN_REAL_FORMAT_G "\n", ark_mem->tretlast); + fprintf(outfile, "hmin = " SUN_REAL_FORMAT_G "\n", ark_mem->hmin); + fprintf(outfile, "hmax_inv = " SUN_REAL_FORMAT_G "\n", ark_mem->hmax_inv); + fprintf(outfile, "h0u = " SUN_REAL_FORMAT_G "\n", ark_mem->h0u); + fprintf(outfile, "tn = " SUN_REAL_FORMAT_G "\n", ark_mem->tn); + fprintf(outfile, "hold = " SUN_REAL_FORMAT_G "\n", ark_mem->hold); fprintf(outfile, "maxnef = %i\n", ark_mem->maxnef); fprintf(outfile, "maxncf = %i\n", ark_mem->maxncf); @@ -2517,7 +2517,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, + "end-step", + "step = %li, h = " SUN_REAL_FORMAT_G + ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, ark_mem->h, ark_mem->tcur); #endif @@ -2625,9 +2627,10 @@ int arkHandleFailure(ARKodeMem ark_mem, int flag) MSG_ARK_MASSSOLVE_FAIL); break; case ARK_NLS_SETUP_FAIL: - arkProcessError(ark_mem, ARK_NLS_SETUP_FAIL, __LINE__, __func__, - __FILE__, "At t = %Lg the nonlinear solver setup failed unrecoverably", - (long double)ark_mem->tcur); + arkProcessError(ark_mem, ARK_NLS_SETUP_FAIL, __LINE__, __func__, __FILE__, + "At t = " SUN_REAL_FORMAT_G + " the nonlinear solver setup failed unrecoverably", + ark_mem->tcur); break; case ARK_VECTOROP_ERR: arkProcessError(ark_mem, ARK_VECTOROP_ERR, __LINE__, __func__, __FILE__, @@ -2655,8 +2658,9 @@ int arkHandleFailure(ARKodeMem ark_mem, int flag) break; case ARK_INTERP_FAIL: arkProcessError(ark_mem, ARK_INTERP_FAIL, __LINE__, __func__, __FILE__, - "At t = %Lg the interpolation module failed unrecoverably", - (long double)ark_mem->tcur); + "At t = " SUN_REAL_FORMAT_G + " the interpolation module failed unrecoverably", + ark_mem->tcur); break; case ARK_INVALID_TABLE: arkProcessError(ark_mem, ARK_INVALID_TABLE, __LINE__, __func__, __FILE__, @@ -2664,8 +2668,8 @@ int arkHandleFailure(ARKodeMem ark_mem, int flag) break; case ARK_RELAX_FAIL: arkProcessError(ark_mem, ARK_RELAX_FAIL, __LINE__, __func__, __FILE__, - "At t = %Lg the relaxation module failed", - (long double)ark_mem->tcur); + "At t = " SUN_REAL_FORMAT_G " the relaxation module failed", + ark_mem->tcur); break; case ARK_RELAX_MEM_NULL: arkProcessError(ark_mem, ARK_RELAX_MEM_NULL, __LINE__, __func__, __FILE__, diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index 7fef0ec2ae..b58811821f 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -54,17 +54,27 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile) { if (hadapt_mem != NULL) { - fprintf(outfile, "ark_hadapt: etamax = %" RSYM "\n", hadapt_mem->etamax); - fprintf(outfile, "ark_hadapt: etamx1 = %" RSYM "\n", hadapt_mem->etamx1); - fprintf(outfile, "ark_hadapt: etamxf = %" RSYM "\n", hadapt_mem->etamxf); - fprintf(outfile, "ark_hadapt: etamin = %" RSYM "\n", hadapt_mem->etamin); + fprintf(outfile, "ark_hadapt: etamax = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->etamax); + fprintf(outfile, "ark_hadapt: etamx1 = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->etamx1); + fprintf(outfile, "ark_hadapt: etamxf = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->etamxf); + fprintf(outfile, "ark_hadapt: etamin = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->etamin); fprintf(outfile, "ark_hadapt: small_nef = %i\n", hadapt_mem->small_nef); - fprintf(outfile, "ark_hadapt: etacf = %" RSYM "\n", hadapt_mem->etacf); - fprintf(outfile, "ark_hadapt: cfl = %" RSYM "\n", hadapt_mem->cfl); - fprintf(outfile, "ark_hadapt: safety = %" RSYM "\n", hadapt_mem->safety); - fprintf(outfile, "ark_hadapt: growth = %" RSYM "\n", hadapt_mem->growth); - fprintf(outfile, "ark_hadapt: lbound = %" RSYM "\n", hadapt_mem->lbound); - fprintf(outfile, "ark_hadapt: ubound = %" RSYM "\n", hadapt_mem->ubound); + fprintf(outfile, "ark_hadapt: etacf = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->etacf); + fprintf(outfile, "ark_hadapt: cfl = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->cfl); + fprintf(outfile, "ark_hadapt: safety = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->safety); + fprintf(outfile, "ark_hadapt: growth = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->growth); + fprintf(outfile, "ark_hadapt: lbound = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->lbound); + fprintf(outfile, "ark_hadapt: ubound = " SUN_REAL_FORMAT_G "\n", + hadapt_mem->ubound); fprintf(outfile, "ark_hadapt: nst_acc = %li\n", hadapt_mem->nst_acc); fprintf(outfile, "ark_hadapt: nst_exp = %li\n", hadapt_mem->nst_exp); fprintf(outfile, "ark_hadapt: pq = %i\n", hadapt_mem->pq); @@ -136,7 +146,9 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt", "new-step-before-bounds", - "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); + "h_acc = " SUN_REAL_FORMAT_G + ", h_cfl = " SUN_REAL_FORMAT_G, + h_acc, h_cfl); #endif /* enforce safety factors */ @@ -152,7 +164,9 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkAdapt", "new-step-after-max-min-bounds", - "h_acc = %" RSYM ", h_cfl = %" RSYM, h_acc, h_cfl); + "h_acc = " SUN_REAL_FORMAT_G + ", h_cfl = " SUN_REAL_FORMAT_G, + h_acc, h_cfl); #endif /* increment the relevant step counter, set desired step */ @@ -181,7 +195,7 @@ int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkAdapt", - "new-step-eta", "eta = %" RSYM, ark_mem->eta); + "new-step-eta", "eta = " SUN_REAL_FORMAT_G, ark_mem->eta); #endif return (retval); diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 5f91285edb..fba3a00a6b 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -723,15 +723,16 @@ void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "ARKStep: implicit Butcher table:\n"); ARKodeButcherTable_Write(step_mem->Bi, outfile); } - fprintf(outfile, "ARKStep: gamma = %" RSYM "\n", step_mem->gamma); - fprintf(outfile, "ARKStep: gammap = %" RSYM "\n", step_mem->gammap); - fprintf(outfile, "ARKStep: gamrat = %" RSYM "\n", step_mem->gamrat); - fprintf(outfile, "ARKStep: crate = %" RSYM "\n", step_mem->crate); - fprintf(outfile, "ARKStep: eRNrm = %" RSYM "\n", step_mem->eRNrm); - fprintf(outfile, "ARKStep: nlscoef = %" RSYM "\n", step_mem->nlscoef); - fprintf(outfile, "ARKStep: crdown = %" RSYM "\n", step_mem->crdown); - fprintf(outfile, "ARKStep: rdiv = %" RSYM "\n", step_mem->rdiv); - fprintf(outfile, "ARKStep: dgmax = %" RSYM "\n", step_mem->dgmax); + fprintf(outfile, "ARKStep: gamma = " SUN_REAL_FORMAT_G "\n", step_mem->gamma); + fprintf(outfile, "ARKStep: gammap = " SUN_REAL_FORMAT_G "\n", step_mem->gammap); + fprintf(outfile, "ARKStep: gamrat = " SUN_REAL_FORMAT_G "\n", step_mem->gamrat); + fprintf(outfile, "ARKStep: crate = " SUN_REAL_FORMAT_G "\n", step_mem->crate); + fprintf(outfile, "ARKStep: eRNrm = " SUN_REAL_FORMAT_G "\n", step_mem->eRNrm); + fprintf(outfile, "ARKStep: nlscoef = " SUN_REAL_FORMAT_G "\n", + step_mem->nlscoef); + fprintf(outfile, "ARKStep: crdown = " SUN_REAL_FORMAT_G "\n", step_mem->crdown); + fprintf(outfile, "ARKStep: rdiv = " SUN_REAL_FORMAT_G "\n", step_mem->rdiv); + fprintf(outfile, "ARKStep: dgmax = " SUN_REAL_FORMAT_G "\n", step_mem->dgmax); #ifdef SUNDIALS_DEBUG_PRINTVEC /* output vector quantities */ @@ -1831,8 +1832,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_INFO, "ARKODE::arkStep_TakeStep_Z", "start-stage", - "step = %li, stage = %i, implicit = %i, h = %" RSYM - ", tcur = %" RSYM, + "step = %li, stage = %i, implicit = %i, h " + "= " SUN_REAL_FORMAT_G ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, 0, implicit_stage, ark_mem->h, ark_mem->tcur); #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG @@ -1884,8 +1885,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, "ARKODE::arkStep_TakeStep_Z", "start-stage", - "step = %li, stage = %i, implicit = %i, h = %" RSYM - ", tcur = %" RSYM, + "step = %li, stage = %i, implicit = %i, h " + "= " SUN_REAL_FORMAT_G ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, is, implicit_stage, ark_mem->h, ark_mem->tcur); #endif @@ -2093,7 +2094,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #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", + "step = %li, h = " SUN_REAL_FORMAT_G + ", dsm = " SUN_REAL_FORMAT_G ", nflag = %d", ark_mem->nst, ark_mem->h, *dsmPtr, *nflagPtr); #endif diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 7df74cb590..c15c45d1c0 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -1201,132 +1201,63 @@ int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - switch (fmt) + /* function evaluations */ + sunfprintf_long(outfile, fmt, SUNTRUE, "Explicit RHS fn evals", step_mem->nfe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Implicit RHS fn evals", step_mem->nfi); + + /* nonlinear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS iters", step_mem->nls_iters); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS fails", step_mem->nls_fails); + if (ark_mem->nst > 0) { - case SUN_OUTPUTFORMAT_TABLE: - /* function evaluations */ - fprintf(outfile, "Explicit RHS fn evals = %ld\n", step_mem->nfe); - fprintf(outfile, "Implicit RHS fn evals = %ld\n", step_mem->nfi); - - /* nonlinear solver stats */ - fprintf(outfile, "NLS iters = %ld\n", step_mem->nls_iters); - fprintf(outfile, "NLS fails = %ld\n", step_mem->nls_fails); - if (ark_mem->nst > 0) - { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", - (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); - } - - /* linear solver stats */ - fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); - if (ark_mem->step_getlinmem(ark_mem)) - { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); - fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); - fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); - fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", arkls_mem->nps); - fprintf(outfile, "LS iters = %ld\n", arkls_mem->nli); - fprintf(outfile, "LS fails = %ld\n", arkls_mem->ncfl); - fprintf(outfile, "Jac-times setups = %ld\n", - arkls_mem->njtsetup); - fprintf(outfile, "Jac-times evals = %ld\n", - arkls_mem->njtimes); - if (step_mem->nls_iters > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); - } - } - - /* mass solve stats */ - if (ark_mem->step_getmassmem(ark_mem)) - { - arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); - fprintf(outfile, "Mass setups = %ld\n", - arklsm_mem->nmsetups); - fprintf(outfile, "Mass solves = %ld\n", - arklsm_mem->nmsolves); - fprintf(outfile, "Mass Prec setup evals = %ld\n", arklsm_mem->npe); - fprintf(outfile, "Mass Prec solves = %ld\n", arklsm_mem->nps); - fprintf(outfile, "Mass LS iters = %ld\n", arklsm_mem->nli); - fprintf(outfile, "Mass LS fails = %ld\n", arklsm_mem->ncfl); - fprintf(outfile, "Mass-times setups = %ld\n", - arklsm_mem->nmtsetup); - fprintf(outfile, "Mass-times evals = %ld\n", - arklsm_mem->nmtimes); - } - break; - - case SUN_OUTPUTFORMAT_CSV: - /* function evaluations */ - fprintf(outfile, ",Explicit RHS fn evals,%ld", step_mem->nfe); - fprintf(outfile, ",Implicit RHS fn evals,%ld", step_mem->nfi); - - /* nonlinear solver stats */ - fprintf(outfile, ",NLS iters,%ld", step_mem->nls_iters); - fprintf(outfile, ",NLS fails,%ld", step_mem->nls_fails); - if (ark_mem->nst > 0) - { - fprintf(outfile, ",NLS iters per step,%" RSYM, - (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); - } - else { fprintf(outfile, ",NLS iters per step,0"); } - - /* linear solver stats */ - fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); - if (ark_mem->step_getlinmem(ark_mem)) - { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); - fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); - fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); - fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); - fprintf(outfile, ",Prec solves,%ld", arkls_mem->nps); - fprintf(outfile, ",LS iters,%ld", arkls_mem->nli); - fprintf(outfile, ",LS fails,%ld", arkls_mem->ncfl); - fprintf(outfile, ",Jac-times setups,%ld", arkls_mem->njtsetup); - fprintf(outfile, ",Jac-times evals,%ld", arkls_mem->njtimes); - if (step_mem->nls_iters > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } - } + sunfprintf_real(outfile, fmt, SUNFALSE, "NLS iters per step", + (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); + } - /* mass solve stats */ - if (ark_mem->step_getmassmem(ark_mem)) + /* linear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "LS setups", step_mem->nsetups); + if (ark_mem->step_getlinmem(ark_mem)) + { + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac fn evals", arkls_mem->nje); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS RHS fn evals", arkls_mem->nfeDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec setup evals", arkls_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec solves", arkls_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS iters", arkls_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS fails", arkls_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times setups", + arkls_mem->njtsetup); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times evals", + arkls_mem->njtimes); + if (step_mem->nls_iters > 0) { - arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); - fprintf(outfile, ",Mass setups,%ld", arklsm_mem->nmsetups); - fprintf(outfile, ",Mass solves,%ld", arklsm_mem->nmsolves); - fprintf(outfile, ",Mass Prec setup evals,%ld", arklsm_mem->npe); - fprintf(outfile, ",Mass Prec solves,%ld", arklsm_mem->nps); - fprintf(outfile, ",Mass LS iters,%ld", arklsm_mem->nli); - fprintf(outfile, ",Mass LS fails,%ld", arklsm_mem->ncfl); - fprintf(outfile, ",Mass-times setups,%ld", arklsm_mem->nmtsetup); - fprintf(outfile, ",Mass-times evals,%ld", arklsm_mem->nmtimes); + sunfprintf_real(outfile, fmt, SUNFALSE, "LS iters per NLS iter", + (sunrealtype)arkls_mem->nli / + (sunrealtype)step_mem->nls_iters); + sunfprintf_real(outfile, fmt, SUNFALSE, "Jac evals per NLS iter", + (sunrealtype)arkls_mem->nje / + (sunrealtype)step_mem->nls_iters); + sunfprintf_real(outfile, fmt, SUNFALSE, "Prec evals per NLS iter", + (sunrealtype)arkls_mem->npe / + (sunrealtype)step_mem->nls_iters); } - fprintf(outfile, "\n"); - break; + } - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return (ARK_ILL_INPUT); + /* mass solve stats */ + if (ark_mem->step_getmassmem(ark_mem)) + { + arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass setups", arklsm_mem->nmsetups); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass solves", arklsm_mem->nmsolves); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass Prec setup evals", + arklsm_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass Prec solves", arklsm_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass LS iters", arklsm_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass LS fails", arklsm_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass-times setups", + arklsm_mem->nmtsetup); + sunfprintf_long(outfile, fmt, SUNFALSE, "Mass-times evals", + arklsm_mem->nmtimes); } return (ARK_SUCCESS); @@ -1368,14 +1299,17 @@ int arkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) if (step_mem->implicit) { fprintf(fp, " Implicit predictor method = %i\n", step_mem->predictor); - fprintf(fp, " Implicit solver tolerance coefficient = %" RSYM "\n", + fprintf(fp, + " Implicit solver tolerance coefficient = " SUN_REAL_FORMAT_G "\n", step_mem->nlscoef); fprintf(fp, " Maximum number of nonlinear corrections = %i\n", step_mem->maxcor); - fprintf(fp, " Nonlinear convergence rate constant = %" RSYM "\n", + fprintf(fp, " Nonlinear convergence rate constant = " SUN_REAL_FORMAT_G "\n", step_mem->crdown); - fprintf(fp, " Nonlinear divergence tolerance = %" RSYM "\n", step_mem->rdiv); - fprintf(fp, " Gamma factor LSetup tolerance = %" RSYM "\n", step_mem->dgmax); + fprintf(fp, " Nonlinear divergence tolerance = " SUN_REAL_FORMAT_G "\n", + step_mem->rdiv); + fprintf(fp, " Gamma factor LSetup tolerance = " SUN_REAL_FORMAT_G "\n", + step_mem->dgmax); fprintf(fp, " Number of steps between LSetup calls = %i\n", step_mem->msbp); } fprintf(fp, "\n"); diff --git a/src/arkode/arkode_butcher.c b/src/arkode/arkode_butcher.c index f0d4326d39..3fdca5a44d 100644 --- a/src/arkode/arkode_butcher.c +++ b/src/arkode/arkode_butcher.c @@ -392,17 +392,23 @@ void ARKodeButcherTable_Write(ARKodeButcherTable B, FILE* outfile) fprintf(outfile, " "); for (j = 0; j < B->stages; j++) { - fprintf(outfile, "%" RSYM " ", B->A[i][j]); + fprintf(outfile, SUN_REAL_FORMAT_G " ", B->A[i][j]); } fprintf(outfile, "\n"); } fprintf(outfile, " c = "); - for (i = 0; i < B->stages; i++) { fprintf(outfile, "%" RSYM " ", B->c[i]); } + for (i = 0; i < B->stages; i++) + { + fprintf(outfile, SUN_REAL_FORMAT_G " ", B->c[i]); + } fprintf(outfile, "\n"); fprintf(outfile, " b = "); - for (i = 0; i < B->stages; i++) { fprintf(outfile, "%" RSYM " ", B->b[i]); } + for (i = 0; i < B->stages; i++) + { + fprintf(outfile, SUN_REAL_FORMAT_G " ", B->b[i]); + } fprintf(outfile, "\n"); if (B->d != NULL) @@ -410,7 +416,7 @@ void ARKodeButcherTable_Write(ARKodeButcherTable B, FILE* outfile) fprintf(outfile, " d = "); for (i = 0; i < B->stages; i++) { - fprintf(outfile, "%" RSYM " ", B->d[i]); + fprintf(outfile, SUN_REAL_FORMAT_G " ", B->d[i]); } fprintf(outfile, "\n"); } diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 5cc09d2390..69e8470353 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -629,7 +629,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", "start-stage", - "step = %li, stage = 0, h = %" RSYM ", tcur = %" RSYM, + "step = %li, stage = 0, h = " SUN_REAL_FORMAT_G + ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, ark_mem->h, ark_mem->tcur); #endif @@ -667,7 +668,8 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::erkStep_TakeStep", "start-stage", - "step = %li, stage = %i, h = %" RSYM ", tcur = %" RSYM, + "step = %li, stage = %i, h = " SUN_REAL_FORMAT_G + ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, is, ark_mem->h, ark_mem->tcur); #endif @@ -722,7 +724,9 @@ int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #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, + "error-test", + "step = %li, h = " SUN_REAL_FORMAT_G + ", dsm = " SUN_REAL_FORMAT_G, ark_mem->nst, ark_mem->h, *dsmPtr); #endif diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 2b4ad70e3a..f83a93fa74 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -40,14 +40,6 @@ extern "C" { #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define RSYM ".32Lg" -#define RSYMW "41.32Lg" -#else -#define RSYM ".16g" -#define RSYMW "23.16g" -#endif - /*=============================================================== SHORTCUTS ===============================================================*/ @@ -651,31 +643,13 @@ int arkGetLastKFlag(void* arkode_mem, int* last_kflag); Reusable ARKODE Error Messages ===============================================================*/ -#if defined(SUNDIALS_EXTENDED_PRECISION) - -#define MSG_TIME "t = %Lg" -#define MSG_TIME_H "t = %Lg and h = %Lg" -#define MSG_TIME_INT "t = %Lg is not between tcur - hold = %Lg and tcur = %Lg." -#define MSG_TIME_TOUT "tout = %Lg" -#define MSG_TIME_TSTOP "tstop = %Lg" - -#elif defined(SUNDIALS_DOUBLE_PRECISION) - -#define MSG_TIME "t = %lg" -#define MSG_TIME_H "t = %lg and h = %lg" -#define MSG_TIME_INT "t = %lg is not between tcur - hold = %lg and tcur = %lg." -#define MSG_TIME_TOUT "tout = %lg" -#define MSG_TIME_TSTOP "tstop = %lg" - -#else - -#define MSG_TIME "t = %g" -#define MSG_TIME_H "t = %g and h = %g" -#define MSG_TIME_INT "t = %g is not between tcur - hold = %g and tcur = %g." -#define MSG_TIME_TOUT "tout = %g" -#define MSG_TIME_TSTOP "tstop = %g" - -#endif +#define MSG_TIME "t = " SUN_REAL_FORMAT_G +#define MSG_TIME_H "t = " SUN_REAL_FORMAT_G " and h = " SUN_REAL_FORMAT_G +#define MSG_TIME_INT \ + "t = " SUN_REAL_FORMAT_G " is not between tcur - hold = " SUN_REAL_FORMAT_G \ + " and tcur = " SUN_REAL_FORMAT_G +#define MSG_TIME_TOUT "tout = " SUN_REAL_FORMAT_G +#define MSG_TIME_TSTOP "tstop = " SUN_REAL_FORMAT_G /* Initialization and I/O error messages */ #define MSG_ARK_NO_MEM "arkode_mem = NULL illegal." diff --git a/src/arkode/arkode_interp.c b/src/arkode/arkode_interp.c index daf42de479..7ee0e6970a 100644 --- a/src/arkode/arkode_interp.c +++ b/src/arkode/arkode_interp.c @@ -270,11 +270,12 @@ void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile) { fprintf(outfile, "arkode_interp (Hermite): degree = %d\n", HINT_DEGREE(interp)); - fprintf(outfile, "arkode_interp (Hermite): told = %" RSYM "\n", + fprintf(outfile, "arkode_interp (Hermite): told = " SUN_REAL_FORMAT_G "\n", HINT_TOLD(interp)); - fprintf(outfile, "arkode_interp (Hermite): tnew = %" RSYM "\n", + fprintf(outfile, "arkode_interp (Hermite): tnew = " SUN_REAL_FORMAT_G "\n", HINT_TNEW(interp)); - fprintf(outfile, "arkode_interp (Hermite): h = %" RSYM "\n", HINT_H(interp)); + fprintf(outfile, "arkode_interp (Hermite): h = " SUN_REAL_FORMAT_G "\n", + HINT_H(interp)); #ifdef SUNDIALS_DEBUG_PRINTVEC fprintf(outfile, "arkode_interp (Hermite): fold:\n"); N_VPrintFile(HINT_FOLD(interp), outfile); @@ -463,7 +464,7 @@ int arkInterpEvaluate_Hermite(ARKodeMem ark_mem, ARKInterp interp, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkInterpEvaluate_Hermite", "interp-eval", - "tau = %" RSYM ", d = %i, q = %i", tau, d, q); + "tau = " SUN_REAL_FORMAT_G ", d = %i, q = %i", tau, d, q); #endif /* call full RHS if needed -- called just AFTER the end of a step, so yn has @@ -964,7 +965,7 @@ void arkInterpPrintMem_Lagrange(ARKInterp I, FILE* outfile) fprintf(outfile, "arkode_interp (Lagrange): thist ="); for (i = 0; i < LINT_NMAX(I); i++) { - fprintf(outfile, " %" RSYM, LINT_TJ(I, i)); + fprintf(outfile, " " SUN_REAL_FORMAT_G, LINT_TJ(I, i)); } fprintf(outfile, "\n"); } @@ -1206,7 +1207,8 @@ int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tau, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkInterpEvaluate_Lagrange", "interp-eval", - "tau = %" RSYM ", d = %i, q = %i", tau, deriv, q); + "tau = " SUN_REAL_FORMAT_G ", d = %i, q = %i", tau, deriv, + q); #endif /* error on illegal deriv */ diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index b8a12c6a33..f2e718964c 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -2720,56 +2720,33 @@ int ARKodePrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) } ark_mem = (ARKodeMem)arkode_mem; - switch (fmt) - { - case SUN_OUTPUTFORMAT_TABLE: - fprintf(outfile, "Current time = %" RSYM "\n", ark_mem->tcur); - fprintf(outfile, "Steps = %ld\n", ark_mem->nst); - fprintf(outfile, "Step attempts = %ld\n", - ark_mem->nst_attempts); - fprintf(outfile, "Stability limited steps = %ld\n", - ark_mem->hadapt_mem->nst_exp); - fprintf(outfile, "Accuracy limited steps = %ld\n", - ark_mem->hadapt_mem->nst_acc); - fprintf(outfile, "Error test fails = %ld\n", ark_mem->netf); - fprintf(outfile, "NLS step fails = %ld\n", ark_mem->ncfn); - fprintf(outfile, "Inequality constraint fails = %ld\n", - ark_mem->nconstrfails); - fprintf(outfile, "Initial step size = %" RSYM "\n", ark_mem->h0u); - fprintf(outfile, "Last step size = %" RSYM "\n", ark_mem->hold); - fprintf(outfile, "Current step size = %" RSYM "\n", - ark_mem->next_h); - if (ark_mem->root_mem) - { - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - fprintf(outfile, "Root fn evals = %ld\n", ark_root_mem->nge); - } - break; - case SUN_OUTPUTFORMAT_CSV: - fprintf(outfile, "Time,%" RSYM, ark_mem->tcur); - fprintf(outfile, ",Steps,%ld", ark_mem->nst); - fprintf(outfile, ",Step attempts,%ld", ark_mem->nst_attempts); - fprintf(outfile, ",Stability limited steps,%ld", - ark_mem->hadapt_mem->nst_exp); - fprintf(outfile, ",Accuracy limited steps,%ld", ark_mem->hadapt_mem->nst_acc); - fprintf(outfile, ",Error test fails,%ld", ark_mem->netf); - fprintf(outfile, ",NLS step fails,%ld", ark_mem->ncfn); - fprintf(outfile, ",Inequality constraint fails,%ld", ark_mem->nconstrfails); - fprintf(outfile, ",Initial step size,%" RSYM, ark_mem->h0u); - fprintf(outfile, ",Last step size,%" RSYM, ark_mem->hold); - fprintf(outfile, ",Current step size,%" RSYM, ark_mem->next_h); - if (ark_mem->root_mem) - { - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - fprintf(outfile, ",Roof fn evals,%ld", ark_root_mem->nge); - } - break; - default: + if (fmt != SUN_OUTPUTFORMAT_TABLE && fmt != SUN_OUTPUTFORMAT_CSV) + { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "Invalid formatting option."); return (ARK_ILL_INPUT); } + sunfprintf_real(outfile, fmt, SUNTRUE, "Current time", ark_mem->tcur); + sunfprintf_long(outfile, fmt, SUNFALSE, "Steps", ark_mem->nst); + sunfprintf_long(outfile, fmt, SUNFALSE, "Step attempts", ark_mem->nst_attempts); + sunfprintf_long(outfile, fmt, SUNFALSE, "Stability limited steps", + ark_mem->hadapt_mem->nst_exp); + sunfprintf_long(outfile, fmt, SUNFALSE, "Accuracy limited steps", + ark_mem->hadapt_mem->nst_acc); + sunfprintf_long(outfile, fmt, SUNFALSE, "Error test fails", ark_mem->netf); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS step fails", ark_mem->ncfn); + sunfprintf_long(outfile, fmt, SUNFALSE, "Inequality constraint fails", + ark_mem->nconstrfails); + sunfprintf_real(outfile, fmt, SUNFALSE, "Initial step size", ark_mem->h0u); + sunfprintf_real(outfile, fmt, SUNFALSE, "Last step size", ark_mem->hold); + sunfprintf_real(outfile, fmt, SUNFALSE, "Current step size", ark_mem->next_h); + if (ark_mem->root_mem) + { + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + sunfprintf_long(outfile, fmt, SUNFALSE, "Root fn evals", ark_root_mem->nge); + } + /* Print relaxation stats */ if (ark_mem->relax_enabled) { @@ -2884,11 +2861,12 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp) fprintf(fp, "ARKODE solver parameters:\n"); if (ark_mem->hmin != ZERO) { - fprintf(fp, " Minimum step size = %" RSYM "\n", ark_mem->hmin); + fprintf(fp, " Minimum step size = " SUN_REAL_FORMAT_G "\n", ark_mem->hmin); } if (ark_mem->hmax_inv != ZERO) { - fprintf(fp, " Maximum step size = %" RSYM "\n", ONE / ark_mem->hmax_inv); + fprintf(fp, " Maximum step size = " SUN_REAL_FORMAT_G "\n", + ONE / ark_mem->hmax_inv); } if (ark_mem->fixedstep) { fprintf(fp, " Fixed time-stepping enabled\n"); } if (ark_mem->itol == ARK_WF) @@ -2897,10 +2875,12 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp) } else { - fprintf(fp, " Solver relative tolerance = %" RSYM "\n", ark_mem->reltol); + fprintf(fp, " Solver relative tolerance = " SUN_REAL_FORMAT_G "\n", + ark_mem->reltol); if (ark_mem->itol == ARK_SS) { - fprintf(fp, " Solver absolute tolerance = %" RSYM "\n", ark_mem->Sabstol); + fprintf(fp, " Solver absolute tolerance = " SUN_REAL_FORMAT_G "\n", + ark_mem->Sabstol); } else { fprintf(fp, " Vector-valued solver absolute tolerance\n"); } } @@ -2914,7 +2894,7 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp) { if (ark_mem->ritol == ARK_SS) { - fprintf(fp, " Absolute residual tolerance = %" RSYM "\n", + fprintf(fp, " Absolute residual tolerance = " SUN_REAL_FORMAT_G "\n", ark_mem->SRabstol); } else { fprintf(fp, " Vector-valued residual absolute tolerance\n"); } @@ -2922,25 +2902,28 @@ int ARKodeWriteParameters(void* arkode_mem, FILE* fp) } if (ark_mem->hin != ZERO) { - fprintf(fp, " Initial step size = %" RSYM "\n", ark_mem->hin); + fprintf(fp, " Initial step size = " SUN_REAL_FORMAT_G "\n", ark_mem->hin); } fprintf(fp, "\n"); - fprintf(fp, " Maximum step increase (first step) = %" RSYM "\n", + fprintf(fp, " Maximum step increase (first step) = " SUN_REAL_FORMAT_G "\n", ark_mem->hadapt_mem->etamx1); - fprintf(fp, " Step reduction factor on multiple error fails = %" RSYM "\n", + fprintf(fp, + " Step reduction factor on multiple error fails = " SUN_REAL_FORMAT_G + "\n", ark_mem->hadapt_mem->etamxf); fprintf(fp, " Minimum error fails before above factor is used = %i\n", ark_mem->hadapt_mem->small_nef); - fprintf(fp, - " Step reduction factor on nonlinear convergence failure = %" RSYM - "\n", + fprintf(fp, " Step reduction factor on nonlinear convergence failure = " SUN_REAL_FORMAT_G "\n", ark_mem->hadapt_mem->etacf); - fprintf(fp, " Explicit safety factor = %" RSYM "\n", ark_mem->hadapt_mem->cfl); - fprintf(fp, " Safety factor = %" RSYM "\n", ark_mem->hadapt_mem->safety); - fprintf(fp, " Growth factor = %" RSYM "\n", ark_mem->hadapt_mem->growth); - fprintf(fp, " Step growth lower bound = %" RSYM "\n", + fprintf(fp, " Explicit safety factor = " SUN_REAL_FORMAT_G "\n", + ark_mem->hadapt_mem->cfl); + fprintf(fp, " Safety factor = " SUN_REAL_FORMAT_G "\n", + ark_mem->hadapt_mem->safety); + fprintf(fp, " Growth factor = " SUN_REAL_FORMAT_G "\n", + ark_mem->hadapt_mem->growth); + fprintf(fp, " Step growth lower bound = " SUN_REAL_FORMAT_G "\n", ark_mem->hadapt_mem->lbound); - fprintf(fp, " Step growth upper bound = %" RSYM "\n", + fprintf(fp, " Step growth upper bound = " SUN_REAL_FORMAT_G "\n", ark_mem->hadapt_mem->ubound); if (ark_mem->hadapt_mem->expstab == arkExpStab) { diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index 646b87ab6f..5429614a29 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -3426,7 +3426,8 @@ int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkLsSolve", "ls-stats", - "bnorm = %" RSYM ", resnorm = %" RSYM + "bnorm = " SUN_REAL_FORMAT_G + ", resnorm = " SUN_REAL_FORMAT_G ", ls_iters = %i, prec_solves = %i", bnorm, resnorm, nli_inc, (int)(arkls_mem->nps - nps_inc)); #else @@ -3854,7 +3855,8 @@ int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkLsMassSolve", "mass-ls-stats", - "resnorm = %" RSYM ", ls_iters = %i, prec_solves = %i", + "resnorm = " SUN_REAL_FORMAT_G + ", 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. */ diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index fa6dd9b256..72e11f124e 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -561,7 +561,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) fprintf(outfile, " c = "); for (i = 0; i < MRIC->stages; i++) { - fprintf(outfile, "%" RSYM " ", MRIC->c[i]); + fprintf(outfile, SUN_REAL_FORMAT_G " ", MRIC->c[i]); } fprintf(outfile, "\n"); @@ -575,7 +575,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) fprintf(outfile, " "); for (j = 0; j < MRIC->stages; j++) { - fprintf(outfile, "%" RSYMW " ", MRIC->W[k][i][j]); + fprintf(outfile, SUN_REAL_FORMAT_G " ", MRIC->W[k][i][j]); } fprintf(outfile, "\n"); } @@ -593,7 +593,7 @@ void MRIStepCoupling_Write(MRIStepCoupling MRIC, FILE* outfile) fprintf(outfile, " "); for (j = 0; j < MRIC->stages; j++) { - fprintf(outfile, "%" RSYMW " ", MRIC->G[k][i][j]); + fprintf(outfile, SUN_REAL_FORMAT_G " ", MRIC->G[k][i][j]); } fprintf(outfile, "\n"); } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 3e856a724a..a91a6ee7e0 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -685,26 +685,27 @@ void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "MRIStep: Coupling structure:\n"); MRIStepCoupling_Write(step_mem->MRIC, outfile); - fprintf(outfile, "MRIStep: gamma = %" RSYM "\n", step_mem->gamma); - fprintf(outfile, "MRIStep: gammap = %" RSYM "\n", step_mem->gammap); - fprintf(outfile, "MRIStep: gamrat = %" RSYM "\n", step_mem->gamrat); - fprintf(outfile, "MRIStep: crate = %" RSYM "\n", step_mem->crate); - fprintf(outfile, "MRIStep: delp = %" RSYM "\n", step_mem->delp); - fprintf(outfile, "MRIStep: eRNrm = %" RSYM "\n", step_mem->eRNrm); - fprintf(outfile, "MRIStep: nlscoef = %" RSYM "\n", step_mem->nlscoef); - fprintf(outfile, "MRIStep: crdown = %" RSYM "\n", step_mem->crdown); - fprintf(outfile, "MRIStep: rdiv = %" RSYM "\n", step_mem->rdiv); - fprintf(outfile, "MRIStep: dgmax = %" RSYM "\n", step_mem->dgmax); + fprintf(outfile, "MRIStep: gamma = " SUN_REAL_FORMAT_G "\n", step_mem->gamma); + fprintf(outfile, "MRIStep: gammap = " SUN_REAL_FORMAT_G "\n", step_mem->gammap); + fprintf(outfile, "MRIStep: gamrat = " SUN_REAL_FORMAT_G "\n", step_mem->gamrat); + fprintf(outfile, "MRIStep: crate = " SUN_REAL_FORMAT_G "\n", step_mem->crate); + fprintf(outfile, "MRIStep: delp = " SUN_REAL_FORMAT_G "\n", step_mem->delp); + fprintf(outfile, "MRIStep: eRNrm = " SUN_REAL_FORMAT_G "\n", step_mem->eRNrm); + fprintf(outfile, "MRIStep: nlscoef = " SUN_REAL_FORMAT_G "\n", + step_mem->nlscoef); + fprintf(outfile, "MRIStep: crdown = " SUN_REAL_FORMAT_G "\n", step_mem->crdown); + fprintf(outfile, "MRIStep: rdiv = " SUN_REAL_FORMAT_G "\n", step_mem->rdiv); + fprintf(outfile, "MRIStep: dgmax = " SUN_REAL_FORMAT_G "\n", step_mem->dgmax); fprintf(outfile, "MRIStep: Ae_row ="); for (i = 0; i < step_mem->nstages_active; i++) { - fprintf(outfile, " %" RSYM, step_mem->Ae_row[i]); + fprintf(outfile, " " SUN_REAL_FORMAT_G, step_mem->Ae_row[i]); } fprintf(outfile, "\n"); fprintf(outfile, "MRIStep: Ai_row ="); for (i = 0; i < step_mem->nstages_active; i++) { - fprintf(outfile, " %" RSYM, step_mem->Ai_row[i]); + fprintf(outfile, " " SUN_REAL_FORMAT_G, step_mem->Ai_row[i]); } fprintf(outfile, "\n"); @@ -1491,7 +1492,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) } #ifdef SUNDIALS_DEBUG - printf(" MRIStep step %li, stage 0, h = %" RSYM ", t_n = %" RSYM "\n", + printf(" MRIStep step %li, stage 0, h = " SUN_REAL_FORMAT_G + ", t_n = " SUN_REAL_FORMAT_G "\n", ark_mem->nst, ark_mem->h, ark_mem->tcur); #endif @@ -1527,8 +1529,8 @@ int mriStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStep", "start-stage", - "step = %li, stage = %i, stage type = %d, h = %" RSYM - ", tcur = %" RSYM, + "step = %li, stage = %i, stage type = %d, h " + "= " SUN_REAL_FORMAT_G ", tcur = " SUN_REAL_FORMAT_G, ark_mem->nst, is, step_mem->stagetypes[is], ark_mem->h, ark_mem->tcur); #endif @@ -1640,7 +1642,9 @@ 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", - "error-test", "step = %li, h = %" RSYM ", dsm = %" RSYM, + "error-test", + "step = %li, h = " SUN_REAL_FORMAT_G + ", dsm = " SUN_REAL_FORMAT_G, ark_mem->nst, ark_mem->h, *dsmPtr); #endif @@ -2811,7 +2815,8 @@ int mriStepInnerStepper_Evolve(MRIStepInnerStepper stepper, sunrealtype t0, #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); + "t0 = " SUN_REAL_FORMAT_G ", tout = " SUN_REAL_FORMAT_G, + t0, tout); #endif stepper->last_flag = stepper->ops->evolve(stepper, t0, tout, y); @@ -2849,7 +2854,7 @@ int mriStepInnerStepper_Reset(MRIStepInnerStepper stepper, sunrealtype tR, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(stepper->sunctx->logger, SUN_LOGLEVEL_INFO, "ARKODE::mriStepInnerStepper_Reset", "reset-inner-state", - "tR = %" RSYM, tR); + "tR = " SUN_REAL_FORMAT_G, tR); #endif if (stepper->ops->reset) diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index d803141044..71a6a4e8b2 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -677,100 +677,48 @@ int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - switch (fmt) + /* function evaluations */ + sunfprintf_long(outfile, fmt, SUNTRUE, "Explicit slow RHS fn evals", + step_mem->nfse); + sunfprintf_long(outfile, fmt, SUNFALSE, "Implicit slow RHS fn evals", + step_mem->nfsi); + + /* nonlinear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS iters", step_mem->nls_iters); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS fails", step_mem->nls_fails); + if (ark_mem->nst > 0) { - case SUN_OUTPUTFORMAT_TABLE: - /* function evaluations */ - fprintf(outfile, "Explicit slow RHS fn evals = %ld\n", step_mem->nfse); - fprintf(outfile, "Implicit slow RHS fn evals = %ld\n", step_mem->nfsi); - - /* nonlinear solver stats */ - fprintf(outfile, "NLS iters = %ld\n", step_mem->nls_iters); - fprintf(outfile, "NLS fails = %ld\n", step_mem->nls_fails); - if (ark_mem->nst > 0) - { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", - (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); - } - - /* linear solver stats */ - fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); - if (ark_mem->step_getlinmem(ark_mem)) - { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); - fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); - fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); - fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", arkls_mem->nps); - fprintf(outfile, "LS iters = %ld\n", arkls_mem->nli); - fprintf(outfile, "LS fails = %ld\n", arkls_mem->ncfl); - fprintf(outfile, "Jac-times setups = %ld\n", - arkls_mem->njtsetup); - fprintf(outfile, "Jac-times evals = %ld\n", - arkls_mem->njtimes); - if (step_mem->nls_iters > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); - } - } - break; - - case SUN_OUTPUTFORMAT_CSV: - /* function evaluations */ - fprintf(outfile, ",Explicit slow RHS fn evals,%ld", step_mem->nfse); - fprintf(outfile, ",Implicit slow RHS fn evals,%ld", step_mem->nfsi); - - /* nonlinear solver stats */ - fprintf(outfile, ",NLS iters,%ld", step_mem->nls_iters); - fprintf(outfile, ",NLS fails,%ld", step_mem->nls_fails); - if (ark_mem->nst > 0) - { - fprintf(outfile, ",NLS iters per step,%" RSYM, - (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); - } - else { fprintf(outfile, ",NLS iters per step,0"); } + sunfprintf_real(outfile, fmt, SUNFALSE, "NLS iters per step", + (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); + } - /* linear solver stats */ - fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); - if (ark_mem->step_getlinmem(ark_mem)) + /* linear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "LS setups", step_mem->nsetups); + if (ark_mem->step_getlinmem(ark_mem)) + { + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac fn evals", arkls_mem->nje); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS RHS fn evals", arkls_mem->nfeDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec setup evals", arkls_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec solves", arkls_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS iters", arkls_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS fails", arkls_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times setups", + arkls_mem->njtsetup); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times evals", + arkls_mem->njtimes); + if (step_mem->nls_iters > 0) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); - fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); - fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); - fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); - fprintf(outfile, ",Prec solves,%ld", arkls_mem->nps); - fprintf(outfile, ",LS iters,%ld", arkls_mem->nli); - fprintf(outfile, ",LS fails,%ld", arkls_mem->ncfl); - fprintf(outfile, ",Jac-times setups,%ld", arkls_mem->njtsetup); - fprintf(outfile, ",Jac-times evals,%ld", arkls_mem->njtimes); - if (step_mem->nls_iters > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } + sunfprintf_real(outfile, fmt, SUNFALSE, "LS iters per NLS iter", + (sunrealtype)arkls_mem->nli / + (sunrealtype)step_mem->nls_iters); + sunfprintf_real(outfile, fmt, SUNFALSE, "Jac evals per NLS iter", + (sunrealtype)arkls_mem->nje / + (sunrealtype)step_mem->nls_iters); + sunfprintf_real(outfile, fmt, SUNFALSE, "Prec evals per NLS iter", + (sunrealtype)arkls_mem->npe / + (sunrealtype)step_mem->nls_iters); } - fprintf(outfile, "\n"); - break; - - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return (ARK_ILL_INPUT); } return (ARK_SUCCESS); @@ -815,14 +763,17 @@ int mriStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) if (step_mem->implicit_rhs) { fprintf(fp, " Implicit predictor method = %i\n", step_mem->predictor); - fprintf(fp, " Implicit solver tolerance coefficient = %" RSYM "\n", + fprintf(fp, + " Implicit solver tolerance coefficient = " SUN_REAL_FORMAT_G "\n", step_mem->nlscoef); fprintf(fp, " Maximum number of nonlinear corrections = %i\n", step_mem->maxcor); - fprintf(fp, " Nonlinear convergence rate constant = %" RSYM "\n", + fprintf(fp, " Nonlinear convergence rate constant = " SUN_REAL_FORMAT_G "\n", step_mem->crdown); - fprintf(fp, " Nonlinear divergence tolerance = %" RSYM "\n", step_mem->rdiv); - fprintf(fp, " Gamma factor LSetup tolerance = %" RSYM "\n", step_mem->dgmax); + fprintf(fp, " Nonlinear divergence tolerance = " SUN_REAL_FORMAT_G "\n", + step_mem->rdiv); + fprintf(fp, " Gamma factor LSetup tolerance = " SUN_REAL_FORMAT_G "\n", + step_mem->dgmax); fprintf(fp, " Number of steps between LSetup calls = %i\n", step_mem->msbp); } fprintf(fp, "\n"); diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index c911077580..fef9ec9ccd 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -125,7 +125,8 @@ static int arkRelaxNewtonSolve(ARKodeMem ark_mem) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxNewtonSolve", "residual", - "iter = %i, relax_param = %" RSYM ", residual = %" RSYM, + "iter = %i, relax_param = " SUN_REAL_FORMAT_G + ", residual = " SUN_REAL_FORMAT_G, i, relax_mem->relax_param, relax_mem->res); #endif @@ -349,7 +350,8 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", - "compute delta e", "delta_e = %" RSYM, relax_mem->delta_e); + "compute delta e", "delta_e = " SUN_REAL_FORMAT_G, + relax_mem->delta_e); #endif /* Get the change in state (delta_y = tempv2) */ @@ -370,7 +372,8 @@ static int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkRelaxSolve", - "compute old e", "e_old = %" RSYM, relax_mem->e_old); + "compute old e", "e_old = " SUN_REAL_FORMAT_G, + relax_mem->e_old); #endif /* Initial guess for relaxation parameter */ @@ -915,8 +918,9 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkStep_TakeStep_Z", "relaxation", - "relaxation parameter = %" RSYM ", relaxed h = %" RSYM - ", relaxed error = %" RSYM, + "relaxation parameter = " SUN_REAL_FORMAT_G + ", relaxed h = " SUN_REAL_FORMAT_G + ", relaxed error = " SUN_REAL_FORMAT_G, relax_val, ark_mem->h, *dsm_inout); #endif diff --git a/src/arkode/arkode_root.c b/src/arkode/arkode_root.c index 05d0a4a08c..05ed6c300a 100644 --- a/src/arkode/arkode_root.c +++ b/src/arkode/arkode_root.c @@ -365,14 +365,15 @@ int arkPrintRootMem(void* arkode_mem, FILE* outfile) ark_mem->root_mem->gactive[i]); } } - fprintf(outfile, "ark_tlo = %" RSYM "\n", ark_mem->root_mem->tlo); - fprintf(outfile, "ark_thi = %" RSYM "\n", ark_mem->root_mem->thi); - fprintf(outfile, "ark_trout = %" RSYM "\n", ark_mem->root_mem->trout); + fprintf(outfile, "ark_tlo = " SUN_REAL_FORMAT_G "\n", ark_mem->root_mem->tlo); + fprintf(outfile, "ark_thi = " SUN_REAL_FORMAT_G "\n", ark_mem->root_mem->thi); + fprintf(outfile, "ark_trout = " SUN_REAL_FORMAT_G "\n", + ark_mem->root_mem->trout); if (ark_mem->root_mem->glo != NULL) { for (i = 0; i < ark_mem->root_mem->nrtfn; i++) { - fprintf(outfile, "ark_glo[%i] = %" RSYM "\n", i, + fprintf(outfile, "ark_glo[%i] = " SUN_REAL_FORMAT_G "\n", i, ark_mem->root_mem->glo[i]); } } @@ -380,7 +381,7 @@ int arkPrintRootMem(void* arkode_mem, FILE* outfile) { for (i = 0; i < ark_mem->root_mem->nrtfn; i++) { - fprintf(outfile, "ark_ghi[%i] = %" RSYM "\n", i, + fprintf(outfile, "ark_ghi[%i] = " SUN_REAL_FORMAT_G "\n", i, ark_mem->root_mem->ghi[i]); } } @@ -388,12 +389,14 @@ int arkPrintRootMem(void* arkode_mem, FILE* outfile) { for (i = 0; i < ark_mem->root_mem->nrtfn; i++) { - fprintf(outfile, "ark_grout[%i] = %" RSYM "\n", i, + fprintf(outfile, "ark_grout[%i] = " SUN_REAL_FORMAT_G "\n", i, ark_mem->root_mem->grout[i]); } } - fprintf(outfile, "ark_toutc = %" RSYM "\n", ark_mem->root_mem->toutc); - fprintf(outfile, "ark_ttol = %" RSYM "\n", ark_mem->root_mem->ttol); + fprintf(outfile, "ark_toutc = " SUN_REAL_FORMAT_G "\n", + ark_mem->root_mem->toutc); + fprintf(outfile, "ark_ttol = " SUN_REAL_FORMAT_G "\n", + ark_mem->root_mem->ttol); } return (ARK_SUCCESS); } diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index d10dbf923c..4f9133cf12 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -128,17 +128,10 @@ SUNErrCode SUNAdaptController_Write_ARKUserControl(SUNAdaptController C, FILE* fptr) { fprintf(fptr, "ARKUserControl module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " hp = %12Lg\n", SC_HP(C)); - fprintf(fptr, " hpp = %12Lg\n", SC_HPP(C)); - fprintf(fptr, " ep = %12Lg\n", SC_EP(C)); - fprintf(fptr, " epp = %12Lg\n", SC_EPP(C)); -#else - fprintf(fptr, " hp = %12g\n", SC_HP(C)); - fprintf(fptr, " hpp = %12g\n", SC_HPP(C)); - fprintf(fptr, " ep = %12g\n", SC_EP(C)); - fprintf(fptr, " epp = %12g\n", SC_EPP(C)); -#endif + fprintf(fptr, " hp = " SUN_REAL_FORMAT_G "\n", SC_HP(C)); + fprintf(fptr, " hpp = " SUN_REAL_FORMAT_G "\n", SC_HPP(C)); + fprintf(fptr, " ep = " SUN_REAL_FORMAT_G "\n", SC_EP(C)); + fprintf(fptr, " epp = " SUN_REAL_FORMAT_G "\n", SC_EPP(C)); fprintf(fptr, " hadapt_data = %p\n", SC_DATA(C)); return SUN_SUCCESS; } diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c index 0558991e85..9440962a99 100644 --- a/src/cvode/cvode.c +++ b/src/cvode/cvode.c @@ -2356,7 +2356,8 @@ static int cvStep(CVodeMem cv_mem) #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", + "step = %li, h = " SUN_REAL_FORMAT_G + ", q = %d, t_n = " SUN_REAL_FORMAT_G "", cv_mem->cv_nst, cv_mem->cv_next_h, cv_mem->cv_next_q, cv_mem->cv_tn); #endif @@ -3294,7 +3295,9 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", - "error-test", "step = %li, h = %.16g, dsm = %.16g", + "error-test", + "step = %li, h = " SUN_REAL_FORMAT_G + ", dsm = " SUN_REAL_FORMAT_G, cv_mem->cv_nst, cv_mem->cv_h, dsm); #endif @@ -3334,7 +3337,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", - "new-step-eta", "eta = %.16g", cv_mem->cv_eta); + "new-step-eta", "eta = " SUN_REAL_FORMAT_G, + cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -3352,7 +3356,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, "CVODE::cvDoErrorTest", - "new-step-eta-mxnef1", "eta = %.16g", cv_mem->cv_eta); + "new-step-eta-mxnef1", "eta = " SUN_REAL_FORMAT_G, + cv_mem->cv_eta); #endif return (TRY_AGAIN); } @@ -3377,7 +3382,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvDoErrorTest", - "new-step-eta-mxnef1-q1", "eta = %.16g", cv_mem->cv_eta); + "new-step-eta-mxnef1-q1", "eta = " SUN_REAL_FORMAT_G, + cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -3503,7 +3509,8 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvPrepareNextStep", "return", - "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d\n", + "eta = " SUN_REAL_FORMAT_G ", hprime = " SUN_REAL_FORMAT_G + ", qprime = %d, qwait = %d\n", cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, cv_mem->cv_qwait); #endif diff --git a/src/cvode/cvode_impl.h b/src/cvode/cvode_impl.h index e2f3a36350..08e0f54fd3 100644 --- a/src/cvode/cvode_impl.h +++ b/src/cvode/cvode_impl.h @@ -32,14 +32,6 @@ extern "C" { #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define RSYM ".32Lg" -#define RSYMW "19.32Lg" -#else -#define RSYM ".16g" -#define RSYMW "23.16g" -#endif - /*=============================================================== SHORTCUTS ===============================================================*/ @@ -669,31 +661,13 @@ int cvDiagSolve_updateM(const sunrealtype r, N_Vector M); * ================================================================= */ -#if defined(SUNDIALS_EXTENDED_PRECISION) - -#define MSG_TIME "t = %Lg" -#define MSG_TIME_H "t = %Lg and h = %Lg" -#define MSG_TIME_INT "t = %Lg is not between tcur - hu = %Lg and tcur = %Lg." -#define MSG_TIME_TOUT "tout = %Lg" -#define MSG_TIME_TSTOP "tstop = %Lg" - -#elif defined(SUNDIALS_DOUBLE_PRECISION) - -#define MSG_TIME "t = %lg" -#define MSG_TIME_H "t = %lg and h = %lg" -#define MSG_TIME_INT "t = %lg is not between tcur - hu = %lg and tcur = %lg." -#define MSG_TIME_TOUT "tout = %lg" -#define MSG_TIME_TSTOP "tstop = %lg" - -#else - -#define MSG_TIME "t = %g" -#define MSG_TIME_H "t = %g and h = %g" -#define MSG_TIME_INT "t = %g is not between tcur - hu = %g and tcur = %g." -#define MSG_TIME_TOUT "tout = %g" -#define MSG_TIME_TSTOP "tstop = %g" - -#endif +#define MSG_TIME "t = " SUN_REAL_FORMAT_G +#define MSG_TIME_H "t = " SUN_REAL_FORMAT_G " and h = " SUN_REAL_FORMAT_G +#define MSG_TIME_INT \ + "t = " SUN_REAL_FORMAT_G " is not between tcur - hold = " SUN_REAL_FORMAT_G \ + " and tcur = " SUN_REAL_FORMAT_G +#define MSG_TIME_TOUT "tout = " SUN_REAL_FORMAT_G +#define MSG_TIME_TSTOP "tstop = " SUN_REAL_FORMAT_G /* Initialization and I/O error messages */ diff --git a/src/cvode/cvode_io.c b/src/cvode/cvode_io.c index 1f23b850c0..a6798f53b8 100644 --- a/src/cvode/cvode_io.c +++ b/src/cvode/cvode_io.c @@ -1632,148 +1632,71 @@ int CVodePrintAllStats(void* cvode_mem, FILE* outfile, SUNOutputFormat fmt) cv_mem = (CVodeMem)cvode_mem; - switch (fmt) - { - case SUN_OUTPUTFORMAT_TABLE: - /* step and method stats */ - fprintf(outfile, "Current time = %" RSYM "\n", cv_mem->cv_tn); - fprintf(outfile, "Steps = %ld\n", cv_mem->cv_nst); - fprintf(outfile, "Error test fails = %ld\n", cv_mem->cv_netf); - fprintf(outfile, "NLS step fails = %ld\n", cv_mem->cv_ncfn); - fprintf(outfile, "Initial step size = %" RSYM "\n", - cv_mem->cv_h0u); - fprintf(outfile, "Last step size = %" RSYM "\n", cv_mem->cv_hu); - fprintf(outfile, "Current step size = %" RSYM "\n", - cv_mem->cv_next_h); - fprintf(outfile, "Last method order = %d\n", cv_mem->cv_qu); - fprintf(outfile, "Current method order = %d\n", cv_mem->cv_next_q); - fprintf(outfile, "Stab. lim. order reductions = %ld\n", cv_mem->cv_nor); - - /* function evaluations */ - fprintf(outfile, "RHS fn evals = %ld\n", cv_mem->cv_nfe); - - /* nonlinear solver stats */ - fprintf(outfile, "NLS iters = %ld\n", cv_mem->cv_nni); - fprintf(outfile, "NLS fails = %ld\n", cv_mem->cv_nnf); - if (cv_mem->cv_nst > 0) - { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", - (sunrealtype)cv_mem->cv_nni / (sunrealtype)cv_mem->cv_nst); - } - - /* linear solver stats */ - fprintf(outfile, "LS setups = %ld\n", cv_mem->cv_nsetups); - if (cv_mem->cv_lmem) - { - cvls_mem = (CVLsMem)(cv_mem->cv_lmem); - fprintf(outfile, "Jac fn evals = %ld\n", cvls_mem->nje); - fprintf(outfile, "LS RHS fn evals = %ld\n", cvls_mem->nfeDQ); - fprintf(outfile, "Prec setup evals = %ld\n", cvls_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", cvls_mem->nps); - fprintf(outfile, "LS iters = %ld\n", cvls_mem->nli); - fprintf(outfile, "LS fails = %ld\n", cvls_mem->ncfl); - fprintf(outfile, "Jac-times setups = %ld\n", - cvls_mem->njtsetup); - fprintf(outfile, "Jac-times evals = %ld\n", cvls_mem->njtimes); - if (cv_mem->cv_nni > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)cvls_mem->nli / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)cvls_mem->nje / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)cvls_mem->npe / (sunrealtype)cv_mem->cv_nni); - } - } - - /* rootfinding stats */ - fprintf(outfile, "Root fn evals = %ld\n", cv_mem->cv_nge); - - /* projection stats */ - if (cv_mem->proj_mem) - { - cvproj_mem = (CVodeProjMem)(cv_mem->proj_mem); - fprintf(outfile, "Projection fn evals = %ld\n", cvproj_mem->nproj); - fprintf(outfile, "Projection fails = %ld\n", - cvproj_mem->npfails); - } - break; - - case SUN_OUTPUTFORMAT_CSV: - /* step and method stats */ - fprintf(outfile, "Time,%" RSYM, cv_mem->cv_tn); - fprintf(outfile, ",Steps,%ld", cv_mem->cv_nst); - fprintf(outfile, ",Error test fails,%ld", cv_mem->cv_netf); - fprintf(outfile, ",NLS step fails,%ld", cv_mem->cv_ncfn); - fprintf(outfile, ",Initial step size,%" RSYM, cv_mem->cv_h0u); - fprintf(outfile, ",Last step size,%" RSYM, cv_mem->cv_hu); - fprintf(outfile, ",Current step size,%" RSYM, cv_mem->cv_next_h); - fprintf(outfile, ",Last method order,%d", cv_mem->cv_qu); - fprintf(outfile, ",Current method order,%d", cv_mem->cv_next_q); - fprintf(outfile, ",Stab. lim. order reductions,%ld", cv_mem->cv_nor); - - /* function evaluations */ - fprintf(outfile, ",RHS fn evals,%ld", cv_mem->cv_nfe); - - /* nonlinear solver stats */ - fprintf(outfile, ",NLS iters,%ld", cv_mem->cv_nni); - fprintf(outfile, ",NLS fails,%ld", cv_mem->cv_nnf); - if (cv_mem->cv_nst > 0) - { - fprintf(outfile, ",NLS iters per step,%" RSYM, - (sunrealtype)cv_mem->cv_nni / (sunrealtype)cv_mem->cv_nst); - } - else { fprintf(outfile, ",NLS iters per step,0"); } - - /* linear solver stats */ - fprintf(outfile, ",LS setups,%ld", cv_mem->cv_nsetups); - if (cv_mem->cv_lmem) - { - cvls_mem = (CVLsMem)(cv_mem->cv_lmem); - fprintf(outfile, ",Jac fn evals,%ld", cvls_mem->nje); - fprintf(outfile, ",LS RHS fn evals,%ld", cvls_mem->nfeDQ); - fprintf(outfile, ",Prec setup evals,%ld", cvls_mem->npe); - fprintf(outfile, ",Prec solves,%ld", cvls_mem->nps); - fprintf(outfile, ",LS iters,%ld", cvls_mem->nli); - fprintf(outfile, ",LS fails,%ld", cvls_mem->ncfl); - fprintf(outfile, ",Jac-times setups,%ld", cvls_mem->njtsetup); - fprintf(outfile, ",Jac-times evals,%ld", cvls_mem->njtimes); - if (cv_mem->cv_nni > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)cvls_mem->nli / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)cvls_mem->nje / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)cvls_mem->npe / (sunrealtype)cv_mem->cv_nni); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } - } - - /* rootfinding stats */ - fprintf(outfile, ",Root fn evals,%ld", cv_mem->cv_nge); - - /* projection stats */ - if (cv_mem->proj_mem) - { - cvproj_mem = (CVodeProjMem)(cv_mem->proj_mem); - fprintf(outfile, ",Projection fn evals,%ld", cvproj_mem->nproj); - fprintf(outfile, ",Projection fails,%ld", cvproj_mem->npfails); - } - fprintf(outfile, "\n"); - break; - - default: + if (fmt != SUN_OUTPUTFORMAT_TABLE && fmt != SUN_OUTPUTFORMAT_CSV) + { cvProcessError(cv_mem, CV_ILL_INPUT, __LINE__, __func__, __FILE__, "Invalid formatting option."); return (CV_ILL_INPUT); } + /* step and method stats */ + sunfprintf_real(outfile, fmt, SUNTRUE, "Current time", cv_mem->cv_tn); + sunfprintf_long(outfile, fmt, SUNFALSE, "Steps", cv_mem->cv_nst); + sunfprintf_long(outfile, fmt, SUNFALSE, "Error test fails", cv_mem->cv_netf); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS step fails", cv_mem->cv_ncfn); + sunfprintf_real(outfile, fmt, SUNFALSE, "Initial step size", cv_mem->cv_h0u); + sunfprintf_real(outfile, fmt, SUNFALSE, "Last step size", cv_mem->cv_hu); + sunfprintf_real(outfile, fmt, SUNFALSE, "Current step size", cv_mem->cv_next_h); + sunfprintf_long(outfile, fmt, SUNFALSE, "Last method order", cv_mem->cv_qu); + sunfprintf_long(outfile, fmt, SUNFALSE, "Current method order", + cv_mem->cv_next_q); + sunfprintf_long(outfile, fmt, SUNFALSE, "Stab. lim. order reductions", + cv_mem->cv_nor); + /* function evaluations */ + sunfprintf_long(outfile, fmt, SUNFALSE, "RHS fn evals", cv_mem->cv_nfe); + /* nonlinear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS iters", cv_mem->cv_nni); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS fails", cv_mem->cv_nnf); + if (cv_mem->cv_nst > 0) + { + sunfprintf_real(outfile, fmt, SUNFALSE, "NLS iters per step", + (sunrealtype)cv_mem->cv_nni / (sunrealtype)cv_mem->cv_nst); + } + sunfprintf_long(outfile, fmt, SUNFALSE, "LS setups", cv_mem->cv_nsetups); + if (cv_mem->cv_lmem) + { + cvls_mem = (CVLsMem)(cv_mem->cv_lmem); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac fn evals", cvls_mem->nje); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS RHS fn evals", cvls_mem->nfeDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec setup evals", cvls_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec solves", cvls_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS iters", cvls_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS fails", cvls_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times setups", + cvls_mem->njtsetup); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times evals", cvls_mem->njtimes); + if (cv_mem->cv_nni > 0) + { + sunfprintf_real(outfile, fmt, SUNFALSE, "LS iters per NLS iter", + (sunrealtype)cvls_mem->nli / (sunrealtype)cv_mem->cv_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Jac evals per NLS iter", + (sunrealtype)cvls_mem->nje / (sunrealtype)cv_mem->cv_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Prec evals per NLS iter", + (sunrealtype)cvls_mem->npe / (sunrealtype)cv_mem->cv_nni); + } + } + /* rootfinding stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "Root fn evals", cv_mem->cv_nge); + /* projection stats */ + if (cv_mem->proj_mem) + { + cvproj_mem = (CVodeProjMem)(cv_mem->proj_mem); + sunfprintf_long(outfile, fmt, SUNFALSE, "Projection fn evals", + cvproj_mem->nproj); + sunfprintf_long(outfile, fmt, SUNFALSE, "Projection fails", + cvproj_mem->npfails); + } + return (CV_SUCCESS); } diff --git a/src/cvode/cvode_ls.c b/src/cvode/cvode_ls.c index 50c60c6e8b..41ab0493ed 100644 --- a/src/cvode/cvode_ls.c +++ b/src/cvode/cvode_ls.c @@ -1782,7 +1782,10 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvLsSolve", - "ls-stats", "bnorm = %.16g, resnorm = %.16g, ls_iters = %i, prec_solves = %i", + "ls-stats", + "bnorm = " SUN_REAL_FORMAT_G + ", resnorm = " SUN_REAL_FORMAT_G + ", 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 55399d7349..c772068fb3 100644 --- a/src/cvodes/cvodes.c +++ b/src/cvodes/cvodes.c @@ -5860,7 +5860,8 @@ static int cvStep(CVodeMem cv_mem) #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", + "step = %li, h = " SUN_REAL_FORMAT_G + ", q = %d, t_n = " SUN_REAL_FORMAT_G, cv_mem->cv_nst, cv_mem->cv_next_h, cv_mem->cv_next_q, cv_mem->cv_tn); #endif @@ -7470,7 +7471,9 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", - "error-test", "step = %li, h = %.16g, dsm = %.16g", + "error-test", + "step = %li, h = " SUN_REAL_FORMAT_G + ", dsm = " SUN_REAL_FORMAT_G, cv_mem->cv_nst, cv_mem->cv_h, dsm); #endif @@ -7510,7 +7513,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", - "new-step-eta", "eta = %.16g", cv_mem->cv_eta); + "new-step-eta", "eta = " SUN_REAL_FORMAT_G, + cv_mem->cv_eta); #endif return (TRY_AGAIN); @@ -7528,7 +7532,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, "CVODES::cvDoErrorTest", - "new-step-eta-mxnef1", "eta = %.16g", cv_mem->cv_eta); + "new-step-eta-mxnef1", "eta = " SUN_REAL_FORMAT_G, + cv_mem->cv_eta); #endif return (TRY_AGAIN); } @@ -7553,7 +7558,8 @@ static int cvDoErrorTest(CVodeMem cv_mem, int* nflagPtr, sunrealtype saved_t, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvDoErrorTest", - "new-step-eta-mxnef1-q1", "eta = %.16g", cv_mem->cv_eta); + "new-step-eta-mxnef1-q1", "eta = " SUN_REAL_FORMAT_G "", + cv_mem->cv_eta); #endif if (cv_mem->cv_quadr) @@ -7782,7 +7788,8 @@ static void cvPrepareNextStep(CVodeMem cv_mem, sunrealtype dsm) #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODES::cvPrepareNextStep", "return", - "eta = %.16g, hprime = %.16g, qprime = %d, qwait = %d\n", + "eta = " SUN_REAL_FORMAT_G ", hprime = " SUN_REAL_FORMAT_G + ", qprime = %d, qwait = %d\n", cv_mem->cv_eta, cv_mem->cv_hprime, cv_mem->cv_qprime, cv_mem->cv_qwait); #endif diff --git a/src/cvodes/cvodes_impl.h b/src/cvodes/cvodes_impl.h index c22d166359..adc4a42877 100644 --- a/src/cvodes/cvodes_impl.h +++ b/src/cvodes/cvodes_impl.h @@ -31,14 +31,6 @@ extern "C" { #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define RSYM ".32Lg" -#define RSYMW "19.32Lg" -#else -#define RSYM ".16g" -#define RSYMW "23.16g" -#endif - /*=================================================================*/ /* Shortcuts */ /*=================================================================*/ @@ -1188,31 +1180,13 @@ int cvSensRhs1InternalDQ(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, * ================================================================= */ -#if defined(SUNDIALS_EXTENDED_PRECISION) - -#define MSG_TIME "t = %Lg" -#define MSG_TIME_H "t = %Lg and h = %Lg" -#define MSG_TIME_INT "t = %Lg is not between tcur - hu = %Lg and tcur = %Lg." -#define MSG_TIME_TOUT "tout = %Lg" -#define MSG_TIME_TSTOP "tstop = %Lg" - -#elif defined(SUNDIALS_DOUBLE_PRECISION) - -#define MSG_TIME "t = %lg" -#define MSG_TIME_H "t = %lg and h = %lg" -#define MSG_TIME_INT "t = %lg is not between tcur - hu = %lg and tcur = %lg." -#define MSG_TIME_TOUT "tout = %lg" -#define MSG_TIME_TSTOP "tstop = %lg" - -#else - -#define MSG_TIME "t = %g" -#define MSG_TIME_H "t = %g and h = %g" -#define MSG_TIME_INT "t = %g is not between tcur - hu = %g and tcur = %g." -#define MSG_TIME_TOUT "tout = %g" -#define MSG_TIME_TSTOP "tstop = %g" - -#endif +#define MSG_TIME "t = " SUN_REAL_FORMAT_G +#define MSG_TIME_H "t = " SUN_REAL_FORMAT_G " and h = " SUN_REAL_FORMAT_G +#define MSG_TIME_INT \ + "t = " SUN_REAL_FORMAT_G " is not between tcur - hold = " SUN_REAL_FORMAT_G \ + " and tcur = " SUN_REAL_FORMAT_G +#define MSG_TIME_TOUT "tout = " SUN_REAL_FORMAT_G +#define MSG_TIME_TSTOP "tstop = " SUN_REAL_FORMAT_G /* Initialization and I/O error messages */ @@ -1447,7 +1421,7 @@ int cvSensRhs1InternalDQ(int Ns, sunrealtype t, N_Vector y, N_Vector ydot, "The final time tBout is outside the interval over which the forward " \ "problem was solved." #define MSGCV_BACK_ERROR "Error occured while integrating backward problem # %d" -#define MSGCV_BAD_TINTERP "Bad t = %g for interpolation." +#define MSGCV_BAD_TINTERP "Bad t = " SUN_REAL_FORMAT_G " for interpolation." #define MSGCV_WRONG_INTERP \ "This function cannot be called for the specified interp type." diff --git a/src/cvodes/cvodes_io.c b/src/cvodes/cvodes_io.c index e4599bd853..949c2a04dc 100644 --- a/src/cvodes/cvodes_io.c +++ b/src/cvodes/cvodes_io.c @@ -2522,7 +2522,6 @@ int CVodePrintAllStats(void* cvode_mem, FILE* outfile, SUNOutputFormat fmt) CVodeMem cv_mem; CVLsMem cvls_mem; CVodeProjMem cvproj_mem; - int is; if (cvode_mem == NULL) { @@ -2532,248 +2531,119 @@ int CVodePrintAllStats(void* cvode_mem, FILE* outfile, SUNOutputFormat fmt) cv_mem = (CVodeMem)cvode_mem; - switch (fmt) + if (fmt != SUN_OUTPUTFORMAT_TABLE && fmt != SUN_OUTPUTFORMAT_CSV) { - case SUN_OUTPUTFORMAT_TABLE: - /* step and method stats */ - fprintf(outfile, "Current time = %" RSYM "\n", cv_mem->cv_tn); - fprintf(outfile, "Steps = %ld\n", cv_mem->cv_nst); - fprintf(outfile, "Error test fails = %ld\n", cv_mem->cv_netf); - fprintf(outfile, "NLS step fails = %ld\n", cv_mem->cv_ncfn); - fprintf(outfile, "Initial step size = %" RSYM "\n", - cv_mem->cv_h0u); - fprintf(outfile, "Last step size = %" RSYM "\n", cv_mem->cv_hu); - fprintf(outfile, "Current step size = %" RSYM "\n", - cv_mem->cv_next_h); - fprintf(outfile, "Last method order = %d\n", cv_mem->cv_qu); - fprintf(outfile, "Current method order = %d\n", cv_mem->cv_next_q); - fprintf(outfile, "Stab. lim. order reductions = %ld\n", cv_mem->cv_nor); - - /* function evaluations */ - fprintf(outfile, "RHS fn evals = %ld\n", cv_mem->cv_nfe); - - /* nonlinear solver stats */ - fprintf(outfile, "NLS iters = %ld\n", cv_mem->cv_nni); - fprintf(outfile, "NLS fails = %ld\n", cv_mem->cv_nnf); - if (cv_mem->cv_nst > 0) - { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", - (sunrealtype)cv_mem->cv_nni / (sunrealtype)cv_mem->cv_nst); - } - - /* linear solver stats */ - fprintf(outfile, "LS setups = %ld\n", cv_mem->cv_nsetups); - if (cv_mem->cv_lmem) - { - cvls_mem = (CVLsMem)(cv_mem->cv_lmem); - fprintf(outfile, "Jac fn evals = %ld\n", cvls_mem->nje); - fprintf(outfile, "LS RHS fn evals = %ld\n", cvls_mem->nfeDQ); - fprintf(outfile, "Prec setup evals = %ld\n", cvls_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", cvls_mem->nps); - fprintf(outfile, "LS iters = %ld\n", cvls_mem->nli); - fprintf(outfile, "LS fails = %ld\n", cvls_mem->ncfl); - fprintf(outfile, "Jac-times setups = %ld\n", - cvls_mem->njtsetup); - fprintf(outfile, "Jac-times evals = %ld\n", cvls_mem->njtimes); - if (cv_mem->cv_nni > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)cvls_mem->nli / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)cvls_mem->nje / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)cvls_mem->npe / (sunrealtype)cv_mem->cv_nni); - } - } - - /* rootfinding stats */ - fprintf(outfile, "Root fn evals = %ld\n", cv_mem->cv_nge); + cvProcessError(cv_mem, CV_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid formatting option."); + return (CV_ILL_INPUT); + } - /* projection stats */ - if (cv_mem->proj_mem) - { - cvproj_mem = (CVodeProjMem)(cv_mem->proj_mem); - fprintf(outfile, "Projection fn evals = %ld\n", cvproj_mem->nproj); - fprintf(outfile, "Projection fails = %ld\n", - cvproj_mem->npfails); - } + sunfprintf_real(outfile, fmt, SUNTRUE, "Current time", cv_mem->cv_tn); + sunfprintf_long(outfile, fmt, SUNFALSE, "Steps", cv_mem->cv_nst); + sunfprintf_long(outfile, fmt, SUNFALSE, "Error test fails", cv_mem->cv_netf); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS step fails", cv_mem->cv_ncfn); + sunfprintf_real(outfile, fmt, SUNFALSE, "Initial step size", cv_mem->cv_h0u); + sunfprintf_real(outfile, fmt, SUNFALSE, "Last step size", cv_mem->cv_hu); + sunfprintf_real(outfile, fmt, SUNFALSE, "Current step size", cv_mem->cv_next_h); + sunfprintf_long(outfile, fmt, SUNFALSE, "Last method order", cv_mem->cv_qu); + sunfprintf_long(outfile, fmt, SUNFALSE, "Current method order", + cv_mem->cv_next_q); + sunfprintf_long(outfile, fmt, SUNFALSE, "Stab. lim. order reductions", + cv_mem->cv_nor); - /* quadrature stats */ - if (cv_mem->cv_quadr) - { - fprintf(outfile, "Quad fn evals = %ld\n", cv_mem->cv_nfQe); - fprintf(outfile, "Quad error test fails = %ld\n", cv_mem->cv_netfQ); - } + /* function evaluations */ + sunfprintf_long(outfile, fmt, SUNFALSE, "RHS fn evals", cv_mem->cv_nfe); - /* sensitivity stats */ - if (cv_mem->cv_sensi) - { - fprintf(outfile, "Sens fn evals = %ld\n", cv_mem->cv_nfSe); - fprintf(outfile, "Sens RHS fn evals = %ld\n", cv_mem->cv_nfeS); - fprintf(outfile, "Sens error test fails = %ld\n", cv_mem->cv_netfS); - if (cv_mem->cv_ism != CV_SIMULTANEOUS) - { - fprintf(outfile, "Sens NLS iters = %ld\n", cv_mem->cv_nniS); - fprintf(outfile, "Sens NLS fails = %ld\n", cv_mem->cv_nnfS); - fprintf(outfile, "Sens NLS step fails = %ld\n", - cv_mem->cv_ncfnS); - } - if (cv_mem->cv_ism == CV_STAGGERED1) - { - fprintf(outfile, "Sens stgr1 NLS iters = %ld", - cv_mem->cv_nniS1[0]); - for (is = 1; is < cv_mem->cv_Ns; is++) - { - fprintf(outfile, ", %ld", cv_mem->cv_nniS1[is]); - } - fprintf(outfile, "\n"); - fprintf(outfile, "Sens stgr1 NLS fails = %ld", - cv_mem->cv_nnfS1[0]); - for (is = 1; is < cv_mem->cv_Ns; is++) - { - fprintf(outfile, ", %ld", cv_mem->cv_nnfS1[is]); - } - fprintf(outfile, "\n"); - fprintf(outfile, "Sens stgr1 NLS step fails = %ld", - cv_mem->cv_ncfnS1[0]); - for (is = 1; is < cv_mem->cv_Ns; is++) - { - fprintf(outfile, ", %ld", cv_mem->cv_ncfnS1[is]); - } - fprintf(outfile, "\n"); - } - fprintf(outfile, "Sens LS setups = %ld\n", - cv_mem->cv_nsetupsS); - } + /* nonlinear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS iters", cv_mem->cv_nni); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS fails", cv_mem->cv_nnf); - /* quadrature-sensitivity stats */ - if (cv_mem->cv_quadr_sensi) - { - fprintf(outfile, "QuadSens fn evals = %ld\n", cv_mem->cv_nfQSe); - fprintf(outfile, "QuadSens error test fails = %ld\n", cv_mem->cv_netfQS); - } - break; - - case SUN_OUTPUTFORMAT_CSV: - /* step and method stats */ - fprintf(outfile, "Time,%" RSYM, cv_mem->cv_tn); - fprintf(outfile, ",Steps,%ld", cv_mem->cv_nst); - fprintf(outfile, ",Error test fails,%ld", cv_mem->cv_netf); - fprintf(outfile, ",NLS step fails,%ld", cv_mem->cv_ncfn); - fprintf(outfile, ",Initial step size,%" RSYM, cv_mem->cv_h0u); - fprintf(outfile, ",Last step size,%" RSYM, cv_mem->cv_hu); - fprintf(outfile, ",Current step size,%" RSYM, cv_mem->cv_next_h); - fprintf(outfile, ",Last method order,%d", cv_mem->cv_qu); - fprintf(outfile, ",Current method order,%d", cv_mem->cv_next_q); - fprintf(outfile, ",Stab. lim. order reductions,%ld", cv_mem->cv_nor); - - /* function evaluations */ - fprintf(outfile, ",RHS fn evals,%ld", cv_mem->cv_nfe); - - /* nonlinear solver stats */ - fprintf(outfile, ",NLS iters,%ld", cv_mem->cv_nni); - fprintf(outfile, ",NLS fails,%ld", cv_mem->cv_nnf); - if (cv_mem->cv_nst > 0) - { - fprintf(outfile, ",NLS iters per step,%" RSYM, - (sunrealtype)cv_mem->cv_nni / (sunrealtype)cv_mem->cv_nst); - } - else { fprintf(outfile, ",NLS iters per step,0"); } - - /* linear solver stats */ - fprintf(outfile, ",LS setups,%ld", cv_mem->cv_nsetups); - if (cv_mem->cv_lmem) + if (cv_mem->cv_nst > 0) + { + sunfprintf_real(outfile, fmt, SUNFALSE, "NLS iters per step", + (sunrealtype)cv_mem->cv_nni / (sunrealtype)cv_mem->cv_nst); + } + + /* linear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "LS setups", cv_mem->cv_nsetups); + if (cv_mem->cv_lmem) + { + cvls_mem = (CVLsMem)(cv_mem->cv_lmem); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac fn evals", cvls_mem->nje); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS RHS fn evals", cvls_mem->nfeDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec setup evals", cvls_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec solves", cvls_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS iters", cvls_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS fails", cvls_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times setups", + cvls_mem->njtsetup); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times evals", cvls_mem->njtimes); + if (cv_mem->cv_nni > 0) { - cvls_mem = (CVLsMem)(cv_mem->cv_lmem); - fprintf(outfile, ",Jac fn evals,%ld", cvls_mem->nje); - fprintf(outfile, ",LS RHS fn evals,%ld", cvls_mem->nfeDQ); - fprintf(outfile, ",Prec setup evals,%ld", cvls_mem->npe); - fprintf(outfile, ",Prec solves,%ld", cvls_mem->nps); - fprintf(outfile, ",LS iters,%ld", cvls_mem->nli); - fprintf(outfile, ",LS fails,%ld", cvls_mem->ncfl); - fprintf(outfile, ",Jac-times setups,%ld", cvls_mem->njtsetup); - fprintf(outfile, ",Jac-times evals,%ld", cvls_mem->njtimes); - if (cv_mem->cv_nni > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)cvls_mem->nli / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)cvls_mem->nje / (sunrealtype)cv_mem->cv_nni); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)cvls_mem->npe / (sunrealtype)cv_mem->cv_nni); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } + sunfprintf_real(outfile, fmt, SUNFALSE, "LS iters per NLS iter", + (sunrealtype)cvls_mem->nli / (sunrealtype)cv_mem->cv_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Jac evals per NLS iter", + (sunrealtype)cvls_mem->nje / (sunrealtype)cv_mem->cv_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Prec evals per NLS iter", + (sunrealtype)cvls_mem->npe / (sunrealtype)cv_mem->cv_nni); } + } - /* rootfinding stats */ - fprintf(outfile, ",Root fn evals,%ld", cv_mem->cv_nge); + /* rootfinding stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "Root fn evals", cv_mem->cv_nge); - /* projection stats */ - if (cv_mem->proj_mem) - { - cvproj_mem = (CVodeProjMem)(cv_mem->proj_mem); - fprintf(outfile, ",Projection fn evals,%ld", cvproj_mem->nproj); - fprintf(outfile, ",Projection fails,%ld", cvproj_mem->npfails); - } + /* projection stats */ + if (cv_mem->proj_mem) + { + cvproj_mem = (CVodeProjMem)(cv_mem->proj_mem); + sunfprintf_long(outfile, fmt, SUNFALSE, "Projection fn evals", + cvproj_mem->nproj); + sunfprintf_long(outfile, fmt, SUNFALSE, "Projection fails", + cvproj_mem->npfails); + } - /* quadrature stats */ - if (cv_mem->cv_quadr) - { - fprintf(outfile, ",Quad fn evals,%ld", cv_mem->cv_nfQe); - fprintf(outfile, ",Quad error test fails,%ld", cv_mem->cv_netfQ); - } + /* quadrature stats */ + if (cv_mem->cv_quadr) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "Quad fn evals", cv_mem->cv_nfQe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Quad error test fails", + cv_mem->cv_netfQ); + } - /* sensitivity stats */ - if (cv_mem->cv_sensi) + /* sensitivity stats */ + if (cv_mem->cv_sensi) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens fn evals", cv_mem->cv_nfSe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens RHS fn evals", cv_mem->cv_nfeS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens error test fails", + cv_mem->cv_netfS); + if (cv_mem->cv_ism != CV_SIMULTANEOUS) { - fprintf(outfile, ",Sens fn evals,%ld", cv_mem->cv_nfSe); - fprintf(outfile, ",Sens RHS fn evals,%ld", cv_mem->cv_nfeS); - fprintf(outfile, ",Sens error test fails,%ld", cv_mem->cv_netfS); - if (cv_mem->cv_ism != CV_SIMULTANEOUS) - { - fprintf(outfile, ",Sens NLS iters,%ld", cv_mem->cv_nniS); - fprintf(outfile, ",Sens NLS fails,%ld", cv_mem->cv_nnfS); - fprintf(outfile, ",Sens NLS step fails,%ld", cv_mem->cv_ncfnS); - } - if (cv_mem->cv_ism == CV_STAGGERED1) - { - for (is = 0; is < cv_mem->cv_Ns; is++) - { - fprintf(outfile, ",Sens stgr1[%i] NLS iters,%ld", is, - cv_mem->cv_nniS1[is]); - } - for (is = 0; is < cv_mem->cv_Ns; is++) - { - fprintf(outfile, ",Sens stgr1[%i] NLS fails,%ld", is, - cv_mem->cv_nnfS1[is]); - } - for (is = 0; is < cv_mem->cv_Ns; is++) - { - fprintf(outfile, ",Sens stgr1[%i] NLS step fails,%ld", is, - cv_mem->cv_ncfnS1[is]); - } - } - fprintf(outfile, ",Sens LS setups,%ld", cv_mem->cv_nsetupsS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens NLS iters", cv_mem->cv_nniS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens NLS fails", cv_mem->cv_nnfS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens NLS step fails", + cv_mem->cv_ncfnS); } - - /* quadrature-sensitivity stats */ - if (cv_mem->cv_quadr_sensi) + if (cv_mem->cv_ism == CV_STAGGERED1) { - fprintf(outfile, ",QuadSens fn evals,%ld", cv_mem->cv_nfQSe); - fprintf(outfile, ",QuadSens error test fails,%ld", cv_mem->cv_netfQS); + sunfprintf_long_array(outfile, fmt, SUNFALSE, "Sens stgr1 NLS iters", + cv_mem->cv_nniS1, cv_mem->cv_Ns); + sunfprintf_long_array(outfile, fmt, SUNFALSE, "Sens stgr1 NLS fails", + cv_mem->cv_nnfS1, cv_mem->cv_Ns); + sunfprintf_long_array(outfile, fmt, SUNFALSE, "Sens stgr1 NLS step fails", + cv_mem->cv_ncfnS1, cv_mem->cv_Ns); } - fprintf(outfile, "\n"); - break; + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens LS setups", + cv_mem->cv_nsetupsS); + } - default: - cvProcessError(cv_mem, CV_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return (CV_ILL_INPUT); + /* quadrature-sensitivity stats */ + if (cv_mem->cv_quadr_sensi) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "QuadSens fn evals", + cv_mem->cv_nfQSe); + sunfprintf_long(outfile, fmt, SUNFALSE, "QuadSens error test fails", + cv_mem->cv_netfQS); } return (CV_SUCCESS); diff --git a/src/cvodes/cvodes_ls.c b/src/cvodes/cvodes_ls.c index 539a69a1d4..52103e7be6 100644 --- a/src/cvodes/cvodes_ls.c +++ b/src/cvodes/cvodes_ls.c @@ -1878,7 +1878,10 @@ int cvLsSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ynow, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(CV_LOGGER, SUN_LOGLEVEL_DEBUG, "CVODE::cvLsSolve", - "ls-stats", "bnorm = %.16g, resnorm = %.16g, ls_iters = %i, prec_solves = %i", + "ls-stats", + "bnorm = " SUN_REAL_FORMAT_G + ", resnorm = " SUN_REAL_FORMAT_G + ", ls_iters = %i, prec_solves = %i", bnorm, resnorm, nli_inc, (int)(cvls_mem->nps - nps_inc)); #endif diff --git a/src/ida/ida.c b/src/ida/ida.c index ea06a7a0b3..7ca5b60af8 100644 --- a/src/ida/ida.c +++ b/src/ida/ida.c @@ -2506,7 +2506,7 @@ static int IDAStep(IDAMem IDA_mem) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAStep", - "start-step-attempt", "step = %li, h = %" RSYM, + "start-step-attempt", "step = %li, h = " SUN_REAL_FORMAT_G, IDA_mem->ida_nst, IDA_mem->ida_hh); #endif @@ -2868,7 +2868,9 @@ 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", "estimate-error-order-k", - "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); + "err_k = " SUN_REAL_FORMAT_G + ", terr_k = " SUN_REAL_FORMAT_G, + *err_k, terr_k); #endif IDA_mem->ida_knew = IDA_mem->ida_kk; @@ -2886,8 +2888,9 @@ 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", "estimate-error-order-km1", - "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, - terr_km1); + "err_km1 = " SUN_REAL_FORMAT_G + ", terr_km1 = " SUN_REAL_FORMAT_G, + *err_km1, terr_km1); #endif if (IDA_mem->ida_kk > 2) @@ -2903,8 +2906,9 @@ 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", "estimate-error-order-km2", - "err_km2 = %" RSYM ", terr_km2 = %" RSYM, err_km2, - terr_km2); + "err_km2 = " SUN_REAL_FORMAT_G + ", terr_km2 = " SUN_REAL_FORMAT_G, + err_km2, terr_km2); #endif /* Decrease order if errors are reduced */ @@ -2929,7 +2933,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, IDA_mem->ida_knew); SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDATestError", - "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); + "error-estimate", "ck_enorm_k = " SUN_REAL_FORMAT_G, + ck * enorm_k); #endif /* Perform error test */ @@ -3090,7 +3095,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAHandleNFlag", "first-error-test_fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, + "kk = %i, eta = " SUN_REAL_FORMAT_G + ", h = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif @@ -3109,7 +3115,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAHandleNFlag", "second-error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, + "kk = %i, eta = " SUN_REAL_FORMAT_G + ", h = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif @@ -3127,7 +3134,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDA::IDAHandleNFlag", "error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, + "kk = %i, eta = " SUN_REAL_FORMAT_G + ", h = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif @@ -3249,8 +3257,9 @@ 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", - "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, - terr_kp1); + "terr_k = " SUN_REAL_FORMAT_G + ", terr_kp1 = " SUN_REAL_FORMAT_G, + terr_k, terr_kp1); #endif } else @@ -3263,8 +3272,9 @@ 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-rasie-or-lower", - "terr_km1 = %" RSYM ", terr_k = %" RSYM - ", terr_kp1 = %" RSYM, + "terr_km1 = " SUN_REAL_FORMAT_G + ", terr_k = " SUN_REAL_FORMAT_G + ", terr_kp1 = " SUN_REAL_FORMAT_G, terr_km1, terr_k, terr_kp1); #endif } @@ -3315,8 +3325,9 @@ 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", "new-step-and-order", - "knew = %i, err_knew = %" RSYM ", eta = %" RSYM - ", hnew = %" RSYM, + "knew = %i, err_knew = " SUN_REAL_FORMAT_G + ", eta = " SUN_REAL_FORMAT_G + ", hnew = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, err_knew, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif diff --git a/src/ida/ida_impl.h b/src/ida/ida_impl.h index f61a79381e..9cd829f43c 100644 --- a/src/ida/ida_impl.h +++ b/src/ida/ida_impl.h @@ -31,14 +31,6 @@ extern "C" { #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define RSYM ".32Lg" -#define RSYMW "41.32Lg" -#else -#define RSYM ".16g" -#define RSYMW "23.16g" -#endif - /*=================================================================*/ /* Shortcuts */ /*=================================================================*/ @@ -460,31 +452,13 @@ int idaNlsInit(IDAMem IDA_mem); * ================================================================= */ -#if defined(SUNDIALS_EXTENDED_PRECISION) - -#define MSG_TIME "t = %Lg, " -#define MSG_TIME_H "t = %Lg and h = %Lg, " -#define MSG_TIME_INT "t = %Lg is not between tcur - hu = %Lg and tcur = %Lg." -#define MSG_TIME_TOUT "tout = %Lg" -#define MSG_TIME_TSTOP "tstop = %Lg" - -#elif defined(SUNDIALS_DOUBLE_PRECISION) - -#define MSG_TIME "t = %lg, " -#define MSG_TIME_H "t = %lg and h = %lg, " -#define MSG_TIME_INT "t = %lg is not between tcur - hu = %lg and tcur = %lg." -#define MSG_TIME_TOUT "tout = %lg" -#define MSG_TIME_TSTOP "tstop = %lg" - -#else - -#define MSG_TIME "t = %g, " -#define MSG_TIME_H "t = %g and h = %g, " -#define MSG_TIME_INT "t = %g is not between tcur - hu = %g and tcur = %g." -#define MSG_TIME_TOUT "tout = %g" -#define MSG_TIME_TSTOP "tstop = %g" - -#endif +#define MSG_TIME "t = " SUN_REAL_FORMAT_G +#define MSG_TIME_H "t = " SUN_REAL_FORMAT_G " and h = " SUN_REAL_FORMAT_G +#define MSG_TIME_INT \ + "t = " SUN_REAL_FORMAT_G " is not between tcur - hold = " SUN_REAL_FORMAT_G \ + " and tcur = " SUN_REAL_FORMAT_G +#define MSG_TIME_TOUT "tout = " SUN_REAL_FORMAT_G +#define MSG_TIME_TSTOP "tstop = " SUN_REAL_FORMAT_G /* General errors */ diff --git a/src/ida/ida_io.c b/src/ida/ida_io.c index e3d9facbd8..dfb0a1b923 100644 --- a/src/ida/ida_io.c +++ b/src/ida/ida_io.c @@ -1418,16 +1418,16 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) { case SUN_OUTPUTFORMAT_TABLE: /* step and method stats */ - fprintf(outfile, "Current time = %" RSYM "\n", + fprintf(outfile, "Current time = " SUN_REAL_FORMAT_G "\n", IDA_mem->ida_tn); fprintf(outfile, "Steps = %ld\n", IDA_mem->ida_nst); fprintf(outfile, "Error test fails = %ld\n", IDA_mem->ida_netf); fprintf(outfile, "NLS step fails = %ld\n", IDA_mem->ida_ncfn); - fprintf(outfile, "Initial step size = %" RSYM "\n", + fprintf(outfile, "Initial step size = " SUN_REAL_FORMAT_G "\n", IDA_mem->ida_h0u); - fprintf(outfile, "Last step size = %" RSYM "\n", + fprintf(outfile, "Last step size = " SUN_REAL_FORMAT_G "\n", IDA_mem->ida_hused); - fprintf(outfile, "Current step size = %" RSYM "\n", + fprintf(outfile, "Current step size = " SUN_REAL_FORMAT_G "\n", IDA_mem->ida_hh); fprintf(outfile, "Last method order = %d\n", IDA_mem->ida_kused); fprintf(outfile, "Current method order = %d\n", IDA_mem->ida_kk); @@ -1443,7 +1443,7 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) fprintf(outfile, "NLS fails = %ld\n", IDA_mem->ida_nnf); if (IDA_mem->ida_nst > 0) { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", + fprintf(outfile, "NLS iters per step = " SUN_REAL_FORMAT_G "\n", (sunrealtype)IDA_mem->ida_nre / (sunrealtype)IDA_mem->ida_nst); } @@ -1465,11 +1465,11 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) idals_mem->njtimes); if (IDA_mem->ida_nni > 0) { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", + fprintf(outfile, "LS iters per NLS iter = " SUN_REAL_FORMAT_G "\n", (sunrealtype)idals_mem->nli / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", + fprintf(outfile, "Jac evals per NLS iter = " SUN_REAL_FORMAT_G "\n", (sunrealtype)idals_mem->nje / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", + fprintf(outfile, "Prec evals per NLS iter = " SUN_REAL_FORMAT_G "\n", (sunrealtype)idals_mem->npe / (sunrealtype)IDA_mem->ida_nni); } } @@ -1480,13 +1480,13 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) case SUN_OUTPUTFORMAT_CSV: /* step and method stats */ - fprintf(outfile, "Time,%" RSYM, IDA_mem->ida_tn); + fprintf(outfile, "Time," SUN_REAL_FORMAT_G, IDA_mem->ida_tn); fprintf(outfile, ",Steps,%ld", IDA_mem->ida_nst); fprintf(outfile, ",Error test fails,%ld", IDA_mem->ida_netf); fprintf(outfile, ",NLS step fails,%ld", IDA_mem->ida_ncfn); - fprintf(outfile, ",Initial step size,%" RSYM, IDA_mem->ida_h0u); - fprintf(outfile, ",Last step size,%" RSYM, IDA_mem->ida_hused); - fprintf(outfile, ",Current step size,%" RSYM, IDA_mem->ida_hh); + fprintf(outfile, ",Initial step size," SUN_REAL_FORMAT_G, IDA_mem->ida_h0u); + fprintf(outfile, ",Last step size," SUN_REAL_FORMAT_G, IDA_mem->ida_hused); + fprintf(outfile, ",Current step size," SUN_REAL_FORMAT_G, IDA_mem->ida_hh); fprintf(outfile, ",Last method order,%d", IDA_mem->ida_kused); fprintf(outfile, ",Current method order,%d", IDA_mem->ida_kk); @@ -1501,7 +1501,7 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) fprintf(outfile, ",NLS fails,%ld", IDA_mem->ida_nnf); if (IDA_mem->ida_nst > 0) { - fprintf(outfile, ",NLS iters per step,%" RSYM, + fprintf(outfile, ",NLS iters per step," SUN_REAL_FORMAT_G, (sunrealtype)IDA_mem->ida_nre / (sunrealtype)IDA_mem->ida_nst); } else { fprintf(outfile, ",NLS iters per step,0"); } @@ -1521,11 +1521,11 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) fprintf(outfile, ",Jac-times evals,%ld", idals_mem->njtimes); if (IDA_mem->ida_nni > 0) { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, + fprintf(outfile, ",LS iters per NLS iter," SUN_REAL_FORMAT_G, (sunrealtype)idals_mem->nli / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, + fprintf(outfile, ",Jac evals per NLS iter," SUN_REAL_FORMAT_G, (sunrealtype)idals_mem->nje / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, + fprintf(outfile, ",Prec evals per NLS iter," SUN_REAL_FORMAT_G, (sunrealtype)idals_mem->npe / (sunrealtype)IDA_mem->ida_nni); } else diff --git a/src/ida/ida_ls_impl.h b/src/ida/ida_ls_impl.h index 6248e52e9d..9ab3321559 100644 --- a/src/ida/ida_ls_impl.h +++ b/src/ida/ida_ls_impl.h @@ -150,16 +150,8 @@ int idaLs_AccessLMem(void* ida_mem, const char* fname, IDAMem* IDA_mem, Error and Warning Messages ---------------------------------------------------------------*/ -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define MSG_LS_TIME "at t = %Lg, " -#define MSG_LS_FRMT "%Le." -#elif defined(SUNDIALS_DOUBLE_PRECISION) -#define MSG_LS_TIME "at t = %lg, " -#define MSG_LS_FRMT "%le." -#else -#define MSG_LS_TIME "at t = %g, " -#define MSG_LS_FRMT "%e." -#endif +#define MSG_LS_TIME "at t = " SUN_REAL_FORMAT_G ", " +#define MSG_LS_FRMT SUN_REAL_FORMAT_G "." /* Error Messages */ #define MSG_LS_IDAMEM_NULL "Integrator memory is NULL." diff --git a/src/idas/idas.c b/src/idas/idas.c index 3174660c12..1497e8e60c 100644 --- a/src/idas/idas.c +++ b/src/idas/idas.c @@ -5912,7 +5912,7 @@ static int IDAStep(IDAMem IDA_mem) { #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAStep", - "start-step-attempt", "step = %li, h = %" RSYM, + "start-step-attempt", "step = %li, h = " SUN_REAL_FORMAT_G, IDA_mem->ida_nst, IDA_mem->ida_hh); #endif @@ -6678,7 +6678,9 @@ 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", "estimate-error-order-k", - "err_k = %" RSYM ", terr_k = %" RSYM, *err_k, terr_k); + "err_k = " SUN_REAL_FORMAT_G + ", terr_k = " SUN_REAL_FORMAT_G, + *err_k, terr_k); #endif IDA_mem->ida_knew = IDA_mem->ida_kk; @@ -6696,8 +6698,9 @@ 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", "estimate-error-order-km1", - "err_km1 = %" RSYM ", terr_km1 = %" RSYM, *err_km1, - terr_km1); + "err_km1 = " SUN_REAL_FORMAT_G + ", terr_km1 = " SUN_REAL_FORMAT_G, + *err_km1, terr_km1); #endif if (IDA_mem->ida_kk > 2) @@ -6713,8 +6716,9 @@ 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", "estimate-error-order-km2", - "err_km2 = %" RSYM ", terr_km2 = %" RSYM, *err_km2, - terr_km2); + "err_km2 = " SUN_REAL_FORMAT_G + ", terr_km2 = " SUN_REAL_FORMAT_G, + *err_km2, terr_km2); #endif /* Decrease order if errors are reduced */ @@ -6739,7 +6743,8 @@ static int IDATestError(IDAMem IDA_mem, sunrealtype ck, sunrealtype* err_k, IDA_mem->ida_knew); SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDATestError", - "error-estimate", "ck_enorm_k = %" RSYM, ck * enorm_k); + "error-estimate", "ck_enorm_k = " SUN_REAL_FORMAT_G, + ck * enorm_k); #endif /* Perform error test */ @@ -7254,7 +7259,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAHandleNFlag", "first-error-test_fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, + "kk = %i, eta = " SUN_REAL_FORMAT_G + ", h = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif @@ -7273,7 +7279,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAHandleNFlag", "second-error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, + "kk = %i, eta = " SUN_REAL_FORMAT_G + ", h = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif @@ -7291,7 +7298,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, sunrealtype err_k, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(IDA_LOGGER, SUN_LOGLEVEL_INFO, "IDAS::IDAHandleNFlag", "error-test-fail", - "kk = %i, eta = %" RSYM ", h = %" RSYM, + "kk = %i, eta = " SUN_REAL_FORMAT_G + ", h = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif @@ -7474,8 +7482,9 @@ 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", - "terr_k = %" RSYM ", terr_kp1 = %" RSYM, terr_k, - terr_kp1); + "terr_k = " SUN_REAL_FORMAT_G + ", terr_kp1 = " SUN_REAL_FORMAT_G, + terr_k, terr_kp1); #endif } else @@ -7488,8 +7497,9 @@ 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-rasie-or-lower", - "terr_km1 = %" RSYM ", terr_k = %" RSYM - ", terr_kp1 = %" RSYM, + "terr_km1 = " SUN_REAL_FORMAT_G + ", terr_k = " SUN_REAL_FORMAT_G + ", terr_kp1 = " SUN_REAL_FORMAT_G, terr_km1, terr_k, terr_kp1); #endif } @@ -7540,8 +7550,9 @@ 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", "new-step-and-order", - "knew = %i, err_knew = %" RSYM ", eta = %" RSYM - ", hnew = %" RSYM, + "knew = %i, err_knew = " SUN_REAL_FORMAT_G + ", eta = " SUN_REAL_FORMAT_G + ", hnew = " SUN_REAL_FORMAT_G, IDA_mem->ida_kk, err_knew, IDA_mem->ida_eta, IDA_mem->ida_hh); #endif diff --git a/src/idas/idas_impl.h b/src/idas/idas_impl.h index e54b593bc5..73cdc9e569 100644 --- a/src/idas/idas_impl.h +++ b/src/idas/idas_impl.h @@ -30,14 +30,6 @@ extern "C" { #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define RSYM ".32Lg" -#define RSYMW "41.32Lg" -#else -#define RSYM ".16g" -#define RSYMW "23.16g" -#endif - /*=================================================================*/ /* Shortcuts */ /*=================================================================*/ @@ -988,31 +980,13 @@ int IDASensResDQ(int Ns, sunrealtype t, N_Vector yy, N_Vector yp, * ================================================================= */ -#if defined(SUNDIALS_EXTENDED_PRECISION) - -#define MSG_TIME "t = %Lg, " -#define MSG_TIME_H "t = %Lg and h = %Lg, " -#define MSG_TIME_INT "t = %Lg is not between tcur - hu = %Lg and tcur = %Lg." -#define MSG_TIME_TOUT "tout = %Lg" -#define MSG_TIME_TSTOP "tstop = %Lg" - -#elif defined(SUNDIALS_DOUBLE_PRECISION) - -#define MSG_TIME "t = %lg, " -#define MSG_TIME_H "t = %lg and h = %lg, " -#define MSG_TIME_INT "t = %lg is not between tcur - hu = %lg and tcur = %lg." -#define MSG_TIME_TOUT "tout = %lg" -#define MSG_TIME_TSTOP "tstop = %lg" - -#else - -#define MSG_TIME "t = %g, " -#define MSG_TIME_H "t = %g and h = %g, " -#define MSG_TIME_INT "t = %g is not between tcur - hu = %g and tcur = %g." -#define MSG_TIME_TOUT "tout = %g" -#define MSG_TIME_TSTOP "tstop = %g" - -#endif +#define MSG_TIME "t = " SUN_REAL_FORMAT_G +#define MSG_TIME_H "t = " SUN_REAL_FORMAT_G " and h = " SUN_REAL_FORMAT_G +#define MSG_TIME_INT \ + "t = " SUN_REAL_FORMAT_G " is not between tcur - hold = " SUN_REAL_FORMAT_G \ + " and tcur = " SUN_REAL_FORMAT_G +#define MSG_TIME_TOUT "tout = " SUN_REAL_FORMAT_G +#define MSG_TIME_TSTOP "tstop = " SUN_REAL_FORMAT_G /* General errors */ @@ -1244,7 +1218,7 @@ int IDASensResDQ(int Ns, sunrealtype t, N_Vector yy, N_Vector yp, "The final time tBout is outside the interval over which the forward " \ "problem was solved." #define MSGAM_BACK_ERROR "Error occured while integrating backward problem # %d" -#define MSGAM_BAD_TINTERP "Bad t = %g for interpolation." +#define MSGAM_BAD_TINTERP "Bad t = " SUN_REAL_FORMAT_G " for interpolation." #define MSGAM_BAD_T "Bad t for interpolation." #define MSGAM_WRONG_INTERP \ "This function cannot be called for the specified interp type." diff --git a/src/idas/idas_io.c b/src/idas/idas_io.c index ffbc13f95f..d17bad89ea 100644 --- a/src/idas/idas_io.c +++ b/src/idas/idas_io.c @@ -2241,203 +2241,108 @@ int IDAPrintAllStats(void* ida_mem, FILE* outfile, SUNOutputFormat fmt) IDA_mem = (IDAMem)ida_mem; - switch (fmt) - { - case SUN_OUTPUTFORMAT_TABLE: - /* step and method stats */ - fprintf(outfile, "Current time = %" RSYM "\n", - IDA_mem->ida_tn); - fprintf(outfile, "Steps = %ld\n", IDA_mem->ida_nst); - fprintf(outfile, "Error test fails = %ld\n", IDA_mem->ida_netf); - fprintf(outfile, "NLS step fails = %ld\n", IDA_mem->ida_ncfn); - fprintf(outfile, "Initial step size = %" RSYM "\n", - IDA_mem->ida_h0u); - fprintf(outfile, "Last step size = %" RSYM "\n", - IDA_mem->ida_hused); - fprintf(outfile, "Current step size = %" RSYM "\n", - IDA_mem->ida_hh); - fprintf(outfile, "Last method order = %d\n", IDA_mem->ida_kused); - fprintf(outfile, "Current method order = %d\n", IDA_mem->ida_kk); - - /* function evaluations */ - fprintf(outfile, "Residual fn evals = %ld\n", IDA_mem->ida_nre); - - /* IC calculation stats */ - fprintf(outfile, "IC linesearch backtrack ops = %d\n", IDA_mem->ida_nbacktr); - - /* nonlinear solver stats */ - fprintf(outfile, "NLS iters = %ld\n", IDA_mem->ida_nni); - fprintf(outfile, "NLS fails = %ld\n", IDA_mem->ida_nnf); - if (IDA_mem->ida_nst > 0) - { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", - (sunrealtype)IDA_mem->ida_nre / (sunrealtype)IDA_mem->ida_nst); - } - - /* linear solver stats */ - fprintf(outfile, "LS setups = %ld\n", - IDA_mem->ida_nsetups); - if (IDA_mem->ida_lmem) - { - idals_mem = (IDALsMem)(IDA_mem->ida_lmem); - fprintf(outfile, "Jac fn evals = %ld\n", idals_mem->nje); - fprintf(outfile, "LS residual fn evals = %ld\n", idals_mem->nreDQ); - fprintf(outfile, "Prec setup evals = %ld\n", idals_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", idals_mem->nps); - fprintf(outfile, "LS iters = %ld\n", idals_mem->nli); - fprintf(outfile, "LS fails = %ld\n", idals_mem->ncfl); - fprintf(outfile, "Jac-times setups = %ld\n", - idals_mem->njtsetup); - fprintf(outfile, "Jac-times evals = %ld\n", - idals_mem->njtimes); - if (IDA_mem->ida_nni > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)idals_mem->nli / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)idals_mem->nje / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)idals_mem->npe / (sunrealtype)IDA_mem->ida_nni); - } - } - - /* rootfinding stats */ - fprintf(outfile, "Root fn evals = %ld\n", IDA_mem->ida_nge); - - /* quadrature stats */ - if (IDA_mem->ida_quadr) - { - fprintf(outfile, "Quad fn evals = %ld\n", IDA_mem->ida_nrQe); - fprintf(outfile, "Quad error test fails = %ld\n", - IDA_mem->ida_netfQ); - } - - /* sensitivity stats */ - if (IDA_mem->ida_sensi) - { - fprintf(outfile, "Sens fn evals = %ld\n", IDA_mem->ida_nrSe); - fprintf(outfile, "Sens residual fn evals = %ld\n", IDA_mem->ida_nreS); - fprintf(outfile, "Sens error test fails = %ld\n", - IDA_mem->ida_netfS); - if (IDA_mem->ida_ism == IDA_STAGGERED) - { - fprintf(outfile, "Sens NLS iters = %ld\n", - IDA_mem->ida_nniS); - fprintf(outfile, "Sens NLS fails = %ld\n", - IDA_mem->ida_nnfS); - fprintf(outfile, "Sens NLS step fails = %ld\n", - IDA_mem->ida_ncfnS); - } - fprintf(outfile, "Sens LS setups = %ld\n", - IDA_mem->ida_nsetupsS); - } - - /* quadrature-sensitivity stats */ - if (IDA_mem->ida_quadr_sensi) - { - fprintf(outfile, "QuadSens residual evals = %ld\n", - IDA_mem->ida_nrQSe); - fprintf(outfile, "QuadSens error test fails = %ld\n", - IDA_mem->ida_netfQS); - } - break; - - case SUN_OUTPUTFORMAT_CSV: - /* step and method stats */ - fprintf(outfile, "Time,%" RSYM, IDA_mem->ida_tn); - fprintf(outfile, ",Steps,%ld", IDA_mem->ida_nst); - fprintf(outfile, ",Error test fails,%ld", IDA_mem->ida_netf); - fprintf(outfile, ",NLS step fails,%ld", IDA_mem->ida_ncfn); - fprintf(outfile, ",Initial step size,%" RSYM, IDA_mem->ida_h0u); - fprintf(outfile, ",Last step size,%" RSYM, IDA_mem->ida_hused); - fprintf(outfile, ",Current step size,%" RSYM, IDA_mem->ida_hh); - fprintf(outfile, ",Last method order,%d", IDA_mem->ida_kused); - fprintf(outfile, ",Current method order,%d", IDA_mem->ida_kk); - - /* function evaluations */ - fprintf(outfile, ",Residual fn evals,%ld", IDA_mem->ida_nre); - - /* IC calculation stats */ - fprintf(outfile, ",IC linesearch backtrack ops,%d", IDA_mem->ida_nbacktr); - - /* nonlinear solver stats */ - fprintf(outfile, ",NLS iters,%ld", IDA_mem->ida_nni); - fprintf(outfile, ",NLS fails,%ld", IDA_mem->ida_nnf); - if (IDA_mem->ida_nst > 0) - { - fprintf(outfile, ",NLS iters per step,%" RSYM, - (sunrealtype)IDA_mem->ida_nre / (sunrealtype)IDA_mem->ida_nst); - } - else { fprintf(outfile, ",NLS iters per step,0"); } + if (fmt != SUN_OUTPUTFORMAT_TABLE && fmt != SUN_OUTPUTFORMAT_CSV) + { + IDAProcessError(ida_mem, IDA_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid formatting option."); + return (IDA_ILL_INPUT); + } - /* linear solver stats */ - fprintf(outfile, ",LS setups,%ld", IDA_mem->ida_nsetups); - if (IDA_mem->ida_lmem) + /* step and method stats */ + sunfprintf_real(outfile, fmt, SUNTRUE, "Current time", IDA_mem->ida_tn); + sunfprintf_long(outfile, fmt, SUNFALSE, "Steps", IDA_mem->ida_nst); + sunfprintf_long(outfile, fmt, SUNFALSE, "Error test fails", IDA_mem->ida_netf); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS step fails", IDA_mem->ida_ncfn); + sunfprintf_real(outfile, fmt, SUNFALSE, "Initial step size", IDA_mem->ida_h0u); + sunfprintf_real(outfile, fmt, SUNFALSE, "Last step size", IDA_mem->ida_hused); + sunfprintf_real(outfile, fmt, SUNFALSE, "Current step size", IDA_mem->ida_hh); + sunfprintf_long(outfile, fmt, SUNFALSE, "Last method order", + IDA_mem->ida_kused); + sunfprintf_long(outfile, fmt, SUNFALSE, "Current method order", + IDA_mem->ida_kk); + + /* function evaluations */ + sunfprintf_long(outfile, fmt, SUNFALSE, "Residual fn evals", IDA_mem->ida_nre); + + /* IC calculation stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "IC linesearch backtrack ops", + IDA_mem->ida_nbacktr); + + /* nonlinear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS iters", IDA_mem->ida_nni); + sunfprintf_long(outfile, fmt, SUNFALSE, "NLS fails", IDA_mem->ida_nnf); + if (IDA_mem->ida_nst > 0) + { + sunfprintf_real(outfile, fmt, SUNFALSE, "NLS iters per step", + (sunrealtype)IDA_mem->ida_nre / (sunrealtype)IDA_mem->ida_nst); + } + + /* linear solver stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "LS setups", IDA_mem->ida_nsetups); + if (IDA_mem->ida_lmem) + { + idals_mem = (IDALsMem)(IDA_mem->ida_lmem); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac fn evals", idals_mem->nje); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS residual fn evals", + idals_mem->nreDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec setup evals", idals_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec solves", idals_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS iters", idals_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS fails", idals_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times setups", + idals_mem->njtsetup); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times evals", + idals_mem->njtimes); + if (IDA_mem->ida_nni > 0) { - idals_mem = (IDALsMem)(IDA_mem->ida_lmem); - fprintf(outfile, ",Jac fn evals,%ld", idals_mem->nje); - fprintf(outfile, ",LS residual evals,%ld", idals_mem->nreDQ); - fprintf(outfile, ",Prec setup evals,%ld", idals_mem->npe); - fprintf(outfile, ",Prec solves,%ld", idals_mem->nps); - fprintf(outfile, ",LS iters,%ld", idals_mem->nli); - fprintf(outfile, ",LS fails,%ld", idals_mem->ncfl); - fprintf(outfile, ",Jac-times setups,%ld", idals_mem->njtsetup); - fprintf(outfile, ",Jac-times evals,%ld", idals_mem->njtimes); - if (IDA_mem->ida_nni > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)idals_mem->nli / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)idals_mem->nje / (sunrealtype)IDA_mem->ida_nni); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)idals_mem->npe / (sunrealtype)IDA_mem->ida_nni); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } + sunfprintf_real(outfile, fmt, SUNFALSE, "LS iters per NLS iter", + (sunrealtype)idals_mem->nli / (sunrealtype)IDA_mem->ida_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Jac evals per NLS iter", + (sunrealtype)idals_mem->nje / (sunrealtype)IDA_mem->ida_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Prec evals per NLS iter", + (sunrealtype)idals_mem->npe / (sunrealtype)IDA_mem->ida_nni); } + } - /* rootfinding stats */ - fprintf(outfile, ",Root fn evals,%ld", IDA_mem->ida_nge); - - /* quadrature stats */ - if (IDA_mem->ida_quadr) - { - fprintf(outfile, ",Quad fn evals,%ld", IDA_mem->ida_nrQe); - fprintf(outfile, ",Quad error test fails,%ld", IDA_mem->ida_netfQ); - } + /* rootfinding stats */ + sunfprintf_long(outfile, fmt, SUNFALSE, "Root fn evals", IDA_mem->ida_nge); - /* sensitivity stats */ - if (IDA_mem->ida_sensi) - { - fprintf(outfile, ",Sens fn evals,%ld", IDA_mem->ida_nrSe); - fprintf(outfile, ",Sens residual fn evals,%ld", IDA_mem->ida_nreS); - fprintf(outfile, ",Sens error test fails,%ld", IDA_mem->ida_netfS); - if (IDA_mem->ida_ism == IDA_STAGGERED) - { - fprintf(outfile, ",Sens NLS iters,%ld", IDA_mem->ida_nniS); - fprintf(outfile, ",Sens NLS fails,%ld", IDA_mem->ida_nnfS); - fprintf(outfile, ",Sens NLS step fails,%ld", IDA_mem->ida_ncfnS); - } - fprintf(outfile, ",Sens LS setups,%ld", IDA_mem->ida_nsetupsS); - } + /* quadrature stats */ + if (IDA_mem->ida_quadr) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "Quad fn evals", IDA_mem->ida_nrQe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Quad error test fails", + IDA_mem->ida_netfQ); + } - /* quadrature-sensitivity stats */ - if (IDA_mem->ida_quadr_sensi) + /* sensitivity stats */ + if (IDA_mem->ida_sensi) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens fn evals", IDA_mem->ida_nrSe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens residual fn evals", + IDA_mem->ida_nreS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens error test fails", + IDA_mem->ida_netfS); + if (IDA_mem->ida_ism == IDA_STAGGERED) { - fprintf(outfile, ",QuadSens residual evals,%ld", IDA_mem->ida_nrQSe); - fprintf(outfile, ",QuadSens error test fails,%ld", IDA_mem->ida_netfQS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens NLS iters", + IDA_mem->ida_nniS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens NLS fails", + IDA_mem->ida_nnfS); + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens NLS step fails", + IDA_mem->ida_ncfnS); } - fprintf(outfile, "\n"); - break; + sunfprintf_long(outfile, fmt, SUNFALSE, "Sens LS setups", + IDA_mem->ida_nsetupsS); + } - default: - IDAProcessError(IDA_mem, IDA_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return (IDA_ILL_INPUT); + /* quadrature-sensitivity stats */ + if (IDA_mem->ida_quadr_sensi) + { + sunfprintf_long(outfile, fmt, SUNFALSE, "QuadSens residual evals", + IDA_mem->ida_nrQSe); + sunfprintf_long(outfile, fmt, SUNFALSE, "QuadSens error test fails", + IDA_mem->ida_netfQS); } return (IDA_SUCCESS); diff --git a/src/idas/idas_ls_impl.h b/src/idas/idas_ls_impl.h index f219cb1d31..07932bc53b 100644 --- a/src/idas/idas_ls_impl.h +++ b/src/idas/idas_ls_impl.h @@ -150,16 +150,8 @@ int idaLs_AccessLMem(void* ida_mem, const char* fname, IDAMem* IDA_mem, Error and Warning Messages ---------------------------------------------------------------*/ -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define MSG_LS_TIME "at t = %Lg, " -#define MSG_LS_FRMT "%Le." -#elif defined(SUNDIALS_DOUBLE_PRECISION) -#define MSG_LS_TIME "at t = %lg, " -#define MSG_LS_FRMT "%le." -#else -#define MSG_LS_TIME "at t = %g, " -#define MSG_LS_FRMT "%e." -#endif +#define MSG_LS_TIME "at t = " SUN_REAL_FORMAT_G ", " +#define MSG_LS_FRMT SUN_REAL_FORMAT_G "." /* Error Messages */ #define MSG_LS_IDAMEM_NULL "Integrator memory is NULL." diff --git a/src/kinsol/kinsol_impl.h b/src/kinsol/kinsol_impl.h index 117bf003f5..aedd0ebc62 100644 --- a/src/kinsol/kinsol_impl.h +++ b/src/kinsol/kinsol_impl.h @@ -33,14 +33,6 @@ extern "C" { #endif -#if defined(SUNDIALS_EXTENDED_PRECISION) -#define RSYM ".32Lg" -#define RSYMW "19.32Lg" -#else -#define RSYM ".16g" -#define RSYMW "23.16g" -#endif - /* * ================================================================= * M A I N S O L V E R M E M O R Y B L O C K @@ -472,55 +464,26 @@ void KINInfoHandler(const char* module, const char* function, char* msg, #define INFO_RETVAL "Return value: %d" #define INFO_ADJ "no. of lambda adjustments = %ld" -#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_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_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" -#define INFO_ALPHABETA \ - "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_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_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" -#define INFO_ALPHABETA \ - "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_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_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" -#define INFO_ALPHABETA \ - "f1norm = %15.8e alpha_cond = %15.8e beta_cond = %15.8e lam = %15.8e" - -#endif +#define INFO_RVAR "%s = " SUN_REAL_FORMAT_G +#define INFO_NNI "nni = %4ld nfe = %6ld fnorm = " SUN_REAL_FORMAT_G +#define INFO_TOL \ + "scsteptol = " SUN_REAL_FORMAT_G " fnormtol = " SUN_REAL_FORMAT_G +#define INFO_FMAX "scaled f norm (for stopping) = " SUN_REAL_FORMAT_G +#define INFO_PNORM "pnorm = " SUN_REAL_FORMAT_E +#define INFO_PNORM1 "(ivio=1) pnorm = " SUN_REAL_FORMAT_E +#define INFO_FNORM "fnorm(L2) = " SUN_REAL_FORMAT_E +#define INFO_LAM \ + "min_lam = " SUN_REAL_FORMAT_E " f1norm = " SUN_REAL_FORMAT_E \ + " pnorm = " SUN_REAL_FORMAT_E +#define INFO_ALPHA \ + "fnorm = " SUN_REAL_FORMAT_E " f1norm = " SUN_REAL_FORMAT_E \ + " alpha_cond = " SUN_REAL_FORMAT_E " lam = " SUN_REAL_FORMAT_E "" +#define INFO_BETA \ + "f1norm = " SUN_REAL_FORMAT_E " beta_cond = " SUN_REAL_FORMAT_E \ + " lam = " SUN_REAL_FORMAT_E "" +#define INFO_ALPHABETA \ + "f1norm = " SUN_REAL_FORMAT_E " alpha_cond = " SUN_REAL_FORMAT_E \ + " beta_cond = " SUN_REAL_FORMAT_E " lam = " SUN_REAL_FORMAT_E "" #ifdef __cplusplus } diff --git a/src/kinsol/kinsol_io.c b/src/kinsol/kinsol_io.c index 7b4a8128a9..0b64de5359 100644 --- a/src/kinsol/kinsol_io.c +++ b/src/kinsol/kinsol_io.c @@ -1089,84 +1089,47 @@ int KINPrintAllStats(void* kinmem, FILE* outfile, SUNOutputFormat fmt) kin_mem = (KINMem)kinmem; - switch (fmt) - { - case SUN_OUTPUTFORMAT_TABLE: - /* main solver stats */ - fprintf(outfile, "Nonlinear iters = %li\n", kin_mem->kin_nni); - fprintf(outfile, "Nonlinear fn evals = %li\n", kin_mem->kin_nfe); - fprintf(outfile, "Beta condition fails = %li\n", kin_mem->kin_nbcf); - fprintf(outfile, "Backtrack operations = %li\n", kin_mem->kin_nbktrk); - fprintf(outfile, "Nonlinear fn norm = %" RSYM "\n", kin_mem->kin_fnorm); - fprintf(outfile, "Step length = %" RSYM "\n", kin_mem->kin_stepl); - - /* linear solver stats */ - if (kin_mem->kin_lmem) - { - kinls_mem = (KINLsMem)(kin_mem->kin_lmem); - fprintf(outfile, "Jac fn evals = %ld\n", kinls_mem->nje); - fprintf(outfile, "LS Nonlinear fn evals = %ld\n", kinls_mem->nfeDQ); - fprintf(outfile, "Prec setup evals = %ld\n", kinls_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", kinls_mem->nps); - fprintf(outfile, "LS iters = %ld\n", kinls_mem->nli); - fprintf(outfile, "LS fails = %ld\n", kinls_mem->ncfl); - fprintf(outfile, "Jac-times evals = %ld\n", kinls_mem->njtimes); - if (kin_mem->kin_nni > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)kinls_mem->nli / (sunrealtype)kin_mem->kin_nni); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)kinls_mem->nje / (sunrealtype)kin_mem->kin_nni); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)kinls_mem->npe / (sunrealtype)kin_mem->kin_nni); - } - } - - break; - case SUN_OUTPUTFORMAT_CSV: - /* main solver stats */ - fprintf(outfile, "Nonlinear iters,%li", kin_mem->kin_nni); - fprintf(outfile, ",Nonlinear fn evals,%li", kin_mem->kin_nfe); - fprintf(outfile, ",Beta condition fails,%li", kin_mem->kin_nbcf); - fprintf(outfile, ",Backtrack operations,%li", kin_mem->kin_nbktrk); - fprintf(outfile, ",Nonlinear fn norm,%" RSYM, kin_mem->kin_fnorm); - fprintf(outfile, ",Step length,%" RSYM, kin_mem->kin_stepl); - - /* linear solver stats */ - if (kin_mem->kin_lmem) - { - kinls_mem = (KINLsMem)(kin_mem->kin_lmem); - fprintf(outfile, ",Jac fn evals,%ld", kinls_mem->nje); - fprintf(outfile, ",LS Nonlinear fn evals,%ld", kinls_mem->nfeDQ); - fprintf(outfile, ",Prec setup evals,%ld", kinls_mem->npe); - fprintf(outfile, ",Prec solves,%ld", kinls_mem->nps); - fprintf(outfile, ",LS iters,%ld", kinls_mem->nli); - fprintf(outfile, ",LS fails,%ld", kinls_mem->ncfl); - fprintf(outfile, ",Jac-times evals,%ld", kinls_mem->njtimes); - if (kin_mem->kin_nni > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)kinls_mem->nli / (sunrealtype)kin_mem->kin_nni); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)kinls_mem->nje / (sunrealtype)kin_mem->kin_nni); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)kinls_mem->npe / (sunrealtype)kin_mem->kin_nni); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } - } - fprintf(outfile, "\n"); - break; - default: + if (fmt != SUN_OUTPUTFORMAT_TABLE && fmt != SUN_OUTPUTFORMAT_CSV) + { KINProcessError(kin_mem, KIN_ILL_INPUT, __LINE__, __func__, __FILE__, "Invalid formatting option."); return (KIN_ILL_INPUT); } + sunfprintf_long(outfile, fmt, SUNTRUE, "Nonlinear iters", kin_mem->kin_nni); + sunfprintf_long(outfile, fmt, SUNFALSE, "Nonlinear fn evals", kin_mem->kin_nfe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Beta condition fails", + kin_mem->kin_nbcf); + sunfprintf_long(outfile, fmt, SUNFALSE, "Backtrack operations", + kin_mem->kin_nbktrk); + sunfprintf_real(outfile, fmt, SUNFALSE, "Nonlinear fn norm", + kin_mem->kin_fnorm); + sunfprintf_real(outfile, fmt, SUNFALSE, "Step length", kin_mem->kin_stepl); + + /* linear solver stats */ + if (kin_mem->kin_lmem) + { + kinls_mem = (KINLsMem)(kin_mem->kin_lmem); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac fn evals", kinls_mem->nje); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS Nonlinear fn evals", + kinls_mem->nfeDQ); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec setup evals", kinls_mem->npe); + sunfprintf_long(outfile, fmt, SUNFALSE, "Prec solves", kinls_mem->nps); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS iters", kinls_mem->nli); + sunfprintf_long(outfile, fmt, SUNFALSE, "LS fails", kinls_mem->ncfl); + sunfprintf_long(outfile, fmt, SUNFALSE, "Jac-times evals", + kinls_mem->njtimes); + if (kin_mem->kin_nni > 0) + { + sunfprintf_real(outfile, fmt, SUNFALSE, "LS iters per NLS iter", + (sunrealtype)kinls_mem->nli / (sunrealtype)kin_mem->kin_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Jac evals per NLS iter", + (sunrealtype)kinls_mem->nje / (sunrealtype)kin_mem->kin_nni); + sunfprintf_real(outfile, fmt, SUNFALSE, "Prec evals per NLS iter", + (sunrealtype)kinls_mem->npe / (sunrealtype)kin_mem->kin_nni); + } + } + return (KIN_SUCCESS); } diff --git a/src/kinsol/kinsol_ls_impl.h b/src/kinsol/kinsol_ls_impl.h index 6a47b9ba9a..1354409f22 100644 --- a/src/kinsol/kinsol_ls_impl.h +++ b/src/kinsol/kinsol_ls_impl.h @@ -163,20 +163,8 @@ int kinLs_AccessLMem(void* kinmem, const char* fname, KINMem* kin_mem, ------------------------------------------------------------------*/ #define INFO_NLI "nli_inc = %d" - -#if defined(SUNDIALS_EXTENDED_PRECISION) - -#define INFO_EPS "residual norm = %12.3Lg eps = %12.3Lg" - -#elif defined(SUNDIALS_DOUBLE_PRECISION) - -#define INFO_EPS "residual norm = %12.3lg eps = %12.3lg" - -#else - -#define INFO_EPS "residual norm = %12.3g eps = %12.3g" - -#endif +#define INFO_EPS \ + "residual norm = " SUN_REAL_FORMAT_G " eps = " SUN_REAL_FORMAT_G #ifdef __cplusplus } diff --git a/src/nvector/cuda/nvector_cuda.cu b/src/nvector/cuda/nvector_cuda.cu index 5acd83c038..bf68156eaf 100644 --- a/src/nvector/cuda/nvector_cuda.cu +++ b/src/nvector/cuda/nvector_cuda.cu @@ -611,15 +611,8 @@ void N_VPrintFile_Cuda(N_Vector x, FILE* outfile) for (i = 0; i < NVEC_CUDA_CONTENT(x)->length; i++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%35.32Le\n", NVEC_CUDA_HDATAp(x)[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%19.16e\n", NVEC_CUDA_HDATAp(x)[i]); -#else - fprintf(outfile, "%11.8e\n", NVEC_CUDA_HDATAp(x)[i]); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E "\n", NVEC_CUDA_HDATAp(x)[i]); } - fprintf(outfile, "\n"); return; } diff --git a/src/nvector/hip/nvector_hip.hip.cpp b/src/nvector/hip/nvector_hip.hip.cpp index 95f2d09f25..ca7dcd027b 100644 --- a/src/nvector/hip/nvector_hip.hip.cpp +++ b/src/nvector/hip/nvector_hip.hip.cpp @@ -578,15 +578,8 @@ void N_VPrintFile_Hip(N_Vector x, FILE* outfile) for (i = 0; i < NVEC_HIP_CONTENT(x)->length; i++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%35.32Le\n", NVEC_HIP_HDATAp(x)[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%19.16e\n", NVEC_HIP_HDATAp(x)[i]); -#else - fprintf(outfile, "%11.8e\n", NVEC_HIP_HDATAp(x)[i]); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E "\n", NVEC_HIP_HDATAp(x)[i]); } - fprintf(outfile, "\n"); return; } diff --git a/src/nvector/openmp/nvector_openmp.c b/src/nvector/openmp/nvector_openmp.c index bcb1f6d6b6..25b86ef200 100644 --- a/src/nvector/openmp/nvector_openmp.c +++ b/src/nvector/openmp/nvector_openmp.c @@ -265,16 +265,7 @@ void N_VPrintFile_OpenMP(N_Vector x, FILE* outfile) N = NV_LENGTH_OMP(x); xd = NV_DATA_OMP(x); - for (i = 0; i < N; i++) - { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%11.8Lg\n", xd[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%11.8g\n", xd[i]); -#else - fprintf(outfile, "%11.8g\n", xd[i]); -#endif - } + for (i = 0; i < N; i++) { fprintf(outfile, SUN_REAL_FORMAT_E "\n", xd[i]); } fprintf(outfile, "\n"); return; diff --git a/src/nvector/openmpdev/nvector_openmpdev.c b/src/nvector/openmpdev/nvector_openmpdev.c index 773feae94e..ca3b8caf8a 100644 --- a/src/nvector/openmpdev/nvector_openmpdev.c +++ b/src/nvector/openmpdev/nvector_openmpdev.c @@ -284,16 +284,7 @@ void N_VPrintFile_OpenMPDEV(N_Vector x, FILE* outfile) N = NV_LENGTH_OMPDEV(x); xd = NV_DATA_HOST_OMPDEV(x); - for (i = 0; i < N; i++) - { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%11.8Lg\n", xd[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%11.8g\n", xd[i]); -#else - fprintf(outfile, "%11.8g\n", xd[i]); -#endif - } + for (i = 0; i < N; i++) { fprintf(outfile, SUN_REAL_FORMAT_E "\n", xd[i]); } fprintf(outfile, "\n"); return; diff --git a/src/nvector/parallel/nvector_parallel.c b/src/nvector/parallel/nvector_parallel.c index eb278bc21d..a2d0642108 100644 --- a/src/nvector/parallel/nvector_parallel.c +++ b/src/nvector/parallel/nvector_parallel.c @@ -288,16 +288,7 @@ void N_VPrintFile_Parallel(N_Vector x, FILE* outfile) N = NV_LOCLENGTH_P(x); xd = NV_DATA_P(x); - for (i = 0; i < N; i++) - { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%35.32Le\n", xd[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%19.16e\n", xd[i]); -#else - fprintf(outfile, "%11.8e\n", xd[i]); -#endif - } + for (i = 0; i < N; i++) { fprintf(outfile, SUN_REAL_FORMAT_E "\n", xd[i]); } fprintf(outfile, "\n"); return; diff --git a/src/nvector/parhyp/nvector_parhyp.c b/src/nvector/parhyp/nvector_parhyp.c index aee1f08450..2ad770d41b 100644 --- a/src/nvector/parhyp/nvector_parhyp.c +++ b/src/nvector/parhyp/nvector_parhyp.c @@ -289,16 +289,7 @@ void N_VPrintFile_ParHyp(N_Vector x, FILE* outfile) N = NV_LOCLENGTH_PH(x); xd = NV_DATA_PH(x); - for (i = 0; i < N; i++) - { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%Lg\n", xd[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%g\n", xd[i]); -#else - fprintf(outfile, "%g\n", xd[i]); -#endif - } + for (i = 0; i < N; i++) { fprintf(outfile, SUN_REAL_FORMAT_E "\n", xd[i]); } fprintf(outfile, "\n"); return; diff --git a/src/nvector/pthreads/nvector_pthreads.c b/src/nvector/pthreads/nvector_pthreads.c index 5e5314afb3..233807f6fb 100644 --- a/src/nvector/pthreads/nvector_pthreads.c +++ b/src/nvector/pthreads/nvector_pthreads.c @@ -339,16 +339,7 @@ void N_VPrintFile_Pthreads(N_Vector x, FILE* outfile) N = NV_LENGTH_PT(x); xd = NV_DATA_PT(x); - for (i = 0; i < N; i++) - { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%11.8Lg\n", xd[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%11.8g\n", xd[i]); -#else - fprintf(outfile, "%11.8g\n", xd[i]); -#endif - } + for (i = 0; i < N; i++) { fprintf(outfile, SUN_REAL_FORMAT_E "\n", xd[i]); } fprintf(outfile, "\n"); return; diff --git a/src/nvector/raja/nvector_raja.cpp b/src/nvector/raja/nvector_raja.cpp index 5369a06f1a..36c8e75d6f 100644 --- a/src/nvector/raja/nvector_raja.cpp +++ b/src/nvector/raja/nvector_raja.cpp @@ -616,15 +616,8 @@ void N_VPrintFile_Raja(N_Vector X, FILE* outfile) for (i = 0; i < NVEC_RAJA_CONTENT(X)->length; i++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%35.32Lg\n", NVEC_RAJA_HDATAp(X)[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%19.16g\n", NVEC_RAJA_HDATAp(X)[i]); -#else - fprintf(outfile, "%11.8g\n", NVEC_RAJA_HDATAp(X)[i]); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E "\n", NVEC_RAJA_HDATAp(X)[i]); } - fprintf(outfile, "\n"); return; } diff --git a/src/nvector/serial/nvector_serial.c b/src/nvector/serial/nvector_serial.c index 255aca3fb6..4a5a558ef4 100644 --- a/src/nvector/serial/nvector_serial.c +++ b/src/nvector/serial/nvector_serial.c @@ -258,16 +258,7 @@ void N_VPrintFile_Serial(N_Vector x, FILE* outfile) N = NV_LENGTH_S(x); xd = NV_DATA_S(x); - for (i = 0; i < N; i++) - { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%35.32Le\n", xd[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%19.16e\n", xd[i]); -#else - fprintf(outfile, "%11.8e\n", xd[i]); -#endif - } + for (i = 0; i < N; i++) { fprintf(outfile, SUN_REAL_FORMAT_E "\n", xd[i]); } fprintf(outfile, "\n"); return; diff --git a/src/nvector/sycl/nvector_sycl.cpp b/src/nvector/sycl/nvector_sycl.cpp index ce2106e210..0c58a072e5 100644 --- a/src/nvector/sycl/nvector_sycl.cpp +++ b/src/nvector/sycl/nvector_sycl.cpp @@ -709,15 +709,8 @@ void N_VPrintFile_Sycl(N_Vector X, FILE* outfile) for (i = 0; i < NVEC_SYCL_CONTENT(X)->length; i++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%35.32Lg\n", NVEC_SYCL_HDATAp(X)[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%19.16g\n", NVEC_SYCL_HDATAp(X)[i]); -#else - fprintf(outfile, "%11.8g\n", NVEC_SYCL_HDATAp(X)[i]); -#endif - } - fprintf(outfile, "\n"); + fprintf(outfile, SUN_REAL_FORMAT_E "\n", NVEC_SYCL_HDATAp(X)[i]); + } return; } diff --git a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c index e4bb23e6dd..f40d8d0407 100644 --- a/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c +++ b/src/sunadaptcontroller/imexgus/sunadaptcontroller_imexgus.c @@ -181,23 +181,13 @@ SUNErrCode SUNAdaptController_Write_ImExGus(SUNAdaptController C, FILE* fptr) SUNFunctionBegin(C->sunctx); SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); fprintf(fptr, "ImEx Gustafsson SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1e = %32Lg\n", SACIMEXGUS_K1E(C)); - fprintf(fptr, " k2e = %32Lg\n", SACIMEXGUS_K2E(C)); - fprintf(fptr, " k1i = %32Lg\n", SACIMEXGUS_K1I(C)); - fprintf(fptr, " k2i = %32Lg\n", SACIMEXGUS_K2I(C)); - fprintf(fptr, " bias factor = %22Lg\n", SACIMEXGUS_BIAS(C)); - fprintf(fptr, " previous error = %22Lg\n", SACIMEXGUS_EP(C)); - fprintf(fptr, " previous step = %22Lg\n", SACIMEXGUS_HP(C)); -#else - fprintf(fptr, " k1e = %16g\n", SACIMEXGUS_K1E(C)); - fprintf(fptr, " k2e = %16g\n", SACIMEXGUS_K2E(C)); - fprintf(fptr, " k1i = %16g\n", SACIMEXGUS_K1I(C)); - fprintf(fptr, " k2i = %16g\n", SACIMEXGUS_K2I(C)); - fprintf(fptr, " bias factor = %16g\n", SACIMEXGUS_BIAS(C)); - fprintf(fptr, " previous error = %16g\n", SACIMEXGUS_EP(C)); - fprintf(fptr, " previous step = %16g\n", SACIMEXGUS_HP(C)); -#endif + fprintf(fptr, " k1e = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_K1E(C)); + fprintf(fptr, " k2e = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_K2E(C)); + fprintf(fptr, " k1i = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_K1I(C)); + fprintf(fptr, " k2i = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_K2I(C)); + fprintf(fptr, " bias factor = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_BIAS(C)); + fprintf(fptr, " previous error = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_EP(C)); + fprintf(fptr, " previous step = " SUN_REAL_FORMAT_G "\n", SACIMEXGUS_HP(C)); return SUN_SUCCESS; } diff --git a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c index bca88252cb..8c9ac934e5 100644 --- a/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c +++ b/src/sunadaptcontroller/soderlind/sunadaptcontroller_soderlind.c @@ -372,29 +372,18 @@ SUNErrCode SUNAdaptController_Write_Soderlind(SUNAdaptController C, FILE* fptr) SUNFunctionBegin(C->sunctx); SUNAssert(fptr, SUN_ERR_ARG_CORRUPT); fprintf(fptr, "Soderlind SUNAdaptController module:\n"); -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(fptr, " k1 = %32Lg\n", SODERLIND_K1(C)); - fprintf(fptr, " k2 = %32Lg\n", SODERLIND_K2(C)); - fprintf(fptr, " k3 = %32Lg\n", SODERLIND_K3(C)); - fprintf(fptr, " k4 = %32Lg\n", SODERLIND_K4(C)); - fprintf(fptr, " k5 = %32Lg\n", SODERLIND_K5(C)); - fprintf(fptr, " bias factor = %22Lg\n", SODERLIND_BIAS(C)); - fprintf(fptr, " previous error = %22Lg\n", SODERLIND_EP(C)); - fprintf(fptr, " previous-previous error = %22Lg\n", SODERLIND_EPP(C)); - fprintf(fptr, " previous step = %22Lg\n", SODERLIND_HP(C)); - fprintf(fptr, " previous-previous step = %22Lg\n", SODERLIND_HPP(C)); -#else - fprintf(fptr, " k1 = %16g\n", SODERLIND_K1(C)); - fprintf(fptr, " k2 = %16g\n", SODERLIND_K2(C)); - fprintf(fptr, " k3 = %16g\n", SODERLIND_K3(C)); - fprintf(fptr, " k4 = %16g\n", SODERLIND_K4(C)); - fprintf(fptr, " k5 = %16g\n", SODERLIND_K5(C)); - fprintf(fptr, " bias factor = %16g\n", SODERLIND_BIAS(C)); - fprintf(fptr, " previous error = %16g\n", SODERLIND_EP(C)); - fprintf(fptr, " previous-previous error = %16g\n", SODERLIND_EPP(C)); - fprintf(fptr, " previous step = %16g\n", SODERLIND_HP(C)); - fprintf(fptr, " previous-previous step = %16g\n", SODERLIND_HPP(C)); -#endif + fprintf(fptr, " k1 = " SUN_REAL_FORMAT_G "\n", SODERLIND_K1(C)); + fprintf(fptr, " k2 = " SUN_REAL_FORMAT_G "\n", SODERLIND_K2(C)); + fprintf(fptr, " k3 = " SUN_REAL_FORMAT_G "\n", SODERLIND_K3(C)); + fprintf(fptr, " k4 = " SUN_REAL_FORMAT_G "\n", SODERLIND_K4(C)); + fprintf(fptr, " k5 = " SUN_REAL_FORMAT_G "\n", SODERLIND_K5(C)); + fprintf(fptr, " bias factor = " SUN_REAL_FORMAT_G "\n", SODERLIND_BIAS(C)); + fprintf(fptr, " previous error = " SUN_REAL_FORMAT_G "\n", SODERLIND_EP(C)); + fprintf(fptr, " previous-previous error = " SUN_REAL_FORMAT_G "\n", + SODERLIND_EPP(C)); + fprintf(fptr, " previous step = " SUN_REAL_FORMAT_G "\n", SODERLIND_HP(C)); + fprintf(fptr, " previous-previous step = " SUN_REAL_FORMAT_G "\n", + SODERLIND_HPP(C)); fprintf(fptr, " firststeps = %i\n", SODERLIND_FIRSTSTEPS(C)); return SUN_SUCCESS; } diff --git a/src/sundials/sundials_direct.c b/src/sundials/sundials_direct.c index 02ff31d96c..0977f95f1f 100644 --- a/src/sundials/sundials_direct.c +++ b/src/sundials/sundials_direct.c @@ -323,13 +323,7 @@ void SUNDlsMat_PrintMat(SUNDlsMat A, FILE* outfile) { for (j = 0; j < A->N; j++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%12Lg ", SUNDLS_DENSE_ELEM(A, i, j)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%12g ", SUNDLS_DENSE_ELEM(A, i, j)); -#else - fprintf(outfile, "%12g ", SUNDLS_DENSE_ELEM(A, i, j)); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E " ", SUNDLS_DENSE_ELEM(A, i, j)); } fprintf(outfile, "\n"); } @@ -348,13 +342,7 @@ void SUNDlsMat_PrintMat(SUNDlsMat A, FILE* outfile) for (j = 0; j < start; j++) { fprintf(outfile, "%12s ", ""); } for (j = start; j <= finish; j++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%12Lg ", a[j][i - j + A->s_mu]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%12g ", a[j][i - j + A->s_mu]); -#else - fprintf(outfile, "%12g ", a[j][i - j + A->s_mu]); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E " ", a[j][i - j + A->s_mu]); } fprintf(outfile, "\n"); } diff --git a/src/sundials/sundials_utils.h b/src/sundials/sundials_utils.h index 44ce2a7d4b..028759c1e1 100644 --- a/src/sundials/sundials_utils.h +++ b/src/sundials/sundials_utils.h @@ -24,6 +24,9 @@ #include #include +/* width of name field in sunfprintf_ for aligning table output */ +#define SUN_TABLE_WIDTH 28 + static inline char* sunCombineFileAndLine(int line, const char* file) { size_t total_str_len = strlen(file) + 6; @@ -86,4 +89,56 @@ static inline void sunCompensatedSum(sunrealtype base, sunrealtype inc, *sum = tmp2; } +static inline void sunfprintf_real(FILE* fp, SUNOutputFormat fmt, + sunbooleantype start, const char* name, + sunrealtype value) +{ + if (fmt == SUN_OUTPUTFORMAT_TABLE) + { + fprintf(fp, "%-*s = " SUN_REAL_FORMAT_G "\n", SUN_TABLE_WIDTH, name, value); + } + else + { + if (!start) { fprintf(fp, ","); } + fprintf(fp, "%s," SUN_REAL_FORMAT_E, name, value); + } +} + +static inline void sunfprintf_long(FILE* fp, SUNOutputFormat fmt, + sunbooleantype start, const char* name, + long value) +{ + if (fmt == SUN_OUTPUTFORMAT_TABLE) + { + fprintf(fp, "%-*s = %ld\n", SUN_TABLE_WIDTH, name, value); + } + else + { + if (!start) { fprintf(fp, ","); } + fprintf(fp, "%s,%ld", name, value); + } +} + +static inline void sunfprintf_long_array(FILE* fp, SUNOutputFormat fmt, + sunbooleantype start, const char* name, + long* value, size_t count) +{ + if (count < 1) { return; } + + if (fmt == SUN_OUTPUTFORMAT_TABLE) + { + fprintf(fp, "%-*s = %ld\n", SUN_TABLE_WIDTH, name, value[0]); + for (size_t i = 1; i < count; i++) { fprintf(fp, ", %ld", value[i]); } + fprintf(fp, "\n"); + } + else + { + if (!start) { fprintf(fp, ","); } + for (size_t i = 0; i < count; i++) + { + fprintf(fp, "%s %zu,%ld", name, i, value[i]); + } + } +} + #endif /* _SUNDIALS_UTILS_H */ diff --git a/src/sunlinsol/pcg/sunlinsol_pcg.c b/src/sunlinsol/pcg/sunlinsol_pcg.c index 100183e82c..28cccd82d2 100644 --- a/src/sunlinsol/pcg/sunlinsol_pcg.c +++ b/src/sunlinsol/pcg/sunlinsol_pcg.c @@ -348,8 +348,9 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_PCG", - "initial-residual", "nli = %li, resnorm = %.16g", - (long int)0, *res_norm); + "initial-residual", + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (long int)0, + *res_norm); #endif if (rho <= delta) @@ -440,7 +441,8 @@ int SUNLinSolSolve_PCG(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix nul, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_PCG", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (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 67df9bcdfe..d434b3119d 100644 --- a/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c +++ b/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c @@ -426,7 +426,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPBCGS", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (long int)0, + *res_norm); #endif if (r_norm <= delta) @@ -657,7 +658,8 @@ int SUNLinSolSolve_SPBCGS(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPBCGS", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (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 a1d3ea27ad..e04e006ff5 100644 --- a/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c +++ b/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c @@ -466,7 +466,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPFGMR", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (long int)0, + *res_norm); #endif if (r_norm <= delta) @@ -577,7 +578,8 @@ int SUNLinSolSolve_SPFGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPFGMR", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (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 6ef57661ae..c5e69cb144 100644 --- a/src/sunlinsol/spgmr/sunlinsol_spgmr.c +++ b/src/sunlinsol/spgmr/sunlinsol_spgmr.c @@ -470,7 +470,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPGMR", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (long int)0, + *res_norm); #endif if (r_norm <= delta) @@ -602,7 +603,8 @@ int SUNLinSolSolve_SPGMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPGMR", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)*nli, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, + (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 28ad1ef883..17ed506816 100644 --- a/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c +++ b/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c @@ -428,7 +428,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPFTQMR", "initial-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (long int)0, + *res_norm); #endif if (r_init_norm <= delta) @@ -657,7 +658,8 @@ int SUNLinSolSolve_SPTFQMR(SUNLinearSolver S, SUNDIALS_MAYBE_UNUSED SUNMatrix A, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFOs SUNLogger_QueueMsg(S->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNLinSolSolve_SPTFQMR", "iterate-residual", - "nli = %li, resnorm = %.16g", (long int)0, *res_norm); + "nli = %li, resnorm = " SUN_REAL_FORMAT_G, (long int)0, + *res_norm); #endif /* Exit inner loop if iteration has converged based upon approximation diff --git a/src/sunmatrix/band/sunmatrix_band.c b/src/sunmatrix/band/sunmatrix_band.c index f3d06c730b..0a8b278591 100644 --- a/src/sunmatrix/band/sunmatrix_band.c +++ b/src/sunmatrix/band/sunmatrix_band.c @@ -138,13 +138,7 @@ void SUNBandMatrix_Print(SUNMatrix A, FILE* outfile) for (j = 0; j < start; j++) { fprintf(outfile, "%12s ", ""); } for (j = start; j <= finish; j++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%12Lg ", SM_ELEMENT_B(A, i, j)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%12g ", SM_ELEMENT_B(A, i, j)); -#else - fprintf(outfile, "%12g ", SM_ELEMENT_B(A, i, j)); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E " ", SM_ELEMENT_B(A, i, j)); } fprintf(outfile, "\n"); } diff --git a/src/sunmatrix/dense/sunmatrix_dense.c b/src/sunmatrix/dense/sunmatrix_dense.c index c1250a9eaa..9a60ba7975 100644 --- a/src/sunmatrix/dense/sunmatrix_dense.c +++ b/src/sunmatrix/dense/sunmatrix_dense.c @@ -114,13 +114,7 @@ void SUNDenseMatrix_Print(SUNMatrix A, FILE* outfile) { for (j = 0; j < SM_COLUMNS_D(A); j++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%12Lg ", SM_ELEMENT_D(A, i, j)); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%12g ", SM_ELEMENT_D(A, i, j)); -#else - fprintf(outfile, "%12g ", SM_ELEMENT_D(A, i, j)); -#endif + fprintf(outfile, SUN_REAL_FORMAT_E " ", SM_ELEMENT_D(A, i, j)); } fprintf(outfile, "\n"); } diff --git a/src/sunmatrix/sparse/sunmatrix_sparse.c b/src/sunmatrix/sparse/sunmatrix_sparse.c index bbdbc344d2..4195351423 100644 --- a/src/sunmatrix/sparse/sunmatrix_sparse.c +++ b/src/sunmatrix/sparse/sunmatrix_sparse.c @@ -416,16 +416,8 @@ void SUNSparseMatrix_Print(SUNMatrix A, FILE* outfile) fprintf(outfile, " "); for (i = (SM_INDEXPTRS_S(A))[j]; i < (SM_INDEXPTRS_S(A))[j + 1]; i++) { -#if defined(SUNDIALS_EXTENDED_PRECISION) - fprintf(outfile, "%ld: %.32Lg ", (long int)(SM_INDEXVALS_S(A))[i], - (SM_DATA_S(A))[i]); -#elif defined(SUNDIALS_DOUBLE_PRECISION) - fprintf(outfile, "%ld: %.16g ", (long int)(SM_INDEXVALS_S(A))[i], - (SM_DATA_S(A))[i]); -#else - fprintf(outfile, "%ld: %.8g ", (long int)(SM_INDEXVALS_S(A))[i], - (SM_DATA_S(A))[i]); -#endif + fprintf(outfile, "%ld: " SUN_REAL_FORMAT_E " ", + (long int)(SM_INDEXVALS_S(A))[i], (SM_DATA_S(A))[i]); } fprintf(outfile, "\n"); } diff --git a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c index ff1d45a2c9..0f9ff3d13a 100644 --- a/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +++ b/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c @@ -243,7 +243,7 @@ int SUNNonlinSolSolve_FixedPoint(SUNNonlinearSolver NLS, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, "SUNNonlinSolSolve_FixedPoint", "end-of-iterate", - "iter = %ld, nni = %ld, wrmsnorm = %.16g", + "iter = %ld, nni = %ld, wrmsnorm = " SUN_REAL_FORMAT_G, (long int)FP_CONTENT(NLS)->curiter, FP_CONTENT(NLS)->niters, N_VWrmsNorm(delta, w)); #endif diff --git a/src/sunnonlinsol/newton/sunnonlinsol_newton.c b/src/sunnonlinsol/newton/sunnonlinsol_newton.c index c4c0af932a..5780884964 100644 --- a/src/sunnonlinsol/newton/sunnonlinsol_newton.c +++ b/src/sunnonlinsol/newton/sunnonlinsol_newton.c @@ -257,7 +257,8 @@ int SUNNonlinSolSolve_Newton(SUNNonlinearSolver NLS, #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_INFO SUNLogger_QueueMsg(NLS->sunctx->logger, SUN_LOGLEVEL_INFO, __func__, - "end-iterate", "iter = %ld, nni = %ld, wrmsnorm = %.16g", + "end-iterate", + "iter = %ld, nni = %ld, wrmsnorm = " SUN_REAL_FORMAT_G, NEWTON_CONTENT(NLS)->curiter, NEWTON_CONTENT(NLS)->niters - 1, N_VWrmsNorm(delta, w)); #endif diff --git a/swig/sundials/fsundials_types.i b/swig/sundials/fsundials_types.i index 0f61838b50..3413d08015 100644 --- a/swig/sundials/fsundials_types.i +++ b/swig/sundials/fsundials_types.i @@ -32,6 +32,9 @@ #define SUNDIALS_DOUBLE_PRECISION #define sunbooleantype int +%ignore SUN_REAL_FORMAT_E; +%ignore SUN_REAL_FORMAT_G; + // Handle MPI_Comm and SUNComm %include diff --git a/test/answers b/test/answers index dd4aebcaa5..0931930a2d 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit dd4aebcaa5a886746fa281c528d452fdae825cd2 +Subproject commit 0931930a2d2b3af09999c1d8736684d1e597c9c5