source: LMDZ6/trunk/create_make_gcm @ 3133

Last change on this file since 3133 was 3045, checked in by Ehouarn Millour, 7 years ago

Adapt makelmdz* and related scripts to read "ar" options from arch files.
EM

  • 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: 9.0 KB
RevLine 
[524]1#!/bin/sh
2#
[1492]3# $Id: create_make_gcm 3045 2017-10-26 13:45:43Z fairhead $
[524]4#
5#set -xv
[1714]6
[2238]7# arguments given to create_make_gcm are the directories to scan
8src_dirs=$*
[1714]9
[524]10machine=`hostname`
11os=`uname`
12gcm=`pwd`
[1990]13logfile=$gcm/create_make_gcm.log
14rm -f $logfile ; touch -f $logfile
[524]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
[536]25X6NEC=0
26if [ "$machine" = "mercure" ] ; then
27  X6NEC=1
28fi
[768]29X8BRODIE=0
30if [ "$machine" = "brodie" ] ; then
31  X8BRODIE=1
32fi
[524]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`"
[2239]52echo 'MISC    = $(LIBF)/misc'
[524]53echo "FILTRE   = filtre"
54echo "PHYS  = "
55echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a'
[2326]56echo 'LIBPHY_COMMON= $(LIBO)/libphy_common.a'
[2239]57echo 'LIBDYN_PHY = $(LIBO)/libdynlmdz_phy$(PHYS).a'
[768]58echo 'DIRMAIN=dyn$(DIM)d$(FLAG_PARA)'
[524]59echo 'RM=rm'
60echo
61echo "OPLINK = "
62echo
63echo '# Les differentes librairies pour l"edition des liens:'
[2016]64echo 'L_DYN      = -ldyn$(DIM)d$(FLAG_PARA) -ldyn3d_common'
[1492]65echo 'L_FILTRE   = -l$(FILTRE)'
[2239]66echo 'L_DYN_PHY = -ldynlmdz_phy$(PHYS) '
[2326]67echo 'L_PHY = -lphy$(PHYS) -lphy_common'
[2239]68echo 'L_MISC    = -lmisc'
[1492]69echo 'L_ADJNT    ='
[1666]70echo 'L_COSP     = -lcosp'
[768]71
[524]72echo
73echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
74echo "# Option de compilation FORTRAN"
75echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
76echo
77   echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c'
78   echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c'
79   echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c'
[3045]80   echo 'LINK    = $(LINK)'
81   echo 'AR      = $(AR)'
82   echo 'ARFLAGS   = $(ARFLAGS)'
[524]83echo
84echo
85echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
86echo "# Creation des differents executables"
87echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
88echo
89echo "# Executables:"
90echo "# ------------"
91echo
92echo "PROG = code"
[2018]93echo 'DYN  = dyn$(DIM)d'
[524]94echo
[2239]95#echo 'main : chimie $(DYN) misc phys $(OPTION_DEP) '
[2326]96echo 'main : $(DYN) misc phys phy_common dyn_phy $(OPTION_DEP) '
[524]97echo '  cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\'
98echo '  cd $(LOCAL_DIR); \'
[1403]99echo '  $(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \'
[2239]100echo '  $(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_DYN_PHY) $(L_ADJNT) $(L_COSP) $(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 '
[524]101echo
102echo 'phys : $(LIBPHY)'
[2326]103echo 'phy_common : $(LIBPHY_COMMON)'
[2018]104echo 'dyn3d : $(LIBO)/libdyn$(DIM)d$(FLAG_PARA).a $(LIBO)/lib$(FILTRE).a $(LIBO)/libdyn3d_common.a'
105echo 'dyn2d : $(LIBO)/libdyn2d.a'
106echo 'dyn1d :'
[524]107echo
[2239]108echo 'dyn_phy: $(LIBDYN_PHYS)'
[2018]109echo
[768]110#echo 'chimie : $(LIBO)/libchimie.a'
111echo
[2239]112echo 'misc : $(LIBO)/libmisc.a'
[524]113echo
114echo 'adjnt : $(LIBO)/libadjnt.a'
115echo
[1666]116echo 'cosp : $(LIBO)/libcosp.a'
[1279]117echo
[524]118echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a'
119echo
120echo '$(FILTRE)2d :'
121echo
122echo '$(FILTRE)1d :'
123echo
124echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
125echo "# Contenu des differentes bibliotheques"
126echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
127echo
128echo
129cd $libf >/dev/null 2>&1
[1714]130
[2238]131for diri in $src_dirs ; do
[1714]132
[524]133   if [ -d $diri ] ; then
[2238]134   if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.[fF]90`" != "" ]  ; then 
[1714]135#      cd $diri >/dev/null 2>&1
[524]136      echo
137      listlib=""
[1714]138# Liste des fichiers .F et .F90 n'etant pas des programmes principaux
[2238]139      for fili in `ls $diri/*.[fF]` ; do
140         # Check if file is a routine or main program
141         # i.e: look for the "program" keword preceeded by leading spaces
142         test=` (  head $fili | grep -i '^ *program' ) `
143         # if it is not a main program, add it to the list
[1714]144         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi
[524]145      done
[2238]146      for fili in `ls $diri/*.[fF]90` ; do
147         # Check if file is a routine or main program
148         # i.e. look for "program" keyword (with possibly some leading spaces)
149         test=` (  head $fili | grep -i '^ \{0,\}program' ) `
150         # if it is not a main program, add it to the list
[1714]151         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi 
[524]152      done
153      echo
[1990]154      echo $listlib >> $logfile
[524]155      echo
[2238]156      # topdiri contains main dir name (without trailing "/blabla" for subdirs)
157      topdiri=${diri%/*}
[1714]158      echo "#=================================================================="
[524]159      echo "# Contenu de la bibliotheque correspondant au Directory "$diri
[1714]160      echo "#=================================================================="
[524]161      echo
[1714]162      for trufile in $listlib ; do
163         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
[2238]164         echo '$(LIBO)/lib'$topdiri".a : " '$(LIBO)/lib'$topdiri".a("$fili".o)"
[524]165         echo
166      done
[2238]167      echo '.PRECIOUS   : $(LIBO)/lib'$topdiri'.a'
[524]168      echo
169      echo
[2238]170      echo "# Compilation of elements in $diri of library lib"$topdiri".a"
[524]171      echo
[1714]172      for trufile in $listlib ; do
173         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
[524]174         F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1
175                 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1
[536]176                 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1
[2238]177         str1='$(LIBO)/lib'$topdiri'.a('$fili'.o) : $(LIBF)/'$trufile
[1714]178         [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F
[1112]179
[1714]180##########################################################################
181# TRAITEMENT DES DEPENDANCES
[1112]182# Differents cas de dependance correspondant a des include ou des
183# use module.
184# soit dans le repertoire local soit dans un autre.
[1714]185# Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN
186# ou quelque chose du genre.
187##########################################################################
[1112]188
[1962]189         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
[1990]190            echo $trufile $fili $stri >> $logfile
[1714]191            strj=`echo $stri | tr [A-Z] [a-z]`
192            str2=""
[2238]193            for dirinc in $src_dirs ; do
[1714]194# Recherche dans l'ordre hierarchique inverse car seule la derniere
195# ligne est conservee
[2238]196#               if [ $dirinc = phydev ] ; then
197#                   dirstr='$(PHYS)'
198#                   libstr='phy$(PHYS)'
199#               else
[1810]200                   dirstr=$dirinc
201                   libstr=$dirinc
[2238]202#               fi
[1990]203               echo dirinc $dirinc >> $logfile
[1714]204               if [ -f $dirinc/$stri ] ; then
[1810]205                  str2='$(LIBF)/'$dirstr/$stri
[1714]206               elif [ -f $dirinc/$strj ] ; then
[1810]207                  str2='$(LIBF)/'$dirstr/$stri
[2085]208               elif [ -f $dirinc/$strj.[fF]90 ]  || [ -f $dirinc/$strj.[fF] ]  ; then 
[1810]209                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
[1714]210                  str2='$(LIBO)/lib'$strlib'.a('$strj'.o)'
[2085]211               elif [ -f $dirinc/$stri.[fF]90 ]  || [ -f $dirinc/$stri.[fF] ]  ; then 
[1865]212                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
213                  str2='$(LIBO)/lib'$strlib'.a('$stri'.o)'
[1714]214               fi
[1990]215               echo stri $stri  >> $logfile
216               echo str2 $str2  >> $logfile
[1714]217            done
[1990]218               echo dernier str2 $str2  >> $logfile
[1714]219            if [ "$str2" = "" ] ; then
[1990]220               echo Warn: Include $diri $trufile $fili $stri pas trouve >> $logfile
[1714]221            elif [ "$str2" = "$str1" ] ; then
[1990]222               echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $logfile
[1714]223            else
[524]224               echo $str1 \\
[1714]225               str1=$str2
[524]226            fi
[1714]227         done # Fin de la boucle sur les dependances et ecriture de la derniere
[524]228         echo $str1
[1492]229         # Compile in LIBO directory; and before compiling, remove
230         # object from library
231         echo ' cd $(LIBO); \'
[3045]232         echo ' $(AR) -d $(LIBO)/lib'$topdiri'.a '$fili'.o ; \'
[768]233         if [ "$F90" -eq '0' ] ; then
[1492]234         ## Fixed Form Fortran 77
[1714]235           echo '       $(COMPILE) $(LIBF)/'$trufile' ; \'
[524]236         else
[1492]237         ## Fortran 90
[1714]238           if [ `echo $trufile | cut -d. -f2` = F90 ] ; then
[1492]239              ## Free Form
[1714]240              echo '    $(COMPTRU90) $(LIBF)/'$trufile' ; \'
[524]241           else
[1714]242              echo '    $(COMPILE90) $(LIBF)/'$trufile' ; \'
[524]243           fi
244         fi
[1492]245         # Put generated object in library
[3045]246         echo ' $(AR) $(ARFLAGS) $(LIBO)/lib'$topdiri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
[524]247         echo
248      done
249#       
250      echo
251   cd $libf
252   fi
253   fi
254done
Note: See TracBrowser for help on using the repository browser.