Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge gridded_code into master #375

Merged
merged 176 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 169 commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
0c37b6f
(issue #256) moved RandSeed() calls to right before runGrid()
Apr 4, 2019
7d89416
(issue #251) removed unneeded call to free_all_sxw_memory
Apr 4, 2019
9f215fb
(Issue #254) Remove xgrow and veg_prod_type
fdpierson Apr 6, 2019
ed2bc25
Prototyped CellType struct, created ST_stats.h
Apr 7, 2019
97a6d4c
Moved randseed to former location, added randseed calls to ST_grid.c
Apr 10, 2019
9690c04
Compress sxw.c variables into struct.
Apr 11, 2019
c8e793e
Issue #259 Added SXW variables to CellType struct
Apr 11, 2019
a13702f
Issue #253 removed readme.txt from testing.sagebrush.master folder
Apr 11, 2019
f0ca090
Changed name of new sxw struct (issue #267)
Apr 12, 2019
59702c7
(issue #271) changed global variables to pointers
Apr 14, 2019
6429ee2
Issue #271 added dealloc_Globals() function to be called at the end o…
Apr 15, 2019
5384d06
issue #271 move SOILWAT head to my branch
Apr 17, 2019
daac9e6
Created allocate_gridCells and load_cell functions
Apr 18, 2019
f8f507e
Changed _Ppt, _Dist, _Temp to pointers
Apr 18, 2019
382f7be
(issue #274) created stat_Copy_Accumulators function
Apr 22, 2019
d6b2a13
(issue #278) Made transp_window a pointer
Apr 23, 2019
5dc004d
(issue #279) added .vscode to the gitignore
Apr 23, 2019
c3b8aa9
(issue #728) added deallocation function to sxw.c
Apr 23, 2019
3955a3b
(issue #280) changed SXW and SXWResources to pointers
Apr 23, 2019
ca00257
(issue #247) updated SOILWAT head
Apr 24, 2019
804c2e2
Added call to stat_Copy_Accumulators in load_cell.
Apr 24, 2019
873a2f5
Created and implemented new copy_sxw_variables funciton
Apr 24, 2019
8d58b08
(issue #277) changed name of copy_sxw function in ST_grid.c
Apr 24, 2019
8a072e5
(issue #280) removed unused SXW reference in ST_stats.c
Apr 25, 2019
015f54b
(issue #281) restructured variable _SomeKillage
Apr 25, 2019
5b777b9
(issue #281) added _SomeKillage to deallocate_Globals function
Apr 25, 2019
60f9f3d
Moved allocate_gridCells into _init_grid_inputs
Apr 30, 2019
a7e5409
(issue #286) reordered init functions
May 1, 2019
d56e1a0
Moved local variable declarations to the top, moved function description
May 1, 2019
bbe9ba7
Added SoilType struct to CellType.
May 7, 2019
c648091
Added init Species struct to CellType struct
May 9, 2019
7151fe3
Continued work on RunGrid()
May 14, 2019
d278849
Made RunGrid more similar to main
May 14, 2019
9ebeccf
Resolved conflict for PR #297
May 14, 2019
915086b
Resolved incompatibility resulting from merging master into this branch
May 14, 2019
1003e0c
Removed load_spinup_cell call and renamed a variable
May 17, 2019
92e95d1
Merge remote-tracking branch 'origin/gridded_code' into gridded_code
May 17, 2019
d893eb8
Changed structure and function calls of _run_spinup
May 17, 2019
8b69747
Removed assignment of Globals->nCells
May 20, 2019
2643aba
Addressed comment made on commit d278849
May 20, 2019
ca6c274
Overhauled _init_stepwat_inputs
May 22, 2019
e8cd4b5
(Issue #305) Merge master (clean_code_lowpriority) into gridded_code
fdpierson May 22, 2019
f6819fa
(Issue #305) Uncomment gridded code
fdpierson May 22, 2019
0ec1b8c
(Issue #306) Multiple changes (read description)
fdpierson May 22, 2019
e948b0b
(Issue #306) Change where _resource_cur is initialized
fdpierson May 22, 2019
0b3274a
(Issue #283) Implement grid file and directory enum
fdpierson May 23, 2019
790eb6c
Spinup now uses the requested species
May 23, 2019
3a08b51
Created unload_cell function.
May 23, 2019
78cb4f3
Implemented unload_cell.
May 23, 2019
a978033
Removed UseSeedDispersal and DuringSpinup from unload_cell
May 23, 2019
6072486
Uncommented Species and RGroup from load_cell
May 23, 2019
5f76e42
(Issue #285) Move reading maxrgroupspecies.in outside parm_Initialize
fdpierson May 23, 2019
74f2db3
(Issue #307) Create struct for truly global variables
fdpierson May 23, 2019
d7faa50
(Issue #285) Allow maxrgroupspecies.in to be read
fdpierson May 23, 2019
8e71c20
Removed _copy_species from ST_grid.c
May 24, 2019
87d4f2e
(Issue #285) Overhaul _read_disturbances_in
fdpierson May 25, 2019
6009138
Revert "(Issue #285) Overhaul _read_disturbances_in"
fdpierson May 25, 2019
fa1b862
(Issue #284) Make RGroup and Species work correctly in gridded mode
fdpierson May 28, 2019
8f6a344
Addressed typo in commit 873a2f5
chaukap May 28, 2019
2556c1f
(Issues #285 #286) Break up _init_grid_inputs
fdpierson May 29, 2019
e5abfcb
(Issue #285) Overhaul _init_grid_inputs
fdpierson May 30, 2019
60d78ae
(Issue #285) Overhaul _read_disturbances_in
fdpierson May 30, 2019
e27b2bd
(Issue #285) Overhaul _read_init_species
fdpierson May 30, 2019
0e90845
(Issue #285) Overhaul _read_soils_in
fdpierson May 30, 2019
e7271e4
(Issue #285) Overhaul _read_seed_dispersal_in
fdpierson May 31, 2019
29489fa
(Issue #285) Overhaul _init_grid_globals
fdpierson May 31, 2019
0c4c175
(Issue #285) Fixed bugs in _read_seed_dispersal_in
fdpierson May 31, 2019
1c723c2
Fixed some issues with SXW initialization
Jun 3, 2019
5afbc6d
Removed references to Globals without loading a cell
Jun 3, 2019
58d8a92
Added someKillage to cellType
Jun 3, 2019
93345f5
Added function to allocate gridCell accumulators
Jun 4, 2019
bf83f86
Moved printing general info to RunGrid
Jun 4, 2019
d346d9e
Changes _load_cell call in RunGrid, updated Spinup
Jun 4, 2019
3201f8e
SXW_Reset(void) -> SXW_Reset(char* SOILWAT_file)
Jun 4, 2019
825388e
Moved runModelYears, runModelIterations, nCells and randseed
Jun 5, 2019
63fe8e4
Merging master into girdded_code
Jun 5, 2019
e95891c
Updated _set_sd_lyppt to use gridCells
Jun 6, 2019
70da4f4
Removed _set_sd_lyppt entirely (issue #287)
Jun 7, 2019
2d55c58
Corrected 1-indexing issues (issue #287)
Jun 7, 2019
819bbb0
Uncommented _do_seed_dispersal
Jun 7, 2019
4862018
Removed strange values from grid_disturbances.csv
Jun 7, 2019
9ad09ec
(Issue #309) Convert _do_seed_dispersal to use gridCells
fdpierson Jun 9, 2019
9a2a5f5
(Issue #309) Remove H and VT from grid_seed_dispersal.in
fdpierson Jun 9, 2019
2ea8f25
Merged master into gridded_code (#320)
Jun 10, 2019
f454ce1
Resolved errors introduced while merging pull request #320
Jun 10, 2019
d262025
(Issue #309) Forgot to replace grid_Disturb[i] with RGroup[0]
fdpierson Jun 12, 2019
d8aa20e
Stat output fixed to point of completion
Jun 12, 2019
02e1668
Continued work on all cell average function
Jun 12, 2019
2deb521
partially overhauled _free_grid_memory
Jun 12, 2019
d9115ed
(issue #310) corrected misstyped assignment
Jun 14, 2019
be91251
Compressed all global deallocation into one function
Jun 17, 2019
010e678
Sealed up memory leaks
Jun 17, 2019
a932dc5
Removed references to load_sxw_memory from ST_grid
Jun 17, 2019
25038dd
(Issues #300 #301) Add _kill_maxage
fdpierson Jun 18, 2019
df9fcfa
(Issues #287 #301) Add _kill_maxage
fdpierson Jun 18, 2019
67c2a06
Merge remote-tracking branch 'origin/gridded_code' into gridded_code
fdpierson Jun 18, 2019
a01823f
Added standard deviation calculation.
Jun 19, 2019
a997103
Corrected deallocation of mySeedDispersal->prob
Jun 21, 2019
2b83aca
Removed a few deprecated functions
Jun 21, 2019
5356507
Reset SXW for all grid cells
Jun 21, 2019
feab651
Fixed historical weather file not being used.
Jun 21, 2019
21f2748
Removed unnecessary Mem_free call (issue #327)
Jun 24, 2019
2973b8e
Modified initialization parameters
Jun 26, 2019
5078bea
Created methods for saving and loading the spinup conditions.
Jul 3, 2019
de121d3
Continued work on Spinup (issue #300)
Jul 5, 2019
d5c92f5
removed use_spinup column from grid_initSpecies.csv
Jul 5, 2019
f30821e
Updated grid_disturbances.in
Jul 5, 2019
6803c71
Removed unused functions (issue #311)
Jul 8, 2019
02390dd
Corrected some compiler warnings
Jul 8, 2019
3bd1fa4
Overhauled progress bar
Jul 8, 2019
ec1587a
Removed old progress bar and improved new one.
Jul 8, 2019
0a65e47
Added two new functions related to Initialization
Jul 9, 2019
f1b3bb2
Modified general info printed to terminal
Jul 9, 2019
573cecf
Changed some variable names to make them more ambigous
Jul 9, 2019
299774c
(issue #252) Removed cheatgrass parameters from grid_disturbances.csv
Jul 13, 2019
8f8771d
(issue #343) created a input parameter for spinup years.
Jul 13, 2019
3fdc724
(issue #344) moved VW to species.in.
Jul 13, 2019
1e60f6a
(issue #344) added VW column header to species.in
Jul 13, 2019
6ec9a3b
Combined grid_seed_dispersal.in and grid_setup.in (issue #351)
Jul 13, 2019
3ce4b5f
Removed unused variables deprecated by merging grid_seed_dispersal an…
Jul 15, 2019
4be9ffc
Removed deprecated function _read_a_float.
Jul 15, 2019
6a77ca6
Continued work on the Initialization process. (issue #342)
Jul 15, 2019
f7faa9d
Removed deprecated summary at the top of the file
Jul 15, 2019
bde26a7
Reviewed parameter initialization functions and made small changes.
Jul 15, 2019
9fcffa0
Removed deprecated functions and removed unnecessary declarations
Jul 15, 2019
1219c12
Added a blocker to seed dispersal. (issue #326)
Jul 16, 2019
c23e288
First attempt at fixing _init_seed_dispersal
Jul 16, 2019
dd9c53e
Introduced a "sender" variable to improve code readability
Jul 16, 2019
cd53202
(issue #312) Improved function and variable descriptions
Jul 17, 2019
b3cd79c
Moved functionallity from _run_spinup to runInitialization
Jul 17, 2019
e09fa9f
Separated initialization from ST_grid and added header files (Large c…
Jul 18, 2019
cab7430
(issue #359) Created progress bar .c and .h files.
Jul 19, 2019
9e22edc
Addressed comment on commit f7faa9d
Jul 22, 2019
c6dd45b
Created seed dispersal module (.c and .h files)
Jul 22, 2019
b25a9ba
Added some documentation to the ST_seedDispersal files.
Jul 22, 2019
cb94da8
Addressing comments on commit c23e288
Jul 22, 2019
2cce478
Sealed additional memory leaks (issue #322)
Jul 24, 2019
0485b90
Added input parameter for individual cell output (issue #360)
Jul 27, 2019
d33d857
Hard-coded UseSeedDispersal to FALSE
Jul 28, 2019
bfc8776
Added function to calculate average mortality (issue #361)
Jul 29, 2019
a898b36
Resolved some compiler warnings
Jul 30, 2019
7575ffd
(issue #369) removed mort_EndOfYear form spinup
Jul 30, 2019
7f2d9e8
Issue #367 modified SoilType struct to match SOILWAT better
Jul 31, 2019
977e31d
Overhauled soil layer swapping (issue #367)
Aug 2, 2019
1c3546d
updated SOILWAT head to latest commit on Bugfix_247
Aug 2, 2019
20698f2
#374 overhauled grid_soils.csv
Aug 5, 2019
c06c04c
Addressed seg faults in copy_ functions
Aug 6, 2019
58b1ac7
Merged pull request #373
Aug 6, 2019
edd0abf
Updated SOILWAT2 head to latest commit on Bugfix_247
Aug 6, 2019
d0f2aef
#372 Located bug causing non-gridded mode to crash
Aug 7, 2019
213fbb3
Addressing comments on pull request #375
Aug 8, 2019
5259988
Multiple changes to ST_stats.
Aug 9, 2019
8fa4da7
Added error check to _read_soils_in
Aug 9, 2019
c8b0094
Removed spaces between grid_soils.csv entries
Aug 12, 2019
9b99edd
Addressing comments on PR #375
Aug 15, 2019
e27a4be
Addressing comments on PR #375
Aug 19, 2019
d03b276
Resolved merge conflict for PR #382
Aug 21, 2019
5c965a8
Addressing comments on PR #375
Aug 28, 2019
5b1b919
Removed unused includes and fixed a typo
Sep 26, 2019
d3cb3fd
Removed unused print satements and redundancies
Sep 26, 2019
103ca00
Removed commented-out code
Sep 26, 2019
2a1ff37
Removed commented-out statements
Sep 26, 2019
c8605b7
Added back a print statement in ST_main.c
Sep 27, 2019
af5d2f8
Small changes requested in PR #375
Nov 4, 2019
0fd76ca
Addressing comments on pull request #375
Nov 6, 2019
715e1e3
Addressing comments on pull request #375
Nov 12, 2019
d192856
Addressing comments on pull request #375
Nov 13, 2019
0291723
Continued addressing comments on pull request #375
Nov 14, 2019
fd179cc
Addressed more comments on pull request #375
Nov 15, 2019
6a53657
Modified two comments as discussed in pull request #375
Nov 18, 2019
f70d4af
Reduced number of cells specified in grid input CSVs
Nov 19, 2019
01db611
Improved documentation of unusual code in runGrid()
Nov 19, 2019
f944a09
Updated sw_src to latest commit on Bugfix_247_STEPWAT_compatability
Nov 26, 2019
32567b3
Merge branch 'master' into gridded_code
Nov 26, 2019
2889da3
Updated ST_params.c To work with gridded mode.
Nov 26, 2019
a4dd5f7
Update SOILWAT2 head
Dec 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ nbproject/private/launcher.properties
nbproject/private/private.xml
nbproject/project.xml

# VScode project files
######################
.vscode

# CLion project files
cmake-build-debug/*
.idea/*
Expand Down
11 changes: 6 additions & 5 deletions ST_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
/***************************************************
* Basic definitions
***************************************************/
#define MAX_SPECIES (Globals.max_spp_per_grp * Globals.max_rgroups)
#define MAX_SPECIES (SuperGlobals.max_spp_per_grp * SuperGlobals.max_rgroups)
#define MAX_SPECIESNAMELEN 4 /* keep around for SOILWAT for now */

/* output_Bmass_Yearly of ST_output.c and _make_header and _make_header_with_std
* of ST_stats.c output different numbers of fields. Set MAX_OUTFIELDS to the
* maximum number of fields these three functions are capable of outputting. */
#define MAX_OUTFIELDS ((MAX_SPECIES * 2) + (Globals.max_rgroups * 6) + 8)
#define MAX_OUTFIELDS ((MAX_SPECIES * 2) + (SuperGlobals.max_rgroups * 6) + 8)

#define MAX_FIELDLEN (Globals.max_groupnamelen + 6) /* +6 for xtra chars like _RSize, etc */
#define MAX_FIELDLEN (SuperGlobals.max_groupnamelen + 6) /* +6 for xtra chars like _RSize, etc */
#define MAX_CELLS 10000 // defines the maximum number of cells in the grid option

/* Constants for flagging whether a sort is
Expand Down Expand Up @@ -114,12 +114,12 @@ typedef enum {F_First, F_Log, F_Model, F_Env, F_Plot, F_RGroup, F_Species,
* preferably as GrpIndex, but note that it gets changed, so it
* can only be an lvalue. */
/* void ForEachGroup(GrpIndex) */
#define ForEachGroup(c) for((c)=0; (c)< Globals.grpCount; (c)++)
#define ForEachGroup(c) for((c)=0; (c)< Globals->grpCount; (c)++)

/* Generate an SppIndex to access Species[] to loop over each
* defined species, irrespective of group. */
/* void ForEachSpecies(SppIndex) */
#define ForEachSpecies(s) for((s)=0; (s)< Globals.sppCount; (s)++)
#define ForEachSpecies(s) for((s)=0; (s)< Globals->sppCount; (s)++)

/* Same for individuals within a species. Traverses a species'
* linked list of IndivType objects. i is a pointer to
Expand Down Expand Up @@ -179,6 +179,7 @@ typedef struct plot_st PlotType;
typedef struct globals_st ModelType;
typedef struct bmassflags_st BmassFlagsType;
typedef struct mortflags_st MortFlagsType;
typedef struct superglobals_st GlobalType;


#endif
176 changes: 108 additions & 68 deletions ST_environs.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "sxw_funcs.h"
#include "sw_src/filefuncs.h"
#include "sw_src/Times.h"
extern SXW_t SXW;
extern SXW_t* SXW;

/*********** Locally Used Function Declarations ************/
/***********************************************************/
Expand Down Expand Up @@ -60,27 +60,67 @@ void Env_Generate( void) {
_make_disturbance();
}

/* Deep copy one EnvType's information to another. Note that both must be initialized
BEFORE calling this function. */
void copy_environment(const EnvType* src, EnvType* dest){
if(!src){
return;
}

dest->lyppt = src->lyppt;
dest->ppt = src->ppt;
dest->temp = src->temp;
dest->gsppt = src->gsppt;
dest->temp_reduction[0] = src->temp_reduction[0];
dest->temp_reduction[1] = src->temp_reduction[1];
dest->wet_dry = src->wet_dry;
}

/* Deep copy one PlotType's information to another. Note that both must be initialized
BEFORE calling this function. */
void copy_plot(const PlotType* src, PlotType* dest){
if(!src){
return;
}

dest->disturbance = src->disturbance;
dest->disturbed = src->disturbed;
dest->pat_removed = src->pat_removed;
}

/* Deep copy one SucculentType's information to another. Note that both must be initialized
BEFORE calling this function. */
void copy_succulent(const SucculentType* src, SucculentType* dest){
if(!src){
return;
}

dest->growth[0] = src->growth[0];
dest->growth[1] = src->growth[1];
dest->mort[0] = src->mort[0];
dest->mort[1] = src->mort[1];
dest->prob_death = src->prob_death;
dest->reduction = src->reduction;
}

/**************************************************************/
static void _make_ppt( void) {
/*======================================================*/
/* If not running SOILWAT,take a random number from normal distribution with*/
/* mean, stddev that is between min & max from */
/* the Globals.ppt structure.*/
/* Also set the growing season precip. */
/* the Globals->ppt structure.*/
/* Also determine growing season precipitation. */

/* HISTORY */
/* Chris Bennett @ LTER-CSU 6/15/2000 */
/* cwb - 6-Dec-02 -- added code to interface with STEPWAT.
* The ppt and gsppt are set in _sxw_set_environs()
* but we still pass through this code to set the
* Dry/Wet/Normal state.
* KAP 1/26/2017 The above note by CB is not correct. Env.ppt
* is set in _sxw_set_environs, but gsppt is not, it is
* set below. When using SOILWAT or not, the gsspt, ppt.dry,
* and ppt.wet is currently fixed each year and read from env.in
* We should consider calculating gsspt in the _sxw_set_environs
* function when running SOILWAT (so it is not fixed), and allowing
* what constitutes a wet and dry year to vary across sites. */
* KAP 1/26/2017 We should consider calculating amount of growing-season
* precipitation this year in the _sxw_set_environs function when
* running SOILWAT (so it is not fixed), and allowing what constitutes
* a wet and dry year to vary across sites. */
chaukap marked this conversation as resolved.
Show resolved Hide resolved

/*------------------------------------------------------*/

Expand All @@ -93,27 +133,27 @@ static void _make_ppt( void) {
// Run with SOILWAT2: we have monthly PPT and temperature to calculate
// growing season precipitation as sum of monthly precipitation of those
// months when mean air temperature exceeds a threshold that allows for plant growth 'Globals.temp.gstemp'
Env.gsppt = 0; // gsppt is defined as IntS and units are millimeters
Env->gsppt = 0; // gsppt is defined as IntS and units are millimeters

for (i = 0; i < MAX_MONTHS; i++)
{
Env.gsppt += GE(SXW.temp_monthly[i], Globals.temp.gstemp) ?
(IntS) (SXW.ppt_monthly[i] * 10. + 0.5) : 0;
Env->gsppt += GE(SXW->temp_monthly[i], Globals->temp.gstemp) ?
(IntS) (SXW->ppt_monthly[i] * 10. + 0.5) : 0;
}

if (Env.gsppt <= 0)
if (Env->gsppt <= 0)
{
LogError(logfp, LOGWARN, "Zero growing season precipitation in "\
"year = %d of iteration = %d", Globals.currYear, Globals.currIter);
Env.gsppt = 0;
"year = %d of iteration = %d", Globals->currYear, Globals->currIter);
Env->gsppt = 0;
}

if ( Env.ppt <= Globals.ppt.dry )
Env.wet_dry = Ppt_Dry;
else if (Env.ppt >= Globals.ppt.wet)
Env.wet_dry = Ppt_Wet;
if ( Env->ppt <= Globals->ppt.dry )
Env->wet_dry = Ppt_Dry;
else if (Env->ppt >= Globals->ppt.wet)
Env->wet_dry = Ppt_Wet;
else
Env.wet_dry = Ppt_Norm;
Env->wet_dry = Ppt_Norm;
}

/**************************************************************/
Expand All @@ -127,12 +167,12 @@ static void _set_ppt_reduction( void) {
/*------------------------------------------------------*/

/* EQN 10*/
Succulent.reduction = fabs(Succulent.growth[Slope]
* Env.gsppt
+ Succulent.growth[Intcpt]);
Succulent->reduction = fabs(Succulent->growth[Slope]
* Env->gsppt
+ Succulent->growth[Intcpt]);
/* EQN 16*/
Succulent.prob_death = (Succulent.mort[Slope] * Env.gsppt
+ Succulent.mort[Intcpt]) / 100.0;
Succulent->prob_death = (Succulent->mort[Slope] * Env->gsppt
+ Succulent->mort[Intcpt]) / 100.0;
}

/**************************************************************/
Expand All @@ -158,20 +198,20 @@ static void _set_temp_reduction( void) {
RealF tp[4]; /* parms for temp growth modifier eqn.*/

for ( i=CoolSeason; i <= WarmSeason; i ++ ){
tp[1] = Globals.tempparm[i][0];
tp[2] = Globals.tempparm[i][1];
tp[3] = Globals.tempparm[i][2];
tp[0] = Env.temp + tp[1];
Env.temp_reduction[i] = tp[2]*tp[0] + tp[3] * (tp[0]*tp[0]);
Env.temp_reduction[i] = max(0., Env.temp_reduction[i]);
tp[1] = Globals->tempparm[i][0];
tp[2] = Globals->tempparm[i][1];
tp[3] = Globals->tempparm[i][2];
tp[0] = Env->temp + tp[1];
Env->temp_reduction[i] = tp[2]*tp[0] + tp[3] * (tp[0]*tp[0]);
Env->temp_reduction[i] = max(0., Env->temp_reduction[i]);
}

if (Env.temp < 9.5 ) {
Env.temp_reduction[CoolSeason] = .9;
Env.temp_reduction[WarmSeason] = .6;
if (Env->temp < 9.5 ) {
Env->temp_reduction[CoolSeason] = .9;
Env->temp_reduction[WarmSeason] = .6;
} else {
Env.temp_reduction[CoolSeason] = .6;
Env.temp_reduction[WarmSeason] = .9;
Env->temp_reduction[CoolSeason] = .6;
Env->temp_reduction[WarmSeason] = .9;
}
}

Expand All @@ -191,73 +231,73 @@ static void _make_disturbance( void) {

/*------------------------------------------------------*/
/* Can't have simultaneous disturbances*/
if (Plot.disturbance != NoDisturb) {
switch( Plot.disturbance) {
if (Plot->disturbance != NoDisturb) {
switch( Plot->disturbance) {
case FecalPat:
if (Plot.pat_removed) {
Plot.disturbed = 0;
Plot.pat_removed = FALSE;
Plot.disturbance = NoDisturb;
if (Plot->pat_removed) {
Plot->disturbed = 0;
Plot->pat_removed = FALSE;
Plot->disturbance = NoDisturb;
} else {
pc = Globals.pat.recol[Slope] * Plot.disturbed
+ Globals.pat.recol[Intcpt];
pc = Globals->pat.recol[Slope] * Plot->disturbed
+ Globals->pat.recol[Intcpt];
if (RandUni(&environs_rng) <= pc) {
Plot.pat_removed = TRUE;
Plot->pat_removed = TRUE;
/* slight effects for one year*/
Plot.disturbed = 1;
Plot->disturbed = 1;
} else {
Plot.pat_removed = FALSE;
Plot.disturbed++;
Plot->pat_removed = FALSE;
Plot->disturbed++;
}
}
break;
case NoDisturb: // Does nothing but prevent a compiler warning
case LastDisturb:
default:
Plot.disturbed = (Plot.disturbed) ? Plot.disturbed -1 : 0;
Plot->disturbed = (Plot->disturbed) ? (Plot->disturbed - 1) : 0;
break;
}
if (Plot.disturbed == 0)
Plot.disturbance = NoDisturb;
if (Plot->disturbed == 0)
Plot->disturbance = NoDisturb;

}

/* if the disturbance was expired above, */
/* we can generate a new one immediately */
if (Plot.disturbance == NoDisturb) {
if (Plot->disturbance == NoDisturb) {

/* pick some type of disturbance (other than none)*/
event = (DisturbEvent) RandUniIntRange(1, LastDisturb -1, &environs_rng);

/* make sure this is off unless needed */
Plot.pat_removed = FALSE;
Plot->pat_removed = FALSE;
switch( event) {
case FecalPat:
if (!Globals.pat.use) {event=NoDisturb; break;}
event = (RandUni(&environs_rng) <= Globals.pat.occur)
if (!Globals->pat.use) {event=NoDisturb; break;}
event = (RandUni(&environs_rng) <= Globals->pat.occur)
? event : NoDisturb;
if (event == NoDisturb) break;
Plot.pat_removed = (RandUni(&environs_rng) <= Globals.pat.removal)
? TRUE : FALSE;
Plot.disturbed = 0;
Plot->pat_removed = (RandUni(&environs_rng) <= Globals->pat.removal);
Plot->disturbed = 0;
break;
case AntMound:
if (!Globals.mound.use) {event=NoDisturb; break;}
event = (RandUni(&environs_rng) <= Globals.mound.occur)
if (!Globals->mound.use) {event=NoDisturb; break;}
event = (RandUni(&environs_rng) <= Globals->mound.occur)
? event :NoDisturb;
if (event == NoDisturb) break;

Plot.disturbed = RandUniIntRange(Globals.mound.minyr,
Globals.mound.maxyr,
Plot->disturbed = RandUniIntRange(Globals->mound.minyr,
Globals->mound.maxyr,
&environs_rng);
break;
case Burrow:
if (!Globals.burrow.use) {event=NoDisturb; break;}
event = (RandUni(&environs_rng) <= Globals.burrow.occur)
if (!Globals->burrow.use) {event=NoDisturb; break;}
event = (RandUni(&environs_rng) <= Globals->burrow.occur)
? event :NoDisturb;
if (event == NoDisturb) break;

Plot.disturbed = (Globals.burrow.minyr > 0)
? RandUniIntRange(1, Globals.burrow.minyr, &environs_rng)
Plot->disturbed = (Globals->burrow.minyr > 0)
? RandUniIntRange(1, Globals->burrow.minyr, &environs_rng)
: 0;
break;
case NoDisturb:
Expand All @@ -267,7 +307,7 @@ static void _make_disturbance( void) {
default:
break;
}
Plot.disturbance = event;
Plot->disturbance = event;

}

Expand Down
3 changes: 3 additions & 0 deletions ST_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include "ST_defines.h"

void Env_Generate( void );
void copy_environment(const EnvType* src, EnvType* dest);
void copy_plot(const PlotType* src, PlotType* dest);
void copy_succulent(const SucculentType* src, SucculentType* dest);

/* See steppe_main.c for declarations of the following

Expand Down
11 changes: 5 additions & 6 deletions ST_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@

extern SpeciesType **Species;
extern GroupType **RGroup;
extern SucculentType Succulent;
extern EnvType Env;
extern PlotType Plot;
extern ModelType Globals;
extern SucculentType *Succulent;
extern EnvType *Env;
extern PlotType *Plot;
extern ModelType *Globals;
extern BmassFlagsType BmassFlags;
extern MortFlagsType MortFlags;
extern GlobalType SuperGlobals;

extern Bool UseSeedDispersal;
extern Bool UseGrid;
extern Bool DuringSpinup;
Loading