source:
trunk/NEMOGCM/TOOLS/MISCELLANEOUS/chk_wrk_alloc.sh
@
5476
Last change on this file since 5476 was 5407, checked in by smasson, 9 years ago | |
---|---|
|
|
File size: 1.3 KB |
Rev | Line | |
---|---|---|
[3137] | 1 | #!/bin/bash |
2 | # | |
3 | # purpose: | |
4 | # small script to check in all *90 files of the current directory and subdirectories | |
5 | # if all lines with wrk_alloc have their corresponding lines with wrk_dealloc | |
6 | # | |
7 | # use: | |
8 | # call chk_wrk_alloc.sh from the directory you want to check | |
9 | # | |
10 | # example: | |
11 | # cd ~/dev_NEMO_MERGE_2011/NEMOGCM/NEMO | |
12 | # ../TOOLS/MISCELLANEOUS/chk_wrk_alloc.sh | |
13 | # | |
[5302] | 14 | set -u |
[3137] | 15 | # |
16 | echo "check for all *90 files contained in "$( pwd )" and its subdirectories" | |
17 | # | |
[5302] | 18 | for ff in $( grep -il "^ *use *wrk_nemo" $( find . -name "*90" ) $( find . -name "*h90" ) ) |
[3137] | 19 | do |
20 | # number of lines with wrk_alloc | |
[5302] | 21 | n1=$( grep -ic "call *wrk_alloc *(" $ff ) |
22 | # number of lines with wrk_dealloc | |
23 | nn1=$( grep -ic "call *wrk_dealloc *(" $ff ) | |
24 | ||
25 | if [ $(( $n1 + $nn1 )) -ne 0 ] | |
26 | then | |
27 | # replace wrk_alloc with wrk_dealloc and count the lines | |
28 | n2=$( sed -e "s/wrk_alloc/wrk_dealloc/" $ff | grep -ic "call *wrk_dealloc *(" ) | |
29 | # we should get n2 = 2 * n1... | |
30 | [ $(( 2 * $n1 )) -ne $n2 ] && echo "problem with wrk_alloc in $ff" | |
31 | ||
32 | # same story but for wrk_dealloc | |
33 | nn2=$( sed -e "s/wrk_dealloc/wrk_alloc/" $ff | grep -ic "call *wrk_alloc *(" ) | |
[5407] | 34 | if [ $(( 2 * $nn1 )) -ne $nn2 ] |
35 | then | |
36 | echo "problem with wrk_dealloc in $ff" | |
37 | grep -i "call *wrk_alloc *(" $ff | |
38 | grep -i "call *wrk_dealloc *(" $ff | |
39 | echo | |
40 | fi | |
[5302] | 41 | fi |
42 | ||
[3137] | 43 | done |
Note: See TracBrowser
for help on using the repository browser.