Skip to content

Commit

Permalink
modifications to allow running example VIC simulations on travis CI
Browse files Browse the repository at this point in the history
https url for submodule
  • Loading branch information
Joe Hamman committed Mar 25, 2016
1 parent 84614fd commit 847ad11
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ before_install:
- vic_before_install
install:
- vic_install
before_script:
- vic_before_script
script:
- vic_script
after_success:
Expand Down
12 changes: 10 additions & 2 deletions ci/classic.travis
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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

}

Expand Down
13 changes: 11 additions & 2 deletions ci/image.travis
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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

}

Expand Down
2 changes: 1 addition & 1 deletion samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 0 additions & 1 deletion samples/VIC_sample_data
Submodule VIC_sample_data deleted from b7b16c
1 change: 1 addition & 0 deletions samples/data
Submodule data added at 568cbe
2 changes: 1 addition & 1 deletion samples/get_sample_data.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/examples/global_param.classic.STEHE.feb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/examples/global_param.classic.STEHE.save_state.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/examples/global_param.classic.STEHE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/examples/global_param.classic.STEHE.wb_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/examples/global_param.image.STEHE.feb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
23 changes: 9 additions & 14 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# ---------------------------------------------------------------- #
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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'''

# ---------------------------------------------------------------- #
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'''

# ---------------------------------------------------------------- #
Expand Down Expand Up @@ -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 '''

# ---------------------------------------------------------------- #
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 847ad11

Please sign in to comment.