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.
branch_stats.sh in utils/developer – NEMO

source: utils/developer/branch_stats.sh @ 14182

Last change on this file since 14182 was 14182, checked in by nicolasmartin, 4 years ago

Move scripts for checking branch to developer dir and create symlinks at the root of /NEMO

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/bin/bash
2
3#set -ex
4
5## Rough statistics on routines (code / notes / blank)
6
7[ -z "$*" ] && { echo 'No branch path(s) given => QUIT'; exit 2; }
8
9branches=$*
10
11export LC_NUMERIC='en_GB.UTF-8' ## Decimal separator
12fmt='%-50s %7d(%4.1f%%) %7d(%4.1f%%) %7d(%4.1f%%) %7d\n'
13
14for branch in $branches; do
15
16   cod_sum=0; not_sum=0; blk_sum=0; lin_sum=0
17   paths="$branch/NEMOGCM/NEMO $branch/src"
18
19   [ -z "$( ls $paths 2> /dev/null )" ] && continue
20
21   printf "%-50s %7s(ratio) %7s(ratio) %7s(ratio) %7s\n" \
22           ''    code       notes      blank      all
23
24   for dir in $( find $paths -type d -mindepth 1 -maxdepth 1 2> /dev/null ); do
25
26      files=$( find $dir -name "*.[fFh]90" 2> /dev/null )
27
28      cod_nb=$( grep -h '^ *[^! ]' $files | wc -l ); not_nb=$( grep -h '^ *!'     $files | wc -l )
29      blk_nb=$( grep -h '^ *$'     $files | wc -l )
30      lin_nb=$(( cod_nb + not_nb + blk_nb ))
31
32      cod_ratio=$( echo "scale = 3; ( ${cod_nb} / ${lin_nb} ) * 100" | bc )
33      not_ratio=$( echo "scale = 3; ( ${not_nb} / ${lin_nb} ) * 100" | bc )
34      blk_ratio=$( echo "scale = 3; ( ${blk_nb} / ${lin_nb} ) * 100" | bc )
35
36      dir=$( echo $dir | awk -F/ '{printf "%s/%s/%s", $(NF-2), $(NF-1), $(NF)}' )
37     
38      printf "$fmt" $dir                                                                 \
39                    ${cod_nb} ${cod_ratio} ${not_nb} ${not_ratio} ${blk_nb} ${blk_ratio} \
40                    $lin_nb
41
42      cod_sum=$(( cod_sum + cod_nb )); not_sum=$(( not_sum + not_nb ))
43      blk_sum=$(( blk_sum + blk_nb )); lin_sum=$(( lin_sum + lin_nb ))
44
45   done
46
47   cod_ratio=$( echo "scale = 3; ( ${cod_sum} / ${lin_sum} ) * 100" | bc )
48   not_ratio=$( echo "scale = 3; ( ${not_sum} / ${lin_sum} ) * 100" | bc )
49   blk_ratio=$( echo "scale = 3; ( ${blk_sum} / ${lin_sum} ) * 100" | bc )
50
51   branch=$( echo $branch | awk -F/ '{print $NF}' )
52
53   printf "$fmt" $branch                                                                 \
54                 ${cod_sum} ${cod_ratio} ${not_sum} ${not_ratio} ${blk_sum} ${blk_ratio} \
55                 ${lin_sum}
56
57   echo
58   
59done
60
61exit 0
Note: See TracBrowser for help on using the repository browser.