SDDSlib
Loading...
Searching...
No Matches
diffeqResDescrip.c
Go to the documentation of this file.
1/**
2 * @file diffeqResDescrip.c
3 * @brief Provides a description string corresponding to a given differential equation result code.
4 *
5 * This file defines a function that, given a result code from a differential equation
6 * solver, returns a human-readable description of the result. The possible codes
7 * range from error conditions to successful completion indicators.
8 *
9 * @copyright
10 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
11 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
12 *
13 * @license
14 * This file is distributed under the terms of the Software License Agreement
15 * found in the file LICENSE included with this distribution.
16 *
17 * @author M. Borland, C. Saunders, R. Soliday
18 */
19#include "mdb.h"
20
21#define N_DIFFEQ_RETURNS 8
22
23static struct {
24 long code;
25 char *description;
26} diffeq_return[N_DIFFEQ_RETURNS] = {
27 {-4, "exit condition failure"},
28 {-3, "zero stepsize"},
29 {-2, "can't take initial step"},
30 {-1, "solution stepped outside of integration interval"},
31 {0, "initial independent variable value greater than desired final value"},
32 {1, "differential equations solved already"},
33 {2, "zero of exit-function found"},
34 {3, "end of integration interval reached"}};
35static char *unknown = "unknown error";
36
37/**
38 * @brief Return a descriptive string for a given differential equation result code.
39 *
40 * This function maps a numerical result code to a corresponding string describing
41 * the outcome of a differential equation integration procedure. If the code is not
42 * recognized, the function returns "unknown error".
43 *
44 * @param result_code The integer code representing the result of a differential equation solver.
45 * @return A constant character pointer to a descriptive string for the given code.
46 */
47char *diffeq_result_description(long result_code) {
48 int i;
49 for (i = 0; i < N_DIFFEQ_RETURNS; i++) {
50 if (result_code == diffeq_return[i].code)
51 return (diffeq_return[i].description);
52 }
53 return unknown;
54}
char * diffeq_result_description(long result_code)
Return a descriptive string for a given differential equation result code.