Ignore:
Timestamp:
Oct 19, 2023, 4:02:57 PM (8 months ago)
Author:
idelkadi
Message:

Merged trunk changes -r4488:4726 LMDZ_ECRad branch

Location:
LMDZ6/branches/LMDZ_ECRad
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/LMDZ_ECRad

  • LMDZ6/branches/LMDZ_ECRad/tools/diffdef.sh

    r2426 r4727  
    22# Author: Lionel GUEZ
    33
    4 # This script compares files "*.def" other than "*traceur.def" and
    5 # "out.def" in two directories.
     4# This script compares files "*.def" other than "traceur.def",
     5# "tracer.def", "isotopes_params.def" and "out.def" in two directories.
    66
    77# This script uses GNU versions of the utilities cut, sort and uniq,
     
    99
    1010# See guide:
    11 # http://lmdz.lmd.jussieu.fr/utilisateurs/outils/utilisation-de-lmdz#section-5
     11# http://lmdz.lmd.jussieu.fr/utilisateurs/utilisation-de-lmdz#section-5
    1212
    1313USAGE="usage: `basename $0` directory_1 directory_2"
    1414
    1515if (($# != 2))
    16     then
     16then
    1717    echo "$USAGE" >&2
    1818    exit 1
     
    2020
    2121##set -x
    22 
    23 type python3 >/dev/null 2>&1
    24 if (($? == 0))
    25 then
    26     my_python=python3
    27 else
    28     my_python=python
    29 fi
    30 
    3122set -e
    3223
     
    4031
    4132for my_directory in $*
    42   do
    43   cd $my_directory
    44   rm -f all.def
    45   echo "def files in $my_directory:"
    46   ls !(*traceur|out).def
     33do
     34    cd $my_directory
     35    rm -f all.def
     36    echo "def files in $my_directory:"
     37    ls !(traceur|tracer|out|isotopes_params).def
    4738
    48   # Concatenate and format the def files:
    49   cat !(*traceur|out).def | tr '\r' '\n' | tr -d " " \
    50       | grep -v -E '(^#|^!|INCLUDEDEF|^$)' \
    51       | tr '[:lower:]' '[:upper:]' | sed 's/=[NF]$/=FALSE/' \
    52       | sed 's/=[YT]$/=TRUE/' | sort >all.def
     39    # Concatenate and format the def files:
     40    cat !(traceur|tracer|out|isotopes_params).def | tr -d " \t" \
     41        | grep -v -E '(^#|^!|INCLUDEDEF|^$)' \
     42        | tr '[:lower:]' '[:upper:]' | sed 's/=[NF]$/=FALSE/' \
     43        | sed 's/=[YT]$/=TRUE/' | sort >all.def
    5344
    54   # Check that no variable is repeated:
    55   cut --fields=1 --delimiter="=" all.def | uniq --repeated >plouf_$$
    56   if [[ -s plouf_$$ ]]
    57       then
    58       echo
    59       echo "Error: a variable is repeated in directory \"$my_directory\"."
    60       echo
    61       echo "Here is the list of repeated variables in directory \"$my_directory\":"
    62       echo
    63       cat plouf_$$
    64       rm plouf_$$
    65       rm all.def
    66       exit 1
    67   fi
    68   rm plouf_$$
    69 
    70   cd - >/dev/null
     45    # Check that no variable is repeated:
     46   
     47    cut --fields=1 --delimiter="=" all.def | uniq --repeated >plouf_$$
     48   
     49    if [[ -s plouf_$$ ]]
     50    then
     51        echo
     52        echo "Error: a variable is repeated in directory \"$my_directory\"."
     53        echo
     54        echo "Here is the list of repeated variables in directory " \
     55             "\"$my_directory\":"
     56        echo
     57        cat plouf_$$
     58        rm plouf_$$
     59        rm all.def
     60        exit 1
     61    fi
     62   
     63    rm plouf_$$
     64    cd - >/dev/null
    7165done
    72 
    7366
    7467sort $1/all.def $2/all.def | uniq --repeated >common_lines
    7568
    7669for my_directory in $*
    77   do
    78   sort $my_directory/all.def common_lines | uniq --unique \
    79       >$my_directory/uniq_lines
     70do
     71    sort $my_directory/all.def common_lines | uniq --unique \
     72                                                   >$my_directory/uniq_lines
    8073done
    8174
     
    8679
    8780for my_directory in $*
    88   do
    89   cd $my_directory
    90   echo "Created file \"$my_directory/uniq_var\"."
    91   sort uniq_lines uniq_var | uniq --unique >common_var
    92   rm uniq_lines
    93   cd - >/dev/null
     81do
     82    cd $my_directory
     83    echo "Created file \"$my_directory/uniq_var\"."
     84    sort uniq_lines uniq_var | uniq --unique >common_var
     85    rm uniq_lines
     86    cd - >/dev/null
    9487done
    9588
    96 $my_python $script_dir/compare_real.py $*
     89$script_dir/compare_real.py $*
    9790sort common_lines --output=common_lines # was modified by the Python script
    9891echo "Created files \"./common_lines\" and \"./uniq_val\"."
     
    10093# Clean up:
    10194for my_directory in $*
    102   do
     95do
    10396    rm $my_directory/common_var $my_directory/all.def
    10497done
Note: See TracChangeset for help on using the changeset viewer.