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

Prepare STEPWAT2 to handle SOILWAT2's additional daily inputs #539

Merged
merged 7 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "sw_src"]
path = sw_src
url = https://github.com/DrylandEcology/SOILWAT2.git
branch = release/devel_v7.0.0
branch = read_more_daily_input
ignore = dirty
2 changes: 1 addition & 1 deletion sw_src
Submodule sw_src updated 43 files
+2 −2 .github/workflows/main_nix.yml
+2 −2 .github/workflows/main_win.yml
+26 −0 NEWS.md
+3 −1 doc/Doxyfile
+1 −1 doc/additional_pages/A_SOILWAT2_user_guide.md
+20 −1 include/SW_Defines.h
+12 −3 include/SW_Flow_lib_PET.h
+1 −1 include/SW_Main_lib.h
+1 −5 include/SW_Sky.h
+47 −6 include/SW_Weather.h
+2 −1 include/Times.h
+12 −0 makefile
+1 −1 src/SW_Control.c
+7 −6 src/SW_Flow.c
+292 −45 src/SW_Flow_lib_PET.c
+1 −14 src/SW_Main.c
+16 −0 src/SW_Main_lib.c
+6 −1 src/SW_Markov.c
+4 −2 src/SW_Output_outarray.c
+2 −31 src/SW_Sky.c
+10 −7 src/SW_VegProd.c
+766 −44 src/SW_Weather.c
+20 −7 src/Times.c
+28 −11 src/filefuncs.c
+368 −0 tests/example/Input/data_weather_daymet/weath.1980
+367 −0 tests/example/Input/data_weather_daymet/weath.1981
+368 −0 tests/example/Input/data_weather_gridmet/weath.1980
+367 −0 tests/example/Input/data_weather_gridmet/weath.1981
+368 −0 tests/example/Input/data_weather_maca/weath.1980
+367 −0 tests/example/Input/data_weather_maca/weath.1981
+52 −13 tests/example/Input/weathsetup.in
+1 −20 tests/gtests/sw_maintest.cc
+26 −14 tests/gtests/sw_testhelpers.cc
+137 −30 tests/gtests/test_SW_Flow_Lib_PET.cc
+2 −2 tests/gtests/test_SW_Flow_lib_temp.cc
+1 −1 tests/gtests/test_SW_Markov.cc
+12 −6 tests/gtests/test_SW_Site.cc
+7 −7 tests/gtests/test_SW_SoilWater.cc
+5 −2 tests/gtests/test_SW_VegProd.cc
+490 −5 tests/gtests/test_SW_Weather.cc
+38 −25 tests/gtests/test_Times.cc
+134 −0 tests/gtests/test_WaterBalance.cc
+7 −0 tools/run_doxygen.sh
18 changes: 17 additions & 1 deletion sxw_soilwat.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "sw_src/include/SW_SoilWater.h"
#include "sw_src/include/SW_VegProd.h" // externs `SW_VegProd`
#include "sw_src/include/SW_Files.h"
#include "sw_src/include/SW_Sky.h" // externs SW_Sky



