New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 10443 – NEMO

Changeset 10443


Ignore:
Timestamp:
2018-12-21T15:36:36+01:00 (5 years ago)
Author:
nicolasmartin
Message:

Improve bash script to check the validity of the references included in the manual wrt to NEMO source code
manuals_checking.sh will report

  • missing namelists
  • vanished references (\mdl, \ngn, \nlst, \rou and \np)
  • namelist parameters not following the current conventions: [cdlnr]n_*
File:
1 moved

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/doc/bin/manuals_checking.sh

    r10442 r10443  
    11#!/bin/sh 
    22 
     3#set -evx 
     4 
    35if [[ $* != '' ]]; then 
    4  
    5     if [[ $1 = 'all' ]]; then 
    6         models='NEMO SI3 TOP' 
    7     else 
    8         models=$1 
    9     fi 
    10  
     6    if [[ $1 = 'all' ]]; then models='NEMO SI3 TOP'; else models=$1; fi 
    117else 
    12     models='NEMO' 
     8    models='NEMO' 
    139fi 
    1410 
     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 
    1516for model in $models; do 
    16     [[ $model =~ ^(SI3|TOP)$ ]] && continue 
    17     echo 'Namelists not included in the '$model' manual:' 
     17    [[ $model =~ ^(SI3|TOP)$ ]] && continue 
    1818 
    19     for nlst in $( ls namelists ); do 
     19    tex_files=$( find latex/$model -type f -name *.tex ) 
    2020 
    21         if [[ ! $( grep "\\nlst{$nlst}" ./latex/$model/subfiles/*.tex ) ]]; then 
    22             printf "$nlst " 
     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_*)' 
     55 
     56for nlst in $( ls namelists ); do 
     57    np_list=$( f90nml namelists/$nlst 2> /dev/null | awk '/=/ { print $1 }' ) 
     58    array=() 
     59 
     60    for np in ${np_list}; do 
     61 
     62        if [[ ! ${np:0:3} =~ ^[cdlnr]n_$ ]]; then 
     63            array+=$np' ' 
    2364        fi 
    2465 
    2566    done 
    2667 
    27     echo 
     68    if (( ${#array[@]} != 0 )); then 
     69        printf '%15s: ' $nlst 
     70        echo ${array[@]} 
     71    fi 
    2872 
    2973done 
Note: See TracChangeset for help on using the changeset viewer.