--- ray/src/hd/rholo.c 1997/12/02 12:29:17 3.15 +++ ray/src/hd/rholo.c 1997/12/11 12:09:33 3.19 @@ -30,6 +30,8 @@ int ncprocs = 0; /* desired number of compute process char *outdev = NULL; /* output device name */ +int readinp = 0; /* read commands from stdin */ + time_t starttime; /* time we got started */ time_t endtime; /* time we should end by */ time_t reporttime; /* time for next report */ @@ -60,7 +62,7 @@ char *argv[]; int force = 0; /* mark start time */ starttime = time(NULL); - initurand(10240); /* initialize urand */ + initurand(16384); /* initialize urand */ progname = argv[0]; /* get arguments */ for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { @@ -70,6 +72,9 @@ char *argv[]; case 'f': /* force overwrite */ force++; break; + case 'i': /* read input from stdin */ + readinp++; + break; case 'n': /* compute processes */ if (i >= argc-2) goto userr; @@ -187,6 +192,8 @@ initrholo() /* get our holodeck running */ { extern int global_packet(); register int i; + /* close holodeck on exec() */ + fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC); if (outdev != NULL) /* open output device */ disp_open(outdev); @@ -272,7 +279,7 @@ rholo() /* holodeck main loop */ if (!disp_check(idle)) return(0); /* display only? */ - if (ncprocs <= 0) + if (nprocs <= 0) return(1); /* check file size */ if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) { @@ -363,12 +370,14 @@ register HDGRID *gp; if (gp == NULL) /* already initialized? */ return; /* set grid parameters */ + gp->grid[0] = gp->grid[1] = gp->grid[2] = 0; if (sscanf(vval(SECTION), - "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", + "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd", &gp->orig[0], &gp->orig[1], &gp->orig[2], &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2], &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2], - &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2]) != 12) + &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2], + &gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12) badvalue(SECTION); maxlen = 0.; for (i = 0; i < 3; i++) @@ -382,7 +391,8 @@ register HDGRID *gp; if ((d = vflt(GRID)) <= FTINY) badvalue(GRID); for (i = 0; i < 3; i++) - gp->grid[i] = len[i]/d + (1.-FTINY); + if (gp->grid[i] <= 0) + gp->grid[i] = len[i]/d + (1.-FTINY); } @@ -490,7 +500,7 @@ PACKET *pl; p->next = freepacks; freepacks = p; } - if (n2flush > 512*RPACKSIZ*ncprocs) { + if (n2flush > 512*RPACKSIZ*nprocs) { hdflush(NULL); /* flush holodeck buffers */ n2flush = 0; } @@ -600,22 +610,21 @@ int ec; int status = 0; if (hdlist[0] != NULL) { /* flush holodeck */ - if (ncprocs > 0) { + if (nprocs > 0) { done_packets(flush_queue()); status = end_rtrace(); /* close rtrace */ - hdflush(NULL); - if (vdef(REPORT)) { - long fsiz, fuse; - report(0); - fsiz = hdfilen(hdlist[0]->fd); - fuse = hdfiluse(hdlist[0]->fd, 1); - fprintf(stderr, + } + hdflush(NULL); + if (ncprocs > 0 && vdef(REPORT)) { + long fsiz, fuse; + report(0); + fsiz = hdfilen(hdlist[0]->fd); + fuse = hdfiluse(hdlist[0]->fd, 1); + fprintf(stderr, "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n", - hdkfile, fsiz/(1024.*1024.), - 100.*(fsiz-fuse)/fsiz); - } - } else - hdflush(NULL); + hdkfile, fsiz/(1024.*1024.), + 100.*(fsiz-fuse)/fsiz); + } } if (orig_mode >= 0) /* reset holodeck access mode */ fchmod(hdlist[0]->fd, orig_mode);