source: trunk/UTIL/chk_iomput.sh @ 2529

Last change on this file since 2529 was 1705, checked in by smasson, 12 years ago

impact of HF winds in TKE, see ticket:585

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1#!/bin/bash
2#------------------------------------------------
3#$Id$
4#------------------------------------------------
5#
6set -u
7#
8inxml=0
9insrc=0
10xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"}
11srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"}
12while [ $# -gt 0 ]   # Until you run out of parameters . . .
13do   
14    case "$1" in
15        --inxml) inxml=1 ;;
16        --insrc) insrc=1 ;;
17   *) xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"}
18      srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"}
19      shift
20    esac
21    shift       # Check next set of parameters.
22done 
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#
34srclist=$( find $srcdir -name "*.[Ffh]90" -exec grep -il "^[^\!]*call  *iom_put *(" {} \; )
35#
36# list of variables used in "CALL iom_put"
37#
38varlistsrc=$( 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#
42varlistxml=$( 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#
46varlistout=$( grep "< *field * ref *=" $xmlfile  | sed -e "s/^.*< *field * ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
47#
48echo "--------------------------------------------------"
49echo  check if all iom_put found in $srcdir
50echo  have a corresponding variable definition in $xmlfile
51echo "--------------------------------------------------"
52for var in $varlistsrc
53do
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
64done
65#
66echo "--------------------------------------------------"
67echo  check if all variables defined in $xmlfile
68echo  have a corresponding \"call iom_put\" in sources found in $srcdir
69echo "--------------------------------------------------"
70#
71for var in $varlistxml
72do
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
80done
81#
82echo "--------------------------------------------------"
83echo  ${xmlfile}: check if all variables to be outputed in files are really defined...
84echo "--------------------------------------------------"
85#
86# list of variables defined in the xml file
87for var in $varlistout
88do
89    found=$( echo " "$varlistxml" " | grep -c " $var " )
90    [ $found -eq 0 ] && echo variable to be outputed but not defined: $var 
91done
92
93
94
95exit
Note: See TracBrowser for help on using the repository browser.