1 | #!/bin/sh |
---|
2 | #set -xv |
---|
3 | machine=`hostname` |
---|
4 | os=`uname` |
---|
5 | gcm=`pwd` |
---|
6 | libf=$gcm/libf |
---|
7 | libo=$gcm/libo |
---|
8 | CRAY=0 |
---|
9 | if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then |
---|
10 | CRAY=1 |
---|
11 | fi |
---|
12 | XNEC=0 |
---|
13 | if [ "$machine" = "rhodes" ] ; then |
---|
14 | XNEC=1 |
---|
15 | fi |
---|
16 | VPP=0 |
---|
17 | if [ "$machine" = "nymphea0" ] ; then |
---|
18 | VPP=1 |
---|
19 | fi |
---|
20 | # |
---|
21 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
22 | echo "# Definitions de Macros pour Make" |
---|
23 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
24 | echo |
---|
25 | echo "# Repertoires :" |
---|
26 | echo |
---|
27 | echo "GCM = "$gcm |
---|
28 | if [ "$CRAY" = '0' ] ; then |
---|
29 | echo "MACHINE = sun4" |
---|
30 | fi |
---|
31 | echo 'LIBF = $(GCM)/libf' |
---|
32 | if [ "$CRAY" = '0' ] ; then |
---|
33 | # echo 'LIBO = $(GCM)/libo/$(MACHINE)' |
---|
34 | echo 'LIBO = $(LIBOGCM)/$(MACHINE)' |
---|
35 | else |
---|
36 | echo 'LIBO = $(GCM)/libo' |
---|
37 | fi |
---|
38 | #echo 'LOCAL_DIR=$(GCM)' |
---|
39 | #echo $localdir |
---|
40 | echo "LOCAL_DIR=`echo $localdir`" |
---|
41 | echo 'BIBIO = $(LIBF)/bibio' |
---|
42 | echo 'AERONOMARS = $(LIBF)/aeronomars' |
---|
43 | echo "FILTRE = filtre" |
---|
44 | echo "PHYS = " |
---|
45 | echo "DYN = dyn " |
---|
46 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
47 | echo 'DIRMAIN=dyn$(DIM)d' |
---|
48 | echo 'RM=rm' |
---|
49 | echo |
---|
50 | echo "OPLINK = " |
---|
51 | echo |
---|
52 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
53 | echo |
---|
54 | if [ "$XNEC" = '1' ] ; then |
---|
55 | echo 'dyn3d = $(LIBO)/libsxdyn3d.a $(LIBO)/libsx$(FILTRE).a' |
---|
56 | echo 'dyn2d = $(LIBO)/libsxdyn2d.a' |
---|
57 | echo 'dyn1d = $(LIBO)/libsxdyn1d.a' |
---|
58 | echo 'L_DYN = -lsxdyn$(DIM)d' |
---|
59 | echo 'L_FILTRE = -lsx$(FILTRE)' |
---|
60 | echo 'L_PHY = -lsxphy$(PHYS) ' |
---|
61 | echo 'L_BIBIO = -lsxbibio' |
---|
62 | echo 'L_AERONOMARS = -lsxaeronomars' |
---|
63 | echo 'L_ADJNT =' |
---|
64 | else |
---|
65 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
66 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
67 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
68 | echo 'L_DYN = -ldyn$(DIM)d' |
---|
69 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
70 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
71 | echo 'L_BIBIO = -lbibio' |
---|
72 | echo 'L_AERONOMARS = -laeronomars' |
---|
73 | echo 'L_ADJNT =' |
---|
74 | fi |
---|
75 | echo |
---|
76 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
77 | echo "# Option de compilation FORTRAN" |
---|
78 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
79 | echo |
---|
80 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
81 | echo "LINK = $LINK" |
---|
82 | echo "AR = $AR" |
---|
83 | echo |
---|
84 | echo |
---|
85 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
86 | echo "# Creation des differents executables" |
---|
87 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
88 | echo |
---|
89 | echo "# Executables:" |
---|
90 | echo "# ------------" |
---|
91 | echo |
---|
92 | echo "PROG = code" |
---|
93 | echo |
---|
94 | echo 'main : $(DYN) bibio phys aeronomars $(OPTION_DEP) ' |
---|
95 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
96 | echo ' cd $(LOCAL_DIR); \' |
---|
97 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(PROG).F -o $(PROG).o ; \' |
---|
98 | if [ "$CRAY" = '0' ] ; then |
---|
99 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_AERONOMARS) $(L_PHY) $(L_BIBIO) $(L_DYN) $(L_AERONOMARS) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
100 | else |
---|
101 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_AERONOMARS) $(L_PHY) $(L_BIBIO) $(L_DYN) $(L_AERONOMARS) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
102 | fi |
---|
103 | echo |
---|
104 | echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
105 | echo |
---|
106 | echo 'phys : $(LIBPHY)' |
---|
107 | echo |
---|
108 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
109 | echo |
---|
110 | echo 'aeronomars : $(LIBO)/libaeronomars.a' |
---|
111 | echo |
---|
112 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
113 | echo |
---|
114 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
115 | echo |
---|
116 | echo '$(FILTRE)2d :' |
---|
117 | echo |
---|
118 | echo '$(FILTRE)1d :' |
---|
119 | echo |
---|
120 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
121 | echo "# Contenu des differentes bibliotheques" |
---|
122 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
123 | echo |
---|
124 | echo |
---|
125 | cd $libf >/dev/null 2>&1 |
---|
126 | for diri in ` ls ` |
---|
127 | do |
---|
128 | if [ -d $diri ] ; then |
---|
129 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
130 | cd $diri >/dev/null 2>&1 |
---|
131 | echo |
---|
132 | listlib="" |
---|
133 | for i in `ls *.F` |
---|
134 | do |
---|
135 | fili=`basename $i .F` |
---|
136 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
137 | if [ "$test" = "" ] ; then |
---|
138 | listlib=$listlib" "$fili |
---|
139 | fi |
---|
140 | done |
---|
141 | for i in `ls *.F90` |
---|
142 | do |
---|
143 | fili=`basename $i .F90` |
---|
144 | test=` ( head $i | grep ' PROGRAM' ) ` |
---|
145 | if [ "$test" = "" ] ; then |
---|
146 | listlib=$listlib" "$fili |
---|
147 | fi |
---|
148 | done |
---|
149 | # |
---|
150 | echo |
---|
151 | echo |
---|
152 | echo "#=======================================================================" |
---|
153 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
154 | echo "#=======================================================================" |
---|
155 | echo |
---|
156 | for fili in $listlib |
---|
157 | do |
---|
158 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
159 | echo |
---|
160 | done |
---|
161 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
162 | echo |
---|
163 | echo |
---|
164 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
165 | echo |
---|
166 | for fili in $listlib |
---|
167 | do |
---|
168 | if [ -f $fili.F90 ] ; then |
---|
169 | trufile=$fili.F90 |
---|
170 | else |
---|
171 | trufile=$fili.F |
---|
172 | fi |
---|
173 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
174 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
175 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
176 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
177 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | awk ' { print $2 } ' ) ` |
---|
178 | do |
---|
179 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
180 | if [ -f $stri ] ; then |
---|
181 | echo $str1 \\ |
---|
182 | str1='$(LIBF)/'$diri'/'$stri |
---|
183 | else |
---|
184 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
185 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
186 | else |
---|
187 | for dirinc in dyn3d grid bibio aeronomars phymars |
---|
188 | do |
---|
189 | if [ -f ../$dirinc/$stri ] ; then |
---|
190 | echo $str1 \\ |
---|
191 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
192 | fi |
---|
193 | done |
---|
194 | fi |
---|
195 | fi |
---|
196 | done |
---|
197 | echo $str1 |
---|
198 | echo ' cd $(LOCAL_DIR); \' |
---|
199 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
200 | MODU=0; egrep -i ' *module ' $trufile> /dev/null 2>&1 && MODU=1 |
---|
201 | if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then |
---|
202 | if [ "$os" = 'UNIX_System_V' ] ; then |
---|
203 | echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \' |
---|
204 | else |
---|
205 | echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \' |
---|
206 | fi |
---|
207 | fi |
---|
208 | if [ "$XNEC" -eq '1' ] ; then |
---|
209 | echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \' |
---|
210 | fi |
---|
211 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
212 | echo ' cd $(GCM)' |
---|
213 | echo |
---|
214 | done |
---|
215 | # |
---|
216 | echo |
---|
217 | cd $libf |
---|
218 | fi |
---|
219 | fi |
---|
220 | done |
---|