Documentation/UserGuide/restartability: differr100.sh

File differr100.sh, 1.5 KB (added by jgipsl, 4 years ago)

Script to compare netcdf files when error 100, J. Ghattas

Line 
1#!/bin/bash
2#set -xv
3
4# This script is used to compares two netcdf files when there are some more variables in one or
5# the other of the files. The script will:
6# 1) Compare using ncdump the variables in both files and ask the user to remove if wanted.
7#    Temporary files are created with less variables.
8# 2) use cdo diffv on the temporary files
9
10file1=$1
11file2=$2
12
13rm -f dump1 dump2 file1tmp.nc file2tmp.nc
14
15ncdump -h $file1 > dump1
16ncdump -h $file2 > dump2
17
18echo "Diff with grep float:"
19diff dump1 dump2 |grep float
20echo "Type variable list to be removed from input files before comparison"
21echo "or press enter if the list is empty to search for variables in double pression"
22echo ""
23echo "Type varlist1:"
24echo "Syntax: var1,var2,var3"
25read varlist1
26echo "Type varlist2:"
27read varlist2
28
29echo varlist1=$varlist1 varlist2=$varlist2
30
31if [ X$varlist1 == X ] && [ X$varlist2 == X ] ; then
32   echo "Search for variables in double precision"
33   diff dump1 dump2 |grep double
34   echo "Type variable list to be removed from input files before comparison"
35   echo ""
36   echo "Type varlist1:"
37   echo "Syntax: var1,var2,var3"
38   read varlist1
39   echo "Type varlist2:"
40   read varlist2
41
42   echo varlist1=$varlist1 varlist2=$varlist2
43fi
44
45if [ X$varlist1 == X ] ; then
46  # only copy the file
47  ncks $file1 -o file1tmp.nc
48else
49  # extract variables
50  ncks -x -v $varlist1 $file1 -o file1tmp.nc
51fi
52
53if [ X$varlist2 == X ] ; then
54  ncks $file2 -o file2tmp.nc
55else
56  ncks -x -v $varlist2 $file2 -o file2tmp.nc
57fi
58
59cdo diffv file1tmp.nc file2tmp.nc
60