MRKISS 2025-09-10
A tiny library with zero dependencies that aims to make it easy to use & experiment with explicit Runge-Kutta methods.
Loading...
Searching...
No Matches
mrkiss_utils Module Reference

Utilities. More...

Functions/Subroutines

I/O
subroutine, public print_solution (status, solution, filename_o, separator_o, fmt_w_o, fmt_d_o, fmt_e_o, start_o, end_o, step_o, prt_titles_o, t_min_o, t_max_o, tag_o, append_o)
 Output an RK solution matrix.
subroutine, public print_istats (status, istats, idxs_to_prt_o, filename_o, fmt_w_o, prt_zeros_o)
 Output an istat array.
subroutine, public analyze_solution (status, solution, filename_o, start_o, end_o, y_delta_len_idxs_o, fmt_w_o, fmt_d_o, fmt_e_o)
 Analyze an RK solution matrix.
Miscellaneous
subroutine, public seq (status, t, from_o, to_o, step_o, max_pts_o)
 Produce a sequence of values with fixed seporation.
Status Codes
character(len=32) function, public status_to_origin (status)
 Return, as a string, the source of a status code.
character(len=128) function, public status_to_message (status)
 Return, as a string, the source of a status code.

Detailed Description

Utilities.

Function/Subroutine Documentation

◆ print_solution()

subroutine, public mrkiss_utils::print_solution ( integer, intent(out) status,
real(kind=rk), dimension(:,:), intent(in) solution,
character(len=*), intent(in), optional filename_o,
character(len=*), intent(in), optional separator_o,
integer, intent(in), optional fmt_w_o,
integer, intent(in), optional fmt_d_o,
integer, intent(in), optional fmt_e_o,
integer, intent(in), optional start_o,
integer, intent(in), optional end_o,
integer, intent(in), optional step_o,
logical, intent(in), optional prt_titles_o,
real(kind=rk), intent(in), optional t_min_o,
real(kind=rk), intent(in), optional t_max_o,
integer, intent(in), optional tag_o,
logical, intent(in), optional append_o )

Output an RK solution matrix.

Examples

  • 1: The default values will produce CSV output
    print_solution(solution)
  • 2: For columnar output we just need to add a width
    print_solution(solution, fmt_w_o=30)
