1 | #!/bin/bash |
---|
2 | |
---|
3 | ROOT=$PWD |
---|
4 | MOD=$ROOT/xmod |
---|
5 | INC=/usr/lib64/openmpi/1.8.8-gfortran49/include |
---|
6 | |
---|
7 | function parse() |
---|
8 | { |
---|
9 | cd $1 ; shift |
---|
10 | for SRC in $* ; do |
---|
11 | F_Front -M $MOD -I $INC $SRC.f90 -o $ROOT/xml/$SRC.xml > $ROOT/xml/$SRC.err 2>&1 |
---|
12 | done |
---|
13 | cd $ROOT |
---|
14 | } |
---|
15 | |
---|
16 | function add_srcfiles() |
---|
17 | { |
---|
18 | while (($# > 0)) ; do |
---|
19 | DIR=$1 |
---|
20 | SRC=$2 |
---|
21 | # echo $SRC ${dir[$SRC]} |
---|
22 | if [[ -z ${dir[$SRC]} ]] ; then |
---|
23 | # echo "add_srcfiles : $NUMFILE $DIR $SRC" |
---|
24 | src[$NUMFILE]=$SRC |
---|
25 | dir[$SRC]=$DIR |
---|
26 | ok[$SRC]=NO |
---|
27 | ((NUMFILE++)) |
---|
28 | fi |
---|
29 | shift ; shift |
---|
30 | done |
---|
31 | } |
---|
32 | |
---|
33 | NETCDF=netcdf-fortran-4.4.5 |
---|
34 | if [ ! -d "$NETCDF" ]; then |
---|
35 | tar xzvf ${NETCDF}.tar.gz |
---|
36 | fi |
---|
37 | |
---|
38 | rm -f xml/* xmod/* |
---|
39 | echo "Parsing NetCDF ..." |
---|
40 | parse ${NETCDF}/fortran typeSizes netcdf4 |
---|
41 | echo "... done." |
---|
42 | |
---|
43 | # create arrays |
---|
44 | declare -a src |
---|
45 | declare -A dir |
---|
46 | declare -A ok |
---|
47 | NUMFILE=0 |
---|
48 | |
---|
49 | # first read from text file parse_order.txt |
---|
50 | touch parse_order.txt |
---|
51 | add_srcfiles $(cat parse_order.txt) |
---|
52 | # then, for completeness and bootstrapping, add files found in relevant places |
---|
53 | for DIR in $(find ../tools/ioipsl ../src ../ppsrc external_src -type d) ; do |
---|
54 | cd -P $ROOT/$DIR |
---|
55 | for F90 in $(ls *.f90 2>/dev/null) ; do |
---|
56 | SRC=$(echo "$F90" | cut -d'.' -f1) |
---|
57 | add_srcfiles $DIR $SRC |
---|
58 | done |
---|
59 | done |
---|
60 | cd $ROOT |
---|
61 | |
---|
62 | echo "$NUMFILE files to be parsed." |
---|
63 | rm -f parse_order.txt |
---|
64 | |
---|
65 | PASS=0 |
---|
66 | AGAIN=YES |
---|
67 | |
---|
68 | while [[ "$AGAIN" == "YES" ]] ; do |
---|
69 | AGAIN=NO |
---|
70 | ((PASS++)) |
---|
71 | echo "------------------ pass $PASS ------------------" |
---|
72 | for SRC in ${src[@]} ; do |
---|
73 | DIR=${dir[$SRC]} |
---|
74 | YESNO=${ok[$SRC]} |
---|
75 | if [[ "$YESNO" == "NO" ]] ; then |
---|
76 | parse $DIR $SRC |
---|
77 | grep 'failed to import module' xml/$SRC.err > /dev/null |
---|
78 | if [ $? -ne 0 ]; then |
---|
79 | echo "$SRC : $DIR/$SRC.f90" |
---|
80 | echo "$DIR $SRC" >> parse_order.txt |
---|
81 | ok[$SRC]=YES |
---|
82 | AGAIN=YES |
---|
83 | else |
---|
84 | rm xml/$SRC.xml |
---|
85 | fi |
---|
86 | fi |
---|
87 | done |
---|
88 | done |
---|
89 | |
---|
90 | echo "------------------------------------" |
---|
91 | for SRC in ${!dir[@]} ; do |
---|
92 | DIR=${dir[$SRC]} |
---|
93 | YESNO=${ok[$SRC]} |
---|
94 | if [[ "$YESNO" == "NO" ]] ; then |
---|
95 | echo "Unable to parse : $SRC $DIR/$SRC.f90, check xml/$SRC.err" |
---|
96 | fi |
---|
97 | done |
---|
98 | |
---|
99 | # cleanup |
---|
100 | find xml -name '*.err' -size 0 -print0 | xargs -0 rm |
---|