[38] | 1 | #!/bin/sh |
---|
| 2 | #set -xv |
---|
| 3 | # |
---|
| 4 | # Ehouarn: added the following feature: |
---|
| 5 | # create_make_gcm must be called with list of directories |
---|
| 6 | # which contain header (or modules) which should be scanned |
---|
| 7 | # by create_make_gcm when checking dependencies. |
---|
| 8 | # Example: |
---|
| 9 | # create_make_gcm dyn3d grid |
---|
| 10 | # means that header/modules will be looked for in directories |
---|
| 11 | # ., dyn3d and grid |
---|
| 12 | # |
---|
| 13 | machine=`hostname` |
---|
| 14 | os=`uname` |
---|
| 15 | gcm=`pwd` |
---|
| 16 | libf=$gcm/libf |
---|
| 17 | libo=$gcm/libo |
---|
| 18 | CRAY=0 |
---|
| 19 | if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then |
---|
| 20 | CRAY=1 |
---|
| 21 | fi |
---|
| 22 | XNEC=0 |
---|
| 23 | if [ "$machine" = "rhodes" ] ; then |
---|
| 24 | XNEC=1 |
---|
| 25 | fi |
---|
| 26 | VPP=0 |
---|
| 27 | if [ "$machine" = "nymphea0" ] ; then |
---|
| 28 | VPP=1 |
---|
| 29 | fi |
---|
| 30 | # |
---|
| 31 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 32 | echo "# Definitions de Macros pour Make" |
---|
| 33 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 34 | echo |
---|
| 35 | echo "# create_make_gcm arguments: $*" |
---|
| 36 | echo |
---|
| 37 | echo "# Repertoires :" |
---|
| 38 | echo |
---|
| 39 | echo "GCM = "$gcm |
---|
| 40 | if [ "$CRAY" = '0' ] ; then |
---|
| 41 | echo "MACHINE = sun4" |
---|
| 42 | fi |
---|
| 43 | echo 'LIBF = $(GCM)/libf' |
---|
| 44 | if [ "$CRAY" = '0' ] ; then |
---|
| 45 | # echo 'LIBO = $(GCM)/libo/$(MACHINE)' |
---|
| 46 | echo 'LIBO = $(LIBOGCM)/$(MACHINE)' |
---|
| 47 | else |
---|
| 48 | echo 'LIBO = $(GCM)/libo' |
---|
| 49 | fi |
---|
| 50 | #echo 'LOCAL_DIR=$(GCM)' |
---|
| 51 | #echo $localdir |
---|
| 52 | echo "LOCAL_DIR=`echo $localdir`" |
---|
| 53 | echo 'BIBIO = $(LIBF)/bibio' |
---|
| 54 | echo 'AERONOMARS = $(LIBF)/aeronomars' |
---|
| 55 | echo "FILTRE = filtre" |
---|
| 56 | echo "PHYS = " |
---|
| 57 | echo 'DYN = $(DYNTYPE)' |
---|
| 58 | echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' |
---|
| 59 | echo 'DIRMAIN= $(DYN)$(DIM)d' |
---|
| 60 | echo 'RM=rm' |
---|
| 61 | echo |
---|
| 62 | echo "OPLINK = " |
---|
| 63 | echo |
---|
| 64 | echo '# Les differentes librairies pour l"edition des liens:' |
---|
| 65 | echo |
---|
| 66 | if [ "$XNEC" = '1' ] ; then |
---|
| 67 | echo 'dyn3d = $(LIBO)/libsxdyn3d.a $(LIBO)/libsx$(FILTRE).a' |
---|
| 68 | echo 'dyn2d = $(LIBO)/libsxdyn2d.a' |
---|
| 69 | echo 'dyn1d = $(LIBO)/libsxdyn1d.a' |
---|
| 70 | echo 'L_DYN = -lsxdyn$(DIM)d' |
---|
| 71 | echo 'L_FILTRE = -lsx$(FILTRE)' |
---|
| 72 | echo 'L_PHY = -lsxphy$(PHYS) ' |
---|
| 73 | echo 'L_BIBIO = -lsxbibio' |
---|
| 74 | echo 'L_AERONOMARS = -lsxaeronomars' |
---|
| 75 | echo 'L_ADJNT =' |
---|
| 76 | else |
---|
| 77 | echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' |
---|
| 78 | echo 'dyn2d = $(LIBO)/libdyn2d.a' |
---|
| 79 | echo 'dyn1d = $(LIBO)/libdyn1d.a' |
---|
| 80 | echo 'L_DYN = -l$(DYN)$(DIM)d' |
---|
| 81 | echo 'L_FILTRE = -l$(FILTRE)' |
---|
| 82 | echo 'L_PHY = -lphy$(PHYS) ' |
---|
| 83 | echo 'L_BIBIO = -lbibio' |
---|
| 84 | echo 'L_AERONOMARS = -laeronomars' |
---|
| 85 | echo 'L_ADJNT =' |
---|
| 86 | fi |
---|
| 87 | echo |
---|
| 88 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 89 | echo "# Option de compilation FORTRAN" |
---|
| 90 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 91 | echo |
---|
| 92 | echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' |
---|
| 93 | echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' |
---|
| 94 | echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' |
---|
| 95 | echo "LINK = $LINK" |
---|
| 96 | echo "AR = $AR" |
---|
| 97 | echo |
---|
| 98 | echo |
---|
| 99 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 100 | echo "# Creation des differents executables" |
---|
| 101 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 102 | echo |
---|
| 103 | echo "# Executables:" |
---|
| 104 | echo "# ------------" |
---|
| 105 | echo |
---|
| 106 | echo "PROG = code" |
---|
| 107 | echo |
---|
| 108 | echo 'main : $(DYN) bibio phys aeronomars $(OPTION_DEP) ' |
---|
| 109 | echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' |
---|
| 110 | echo ' cd $(LOCAL_DIR); \' |
---|
[519] | 111 | echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' |
---|
[38] | 112 | if [ "$CRAY" = '0' ] ; then |
---|
| 113 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_AERONOMARS) $(L_PHY) $(L_BIBIO) $(L_DYN) $(L_AERONOMARS) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
| 114 | else |
---|
| 115 | echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_AERONOMARS) $(L_PHY) $(L_BIBIO) $(L_DYN) $(L_AERONOMARS) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' |
---|
| 116 | fi |
---|
| 117 | echo |
---|
| 118 | echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
| 119 | echo |
---|
| 120 | echo 'olddyn : $(LIBO)/libolddyn$(DIM)d.a $(FILTRE)$(DIM)d' |
---|
| 121 | echo |
---|
| 122 | echo 'phys : $(LIBPHY)' |
---|
| 123 | echo |
---|
| 124 | echo 'bibio : $(LIBO)/libbibio.a' |
---|
| 125 | echo |
---|
| 126 | echo 'aeronomars : $(LIBO)/libaeronomars.a' |
---|
| 127 | echo |
---|
| 128 | echo 'adjnt : $(LIBO)/libadjnt.a' |
---|
| 129 | echo |
---|
| 130 | echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' |
---|
| 131 | echo |
---|
| 132 | echo '$(FILTRE)2d :' |
---|
| 133 | echo |
---|
| 134 | echo '$(FILTRE)1d :' |
---|
| 135 | echo |
---|
| 136 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 137 | echo "# Contenu des differentes bibliotheques" |
---|
| 138 | echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" |
---|
| 139 | echo |
---|
| 140 | echo |
---|
| 141 | cd $libf >/dev/null 2>&1 |
---|
| 142 | for diri in ` ls ` |
---|
| 143 | do |
---|
| 144 | if [ -d $diri ] ; then |
---|
| 145 | if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.F90`" != "" ] ; then |
---|
| 146 | cd $diri >/dev/null 2>&1 |
---|
| 147 | echo |
---|
| 148 | listlib="" |
---|
| 149 | for i in `ls *.F` |
---|
| 150 | do |
---|
| 151 | fili=`basename $i .F` |
---|
[634] | 152 | # Check if file is a routine or main program |
---|
| 153 | # i.e: look for the "program" keword preceeded by leading spaces |
---|
| 154 | test=` ( head $i | grep -i '^ *program' ) ` |
---|
[38] | 155 | if [ "$test" = "" ] ; then |
---|
[634] | 156 | # if it is not a main program, add it to the list |
---|
[38] | 157 | listlib=$listlib" "$fili |
---|
| 158 | fi |
---|
| 159 | done |
---|
| 160 | for i in `ls *.F90` |
---|
| 161 | do |
---|
| 162 | fili=`basename $i .F90` |
---|
[634] | 163 | # Check if file is a routine or main program |
---|
| 164 | # i.e. look for "program" keyword (with possibly some leading spaces) |
---|
| 165 | test=` ( head $i | grep -i '^ \{0,\}program' ) ` |
---|
[38] | 166 | if [ "$test" = "" ] ; then |
---|
[634] | 167 | # if it is not a main program, add it to the list |
---|
[38] | 168 | listlib=$listlib" "$fili |
---|
| 169 | fi |
---|
| 170 | done |
---|
| 171 | # |
---|
| 172 | echo |
---|
| 173 | echo |
---|
| 174 | echo "#=======================================================================" |
---|
| 175 | echo "# Contenu de la bibliotheque correspondant au Directory "$diri |
---|
| 176 | echo "#=======================================================================" |
---|
| 177 | echo |
---|
| 178 | for fili in $listlib |
---|
| 179 | do |
---|
| 180 | echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" |
---|
| 181 | echo |
---|
| 182 | done |
---|
| 183 | echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' |
---|
| 184 | echo |
---|
| 185 | echo |
---|
| 186 | echo "# Compilation des membres de la bibliotheque lib"$diri".a" |
---|
| 187 | echo |
---|
| 188 | for fili in $listlib |
---|
| 189 | do |
---|
| 190 | if [ -f $fili.F90 ] ; then |
---|
| 191 | trufile=$fili.F90 |
---|
| 192 | else |
---|
| 193 | trufile=$fili.F |
---|
| 194 | fi |
---|
| 195 | F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 196 | egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 197 | egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 |
---|
| 198 | str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile |
---|
| 199 | [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F |
---|
| 200 | for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` |
---|
| 201 | do |
---|
| 202 | stri=`echo $stri | tr [A-Z] [a-z]` |
---|
| 203 | if [ -f $stri ] ; then |
---|
| 204 | echo $str1 \\ |
---|
| 205 | str1='$(LIBF)/'$diri'/'$stri |
---|
| 206 | else |
---|
| 207 | if [ -f $stri.F ] || [ -f $stri.F90 ] ; then |
---|
| 208 | echo $str1 \\ |
---|
| 209 | str1='$(LIBO)/lib'$diri'.a('$stri'.o)' |
---|
| 210 | else |
---|
| 211 | # for dirinc in dyn3d grid bibio aeronomars phymars |
---|
| 212 | for dirinc in $* |
---|
| 213 | do |
---|
| 214 | if [ -f ../$dirinc/$stri ] ; then |
---|
| 215 | echo $str1 \\ |
---|
| 216 | str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` |
---|
| 217 | fi |
---|
| 218 | if [ -f ../$dirinc/$stri.F90 ] ; then |
---|
| 219 | echo $str1 \\ |
---|
| 220 | str1='$(LIBO)/lib'$dirinc'.a('$stri'.o)' |
---|
| 221 | fi |
---|
| 222 | done |
---|
| 223 | fi |
---|
| 224 | fi |
---|
| 225 | done |
---|
| 226 | echo $str1 |
---|
[519] | 227 | # Compile in LOCAL_DIR directory, and before compiling, |
---|
| 228 | # remove the object from the library |
---|
| 229 | echo ' cd $(LOCAL_DIR); \' |
---|
| 230 | echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' |
---|
[38] | 231 | if [ "$F90" -eq '0' ] ; then |
---|
[519] | 232 | ## Fixed Form Fortran 77 |
---|
[38] | 233 | echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
| 234 | else |
---|
[519] | 235 | ## Fortran 90 |
---|
[38] | 236 | if [ -f $fili.F90 ] ; then |
---|
[519] | 237 | ## Free Form Fortran 90 |
---|
| 238 | echo ' $(COMPTRU90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
[38] | 239 | else |
---|
[519] | 240 | ## Fixed Form Fortran 90 |
---|
| 241 | echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' |
---|
[38] | 242 | fi |
---|
[519] | 243 | ## If a module, handle created module descriptor file |
---|
[38] | 244 | MODU=0; egrep -i '^ *module ' $trufile> /dev/null 2>&1 && MODU=1 |
---|
| 245 | if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then |
---|
| 246 | if [ "$os" = 'UNIX_System_V' ] ; then |
---|
| 247 | echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \' |
---|
| 248 | else |
---|
| 249 | echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \' |
---|
| 250 | # echo ' if [ "$(MOD_LOC_DIR)" ne "$(LIBO)" ] ; then mv $(MOD_LOC_DIR)/'*'.$(MOD_SUFFIX) $(LIBO) ; fi ; \' |
---|
| 251 | fi |
---|
| 252 | fi |
---|
| 253 | fi |
---|
| 254 | if ( [ "$XNEC" -eq '1' ] || [ "$X6NEC" = '1' ] || [ "$X8BRODIE" = '1' ] ) ; then |
---|
| 255 | echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \' |
---|
| 256 | fi |
---|
[519] | 257 | # Put generated object in library |
---|
[38] | 258 | echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' |
---|
| 259 | echo ' cd $(GCM)' |
---|
| 260 | echo |
---|
| 261 | done |
---|
| 262 | # |
---|
| 263 | echo |
---|
| 264 | cd $libf |
---|
| 265 | fi |
---|
| 266 | fi |
---|
| 267 | done |
---|