diff --git a/ST_indivs.c b/ST_indivs.c index 4d44b7a9..1230edca 100755 --- a/ST_indivs.c +++ b/ST_indivs.c @@ -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 ********************/ @@ -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", @@ -219,7 +220,7 @@ 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); @@ -227,7 +228,6 @@ void indiv_proportion_Kill( IndivType *ndv, int killType, RealF proportKilled){ else { RealF newSize = -(ndv->relsize * proportKilled); - ndv->relsize = ndv->relsize + newSize; Species_Update_Newsize(ndv->myspecies, newSize); } } @@ -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. diff --git a/ST_mortality.c b/ST_mortality.c index 296b76d0..77375b4b 100755 --- a/ST_mortality.c +++ b/ST_mortality.c @@ -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(); diff --git a/ST_params.c b/ST_params.c index 181a85b2..0fe243c4 100755 --- a/ST_params.c +++ b/ST_params.c @@ -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; diff --git a/ST_resgroups.c b/ST_resgroups.c index f86ece6e..f3e8fd86 100755 --- a/ST_resgroups.c +++ b/ST_resgroups.c @@ -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 */ diff --git a/ST_species.c b/ST_species.c index 05f0b134..372c34d8 100755 --- a/ST_species.c +++ b/ST_species.c @@ -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 */ @@ -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) { @@ -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)-xD_DELTA && (x)IndvHead, *t; if (Species[sp]->max_age == 1) { @@ -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 }