#!/bin/bash #------------------------------------------------ #$Id: chk_iomput.sh 4162 2013-11-07 10:19:49Z cetlod $ #------------------------------------------------ # set -u # # if not argument -> get the help [ $# -eq 0 ] && ./$0 --help && exit # inxml=0 insrc=0 while [ $# -gt 0 ] # Until you run out of parameters . . . do case "$1" in -h|--help) echo echo 'Description:' echo ' check that an xml file is coherant with the source code:' echo ' - all variable ids defined by "call iom_put" must have their counterpart' echo ' in the variable definition in xml file' echo ' - list variable ids defined in xml file without any corresponding call' echo ' to iom_put. This can be done but it is useless as iom will only ouput zeros' echo ' - all variable ids used in the files definition in xml file must have' echo ' their counterpart in the variable definition in xml file' echo 'Usage:' echo ' chk_iomput.sh [OPTION]' echo ' or chk_iomput.sh [OPTION] xmlfile DIRECTORIES' echo ' with:' echo ' xmlfile: the xml file to test' echo ' DIRECTORIES: a list of directories containing the source code' echo 'Options' echo ' -h, --help to get this help' echo ' --inxml only print all variable definitions found in the xml file' echo ' --insrc only print all variable definitions found in the source code' echo 'Examples' echo ' ./chk_iomput.sh' echo ' ./chk_iomput.sh --help' echo ' ./chk_iomput.sh ../../CONFIG/ORCA2_LIM/EXP00/iodef.xml "../../NEMO/OPA_SRC/ ../../NEMO/LIM_SRC_2/"' echo exit ;; --inxml) inxml=1 ;; --insrc) insrc=1 ;; -*) echo ; echo "illegal option" ; ./$0 --help && exit ;; *) [ $# -ne 2 ] && echo && echo "wrong number of arguments" && ./$0 --help && exit xmlfile=${1} srcdir=${2} shift esac shift # Check next set of parameters. done # [ ! -f "$xmlfile" ] && echo "$xmlfile not found, we stop..." && exit for i in $srcdir do [ ! -d $i ] && echo "$i is not a directory, we stop..." && exit done # #------------------------------------------------ # external=$( grep -c "