1 |
< |
/* Copyright (c) 1995 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
15 |
|
#include "view.h" |
16 |
|
#include "vars.h" |
17 |
|
#include "netproc.h" |
18 |
+ |
/* default remote shell */ |
19 |
+ |
#ifdef _AUX_SOURCE |
20 |
+ |
#define REMSH "remsh" |
21 |
+ |
#else |
22 |
+ |
#define REMSH "rsh" |
23 |
+ |
#endif |
24 |
|
/* input variables */ |
25 |
|
#define HOST 0 /* rendering host machine */ |
26 |
|
#define RENDER 1 /* rendering options */ |
44 |
|
#define DISKSPACE 19 /* how much disk space to use */ |
45 |
|
#define RESOLUTION 20 /* desired final resolution */ |
46 |
|
#define EXPOSURE 21 /* how to compute exposure */ |
47 |
+ |
#define RSH 22 /* remote shell script or program */ |
48 |
|
|
49 |
< |
int NVARS = 22; /* total number of variables */ |
49 |
> |
int NVARS = 23; /* total number of variables */ |
50 |
|
|
51 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
52 |
|
{"host", 4, 0, NULL, NULL}, |
64 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
65 |
|
{"TRANSFER", 2, 0, NULL, onevalue}, |
66 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
67 |
< |
{"INTERP", 3, 0, NULL, intvalue}, |
68 |
< |
{"OVERSAMP", 2, 0, NULL, fltvalue}, |
67 |
> |
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
68 |
> |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
69 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
70 |
|
{"RTRACE", 2, 0, NULL, boolvalue}, |
71 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
72 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
73 |
|
{"EXPOSURE", 3, 0, NULL, onevalue}, |
74 |
+ |
{"RSH", 3, 0, NULL, onevalue}, |
75 |
|
}; |
76 |
|
|
77 |
|
#define SFNAME "STATUS" /* status file name */ |
92 |
|
int silent = 0; /* silent mode? */ |
93 |
|
int noaction = 0; /* take no action? */ |
94 |
|
|
95 |
< |
char rendopt[2048] = ""; /* rendering options */ |
95 |
> |
char *remsh; /* remote shell program/script */ |
96 |
> |
char rendopt[2048]; /* rendering options */ |
97 |
|
char rresopt[32]; /* rendering resolution options */ |
98 |
|
char fresopt[32]; /* filter resolution options */ |
99 |
|
int pfiltalways; /* always use pfilt? */ |
100 |
|
|
101 |
+ |
char arcargs[10240]; /* files to archive */ |
102 |
+ |
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
103 |
+ |
|
104 |
|
struct pslot { |
105 |
|
int pid; /* process ID (0 if empty) */ |
106 |
|
int fout; /* output frame number */ |
108 |
|
} *pslot; /* process slots */ |
109 |
|
int npslots; /* number of process slots */ |
110 |
|
|
111 |
< |
int lastpid; /* ID of last completed background process */ |
100 |
< |
PSERVER *lastpserver; /* last process server used */ |
111 |
> |
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
112 |
|
|
113 |
|
struct pslot *findpslot(); |
114 |
|
|
115 |
+ |
PSERVER *lastpserver; /* last process server with error */ |
116 |
+ |
|
117 |
|
VIEW *getview(); |
118 |
|
char *getexp(); |
119 |
|
|
120 |
+ |
extern time_t fdate(), time(); |
121 |
|
|
122 |
+ |
|
123 |
|
main(argc, argv) |
124 |
|
int argc; |
125 |
|
char *argv[]; |
150 |
|
cfname = argv[i]; |
151 |
|
/* load variables */ |
152 |
|
loadvars(cfname); |
153 |
+ |
/* check variables */ |
154 |
+ |
checkvalues(); |
155 |
|
/* did we get DIRECTORY? */ |
156 |
|
checkdir(); |
157 |
|
/* check status */ |
178 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
179 |
|
if (!silent) |
180 |
|
printargs(argc, argv, stdout); |
181 |
< |
execvp(progname, argv); /* pass to next */ |
182 |
< |
quit(1); /* shouldn't return */ |
181 |
> |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
182 |
> |
fprintf(stderr, "%s: command not found\n", progname); |
183 |
> |
else |
184 |
> |
execv(progname, argv); |
185 |
> |
quit(1); |
186 |
|
} |
187 |
|
quit(0); |
188 |
|
userr: |
193 |
|
|
194 |
|
getastat() /* check/set animation status */ |
195 |
|
{ |
196 |
< |
char buf[256]; |
196 |
> |
char sfname[256]; |
197 |
|
FILE *fp; |
198 |
|
|
199 |
< |
sprintf(buf, "%s/%s", vval(DIRECTORY), SFNAME); |
200 |
< |
if ((fp = fopen(buf, "r")) == NULL) { |
199 |
> |
sprintf(sfname, "%s/%s", vval(DIRECTORY), SFNAME); |
200 |
> |
if ((fp = fopen(sfname, "r")) == NULL) { |
201 |
|
if (errno != ENOENT) { |
202 |
< |
perror(buf); |
202 |
> |
perror(sfname); |
203 |
|
return(-1); |
204 |
|
} |
205 |
|
astat.rnext = astat.fnext = astat.tnext = 0; |
219 |
|
goto fmterr; |
220 |
|
fclose(fp); |
221 |
|
if (astat.pid != 0) { /* thinks it's still running */ |
222 |
< |
gethostname(buf, sizeof(buf)); |
203 |
< |
if (strcmp(buf, astat.host)) { |
222 |
> |
if (strcmp(myhostname(), astat.host)) { |
223 |
|
fprintf(stderr, |
224 |
|
"%s: process %d may still be running on host %s\n", |
225 |
|
progname, astat.pid, astat.host); |
232 |
|
} |
233 |
|
/* assume it is dead */ |
234 |
|
} |
235 |
< |
if (strcmp(cfname, astat.cfname) && astat.tnext != 0) { /* other's */ |
235 |
> |
if (strcmp(cfname, astat.cfname) && astat.pid != 0) { /* other's */ |
236 |
|
fprintf(stderr, "%s: unfinished job \"%s\"\n", |
237 |
|
progname, astat.cfname); |
238 |
|
return(-1); |
239 |
|
} |
240 |
+ |
/* check control file mods. */ |
241 |
+ |
if (!nowarn && fdate(cfname) > fdate(sfname)) |
242 |
+ |
fprintf(stderr, |
243 |
+ |
"%s: warning - control file modified since last run\n", |
244 |
+ |
progname); |
245 |
|
setours: /* set our values */ |
246 |
< |
gethostname(astat.host, sizeof(astat.host)); |
246 |
> |
strcpy(astat.host, myhostname()); |
247 |
|
astat.pid = getpid(); |
248 |
|
strcpy(astat.cfname, cfname); |
249 |
|
return(0); |
250 |
|
fmterr: |
251 |
|
fprintf(stderr, "%s: format error in status file \"%s\"\n", |
252 |
< |
progname, buf); |
252 |
> |
progname, sfname); |
253 |
|
fclose(fp); |
254 |
|
return(-1); |
255 |
|
} |
301 |
|
|
302 |
|
setdefaults() /* set default values */ |
303 |
|
{ |
304 |
+ |
extern char *atos(); |
305 |
+ |
int decades; |
306 |
|
char buf[256]; |
307 |
|
|
308 |
|
if (vdef(ANIMATE)) { |
326 |
|
vdef(START)++; |
327 |
|
} |
328 |
|
if (!vdef(END)) { |
329 |
< |
sprintf(buf, "%d", countviews()); |
329 |
> |
sprintf(buf, "%d", countviews()+vint(START)-1); |
330 |
|
vval(END) = savqstr(buf); |
331 |
|
vdef(END)++; |
332 |
|
} |
333 |
+ |
if (vint(END) < vint(START)) { |
334 |
+ |
fprintf(stderr, "%s: ending frame less than starting frame\n", |
335 |
+ |
progname); |
336 |
+ |
quit(1); |
337 |
+ |
} |
338 |
|
if (!vdef(BASENAME)) { |
339 |
< |
sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); |
339 |
> |
decades = (int)log10((double)vint(END)) + 1; |
340 |
> |
if (decades < 3) decades = 3; |
341 |
> |
sprintf(buf, "%s/frame%%0%dd", vval(DIRECTORY), decades); |
342 |
|
vval(BASENAME) = savqstr(buf); |
343 |
|
vdef(BASENAME)++; |
344 |
|
} |
370 |
|
vval(DISKSPACE) = "100"; |
371 |
|
vdef(DISKSPACE)++; |
372 |
|
} |
373 |
+ |
if (!vdef(RSH)) { |
374 |
+ |
vval(RSH) = REMSH; |
375 |
+ |
vdef(RSH)++; |
376 |
+ |
} |
377 |
+ |
/* locate remote shell program */ |
378 |
+ |
atos(buf, sizeof(buf), vval(RSH)); |
379 |
+ |
if ((remsh = getpath(buf, getenv("PATH"), X_OK)) != NULL) |
380 |
+ |
remsh = savqstr(remsh); |
381 |
+ |
else |
382 |
+ |
remsh = vval(RSH); /* will generate error if used */ |
383 |
+ |
|
384 |
|
/* append rendering options */ |
385 |
|
if (vdef(RENDER)) |
386 |
|
sprintf(rendopt+strlen(rendopt), " %s", vval(RENDER)); |
443 |
|
} |
444 |
|
|
445 |
|
|
446 |
< |
getradfile(rfname) /* run rad and get needed variables */ |
447 |
< |
char *rfname; |
446 |
> |
getradfile(rfargs) /* run rad and get needed variables */ |
447 |
> |
char *rfargs; |
448 |
|
{ |
449 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
450 |
|
char combuf[256]; |
454 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
455 |
|
sprintf(combuf, |
456 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
457 |
< |
rfname, rendopt+2); |
457 |
> |
rfargs, rendopt+2); |
458 |
|
cp = combuf; |
459 |
|
while (*cp) cp++; /* match unset variables */ |
460 |
|
for (i = 0; mvar[i] >= 0; i++) |
466 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
467 |
|
cp += 11; /* point to file name */ |
468 |
|
if (system(combuf)) { |
469 |
< |
fprintf(stderr, "%s: bad rad input file \"%s\"\n", |
470 |
< |
progname, rfname); |
469 |
> |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
470 |
> |
progname, combuf); |
471 |
|
quit(1); |
472 |
|
} |
473 |
|
loadvars(cp); /* load variables and remove file */ |
486 |
|
i = sscanf(vval(RESOLUTION), "%d %d %f", &xres, &yres, &pa); |
487 |
|
mult = vflt(OVERSAMP); |
488 |
|
if (i == 3) { |
489 |
< |
sprintf(rresopt, "-x %d -y %d -pa %f", (int)(mult*xres), |
489 |
> |
sprintf(rresopt, "-x %d -y %d -pa %.3f", (int)(mult*xres), |
490 |
|
(int)(mult*yres), pa); |
491 |
< |
sprintf(fresopt, "-x %d -y %d -pa %f", xres, yres, pa); |
491 |
> |
sprintf(fresopt, "-x %d -y %d -pa %.3f", xres, yres, pa); |
492 |
|
} else if (i) { |
493 |
|
if (i == 1) yres = xres; |
494 |
|
sprintf(rresopt, "-x %d -y %d", (int)(mult*xres), |
516 |
|
/* figure # frames per batch */ |
517 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
518 |
|
if ((i=vint(INTERP)) || atoi(vval(MBLUR))) |
519 |
< |
d1 += mult*xres*mult*yres*4; /* space for z-buffer */ |
519 |
> |
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
520 |
|
d2 = xres*yres*4; /* space for final picture */ |
521 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
522 |
|
if (frames_batch < i+2) { |
524 |
|
progname); |
525 |
|
quit(1); |
526 |
|
} |
527 |
+ |
/* initialize archive argument list */ |
528 |
+ |
i = 16; |
529 |
+ |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
530 |
+ |
i = strlen(vval(ARCHIVE)); |
531 |
+ |
arcnext = arcfirst = arcargs + i; |
532 |
|
/* initialize status file */ |
533 |
|
if (astat.rnext == 0) |
534 |
|
astat.rnext = astat.fnext = astat.tnext = vint(START); |
623 |
|
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
624 |
|
} |
625 |
|
bwait(0); /* wait for filter processes */ |
626 |
< |
archive(astat.fnext, i-1); /* archive originals */ |
626 |
> |
archive(); /* archive originals */ |
627 |
|
astat.fnext = i; /* update status */ |
628 |
|
putastat(); |
629 |
|
} |
685 |
|
char *vfn; |
686 |
|
{ |
687 |
|
char combuf[2048]; |
688 |
+ |
char *inspoint; |
689 |
|
register int i; |
690 |
|
|
691 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
696 |
|
close(open(combuf, O_RDONLY|O_CREAT, 0666)); |
697 |
|
} |
698 |
|
/* create command */ |
699 |
< |
sprintf(combuf, "rpict%s -w0 ", rendopt); |
699 |
> |
sprintf(combuf, "rpict%s -w0", rendopt); |
700 |
|
if (vint(INTERP) || atoi(vval(MBLUR))) |
701 |
< |
sprintf(combuf+strlen(combuf), "-z %s.zbf ", vval(BASENAME)); |
702 |
< |
sprintf(combuf+strlen(combuf), "-o %s.unf %s -S %d %s < %s", |
703 |
< |
vval(BASENAME), rresopt, first, vval(OCTREE), vfn); |
701 |
> |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
702 |
> |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
703 |
> |
vval(BASENAME), rresopt, first); |
704 |
> |
inspoint = combuf + strlen(combuf); |
705 |
> |
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
706 |
|
/* run in parallel */ |
707 |
< |
if (pruncom(combuf, (last-first+1)/(vint(INTERP)+1))) { |
707 |
> |
i = (last-first+1)/(vint(INTERP)+1); |
708 |
> |
if (i < 1) i = 1; |
709 |
> |
if (pruncom(combuf, inspoint, i)) { |
710 |
|
fprintf(stderr, "%s: error rendering frames %d through %d\n", |
711 |
|
progname, first, last); |
712 |
|
quit(1); |
784 |
|
} |
785 |
|
|
786 |
|
|
787 |
< |
archive(first, last) /* archive and remove renderings */ |
734 |
< |
int first, last; |
787 |
> |
archive() /* archive and remove renderings */ |
788 |
|
{ |
789 |
|
#define RMCOML (sizeof(rmcom)-1) |
790 |
|
static char rmcom[] = "rm -f"; |
738 |
– |
int offset = RMCOML; |
739 |
– |
char combuf[10240]; |
740 |
– |
struct stat stb; |
741 |
– |
register char *cp; |
791 |
|
register int i; |
792 |
|
|
793 |
< |
if (noaction) |
794 |
< |
return; |
746 |
< |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > offset) |
747 |
< |
offset = strlen(vval(ARCHIVE)); |
748 |
< |
cp = combuf + offset; |
749 |
< |
*cp++ = ' '; /* make argument list */ |
750 |
< |
for (i = first; i <= last; i++) { |
751 |
< |
sprintf(cp, vval(BASENAME), i); |
752 |
< |
strcat(cp, ".unf"); |
753 |
< |
if (stat(cp, &stb) == 0 && stb.st_size > 0) { /* non-zero? */ |
754 |
< |
while (*cp) cp++; |
755 |
< |
*cp++ = ' '; |
756 |
< |
sprintf(cp, vval(BASENAME), i); |
757 |
< |
strcat(cp, ".zbf"); |
758 |
< |
if (access(cp, F_OK) == 0) { /* exists? */ |
759 |
< |
while (*cp) cp++; |
760 |
< |
*cp++ = ' '; |
761 |
< |
} |
762 |
< |
} |
763 |
< |
} |
764 |
< |
*--cp = '\0'; |
765 |
< |
if (cp <= combuf + offset) /* no files? */ |
766 |
< |
return; |
793 |
> |
if (arcnext == arcfirst) |
794 |
> |
return; /* nothing to do */ |
795 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
796 |
|
i = strlen(vval(ARCHIVE)); |
797 |
< |
strncpy(combuf+offset-i, vval(ARCHIVE), i); |
798 |
< |
if (runcom(combuf+offset-i)) { |
799 |
< |
fprintf(stderr, |
800 |
< |
"%s: error running archive command on frames %d through %d\n", |
773 |
< |
progname, first, last); |
797 |
> |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
798 |
> |
if (runcom(arcfirst-i)) { |
799 |
> |
fprintf(stderr, "%s: error running archive command\n", |
800 |
> |
progname); |
801 |
|
quit(1); |
802 |
|
} |
803 |
|
} |
804 |
|
/* run remove command */ |
805 |
< |
strncpy(combuf+offset-RMCOML, rmcom, RMCOML); |
806 |
< |
runcom(combuf+offset-RMCOML); |
805 |
> |
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
806 |
> |
runcom(arcfirst-RMCOML); |
807 |
> |
arcnext = arcfirst; /* reset argument list */ |
808 |
|
#undef RMCOML |
809 |
|
} |
810 |
|
|
817 |
|
int rvr; |
818 |
|
{ |
819 |
|
extern int frecover(); |
820 |
+ |
static int iter = 0; |
821 |
|
char fnbefore[128], fnafter[128]; |
822 |
< |
char combuf[1024], fname[128]; |
823 |
< |
int usepinterp, usepfilt; |
822 |
> |
char combuf[1024], fname0[128], fname1[128]; |
823 |
> |
int usepinterp, usepfilt, nora_rgbe; |
824 |
|
int frseq[2]; |
825 |
|
/* check what is needed */ |
826 |
|
usepinterp = atoi(vval(MBLUR)); |
827 |
|
usepfilt = pfiltalways | ep==NULL; |
828 |
+ |
if (ep != NULL && !strcmp(ep, "1")) |
829 |
+ |
ep = "+0"; |
830 |
+ |
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
831 |
+ |
*ep != '+' || *ep != '-' || !isint(ep); |
832 |
|
/* compute rendered views */ |
833 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
834 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
837 |
|
if (frseq[1] == frame) { /* pfilt only */ |
838 |
|
frseq[0] = frseq[1]; |
839 |
|
usepinterp = 0; /* update what's needed */ |
840 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
841 |
< |
} else if (frseq[0] == frame) { /* no interpolation */ |
842 |
< |
/* update what's needed */ |
843 |
< |
if (!usepinterp) |
844 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
840 |
> |
usepfilt |= nora_rgbe; |
841 |
> |
} else if (frseq[0] == frame) { /* no interpolation needed */ |
842 |
> |
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
843 |
> |
*arcnext++ = ' '; |
844 |
> |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
845 |
> |
while (*arcnext) arcnext++; |
846 |
> |
strcpy(arcnext, ".unf"); |
847 |
> |
arcnext += 4; |
848 |
> |
if (usepinterp || vint(INTERP)) { /* and Z-buf */ |
849 |
> |
*arcnext++ = ' '; |
850 |
> |
sprintf(arcnext, vval(BASENAME), |
851 |
> |
frame-vint(INTERP)-1); |
852 |
> |
while (*arcnext) arcnext++; |
853 |
> |
strcpy(arcnext, ".zbf"); |
854 |
> |
arcnext += 4; |
855 |
> |
} |
856 |
> |
} |
857 |
> |
if (!usepinterp) /* update what's needed */ |
858 |
> |
usepfilt |= nora_rgbe; |
859 |
|
} else /* interpolation needed */ |
860 |
|
usepinterp++; |
861 |
|
if (frseq[1] >= astat.rnext) /* next batch unavailable */ |
870 |
|
return(1); |
871 |
|
if (atoi(vval(MBLUR))) { |
872 |
|
FILE *fp; /* motion blurring */ |
873 |
< |
sprintf(fname, "%s/vw0", vval(DIRECTORY)); |
874 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
875 |
< |
perror(fname); quit(1); |
873 |
> |
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
874 |
> |
'a'+(iter%26)); |
875 |
> |
if ((fp = fopen(fname0, "w")) == NULL) { |
876 |
> |
perror(fname0); quit(1); |
877 |
|
} |
878 |
|
fputs(VIEWSTR, fp); |
879 |
|
fprintview(vp, fp); |
884 |
|
progname, frame+1); |
885 |
|
quit(1); |
886 |
|
} |
887 |
< |
sprintf(fname, "%s/vw1", vval(DIRECTORY)); |
888 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
889 |
< |
perror(fname); quit(1); |
887 |
> |
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
888 |
> |
'a'+(iter%26)); |
889 |
> |
if ((fp = fopen(fname1, "w")) == NULL) { |
890 |
> |
perror(fname1); quit(1); |
891 |
|
} |
892 |
|
fputs(VIEWSTR, fp); |
893 |
|
fprintview(vp, fp); |
894 |
|
putc('\n', fp); fclose(fp); |
895 |
|
sprintf(combuf, |
896 |
< |
"(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B", |
896 |
> |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
897 |
|
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
898 |
< |
atoi(vval(MBLUR)), vval(DIRECTORY), |
899 |
< |
vval(DIRECTORY), vval(DIRECTORY), |
900 |
< |
vval(DIRECTORY), vval(DIRECTORY)); |
898 |
> |
atoi(vval(MBLUR)), |
899 |
> |
fname0, fname1, fname0, fname1); |
900 |
> |
iter++; |
901 |
|
} else /* no blurring */ |
902 |
|
strcpy(combuf, "pinterp"); |
903 |
|
strcat(combuf, viewopt(vp)); |
904 |
|
if (vbool(RTRACE)) |
905 |
|
sprintf(combuf+strlen(combuf), " -ff -fr '%s -w0 %s'", |
906 |
< |
rendopt, vval(OCTREE)); |
906 |
> |
rendopt+1, vval(OCTREE)); |
907 |
|
if (vdef(PINTERP)) |
908 |
|
sprintf(combuf+strlen(combuf), " %s", vval(PINTERP)); |
909 |
|
if (usepfilt) |
944 |
|
} else { /* else just check it */ |
945 |
|
if (rvr == 2) |
946 |
|
return(1); |
947 |
< |
sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore); |
947 |
> |
sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore); |
948 |
|
} |
949 |
|
/* output file name */ |
950 |
< |
sprintf(fname, vval(BASENAME), frame); |
951 |
< |
sprintf(combuf+strlen(combuf), " > %s.pic", fname); |
950 |
> |
sprintf(fname0, vval(BASENAME), frame); |
951 |
> |
sprintf(combuf+strlen(combuf), " > %s.pic", fname0); |
952 |
|
if (rvr) /* in recovery */ |
953 |
|
return(runcom(combuf)); |
954 |
|
bruncom(combuf, frame, frecover); /* else run in background */ |
980 |
|
quit(1); |
981 |
|
} |
982 |
|
} else if (n < viewnum) { /* rewind file */ |
983 |
+ |
if (viewnum == 1 && feof(viewfp)) |
984 |
+ |
return(&curview); /* just one view */ |
985 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
986 |
|
perror(vval(VIEWFILE)); |
987 |
|
quit(1); |
991 |
|
} |
992 |
|
while (n > viewnum) { /* scan to desired view */ |
993 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
994 |
< |
return(NULL); |
994 |
> |
return(viewnum==1 ? &curview : (VIEW *)NULL); |
995 |
|
if (isview(linebuf) && sscanview(&curview, linebuf) > 0) |
996 |
|
viewnum++; |
997 |
|
} |
1024 |
|
if (n == 0) { /* signal to close file */ |
1025 |
|
if (expfp != NULL) { |
1026 |
|
fclose(expfp); |
1027 |
+ |
free((char *)exppos); |
1028 |
|
expfp = NULL; |
1029 |
|
} |
1030 |
|
return(NULL); |
1031 |
< |
} |
1031 |
> |
} else if (n > vint(END)) /* request past end (error?) */ |
1032 |
> |
return(NULL); |
1033 |
|
if (!vdef(EXPOSURE)) /* no setting (auto) */ |
1034 |
|
return(NULL); |
1035 |
|
if (isflt(vval(EXPOSURE))) /* always the same */ |
1067 |
|
} |
1068 |
|
curfrm++; |
1069 |
|
cp = fskip(expval); /* check format */ |
1070 |
< |
if (cp == NULL || *cp != '\n') { |
1070 |
> |
if (cp != NULL) |
1071 |
> |
while (isspace(*cp)) |
1072 |
> |
*cp++ = '\0'; |
1073 |
> |
if (cp == NULL || *cp) { |
1074 |
|
fprintf(stderr, |
1075 |
|
"%s: exposure format error on line %d\n", |
1076 |
|
vval(EXPOSURE), curfrm); |
1077 |
|
quit(1); |
1078 |
|
} |
1023 |
– |
*cp = '\0'; |
1079 |
|
} |
1080 |
|
return(expval); /* return value */ |
1081 |
|
} |
1105 |
|
int status; |
1106 |
|
{ |
1107 |
|
register PROC *pp; |
1108 |
+ |
register struct pslot *psl; |
1109 |
|
|
1110 |
|
pp = ps->proc + pn; |
1055 |
– |
if (!silent) { /* echo command */ |
1056 |
– |
if (ps->hostname[0]) |
1057 |
– |
printf("On %s:", ps->hostname); |
1058 |
– |
printf("\t%s\n", pp->com); |
1059 |
– |
fflush(stdout); |
1060 |
– |
} |
1111 |
|
if (pp->elen) { /* pass errors */ |
1112 |
+ |
if (ps->hostname[0]) |
1113 |
+ |
fprintf(stderr, "%s: ", ps->hostname); |
1114 |
+ |
fprintf(stderr, "Error output from: %s\n", pp->com); |
1115 |
|
fputs(pp->errs, stderr); |
1116 |
|
fflush(stderr); |
1117 |
|
if (ps->hostname[0]) |
1118 |
|
status = 1; /* because rsh doesn't return status */ |
1119 |
|
} |
1120 |
+ |
lastpserver = NULL; |
1121 |
+ |
psl = findpslot(pp->pid); /* check for bruncom() slot */ |
1122 |
+ |
if (psl->pid) { |
1123 |
+ |
if (status) { |
1124 |
+ |
if (psl->rcvf != NULL) /* attempt recovery */ |
1125 |
+ |
status = (*psl->rcvf)(psl->fout); |
1126 |
+ |
if (status) { |
1127 |
+ |
fprintf(stderr, |
1128 |
+ |
"%s: error rendering frame %d\n", |
1129 |
+ |
progname, psl->fout); |
1130 |
+ |
quit(1); |
1131 |
+ |
} |
1132 |
+ |
lastpserver = ps; |
1133 |
+ |
} |
1134 |
+ |
psl->pid = 0; /* free process slot */ |
1135 |
+ |
} else if (status) |
1136 |
+ |
lastpserver = ps; |
1137 |
|
freestr(pp->com); /* free command string */ |
1068 |
– |
lastpid = pp->pid; /* record PID for bwait() */ |
1069 |
– |
lastpserver = ps; /* record server for serverdown() */ |
1138 |
|
return(status); |
1139 |
|
} |
1140 |
|
|
1142 |
|
int |
1143 |
|
serverdown() /* check status of last process server */ |
1144 |
|
{ |
1145 |
+ |
if (lastpserver == NULL || !lastpserver->hostname[0]) |
1146 |
+ |
return(0); |
1147 |
|
if (pserverOK(lastpserver)) /* server still up? */ |
1148 |
|
return(0); |
1149 |
|
delpserver(lastpserver); /* else delete it */ |
1167 |
|
|
1168 |
|
if (noaction) { |
1169 |
|
if (!silent) |
1170 |
< |
printf("\t%s\n", com); /* just echo it */ |
1170 |
> |
printf("\t%s\n", com); /* echo command */ |
1171 |
|
return(0); |
1172 |
|
} |
1173 |
< |
/* else start it when we can */ |
1174 |
< |
while ((pid = startjob(NULL, savestr(com), donecom)) == -1) |
1173 |
> |
com = savestr(com); /* else start it when we can */ |
1174 |
> |
while ((pid = startjob(NULL, com, donecom)) == -1) |
1175 |
|
bwait(1); |
1176 |
+ |
if (!silent) { /* echo command */ |
1177 |
+ |
PSERVER *ps; |
1178 |
+ |
int psn = pid; |
1179 |
+ |
ps = findjob(&psn); |
1180 |
+ |
printf("\t%s\n", com); |
1181 |
+ |
printf("\tProcess started on %s\n", phostname(ps)); |
1182 |
+ |
fflush(stdout); |
1183 |
+ |
} |
1184 |
|
psl = findpslot(pid); /* record info. in appropriate slot */ |
1185 |
|
psl->pid = pid; |
1186 |
|
psl->fout = fout; |
1193 |
|
int ncoms; |
1194 |
|
{ |
1195 |
|
int status; |
1118 |
– |
register struct pslot *psl; |
1196 |
|
|
1197 |
|
if (noaction) |
1198 |
|
return; |
1199 |
|
while ((status = wait4job(NULL, -1)) != -1) { |
1200 |
< |
psl = findpslot(lastpid); |
1201 |
< |
if (status) { /* attempt recovery */ |
1202 |
< |
serverdown(); /* check server */ |
1126 |
< |
if (psl->rcvf == NULL || (*psl->rcvf)(psl->fout)) { |
1127 |
< |
fprintf(stderr, |
1128 |
< |
"%s: error rendering frame %d\n", |
1129 |
< |
progname, psl->fout); |
1130 |
< |
quit(1); |
1131 |
< |
} |
1132 |
< |
} |
1133 |
< |
psl->pid = 0; /* free process slot */ |
1134 |
< |
if (!--ncoms) |
1135 |
< |
return; /* done enough */ |
1200 |
> |
serverdown(); /* update server status */ |
1201 |
> |
if (--ncoms == 0) |
1202 |
> |
break; /* done enough */ |
1203 |
|
} |
1204 |
|
} |
1205 |
|
|
1206 |
|
|
1207 |
|
int |
1208 |
< |
pruncom(com, maxcopies) /* run a command in parallel over network */ |
1209 |
< |
char *com; |
1208 |
> |
pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ |
1209 |
> |
char *com, *ppins; |
1210 |
|
int maxcopies; |
1211 |
|
{ |
1212 |
|
int retstatus = 0; |
1213 |
+ |
int hostcopies; |
1214 |
+ |
char buf[10240], *com1, *s; |
1215 |
|
int status; |
1216 |
+ |
int pfd; |
1217 |
+ |
register int n; |
1218 |
|
register PSERVER *ps; |
1219 |
|
|
1220 |
< |
if (noaction) { |
1221 |
< |
if (!silent) |
1222 |
< |
printf("\t%s\n", com); /* just echo */ |
1220 |
> |
if (!silent) |
1221 |
> |
printf("\t%s\n", com); /* echo command */ |
1222 |
> |
if (noaction) |
1223 |
|
return(0); |
1224 |
< |
} |
1224 |
> |
fflush(stdout); |
1225 |
|
/* start jobs on each server */ |
1226 |
< |
for (ps = pslist; ps != NULL; ps = ps->next) |
1227 |
< |
while (maxcopies > 0 && |
1228 |
< |
startjob(ps, savestr(com), donecom) != -1) { |
1229 |
< |
sleep(10); |
1230 |
< |
maxcopies--; |
1226 |
> |
for (ps = pslist; ps != NULL; ps = ps->next) { |
1227 |
> |
hostcopies = 0; |
1228 |
> |
if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { |
1229 |
> |
strcpy(com1=buf, com); /* build -PP command */ |
1230 |
> |
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1231 |
> |
vval(DIRECTORY), phostname(ps)); |
1232 |
> |
strcat(com1, ppins); |
1233 |
> |
} else |
1234 |
> |
com1 = com; |
1235 |
> |
while (maxcopies > 0) { |
1236 |
> |
s = savestr(com1); |
1237 |
> |
if (startjob(ps, s, donecom) != -1) { |
1238 |
> |
sleep(20); |
1239 |
> |
hostcopies++; |
1240 |
> |
maxcopies--; |
1241 |
> |
} else { |
1242 |
> |
freestr(s); |
1243 |
> |
break; |
1244 |
> |
} |
1245 |
|
} |
1246 |
+ |
if (!silent && hostcopies) { |
1247 |
+ |
if (hostcopies > 1) |
1248 |
+ |
printf("\t%d duplicate processes", hostcopies); |
1249 |
+ |
else |
1250 |
+ |
printf("\tProcess"); |
1251 |
+ |
printf(" started on %s\n", phostname(ps)); |
1252 |
+ |
fflush(stdout); |
1253 |
+ |
} |
1254 |
+ |
} |
1255 |
|
/* wait for jobs to finish */ |
1256 |
|
while ((status = wait4job(NULL, -1)) != -1) |
1257 |
< |
if (status) |
1258 |
< |
retstatus += !serverdown(); /* check server */ |
1257 |
> |
retstatus += status && !serverdown(); |
1258 |
> |
/* terminate parallel rpict's */ |
1259 |
> |
for (ps = pslist; ps != NULL; ps = ps->next) { |
1260 |
> |
sprintf(buf, "%s/%s.persist", vval(DIRECTORY), phostname(ps)); |
1261 |
> |
if ((pfd = open(buf, O_RDONLY)) >= 0) { |
1262 |
> |
n = read(pfd, buf, sizeof(buf)-1); /* get PID */ |
1263 |
> |
buf[n] = '\0'; |
1264 |
> |
close(pfd); |
1265 |
> |
for (n = 0; buf[n] && !isspace(buf[n]); n++) |
1266 |
> |
; |
1267 |
> |
/* terminate */ |
1268 |
> |
sprintf(buf, "kill -ALRM %d", atoi(buf+n)); |
1269 |
> |
wait4job(ps, startjob(ps, buf, NULL)); |
1270 |
> |
} |
1271 |
> |
} |
1272 |
|
return(retstatus); |
1273 |
|
} |
1274 |
|
|