--- ray/src/util/ranimate.c 1996/01/18 11:25:11 2.2 +++ ray/src/util/ranimate.c 1996/01/22 17:19:37 2.4 @@ -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(); @@ -636,6 +638,7 @@ int first, last; char *vfn; { char combuf[2048]; + char *inspoint; register int i; if (!noaction && vint(INTERP)) /* create dummy frames */ @@ -646,13 +649,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); @@ -1052,13 +1057,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]) @@ -1095,14 +1097,21 @@ int (*rf)(); int pid; register struct pslot *psl; - if (noaction) { - if (!silent) - printf("\t%s\n", com); /* just echo it */ + if (!silent) + printf("\t%s &\n", com); /* echo command */ + if (noaction) return(0); - } + fflush(stdout); /* else start it when we can */ while ((pid = startjob(NULL, savestr(com), donecom)) == -1) bwait(1); + if (!silent) { + PSERVER *ps; + int psn = pid; + ps = findjob(&psn); + 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 +1147,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)