3 # DOMAIN_TIME_TEST.csh wrf_ascii_output test_case
5 # Extract domain self-test results from WRF ASCII output file
6 # "wrf_ascii_output" and compare with known-good results, echoing
7 # "PASS" iff results match. Note that these tests are normally turned off
8 # but may be enabled by setting namelist variable self_test_domain to .true.
9 # in namelist /time_control/ . This script looks in the directory in which
10 # it resides to locate files that contain known-good test output. Second
11 # argument "test_case" is used to determine which known-good file to compare
12 # against via the naming convention:
13 # DOMAIN_TIME_TEST.${test_case}.correct
15 # If the test passes, the following string is echoed by itself:
16 # "PASS DOMAIN_TIME_TEST.csh $test_case"
18 # If the test fails, the following string is echoed along with other
20 # "FAIL DOMAIN_TIME_TEST.csh $test_case"
22 # In the event of an error (file not found, etc.) the following string is
23 # echoed along with other diagnostics:
24 # "ERROR DOMAIN_TIME_TEST.csh $test_case"
25 # Note that in this case, $test_case is left off if not specified as an
28 # This script must be run using a fully-qualified path as it deduces the
29 # location of correct test results from this path.
31 # EXAMPLE (running from test/em_real):
32 # >> ../../tools/DOMAIN_TIME_TEST/DOMAIN_TIME_TEST.csh rsl.out.0000 jan00_12hr
33 # PASS DOMAIN_TIME_TEST.csh jan00_12hr
37 # Tom Henderson NCAR/MMM
44 set self
= $selflong:t
45 set scriptdir
= $selflong:h
47 if ( $#argv != 2 ) then
49 echo "ERROR: Must specify a WRF ASCII output file as first argument and "
50 echo "ERROR: name of test case as second argument."
51 echo "USAGE: ${self} wrf_ascii_output test_case"
52 echo "EXAMPLE: ${selflong} rsl.out.0000 jan00_12hr"
59 set correct_file
= "${scriptdir}/DOMAIN_TIME_TEST.${test_case}.correct"
60 set tmp_file
= "DOMAIN_TIME_TEST.${test_case}.${pid}.tmp"
62 if ( ! -f $ascii_file ) then
63 echo "ERROR ${self} ${test_case}"
64 echo "ERROR: could not find WRF ASCII output file ${ascii_file}"
67 if ( ! -f $correct_file ) then
68 echo "ERROR ${self} ${test_case}"
69 echo "ERROR: could not find correct test results file ${correct_file}"
74 grep DOMAIN_TIME_TEST
$ascii_file >! ${tmp_file} || echo "ERROR ${self} ${test_case}: could not grep file ${ascii_file}" && exit 40
76 if ( ! `diff ${correct_file} ${tmp_file} | wc -c` ) then
77 echo "PASS
${self} ${test_case}"
80 echo "FAIL
${self} ${test_case}"
81 echo "FAIL
: Differences follow
:"
82 echo "diff ${correct_file} ${tmp_file}"
83 diff ${correct_file} ${tmp_file}