Skip to content

Commit a67d58f

Browse files
clarify code to calculate time delay from spawn to settlement
1 parent 2b9660b commit a67d58f

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

SS_readcontrol_330.tpl

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,7 @@
292292
}
293293
}
294294
}
295-
echoinput << "N settle timings: " << N_settle_timings << endl
296-
<< " unique_settle_times: " << endl
297-
<< settle_timings_tempvec << endl;
295+
echoinput << "N settle timings: " << N_settle_timings << endl;
298296
echoinput << "settle events use these settle_times: " << settle_assignments_timing << endl;
299297

300298
if (recr_dist_method == 2)
@@ -343,15 +341,16 @@
343341
for (settle_time = 1; settle_time <= N_settle_timings; settle_time++)
344342
{
345343
j = 0; // temp value for calculated settlement age
346-
if (spawn_month > Settle_month(settle_time))
344+
if (Settle_month(settle_time) < spawn_month ) // settlement month before spawn_month, so settlement will be at least 1 calender year increment after spawning
347345
{
348-
k = 1;
349-
j++; // so sets season 1 as earliest possible settlement at age 1
346+
k = 1; // so sets season 1 as earliest possible season for settlement
347+
j = max( 1, Settle_age(settle_time) ); // calendar elapsed years at settlement
350348
}
351-
else
349+
else // settlement date is at or after spawn_month
352350
{
353-
k = spawn_seas; // earliest possible season for settlement at age 0
354-
}
351+
k = spawn_seas; // earliest possible season for settlement
352+
j = Settle_age(settle_time); // calendar elapsed years at settlement
353+
}
355354
temp = azero_seas(k); // annual elapsed time fraction at begin of this season
356355
Settle_timing_seas(settle_time) = (Settle_month(settle_time) - 1.0) / sumseas; // fraction of year at settlement month
357356

@@ -360,27 +359,23 @@
360359
temp += seasdur(k);
361360
if (k == nseas)
362361
{
363-
k = 1;
364-
j++;
362+
k = 1; // got to seas 1 in next year
363+
j++; // advance years since spawning
365364
}
366365
else
367366
{
368367
k++;
369368
}
370369
}
371-
// if (j != Settle_age(settle_time))
372-
// {
373-
// warnstream << "settle_month is less than spawn_month, so logical age at settlement calculated to be: " << j
374-
// << " for settle_time " << settle_time << ". Does not match read value of " << Settle_age(settle_time) << " are you sure? ";
375-
// write_message (NOTE, 0);
376-
// }
370+
377371
Settle_seas(settle_time) = k;
378-
Settle_seas_offset(settle_time) = Settle_seas(settle_time) - spawn_seas + j * nseas + Settle_age(settle_time) * nseas; // number of seasons between spawning and the season in which settlement occurs
372+
// echoinput << "Calendar years since spawning: " << j << endl;
373+
Settle_seas_offset(settle_time) = Settle_seas(settle_time) - spawn_seas + j * nseas; // number of seasons between spawning and the season in which settlement occurs
379374
Settle_timing_seas(settle_time) -= temp; // timing from beginning of this season; needed for mortality calculation
380375
echoinput << settle_time << " / " << Settle_month(settle_time);
381376
echoinput << " / " << Settle_seas(settle_time) << " / " << Settle_seas_offset(settle_time) << " / "
382377
<< Settle_timing_seas(settle_time) << " / " << Settle_age(settle_time) << endl;
383-
if (Settle_seas_offset(settle_time) == 0 && spawn_time_seas > 0.0)
378+
if ( Settle_seas_offset(settle_time) == 0 && spawn_time_seas > 0.0 && Settle_age(settle_time) == 0 )
384379
{
385380
warnstream << "Cannot have spawn_time_seas after beginning of a season and settlements in the same season" << endl
386381
<< "++ put spawning at beginning of the season, or move settlements to next season";

0 commit comments

Comments
 (0)