source: LMDZ5/trunk/tools/diffdef.sh @ 2098

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

Replaced 360 in calbeta_clim by length of current year according to
chosen calendar. Length of current year is given by
ioget_year_len. Since we already need this for ozone, moved the call
to ioget_year_len from physiq to phys_cal_mod and created variable
year_len of module phys_cal_mod.

Control the output from minmaxqfi.

Non-ASCII characters in comments are not always rendered properly and
they risk being lost. See revision 1740.

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1# This is a script in Bash.
2# Author: Lionel GUEZ
3
4# This script compares files "*.def" other than "traceur.def" in two
5# directories. The script uses GNU versions of the utilities cut, sort
6# and uniq.
7
8# See guide:
9# http://lmdz.lmd.jussieu.fr/utilisateurs/outils/utilisation-de-lmdz#section-5
10
11USAGE="usage: `basename $0` directory_1 directory_2"
12
13if (($# != 2))
14    then
15    echo "$USAGE" >&2
16    exit 1
17fi
18
19##set -x
20set -e
21
22script_dir=`dirname $0`
23
24# Let us make sure we know what the sort order is:
25export LC_ALL=C
26
27# Enable extended pattern matching features:
28shopt -s extglob
29
30for my_directory in $*
31  do
32  cd $my_directory
33  rm -f all.def
34  echo "def files in $my_directory:"
35  ls !(traceur).def
36
37  # Concatenate and format the def files:
38  cat !(traceur).def | tr -d " " | grep -v -E '(^#|^!|INCLUDEDEF|^$)' \
39      | tr '[:lower:]' '[:upper:]' | sed 's/=N$/=FALSE/' | sed 's/=Y$/=TRUE/' \
40      | sort >all.def
41
42  # Check that no variable is repeated:
43  cut --fields=1 --delimiter="=" all.def | uniq --repeated >plouf_$$
44  if [[ -s plouf_$$ ]]
45      then
46      echo
47      echo "Error: a variable is repeated in directory \"$my_directory\"."
48      echo
49      echo "Here is the list of repeated variables in directory \"$my_directory\":"
50      echo
51      cat plouf_$$
52      rm plouf_$$
53      exit 1
54  fi
55  rm plouf_$$
56
57  cd - >/dev/null
58done
59
60
61sort $1/all.def $2/all.def | uniq --repeated >common_lines
62
63for my_directory in $*
64  do
65  sort $my_directory/all.def common_lines | uniq --unique \
66      >$my_directory/uniq_lines
67done
68
69sort --field-separator="=" --key=1,1 --unique $2/uniq_lines $1/uniq_lines \
70    | sort - $2/uniq_lines | uniq --unique >$1/uniq_var
71sort --field-separator="=" --key=1,1 --unique $1/uniq_lines $2/uniq_lines \
72    | sort - $1/uniq_lines | uniq --unique >$2/uniq_var
73
74for my_directory in $*
75  do
76  cd $my_directory
77  echo "Created file \"$my_directory/uniq_var\"."
78  sort uniq_lines uniq_var | uniq --unique >common_var
79  rm uniq_lines
80  cd - >/dev/null
81done
82
83$script_dir/compare_real.py $*
84sort common_lines --output=common_lines # was modified by the Python script
85echo "Created files \"./common_lines\" and \"./uniq_val\"."
86
87# Clean up:
88for my_directory in $*
89  do
90    rm $my_directory/common_var $my_directory/all.def
91done
Note: See TracBrowser for help on using the repository browser.