--- ray/src/util/ranimate.c 1996/01/18 11:25:11 2.2 +++ ray/src/util/ranimate.c 1996/01/23 17:01:33 2.6 @@ -57,8 +57,8 @@ VARIABLE vv[] = { /* variable-value pairs */ {"ANIMATE", 2, 0, NULL, onevalue}, {"TRANSFER", 2, 0, NULL, onevalue}, {"ARCHIVE", 2, 0, NULL, onevalue}, - {"INTERP", 3, 0, NULL, intvalue}, - {"OVERSAMP", 2, 0, NULL, fltvalue}, + {"INTERPOLATE", 3, 0, NULL, intvalue}, + {"OVERSAMPLE", 2, 0, NULL, fltvalue}, {"MBLUR", 2, 0, NULL, onevalue}, {"RTRACE", 2, 0, NULL, boolvalue}, {"DISKSPACE", 3, 0, NULL, fltvalue}, @@ -99,6 +99,8 @@ int npslots; /* number of process slots */ int lastpid; /* ID of last completed background process */ PSERVER *lastpserver; /* last process server used */ +#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) + struct pslot *findpslot(); VIEW *getview(); @@ -300,10 +302,15 @@ setdefaults() /* set default values */ vdef(START)++; } if (!vdef(END)) { - sprintf(buf, "%d", countviews()); + sprintf(buf, "%d", countviews()+vint(START)-1); vval(END) = savqstr(buf); vdef(END)++; } + if (vint(END) < vint(START)) { + fprintf(stderr, "%s: ending frame less than starting frame\n", + progname); + quit(1); + } if (!vdef(BASENAME)) { sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); vval(BASENAME) = savqstr(buf); @@ -636,6 +643,7 @@ int first, last; char *vfn; { char combuf[2048]; + char *inspoint; register int i; if (!noaction && vint(INTERP)) /* create dummy frames */ @@ -646,13 +654,15 @@ char *vfn; close(open(combuf, O_RDONLY|O_CREAT, 0666)); } /* create command */ - sprintf(combuf, "rpict%s -w0 ", rendopt); + sprintf(combuf, "rpict%s -w0", rendopt); if (vint(INTERP) || atoi(vval(MBLUR))) - sprintf(combuf+strlen(combuf), "-z %s.zbf ", vval(BASENAME)); - sprintf(combuf+strlen(combuf), "-o %s.unf %s -S %d %s < %s", - vval(BASENAME), rresopt, first, vval(OCTREE), vfn); + sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); + sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", + vval(BASENAME), rresopt, first); + inspoint = combuf + strlen(combuf); + sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); /* run in parallel */ - if (pruncom(combuf, (last-first+1)/(vint(INTERP)+1))) { + if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) { fprintf(stderr, "%s: error rendering frames %d through %d\n", progname, first, last); quit(1); @@ -789,8 +799,9 @@ char *ep; int rvr; { extern int frecover(); + static int iter = 0; char fnbefore[128], fnafter[128]; - char combuf[1024], fname[128]; + char combuf[1024], fname0[128], fname1[128]; int usepinterp, usepfilt; int frseq[2]; /* check what is needed */ @@ -823,9 +834,10 @@ int rvr; return(1); if (atoi(vval(MBLUR))) { FILE *fp; /* motion blurring */ - sprintf(fname, "%s/vw0", vval(DIRECTORY)); - if ((fp = fopen(fname, "w")) == NULL) { - perror(fname); quit(1); + sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), + 'a'+(iter%26)); + if ((fp = fopen(fname0, "w")) == NULL) { + perror(fname0); quit(1); } fputs(VIEWSTR, fp); fprintview(vp, fp); @@ -836,19 +848,20 @@ int rvr; progname, frame+1); quit(1); } - sprintf(fname, "%s/vw1", vval(DIRECTORY)); - if ((fp = fopen(fname, "w")) == NULL) { - perror(fname); quit(1); + sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), + 'a'+(iter%26)); + if ((fp = fopen(fname1, "w")) == NULL) { + perror(fname1); quit(1); } fputs(VIEWSTR, fp); fprintview(vp, fp); putc('\n', fp); fclose(fp); sprintf(combuf, - "(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B", + "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", - atoi(vval(MBLUR)), vval(DIRECTORY), - vval(DIRECTORY), vval(DIRECTORY), - vval(DIRECTORY), vval(DIRECTORY)); + atoi(vval(MBLUR)), + fname0, fname1, fname0, fname1); + iter++; } else /* no blurring */ strcpy(combuf, "pinterp"); strcat(combuf, viewopt(vp)); @@ -898,8 +911,8 @@ int rvr; sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore); } /* output file name */ - sprintf(fname, vval(BASENAME), frame); - sprintf(combuf+strlen(combuf), " > %s.pic", fname); + sprintf(fname0, vval(BASENAME), frame); + sprintf(combuf+strlen(combuf), " > %s.pic", fname0); if (rvr) /* in recovery */ return(runcom(combuf)); bruncom(combuf, frame, frecover); /* else run in background */ @@ -1052,13 +1065,10 @@ int status; register PROC *pp; pp = ps->proc + pn; - if (!silent) { /* echo command */ - if (ps->hostname[0]) - printf("On %s:", ps->hostname); - printf("\t%s\n", pp->com); - fflush(stdout); - } if (pp->elen) { /* pass errors */ + if (ps->hostname[0]) + fprintf(stderr, "%s: ", ps->hostname); + fprintf(stderr, "Error output from: %s\n", pp->com); fputs(pp->errs, stderr); fflush(stderr); if (ps->hostname[0]) @@ -1097,12 +1107,20 @@ int (*rf)(); if (noaction) { if (!silent) - printf("\t%s\n", com); /* just echo it */ + printf("\t%s\n", com); /* echo command */ return(0); } /* else start it when we can */ while ((pid = startjob(NULL, savestr(com), donecom)) == -1) bwait(1); + if (!silent) { /* echo command */ + PSERVER *ps; + int psn = pid; + ps = findjob(&psn); + printf("\t%s\n", com); + printf("\tProcess started on %s\n", phostname(ps)); + fflush(stdout); + } psl = findpslot(pid); /* record info. in appropriate slot */ psl->pid = pid; psl->fout = fout; @@ -1138,26 +1156,53 @@ int ncoms; int -pruncom(com, maxcopies) /* run a command in parallel over network */ -char *com; +pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ +char *com, *ppins; int maxcopies; { int retstatus = 0; + int hostcopies; + char com1buf[10240], *com1, *endcom1; int status; register PSERVER *ps; - if (noaction) { - if (!silent) - printf("\t%s\n", com); /* just echo */ + if (!silent) + printf("\t%s\n", com); /* echo command */ + if (noaction) return(0); - } + fflush(stdout); /* start jobs on each server */ - for (ps = pslist; ps != NULL; ps = ps->next) + for (ps = pslist; ps != NULL; ps = ps->next) { + hostcopies = 0; + if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { + strcpy(com1=com1buf, com); /* build -PP command */ + sprintf(com1+(ppins-com), " -PP %s/%s.persist", + vval(DIRECTORY), phostname(ps)); + strcat(com1, ppins); + endcom1 = com1 + strlen(com1); + sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", + vval(DIRECTORY), phostname(ps)); + } else { + com1 = com; + endcom1 = NULL; + } while (maxcopies > 0 && - startjob(ps, savestr(com), donecom) != -1) { + startjob(ps, savestr(com1), donecom) != -1) { sleep(10); + hostcopies++; maxcopies--; + if (endcom1 != NULL) + *endcom1 = '\0'; } + if (!silent && hostcopies) { + if (hostcopies > 1) + printf("\t%d duplicate processes", hostcopies); + else + printf("\tProcess"); + printf(" started on %s\n", phostname(ps)); + fflush(stdout); + } + } /* wait for jobs to finish */ while ((status = wait4job(NULL, -1)) != -1) if (status)