#!/bin/sh # # $Id: create_make_gcm 1461 2010-12-03 11:12:25Z emillour $ # #set -xv rm -f create_make_gcm.log machine=`hostname` os=`uname` gcm=`pwd` libf=$gcm/libf libo=$gcm/libo CRAY=0 if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then CRAY=1 fi XNEC=0 if [ "$machine" = "rhodes" ] ; then XNEC=1 fi X6NEC=0 if [ "$machine" = "mercure" ] ; then X6NEC=1 fi X8BRODIE=0 if [ "$machine" = "brodie" ] ; then X8BRODIE=1 fi VPP=0 if [ "$machine" = "nymphea0" ] ; then VPP=1 fi # echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo "# Definitions de Macros pour Make" echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo echo "# Repertoires :" echo echo "GCM = "$gcm echo 'LIBF = $(GCM)/libf' if [ "$CRAY" = '0' ] ; then # echo 'LIBO = $(GCM)/libo/$(MACHINE)' echo 'LIBO = $(LIBOGCM)/$(MACHINE)' else echo 'LIBO = $(GCM)/libo' fi #echo 'LOCAL_DIR=$(GCM)' #echo $localdir echo "LOCAL_DIR=`echo $localdir`" echo 'BIBIO = $(LIBF)/bibio' echo "FILTRE = filtre" echo "PHYS = " echo "DYN = dyn " echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a' echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)' echo 'RM=rm' echo echo "OPLINK = " echo echo '# Les differentes librairies pour l"edition des liens:' echo echo 'dyn3d = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a' echo 'dyn3dpar = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a' echo 'dyn2d = $(LIBO)/libdyn2d.a' echo 'dyn1d = $(LIBO)/libdyn1d.a' echo 'L_DYN = -ldyn$(DIM)d$(FLAG_PARA)' echo 'L_FILTRE = -l$(FILTRE)' echo 'L_PHY = -lphy$(PHYS) ' echo 'L_BIBIO = -lbibio' echo 'L_ADJNT =' echo 'L_COSP = -lcosp' echo echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo "# Option de compilation FORTRAN" echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c' echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c' echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c' echo "LINK = $LINK" echo "AR = $AR" echo echo echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' echo '# Option de compilation C' echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' echo echo 'COMPILEC = $(CCC) $(OPTIMC) $(INCLUDEC) -c' echo echo echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo "# Creation des differents executables" echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo echo "# Executables:" echo "# ------------" echo echo "PROG = code" echo #echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) ' echo 'main : bibio $(DYN) phys $(OPTION_DEP) ' echo ' cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\' echo ' cd $(LOCAL_DIR); \' echo ' $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \' echo ' $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_COSP) $(L_FILTRE) $(L_PHY) $(L_DYN) $(L_BIBIO) $(L_DYN) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o ' echo echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d' echo echo 'phys : $(LIBPHY)' echo #echo 'chimie : $(LIBO)/libchimie.a' echo echo 'bibio : $(LIBO)/libbibio.a' echo echo 'adjnt : $(LIBO)/libadjnt.a' echo echo 'cosp : $(LIBO)/libcosp.a' echo echo 'chimtitan : $(LIBO)/libchimtitan.a' echo echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a' echo echo '$(FILTRE)2d :' echo echo '$(FILTRE)1d :' echo echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo "# Contenu des differentes bibliotheques" echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo echo cd $libf >/dev/null 2>&1 for diri in ` ls ` do if [ -d $diri ] ; then if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.F90 $diri/*/*.F90`" != "" ] ; then # cd $diri >/dev/null 2>&1 echo listlib="" # Liste des fichiers .F et .F90 n'etant pas des programmes principaux for fili in `ls $diri/*.F $diri/*/*.F` do # Check if file is a routine or main program # i.e: look for the "program" keword preceeded by leading spaces test=` ( head $fili | grep -i '^ *program' ) ` if [ "$test" = "" ] ; then # if it is not a main program, add it to the list listlib=$listlib" "$fili fi done for fili in `ls $diri/*.F90 $diri/*/*.F90` do # Check if file is a routine or main program # i.e. look for "program" keyword (with possibly some leading spaces) test=` ( head $fili | grep -i '^ \{0,\}program' ) ` if [ "$test" = "" ] ; then # if it is not a main program, add it to the list listlib=$listlib" "$fili fi done # echo echo $listlib >> create_make_gcm.log echo echo "#=======================================================================" echo "# Contenu de la bibliotheque correspondant au Directory "$diri echo "#=======================================================================" echo for trufile in $listlib do fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" echo done echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' echo echo echo "# Compilation des membres de la bibliotheque lib"$diri".a" echo for trufile in $listlib do # if [ -f $fili.F90 ] ; then # trufile=$fili.F90 # else # trufile=$fili.F # fi fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1` F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1 str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F ########################################################################## # TRAITEMENT DES DEPENDANCES # Differents cas de dependance correspondant a des include ou des # use module. # soit dans le repertoire local soit dans un autre. # Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN # ou quelque chose du genre. ########################################################################## 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 echo $trufile $fili $stri >> create_make_gcm.log strj=`echo $stri | tr [A-Z] [a-z]` str2="" for dirinc in filtrez bibio grid dyn3d $diri $diri/*/ ; do # Recherche dans l'ordre hierarchique inverse car seule la derniere # ligne est conservee if [ -f $dirinc/$stri ] ; then str2='$(LIBF)/'$dirinc/$stri elif [ -f $dirinc/$strj ] ; then str2='$(LIBF)/'$dirinc/$stri elif [ -f $dirinc/$strj.F90 ] || [ -f $dirinc/$strj.F ] ; then strlib=`echo $dirinc | awk -F/ ' { print $1 } '` str2='$(LIBO)/lib'$strlib'.a('$strj'.o)' fi done if [ "$str2" = "" ] ; then echo Warn: Include $diri $trufile $fili $stri pas trouve >> $gcm/create_make_gcm.log elif [ "$str2" = "$str1" ] ; then echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $gcm/create_make_gcm.log else echo $str1 \\ str1=$str2 fi done # Fin de la boucle sur les dependances et ecriture de la derniere echo $str1 # Compile in LIBO directory; and before compiling, remove # object from library echo ' cd $(LIBO); \' echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' if [ "$F90" -eq '0' ] ; then ## Fixed Form Fortran 77 echo ' $(COMPILE) $(LIBF)/'$trufile' ; \' else ## Fortran 90 if [ -f $fili.F90 ] ; then ## Free Form echo ' $(COMPTRU90) $(LIBF)/'$trufile' ; \' else echo ' $(COMPILE90) $(LIBF)/'$trufile' ; \' fi fi # Put generated object in library echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' echo ' cd $(GCM)' echo done # echo cd $libf ############################## ## CAS DES FICHIERS EN C ###### elif [ "`ls $diri/*.c`" != "" ] ; then cd $diri >/dev/null 2>&1 echo listlib="" for i in `ls *.c` do fili=`basename $i .c` # Check if file is a function or main program # i.e. look for "int main" keywords (with possibly some leading spaces) test=` ( head $i | grep '^ \{0,\}int main' ) ` if [ "$test" = "" ] ; then # if it is not a main program, add it to the list listlib=$listlib" "$fili fi done # echo echo echo '#=======================================================================' echo '# Contenu de la bibliotheque correspondant au Directory '$diri echo '#=======================================================================' echo for fili in $listlib do echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)" echo done echo '.PRECIOUS : $(LIBO)/lib'$diri'.a' echo echo echo '# Compilation des membres de la bibliotheque lib'$diri'.a' echo for fili in $listlib do str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$fili.c for stri in ` ( sed -n "/\#include/s/\#include//p" $fili.c | sed 's/\"//g' ) ` do if [ -f $stri ] ; then echo $str1 \\ str1='$(LIBF)/'$diri'/'$stri else for dirinc in dyn3d grid bibio do if [ -f ../$dirinc/$stri ] ; then echo $str1 \\ str1='$(LIBF)/'`cd .. ; ls */$stri | head -1` fi done fi done echo $str1 # Compile in LIBO directory; and before compiling, remove # object from library echo ' cd $(LIBO); \' echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \' ## C echo ' $(COMPILEC) $(LIBF)/'$diri'/'$fili'.c; \' # Put generated object in library echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \' echo ' cd $(GCM)' echo done # echo cd $libf ############################## fi fi done