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