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 Seed Dispersal into master #484

Merged
merged 111 commits into from
Sep 13, 2023
Merged

Merge Seed Dispersal into master #484

merged 111 commits into from
Sep 13, 2023

Conversation

kpalmqui
Copy link
Member

This pull requests overhauls the seed dispersal module within gridded mode of STEPWAT2

chaukap and others added 30 commits December 12, 2019 12:32
(issue #417)
* Added MAXD to the SpeciesType struct. NOTE: I names the new variable maxDispersalDistance because it is more readable.

(issue #418)
* Removed sd_VW and sd_VT from species.in and from the program.

(issue #420)
* Added Doxygen module for seed dispersal.
… documenting.

(issue #416)
* Added Pmd to species.in and added a corresponding variable to the SpeciesType struct.
* In SpeciesType the variable is called maxDispersalProbability to make it easy to read.

(issue #420)
* I documented the _cell_dist function in ST_seedDispersal.c.

(issue #417)
* I changed MAXD for artr to 30.0 meters.
(issue #413)
This function is complete and ready for use.

I also renamed param1 to minReproductiveSize as discussed in the same issue.
(issue #422)
HBAR and HMAX are read in and stored in the SpeciesType struct. I also created the associated function, getSpeciesHeight, but for now it only returns HBAR until the actual implementation is made clear.

The values I chose for HMax need to be updated. For now they are all 40.0 centimeters.
* HSlope is now specified in species.in.
* HSlope is stored in the SpeciesType struct as heightSlope.

I also made two aesthetic changes:
* The "dispersal" column in species.in was changed to "Use". I did this to shorten the name, and becasue it better describes the column.
* I documented _species_init for Doxygen.
(issue #415)
The function now implements the equation for height as specified in the issue.
(issue #414)
* Removed sd_PPTwet and sd_PPTdry from SpeciesType struct
* Removed lyppt from Grid_SD_St struct
My new implementation is inline with issue #309.

I also documented ST_seedDispersal.c and .h for Doxygen.

While writing the new implementation the nested for loops were making the lines obnoxiously large (120+ characters) so I ran clang format on ST_seedDispersal.c This will make it look a little messy, but it is much easier to read in an IDE.
The old implementation was a mess and didn't work properly. The new implementation accounts for the three reasons to establish (seed dispersal, forced establishment, and establishment based on seedling_estab_prob) and is easy to read.

NOTE: This implementation changes the number of calls to the random number generator. Therefore, the output will not match any previous commits. I did, however, test it and the output is acceptable.

(issue #428)
issue #428
* Added an additional check to the seed dispersal section of Species_NumEstablish()
* Added print statements which will be helpfull as we test the program.

Issue #326
* Restrictions on running seed dispersal have been removed.
* Seed dispersal is now a valid option for gridded mode.

I also made some minor documentation and ordering changes suggested in other commits.

NOTE:
There are some problems still on the table. I am commiting my code along with input files that make seed dispersal work as expected for sagebrush if and only if initialization is turned on for Sagebrush. I will discuss the limitations and problems with seed dispersal further in issue #326.
(issue #414)
I forgot to turn on auto-save on my new laptop, and therefore forgot to
commit a few things.
(issue #409)
All progress bar code is now documented.
I also added modules for the Grid and Initialization.
(issue #409)
* ST_grid.h and every feature within has been documented.
* The ST_grid.c file itself is documented, but not the features.
* Added an SXW_PRIVATE module.
* Fixed typo in _rateOfDispersal documentation.
(issue #432)
This function loops through all cells and all species to set seedsPresent to TRUE, basically acting as a seed bank.
I removed a ton of redundant header inclusions, making the dependencies of the program much clearer.
(issue #433)
(issue #434)
Every file now has a description at the top written in Doxygen notation.
This commit adds three files:
* ST_colonization.c
* ST_colonization.h
* grid_colonization.csv

These files comprise the colonization module. I then added all
functions, files, and structs to the doxygen documentation. I also added
ST_colonization.c to the makefile.

I have NOT yet incorporated the module into gridded mode. That commit
will come after additional testing.
Merge master into seed dispersal branch
(issue #444)
I began with the three steps I layed out in the issue, then ran into a
few bugs that caused me to rewite some of my algorithms:
1) I realized that passing the year into the colonize() function as a
parameter was far easier than trying to infer the year from the grid.
2) Placing the species name in the second column of the input csv was
causing sscanf to have trouble reading the rest of the csv. The easiest
solution was to move the species name to the last column.
3) There were some problems in initColonization regarding pointers.
First of all, I forgot to actually allocate memory to _allEvents, which
is the main variable of the colonization module. Second, I needed to
load a cell before attempting to call any functions from ST_species.c.

Now, colonization works in the gridded mode.
These warnings were all minor: broken links, malformed syntax, ect.
(issue #443)
The user can now enter a range of cells or use "-1" to specify all
cells.
This function will output every dispersal event (an instance of one cell giving seeds to another cell) in a single CSV file.
Nicholas Persley and others added 13 commits January 30, 2023 20:15
- for details, see DrylandEcology/SOILWAT2#345
-> "weathsetup.in" gained a new input "description of downward surface shortwave radiation"

-> none of that is currently relevant or active for STEPWAT2

- this commit produces identical output to commit c974dc6 on branch feature_SOILWAT2_v700_devel
Prepare STEPWAT2 to handle SOILWAT2's additional daily inputs

- no impacts on STEPWAT2 output: STEPWAT2 does not utilize new daily inputs
Updates for SOILWAT2 release v7.0.0

- https://github.com/DrylandEcology/SOILWAT2/releases/tag/v7.0.0

- The interface to SOILWAT2 is updated to work with SOILWAT2 v7.0.0
* new settings will be set such that they reproduce previous behavior

- small difference arise in how nongridded STEPWAT2 runs use the weather generator (now a seed is set once a year -- instead of once at the beginning; see commit 755b3e9)
STEPWAT2 should meet reproducibility expectations as formulated with
PR #528 (#528) that was
merged into the main branch on Sep 18, 2022 with commit
(7dce3c7)
"Exactly reproduce random number sequences"

This new bash script automatically runs gridded and nongridded example runs with STEPWAT2 using different seeds and uses 'diff' and 'Rscript' to check the following:

* if seed != 0 (output is reproduced among runs)
** weather is exactly identical among runs and cells
** weather is different among years, iterations and seeds

* if seed == 0 (output cannot be reproduced among runs)
** weather is different among cells, years, iterations and runs

Note that 'master' and 'Seed_Dispersal' branches use different naming schemes of output files -> these need to be manually adjusted with variables `tag_gridded_biomass_cellk` (line 30) and `fname_gridded_biomass_meancell` (line 35) -- they are currently set to the 'Seed_Dispersal' scheme
@kpalmqui kpalmqui requested a review from alexisBelt July 16, 2023 13:24
@kpalmqui kpalmqui self-assigned this Jul 16, 2023
Copy link
Contributor

@alexisBelt alexisBelt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good and I don't see any glaring issues!

Nicholas Persley and others added 11 commits July 28, 2023 12:49
- This commit puts together all changes made on the original development branch (#544) but without the changes to whitespace

- Update submodule to the latest SOILWAT2 version

- To prepare for parallelization, SOILWAT2 has been given the capability to be thread-safe and reentrant and has gained four new main structs
* SW_ALL - All information relevant to the simulation, e.g., simulation output, program/user settings, etc.
* LOG_INFO - Information pertaining to logging in the case of a warning, note, error, etc. output
* PATH_INFO - Details about the program/project directory (input files, output files, and prefixes)
* SW_OUTPUT_POINTERS - Storage to hold specific subroutines for output
* STEPWAT2 gains these types as global

- Most functions within SOILWAT2 have had their interfaces updated to have access to local instances of the four new structs and subtypes (SW_WEATHER, SW_MODEL, etc.)
- Functions that call `LogError()` are updated to send in global LOG_INFO
- Updated `ForEach*TranspLayer()` macro calls with `ForEachTranspLayer()` due to `ForEach*TranspLayer()` being replaced with `ForEachTranspLayer()` on SOILWAT2
- Updated other SOILWAT2 function calls to have the information it requires
- Functions that read in files gain local buffers to write into instead of writing into a global buffer from SOILWAT2

- Removed "extern" comments for types/variables that are no longer globals
- Removed unnecessary inclusion of SOILWAT2 files

- sxw_sql.c/sxw.c gain SW_Times.h for constants representing the number of every month

- Because STEPWAT2 does not use SOILWAT2 globals, we have to
* Copy STEPWAT2 globals, SuperGlobals and Globals into SOILWAT2 instances of it after every model year run
* Copy STEPWAT2 global, SuperGlobals into SOILWAT2 instance before reading in input from disk
* Copy SOILWAT2's instance of SXW into STEPWAT2's global after every model year run

- SOILWAT2 removed the "OUTSEP" line of "outsetup.in", so within STEPWAT inputs, the line has been removed

- Updated test to create a local instance of LOG_INFO
- `SXW_Init()` now calls `SXW_Reset()` instead of directly `SXW_Reinit()` because gridded mode needs to deallocate memory that was previously dynamically allocated by SOILWAT2 for global variables `SoilWatAll`, etc.

- gridded mode uses the same global variables for all grid cells and they are initialized by `_init_stepwat_inputs()` > loop over gridcells: `_init_SXW_inputs()` > `SXW_Init()`; thus, we were previously leaking memory that was allocated via call to `SXW_Init()` and not freed for the next grid cell.

- this will no longer be needed once grid cells use their own local SOILWAT2 variables

- sharing these global variables among iterations was already working correctly because it already called `SXW_Reset()`
…cy_threadsafety_compact

- Updates SOILWAT2 to latest development version - v7.1.0 (includes preparations for threadsafety and reentrancy)
- Added globals of the four new main (SOILWAT2) types - SW_ALL, SW_OUTPUT_POINTERS, PATH_INFO, and LOG_INFO
Updates for SOILWAT2 v7.1.0

- SOILWAT2 v7.1.0 (preparations for thread-safe and reentrant code)
- STEPWAT2 functionality, behavior, and outputs remain identical
- New shell script `tools/check_STEPWAT2.sh` to check for STEPWAT2 reproducibility
- merging 'master'

- porting changes from 'Seed_Dispersal' to new code sections received from 'master'
* `Mem_Calloc()` gained a "LOG_INFO" argument
* "ST_initialization" ('master') was renamed to "ST_spinup" ('Seed_Dispersal')

# Conflicts:
#	ST_grid.c
#	ST_grid.h
#	ST_initialization.c
#	ST_params.c
- previously, `make all` compiled both the "stepwat" executable and the unit test executable "stepwat_test"
- now, "all" only compiles the "stepwat" executable
- the "stepwat_test" executable can (as previously) be compiled with `make stepwat_test`

- note that the "stepwat_test" executable currently fails to compile on the Seed_Dispersal branch because updated googletest version requires std=c++14 (see issue #558)
-comment out printf statements used for tracking parameters in gridded mode
@kpalmqui kpalmqui merged commit ec1c1d7 into master Sep 13, 2023
@kpalmqui kpalmqui deleted the Seed_Dispersal branch September 26, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants