86 |
|
#include <string.h> |
87 |
|
#include <ctype.h> |
88 |
|
#include "rtmath.h" |
89 |
+ |
#include "resolu.h" |
90 |
|
#include "platform.h" |
91 |
|
#include "color.h" |
92 |
+ |
#include "resolu.h" |
93 |
|
|
94 |
|
char *progname; /* Program name */ |
95 |
|
char errmsg[128]; /* Error message buffer */ |
321 |
|
int dir_is_horiz; /* direct is meas. on horizontal? */ |
322 |
|
float *mtx_data = NULL; /* our matrix data */ |
323 |
|
int ntsteps = 0; /* number of rows in matrix */ |
324 |
+ |
int step_alloc = 0; |
325 |
|
int last_monthly = 0; /* month of last report */ |
326 |
+ |
int inconsistent = 0; /* inconsistent options set? */ |
327 |
|
int mo, da; /* month (1-12) and day (1-31) */ |
328 |
|
double hr; /* hour (local standard time) */ |
329 |
|
double dir, dif; /* direct and diffuse values */ |
374 |
|
rhsubdiv = atoi(argv[++i]); |
375 |
|
break; |
376 |
|
case 'c': /* sky color */ |
377 |
+ |
inconsistent |= (skycolor[1] <= 1e-4); |
378 |
|
skycolor[0] = atof(argv[++i]); |
379 |
|
skycolor[1] = atof(argv[++i]); |
380 |
|
skycolor[2] = atof(argv[++i]); |
381 |
|
break; |
382 |
|
case 'd': /* solar (direct) only */ |
383 |
|
skycolor[0] = skycolor[1] = skycolor[2] = 0; |
384 |
< |
if (suncolor[1] <= 1e-4) |
384 |
> |
if (suncolor[1] <= 1e-4) { |
385 |
> |
inconsistent = 1; |
386 |
|
suncolor[0] = suncolor[1] = suncolor[2] = 1; |
387 |
+ |
} |
388 |
|
break; |
389 |
|
case 's': /* sky only (no direct) */ |
390 |
|
suncolor[0] = suncolor[1] = suncolor[2] = 0; |
391 |
< |
if (skycolor[1] <= 1e-4) |
391 |
> |
if (skycolor[1] <= 1e-4) { |
392 |
> |
inconsistent = 1; |
393 |
|
skycolor[0] = skycolor[1] = skycolor[2] = 1; |
394 |
+ |
} |
395 |
|
break; |
396 |
|
case 'r': /* rotate distribution */ |
397 |
|
if (argv[i][2] && argv[i][2] != 'z') |
400 |
|
break; |
401 |
|
case '5': /* 5-phase calculation */ |
402 |
|
nsuns = 1; |
403 |
< |
fixed_sun_sa = 6.797e-05; |
403 |
> |
fixed_sun_sa = PI/360.*atof(argv[++i]); |
404 |
> |
if (fixed_sun_sa <= 0) { |
405 |
> |
fprintf(stderr, "%s: missing solar disk size argument for '-5' option\n", |
406 |
> |
argv[0]); |
407 |
> |
exit(1); |
408 |
> |
} |
409 |
> |
fixed_sun_sa *= fixed_sun_sa*PI; |
410 |
|
break; |
411 |
|
default: |
412 |
|
goto userr; |
413 |
|
} |
414 |
|
if (i < argc-1) |
415 |
|
goto userr; |
416 |
+ |
if (inconsistent) |
417 |
+ |
fprintf(stderr, "%s: WARNING: inconsistent -s, -d, -c options!\n", |
418 |
+ |
progname); |
419 |
|
if (i == argc-1 && freopen(argv[i], "r", stdin) == NULL) { |
420 |
|
fprintf(stderr, "%s: cannot open '%s' for input\n", |
421 |
|
progname, argv[i]); |
478 |
|
double sda, sta; |
479 |
|
/* make space for next time step */ |
480 |
|
mtx_offset = 3*nskypatch*ntsteps++; |
481 |
< |
mtx_data = resize_dmatrix(mtx_data, ntsteps, nskypatch); |
481 |
> |
if (ntsteps > step_alloc) { |
482 |
> |
step_alloc += (step_alloc>>1) + ntsteps + 7; |
483 |
> |
mtx_data = resize_dmatrix(mtx_data, step_alloc, nskypatch); |
484 |
> |
} |
485 |
|
if (dif <= 1e-4) { |
486 |
|
memset(mtx_data+mtx_offset, 0, sizeof(float)*3*nskypatch); |
487 |
|
continue; |
536 |
|
printf("NROWS=%d\n", nskypatch); |
537 |
|
printf("NCOLS=%d\n", ntsteps); |
538 |
|
printf("NCOMP=3\n"); |
539 |
< |
fputformat(getfmtname(outfmt), stdout); |
539 |
> |
fputformat((char *)getfmtname(outfmt), stdout); |
540 |
|
putchar('\n'); |
541 |
|
} |
542 |
|
/* patches are rows (outer sort) */ |