[524] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[1492] | 3 | # $Id: create_make_gcm 1962 2014-02-08 00:38:55Z fhourdin $ |
---|
[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' |
---|
[1944] | 50 | echo 'DYN3D_COMMON = $(LIBF)/dyn3d_common' |
---|
[524] | 51 | echo "FILTRE = filtre" |
---|
| 52 | echo "PHYS = " |
---|
| 53 | echo "DYN = dyn " |
---|
| 54 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
[768] | 55 | echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' |
---|
[524] | 56 | echo 'RM=rm' |
---|
| 57 | echo |
---|
| 58 | echo "OPLINK = " |
---|
| 59 | echo |
---|
| 60 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
| 61 | echo |
---|
[1492] | 62 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
| 63 | echo 'dyn3dpar = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a' |
---|
| 64 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
| 65 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
| 66 | echo 'L_DYN = -ldyn$(DIM)d$(FLAG_PARA)' |
---|
| 67 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
| 68 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
| 69 | echo 'L_BIBIO = -lbibio' |
---|
[1944] | 70 | echo 'L_DYN3D_COMMON = -ldyn3d_common' |
---|
[1492] | 71 | echo 'L_ADJNT =' |
---|
[1666] | 72 | echo 'L_COSP = -lcosp' |
---|
[768] | 73 | |
---|
[524] | 74 | echo |
---|
| 75 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 76 | echo "# Option de compilation FORTRAN" |
---|
| 77 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 78 | echo |
---|
| 79 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
| 80 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
| 81 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
| 82 | echo "LINK = $LINK" |
---|
| 83 | echo "AR = $AR" |
---|
| 84 | echo |
---|
| 85 | echo |
---|
| 86 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 87 | echo "# Creation des differents executables" |
---|
| 88 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 89 | echo |
---|
| 90 | echo "# Executables:" |
---|
| 91 | echo "# ------------" |
---|
| 92 | echo |
---|
| 93 | echo "PROG = code" |
---|
| 94 | echo |
---|
[768] | 95 | #echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) ' |
---|
[1944] | 96 | echo 'main : $(DYN) bibio dyn3d_common phys $(OPTION_DEP) ' |
---|
[524] | 97 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
| 98 | echo ' cd $(LOCAL_DIR); \' |
---|
[1403] | 99 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
[1954] | 100 | 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 ' |
---|
[524] | 101 | echo |
---|
[768] | 102 | echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d' |
---|
[524] | 103 | echo |
---|
| 104 | echo 'phys : $(LIBPHY)' |
---|
| 105 | echo |
---|
[768] | 106 | #echo 'chimie : $(LIBO)/libchimie.a' |
---|
| 107 | echo |
---|
[524] | 108 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
| 109 | echo |
---|
[1944] | 110 | echo 'dyn3d_common : $(LIBO)/libdyn3d_common.a' |
---|
| 111 | echo |
---|
[524] | 112 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
| 113 | echo |
---|
[1666] | 114 | echo 'cosp : $(LIBO)/libcosp.a' |
---|
[1279] | 115 | echo |
---|
[524] | 116 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
| 117 | echo |
---|
| 118 | echo '$(FILTRE)2d :' |
---|
| 119 | echo |
---|
| 120 | echo '$(FILTRE)1d :' |
---|
| 121 | echo |
---|
| 122 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 123 | echo "# Contenu des differentes bibliotheques" |
---|
| 124 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 125 | echo |
---|
| 126 | echo |
---|
| 127 | cd $libf >/dev/null 2>&1 |
---|
[1714] | 128 | |
---|
| 129 | for diri in ` ls ` ; do |
---|
| 130 | |
---|
[524] | 131 | if [ -d $diri ] ; then |
---|
[1714] | 132 | if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.F90 $diri/*/*.F90`" != "" ] ; then |
---|
| 133 | # cd $diri >/dev/null 2>&1 |
---|
[524] | 134 | echo |
---|
| 135 | listlib="" |
---|
[1714] | 136 | # Liste des fichiers .F et .F90 n'etant pas des programmes principaux |
---|
| 137 | for fili in `ls $diri/*.F $diri/*/*.F` ; do |
---|
| 138 | test=` ( head $fili | grep ' PROGRAM' ) ` |
---|
| 139 | if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi |
---|
[524] | 140 | done |
---|
[1714] | 141 | for fili in `ls $diri/*.F90 $diri/*/*.F90` ; do |
---|
| 142 | test=` ( head $fili | grep 'PROGRAM' ) ` |
---|
| 143 | if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi |
---|
[524] | 144 | done |
---|
| 145 | echo |
---|
[1714] | 146 | echo $listlib >> create_makeg_gcm.log |
---|
[524] | 147 | echo |
---|
[1714] | 148 | echo "#==================================================================" |
---|
[524] | 149 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
[1714] | 150 | echo "#==================================================================" |
---|
[524] | 151 | echo |
---|
[1714] | 152 | for trufile in $listlib ; do |
---|
| 153 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[524] | 154 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 155 | echo |
---|
| 156 | done |
---|
| 157 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 158 | echo |
---|
| 159 | echo |
---|
| 160 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
| 161 | echo |
---|
[1714] | 162 | for trufile in $listlib ; do |
---|
| 163 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[524] | 164 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 165 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[536] | 166 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[1714] | 167 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile |
---|
| 168 | [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
[1112] | 169 | |
---|
[1714] | 170 | ########################################################################## |
---|
| 171 | # TRAITEMENT DES DEPENDANCES |
---|
[1112] | 172 | # Differents cas de dependance correspondant a des include ou des |
---|
| 173 | # use module. |
---|
| 174 | # soit dans le repertoire local soit dans un autre. |
---|
[1714] | 175 | # Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN |
---|
| 176 | # ou quelque chose du genre. |
---|
| 177 | ########################################################################## |
---|
[1112] | 178 | |
---|
[1962] | 179 | 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 |
---|
[1714] | 180 | echo $trufile $fili $stri >> create_make_gcm.log |
---|
| 181 | strj=`echo $stri | tr [A-Z] [a-z]` |
---|
| 182 | str2="" |
---|
[1944] | 183 | for dirinc in filtrez bibio dyn3d_common grid dyn3d phydev $diri $diri/*/ ; do |
---|
[1714] | 184 | # Recherche dans l'ordre hierarchique inverse car seule la derniere |
---|
| 185 | # ligne est conservee |
---|
[1810] | 186 | if [ $dirinc = phydev ] ; then |
---|
| 187 | dirstr='$(PHYS)' |
---|
| 188 | libstr='phy$(PHYS)' |
---|
| 189 | else |
---|
| 190 | dirstr=$dirinc |
---|
| 191 | libstr=$dirinc |
---|
| 192 | fi |
---|
[1714] | 193 | if [ -f $dirinc/$stri ] ; then |
---|
[1810] | 194 | str2='$(LIBF)/'$dirstr/$stri |
---|
[1714] | 195 | elif [ -f $dirinc/$strj ] ; then |
---|
[1810] | 196 | str2='$(LIBF)/'$dirstr/$stri |
---|
[1714] | 197 | elif [ -f $dirinc/$strj.F90 ] || [ -f $dirinc/$strj.F ] ; then |
---|
[1810] | 198 | strlib=`echo $libstr | awk -F/ ' { print $1 } '` |
---|
[1714] | 199 | str2='$(LIBO)/lib'$strlib'.a('$strj'.o)' |
---|
[1865] | 200 | elif [ -f $dirinc/$stri.F90 ] || [ -f $dirinc/$stri.F ] ; then |
---|
| 201 | strlib=`echo $libstr | awk -F/ ' { print $1 } '` |
---|
| 202 | str2='$(LIBO)/lib'$strlib'.a('$stri'.o)' |
---|
[1714] | 203 | fi |
---|
| 204 | done |
---|
| 205 | if [ "$str2" = "" ] ; then |
---|
| 206 | echo Warn: Include $diri $trufile $fili $stri pas trouve >> $gcm/create_make_gcm.log |
---|
| 207 | elif [ "$str2" = "$str1" ] ; then |
---|
| 208 | echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $gcm/create_make_gcm.log |
---|
| 209 | else |
---|
[524] | 210 | echo $str1 \\ |
---|
[1714] | 211 | str1=$str2 |
---|
[524] | 212 | fi |
---|
[1714] | 213 | done # Fin de la boucle sur les dependances et ecriture de la derniere |
---|
[524] | 214 | echo $str1 |
---|
[1492] | 215 | # Compile in LIBO directory; and before compiling, remove |
---|
| 216 | # object from library |
---|
| 217 | echo ' cd $(LIBO); \' |
---|
| 218 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
[768] | 219 | if [ "$F90" -eq '0' ] ; then |
---|
[1492] | 220 | ## Fixed Form Fortran 77 |
---|
[1714] | 221 | echo ' $(COMPILE) $(LIBF)/'$trufile' ; \' |
---|
[524] | 222 | else |
---|
[1492] | 223 | ## Fortran 90 |
---|
[1714] | 224 | if [ `echo $trufile | cut -d. -f2` = F90 ] ; then |
---|
[1492] | 225 | ## Free Form |
---|
[1714] | 226 | echo ' $(COMPTRU90) $(LIBF)/'$trufile' ; \' |
---|
[524] | 227 | else |
---|
[1714] | 228 | echo ' $(COMPILE90) $(LIBF)/'$trufile' ; \' |
---|
[524] | 229 | fi |
---|
| 230 | fi |
---|
[1492] | 231 | # Put generated object in library |
---|
[524] | 232 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 233 | echo |
---|
| 234 | done |
---|
| 235 | # |
---|
| 236 | echo |
---|
| 237 | cd $libf |
---|
| 238 | fi |
---|
| 239 | fi |
---|
| 240 | done |
---|