diff --git a/README.html b/README.html index 591909f..7c71831 100644 --- a/README.html +++ b/README.html @@ -34,4 +34,9 @@ are available from the menu. This model code was supplied by Bill Lytton. + +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/intf.mod b/intf.mod index 96b977c..72aa56f 100644 --- a/intf.mod +++ b/intf.mod @@ -36,7 +36,7 @@ typedef struct VPT { unsigned int size; unsigned int p; double* vvo[NSV]; - void* vv[NSV]; + IvocVect* vv[NSV]; } vpt; typedef struct ID0 { @@ -64,7 +64,7 @@ static unsigned int jtpt,jitmax; static double vii[NSV]; // temp storage static unsigned int wwpt,wwsz,wwaz; // pointer and size for the shared recording vector FILE *wf1, *wf2; -void* ww[NSW]; +IvocVect* ww[NSW]; double* wwo[NSW]; float wwt[WSZ]; float www[WSZ]; unsigned int wwi[WSZ]; char wws[WSZ]; ENDVERBATIM @@ -154,7 +154,7 @@ CONSTRUCTOR { { int lid,lty; if (ifarg(2)) { lid=(int) *getarg(2); } else { lid= UINT_MAX; } if (ifarg(3)) { lty=(int) *getarg(3); } else { lty= -1; } - _p_sop = (void*)ecalloc(1, sizeof(id0)); + _p_sop = (double*)ecalloc(1, sizeof(id0)); ip = IDP; ip->id=lid; ip->type=lty; ip->invl0 = ip->record = ip->jitter = ip->input = 0; // all flags off @@ -361,7 +361,7 @@ PROCEDURE randspk () { :** 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); @@ -376,11 +376,11 @@ PROCEDURE record () { VERBATIM { int k; double ti; vp = SOP; - if (tg>=t) return; - if (vp->p >= vp->size) { if (errflag) return; + if (tg>=t) return 0; + if (vp->p >= vp->size) { if (errflag) return 0; printf("**** WARNING out of recording room for INTF type%d id%d at %g****\n",IDP->type,IDP->id,t); printf("**************** WARNING: No further WARNINGS ****************\n"); - errflag=1; return; } + errflag=1; return 0; } for (ti=tg;ti<=t && vp->p < vp->size;ti+=vdt,vp->p++) { val(ti,tg); vp->vvo[0][vp->p]=ti; @@ -398,7 +398,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; vp->vvo[0][vp->p-1]=_lx; vp->vvo[6][vp->p-1]=spkht; // the spike tg=_lx; @@ -575,13 +575,13 @@ PROCEDURE chk () { if (SOP!=nil) { vp = SOP; printf("p %d size %d tg %g\n",vp->p,vp->size,tg); - for (i=0;ivv[i],vp->vvo[i]); + for (i=0;ivv[i],vp->vvo[i]); } else printf("Recording pointers not initialized"); } if (lfg==2) { printf("Global vectors for input and jitter: \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,jitmax); else printf("no JSP\n"); + if (vsp!=nil) printf("VSP: %p (%d/%d-%d)\n",vsp,ip->rvi,ip->rvb,ip->rve); else printf("no VSP\n"); + if (jsp!=nil) printf("JSP: %p (%d/%d)\n",jsp,jtpt,jitmax); else printf("no JSP\n"); } if (lfg==3) { if (vsp!=nil) { printf("VSP: (%d/%d-%d)\n",ip->rvi,ip->rvb,ip->rve); @@ -593,7 +593,7 @@ PROCEDURE chk () { } if (lfg==5) { printf("wwpt %d wwsz %d\n WW vecs: ",wwpt,wwsz); - for (i=0;iid; if (wwpt >= wwsz) { wwpt=0; - fprintf(wf1,"//b8 %d INTF %g %d\n",WSZ,_lt,ftell(wf2)); + fprintf(wf1,"//b8 %d INTF %g %ld\n",WSZ,_lt,ftell(wf2)); fwrite(&wwt,sizeof(float),WSZ,wf2); // write out the size fwrite(&wwi,sizeof(int),WSZ,wf2); // write out the size fwrite(&wws,sizeof(char),WSZ,wf2); // write out the size @@ -845,12 +845,12 @@ PROCEDURE global_fini () { if (wwo[0]!=0) { for (k=0;k #include #include +#ifndef NRN_VERSION_GTEQ_8_2_0 +FILE* hoc_obj_file_arg(int); +#endif ENDVERBATIM :* FUNCTION file_exist() @@ -56,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); @@ -77,19 +80,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 M } 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 M } /* assign_hoc_str(strname, string, 0); */ @@ -112,17 +114,17 @@ VERBATIM if ( !(outfile = fopen("dassign","w"))) { fprintf(stderr,"Can't open output file dassign\n"); - return; + return 0; } if( !(pipein = popen(syscall, "r"))) { fprintf(stderr,"System call failed\n"); - fclose(outfile); return; + 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; + fclose(outfile); pclose(pipein); return 0; } fprintf(outfile,"%s=%g\n",strname,num); @@ -176,7 +178,7 @@ ENDVERBATIM PROCEDURE fspitchar(c) { VERBATIM { - FILE* f, *hoc_obj_file_arg(); + FILE* f; f = hoc_obj_file_arg(2); fprintf(f, "%c", (int)_lc); } @@ -196,7 +198,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 77d7867..e94cdeb 100644 --- a/stats.mod +++ b/stats.mod @@ -333,8 +333,8 @@ static double bin(void* vv) { invl = (int)*getarg(2); vv=vector_arg(1); - maxsz=vector_buffer_size(vv); - vector_resize(vv, maxsz); + maxsz=vector_buffer_size((IvocVect*)vv); + vector_resize((IvocVect*)vv, maxsz); if (x[nx-1]/invl>(double)(maxsz-1)) { printf("Need size %d in target vector (%d)\n",(int)(x[nx-1]/invl+1),maxsz); hoc_execerror("",0); } @@ -345,7 +345,7 @@ static double bin(void* vv) { y[j]++; } } - vector_resize(vv, j); + vector_resize((IvocVect*)vv, j); return (double)j; } ENDVERBATIM diff --git a/vecst.mod b/vecst.mod index 55ede77..59ded91 100644 --- a/vecst.mod +++ b/vecst.mod @@ -101,9 +101,9 @@ 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); -int list_vector_px(); -int list_vector_px2(); -int list_vector_resize(); +int list_vector_px(Object *ob, int i, double** px); +int list_vector_px2 (Object *ob, int i, double** px, IvocVect** vv); +int list_vector_resize (Object *ob, int i, int sz); static double sc[6]; typedef struct BVEC { @@ -131,8 +131,9 @@ 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",vv,x,nx,bsz); + bsz=vector_buffer_size((IvocVect*)vv); + printf("Obj*%p Dbl*%p Size: %d Bufsize: %d\n",vv,x,nx,bsz); + return (double)nx; // similar to other versions of vecst.mod } ENDVERBATIM @@ -207,6 +208,7 @@ 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[11], bv[11], num; Object *ob1, *ob2; double *ind, *avo[11], *bvo[11]; @@ -224,12 +226,12 @@ static double findx (void* vv) { } nx=av[0]; // size of source vecs for (i=0;iscrsz) { @@ -394,7 +396,7 @@ static double slct (void* vv) { } if (fl) ind[k++]=j; // all equal } - vector_resize(vv, k); + vector_resize((IvocVect*)vv, k); return k; } ENDVERBATIM @@ -470,7 +472,7 @@ static double slor(void* vv) { } if (fl) ind[k++]=j; // all equal } - vector_resize(vv, k); + vector_resize((IvocVect*)vv, k); return k; } ENDVERBATIM @@ -480,7 +482,7 @@ VERBATIM static double iwr(void* vv) { int i, j, nx; double *x; - FILE* f, *hoc_obj_file_arg(); + FILE* f; f = hoc_obj_file_arg(1); nx = vector_instance_px(vv, &x); if (nx>scrsz) { @@ -498,27 +500,27 @@ ENDVERBATIM :* v.ird() VERBATIM static double ird(void* vv) { - int i, j, nx, n; + int i, j, nx, n; size_t r; double *x; - FILE* f, *hoc_obj_file_arg(); + FILE* f; f = hoc_obj_file_arg(1); nx = vector_instance_px(vv, &x); - fread(&n,sizeof(int),1,f); // size + r=fread(&n,sizeof(int),1,f); // size if (n>scrsz) { if (scrsz>0) { free(scr); scr=(unsigned int *)NULL; } scrsz=n+10000; scr=(unsigned int *)ecalloc(scrsz, sizeof(int)); } if (n!=nx) { - nx=vector_buffer_size(vv); + nx=vector_buffer_size((IvocVect*)vv); if (n<=nx) { - vector_resize(vv, n); nx=n; + vector_resize((IvocVect*)vv, n); nx=n; } else { printf("%d > %d :: ",n,nx); hoc_execerror("Vector max capacity too small for ird ", 0); } } - fread(scr,sizeof(int),n,f); + r=fread(scr,sizeof(int),n,f); for (i=0;imaxsz) { 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; @@ -551,7 +553,7 @@ static double fread2(void* vv) { scr=(unsigned int *)ecalloc(scrsz, sizeof(int)); } xs=(unsigned int*)scr; - fread(xs,sizeof(int),n,fp); + r=fread(xs,sizeof(int),n,fp); if (type==16) BYTESWAP_FLAG=1; for (i=0;imaxsz) { printf("\tinsct WARNING: ran out of room: %d<%d\n",maxsz,k); - } else { vector_resize(vv, k); } + } else { vector_resize((IvocVect*)vv, k); } return (double)k; } ENDVERBATIM @@ -600,6 +603,7 @@ static double vfill (void* vv) { nx = vector_instance_px(vv, &x); nv1 = vector_arg_px(1, &v1); for (i=0;imaxsz) { printf("\tcull WARNING: ran out of room: %d<%d\n",maxsz,k); - } else { vector_resize(vv, k); } + } else { vector_resize((IvocVect*)vv, k); } return (double)k; } ENDVERBATIM @@ -635,14 +639,14 @@ static double redundout(void* vv) { double *x, *v1, val; if (ifarg(2)) indflag=1; else indflag=0; nx = vector_instance_px(vv, &x); - maxsz=vector_buffer_size(vv); - vector_resize(vv, maxsz); + maxsz=vector_buffer_size((IvocVect*)vv); + vector_resize((IvocVect*)vv, maxsz); nv1 = vector_arg_px(1, &v1); val=v1[0]; x[0]=(indflag?0:val); for (j=1,i=1;i11) hoc_execerror("mredundout ****ERRA****: can only handle 11 vectors", 0); for (i=0;imaxsz){printf("mredundout****ERRE**** vec overflow %d>%d\n",k,maxsz);hoc_execerror("", 0);} for (i=0;i0 && k10) hoc_execerror("ERR: keyind can only handle 9 vectors", 0); num = i-1; /* number of vectors to be picked apart */ for (i=0;ith) { /* ? passing thresh */ @@ -1025,7 +1031,7 @@ static double xing(void* vv) { if (f==1) { f=0; } /* just passed going down */ } } - vector_resize(vv, j); + vector_resize((IvocVect*)vv, j); return (double)i; } ENDVERBATIM @@ -1128,9 +1134,9 @@ static double lcat(void* vv) { int i, j, k, n, lc, cap, maxsz; Object *ob1, *ob2; 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_px(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); - 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; } @@ -1263,13 +1269,13 @@ int list_vector_resize (Object *ob, int i, int sz) { Object* obv; int maxsz; obv = ivoc_list_item(ob, i); - maxsz = vector_buffer_size(obv->u.this_pointer); + maxsz = vector_buffer_size((IvocVect*)obv->u.this_pointer); if (sz>maxsz) { printf("max:%d request:%d ",maxsz,sz); hoc_execerror("Can't grow vector in list_vector_resize ", 0); return -1; } - vector_resize(obv->u.this_pointer,sz); + vector_resize((IvocVect*)obv->u.this_pointer,sz); return sz; } ENDVERBATIM @@ -1349,9 +1355,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); @@ -1387,20 +1393,20 @@ ENDVERBATIM : needs to be generalized so reads code as well, also should do BYTESWAP VERBATIM static double vrdh (void* vv) { - int code, i, num, n[2], maxsz; + int code, i, num, n[2], maxsz; size_t r; double *x; 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);hoc_execerror("", 0);} - vector_resize(vv, 2*num); + vector_resize((IvocVect*)vv, 2*num); for (i=0;itemplate != ob2->template) { +#define ctemplate template +#ifdef NRN_VERSION_GTEQ_8_2_0 +#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; @@ -1504,7 +1518,7 @@ FUNCTION eqojt () { :* rdmany(FILE,veclist,code) FUNCTION rdmany () { VERBATIM { - int code, i, j, nx, nv, num, n[2]; + int code, i, j, nx, nv, num, n[2]; size_t r; Object* ob; double *vvo[100], sf[2]; FILE* f; @@ -1530,11 +1544,11 @@ FUNCTION rdmany () { unsigned short *xs; xs=(unsigned short *)scr; for (i=0;i 5) { BYTESWAP_FLAG = 1; ret = 1.;