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

Updates for SOILWAT2 v7.1.0 #555

Merged
merged 7 commits into from
Aug 23, 2023
Merged

Conversation

dschlaep
Copy link
Member

@dschlaep dschlaep commented Aug 3, 2023

See DrylandEcology/SOILWAT2#351

  • SOILWAT2 v7.1.0 (preparations for thread-safe and reentrant code)
  • New shell script to run tests for STEPWAT2 reproducibility tools/check_STEPWAT2.sh
  • STEPWAT2 functionality, behavior, and outputs remain identical

dschlaep and others added 5 commits June 30, 2023 08:44
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
- 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
@dschlaep dschlaep requested a review from kpalmqui August 3, 2023 14:41
@dschlaep dschlaep merged commit 5533f41 into Seed_Dispersal Aug 23, 2023
@dschlaep dschlaep deleted the feature_SOILWAT2_v710_devel branch August 23, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants