Everglades Landscape Model (ELM) Home Page |
#include "success.h"
Include dependency graph for Success.c:
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, 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: Jan 2005
Definition in file Success.c.
|
Transfers habitat-specific parameters into data struct, allocate memory.
Definition at line 23 of file Success.c. References alloc_hab_hist(), Habi, HP_FireInt, HP_PhosHi, HP_PhosInt, HP_PhosLo, HP_SfDepthHi, HP_SfDepthInt, HP_SfDepthLo, HabData::Lhi, HabData::Llo, msgStr, Habitat::Nutrient, Habitat::PFin, HabData::Pin, usrErr(), Habitat::Water, and WriteMsg(). 00024 { 00025 int ii; 00026 00027 /* put these habitat-specific parameters into a concise data struct for use here */ 00028 for( ii = 0; ii < habNumTot; ii++) { 00029 Habi[ii].Water.Llo = HP_SfDepthLo[ii+1]; 00030 Habi[ii].Water.Lhi = HP_SfDepthHi[ii+1]; 00031 Habi[ii].Water.Pin = HP_SfDepthInt[ii+1]; 00032 Habi[ii].Nutrient.Llo = HP_PhosLo[ii+1]; 00033 Habi[ii].Nutrient.Lhi = HP_PhosHi[ii+1]; 00034 Habi[ii].Nutrient.Pin = HP_PhosInt[ii+1]; 00035 Habi[ii].PFin = HP_FireInt[ii+1]; 00036 } 00037 00038 alloc_hab_hist( ); 00039 sprintf (msgStr, "Succession ON, module OK for %d habitats...", ii ); usrErr(msgStr); WriteMsg(msgStr,1); 00040 00041 return; 00042 }
|
Here is the call graph for this function:
|
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
Definition at line 60 of file Success.c. References AV_PER, cell, conv_kgTOmg, HAB, HabHist, Habi, habNumTot, InHab(), Habitat::Nutrient, HabData::Pin, SimTime, T, simTime::TIME, and Habitat::Water. 00061 { 00062 int StateW, StateN, i; 00063 int HabW[MAX_NHAB], HabN[MAX_NHAB], DW, DN; 00064 int cell = T(ix,iy); 00065 int hab = HAB[cell]; /* current habitat in the cell */ 00066 00067 /* define the habitat type that matches the existing water conditions */ 00068 00069 /* HabHist is an array of integers : nnNssS, where nn are the two digits for the number of 00070 weeks being in the nutrient favorable conditions, N the number of days in those conditions 00071 during the current week; similarly ss are the two digits for the number of weeks in the 00072 water level favorable conditions and S is the number of days during the current week in 00073 that state. The switching occurs when both of these histories exceed the habitat specific 00074 periods Pin. 00075 */ 00076 for ( i = 0; i < habNumTot; i++ ) 00077 { 00078 DW = HabHist[cell*habNumTot +i]%10; 00079 HabW[i] = (HabHist[cell*habNumTot +i]/10)%100; 00080 DN = (HabHist[cell*habNumTot +i]/1000)%10; 00081 HabN[i] = HabHist[cell*habNumTot +i]/10000; 00082 00083 /* when the averaging time elapses, if #favorable days exceeds a threshold (using 4 for 7 day AV_PER), increment the period (weeks) history */ 00084 if ((int)SimTime.TIME%AV_PER == 0) 00085 { 00086 if (DW > SW_TIME_TH_W) HabHist[cell*habNumTot +i] = HabHist[cell*habNumTot +i] - DW + 100; 00087 else HabHist[cell*habNumTot +i] = 0; 00088 if (DN > SW_TIME_TH_N) HabHist[cell*habNumTot +i] = HabHist[cell*habNumTot +i] - DN*1000 + 10000; 00089 else HabHist[cell*habNumTot +i] = 0; 00090 } 00091 00092 /* check what habitat type the existing conditions match; increment the day# if conditions are favorable */ 00093 if ( InHab (Water[cell], Habi[i].Water) ) HabHist[cell*habNumTot + i]++; 00094 if ( InHab (Nutrient[cell]*conv_kgTOmg, Habi[i].Nutrient) ) 00095 HabHist[cell*habNumTot + i] = HabHist[cell*habNumTot + i] + 1000; 00096 } 00097 00098 /* check if the historical conditions for switching hold */ 00099 for ( i = 0; i < habNumTot; i++ ) 00100 if ( HabW[i] >= Habi[i].Water.Pin && HabN[i] >= Habi[i].Nutrient.Pin ) 00101 { HabHist[cell*habNumTot +i] = 0; 00102 return (i+1); /* returns new hab, HAB[] is offset by 1 from these array IDs */ 00103 } 00104 00105 return hab; 00106 }
|
Here is the call graph for this function:
|
Defines the suitability of current habitat relative to existing conditions.
Definition at line 112 of file Success.c. References HabData::Lhi, and HabData::Llo. Referenced by HabSwitch(). 00113 { 00114 if ( (Var <= Params.Lhi || Params.Lhi >= MAX_SW) && Var >= Params.Llo ) 00115 return 1; 00116 else return 0; 00117 }
|
|
Allocate memory for habitat history info.
Definition at line 121 of file Success.c. References HabHist, habNumTot, init_pvar(), nalloc(), s0, and s1. Referenced by HabSwitch_Init(). 00122 { 00123 HabHist = (unsigned long *) nalloc(sizeof(unsigned long)*(s0+2)*(s1+2)*(habNumTot),"HabHist"); 00124 init_pvar(HabHist,NULL,'i',0); 00125 }
|
Here is the call graph for this function: