/[MITgcm]/MITgcm_contrib/jmc_script/mk_options_list
ViewVC logotype

Contents of /MITgcm_contrib/jmc_script/mk_options_list

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Aug 10 21:29:06 2012 UTC (11 years, 8 months ago) by jmc
Branch: MAIN
add a script to generate list of CPP Options used in Fortran source files

1 #! /usr/bin/env bash
2 #
3 # $Header: $
4 # $Name: $
5
6 # generate list of CPP Options used in Fortran source files
7 # arguments = list of Fortran source files
8
9 clean=1
10 listOpt='TTT.listOpt'
11 get_sd='options_get.sed'
12 sortsd='options_sort.sed'
13 tmpfil=TTT.$$
14 #echo $tmpfil
15
16 if [ $# -eq 0 ] ; then
17 echo "Usage: `basename $0` {list_of_files}"
18 echo " generate list of CPP Options used in all the Fortran source files"
19 echo " which are given in argument list {list_of_files}"
20 echo " or : `basename $0` -clean"
21 echo " just clean-up temp files"
22 exit
23 fi
24 if test $1 = '-clean' ; then
25 LIST=`ls -C $get_sd $sortsd $listOpt 2>/dev/null`
26 #echo "LIST='$LIST'"
27 if test "x$LIST" != x ; then
28 echo " remove: $LIST" ; rm -f $LIST
29 else
30 echo " no file to remove"
31 fi
32 exit
33 fi
34
35
36 if [ $clean -ge 3 ] ; then rm -f $get_sd $sortsd ; fi
37 if test -f $get_sd ; then ls -l $get_sd
38 else
39 cat <<EOF >> $get_sd
40 /^#.*\\\\ *$/{N
41 s/\\\\//
42 p
43 }
44 EOF
45 fi
46 if test -f $sortsd ; then ls -l $sortsd
47 else
48 cat <<EOF >> $sortsd
49 /^ccc /d
50 s/^# *ifndef//
51 s/^# *ifdef//
52 s/^# *if//
53 s/^# *elif//
54 s/||//g
55 s/&&//g
56 s/(//g
57 s/)//g
58 s/defined//g
59 s/!//g
60 EOF
61 fi
62
63 rm -f $listOpt
64 for xx in $*
65 do
66 echo "ccc start file: $xx -----------------" >> $listOpt
67 sed -n '/^ .*\\ *$/p' $xx | sed 's/\\ *$//' >> $listOpt
68 echo "ccc above: between cont line | below: 1rst and last of cont line" >> $listOpt
69 sed '/^ .*\\ *$/d' $xx > $tmpfil
70 sed -n -f $get_sd $tmpfil >> $listOpt
71 echo "ccc below: single line" >> $listOpt
72 sed '/^# *e*l*if.*\\ *$/d' $tmpfil | sed -n '/^# *e*l*if/p' >> $listOpt
73 echo "ccc end file: $xx -----------------" >> $listOpt
74 rm -f $tmpfil
75 done
76 LIST=`sed -f $sortsd $listOpt`
77 if [ $clean -ge 2 ] ; then
78 rm -f $listOpt
79 fi
80
81 for xx in $LIST
82 do
83 echo $xx >> $tmpfil
84 done
85
86 echo "-- used CPP options:"
87 cat $tmpfil | sort | uniq
88 if [ $clean -ge 1 ] ; then rm -f $tmpfil ; fi

  ViewVC Help
Powered by ViewVC 1.1.22