--- ray/src/util/rtcontrib.c 2005/06/14 02:50:23 1.22 +++ ray/src/util/rtcontrib.c 2005/09/13 22:58:22 1.25 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtcontrib.c,v 1.22 2005/06/14 02:50:23 greg Exp $"; +static const char RCSid[] = "$Id: rtcontrib.c,v 1.25 2005/09/13 22:58:22 greg Exp $"; #endif /* * Gather rtrace output to compute contributions from particular sources @@ -173,6 +173,13 @@ main(int argc, char *argv[]) char *binval = NULL; char fmt[8]; int i, j; + /* need at least one argument */ + if (argc < 2) { + fprintf(stderr, +"Usage: %s [-n nprocs][-r][-e expr][-f source][-o ospec][-b binv] {-m mod | -M file} [rtrace options] octree\n", + argv[0]); + exit(1); + } /* global program name */ gargv = argv; /* initialize calcomp routines */ @@ -315,11 +322,11 @@ main(int argc, char *argv[]) error(USER, "missing octree argument"); rtargv[rtargc++] = octree = argv[i]; rtargv[rtargc] = NULL; - /* start rtrace & compute contributions */ + /* start rtrace */ init(nprocs); if (recover) /* perform recovery if requested */ recover_output(stdin); - trace_contribs(stdin); + trace_contribs(stdin); /* compute contributions */ quit(0); } @@ -1030,8 +1037,13 @@ recover_output(FILE *fin) error(USER, "cannot recover from command"); /* open output */ fp = fopen(oname, "rb+"); - if (fp == NULL) - break; /* must be end of modifier */ + if (fp == NULL) { + if (j) + break; /* assume end of modifier */ + sprintf(errmsg, "missing recover file '%s'", + oname); + error(USER, errmsg); + } nvals = lseek(fileno(fp), 0, SEEK_END); if (nvals <= 0) { lastout = 0; /* empty output, quit here */ @@ -1085,6 +1097,11 @@ recover_output(FILE *fin) if (lastout < 0) { error(WARNING, "no output files to recover"); return; + } + if (raysleft && lastout >= raysleft) { + error(WARNING, "output appears to be complete"); + /* XXX should read & discard input? */ + quit(0); } /* seek on all files */ nvals = lastout * outvsiz;