Ecological Landscape Modeling: Models Pages |
#include "success.h"
Go to the source code of this file.
Functions | |
void | HabSwitch_Init (void) |
Transfers habitat-specific parameters into data struct, allocate memory. | |
unsigned char | HabSwitch (int ix, int iy, float *Water, float *Nutrient, int *Fire, float *Salinity, unsigned char *HAB) |
Switches habitats (the option that is currently used). | |
int | InHab (float Var, struct HabData Params) |
Defines the suitability of current habitat relative to existing conditions. | |
void | alloc_hab_hist (void) |
Allocate memory for habitat history info. |
This source file determines the switching of habitats (succession).
Note: documented with Doxygen, which expects specific syntax within special comments.
The Everglades Landscape Model (ELM).
last updated: Sep 2011
Definition in file Success.c.
void HabSwitch_Init | ( | void | ) |
Transfers habitat-specific parameters into data struct, allocate memory.
Definition at line 25 of file Success.c.
References alloc_hab_hist(), Habi, habNumTot, HP_FireInt, HP_PhosHi, HP_PhosInt, HP_PhosLo, HP_SalinHi, HP_SalinInt, HP_SalinLo, HP_SfDepthHi, HP_SfDepthInt, HP_SfDepthLo, HabData::Lhi, HabData::Llo, msgStr, Habitat::Nutrient, Habitat::PFin, HabData::Pin, Habitat::Salinity, usrErr(), Habitat::Water, and WriteMsg().
Referenced by init_succession().
00026 { 00027 int ii; 00028 00029 /* put these habitat-specific parameters into a concise data struct for use here */ 00030 for( ii = 0; ii < habNumTot; ii++) { 00031 Habi[ii].Water.Llo = HP_SfDepthLo[ii+1]; 00032 Habi[ii].Water.Lhi = HP_SfDepthHi[ii+1]; 00033 Habi[ii].Water.Pin = HP_SfDepthInt[ii+1]; 00034 Habi[ii].Nutrient.Llo = HP_PhosLo[ii+1]; 00035 Habi[ii].Nutrient.Lhi = HP_PhosHi[ii+1]; 00036 Habi[ii].Nutrient.Pin = HP_PhosInt[ii+1]; 00037 Habi[ii].PFin = HP_FireInt[ii+1]; 00038 Habi[ii].Salinity.Llo = HP_SalinLo[ii+1]; 00039 Habi[ii].Salinity.Lhi = HP_SalinHi[ii+1]; 00040 Habi[ii].Salinity.Pin = HP_SalinInt[ii+1]; 00041 } 00042 00043 alloc_hab_hist( ); 00044 sprintf (msgStr, "Succession ON, module OK for %d habitats...", ii ); usrErr(msgStr); WriteMsg(msgStr,1); 00045 00046 return; 00047 }
unsigned char HabSwitch | ( | int | ix, | |
int | iy, | |||
float * | Water, | |||
float * | Nutrient, | |||
int * | Fire, | |||
float * | Salinity, | |||
unsigned char * | HAB | |||
) |
Switches habitats (the option that is currently used).
Returns the number of habitat to switch to based on the length of the weekly (or other) averaged period of favorable conditions. In this case the period of habitat favorable conditions is calculated as the number of weeks (or other time intervals) during which the habitat conditions matched the specified for a period longer than the given one - SW_TIME_TH. The switching occurs as soon as the number of such successfull weeks exceeds the time specified in Pin
ix | Model domain row | |
iy | Model domain column | |
Water | Current water depth data array | |
Nutrient | Current nutrient conc. data array | |
Fire | Fire data array (unused, no fire implemented) | |
Salinity | Current salinity conc. data array | |
HAB | Habitat-type data array |
Definition at line 66 of file Success.c.
References AV_PER, cell, conv_kgTOmg, HabHist, Habi, habNumTot, InHab(), MAX_NHAB, Habitat::Nutrient, HabData::Pin, Habitat::Salinity, SimTime, SW_TIME_TH_N, SW_TIME_TH_S, SW_TIME_TH_W, T, and simTime::TIME.
Referenced by cell_dyn1().
00067 { 00068 int StateW, StateN, StateS, i; 00069 int HabW[MAX_NHAB], HabN[MAX_NHAB], HabS[MAX_NHAB], DW, DN, DS; 00070 int cell = T(ix,iy); 00071 int hab = HAB[cell]; /* current habitat in the cell */ 00072 00073 /* define the habitat type that matches the existing water conditions */ 00074 00075 /* HabHist is an array of integers : ssSnnNwwW, where 00076 ww are the two digits for the number of weeks in the water level favorable conditions, 00077 W the number of days in those conditions during the current week; 00078 nn are the two digits for the number of weeks being in the nutrient favorable conditions, 00079 N the number of days in those conditions during the current week; 00080 ss are the two digits for the number of weeks in the salinity favorable conditions, 00081 S the number of days in those conditions during the current week; 00082 00083 The switching occurs when all of these histories exceed the habitat specific 00084 periods Pin. 00085 */ 00086 for ( i = 0; i < habNumTot; i++ ) 00087 { 00088 DW = HabHist[cell*habNumTot +i]%10; 00089 HabW[i] = (HabHist[cell*habNumTot +i]/10)%100; 00090 DN = (HabHist[cell*habNumTot +i]/1000)%10; 00091 HabN[i] = HabHist[cell*habNumTot +i]/10000; 00092 DS = (HabHist[cell*habNumTot +i]/1000000)%10; 00093 HabS[i] = HabHist[cell*habNumTot +i]/10000000; 00094 00095 /* when the averaging time elapses, if #favorable days exceeds a threshold (using 4 for 7 day AV_PER), increment the period (weeks) history */ 00096 if ((int)SimTime.TIME%AV_PER == 0) 00097 { 00098 if (DW > SW_TIME_TH_W) HabHist[cell*habNumTot +i] = HabHist[cell*habNumTot +i] - DW + 100; 00099 else HabHist[cell*habNumTot +i] = 0; 00100 if (DN > SW_TIME_TH_N) HabHist[cell*habNumTot +i] = HabHist[cell*habNumTot +i] - DN*1000 + 10000; 00101 else HabHist[cell*habNumTot +i] = 0; 00102 if (DS > SW_TIME_TH_S) HabHist[cell*habNumTot +i] = HabHist[cell*habNumTot +i] - DS*1000000 + 10000000; 00103 else HabHist[cell*habNumTot +i] = 0; 00104 } 00105 00106 /* check what habitat type the existing conditions match; increment the day# if conditions are favorable */ 00107 if ( InHab (Water[cell], Habi[i].Water) ) HabHist[cell*habNumTot + i] = HabHist[cell*habNumTot + i] + 1; 00108 if ( InHab (Nutrient[cell]*conv_kgTOmg, Habi[i].Nutrient) ) HabHist[cell*habNumTot + i] = HabHist[cell*habNumTot + i] + 1000; 00109 if ( InHab (Salinity[cell], Habi[i].Salinity) ) HabHist[cell*habNumTot + i] = HabHist[cell*habNumTot + i] + 1000000; 00110 } 00111 00112 /* check if the historical conditions for switching hold */ 00113 for ( i = 0; i < habNumTot; i++ ) 00114 if ( HabW[i] >= Habi[i].Water.Pin && HabN[i] >= Habi[i].Nutrient.Pin && HabS[i] >= Habi[i].Salinity.Pin ) 00115 { HabHist[cell*habNumTot +i] = 0; 00116 return (i+1); /* returns new hab, HAB[] is offset by 1 from these array IDs */ 00117 } 00118 00119 return hab; 00120 }
int InHab | ( | float | Var, | |
struct HabData | Params | |||
) |
Defines the suitability of current habitat relative to existing conditions.
Var | The model variable being considered | |
Params | Struct of habitat switching parameters |
Definition at line 128 of file Success.c.
References HabData::Llo, and MAX_SW.
Referenced by HabSwitch().
00129 { 00130 if ( (Var <= Params.Lhi || Params.Lhi >= MAX_SW) && Var >= Params.Llo ) 00131 return 1; 00132 else return 0; 00133 }
void alloc_hab_hist | ( | void | ) |
Allocate memory for habitat history info.
Definition at line 137 of file Success.c.
References HabHist, habNumTot, init_pvar(), nalloc(), s0, and s1.
Referenced by HabSwitch_Init().
00138 { 00139 HabHist = (unsigned long *) nalloc(sizeof(unsigned long)*(s0+2)*(s1+2)*(habNumTot),"HabHist"); 00140 init_pvar(HabHist,NULL,'i',0); 00141 }