| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
#include "rcontrib.h" |
| 10 |
– |
#include "source.h" |
| 10 |
|
#include "otypes.h" |
| 11 |
< |
#include "platform.h" |
| 11 |
> |
#include "source.h" |
| 12 |
|
|
| 13 |
|
char *shm_boundary = NULL; /* boundary of shared memory */ |
| 14 |
|
|
| 26 |
|
|
| 27 |
|
int rand_samp = 1; /* pure Monte Carlo sampling? */ |
| 28 |
|
|
| 29 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
| 29 |
> |
double dstrsrc = 0.9; /* square source distribution */ |
| 30 |
|
double shadthresh = .03; /* shadow threshold */ |
| 31 |
|
double shadcert = .75; /* shadow certainty */ |
| 32 |
|
int directrelay = 3; /* number of source relays */ |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
|
| 139 |
< |
/* add modifiers from a file list */ |
| 139 |
> |
/* Add modifiers from a file list */ |
| 140 |
|
void |
| 141 |
|
addmodfile(char *fname, char *outf, char *binv, int bincnt) |
| 142 |
|
{ |
| 158 |
|
) |
| 159 |
|
{ |
| 160 |
|
if (nchild > 0) /* close children if any */ |
| 161 |
< |
end_children(); |
| 161 |
> |
end_children(code != 0); |
| 162 |
|
exit(code); |
| 163 |
|
} |
| 164 |
|
|
| 177 |
|
/* set shared memory boundary */ |
| 178 |
|
shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY"); |
| 179 |
|
} |
| 180 |
< |
if ((nproc > 1) & (accumulate <= 0)) |
| 181 |
< |
put_zero_record(0); /* prime our queue to accumulate */ |
| 183 |
< |
|
| 180 |
> |
for (i = 0; i < nsources; i++) /* tracing to sources as well */ |
| 181 |
> |
source[i].sflags |= SFOLLOW; |
| 182 |
|
if (yres > 0) { /* set up flushing & ray counts */ |
| 183 |
|
if (xres > 0) |
| 184 |
|
raysleft = (RNUMBER)xres*yres; |
| 189 |
|
if ((account = accumulate) > 1) |
| 190 |
|
raysleft *= accumulate; |
| 191 |
|
waitflush = (yres > 0) & (xres > 1) ? 0 : xres; |
| 194 |
– |
/* tracing to sources as well */ |
| 195 |
– |
for (i = 0; i < nsources; i++) |
| 196 |
– |
source[i].sflags |= SFOLLOW; |
| 192 |
|
|
| 193 |
|
if (nproc > 1 && in_rchild()) /* forked child? */ |
| 194 |
|
return; /* return to main processing loop */ |
| 195 |
|
|
| 196 |
|
if (recover) { /* recover previous output? */ |
| 197 |
< |
if (accumulate <= 0) { |
| 197 |
> |
if (accumulate <= 0) |
| 198 |
|
reload_output(); |
| 199 |
< |
if (nproc > 1) |
| 205 |
< |
queue_modifiers(); |
| 206 |
< |
} else |
| 199 |
> |
else |
| 200 |
|
recover_output(); |
| 201 |
|
} |
| 202 |
|
if (nproc == 1) /* single process? */ |
| 203 |
|
return; |
| 204 |
< |
|
| 205 |
< |
parental_loop(); /* else run controller */ |
| 204 |
> |
/* else run appropriate controller */ |
| 205 |
> |
if (accumulate <= 0) |
| 206 |
> |
feeder_loop(); |
| 207 |
> |
else |
| 208 |
> |
parental_loop(); |
| 209 |
|
quit(0); /* parent musn't return! */ |
| 210 |
|
} |
| 211 |
|
|
| 226 |
|
|
| 227 |
|
if (mp == NULL) /* not in our list? */ |
| 228 |
|
return; |
| 229 |
+ |
/* shadow ray not on source? */ |
| 230 |
+ |
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
| 231 |
+ |
return; |
| 232 |
|
|
| 233 |
< |
worldfunc(RCCONTEXT, r); /* get bin number */ |
| 233 |
> |
worldfunc(RCCONTEXT, r); /* else get bin number */ |
| 234 |
|
bn = (int)(evalue(mp->binv) + .5); |
| 235 |
|
if ((bn < 0) | (bn >= mp->nbins)) { |
| 236 |
|
error(WARNING, "bad bin number (ignored)"); |
| 237 |
|
return; |
| 238 |
|
} |
| 239 |
< |
raycontrib(contr, r, PRIMARY); |
| 239 |
> |
raycontrib(contr, r, PRIMARY); /* compute coefficient */ |
| 240 |
|
if (contrib) |
| 241 |
< |
multcolor(contr, r->rcol); |
| 241 |
> |
multcolor(contr, r->rcol); /* -> contribution */ |
| 242 |
|
addcolor(mp->cbin[bn], contr); |
| 243 |
|
} |
| 244 |
|
|
| 345 |
|
account = 1; /* output accumulated totals */ |
| 346 |
|
done_contrib(); |
| 347 |
|
} |
| 348 |
+ |
lu_done(&ofiletab); /* close output files */ |
| 349 |
|
if (raysleft) |
| 350 |
|
error(USER, "unexpected EOF on input"); |
| 351 |
– |
lu_done(&ofiletab); /* close output files */ |
| 351 |
|
} |