diff --git a/.gitmodules b/.gitmodules index 507b8f0ad..66731ebfb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "samples/VIC_sample_data"] - path = samples/VIC_sample_data - url = https://github.com/jhamman/VIC_sample_data +[submodule "samples/data"] + path = samples/data + url = https://github.com/UW-Hydro/VIC_sample_data.git diff --git a/.travis.yml b/.travis.yml index f43b70d6f..62e7919eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,6 +77,8 @@ before_install: - vic_before_install install: - vic_install +before_script: + - vic_before_script script: - vic_script after_success: diff --git a/ci/classic.travis b/ci/classic.travis index a0583aad5..c09793b4b 100644 --- a/ci/classic.travis +++ b/ci/classic.travis @@ -2,8 +2,9 @@ set -e -DRIVER_PATH="vic/drivers/classic/" +DRIVER_PATH="${TRAVIS_BUILD_DIR}/vic/drivers/classic/" DRIVER_EXE="${DRIVER_PATH}vic_classic.exe" +SAMPLES_PATH="${TRAVIS_BUILD_DIR}/samples/" function vic_before_install { echo vic_before_install @@ -46,6 +47,9 @@ function vic_before_script { echo "Executable (${DRIVER_EXE}) not found!" exit 1 fi + + echo "Getting sample data" + bash ${SAMPLES_PATH}/get_sample_data.bash } function vic_script { @@ -54,7 +58,11 @@ function vic_script { $DRIVER_EXE -o # Run test package - ./tests/run_tests.py unit --vic_exe=$DRIVER_EXE + ./tests/run_tests.py unit examples \ + --vic_exe=${DRIVER_EXE} \ + --driver=${TESTID} \ + --data_dir=${SAMPLES_PATH}/data \ + --examples=./tests/examples/examples.cfg } diff --git a/ci/image.travis b/ci/image.travis index 3be60c777..613f10d5e 100644 --- a/ci/image.travis +++ b/ci/image.travis @@ -2,8 +2,9 @@ set -e -DRIVER_PATH="./vic/drivers/image/" +DRIVER_PATH="${TRAVIS_BUILD_DIR}/vic/drivers/image/" DRIVER_EXE="${DRIVER_PATH}vic_image.exe" +SAMPLES_PATH="${TRAVIS_BUILD_DIR}/samples/" function vic_before_install { echo vic_before_install @@ -64,6 +65,10 @@ function vic_before_script { echo "Executable (${DRIVER_EXE}) not found!" exit 1 fi + + echo "Getting sample data" + bash ${SAMPLES_PATH}/get_sample_data.bash + } function vic_script { @@ -72,7 +77,11 @@ function vic_script { $DRIVER_EXE -o # Run test package - ./tests/run_tests.py unit --vic_exe=$DRIVER_EXE + ./tests/run_tests.py unit examples \ + --vic_exe=${DRIVER_EXE} \ + --driver=${TESTID} \ + --data_dir=${SAMPLES_PATH}/data \ + --examples=./tests/examples/examples.cfg } diff --git a/samples/README.md b/samples/README.md index a0e0d9d40..ccb0867d5 100644 --- a/samples/README.md +++ b/samples/README.md @@ -24,5 +24,5 @@ The VIC sample datasets are in a "git submodule". To download the datasets to th You may also download the sample data to another location on your computer by specifying the directory in which you would like to add the data: ``` -git clone https://github.com/jhamman/VIC_sample_data.git path/folder_name +git clone https://github.com/UW-Hydro/VIC_sample_data.git path/folder_name ``` diff --git a/samples/VIC_sample_data b/samples/VIC_sample_data deleted file mode 160000 index b7b16cb0f..000000000 --- a/samples/VIC_sample_data +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b7b16cb0ff517767130a9d1a323349d09f5efee0 diff --git a/samples/data b/samples/data new file mode 160000 index 000000000..568cbe80d --- /dev/null +++ b/samples/data @@ -0,0 +1 @@ +Subproject commit 568cbe80d8ccf1bdfd41446fb279be8f64b62b5e diff --git a/samples/get_sample_data.bash b/samples/get_sample_data.bash index 3b1182a9f..73d84be22 100755 --- a/samples/get_sample_data.bash +++ b/samples/get_sample_data.bash @@ -9,7 +9,7 @@ SAMPLES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" git submodule init # Get the sample data -cd $SAMPLES/VIC_sample_data +cd $SAMPLES/data git fetch origin # TODO - get data branch/tag that aligns with the state of the VIC repo. git checkout master diff --git a/tests/examples/global_param.classic.STEHE.feb.txt b/tests/examples/global_param.classic.STEHE.feb.txt index d9f4e0ed7..2836d1cc3 100644 --- a/tests/examples/global_param.classic.STEHE.feb.txt +++ b/tests/examples/global_param.classic.STEHE.feb.txt @@ -6,7 +6,7 @@ RUNOFF_STEPS_PER_DAY 24 STARTYEAR 1949 STARTMONTH 01 STARTDAY 01 -STARTHOUR 00 +STARTSEC 00 ENDYEAR 1949 ENDMONTH 01 ENDDAY 10 @@ -39,7 +39,7 @@ VEGPARAM_LAI TRUE LAI_SRC FROM_VEGLIB SNOW_BAND 5 $test_data_dir/classic/Stehekin/parameters/Stehekin_snowbands.txt RESULT_DIR $result_dir -OUT_STEP 0 +OUTPUT_STEPS_PER_DAY 0 SKIPYEAR 0 COMPRESS FALSE BINARY_OUTPUT FALSE diff --git a/tests/examples/global_param.classic.STEHE.save_state.txt b/tests/examples/global_param.classic.STEHE.save_state.txt index c1079d57c..4799817d5 100644 --- a/tests/examples/global_param.classic.STEHE.save_state.txt +++ b/tests/examples/global_param.classic.STEHE.save_state.txt @@ -6,7 +6,7 @@ RUNOFF_STEPS_PER_DAY 24 STARTYEAR 1949 STARTMONTH 01 STARTDAY 01 -STARTHOUR 00 +STARTSEC 00 ENDYEAR 1949 ENDMONTH 01 ENDDAY 10 @@ -44,7 +44,7 @@ VEGPARAM_LAI TRUE LAI_SRC FROM_VEGLIB SNOW_BAND 5 $test_data_dir/classic/Stehekin/parameters/Stehekin_snowbands.txt RESULT_DIR $result_dir -OUT_STEP 0 +OUTPUT_STEPS_PER_DAY 0 SKIPYEAR 0 COMPRESS FALSE BINARY_OUTPUT FALSE diff --git a/tests/examples/global_param.classic.STEHE.txt b/tests/examples/global_param.classic.STEHE.txt index 13d0709f9..612162dd1 100644 --- a/tests/examples/global_param.classic.STEHE.txt +++ b/tests/examples/global_param.classic.STEHE.txt @@ -6,7 +6,7 @@ RUNOFF_STEPS_PER_DAY 24 STARTYEAR 1949 STARTMONTH 01 STARTDAY 01 -STARTHOUR 00 +STARTSEC 00 ENDYEAR 1949 ENDMONTH 01 ENDDAY 10 @@ -39,7 +39,7 @@ VEGPARAM_LAI TRUE LAI_SRC FROM_VEGLIB SNOW_BAND 5 $test_data_dir/classic/Stehekin/parameters/Stehekin_snowbands.txt RESULT_DIR $result_dir -OUT_STEP 0 +OUTPUT_STEPS_PER_DAY 0 SKIPYEAR 0 COMPRESS FALSE BINARY_OUTPUT FALSE diff --git a/tests/examples/global_param.classic.STEHE.wb_output.txt b/tests/examples/global_param.classic.STEHE.wb_output.txt index e2ff15403..367dbf1e8 100644 --- a/tests/examples/global_param.classic.STEHE.wb_output.txt +++ b/tests/examples/global_param.classic.STEHE.wb_output.txt @@ -6,7 +6,7 @@ RUNOFF_STEPS_PER_DAY 24 STARTYEAR 1949 STARTMONTH 01 STARTDAY 01 -STARTHOUR 00 +STARTSEC 00 ENDYEAR 1949 ENDMONTH 01 ENDDAY 10 @@ -39,7 +39,7 @@ VEGPARAM_LAI TRUE LAI_SRC FROM_VEGLIB SNOW_BAND 5 $test_data_dir/classic/Stehekin/parameters/Stehekin_snowbands.txt RESULT_DIR $result_dir -OUT_STEP 0 +OUTPUT_STEPS_PER_DAY 0 SKIPYEAR 0 COMPRESS FALSE BINARY_OUTPUT FALSE diff --git a/tests/examples/global_param.image.STEHE.feb.txt b/tests/examples/global_param.image.STEHE.feb.txt index 4f5a61d17..b656d5965 100644 --- a/tests/examples/global_param.image.STEHE.feb.txt +++ b/tests/examples/global_param.image.STEHE.feb.txt @@ -14,7 +14,7 @@ FROZEN_SOIL FALSE AERO_RESIST_CANSNOW AR_406 -DOMAIN $test_data_dir/image/Stehekin/domain.stehekin.20151028.nc +DOMAIN $test_data_dir/image/Stehekin/parameters/domain.stehekin.20151028.nc DOMAIN_TYPE LAT lat DOMAIN_TYPE LON lon DOMAIN_TYPE MASK mask @@ -23,7 +23,7 @@ DOMAIN_TYPE FRAC frac DOMAIN_TYPE YDIM lat DOMAIN_TYPE XDIM lon -FORCING1 $test_data_dir/image/Stehekin/Stehekin_image_test.forcings_10days. +FORCING1 $test_data_dir/image/Stehekin/forcings/Stehekin_image_test.forcings_10days. FORCE_TYPE AIR_TEMP tas FORCE_TYPE PREC prcp FORCE_TYPE PRESSURE pres @@ -32,12 +32,12 @@ FORCE_TYPE LWDOWN dlwrf FORCE_TYPE VP shum WIND_H 10.0 -SOIL $test_data_dir/image/Stehekin/Stehekin_test_params_20151028.nc +SOIL $test_data_dir/image/Stehekin/parameters/Stehekin_test_params_20151028.nc NODES 3 -VEGPARAM $test_data_dir/image/Stehekin/Stehekin_test_params_20151028.nc +VEGPARAM $test_data_dir/image/Stehekin/parameters/Stehekin_test_params_20151028.nc ROOT_ZONES 3 -VEGLIB $test_data_dir/image/Stehekin/Stehekin_test_params_20151028.nc -SNOW_BAND 1 $test_data_dir/image/Stehekin/Stehekin_test_params_20151028.nc +VEGLIB $test_data_dir/image/Stehekin/parameters/Stehekin_test_params_20151028.nc +SNOW_BAND 1 $test_data_dir/image/Stehekin/parameters/Stehekin_test_params_20151028.nc RESULT_DIR $result_dir/Stehekin.history.nc OUTPUT_STEPS_PER_DAY 24 diff --git a/tests/run_tests.py b/tests/run_tests.py index ce487e830..fbffc2399 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -143,7 +143,6 @@ def main(): # ---------------------------------------------------------------- # # Define test directories data_dir = args.data_dir - test_dir = os.path.dirname(os.path.realpath(__file__)) out_dir = os.path.expandvars(args.output_dir) os.makedirs(out_dir, exist_ok=True) # ---------------------------------------------------------------- # @@ -178,21 +177,17 @@ def main(): # system if any(i in ['all', 'system'] for i in args.tests): - test_results['system'] = run_system(args.system, vic_exe, - 'system', data_dir, + test_results['system'] = run_system(args.system, vic_exe, data_dir, os.path.join(out_dir, 'system'), args.driver) # science if any(i in ['all', 'science'] for i in args.tests): - test_results['science'] = run_science(args.science, vic_exe, - 'science', data_dir, + test_results['science'] = run_science(args.science, vic_exe, data_dir, os.path.join(out_dir, 'science')) # examples if any(i in ['all', 'examples'] for i in args.tests): - test_results['examples'] = run_examples(args.examples, vic_exe, - 'examples', data_dir, - os.path.join(out_dir, - 'examples'), + test_results['examples'] = run_examples(args.examples, vic_exe, data_dir, + os.path.join(out_dir, 'examples'), args.driver) # release if any(i in ['all', 'release'] for i in args.tests): @@ -263,7 +258,7 @@ def run_unit_tests(): # -------------------------------------------------------------------- # -def run_system(config_file, vic_exe, test_dir, test_data_dir, out_dir, driver): +def run_system(config_file, vic_exe, test_data_dir, out_dir, driver): '''Run system tests from config file''' # ---------------------------------------------------------------- # @@ -297,7 +292,7 @@ def run_system(config_file, vic_exe, test_dir, test_data_dir, out_dir, driver): # ------------------------------------------------------------ # # read template global parameter file - infile = os.path.join(test_dir, + infile = os.path.join(test_dir, 'samples', test_dict['global_parameter_file']) with open(infile, 'r') as global_file: @@ -420,7 +415,7 @@ def run_system(config_file, vic_exe, test_dir, test_data_dir, out_dir, driver): # -------------------------------------------------------------------- # -def run_science(config_file, vic_exe, test_dir, test_data_dir, out_dir): +def run_science(config_file, vic_exe, test_data_dir, out_dir): '''Run science tests from config file''' # ---------------------------------------------------------------- # @@ -564,7 +559,7 @@ def run_science(config_file, vic_exe, test_dir, test_data_dir, out_dir): # -------------------------------------------------------------------- # -def run_examples(config_file, vic_exe, test_dir, test_data_dir, out_dir, driver): +def run_examples(config_file, vic_exe, test_data_dir, out_dir, driver): '''Run examples tests from config file ''' # ---------------------------------------------------------------- # @@ -607,7 +602,7 @@ def run_examples(config_file, vic_exe, test_dir, test_data_dir, out_dir, driver) # ------------------------------------------------------------ # # read template global parameter file - infile = os.path.join(test_dir, test_dict['global_parameter_file']) + infile = os.path.join(test_dir, 'examples', test_dict['global_parameter_file']) with open(infile, 'r') as global_file: global_param = global_file.read()