source: trunk/LMDZ.COMMON/create_make_gcm @ 1391

Last change on this file since 1391 was 1391, checked in by emillour, 10 years ago

Common dynamical core:
Updates in the dynamics to keeup up with updates in LMDZ5
(up to LMDZ5 trunk rev 2200):

  • compilation:
  • create_make_gcm : added processing of .f & .f90 files (not just .F and .F90)
  • makelmdz: add "mix" option for -io (ouptut with both IOIPSL and XIOS)
  • makelmdz_fcm: add "mix" option for -io
  • filtrez:
  • acc.F and eigen.F : add "implicit none" and variable declarations
  • bibio:
  • handle_err_m.F90: replace "stop" with call to abort_gcm()
  • i1mach.F, j4save.F: add "implicit none" and variable declarations
  • xercnt.F, xermsg.F, xerprn.F, xersve.F, xgetua.F: add "implicit none" and variable declarations
  • dyn3d_common:
  • disvert.F90 : added comments on meaning of "pa" variable
  • grid_atob.F : better control on level of default ouputs
  • infotrac.F90: update Earth-specific stuff (nqo water tracers)
  • interpre.F: correction on the size of input array w
  • juldate.F, massbar.F, ppm3d.F, ran1.F: add "implicit none" and variable declarations
  • sortvarc.F: code cleanup
  • iniacademic.F90: cleanup and extra sanity check.
  • dyn3d:
  • abort_gcm.F: additions for XIOS
  • conf_gcm.F90: transformed to free form from conf_gcm.F
  • gcm.F: added test to check that iphysiq is a multiple of iperiod
  • getparam.F90, guidz_mod.F: update from LMDZ5
  • integrd.F: replace stop with call_abort()
  • dyn3dpar:
  • abort_gcm.F: minor cleanup
  • gcm.F: added test to check that iphysiq is a multiple of iperiod
  • getparam.F90, guide_p_mod.F90: update from LMDZ5
  • integrd_p.F: abort with call_abort when there is negative surface pressure
  • leapfrog_p.F: add INCA specific stuff to keep up with current LMDZ5
  • conf_gcm.F90: transformed to free form from conf_gcm.F

EM

