Changeset 1403 for trunk/LMDZ.GENERIC/create_make_gcm
- Timestamp:
- Mar 31, 2015, 3:49:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.GENERIC/create_make_gcm
r634 r1403 11 11 # ., dyn3d and grid 12 12 # 13 14 # arguments given to create_make_gcm are the directories to scan 15 src_dirs=$* 16 13 17 machine=`hostname` 14 18 os=`uname` 15 19 gcm=`pwd` 20 logfile=$gcm/create_make_gcm.log 21 rm -f $logfile ; touch -f $logfile 16 22 libf=$gcm/libf 17 23 libo=$gcm/libo … … 51 57 #echo $localdir 52 58 echo "LOCAL_DIR=`echo $localdir`" 53 echo ' BIBIO = $(LIBF)/bibio'54 # #echo 'AERONOMARS = $(LIBF)/aeronomars'59 echo 'MISC = $(LIBF)/misc' 60 #echo 'AERONOMARS = $(LIBF)/aeronomars' 55 61 echo "FILTRE = filtre" 56 62 echo "PHYS = " 57 63 echo 'DYN = $(DYNTYPE)' 58 64 echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' 65 echo 'LIBDYN_PHY = $(LIBO)/libdynlmdz_phy$(PHYS).a' 59 66 echo 'DIRMAIN= $(DYN)$(DIM)d' 60 67 echo 'RM=rm' … … 64 71 echo '# Les differentes librairies pour l"edition des liens:' 65 72 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 73 echo 'L_DYN = -ldyn$(DIM)d' 74 echo 'L_FILTRE = -l$(FILTRE)' 75 echo 'L_DYN_PHY = -ldynlmdz_phy$(PHYS) ' 76 echo 'L_PHY = -lphy$(PHYS) ' 77 echo 'L_MISC = -lmisc' 78 #echo 'L_AERONOMARS = -laeronomars' 79 echo 'L_ADJNT =' 87 80 echo 88 81 echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" … … 105 98 echo 106 99 echo "PROG = code" 107 echo 108 ##echo 'main : $(DYN) bibio phys aeronomars $(OPTION_DEP) ' 109 echo 'main : $(DYN) bibio phys$(OPTION_DEP) '100 echo 'DYN = dyn$(DIM)d' 101 echo 102 echo 'main : $(DYN) misc phys dyn_phy $(OPTION_DEP) ' 110 103 echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' 111 104 echo ' cd $(LOCAL_DIR); \' 112 105 echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' 113 106 if [ "$CRAY" = '0' ] ; then 114 ##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 ' 115 echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_BIBIO) $(L_DYN) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' 107 echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_DYN_PHY) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_DYN_PHY) $(L_MISC) $(L_DYN) $(L_PHY) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' 116 108 else 117 ##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 ' 118 echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_BIBIO) $(L_DYN) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' 109 echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_DYN_PHY) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_DYN_PHY) $(L_MISC) $(L_DYN) $(L_PHY) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' 119 110 fi 120 111 echo … … 125 116 echo 'phys : $(LIBPHY)' 126 117 echo 127 echo 'bibio : $(LIBO)/libbibio.a' 128 echo 129 ##echo 'aeronomars : $(LIBO)/libaeronomars.a' 130 ##echo 118 echo 'dyn3d : $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' 119 echo 'dyn2d : $(LIBO)/libdyn2d.a' 120 echo 'dyn1d : ' 121 echo 122 echo 'dyn_phy: $(LIBDYN_PHYS)' 123 echo 124 echo 'misc : $(LIBO)/libmisc.a' 125 echo 126 #echo 'aeronomars : $(LIBO)/libaeronomars.a' 127 #echo 131 128 echo 'adjnt : $(LIBO)/libadjnt.a' 132 129 echo … … 143 140 echo 144 141 cd $libf >/dev/null 2>&1 145 for diri in ` ls ` 146 do 142 143 for diri in $src_dirs ; do 144 147 145 if [ -d $diri ] ; then 148 if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*. F90`" != "" ] ; then149 cd $diri >/dev/null 2>&1146 if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.[fF]90`" != "" ] ; then 147 # cd $diri >/dev/null 2>&1 150 148 echo 151 149 listlib="" 152 for i in `ls *.F` 153 do 154 fili=`basename $i .F` 150 # Liste des fichiers .F et .F90 n'etant pas des programmes principaux 151 for fili in `ls $diri/*.[fF]` ; do 155 152 # Check if file is a routine or main program 156 153 # i.e: look for the "program" keword preceeded by leading spaces 157 test=` ( head $i | grep -i '^ *program' ) ` 158 if [ "$test" = "" ] ; then 159 # if it is not a main program, add it to the list 160 listlib=$listlib" "$fili 161 fi 162 done 163 for i in `ls *.F90` 164 do 165 fili=`basename $i .F90` 154 test=` ( head $fili | grep -i '^ *program' ) ` 155 # if it is not a main program, add it to the list 156 if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi 157 done 158 for fili in `ls $diri/*.[fF]90` ; do 166 159 # Check if file is a routine or main program 167 160 # i.e. look for "program" keyword (with possibly some leading spaces) 168 test=` ( head $ i | grep -i '^ \{0,\}program' ) `169 if [ "$test" = "" ] ; then170 # if it is not a main program, add it to the list171 listlib=$listlib" "$fili172 fi173 done174 # 175 echo176 echo177 echo "#================================================================== ====="161 test=` ( head $fili | grep -i '^ \{0,\}program' ) ` 162 # if it is not a main program, add it to the list 163 if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi 164 done 165 echo 166 echo $listlib >> $logfile 167 echo 168 # topdiri contains main dir name (without trailing "/blabla" for subdirs) 169 topdiri=${diri%/*} 170 echo "#==================================================================" 178 171 echo "# Contenu de la bibliotheque correspondant au Directory "$diri 179 echo "#================================================================== ====="180 echo 181 for fili in $listlib182 do183 echo '$(LIBO)/lib'$ diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)"172 echo "#==================================================================" 173 echo 174 for trufile in $listlib ; do 175 fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` 176 echo '$(LIBO)/lib'$topdiri".a : " '$(LIBO)/lib'$topdiri".a("$fili".o)" 184 177 echo 185 178 done 186 echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' 187 echo 188 echo 189 echo "# Compilation des membres de la bibliotheque lib"$diri".a" 190 echo 191 for fili in $listlib 192 do 193 if [ -f $fili.F90 ] ; then 194 trufile=$fili.F90 195 else 196 trufile=$fili.F 197 fi 179 echo '.PRECIOUS : $(LIBO)/lib'$topdiri'.a' 180 echo 181 echo 182 echo "# Compilation of elements in $diri of library lib"$topdiri".a" 183 echo 184 for trufile in $listlib ; do 185 fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` 198 186 F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 199 187 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 200 188 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 201 str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$trufile 202 [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F 203 for stri in ` ( sed -n "/\#include/s/\#include//p" $trufile | sed 's/\"//g' ; egrep -i '^ *use ' $trufile | sed -e 's/,/ /' | awk ' { print $2 } ' ) ` 204 do 205 stri=`echo $stri | tr [A-Z] [a-z]` 206 if [ -f $stri ] ; then 189 str1='$(LIBO)/lib'$topdiri'.a('$fili'.o) : $(LIBF)/'$trufile 190 [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F 191 192 ########################################################################## 193 # TRAITEMENT DES DEPENDANCES 194 # Differents cas de dependance correspondant a des include ou des 195 # use module. 196 # soit dans le repertoire local soit dans un autre. 197 # Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN 198 # ou quelque chose du genre. 199 ########################################################################## 200 201 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 202 echo $trufile $fili $stri >> $logfile 203 strj=`echo $stri | tr [A-Z] [a-z]` 204 str2="" 205 for dirinc in $src_dirs ; do 206 # Recherche dans l'ordre hierarchique inverse car seule la derniere 207 # ligne est conservee 208 # if [ $dirinc = phydev ] ; then 209 # dirstr='$(PHYS)' 210 # libstr='phy$(PHYS)' 211 # else 212 dirstr=$dirinc 213 libstr=$dirinc 214 # fi 215 echo dirinc $dirinc >> $logfile 216 if [ -f $dirinc/$stri ] ; then 217 str2='$(LIBF)/'$dirstr/$stri 218 elif [ -f $dirinc/$strj ] ; then 219 str2='$(LIBF)/'$dirstr/$stri 220 elif [ -f $dirinc/$strj.[fF]90 ] || [ -f $dirinc/$strj.[fF] ] ; then 221 strlib=`echo $libstr | awk -F/ ' { print $1 } '` 222 str2='$(LIBO)/lib'$strlib'.a('$strj'.o)' 223 elif [ -f $dirinc/$stri.[fF]90 ] || [ -f $dirinc/$stri.[fF] ] ; then 224 strlib=`echo $libstr | awk -F/ ' { print $1 } '` 225 str2='$(LIBO)/lib'$strlib'.a('$stri'.o)' 226 fi 227 echo stri $stri >> $logfile 228 echo str2 $str2 >> $logfile 229 done 230 echo dernier str2 $str2 >> $logfile 231 if [ "$str2" = "" ] ; then 232 echo Warn: Include $diri $trufile $fili $stri pas trouve >> $logfile 233 elif [ "$str2" = "$str1" ] ; then 234 echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $logfile 235 else 207 236 echo $str1 \\ 208 str1='$(LIBF)/'$diri'/'$stri 209 else 210 if [ -f $stri.F ] || [ -f $stri.F90 ] ; then 211 echo $str1 \\ 212 str1='$(LIBO)/lib'$diri'.a('$stri'.o)' 213 else 214 # for dirinc in dyn3d grid bibio aeronomars phymars 215 for dirinc in $* 216 do 217 if [ -f ../$dirinc/$stri ] ; then 218 echo $str1 \\ 219 str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` 220 fi 221 if [ -f ../$dirinc/$stri.F90 ] ; then 222 echo $str1 \\ 223 str1='$(LIBO)/lib'$dirinc'.a('$stri'.o)' 224 fi 225 done 226 fi 237 str1=$str2 227 238 fi 228 done 239 done # Fin de la boucle sur les dependances et ecriture de la derniere 229 240 echo $str1 230 # Compile in L OCAL_DIR directory, and before compiling,231 # remove the object from thelibrary232 echo ' cd $(L OCAL_DIR); \'233 echo ' $(AR) d $(LIBO)/lib'$ diri'.a '$fili'.o ; \'241 # Compile in LIBO directory; and before compiling, remove 242 # object from library 243 echo ' cd $(LIBO); \' 244 echo ' $(AR) d $(LIBO)/lib'$topdiri'.a '$fili'.o ; \' 234 245 if [ "$F90" -eq '0' ] ; then 235 236 echo ' $(COMPILE) $(LIBF)/'$diri'/'$trufile' ; \'246 ## Fixed Form Fortran 77 247 echo ' $(COMPILE) $(LIBF)/'$trufile' ; \' 237 248 else 238 249 ## Fortran 90 239 if [ -f $fili.F90 ] ; then240 ## Free Form Fortran 90241 echo ' $(COMPTRU90) $(LIBF)/'$ diri'/'$trufile' ; \'250 if [ `echo $trufile | cut -d. -f2` = F90 ] ; then 251 ## Free Form 252 echo ' $(COMPTRU90) $(LIBF)/'$trufile' ; \' 242 253 else 243 ## Fixed Form Fortran 90 244 echo ' $(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \' 254 echo ' $(COMPILE90) $(LIBF)/'$trufile' ; \' 245 255 fi 246 ## If a module, handle created module descriptor file247 MODU=0; egrep -i '^ *module ' $trufile> /dev/null 2>&1 && MODU=1248 if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then249 if [ "$os" = 'UNIX_System_V' ] ; then250 echo ' cp $(MOD_LOC_DIR)/*.$(MOD_SUFFIX) $(LIBO)/ ; \'251 else252 echo ' mv $(MOD_LOC_DIR)/'$fili'.$(MOD_SUFFIX) $(LIBO)/'$fili'.$(MOD_SUFFIX) ; \'253 # echo ' if [ "$(MOD_LOC_DIR)" ne "$(LIBO)" ] ; then mv $(MOD_LOC_DIR)/'*'.$(MOD_SUFFIX) $(LIBO) ; fi ; \'254 fi255 fi256 256 fi 257 if ( [ "$XNEC" -eq '1' ] || [ "$X6NEC" = '1' ] || [ "$X8BRODIE" = '1' ] ) ; then258 echo ' sxar r $(LIBO)/libsx'$diri'.a '$fili'.o ; \'259 fi260 257 # Put generated object in library 261 echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' 262 echo ' cd $(GCM)' 258 echo ' $(AR) r $(LIBO)/lib'$topdiri'.a '$fili'.o ; $(RM) '$fili'.o ; \' 263 259 echo 264 260 done
Note: See TracChangeset
for help on using the changeset viewer.