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