source: TOOLS/diff.bash @ 2133

Last change on this file since 2133 was 2133, checked in by acosce, 11 years ago

New tools allows packing simulation already pack (so pack with a bigger frequency)

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