57 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
58 |
|
{"TRANSFER", 2, 0, NULL, onevalue}, |
59 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
60 |
< |
{"INTERP", 3, 0, NULL, intvalue}, |
61 |
< |
{"OVERSAMP", 2, 0, NULL, fltvalue}, |
60 |
> |
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
61 |
> |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
62 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
63 |
|
{"RTRACE", 2, 0, NULL, boolvalue}, |
64 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
89 |
|
char fresopt[32]; /* filter resolution options */ |
90 |
|
int pfiltalways; /* always use pfilt? */ |
91 |
|
|
92 |
+ |
char arcargs[10240]; /* files to archive */ |
93 |
+ |
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
94 |
+ |
|
95 |
|
struct pslot { |
96 |
|
int pid; /* process ID (0 if empty) */ |
97 |
|
int fout; /* output frame number */ |
102 |
|
int lastpid; /* ID of last completed background process */ |
103 |
|
PSERVER *lastpserver; /* last process server used */ |
104 |
|
|
105 |
+ |
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
106 |
+ |
|
107 |
|
struct pslot *findpslot(); |
108 |
|
|
109 |
|
VIEW *getview(); |
305 |
|
vdef(START)++; |
306 |
|
} |
307 |
|
if (!vdef(END)) { |
308 |
< |
sprintf(buf, "%d", countviews()); |
308 |
> |
sprintf(buf, "%d", countviews()+vint(START)-1); |
309 |
|
vval(END) = savqstr(buf); |
310 |
|
vdef(END)++; |
311 |
|
} |
312 |
+ |
if (vint(END) < vint(START)) { |
313 |
+ |
fprintf(stderr, "%s: ending frame less than starting frame\n", |
314 |
+ |
progname); |
315 |
+ |
quit(1); |
316 |
+ |
} |
317 |
|
if (!vdef(BASENAME)) { |
318 |
|
sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); |
319 |
|
vval(BASENAME) = savqstr(buf); |
409 |
|
} |
410 |
|
|
411 |
|
|
412 |
< |
getradfile(rfname) /* run rad and get needed variables */ |
413 |
< |
char *rfname; |
412 |
> |
getradfile(rfargs) /* run rad and get needed variables */ |
413 |
> |
char *rfargs; |
414 |
|
{ |
415 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
416 |
|
char combuf[256]; |
420 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
421 |
|
sprintf(combuf, |
422 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
423 |
< |
rfname, rendopt+2); |
423 |
> |
rfargs, rendopt+2); |
424 |
|
cp = combuf; |
425 |
|
while (*cp) cp++; /* match unset variables */ |
426 |
|
for (i = 0; mvar[i] >= 0; i++) |
432 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
433 |
|
cp += 11; /* point to file name */ |
434 |
|
if (system(combuf)) { |
435 |
< |
fprintf(stderr, "%s: bad rad input file \"%s\"\n", |
436 |
< |
progname, rfname); |
435 |
> |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
436 |
> |
progname, combuf); |
437 |
|
quit(1); |
438 |
|
} |
439 |
|
loadvars(cp); /* load variables and remove file */ |
490 |
|
progname); |
491 |
|
quit(1); |
492 |
|
} |
493 |
+ |
/* initialize archive argument list */ |
494 |
+ |
i = 16; |
495 |
+ |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
496 |
+ |
i = strlen(vval(ARCHIVE)); |
497 |
+ |
arcnext = arcfirst = arcargs + i; |
498 |
|
/* initialize status file */ |
499 |
|
if (astat.rnext == 0) |
500 |
|
astat.rnext = astat.fnext = astat.tnext = vint(START); |
589 |
|
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
590 |
|
} |
591 |
|
bwait(0); /* wait for filter processes */ |
592 |
< |
archive(astat.fnext, i-1); /* archive originals */ |
592 |
> |
archive(); /* archive originals */ |
593 |
|
astat.fnext = i; /* update status */ |
594 |
|
putastat(); |
595 |
|
} |
651 |
|
char *vfn; |
652 |
|
{ |
653 |
|
char combuf[2048]; |
654 |
+ |
char *inspoint; |
655 |
|
register int i; |
656 |
|
|
657 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
662 |
|
close(open(combuf, O_RDONLY|O_CREAT, 0666)); |
663 |
|
} |
664 |
|
/* create command */ |
665 |
< |
sprintf(combuf, "rpict%s -w0 ", rendopt); |
665 |
> |
sprintf(combuf, "rpict%s -w0", rendopt); |
666 |
|
if (vint(INTERP) || atoi(vval(MBLUR))) |
667 |
< |
sprintf(combuf+strlen(combuf), "-z %s.zbf ", vval(BASENAME)); |
668 |
< |
sprintf(combuf+strlen(combuf), "-o %s.unf %s -S %d %s < %s", |
669 |
< |
vval(BASENAME), rresopt, first, vval(OCTREE), vfn); |
667 |
> |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
668 |
> |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
669 |
> |
vval(BASENAME), rresopt, first); |
670 |
> |
inspoint = combuf + strlen(combuf); |
671 |
> |
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
672 |
|
/* run in parallel */ |
673 |
< |
if (pruncom(combuf, (last-first+1)/(vint(INTERP)+1))) { |
673 |
> |
i = (last-first+1)/(vint(INTERP)+1); |
674 |
> |
if (i < 1) i = 1; |
675 |
> |
if (pruncom(combuf, inspoint, i)) { |
676 |
|
fprintf(stderr, "%s: error rendering frames %d through %d\n", |
677 |
|
progname, first, last); |
678 |
|
quit(1); |
750 |
|
} |
751 |
|
|
752 |
|
|
753 |
< |
archive(first, last) /* archive and remove renderings */ |
734 |
< |
int first, last; |
753 |
> |
archive() /* archive and remove renderings */ |
754 |
|
{ |
755 |
|
#define RMCOML (sizeof(rmcom)-1) |
756 |
|
static char rmcom[] = "rm -f"; |
738 |
– |
int offset = RMCOML; |
739 |
– |
char combuf[10240]; |
740 |
– |
struct stat stb; |
741 |
– |
register char *cp; |
757 |
|
register int i; |
758 |
|
|
759 |
< |
if (noaction) |
760 |
< |
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; |
759 |
> |
if (arcnext == arcfirst) |
760 |
> |
return; /* nothing to do */ |
761 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
762 |
|
i = strlen(vval(ARCHIVE)); |
763 |
< |
strncpy(combuf+offset-i, vval(ARCHIVE), i); |
764 |
< |
if (runcom(combuf+offset-i)) { |
765 |
< |
fprintf(stderr, |
766 |
< |
"%s: error running archive command on frames %d through %d\n", |
773 |
< |
progname, first, last); |
763 |
> |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
764 |
> |
if (runcom(arcfirst-i)) { |
765 |
> |
fprintf(stderr, "%s: error running archive command\n", |
766 |
> |
progname); |
767 |
|
quit(1); |
768 |
|
} |
769 |
|
} |
770 |
|
/* run remove command */ |
771 |
< |
strncpy(combuf+offset-RMCOML, rmcom, RMCOML); |
772 |
< |
runcom(combuf+offset-RMCOML); |
771 |
> |
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
772 |
> |
runcom(arcfirst-RMCOML); |
773 |
> |
arcnext = arcfirst; /* reset argument list */ |
774 |
|
#undef RMCOML |
775 |
|
} |
776 |
|
|
783 |
|
int rvr; |
784 |
|
{ |
785 |
|
extern int frecover(); |
786 |
+ |
static int iter = 0; |
787 |
|
char fnbefore[128], fnafter[128]; |
788 |
< |
char combuf[1024], fname[128]; |
789 |
< |
int usepinterp, usepfilt; |
788 |
> |
char combuf[1024], fname0[128], fname1[128]; |
789 |
> |
int usepinterp, usepfilt, nora_rgbe; |
790 |
|
int frseq[2]; |
791 |
|
/* check what is needed */ |
792 |
|
usepinterp = atoi(vval(MBLUR)); |
793 |
|
usepfilt = pfiltalways | ep==NULL; |
794 |
+ |
if (ep != NULL && !strcmp(ep, "1")) |
795 |
+ |
ep = "+0"; |
796 |
+ |
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
797 |
+ |
*ep != '+' || *ep != '-' || !isint(ep); |
798 |
|
/* compute rendered views */ |
799 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
800 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
803 |
|
if (frseq[1] == frame) { /* pfilt only */ |
804 |
|
frseq[0] = frseq[1]; |
805 |
|
usepinterp = 0; /* update what's needed */ |
806 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
807 |
< |
} else if (frseq[0] == frame) { /* no interpolation */ |
808 |
< |
/* update what's needed */ |
809 |
< |
if (!usepinterp) |
810 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
806 |
> |
usepfilt |= nora_rgbe; |
807 |
> |
} else if (frseq[0] == frame) { /* no interpolation needed */ |
808 |
> |
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
809 |
> |
*arcnext++ = ' '; |
810 |
> |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
811 |
> |
while (*arcnext) arcnext++; |
812 |
> |
strcpy(arcnext, ".unf"); |
813 |
> |
arcnext += 4; |
814 |
> |
if (usepinterp || vint(INTERP)) { /* and z-buf */ |
815 |
> |
*arcnext++ = ' '; |
816 |
> |
sprintf(arcnext, vval(BASENAME), |
817 |
> |
frame-vint(INTERP)-1); |
818 |
> |
while (*arcnext) arcnext++; |
819 |
> |
strcpy(arcnext, ".zbf"); |
820 |
> |
arcnext += 4; |
821 |
> |
} |
822 |
> |
} |
823 |
> |
if (!usepinterp) /* update what's needed */ |
824 |
> |
usepfilt |= nora_rgbe; |
825 |
|
} else /* interpolation needed */ |
826 |
|
usepinterp++; |
827 |
|
if (frseq[1] >= astat.rnext) /* next batch unavailable */ |
836 |
|
return(1); |
837 |
|
if (atoi(vval(MBLUR))) { |
838 |
|
FILE *fp; /* motion blurring */ |
839 |
< |
sprintf(fname, "%s/vw0", vval(DIRECTORY)); |
840 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
841 |
< |
perror(fname); quit(1); |
839 |
> |
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
840 |
> |
'a'+(iter%26)); |
841 |
> |
if ((fp = fopen(fname0, "w")) == NULL) { |
842 |
> |
perror(fname0); quit(1); |
843 |
|
} |
844 |
|
fputs(VIEWSTR, fp); |
845 |
|
fprintview(vp, fp); |
850 |
|
progname, frame+1); |
851 |
|
quit(1); |
852 |
|
} |
853 |
< |
sprintf(fname, "%s/vw1", vval(DIRECTORY)); |
854 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
855 |
< |
perror(fname); quit(1); |
853 |
> |
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
854 |
> |
'a'+(iter%26)); |
855 |
> |
if ((fp = fopen(fname1, "w")) == NULL) { |
856 |
> |
perror(fname1); quit(1); |
857 |
|
} |
858 |
|
fputs(VIEWSTR, fp); |
859 |
|
fprintview(vp, fp); |
860 |
|
putc('\n', fp); fclose(fp); |
861 |
|
sprintf(combuf, |
862 |
< |
"(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B", |
862 |
> |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
863 |
|
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
864 |
< |
atoi(vval(MBLUR)), vval(DIRECTORY), |
865 |
< |
vval(DIRECTORY), vval(DIRECTORY), |
866 |
< |
vval(DIRECTORY), vval(DIRECTORY)); |
864 |
> |
atoi(vval(MBLUR)), |
865 |
> |
fname0, fname1, fname0, fname1); |
866 |
> |
iter++; |
867 |
|
} else /* no blurring */ |
868 |
|
strcpy(combuf, "pinterp"); |
869 |
|
strcat(combuf, viewopt(vp)); |
910 |
|
} else { /* else just check it */ |
911 |
|
if (rvr == 2) |
912 |
|
return(1); |
913 |
< |
sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore); |
913 |
> |
sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore); |
914 |
|
} |
915 |
|
/* output file name */ |
916 |
< |
sprintf(fname, vval(BASENAME), frame); |
917 |
< |
sprintf(combuf+strlen(combuf), " > %s.pic", fname); |
916 |
> |
sprintf(fname0, vval(BASENAME), frame); |
917 |
> |
sprintf(combuf+strlen(combuf), " > %s.pic", fname0); |
918 |
|
if (rvr) /* in recovery */ |
919 |
|
return(runcom(combuf)); |
920 |
|
bruncom(combuf, frame, frecover); /* else run in background */ |
1067 |
|
register PROC *pp; |
1068 |
|
|
1069 |
|
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 |
– |
} |
1070 |
|
if (pp->elen) { /* pass errors */ |
1071 |
+ |
if (ps->hostname[0]) |
1072 |
+ |
fprintf(stderr, "%s: ", ps->hostname); |
1073 |
+ |
fprintf(stderr, "Error output from: %s\n", pp->com); |
1074 |
|
fputs(pp->errs, stderr); |
1075 |
|
fflush(stderr); |
1076 |
|
if (ps->hostname[0]) |
1109 |
|
|
1110 |
|
if (noaction) { |
1111 |
|
if (!silent) |
1112 |
< |
printf("\t%s\n", com); /* just echo it */ |
1112 |
> |
printf("\t%s\n", com); /* echo command */ |
1113 |
|
return(0); |
1114 |
|
} |
1115 |
|
/* else start it when we can */ |
1116 |
|
while ((pid = startjob(NULL, savestr(com), donecom)) == -1) |
1117 |
|
bwait(1); |
1118 |
+ |
if (!silent) { /* echo command */ |
1119 |
+ |
PSERVER *ps; |
1120 |
+ |
int psn = pid; |
1121 |
+ |
ps = findjob(&psn); |
1122 |
+ |
printf("\t%s\n", com); |
1123 |
+ |
printf("\tProcess started on %s\n", phostname(ps)); |
1124 |
+ |
fflush(stdout); |
1125 |
+ |
} |
1126 |
|
psl = findpslot(pid); /* record info. in appropriate slot */ |
1127 |
|
psl->pid = pid; |
1128 |
|
psl->fout = fout; |
1158 |
|
|
1159 |
|
|
1160 |
|
int |
1161 |
< |
pruncom(com, maxcopies) /* run a command in parallel over network */ |
1162 |
< |
char *com; |
1161 |
> |
pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ |
1162 |
> |
char *com, *ppins; |
1163 |
|
int maxcopies; |
1164 |
|
{ |
1165 |
|
int retstatus = 0; |
1166 |
+ |
int hostcopies; |
1167 |
+ |
char com1buf[10240], *com1, *endcom1; |
1168 |
|
int status; |
1169 |
|
register PSERVER *ps; |
1170 |
|
|
1171 |
< |
if (noaction) { |
1172 |
< |
if (!silent) |
1173 |
< |
printf("\t%s\n", com); /* just echo */ |
1171 |
> |
if (!silent) |
1172 |
> |
printf("\t%s\n", com); /* echo command */ |
1173 |
> |
if (noaction) |
1174 |
|
return(0); |
1175 |
< |
} |
1175 |
> |
fflush(stdout); |
1176 |
|
/* start jobs on each server */ |
1177 |
< |
for (ps = pslist; ps != NULL; ps = ps->next) |
1177 |
> |
for (ps = pslist; ps != NULL; ps = ps->next) { |
1178 |
> |
hostcopies = 0; |
1179 |
> |
if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { |
1180 |
> |
strcpy(com1=com1buf, com); /* build -PP command */ |
1181 |
> |
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1182 |
> |
vval(DIRECTORY), phostname(ps)); |
1183 |
> |
strcat(com1, ppins); |
1184 |
> |
endcom1 = com1 + strlen(com1); |
1185 |
> |
sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", |
1186 |
> |
vval(DIRECTORY), phostname(ps)); |
1187 |
> |
} else { |
1188 |
> |
com1 = com; |
1189 |
> |
endcom1 = NULL; |
1190 |
> |
} |
1191 |
|
while (maxcopies > 0 && |
1192 |
< |
startjob(ps, savestr(com), donecom) != -1) { |
1192 |
> |
startjob(ps, savestr(com1), donecom) != -1) { |
1193 |
|
sleep(10); |
1194 |
+ |
hostcopies++; |
1195 |
|
maxcopies--; |
1196 |
+ |
if (endcom1 != NULL) |
1197 |
+ |
*endcom1 = '\0'; |
1198 |
|
} |
1199 |
+ |
if (!silent && hostcopies) { |
1200 |
+ |
if (hostcopies > 1) |
1201 |
+ |
printf("\t%d duplicate processes", hostcopies); |
1202 |
+ |
else |
1203 |
+ |
printf("\tProcess"); |
1204 |
+ |
printf(" started on %s\n", phostname(ps)); |
1205 |
+ |
fflush(stdout); |
1206 |
+ |
} |
1207 |
+ |
} |
1208 |
|
/* wait for jobs to finish */ |
1209 |
|
while ((status = wait4job(NULL, -1)) != -1) |
1210 |
|
if (status) |