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 14182 – NEMO

Changeset 14182


Ignore:
Timestamp:
2020-12-15T23:39:04+01:00 (3 years ago)
Author:
nicolasmartin
Message:

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

Files:
3 added
1 copied

Legend:

Unmodified
Added
Removed
  • utils/developer/branch_stats.sh

    r14165 r14182  
    1 #!/bin/sh 
     1#!/bin/bash 
    22 
    3 ## Basic statistics for NEMO sources per release (code / comments / blank lines) 
    4 ## loc: lines of code 
    5 ## lon:   "   "" notes 
    6 ## lob:   "   "" blank 
     3#set -ex 
    74 
    8 printf "%40s %7s(ratio) %7s(ratio) %7s(ratio) %7s\n\n" '' code notes blank sum 
     5## Rough statistics on routines (code / notes / blank) 
    96 
    10 for release_srcs in "release-3.4/NEMOGCM/NEMO/*" "release-3.6/NEMOGCM/NEMO/*" "release-4.0/src/*"; do 
     7[ -z "$*" ] && { echo 'No branch path(s) given => QUIT'; exit 2; } 
    118 
    12     sum_loc=0; sum_lon=0; sum_lob=0; sum_ful=0 
     9branches=$* 
    1310 
    14     for dir in ${release_srcs}; do 
    15         nb_loc=$( find $dir -name *.[fFh]90 -exec grep '^ *[^! ]' {} \; | wc -l ) 
    16         nb_lon=$( find $dir -name *.[fFh]90 -exec grep '^ *!'     {} \; | wc -l ) 
    17         nb_lob=$( find $dir -name *.[fFh]90 -exec grep '^ *$'     {} \; | wc -l ) 
    18         ratio_c=$( echo "scale = 3; ( ${nb_loc} / ( ${nb_loc} + ${nb_lon} + ${nb_lob} ) ) * 100" | bc | tr . , ) 
    19         ratio_n=$( echo "scale = 3; ( ${nb_lon} / ( ${nb_loc} + ${nb_lon} + ${nb_lob} ) ) * 100" | bc | tr . , ) 
    20         ratio_b=$( echo "scale = 3; ( ${nb_lob} / ( ${nb_loc} + ${nb_lon} + ${nb_lob} ) ) * 100" | bc | tr . , ) 
    21         printf "%-40s %7d(%4.1f%%) %7d(%4.1f%%) %7d(%4.1f%%) %7d\n" \ 
    22             $dir ${nb_loc} ${ratio_c} ${nb_lon} ${ratio_n} ${nb_lob} ${ratio_b} $(( nb_loc + nb_lon + nb_lob )) 
    23         sum_loc=$(( sum_loc + nb_loc                   )) 
    24         sum_lon=$(( sum_lon          + nb_lon          )) 
    25         sum_lob=$(( sum_lob                   + nb_lob )) 
    26         sum_ful=$(( sum_ful + nb_loc + nb_lon + nb_lob )) 
    27     done 
     11export LC_NUMERIC='en_GB.UTF-8' ## Decimal separator 
     12fmt='%-50s %7d(%4.1f%%) %7d(%4.1f%%) %7d(%4.1f%%) %7d\n' 
    2813 
    29     ratio_c=$( echo "scale = 3; ( ${sum_loc} / ${sum_ful} ) * 100" | bc | tr . , ) 
    30     ratio_n=$( echo "scale = 3; ( ${sum_lon} / ${sum_ful} ) * 100" | bc | tr . , ) 
    31     ratio_b=$( echo "scale = 3; ( ${sum_lob} / ${sum_ful} ) * 100" | bc | tr . , ) 
    32     printf "%40s %7d(%4.1f%%) %7d(%4.1f%%) %7d(%4.1f%%) %7d\n\n" \ 
    33         sum ${sum_loc} ${ratio_c} ${sum_lon} ${ratio_n} ${sum_lob} ${ratio_b} ${sum_ful} 
     14for branch in $branches; do 
    3415 
     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    
    3559done 
    3660 
Note: See TracChangeset for help on using the changeset viewer.