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