| 1 | #!/bin/csh |
|---|
| 2 | # |
|---|
| 3 | # DOMAIN_TIME_TEST.csh wrf_ascii_output test_case |
|---|
| 4 | # |
|---|
| 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 |
|---|
| 14 | # |
|---|
| 15 | # If the test passes, the following string is echoed by itself: |
|---|
| 16 | # "PASS DOMAIN_TIME_TEST.csh $test_case" |
|---|
| 17 | # |
|---|
| 18 | # If the test fails, the following string is echoed along with other |
|---|
| 19 | # diagnostics: |
|---|
| 20 | # "FAIL DOMAIN_TIME_TEST.csh $test_case" |
|---|
| 21 | # |
|---|
| 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 |
|---|
| 26 | # argument. |
|---|
| 27 | # |
|---|
| 28 | # This script must be run using a fully-qualified path as it deduces the |
|---|
| 29 | # location of correct test results from this path. |
|---|
| 30 | # |
|---|
| 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 |
|---|
| 34 | # |
|---|
| 35 | # |
|---|
| 36 | # AUTHOR: |
|---|
| 37 | # Tom Henderson NCAR/MMM |
|---|
| 38 | # |
|---|
| 39 | # DATE: |
|---|
| 40 | # 20060316 |
|---|
| 41 | # |
|---|
| 42 | |
|---|
| 43 | set selflong = $0 |
|---|
| 44 | set self = $selflong:t |
|---|
| 45 | set scriptdir = $selflong:h |
|---|
| 46 | |
|---|
| 47 | if ( $#argv != 2 ) then |
|---|
| 48 | echo "ERROR ${self}" |
|---|
| 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" |
|---|
| 53 | exit 10 |
|---|
| 54 | endif |
|---|
| 55 | |
|---|
| 56 | set ascii_file = $1 |
|---|
| 57 | set test_case = $2 |
|---|
| 58 | set pid = $$ |
|---|
| 59 | set correct_file = "${scriptdir}/DOMAIN_TIME_TEST.${test_case}.correct" |
|---|
| 60 | set tmp_file = "DOMAIN_TIME_TEST.${test_case}.${pid}.tmp" |
|---|
| 61 | |
|---|
| 62 | if ( ! -f $ascii_file ) then |
|---|
| 63 | echo "ERROR ${self} ${test_case}" |
|---|
| 64 | echo "ERROR: could not find WRF ASCII output file ${ascii_file}" |
|---|
| 65 | exit 20 |
|---|
| 66 | endif |
|---|
| 67 | if ( ! -f $correct_file ) then |
|---|
| 68 | echo "ERROR ${self} ${test_case}" |
|---|
| 69 | echo "ERROR: could not find correct test results file ${correct_file}" |
|---|
| 70 | exit 30 |
|---|
| 71 | endif |
|---|
| 72 | |
|---|
| 73 | \rm -f ${tmp_file} |
|---|
| 74 | grep DOMAIN_TIME_TEST $ascii_file >! ${tmp_file} || echo "ERROR ${self} ${test_case}: could not grep file ${ascii_file}" && exit 40 |
|---|
| 75 | |
|---|
| 76 | if ( ! `diff ${correct_file} ${tmp_file} | wc -c` ) then |
|---|
| 77 | echo "PASS ${self} ${test_case}" |
|---|
| 78 | \rm -f ${tmp_file} |
|---|
| 79 | else |
|---|
| 80 | echo "FAIL ${self} ${test_case}" |
|---|
| 81 | echo "FAIL: Differences follow:" |
|---|
| 82 | echo "diff ${correct_file} ${tmp_file}" |
|---|
| 83 | diff ${correct_file} ${tmp_file} |
|---|
| 84 | \rm -f ${tmp_file} |
|---|
| 85 | exit 50 |
|---|
| 86 | endif |
|---|
| 87 | |
|---|
| 88 | exit 0 |
|---|
| 89 | |
|---|