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

Development for v7.1.0 #351

Merged
merged 156 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
eab14cf
New comprehensive SW struct + includes VegProd
Mar 19, 2023
8bacfae
Comprehensive struct gains SW_WEATHER
Mar 21, 2023
e4eeab5
Removed function `SW_OutputPrefix()`
Mar 25, 2023
e7e5c55
All (mock)output functions gain umbrella struct
Mar 25, 2023
0039e56
New file `SW_datastructs.h`
Apr 2, 2023
daf64fa
Purged unnecessary `#include`s
Apr 2, 2023
801fd4f
Fixed dynamic call definitions for rSOILWAT2/STEPWAT2
Apr 2, 2023
c7d2b0d
Removed `unused parameter` warnings
Apr 2, 2023
6450afb
Comprehensive struct gains SW_SOILWAT
Apr 3, 2023
942ec7d
Removed unnecessary parameters of types within SW_ALL
Apr 9, 2023
bd1fcb9
Updated function parameter documentation
Apr 9, 2023
592ec24
Removed excessive SoilWater memory freeing
Apr 15, 2023
a41e1b1
Comprehensive struct gains SW_MODEL
Apr 22, 2023
a5eef1f
Comprehensive struct gains SW_SITE
Apr 23, 2023
a6e314e
Comprehensive struct gains SW_VEGESTAB
Apr 30, 2023
994c2da
Fix argument order of `SW_VES_read2()`
dschlaep May 1, 2023
f1a2a04
Catch-up on function documentation
May 7, 2023
9e45c44
Comprehensive struct gains SW_SKY
May 8, 2023
4e2f08f
Add missed parameter documentation for `SW_CBN_read()`
May 8, 2023
c654b6f
Comprehensive struct gains SW_CARBON
May 8, 2023
3312b0e
`soil_temperature()` loses argument "oldavgLyrTemp"
dschlaep May 4, 2023
f4491df
Remove SWC and drainage from copying arrays <-> records in flow module
dschlaep May 4, 2023
be0a3d8
Remove soil temperature from copying arrays <-> records in flow module
dschlaep May 4, 2023
0245d25
Eliminate static two-day `surfaceAvg` and replace with `SW_Weather->s…
dschlaep May 5, 2023
dad890d
Fix debug statement of `SW_OUT_write_today()`
dschlaep May 5, 2023
803ff00
Remove hydraulic redistribution from copying arrays <-> records in fl…
dschlaep May 6, 2023
2964e19
Remove transpiration from copying arrays <-> records in flow module
dschlaep May 6, 2023
6071ea0
Clarify bare-soil evaporation variables
dschlaep May 6, 2023
d189a96
Finalize elimination of `arrays2records()`
dschlaep May 8, 2023
e7aab1d
Fix updated interface of `SW_WaterBalance_Checks()`
dschlaep May 8, 2023
6042818
Fix `SW_SWC_end_day()` and `soil_temperature()` documenation
May 10, 2023
2ecdbd5
Merge pull request #350 from DrylandEcology/simplify_arrays_in_flow
N1ckP3rsl3y May 11, 2023
9fde3e4
Comprehensive struct gains ST_RGR_VALUES
May 12, 2023
e90722c
Comprehensive struct gains SW_FILE_STATUS
May 12, 2023
62992bc
Comprehensive struct gains SW_MARKOV
May 15, 2023
b90cf58
New output struct + comprehensive struct gains SW_OUTPUT
May 22, 2023
d6aef71
Struct conversion clean up
May 23, 2023
1ec8c17
.gitignore gains VS Code folder (.vscode/)
May 23, 2023
8fe3927
Convert `MyFileName` from global to local scope
May 24, 2023
cea5710
Misc. static conversion (_notime, temp_snow, _prev*)
May 24, 2023
a342b6b
Comprehensive struct gains new `SW_FLOW_LIB_VALUES`
May 24, 2023
14eabb1
Convert local snow static variables to constants
May 25, 2023
4a36830
SW_SOILWAT gains global water storage (from `SW_Flow.c`)
May 25, 2023
09f03f2
New struct which comprehensive struct gains - SW_ATMD
May 30, 2023
e79fb7d
`Times.c` loses global static variables
May 30, 2023
3bf425a
Deleted struct SW_FLOW_LIB_VALUES
May 31, 2023
362ef62
`generic.h` conv. part 1 - new struct, `QuietMode` & `logged`
Jun 2, 2023
774722d
`generic.h` conv. part 2 - `errstr` & spread LOG_INFO
Jun 2, 2023
f1feb07
Remove global `inbuf`
Jun 2, 2023
713c38c
New struct PATH_INFO Part 1 - remove globals
Jun 3, 2023
01eb1c0
New struct PATH_INFO Part 2 - remove `init()`
Jun 3, 2023
29f4d6b
Remove globals `bFlush_output` & `useTimeStep`
Jun 3, 2023
49e49c0
Convert `UpNeigh_*` to local arrays in `SW_Water_Flow()`
Jun 3, 2023
825906c
Convert global `_Sep` + remove `OUTSEP` in `outsetup.in`
Jun 3, 2023
f5b0a00
New struct SW_GEN_OUT
Jun 3, 2023
3e152af
SW_Site.c loses non-constant globals
Jun 3, 2023
4bcb985
Remove `markov_rng` as a global
Jun 3, 2023
c1f77c6
Output_outarray loses globals Part 1 - SW_GEN_OUT gains vars.
Jun 4, 2023
70beb3d
Output_outarray loses globals Part 2 - iOUT(2)
Jun 4, 2023
3a7cb4a
Output_outtext loses globals (i.e., `print_IterationSummary`, etc.)
Jun 4, 2023
08fd213
SW_GEN_OUT gains STEPWAT2 globals from SW_Output.c
Jun 4, 2023
132a8ad
Make `DirName()` thread-safe
Jun 4, 2023
7519454
Fix `SW_OUT_write_today()` & `SW_OUT_SetMemoryRefs()`
Jun 4, 2023
7dd9bfa
Catch-up func. documentation + remove test print statement
Jun 4, 2023
767d633
Remove "module-level" from descriptions of converted vars
Jun 4, 2023
c9d2aae
Fix `soil_temperature()` prototype in header file
Jun 4, 2023
14203a4
Clean unnecessary "// Externs ..." comments
Jun 4, 2023
5b3a092
Fix `get_outvalleader()` calls
Jun 4, 2023
dd50eae
SW_Output.h loses globals that have been converted
Jun 4, 2023
50baf6b
`SW_OUT_deconstruct()` gains SW_GEN_OUT and SW_OUTPUT
Jun 4, 2023
d862dbe
Convert STEPWAT2 globals
Jun 5, 2023
e9ec6b1
Fix memory leaks in tests
Jun 5, 2023
2f2a25f
`create_test_soillayers()` gains SW_VEGPROD and SW_SITE
Jun 5, 2023
8b141ba
Remove "defined in SW_Main_lib.c" comment for `logfp` and `logged`
Jun 5, 2023
60688e2
Fix test failures attempt 1
Jun 6, 2023
c870ad3
Remove `SW_F_name()`
Jun 7, 2023
d5b31a6
Remove `SW_WeatherPrefix()`
Jun 7, 2023
e1e2096
Test globals have a more consistent position
Jun 7, 2023
6c02a03
Fix test failures attempt 2
Jun 7, 2023
174316b
Undo test global file name placement (fix tests attempt 3)
Jun 7, 2023
d622a02
Prevent future STEPWAT2 warnings within `SW_OUT_write_today()`
Jun 7, 2023
1e3f5a2
`SW_Flow.c` loses globals part 1 - conversion/lose SW_LAYER_INFO
Jun 8, 2023
e614c63
`SW_Flow.c` loses globals part 2 - remove `records2arrays()`
Jun 8, 2023
6d3cd0a
`SW_Flow.c` loses globals part 3 - remove site deconstruct functions
Jun 8, 2023
4287123
`SW_Flow.c` loses globals part 4 - remove `_newlayer()`
Jun 8, 2023
27fa774
r/STEPWAT only variables output vars regain not being defined in SOILWAT
Jun 9, 2023
037584d
`create_test_soillayers()` gains parameter of LOG_INFO
Jun 9, 2023
f173e12
Prepare NEWS for development of v7.1.0
dschlaep Jun 9, 2023
0bcd6b2
Merge branch 'release/devel_v7.0.0' into feature_reentrancy_threadsafety
Jun 11, 2023
bd02e09
Correct defines for variables not used in SOILWAT2
Jun 11, 2023
c3c5a92
Fix declaration of variables used in SOILWAT2 within SW_GEN_OUT
Jun 11, 2023
98299eb
Tests now use Google Test Fixtures
Jun 11, 2023
aee615d
Move any parameter of type LOG_INFO to be last in prototypes
Jun 11, 2023
186f8d1
Compact `SW_ST_setup_run()` parameters that deal with SW_SITE
Jun 11, 2023
0c2acc0
Add explanation block to variables `swrcp` & `my_transp_rgn`
Jun 12, 2023
23c7ebf
Fix `percolation*` sizes in `SW_WaterBalance_Checks()`
Jun 12, 2023
4784a0b
Merge branch 'release/devel_v7.1.0' into feature_reentrancy_threadsafety
Jun 12, 2023
19973e1
Improve test names to include fitting "test suite" names
Jun 12, 2023
4dfa20a
Clean the rest of "reset SOILWAT2" comments in tests
Jun 12, 2023
5674961
Simplify the setting of `SW_Site->deep_lyr` in `add_deepdrain_layer()`
Jun 13, 2023
ad66be3
New tests to check runs with one and max number of soil layers
dschlaep Jun 13, 2023
37b3ad1
Fix test "AllTest, WaterBalanceWithMaxSoilLayers"
dschlaep Jun 14, 2023
728364b
Make "AllTest, WaterBalanceWithOneSoilLayer" consistent
dschlaep Jun 14, 2023
aec2515
Deep drainage is now percolation from deepest soil layer
dschlaep Jun 14, 2023
1696624
Fix STEPWAT2 in SOILWAT2 Part 1 - Move `SW_datastructs.h` types to `S…
Jun 16, 2023
c00f83c
Fix STEPWAT2 in SOILWAT2 Part 2 - fix `setGlobalSTEPWAT2_OutputVariab…
Jun 16, 2023
15e4498
Fix STEPWAT2 in SOILWAT2 Part 3 - fix `SW_Output_outarray.c` includes
Jun 16, 2023
77b5aa0
Fix STEPWAT2 in SOILWAT2 Part 4 - fix `format_IterationSummary2()`
Jun 16, 2023
5acaa64
Fix STEPWAT2 in SOILWAT2 Part 5 - fix `SW_OUT_create_*_files()`
Jun 16, 2023
1bc8c39
Fix STEPWAT2 in SOILWAT2 Part 6 - silence compiler about unused varia…
Jun 16, 2023
95c72ed
Fix STEPWAT2 in SOILWAT2 Part 6 - fix `_create_csv_file_ST()`
Jun 16, 2023
2cc4855
Fix STEPWAT2 Part 8 - `_set_SXWrequests(_helper)()` & `has_OutPeriod_…
Jun 16, 2023
1f39b0e
Fix STEPWAT2 Part 9 - `SW_OUT_construct()` uses type SW_OUTPUT_POINTERS
Jun 16, 2023
5df1977
Fix STEPWAT2 Part 10 - `SW_OUT_close_files()` properly uses SW_GEN_OUT
Jun 17, 2023
c72bc69
Remove `EchoInits` in `SW_VES_read2()`
Jun 17, 2023
f49754c
Fix STEPWAT2 (/rSOLWAT2) Part 11 - fix `iOUT()` arguments & parameters
Jun 17, 2023
45949e7
Fix STEPWAT2 (/rSOLWAT2) Part 12 - misc. fix in `SW_Output_get_functi…
Jun 18, 2023
d5edc0c
`SW_F_construct()` makes a local copy of `firstfile`
Jun 20, 2023
693d7fc
Remove `SW_datastructs.h` dependency on STEPWAT2 headers
Jun 20, 2023
4bdfe63
Misc. changes - `SW_F_construct()`, `SW_Output_get_functions.c` & tes…
Jun 20, 2023
7835a0a
Re-extern the global `ncol_TimeOUT`
Jun 21, 2023
ae858d2
Fix rSOILWAT2 in SOILWAT2 Part 1 - correct `get_outvalleader()`
Jun 21, 2023
1e16280
Fix rSOILWAT2 in SOILWAT2 Part 2 - misc. changes to SW_Output.c
Jun 21, 2023
0f0a875
Fix rSOILWAT2 Part 3 - correct logfp accessing in `filefuncs.c`
Jun 21, 2023
ace5df1
Fix STEPWAT2/rSOILWAT2 segmentation faults attempt 1
Jun 21, 2023
d56bd23
Remove pointers within `SW_GEN_OUT` (STEPWAT2 side)
Jun 22, 2023
ff62f59
Correct the setting of `tOffset` in SW_GEN_OUT
Jun 26, 2023
f5a53fa
Update `used_OUTNPERIODS` in `SW_OUT_set_SXWrequests()`
Jun 26, 2023
5997fd7
Correct calls to `write_headers_to_csv()`
Jun 26, 2023
32e76a3
Initialize average layer temperature to zero in `soil_temperature()`
Jun 27, 2023
53506fe
Improve SOILWAT2 tools (#352)
dschlaep Jun 27, 2023
f9a548e
Tests now use DFLT_FIRSTFILE instead of a local variable
Jun 27, 2023
f571d03
Clean up `iOUT(2)()` lines of code in `SW_Output_get_functions.c`
Jun 27, 2023
a225a47
Merge branch 'release/devel_v7.1.0' into feature_reentrancy_threadsafety
Jun 27, 2023
0d0a162
Fix initialization of avg. layer temp. in `soil_temperature()`
Jun 27, 2023
9216c3b
Feature soil temperature initialization (#354)
dschlaep Jun 30, 2023
4d0ec61
Move `LOG_INFO` arguments to last position (Part 2)
Jul 2, 2023
39f44b4
Fix rSOILWAT2's calls to `iOUT()`
Jul 2, 2023
49941c7
Correct `LogError()` call in `SWRC_PTF_estimate_parameters()`
Jul 7, 2023
c5c669a
Update death test fixtures
Jul 7, 2023
a490201
Update googletests to use C++14
Jul 14, 2023
1e9e449
Remove note from variable `p_OUT` in SW_GEN_OUT
Jul 14, 2023
e429d21
Fix: "Freed pointer was not allocated error"
dschlaep Jul 18, 2023
5322ae0
Fix memory leak in test "VegProdConstructor"
dschlaep Jul 18, 2023
642a286
`SW_SIT_init_run()` does not need argument `PATH_INFO *PathInfo`
dschlaep Jul 18, 2023
54d2df6
Improve tool "check_SOILWAT2.sh": added step to run leaks command
dschlaep Jul 20, 2023
d3fd497
Reorganize tests
dschlaep Jul 20, 2023
719a4bb
Merge pull request #358 from DrylandEcology/feature_memoryfixes
dschlaep Jul 20, 2023
374850b
Remove `n_layers` from `iOUT()` call
Jul 20, 2023
58963de
Update doxygen description of `irow_OUT` for `get_outvalleader()`
Jul 20, 2023
0d763f6
Added comment on `tempstr` in `SW_OUT_write_today()`
Jul 23, 2023
6f6f3c6
Update NEWS.md to explain version 7.1.0
Jul 28, 2023
3ea9315
Merge pull request #349 from DrylandEcology/feature_reentrancy_thread…
N1ckP3rsl3y Jul 28, 2023
210e7f4
Update googletest to v1.14.0
dschlaep Aug 3, 2023
4a31dcb
Finalize for release v7.1.0
dschlaep Aug 3, 2023
27bb32c
Remove unnecessary `InFiles` parameters
Aug 4, 2023
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
3 changes: 0 additions & 3 deletions .LSAN_suppr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@

# These are known leaks that await fixing

# https://github.com/DrylandEcology/SOILWAT2/issues/205
leak:SW_VPD_construct

# on Apple arm64: https://github.com/google/sanitizers/issues/1501
leak:realizeClassWithoutSwift
5 changes: 5 additions & 0 deletions .github/workflows/main_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
make clean bin_run
make clean bin_debug_severe

- name: Run binary (with sanitizers)
# Apple clang does not support "AddressSanitizer: detect_leaks" (at least as of clang-1200.0.32.29)
if: ${{ runner.os != 'macOS' }}
run: make clean bin_leaks

- name: Unit tests (shuffle and repeat 3x)
run: make clean test_rep3rnd

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
.project
.settings/

# VS Code default folder
.vscode/

# History files
.Rhistory

Expand Down
36 changes: 36 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# NEWS

# SOILWAT2 v7.1.0
* Simulation output remains the same as the previous version.

* Prepare for SOILWAT2 to become thread-safe and reentrant (#346; @N1ckP3rsl3y)
* Definition clarifications
* Thread-safe - Multiple threads (a future SOILWAT2 development)
will not influence each other unintentionally. Here, we implemented
structures to enable thread-local storage, i.e., each thread operates
on local data structures or with static data.
* Reentrant - The ability to correctly execute any part of the program
by multiple threads simultaneously but independently from others.
* All non-static variables are replaced by local variables;
functions gained arguments to pass local variables by reference
(replacing global variables).
* New main abstract types
* SW_ALL - Contains the existing structures that are relevant
for the simulation itself, e.g., SW_MODEL, SW_SOILWAT, SW_WEATHER.
* PATH_INFO - Holds information about location of input and output data,
e.g., directories, file paths to input data.
* SW_OUTPUT_POINTERS - Points to requested output subroutines.
* LOG_INFO - Manages information for logging warnings and errors.

* Tests now require `c++14` and utilize `googletest` `v1.14.0` (issue #339).

* Bugfixes
* Fix an error where a pointer was freed even though it was not allocated
(issue #356; @dschlaep).
* Fix memory leak in test of `SW_VPD_construct()` (issue #205; @dschlaep).

## Changes to inputs
* The output separator `OUTSEP` has been unused since the switch (`v4.0.0`)
from writing free-form text files to `"csv"` spreadsheets
(where the separator is fixed to a comma); the occurrence of
`OUTSEP` in `"outsetup.in"` is now deprecated and triggers a warning.


# SOILWAT2 v7.0.0
* This version produces nearly identical simulation output
as the previous release under default values for the new inputs.
Expand Down
2 changes: 1 addition & 1 deletion external/googletest
Submodule googletest updated 209 files
32 changes: 6 additions & 26 deletions include/SW_Carbon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,23 @@
#ifndef CARBON
#define CARBON

#include "include/SW_Defines.h"
#include "include/SW_datastructs.h"


#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief The main structure holding all CO2-related data.
*/
typedef struct {
int
use_wue_mult, /**< A boolean integer indicating if WUE multipliers should be calculated. */
use_bio_mult; /**< A boolean integer indicating if biomass multipliers should be calculated. */

char
scenario[64]; /**< A 64-char array holding the scenario name for which we are extracting CO2 data from the carbon.in file. */

double
ppm[MAX_NYEAR]; /**< A 1D array holding atmospheric CO2 concentration values (units ppm) that are indexed by calendar year. Is typically only populated for the years that are being simulated. `ppm[index]` is the CO2 value for the calendar year `index + 1` */

} SW_CARBON;


/* =================================================== */
/* Externed Global Variables */
/* --------------------------------------------------- */
extern SW_CARBON SW_Carbon;


/* =================================================== */
/* Global Function Declarations */
/* --------------------------------------------------- */
void SW_CBN_construct(void);
void SW_CBN_construct(SW_CARBON* SW_Carbon);
void SW_CBN_deconstruct(void);
void SW_CBN_read(void);
void SW_CBN_init_run(void);
void SW_CBN_read(SW_CARBON* SW_Carbon, SW_MODEL* SW_Model, char *InFiles[],
LOG_INFO* LogInfo);
void SW_CBN_init_run(VegType VegProd_veg[], SW_MODEL* SW_Model,
SW_CARBON* SW_Carbon, LOG_INFO* LogInfo) ;


#ifdef __cplusplus
Expand Down
19 changes: 12 additions & 7 deletions include/SW_Control.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define SW_CONTROL_H

#include "include/generic.h" // for `Bool`, `swTRUE`, `swFALSE`
#include "include/SW_datastructs.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -27,15 +28,19 @@ extern "C" {
/* =================================================== */
/* Global Function Declarations */
/* --------------------------------------------------- */
void SW_CTL_setup_model(const char *firstfile);
void SW_CTL_clear_model(Bool full_reset);
void SW_CTL_init_run(void);
void SW_CTL_read_inputs_from_disk(void);
void SW_CTL_main(void); /* main controlling loop for SOILWAT */
void SW_CTL_run_current_year(void);
void SW_CTL_setup_model(SW_ALL* sw, SW_OUTPUT_POINTERS* SW_OutputPtrs,
PATH_INFO* PathInfo, LOG_INFO* LogInfo);
void SW_CTL_clear_model(Bool full_reset, SW_ALL* sw, PATH_INFO* PathInfo);
void SW_CTL_init_run(SW_ALL* sw, LOG_INFO* LogInfo);
void SW_CTL_read_inputs_from_disk(SW_ALL* sw, PATH_INFO* PathInfo,
LOG_INFO* LogInfo);
void SW_CTL_main(SW_ALL* sw, SW_OUTPUT_POINTERS* SW_OutputPtrs,
LOG_INFO* LogInfo); /* main controlling loop for SOILWAT */
void SW_CTL_run_current_year(SW_ALL* sw, SW_OUTPUT_POINTERS* SW_OutputPtrs,
LOG_INFO* LogInfo);

#ifdef DEBUG_MEM
void SW_CTL_SetMemoryRefs(void);
void SW_CTL_SetMemoryRefs(SW_OUTPUT SW_Output[]);
#endif


Expand Down
40 changes: 33 additions & 7 deletions include/SW_Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ extern "C" {

#define SEC_PER_DAY 86400. // the # of seconds in a day... (24 hrs * 60 mins/hr * 60 sec/min = 86400 seconds)

#define OUTSTRLEN 3000 /* max output string length: in get_transp: 4*every soil layer with 14 chars */
#define OUT_DIGITS 6 // number of floating point decimal digits written to output files
#define _OUTSEP ',' // Separator used when generating output files

//was 256 & 1024...
#define MAX_FILENAMESIZE 512
Expand Down Expand Up @@ -116,6 +119,20 @@ extern "C" {
#define SW_FORBS 2
#define SW_GRASS 3

/* Constants for number of months, weeks, and days in a year */
/* number of days in each week. unlikely to change, but
* useful as a readable indicator of usage where it occurs.
* On the other hand, it is conceivable that one might be
* interested in 4, 5, or 6 day periods, but redefine it
* in specific programs and take responsibility there,
* not here.
*/
#define MAX_MONTHS 12
#define MAX_WEEKS 53
#define MAX_DAYS 366

#define SWRC_PARAM_NMAX 6 /**< Maximal number of SWRC parameters implemented */

/*
Indices to daily input flags/indices (dailyInputFlags & dailyInputIndices in SW_WEATHER)
The order of these indices must match the order of weather input flags within `weathsetup.in`
Expand Down Expand Up @@ -158,17 +175,22 @@ extern "C" {
// macro `ForEachOutPeriod` --> instead, define as type `IntUS`
typedef IntUS OutPeriod;

/*
* Number of output keys

* Must match number of items in output enum (minus eSW_NoKey and eSW_LastKey)
*/
#define SW_OUTNKEYS 32

/*------------ DON'T CHANGE ANYTHING BELOW THIS LINE ------------*/
/* Macros to simplify and add consistency to common tasks */
/* Note the loop var must be declared as LyrIndex */
#define ForEachSoilLayer(i) for((i)=0; (i) < SW_Site.n_layers; (i)++)
#define ForEachEvapLayer(i) for((i)=0; (i) < SW_Site.n_evap_lyrs; (i)++)
#define ForEachTreeTranspLayer(i) for((i)=0; (i) < SW_Site.n_transp_lyrs[SW_TREES]; (i)++)
#define ForEachShrubTranspLayer(i) for((i)=0; (i) < SW_Site.n_transp_lyrs[SW_SHRUB]; (i)++)
#define ForEachGrassTranspLayer(i) for((i)=0; (i) < SW_Site.n_transp_lyrs[SW_GRASS]; (i)++)
#define ForEachForbTranspLayer(i) for((i)=0; (i) < SW_Site.n_transp_lyrs[SW_FORBS]; (i)++)
#define ForEachTranspRegion(r) for((r)=0; (r) < SW_Site.n_transp_rgn; (r)++)
#define ForEachSoilLayer(i, n_layers) for((i)=0; (i) < (n_layers); (i)++)
#define ForEachEvapLayer(i, n_evap_lyrs) for((i)=0; (i) < (n_evap_lyrs); (i)++)
#ifdef STEPWAT
#define ForEachTranspLayer(i, n_transp_lyrs, veg_index) for((i)=0; (i) < (n_transp_lyrs)[(veg_index)]; (i)++)
#endif
#define ForEachTranspRegion(r, n_transp_rgn) for((r)=0; (r) < ((unsigned int)n_transp_rgn); (r)++)
#define ForEachVegType(k) for ((k) = 0; (k) < NVEGTYPES; (k)++)
#define ForEachVegTypeBottomUp(k) for ((k) = NVEGTYPES - 1; (k) >= 0; (k)--)
/* define m as Months */
Expand Down Expand Up @@ -218,6 +240,10 @@ typedef enum { eF, /* file management */
eOUT /* output */
} ObjType;

/* Types to use for time and layer-related values and make a custom flag */
typedef unsigned int TimeInt;
typedef unsigned int LyrIndex;
typedef signed char flag;

#ifdef __cplusplus
}
Expand Down
26 changes: 7 additions & 19 deletions include/SW_Files.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#ifndef SW_FILES_H
#define SW_FILES_H

#include "include/SW_datastructs.h"

#ifdef __cplusplus
extern "C" {
#endif

#define SW_NFILES 23

/* The number of enum elements between eNoFile and
* eEndFile (not inclusive) must match SW_NFILES.
* also, these elements must match the order of
Expand Down Expand Up @@ -49,26 +49,14 @@ typedef enum {
eEndFile
} SW_FileIndex;


/* =================================================== */
/* Externed Global Variables */
/* --------------------------------------------------- */
extern char *InFiles[SW_NFILES];
extern char _ProjDir[FILENAME_MAX];
extern char weather_prefix[FILENAME_MAX];
extern char output_prefix[FILENAME_MAX];


/* =================================================== */
/* Global Function Declarations */
/* --------------------------------------------------- */
void SW_F_read(const char *s);
char *SW_F_name(SW_FileIndex i);
void SW_F_construct(const char *firstfile);
void SW_F_deconstruct(void);
void SW_WeatherPrefix(char prefix[]);
void SW_OutputPrefix(char prefix[]);
void SW_CSV_F_INIT(const char *s);
void SW_F_read(PATH_INFO* PathInfo, LOG_INFO* LogInfo);
void SW_F_construct(char *InFiles[], const char *firstfile, char _ProjDir[],
LOG_INFO *LogInfo);
void SW_F_deconstruct(char *InFiles[]);
void SW_CSV_F_INIT(const char *s, LOG_INFO* LogInfo);

#ifdef DEBUG_MEM
void SW_F_SetMemoryRefs(void);
Expand Down
5 changes: 3 additions & 2 deletions include/SW_Flow.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef SW_FLOW_H
#define SW_FLOW_H

#include "include/SW_datastructs.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -9,8 +10,8 @@ extern "C" {
/* =================================================== */
/* Global Function Declarations */
/* --------------------------------------------------- */
void SW_FLW_init_run(void);
void SW_Water_Flow(void);
void SW_FLW_init_run(SW_SOILWAT* SW_SoilWat);
void SW_Water_Flow(SW_ALL* sw, LOG_INFO* LogInfo);


#ifdef __cplusplus
Expand Down
Loading