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