![]() |
NEURON
|
#include <../../nmodlconf.h>#include "nrnassrt.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 |
| #define | OUTTOLERANCE(arg1, arg2) (fabs(arg2 / arg1 - 1.) > 1.e-5) |
| #define | NTAB 601 |
| #define | SUFFIX "" |
| #define | UNIT_STK_SIZE 20 |
Functions | |
| double | fabs (double) |
| void | diag (char *, char *) |
| double | getflt () |
| void | fperr (int) |
| int | lookup (char *name, unit *up, int den, int c) |
| struct table * | hash_table (char *) |
| void | chkfperror () |
| void | units (unit *) |
| int | pu (int, int, int) |
| int | convr (unit *) |
| void | units_cpp_init () |
| int | get () |
| void | Unit_push (char *) |
| static int | Getc (FILE *inp) |
| static char * | neuronhome () |
| char * | Unit_str (unit *up) |
| void | unit_pop () |
| void | unit_swap () |
| double | unit_mag () |
| void | unit_mag_mul (double d) |
| void | punit () |
| void | ucopypop (unit *up) |
| void | ucopypush (unit *up) |
| void | unit_push_num (double d) |
| void | unitcheck (char *s) |
| char * | unit_str () |
| static void | install_units_help (char *s1, char *s2) |
| static void | switch_units (int legacy) |
| void | install_units (char *s1, char *s2) |
| void | check_num () |
| void | unit_mul () |
| void | unit_div () |
| void | Unit_exponent (int val) |
| int | unit_cmp_exact () |
| static void | print_unit_expr (int i) |
| void | Unit_cmp () |
| int | unit_diff () |
| void | dimensionless () |
| void | unit_less () |
| void | unit_stk_clean () |
| static void | units_alloc () |
| void | unit_init () |
| static int | equal (char *s1, char *s2) |
| static double | dynam_unit_mag (int legacy, char *u1, char *u2) |
| void | nrnunit_dynamic_str (char *buf, const char *name, char *u1, char *u2) |
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 IFUNITS |
| #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., @LegacyY@faraday 9.6485309+4 coul @LegacyN@faraday 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 |