clock_gettime(CLOCK_REALTIME, &ts);
seed = ((unsigned long)(ts.tv_sec) ^ (unsigned long)ts.tv_nsec) & 0xffffffff;
- while ((opt = getopt(ac, av, "r:s:ehp:y:g:m:t:d:")) != -1) {
+ while ((opt = getopt(ac, av, "f:r:s:ehp:y:g:m:t:d:")) != -1) {
switch (opt) {
case 's': seed = atoi(optarg); break;
case 'r': run = atoi(optarg); break;
case 'e': eemian = 1; break;
case 'h': holocene = 1; break;
case 'p': setpopstr(map, optarg); defaultpop = 0;break;
+ case 'f': if (freopen(optarg, "w", stdout) == NULL) {
+ perror("sim");
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
fprintf(stderr, "Usage: %s [-s seed] [-r run] [-y startyear] [-eh] [-p hex:freq,freq[:freq,freq...]\n",
av[0]);
printf("{");
printf(" \"run\": %d, \"seed\": %d, \"gens\": %d", run, seed, gens);
- printf(",\n\"options\": { \"capfactor\": %f }", capfactor);
+ printf(",\n\"options\": { \"capfactor\": %g }", capfactor);
printf(",\n\"gendata\": [\n");
dumpgenjson(map, 0, year);