ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
(Generate patch)

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.33 by gregl, Wed Dec 31 20:45:31 1997 UTC vs.
Revision 3.40 by gwlarson, Wed Jun 3 12:18:24 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1997 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 26 | Line 26 | char   *progname;              /* our program name */
26   char    *hdkfile;               /* holodeck file name */
27   char    froot[256];             /* root file name */
28  
29 int     nowarn = 0;             /* turn warnings off? */
30
29   int     ncprocs = 0;            /* desired number of compute processes */
30  
31   char    *outdev = NULL;         /* output device name */
# Line 51 | Line 49 | long   nraysdone = 0L;         /* number of rays done */
49   long    npacksdone = 0L;        /* number of packets done */
50  
51   PACKET  *freepacks;             /* available packets */
52 < int     avgqlen;                /* average queue length when full */
52 > int     totqlen;                /* maximum queue length when full */
53  
54   char  *sigerr[NSIG];            /* signal error messages */
55  
56 + extern int      nowarn;         /* turn warnings off? */
57 +
58   extern time_t   time();
59  
60  
# Line 109 | Line 109 | char   *argv[];
109                  }
110                                                  /* check settings */
111          checkvalues();
112 <                                                /* load RIF if any */
112 >                                                /* load rad input file */
113          getradfile();
114  
115          if (hdlist[0] == NULL) {                /* create new holodeck */
# Line 175 | Line 175 | int    fd, mod;
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) {
# Line 222 | Line 222 | initrholo()                    /* get our holodeck running */
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 */
# Line 233 | Line 233 | initrholo()                    /* get our holodeck running */
233                  freepacks = (PACKET *)bmalloc(i*sizeof(PACKET));
234                  if (freepacks == NULL)
235                          goto memerr;
236                if (!(avgqlen = i/nprocs))      /* record mean queue length */
237                        avgqlen = 1;
236                  freepacks[--i].nr = 0;
237                  freepacks[i].next = NULL;
238                  if (!vdef(OBSTRUCTIONS) || !vbool(OBSTRUCTIONS)) {
# Line 302 | Line 300 | rholo()                                /* holodeck main loop */
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)
# Line 332 | Line 330 | register HDGRID        *gp;
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)) {
# Line 366 | Line 364 | register HDGRID        *gp;
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);
369                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)
# Line 453 | Line 453 | loadholo()                     /* start loading a holodeck from fname */
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 */
# Line 504 | Line 504 | PACKET *pl;
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          }
# Line 550 | Line 550 | register char  *s;
550                  fflush(stderr);
551                  midline = 0;
552          }
553 }
554
555
556 wputs(s)                        /* put warning string to stderr */
557 char    *s;
558 {
559        if (!nowarn)
560                eputs(s);
553   }
554  
555  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines