source: LMDZ5/branches/testing/create_make_gcm @ 2283

Last change on this file since 2283 was 2160, checked in by Laurent Fairhead, 10 years ago

Merged trunk changes -r2070:2158 into testing branch. Compilation problems introduced by revision r2155 have been corrected by hand

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.2 KB
RevLine 
[524]1#!/bin/sh
2#
[1492]3# $Id: create_make_gcm 2160 2014-11-28 15:36:29Z fairhead $
[524]4#
5#set -xv
[1750]6
7
[524]8machine=`hostname`
9os=`uname`
10gcm=`pwd`
[1999]11logfile=$gcm/create_make_gcm.log
12rm -f $logfile ; touch -f $logfile
[524]13libf=$gcm/libf
14libo=$gcm/libo
15CRAY=0
16if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then
17  CRAY=1
18fi
19XNEC=0
20if [ "$machine" = "rhodes" ] ; then
21  XNEC=1
22fi
[536]23X6NEC=0
24if [ "$machine" = "mercure" ] ; then
25  X6NEC=1
26fi
[768]27X8BRODIE=0
28if [ "$machine" = "brodie" ] ; then
29  X8BRODIE=1
30fi
[524]31VPP=0
32if [ "$machine" = "nymphea0" ] ; then
33  VPP=1
34fi
35#
36echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
37echo "# Definitions de Macros pour Make"
38echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
39echo
40echo "# Repertoires :"
41echo
42echo "GCM     = "$gcm
43echo 'LIBF    = $(GCM)/libf'
44if [ "$CRAY" = '0' ] ; then
45   echo 'LIBO    = $(LIBOGCM)/$(MACHINE)'
46else
47   echo 'LIBO    = $(GCM)/libo'
48fi
49echo "LOCAL_DIR=`echo $localdir`"
50echo 'BIBIO    = $(LIBF)/bibio'
51echo "FILTRE   = filtre"
52echo "PHYS  = "
53echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a'
[768]54echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)'
[524]55echo 'RM=rm'
56echo
57echo "OPLINK = "
58echo
59echo '# Les differentes librairies pour l"edition des liens:'
[2056]60echo 'L_DYN      = -ldyn$(DIM)d$(FLAG_PARA) -ldyn3d_common'
[1492]61echo 'L_FILTRE   = -l$(FILTRE)'
62echo 'L_PHY = -lphy$(PHYS) '
63echo 'L_BIBIO    = -lbibio'
64echo 'L_ADJNT    ='
65echo 'L_COSP     = -lcosp'
[768]66
[524]67echo
68echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
69echo "# Option de compilation FORTRAN"
70echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
71echo
72   echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c'
73   echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c'
74   echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c'
75   echo "LINK    = $LINK"
76   echo "AR      = $AR"
77echo
78echo
79echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
80echo "# Creation des differents executables"
81echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
82echo
83echo "# Executables:"
84echo "# ------------"
85echo
86echo "PROG = code"
[2056]87echo 'DYN  = dyn$(DIM)d'
[524]88echo
[768]89#echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) '
[2056]90echo 'main : $(DYN) bibio phys $(OPTION_DEP) '
[524]91echo '  cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\'
92echo '  cd $(LOCAL_DIR); \'
[1403]93echo '  $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \'
[1999]94echo '  $(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]95echo
96echo 'phys : $(LIBPHY)'
[2056]97echo 'dyn3d : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(LIBO)/lib$(FILTRE).a $(LIBO)/libdyn3d_common.a'
98echo 'dyn2d : $(LIBO)/libdyn2d.a'
99echo 'dyn1d :'
[524]100echo
[2056]101echo
[768]102#echo 'chimie : $(LIBO)/libchimie.a'
103echo
[524]104echo 'bibio : $(LIBO)/libbibio.a'
105echo
106echo 'adjnt : $(LIBO)/libadjnt.a'
107echo
[1279]108echo 'cosp : $(LIBO)/libcosp.a'
109echo
[524]110echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a'
111echo
112echo '$(FILTRE)2d :'
113echo
114echo '$(FILTRE)1d :'
115echo
116echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
117echo "# Contenu des differentes bibliotheques"
118echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
119echo
120echo
121cd $libf >/dev/null 2>&1
[1750]122
123for diri in ` ls ` ; do
124
[524]125   if [ -d $diri ] ; then
[2160]126   if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.[fF]90 $diri/*/*.[fF]90`" != "" ]  ; then 
[1750]127#      cd $diri >/dev/null 2>&1
[524]128      echo
129      listlib=""
[1750]130# Liste des fichiers .F et .F90 n'etant pas des programmes principaux
[2160]131      for fili in `ls $diri/*.[fF] $diri/*/*.[fF]` ; do
[1750]132         test=` (  head $fili | grep '      PROGRAM' ) `
133         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi
[524]134      done
[2160]135      for fili in `ls $diri/*.[fF]90 $diri/*/*.[fF]90` ; do
[1750]136         test=` (  head $fili | grep 'PROGRAM' ) `
137         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi 
[524]138      done
139      echo
[1999]140      echo $listlib >> $logfile
[524]141      echo
[1750]142      echo "#=================================================================="
[524]143      echo "# Contenu de la bibliotheque correspondant au Directory "$diri
[1750]144      echo "#=================================================================="
[524]145      echo
[1750]146      for trufile in $listlib ; do
147         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
[524]148         echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)"
149         echo
150      done
151      echo '.PRECIOUS   : $(LIBO)/lib'$diri'.a'
152      echo
153      echo
154      echo "# Compilation des membres de la bibliotheque lib"$diri".a"
155      echo
[1750]156      for trufile in $listlib ; do
157         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
[524]158         F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1
159                 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1
[536]160                 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1
[1750]161         str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile
162         [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F
[1112]163
[1750]164##########################################################################
165# TRAITEMENT DES DEPENDANCES
[1112]166# Differents cas de dependance correspondant a des include ou des
167# use module.
168# soit dans le repertoire local soit dans un autre.
[1750]169# Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN
170# ou quelque chose du genre.
171##########################################################################
[1112]172
[1999]173         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
174            echo $trufile $fili $stri >> $logfile
[1750]175            strj=`echo $stri | tr [A-Z] [a-z]`
176            str2=""
[1999]177            for dirinc in filtrez bibio dyn3d_common grid dyn3d phydev $diri $diri/*/ ; do
[1750]178# Recherche dans l'ordre hierarchique inverse car seule la derniere
179# ligne est conservee
[1864]180               if [ $dirinc = phydev ] ; then
181                   dirstr='$(PHYS)'
182                   libstr='phy$(PHYS)'
183               else
184                   dirstr=$dirinc
185                   libstr=$dirinc
186               fi
[1999]187               echo dirinc $dirinc >> $logfile
[1750]188               if [ -f $dirinc/$stri ] ; then
[1864]189                  str2='$(LIBF)/'$dirstr/$stri
[1750]190               elif [ -f $dirinc/$strj ] ; then
[1864]191                  str2='$(LIBF)/'$dirstr/$stri
[2160]192               elif [ -f $dirinc/$strj.[fF]90 ]  || [ -f $dirinc/$strj.[fF] ]  ; then 
[1864]193                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
[1750]194                  str2='$(LIBO)/lib'$strlib'.a('$strj'.o)'
[2160]195               elif [ -f $dirinc/$stri.[fF]90 ]  || [ -f $dirinc/$stri.[fF] ]  ; then 
[1910]196                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
197                  str2='$(LIBO)/lib'$strlib'.a('$stri'.o)'
[1750]198               fi
[1999]199               echo stri $stri  >> $logfile
200               echo str2 $str2  >> $logfile
[1750]201            done
[1999]202               echo dernier str2 $str2  >> $logfile
[1750]203            if [ "$str2" = "" ] ; then
[1999]204               echo Warn: Include $diri $trufile $fili $stri pas trouve >> $logfile
[1750]205            elif [ "$str2" = "$str1" ] ; then
[1999]206               echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $logfile
[1750]207            else
[524]208               echo $str1 \\
[1750]209               str1=$str2
[524]210            fi
[1750]211         done # Fin de la boucle sur les dependances et ecriture de la derniere
[524]212         echo $str1
[1492]213         # Compile in LIBO directory; and before compiling, remove
214         # object from library
215         echo ' cd $(LIBO); \'
216         echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \'
[768]217         if [ "$F90" -eq '0' ] ; then
[1492]218         ## Fixed Form Fortran 77
[1750]219           echo '       $(COMPILE) $(LIBF)/'$trufile' ; \'
[524]220         else
[1492]221         ## Fortran 90
[1750]222           if [ `echo $trufile | cut -d. -f2` = F90 ] ; then
[1492]223              ## Free Form
[1750]224              echo '    $(COMPTRU90) $(LIBF)/'$trufile' ; \'
[524]225           else
[1750]226              echo '    $(COMPILE90) $(LIBF)/'$trufile' ; \'
[524]227           fi
228         fi
[1492]229         # Put generated object in library
[524]230         echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
231         echo
232      done
233#       
234      echo
235   cd $libf
236   fi
237   fi
238done
Note: See TracBrowser for help on using the repository browser.