From 5753ed3f2c9d8a81e73540cd6a3ba4a2fe008abf Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Mon, 16 May 2022 15:19:55 +0200 Subject: [PATCH 01/23] Fix infot.mod --- infot.mod | 26 ++++++++++++++++---------- misc.h | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/infot.mod b/infot.mod index 60c86f6..6fd71b4 100644 --- a/infot.mod +++ b/infot.mod @@ -29,7 +29,9 @@ VERBATIM #include #include static const double* ITsortdata = NULL; /* used in the quicksort algorithm */ -static double tetrospks2(), pdfpr(), tetrospks3(); +static double tetrospks2 (double* X1d,double* X2d,double* XO,int szX1,int szXO,int shuf); +static void pdfpr (double* pdf,int szp,int dim, char* name); +static double tetrospks3 (double* X1d,double* X2d,double* X3d,double* XO,int szX1,int szXO,int shuf); static int dbxi[10]; typedef struct ITNode_ { @@ -42,9 +44,9 @@ typedef struct ITNode_ { ITNode* allocITNode(int idims) { ITNode* p; - p = calloc(1,sizeof(ITNode)); + p = (ITNode*)calloc(1,sizeof(ITNode)); if(!p) { printf("allocITNode: out of mem!\n"); hxe(); return 0x0; } - p->pvals = calloc(idims,sizeof(int)); + p->pvals = (int*)calloc(idims,sizeof(int)); return p; } @@ -395,6 +397,8 @@ static double lz76c (void* vv) { return lz76complexityd(x,n); } +extern void ishuffle(int* x,int nx); + //* tentropd() transfer entropy of y -> x //x=time-series 1, y=time-series 2,iLen=# of samples,nbins=# of values to discretize time-series to, //xpast=# of past x values to use for prediction,ypast=# of past y values to use for prediction @@ -508,7 +512,7 @@ double tentropd (double* x,double* y,int iLen,int nbins,int xpast,int ypast,int } if(verbose>1) {printf("cntjxy=%d\n",cntjxy); for(i=0;i Date: Mon, 16 May 2022 14:50:37 +0200 Subject: [PATCH 02/23] =?UTF-8?q?=E2=80=9Cinitial=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infot.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infot.mod b/infot.mod index 6fd71b4..846e3ac 100644 --- a/infot.mod +++ b/infot.mod @@ -876,7 +876,7 @@ static double entropxfgxp (void* vv) { int sz,minv,maxv,cnt,i,j,szp,*X; sz = vector_instance_px(vv,&x); cnt=0; - X=iscrset(sz); + X=scrset(sz); minv=1e9; maxv=-1e9; for (i=0;i Date: Mon, 16 May 2022 16:29:51 +0200 Subject: [PATCH 03/23] fixing for neuron 9.0 --- clampex.mod | 14 ++++++++++---- field.mod | 2 +- infot.mod | 24 ++++++++++++------------ intf_.mod | 10 +++++----- misc.h | 1 + vecst.mod | 10 +++++----- 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/clampex.mod b/clampex.mod index c1c958a..71ea7c5 100644 --- a/clampex.mod +++ b/clampex.mod @@ -9,7 +9,9 @@ ASSIGNED { } VERBATIM +#ifndef NRN_VERSION_GTEQ_8_2_0 extern double chkarg(); +#endif typedef struct CEXData { #if 1 @@ -31,7 +33,7 @@ typedef struct CEXData { }CEXData; #define CEXD CEXData* cexd = (CEXData*)((unsigned long)pointer); -static void reverse(b, n ) char* b; int n; { +static void reverse(char* b, int n) { int i, j, v_; for (i=0, j=n-1; iheader); diff --git a/field.mod b/field.mod index a73b5c2..5f2818b 100644 --- a/field.mod +++ b/field.mod @@ -3,7 +3,7 @@ VERBATIM #include "misc.h" #define NSW 5 // store into this many ww field vecs -static void* ww[NSW]; +static IvocVect* ww[NSW]; static double* wwo[NSW]; static int ixp1; ENDVERBATIM diff --git a/infot.mod b/infot.mod index 846e3ac..f922108 100644 --- a/infot.mod +++ b/infot.mod @@ -34,6 +34,10 @@ static void pdfpr (double* pdf,int szp,int dim, char* name); static double tetrospks3 (double* X1d,double* X2d,double* X3d,double* XO,int szX1,int szXO,int shuf); static int dbxi[10]; +static double tetrospks2 (double* X1d,double* X2d,double* XO,int szX1,int szXO,int shuf); +static void pdfpr (double* pdf,int szp,int dim, char* name); +static double tetrospks3 (double* X1d,double* X2d,double* X3d,double* XO,int szX1,int szXO,int shuf); + typedef struct ITNode_ { int idims; int icount; @@ -397,8 +401,6 @@ static double lz76c (void* vv) { return lz76complexityd(x,n); } -extern void ishuffle(int* x,int nx); - //* tentropd() transfer entropy of y -> x //x=time-series 1, y=time-series 2,iLen=# of samples,nbins=# of values to discretize time-series to, //xpast=# of past x values to use for prediction,ypast=# of past y values to use for prediction @@ -721,7 +723,7 @@ static double ntedir (void* vv) { // of X1spikecounts,X2spikecounts onto X3spikecounts static double tentropspks (void* vv) { double *X1,*X2,*XO,*X3; int szX1,szX2,szXO,shuf,szX3; - szX1 = vector_instance_px(vv,&X1); + szX1 = vector_instance_px((IvocVect*)vv,&X1); if((szX2=vector_arg_px(1,&X2))!=szX1) { printf("tentropspks ERRA: X1,X2 must have same size (%d,%d)\n",szX1,szX2); return -1.0; } szXO=ifarg(2)?vector_arg_px(2,&XO):0; @@ -762,13 +764,11 @@ NTEL2DOFREE: return ret; } -extern int list_vector_px3 (Object *ob, int i, double** px, void** vv); - //*** Vind0.nte(Vind1,LIST,OUTVEC or OUTLIST) // do normalization with H(X2F|X2P) static double nte (void* vv) { int i, j, k, ii, jj, oi, nx, ny, omax, sz, ci, bg, flag, nshuf, szX, *x1i, *x2i, x1z, x2z; - ListVec *pLi; Object *obi,*ob; double *x, *y, *out, o1, o2, cnt, *vvo[3]; void *vvl; - nx = vector_instance_px(vv, &x); // index i vector + ListVec *pLi; Object *obi,*ob; double *x, *y, *out, o1, o2, cnt, *vvo[3]; IvocVect *vvl; + nx = vector_instance_px((IvocVect*)vv, &x); // index i vector ny = vector_arg_px(1, &y); // index j vectors pLi = AllocListVec(obi=*hoc_objgetarg(2)); // input vectors ob = *hoc_objgetarg(3); @@ -873,10 +873,10 @@ double entropxfgxpd (double* pXP, double* pXFXP,int minv,int maxv,int szp) { // Vector has elements of X static double entropxfgxp (void* vv) { double *x,*pXP,*pXFXP,dret; - int sz,minv,maxv,cnt,i,j,szp,*X; - sz = vector_instance_px(vv,&x); + int sz,minv,maxv,cnt,i,j,szp; + sz = vector_instance_px((IvocVect*)vv,&x); cnt=0; - X=scrset(sz); + unsigned int* X=scrset(sz); minv=1e9; maxv=-1e9; for (i=0;i 0!\n"); return -1.0;} size=(double)sz; ret=-1.0; err=0; px=NULL; minv=1000000000; maxv=-1000000000; - X=scrset(sz*2); // move into integer arrays + unsigned int* X=scrset(sz*2); // move into integer arrays cnt=0; for (i=0;iid*seedstep); // all integers } else { // hash on presynaptic id+FOFFSET,poid,seedstep hsh[0]=floor(_lflag); hsh[1]=(double)ip->id; hsh[2]=seedstep; - sead=hashseed2(3,&hsh); // hsh[] is just scratch pad + sead=hashseed2(3,hsh); // hsh[] is just scratch pad } mcell_ran4(&sead, &_args[sy], 2, 1.); for (ii=sy;iiid)*qp->id*seedstep; } else { // hashed sead setting hsh[0]=(double)(FOFFSET+ip->id); hsh[1]=(double)(qp->id); hsh[2]=seedstep; - sead=hashseed2(3,&hsh); + sead=hashseed2(3,hsh); } mcell_ran4(&sead, y, 2, 1.); for(ii=0;ii<2;ii++) { diff --git a/misc.h b/misc.h index 2e7ed9f..1456cb8 100644 --- a/misc.h +++ b/misc.h @@ -61,6 +61,7 @@ typedef double sf8; /* eight byte signed floating point number */ extern double ERR,GET,SET,OK,NOP,ALL,NEG,POS,CHK,NOZ,GTH,GTE,LTH,LTE,EQU; extern double EQV,EQW,EQX,NEQ,SEQ,RXP,IBE,EBI,IBI,EBE; +extern void ishuffle(int* x,int nx); extern double *vector_newsize(); extern unsigned int dcrsz; extern double *dcr; diff --git a/vecst.mod b/vecst.mod index d191865..2bd5a89 100644 --- a/vecst.mod +++ b/vecst.mod @@ -2091,28 +2091,28 @@ int list_vector_px (Object *ob, int i, double** px) { //* list_vector_px2(LIST,ITEM#,DOUBLE PTR ADDRESS,VEC POINTER ADDRESS) // returns the vector pointer as well as the double pointer -int list_vector_px2 (Object *ob, int i, double** px, void** vv) { +int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv) { Object* obv; int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; sz = vector_capacity(obv->u.this_pointer); *px = vector_vec(obv->u.this_pointer); - *vv = (void*) obv->u.this_pointer; + *vv = (IvocVect*) obv->u.this_pointer; return sz; } //* list_vector_px3(LIST,ITEM#,DOUBLE PTR ADDRESS,VEC POINTER ADDRESS) // same as px2 but returns max vec size instead of current vecsize // side effect -- increase vector size to maxsize -int list_vector_px3 (Object *ob, int i, double** px, void** vv) { +int list_vector_px3 (Object *ob, int i, double** px, IvocVect** vv) { Object* obv; int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; sz = vector_buffer_size(obv->u.this_pointer); *px = vector_vec(obv->u.this_pointer); - *vv = (void*) obv->u.this_pointer; + *vv = (IvocVect*) obv->u.this_pointer; vector_resize(*vv,sz); return sz; } @@ -2399,7 +2399,7 @@ int openvec (int arg, double **y) { } // vector_newsize() will also increase size of vector -double *vector_newsize (void* vv, int n) { +double *vector_newsize (IvocVect* vv, int n) { vector_resize(vv,n); return vector_vec(vv); } From 11afe8cc1aad23655ddc0f09da0ac7a6605fd7ed Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Mon, 16 May 2022 16:31:20 +0200 Subject: [PATCH 04/23] fixing for neuron 9.0 --- driver.hoc | 36 ++++++++++++++++++++++++++++++++++++ misc.h | 49 ++++++++++++++++++++++++++----------------------- netrand.inc | 2 +- 3 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 driver.hoc diff --git a/driver.hoc b/driver.hoc new file mode 100644 index 0000000..5cd147f --- /dev/null +++ b/driver.hoc @@ -0,0 +1,36 @@ + +strdef verify_dir_ +verify_dir_ = "/gpfs/bbp.cscs.ch/data/project/proj16/kotsalos/nrn_HACK/mdb/ncdemo" + +if (name_declared("verify_dir_") == 0) { + execute("~strdef verify_dir_") + execute("verify_dir_ = \".\"") +} +strdef verify_tstr_ +objref verify_glist_, verify_xvec_, verify_yvec_, verify_file_ +verify_file_ = new File() +sprint(verify_tstr_, "%s/gout", verify_dir_) +verify_file_.wopen(verify_tstr_) +verify_xvec_ = new Vector() +verify_yvec_ = new Vector() +verify_glist_ = new List("Graph") + +proc verify_graph_() {local i, j, k + verify_file_.printf("Graphs %d\n", verify_glist_.count) + for i=0, verify_glist_.count-1 { + verify_file_.printf("%s\n", verify_glist_.object(i)) + k = 0 + for (j=-1; (j=verify_glist_.object(i).line_info(j, verify_xvec_)) != -1; ){ + k += 1 + } + verify_file_.printf("lines %d\n", k) + for (j=-1; (j=verify_glist_.object(i).getline(j, verify_xvec_, verify_yvec_)) != -1; ){ + verify_file_.printf("points %d\n", verify_xvec_.size) + verify_file_.printf("xvec%d\n", j) + verify_xvec_.printf(verify_file_) + verify_file_.printf("yvec%d\n", j) + verify_yvec_.printf(verify_file_) + } + } +} +verify_graph_() \ No newline at end of file diff --git a/misc.h b/misc.h index 1456cb8..586dff1 100644 --- a/misc.h +++ b/misc.h @@ -61,18 +61,8 @@ typedef double sf8; /* eight byte signed floating point number */ extern double ERR,GET,SET,OK,NOP,ALL,NEG,POS,CHK,NOZ,GTH,GTE,LTH,LTE,EQU; extern double EQV,EQW,EQX,NEQ,SEQ,RXP,IBE,EBI,IBI,EBE; -extern void ishuffle(int* x,int nx); -extern double *vector_newsize(); -extern unsigned int dcrsz; -extern double *dcr; -extern double *dcrset(int); -extern unsigned int scrsz; -extern unsigned int *scr; -extern unsigned int *scrset(int); -extern unsigned int iscrsz; -extern int *iscr; -extern int *iscrset(int); -extern double BVBASE; +extern double *vector_newsize (IvocVect* vv, int n); +#ifndef NRN_VERSION_GTEQ_8_2_0 extern double* hoc_pgetarg(); extern void hoc_notify_iv(); extern double hoc_call_func(Symbol*, int narg); @@ -85,17 +75,11 @@ extern int vector_instance_px(); extern void* vector_arg(); extern double* vector_vec(); extern int vector_buffer_size(void*); -extern double hoc_epsilon; -extern int stoprun; -extern void set_seed(); -extern void dshuffle(double* x,int nx); -extern unsigned int valseed; extern void mcell_ran4_init(unsigned int *idum); extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); extern int nrn_mlh_gsort(); extern int ivoc_list_count(Object*); extern Object* ivoc_list_item(Object*, int); -extern int list_vector_px2(); extern int hoc_is_double_arg(int narg); extern int hoc_is_str_arg(int narg); extern int hoc_is_object_arg(int narg); @@ -103,12 +87,33 @@ extern int hoc_is_pdouble_arg(int narg); extern Symbol *hoc_get_symbol(char *); extern Symbol *hoc_lookup(const char*); extern Point_process* ob2pntproc(Object*); - extern char* hoc_object_name(Object*); +extern double nrn_event_queue_stats(double*); +extern void clear_event_queue(); +#endif +extern unsigned int hashseed2 (int na, double* x); +extern unsigned int dcrsz; +extern double *dcr; +extern double *dcrset(int); +extern unsigned int scrsz; +extern unsigned int *scr; +extern unsigned int *scrset(int); +extern unsigned int iscrsz; +extern int *iscr; +extern int *iscrset(int); +extern double BVBASE; +extern double hoc_epsilon; +extern int stoprun; +extern void set_seed(); +extern void dshuffle(double* x,int nx); +extern void ishuffle(int* x,int nx); +extern unsigned int valseed; +extern int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv); +extern int list_vector_px3 (Object *ob, int i, double** px, IvocVect** vv); extern int cmpdfn(); extern int openvec(int, double **); -int list_vector_px(); -double *list_vector_resize (Object *ob, int i, int sz); +int list_vector_px(Object *ob, int i, double** px); +double *list_vector_resize(Object *ob, int i, int sz); static void hxe() { hoc_execerror("",0); } extern void FreeListVec(ListVec** pp); extern ListVec* AllocListVec(Object* p); @@ -116,8 +121,6 @@ extern ListVec* AllocILV(Object*, int, double *); void FillListVec(ListVec* p,double dval); void ListVecResize(ListVec* p,int newsz); extern short *nrn_artcell_qindex_; -extern double nrn_event_queue_stats(double*); -extern void clear_event_queue(); static double sc[6]; static FILE* testout; diff --git a/netrand.inc b/netrand.inc index 5737d41..1a2d7f0 100644 --- a/netrand.inc +++ b/netrand.inc @@ -51,7 +51,7 @@ INITIAL { CONSTRUCTOR { VERBATIM cbsv=0x0; - _p_sop = (void*)ecalloc(1, sizeof(id0)); // important that calloc sets all flags etc to 0 + _p_sop = (double*)ecalloc(1, sizeof(id0)); // important that calloc sets all flags etc to 0 ip = IDP; ENDVERBATIM } From b0915063dbfe1fcb6daa5d12c4523a36d7e08acf Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Tue, 17 May 2022 14:12:45 +0200 Subject: [PATCH 05/23] more work --- intf_.mod | 84 +++++++++++++++-------------- intfsw.mod | 23 ++++---- misc.h | 26 +++++++-- misc.mod | 16 +++--- pregencv.mod | 2 +- stats.mod | 40 +++++++------- updown.mod | 25 +-------- vecst.mod | 150 ++++++++++++++++++++++++++------------------------- 8 files changed, 185 insertions(+), 181 deletions(-) diff --git a/intf_.mod b/intf_.mod index 38fa8aa..cf3f9bc 100644 --- a/intf_.mod +++ b/intf_.mod @@ -18,6 +18,7 @@ ENDCOMMENT :* main VERBATIM block VERBATIM #include "misc.h" +#include "unistd.h" static int ctt(unsigned int, char**); static int setdvi2(double*,double*,int,int); @@ -122,6 +123,7 @@ double* wwo[NSW]; static int AM=0, NM=1, GA=2, GB=3, SU=3, IN=4, DP=2; // from labels.hoc static double wts[10],hsh[10]; // for jitcons to use as a junk pointer static void spkoutf2(); +int gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das); ENDVERBATIM :* NEURON, PARAMETER, ASSIGNED blocks @@ -231,7 +233,7 @@ CONSTRUCTOR { if (ifarg(2)) { lty=(int) *getarg(2); } else { lty= -1; } if (ifarg(3)) { lin=(int) *getarg(3); } else { lin= -1; } if (ifarg(4)) { lco=(int) *getarg(4); } else { lco= -1; } - _p_sop = (void*)ecalloc(1, sizeof(id0)); // important that calloc sets all flags etc to 0 + _p_sop = (double*)ecalloc(1, sizeof(id0)); // important that calloc sets all flags etc to 0 ip = IDP; ip->id=lid; ip->type=lty; ip->inhib=lin; ip->col=lco; ip->pg=0x0; ip->dvi=0x0; ip->sprob=0x0; @@ -348,7 +350,7 @@ ENDVERBATIM VERBATIM if (stopoq && !qsz()) stoprun=1; ip=IDP; pg=ip->pg; - if (ip->dead) return; // this cell has died + if (ip->dead) return; _ljcn=ip->jcn; _lid=ip->id; tpnt = _pnt; // this pnt if (PATHMEASURE) { // do all code for this @@ -910,7 +912,7 @@ PROCEDURE callback (fl) { if (jp->sprob[i]) (*pnt_receive[jp->dvi[i]->_prop->_type])(jp->dvi[i], wts, idty); _p=upnt->_prop->param; _ppvar=upnt->_prop->dparam; // restore pointers i++; - if (i>=jp->dvt) return; // ran out + if (i>=jp->dvt) return 0; // ran out TODO:Ask Michel ddel=jp->del[i]-del0; // delays are relative to event; use difference in delays } // skip over pruned outputs and dead cells: @@ -934,7 +936,7 @@ VERBATIM { int i,j,k,prty,poty,dv,dvt,dvii; double *x, *db, *dbs; Object *lb; Point_process *pnnt, **da, **das; ip=IDP; pg=ip->pg; // this should be called right after jitcondiv() - if (ip->dead) return; + if (ip->dead) return 0; // TODO: Ask Michael prty=ip->type; sead=GetDVIDSeedVal(ip->id);//seed for divergence and delays for (i=0,k=0,dvt=0;ipg; // this should be called right after jitcondiv() getactive=a2=a3=a4=0; - if (ip->dead) return; + if (ip->dead) return 0; // TODO: Ask Michael dvt=ip->dvt; dbs=ip->del; das=ip->dvi; _lgetdvi=(double)dvt; @@ -1067,13 +1069,13 @@ FUNCTION getdvi () { } else av1=1; // 1st vector arg //just get active postsynapses (not dead and non pruned) voi=vector_arg(iarg++); - if (flag==2) { x1=vector_newsize(voi,CTYPi); for (i=0;iid)+1e-2*(double)ip->type+1e-3*(double)ip->inhib+1e-4; prty=ip->type; sy=ip->inhib?GA:AM; @@ -1129,8 +1131,8 @@ VERBATIM } if (!ifarg(iarg)) prfl=0; else { prfl=1; voi=vector_arg(iarg); - if (flag==2.) { x=vector_newsize(voi,CTYPi); for (i=0;isprob[j]==0) continue; if (ip==*((id0**) &((das[j]->_prop->dparam)[2]))) { if (prfl) { - if (flag!=2.0 && k>=sz) x=vector_newsize(voi,sz*=2); + if (flag!=2.0 && k>=sz) x=vector_newsize((IvocVect*)voi,sz*=2); if (flag==1.0) { x[k]=(double)qp->type; } else if (flag==2.0) { x[qp->type]++; } else x[k]=(double)qp->id; @@ -1150,7 +1152,7 @@ VERBATIM } } } - if (prfl && flag!=2) vector_resize(voi,k); + if (prfl && flag!=2) vector_resize((IvocVect*)voi,k); _lgetconv=(double)k; } ENDVERBATIM @@ -1216,7 +1218,7 @@ FUNCTION rddvi () { fread(&qp->dvt,sizeof(unsigned int),1,fp); // read divergence size //free up old pointers if(qp->del){ free(qp->del); free(qp->dvi); free(qp->sprob); - qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(char *)0x0; } + qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(unsigned char *)0x0; } //if divergence == 0 , continue if(!qp->dvt) continue; qp->dvi = (Point_process**)malloc(sizeof(Point_process*)*qp->dvt); @@ -1319,7 +1321,7 @@ PROCEDURE clrdvi () { lop(ce,i); if (qp->dvt!=0x0) { free(qp->dvi); free(qp->del); free(qp->sprob); - qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(char *)0x0; + qp->dvt=0; qp->dvi=(Point_process**)0x0; qp->del=(double*)0x0; qp->sprob=(unsigned char *)0x0; } } ENDVERBATIM @@ -1393,9 +1395,9 @@ ENDVERBATIM PROCEDURE setdvi () { VERBATIM { int i,dvt,flag; double *d, *y; - if (! ifarg(1)) {printf("setdvi(v1,v2[,flag]): v1:cell#s; v2:delays\n"); return; } + if (! ifarg(1)) {printf("setdvi(v1,v2[,flag]): v1:cell#s; v2:delays\n"); return 0; } // TODO: Ask Michael ip=IDP; pg=ip->pg; // this should be called right after jitcondiv() - if (ip->dead) return; + if (ip->dead) return 0; // TODO: Ask Michael dvt=vector_arg_px(1, &y); i=vector_arg_px(2, &d); if (ifarg(3)) flag=(int)*getarg(3); else flag=0; @@ -1416,10 +1418,10 @@ static int setdvi2 (double *y,double *d,int dvt,int flag) { if (flag==0) { b=0; e=dvt; // begin to end if (ip->dvi) { free(ip->dvi); free(ip->del); free(ip->sprob); - ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(char *)0x0; + ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0; } // make sure all null pointers for realloc } else { - if (ip->dvt==0) {ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(char *)0x0;} + if (ip->dvt==0) {ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0;} b=ip->dvt; e=ip->dvt+dvt; // dvt is amount to grow } @@ -1458,7 +1460,7 @@ PROCEDURE prune () { printf("INTFpruneB:Div exceeds dscrsz: %d>%d\n",ip->dvt,dscrsz); hxe(); } if (p==0.) { for (j=0;jdvt;j++) ip->sprob[j]=1; // unprune completely - return; // now that unpruning is done, can return + return 0; // now that unpruning is done, can return TODO: Ask Michael } potype=ifarg(2)?(int)*getarg(2):-1; sead=(ifarg(3))?(unsigned int)*getarg(3):GetDVIDSeedVal(ip->id);//seed for divergence and delays @@ -1529,7 +1531,7 @@ int gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process ** int i; scr=scrset(dvt); for (i=0;idvi) { free(jp->dvi); free(jp->del); free(jp->sprob); - jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(char *)0x0; + jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(unsigned char *)0x0; } } ENDVERBATIM @@ -1637,7 +1639,7 @@ PROCEDURE jitrec () { int i; if (! ifarg(2)) { // clear with jitrec() or jitrec(0) jrmax=0; jridv=0x0; jrtvv=0x0; - return; + return 0; // TODO: Ask Michael } i = vector_arg_px(1, &jrid); // could just set up the pointers once jrmax=vector_arg_px(2, &jrtv); @@ -1780,11 +1782,11 @@ PROCEDURE record () { VERBATIM { int i,j,k,nz; double ti; vp = SOP; - if (tg>=t) return; + if (tg>=t) return 0; // TODO: Ask Michael if (ip->record==1) { while ((int)vp->p >= (int)vp->size-(int)((t-tg)/vdt)-10) { vp->size*=2; - for (k=0;kvv[k]!=0x0) vp->vvo[k]=vector_newsize(vp->vv[k], vp->size); + for (k=0;kvv[k]!=0x0) vp->vvo[k]=vector_newsize((IvocVect*)vp->vv[k], vp->size); // printf("**** WARNING expanding recording room to %d (type%d id%d at %g)****\n",vp->size,IDP->type,IDP->id,t); } } else if ((int)vp->p > (int)vp->size-(int)((t-tg)/vdt)) { // shift if record==2 @@ -1818,7 +1820,7 @@ PROCEDURE recspk (x) { VERBATIM { int k; vp = SOP; record(); - if (vp->p > vp->size || vp->vvo[6]==0) return; + if (vp->p > vp->size || vp->vvo[6]==0) return 0; // TODO: Ask Michael if (vp->vvo[0]!=0x0) vp->vvo[0][vp->p-1]=_lx; vp->vvo[6][vp->p-1]=spkht; // the spike tg=_lx; @@ -2040,7 +2042,7 @@ VERBATIM { num = ivoc_list_count(ob); if (num!=7) { printf("INTF lof ERR %d>7\n",num); hxe(); } for (i=0;ip,vp->size,tg); - for (i=0;ivv[i]) printf("%d %x %x;",i,(unsigned int)vp->vv[i],(unsigned int)vp->vvo[i]); + for (i=0;ivv[i]) printf("%d %x %x;",i,vp->vv[i],vp->vvo[i]); } else printf("Recording pointers not initialized"); } if (lfg==2) { printf("Global vectors for input and jitter (jttr): \n"); - if (vsp!=nil) printf("VSP: %x (%d/%d-%d)\n",(unsigned int)vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); - if (jsp!=nil) printf("JSP: %x (%d/%d)\n",(unsigned int)jsp,jtpt,jtmax); else printf("no JSP\n"); + if (vsp!=nil) printf("VSP: %x (%d/%d-%d)\n",vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); + if (jsp!=nil) printf("JSP: %x (%d/%d)\n",jsp,jtpt,jtmax); else printf("no JSP\n"); } if (lfg==3) { if (vsp!=nil) { printf("VSP: (%d/%d-%d)\n",ip->rvi,ip->rvb,ip->rve); @@ -2161,7 +2163,7 @@ PROCEDURE chk (f) { if (lfg==5) { printf("wwpt %d wwsz %d\n WW vecs: ",wwpt,wwsz); printf("wwwid %g wwht %d nsw %g\n WW vecs: ",wwwid,(int)wwht,nsw); - for (i=0;iNSW) { printf("INTF initwrec() WARN: can only store %d ww vecs\n",NSW); hxe();} nsw=(double)num; for (k=0;k=t) { return; + } else if (twg>=t) { return 0; // TODO: Ask Michael } else { for (ti=twg,k=(int)floor((twg-rebeg)/vdt+0.5);ti<=t && kdbx==-1)printf("slowset fi:%d ix:%d ss:%g delt:%g t:%g\n",fi,ix,slowset,delt,t); if (t>slowset || ix>=cesz) { // done printf("Slow-setting of flag %d finished at %g: (%d,%g,%g)\n",fi,t,ix,delt,slowset); - slowset=0.; return; + slowset=0.; return 0; // TODO: Ask Michael } if (ix0 && ifarg(3)) { printf("INTF flag() slowset ERR; attempted set during slowset: fi:%d ix:%d ss:%g delt:%g t:%g",\ fi,ix,slowset,delt,t); - return; + return 0; // TODO: Ask Michael } ip = IDP; setfl=ifarg(3); if (ifarg(4)) { slowset=*getarg(4); delt=slowset/cesz; slowset+=t; } @@ -2554,7 +2556,7 @@ FUNCTION flag () { FUNCTION allspck () { VERBATIM - int i; double *x, sum; void *voi; + int i; double *x, sum; IvocVect* voi; ip = IDP; voi=vector_arg(1); x=vector_newsize(voi,cesz); for (i=0,sum=0;ipv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found int* pNeighbors = (int*)calloc(iCells,sizeof(int)); @@ -543,7 +543,7 @@ FUNCTION GetCentrality () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pCE; @@ -655,7 +655,7 @@ FUNCTION GetCC () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found int* pNeighbors = (int*)calloc(iCells,sizeof(int)); @@ -753,7 +753,7 @@ FUNCTION CountNeighborsR () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1166,7 +1166,7 @@ FUNCTION GetPathR () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1313,7 +1313,7 @@ FUNCTION GetCCSubPop () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found int* pNeighbors = (int*)calloc(iCells,sizeof(int)); @@ -1422,7 +1422,8 @@ FUNCTION GetCCSubPop () { FUNCTION GetRecurCount () { VERBATIM ListVec* pList; - int iCells,*pLen,iFromSz,iThruSz,idx,myID,youID,jdx,iCheckSz,*pVisited,*pCheck; + unsigned int* pLen; + int iCells,iFromSz,iThruSz,idx,myID,youID,jdx,iCheckSz,*pVisited,*pCheck; double **pLV,*pFrom,*pThru,*pR; pList = AllocListVec(*hoc_objgetarg(1)); @@ -1509,7 +1510,7 @@ FUNCTION GetPairDist () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; double* pFrom = 0, *pTo = 0; int iFromSz = vector_arg_px(3,&pFrom) , iToSz = vector_arg_px(4,&pTo); @@ -1632,7 +1633,7 @@ FUNCTION GetPathSubPop () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1787,7 +1788,7 @@ FUNCTION GetLoopLength () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of avg distances to each cell , 0 == no path found double* pVD; @@ -1928,7 +1929,7 @@ FUNCTION GetPathEV () { } double** pLV = pList->pv; - int* pLen = pList->plen; + unsigned int* pLen = pList->plen; //init vector of distances to each cell , 0 == no path found double* pVD; diff --git a/misc.h b/misc.h index 586dff1..e02e615 100644 --- a/misc.h +++ b/misc.h @@ -7,6 +7,7 @@ #include #include #include +#include #if !defined(t) #define _pval pval @@ -75,11 +76,10 @@ extern int vector_instance_px(); extern void* vector_arg(); extern double* vector_vec(); extern int vector_buffer_size(void*); -extern void mcell_ran4_init(unsigned int *idum); -extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); -extern int nrn_mlh_gsort(); +extern void mcell_ran4_init(uint32_t idum); +extern double mcell_ran4(uint32_t* high, double* x, unsigned int n, double range); +extern int nrn_mlh_gsort(double* vec, int* base_ptr, int total_elems, int (*cmp)(double, double)); extern int ivoc_list_count(Object*); -extern Object* ivoc_list_item(Object*, int); extern int hoc_is_double_arg(int narg); extern int hoc_is_str_arg(int narg); extern int hoc_is_object_arg(int narg); @@ -90,6 +90,18 @@ extern Point_process* ob2pntproc(Object*); extern char* hoc_object_name(Object*); extern double nrn_event_queue_stats(double*); extern void clear_event_queue(); +extern void cvode_fadvance(double); +extern int hoc_is_tempobj_arg(int narg); +extern Object* ivoc_list_item(Object*, int); +#else // TODO: Update nrn master & C++ PR +#ifdef __cplusplus +extern "C" { +#endif +Object* ivoc_list_item(Object*, int); +Symbol* hoc_get_symbol(const char* var); +#ifdef __cplusplus +} +#endif #endif extern unsigned int hashseed2 (int na, double* x); extern unsigned int dcrsz; @@ -110,7 +122,8 @@ extern void ishuffle(int* x,int nx); extern unsigned int valseed; extern int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv); extern int list_vector_px3 (Object *ob, int i, double** px, IvocVect** vv); -extern int cmpdfn(); +extern int list_vector_px4 (Object *ob, int i, double** px, unsigned int n); +extern int cmpdfn(double a, double b); extern int openvec(int, double **); int list_vector_px(Object *ob, int i, double** px); double *list_vector_resize(Object *ob, int i, int sz); @@ -121,6 +134,9 @@ extern ListVec* AllocILV(Object*, int, double *); void FillListVec(ListVec* p,double dval); void ListVecResize(ListVec* p,int newsz); extern short *nrn_artcell_qindex_; +extern int IsList (Object* p); +extern int uniq2 (int n, double *x, double *y, double *z); +static void vprpr (double x, int base); static double sc[6]; static FILE* testout; diff --git a/misc.mod b/misc.mod index 87b063e..6c5600b 100644 --- a/misc.mod +++ b/misc.mod @@ -48,6 +48,7 @@ VERBATIM #include #include #include +#include extern int hoc_is_tempobj(int narg); ENDVERBATIM @@ -58,7 +59,7 @@ VERBATIM errno else will get a nrnoc error. Seems to be a problem even if I don't include */ - char *gargstr(), *filename; + char *filename; filename = gargstr(1); @@ -85,19 +86,18 @@ PROCEDURE sassign() { VERBATIM FILE *pipein; char string[BUFSIZ], **strname, *syscall; - char** hoc_pgargstr(); strname = hoc_pgargstr(1); syscall = gargstr(2); if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - return; + return 0; // TODO: Ask Michael } if (fgets(string,BUFSIZ,pipein) == NULL) { fprintf(stderr,"System call did not return a string\n"); - pclose(pipein); return; + pclose(pipein); return 0; // TODO: Ask Michael } /* assign_hoc_str(strname, string, 0); */ @@ -120,17 +120,17 @@ VERBATIM if ( !(outfile = fopen("dassign","w"))) { fprintf(stderr,"Can't open output file dassign\n"); - return; + return 0; // TODO: Ask Michael } if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - fclose(outfile); return; + fclose(outfile); return 0; // TODO: Ask Michael } if (fscanf(pipein,"%lf",&num) != 1) { fprintf(stderr,"System call did not return a number\n"); - fclose(outfile); pclose(pipein); return; + fclose(outfile); pclose(pipein); return 0; // TODO: Ask Michael } fprintf(outfile,"%s=%g\n",strname,num); @@ -214,7 +214,7 @@ ENDVERBATIM FUNCTION hocgetc() { VERBATIM { - FILE* f, *hoc_obj_file_arg(); + FILE* f; f = hoc_obj_file_arg(1); _lhocgetc = (double)getc(f); } diff --git a/pregencv.mod b/pregencv.mod index 501f510..3b95dfc 100644 --- a/pregencv.mod +++ b/pregencv.mod @@ -87,7 +87,7 @@ PROCEDURE event_time() { PROCEDURE generate() { if (at_time(event)) { VERBATIM - {char func[8] = "pregencv_c"; + {char func[11] = "pregencv_c"; Symbol* s = hoc_lookup(func); if (s) { hoc_pushx(num); diff --git a/stats.mod b/stats.mod index 13d4828..fc7b123 100644 --- a/stats.mod +++ b/stats.mod @@ -425,9 +425,9 @@ static double* getrank (int n, double mdata[]) { int i; double* rank; int* index; - rank = malloc(n*sizeof(double)); + rank = (double*)malloc(n*sizeof(double)); if (!rank) return NULL; - index = malloc(n*sizeof(int)); + index = (int*)malloc(n*sizeof(int)); if (!index) { free(rank); return NULL; @@ -469,9 +469,9 @@ static double spearman(int n, double* data1, double* data2) double avgrank; double* tdata1; double* tdata2; - tdata1 = malloc(n*sizeof(double)); + tdata1 = (double*)malloc(n*sizeof(double)); if(!tdata1) return 0.0; /* Memory allocation error */ - tdata2 = malloc(n*sizeof(double)); + tdata2 = (double*)malloc(n*sizeof(double)); if(!tdata2) /* Memory allocation error */ { free(tdata1); return 0.0; @@ -642,7 +642,7 @@ int qsort2 (double *p1in, double* p2in, int n,double* p1out,double* p2out) { int i; scr=scrset(n); for (i=0;iUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 valseed*=(unsigned int)y; // keep multiplying these out } @@ -2090,7 +2090,7 @@ FUNCTION mc4seed () { for (i=2;ifarg(i);i++) { valseed*=(unsigned int)(*getarg(i)); } - mcell_ran4_init(&valseed); // do initialization + mcell_ran4_init((uint32_t)valseed); // do initialization return valseed; ENDVERBATIM } @@ -2118,7 +2118,7 @@ FUNCTION gammln (xx) { FUNCTION betai(a,b,x) { VERBATIM { double bt; - double gammln(),betacf(); + double gammln(double),betacf(double,double,double); if (_lx < 0.0 || _lx > 1.0) {printf("Bad x in routine BETAI\n"); hxe();} if (_lx == 0.0 || _lx == 1.0) bt=0.0; @@ -2192,7 +2192,7 @@ FUNCTION tstat() { FUNCTION tdistrib() { VERBATIM - double gammln(); + double gammln(double); double x = *getarg(1); double dof = *getarg(2); double res = (gammln( (dof+1.0) / 2.0 ) / gammln( dof / 2.0 ) ); diff --git a/updown.mod b/updown.mod index e9f5c0a..8ecd7dc 100644 --- a/updown.mod +++ b/updown.mod @@ -19,28 +19,7 @@ VERBATIM #include #include // contains LONG_MAX #include -extern double* hoc_pgetarg(); -extern double hoc_call_func(Symbol*, int narg); -extern FILE* hoc_obj_file_arg(int narg); -extern Object** hoc_objgetarg(); -extern void vector_resize(); -extern int vector_instance_px(); -extern void* vector_arg(); -extern double* vector_vec(); -extern double hoc_epsilon; -extern double chkarg(); -extern void set_seed(); -extern int ivoc_list_count(Object*); -extern Object* ivoc_list_item(Object*, int); -extern int hoc_is_double_arg(int narg); -extern char* hoc_object_name(Object*); -char ** hoc_pgargstr(); -int list_vector_px(); -int list_vector_px2(); -int list_vector_px3(); -double *list_vector_resize(); -int ismono1(); -static void hxe() { hoc_execerror("",0); } +#include static void hxf(void *ptr) { free(ptr); hoc_execerror("",0); } ENDVERBATIM @@ -72,7 +51,7 @@ static double updown (void* vv) { int i, k, m, n, nqsz, nsrc, jj[UDSL], f[UDSL], lc, dsz[UDSL], nqmax, thsz, lc2, done, dbn; double *src, *tvec, *th, *dest[UDSL], *nq[UDNQ], *tmp, *dbx, lt, thdist; Object *ob, *ob2; - void *vvd[UDSL], *vvth, *vnq[UDNQ]; + IvocVect *vvd[UDSL], *vvth, *vnq[UDNQ]; //** read in vectors and verify sizes, etc nsrc = vector_instance_px(vv, &src); // trace to analyze thsz = vector_arg_px(1, &th); // vector of thresholds to check diff --git a/vecst.mod b/vecst.mod index 2bd5a89..ecb1704 100644 --- a/vecst.mod +++ b/vecst.mod @@ -150,7 +150,7 @@ static double ident (void* vv) { int nx,bsz; double* x; nx = vector_instance_px(vv, &x); bsz=vector_buffer_size(vv); - printf("Obj*%x Dbl*%x Size: %d Bufsize: %d\n",(unsigned int)vv,(unsigned int)x,nx,bsz); + printf("Obj*%x Dbl*%x Size: %d Bufsize: %d\n",vv,x,nx,bsz); return (double)nx; } ENDVERBATIM @@ -228,7 +228,7 @@ static double circ (void* vv) { int i, nx, ny, flag, lnew; double *x, *y, x0, y0, x1, y1, rad, theta; lnew=0; - nx = vector_instance_px(vv, &x); + nx = vector_instance_px((IvocVect*)vv, &x); ny = vector_arg_px(1, &y); if (ny!=nx) { hoc_execerror("v.circ: Vector sizes don't match.", 0); } x0=*getarg(2); y0=*getarg(3); rad=*getarg(4); @@ -237,7 +237,7 @@ static double circ (void* vv) { rad=sqrt((x0-x1)*(x0-x1) + (y0-y1)*(y0-y1)); lnew=*getarg(6); // resize the vectors } else if (ifarg(5)) lnew=*getarg(5); // resize the vectors - if (lnew) { nx=lnew; x=vector_newsize(vv,nx); y=vector_newsize(vector_arg(1),ny=nx); } + if (lnew) { nx=lnew; x=vector_newsize((IvocVect*)vv,nx); y=vector_newsize(vector_arg(1),ny=nx); } for (i=0,theta=0; iscrsz) { @@ -369,10 +370,11 @@ ENDVERBATIM : ind picks out specific vectors if not doing all of them VERBATIM static double lma (void* vv) { + IvocVect* vv_tmp = (IvocVect*)vv; int i, j, k, ia, ib, ni, nj, nx, av[VRRY], bv[VRRY], num, numb, beg, end, *xx; Object *ob1, *ob2; double *ind, *avo[VRRY], *bvo[VRRY], mul,mmul,add,madd; - ni = vector_instance_px(vv, &ind); + ni = vector_instance_px((IvocVect*)vv, &ind); xx=iscrset(ni); ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); beg = (int)*getarg(3); end= (int)*getarg(4); @@ -395,8 +397,8 @@ static double lma (void* vv) { nx=av[0]; // size of source vecs if (beg>=end || beg<0 || end>nx) {printf("lma ERRC1 OOB %d - %d (%d)\n",beg,end,nx); hxe();} for (i=0;i0) { for (ia=0,ib=0,mmul=1.,madd=0.;ia=nx) x=vector_newsize(vv,nx*=4); + if (k>=nx) x=vector_newsize((IvocVect*)vv,nx*=4); x[k]=*getarg(i); } else { ny=vector_arg_px(i, &y); - if (k+ny>=nx) x=vector_newsize(vv,nx=2*(nx+ny)); + if (k+ny>=nx) x=vector_newsize((IvocVect*)vv,nx=2*(nx+ny)); for (j=0;jisz;iv++) { @@ -895,13 +897,13 @@ static double linsct (void* vv) { } if (fl) cnt++; if (cnt>=min) { - if (k==maxsz) x=vector_newsize(vv, maxsz*=2); + if (k==maxsz) x=vector_newsize((IvocVect*)vv, maxsz*=2); x[k++]=val; break; } } } - vector_resize(vv, k); + vector_resize((IvocVect*)vv, k); return (double)k; } ENDVERBATIM @@ -924,17 +926,17 @@ VERBATIM static double cull (void* vv) { int i, j, k, nx, nv1, nv2, flag; double *x, *v1, *v2, val; - nx = vector_instance_px(vv, &x); + nx = vector_instance_px((IvocVect*)vv, &x); nv1 = vector_arg_px(1, &v1); if (hoc_is_double_arg(2)) { val=*getarg(2); nv2=0; } else nv2=vector_arg_px(2, &v2); - x=vector_newsize(vv,nx=nv1); + x=vector_newsize((IvocVect*)vv,nx=nv1); for (i=0,k=0;iVRRY) hoc_execerror("mredundout ****ERRA****: can only handle VRRY vectors", 0); for (i=0;imaxsz){printf("mredundout****ERRE**** vec overflow %d>%d\n",k,maxsz);hxe();} for (i=0;i0 && kk0 && kk=nv[1]) { printf("nearall WARN: oor %d %d\n",k,nv[1]); return -1.; } vvo[0][k]=dist; vvo[2][k]=targ; vvo[3][k]=x[minind]; k++; @@ -1395,14 +1397,14 @@ ENDVERBATIM VERBATIM static double nearest (void* vv) { int i, nx, minind, flag=0; - double *x, targ, dist, new, *to; + double *x, targ, dist, new_, *to; nx = vector_instance_px(vv, &x); targ = *getarg(1); if (ifarg(3)) flag = (int)*getarg(3); dist = 1e9; - for (i=0; i=cnt) {printf("vecst:l2p() ERRA: %d %d %d\n",i,ix,cnt); hxe();} @@ -1835,7 +1837,7 @@ static double fetch (void* vv) { ny = vector_arg_px(3, &y); if (ny>pL->isz) vector_resize(vector_arg(3),pL->isz); // don't make bigger if only want a few for (i=0,j=0,cnt=0;iisz && jpL->plen[i]) {printf("vecst:fetch()ERRB: %d %d %x\n",i,ix,(unsigned int)pL->pv[i]); + if (ix>pL->plen[i]) {printf("vecst:fetch()ERRB: %d %d %x\n",i,ix,pL->pv[i]); FreeListVec(&pL); hxe();} y[j]=pL->pv[i][ix]; cnt++; @@ -1844,7 +1846,7 @@ static double fetch (void* vv) { } else { for (i=0,j=3,cnt=0;iisz && ifarg(j);i++,j++) { if (hoc_is_double_arg(j)) continue; // skip this one - if (ix>pL->plen[i]) {printf("vecst:fetch()ERRB1: %d %d %x\n",i,ix,(unsigned int)pL->pv[i]); + if (ix>pL->plen[i]) {printf("vecst:fetch()ERRB1: %d %d %x\n",i,ix,pL->pv[i]); FreeListVec(&pL); hxe();} *hoc_pgetarg(j)=ret=pL->pv[i][ix]; cnt++; @@ -1969,7 +1971,7 @@ static double lcat (void* vv) { int i, j, k, n, lc, cap, maxsz; Object *ob1; double *x, *fr; - void *vw; + IvocVect *vw; n = vector_instance_px(vv, &x); vector_resize(vv,maxsz=vector_buffer_size(vv)); // open it up fully ob1 = *hoc_objgetarg(1); @@ -2232,7 +2234,7 @@ VERBATIM static double uniq (void* vv) { int i, j, k, n, cnt, ny, nz, flag, lt, rt, mid, res; double *x, *y, *z, lastx, num; - void* voi[2]; Object* ob; char *ix; + IvocVect* voi[2]; Object* ob; char *ix; n = vector_instance_px(vv, &x); flag=ny=nz=0; if (n==0) {printf("vecst:uniq WARNA empty input vector\n"); return 0;} @@ -2261,7 +2263,7 @@ static double uniq (void* vv) { } scrset(n); for (i=0;i0) z[0]=1.; for (i=1, lastx=x[scr[0]], cnt=1; ilastx+hoc_epsilon) { @@ -2352,6 +2342,18 @@ int uniq2 (int n, double *x, double *y, double *z) { return cnt; } +// x.unq(y,z) calls uniq2() -- functionality same as uniq(List,1) +static double unq (void* vv) { + int n, cnt; double *x, *y, *z; + n=vector_instance_px(vv, &x); + y=vector_newsize(vector_arg(1),n); // all same size + z=vector_newsize(vector_arg(2),n); + cnt=uniq2(n,x,y,z); + y=vector_newsize(vector_arg(1),cnt); + z=vector_newsize(vector_arg(2),cnt); + return (double)cnt; +} + // v1.nqsvt() for nqs vt iterator static double nqsvt (void* vv) { int i, j, n, flag, cols; @@ -2681,7 +2683,7 @@ ENDVERBATIM VERBATIM static double rdfile (void* vv) { int i, j, k, ni, vsz, ty, ny, nv, num, cnt, n[2], hd, vflag; - void* vnq[10000]; size_t r; + IvocVect* vnq[10000]; size_t r; size_t sz; char* xc; int *xi; float *xf; double *xd; void* xv; unsigned short* xus; Object* ob; @@ -2868,7 +2870,11 @@ FUNCTION isojt () { Object *ob1, *ob2; ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); if (!ob1) if (!ob2) return 1; else return 0; +#ifndef NRN_VERSION_GTEQ_8_2_0 if (!ob2 || ob1->template != ob2->template) { +#else + if (!ob2 || ob1->ctemplate != ob2->ctemplate) { +#endif return 0; } return 1; @@ -3145,7 +3151,7 @@ void ListVecResize (ListVec* p,int newsz) { int i,j; Object* obv; for(i=0;iisz;i++){ obv = ivoc_list_item(p->pL, i); - p->pv[i]=vector_newsize(obv->u.this_pointer,newsz); + p->pv[i]=vector_newsize((IvocVect*)obv->u.this_pointer,newsz); p->plen[i]=newsz; } } From ad87672d587ae349d02011ee6ea0673baea66013 Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Tue, 17 May 2022 14:56:00 +0200 Subject: [PATCH 06/23] 9.0.0 works almost without warnings --- intf_.mod | 32 +++++++------- intfsw.mod | 6 +-- stats.mod | 27 +++++------ vecst.mod | 128 ++++++++++++++++++++++++++++------------------------- 4 files changed, 101 insertions(+), 92 deletions(-) diff --git a/intf_.mod b/intf_.mod index cf3f9bc..72f378a 100644 --- a/intf_.mod +++ b/intf_.mod @@ -20,7 +20,7 @@ VERBATIM #include "misc.h" #include "unistd.h" static int ctt(unsigned int, char**); -static int setdvi2(double*,double*,int,int); +static void setdvi2(double*,double*,int,int); #define PI 3.141592653589793115997963468544 #define nil 0 @@ -105,7 +105,7 @@ static int vspn; static double *isp, *vsp, *wsp, *jsp, *invlp; static double *lop(Object *ob, unsigned int i); // accessed by all INTF static double *jrid, *jrtv; -static void *jridv, *jrtvv; +static IvocVect *jridv, *jrtvv; static unsigned int jtpt,jtmax,jrmax; static unsigned long int jri,jrj; static unsigned long int spktot, eventtot; @@ -123,7 +123,7 @@ double* wwo[NSW]; static int AM=0, NM=1, GA=2, GB=3, SU=3, IN=4, DP=2; // from labels.hoc static double wts[10],hsh[10]; // for jitcons to use as a junk pointer static void spkoutf2(); -int gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das); +void gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das); ENDVERBATIM :* NEURON, PARAMETER, ASSIGNED blocks @@ -1356,7 +1356,7 @@ FUNCTION setdviv () { : finishdvi2 () -- finalize dvi , sort dvi , allocate and set sprob VERBATIM -static int finishdvi2 (struct ID0* p) { +static void finishdvi2 (struct ID0* p) { Point_process **da,**das; double *db,*dbs; int i, dvt; @@ -1410,7 +1410,7 @@ ENDVERBATIM VERBATIM // setdvi2(divid_vec,del_vec,div_cnt,flag) // flag 1 means just augment, 0or2: sort by del, 0: clear lists and replace -static int setdvi2 (double *y,double *d,int dvt,int flag) { +static void setdvi2 (double *y,double *d,int dvt,int flag) { int i,j,ddvi; double *db, *dbs; unsigned char pdead; unsigned int b,e; Object *lb; Point_process *pnnt, **da, **das; ddvi=(int)DEAD_DIV; @@ -1527,7 +1527,7 @@ PROCEDURE turnoff () { VERBATIM // gsort2() sorts 2 parallel vectors -- delays and Point_process pointers -int gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das) { +void gsort2 (double *db, Point_process **da,int dvt,double *dbs, Point_process **das) { int i; scr=scrset(dvt); for (i=0;ip=0; // open up the vector maximally before writing into it; will correct size in fini - for (k=0;kvvo[k]!=0) vector_resize(vp->vv[k], vp->size); + for (k=0;kvvo[k]!=0) vector_resize((IvocVect*)vp->vv[k], vp->size); }} ENDVERBATIM } @@ -2126,7 +2126,7 @@ PROCEDURE fini () { if (IDP->record) { record(); // finish up for (k=0;kvvo[k]!=0) { // not nil pointer - vector_resize(vp->vv[k], vp->p); + vector_resize((IvocVect*)vp->vv[k], vp->p); } }} ENDVERBATIM @@ -2225,9 +2225,9 @@ PROCEDURE initrec () { if (i==-1) {printf("INTF record ERR %s not recognized\n",name); hoc_execerror("",0); } vp->vv[i]=vector_arg(2); vector_arg_px(2, &(vp->vvo[i])); - if (vp->size==0) { vp->size=(unsigned int)vector_buffer_size(vp->vv[i]); - } else if (vp->size != (unsigned int)vector_buffer_size(vp->vv[i])) { - printf("INTF initrec ERR vectors not all same size: %d vs %d",vp->size,vector_buffer_size(vp->vv[i])); + if (vp->size==0) { vp->size=(unsigned int)vector_buffer_size((IvocVect*)vp->vv[i]); + } else if (vp->size != (unsigned int)vector_buffer_size((IvocVect*)vp->vv[i])) { + printf("INTF initrec ERR vectors not all same size: %d vs %d",vp->size,vector_buffer_size((IvocVect*)vp->vv[i])); hoc_execerror("", 0); }} ENDVERBATIM @@ -2427,7 +2427,7 @@ PROCEDURE global_init () { printf("Initializing ww to record for %g (%g)\n",vdt*wwsz,vdt); wwpt=0; for (k=0;k<(int)nsw;k++) { - vector_resize(ww[k], wwsz); + vector_resize((IvocVect*)ww[k], wwsz); for (j=0;j2){ for(j=0;jUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 valseed*=(unsigned int)y; // keep multiplying these out } @@ -2090,7 +2091,7 @@ FUNCTION mc4seed () { for (i=2;ifarg(i);i++) { valseed*=(unsigned int)(*getarg(i)); } - mcell_ran4_init((uint32_t)valseed); // do initialization + mcell_ran4_init(valseed); // do initialization return valseed; ENDVERBATIM } diff --git a/vecst.mod b/vecst.mod index ecb1704..b158936 100644 --- a/vecst.mod +++ b/vecst.mod @@ -149,7 +149,7 @@ VERBATIM static double ident (void* vv) { int nx,bsz; double* x; nx = vector_instance_px(vv, &x); - bsz=vector_buffer_size(vv); + bsz=vector_buffer_size((IvocVect*)vv); printf("Obj*%x Dbl*%x Size: %d Bufsize: %d\n",vv,x,nx,bsz); return (double)nx; } @@ -345,7 +345,7 @@ static double findx (void* vv) { for (i=0;i %d :: ",n,nx); hoc_execerror("Vector max capacity too small for ird ", 0); @@ -760,14 +760,14 @@ static double fread2 (void* vv) { fp = hoc_obj_file_arg(1); nx = vector_instance_px(vv, &x); - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); n = (int)*getarg(2); type = (int)*getarg(3); if (n>maxsz) { printf("%d > %d :: ",n,maxsz); hoc_execerror("Vector max capacity too small for fread2 ", 0); } else { - vector_resize(vv, n); + vector_resize((IvocVect*)vv, n); } if (type==6 || type==16) { // unsigned ints unsigned int *xs; @@ -794,6 +794,7 @@ static double fread2 (void* vv) { } free((char *)xf); } else hoc_execerror("Type unsupported in fread2 ", 0); + return 0; // TODO: Shoulf we return 0 or 1? } ENDVERBATIM @@ -815,6 +816,7 @@ static double revec (void* vv) { } } vector_resize((IvocVect*)vv,k); + return 0; // TODO: Shoulf we return 0 or 1? } ENDVERBATIM @@ -842,7 +844,7 @@ static double has (void* vv) { } } else return 1; } - if (j>0) vector_resize(vc,j); // only fall through here when doing indvwhere + if (j>0) vector_resize((IvocVect*)vc,j); // only fall through here when doing indvwhere return (double)j; } ENDVERBATIM @@ -917,6 +919,7 @@ static double vfill (void* vv) { nx = vector_instance_px(vv, &x); nv1 = vector_arg_px(1, &v1); for (i=0;i=maxsz) { printf("\tredundout WARNING: ran out of room: %d=ncntr) { printf("\tredundout WARNING: cntr ran out of room: %d0 && kmaxsz) {printf("VECST samp ERRA: dest vec too small: %d %d\n",iNewSz,maxsz); hxe();} - vector_resize(vv,iNewSz); + vector_resize((IvocVect*)vv,iNewSz); scale = (double) iOrigSz / (double) iNewSz; for(i=0;imaxsz) { printf("%d > %d\n",size,maxsz); hoc_execerror("v.snap: insufficient room in dest", 0); } - vector_resize(vv, size); + vector_resize((IvocVect*)vv, size); if (nsrc!=ntvec) hoc_execerror("v.snap: src and tvec not same size", 0); for (tt=0,i=0;ipL->isz) vector_resize(vector_arg(3),pL->isz); // don't make bigger if only want a few + if (ny>pL->isz) vector_resize((IvocVect*)vector_arg(3),pL->isz); // don't make bigger if only want a few for (i=0,j=0,cnt=0;iisz && jpL->plen[i]) {printf("vecst:fetch()ERRB: %d %d %x\n",i,ix,pL->pv[i]); FreeListVec(&pL); hxe();} @@ -1973,7 +1981,7 @@ static double lcat (void* vv) { double *x, *fr; IvocVect *vw; n = vector_instance_px(vv, &x); - vector_resize(vv,maxsz=vector_buffer_size(vv)); // open it up fully + vector_resize((IvocVect*)vv,maxsz=vector_buffer_size((IvocVect*)vv)); // open it up fully ob1 = *hoc_objgetarg(1); lc = ivoc_list_count(ob1); for (i=0,j=0;iu.this_pointer); - *px = vector_vec(obv->u.this_pointer); + sz = vector_capacity((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); return sz; } @@ -2098,8 +2106,8 @@ int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv) { int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; - sz = vector_capacity(obv->u.this_pointer); - *px = vector_vec(obv->u.this_pointer); + sz = vector_capacity((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); *vv = (IvocVect*) obv->u.this_pointer; return sz; } @@ -2112,8 +2120,8 @@ int list_vector_px3 (Object *ob, int i, double** px, IvocVect** vv) { int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; - sz = vector_buffer_size(obv->u.this_pointer); - *px = vector_vec(obv->u.this_pointer); + sz = vector_buffer_size((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); *vv = (IvocVect*) obv->u.this_pointer; vector_resize(*vv,sz); return sz; @@ -2127,14 +2135,14 @@ int list_vector_px4 (Object *ob, int i, double** px, unsigned int n) { int sz; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return -1; - sz = vector_buffer_size(obv->u.this_pointer); - *px = vector_vec(obv->u.this_pointer); + sz = vector_buffer_size((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)obv->u.this_pointer); vv = (void*) obv->u.this_pointer; if (n>sz) { printf("List vector WARNING: unable to resize to %d requested (%d)\n",n,sz); - vector_resize(vv,sz); + vector_resize((IvocVect*)vv,sz); return 0; - } else vector_resize(vv,n); + } else vector_resize((IvocVect*)vv,n); return 1; } @@ -2143,8 +2151,8 @@ double *list_vector_resize (Object *ob, int i, int sz) { Object* obv; obv = ivoc_list_item(ob, i); if (! ISVEC(obv)) return 0x0; - vector_resize(obv->u.this_pointer,sz); - return vector_vec(obv->u.this_pointer); + vector_resize((IvocVect*)obv->u.this_pointer,sz); + return vector_vec((IvocVect*)obv->u.this_pointer); } ENDVERBATIM @@ -2394,16 +2402,16 @@ int openvec (int arg, double **y) { if (! ISVEC(ob)) return -1; vector_arg_px(arg, y); vv=vector_arg(arg); - max=vector_buffer_size(vv); - vector_resize(vv, max); + max=vector_buffer_size((IvocVect*)vv); + vector_resize((IvocVect*)vv, max); if (max==0) printf("openvec(): 0 size vec\n"); return max; } // vector_newsize() will also increase size of vector double *vector_newsize (IvocVect* vv, int n) { - vector_resize(vv,n); - return vector_vec(vv); + vector_resize((IvocVect*)vv,n); + return vector_vec((IvocVect*)vv); } ENDVERBATIM @@ -2427,7 +2435,7 @@ static double pop (void* vv) { double *x; n = vector_instance_px(vv, &x); if (n==0) {printf("vec.pop ERR: empty vec\n");hxe();} - vector_resize(vv,n-1); + vector_resize((IvocVect*)vv,n-1); return x[n-1]; } ENDVERBATIM @@ -2480,9 +2488,9 @@ static double smgs (void* vv) { points = (int)((high-low)/step+hoc_epsilon); if (nsum!=points) { - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); if (points<=maxsz) { - nsum=points; vector_resize(vv, nsum); + nsum=points; vector_resize((IvocVect*)vv, nsum); } else { printf("%d > %d :: ",points,maxsz); hoc_execerror("Vector max capacity too small in smgs ", 0); @@ -2530,9 +2538,9 @@ static double smsy (void* vv) { points=(int)(tstop/mdt+hoc_epsilon); if (nsum!=points) { - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); if (points<=maxsz) { - vector_resize(vv, points); points=nsum; + vector_resize((IvocVect*)vv, points); points=nsum; } else { printf("%d > %d :: ",points,maxsz); hoc_execerror("Dest vector too small in smsy ", 0); @@ -2555,12 +2563,12 @@ static double vrdh (void* vv) { FILE* f; num = vector_instance_px(vv, &x); - maxsz=vector_buffer_size(vv); + maxsz=vector_buffer_size((IvocVect*)vv); f = hoc_obj_file_arg(1); num = (int)*getarg(2); // number of vectors to look for if (maxsz<2*num){printf("vrdh ERR0 need %d room in vec\n",2*num);hxe();} - vector_resize(vv, 2*num); + vector_resize((IvocVect*)vv, 2*num); for (i=0;i1e7) { free(scr); scr=(unsigned int *)NULL; scrsz=0; } return (double)num; } @@ -3116,9 +3124,9 @@ ListVec* AllocListVec (Object* p) { if(!pList->pv){free(pList->plen); printf("AllocListVec ERRC: Out of memory!\n"); hxe();} for(i=0;iisz;i++) { obv = ivoc_list_item(p,i); - pList->pv[i]=vector_vec(obv->u.this_pointer); - pList->plen[i]=vector_capacity(obv->u.this_pointer); - pList->pbuflen[i]=vector_buffer_size(obv->u.this_pointer);; + pList->pv[i]=vector_vec((IvocVect*)obv->u.this_pointer); + pList->plen[i]=vector_capacity((IvocVect*)obv->u.this_pointer); + pList->pbuflen[i]=vector_buffer_size((IvocVect*)obv->u.this_pointer);; } return pList; } @@ -3140,9 +3148,9 @@ ListVec* AllocILV (Object* p, int nx, double *x) { for(i=0;i=ilc){printf("AllocILV ERRD: index OOB: %d>=%d\n",j,ilc); hxe();} obv = ivoc_list_item(p,j); - pList->pv[i]=vector_vec(obv->u.this_pointer); - pList->plen[i]=vector_capacity(obv->u.this_pointer); - pList->pbuflen[i]=vector_buffer_size(obv->u.this_pointer);; + pList->pv[i]=vector_vec((IvocVect*)obv->u.this_pointer); + pList->plen[i]=vector_capacity((IvocVect*)obv->u.this_pointer); + pList->pbuflen[i]=vector_buffer_size((IvocVect*)obv->u.this_pointer);; } return pList; } From b99bf52a70a869af07d84c925a9bf92f098fa0b5 Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Tue, 17 May 2022 15:12:11 +0200 Subject: [PATCH 07/23] 8.1.0 & 9.0.0 work, except for 8.2.0 ctemplate issue --- intfsw.mod | 12 ++++++------ misc.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/intfsw.mod b/intfsw.mod index a79ab1a..4a2d6e6 100644 --- a/intfsw.mod +++ b/intfsw.mod @@ -454,7 +454,7 @@ FUNCTION GetCCR () { return 0.0; } - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; double* pUse = 0; @@ -562,7 +562,7 @@ FUNCTION GetCentrality () { return 0.0; } - unsigned int iSeed = ifarg(4)?(unsigned int)*getarg(4):INT_MAX-109754; + uint32_t iSeed = ifarg(4)?(uint32_t)*getarg(4):INT_MAX-109754; double* pUse = 0; @@ -780,7 +780,7 @@ FUNCTION CountNeighborsR () { double dSubsamp = ifarg(6)?*getarg(6):1.0; - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; if(iStartID < 0 || iStartID >= iCells || iEndID < 0 || iEndID >= iCells || @@ -1185,7 +1185,7 @@ FUNCTION GetPathR () { double dSubsamp = ifarg(6)?*getarg(6):1.0; - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; if(iStartID < 0 || iStartID >= iCells || iEndID < 0 || iEndID >= iCells || @@ -1657,7 +1657,7 @@ FUNCTION GetPathSubPop () { int bSelfLoop = ifarg(6)?(int)*getarg(6):0; - unsigned int iSeed = ifarg(7)?(unsigned int)*getarg(7):INT_MAX-109754; + uint32_t iSeed = ifarg(7)?(uint32_t)*getarg(7):INT_MAX-109754; //init array of cells/neighbors to check int* pCheck = (int*)malloc(sizeof(int)*iCells); @@ -1810,7 +1810,7 @@ FUNCTION GetLoopLength () { } double dSubsamp = ifarg(5)?*getarg(5):1.0; - unsigned int iSeed = ifarg(6)?(unsigned int)*getarg(6):INT_MAX-109754; + uint32_t iSeed = ifarg(6)?(uint32_t)*getarg(6):INT_MAX-109754; //init array of cells/neighbors to check int* pCheck = (int*)malloc(sizeof(int)*iCells); diff --git a/misc.h b/misc.h index e02e615..6c70686 100644 --- a/misc.h +++ b/misc.h @@ -77,7 +77,7 @@ extern void* vector_arg(); extern double* vector_vec(); extern int vector_buffer_size(void*); extern void mcell_ran4_init(uint32_t idum); -extern double mcell_ran4(uint32_t* high, double* x, unsigned int n, double range); +extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); extern int nrn_mlh_gsort(double* vec, int* base_ptr, int total_elems, int (*cmp)(double, double)); extern int ivoc_list_count(Object*); extern int hoc_is_double_arg(int narg); From 148d1a29c264193fae787fe6349e25903c5ddaa1 Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Tue, 17 May 2022 15:17:27 +0200 Subject: [PATCH 08/23] works with all versions --- vecst.mod | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vecst.mod b/vecst.mod index b158936..5d978a5 100644 --- a/vecst.mod +++ b/vecst.mod @@ -2878,10 +2878,10 @@ FUNCTION isojt () { Object *ob1, *ob2; ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); if (!ob1) if (!ob2) return 1; else return 0; -#ifndef NRN_VERSION_GTEQ_8_2_0 - if (!ob2 || ob1->template != ob2->template) { -#else +#ifdef __cplusplus if (!ob2 || ob1->ctemplate != ob2->ctemplate) { +#else + if (!ob2 || ob1->template != ob2->template) { #endif return 0; } From fd80ad38a49671b0647aaa9465e747045ce10b49 Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Tue, 17 May 2022 15:25:53 +0200 Subject: [PATCH 09/23] works with all versions --- driver.hoc | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 driver.hoc diff --git a/driver.hoc b/driver.hoc deleted file mode 100644 index 5cd147f..0000000 --- a/driver.hoc +++ /dev/null @@ -1,36 +0,0 @@ - -strdef verify_dir_ -verify_dir_ = "/gpfs/bbp.cscs.ch/data/project/proj16/kotsalos/nrn_HACK/mdb/ncdemo" - -if (name_declared("verify_dir_") == 0) { - execute("~strdef verify_dir_") - execute("verify_dir_ = \".\"") -} -strdef verify_tstr_ -objref verify_glist_, verify_xvec_, verify_yvec_, verify_file_ -verify_file_ = new File() -sprint(verify_tstr_, "%s/gout", verify_dir_) -verify_file_.wopen(verify_tstr_) -verify_xvec_ = new Vector() -verify_yvec_ = new Vector() -verify_glist_ = new List("Graph") - -proc verify_graph_() {local i, j, k - verify_file_.printf("Graphs %d\n", verify_glist_.count) - for i=0, verify_glist_.count-1 { - verify_file_.printf("%s\n", verify_glist_.object(i)) - k = 0 - for (j=-1; (j=verify_glist_.object(i).line_info(j, verify_xvec_)) != -1; ){ - k += 1 - } - verify_file_.printf("lines %d\n", k) - for (j=-1; (j=verify_glist_.object(i).getline(j, verify_xvec_, verify_yvec_)) != -1; ){ - verify_file_.printf("points %d\n", verify_xvec_.size) - verify_file_.printf("xvec%d\n", j) - verify_xvec_.printf(verify_file_) - verify_file_.printf("yvec%d\n", j) - verify_yvec_.printf(verify_file_) - } - } -} -verify_graph_() \ No newline at end of file From 92735a7fec7b90e82179cd9883515ceb82cc8a3a Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 18:08:42 +0200 Subject: [PATCH 10/23] Added changelog in readme --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index 4b19334..c1f0679 100644 --- a/readme.txt +++ b/readme.txt @@ -59,3 +59,5 @@ For questions/comments/collaborations please contact Samuel Neymotin at samn at neurosim dot downstate dot edu or Bill Lytton at billl at neurosim dot downstate dot edu + +20220517 Edited multiple files to support NEURON versions <8.1.0, 8.2.0 and 9.0.0. -NEURON Developers From db4d3b76d38f0c73b470c648ec314fdec243b51e Mon Sep 17 00:00:00 2001 From: Christos Kotsalos Date: Wed, 18 May 2022 08:11:07 +0200 Subject: [PATCH 11/23] small fixes based on review --- intf_.mod | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/intf_.mod b/intf_.mod index 72f378a..d1b3793 100644 --- a/intf_.mod +++ b/intf_.mod @@ -44,7 +44,7 @@ typedef struct VPT { unsigned int id; unsigned int size; unsigned int p; - void* vv[NSV]; + IvocVect* vv[NSV]; double* vvo[NSV]; } vpt; @@ -118,7 +118,7 @@ static int cty[CTYPp], process; static int CTYN, CTYPi, STYPi, dscrsz; // from labels.hoc static double qlimit, *dscr; FILE *wf1, *wf2, *tf; -void* ww[NSW]; +IvocVect* ww[NSW]; double* wwo[NSW]; static int AM=0, NM=1, GA=2, GB=3, SU=3, IN=4, DP=2; // from labels.hoc static double wts[10],hsh[10]; // for jitcons to use as a junk pointer @@ -1119,7 +1119,7 @@ FUNCTION getconv () { VERBATIM { int iarg,i,j,k,dvt,sz,prfl,getactive; double *x,flag; - void* voi; Point_process **das; id0 *pp; + IvocVect* voi; Point_process **das; id0 *pp; ip=IDP; pg=ip->pg; // this should be called right after jitcondiv() sz=ip->dvt; // // assume conv similar to div getactive=0; @@ -1131,8 +1131,8 @@ VERBATIM } if (!ifarg(iarg)) prfl=0; else { prfl=1; voi=vector_arg(iarg); - if (flag==2.) { x=vector_newsize((IvocVect*)voi,CTYPi); for (i=0;isprob[j]==0) continue; if (ip==*((id0**) &((das[j]->_prop->dparam)[2]))) { if (prfl) { - if (flag!=2.0 && k>=sz) x=vector_newsize((IvocVect*)voi,sz*=2); + if (flag!=2.0 && k>=sz) x=vector_newsize(voi,sz*=2); if (flag==1.0) { x[k]=(double)qp->type; } else if (flag==2.0) { x[qp->type]++; } else x[k]=(double)qp->id; @@ -1152,7 +1152,7 @@ VERBATIM } } } - if (prfl && flag!=2) vector_resize((IvocVect*)voi,k); + if (prfl && flag!=2) vector_resize(voi,k); _lgetconv=(double)k; } ENDVERBATIM @@ -1786,7 +1786,7 @@ PROCEDURE record () { if (ip->record==1) { while ((int)vp->p >= (int)vp->size-(int)((t-tg)/vdt)-10) { vp->size*=2; - for (k=0;kvv[k]!=0x0) vp->vvo[k]=vector_newsize((IvocVect*)vp->vv[k], vp->size); + for (k=0;kvv[k]!=0x0) vp->vvo[k]=vector_newsize(vp->vv[k], vp->size); // printf("**** WARNING expanding recording room to %d (type%d id%d at %g)****\n",vp->size,IDP->type,IDP->id,t); } } else if ((int)vp->p > (int)vp->size-(int)((t-tg)/vdt)) { // shift if record==2 @@ -2036,13 +2036,13 @@ PROCEDURE test () { : lof can find object information PROCEDURE lof () { VERBATIM { - Object *ob; int num,i,ii,j,k,si,nx; double *vvo[7], *par; void *vv[7]; + Object *ob; int num,i,ii,j,k,si,nx; double *vvo[7], *par; IvocVect *vv[7]; ob = *(hoc_objgetarg(1)); si=(int)*getarg(2); num = ivoc_list_count(ob); if (num!=7) { printf("INTF lof ERR %d>7\n",num); hxe(); } for (i=0;ip=0; // open up the vector maximally before writing into it; will correct size in fini - for (k=0;kvvo[k]!=0) vector_resize((IvocVect*)vp->vv[k], vp->size); + for (k=0;kvvo[k]!=0) vector_resize(vp->vv[k], vp->size); }} ENDVERBATIM } @@ -2126,7 +2126,7 @@ PROCEDURE fini () { if (IDP->record) { record(); // finish up for (k=0;kvvo[k]!=0) { // not nil pointer - vector_resize((IvocVect*)vp->vv[k], vp->p); + vector_resize(vp->vv[k], vp->p); } }} ENDVERBATIM @@ -2163,7 +2163,7 @@ PROCEDURE chk (f) { if (lfg==5) { printf("wwpt %d wwsz %d\n WW vecs: ",wwpt,wwsz); printf("wwwid %g wwht %d nsw %g\n WW vecs: ",wwwid,(int)wwht,nsw); - for (i=0;ivv[i]=vector_arg(2); vector_arg_px(2, &(vp->vvo[i])); - if (vp->size==0) { vp->size=(unsigned int)vector_buffer_size((IvocVect*)vp->vv[i]); - } else if (vp->size != (unsigned int)vector_buffer_size((IvocVect*)vp->vv[i])) { - printf("INTF initrec ERR vectors not all same size: %d vs %d",vp->size,vector_buffer_size((IvocVect*)vp->vv[i])); + if (vp->size==0) { vp->size=(unsigned int)vector_buffer_size(vp->vv[i]); + } else if (vp->size != (unsigned int)vector_buffer_size(vp->vv[i])) { + printf("INTF initrec ERR vectors not all same size: %d vs %d",vp->size,vector_buffer_size(vp->vv[i])); hoc_execerror("", 0); }} ENDVERBATIM @@ -2277,7 +2277,7 @@ PROCEDURE initwrec () { if (num>NSW) { printf("INTF initwrec() WARN: can only store %d ww vecs\n",NSW); hxe();} nsw=(double)num; for (k=0;k Date: Thu, 19 May 2022 11:14:46 +0200 Subject: [PATCH 12/23] fixup for new wheels, drop register keyword, drop values.h for macOS --- misc.h | 21 ++++++--------------- vecst.mod | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/misc.h b/misc.h index 6c70686..6647555 100644 --- a/misc.h +++ b/misc.h @@ -2,10 +2,10 @@ #include #include +#include /* contains DBL_MAX */ #include /* contains LONG_MAX */ #include -#include -#include +#include #include #include @@ -54,10 +54,10 @@ typedef unsigned char ui1; /* one byte unsigned integer */ typedef char si1; /* one byte signed integer */ typedef unsigned short ui2; /* two byte unsigned integer */ typedef short si2; /* two byte signed integer */ -typedef unsigned int ui4; /* four byte unsigned integer */ -typedef int si4; /* four byte signed integer */ -typedef float sf4; /* four byte signed floating point number */ -typedef double sf8; /* eight byte signed floating point number */ +typedef unsigned int ui4; /* four byte unsigned integer */ +typedef int si4; /* four byte signed integer */ +typedef float sf4; /* four byte signed floating point number */ +typedef double sf8; /* eight byte signed floating point number */ extern double ERR,GET,SET,OK,NOP,ALL,NEG,POS,CHK,NOZ,GTH,GTE,LTH,LTE,EQU; extern double EQV,EQW,EQX,NEQ,SEQ,RXP,IBE,EBI,IBI,EBE; @@ -93,15 +93,6 @@ extern void clear_event_queue(); extern void cvode_fadvance(double); extern int hoc_is_tempobj_arg(int narg); extern Object* ivoc_list_item(Object*, int); -#else // TODO: Update nrn master & C++ PR -#ifdef __cplusplus -extern "C" { -#endif -Object* ivoc_list_item(Object*, int); -Symbol* hoc_get_symbol(const char* var); -#ifdef __cplusplus -} -#endif #endif extern unsigned int hashseed2 (int na, double* x); extern unsigned int dcrsz; diff --git a/vecst.mod b/vecst.mod index 5d978a5..907b150 100644 --- a/vecst.mod +++ b/vecst.mod @@ -1343,7 +1343,7 @@ ENDVERBATIM : max is maximum diff to add to the tq db VERBATIM static double nearall (void* vv) { - register int lo, hi, mid; + int lo, hi, mid; int i, j, k, kk, nx, ny, minind, nv[4]; Object *ob; IvocVect* vvl[4]; From 0eb8038f92da7752e4b48a9a8294a799e052d4fa Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Thu, 19 May 2022 16:40:07 +0200 Subject: [PATCH 13/23] fixup for new 8.2 wheel --- vecst.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vecst.mod b/vecst.mod index 907b150..6e9a6d9 100644 --- a/vecst.mod +++ b/vecst.mod @@ -2878,7 +2878,7 @@ FUNCTION isojt () { Object *ob1, *ob2; ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); if (!ob1) if (!ob2) return 1; else return 0; -#ifdef __cplusplus +#ifdef NRN_VERSION_GTEQ_8_2_0 if (!ob2 || ob1->ctemplate != ob2->ctemplate) { #else if (!ob2 || ob1->template != ob2->template) { From 2cce6fab73ba0cc3282ecf04e63996651f93ad38 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Mon, 23 May 2022 10:27:21 +0200 Subject: [PATCH 14/23] fix warnings --- infot.mod | 2 +- intf_.mod | 12 +++++++----- netrand.inc | 10 +++++----- readme.txt | 6 +++++- stats.mod | 2 +- vecst.mod | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/infot.mod b/infot.mod index f922108..a30b5eb 100644 --- a/infot.mod +++ b/infot.mod @@ -865,7 +865,7 @@ double entropxfgxpd (double* pXP, double* pXFXP,int minv,int maxv,int szp) { if (usetable && tmp[3]>=MINLOG2 && tmp[3]<=MAXLOG2) { tmp[0] -=tmp[2]*_n_LOG2(tmp[3]); } else { tmp[0] -=tmp[2]* log2d(tmp[3]); if (usetable&&verbose>0.4) { - printf("WARNA:%g outside of [%g,%g] TABLE\n",tmp[4],MINLOG2,MAXLOG2); }}}} + printf("WARNA:%g outside of [%g,%g] TABLE\n",tmp[3],MINLOG2,MAXLOG2); }}}} return tmp[0]; } diff --git a/intf_.mod b/intf_.mod index d1b3793..ef45989 100644 --- a/intf_.mod +++ b/intf_.mod @@ -1950,11 +1950,12 @@ PROCEDURE trvsp () { VERBATIM int i, flag; - double ind, t0; + double ind, local_t0; ip=IDP; flag=(int) *getarg(1); if (subsvint==0.) {printf("trvsp"); return(0.);} - ind=isp[0]; t0=vsp[0]; + ind=isp[0]; + local_t0=vsp[0]; if (flag==1) { for (i=0; itsp); - max=vector_arg_px(i++, &ip->wsp); + j=vector_arg_px(local_i++, &ip->tsp); + max=vector_arg_px(local_i++, &ip->wsp); if (max!=j) {printf("initrnd ERR: vecs of different size: %d %d\n",max,j); hxe();} if (max==0) {printf("initrnd ERR: vec not initialized\n"); hxe();} ENDVERBATIM diff --git a/readme.txt b/readme.txt index c1f0679..567957f 100644 --- a/readme.txt +++ b/readme.txt @@ -60,4 +60,8 @@ Samuel Neymotin at samn at neurosim dot downstate dot edu or Bill Lytton at billl at neurosim dot downstate dot edu -20220517 Edited multiple files to support NEURON versions <8.1.0, 8.2.0 and 9.0.0. -NEURON Developers +-------------------------------------------------------------------------- + Changelog +-------------------------------------------------------------------------- +2022-05: Updated MOD files to contain valid C++ and be compatible with the + upcoming versions 8.2 and 9.0 of NEURON. diff --git a/stats.mod b/stats.mod index 1e379dc..498a952 100644 --- a/stats.mod +++ b/stats.mod @@ -1445,7 +1445,7 @@ static double rantran (void* vv) { int i,j,ix,ixe,ixvn,nvn,rvn,na,xj; double *ixv, *nv, *x, y[1], ixn,step,indx; rvn=vector_instance_px(vv, &x); - for (na=1;ifarg(na);na++); na--; // count args + for (na=1;ifarg(na);na++) {} na--; // count args for (i=1;iVRRY) hoc_execerror("ERR: keyind can only handle VRRY vectors", 0); num = i-1; // number of vectors to be picked apart for (i=0;i Date: Mon, 23 May 2022 10:40:14 +0200 Subject: [PATCH 15/23] add comments about C compilation warnings --- infot.mod | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infot.mod b/infot.mod index a30b5eb..cdfd7e1 100644 --- a/infot.mod +++ b/infot.mod @@ -417,6 +417,7 @@ double tentropd (double* x,double* y,int iLen,int nbins,int xpast,int ypast,int dsum=0.0; *sig=-1e6;//init sig to neg *nTE = 0.0; + /* 2nd cntpx should be cntpxy? */ sh=cntjxy=cntjx=cntpx=cntpx=0; teavg=testd=te=teout=0.0; px = nbins>0 ? getnormd(x,iLen,nbins) : doublep2intp(x,iLen); //discretize x to nbins, or just copy to ints @@ -1105,6 +1106,7 @@ static double tetrospks2 (double* X1d,double* X2d,double* XO,int szX1,int szXO,i cnt1/=sz; cnt2/=sz; // ignore if not enough of the windows are filled if (cnt1binmax) return -11.; else if (cnt2>binmax) return -12.; + /* this should perhaps be fabs */ if (abs(cnt1-cnt2)>cutoff) return -13.; } if(verbose>2)printf("tentropspks:minv1=%d,maxv1=%d,minv2=%d,maxv2=%d\n",minv1,maxv1,minv2,maxv2); From 7c83f84130efe5b2754cd8c9c7d2caa7dd6989c6 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Mon, 23 May 2022 10:47:24 +0200 Subject: [PATCH 16/23] reduce diff and preserve probably-buggy behaviour. --- stats.mod | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stats.mod b/stats.mod index 498a952..c947b09 100644 --- a/stats.mod +++ b/stats.mod @@ -39,6 +39,7 @@ PARAMETER { ASSIGNED { seed } VERBATIM +#include #include "misc.h" #define MIN_MERGESORT_LIST_SIZE 32 @@ -860,7 +861,8 @@ static double hash (void* vv) { } else { xx.d=vvo[j][i]; } if (xx.i[0]==0) { xx.i[0]=xx.i[1]; xx.i[0]<<=4; } // high order bits may be 0 if (xx.i[1]==0) { xx.i[1]=xx.i[0]; xx.i[1]<<=4; } // low order bits unlikely 0 - mcell_ran4_init(xx.i[1]); + /* casts are trying to preserve (probably buggy) C behaviour in C++ */ + mcell_ran4_init((uint32_t)(uintptr_t)&xx.i[1]); mcell_ran4(&xx.i[0], &y, 1, big); // generate a pseudorand number based on these prod*=y; // keep multiplying these out } @@ -2025,7 +2027,8 @@ unsigned int hashseed2 (int na, double* x) { if (xx.i[0]==0) { xx.i[0]=xx.i[1]; xx.i[0]<<=4; } // high order bits may be 0 if (xx.i[1]==0) { xx.i[1]=xx.i[0]; xx.i[1]<<=4; } // low order bits unlikely 0 xx.i[0]+=(i+1); xx.i[1]+=(i+1); // so different for different order args - mcell_ran4_init(xx.i[1]); + /* casts are trying to preserve (probably buggy) C behaviour in C++ */ + mcell_ran4_init((uint32_t)(uintptr_t)&xx.i[1]); mcell_ran4(&xx.i[0], &y, 1, big); // generate a pseudorand number based on these while (y>UINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 valseed*=(unsigned int)y; // keep multiplying these out @@ -2091,7 +2094,8 @@ FUNCTION mc4seed () { for (i=2;ifarg(i);i++) { valseed*=(unsigned int)(*getarg(i)); } - mcell_ran4_init(valseed); // do initialization + /* casts are trying to preserve (probably buggy) C behaviour in C++ */ + mcell_ran4_init((uint32_t)(uintptr_t)&valseed); // do initialization return valseed; ENDVERBATIM } From a1d83b94ebf8d23286b8269d31abdd2c11fe7f5d Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Mon, 23 May 2022 11:01:13 +0200 Subject: [PATCH 17/23] reduce diff and preserve probably-buggy behaviour. --- intf_.mod | 39 +++++++++++++++++++++------------------ misc.mod | 14 +++++++++----- stats.mod | 3 +-- vecst.mod | 16 ++++++++-------- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/intf_.mod b/intf_.mod index ef45989..618eb2a 100644 --- a/intf_.mod +++ b/intf_.mod @@ -325,7 +325,8 @@ unsigned int GetDVIDSeedVal(unsigned int id) { } else { if (seadsetting==2) printf("Warning: GetDVIDSeedVal called with wt rand turned off\n"); x[0]=(double)id; x[1]=seaddvioff; - sead=hashseed2(2,x); + /* the cast is trying to preserve (probably buggy) C behaviour in C++ */ + sead=hashseed2(2, (double*)&x); } return sead; } @@ -350,7 +351,7 @@ ENDVERBATIM VERBATIM if (stopoq && !qsz()) stoprun=1; ip=IDP; pg=ip->pg; - if (ip->dead) return; + if (ip->dead) return; // this cell has died _ljcn=ip->jcn; _lid=ip->id; tpnt = _pnt; // this pnt if (PATHMEASURE) { // do all code for this @@ -416,7 +417,8 @@ ENDVERBATIM sead=(unsigned int)(floor(_lflag)*ip->id*seedstep); // all integers } else { // hash on presynaptic id+FOFFSET,poid,seedstep hsh[0]=floor(_lflag); hsh[1]=(double)ip->id; hsh[2]=seedstep; - sead=hashseed2(3,hsh); // hsh[] is just scratch pad + /* the cast is trying to preserve (probably buggy) C behaviour in C++ */ + sead=hashseed2(3,(double*)&hsh); // hsh[] is just scratch pad } mcell_ran4(&sead, &_args[sy], 2, 1.); for (ii=sy;iisprob[i]) (*pnt_receive[jp->dvi[i]->_prop->_type])(jp->dvi[i], wts, idty); _p=upnt->_prop->param; _ppvar=upnt->_prop->dparam; // restore pointers i++; - if (i>=jp->dvt) return 0; // ran out TODO:Ask Michel + if (i>=jp->dvt) return 0; // ran out ddel=jp->del[i]-del0; // delays are relative to event; use difference in delays } // skip over pruned outputs and dead cells: @@ -936,7 +938,7 @@ VERBATIM { int i,j,k,prty,poty,dv,dvt,dvii; double *x, *db, *dbs; Object *lb; Point_process *pnnt, **da, **das; ip=IDP; pg=ip->pg; // this should be called right after jitcondiv() - if (ip->dead) return 0; // TODO: Ask Michael + if (ip->dead) return 0; prty=ip->type; sead=GetDVIDSeedVal(ip->id);//seed for divergence and delays for (i=0,k=0,dvt=0;ipg; // this should be called right after jitcondiv() getactive=a2=a3=a4=0; - if (ip->dead) return 0; // TODO: Ask Michael + if (ip->dead) return 0; dvt=ip->dvt; dbs=ip->del; das=ip->dvi; _lgetdvi=(double)dvt; @@ -1097,7 +1099,8 @@ FUNCTION getdvi () { sead=(unsigned int)(FOFFSET+ip->id)*qp->id*seedstep; } else { // hashed sead setting hsh[0]=(double)(FOFFSET+ip->id); hsh[1]=(double)(qp->id); hsh[2]=seedstep; - sead=hashseed2(3,hsh); + /* the cast is trying to preserve (probably buggy) C behaviour in C++ */ + sead=hashseed2(3, (double*)&hsh); } mcell_ran4(&sead, y, 2, 1.); for(ii=0;ii<2;ii++) { @@ -1395,9 +1398,9 @@ ENDVERBATIM PROCEDURE setdvi () { VERBATIM { int i,dvt,flag; double *d, *y; - if (! ifarg(1)) {printf("setdvi(v1,v2[,flag]): v1:cell#s; v2:delays\n"); return 0; } // TODO: Ask Michael + if (! ifarg(1)) {printf("setdvi(v1,v2[,flag]): v1:cell#s; v2:delays\n"); return 0; } ip=IDP; pg=ip->pg; // this should be called right after jitcondiv() - if (ip->dead) return 0; // TODO: Ask Michael + if (ip->dead) return 0; dvt=vector_arg_px(1, &y); i=vector_arg_px(2, &d); if (ifarg(3)) flag=(int)*getarg(3); else flag=0; @@ -1460,7 +1463,7 @@ PROCEDURE prune () { printf("INTFpruneB:Div exceeds dscrsz: %d>%d\n",ip->dvt,dscrsz); hxe(); } if (p==0.) { for (j=0;jdvt;j++) ip->sprob[j]=1; // unprune completely - return 0; // now that unpruning is done, can return TODO: Ask Michael + return 0; // now that unpruning is done, can return } potype=ifarg(2)?(int)*getarg(2):-1; sead=(ifarg(3))?(unsigned int)*getarg(3):GetDVIDSeedVal(ip->id);//seed for divergence and delays @@ -1639,7 +1642,7 @@ PROCEDURE jitrec () { int i; if (! ifarg(2)) { // clear with jitrec() or jitrec(0) jrmax=0; jridv=0x0; jrtvv=0x0; - return 0; // TODO: Ask Michael + return 0; } i = vector_arg_px(1, &jrid); // could just set up the pointers once jrmax=vector_arg_px(2, &jrtv); @@ -1782,7 +1785,7 @@ PROCEDURE record () { VERBATIM { int i,j,k,nz; double ti; vp = SOP; - if (tg>=t) return 0; // TODO: Ask Michael + if (tg>=t) return 0; if (ip->record==1) { while ((int)vp->p >= (int)vp->size-(int)((t-tg)/vdt)-10) { vp->size*=2; @@ -1820,7 +1823,7 @@ PROCEDURE recspk (x) { VERBATIM { int k; vp = SOP; record(); - if (vp->p > vp->size || vp->vvo[6]==0) return 0; // TODO: Ask Michael + if (vp->p > vp->size || vp->vvo[6]==0) return 0; if (vp->vvo[0]!=0x0) vp->vvo[0][vp->p-1]=_lx; vp->vvo[6][vp->p-1]=spkht; // the spike tg=_lx; @@ -2318,7 +2321,7 @@ PROCEDURE wrecord (te) { wwo[wrp][k+j] += scale*_t_Psk[j+max]; // direct copy from the Psk table } } - } else if (twg>=t) { return 0; // TODO: Ask Michael + } else if (twg>=t) { return 0; } else { for (ti=twg,k=(int)floor((twg-rebeg)/vdt+0.5);ti<=t && kdbx==-1)printf("slowset fi:%d ix:%d ss:%g delt:%g t:%g\n",fi,ix,slowset,delt,t); if (t>slowset || ix>=cesz) { // done printf("Slow-setting of flag %d finished at %g: (%d,%g,%g)\n",fi,t,ix,delt,slowset); - slowset=0.; return 0; // TODO: Ask Michael + slowset=0.; return 0; } if (ix0 && ifarg(3)) { printf("INTF flag() slowset ERR; attempted set during slowset: fi:%d ix:%d ss:%g delt:%g t:%g",\ fi,ix,slowset,delt,t); - return 0; // TODO: Ask Michael + return 0; } ip = IDP; setfl=ifarg(3); if (ifarg(4)) { slowset=*getarg(4); delt=slowset/cesz; slowset+=t; } diff --git a/misc.mod b/misc.mod index 6c5600b..c5e97c5 100644 --- a/misc.mod +++ b/misc.mod @@ -92,12 +92,13 @@ VERBATIM if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - return 0; // TODO: Ask Michael + return 0; } if (fgets(string,BUFSIZ,pipein) == NULL) { fprintf(stderr,"System call did not return a string\n"); - pclose(pipein); return 0; // TODO: Ask Michael + pclose(pipein); + return 0; } /* assign_hoc_str(strname, string, 0); */ @@ -120,17 +121,20 @@ VERBATIM if ( !(outfile = fopen("dassign","w"))) { fprintf(stderr,"Can't open output file dassign\n"); - return 0; // TODO: Ask Michael + return 0; } if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - fclose(outfile); return 0; // TODO: Ask Michael + fclose(outfile); + return 0; } if (fscanf(pipein,"%lf",&num) != 1) { fprintf(stderr,"System call did not return a number\n"); - fclose(outfile); pclose(pipein); return 0; // TODO: Ask Michael + fclose(outfile); + pclose(pipein); + return 0; } fprintf(outfile,"%s=%g\n",strname,num); diff --git a/stats.mod b/stats.mod index c947b09..d4348b6 100644 --- a/stats.mod +++ b/stats.mod @@ -2123,7 +2123,7 @@ FUNCTION gammln (xx) { FUNCTION betai(a,b,x) { VERBATIM { double bt; - double gammln(double),betacf(double,double,double); + double betacf(double,double,double); if (_lx < 0.0 || _lx > 1.0) {printf("Bad x in routine BETAI\n"); hxe();} if (_lx == 0.0 || _lx == 1.0) bt=0.0; @@ -2197,7 +2197,6 @@ FUNCTION tstat() { FUNCTION tdistrib() { VERBATIM - double gammln(double); double x = *getarg(1); double dof = *getarg(2); double res = (gammln( (dof+1.0) / 2.0 ) / gammln( dof / 2.0 ) ); diff --git a/vecst.mod b/vecst.mod index 93a9dda..b6efa47 100644 --- a/vecst.mod +++ b/vecst.mod @@ -794,7 +794,7 @@ static double fread2 (void* vv) { } free((char *)xf); } else hoc_execerror("Type unsupported in fread2 ", 0); - return 0; // TODO: Shoulf we return 0 or 1? + return 0; } ENDVERBATIM @@ -816,7 +816,7 @@ static double revec (void* vv) { } } vector_resize((IvocVect*)vv,k); - return 0; // TODO: Shoulf we return 0 or 1? + return 0; } ENDVERBATIM @@ -919,7 +919,7 @@ static double vfill (void* vv) { nx = vector_instance_px(vv, &x); nv1 = vector_arg_px(1, &v1); for (i=0;i0 && k Date: Mon, 23 May 2022 17:03:42 +0200 Subject: [PATCH 18/23] Object member is called template in C in 8.2 --- vecst.mod | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vecst.mod b/vecst.mod index b6efa47..2e7fc83 100644 --- a/vecst.mod +++ b/vecst.mod @@ -2878,11 +2878,15 @@ FUNCTION isojt () { Object *ob1, *ob2; ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); if (!ob1) if (!ob2) return 1; else return 0; +#define ctemplate template #ifdef NRN_VERSION_GTEQ_8_2_0 - if (!ob2 || ob1->ctemplate != ob2->ctemplate) { -#else - if (!ob2 || ob1->template != ob2->template) { +#if NRN_VERSION_GTEQ(9, 0, 0) +#undef ctemplate +#define ctemplate ctemplate +#endif #endif + if (!ob2 || ob1->ctemplate != ob2->ctemplate) { +#undef ctemplate return 0; } return 1; From b5e40d6b97ef356ca0030976f406e0c74d753965 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 24 May 2022 11:00:17 +0200 Subject: [PATCH 19/23] Addressed Pramod's comments --- infot.mod | 4 ---- misc.mod | 2 +- updown.mod | 2 +- vecst.mod | 10 ++++------ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/infot.mod b/infot.mod index cdfd7e1..90af70d 100644 --- a/infot.mod +++ b/infot.mod @@ -34,10 +34,6 @@ static void pdfpr (double* pdf,int szp,int dim, char* name); static double tetrospks3 (double* X1d,double* X2d,double* X3d,double* XO,int szX1,int szXO,int shuf); static int dbxi[10]; -static double tetrospks2 (double* X1d,double* X2d,double* XO,int szX1,int szXO,int shuf); -static void pdfpr (double* pdf,int szp,int dim, char* name); -static double tetrospks3 (double* X1d,double* X2d,double* X3d,double* XO,int szX1,int szXO,int shuf); - typedef struct ITNode_ { int idims; int icount; diff --git a/misc.mod b/misc.mod index c5e97c5..9442107 100644 --- a/misc.mod +++ b/misc.mod @@ -48,7 +48,7 @@ VERBATIM #include #include #include -#include +#include "misc.h" extern int hoc_is_tempobj(int narg); ENDVERBATIM diff --git a/updown.mod b/updown.mod index 8ecd7dc..ec290b7 100644 --- a/updown.mod +++ b/updown.mod @@ -19,7 +19,7 @@ VERBATIM #include #include // contains LONG_MAX #include -#include +#include "misc.h" static void hxf(void *ptr) { free(ptr); hoc_execerror("",0); } ENDVERBATIM diff --git a/vecst.mod b/vecst.mod index 2e7fc83..a6c0170 100644 --- a/vecst.mod +++ b/vecst.mod @@ -325,7 +325,6 @@ ENDVERBATIM : uses ind as index into vecA's to load in vecB's (for select); a nondestructive fewind() VERBATIM static double findx (void* vv) { - IvocVect* vv_tmp = (IvocVect*)vv; int i, j, ni, nx, av[VRRY], bv[VRRY], num; Object *ob1, *ob2; double *ind, *avo[VRRY], *bvo[VRRY]; @@ -343,7 +342,7 @@ static double findx (void* vv) { } nx=av[0]; // size of source vecs for (i=0;i=end || beg<0 || end>nx) {printf("lma ERRC1 OOB %d - %d (%d)\n",beg,end,nx); hxe();} for (i=0;i0) { @@ -2410,8 +2408,8 @@ int openvec (int arg, double **y) { // vector_newsize() will also increase size of vector double *vector_newsize (IvocVect* vv, int n) { - vector_resize((IvocVect*)vv,n); - return vector_vec((IvocVect*)vv); + vector_resize(vv,n); + return vector_vec(vv); } ENDVERBATIM From 927bcdc570ef2f8d386a0d9b71d0da6fa6fc5fb6 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 12:50:35 +0200 Subject: [PATCH 20/23] mcell_ran4_init: pass a value --- stats.mod | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stats.mod b/stats.mod index d4348b6..6198ce2 100644 --- a/stats.mod +++ b/stats.mod @@ -861,8 +861,7 @@ static double hash (void* vv) { } else { xx.d=vvo[j][i]; } if (xx.i[0]==0) { xx.i[0]=xx.i[1]; xx.i[0]<<=4; } // high order bits may be 0 if (xx.i[1]==0) { xx.i[1]=xx.i[0]; xx.i[1]<<=4; } // low order bits unlikely 0 - /* casts are trying to preserve (probably buggy) C behaviour in C++ */ - mcell_ran4_init((uint32_t)(uintptr_t)&xx.i[1]); + mcell_ran4_init(xx.i[1]); mcell_ran4(&xx.i[0], &y, 1, big); // generate a pseudorand number based on these prod*=y; // keep multiplying these out } @@ -2027,8 +2026,7 @@ unsigned int hashseed2 (int na, double* x) { if (xx.i[0]==0) { xx.i[0]=xx.i[1]; xx.i[0]<<=4; } // high order bits may be 0 if (xx.i[1]==0) { xx.i[1]=xx.i[0]; xx.i[1]<<=4; } // low order bits unlikely 0 xx.i[0]+=(i+1); xx.i[1]+=(i+1); // so different for different order args - /* casts are trying to preserve (probably buggy) C behaviour in C++ */ - mcell_ran4_init((uint32_t)(uintptr_t)&xx.i[1]); + mcell_ran4_init(xx.i[1]); mcell_ran4(&xx.i[0], &y, 1, big); // generate a pseudorand number based on these while (y>UINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 valseed*=(unsigned int)y; // keep multiplying these out @@ -2094,8 +2092,7 @@ FUNCTION mc4seed () { for (i=2;ifarg(i);i++) { valseed*=(unsigned int)(*getarg(i)); } - /* casts are trying to preserve (probably buggy) C behaviour in C++ */ - mcell_ran4_init((uint32_t)(uintptr_t)&valseed); // do initialization + mcell_ran4_init(valseed); // do initialization return valseed; ENDVERBATIM } From 8978dccbb34cb7734417111eb0ed4f97e2387f51 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 12:54:06 +0200 Subject: [PATCH 21/23] mcell_ran4_init: update readme --- readme.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 567957f..9320e5e 100644 --- a/readme.txt +++ b/readme.txt @@ -64,4 +64,5 @@ Bill Lytton at billl at neurosim dot downstate dot edu Changelog -------------------------------------------------------------------------- 2022-05: Updated MOD files to contain valid C++ and be compatible with the - upcoming versions 8.2 and 9.0 of NEURON. + upcoming versions 8.2 and 9.0 of NEURON. Updated to use post ~2011 + signature of mcell_ran4_init function. From eeca94f9b239fcd1e21da3369155b8258892374e Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 14:08:44 +0200 Subject: [PATCH 22/23] hashseed2: probable bugfix --- intf_.mod | 9 +++------ readme.txt | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/intf_.mod b/intf_.mod index 618eb2a..7ff463c 100644 --- a/intf_.mod +++ b/intf_.mod @@ -325,8 +325,7 @@ unsigned int GetDVIDSeedVal(unsigned int id) { } else { if (seadsetting==2) printf("Warning: GetDVIDSeedVal called with wt rand turned off\n"); x[0]=(double)id; x[1]=seaddvioff; - /* the cast is trying to preserve (probably buggy) C behaviour in C++ */ - sead=hashseed2(2, (double*)&x); + sead=hashseed2(2, x); } return sead; } @@ -417,8 +416,7 @@ ENDVERBATIM sead=(unsigned int)(floor(_lflag)*ip->id*seedstep); // all integers } else { // hash on presynaptic id+FOFFSET,poid,seedstep hsh[0]=floor(_lflag); hsh[1]=(double)ip->id; hsh[2]=seedstep; - /* the cast is trying to preserve (probably buggy) C behaviour in C++ */ - sead=hashseed2(3,(double*)&hsh); // hsh[] is just scratch pad + sead=hashseed2(3, hsh); // hsh[] is just scratch pad } mcell_ran4(&sead, &_args[sy], 2, 1.); for (ii=sy;iiid)*qp->id*seedstep; } else { // hashed sead setting hsh[0]=(double)(FOFFSET+ip->id); hsh[1]=(double)(qp->id); hsh[2]=seedstep; - /* the cast is trying to preserve (probably buggy) C behaviour in C++ */ - sead=hashseed2(3, (double*)&hsh); + sead=hashseed2(3, hsh); } mcell_ran4(&sead, y, 2, 1.); for(ii=0;ii<2;ii++) { diff --git a/readme.txt b/readme.txt index 9320e5e..d4a6ab8 100644 --- a/readme.txt +++ b/readme.txt @@ -65,4 +65,4 @@ Bill Lytton at billl at neurosim dot downstate dot edu -------------------------------------------------------------------------- 2022-05: Updated MOD files to contain valid C++ and be compatible with the upcoming versions 8.2 and 9.0 of NEURON. Updated to use post ~2011 - signature of mcell_ran4_init function. + signature of mcell_ran4_init function and fix hashseed2 argument. From 65313b155a6a8b8fccac045c0e2d7434467ba865 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 14:13:20 +0200 Subject: [PATCH 23/23] cntpx -> cntpxy probable typo (compiler warning fix) --- infot.mod | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/infot.mod b/infot.mod index 90af70d..c09e496 100644 --- a/infot.mod +++ b/infot.mod @@ -413,8 +413,7 @@ double tentropd (double* x,double* y,int iLen,int nbins,int xpast,int ypast,int dsum=0.0; *sig=-1e6;//init sig to neg *nTE = 0.0; - /* 2nd cntpx should be cntpxy? */ - sh=cntjxy=cntjx=cntpx=cntpx=0; teavg=testd=te=teout=0.0; + sh=cntjxy=cntjx=cntpx=cntpxy=0; teavg=testd=te=teout=0.0; px = nbins>0 ? getnormd(x,iLen,nbins) : doublep2intp(x,iLen); //discretize x to nbins, or just copy to ints py = nbins>0 ? getnormd(y,iLen,nbins) : doublep2intp(y,iLen); //discretize y to nbins, or just copy to ints