source: TOOLS/PACK_IPSL/diff.bash @ 1879

Last change on this file since 1879 was 1879, checked in by aclsce, 12 years ago

Modified to exclude good variables

  • Property svn:executable set to *
File size: 962 bytes
Line 
1#!/bin/bash
2set -vx
3#==============================================
4#
5# Usage:
6# ./diff.bash f1.nc f1.nc
7# ./diff.bash f1.nc f1_witherror.nc
8#
9# ./diff.bash fileA.nc fileB.nc 'var1,var2'
10#
11# ex: ./diff.bash file_ncrcat.nc file_cdocat.nc 'contfracATM'
12#
13#==============================================
14
15if [ $# -eq 3 ] ; then
16        delname="-delname,$3"
17fi
18
19cdo -s $delname $1 out_tmp1.nc
20cdo -s $delname $2 out_tmp2.nc
21
22cdo -s diff out_tmp1.nc out_tmp2.nc > diff_$$.tmp 2>&1
23result2=`cat diff_$$.tmp | grep -i "records differ" | tr -s " " | cut -f2 -d" "`
24
25if [ "$result2" = "0" ] ; then
26        # EXIT_SUCCESS
27        echo "Variables from netcdf files : "
28        echo "$1"
29        echo "$2" 
30        echo "are the same"
31        rm -f diff_$$.tmp out_tmp1.nc out_tmp2.nc
32        exit 0
33else
34        # EXIT_FAILURE
35        echo "Variables from netcdf files : "
36        echo "$1"
37        echo "$2" 
38        echo "differ"   
39        cat diff_$$.tmp | grep -i "records differ"
40        rm -f diff_$$.tmp out_tmp1.nc out_tmp2.nc
41        echo "==============> ERROR"
42        exit 1
43fi
44
Note: See TracBrowser for help on using the repository browser.