![]() |
NEURON
|
#include <../../nmodlconf.h>#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <string.h>#include "units.h"#include <assert.h>Go to the source code of this file.
Classes | |
| struct | table |
| struct | prefix |
Macros | |
| #define | NRN_DYNAMIC_UNITS 0 |
| The strategy for dynamic units selection between Legacy and modern units is to maintain two complete tables respectively. More... | |
| #define | IFUNITS {if (!UnitsOn) return;} |
| #define | OUTTOLERANCE(arg1, arg2) (fabs(arg2/arg1 - 1.) > 1.e-5) |
| #define | NTAB 601 |
| #define | SUFFIX "" |
| #define | UNIT_STK_SIZE 20 |
Variables | |
| int | unitonflag = 1 |
| static int | UnitsOn = 0 |
| static char * | dfile = "/usr/lib/units" |
| static char * | dfilealt = "../../share/lib/nrnunits.lib" SUFFIX |
| static char * | unames [NDIM] |
| static struct table * | table |
| static char * | names |
| static struct prefix | prefix [] |
| static FILE * | inpfile |
| static int | fperrc |
| static int | peekc |
| static int | dumpflg |
| static char * | pc |
| static struct unit | unit_stack [UNIT_STK_SIZE] |
| static struct unit * | usp {nullptr} |
| static char * | ucp |
| #define NRN_DYNAMIC_UNITS 0 |
The strategy for dynamic units selection between Legacy and modern units is to maintain two complete tables respectively.
Legacy and modern in the nrnunits.lib.in file are distinquished by, e.g., 9.6485309+4 coul 96485.3321233100184 coul The reason for two complete tables, as opposed to a main table and several short legacy and modern tables, is that units are often defined in terms of modified units. eg, "R = (k-mole) (joule/degC)"
Nmodl, via the parser, uses only unit_pop, unit_mag, Unit_push, install_units, unit_div, and modl_units.
The issue of unit magnitude arises only when declaring a unit factor as in the gasconstant (R) above or with the equivalent "name = (unit) -> (unit)" syntax. If the magnitude difers between legacy and modern, then instead of emitting code like "static double FARADAY = 96485.3;\n" we can emit #define FARADAY nrnunit_FARADAY[nrnunit_use_legacy] static double nrnunit_FARADAY[2] = {96485.3321233100184, 96485.3};
|
static |
| double fabs | ( | double | ) |
|
static |
| void nrnunit_dynamic_str | ( | char * | buf, |
| const char * | name, | ||
| char * | u1, | ||
| char * | u2 | ||
| ) |
|
static |
|
static |