source: LMDZ5/branches/testing/create_make_gcm @ 1999

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

Merged trunk changes r1920:1997 into testing branch

  • 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.5 KB
Line 
1#!/bin/sh
2#
3# $Id: create_make_gcm 1999 2014-03-20 09:57:19Z fairhead $
4#
5#set -xv
6
7
8machine=`hostname`
9os=`uname`
10gcm=`pwd`
11logfile=$gcm/create_make_gcm.log
12rm -f $logfile ; touch -f $logfile
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
23X6NEC=0
24if [ "$machine" = "mercure" ] ; then
25  X6NEC=1
26fi
27X8BRODIE=0
28if [ "$machine" = "brodie" ] ; then
29  X8BRODIE=1
30fi
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 'DYN3D_COMMON   = $(LIBF)/dyn3d_common'
52echo "FILTRE   = filtre"
53echo "PHYS  = "
54echo "DYN  = dyn "
55echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a'
56echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)'
57echo 'RM=rm'
58echo
59echo "OPLINK = "
60echo
61echo '# Les differentes librairies pour l"edition des liens:'
62echo
63echo 'dyn3d            = $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a'
64echo 'dyn3dpar      = $(LIBO)/libdyn3dpar.a $(LIBO)/lib$(FILTRE).a'
65echo 'dyn2d            = $(LIBO)/libdyn2d.a'
66echo 'dyn1d            = $(LIBO)/libdyn1d.a'
67echo 'L_DYN      = -ldyn$(DIM)d$(FLAG_PARA)'
68echo 'L_FILTRE   = -l$(FILTRE)'
69echo 'L_PHY = -lphy$(PHYS) '
70echo 'L_BIBIO    = -lbibio'
71echo 'L_DYN3D_COMMON    = -ldyn3d_common'
72echo 'L_ADJNT    ='
73echo 'L_COSP     = -lcosp'
74
75echo
76echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
77echo "# Option de compilation FORTRAN"
78echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
79echo
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"
85echo
86echo
87echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
88echo "# Creation des differents executables"
89echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
90echo
91echo "# Executables:"
92echo "# ------------"
93echo
94echo "PROG = code"
95echo
96#echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) '
97echo 'main : $(DYN) bibio dyn3d_common phys $(OPTION_DEP) '
98echo '  cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\'
99echo '  cd $(LOCAL_DIR); \'
100echo '  $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \'
101echo '  $(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 '
102echo
103echo 'dyn : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(FILTRE)$(DIM)d'
104echo
105echo 'phys : $(LIBPHY)'
106echo
107#echo 'chimie : $(LIBO)/libchimie.a'
108echo
109echo 'bibio : $(LIBO)/libbibio.a'
110echo
111echo 'dyn3d_common : $(LIBO)/libdyn3d_common.a'
112echo
113echo 'adjnt : $(LIBO)/libadjnt.a'
114echo
115echo 'cosp : $(LIBO)/libcosp.a'
116echo
117echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a'
118echo
119echo '$(FILTRE)2d :'
120echo
121echo '$(FILTRE)1d :'
122echo
123echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
124echo "# Contenu des differentes bibliotheques"
125echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
126echo
127echo
128cd $libf >/dev/null 2>&1
129
130for diri in ` ls ` ; do
131
132   if [ -d $diri ] ; then
133   if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.F90 $diri/*/*.F90`" != "" ]  ; then 
134#      cd $diri >/dev/null 2>&1
135      echo
136      listlib=""
137# Liste des fichiers .F et .F90 n'etant pas des programmes principaux
138      for fili in `ls $diri/*.F $diri/*/*.F` ; do
139         test=` (  head $fili | grep '      PROGRAM' ) `
140         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi
141      done
142      for fili in `ls $diri/*.F90 $diri/*/*.F90` ; do
143         test=` (  head $fili | grep 'PROGRAM' ) `
144         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi 
145      done
146      echo
147      echo $listlib >> $logfile
148      echo
149      echo "#=================================================================="
150      echo "# Contenu de la bibliotheque correspondant au Directory "$diri
151      echo "#=================================================================="
152      echo
153      for trufile in $listlib ; do
154         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
155         echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)"
156         echo
157      done
158      echo '.PRECIOUS   : $(LIBO)/lib'$diri'.a'
159      echo
160      echo
161      echo "# Compilation des membres de la bibliotheque lib"$diri".a"
162      echo
163      for trufile in $listlib ; do
164         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
165         F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1
166                 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1
167                 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1
168         str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile
169         [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F
170
171##########################################################################
172# TRAITEMENT DES DEPENDANCES
173# Differents cas de dependance correspondant a des include ou des
174# use module.
175# soit dans le repertoire local soit dans un autre.
176# Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN
177# ou quelque chose du genre.
178##########################################################################
179
180         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
181            echo $trufile $fili $stri >> $logfile
182            strj=`echo $stri | tr [A-Z] [a-z]`
183            str2=""
184            for dirinc in filtrez bibio dyn3d_common grid dyn3d phydev $diri $diri/*/ ; do
185# Recherche dans l'ordre hierarchique inverse car seule la derniere
186# ligne est conservee
187               if [ $dirinc = phydev ] ; then
188                   dirstr='$(PHYS)'
189                   libstr='phy$(PHYS)'
190               else
191                   dirstr=$dirinc
192                   libstr=$dirinc
193               fi
194               echo dirinc $dirinc >> $logfile
195               if [ -f $dirinc/$stri ] ; then
196                  str2='$(LIBF)/'$dirstr/$stri
197               elif [ -f $dirinc/$strj ] ; then
198                  str2='$(LIBF)/'$dirstr/$stri
199               elif [ -f $dirinc/$strj.F90 ]  || [ -f $dirinc/$strj.F ]  ; then 
200                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
201                  str2='$(LIBO)/lib'$strlib'.a('$strj'.o)'
202               elif [ -f $dirinc/$stri.F90 ]  || [ -f $dirinc/$stri.F ]  ; then 
203                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
204                  str2='$(LIBO)/lib'$strlib'.a('$stri'.o)'
205               fi
206               echo stri $stri  >> $logfile
207               echo str2 $str2  >> $logfile
208            done
209               echo dernier str2 $str2  >> $logfile
210            if [ "$str2" = "" ] ; then
211               echo Warn: Include $diri $trufile $fili $stri pas trouve >> $logfile
212            elif [ "$str2" = "$str1" ] ; then
213               echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $logfile
214            else
215               echo $str1 \\
216               str1=$str2
217            fi
218         done # Fin de la boucle sur les dependances et ecriture de la derniere
219         echo $str1
220         # Compile in LIBO directory; and before compiling, remove
221         # object from library
222         echo ' cd $(LIBO); \'
223         echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \'
224         if [ "$F90" -eq '0' ] ; then
225         ## Fixed Form Fortran 77
226           echo '       $(COMPILE) $(LIBF)/'$trufile' ; \'
227         else
228         ## Fortran 90
229           if [ `echo $trufile | cut -d. -f2` = F90 ] ; then
230              ## Free Form
231              echo '    $(COMPTRU90) $(LIBF)/'$trufile' ; \'
232           else
233              echo '    $(COMPILE90) $(LIBF)/'$trufile' ; \'
234           fi
235         fi
236         # Put generated object in library
237         echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
238         echo
239      done
240#       
241      echo
242   cd $libf
243   fi
244   fi
245done
Note: See TracBrowser for help on using the repository browser.