Everglades Landscape Model (ELM) Home Page |
#include "globals.h"
Include dependency graph for success.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | HabData |
struct | Habitat |
Defines | |
#define | MAX_SW 9999 |
#define | AV_PER 7 |
#define | SW_TIME_TH_W 4 |
#define | SW_TIME_TH_N 4 |
Functions | |
void | HabSwitch_Init (void) |
Transfers habitat-specific parameters into data struct, allocate memory. | |
void | alloc_hab_hist (void) |
Allocate memory for habitat history info. | |
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 | init_pvar (VOIDP Map, UCHAR *mask, unsigned char Mtype, float iv) |
Initialize a variable to a value. | |
VOIDP | nalloc (unsigned mem_size, const char var_name[]) |
Allocate memory for a variable. | |
Variables | |
unsigned long * | HabHist |
Habitat | Habi [MAX_NHAB] |
float * | HP_SfDepthLo |
float * | HP_SfDepthHi |
float * | HP_SfDepthInt |
float * | HP_PhosLo |
float * | HP_PhosHi |
float * | HP_PhosInt |
float * | HP_FireInt |
int | habNumTot |
This defines or declares variables & functions that are global to Success.c.
Note: documented with Doxygen, which expects specific syntax within special comments.
The Everglades Landscape Model (ELM).
last updated: Jan 2005
Definition in file success.h.
|
A maximum value for high-end of a switching parameter (suitable conditions re. that variable are always met if actual parm exceeds it) |
|
Number of days that constitutes the period of averaging - use weekly (7 d); should be <100 Definition at line 19 of file success.h. Referenced by HabSwitch(). |
|
Switching time threshold for water - use 4 d for weekly AV_PER (i.e., majority of week) |
|
Switching time threshold for nutrients - use 4 d for weekly AV_PER (i.e., majority of week) |
|
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:
|
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:
|
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 }
|
|
Initialize a variable to a value.
Definition at line 925 of file Driver_Utilities.c. Referenced by alloc_hab_hist(), alloc_mem_stats(), alloc_memory(), Canal_Network_Init(), and Channel_configure(). 00926 { 00927 int i0, i1; 00928 00929 switch(Mtype) { 00930 case 'b' : /* added double for (non-map) basin (b) array budget calcs */ 00931 for(i0=0; i0<=numBasn; i0++) { 00932 ((double*)Map)[i0] = iv; 00933 } 00934 break; 00935 case 'l' : /* added double (l == letter "ell" ) for map arrays */ 00936 for(i0=0; i0<=s0+1; i0++) 00937 for(i1=0; i1<=s1+1; i1++) { 00938 if(mask==NULL) ((double*)Map)[T(i0,i1)] = iv; 00939 else if ( mask[T(i0,i1)] == 0 ) ((double*)Map)[T(i0,i1)] = 0; 00940 else ((double*)Map)[T(i0,i1)] = iv; 00941 } 00942 break; 00943 case 'f' : 00944 for(i0=0; i0<=s0+1; i0++) 00945 for(i1=0; i1<=s1+1; i1++) { 00946 if(mask==NULL) ((float*)Map)[T(i0,i1)] = iv; 00947 else if ( mask[T(i0,i1)] == 0 ) ((float*)Map)[T(i0,i1)] = 0; 00948 else ((float*)Map)[T(i0,i1)] = iv; 00949 } 00950 break; 00951 case 'i' : case 'd' : 00952 for(i0=0; i0<=s0+1; i0++) 00953 for(i1=0; i1<=s1+1; i1++) { 00954 if(mask==NULL) ((int*)Map)[T(i0,i1)] = (int)iv; 00955 else if ( mask[T(i0,i1)] == 0 ) ((int*)Map)[T(i0,i1)] = 0; 00956 else ((int*)Map)[T(i0,i1)] = (int)iv; 00957 } 00958 break; 00959 case 'c' : 00960 for(i0=0; i0<=s0+1; i0++) 00961 for(i1=0; i1<=s1+1; i1++) { 00962 if(mask==NULL) ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv; 00963 else if ( mask[T(i0,i1)] == 0 ) ((unsigned char*)Map)[T(i0,i1)] = '\0'; 00964 else ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv; 00965 } 00966 break; 00967 00968 default : 00969 printf(" in default case\n"); 00970 break; 00971 } 00972 }
|
|
Allocate memory for a variable.
Definition at line 1774 of file Driver_Utilities.c. References Exit(), fasync(), fmulti(), total_memory, and VOIDP. Referenced by alloc_hab_hist(), alloc_mem_stats(), alloc_memory(), Canal_Network_Init(), Channel_configure(), initDataStruct(), read_map_file(), readSeriesCol(), ReadStructures(), readViewParms(), setup_grid(), and write_map_file(). 01775 { 01776 VOIDP rp; 01777 01778 01779 if(mem_size == 0) return(NULL); 01780 rp = (VOIDP)malloc( mem_size ); 01781 total_memory += mem_size; 01782 fasync(stderr); 01783 if( rp == NULL ) { 01784 fprintf(stderr,"Sorry, out of memory(%d): %s\n",mem_size,var_name); 01785 Exit(0); 01786 } 01787 fmulti(stderr); 01788 return(rp); 01789 }
|
Here is the call graph for this function:
|
HabHist is an array of integers : nnNssS, where nn are the two digits for the number of weeks being in the nutrient favorable conditions, N the number of days in those conditions during the current week; similarly ss are the two digits for the number of weeks in the water level favorable conditions and S is the number of days during the current week in that state. The switching occurs when both of these histories exceed the habitat specific periods Pin. Definition at line 30 of file success.h. Referenced by alloc_hab_hist(), and HabSwitch(). |
|
Definition at line 47 of file success.h. Referenced by HabSwitch(), and HabSwitch_Init(). |
|
Habitat-specific parameter. _Units_: m; _Brief_: Lower Depth tolerance for Surface Water Depth Definition at line 71 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
Habitat-specific parameter. _Units_: m; _Brief_: Higher Depth tolerance for Surface Water Depth Definition at line 72 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
Habitat-specific parameter. _Units_: days; _Brief_: Time Interval for staying within Surface Water Depth range Definition at line 73 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
Habitat-specific parameter. _Units_: mgP/kg soil; _Brief_: Lower concentration tolerance for soil total Phosphorus Definition at line 74 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
Habitat-specific parameter. _Units_: mgP/kg soil; _Brief_: Higher concentration tolerance for soil total Phosphorus Definition at line 75 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
Habitat-specific parameter. _Units_: days; _Brief_: Time Interval for staying within soil total Phosphorus range Definition at line 76 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
Habitat-specific parameter. _Units_: days; _Brief_: UNUSED. Time Interval since last Fire Definition at line 77 of file unitmod_habparms.h. Referenced by alloc_memory(), HabSwitch_Init(), and ReadHabParms(). |
|
total number of habitat-types used in model Definition at line 45 of file serial.h. Referenced by alloc_hab_hist(), get_hab_parm(), and HabSwitch(). |