OMCompiler/SimulationRuntime/c/util/varinfo.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | #include "omc_error.h" | ||
| 29 | #include "../simulation_data.h" | ||
| 30 | #include "varinfo.h" | ||
| 31 | |||
| 32 | const char *var_type_names[VAR_TYPE_MAX] = { | ||
| 33 | [VAR_TYPE_UNKNOWN] = "unknown", | ||
| 34 | |||
| 35 | [VAR_TYPE_REAL] = "real", | ||
| 36 | [VAR_TYPE_INTEGER] = "integer", | ||
| 37 | [VAR_TYPE_BOOLEAN] = "boolean", | ||
| 38 | [VAR_TYPE_STRING] = "string" | ||
| 39 | }; | ||
| 40 | |||
| 41 | const char *var_kind_names[VAR_KIND_MAX] = { | ||
| 42 | [VAR_KIND_UNKNOWN] = "unknown", | ||
| 43 | |||
| 44 | [VAR_KIND_STATE] = "state", | ||
| 45 | [VAR_KIND_VARIABLE] = "variable", | ||
| 46 | [VAR_KIND_PARAMETER] = "parameter" | ||
| 47 | }; | ||
| 48 | |||
| 49 | ✗ | void printErrorEqSyst(EQUATION_SYSTEM_ERROR err, EQUATION_INFO eq, double time) | |
| 50 | { | ||
| 51 | ✗ | int indexes[2] = {1,eq.id}; | |
| 52 | ✗ | switch(err) | |
| 53 | { | ||
| 54 | ✗ | case ERROR_AT_TIME: | |
| 55 | ✗ | warningStreamPrintWithEquationIndexes(OMC_LOG_NLS, omc_dummyFileInfo, 0, indexes, "Error solving nonlinear system %d at time %g", eq.id, time); | |
| 56 | ✗ | break; | |
| 57 | ✗ | case NO_PROGRESS_START_POINT: | |
| 58 | ✗ | warningStreamPrintWithEquationIndexes(OMC_LOG_NLS, omc_dummyFileInfo, 0, indexes, "Solving nonlinear system %d: iteration not making progress, trying with different starting points (+%g)", eq.id, time); | |
| 59 | ✗ | break; | |
| 60 | ✗ | case NO_PROGRESS_FACTOR: | |
| 61 | ✗ | warningStreamPrintWithEquationIndexes(OMC_LOG_NLS, omc_dummyFileInfo, 0, indexes, "Solving nonlinear system %d: iteration not making progress, trying to decrease factor to %g", eq.id, time); | |
| 62 | ✗ | break; | |
| 63 | ✗ | case IMPROPER_INPUT: | |
| 64 | ✗ | warningStreamPrintWithEquationIndexes(OMC_LOG_NLS, omc_dummyFileInfo, 0, indexes, "improper input parameters to nonlinear eq. syst: %d at time %g", eq.id, time); | |
| 65 | ✗ | break; | |
| 66 | ✗ | default: | |
| 67 | ✗ | warningStreamPrintWithEquationIndexes(OMC_LOG_NLS, omc_dummyFileInfo, 0, indexes, "Unknown equation system error: %d %d %g", err, eq.id, time); | |
| 68 | ✗ | break; | |
| 69 | } | ||
| 70 | ✗ | } | |
| 71 | |||
| 72 | /** | ||
| 73 | * @brief Free memory allocated by `read_var_info`. | ||
| 74 | * | ||
| 75 | * @param info Pointer to variable info. | ||
| 76 | */ | ||
| 77 | 3 | void freeVarInfo(VAR_INFO* info) | |
| 78 | { | ||
| 79 | 3 | free((void*)info->info.filename); | |
| 80 | 3 | free((void*)info->name); | |
| 81 | 3 | free((void*)info->comment); | |
| 82 | 3 | } | |
| 83 |