[1] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[66] | 3 | # $Id: create_make_gcm 1461 2010-12-03 11:12:25Z emillour $ |
---|
[1] | 4 | # |
---|
| 5 | #set -xv |
---|
[979] | 6 | |
---|
| 7 | rm -f create_make_gcm.log |
---|
| 8 | |
---|
[1] | 9 | machine=`hostname` |
---|
| 10 | os=`uname` |
---|
| 11 | gcm=`pwd` |
---|
| 12 | libf=$gcm/libf |
---|
| 13 | libo=$gcm/libo |
---|
| 14 | CRAY=0 |
---|
| 15 | if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then |
---|
| 16 | CRAY=1 |
---|
| 17 | fi |
---|
| 18 | XNEC=0 |
---|
| 19 | if [ "$machine" = "rhodes" ] ; then |
---|
| 20 | XNEC=1 |
---|
| 21 | fi |
---|
| 22 | X6NEC=0 |
---|
| 23 | if [ "$machine" = "mercure" ] ; then |
---|
| 24 | X6NEC=1 |
---|
| 25 | fi |
---|
| 26 | X8BRODIE=0 |
---|
| 27 | if [ "$machine" = "brodie" ] ; then |
---|
| 28 | X8BRODIE=1 |
---|
| 29 | fi |
---|
| 30 | VPP=0 |
---|
| 31 | if [ "$machine" = "nymphea0" ] ; then |
---|
| 32 | VPP=1 |
---|
| 33 | fi |
---|
| 34 | # |
---|
| 35 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 36 | echo "# Definitions de Macros pour Make" |
---|
| 37 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 38 | echo |
---|
| 39 | echo "# Repertoires :" |
---|
| 40 | echo |
---|
| 41 | echo "GCM = "$gcm |
---|
| 42 | echo 'LIBF = $(GCM)/libf' |
---|
| 43 | if [ "$CRAY" = '0' ] ; then |
---|
| 44 | # echo 'LIBO = $(GCM)/libo/$(MACHINE)' |
---|
| 45 | echo 'LIBO = $(LIBOGCM)/$(MACHINE)' |
---|
| 46 | else |
---|
| 47 | echo 'LIBO = $(GCM)/libo' |
---|
| 48 | fi |
---|
| 49 | #echo 'LOCAL_DIR=$(GCM)' |
---|
| 50 | #echo $localdir |
---|
| 51 | echo "LOCAL_DIR=`echo $localdir`" |
---|
| 52 | echo 'BIBIO = $(LIBF)/bibio' |
---|
| 53 | echo "FILTRE = filtre" |
---|
| 54 | echo "PHYS = " |
---|
| 55 | echo "DYN = dyn " |
---|
| 56 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
| 57 | echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' |
---|
| 58 | echo 'RM=rm' |
---|
| 59 | echo |
---|
| 60 | echo "OPLINK = " |
---|
| 61 | echo |
---|
| 62 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
| 63 | echo |
---|
[66] | 64 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
| 65 | echo 'dyn3dpar = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a' |
---|
| 66 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
| 67 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
| 68 | echo 'L_DYN = -ldyn$(DIM)d$(FLAG_PARA)' |
---|
| 69 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
| 70 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
| 71 | echo 'L_BIBIO = -lbibio' |
---|
| 72 | echo 'L_ADJNT =' |
---|
| 73 | echo 'L_COSP = -lcosp' |
---|
[1] | 74 | |
---|
| 75 | echo |
---|
| 76 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 77 | echo "# Option de compilation FORTRAN" |
---|
| 78 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 79 | echo |
---|
| 80 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
| 81 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
| 82 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
| 83 | echo "LINK = $LINK" |
---|
| 84 | echo "AR = $AR" |
---|
| 85 | echo |
---|
| 86 | echo |
---|
[104] | 87 | echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
---|
| 88 | echo '# Option de compilation C' |
---|
| 89 | echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' |
---|
| 90 | echo |
---|
| 91 | echo 'COMPILEC = $(CCC) $(OPTIMC) $(INCLUDEC) -c' |
---|
| 92 | echo |
---|
| 93 | echo |
---|
[1] | 94 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 95 | echo "# Creation des differents executables" |
---|
| 96 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 97 | echo |
---|
| 98 | echo "# Executables:" |
---|
| 99 | echo "# ------------" |
---|
| 100 | echo |
---|
| 101 | echo "PROG = code" |
---|
| 102 | echo |
---|
| 103 | #echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) ' |
---|
[814] | 104 | echo 'main : bibio $(DYN) phys $(OPTION_DEP) ' |
---|
[1] | 105 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
| 106 | echo ' cd $(LOCAL_DIR); \' |
---|
| 107 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
| 108 | 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 ' |
---|
| 109 | echo |
---|
| 110 | echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d' |
---|
| 111 | echo |
---|
| 112 | echo 'phys : $(LIBPHY)' |
---|
| 113 | echo |
---|
| 114 | #echo 'chimie : $(LIBO)/libchimie.a' |
---|
| 115 | echo |
---|
| 116 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
| 117 | echo |
---|
| 118 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
| 119 | echo |
---|
| 120 | echo 'cosp : $(LIBO)/libcosp.a' |
---|
| 121 | echo |
---|
[104] | 122 | echo 'chimtitan : $(LIBO)/libchimtitan.a' |
---|
| 123 | echo |
---|
[1] | 124 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
| 125 | echo |
---|
| 126 | echo '$(FILTRE)2d :' |
---|
| 127 | echo |
---|
| 128 | echo '$(FILTRE)1d :' |
---|
| 129 | echo |
---|
| 130 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 131 | echo "# Contenu des differentes bibliotheques" |
---|
| 132 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 133 | echo |
---|
| 134 | echo |
---|
| 135 | cd $libf >/dev/null 2>&1 |
---|
| 136 | for diri in ` ls ` |
---|
| 137 | do |
---|
| 138 | if [ -d $diri ] ; then |
---|
[979] | 139 | if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.F90 $diri/*/*.F90`" != "" ] ; then |
---|
| 140 | # cd $diri >/dev/null 2>&1 |
---|
[1] | 141 | echo |
---|
| 142 | listlib="" |
---|
[979] | 143 | # Liste des fichiers .F et .F90 n'etant pas des programmes principaux |
---|
| 144 | for fili in `ls $diri/*.F $diri/*/*.F` |
---|
[1] | 145 | do |
---|
[634] | 146 | # Check if file is a routine or main program |
---|
| 147 | # i.e: look for the "program" keword preceeded by leading spaces |
---|
[979] | 148 | test=` ( head $fili | grep -i '^ *program' ) ` |
---|
[1] | 149 | if [ "$test" = "" ] ; then |
---|
[634] | 150 | # if it is not a main program, add it to the list |
---|
[1] | 151 | listlib=$listlib" "$fili |
---|
| 152 | fi |
---|
| 153 | done |
---|
[979] | 154 | for fili in `ls $diri/*.F90 $diri/*/*.F90` |
---|
[1] | 155 | do |
---|
[634] | 156 | # Check if file is a routine or main program |
---|
| 157 | # i.e. look for "program" keyword (with possibly some leading spaces) |
---|
[979] | 158 | test=` ( head $fili | grep -i '^ \{0,\}program' ) ` |
---|
[1] | 159 | if [ "$test" = "" ] ; then |
---|
[634] | 160 | # if it is not a main program, add it to the list |
---|
[1] | 161 | listlib=$listlib" "$fili |
---|
| 162 | fi |
---|
| 163 | done |
---|
| 164 | # |
---|
| 165 | echo |
---|
[979] | 166 | echo $listlib >> create_make_gcm.log |
---|
[1] | 167 | echo |
---|
| 168 | echo "#=======================================================================" |
---|
| 169 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
| 170 | echo "#=======================================================================" |
---|
| 171 | echo |
---|
[979] | 172 | for trufile in $listlib |
---|
[1] | 173 | do |
---|
[979] | 174 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[1] | 175 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 176 | echo |
---|
| 177 | done |
---|
| 178 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 179 | echo |
---|
| 180 | echo |
---|
| 181 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
| 182 | echo |
---|
[979] | 183 | for trufile in $listlib |
---|
[1] | 184 | do |
---|
[979] | 185 | # if [ -f $fili.F90 ] ; then |
---|
| 186 | # trufile=$fili.F90 |
---|
| 187 | # else |
---|
| 188 | # trufile=$fili.F |
---|
| 189 | # fi |
---|
| 190 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[1] | 191 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 192 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 193 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[979] | 194 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile |
---|
[1] | 195 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
| 196 | |
---|
[979] | 197 | ########################################################################## |
---|
| 198 | # TRAITEMENT DES DEPENDANCES |
---|
[1] | 199 | # Differents cas de dependance correspondant a des include ou des |
---|
| 200 | # use module. |
---|
| 201 | # soit dans le repertoire local soit dans un autre. |
---|
[979] | 202 | # Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN |
---|
| 203 | # ou quelque chose du genre. |
---|
| 204 | ########################################################################## |
---|
[1] | 205 | |
---|
[979] | 206 | for stri in ` ( sed -e '/^[cC\!]/d' $trufile | sed -n "/\#include/s/\#include//p" | sed 's/\"//g' ; sed -e '/^[cC\!]/d' $trufile | egrep -i '^ *use ' | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` |
---|
| 207 | do |
---|
| 208 | echo $trufile $fili $stri >> create_make_gcm.log |
---|
| 209 | strj=`echo $stri | tr [A-Z] [a-z]` |
---|
| 210 | str2="" |
---|
| 211 | for dirinc in filtrez bibio grid dyn3d $diri $diri/*/ ; do |
---|
| 212 | # Recherche dans l'ordre hierarchique inverse car seule la derniere |
---|
| 213 | # ligne est conservee |
---|
| 214 | if [ -f $dirinc/$stri ] ; then |
---|
| 215 | str2='$(LIBF)/'$dirinc/$stri |
---|
| 216 | elif [ -f $dirinc/$strj ] ; then |
---|
| 217 | str2='$(LIBF)/'$dirinc/$stri |
---|
| 218 | elif [ -f $dirinc/$strj.F90 ] || [ -f $dirinc/$strj.F ] ; then |
---|
| 219 | strlib=`echo $dirinc | awk -F/ ' { print $1 } '` |
---|
| 220 | str2='$(LIBO)/lib'$strlib'.a('$strj'.o)' |
---|
| 221 | fi |
---|
| 222 | done |
---|
| 223 | if [ "$str2" = "" ] ; then |
---|
| 224 | echo Warn: Include $diri $trufile $fili $stri pas trouve >> $gcm/create_make_gcm.log |
---|
| 225 | elif [ "$str2" = "$str1" ] ; then |
---|
| 226 | echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $gcm/create_make_gcm.log |
---|
| 227 | else |
---|
[1] | 228 | echo $str1 \\ |
---|
[979] | 229 | str1=$str2 |
---|
[1] | 230 | fi |
---|
[979] | 231 | done # Fin de la boucle sur les dependances et ecriture de la derniere |
---|
[1] | 232 | echo $str1 |
---|
[66] | 233 | # Compile in LIBO directory; and before compiling, remove |
---|
| 234 | # object from library |
---|
| 235 | echo ' cd $(LIBO); \' |
---|
| 236 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
[1] | 237 | if [ "$F90" -eq '0' ] ; then |
---|
[66] | 238 | ## Fixed Form Fortran 77 |
---|
[979] | 239 | echo ' $(COMPILE) $(LIBF)/'$trufile' ; \' |
---|
[1] | 240 | else |
---|
[66] | 241 | ## Fortran 90 |
---|
[1] | 242 | if [ -f $fili.F90 ] ; then |
---|
[66] | 243 | ## Free Form |
---|
[979] | 244 | echo ' $(COMPTRU90) $(LIBF)/'$trufile' ; \' |
---|
[1] | 245 | else |
---|
[979] | 246 | echo ' $(COMPILE90) $(LIBF)/'$trufile' ; \' |
---|
[1] | 247 | fi |
---|
| 248 | fi |
---|
[66] | 249 | # Put generated object in library |
---|
[1] | 250 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 251 | echo ' cd $(GCM)' |
---|
| 252 | echo |
---|
| 253 | done |
---|
| 254 | # |
---|
| 255 | echo |
---|
[104] | 256 | cd $libf |
---|
| 257 | ############################## |
---|
| 258 | ## CAS DES FICHIERS EN C |
---|
| 259 | ###### |
---|
| 260 | elif [ "`ls $diri/*.c`" != "" ] ; then |
---|
| 261 | cd $diri >/dev/null 2>&1 |
---|
| 262 | echo |
---|
| 263 | listlib="" |
---|
| 264 | for i in `ls *.c` |
---|
| 265 | do |
---|
| 266 | fili=`basename $i .c` |
---|
[634] | 267 | # Check if file is a function or main program |
---|
| 268 | # i.e. look for "int main" keywords (with possibly some leading spaces) |
---|
| 269 | test=` ( head $i | grep '^ \{0,\}int main' ) ` |
---|
[104] | 270 | if [ "$test" = "" ] ; then |
---|
[634] | 271 | # if it is not a main program, add it to the list |
---|
[104] | 272 | listlib=$listlib" "$fili |
---|
| 273 | fi |
---|
| 274 | done |
---|
| 275 | # |
---|
| 276 | echo |
---|
| 277 | echo |
---|
| 278 | echo '#=======================================================================' |
---|
| 279 | echo '# Contenu de la bibliotheque correspondant au Directory '$diri |
---|
| 280 | echo '#=======================================================================' |
---|
| 281 | echo |
---|
| 282 | for fili in $listlib |
---|
| 283 | do |
---|
| 284 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 285 | echo |
---|
| 286 | done |
---|
| 287 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 288 | echo |
---|
| 289 | echo |
---|
| 290 | echo '# Compilation des membres de la bibliotheque lib'$diri'.a' |
---|
| 291 | echo |
---|
| 292 | for fili in $listlib |
---|
| 293 | do |
---|
| 294 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$fili.c |
---|
| 295 | for stri in ` ( sed -n "/\#include/s/\#include//p" $fili.c | sed 's/\"//g' ) ` |
---|
| 296 | do |
---|
| 297 | if [ -f $stri ] ; then |
---|
| 298 | echo $str1 \\ |
---|
| 299 | str1='$(LIBF)/'$diri'/'$stri |
---|
| 300 | else |
---|
| 301 | for dirinc in dyn3d grid bibio |
---|
| 302 | do |
---|
| 303 | if [ -f ../$dirinc/$stri ] ; then |
---|
| 304 | echo $str1 \\ |
---|
| 305 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
| 306 | fi |
---|
| 307 | done |
---|
| 308 | fi |
---|
| 309 | done |
---|
| 310 | echo $str1 |
---|
| 311 | # Compile in LIBO directory; and before compiling, remove |
---|
| 312 | # object from library |
---|
| 313 | echo ' cd $(LIBO); \' |
---|
| 314 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
| 315 | ## C |
---|
| 316 | echo ' $(COMPILEC) $(LIBF)/'$diri'/'$fili'.c; \' |
---|
| 317 | # Put generated object in library |
---|
| 318 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 319 | echo ' cd $(GCM)' |
---|
| 320 | echo |
---|
| 321 | done |
---|
| 322 | # |
---|
| 323 | echo |
---|
| 324 | cd $libf |
---|
| 325 | ############################## |
---|
[1] | 326 | fi |
---|
| 327 | fi |
---|
| 328 | done |
---|