[524] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[1492] | 3 | # $Id: create_make_gcm 1907 2013-11-26 13:10:46Z jghattas $ |
---|
[524] | 4 | # |
---|
| 5 | #set -xv |
---|
[1714] | 6 | |
---|
| 7 | rm -f create_make_gcm.log |
---|
| 8 | |
---|
[524] | 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 |
---|
[536] | 22 | X6NEC=0 |
---|
| 23 | if [ "$machine" = "mercure" ] ; then |
---|
| 24 | X6NEC=1 |
---|
| 25 | fi |
---|
[768] | 26 | X8BRODIE=0 |
---|
| 27 | if [ "$machine" = "brodie" ] ; then |
---|
| 28 | X8BRODIE=1 |
---|
| 29 | fi |
---|
[524] | 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 = $(LIBOGCM)/$(MACHINE)' |
---|
| 45 | else |
---|
| 46 | echo 'LIBO = $(GCM)/libo' |
---|
| 47 | fi |
---|
| 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' |
---|
[768] | 54 | echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' |
---|
[524] | 55 | echo 'RM=rm' |
---|
| 56 | echo |
---|
| 57 | echo "OPLINK = " |
---|
| 58 | echo |
---|
| 59 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
| 60 | echo |
---|
[1492] | 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 =' |
---|
[1666] | 70 | echo 'L_COSP = -lcosp' |
---|
[768] | 71 | |
---|
[524] | 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 |
---|
[768] | 93 | #echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) ' |
---|
| 94 | echo 'main : $(DYN) bibio phys $(OPTION_DEP) ' |
---|
[524] | 95 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
| 96 | echo ' cd $(LOCAL_DIR); \' |
---|
[1403] | 97 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
[1692] | 98 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_COSP) $(L_PHY) $(L_DYN) $(L_BIBIO) $(L_DYN) $(L_FILTRE) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
[524] | 99 | echo |
---|
[768] | 100 | echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d' |
---|
[524] | 101 | echo |
---|
| 102 | echo 'phys : $(LIBPHY)' |
---|
| 103 | echo |
---|
[768] | 104 | #echo 'chimie : $(LIBO)/libchimie.a' |
---|
| 105 | echo |
---|
[524] | 106 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
| 107 | echo |
---|
| 108 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
| 109 | echo |
---|
[1666] | 110 | echo 'cosp : $(LIBO)/libcosp.a' |
---|
[1279] | 111 | echo |
---|
[524] | 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 |
---|
[1714] | 124 | |
---|
| 125 | for diri in ` ls ` ; do |
---|
| 126 | |
---|
[524] | 127 | if [ -d $diri ] ; then |
---|
[1714] | 128 | if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.F90 $diri/*/*.F90`" != "" ] ; then |
---|
| 129 | # cd $diri >/dev/null 2>&1 |
---|
[524] | 130 | echo |
---|
| 131 | listlib="" |
---|
[1714] | 132 | # Liste des fichiers .F et .F90 n'etant pas des programmes principaux |
---|
| 133 | for fili in `ls $diri/*.F $diri/*/*.F` ; do |
---|
| 134 | test=` ( head $fili | grep ' PROGRAM' ) ` |
---|
| 135 | if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi |
---|
[524] | 136 | done |
---|
[1714] | 137 | for fili in `ls $diri/*.F90 $diri/*/*.F90` ; do |
---|
| 138 | test=` ( head $fili | grep 'PROGRAM' ) ` |
---|
| 139 | if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi |
---|
[524] | 140 | done |
---|
| 141 | echo |
---|
[1714] | 142 | echo $listlib >> create_makeg_gcm.log |
---|
[524] | 143 | echo |
---|
[1714] | 144 | echo "#==================================================================" |
---|
[524] | 145 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
[1714] | 146 | echo "#==================================================================" |
---|
[524] | 147 | echo |
---|
[1714] | 148 | for trufile in $listlib ; do |
---|
| 149 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[524] | 150 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 151 | echo |
---|
| 152 | done |
---|
| 153 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 154 | echo |
---|
| 155 | echo |
---|
| 156 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
| 157 | echo |
---|
[1714] | 158 | for trufile in $listlib ; do |
---|
| 159 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[524] | 160 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 161 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[536] | 162 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[1714] | 163 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile |
---|
| 164 | [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
[1112] | 165 | |
---|
[1714] | 166 | ########################################################################## |
---|
| 167 | # TRAITEMENT DES DEPENDANCES |
---|
[1112] | 168 | # Differents cas de dependance correspondant a des include ou des |
---|
| 169 | # use module. |
---|
| 170 | # soit dans le repertoire local soit dans un autre. |
---|
[1714] | 171 | # Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN |
---|
| 172 | # ou quelque chose du genre. |
---|
| 173 | ########################################################################## |
---|
[1112] | 174 | |
---|
[1714] | 175 | 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 } ' ) ` ; do |
---|
| 176 | echo $trufile $fili $stri >> create_make_gcm.log |
---|
| 177 | strj=`echo $stri | tr [A-Z] [a-z]` |
---|
| 178 | str2="" |
---|
[1810] | 179 | for dirinc in filtrez bibio grid dyn3d phydev $diri $diri/*/ ; do |
---|
[1714] | 180 | # Recherche dans l'ordre hierarchique inverse car seule la derniere |
---|
| 181 | # ligne est conservee |
---|
[1810] | 182 | if [ $dirinc = phydev ] ; then |
---|
| 183 | dirstr='$(PHYS)' |
---|
| 184 | libstr='phy$(PHYS)' |
---|
| 185 | else |
---|
| 186 | dirstr=$dirinc |
---|
| 187 | libstr=$dirinc |
---|
| 188 | fi |
---|
[1714] | 189 | if [ -f $dirinc/$stri ] ; then |
---|
[1810] | 190 | str2='$(LIBF)/'$dirstr/$stri |
---|
[1714] | 191 | elif [ -f $dirinc/$strj ] ; then |
---|
[1810] | 192 | str2='$(LIBF)/'$dirstr/$stri |
---|
[1714] | 193 | elif [ -f $dirinc/$strj.F90 ] || [ -f $dirinc/$strj.F ] ; then |
---|
[1810] | 194 | strlib=`echo $libstr | awk -F/ ' { print $1 } '` |
---|
[1714] | 195 | str2='$(LIBO)/lib'$strlib'.a('$strj'.o)' |
---|
[1865] | 196 | elif [ -f $dirinc/$stri.F90 ] || [ -f $dirinc/$stri.F ] ; then |
---|
| 197 | strlib=`echo $libstr | awk -F/ ' { print $1 } '` |
---|
| 198 | str2='$(LIBO)/lib'$strlib'.a('$stri'.o)' |
---|
[1714] | 199 | fi |
---|
| 200 | done |
---|
| 201 | if [ "$str2" = "" ] ; then |
---|
| 202 | echo Warn: Include $diri $trufile $fili $stri pas trouve >> $gcm/create_make_gcm.log |
---|
| 203 | elif [ "$str2" = "$str1" ] ; then |
---|
| 204 | echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $gcm/create_make_gcm.log |
---|
| 205 | else |
---|
[524] | 206 | echo $str1 \\ |
---|
[1714] | 207 | str1=$str2 |
---|
[524] | 208 | fi |
---|
[1714] | 209 | done # Fin de la boucle sur les dependances et ecriture de la derniere |
---|
[524] | 210 | echo $str1 |
---|
[1492] | 211 | # Compile in LIBO directory; and before compiling, remove |
---|
| 212 | # object from library |
---|
| 213 | echo ' cd $(LIBO); \' |
---|
| 214 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
[768] | 215 | if [ "$F90" -eq '0' ] ; then |
---|
[1492] | 216 | ## Fixed Form Fortran 77 |
---|
[1714] | 217 | echo ' $(COMPILE) $(LIBF)/'$trufile' ; \' |
---|
[524] | 218 | else |
---|
[1492] | 219 | ## Fortran 90 |
---|
[1714] | 220 | if [ `echo $trufile | cut -d. -f2` = F90 ] ; then |
---|
[1492] | 221 | ## Free Form |
---|
[1714] | 222 | echo ' $(COMPTRU90) $(LIBF)/'$trufile' ; \' |
---|
[524] | 223 | else |
---|
[1714] | 224 | echo ' $(COMPILE90) $(LIBF)/'$trufile' ; \' |
---|
[524] | 225 | fi |
---|
| 226 | fi |
---|
[1492] | 227 | # Put generated object in library |
---|
[524] | 228 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 229 | echo |
---|
| 230 | done |
---|
| 231 | # |
---|
| 232 | echo |
---|
| 233 | cd $libf |
---|
| 234 | fi |
---|
| 235 | fi |
---|
| 236 | done |
---|