1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
51 |
|
long npacksdone = 0L; /* number of packets done */ |
52 |
|
|
53 |
|
PACKET *freepacks; /* available packets */ |
54 |
< |
int avgqlen; /* average queue length when full */ |
54 |
> |
int totqlen; /* maximum queue length when full */ |
55 |
|
|
56 |
|
char *sigerr[NSIG]; /* signal error messages */ |
57 |
|
|
109 |
|
} |
110 |
|
/* check settings */ |
111 |
|
checkvalues(); |
112 |
< |
/* load RIF if rtrace */ |
113 |
< |
if (ncprocs) |
114 |
< |
getradfile(); |
112 |
> |
/* load rad input file */ |
113 |
> |
getradfile(); |
114 |
|
|
115 |
|
if (hdlist[0] == NULL) { /* create new holodeck */ |
116 |
|
HDGRID hdg[HDMAX]; |
175 |
|
if (fstat(fd, &stbuf) < 0) |
176 |
|
error(SYSTEM, "cannot stat open holodeck file"); |
177 |
|
mod &= stbuf.st_mode; /* always more restrictive */ |
178 |
< |
if (mod == stbuf.st_mode) |
178 |
> |
if (mod == (stbuf.st_mode & 0777)) |
179 |
|
return(-1); /* already set */ |
180 |
|
/* else change it */ |
181 |
|
if (fchmod(fd, mod) < 0) { |
222 |
|
endtime = starttime + vflt(TIME)*3600. + .5; |
223 |
|
/* start rtrace */ |
224 |
|
if (ncprocs > 0) { |
225 |
< |
i = start_rtrace(); |
225 |
> |
totqlen = i = start_rtrace(); |
226 |
|
if (i < 1) |
227 |
|
error(USER, "cannot start rtrace process(es)"); |
228 |
|
if (vdef(REPORT)) { /* make first report */ |
233 |
|
freepacks = (PACKET *)bmalloc(i*sizeof(PACKET)); |
234 |
|
if (freepacks == NULL) |
235 |
|
goto memerr; |
237 |
– |
if (!(avgqlen = i/nprocs)) /* record mean queue length */ |
238 |
– |
avgqlen = 1; |
236 |
|
freepacks[--i].nr = 0; |
237 |
|
freepacks[i].next = NULL; |
238 |
|
if (!vdef(OBSTRUCTIONS) || !vbool(OBSTRUCTIONS)) { |
300 |
|
report(t); |
301 |
|
/* figure out good packet size */ |
302 |
|
#if MAXQTIME |
303 |
< |
pksiz = nraysdone*MAXQTIME/(avgqlen*(t - starttime + 1L)); |
303 |
> |
pksiz = nraysdone*MAXQTIME/(totqlen*(t - starttime + 1L)); |
304 |
|
if (pksiz < 1) |
305 |
|
pksiz = 1; |
306 |
|
else if (pksiz > RPACKSIZ) |
330 |
|
extern char *atos(); |
331 |
|
register int i; |
332 |
|
int n; |
333 |
< |
double len[3], maxlen, d; |
333 |
> |
double len[3], d; |
334 |
|
char buf[64]; |
335 |
|
|
336 |
|
if (!vdef(SECTION)) { |
364 |
|
&gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2], |
365 |
|
&gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12) |
366 |
|
badvalue(SECTION); |
370 |
– |
maxlen = 0.; |
367 |
|
for (i = 0; i < 3; i++) |
368 |
< |
if ((len[i] = VLEN(gp->xv[i])) > maxlen) |
369 |
< |
maxlen = len[i]; |
370 |
< |
if (!vdef(GRID)) |
371 |
< |
d = 0.125*maxlen; |
372 |
< |
else if ((d = vflt(GRID)) <= FTINY) |
368 |
> |
len[i] = VLEN(gp->xv[i]); |
369 |
> |
if (!vdef(GRID)) { |
370 |
> |
d = 2/5e5*( len[0]*len[0]*(len[1]*len[1] + |
371 |
> |
len[2]*len[2] + 4*len[1]*len[2]) |
372 |
> |
+ len[1]*len[1]*len[2]*(len[2] + 4*len[0]) |
373 |
> |
+ 4*len[0]*len[1]*len[2]*len[2] ); |
374 |
> |
d = sqrt(sqrt(d)); |
375 |
> |
} else if ((d = vflt(GRID)) <= FTINY) |
376 |
|
badvalue(GRID); |
377 |
|
for (i = 0; i < 3; i++) |
378 |
|
if (gp->grid[i] <= 0) |
453 |
|
int4 nextloc; |
454 |
|
/* open holodeck file */ |
455 |
|
if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) { |
456 |
< |
sprintf(errmsg, "cannot open \"%s\" for %s", hdkfile, |
457 |
< |
ncprocs>0 ? "appending" : "reading"); |
456 |
> |
sprintf(errmsg, "cannot %s \"%s\"", |
457 |
> |
ncprocs>0 ? "append" : "read", hdkfile); |
458 |
|
error(SYSTEM, errmsg); |
459 |
|
} |
460 |
|
/* load variables from header */ |
504 |
|
p->next = freepacks; /* push onto free list */ |
505 |
|
freepacks = p; |
506 |
|
} |
507 |
< |
if (n2flush > 300/MAXQTIME*avgqlen*nprocs) { |
507 |
> |
if (n2flush > 300/MAXQTIME*totqlen) { |
508 |
|
hdflush(NULL); /* flush holodeck buffers */ |
509 |
|
n2flush = 0; |
510 |
|
} |