9 |
|
*/ |
10 |
|
|
11 |
|
#include "ray.h" |
12 |
+ |
#include "platform.h" |
13 |
|
#include "source.h" |
14 |
|
#include "view.h" |
15 |
|
#include "random.h" |
78 |
|
int ec; |
79 |
|
{ |
80 |
|
if (ray_pnprocs > 0) /* close children if any */ |
81 |
< |
ray_pclose(0); |
81 |
> |
ray_pclose(0); |
82 |
> |
else if (ray_pnprocs < 0) |
83 |
> |
_exit(ec); /* avoid flush in child */ |
84 |
|
exit(ec); |
85 |
|
} |
86 |
|
|
240 |
|
cp = fskip(cp); |
241 |
|
if (cp == NULL) |
242 |
|
break; |
243 |
< |
if (ntp[1] > 1 && sarr[ntp[1]+1] <= sarr[ntp[1]]) { |
243 |
> |
if (ntp[1] > 1 && sarr[ntp[1]+1] <= sarr[ntp[1]]+FTINY) { |
244 |
|
sprintf(errmsg, |
245 |
|
"Phi values not monotinically increasing in sensor file '%s'", |
246 |
|
sfile); |
266 |
|
cp = fskip(cp); |
267 |
|
if (cp == NULL) |
268 |
|
break; |
269 |
< |
if (i && sarr[i] < .0) { |
269 |
> |
if (sarr[i] < .0) { |
270 |
|
if (!warnedneg++) { |
271 |
|
sprintf(errmsg, |
272 |
|
"Negative value(s) in sensor file '%s' (ignored)\n", sfile); |
273 |
|
error(WARNING, errmsg); |
274 |
|
} |
275 |
|
sarr[i] = .0; |
276 |
< |
} else if (i > ntp[0]*(ntp[1]+1) && sarr[i] > FTINY) |
276 |
> |
} else if (sarr[i] > FTINY && i > ntp[0]*(ntp[1]+1)) |
277 |
|
last_pos_val = i; |
278 |
|
++i; |
279 |
|
} |
280 |
< |
if (i == ntp[0]*(ntp[1]+1)) |
280 |
> |
if (i == ntp[0]*(ntp[1]+1)) /* empty line? */ |
281 |
|
break; |
282 |
|
if (ntp[0] > 1 && sarr[ntp[0]*(ntp[1]+1)] <= |
283 |
|
sarr[(ntp[0]-1)*(ntp[1]+1)]) { |
300 |
|
errmsg[0] = '\0'; /* sanity checks */ |
301 |
|
if (!last_pos_val) |
302 |
|
sprintf(errmsg, "no positive sensor values in file '%s'", sfile); |
300 |
– |
if (ntp[0] <= 0) |
301 |
– |
sprintf(errmsg, "no data in sensor file '%s'", sfile); |
303 |
|
else if (fabs(sarr[ntp[1]+1]) > FTINY) |
304 |
|
sprintf(errmsg, "minimum theta must be 0 in sensor file '%s'", |
305 |
|
sfile); |
306 |
|
else if (fabs(sarr[1]) > FTINY) |
307 |
|
sprintf(errmsg, "minimum phi must be 0 in sensor file '%s'", |
308 |
|
sfile); |
309 |
< |
else if (sarr[ntp[1]] <= FTINY) |
309 |
> |
else if (sarr[ntp[1]] < 270.-FTINY) |
310 |
|
sprintf(errmsg, |
311 |
< |
"maximum phi must be positive in sensor file '%s'", |
311 |
> |
"maximum phi must be 270 or greater in sensor file '%s'", |
312 |
|
sfile); |
313 |
< |
else if (sarr[ntp[0]*(ntp[1]+1)] <= FTINY) |
313 |
> |
else if (sarr[ntp[1]] >= 360.-FTINY) |
314 |
|
sprintf(errmsg, |
315 |
< |
"maximum theta (%f) must be positive in sensor file '%s'", |
316 |
< |
sarr[ntp[0]*(ntp[1]+1)], sfile); |
315 |
> |
"maximum phi must be less than 360 in sensor file '%s'", |
316 |
> |
sfile); |
317 |
|
if (errmsg[0]) |
318 |
|
error(USER, errmsg); |
319 |
|
return((float *)realloc((void *)sarr, sizeof(float)*nelem)); |
373 |
|
psize = PI*tsize/maxtheta; |
374 |
|
if (sntp[0]*sntp[1] < samptot) /* don't overdo resolution */ |
375 |
|
samptot = sntp[0]*sntp[1]; |
376 |
< |
ntheta = (int)(sqrt((double)samptot*tsize/psize) + 0.5); |
376 |
> |
ntheta = (int)(sqrt((double)samptot*tsize/psize)*sntp[0]/sntp[1]) + 1; |
377 |
|
if (ntheta > MAXNT) |
378 |
|
ntheta = MAXNT; |
379 |
|
nphi = samptot/ntheta; |