source: branches/2015/dev_r5021_UKMO1_CICE_coupling/NEMOGCM/TOOLS/MISCELLANEOUS/chk_ifdef.sh @ 5443

Last change on this file since 5443 was 5443, checked in by davestorkey, 5 years ago

Update 2015/dev_r5021_UKMO1_CICE_coupling branch to revision 5442 of the trunk.

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/bin/bash
2#
3# check the propper syntax of C preprocessor directives.
4# for example:
5#if defined key_traldf_c3d && key_traldf_smag
6# is not good and should be
7#if defined key_traldf_c3d && defined key_traldf_smag
8#
9# use: go to TOOLS/MISCELLANEOUS/ and simply execute:
10#  ./chk_ifdef.sh
11#
12set -u
13#
14grep -r "^ *#if" ../../NEMO | grep -v "~:" > tmp$$      # get each lines of the code starting with #if
15grep -r "^ *#elif" ../../NEMO | grep -v "~:" >> tmp$$   # get each lines of the code starting with #elif
16#
17for ll in $( seq 1 $( cat tmp$$ | wc -l  ) )            # for each of these lines
18do
19    lll=$( sed -n -e "${ll}p" tmp$$ )
20    nbdef=$( echo $lll | grep -o defined  | wc -l )         # number of occurences of "defined"
21    nband=$( echo $lll | grep -o   "&&"   | wc -l )         # number of occurences of "&&"
22    nbor=$(  echo $lll | grep -o   "||"   | wc -l )         # number of occurences of "||"
23    [ $nbdef -ne $(( $nband + $nbor + 1 )) ] && echo $lll   # print bad line
24done
25rm -f tmp$$ 
26
27#
28# add other basic tests
29#
30grep -ir  ":,:.*ji,jj" * | grep -v "~:"
31grep -ir  "ji,jj.*:,:" *  | grep -v "~:"
Note: See TracBrowser for help on using the repository browser.