Skip to content

Commit

Permalink
more warnings and messages fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPannetier committed Feb 13, 2024
1 parent bf735cc commit ab4dc2c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
17 changes: 9 additions & 8 deletions Community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void Community::initialise(Species* pSpecies, int year)
int nsubcomms, npatches, ndistcells, spratio, patchnum, rr = 0;
locn distloc;
patchData pch;
patchLimits limits;
patchLimits limits = patchLimits();
intptr ppatch, subcomm;
std::vector <intptr> subcomms;
std::vector <bool> selected;
Expand Down Expand Up @@ -257,7 +257,8 @@ void Community::initialise(Species* pSpecies, int year)
indIx = 0; // reset index for initial individuals
}
else { // add any initial individuals for the current year
initInd iind; iind.year = 0;
initInd iind = initInd();
iind.year = 0;
int ninds = paramsInit->numInitInds();
while (indIx < ninds && iind.year <= year) {
iind = paramsInit->getInitInd(indIx);
Expand Down Expand Up @@ -505,7 +506,7 @@ void Community::dispersal(short landIx)
#endif // SEASONAL || RS_RCPP
{
#if RSDEBUG
int t0, t1, t2;
time_t t0, t1, t2;
t0 = time(0);
#endif

Expand Down Expand Up @@ -631,7 +632,7 @@ void Community::deleteOccupancy(int nrows) {
// Determine range margins
commStats Community::getStats(void)
{
commStats s;
commStats s = commStats();
landParams ppLand = pLandscape->getLandParams();
s.ninds = s.nnonjuvs = s.suitable = s.occupied = 0;
s.minX = ppLand.maxX; s.minY = ppLand.maxY; s.maxX = s.maxY = 0;
Expand Down Expand Up @@ -883,9 +884,9 @@ void Community::outRange(Species* pSpecies, int rep, int yr, int gen)
outrange << "\t0\t0\t0\t0";

if (emig.indVar || trfr.indVar || sett.indVar) { // output trait means
traitsums ts;
traitsums ts = traitsums();
traitsums scts; // sub-community traits
traitCanvas tcanv;
traitCanvas tcanv = traitCanvas();
int ngenes, popsize;

tcanv.pcanvas[0] = NULL;
Expand Down Expand Up @@ -1889,8 +1890,8 @@ void Community::writeWCPerLocusFstatFile(Species* pSpecies, const int yr, const
const auto pPop = (Population*)patch->getPopn((intptr)pSpecies);
int popSize = pPop->sampleSize();
int het = 0;
for (unsigned int a = 0; a < nAlleles; ++a) {
het += pPop->getHetero(thisLocus, a);
for (int a = 0; a < nAlleles; ++a) {
het += static_cast<int>(pPop->getHetero(thisLocus, a)); // not sure why this returns a double
}
outperlocusfstat << "\t" << het / (2.0 * popSize);
}
Expand Down
18 changes: 9 additions & 9 deletions GeneticLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,27 @@ float GeneticLoad::drawDominance(float selCoef) {
{
const float mean = dominanceParameters.find(MEAN)->second;
const float sd = dominanceParameters.find(SDEV)->second;
h = pRandom->Normal(mean, sd);
h = static_cast<float>(pRandom->Normal(mean, sd));
break;
}
case GAMMA:
{
const float shape = dominanceParameters.find(SHAPE)->second;
const float scale = dominanceParameters.find(SCALE)->second;
h = pRandom->Gamma(shape, scale);
h = static_cast<float>(pRandom->Gamma(shape, scale));
break;
}
case NEGEXP:
{
const float mean = dominanceParameters.find(MEAN)->second;
h = pRandom->NegExp(mean);
h = static_cast<float>(pRandom->NegExp(mean));
break;
}
case SCALED:
{
const float min = 0;
const float max = exp((-log(2 * 0.36) / 0.05) * selCoef);
h = pRandom->FRandom(min, max);
const float max = static_cast<float>(exp((-log(2 * 0.36) / 0.05) * selCoef));
h = static_cast<float>(pRandom->FRandom(min, max));
break;
}

Expand Down Expand Up @@ -270,21 +270,21 @@ float GeneticLoad::drawSelectionCoef() {
{
const float mean = mutationParameters.find(MEAN)->second;
const float sd = mutationParameters.find(SDEV)->second;
s = pRandom->Normal(mean, sd);
s = static_cast<float>(pRandom->Normal(mean, sd));

break;
}
case GAMMA:
{
const float shape = mutationParameters.find(SHAPE)->second;
const float scale = mutationParameters.find(SCALE)->second;
s = pRandom->Gamma(shape, scale);
s = static_cast<float>(pRandom->Gamma(shape, scale));
break;
}
case NEGEXP:
{
const float mean = mutationParameters.find(MEAN)->second;
s = pRandom->NegExp(mean);
s = static_cast<float>(pRandom->NegExp(mean));
break;
}
default:
Expand Down Expand Up @@ -315,7 +315,7 @@ void GeneticLoad::inheritDiploid(sex_t whichChromosome, map<int, vector<shared_p

auto it = recomPositions.lower_bound(parentGenes.begin()->first);

unsigned int nextBreakpoint = *it;
int nextBreakpoint = *it;

auto distance = std::distance(recomPositions.begin(), it);
if (distance % 2 != 0)
Expand Down
20 changes: 12 additions & 8 deletions Population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Population::Population(Species* pSp, Patch* pPch, int ninds, int resol)
pSpecies = pSp;
pPatch = pPch;
// record the new population in the patch
patchPopn pp;
patchPopn pp = patchPopn();
pp.pSp = (intptr)pSpecies; pp.pPop = (intptr)this;
pPatch->addPopn(pp);
#if RSDEBUG
Expand Down Expand Up @@ -229,7 +229,7 @@ Population::~Population(void) {

traitsums Population::getTraits(Species* pSpecies) {
int g;
traitsums ts;
traitsums ts = traitsums();
for (int i = 0; i < NSEXES; i++) {
ts.ninds[i] = 0;
ts.sumD0[i] = ts.ssqD0[i] = 0.0;
Expand Down Expand Up @@ -456,10 +456,10 @@ double Population::computeHs() {

popStats Population::getStats(void)
{
popStats p;
popStats p = popStats();
int ninds;
float fec;
bool breeders[2]; breeders[0] = breeders[1] = false;
bool breeders[2] = { false, false };
demogrParams dem = pSpecies->getDemogr();
p.pSpecies = pSpecies;
p.pPatch = pPatch;
Expand Down Expand Up @@ -1147,7 +1147,7 @@ void Population::allEmigrate(void) {

// If an Individual has been identified as an emigrant, remove it from the Population
disperser Population::extractDisperser(int ix) {
disperser d;
disperser d = disperser();
indStats ind = inds[ix]->getStats();
if (ind.status == 1) { // emigrant
d.pInd = inds[ix]; d.yes = true;
Expand Down Expand Up @@ -1190,7 +1190,7 @@ void Population::addSettleTraitsForInd(int ix, settleTraits& avgSettleTraits) {
// if it is a settler, return its new location and remove it from the current population
// otherwise, leave it in the matrix population for possible reporting before deletion
disperser Population::extractSettler(int ix) {
disperser d;
disperser d = disperser();
Cell* pCell;
//Patch* pPatch;

Expand Down Expand Up @@ -1232,7 +1232,8 @@ int Population::transfer(Landscape* pLandscape, short landIx)
Cell* pCell = 0;
indStats ind;
Population* pNewPopn = 0;
locn newloc, nbrloc;
locn newloc = locn();
locn nbrloc = locn();

landData ppLand = pLandscape->getLandData();
short reptype = pSpecies->getRepType();
Expand Down Expand Up @@ -1716,6 +1717,9 @@ void Population::survival0(float localK, short option0, short option1)
if ((ind.stage == 0 && option0 < 2) || (ind.stage > 0 && option0 > 0)) {
// condition for processing the stage is met...
if (ind.status < 6) { // not already doomed
if (ind.sex < sex_t::FEM || ind.sex > sex_t::MAL)
// ?? MSVC believes it's important to bound check ind.sex
throw runtime_error("Individual sex is out of bounds");
double probsurv = surv[ind.stage][ind.sex];
// does the individual survive?
if (pRandom->Bernoulli(probsurv)) { // survives
Expand Down Expand Up @@ -2129,7 +2133,7 @@ void Population::outIndividual(Landscape* pLandscape, int rep, int yr, int gen,
outInds << "\t" << ind.status;
}
pCell = inds[i]->getLocn(1);
locn loc;
locn loc = locn();
if (pCell == 0) loc.x = loc.y = -1; // beyond boundary or in no-data cell
else loc = pCell->getLocn();
pCell = inds[i]->getLocn(0);
Expand Down
1 change: 0 additions & 1 deletion Population.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ class Population {
int countHeterozygoteLoci();
vector<double> countLociHeterozyotes();
double computeHs();
void updateHeteroTable();

private:
short nStages;
Expand Down

0 comments on commit ab4dc2c

Please sign in to comment.