Parameters
statusExit status
Value Description
-inf-0 Everything worked
1152 Could not open file for write
1153 Could not close file
1154-1183 Unknown error in this routine
solutionArray containing the solution. Each COLUMN is a solution:
  • First element is the \(t\) variable
  • size(y, 1) elements starting with 2 have \(\mathbf{y}\) values
  • The next size(y, 1) elements have \(\mathbf{y}'\) values
filename_oFilename to which we print. Default: NONE
  • If not present, then output will be to output_unit (STDOUT).
fmt_d_oNumber of digits for floating point numbers. Default: mrkiss_config::fmt_d_ai
fmt_w_oWidth of print format for all entities. Default: 0
fmt_e_oNumber of digits in the exponent of floating point numbers. Default: mrkiss_config::fmt_e_ai
  • Ignored if fmt_w_o==0
start_oStarting index to print in solution. Default: 1
end_oEnding index to print in solution. Default: Number of columns in solution.
step_oPrint only every step_o th value in solution. Default: 1
prt_titles_oPrint titles if .TRUE. Default: .not. append_o
separator_oString to place between fields. Default: ',' if fmt_w_o missing, and ' ' otherwise.
t_min_oPrint only solutions with time values >= t_min_o
t_max_oPrint only solutions with time values <= t_min_o
tag_oIf non-negative, this integer that will become the first column of the output. Default: -1
append_oAppend to file instead of overwriting. Default: .FALSE.

Definition at line 89 of file mrkiss_utils.f90.

◆ print_istats()

subroutine, public mrkiss_utils::print_istats ( integer, intent(out) status,
integer, dimension(istats_size), intent(in) istats,
integer, dimension(:), intent(in), optional idxs_to_prt_o,
character(len=*), intent(in), optional filename_o,
integer, intent(in), optional fmt_w_o,
logical, intent(in), optional prt_zeros_o )

Output an istat array.

Parameters
statusExit status
Value Description
-inf-0 Everything worked
1365 Could not open file for write
1366 Could not close file
1367-1381 Unknown error in this routine
istats(:)Integer statistics from a solver run. See mrkiss_utils::print_istats() for description of elements.
idxs_to_prt_o(:)Indexes of istats to print. Indexes too large are silently ignored.
filename_oFilename to which we print. Default: NONE
  • If not present, then output will be to output_unit (STDOUT).
fmt_w_oWidth of print format for all entities. Default: mrkiss_config::fmt_w_ai
prt_zeros_oIf .TRUE., then print zero values. Default: .FALSE.

Definition at line 252 of file mrkiss_utils.f90.

◆ analyze_solution()

subroutine, public mrkiss_utils::analyze_solution ( integer, intent(out) status,
real(kind=rk), dimension(:,:), intent(in) solution,
character(len=*), intent(in), optional filename_o,
integer, intent(in), optional start_o,
integer, intent(in), optional end_o,
integer, dimension(:), intent(in), optional y_delta_len_idxs_o,
integer, intent(in), optional fmt_w_o,
integer, intent(in), optional fmt_d_o,
integer, intent(in), optional fmt_e_o )

Analyze an RK solution matrix.

Parameters
statusExit status
Value Description
-inf-0 Everything worked
1297 Could not open file for write
1298 Could not close file
1299-1313 Unknown error in this routine
solutionArray containing the solution. Each COLUMN is a solution:
  • First element is the \(t\) variable
  • size(y, 1) elements starting with 2 have \(\mathbf{y}\) values
  • The next size(y, 1) elements have \(\mathbf{y}'\) values
start_oStarting index to use in solution. Default: 1
end_oEnding index to use in solution. Default: Number of columns in solution.
y_delta_len_idxs_oComponents of \(\mathbf{\Delta{y}}\) to use for length computation
filename_oFilename to which we print. Default: NONE
  • If not present, then output will be to output_unit (STDOUT).
fmt_d_oNumber of digits for floating point numbers. Default: mrkiss_config::fmt_d_ai
fmt_w_oWidth of print format for all entities. Default: mrkiss_config::fmt_w_ai
fmt_e_oNumber of digits in the exponent of floating point numbers. Default: mrkiss_config::fmt_e_ai

Definition at line 330 of file mrkiss_utils.f90.

◆ seq()

subroutine, public mrkiss_utils::seq ( integer, intent(out) status,
real(kind=rk), dimension(:), intent(out) t,
real(kind=rk), intent(in), optional from_o,
real(kind=rk), intent(in), optional to_o,
real(kind=rk), intent(in), optional step_o,
integer, intent(in), optional max_pts_o )

Produce a sequence of values with fixed seporation.

Modeled after R's seq() function.

Exactly two of from_o, to_o, and step_o should be provided. The one not provided will be computed from the others. If all three are are provided, then they will be checked for consistency. Note that this consistency check is not completely reliable due to round-off error. This is why only two should be provided.

Parameters
statusExit status
Value Description
-inf-0 Everything worked
1314 Inconsistant sequence values: step_v_o * (size(t)-1) /= to_v - from_v
1315 Not enough arguments
1316-1330 Unknown error in this routine
tVector to fill with \(t\) values
from_oStarting value for \(t\)
to_oEnding value for \(t\)
step_oDelta between valeus
max_pts_oMaximum number of points to produce. Default: size(t, 1) If max_pts_o < size(t, 1), then elements beyond max_pts_o will be untouched.

Definition at line 474 of file mrkiss_utils.f90.

◆ status_to_origin()

character(len=32) function, public mrkiss_utils::status_to_origin ( integer, intent(in) status)

Return, as a string, the source of a status code.

Status codes are assigned in blocks to subroutines and interfaces. Status codes are frequently "passed up" the call chain. i.e. a routine may return a status code that was returned to it by another routine it called. Assigning the codes in blocks allows the user to know from which subroutine a status code originated.

Assigned Status Ranges

Range Assignment
0001-0255 mrkiss_solvers_wt::deq_iface & mrkiss_solvers_nt::deq_iface
0256-0511 mrkiss_solvers_wt::stepp_iface & mrkiss_solvers_nt::stepp_iface
0512-0767 mrkiss_solvers_wt::sdf_iface & mrkiss_solvers_nt::sdf_iface
1232-1247 mrkiss_solvers_wt::step_all & mrkiss_solvers_nt::step_all
1248-1263 mrkiss_solvers_wt::step_one & mrkiss_solvers_nt::step_one
1216-1231 mrkiss_solvers_wt::step_richardson & mrkiss_solvers_nt::step_richardson
1200-1215 mrkiss_solvers_wt::step_rk4 & mrkiss_solvers_nt::step_rk4
1184-1199 mrkiss_solvers_wt::step_rkf45 & mrkiss_solvers_nt::step_rkf45
1263-1279 mrkiss_solvers_wt::step_dp54 & mrkiss_solvers_nt::step_dp54
1120-1151 mrkiss_solvers_wt::fixed_t_steps & mrkiss_solvers_nt::fixed_t_steps
1024-1055 mrkiss_solvers_wt::fixed_y_steps & mrkiss_solvers_nt::fixed_y_steps
1280-1296 mrkiss_solvers_wt::sloppy_fixed_y_steps & mrkiss_solvers_nt::sloppy_fixed_y_steps
1056-1119 mrkiss_solvers_wt::adaptive_steps & mrkiss_solvers_nt::adaptive_steps
1152-1183 mrkiss_utils::print_solution
1297-1313 mrkiss_utils::analyze_solution
1314:1330 mrkiss_utils::seq
1331:1347 mrkiss_solvers_wt::interpolate_solution & mrkiss_solvers_nt::interpolate_solution
1348-1364 mrkiss_solvers_wt::fixed_t_steps_between & mrkiss_solvers_nt::fixed_t_steps_between
1365-1381 mrkiss_utils::print_istats
1382-1398 Unallocated
1399-1415 Unallocated

I use the following bit of Emacs lisp code to generate new blocks:

 !! (let ((s ))
 !!   (cl-loop for f from 1348 to 2000 by 17
 !!            do (print f)
 !!            do (setq s (concat s (format  f (+ 16 f)))))
 !!   s)
 !! 
Parameters
statusThis is an intent(in) argument!!!!
Returns
A string (len=32) identifying the origin of the status code.
  • A subroutine or interface name
  • "NO ERROR" for a non-error status of unknown origin
  • "UNKNOWN SOURCE" for an error status of unknown origin

Definition at line 583 of file mrkiss_utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_to_message()

character(len=128) function, public mrkiss_utils::status_to_message ( integer, intent(in) status)

Return, as a string, the source of a status code.

Parameters
statusThis is an intent(in) argument!!!!
Returns
A string (len=128) identifying the message of the status code.
  • Format: "SOURCE: MESSAGE"
    • SOURCE will be the subroutine or interface if known, and "UNKNOWN SOURCE" otherwise
    • MESSAGE will be the error message if known, and "UNKNOWN ERROR" otherwise
  • "NO ERROR" for a non-error status of unknown message

Definition at line 643 of file mrkiss_utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function: