From cb7243a0765b49a05717bee91b5e8217d347afe9 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Mon, 16 May 2022 18:14:10 +0200 Subject: [PATCH 01/17] Fixing intf6_.mod for NEURON 9.0.0, 8.2.0, 8.1.0 --- intf6_.mod | 55 +++++++++++++++++++++++++++--------------------------- misc.h | 44 ++++++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 46 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index ef94b79..84741a2 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -51,7 +51,7 @@ typedef struct VPT { unsigned int id; unsigned int size; unsigned int p; - void* vv[NSV]; + IvocVect* vv[NSV]; double* vvo[NSV]; } vpt; @@ -62,8 +62,8 @@ typedef struct POSTGRP { // postsynaptic group unsigned int col; // COLUMN ID double* jrid; // for recording SPIKES double* jrtv; - void* jridv; - void* jrtvv; + IvocVect* jridv; + IvocVect* jrtvv; unsigned int jtpt,jtmax,jrmax; unsigned long jri,jrj; unsigned long spktot,eventtot; @@ -150,7 +150,7 @@ static int cty[CTYPp], process, ctymap[CTYPp]; 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, AM2=4, NM2=5, GA2=6, SU=3, IN=4, DP=2; // from labels.hoc static double wts[13],hsh[13]; // for jitcons to use as a junk pointer @@ -284,7 +284,7 @@ CONSTRUCTOR { if (ifarg(2)) { lty=(int) *getarg(2); } else { lty= -1; } // type if (ifarg(3)) { lin=(int) *getarg(3); } else { lin= -1; } // inhib if (ifarg(4)) { lco=(int) *getarg(4); } else { lco= -1; } // column - _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; ip->syns=0x0; ip->wgain=0x0; ip->peconv=0x0; ip->syw1 = ip->syw2 = 0x0; @@ -295,7 +295,7 @@ CONSTRUCTOR { pathbeg=-1; slowset=0; ip->gid = nextGID++; // global identifier - process=(int)getpid(); + process=hoc_pid(); CNAME[SU]="SU"; CNAME[DP]="DP"; CNAME[IN]="IN"; if (installed==2.0 && ip->pg) { // jitcondiv was previously run sz=ivoc_list_count(ip->pg->ce); @@ -1313,7 +1313,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 only be called after jitcondiv() sz=ip->dvt; // // assume conv similar to div getactive=0; @@ -1407,11 +1407,12 @@ FUNCTION rddvi () { for(iCell=0;iCellcesz;iCell++){ if(iCell%1000==0)printf("%d ",iCell); lop(pg->ce,iCell); - fread(&qp->id,sizeof(unsigned int),1,fp); // read id - fread(&qp->type,sizeof(unsigned char),1,fp); // read type id - fread(&qp->col,sizeof(unsigned int),1,fp); // read column id - fread(&qp->dead,sizeof(unsigned char),1,fp); // read alive/dead status - fread(&qp->dvt,sizeof(unsigned int),1,fp); // read divergence size + int ret; + ret = fread(&qp->id,sizeof(unsigned int),1,fp); // read id + ret = fread(&qp->type,sizeof(unsigned char),1,fp); // read type id + ret = fread(&qp->col,sizeof(unsigned int),1,fp); // read column id + ret = fread(&qp->dead,sizeof(unsigned char),1,fp); // read alive/dead status + ret = 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; } @@ -1419,15 +1420,15 @@ FUNCTION rddvi () { if(!qp->dvt) continue; qp->dvi = (Point_process**)malloc(sizeof(Point_process*)*qp->dvt); for(i=0;idvt;i++){ - fread(&iOutID,sizeof(unsigned int),1,fp); // id of output cell + ret = fread(&iOutID,sizeof(unsigned int),1,fp); // id of output cell if (!(lb=ivoc_list_item(pg->ce,iOutID))) { printf("INTF6:callback %d exceeds %d for list ce\n",iOutID,pg->cesz); hxe(); } qp->dvi[i]=(Point_process *)lb->u.this_pointer; } qp->del = (double*)malloc(sizeof(double)*qp->dvt); - fread(qp->del,sizeof(double),qp->dvt,fp); // read divergence delays + ret = fread(qp->del,sizeof(double),qp->dvt,fp); // read divergence delays qp->sprob = (unsigned char*)malloc(sizeof(unsigned char)*qp->dvt); - fread(qp->sprob,sizeof(unsigned char),qp->dvt,fp); // read divergence firing probabilities + ret = fread(qp->sprob,sizeof(unsigned char),qp->dvt,fp); // read divergence firing probabilities } printf("\n"); return 1.0; @@ -2475,7 +2476,7 @@ 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); @@ -2583,13 +2584,13 @@ PROCEDURE chk (f) { if (SOP!=nil) { vp = SOP; printf("p %d size %d tg %g\n",vp->p,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 %p %p;",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 (pg->vsp!=nil) printf("VSP: %x (%d/%d-%d)\n",(unsigned int)pg->vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); - if (jsp!=nil) printf("JSP: %x (%d/%d)\n",(unsigned int)jsp,pg->jtpt,pg->jtmax); else printf("no JSP\n"); + if (pg->vsp!=nil) printf("VSP: %p (%d/%d-%d)\n",pg->vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); + if (jsp!=nil) printf("JSP: %p (%d/%d)\n",jsp,pg->jtpt,pg->jtmax); else printf("no JSP\n"); } if (lfg==3) { if (pg->vsp!=nil) { printf("VSP: (%d/%d-%d)\n",ip->rvi,ip->rvb,ip->rve); @@ -2602,7 +2603,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;i=t) { return; + } else if (twg>=t) { return 0; } else { for (ti=twg,k=(int)floor((twg-rebeg)/vdt+0.5);ti<=t && kpg; if (FLAG==OK) { // callback -- DO NOT SET FROM HOC FLAG=0.; - if (stoprun) {slowset=0; return;} + if (stoprun) {slowset=0; return 0.0;} if (IDP->dbx==-1)printf("slowset fi:%d ix:%d ss:%g delt:%g t:%g\n",fi,ix,slowset,delt,t); if (t>slowset || ix>=pg->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.0; } if (ixcesz) { lop(pg->ce,ix); @@ -2964,12 +2965,12 @@ FUNCTION flag () { net_send((void**)0x0, wts,tpnt,delt,OK); #endif } - return; + return 0.0; } if (slowset>0 && ifarg(3)) { printf("INTF6 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.0; } ip = IDP; setfl=ifarg(3); if (ifarg(4)) { slowset=*getarg(4); delt=slowset/pg->cesz; slowset+=t; } @@ -3017,7 +3018,7 @@ FUNCTION flag () { FUNCTION allspck () { VERBATIM - int i; double *x, sum; void *voi; + int i; double *x, sum; IvocVect *voi; ip = IDP; pg=ip->pg; voi=vector_arg(1); x=vector_newsize(voi,pg->cesz); for (i=0,sum=0;icesz;i++) { lop(pg->ce,i); @@ -3045,7 +3046,7 @@ PROCEDURE resetall () { :** floc(x,y[,z]) // find a cell by location FUNCTION floc () { VERBATIM - double x,y,z,r,min,rad, *ix; int ii,i,n,cnt; void* voi; + double x,y,z,r,min,rad, *ix; int ii,i,n,cnt; IvocVect* voi; cnt=0; n=1000; r=-1; ip = IDP; pg=ip->pg; x = *getarg(1); diff --git a/misc.h b/misc.h index f66c830..d68ffda 100644 --- a/misc.h +++ b/misc.h @@ -62,17 +62,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 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 +76,12 @@ 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); @@ -105,10 +91,32 @@ 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(); +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 +124,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; From 63f5b1e220c6806e4c421a16f8d1869913415251 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 16:21:38 +0200 Subject: [PATCH 02/17] Fix intf_6.mod for 9.0.0 and 8.1.0 --- intf6_.mod | 78 ++++++++++++++++++++++++++++++------------------------ misc.h | 7 ++--- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index 84741a2..9b1696f 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -26,6 +26,8 @@ VERBATIM static int ctt(unsigned int, char**); static int setdvi2(double*,double*,char*,int,int); +void gsort3 (double *, Point_process **, char*, int, double *, Point_process **,char*); +void gsort2 (double *, Point_process **, int, double *, Point_process **); #define PI 3.14159265358979323846264338327950288419716939937510 #define nil 0 @@ -154,7 +156,7 @@ IvocVect* ww[NSW]; double* wwo[NSW]; static int AM=0, NM=1, GA=2, GB=3, AM2=4, NM2=5, GA2=6, SU=3, IN=4, DP=2; // from labels.hoc static double wts[13],hsh[13]; // for jitcons to use as a junk pointer -static int spkoutf2(); +static void spkoutf2(); ENDVERBATIM :* NEURON, PARAMETER, ASSIGNED blocks @@ -375,7 +377,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; - sead=hashseed2(2,&x); + sead=hashseed2(2,x); } return sead; } @@ -509,7 +511,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; - 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;ii=qlimit) { printf("qlimit %g exceeded at t=%g\n",qlimit,t); qlimit*=2; } ip=IDP; pg=ip->pg; @@ -1014,7 +1016,7 @@ ENDVERBATIM } VERBATIM -static int spkoutf2 () { +static void spkoutf2 () { fprintf(wf1,"//b9 -2 t%0.2f %ld %ld\n",t/1e3,pg->jrj,ftell(wf2)); fwrite(pg->jrtv,sizeof(double),pg->jrj,wf2); // write times fwrite(pg->jrid,sizeof(double),pg->jrj,wf2); // write id @@ -1096,7 +1098,7 @@ PROCEDURE callback (fl) { if (jp->sprob[i]) (*pnt_receive[jp->dvi[i]->_prop->_type])(jp->dvi[i], wts, idtflg); _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 ddel=jp->del[i]-del0; // delays are relative to event; use difference in delays } // skip over pruned outputs and dead cells: @@ -1120,7 +1122,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 only be called after jitcondiv() - if (ip->dead) return; + 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; getactive=a2=a3=a4=0; - if (ip->dead) return; + if (ip->dead) return 0.0; dvt=ip->dvt; dbs=ip->del; das=ip->dvi; _lgetdvi=(double)dvt; @@ -1289,7 +1291,7 @@ 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); + sead=hashseed2(3,hsh); } mcell_ran4(&sead, y, 2, 1.); for(ii=0;ii<2;ii++) { @@ -1415,7 +1417,7 @@ FUNCTION rddvi () { ret = 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); @@ -1521,7 +1523,7 @@ PROCEDURE clrdvi () { lop(pg->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 @@ -1669,7 +1671,7 @@ ENDVERBATIM : intf.geteconv(vec) - get presynaptic E cell IDs FUNCTION geteconv () { VERBATIM - int i; double *x; void *voi; + int i; double *x; IvocVect *voi; ip=IDP; pg=ip->pg; if(!ip->peconv) ip->peconv=getpeconv(ip,&ip->econvsz); voi=vector_arg(1); @@ -1681,7 +1683,7 @@ FUNCTION geteconv () { : 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; char *syns,*synss; @@ -1727,9 +1729,9 @@ ENDVERBATIM PROCEDURE setdvi () { VERBATIM { int i,j,k,dvt,flag; double *d, *y, *ds; char* s; - if (! ifarg(1)) {printf("setdvi(v1,v2[,v3,flag]): v1:cell#s; v2:delays; v3:distal synapses\n"); return; } + if (! ifarg(1)) {printf("setdvi(v1,v2[,v3,flag]): v1:cell#s; v2:delays; v3:distal synapses\n"); return 0; } ip=IDP; pg=ip->pg; // this should only be called after jitcondiv() - if (ip->dead) return; + if (ip->dead) return 0; dvt=vector_arg_px(1, &y); i=vector_arg_px(2, &d); s=ifarg(3)?(char*)calloc((j=vector_arg_px(3,&ds)),sizeof(char)):0x0; @@ -1738,6 +1740,7 @@ VERBATIM { if (i!=dvt || i==0 || (j>0 && j!=i)) {printf("setdvi() ERR vec sizes: %d %d %d\n",dvt,i,j); hxe();} setdvi2(y,d,s,dvt,flag); } + return 0; ENDVERBATIM } @@ -1752,13 +1755,13 @@ static int setdvi2 (double *y,double *d,char* s,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); free(ip->syns); - ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(char *)0x0; ip->syns=(char*)0x0; + ip->dvt=0; ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0; ip->syns=(char*)0x0; if(ip->wgain){free(ip->wgain); ip->wgain=0x0;} if(ip->peconv){free(ip->peconv); ip->peconv=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; ip->syns=(char*)0x0; + ip->dvi=(Point_process**)0x0; ip->del=(double*)0x0; ip->sprob=(unsigned char *)0x0; ip->syns=(char*)0x0; ip->wgain=0x0; ip->peconv=0x0; } b=ip->dvt; @@ -1783,6 +1786,7 @@ static int setdvi2 (double *y,double *d,char* s,int dvt,int flag) { } ip->dvt=dvt; ip->del=db; ip->dvi=da; ip->syns=syns; if (flag!=1) finishdvi2(ip); // do sort + return 0; } ENDVERBATIM @@ -1796,12 +1800,12 @@ PROCEDURE prune () { if (hoc_is_double_arg(1)) { // prune a certain percent of targets p=*getarg(1); if (p<0 || p>1) {printf("INTF6:pruneERR0:need # [0,1] to prune [ALL,NONE]: %g\n",p); hxe();} - if (p==1.) printf("INTF6pruneWARNING: pruning 100% of cell %d\n",ip->id); + if (p==1.) printf("INTF6pruneWARNING: pruning 100%% of cell %d\n",ip->id); if (verbose && ip->dvt>dscrsz) { printf("INTF6pruneB: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 } potype=ifarg(2)?(int)*getarg(2):-1; sead=(ifarg(3))?(unsigned int)*getarg(3):GetDVIDSeedVal(ip->id);//seed for divergence and delays @@ -1821,6 +1825,7 @@ PROCEDURE prune () { for (j=0;jdvt;j++) ip->sprob[j]=(unsigned char)x[j]; } } + return 0; ENDVERBATIM } @@ -1869,22 +1874,22 @@ 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;idvi); free(jp->del); free(jp->sprob); free(jp->syns); if(jp->wgain){free(jp->wgain); jp->wgain=0x0;} if(jp->peconv){free(jp->peconv); jp->peconv=0x0;} - jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(char *)0x0; jp->syns=(char *)0x0; + jp->dvt=0; jp->dvi=(Point_process**)0x0; jp->del=(double*)0x0; jp->sprob=(unsigned char *)0x0; jp->syns=(char *)0x0; } } ENDVERBATIM @@ -1914,10 +1919,10 @@ FUNCTION qstats () { if (ifarg(1)) {tfo=hoc_obj_file_arg(1); flag=1;} else flag=0; lct=cty[IDP->type]; _lqstats = nrn_event_queue_stats(stt); - printf("SPIKES: %d (%ld:%ld)\n",IDP->spkcnt,spikes[lct],blockcnt[lct]); + printf("SPIKES: %d (%u:%u)\n",IDP->spkcnt,spikes[lct],blockcnt[lct]); printf("QUEUE: Inserted %g; removed %g\n",stt[0],stt[2]); if (flag) { - fprintf(tfo,"SPIKES: %d (%ld:%ld);",IDP->spkcnt,spikes[lct],blockcnt[lct]); + fprintf(tfo,"SPIKES: %d (%u:%u);",IDP->spkcnt,spikes[lct],blockcnt[lct]); fprintf(tfo,"QUEUE: Inserted %g; removed %g remaining: %g\n",stt[0],stt[2],_lqstats); } } @@ -1991,7 +1996,7 @@ PROCEDURE jitcondiv () { if(colid >= ippgbufsz) { // need more memory? then realloc ippgbufsz *= 2; - ppg = realloc((void*)ppg,(size_t)ippgbufsz*sizeof(postgrp*)); + ppg = (postgrp**) realloc((void*)ppg,(size_t)ippgbufsz*sizeof(postgrp*)); } ppg[colid] = pg; pg->col = colid; @@ -2005,7 +2010,7 @@ PROCEDURE jitcondiv () { if (sz==pg->cesz && colid==0) printf("\t**** INTF6 WARNING cesz unchanged: INTF6(s) created off-list ****\n"); } else installed=2.0; pg->cesz = ivoc_list_count(pg->ce); if(verbose) printf("cesz=%d\n",pg->cesz); - pg->lastspk = calloc(pg->cesz,sizeof(double)); // last spike time of each cell + pg->lastspk = (double*)calloc(pg->cesz,sizeof(double)); // last spike time of each cell // not column specific CTYPi=HVAL("CTYPi"); STYPi=HVAL("STYPi"); dscrsz=HVAL("scrsz"); dscr=HPTR("scr"); @@ -2055,7 +2060,7 @@ PROCEDURE jitrec () { if(verbose>1) printf("jitrec from col %d, ip=%p, pg=%p\n",ip->col,ip,pg); if (! ifarg(2)) { // clear with jitrec() or jitrec(0) pg->jrmax=0; pg->jridv=0x0; pg->jrtvv=0x0; - return; + return 0; } i = vector_arg_px(1, &pg->jrid); // could just set up the pointers once pg->jrmax=vector_arg_px(2, &pg->jrtv); @@ -2065,6 +2070,7 @@ PROCEDURE jitrec () { printf("jitrec() ERRA: not same size: %d %d\n",i,pg->jrmax); pg->jrmax=0; hxe(); } pg->jri=pg->jrj=0; // needs to be set at beginning of run } + return 0; ENDVERBATIM } @@ -2171,7 +2177,7 @@ PROCEDURE vers () { :** val(t,tstart) fills global vii[] to pass values back to record() (called from record()) VERBATIM -double val (double xx, double ta) { +void val (double xx, double ta) { vii[1]=VAM*EXP(-(xx - ta)/tauAM); vii[2]=VNM*EXP(-(xx - ta)/tauNM); vii[3]=VGA*EXP(-(xx - ta)/tauGA); @@ -2187,7 +2193,7 @@ ENDVERBATIM :** valps(t,tstart) like val but builds voltages for pop spike VERBATIM -double valps (double xx, double ta) { +void valps (double xx, double ta) { vii[1]=VAM*EXP(-(xx - ta)/tauAM); vii[2]=VNM*EXP(-(xx - ta)/tauNM); vii[3]=VGA*EXP(-(xx - ta)/tauGA); @@ -2204,8 +2210,8 @@ PROCEDURE record () { VERBATIM { int i,j,k,nz; double ti; vp = SOP; - if(!vp) {printf("**** record ERRA: vp=NULL!\n"); return;} - if (tg>=t) return; + if(!vp) {printf("**** record ERRA: vp=NULL!\n"); return 0;} + if (tg>=t) return 0; if (ip->record==1) { while ((int)vp->p >= (int)vp->size-(int)((t-tg)/vdt)-10) { vp->size*=2; @@ -2243,7 +2249,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; if (vp->vvo[0]!=0x0) vp->vvo[0][vp->p-1]=_lx; vp->vvo[6][vp->p-1]=spkht; // the spike tg=_lx; @@ -2451,6 +2457,7 @@ static void lop (Object *ob, unsigned int i) { // use stoppo() as a convenient conditional breakpoint in gdb (gdb watching is too slow) int stoppo () { + return 0; } //** ctt(ITEM#) find cells that exist by name @@ -2782,6 +2789,7 @@ PROCEDURE wrecord (te) { } if (_lte==1.e9) twg=ti; } + return 0; ENDVERBATIM } diff --git a/misc.h b/misc.h index d68ffda..4f0272b 100644 --- a/misc.h +++ b/misc.h @@ -64,6 +64,7 @@ extern double EQV,EQW,EQX,NEQ,SEQ,RXP,IBE,EBI,IBI,EBE; extern double *vector_newsize (IvocVect* vv, int n); #ifndef NRN_VERSION_GTEQ_8_2_0 +extern void cvode_fadvance(double); extern double* hoc_pgetarg(); extern void hoc_notify_iv(); extern double hoc_call_func(Symbol*, int narg); @@ -79,7 +80,7 @@ extern int vector_buffer_size(void*); 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 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); @@ -113,9 +114,9 @@ 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 cmpdfn(double a, double b); extern int openvec(int, double **); -int list_vector_px(); +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); From 3e9c1cad2a2781baf85dbfa19f0e8660731c4bb5 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 16:31:31 +0200 Subject: [PATCH 03/17] Fix intf6_.mod for 8.2.0 and the other NEURON versions --- misc.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/misc.h b/misc.h index 4f0272b..d06e9d0 100644 --- a/misc.h +++ b/misc.h @@ -64,7 +64,6 @@ extern double EQV,EQW,EQX,NEQ,SEQ,RXP,IBE,EBI,IBI,EBE; extern double *vector_newsize (IvocVect* vv, int n); #ifndef NRN_VERSION_GTEQ_8_2_0 -extern void cvode_fadvance(double); extern double* hoc_pgetarg(); extern void hoc_notify_iv(); extern double hoc_call_func(Symbol*, int narg); @@ -79,22 +78,23 @@ extern double* vector_vec(); extern int vector_buffer_size(void*); 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(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); 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 double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); +extern void cvode_fadvance(double); +extern Object* ivoc_list_item(Object*, int); +extern void clear_event_queue(); +extern Symbol *hoc_get_symbol(char *); extern unsigned int hashseed2 (int na, double* x); extern unsigned int dcrsz; extern double *dcr; From d3d2c6b3c4f8eb8f7d05933c9b40053e8b7dd67e Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 16:38:15 +0200 Subject: [PATCH 04/17] Revert change of getpid() --- intf6_.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intf6_.mod b/intf6_.mod index 9b1696f..db17906 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -23,6 +23,7 @@ ENDCOMMENT VERBATIM #include "misc.h" +#include "unistd.h" static int ctt(unsigned int, char**); static int setdvi2(double*,double*,char*,int,int); @@ -297,7 +298,7 @@ CONSTRUCTOR { pathbeg=-1; slowset=0; ip->gid = nextGID++; // global identifier - process=hoc_pid(); + process=(int)getpid(); CNAME[SU]="SU"; CNAME[DP]="DP"; CNAME[IN]="IN"; if (installed==2.0 && ip->pg) { // jitcondiv was previously run sz=ivoc_list_count(ip->pg->ce); From f0b462428732ae21b03dd0d1c20ea923c8834e64 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 17:04:53 +0200 Subject: [PATCH 05/17] Reverting back some changes --- intf6_.mod | 9 ++++----- misc.h | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index db17906..769d0a6 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -26,7 +26,7 @@ VERBATIM #include "unistd.h" static int ctt(unsigned int, char**); -static int setdvi2(double*,double*,char*,int,int); +static void setdvi2(double*,double*,char*,int,int); void gsort3 (double *, Point_process **, char*, int, double *, Point_process **,char*); void gsort2 (double *, Point_process **, int, double *, Point_process **); @@ -1748,7 +1748,7 @@ ENDVERBATIM VERBATIM // setdvi2(divid_vec,del_vec,syns_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,char* s,int dvt,int flag) { +static void setdvi2 (double *y,double *d,char* s,int dvt,int flag) { int i,j,ddvi; double *db, *dbs; unsigned char pdead; unsigned int b,e; char* syns; Object *lb; Point_process *pnnt, **da, **das; ddvi=(int)DEAD_DIV; @@ -1787,7 +1787,6 @@ static int setdvi2 (double *y,double *d,char* s,int dvt,int flag) { } ip->dvt=dvt; ip->del=db; ip->dvi=da; ip->syns=syns; if (flag!=1) finishdvi2(ip); // do sort - return 0; } ENDVERBATIM @@ -1920,10 +1919,10 @@ FUNCTION qstats () { if (ifarg(1)) {tfo=hoc_obj_file_arg(1); flag=1;} else flag=0; lct=cty[IDP->type]; _lqstats = nrn_event_queue_stats(stt); - printf("SPIKES: %d (%u:%u)\n",IDP->spkcnt,spikes[lct],blockcnt[lct]); + printf("SPIKES: %d (%ld:%ld)\n",IDP->spkcnt,spikes[lct],blockcnt[lct]); printf("QUEUE: Inserted %g; removed %g\n",stt[0],stt[2]); if (flag) { - fprintf(tfo,"SPIKES: %d (%u:%u);",IDP->spkcnt,spikes[lct],blockcnt[lct]); + fprintf(tfo,"SPIKES: %d (%ld:%ld);",IDP->spkcnt,spikes[lct],blockcnt[lct]); fprintf(tfo,"QUEUE: Inserted %g; removed %g remaining: %g\n",stt[0],stt[2],_lqstats); } } diff --git a/misc.h b/misc.h index d06e9d0..433a18d 100644 --- a/misc.h +++ b/misc.h @@ -76,7 +76,6 @@ extern int vector_instance_px(); extern void* vector_arg(); extern double* vector_vec(); extern int vector_buffer_size(void*); -extern unsigned int valseed; extern void mcell_ran4_init(unsigned int *idum); extern int nrn_mlh_gsort(double* vec, int* base_ptr, int total_elems, int (*cmp)(double, double)); extern int ivoc_list_count(Object*); From 5f9d9a5fc10d19626147dff9a2c7aa0b880372ef Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 17:27:15 +0200 Subject: [PATCH 06/17] Improved stoppo --- intf6_.mod | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index 769d0a6..1b23ffd 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -2456,8 +2456,7 @@ static void lop (Object *ob, unsigned int i) { } // use stoppo() as a convenient conditional breakpoint in gdb (gdb watching is too slow) -int stoppo () { - return 0; +void stoppo () { } //** ctt(ITEM#) find cells that exist by name From 08bd11ad7bd2366ff26bf5657e07e8130aedf449 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Tue, 17 May 2022 18:04:56 +0200 Subject: [PATCH 07/17] Added changelog in readme --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 5dee95e..9e0cce8 100644 --- a/readme.txt +++ b/readme.txt @@ -70,3 +70,4 @@ http://www.frontiersin.org/Computational_Neuroscience/10.3389/fncom.2011.00019/a 20110418 Updated to run on mswin. -ModelDB Administrator 20110419 Additional button window for autolaunch. -ModelDB Administrator 20111219 readme reformatted. -ModelDB Administrator +20220517 Edited intf_6.mod and misc.h to support NEURON versions <8.1.0, 8.2.0 and 9.0.0. -NEURON Developers \ No newline at end of file From 2a87f4a521623b3f20abdb8ebbdbe61620430e5f Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Wed, 18 May 2022 17:48:39 +0200 Subject: [PATCH 08/17] Fixed vecst.mod --- vecst.mod | 310 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 163 insertions(+), 147 deletions(-) diff --git a/vecst.mod b/vecst.mod index e8322f7..d3a7bc4 100644 --- a/vecst.mod +++ b/vecst.mod @@ -1,4 +1,4 @@ -: $Id: vecst.mod,v 1.496 2011/01/26 01:58:44 samn Exp $ +: $Id: vecst.mod,v 1.491 2010/07/21 15:00:19 billl Exp $ :* COMMENT COMMENT @@ -107,6 +107,9 @@ ENDVERBATIM VERBATIM // Maintain parallel int vector to avoid slowness of repeated casts int cmpdfn (double a, double b) {return ((a)<=(b))?(((a) == (b))?0:-1):1;} +int IsObj (Object* p,char* s); +int IsList (Object* p){return IsObj(p,"List"); } +int list_vector_px4 (Object *ob, int i, double** px, unsigned int n); static unsigned int bufsz=0; unsigned int scrsz=0; unsigned int *scr=0x0; @@ -149,8 +152,8 @@ VERBATIM 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); + bsz=vector_buffer_size((IvocVect*)vv); + printf("Obj*%x Dbl*%x Size: %d Bufsize: %d\n",vv,x,nx,bsz); return (double)nx; } ENDVERBATIM @@ -228,7 +231,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 +240,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 +373,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 +400,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 %d :: ",n,nx); hoc_execerror("Vector max capacity too small for ird ", 0); @@ -755,19 +760,19 @@ VERBATIM static double fread2 (void* vv) { int i, j, nx, n, type, maxsz; size_t r; double *x; - FILE* fp, *hoc_obj_file_arg(); + FILE* fp; BYTEHEADER 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 +799,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 @@ -801,20 +807,21 @@ ENDVERBATIM VERBATIM static double revec (void* vv) { int i,j,k, nx, ny; double *x, *y; - nx = vector_instance_px(vv, &x); - if (nx==0) x=vector_newsize(vv,nx=100); + nx = vector_instance_px((IvocVect*)vv, &x); + if (nx==0) x=vector_newsize((IvocVect*)vv,nx=100); for (i=1,k=0;ifarg(i);i++,k++) { if (hoc_is_double_arg(i)) { - if (k>=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;j0) 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 @@ -853,17 +860,17 @@ VERBATIM static double insct (void* vv) { int i, j, k, nx, nv1, nv2, maxsz; double *x, *v1, *v2; - nx = vector_instance_px(vv, &x); + nx = vector_instance_px((IvocVect*)vv, &x); if (maxsz==0) maxsz=1000; - maxsz=vector_buffer_size(vv); - x=vector_newsize(vv, maxsz); + maxsz=vector_buffer_size((IvocVect*)vv); + x=vector_newsize((IvocVect*)vv, maxsz); nv1 = vector_arg_px(1, &v1); nv2 = vector_arg_px(2, &v2); for (i=0,k=0;iisz;iv++) { @@ -897,13 +904,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 @@ -917,6 +924,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: %dVRRY) 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 && k0 && 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++; @@ -1397,14 +1409,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; imaxsz) {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;ith) { up=1; - if (cnt>=nv) x=vector_newsize(vv,(n+=100)); + if (cnt>=nv) x=vector_newsize((IvocVect*)vv,(n+=100)); x[cnt++]=(double)i; } } - x=vector_newsize(vv,cnt); + x=vector_newsize((IvocVect*)vv,cnt); return (double)cnt; } ENDVERBATIM @@ -1720,10 +1733,10 @@ ENDVERBATIM VERBATIM static double peak (void* vv) { int i, n, nc, ny, up, cnt; - double *x, *y, *vc, last; void* vy; + double *x, *y, *vc, last; IvocVect* vy; n = vector_instance_px(vv, &x); // for indices nc = vector_arg_px(1, &vc); // source vectors - if (n==0) x=vector_newsize(vv,n=100); + if (n==0) x=vector_newsize((IvocVect*)vv,n=100); if (ifarg(2)) y=vector_newsize(vy=vector_arg(2),ny=n); else ny=0; // same size as v1 if (vc[1]-vc[0]<0) up=0; else up=1; // F or T last=vc[1]; @@ -1731,7 +1744,7 @@ static double peak (void* vv) { if (up) { // look for starting down if (vc[i]-last<0) { up=0; - if (cnt>=n) { x=vector_newsize(vv,(n+=100)); + if (cnt>=n) { x=vector_newsize((IvocVect*)vv,(n+=100)); if (ny) y=vector_newsize(vy,n);} x[cnt]=(double)(i-1); if (ny) y[cnt]=last; @@ -1740,7 +1753,7 @@ static double peak (void* vv) { } else if (vc[i]-last>0) up=1; last=vc[i]; } - x=vector_newsize(vv,cnt); + x=vector_newsize((IvocVect*)vv,cnt); if (ny) y=vector_newsize(vy,cnt); return (double)cnt; } @@ -1837,11 +1850,11 @@ VERBATIM static double l2p (void* vv) { int ix, i, j, n, num, cnt; double *x, *y; Object* lob; - n = vector_instance_px(vv, &x); + n = vector_instance_px((IvocVect*)vv, &x); lob = *hoc_objgetarg(1); ix=(int)*getarg(2); num = ivoc_list_count(lob); - x=vector_newsize(vv,num); + x=vector_newsize((IvocVect*)vv,num); for (i=0;i=cnt) {printf("vecst:l2p() ERRA: %d %d %d\n",i,ix,cnt); hxe();} @@ -1869,9 +1882,9 @@ static double fetch (void* vv) { if (ix==n) {if (VERBOSE_VECST) printf("vecst:fetch() WARNING: %g not found\n",val); return ERR;} if (hoc_is_object_arg(3)) { 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 + 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,(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++; @@ -1880,7 +1893,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++; @@ -2005,9 +2018,9 @@ 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 + 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; } //* 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; + sz = vector_capacity((IvocVect*)obv->u.this_pointer); + *px = vector_vec((IvocVect*)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; + 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; } @@ -2161,14 +2174,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; } @@ -2177,8 +2190,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 @@ -2268,7 +2281,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;} @@ -2297,7 +2310,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) { @@ -2388,6 +2389,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; @@ -2428,16 +2441,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 (void* vv, int n) { - vector_resize(vv,n); - return vector_vec(vv); +double *vector_newsize (IvocVect* vv, int n) { + vector_resize((IvocVect*)vv,n); + return vector_vec((IvocVect*)vv); } ENDVERBATIM @@ -2461,7 +2474,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 @@ -2514,9 +2527,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); @@ -2564,9 +2577,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); @@ -2589,12 +2602,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;iscrsz*sizeof(int)) { if (scrsz>0) { free(scr); scr=(unsigned int *)NULL; } scr=(unsigned int *)ecalloc(1, sz); @@ -2802,7 +2815,7 @@ static double rdfile (void* vv) { i+=(vsz*sizeof(short)); } else printf("rdfile() type %d not implemented\n",ty); } - if (vflag) vector_resize(vector_arg(2), k); + if (vflag) vector_resize((IvocVect*)vector_arg(2), k); if (scrsz>1e7) { free(scr); scr=(unsigned int *)NULL; scrsz=0; } return (double)num; } @@ -2905,7 +2918,11 @@ FUNCTION isojt () { Object *ob1, *ob2; ob1 = *hoc_objgetarg(1); ob2 = *hoc_objgetarg(2); if (!ob1) if (!ob2) return 1; else return 0; +#ifdef __cplusplus + if (!ob2 || ob1->ctemplate != ob2->ctemplate) { +#else if (!ob2 || ob1->template != ob2->template) { +#endif return 0; } return 1; @@ -3147,9 +3164,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; } @@ -3171,9 +3188,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; } @@ -3182,7 +3199,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; } } @@ -3202,7 +3219,6 @@ int IsObj (Object* p,char* s){ return !strncmp(hoc_object_name(p),s,strlen(s)); } int IsVector (Object* p){ return IsObj(p,"Vector"); } -int IsList (Object* p){return IsObj(p,"List"); } int** getint2D(int rows,int cols) { int **pp,*pool,*curPtr; int i; From 4ebb05ca9e9befd52d33daaa6af8945deaf9bf5f Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Wed, 18 May 2022 18:18:09 +0200 Subject: [PATCH 09/17] Fixed misc.h, misc.mod, stats.mod and vecst.mod for NEURON 9.0.0, 8.2.0, 8.1.0 --- misc.h | 17 +++++++++++------ misc.mod | 16 ++++++++-------- stats.mod | 50 +++++++++++++++++++++++++------------------------- vecst.mod | 4 +--- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/misc.h b/misc.h index 433a18d..52f50e9 100644 --- a/misc.h +++ b/misc.h @@ -8,6 +8,7 @@ // #include use limits.h above instead #include // added to declare DBL_MAX etc... #include +#include #if !defined(t) #define _pval pval @@ -76,24 +77,24 @@ 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 void mcell_ran4_init(uint32_t idum); +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); extern int hoc_is_str_arg(int narg); extern int hoc_is_object_arg(int narg); 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*); -#endif -extern double mcell_ran4(unsigned int* idum,double* ran_vec,unsigned int n,double range); +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); -extern void clear_event_queue(); -extern Symbol *hoc_get_symbol(char *); +#endif extern unsigned int hashseed2 (int na, double* x); extern unsigned int dcrsz; extern double *dcr; @@ -113,6 +114,7 @@ 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 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); @@ -124,6 +126,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/stats.mod b/stats.mod index e53ec95..bf89685 100644 --- a/stats.mod +++ b/stats.mod @@ -49,7 +49,6 @@ union dblint { unsigned int valseed; static double *x1x, *y1y, *z1z; -static void vprpr(); static int compare_ul(const void* l1, const void* l2) { int retval; @@ -425,9 +424,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 +468,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 +641,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 } @@ -2116,7 +2116,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)(uintptr_t)(&valseed)); // do initialization return valseed; ENDVERBATIM } @@ -2144,7 +2144,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; @@ -2218,7 +2218,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/vecst.mod b/vecst.mod index d3a7bc4..aa1bafc 100644 --- a/vecst.mod +++ b/vecst.mod @@ -107,9 +107,6 @@ ENDVERBATIM VERBATIM // Maintain parallel int vector to avoid slowness of repeated casts int cmpdfn (double a, double b) {return ((a)<=(b))?(((a) == (b))?0:-1):1;} -int IsObj (Object* p,char* s); -int IsList (Object* p){return IsObj(p,"List"); } -int list_vector_px4 (Object *ob, int i, double** px, unsigned int n); static unsigned int bufsz=0; unsigned int scrsz=0; unsigned int *scr=0x0; @@ -3219,6 +3216,7 @@ int IsObj (Object* p,char* s){ return !strncmp(hoc_object_name(p),s,strlen(s)); } int IsVector (Object* p){ return IsObj(p,"Vector"); } +int IsList (Object* p){return IsObj(p,"List"); } int** getint2D(int rows,int cols) { int **pp,*pool,*curPtr; int i; From 78fa98f20fdcc1cbbaec2793aca528b50c42698d Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Wed, 18 May 2022 18:18:57 +0200 Subject: [PATCH 10/17] Updated readme --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 9e0cce8..667ded2 100644 --- a/readme.txt +++ b/readme.txt @@ -70,4 +70,4 @@ http://www.frontiersin.org/Computational_Neuroscience/10.3389/fncom.2011.00019/a 20110418 Updated to run on mswin. -ModelDB Administrator 20110419 Additional button window for autolaunch. -ModelDB Administrator 20111219 readme reformatted. -ModelDB Administrator -20220517 Edited intf_6.mod and misc.h to support NEURON versions <8.1.0, 8.2.0 and 9.0.0. -NEURON Developers \ No newline at end of file +20220517 Edited intf_6.mod, misc.h, misc.mod, stats.mod and vecst.mod to support NEURON versions <8.1.0, 8.2.0 and 9.0.0. -NEURON Developers \ No newline at end of file From 088687ef51a7f98d8d6118eea502812d283d74bd Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Thu, 19 May 2022 14:25:51 +0200 Subject: [PATCH 11/17] fix for new wheels --- vecst.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vecst.mod b/vecst.mod index aa1bafc..c132b41 100644 --- a/vecst.mod +++ b/vecst.mod @@ -1345,7 +1345,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]; @@ -2915,7 +2915,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 f25cd1194d5e32fb138104b581afa40e4e98e181 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Mon, 23 May 2022 11:19:33 +0200 Subject: [PATCH 12/17] Cleanup for merge. --- intf6_.mod | 25 ++++++++++++++++--------- misc.h | 11 ++++++----- misc.mod | 17 ++++++++++------- readme.txt | 3 ++- stats.mod | 5 ++++- vecst.mod | 18 +++++++++--------- 6 files changed, 47 insertions(+), 32 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index 1b23ffd..9786d6b 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -23,7 +23,8 @@ ENDCOMMENT VERBATIM #include "misc.h" -#include "unistd.h" + +#include static int ctt(unsigned int, char**); static void setdvi2(double*,double*,char*,int,int); @@ -378,7 +379,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; } @@ -512,7 +514,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;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); + /* 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++) { @@ -1538,6 +1542,7 @@ FUNCTION setdviv () { nprv=vector_arg_px(1, &prv); i=vector_arg_px(2, &pov); j=vector_arg_px(3, &dlv); + /* probably meant to be = not - */ s-0x0; if(ifarg(4)) { s=(char*)calloc((l=vector_arg_px(4,&ds)),sizeof(char)); for(k=0;kpg; flag=(int) *getarg(1); if (subsvint==0.) {printf("trvsp"); return(0.);} - ind=pg->isp[0]; t0=pg->vsp[0]; + ind = pg->isp[0]; + local_t0 = pg->vsp[0]; if (flag==1) { for (i=0; ivspn; i++) { if (pg->isp[i]!=ind) { @@ -2403,11 +2409,12 @@ PROCEDURE trvsp () } else if (flag==2) { for (i=0; ivspn; i++) { if (pg->isp[i]!=ind) { - pg->vsp[i-1]=t0+subsvint; - ind=pg->isp[i]; t0=pg->vsp[i]; + pg->vsp[i-1] = local_t0 + subsvint; + ind=pg->isp[i]; + local_t0 = pg->vsp[i]; } } - pg->vsp[pg->vspn-1]=t0+subsvint; + pg->vsp[pg->vspn-1] = local_t0 + subsvint; } else {printf("trvsp flag %d not recognized\n",flag); hxe();} ENDVERBATIM } diff --git a/misc.h b/misc.h index 52f50e9..c5beecc 100644 --- a/misc.h +++ b/misc.h @@ -4,7 +4,7 @@ #include #include /* contains LONG_MAX */ #include -#include +#include // #include use limits.h above instead #include // added to declare DBL_MAX etc... #include @@ -55,10 +55,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; @@ -92,6 +92,7 @@ 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(int narg); extern int hoc_is_tempobj_arg(int narg); extern Object* ivoc_list_item(Object*, int); #endif diff --git a/misc.mod b/misc.mod index 6c5600b..eed8af9 100644 --- a/misc.mod +++ b/misc.mod @@ -41,6 +41,7 @@ NEURON { } VERBATIM +#include "misc.h" #include /* F_OK */ #include /* errno */ #include @@ -48,8 +49,6 @@ VERBATIM #include #include #include -#include -extern int hoc_is_tempobj(int narg); ENDVERBATIM :* FUNCTION file_exist() @@ -92,12 +91,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 +120,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/readme.txt b/readme.txt index 667ded2..58d65f0 100644 --- a/readme.txt +++ b/readme.txt @@ -70,4 +70,5 @@ http://www.frontiersin.org/Computational_Neuroscience/10.3389/fncom.2011.00019/a 20110418 Updated to run on mswin. -ModelDB Administrator 20110419 Additional button window for autolaunch. -ModelDB Administrator 20111219 readme reformatted. -ModelDB Administrator -20220517 Edited intf_6.mod, misc.h, misc.mod, stats.mod and vecst.mod to support NEURON versions <8.1.0, 8.2.0 and 9.0.0. -NEURON Developers \ No newline at end of file +20220517 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 bf89685..ac69a7e 100644 --- a/stats.mod +++ b/stats.mod @@ -859,6 +859,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((unsigned int*)(uintptr_t)(&xx.i[0]), &y, 1, big); // generate a pseudorand number based on these prod*=y; // keep multiplying these out @@ -1444,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;iUINT_MAX) y/=1e9; // UINT_MAX is 4.294967e+09 @@ -2116,6 +2118,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 return valseed; ENDVERBATIM diff --git a/vecst.mod b/vecst.mod index c132b41..ec4be10 100644 --- a/vecst.mod +++ b/vecst.mod @@ -796,7 +796,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 @@ -818,7 +818,7 @@ static double revec (void* vv) { } } vector_resize((IvocVect*)vv,k); - return 0; // TODO: Shoulf we return 0 or 1? + return 0; } ENDVERBATIM @@ -921,7 +921,7 @@ static double vfill (void* vv) { nx = vector_instance_px(vv, &x); nv1 = vector_arg_px(1, &v1); for (i=0;i0 && kVRRY) 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 17:03:43 +0200 Subject: [PATCH 13/17] 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 ec4be10..c3ea2cc 100644 --- a/vecst.mod +++ b/vecst.mod @@ -2915,11 +2915,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 2ba2c3818995fb82bcc760c9cf17a34a934bfd5a Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 12:50:39 +0200 Subject: [PATCH 14/17] mcell_ran4_init: pass a value --- stats.mod | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/stats.mod b/stats.mod index ac69a7e..e7682ff 100644 --- a/stats.mod +++ b/stats.mod @@ -859,9 +859,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 - /* casts are trying to preserve (probably buggy) C behaviour in C++ */ - mcell_ran4_init((uint32_t)(uintptr_t)(&xx.i[1])); - mcell_ran4((unsigned int*)(uintptr_t)(&xx.i[0]), &y, 1, big); // generate a pseudorand number based on these + mcell_ran4_init(xx.i[1]); + mcell_ran4((uint32_t*)&xx.i[0], &y, 1, big); // generate a pseudorand number based on these prod*=y; // keep multiplying these out } if (! vfl) x[i]=prod; else return prod; // just return the 1 value @@ -2051,9 +2050,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 - /* casts are trying to preserve (probably buggy) C behaviour in C++ */ - mcell_ran4_init((uint32_t)(uintptr_t)(&xx.i[1])); - mcell_ran4((unsigned int*)(uintptr_t)(&xx.i[0]), &y, 1, big); // generate a pseudorand number based on these + mcell_ran4_init(xx.i[1]); + mcell_ran4((uint32_t*)&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 } @@ -2118,8 +2116,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 f4f11948097daabce316bdb05ed5398bdcdfa6c5 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 12:54:07 +0200 Subject: [PATCH 15/17] mcell_ran4_init: update readme --- readme.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 58d65f0..67535a4 100644 --- a/readme.txt +++ b/readme.txt @@ -71,4 +71,5 @@ http://www.frontiersin.org/Computational_Neuroscience/10.3389/fncom.2011.00019/a 20110419 Additional button window for autolaunch. -ModelDB Administrator 20111219 readme reformatted. -ModelDB Administrator 20220517 Updated MOD files to contain valid C++ and be compatible - with the upcoming versions 8.2 and 9.0 of NEURON. + with the upcoming versions 8.2 and 9.0 of NEURON. Updated to + use post ~2011 signature of mcell_ran4_init function. From b62f8840542d9ae9bbc3e6527b79c59717e94e90 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 14:08:48 +0200 Subject: [PATCH 16/17] hashseed2: probable bugfix --- intf6_.mod | 9 +++------ readme.txt | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index 9786d6b..8b29f5c 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -379,8 +379,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; } @@ -514,8 +513,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 67535a4..aea56a4 100644 --- a/readme.txt +++ b/readme.txt @@ -72,4 +72,5 @@ http://www.frontiersin.org/Computational_Neuroscience/10.3389/fncom.2011.00019/a 20111219 readme reformatted. -ModelDB Administrator 20220517 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. + use post ~2011 signature of mcell_ran4_init function and fix + hashseed2 argument. From 7fef1dd83f5095ea97ca53d87a43be16c3983942 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Tue, 24 May 2022 14:16:10 +0200 Subject: [PATCH 17/17] s-0x0 -> s=0x0: probably typo (and compiler warning) fix --- intf6_.mod | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/intf6_.mod b/intf6_.mod index 8b29f5c..7a551f9 100644 --- a/intf6_.mod +++ b/intf6_.mod @@ -1539,8 +1539,7 @@ FUNCTION setdviv () { nprv=vector_arg_px(1, &prv); i=vector_arg_px(2, &pov); j=vector_arg_px(3, &dlv); - /* probably meant to be = not - */ - s-0x0; + s=0x0; if(ifarg(4)) { s=(char*)calloc((l=vector_arg_px(4,&ds)),sizeof(char)); for(k=0;k