File size: 11.4 KB
Line 
1#!/bin/sh
2#
3# $Id: create_make_gcm 1461 2010-12-03 11:12:25Z emillour $
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 'LIBPHY = $(LIBO)/libphy$(PHYS).a'
55echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)'
56echo 'RM=rm'
57echo
58echo "OPLINK = "
59echo
60echo '# Les differentes librairies pour l"edition des liens:'
61echo 'L_DYN      = -ldyn$(DIM)d$(FLAG_PARA) -ldyn3d_common'
62echo 'L_FILTRE   = -l$(FILTRE)'
63echo 'L_PHY = -lphy$(PHYS) '
64echo 'L_BIBIO    = -lbibio'
65echo 'L_ADJNT    ='
66echo 'L_COSP     = -lcosp'
67echo 'L_AERONOMARS = -laeronomars'
68
69echo
70echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
71echo "# Option de compilation FORTRAN"
72echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
73echo
74   echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c'
75   echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c'
76   echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c'
77   echo "LINK    = $LINK"
78   echo "AR      = $AR"
79echo
80echo
81echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
82echo '# Option de compilation C'
83echo '#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
84echo
85echo 'COMPILEC = $(CCC) $(OPTIMC) $(INCLUDEC) -c'
86echo
87echo
88echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
89echo "# Creation des differents executables"
90echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
91echo
92echo "# Executables:"
93echo "# ------------"
94echo
95echo "PROG = code"
96echo 'DYN  = dyn$(DIM)d'
97echo
98#echo 'main : chimie $(DYN) bibio phys $(OPTION_DEP) '
99echo 'main : $(DYN) bibio phys $(OPTION_DEP) '
100echo '  cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\'
101echo '  cd $(LOCAL_DIR); \'
102echo '  $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \'
103echo '  $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_ADJNT) $(L_COSP) $(L_AERONOMARS) $(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 '
104echo
105echo 'phys : $(LIBPHY)'
106echo 'dyn3d : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(LIBO)/lib$(FILTRE).a $(LIBO)/libdyn3d_common.a'
107echo 'dyn2d : $(LIBO)/libdyn2d.a'
108echo 'dyn1d :'
109echo
110echo
111#echo 'chimie : $(LIBO)/libchimie.a'
112echo
113echo 'bibio : $(LIBO)/libbibio.a'
114echo
115echo 'adjnt : $(LIBO)/libadjnt.a'
116echo
117echo 'cosp : $(LIBO)/libcosp.a'
118echo
119echo 'chimtitan : $(LIBO)/libchimtitan.a'
120echo 
121echo 'aeronomars : $(LIBO)/libaeronomars.a'
122echo
123echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a'
124echo
125echo '$(FILTRE)2d :'
126echo
127echo '$(FILTRE)1d :'
128echo
129echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
130echo "# Contenu des differentes bibliotheques"
131echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
132echo
133echo
134cd $libf >/dev/null 2>&1
135for diri in ` ls ` ; do
136
137   if [ -d $diri ] ; then
138   if [ "`ls $diri/*.F $diri/*/*.F`" != "" ] || [ "`ls $diri/*.[fF]90 $diri/*/*.[fF]90`" != "" ]  ; then 
139#      cd $diri >/dev/null 2>&1
140      echo
141      listlib=""
142# Liste des fichiers .F et .F90 n'etant pas des programmes principaux
143      for fili in `ls $diri/*.[fF] $diri/*/*.[fF]` ; do
144         # Check if file is a routine or main program
145         # i.e: look for the "program" keword preceeded by leading spaces
146         test=` (  head $fili | grep -i '^ *program' ) `
147         if [ "$test" = "" ] ; then 
148            # if it is not a main program, add it to the list
149            listlib=$listlib" "$fili
150         fi
151      done
152      for fili in `ls $diri/*.[fF]90 $diri/*/*.[fF]90` ; do
153         # Check if file is a routine or main program
154         # i.e. look for "program" keyword (with possibly some leading spaces)
155         test=` (  head $fili | grep -i '^ \{0,\}program' ) `
156         if [ "$test" = "" ] ; then
157            # if it is not a main program, add it to the list
158            listlib=$listlib" "$fili
159         fi 
160      done
161#
162      echo
163      echo $listlib >> $logfile
164      echo
165      echo "#======================================================================="
166      echo "# Contenu de la bibliotheque correspondant au Directory "$diri
167      echo "#======================================================================="
168      echo
169      for trufile in $listlib
170      do
171         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
172         echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)"
173         echo
174      done
175      echo '.PRECIOUS   : $(LIBO)/lib'$diri'.a'
176      echo
177      echo
178      echo "# Compilation des membres de la bibliotheque lib"$diri".a"
179      echo
180      for trufile in $listlib ; do
181         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
182         F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1
183                 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1
184                 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1
185         str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$trufile
186         [ "$fili" = "chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F
187
188##########################################################################
189# TRAITEMENT DES DEPENDANCES
190# Differents cas de dependance correspondant a des include ou des
191# use module.
192# soit dans le repertoire local soit dans un autre.
193# Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN
194# ou quelque chose du genre.
195##########################################################################
196
197         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
198            echo $trufile $fili $stri >> $logfile
199            strj=`echo $stri | tr [A-Z] [a-z]`
200            str2=""
201            for dirinc in filtrez bibio dyn3d_common grid dyn3d phy* $diri $diri/*/ ; do
202# Recherche dans l'ordre hierarchique inverse car seule la derniere
203# ligne est conservee
204               if [ $dirinc = phydev ] ; then
205                   dirstr='$(PHYS)'
206                   libstr='phy$(PHYS)'
207               else
208                   dirstr=$dirinc
209                   libstr=$dirinc
210               fi
211               echo dirinc $dirinc >> $logfile
212               if [ -f $dirinc/$stri ] ; then
213                  str2='$(LIBF)/'$dirstr/$stri
214               elif [ -f $dirinc/$strj ] ; then
215                  str2='$(LIBF)/'$dirstr/$stri
216               elif [ -f $dirinc/$strj.[fF]90 ]  || [ -f $dirinc/$strj.[fF] ]  ; then 
217                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
218                  str2='$(LIBO)/lib'$strlib'.a('$strj'.o)'
219               elif [ -f $dirinc/$stri.[fF]90 ]  || [ -f $dirinc/$stri.[fF] ]  ; then 
220                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
221                  str2='$(LIBO)/lib'$strlib'.a('$stri'.o)'
222               fi
223               echo stri $stri  >> $logfile
224               echo str2 $str2  >> $logfile
225            done
226               echo dernier str2 $str2  >> $logfile
227            if [ "$str2" = "" ] ; then
228               echo Warn: Include $diri $trufile $fili $stri pas trouve >> $logfile
229            elif [ "$str2" = "$str1" ] ; then
230               echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $logfile
231            else
232               echo $str1 \\
233               str1=$str2
234            fi
235         done # Fin de la boucle sur les dependances et ecriture de la derniere
236         echo $str1
237         # Compile in LIBO directory; and before compiling, remove
238         # object from library
239         echo ' cd $(LIBO); \'
240         echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \'
241         if [ "$F90" -eq '0' ] ; then
242         ## Fixed Form Fortran 77
243           echo '       $(COMPILE) $(LIBF)/'$trufile' ; \'
244         else
245         ## Fortran 90
246           if [ -f $fili.F90 ] ; then
247              ## Free Form
248              echo '    $(COMPTRU90) $(LIBF)/'$trufile' ; \'
249           else
250              echo '    $(COMPILE90) $(LIBF)/'$trufile' ; \'
251           fi
252         fi
253         # Put generated object in library
254         echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
255         echo ' cd $(GCM)'
256         echo
257      done
258#       
259      echo
260      cd $libf
261##############################
262## CAS DES FICHIERS EN C
263######
264   elif [ "`ls $diri/*.c`" != "" ] ; then 
265      cd $diri >/dev/null 2>&1
266      echo
267      listlib=""
268      for i in `ls *.c`
269      do
270         fili=`basename $i .c`
271         # Check if file is a function or main program
272         # i.e. look for "int main" keywords (with possibly some leading spaces)
273         test=` (  head $i | grep '^ \{0,\}int main' ) `
274         if [ "$test" = "" ] ; then 
275            # if it is not a main program, add it to the list
276            listlib=$listlib" "$fili
277         fi
278      done
279#
280      echo
281      echo
282      echo '#======================================================================='
283      echo '# Contenu de la bibliotheque correspondant au Directory '$diri
284      echo '#======================================================================='
285      echo
286      for fili in $listlib
287      do
288         echo '$(LIBO)/lib'$diri".a : " '$(LIBO)/lib'$diri".a("$fili".o)"
289         echo
290      done
291      echo '.PRECIOUS   : $(LIBO)/lib'$diri'.a'
292      echo
293      echo
294      echo '# Compilation des membres de la bibliotheque lib'$diri'.a'
295      echo
296      for fili in $listlib
297      do
298         str1='$(LIBO)/lib'$diri'.a('$fili'.o) : $(LIBF)/'$diri/$fili.c
299         for stri in ` ( sed -n "/\#include/s/\#include//p" $fili.c  | sed 's/\"//g' ) `
300         do
301            if [ -f $stri ] ; then
302               echo $str1 \\
303               str1='$(LIBF)/'$diri'/'$stri
304            else
305               for dirinc in dyn3d grid bibio
306               do
307                  if [ -f ../$dirinc/$stri ] ; then
308                     echo $str1 \\
309                     str1='$(LIBF)/'`cd .. ; ls */$stri | head -1`
310                  fi
311               done
312            fi
313         done
314         echo $str1
315         # Compile in LIBO directory; and before compiling, remove
316         # object from library
317         echo ' cd $(LIBO); \'
318         echo ' $(AR) d $(LIBO)/lib'$diri'.a '$fili'.o ; \'
319         ## C
320         echo ' $(COMPILEC) $(LIBF)/'$diri'/'$fili'.c; \'
321         # Put generated object in library
322         echo ' $(AR) r $(LIBO)/lib'$diri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
323         echo ' cd $(GCM)'
324         echo
325      done
326#       
327      echo
328      cd $libf
329##############################
330   fi
331   fi
332done
Note: See TracBrowser for help on using the repository browser.