source: LMDZ5/trunk/tools/Max_diff_nc_with_lib/Max_diff_nc/max_diff_nc.sh @ 1907

Last change on this file since 1907 was 1907, checked in by lguez, 10 years ago

Added a copyright property to every file of the distribution, except
for the fcm files (which have their own copyright). Use svn propget on
a file to see the copyright. For instance:

$ svn propget copyright libf/phylmd/physiq.F90
Name of program: LMDZ
Creation date: 1984
Version: LMDZ5
License: CeCILL version 2
Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
See the license file in the root directory

Also added the files defining the CeCILL version 2 license, in French
and English, at the top of the LMDZ tree.

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1# This is a script in Bash.
2# Author: Lionel GUEZ
3
4# This script is a wrapper for a Fortran program. It compares NetCDF
5# variables of type "NF90_FLOAT" or "NF90_DOUBLE" and of rank 1 to 4
6# in two files. NetCDF variables are read into Fortran variables of
7# type "double precision". The program computes the maximum of the
8# absolute value of the difference and the maximum of the absolute
9# value of the relative difference. The program either compares
10# variables with the same varid or variables with the same name, or a
11# single variable selected on the command line. Compared variables are
12# assumed to have the same type. The program checks that compared
13# variables have the same shape.
14
15USAGE="usage: `basename $0` [-s] [-m] [-i] [-q] [-v <var>] file file
16   -s: report identical variables
17   -m: compute average order of magnitude
18   -i: compare variables with same varid, regardless of variable name
19   -q: only report names of variables which differ, without maximum difference
20   -v <var>: only compare variable <var>"
21
22# Default values:
23report_id=False
24comp_mag=False
25same_varid=False
26quiet=False
27
28while getopts smiqv: name
29  do
30  case $name in
31      s) report_id=True;;
32      m) comp_mag=True;;
33      i) same_varid=True;;
34      q) quiet=True;;
35      v) name1=$OPTARG;;
36      \?) echo "$USAGE"
37      exit 1;;
38  esac
39done
40
41shift $((OPTIND - 1))
42
43if (($# != 2))
44    then
45    echo "$USAGE" >&2
46    exit 1
47fi
48
49##set -x
50trap 'exit 1' ERR
51
52for argument in $*
53  do
54  if [[ ! -f $argument ]]
55      then
56      echo "$argument not found"
57      exit 1
58  fi
59done
60
61max_diff_nc=...
62if [[ ! -x $max_diff_nc ]]
63    then
64    echo "Fortran executable not found" >&2
65    exit 1
66fi
67
68ln -s $1 in1.nc
69ln -s $2 in2.nc
70
71trap 'rm in1.nc in2.nc; exit 1' ERR
72
73# Run the Fortran program:
74$max_diff_nc <<EOF
75$same_varid
76$report_id
77$quiet
78$comp_mag
79$name1
80EOF
81
82rm in1.nc in2.nc
Note: See TracBrowser for help on using the repository browser.