[524] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
[1492] | 3 | # $Id: create_make_gcm 1714 2013-01-18 18:10:19Z emillour $ |
---|
[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 = $(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' |
---|
[768] | 57 | echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' |
---|
[524] | 58 | echo 'RM=rm' |
---|
| 59 | echo |
---|
| 60 | echo "OPLINK = " |
---|
| 61 | echo |
---|
| 62 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
| 63 | echo |
---|
[1492] | 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 =' |
---|
[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) ' |
---|
| 97 | echo 'main : $(DYN) bibio 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 ; \' |
---|
[1692] | 101 | 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] | 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 |
---|
| 111 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
| 112 | echo |
---|
[1666] | 113 | echo 'cosp : $(LIBO)/libcosp.a' |
---|
[1279] | 114 | echo |
---|
[524] | 115 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
| 116 | echo |
---|
| 117 | echo '$(FILTRE)2d :' |
---|
| 118 | echo |
---|
| 119 | echo '$(FILTRE)1d :' |
---|
| 120 | echo |
---|
| 121 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 122 | echo "# Contenu des differentes bibliotheques" |
---|
| 123 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 124 | echo |
---|
| 125 | echo |
---|
| 126 | cd $libf >/dev/null 2>&1 |
---|
[1714] | 127 | |
---|
| 128 | for diri in ` ls ` ; do |
---|
| 129 | |
---|
[524] | 130 | if [ -d $diri ] ; then |
---|
[1714] | 131 | if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.F90 $diri/*/*.F90`" != "" ] ; then |
---|
| 132 | # cd $diri >/dev/null 2>&1 |
---|
[524] | 133 | echo |
---|
| 134 | listlib="" |
---|
[1714] | 135 | # Liste des fichiers .F et .F90 n'etant pas des programmes principaux |
---|
| 136 | for fili in `ls $diri/*.F $diri/*/*.F` ; do |
---|
| 137 | test=` ( head $fili | grep ' PROGRAM' ) ` |
---|
| 138 | if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi |
---|
[524] | 139 | done |
---|
[1714] | 140 | for fili in `ls $diri/*.F90 $diri/*/*.F90` ; do |
---|
| 141 | test=` ( head $fili | grep 'PROGRAM' ) ` |
---|
| 142 | if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi |
---|
[524] | 143 | done |
---|
| 144 | echo |
---|
[1714] | 145 | echo $listlib >> create_makeg_gcm.log |
---|
[524] | 146 | echo |
---|
[1714] | 147 | echo "#==================================================================" |
---|
[524] | 148 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
[1714] | 149 | echo "#==================================================================" |
---|
[524] | 150 | echo |
---|
[1714] | 151 | for trufile in $listlib ; do |
---|
| 152 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[524] | 153 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 154 | echo |
---|
| 155 | done |
---|
| 156 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 157 | echo |
---|
| 158 | echo |
---|
| 159 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
| 160 | echo |
---|
[1714] | 161 | for trufile in $listlib ; do |
---|
| 162 | fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` |
---|
[524] | 163 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 164 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[536] | 165 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
[1714] | 166 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile |
---|
| 167 | [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
[1112] | 168 | |
---|
[1714] | 169 | ########################################################################## |
---|
| 170 | # TRAITEMENT DES DEPENDANCES |
---|
[1112] | 171 | # Differents cas de dependance correspondant a des include ou des |
---|
| 172 | # use module. |
---|
| 173 | # soit dans le repertoire local soit dans un autre. |
---|
[1714] | 174 | # Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN |
---|
| 175 | # ou quelque chose du genre. |
---|
| 176 | ########################################################################## |
---|
[1112] | 177 | |
---|
[1714] | 178 | 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 |
---|
| 179 | echo $trufile $fili $stri >> create_make_gcm.log |
---|
| 180 | strj=`echo $stri | tr [A-Z] [a-z]` |
---|
| 181 | str2="" |
---|
| 182 | for dirinc in filtrez bibio grid dyn3d $diri $diri/*/ ; do |
---|
| 183 | # Recherche dans l'ordre hierarchique inverse car seule la derniere |
---|
| 184 | # ligne est conservee |
---|
| 185 | if [ -f $dirinc/$stri ] ; then |
---|
| 186 | str2='$(LIBF)/'$dirinc/$stri |
---|
| 187 | elif [ -f $dirinc/$strj ] ; then |
---|
| 188 | str2='$(LIBF)/'$dirinc/$stri |
---|
| 189 | elif [ -f $dirinc/$strj.F90 ] || [ -f $dirinc/$strj.F ] ; then |
---|
| 190 | strlib=`echo $dirinc | awk -F/ ' { print $1 } '` |
---|
| 191 | str2='$(LIBO)/lib'$strlib'.a('$strj'.o)' |
---|
| 192 | fi |
---|
| 193 | done |
---|
| 194 | if [ "$str2" = "" ] ; then |
---|
| 195 | echo Warn: Include $diri $trufile $fili $stri pas trouve >> $gcm/create_make_gcm.log |
---|
| 196 | elif [ "$str2" = "$str1" ] ; then |
---|
| 197 | echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $gcm/create_make_gcm.log |
---|
| 198 | else |
---|
[524] | 199 | echo $str1 \\ |
---|
[1714] | 200 | str1=$str2 |
---|
[524] | 201 | fi |
---|
[1714] | 202 | done # Fin de la boucle sur les dependances et ecriture de la derniere |
---|
[524] | 203 | echo $str1 |
---|
[1492] | 204 | # Compile in LIBO directory; and before compiling, remove |
---|
| 205 | # object from library |
---|
| 206 | echo ' cd $(LIBO); \' |
---|
| 207 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
[768] | 208 | if [ "$F90" -eq '0' ] ; then |
---|
[1492] | 209 | ## Fixed Form Fortran 77 |
---|
[1714] | 210 | echo ' $(COMPILE) $(LIBF)/'$trufile' ; \' |
---|
[524] | 211 | else |
---|
[1492] | 212 | ## Fortran 90 |
---|
[1714] | 213 | if [ `echo $trufile | cut -d. -f2` = F90 ] ; then |
---|
[1492] | 214 | ## Free Form |
---|
[1714] | 215 | echo ' $(COMPTRU90) $(LIBF)/'$trufile' ; \' |
---|
[524] | 216 | else |
---|
[1714] | 217 | echo ' $(COMPILE90) $(LIBF)/'$trufile' ; \' |
---|
[524] | 218 | fi |
---|
| 219 | fi |
---|
[1492] | 220 | # Put generated object in library |
---|
[524] | 221 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 222 | echo |
---|
| 223 | done |
---|
| 224 | # |
---|
| 225 | echo |
---|
| 226 | cd $libf |
---|
| 227 | fi |
---|
| 228 | fi |
---|
| 229 | done |
---|