Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix vecst for nrn90 #1

Merged
merged 5 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
5 changes: 4 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ calls to sprintf and hoc_obj_file_arg which were not exported by earlier
versions. On a MAC you may need to increase the memory size for NEURON
to 24MB.


Changelog
---------
2022-05: Updated MOD files to contain valid C++ and be compatible with the
upcoming versions 8.2 and 9.0 of NEURON.
8 changes: 6 additions & 2 deletions matrix.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ ENDCOMMENT
NEURON {
SUFFIX nothing
}

VERBATIM
#ifndef NRN_VERSION_GTEQ_8_2_0
extern double hoc_call_func(Symbol*, int narg);
#endif
ENDVERBATIM

:* mat.outprod(x,y) // mat = outer product of vectors x and y
VERBATIM
Expand Down Expand Up @@ -77,8 +83,6 @@ VERBATIM
static double spltp(void* vv) {
int ii, jj, nstpr, nstpo, nw, npr, npo, flag, cnt;
double *stpr, *stpo, *w, *pr, *po;
extern double hoc_call_func(Symbol*, int narg);

char func[4] = "ltp";
Symbol* s = hoc_lookup(func);
if (! s) { hoc_execerror("Can't find ltp() func", 0); }
Expand Down
17 changes: 7 additions & 10 deletions snsarr.inc
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ PROCEDURE init_arrays(num) {
}

VERBATIM
static void hshake();
static void hshake(SynS* ss, PreL* pl, int flag);
ENDVERBATIM
: 2 arguments - index, presyn link
PROCEDURE setlink() {
VERBATIM {
int ii, x, new;
int ii, x, is_new;
SynS *sns;
double ptemp;
PreL *ppsyn;
Expand Down Expand Up @@ -147,16 +147,16 @@ VERBATIM {

if (x == nsyn) {
nsyn++; /* a new entry */
new = 1;
is_new = 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;
is_new = 0;
}

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

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

: manipulate the presynaptic list remotely
VERBATIM
static void hshake(ss,pl,flag)
static void hshake(SynS* ss, PreL* pl, int 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 */
int ii;
double *nn;
double *mx;
Expand Down
36 changes: 19 additions & 17 deletions vecst.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ PARAMETER {
VERBATIM
#include <stdlib.h>
#include <math.h>
/* actually doesn't contain MAXLONG #include <float.h> /* contains MAXLONG */
#include <limits.h> // includes LONG_MAX instead of MAXLONG which is obsolete

#ifndef NRN_VERSION_GTEQ_8_2_0
extern double* hoc_pgetarg();
extern double hoc_call_func(Symbol*, int narg);
extern FILE* hoc_obj_file_arg(int narg);
extern void vector_resize();
extern int vector_instance_px();
extern void* vector_arg();
#endif

/* some machines do not have drand48 and srand48 so use the implementation
at the end of this file */
extern double my_drand48();
extern void my_srand48();
double my_drand48();
void my_srand48(long seedval);
#undef drand48
#undef srand48
#define drand48 my_drand48
Expand Down Expand Up @@ -310,7 +311,7 @@ static double fewind(void* vv) {
for (j=0;j<num;j++) {
for (i=0;i<ni;i++) x[i]=vvo[j][scr[i]];
for (i=0;i<ni;i++) vvo[j][i]=x[i];
vv=vector_arg(j+2); vector_resize(vv, ni);
vv=vector_arg(j+2); vector_resize((IvocVect*)vv, ni);
}
return ni;
}
Expand All @@ -329,7 +330,7 @@ static double insct(void* vv) {
if (k==nx) {
printf("\tinsct WARNING: ran out of room: %d\n",k);
for (;i<nv1;i++,j=0) for (;j<nv2;j++) if (v1[i]==v2[j]) k++;
} else { vector_resize(vv, k); } /* can't resize to make bigger */
} else { vector_resize((IvocVect*)vv, k); } /* can't resize to make bigger */
return (double)k;
}
ENDVERBATIM
Expand All @@ -351,6 +352,7 @@ static double cvlv(void* vv) {
if (k>0 && k<nsrc-1) x[i]+=filt[j]*src[k];
}
}
return 0.;
}
ENDVERBATIM

Expand All @@ -370,6 +372,7 @@ static double intrp(void* vv) {
for (i=la+1; i<lb; i++) x[i]= a + (b-a)/(lb-la)*(i-la);
a=b; la=lb;
}
return 0.;
}
ENDVERBATIM

Expand Down Expand Up @@ -409,7 +412,7 @@ static double nind(void* vv) {
}
for (k=last+1;k<nx;k++,m++) { x[m]=vvo[j][k]; }
for (i=0;i<c;i++) vvo[j][i]=x[i];
vv=vector_arg(j+2); vector_resize(vv, c);
vv=vector_arg(j+2); vector_resize((IvocVect*)vv, c);
}
return c;
}
Expand Down Expand Up @@ -566,6 +569,7 @@ static double bpeval(void* vv) {
} else {
for (i=0;i<n;i++) vo[i]=outp[i]*(1.-1.*outp[i])*del[i];
}
return 0.;
}
ENDVERBATIM

Expand Down Expand Up @@ -827,13 +831,13 @@ static double frd(void* vv) {
#else
f = hoc_obj_file_arg(1);
#endif
num = (int)*getarg(2);
size = (int)*getarg(3);
xf = (char *)malloc(num * size);
if (num!=nx) { hoc_execerror("Correct vector size ", 0); }
fread(xf, num, size, f);
for (i=0;i<num;++i) x[i] = (double)xf[i];
return;
num = (int)*getarg(2);
size = (int)*getarg(3);
xf = (char *)malloc(num * size);
if (num!=nx) { hoc_execerror("Correct vector size ", 0); }
fread(xf, num, size, f);
for (i=0;i<num;++i) x[i] = (double)xf[i];
return 0.;
}
ENDVERBATIM

Expand Down Expand Up @@ -949,9 +953,7 @@ next()
x[0] = LOW(p[0]);
}

void
my_srand48(seedval)
long seedval;
void my_srand48(long seedval)
{
SEED(X0, LOW(seedval), HIGH(seedval));
}
Expand Down