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

Comparing ray/src/util/ranimate.c (file contents):
Revision 2.2 by greg, Thu Jan 18 11:25:11 1996 UTC vs.
Revision 2.6 by greg, Tue Jan 23 17:01:33 1996 UTC

# Line 57 | Line 57 | VARIABLE       vv[] = {                /* variable-value pairs */
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},
# Line 99 | Line 99 | int    npslots;                /* number of process slots */
99   int     lastpid;                /* ID of last completed background process */
100   PSERVER *lastpserver;           /* last process server used */
101  
102 + #define phostname(ps)   ((ps)->hostname[0] ? (ps)->hostname : astat.host)
103 +
104   struct pslot    *findpslot();
105  
106   VIEW    *getview();
# Line 300 | Line 302 | setdefaults()                  /* set default values */
302                  vdef(START)++;
303          }
304          if (!vdef(END)) {
305 <                sprintf(buf, "%d", countviews());
305 >                sprintf(buf, "%d", countviews()+vint(START)-1);
306                  vval(END) = savqstr(buf);
307                  vdef(END)++;
308          }
309 +        if (vint(END) < vint(START)) {
310 +                fprintf(stderr, "%s: ending frame less than starting frame\n",
311 +                                progname);
312 +                quit(1);
313 +        }
314          if (!vdef(BASENAME)) {
315                  sprintf(buf, "%s/frame%%03d", vval(DIRECTORY));
316                  vval(BASENAME) = savqstr(buf);
# Line 636 | Line 643 | int    first, last;
643   char    *vfn;
644   {
645          char    combuf[2048];
646 +        char    *inspoint;
647          register int    i;
648  
649          if (!noaction && vint(INTERP))          /* create dummy frames */
# Line 646 | Line 654 | char   *vfn;
654                                  close(open(combuf, O_RDONLY|O_CREAT, 0666));
655                          }
656                                          /* create command */
657 <        sprintf(combuf, "rpict%s -w0 ", rendopt);
657 >        sprintf(combuf, "rpict%s -w0", rendopt);
658          if (vint(INTERP) || atoi(vval(MBLUR)))
659 <                sprintf(combuf+strlen(combuf), "-z %s.zbf ", vval(BASENAME));
660 <        sprintf(combuf+strlen(combuf), "-o %s.unf %s -S %d %s < %s",
661 <                        vval(BASENAME), rresopt, first, vval(OCTREE), vfn);
659 >                sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME));
660 >        sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d",
661 >                        vval(BASENAME), rresopt, first);
662 >        inspoint = combuf + strlen(combuf);
663 >        sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
664                                          /* run in parallel */
665 <        if (pruncom(combuf, (last-first+1)/(vint(INTERP)+1))) {
665 >        if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) {
666                  fprintf(stderr, "%s: error rendering frames %d through %d\n",
667                                  progname, first, last);
668                  quit(1);
# Line 789 | Line 799 | char   *ep;
799   int     rvr;
800   {
801          extern int      frecover();
802 +        static int      iter = 0;
803          char    fnbefore[128], fnafter[128];
804 <        char    combuf[1024], fname[128];
804 >        char    combuf[1024], fname0[128], fname1[128];
805          int     usepinterp, usepfilt;
806          int     frseq[2];
807                                                  /* check what is needed */
# Line 823 | Line 834 | int    rvr;
834                          return(1);
835                  if (atoi(vval(MBLUR))) {
836                          FILE    *fp;            /* motion blurring */
837 <                        sprintf(fname, "%s/vw0", vval(DIRECTORY));
838 <                        if ((fp = fopen(fname, "w")) == NULL) {
839 <                                perror(fname); quit(1);
837 >                        sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
838 >                                        'a'+(iter%26));
839 >                        if ((fp = fopen(fname0, "w")) == NULL) {
840 >                                perror(fname0); quit(1);
841                          }
842                          fputs(VIEWSTR, fp);
843                          fprintview(vp, fp);
# Line 836 | Line 848 | int    rvr;
848                                                  progname, frame+1);
849                                  quit(1);
850                          }
851 <                        sprintf(fname, "%s/vw1", vval(DIRECTORY));
852 <                        if ((fp = fopen(fname, "w")) == NULL) {
853 <                                perror(fname); quit(1);
851 >                        sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
852 >                                        'a'+(iter%26));
853 >                        if ((fp = fopen(fname1, "w")) == NULL) {
854 >                                perror(fname1); quit(1);
855                          }
856                          fputs(VIEWSTR, fp);
857                          fprintview(vp, fp);
858                          putc('\n', fp); fclose(fp);
859                          sprintf(combuf,
860 <        "(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B",
860 >                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
861                          *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
862 <                                        atoi(vval(MBLUR)), vval(DIRECTORY),
863 <                                        vval(DIRECTORY), vval(DIRECTORY),
864 <                                        vval(DIRECTORY), vval(DIRECTORY));
862 >                                        atoi(vval(MBLUR)),
863 >                                        fname0, fname1, fname0, fname1);
864 >                        iter++;
865                  } else                          /* no blurring */
866                          strcpy(combuf, "pinterp");
867                  strcat(combuf, viewopt(vp));
# Line 898 | Line 911 | int    rvr;
911                  sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore);
912          }
913                                                  /* output file name */
914 <        sprintf(fname, vval(BASENAME), frame);
915 <        sprintf(combuf+strlen(combuf), " > %s.pic", fname);
914 >        sprintf(fname0, vval(BASENAME), frame);
915 >        sprintf(combuf+strlen(combuf), " > %s.pic", fname0);
916          if (rvr)                                /* in recovery */
917                  return(runcom(combuf));
918          bruncom(combuf, frame, frecover);       /* else run in background */
# Line 1052 | Line 1065 | int    status;
1065          register PROC   *pp;
1066  
1067          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        }
1068          if (pp->elen) {                 /* pass errors */
1069 +                if (ps->hostname[0])
1070 +                        fprintf(stderr, "%s: ", ps->hostname);
1071 +                fprintf(stderr, "Error output from: %s\n", pp->com);
1072                  fputs(pp->errs, stderr);
1073                  fflush(stderr);
1074                  if (ps->hostname[0])
# Line 1097 | Line 1107 | int    (*rf)();
1107  
1108          if (noaction) {
1109                  if (!silent)
1110 <                        printf("\t%s\n", com);  /* just echo it */
1110 >                        printf("\t%s\n", com);  /* echo command */
1111                  return(0);
1112          }
1113                                          /* else start it when we can */
1114          while ((pid = startjob(NULL, savestr(com), donecom)) == -1)
1115                  bwait(1);
1116 +        if (!silent) {                          /* echo command */
1117 +                PSERVER *ps;
1118 +                int     psn = pid;
1119 +                ps = findjob(&psn);
1120 +                printf("\t%s\n", com);
1121 +                printf("\tProcess started on %s\n", phostname(ps));
1122 +                fflush(stdout);
1123 +        }
1124          psl = findpslot(pid);           /* record info. in appropriate slot */
1125          psl->pid = pid;
1126          psl->fout = fout;
# Line 1138 | Line 1156 | int    ncoms;
1156  
1157  
1158   int
1159 < pruncom(com, maxcopies)         /* run a command in parallel over network */
1160 < char    *com;
1159 > pruncom(com, ppins, maxcopies)  /* run a command in parallel over network */
1160 > char    *com, *ppins;
1161   int     maxcopies;
1162   {
1163          int     retstatus = 0;
1164 +        int     hostcopies;
1165 +        char    com1buf[10240], *com1, *endcom1;
1166          int     status;
1167          register PSERVER        *ps;
1168  
1169 <        if (noaction) {
1170 <                if (!silent)
1171 <                        printf("\t%s\n", com);  /* just echo */
1169 >        if (!silent)
1170 >                printf("\t%s\n", com);  /* echo command */
1171 >        if (noaction)
1172                  return(0);
1173 <        }
1173 >        fflush(stdout);
1174                                          /* start jobs on each server */
1175 <        for (ps = pslist; ps != NULL; ps = ps->next)
1175 >        for (ps = pslist; ps != NULL; ps = ps->next) {
1176 >                hostcopies = 0;
1177 >                if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) {
1178 >                        strcpy(com1=com1buf, com);      /* build -PP command */
1179 >                        sprintf(com1+(ppins-com), " -PP %s/%s.persist",
1180 >                                        vval(DIRECTORY), phostname(ps));
1181 >                        strcat(com1, ppins);
1182 >                        endcom1 = com1 + strlen(com1);
1183 >                        sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`",
1184 >                                        vval(DIRECTORY), phostname(ps));
1185 >                } else {
1186 >                        com1 = com;
1187 >                        endcom1 = NULL;
1188 >                }
1189                  while (maxcopies > 0 &&
1190 <                                startjob(ps, savestr(com), donecom) != -1) {
1190 >                                startjob(ps, savestr(com1), donecom) != -1) {
1191                          sleep(10);
1192 +                        hostcopies++;
1193                          maxcopies--;
1194 +                        if (endcom1 != NULL)
1195 +                                *endcom1 = '\0';
1196                  }
1197 +                if (!silent && hostcopies) {
1198 +                        if (hostcopies > 1)
1199 +                                printf("\t%d duplicate processes", hostcopies);
1200 +                        else
1201 +                                printf("\tProcess");
1202 +                        printf(" started on %s\n", phostname(ps));
1203 +                        fflush(stdout);
1204 +                }
1205 +        }
1206                                          /* wait for jobs to finish */
1207          while ((status = wait4job(NULL, -1)) != -1)
1208                  if (status)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines