source: NEMO/trunk/doc/bin/manuals_checking.sh @ 10448

Last change on this file since 10448 was 10448, checked in by nicolasmartin, 20 months ago

Add case sensitive check for namelists parameters
We should clearly avoid using uppercase as it can only bring us further issues:

  • Uppercase does not provide any essential information
  • Fortran is case insensitive by default and convert all uppercase to lowercase
  • It generates collateral damage by adding more complexity, for instance when defining correct regular expression to match
  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/bin/sh
2
3#set -evx
4
5if [[ $* != '' ]]; then
6    if [[ $1 = 'all' ]]; then models='NEMO SI3 TOP'; else models=$1; fi
7else
8    models='NEMO'
9fi
10
11extract_arg() {
12    ## $1: macro name, $2: prefix for filtering args (optional)
13    eval grep -Poh "\\$1{\\$2\\\K[^}]+" ${tex_files} | tr -d '\\' | sort -u
14}
15
16for model in $models; do
17    [[ $model =~ ^(SI3|TOP)$ ]] && continue
18
19    tex_files=$( find latex/$model -type f -name *.tex )
20
21    echo '¤ Missing namelist groups in '$model' manual'
22
23    for nlst in $( ls namelists ); do
24        [[ ! $( grep \\nlst{$nlst} ${tex_files} ) ]] && printf '%s ' $nlst
25    done
26
27    echo; echo
28    echo '¤ Vanished references in '$model' manual (\\autoref{...})'
29
30    for item in 'mdl' 'ngn' 'nlst' 'np' 'rou'; do
31        echo '- '$item':'
32        args_list=$( extract_arg $item )
33
34        for arg in ${args_list}; do
35
36            if   [[ "$item" == 'nlst' && ! -f namelists/$arg ]]; then
37                printf '%15s: ' $arg
38                grep -l \\nlst{$arg} ${tex_files} | sed 's/^.*\///'
39            elif [[ ( "$item" == 'mdl' && ! $( find ../src -type f -name $arg.[Ffh]90  ) ) || \
40                    ( "$item" == 'ngn' && ! $( grep     \&$arg             namelists/* ) ) || \
41                    ( "$item" == 'rou' && ! $( grep -ri "SUBROUTINE *$arg" ../src      ) ) || \
42                    ( "$item" == 'np'  && ! $( grep     " $arg *="         namelists/* ) )      ]]; then
43                printf '%s ' $arg
44            fi
45       
46        done
47
48        [ "$item" != 'nlst' ] && echo
49    done
50
51done
52
53echo
54echo '¤ Namelist parameters unfollowing naming conventions (^[cdlnr]n_* or uppercase somewhere)'
55
56for nlst in $( ls namelists ); do
57    np_list=$( sed '/^ *[!/&]/d; s|[!/&].*||' namelists/$nlst | tr -d ' ' | cut -d= -f1 )
58    array=()
59
60    for np in ${np_list}; do
61
62        if [[ ! ${np:0:3} =~ ^[cdlnr]n_$ || $( echo $np | grep [A-Z] ) ]]; then
63            array+=$np' '
64        fi
65
66    done
67
68    if (( ${#array[@]} != 0 )); then
69        printf '%15s: ' $nlst
70        echo ${array[@]}
71    fi
72
73done
74
75exit 0
Note: See TracBrowser for help on using the repository browser.