Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixing intf.mod for NEURON 9.0.0, 8.2.0, 8.1.0 #1

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</pre></html>
30 changes: 15 additions & 15 deletions intf.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;i<NSV;i++) printf("%d %x %x;",i,vp->vv[i],vp->vvo[i]);
for (i=0;i<NSV;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: \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);
Expand All @@ -593,7 +593,7 @@ PROCEDURE chk () {
}
if (lfg==5) {
printf("wwpt %d wwsz %d\n WW vecs: ",wwpt,wwsz);
for (i=0;i<NSW;i++) printf("%d %x %x;",i,ww[i],wwo[i]);
for (i=0;i<NSW;i++) printf("%d %p %p;",i,ww[i],wwo[i]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For fixing warnings like this:

intf.cpp:1216:40: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘double*’ [-Wformat=]
 1216 |     for (i=0;i<NSW;i++) printf("%d %x %x;",i,ww[i],wwo[i]);
      |                                       ~^           ~~~~~~
      |                                        |                |
      |                                        unsigned int     double*

}}
ENDVERBATIM
}
Expand Down Expand Up @@ -773,7 +773,7 @@ PROCEDURE wrecord (t,s0,w0) {
int k; double id = (double)IDP->id;
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
Expand Down Expand Up @@ -845,12 +845,12 @@ PROCEDURE global_fini () {
if (wwo[0]!=0) {
for (k=0;k<NSW;k++) vector_resize(ww[k], wwpt);
} else {
fprintf(wf1,"//b8 %d INTF %g %d\n",wwpt,t,ftell(wf2));
fprintf(wf1,"//b8 %d INTF %g %ld\n",wwpt,t,ftell(wf2));
fwrite(&wwt,sizeof(float),wwpt,wf2); // write out the size
fwrite(&wwi,sizeof(int),wwpt,wf2); // write out the size
fwrite(&wws,sizeof(char),wwpt,wf2); // write out the size
fwrite(&www,sizeof(float),wwpt,wf2); // write out the size
printf("Closing file with wwpt=%d at location %d\n",wwpt,ftell(wf2));
printf("Closing file with wwpt=%d at location %ld\n",wwpt,ftell(wf2));
fclose(wf1); fclose(wf2);
}
} else {
Expand Down
20 changes: 11 additions & 9 deletions misc.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ VERBATIM
#include <time.h>
#include <stdio.h>
#include <limits.h>
#ifndef NRN_VERSION_GTEQ_8_2_0
FILE* hoc_obj_file_arg(int);
#endif
ENDVERBATIM

:* FUNCTION file_exist()
Expand All @@ -56,7 +59,7 @@ VERBATIM
errno else will get a nrnoc error. Seems to be a problem even
if I don't include <errno.h> */

char *gargstr(), *filename;
char *filename;

filename = gargstr(1);

Expand All @@ -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); */
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions stats.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -345,7 +345,7 @@ static double bin(void* vv) {
y[j]++;
}
}
vector_resize(vv, j);
vector_resize((IvocVect*)vv, j);
return (double)j;
}
ENDVERBATIM
Expand Down
Loading