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

Comparing ray/src/util/pvsum.c (file contents):
Revision 2.2 by greg, Thu Mar 27 16:35:00 2025 UTC vs.
Revision 2.5 by greg, Fri Jun 6 18:26:22 2025 UTC

# Line 15 | Line 15 | static const char RCSid[] = "$Id$";
15   #include "rmatrix.h"
16   #if !defined(_WIN32) && !defined(_WIN64)
17   #include <sys/mman.h>
18 + #include <sys/wait.h>
19   #endif
20  
21   int     nprocs = 1;                     /* # of calculation processes (Unix) */
# Line 68 | Line 69 | iheadline(char *s, void *p)
69                  ncomp = ncompval(s);
70                  return(1);
71          }
71        if (isexpos(s)) {
72                if (fabs(1. - exposval(s)) > 0.04)
73                        fputs("Warning - ignoring EXPOSURE setting\n", stderr);
74                return(1);
75        }
72          if (formatval(fmt, s)) {
73                  for (in_type = DTend; --in_type > DTfromHeader; )
74                          if (!strcmp(fmt, cm_fmt_id[in_type]))
# Line 155 | Line 151 | get_iotypes(void)
151   int
152   checkline(char *s, void *p)
153   {
154 <        int     *xyres = (int *)p;
155 <        char    fmt[MAXFMTLEN];
154 >        static int      exposWarned = 0;
155 >        int             *xyres = (int *)p;
156 >        char            fmt[MAXFMTLEN];
157  
158          if (!strncmp(s, "NCOLS=", 6)) {
159                  xyres[0] = atoi(s+6);
# Line 176 | Line 173 | checkline(char *s, void *p)
173                  return(1);
174          }
175          if (isexpos(s)) {
176 <                if (fabs(1. - exposval(s)) > 0.04)
177 <                        fputs("Warning - ignoring EXPOSURE setting\n", stderr);
176 >                if (!exposWarned && fabs(1. - exposval(s)) > 0.04) {
177 >                        fputs("Warning - ignoring EXPOSURE setting(s)\n",
178 >                                        stderr);
179 >                        exposWarned++;
180 >                }
181                  return(1);
182          }
183          if (formatval(fmt, s)) {
# Line 228 | Line 228 | open_output(char *ospec, int fno)
228          if (!ospec) {
229                  ospec = "<stdout>";
230                  fp = stdout;
231                SET_FILE_BINARY(fp);
231          } else if (ospec[0] == '!') {
232                  if (!(fp = popen(ospec+1, "w"))) {
233                          fprintf(stderr, "Cannot start: %s\n", ospec);
234                          return(NULL);
235                  }
236 <                SET_FILE_BINARY(fp);
238 <        } else if (!(fp = fopen(ospec, "wb"))) {
236 >        } else if (!(fp = fopen(ospec, "w"))) {
237                  fprintf(stderr, "%s: cannot open for writing\n", ospec);
238                  return(NULL);
239          }
240 +        SET_FILE_BINARY(fp);
241          newheader("RADIANCE", fp);
242          if (cmtx->info)                 /* prepend matrix metadata */
243                  fputs(cmtx->info, fp);
# Line 476 | Line 475 | multi_process(void)
475                          maplen = dstart + yres*xres*i;
476                          imap = mmap(NULL, maplen, PROT_READ,
477                                          MAP_FILE|MAP_SHARED, fileno(finp), 0);
478 <                        fclose(finp);           /* will load from map (randomly) */
478 >                        fclose(finp);           /* will read from map (randomly) */
479                          if (imap == MAP_FAILED) {
480                                  fprintf(stderr, "%s: unable to map input file\n", fbuf);
481                                  return(0);
# Line 502 | Line 501 | multi_process(void)
501                                  }
502                              }
503                          munmap(imap, maplen);
504 <                }                       /* write out accumulated column result */
504 >                }                       /* write accumulated column picture/matrix */
505                  sprintf(fbuf, out_spec, c);
506                  fout = open_output(fbuf, c);
507                  if (!fout)
# Line 527 | Line 526 | multi_process(void)
526          }
527          free(osum);
528          free(syarr);
529 <        if (coff)                       /* children return here... */
529 >        if (coff)                       /* child processes return here... */
530                  return(1);
531          c = 0;                          /* ...but parent waits for children */
532          while (++coff < nprocs) {
# Line 579 | Line 578 | badopt:                        fprintf(stderr, "%s: bad option: %s\n", argv
578          if ((argc-a < 1) | (argc-a > 2) || argv[a][0] == '-')
579                  goto userr;
580          in_spec = argv[a];
581 <        cmtx = rmx_load(argv[a+1], RMPnone);    /* may load from stdin */
581 >        cmtx = rmx_load(argv[a+1]);     /* loads from stdin if a+1==argc */
582          if (cmtx == NULL)
583                  return(1);              /* error reported */
584 +        if (nprocs > cmtx->ncols)
585 +                nprocs = cmtx->ncols;
586   #if defined(_WIN32) || defined(_WIN64)
587          if (nprocs > 1) {
588                  fprintf(stderr, "%s: warning - Windows only allows -N 1\n", argv[0]);
589                  nprocs = 1;
590          }
591   #else
591        if (nprocs > cmtx->ncols)
592                nprocs = cmtx->ncols;
592          if ((nprocs > 1) & !out_spec) {
593                  fprintf(stderr, "%s: multi-processing result cannot go to stdout\n",
594                                  argv[0]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines