source: trunk/LMDZ.COMMON/create_make_gcm @ 1641

Last change on this file since 1641 was 1521, checked in by emillour, 9 years ago

All GCMs: Updates to make planetary codes (+Earth) setups converge.

  • Made a "phy_common" directory in libf, to contain routines common (wrt structural nature of underlying code/grid) to all LMDZ-related physics packages.
  • moved all "mod_phys_*" and "mod_grid_phy_lmdz" files from dynlonlat_phylonlat to "phy_common"
  • moved "ioipsl_getincom_p.F90 from "misc" to "phy_common" and modified it to match Earth GCM version and renamed it ioipsl_getin_p_mod.F90
  • added an "abort_physics" (as in Earth GCM) in "phy_common"
  • added a "print_control_mod.F90 (as in Earth GCM) in phy_common
  • made similar changes in LMDZ.GENERIC and LMDZ.MARS

EM

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