Skip to content

Commit 6e3f302

Browse files
fix for growth_timevary
1 parent 589c8ba commit 6e3f302

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

SS_biofxn.tpl

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ FUNCTION void get_growth2(const int y)
393393
L_inf(gp) = Lmin(gp) + (Lmax_temp(gp) - Lmin(gp)) / (1. - mfexp(VBK_work * VBK_seas(0) * (AFIX_delta)));
394394
}
395395
396-
// SS_Label_Info_16.2.3 #Set up Lmin and Lmax in Start Year
396+
// SS_Label_Info_16.2.3 #Set up Cohort_Lmin in Start Year
397397
if (y == styr)
398398
{
399399
Cohort_Lmin(gp) = Lmin(gp); // sets for all years and ages
@@ -441,31 +441,35 @@ FUNCTION void get_growth2(const int y)
441441
CV_delta(gp) = 0.0;
442442
CV_G(gp) = CVLmin(gp); // sets all seasons and whole age range
443443
}
444+
} // end preliminary calcs
444445
445446
// SS_Label_Info_16.2.4 #Loop settlement events because growth starts at time of settlement
446-
g = g_Start(gp); // base platoon
447-
for (settle = 1; settle <= N_settle_timings; settle++)
447+
g = g_Start(gp); // base platoon
448+
for (settle = 1; settle <= N_settle_timings; settle++)
449+
{
450+
g += N_platoon; // increment by N_platoon because only middle platoon has growth modeled
451+
if (use_morph(g) > 0)
448452
{
449-
g += N_platoon; // increment by N_platoon because only middle platoon has growth modeled
450-
if (use_morph(g) > 0)
451-
{
452-
// SS_Label_Info_16.2.4.1.1 #if y=styr, get size-at-age in first subseason of first season of this first year
453-
// VBK_seas(0) is the sum of all the season durations * seasonal K adjustments. Normally it has a value of 1.0
454-
// but for seasons-as-years, it will be the value equal to the selected duration of those seasons
455-
Ave_Size(styr, 1, g)(0, first_grow_age(g)) = Lmin(gp);
453+
// SS_Label_Info_16.2.4.1.1 #if y=styr, get size-at-age in first subseason of first season of this first year
454+
// VBK_seas(0) is the sum of all the season durations * seasonal K adjustments. Normally it has a value of 1.0
455+
// but for seasons-as-years, it will be the value equal to the selected duration of those seasons
456+
// Ave_Size(styr, 1, g)(0, first_grow_age(g)) = Lmin(gp);
457+
if (y == styr)
458+
{
459+
456460
switch (Grow_type)
457461
{
458462
case 1:
459463
{
460-
for (a = first_grow_age(g); a <= nages; a++)
464+
for (a = 0; a <= nages; a++)
461465
{
462466
Ave_Size(styr, 1, g, a) = L_inf(gp) + (Lmin(gp) - L_inf(gp)) * mfexp(VBK_work * VBK_seas(0) * (real_age(g, 1, a) - AFIX));
463467
} // done ageloop
464468
break;
465469
}
466470
case 2: // Richards
467471
{
468-
for (a = first_grow_age(g); a <= nages; a++)
472+
for (a = 0; a <= nages; a++)
469473
{
470474
temp = LinfR + (LminR - LinfR) * mfexp(VBK_work * VBK_seas(0) * (real_age(g, 1, a) - AFIX));
471475
Ave_Size(styr, 1, g, a) = pow(temp, inv_Richards);
@@ -482,7 +486,7 @@ FUNCTION void get_growth2(const int y)
482486
{
483487
ALK_idx = 1;
484488
// NOTE: VBK_seas(0) accounts for season duration
485-
for (a = first_grow_age(g); a <= nages; a++)
489+
for (a = 0; a <= nages; a++)
486490
{
487491
k2 = max(0, a - 1);
488492
if (lin_grow(g, ALK_idx, a) >= -1.0) // linear segment, or first time point beyond AFIX;
@@ -502,8 +506,8 @@ FUNCTION void get_growth2(const int y)
502506
// L0 (mean length at age 0)
503507
// Linf (asymptotic mean length)
504508
// k (steepness of the logistic function that models the reduction in the growth increment) = Richards
505-
Ave_Size(styr, 1, g)(0, first_grow_age(g)) = Lmin(gp); //assume first_grow_age(g) = 0
506-
for (a = first_grow_age(g); a <= nages; a++)
509+
// Ave_Size(styr, 1, g)(0, first_grow_age(g)) = Lmin(gp); //assume first_grow_age(g) = 0
510+
for (a = 0; a <= nages; a++)
507511
{
508512
Ave_Size(styr, 1, g, a) = Lmin(gp) + -VBK_work * VBK_seas(0) * ((log(exp(-Richards(gp) * t50) + 1) - log(exp(Richards(gp) * (real_age(g, 1, a) - AFIX - t50)) + 1)) / Richards(gp) + real_age(g, 1, a) - AFIX);
509513
} // done ageloop
@@ -519,7 +523,7 @@ FUNCTION void get_growth2(const int y)
519523
// SS_Label_Info_16.2.4.1.4 #calc approximation to mean size at maxage to account for growth after reaching the maxage (accumulator age)
520524
// note that seasonal adjustment to VBK is dropped
521525
current_size = Ave_Size(styr, 1, g, nages);
522-
if (Linf_decay > -997.) // decay rate has been read and not using "-999" for the 3.24 approach whih=ch sets decay = -0.2
526+
if (Linf_decay > 0.0001) // decay rate has been read. Should be an estimate of initial Z
523527
{
524528
temp1 = 1.0;
525529
temp4 = 1.0;
@@ -552,15 +556,15 @@ FUNCTION void get_growth2(const int y)
552556
}
553557
Ave_Size(styr, 1, g, nages) = temp / temp1; // this is weighted mean size at nages
554558
}
555-
else // decay code set to -998 which omits growth in the plus group
559+
else if (Linf_decay == -998.) // decay code set to -998 which omits growth in the plus group
556560
{
557561
// no adjustment
558562
}
559563
#ifdef DO_ONCE
560564
if (do_once == 1)
561565
echoinput << " adjusted size in plusgroup: " << Ave_Size(styr, 1, g, nages) << " using decay of: " << Linf_decay << endl;
562566
#endif
563-
} // end initial year calcs
567+
} // end initial year calcs
564568
565569
// SS_Label_Info_16.2.4.2 #loop seasons for growth calculation
566570
for (s = 1; s <= nseas; s++)
@@ -580,9 +584,8 @@ FUNCTION void get_growth2(const int y)
580584
else
581585
add_age = 0; // advance age or not
582586
// growth to next season
583-
// following line incorrectly adjusted for season duration
584587
VBK_by_seas = (mfexp(VBK_work * VBK_seas(s)) - 1.0); // for use inside the growth equation
585-
588+
echoinput<<"ready to update growth by season " << y << endl;
586589
switch (Grow_type)
587590
{
588591
case 1: // standard von Bertallanfy
@@ -732,14 +735,16 @@ FUNCTION void get_growth2(const int y)
732735
}
733736
734737
// SS_Label_Info_16.2.4.2.1.2 #after age loop, if(s=nseas) get weighted average for size_at_maxage from carryover fish and fish newly moving into this age
735-
// this code needs to execute every year, so should move to ss_popdyn. Positioned here, it is only updated in years in which there is time-vary growth
736-
if (s == nseas)
738+
// there should be an option to execute this update every year, so code below should move to ss_popdyn. Positioned here, it is only updated in years in which there is time-vary growth
739+
if (y > styr && s == nseas) // do plus group mean size update
737740
{
738-
if (y > styr && Linf_decay != -998.)
741+
if (Linf_decay != -998.)
739742
{
740-
if (do_once == 1)
741-
warnstream << "plus group mean size is being updated in years with time-vary growth; can turn this off with Linf_decay = -998";
742-
write_message (NOTE, 0);
743+
if (do_once == 1 && timevary_MG_firstyr == y)
744+
{
745+
warnstream << "plus group mean size is updated in years with time-vary growth beginning in: " << y << "; can turn this off with Linf_decay = -998";
746+
write_message (NOTE, 0);
747+
}
743748
// 3.24 code
744749
if (do_once == 1)
745750
echoinput << niter << " " << y << " plus group calc: "

0 commit comments

Comments
 (0)