Skip to content

Commit

Permalink
FATE changes :
Browse files Browse the repository at this point in the history
+ remove `MAX_ABUND_LOW`, `MAX_ABUND_MEDIUM`, `MAX_ABUND_HIGH` in global parameters
+ addition of `MAX_ABUND` parameter within PFG succession files
+ transform `SHADE_FACTOR` from int to double
+ correct DROUGHT code
  • Loading branch information
MayaGueguen committed Jun 18, 2024
1 parent c938c6b commit 3bc3caf
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 143 deletions.
22 changes: 10 additions & 12 deletions src/FG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ using namespace std;
/* Constructors */
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/

FG::FG() : m_Name(""), m_M(0), m_L(1), m_MaxA(ANone), m_ImmSize(100), m_MaxStratum(0), m_Strata(0, 1000), /* Life history*/
FG::FG() : m_Name(""), m_M(0), m_L(1), m_MaxAbund(100), m_ImmSize(100), m_MaxStratum(0), m_Strata(0, 1000), /* Life history*/
m_PoolL(PTcount,0), m_InnateDorm(false), m_PotentialFecundity(100), /* Propagule biology */
m_LightShadeFactor(1), m_LightActiveGerm(Rcount, 100), m_LightTolerance(LScount, vector<int>(Rcount, 100)), /* Light response */
m_LightShadeFactor(1.0), m_LightActiveGerm(Rcount, 100), m_LightTolerance(LScount, vector<int>(Rcount, 100)), /* Light response */
m_IsSeeded(false), m_disp50(0.0), m_disp99(0.0), m_dispLD(0.0), /* Dispersal module */
m_SoilContrib(0.0), m_SoilLow(0.0), m_SoilHigh(0.0), /* Soil response */
m_SoilActiveGerm(Rcount, 100), m_SoilTolerance(LScount, vector<int>(Rcount, 100)), /* Soil response */
Expand Down Expand Up @@ -85,13 +85,12 @@ void FG::getSuccParams(const GSP& glob_params, const string& PFG_LifeHistoryFile
logg.error("!!! MATURITY is superior or equal to LONGEVITY. Please check!");
}

m_MaxA = Abund(SuccParams.get_val<int>("MAX_ABUNDANCE")[0]);
m_MaxAbund = SuccParams.get_val<int>("MAX_ABUNDANCE")[0];
m_ImmSize = SuccParams.get_val<int>("IMM_SIZE")[0];
if (m_ImmSize < 0 || m_ImmSize > 100)
{
logg.error("!!! IMM_SIZE must be superior or equal to 0, and inferior or equal to 100. Please check!");
}
//m_MaxStratum = SuccParams.get_val<int>("MAX_STRATUM")[0];
vector<int> v_int = SuccParams.get_val<int>("MAX_STRATUM", true);
if (v_int.size()) m_MaxStratum = v_int[0]; else m_MaxStratum = glob_params.getNoStrata();
m_Strata = SuccParams.get_val<int>("CHANG_STR_AGES");
Expand Down Expand Up @@ -146,7 +145,7 @@ void FG::getLightParams(const string& PFG_LightFile)
/* 2. read light parameters */
par::Params LightParams(PFG_LightFile.c_str(), " = \"", "#");

