Skip to content

Commit

Permalink
Fix check_sizes and call at end of each year
Browse files Browse the repository at this point in the history
- Function `check_sizes` was using the integer instead of floating-point version of `abs`

- see issue #126
  • Loading branch information
dschlaep committed Jun 1, 2018
1 parent a69d926 commit 6072ad6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ST_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ int main(int argc, char **argv) {
_kill_annuals();
proportion_Recovery();
_kill_extra_growth();

// Check that relsizes match up at end of year after extra growth is removed
// may want to wrap this in #ifdef DEBUG once problem is fixed
check_sizes("'main' at end of year");
} /* end model run for this year*/

if (MortFlags.summary) {
Expand Down Expand Up @@ -544,15 +548,15 @@ void check_sizes(const char *chkpt) {
ForEachIndiv(ndv, Species[sp]) spsize += ndv->relsize;
rgsize += spsize;

if (LT(diff, abs(spsize - Species[sp]->relsize)) ) {
if (LT(diff, fabs(spsize - Species[sp]->relsize)) ) {
LogError(stdout, LOGWARN, "%s (%d:%d): SP: \"%s\" size error: "
"SP=%.9f, ndv=%.9f\n",
chkpt, Globals.currIter, Globals.currYear,
Species[sp]->name, Species[sp]->relsize, spsize);
}
}

if ( LT(diff, abs(rgsize -RGroup[rg]->relsize)) ) {
if ( LT(diff, fabs(rgsize -RGroup[rg]->relsize)) ) {
LogError(stdout, LOGWARN, "%s (%d:%d): RG \"%s\" size error: "
"RG=%.9f, ndv=%.9f\n",
chkpt, Globals.currIter, Globals.currYear,
Expand Down

0 comments on commit 6072ad6

Please sign in to comment.