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_ifdef.sh in branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/TOOLS/MISCELLANEOUS – NEMO

source: branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/TOOLS/MISCELLANEOUS/chk_ifdef.sh @ 5980

Last change on this file since 5980 was 5980, checked in by timgraham, 8 years ago

Upgraded to v3.6 revision of trunk (r5518)

  • 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.