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.
chk_iomput.sh in trunk/UTIL – NEMO

source: trunk/UTIL/chk_iomput.sh @ 1482

Last change on this file since 1482 was 1482, checked in by smasson, 15 years ago

distribution of iom_put + cleaning of LIM2 outputs, see ticket:437

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