1 | #!/bin/bash |
---|
2 | #------------------------------------------------ |
---|
3 | #$Id$ |
---|
4 | #------------------------------------------------ |
---|
5 | # |
---|
6 | set -u |
---|
7 | # |
---|
8 | inxml=0 |
---|
9 | insrc=0 |
---|
10 | while [ $# -gt 0 ] # Until you run out of parameters . . . |
---|
11 | do |
---|
12 | case "$1" in |
---|
13 | --inxml) inxml=1 ;; |
---|
14 | --insrc) insrc=1 ;; |
---|
15 | esac |
---|
16 | shift # Check next set of parameters. |
---|
17 | done |
---|
18 | # |
---|
19 | xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"} |
---|
20 | # |
---|
21 | srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"} |
---|
22 | # |
---|
23 | #------------------------------------------------ |
---|
24 | # |
---|
25 | [ $inxml -eq 1 ] && grep "< *field * id *=" $xmlfile |
---|
26 | [ $insrc -eq 1 ] && find $srcdir -name "*.[Ffh]90" -exec grep -iH "^[^\!]*call *iom_put *(" {} \; |
---|
27 | [ $(( $insrc + $inxml )) -ge 1 ] && exit |
---|
28 | # |
---|
29 | #------------------------------------------------ |
---|
30 | # |
---|
31 | # list of file containing "CALL iom_put" in $srcdir |
---|
32 | # |
---|
33 | srclist=$( find $srcdir -name "*.[Ffh]90" -exec grep -il "^[^\!]*call *iom_put *(" {} \; ) |
---|
34 | # |
---|
35 | # list of variables used in "CALL iom_put" |
---|
36 | # |
---|
37 | varlistsrc=$( find $srcdir -name "*.[Ffh]90" -exec grep -i "^[^\!]*call *iom_put *(" {} \; | sed -e "s/.*iom_put *( *[\"\']\([^\"\']*\)[\"\'] *,.*/\1/" | sort -d ) |
---|
38 | # |
---|
39 | # list of variables defined in the xml file |
---|
40 | # |
---|
41 | varlistxml=$( grep "< *field * id *=" $xmlfile | sed -e "s/^.*< *field * id *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d ) |
---|
42 | # |
---|
43 | # list of variables to be outputed in the xml file |
---|
44 | # |
---|
45 | varlistout=$( grep "< *field * ref *=" $xmlfile | sed -e "s/^.*< *field * ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d ) |
---|
46 | # |
---|
47 | echo "--------------------------------------------------" |
---|
48 | echo check if all iom_put found in $srcdir |
---|
49 | echo have a corresponding variable definition in $xmlfile |
---|
50 | echo "--------------------------------------------------" |
---|
51 | for var in $varlistsrc |
---|
52 | do |
---|
53 | tst=$( echo " "$varlistxml" " | grep -c " $var " ) |
---|
54 | if [ $tst -ne 1 ] |
---|
55 | then |
---|
56 | echo "$tst problem with $var, defined in" |
---|
57 | for f in $srclist |
---|
58 | do |
---|
59 | grep -iH "^[^\!]*call *iom_put *( *[\"\']${var}[\"\'] *," $f |
---|
60 | done |
---|
61 | echo |
---|
62 | fi |
---|
63 | done |
---|
64 | # |
---|
65 | echo "--------------------------------------------------" |
---|
66 | echo check if all variables defined in $xmlfile |
---|
67 | echo have a corresponding \"call iom_put\" in sources found in $srcdir |
---|
68 | echo "--------------------------------------------------" |
---|
69 | # |
---|
70 | for var in $varlistxml |
---|
71 | do |
---|
72 | found=$( echo " "$varlistsrc" " | grep -c " $var " ) |
---|
73 | if [ $found -eq 0 ] |
---|
74 | then |
---|
75 | echo \"call iom_put\" not found for variable $var |
---|
76 | grep "< *field * id *= *[\"\']${var}[\"\']" $xmlfile |
---|
77 | echo |
---|
78 | fi |
---|
79 | done |
---|
80 | # |
---|
81 | echo "--------------------------------------------------" |
---|
82 | echo ${xmlfile}: check if all variables to be outputed in files are really defined... |
---|
83 | echo "--------------------------------------------------" |
---|
84 | # |
---|
85 | # list of variables defined in the xml file |
---|
86 | for var in $varlistout |
---|
87 | do |
---|
88 | found=$( echo " "$varlistxml" " | grep -c " $var " ) |
---|
89 | [ $found -eq 0 ] && echo variable to be outputed but not defined: $var |
---|
90 | done |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | exit |
---|