Skip to content

Commit

Permalink
Revert "added changes for rgroup killingfreq and proportional killing"
Browse files Browse the repository at this point in the history
This reverts commit 5a043cc.
  • Loading branch information
ashishtiwari2006 committed Oct 22, 2015
1 parent 5a043cc commit 8fd0a76
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 70 deletions.
12 changes: 6 additions & 6 deletions ST_indivs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void indiv_proportion_Kill( IndivType *ndv, int killType,RealF proportKilled);
/*********** Locally Used Function Declarations ************/
/***********************************************************/
static IndivType *_create ( void);
void _delete (IndivType *ndv);
static void _delete (IndivType *ndv);

/***********************************************************/
/****************** Begin Function Code ********************/
Expand Down Expand Up @@ -204,8 +204,9 @@ void indiv_proportion_Kill( IndivType *ndv, int killType, RealF proportKilled){
/* Chris Bennett @ LTER-CSU 6/15/2000
* 09/23/15 -AT -Added proportionKilled */
/*------------------------------------------------------*/

if (ndv->age > Species[ndv->myspecies]->max_age)


if (ndv->age > Species[ndv->myspecies]->max_age)
{
LogError(logfp, LOGWARN,
"%s dies older than max_age (%d > %d). Iter=%d, Year=%d\n",
Expand All @@ -219,15 +220,14 @@ void indiv_proportion_Kill( IndivType *ndv, int killType, RealF proportKilled){

species_Update_Kills(ndv->myspecies, ndv->age);

if (proportKilled > 0.99)
if (proportKilled > 0.999)
{
Species_Update_Newsize(ndv->myspecies, -ndv->relsize);
_delete(ndv);
}
else
{
RealF newSize = -(ndv->relsize * proportKilled);
ndv->relsize = ndv->relsize + newSize;
Species_Update_Newsize(ndv->myspecies, newSize);
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ void indiv_Kill_Complete( IndivType *ndv, int killType) {
}

/**************************************************************/
void _delete (IndivType *ndv) {
static void _delete (IndivType *ndv) {
/*======================================================*/
/* PURPOSE */
/* Local routine to remove the data object of an individual.
Expand Down
42 changes: 16 additions & 26 deletions ST_mortality.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,22 @@ void mort_EndOfYear( void) {
GrpIndex rg;
GroupType *g;

ForEachGroup(rg)
{
g = RGroup[rg];

if (GT(g->killfreq, 0.))
{
if (LT(g->killfreq, 1.0))
{
if (RandUni() <= g->killfreq)
{
g->killyr = Globals.currYear;
}
}
else if ((Globals.currYear - (g->startyr -1)) % (IntU) g->killfreq == 0)
{
g->killyr = Globals.currYear;
}
}

if (Globals.currYear == RGroup[rg]->extirp)
rgroup_Extirpate(rg);
else if (Globals.currYear == RGroup[rg]->killyr){
RGroup_Kill(rg);
}

}
ForEachGroup(rg) { g = RGroup[rg];

if ( GT( g->killfreq, 0.) ) {
if ( LT(g->killfreq, 1.0) ) {
if (RandUni() <= g->killfreq)
g->killyr = Globals.currYear;
} else if ( (Globals.currYear - g->startyr) % (IntU)g->killfreq == 0) {
g->killyr = Globals.currYear;
}
}

if (Globals.currYear == RGroup[rg]->extirp)
rgroup_Extirpate( rg );
else if (Globals.currYear == RGroup[rg]->killyr)
RGroup_Kill( rg );
}

_kill_extra_growth();
_kill_annuals();
Expand Down
3 changes: 2 additions & 1 deletion ST_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,8 @@ static void _rgroup_add1( char name[], RealF space, RealF density,
RGroup[rg]->use_mort = itob(mort);
RGroup[rg]->veg_prod_type = veg_prod_type;
RGroup[rg]->proportion_killed = prop_killed;
RGroup[rg]->proportion_recovered = prop_recovered;
RGroup[rg]->proportion_recovered = prop_recovered;
printf("grp= %d prop_killed= %f, prop_recovery=%f \n",rg, RGroup[rg]->proportion_killed,RGroup[rg]->proportion_recovered );


RGroup[rg]->extirpated = FALSE;
Expand Down
4 changes: 1 addition & 3 deletions ST_resgroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,7 @@ void RGroup_Update_Newsize( GrpIndex rg) {
/* ie, groupsize=1 when 1 indiv of each species is present */
/* ie each indiv is an equivalent contributor, not based on biomass */
ForEachEstSpp( sp, rg, n) sumsize += Species[sp]->relsize;

//For calculating rgroup relSize, sumsize should be divide by no of current established species in rgroup rather than total no of species in rgroup.
RGroup[rg]->relsize = sumsize / (RealF) RGroup[rg]->est_count;
RGroup[rg]->relsize = sumsize / (RealF) RGroup[rg]->max_spp;

if (RGroup[rg]->max_age != 1) {
/* compute the contribution of each indiv to the group's size */
Expand Down
40 changes: 6 additions & 34 deletions ST_species.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ Bool indiv_New( SppIndex sp);
void indiv_Kill_Complete( IndivType *ndv, int killType);
void indiv_proportion_Kill( IndivType *ndv, int killType,RealF proportionKilled);

void _delete (IndivType *ndv);

/*------------------------------------------------------*/
/* Modular functions only used on one or two specific */
/* places; that is, they are not generally useful */
Expand Down Expand Up @@ -272,12 +270,6 @@ void Species_Update_Newsize( SppIndex sp, RealF newsize ) {
newsize = -Species[sp]->relsize;

Species[sp]->relsize += newsize;

if(LT(Species[sp]->relsize, 0.0) || ZERO(Species[sp]->relsize)){
//Warning:ST_Species.c Species_Update_Newsize() Species[sp]->relsize is either zero or negative
Species[sp]->relsize = 0.0;
}

RGroup_Update_Newsize(rg);

if ( Species[sp]->max_age != 1) {
Expand Down Expand Up @@ -380,13 +372,6 @@ void Species_Proportion_Kill (const SppIndex sp, int killType, RealF proportionK
*/

/*------------------------------------------------------*/
#define xF_DELTA (20*F_DELTA)
#define xD_DELTA (20*D_DELTA)
#define ZERO(x) \
( (sizeof(x) == sizeof(float)) \
? ((x)>-xF_DELTA && (x)<xF_DELTA) \
: ((x)>-xD_DELTA && (x)<xD_DELTA) )

IndivType *p = Species[sp]->IndvHead, *t;

if (Species[sp]->max_age == 1) {
Expand All @@ -397,26 +382,13 @@ void Species_Proportion_Kill (const SppIndex sp, int killType, RealF proportionK
indiv_proportion_Kill( p, killType,proportionKilled);
p = t;
}
}

if ( LT(Species[sp]->relsize, 0.0) || ZERO(Species[sp]->relsize) )
{
//"Warning:ST_species.c Species_Proportion_Kill() Species[sp]->relsize is either zero or negative so deleting all the individual in species and making species rel_size to zero
Species[sp]->relsize = 0.0 ;
IndivType *p1 = Species[sp]->IndvHead, *t1;

while (p1)
{
t1 = p1->Next;
_delete(p);
p1 = t1;
}
rgroup_DropSpecies(sp);
}
}

if (proportionKilled > 0.999)
{
rgroup_DropSpecies(sp);
}

#undef xF_DELTA
#undef xD_DELTA
#undef ZERO

}

Expand Down

0 comments on commit 8fd0a76

Please sign in to comment.