m_LightShadeFactor = LightParams.get_val<int>("SHADE_FACTOR")[0];
m_LightShadeFactor = LightParams.get_val<double>("SHADE_FACTOR")[0];
if (m_LightShadeFactor < 0)
{
logg.error("!!! SHADE_FACTOR must be superior or equal to 0. Please check!");
Expand Down Expand Up @@ -363,7 +362,7 @@ FG::FG(const GSP& glob_params, const FOPL& file_of_params, const unsigned& fg_id
}
} else
{
m_LightShadeFactor = 1;
m_LightShadeFactor = 1.0;
m_LightActiveGerm.resize(Rcount, 100);
m_LightTolerance.resize(LScount, vector<int>(Rcount, 100));
}
Expand Down Expand Up @@ -476,8 +475,7 @@ FG::~FG()
const string& FG::getName() const {return m_Name;}
int FG::getMatTime() const {return m_M;}
int FG::getLifeSpan() const {return m_L;}
const Abund& FG::getMaxAbund() const {return m_MaxA;}
//int FG::getMaxAbund() {return(AbundToInt(m_MaxA));}
int FG::getMaxAbund() const {return m_MaxAbund;}
int FG::getImmSize() const {return m_ImmSize;}
int FG::getMaxStratum() const {return m_MaxStratum;}
const vector<int> FG::getStrata() const {return m_Strata;}
Expand All @@ -486,7 +484,7 @@ const vector<int> FG::getPoolLife() const {return m_PoolL;}
int FG::getPoolLife(const PoolType& pt ) const {return m_PoolL[pt];}
bool FG::getInnateDormancy() const {return m_InnateDorm;}
int FG::getPotentialFecund() const {return m_PotentialFecundity;}
int FG::getLightShadeFactor() const {return m_LightShadeFactor;}
double FG::getLightShadeFactor() const {return m_LightShadeFactor;}
const vector<int> FG::getLightActiveGerm() const {return m_LightActiveGerm;}
const int& FG::getLightActiveGerm(const Resource& r) const {return m_LightActiveGerm[r];}
const vector< vector<int> >& FG::getLightTolerance() const {return m_LightTolerance;}
Expand Down Expand Up @@ -517,7 +515,7 @@ bool FG::getIsAlien() const {return m_IsAlien;}
void FG::setName(const string& name){m_Name = name;}
void FG::setMatTime(const int& matTime){m_M = matTime;}
void FG::setLifeSpan(const int& lifeSpan){m_L = lifeSpan;}
void FG::setMaxAbund(const Abund& maxAbund){m_MaxA = maxAbund;}
void FG::setMaxAbund(const int& maxAbund){m_MaxAbund = maxAbund;}
void FG::setImmSize(const int& immSize){m_ImmSize = immSize;}
void FG::setMaxStratum(const int& maxStratum){m_MaxStratum = maxStratum;}
void FG::setStrata(const vector<int>& strata){m_Strata = strata;}
Expand All @@ -526,7 +524,7 @@ void FG::setPoolLife(const int (&poolLife)[ PTcount ]){for(int i=0; i<PTcount; i
void FG::setPoolLife(const int& poolLife, const PoolType& pt ){m_PoolL[pt] = poolLife;}
void FG::setInnateDormancy(const bool& innateDormancy){m_InnateDorm = innateDormancy;}
void FG::setPotentialFecund(const int& potentialFecund){m_PotentialFecundity = potentialFecund;}
void FG::setLightShadeFactor(const int& lightShadeFactor){m_LightShadeFactor = lightShadeFactor;}
void FG::setLightShadeFactor(const double& lightShadeFactor){m_LightShadeFactor = lightShadeFactor;}
void FG::setLightActiveGerm(const int (&activeGerm) [ Rcount ] ){ for(int i=0; i<Rcount; i++){m_LightActiveGerm[i] = activeGerm[i];}}
void FG::setLightActiveGerm(const int& activeGerm, const Resource& r ){ m_LightActiveGerm[r] = activeGerm;}
void FG::setTolerance(const int (&tolerance)[ LScount ][ Rcount ]){
Expand Down Expand Up @@ -570,7 +568,7 @@ void FG::show()
"\nm_Name = ", m_Name,
"\nm_M = ", m_M,
"\nm_L = ", m_L,
"\nm_MaxA = ", m_MaxA,
"\nm_MaxAbund = ", m_MaxAbund,
"\nm_ImmSize = ", m_ImmSize,
"\nm_MaxStratum = ", m_MaxStratum,
"\nm_Strata = ", m_Strata,
Expand Down
16 changes: 8 additions & 8 deletions src/FG.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class FG
/* Life history*/
int m_M; /*!< Maturation time */
int m_L; /*!< Life span */
Abund m_MaxA; /*!< Maximum Abundance */
int m_MaxAbund; /*!< Maximum Abundance */
int m_ImmSize; /*!< Proportion of immature plants relative to mature abundance */
int m_MaxStratum; /*!< Maximum stratum reached */
vector<int> m_Strata; /*!< Strata change age */
Expand All @@ -84,7 +84,7 @@ class FG
int m_PotentialFecundity; /*!< Potential Fecundity of mature plants */

/* Light interaction module */
int m_LightShadeFactor; /*!< Index of shade quantity to weight PFG abundance and transform it into shade resources */
double m_LightShadeFactor; /*!< Index of shade quantity to weight PFG abundance and transform it into shade resources */
vector<int> m_LightActiveGerm; /*!< Proportion of Active seeds able to germinate considering light resources [Rcount] */
vector< vector<int> > m_LightTolerance; /*!< Is FG survived considering available light resources [LScount][Rcount] */

Expand Down Expand Up @@ -131,7 +131,7 @@ class FG
ar & m_Name;
ar & m_M;
ar & m_L;
ar & m_MaxA;
ar & m_MaxAbund;
ar & m_ImmSize;
ar & m_MaxStratum;
ar & m_Strata;
Expand Down Expand Up @@ -324,7 +324,7 @@ class FG
return (m_Name == o.m_Name &&
m_M == o.m_M &&
m_L == o.m_L &&
m_MaxA == o.m_MaxA &&
m_MaxAbund == o.m_MaxAbund &&
m_ImmSize == o.m_ImmSize &&
m_MaxStratum == o.m_MaxStratum &&
m_Strata == o.m_Strata &&
Expand Down Expand Up @@ -379,7 +379,7 @@ class FG
const string& getName() const;
int getMatTime() const;
int getLifeSpan() const;
const Abund& getMaxAbund() const;
int getMaxAbund() const;
int getImmSize() const;
int getMaxStratum() const;
const vector<int> getStrata() const;
Expand All @@ -388,7 +388,7 @@ class FG
int getPoolLife(const PoolType& pt ) const;
bool getInnateDormancy() const;
int getPotentialFecund() const;
int getLightShadeFactor() const;
double getLightShadeFactor() const;
const vector<int> getLightActiveGerm() const;
const int& getLightActiveGerm(const Resource& r) const;
const vector< vector<int> >& getLightTolerance() const;
Expand Down Expand Up @@ -419,7 +419,7 @@ class FG
void setName(const string& name);
void setMatTime(const int& matTime);
void setLifeSpan(const int& lifeSpan);
void setMaxAbund(const Abund& maxAbund);
void setMaxAbund(const int& maxAbund);
void setImmSize(const int& immSize);
void setMaxStratum(const int& maxStratum);
void setStrata(const vector<int>& strata);
Expand All @@ -428,7 +428,7 @@ class FG
void setPoolLife(const int& poolLife, const PoolType& pt);
void setInnateDormancy(const bool& innateDormancy);
void setPotentialFecund(const int& potentialFecund);
void setLightShadeFactor(const int& lightShadeFactor);
void setLightShadeFactor(const double& lightShadeFactor);
void setLightActiveGerm(const int (&activeGerm)[ Rcount ]);
void setLightActiveGerm(const int& activeGerm, const Resource& r );
void setTolerance(const int (&tolerance)[ LScount ][ Rcount ]);
Expand Down
13 changes: 0 additions & 13 deletions src/FGUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ using namespace std;

/* Available values definition for FGs & environment parameters */

/*!
* \enum Abund
* \brief Factorial PFGs Abundances
*/
enum Abund
{
ANone, /*!< No individuals */
ALow, /*!< Low Abundance (< AA virtual individuals) */
AMedium, /*!< Medium Abundance (< BB virtual individuals) */
AHigh, /*!< High Abundance (> CC virtual individuals) */
Acount
};

/*!
* \enum PoolType
* \brief Different Propagules Pool type
Expand Down
46 changes: 0 additions & 46 deletions src/GlobalSimulParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ using namespace std;

GSP::GSP() : m_NoCPU(1), m_NoFG(0), m_NoStrata(0), m_SimulDuration(0),
m_SeedingDuration(0), m_SeedingTimeStep(0), m_SeedingInput(0), m_PotentialFecundity(0),
m_MaxAbundLow(0), m_MaxAbundMedium(0), m_MaxAbundHigh(0),
m_DoSavingPFGStratum(false), m_DoSavingPFG(false), m_DoSavingStratum(false),
m_DoLightInteraction(false), m_LightThreshLow(0), m_LightThreshMedium(0), m_LightRecruitment(false), m_LightSaving(false),
m_DoHabSuitability(false), m_HabSuitMode(1),
Expand All @@ -64,7 +63,6 @@ m_DoAliensIntroduction(false), m_FreqAliens(0,0)

GSP::GSP(const int& noCPU, const int& noFG, const int& noStrata, const int& simulDuration,
const int& seedingDuration, const int& seedingTimeStep, const int& seedingInput, const int& potentialFecundity,
const int& maxAbundLow, const int& maxAbundMedium, const int& maxAbundHigh,
const bool& doSavingPFGStratum, const bool& doSavingPFG, const bool& doSavingStratum,
const bool& doLightInteraction, const int& lightThreshLow, const int& lightThreshMedium,
const bool& lightRecruitment, const bool& lightSaving,
Expand All @@ -84,7 +82,6 @@ const bool& doDroughtDisturbances, const int& noDroughtSub, const string& chrono
const bool& doAliensIntroduction, const vector<int>& freqAliens) : m_NoFG(noFG), m_NoStrata(noStrata),
m_SimulDuration(simulDuration),
m_SeedingDuration(seedingDuration), m_SeedingTimeStep(seedingTimeStep), m_SeedingInput(seedingInput), m_PotentialFecundity(potentialFecundity),
m_MaxAbundLow(maxAbundLow), m_MaxAbundMedium(maxAbundMedium), m_MaxAbundHigh(maxAbundHigh),
m_DoSavingPFGStratum(doSavingPFGStratum), m_DoSavingPFG(doSavingPFG), m_DoSavingStratum(doSavingStratum),
m_DoLightInteraction(doLightInteraction), m_LightThreshLow(lightThreshLow), m_LightThreshMedium(lightThreshMedium),
m_LightRecruitment(lightRecruitment), m_LightSaving(lightSaving),
Expand Down Expand Up @@ -184,17 +181,6 @@ GSP::GSP(const string globalParamsFile)
{
logg.error("!!! Parameter POTENTIAL_FECUNDITY : must be superior to 0!");
}
m_MaxAbundLow = GlobParms.get_val<int>("MAX_ABUND_LOW")[0];
m_MaxAbundMedium = GlobParms.get_val<int>("MAX_ABUND_MEDIUM")[0];
m_MaxAbundHigh = GlobParms.get_val<int>("MAX_ABUND_HIGH")[0];
if (m_MaxAbundLow > m_MaxAbundMedium)
{
logg.error("!!! Parameter MAX_ABUND_LOW : must be inferior or equal to MAX_ABUND_MEDIUM!");
}
if (m_MaxAbundMedium > m_MaxAbundHigh)
{
logg.error("!!! Parameter MAX_ABUND_MEDIUM : must be inferior or equal to MAX_ABUND_HIGH!");
}

/* GET OPTIONAL parameters : seeding */
v_int = GlobParms.get_val<int>("SEEDING_DURATION", true);
Expand Down Expand Up @@ -485,9 +471,6 @@ int GSP::getSeedingDuration() const{ return m_SeedingDuration; }
int GSP::getSeedingTimeStep() const{ return m_SeedingTimeStep; }
int GSP::getSeedingInput() const{ return m_SeedingInput; }
int GSP::getPotentialFecundity() const{ return m_PotentialFecundity; }
int GSP::getMaxAbundLow() const{ return m_MaxAbundLow; }
int GSP::getMaxAbundMedium() const{ return m_MaxAbundMedium; }
int GSP::getMaxAbundHigh() const{ return m_MaxAbundHigh; }
bool GSP::getDoSavingPFGStratum() const{ return m_DoSavingPFGStratum; }
bool GSP::getDoSavingPFG() const{ return m_DoSavingPFG; }
bool GSP::getDoSavingStratum() const{ return m_DoSavingStratum; }
Expand Down Expand Up @@ -544,9 +527,6 @@ void GSP::setSeedingDuration(const int& seedingDuration){ m_SeedingDuration = se
void GSP::setSeedingTimeStep(const int& seedingTimeStep){ m_SeedingTimeStep = seedingTimeStep; }
void GSP::setSeedingInput(const int& seedingInput){ m_SeedingInput = seedingInput; }
void GSP::setPotentialFecundity(const int& potentialFecundity){ m_PotentialFecundity = potentialFecundity; }
void GSP::setMaxAbundLow(const int& maxAbundLow){ m_MaxAbundLow = maxAbundLow; }
void GSP::setMaxAbundMedium(const int& maxAbundMedium){ m_MaxAbundMedium = maxAbundMedium; }
void GSP::setMaxAbundHigh(const int& maxAbundHigh){ m_MaxAbundHigh = maxAbundHigh; }
void GSP::setDoSavingPFGStratum(const bool& doSavingPFGStratum){ m_DoSavingPFGStratum = doSavingPFGStratum; }
void GSP::setDoSavingPFG(const bool& doSavingPFG){ m_DoSavingPFG = doSavingPFG; }
void GSP::setDoSavingStratum(const bool& doSavingStratum){ m_DoSavingStratum = doSavingStratum; }
Expand Down Expand Up @@ -610,9 +590,6 @@ void GSP::show()
"\nm_SeedingTimeStep = ", m_SeedingTimeStep,
"\nm_SeedingInput = ", m_SeedingInput,
"\nm_PotentialFecundity = ", m_PotentialFecundity,
"\nm_MaxAbundLow = ", m_MaxAbundLow,
"\nm_MaxAbundMedium = ", m_MaxAbundMedium,
"\nm_MaxAbundHigh = ", m_MaxAbundHigh,
"\nm_DoSavingPFGStratum = ", m_DoSavingPFGStratum,
"\nm_DoSavingPFG = ", m_DoSavingPFG,
"\nm_DoSavingStratum = ", m_DoSavingStratum,
Expand Down Expand Up @@ -663,26 +640,3 @@ void GSP::show()
"\n");
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/

int GSP::AbundToInt(Abund abund)
{
/* Convert Abundance classes to integer (defined by user) */
int res = 0;
switch (abund)
{
case ANone: case Acount:
res = 0;
break;
case ALow:
res = m_MaxAbundLow;
break;
case AMedium:
res = m_MaxAbundMedium;
break;
case AHigh:
res = m_MaxAbundHigh;
break;
}
return res;
}
39 changes: 0 additions & 39 deletions src/GlobalSimulParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class GSP
int m_SeedingTimeStep; /*!< Seeding time step */
int m_SeedingInput; /*!< Number of seeds introduced during seeding */
int m_PotentialFecundity; /*!< Potential Fecundity of mature plants (maximum value of seeds produced in optimal conditions) */
int m_MaxAbundLow; /*!< Maximum abundance or space a PFG can occupy : low value */
int m_MaxAbundMedium; /*!< Maximum abundance or space a PFG can occupy : medium value */
int m_MaxAbundHigh; /*!< Maximum abundance or space a PFG can occupy : high value */

/* Saving parameters */
bool m_DoSavingPFGStratum; /*!< Unable or not the saving of abundance maps per PFG per stratum */
Expand Down Expand Up @@ -155,9 +152,6 @@ class GSP
ar & m_SeedingTimeStep;
ar & m_SeedingInput;
ar & m_PotentialFecundity;
ar & m_MaxAbundLow;
ar & m_MaxAbundMedium;
ar & m_MaxAbundHigh;
ar & m_DoSavingPFGStratum;
ar & m_DoSavingPFG;
ar & m_DoSavingStratum;
Expand Down Expand Up @@ -244,12 +238,6 @@ class GSP
* \param seedingInput : number of seeds dispersed each year during seeding
* \param potentialFecundity : potential fecundity of mature plants
* (maximum value of seeds produced in optimal conditions)
* \param maxAbundLow : maximum abundance or space a PFG can occupy : low
* value
* \param maxAbundMedium : maximum abundance or space a PFG can occupy :
* medium value
* \param maxAbundHigh : maximum abundance or space a PFG can occupy :
* high value
* \param doSavingPFGStratum : unable or not the saving of abundance maps
* per PFG per stratum
* \param doSavingPFG : unable or not the saving of abundance maps
Expand Down Expand Up @@ -322,9 +310,6 @@ class GSP
const int& seedingTimeStep,
const int& seedingInput,
const int& potentialFecundity,
const int& maxAbundLow,
const int& maxAbundMedium,
const int& maxAbundHigh,
const bool& doSavingPFGStratum,
const bool& doSavingPFG,
const bool& doSavingStratum,
Expand Down Expand Up @@ -398,9 +383,6 @@ class GSP
m_SeedingTimeStep == o.m_SeedingTimeStep &&
m_SeedingInput == o.m_SeedingInput &&
m_PotentialFecundity == o.m_PotentialFecundity &&
m_MaxAbundLow == o.m_MaxAbundLow &&
m_MaxAbundMedium == o.m_MaxAbundMedium &&
m_MaxAbundHigh == o.m_MaxAbundHigh &&
m_DoSavingPFGStratum == o.m_DoSavingPFGStratum &&
m_DoSavingPFG == o.m_DoSavingPFG &&
m_DoSavingStratum == o.m_DoSavingStratum &&
Expand Down Expand Up @@ -462,10 +444,6 @@ class GSP
int getSeedingTimeStep() const;
int getSeedingInput() const;
int getPotentialFecundity() const;
int getMaxAbundLow() const;
int getMaxAbundMedium() const;
int getMaxAbundHigh() const;
int getMaxAbundPixel() const;
bool getDoSavingPFGStratum() const;
bool getDoSavingPFG() const;
bool getDoSavingStratum() const;
Expand Down Expand Up @@ -522,9 +500,6 @@ class GSP
void setSeedingTimeStep(const int& seedingTimeStep);
void setSeedingInput(const int& seedingInput);
void setPotentialFecundity(const int& potentialFecundity);
void setMaxAbundLow(const int& maxAbundLow);
void setMaxAbundMedium(const int& maxAbundMedium);
void setMaxAbundHigh(const int& maxAbundHigh);
void setDoSavingPFGStratum(const bool& doSavingPFGStratum);
void setDoSavingPFG(const bool& doSavingPFG);
void setDoSavingStratum(const bool& doSavingStratum);
Expand Down Expand Up @@ -579,20 +554,6 @@ class GSP

void show();

/*!
* \brief Convert Abundance classes to integer
*
* This functions converts a value from enum Abund to an integer :
* - ANone -> 0
* - ALow -> m_MaxAbundLow
* - AMedium -> m_MaxAbundMedium
* - AHigh -> m_MaxAbundHigh
*
* \param abund : a value from enum Abund (ANone, ALow, AMedium, AHigh)
* \return : an integer corresponding to a value from enum Abund
*/
int AbundToInt(Abund abund);

};

BOOST_CLASS_VERSION(GSP, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PKG_CXXFLAGS=@PKG_CPPFLAGS@ -Iinclude $(SHLIB_OPENMP_CXXFLAGS) \
-Wsign-compare -Wtype-limits -Wunused -Wunused-parameter \
-Wsign-compare -Wtype-limits -Wunused \
-DBOOST_NO_AUTO_PTR #-DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REF -DBOOST_FILESYSTEM_SINGLE_THREADED
PKG_LIBS=@PKG_LIBS@ $(SHLIB_OPENMP_CXXFLAGS)
CXX_STD=CXX17
Expand Down
Loading

0 comments on commit 3bc3caf

Please sign in to comment.