Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpp compatibility #1

Merged
merged 2 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ time the simulation is run.
Original 1997 code from Paul Bush modified slightly by Bill Lytton to make it work with
current version of NEURON (5.7.139). Thanks to Paul Bush and Ken Miller for
making the code available.

Changelog
---------
20110407 updated solve methods to cnexp, derivimplicit from euler
20150219 implements Michael Hine's suggestion to update the DERIVATIVE
block in kca.mod to a form compatible with cnexp
block in kca.mod to a form compatible with cnexp
20220520 Updated MOD files to contain valid C++ and be compatible with the
upcoming versions 8.2 and 9.0 of NEURON.
34 changes: 11 additions & 23 deletions holt_rnd.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)}

VERBATIM
double holt_random();
void holt_seed();
double holt_normrand();
void holt_seed(int, int);
double holt_normrand(double, double);
double holt_exprand();
int holt_poisrand();
int holt_poisrand(double);
ENDVERBATIM

:
Expand Down Expand Up @@ -108,8 +108,7 @@ extern double drand48();
* 1 = random()
*/
void
holt_seed(seedval, gen_code)
int seedval, gen_code;
holt_seed(int seedval, int gen_code)
{
if (seedval == 0) /* No seed explicitly given? */
seedval=3491;
Expand Down Expand Up @@ -146,6 +145,7 @@ holt_random()
// #ifndef hpux
// case RANDOM: return (double)random() / (double)0x7fffffff;
// #endif
default: abort();
}
}

Expand All @@ -172,13 +172,10 @@ holt_random()
/* */
/*--------------------------------------------------------------*/

double
holt_normrand(mean, std_dev)
double mean, std_dev;
double
holt_normrand(double mean, double std_dev)
{
double s, v1, v2;
extern double sqrt(), log();

s = 1.0;
while (s >= 1.0)
{
Expand All @@ -197,15 +194,11 @@ double mean, std_dev;
*/
#define PI 3.141592654

int
holt_poisrand(xm)
double xm;
{
float gammln();
double drand48();
float gammln(float);

int holt_poisrand(double xm) {
static float sq,alxm,g,oldm=(-1.0);
double em,tt,y;
double exp();

if (xm < 12.0) {
if (xm != oldm) {
Expand Down Expand Up @@ -241,10 +234,7 @@ double xm;
#undef PI
/* (C) Copr. 1986-92 Numerical Recipes Software #.3. */

float
gammln(xx)
float xx;
{
float gammln(float xx) {
double x,tmp,ser;
static double cof[6]={76.18009173,-86.50532033,24.01409822,
-1.231739516,0.120858003e-2,-0.536382e-5};
Expand Down Expand Up @@ -286,8 +276,6 @@ float xx;
double
holt_exprand()
{
extern double log();

return (-log(holt_random()));
}
ENDVERBATIM
Expand Down
2 changes: 1 addition & 1 deletion precall.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PROCEDURE pp() {
spk_internal = 1
spk = 1
VERBATIM
{ extern double hoc_call_func();
{
char func[8] = "precall";
Symbol* s = hoc_lookup(func);
if (s && num>=0) {
Expand Down
17 changes: 7 additions & 10 deletions snsarr.inc
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ PROCEDURE init_arrays(num) {
}

VERBATIM
static void hshake();
static void hshake(SynS*, PreL*, int);
ENDVERBATIM

: 2 arguments - index, presyn link
PROCEDURE setlink() {
VERBATIM {
int ii, x, new;
int ii, x, new_v;
SynS *sns;
double ptemp;
PreL *ppsyn;
Expand Down Expand Up @@ -148,16 +148,16 @@ VERBATIM {

if (x == nsyn) {
nsyn++; /* a new entry */
new = 1;
new_v = 1;
} else {
/* should generate error if try to change something in middle of chain */
if (sns->chainlen == -2) {
hoc_execerror("Internal error: Index used must be multiple of CHAINLEN.", 0);
}
new = 0;
new_v = 0;
}

hshake(sns,ppsyn,new);
hshake(sns,ppsyn,new_v);

x *= (int)CHAINLEN;
for (ii=x;ii < x + CHAINLEN;ii++) {
Expand All @@ -180,12 +180,9 @@ ENDVERBATIM

: manipulate the presynaptic list remotely
VERBATIM
static void hshake(ss,pl,flag)
/* ls will be a pointer to presyn cell's array of pointers */
SynS *ss;
PreL *pl;
int flag; /* flag == 1 if this is a brand new entry */
{
/* flag == 1 if this is a brand new entry */
static void hshake(SynS *ss, PreL *pl, int flag) {
int ii;
double *nn;
double *mx;
Expand Down