Expand Down Expand Up @@ -102,6 +103,7 @@ void _sxw_sw_setup (RealF sizes[]) {
*/
void _sxw_generate_weather(void) {
SW_WEATHER *w = &SW_Weather;
SW_SKY *sky = &SW_Sky;

deallocateAllWeather(w);
w->n_years = 1;
Expand All @@ -116,12 +118,26 @@ void _sxw_generate_weather(void) {
);
}

// Make sure monthly flags are set to interpolate monthly values into daily values
w->use_humidityMonthly = swTRUE;
w->use_cloudCoverMonthly = swTRUE;
w->use_windSpeedMonthly = swTRUE;

readAllWeather(
w->allHist,
w->startYear,
w->n_years,
swTRUE, // `use_weathergenerator_only`
w->name_prefix // not used because `use_weathergenerator_only`
w->name_prefix, // not used because `use_weathergenerator_only`
w->use_cloudCoverMonthly,
w->use_humidityMonthly,
w->use_windSpeedMonthly,
w->n_input_forcings,
w->dailyInputIndices,
w->dailyInputFlags,
sky->cloudcov,
sky->windspeed,
sky->r_humidity
);

finalizeAllWeather(w); // run the weather generator
Expand Down
65 changes: 52 additions & 13 deletions testing.sagebrush.master/Stepwat_Inputs/Input/sxw/Input/weathsetup.in
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@
7 # Seed random number generator for weather generator (only used if SOILWAT2)
# (seed with 0 to use current time)

#--- Flags describing mean monthly climate input usage:
# 0 = Don't use mean monthly input
# 1 = Use mean monthly input (climate.in) and override respective flag for daily input, if flags conflict
1 # Sky cover
1 # Wind speed
1 # Relative humidity


#--- Flags describing daily weather input files "weath.YYYY":
# 0 = Variable is absent
# 1 = Daily variable present
# Note: The order of input values within input files must match the order of flags below (e.g., cloud cover cannot precede minimum temperature)
# Note: If maximum/minimum temperature or precipitation is set to 0 or a flag is set to 1, and the input data is not complete, the program will crash
1 # Maximum daily temperature [C]
1 # Minimum daily temperature [C]
1 # Precipitation [cm]
0 # Cloud cover [%]
0 # Wind speed [m/s]
0 # Wind speed eastward component [m/s]
0 # Wind speed northward component [m/s]
0 # Relative humidity [%]
0 # Maximum relative humidity [%]
0 # Minimum relative humidity [%]
0 # Specific humidity [%]
0 # Dew point temperature [C]
0 # Actual vapor pressure [kPa]
0 # Downward surface shortwave radiation (see `Daily weather input descriptions`)


#--- Daily weather input descriptions
0 # Description of downward surface shortwave radiation
# * 0: `rsds` represents daily global horizontal irradiation [MJ / m2]
# * 1: `rsds` represents flux density [W / m2] for a
# (hypothetical) flat horizon averaged over an entire day (24 hour period)
# * 2: `rsds` represents flux density [W / m2] for a
# (hypothetical) flat horizon averaged over the daylight period of the day


#--- Monthly scaling parameters:
# Month 1 = January, Month 2 = February, etc.
Expand All @@ -24,16 +61,18 @@
# SkyCover = additive for mean monthly sky cover [%]; min(100, max(0, scale + sky cover))
# Wind = multiplicative for mean monthly wind speed; max(0, scale * wind speed)
# rH = additive for mean monthly relative humidity [%]; min(100, max(0, scale + rel. Humidity))
#Mon PPT MaxT MinT SkyCover Wind rH
1 1.000 0.00 0.00 0.0 1.0 0.0
2 1.000 0.00 0.00 0.0 1.0 0.0
3 1.000 0.00 0.00 0.0 1.0 0.0
4 1.000 0.00 0.00 0.0 1.0 0.0
5 1.000 0.00 0.00 0.0 1.0 0.0
6 1.000 0.00 0.00 0.0 1.0 0.0
7 1.000 0.00 0.00 0.0 1.0 0.0
8 1.000 0.00 0.00 0.0 1.0 0.0
9 1.000 0.00 0.00 0.0 1.0 0.0
10 1.000 0.00 0.00 0.0 1.0 0.0
11 1.000 0.00 0.00 0.0 1.0 0.0
12 1.000 0.00 0.00 0.0 1.0 0.0
# ActVP = multiplicative for actual vapor pressure [kPa]; max(0, scale * actual vapor pressure)
# ShortWR = multiplicative for shortwave radiation [W/m2]; max(0, scale * shortwave radiation)
#Mon PPT MaxT MinT SkyCover Wind rH ActVP ShortWR
1 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
2 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
3 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
4 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
5 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
6 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
7 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
8 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
9 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
10 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
11 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0
12 1.000 0.00 0.00 0.0 1.0 0.0 1.0 1.0