Changeset 4512 for LMDZ6/trunk


Ignore:
Timestamp:
Apr 18, 2023, 1:34:29 PM (20 months ago)
Author:
lguez
Message:

Update diffdef.sh

Updated with the version which was on LMDZ website, in [Boîte à outils
LMDZ](https://lmdz.lmd.jussieu.fr/utilisateurs/utilisation-de-lmdz). Removed
the corresponding tar file on LMDZ website, to avoid confusion.

Location:
LMDZ6/trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/tools/compare_real.py

    r2412 r4512  
     1#!/usr/bin/env python3
     2
    13"""This script should be called by "diffdef.sh". It operates on
    2 different lines with common variables. It requires version 2.7 or
    3 higher of Python (it also works with Python 3).
     4different lines with common variables.
    45
    56Author: Lionel GUEZ"""
  • LMDZ6/trunk/tools/diffdef.sh

    r2426 r4512  
    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.