Skip to content

Commit c19da3c

Browse files
fix problem with growth after lin_grow transition
1 parent 6c36325 commit c19da3c

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

SS_biofxn.tpl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ FUNCTION void get_growth2(const int y)
462462
{
463463
switch (Grow_type)
464464
{
465-
case 1:
465+
case 1: // standard von Bertallanfy in styr
466466
{
467467
for (a = 0; a <= nages; a++)
468468
{
@@ -591,7 +591,7 @@ FUNCTION void get_growth2(const int y)
591591
if (do_once == 1) echoinput<<"ready to update growth by season " << y << " VBK_w " << VBK_work << " seas " << VBK_seas(s) << " byseas " << VBK_by_seas << endl << " lingrow " <<lin_grow << endl;
592592
switch (Grow_type)
593593
{
594-
case 1: // standard von Bertallanfy
594+
case 1: // standard von Bertallanfy - seasonal growth
595595
{
596596
// SS_Label_Info_16.2.4.2.1 #standard von Bert growth, loop ages to get size at age at beginning of next season (t+1) which is subseas=1
597597
Ave_Size(t + 1, 1, g, 0) = Ave_Size(t, 1, g, 0); // carryforward, but may be overwritten in some circumstances
@@ -626,7 +626,7 @@ FUNCTION void get_growth2(const int y)
626626
}
627627
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
628628
{
629-
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK_work * VBK_seas(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
629+
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK_work * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
630630
echoinput<<" age: "<<k2<<" Lmin "<<Cohort_Lmin(gp, y, a)<<" time: "<<real_age(g, ALK_idx2, k2) - AFIX << " " <<Ave_Size(t + 1, 1, g, k2) <<endl;
631631
}
632632
else // in linear phase
@@ -660,7 +660,7 @@ FUNCTION void get_growth2(const int y)
660660
}
661661
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
662662
{
663-
temp = LminR + (LminR - LinfR) * (mfexp(VBK_work * VBK_seas(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
663+
temp = LminR + (LminR - LinfR) * (mfexp(VBK_work * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
664664
Ave_Size(t + 1, 1, g, k2) = pow(temp, inv_Richards);
665665
}
666666
else // in linear phase for subseas
@@ -726,7 +726,7 @@ FUNCTION void get_growth2(const int y)
726726
}
727727
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
728728
{
729-
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * VBK_seas(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
729+
Ave_Size(t + 1, 1, g, k2) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx2, k2) - AFIX)) - 1.0) * Cohort_Growth(y, a);
730730
}
731731
else // in linear phase
732732
{
@@ -817,7 +817,7 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
817817
gp = GP(g);
818818
switch (Grow_type)
819819
{
820-
case 1: // regular von B
820+
case 1: // standard von Bertallanfy inseason growth
821821
{
822822
for (a = 0; a <= nages; a++)
823823
{
@@ -842,7 +842,7 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
842842
// NOTE: there is no seasonal interpolation, age-specific K uses calendar age, not real age. Maybe someday....
843843
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
844844
{
845-
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, 0) * VBK_seas(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
845+
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, 0) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
846846
}
847847
}
848848
break;
@@ -873,7 +873,7 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
873873
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
874874
{
875875
// temp=Cohort_Lmin(gp,y,a) + (Cohort_Lmin(gp,y,a)-LinfR)*
876-
temp = LminR + (LminR - LinfR) * (mfexp(VBK(gp, 0) * VBK_seas(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
876+
temp = LminR + (LminR - LinfR) * (mfexp(VBK(gp, 0) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx, a) - AFIX)) - 1.0) * Cohort_Growth(y, a);
877877
Ave_Size(t, subseas, g, a) = pow(temp, inv_Richards);
878878
}
879879
} // done ageloop
@@ -923,7 +923,7 @@ FUNCTION void get_growth3(const int y, const int t, const int s, const int subse
923923
// NOTE: there is no seasonal interpolation, age-specific K uses calendar age, not real age. Maybe someday....
924924
else if (lin_grow(g, ALK_idx, a) == -1.0) // first time point beyond AFIX; lin_grow will stay at -1 for all remaining subseas of this season
925925
{
926-
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * VBK_seas(s) * (real_age(g, ALK_idx, a) - AFIX) ) - 1.0) * Cohort_Growth(y, a);
926+
Ave_Size(t, subseas, g, a) = Cohort_Lmin(gp, y, a) + (Cohort_Lmin(gp, y, a) - L_inf(gp)) * (mfexp(VBK(gp, a) * VBK_seas(s) * seasdur(s) * (real_age(g, ALK_idx, a) - AFIX) ) - 1.0) * Cohort_Growth(y, a);
927927
}
928928
}
929929
break;

SS_readcontrol_330.tpl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,13 @@
487487
{
488488
ALK_idx = (s - 1) * N_subseas + subseas;
489489
settle_time = settle_g(g);
490-
// real_age is real age since settlement and is used in growth calculations
491-
// calen_age is real age since the beginning of the year in which spawning occurred
490+
// real_age is real age since settlement and is used in growth calculations
491+
// calen_age is real age since the beginning of the year in which spawning occurred
492+
// except with seas-as-years, sumseas is < 1.0 so calen_age needs to be in terms of season count, not age
493+
// so, divide by sumseas
492494
for (a = 0; a <= nages; a++)
493495
{
494-
calen_age(g, ALK_idx, a) = r_ages(a) + azero_seas(s) + double(subseas - 1) / double(N_subseas) * seasdur(s);
496+
calen_age(g, ALK_idx, a) = r_ages(a) + azero_seas(s) + double(subseas - 1) / double(N_subseas) * seasdur(s) / (sumseas / 12.);
495497
if (a < Settle_age(settle_time))
496498
{
497499
real_age(g, ALK_idx, a) = 0.;
@@ -979,10 +981,11 @@
979981
N_M_Grow_parms = N_natMparms + N_growparms;
980982
lin_grow.initialize();
981983

982-
echoinput << "g a seas subseas ALK_idx real_age calen_age lin_grow first_grow_age" << endl;
984+
echoinput << "g a seas subseas ALK_idx real_age calen_age lin_grow first_grow_age setfirstgrow" << endl;
983985
for (g = 1; g <= gmorph; g++)
984986
if (use_morph(g) > 0)
985987
{
988+
int setfirstgrowage = -1;
986989
for (a = 0; a <= nages; a++)
987990
{
988991
for (s = 1; s <= nseas; s++)
@@ -999,11 +1002,12 @@
9991002
{
10001003
lin_grow(g, ALK_idx, a) = 1.0; // at the transition from linear to VBK growth
10011004
}
1002-
else if (first_grow_age(g) == 0)
1005+
else if (setfirstgrowage == -1)
10031006
{
10041007
lin_grow(g, ALK_idx, a) = -1.0; // flag for first age on growth curve beyond AFIX
10051008
if (subseas == N_subseas) {
10061009
first_grow_age(g) = a;
1010+
setfirstgrowage = a;
10071011
} // so that lingrow will be -1 for rest of this season
10081012
}
10091013
else
@@ -1012,7 +1016,7 @@
10121016
} // flag for being in growth curve
10131017

10141018
if (a < 4) echoinput << g << " " << a << " " << s << " " << subseas << " " << ALK_idx << " " << real_age(g, ALK_idx, a)
1015-
<< " " << calen_age(g, ALK_idx, a) << " " << lin_grow(g, ALK_idx, a) << " " << first_grow_age(g) << endl;
1019+
<< " " << calen_age(g, ALK_idx, a) << " " << lin_grow(g, ALK_idx, a) << " " << first_grow_age(g) << " " << setfirstgrowage << endl;
10161020
}
10171021
}
10181022
}

SS_readdata_330.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
echoinput << subseasdur_delta << " processed subseason duration (frac. of year) " << endl;
147147
echoinput << " processed subseason cumulative annual time within season " << endl
148148
<< subseasdur << endl;
149+
echoinput << sumseas << " sum of season durations; used in seas-as-years" << endl;
149150
if (seas_as_year == 1)
150151
{
151152
warnstream << "Season durations sum to <11.9, so SS3 assumes you are doing years as pseudo-seasons." << endl

0 commit comments

Comments
 (0)