source: LMDZ5/trunk/makelmdz @ 2682

Last change on this file since 2682 was 2631, checked in by fhourdin, 8 years ago

Modification de makelmdz et makelmdz_fcm pour les aerosols

  • 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:executable set to *
File size: 22.4 KB
RevLine 
[1463]1#!/bin/bash
2#
[1695]3# $Id$
[1463]4#
5#
6########################################################################
7# for debug, uncomment line below
8#set -xv
9########################################################################
10# options par defaut pour la commande make
11########################################################################
12dim="96x72x19"
13physique=lmd
14code=gcm
15filtre=filtrez
16grille=reg
17couple=false
18veget=false
19chimie=false
20parallel=none
[1690]21paramem="par"
[1463]22compil_mod=prod
23io=ioipsl
24LIBPREFIX=""
25fcm_path=none
26cosp=false
[1865]27sisvat=false
[1990]28rrtm=false
[2631]29rrtm=false
30dust=false
[2112]31full=""
[1463]32
33# guess a default 'arch'
[1690]34arch="local" # start with assuming we're on a local machine with local arch file
[1463]35## try to recognise machine and infer arch from it
36machine=`hostname`
[1897]37if [[ "${machine:0:3}" == "ada" ]]
[1463]38then
[1897]39  arch="X64_ADA"
[1463]40fi
41if [[ "${machine:0:7}" == "platine" ]]
42then
43  arch="IA64_PLATINE"
44fi
45if [[ "${machine:0:6}" == "titane" ]]
46then
47  arch="X64_TITANE"
48fi
49if [[ "${machine:0:8}" == "mercure1" ]]
50then
51  arch="SX8_MERCURE"
52fi
53if [[ "${machine:0:8}" == "mercure2" ]]
54then
55  arch="SX9_MERCURE"
56fi
57
58LMDGCM=`pwd -P`
59LIBFGCM=$LMDGCM/libf
60LIBOGCM=$LMDGCM/libo
61if [[ ! -d $LIBOGCM ]]
62then
63  # create the directory
64  mkdir $LIBOGCM
65  if [[ ! $? ]]
66  then
67  echo "Failed to create directory $LIBOGCM"
68  exit
69  fi
70fi
71COSP_PATH=$LMDGCM/.void_dir
72
73
74
75localdir=`pwd -P`
76########################################################################
77#  Quelques initialisations de variables du shell.
78########################################################################
79
80CPP_KEY="" 
[2239]81INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. '
[1463]82LIB=""
83adjnt=""
84##COMPIL_FFLAGS="%PROD_FFLAGS"
85PARA_FFLAGS=""
86PARA_LD=""
87EXT_SRC=""
[2238]88#src_dirs: directories containing source files
[2239]89src_dirs="grid misc" 
[1463]90########################################################################
91# lecture des options
92########################################################################
93
94while (($# > 0))
95  do
96  case $1 in
97      "-h") cat <<fin
98Usage :
[1772]99makelmdz [options] -arch nom_arch exec
100[-h]                       : brief help
101[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
102[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
103[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug
104[-c false/MPI1/MPI2]       : coupling with ocean model : MPI1/MPI2/false (default: false)
105[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
106          false       : no vegetation model
107          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
108          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
109          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
110[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
[2238]111[-cosp true/false]    : compile with/without cosp package (default: false)
112[-sisvat true/false]  : compile with/without sisvat package (default: false)
113[-rrtm true/false]    : compile with/without rrtm package (default: false)
[2631]114[-dust true/false]    : compile with/without the dust package from Boucher et al. (default: false)
[1772]115[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
116[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
[2097]117[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
[1772]118[-include INCLUDES]        : extra include path to add
119[-cpp CPP_KEY]             : additional preprocessing definitions
120[-adjnt]                   : adjoint model, not operational ...
121[-mem]                     : reduced memory dynamics (if in parallel mode)
122[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
[2112]123[-full]                    : Full (re)compilation (from scratch)
[1772]124[-link LINKS]              : additional links with other libraries
125[-fcm_path path]           : path to the fcm tool (default: tools/fcm/bin)
126[-ext_src path]            : path to an additional set of routines to compile with the model
127 -arch nom_arch            : target architecture
128 exec                      : executable to build
[1463]129fin
130          exit;;
131      "-d")
132          dim=$2 ; shift ; shift ;;
133     
134      "-p")
135          physique="$2" ;  shift ; shift ;;
136
137      "-g")
138          grille="$2" ; shift ; shift ;;
139
140      "-c")
141          couple="$2" ; shift ; shift ;;
142
143      "-prod")
144          compil_mod="prod" ; shift ;;
145
146      "-dev")
147          compil_mod="dev" ; shift ;;
148
149      "-debug")
150          compil_mod="debug" ; shift ;;
151
152      "-io")
153          io="$2" ; shift ; shift ;;
154
155      "-v")
156          veget="$2" ; shift ; shift ;;
157
158      "-chimie")
159          chimie="$2" ; shift ; shift ;;
160
161      "-parallel")
162          parallel="$2" ; shift ; shift ;;
163     
164      "-include")
165          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
166
167      "-cpp")
168          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
169
170      "-cosp")
171          cosp="$2" ; shift ; shift ;;
[1690]172     
[1865]173      "-sisvat")
174          sisvat="$2" ; shift ; shift ;;
175     
[1990]176      "-rrtm")
177          rrtm="$2" ; shift ; shift ;;
[2631]178
179      "-dust")
180          dust="$2" ; shift ; shift ;;
[1990]181     
[1690]182      "-mem")
183          paramem="mem" ; shift ;;
[1463]184
185      "-filtre")
186          filtre=$2 ; shift ; shift ;;
187
[2112]188      "-full")
189      full="full" ; shift ;;
190
[1463]191      "-link")
192          LIB="$LIB $2" ; shift ; shift ;;
193
194      "-fcm_path")
195          fcm_path=$2 ; shift ; shift ;;
196
197      "-ext_src")
[2238]198          EXT_SRC=$2 ; src_dirs="$src_dirs $EXT_SRC" ; shift ; shift ;;
[1463]199
200      "-arch")
201          arch=$2 ; shift ; shift ;;
202
203      *)
204          code="$1" ; shift ;;
205  esac
206done
207
208###############################################################
[2098]209# lecture des chemins propres \`a l'architecture de la machine #
[1463]210###############################################################
211rm -f .void_file
212echo > .void_file
213rm -rf .void_dir
214mkdir .void_dir
215rm -f arch.path
216if [[ -r arch/arch-${arch}.path ]]
217then
218  ln -s arch/arch-${arch}.path ./arch.path
219  source arch.path
220else
221  echo "Error: missing arch/arch-${arch}.path file !"
222  exit
223fi
224rm -f arch.fcm
225if [[ -r arch/arch-${arch}.fcm ]]
226then
227  ln -s arch/arch-${arch}.fcm arch.fcm
228else
229  echo "Error: missing arch/arch-${arch}.fcm file !"
230  exit
231fi
232########################################################################
233# Definition des clefs CPP, des chemins des includes et modules
234#  et des libraries
235########################################################################
236
237# basic compile flags from arch.fcm file
238archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm )
239COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} )
240
241# other compile flags, depending on compilation mode
242if [[ "$compil_mod" == "prod" ]]
243then
244## read COMPIL_FFLAGS from arch.fcm file
245  archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm )
246  archfileopt=$( echo ${archfileline##%PROD_FFLAGS} )
247  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
248elif [[ "$compil_mod" == "dev" ]]
249then
250## read %DEV_FFLAGS from arch.fcm file
251  archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm )
252  archfileopt=$( echo ${archfileline##%DEV_FFLAGS} )
253  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
254elif [[ "$compil_mod" == "debug" ]]
255then
256## read %DEBUG_FFLAGS from arch.fcm file
257  archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm )
258  archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} )
259  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
260fi
261
262# add CPP_KEY defined in arch.fcm file
263archfileline=$( grep -i '^%FPP_DEF' arch.fcm )
264archfileopt=$( echo ${archfileline##%FPP_DEF} )
265CPP_KEY="$CPP_KEY ${archfileopt}"
266
267# get compiler name from arch.fcm file
268archfileline=$( grep -i '^%COMPILER' arch.fcm )
269fcompiler=$( echo ${archfileline##%COMPILER} )
270
271# get linker name from arch.fcm file
272archfileline=$( grep -i '^%LINK' arch.fcm )
273linker=$( echo ${archfileline##%LINK} )
274
275# get ar command from arch.fcm file
276archfileline=$( grep -i '^%AR' arch.fcm )
277arcommand=$( echo ${archfileline##%AR} )
278
279# get make utility from arch.fcm file
280archfileline=$( grep -i '^%MAKE' arch.fcm )
281makecommand=$( echo ${archfileline##%MAKE} )
282
283# get basic libraries to link with arch.fcm file
284archfileline=$( grep -i '^%BASE_LD' arch.fcm )
285archfileopt=$( echo ${archfileline##%BASE_LD} )
286LIB="$LIB  ${archfileopt}"
287
[1873]288# add Include files defined in arch.fcm file for pre-processing
289archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm )
290for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
291
[2250]292phys_root=$physique
293if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
294if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
295if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
296if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
297if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
298if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi
299if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
300
[1463]301if [[ "$physique" != "nophys" ]]
302then
[1690]303   #We'll use some physics
[2326]304   src_dirs="$src_dirs phy_common phy$physique"
[2239]305   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
[2326]306   LIBPHY_COMMON='$(LIBO)/libphy_common.a'
307   lib_phy='-lphy'"$physique"' -lphy_common'
[1690]308   CPP_KEY="$CPP_KEY CPP_PHYS"
[2250]309   if [[ $phys_root == "lmd" ]]
310      then
311      #For lmd physics, default planet type is Earth
312      CPP_KEY="$CPP_KEY CPP_EARTH"
[1690]313   fi
[1463]314fi
315
316if [[ "$chimie" == "INCA" ]]
317then
318   CPP_KEY="$CPP_KEY INCA"
319   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
320   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
321   libchimie=" -L${INCA_LIBDIR} -lchimie"
322fi
323
324if [[ "$couple" != "false" ]]
325then
326   CPP_KEY="$CPP_KEY CPP_COUPLE"
327   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
328   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
329fi
330
331if [[ "$parallel" == "none" ]]
332then
333  FLAG_PARA=''
334else
[1810]335  FLAG_PARA="$paramem"
[2202]336  if [[ $paramem == par ]]
337  then
338      echo "The version of the dynamics in dyn3dpar is no longer updated."
339      echo "You should use option \"-mem\"."
340      exit 1
[2238]341  fi
[1463]342fi
343
344if [[ "$parallel" == "mpi" ]]
345then
346   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
347  # MPI additional compilation options
348  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
349  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
350  # MPI additional links
351  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
352  PARA_LD=$( echo ${archfileline##%MPI_LD} )
353elif [[ "$parallel" == "omp" ]]
354then
355   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
356  # OMP additional compilation options
357  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
358  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
359  # OMP additional links
360  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
361  PARA_LD=$( echo ${archfileline##%OMP_LD} )
362elif [[ "$parallel" == "mpi_omp" ]]
363then
364   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
365  # MPI additional compilation options
366  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
367  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
368  # OMP additional compilation options
369  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
370  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
371  # MPI additional links
372  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
373  PARA_LD=$( echo ${archfileline##%MPI_LD} )
374  # OMP additional links
375  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
376  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
377fi
378
379if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
380   && "$compil_mod" == "debug" ]]
381then
382    echo "Usually, parallelization with OpenMP requires some optimization."
383    echo "We suggest switching to \"-dev\"."
384fi
385
[1810]386
387#==============================================================================
388if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
[1463]389then
[1810]390
[1463]391   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
[1772]392   CPP_KEY="$CPP_KEY CPP_VEGET"
[1810]393# temporary, for Orchidee versions 1.9.* (before openmp activation)
394   if [[ "$veget" == "orchidee1.9" ]] ; then
395      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
396   fi
397   if [[ "$veget" == "orchidee2.0" ]] ; then
[1838]398      orch_libs="sechiba parameters stomate parallel orglob orchidee"
[1810]399   else
[1811]400      orch_libs="sechiba parameters stomate parallel orglob"
[1810]401   fi
402   LIB="${LIB} -L${ORCH_LIBDIR}"
[1811]403   for lib in ${orch_libs} ; do
[1810]404      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
405         LIB="${LIB} -l${LIBPREFIX}$lib "
406      fi
407   done
408elif [[ "$veget" != "false" ]] ; then
[1772]409   echo "Option -v $veget does not exist"
410   echo "Use ./makelmdz -h for more information"
411   exit 
[1463]412fi
413
[1810]414#===============================================================================
[1463]415if [[ $io == ioipsl ]]
416then
417   CPP_KEY="$CPP_KEY CPP_IOIPSL"
418   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
419   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
[2097]420elif [[ $io == mix ]]
[1897]421then
422   # For now, xios implies also using ioipsl
423   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
424   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
425   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
[2097]426elif [[ $io == xios ]]
427then
428   # For now, xios implies also using ioipsl
429   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
430   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
431   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
[1463]432fi
433
434if [[ "$cosp" == "true" ]]
435then
436   CPP_KEY="$CPP_KEY CPP_COSP"
[2239]437   COSP_PATH="$LIBFGCM/phylmd/cosp"
[2238]438   src_dirs="$src_dirs cosp"
[1463]439#   LIB="${LIB} -l${LIBPREFIX}cosp"
440   opt_dep="$opt_dep cosp"
441   lcosp="-l${LIBPREFIX}cosp"
442   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
443fi
444
[1865]445if [[ "$sisvat" == "true" ]]
446then
447   CPP_KEY="$CPP_KEY CPP_SISVAT"
[2238]448   src_dirs="$src_dirs phy${physique}/sisvat"
[1865]449fi
450
[1990]451if [[ "$rrtm" == "true" ]]
452then
453   CPP_KEY="$CPP_KEY CPP_RRTM"
[2238]454   src_dirs="$src_dirs phy${physique}/rrtm"
[1990]455fi
[1865]456
[2631]457if [[ "$dust" == "true" ]]
458then
459   CPP_KEY="$CPP_KEY CPP_Dust"
460   src_dirs="$src_dirs phy${physique}/Dust"
461fi
[1990]462
[2631]463
[1551]464INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
465LIB="$LIB ${NETCDF_LIBDIR}"
[1463]466
467########################################################################
468# calcul du nombre de dimensions
469########################################################################
470
471
472dim_full=$dim
473dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
474set $dim
475dimc=$#
476echo calcul de la dimension
477echo dim $dim
478echo dimc $dimc
479
480########################################################################
481# Gestion des dimensions du modele.
482# on cree ou remplace le fichier des dimensions
483########################################################################
484
[1695]485cd $LIBFGCM/grid
486if [[ -f dimensions.h ]]
487then
488  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
489  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
490  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
491  echo  vous pouvez continuer en repondant oui.
492  echo "Voulez-vous vraiment continuer?"
[1755]493  echo ""
494  echo "WARNING: you are probably already compiling the model somewhere else."
495  echo "Wait until the first compilation is finished before launching this one."
496  echo "If you are sure that you are not compiling elsewhere, just answer "
497  echo "yes (or 'oui') to the question below to proceed."
498  echo "Do you wish to continue?"
[1695]499  read reponse
[1755]500  if [[ $reponse == "oui" || $reponse == "yes" ]]
[1695]501  then
[1696]502    \rm -f $LIBFGCM/grid/dimensions.h
[1695]503  else
504    exit
505  fi
506fi
507
[1463]508cd $LIBFGCM/grid/dimension
509./makdim $dim
[2202]510if (($? != 0))
511then
512    exit 1
513fi
514
[1463]515cat $LIBFGCM/grid/dimensions.h
516cd $LMDGCM
517
518########################################################################
519# Differentes dynamiques (3d, 2d, 1d)
520########################################################################
521
[1810]522if (( $dimc == 3 )) ; then
[2238]523   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
[2239]524   if [[ $physique != "nophys" ]] ; then
[2417]525     src_dirs="$src_dirs dynphy_lonlat dynphy_lonlat/phy${phys_root}"
526     libdyn_phy="-ldynphy_lonlat"
527     LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a'
528     INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat'
529     INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat/'"phy${phys_root}"
[2239]530   fi
[1810]531   cd $LIBFGCM/grid
532   \rm fxyprim.h
533   cp -p fxy_${grille}.h fxyprim.h
[1463]534   filtre="FILTRE=$filtre"
[2016]535   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
[1810]536elif (( $dimc == 2 )) ; then
[2239]537   src_dirs="$src_dirs dyn2d"
[1810]538   filtre="FILTRE= L_FILTRE= "
539   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
540elif (( $dimc == 1 )) ; then
[2239]541   #src_dirs="$src_dirs dyn3d dyn3d_common filtrez"
542   src_dirs="$src_dirs phy${physique}/dyn1d"
[2023]543   CPP_KEY="$CPP_KEY CPP_1D"
[2239]544   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
545   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
546   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
[1463]547else
[1810]548   echo Dimension dimc=$dimc pas prevu ; exit
[1463]549fi
550
551cd $LMDGCM
552
[2112]553########################################################################
554# library directory name:
555########################################################################
[1463]556
[2112]557nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'`
558echo "Path to library: "$nomlib
559
[1463]560########################################################################
[2112]561#  Cleanup for a full recompilation, if requested
562########################################################################
563
564if [[ $full == "full" ]]
565then
566# remove makefile and librairies
567  echo "-full option: recompiling from scratch"
568  \rm -f makefile
569  \rm -rf "${LIBOGCM}/${nomlib}"
570fi
571
572########################################################################
[1463]573#  Avant de lancer le make, on recree le makefile si necessaire
574########################################################################
575########################################################################
576# c'est a dire dans 3 cas:
577# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
578#    derniere creation du makefile
579# 2. si le fichier contenant cette liste "liste_des_sources"
580#    n'existe pas.
581# 3. Si le makefile n'existe pas.
582########################################################################
583cd $LMDGCM
[1810]584
[1463]585
[2238]586if [[ -r .makelmdz ]]
[1463]587then
[2238]588old_lmdz_configuration=$(cat .makelmdz )
589else
590old_lmdz_configuration=""
591fi
592lmdz_configuration="$src_dirs"
593if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
594then
595  configuration_change="true"
596else
597  configuration_change="false"
598fi
599
[2250]600mkdir -p make_dir
601suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'`
602echo suf_make $suf_make
603
604\rm tmp77 tmp90
605for dir in $src_dirs ; do
606find libf/$dir -name '*.[Fh]' -print | sort >> tmp77
607find libf/$dir -name '*.F90' -print | sort >> tmp90
608done
609
610liste77=make_dir/liste_des_sources_f77_$suf_make
611liste90=make_dir/liste_des_sources_f90_$suf_make
612makefile=make_dir/makefile_$suf_make
613
[2269]614if [[ $configuration_change == "true" || ! ( -r $makefile ) || ! ( -r $liste90 ) || ! ( -r $liste77 ) || ` diff tmp77 $liste77 | wc -w ` -ne 0 || ` diff tmp90 $liste90 | wc -w ` -ne 0 ]]
[2238]615then
[1463]616  echo "les fichiers suivants ont ete crees ou detruits"
617  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
[2250]618  diff $liste77 tmp77
619  diff $liste90 tmp90
620  \cp -f tmp77 $liste77
621  \cp -f tmp90 $liste90
[2238]622  echo "Recreating the makefile"
623  echo "src_dirs: $src_dirs"
624  ./create_make_gcm $src_dirs > tmp
[2250]625  \mv -f tmp $makefile
[2238]626  echo "New makefile created"
[1463]627fi
628
[2250]629ln -sf $makefile makefile
630
[2238]631#Create a .makelmdz file containing main compilation option for later comparisons
632echo "$lmdz_configuration" > .makelmdz
633
[1463]634#################################################################
635# Preparation de l'execution de la comande make
636#################################################################
637
638source_code=${code}.F
[2239]639dirmain=dyn${dimc}d${FLAG_PARA}
[1463]640if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
641then
642  source_code=${code}.F90
[2016]643elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then
[2239]644  dirmain=phy$physique
[2016]645  source_code=${code}.F90
[2417]646elif [[ -r $LMDGCM/libf/dynphy_lonlat/phy$phys_root/${code}.F90 ]] ; then
647  dirmain="dynphy_lonlat/phy${phys_root}"
[2239]648  source_code=${code}.F90
649elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then
650  dirmain=phy$physique/dyn1d
651  source_code=${code}.F90
[1463]652fi
653
654if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
655then
656  mkdir ${LIBOGCM}/${nomlib}
657  # check we indeed managed to create the directory
658  if [[ ! $? ]]
659  then
660    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
661    exit
662  fi
663fi
664
665# where module files are created
666mod_loc_dir=$localdir
667
668if [[ "$physique" != "nophys" ]]
669then
670  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
671fi
[1810]672INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
[1463]673
674# ranlib utility (check it exists or else default to ls)
675if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
676then
677  ranlib="ranlib"
678else
679  ranlib="ls"
680fi
681
682# add CPP keys to COMPIL_FLAGS
683# (but first add -D before all CPP_KEY items)
684cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
685# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
686if [[ "${fcompiler:0:3}" == "xlf" ]]
687then
688cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
689fi
690COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
691
692#################################################################
693# Execution du make
694#################################################################
695echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
696OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
697OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
698OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
699OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
700INCLUDE="$INCLUDE" \
701$filtre \
702LIBO=${LIBOGCM}/${nomlib} \
703"PHYS=$physique" \
[2239]704LIBPHY=${LIBPHY} \
[2326]705LIBPHY_COMMON=${LIBPHY_COMMON} \
[2239]706LIBDYN_PHYS=${LIBDYN_PHYS} \
[1463]707DIM=$dimc \
708FLAG_PARA=$FLAG_PARA \
[2239]709L_PHY="$lib_phy" \
710L_DYN_PHY="$libdyn_phy" \
[1463]711L_ADJNT=$adjnt \
712L_COSP="$lcosp" \
713L_CHIMIE="$libchimie" \
714LOCAL_DIR="$localdir"  \
715F77="$fcompiler" \
716F90="$fcompiler" \
717OPLINK="$LIB" \
718LINK="$linker" \
719GCM="$LMDGCM" \
720MOD_LOC_DIR=$mod_loc_dir \
721MOD_SUFFIX="mod" \
722AR=$arcommand \
[2239]723DIRMAIN=$dirmain \
[1463]724SOURCE=$source_code \
725PROG=$code
726
727$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
728OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
729OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
730OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
731OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
732INCLUDE="$INCLUDE" \
733$filtre \
734LIBO=${LIBOGCM}/${nomlib} \
735"PHYS=$physique" \
[2239]736LIBPHY=${LIBPHY} \
[2326]737LIBPHY_COMMON=${LIBPHY_COMMON} \
[2239]738LIBDYN_PHYS=${LIBDYN_PHYS} \
[1463]739DIM=$dimc \
740FLAG_PARA=$FLAG_PARA \
[2239]741L_PHY="$lib_phy" \
742L_DYN_PHY="$libdyn_phy" \
[1810]743L_ADJNT=$adjnt \
[1463]744L_COSP="$lcosp" \
745L_CHIMIE="$libchimie" \
746LOCAL_DIR="$localdir"  \
747F77="$fcompiler" \
748F90="$fcompiler" \
749OPLINK="$LIB" \
750LINK="$linker" \
751GCM="$LMDGCM" \
752MOD_LOC_DIR=$mod_loc_dir \
753MOD_SUFFIX="mod" \
754AR=$arcommand \
[2239]755DIRMAIN=$dirmain \
[1463]756SOURCE=$source_code \
757PROG=$code
758
[1810]759
[1696]760if [[ -r $LIBFGCM/grid/dimensions.h ]]
[1463]761then
762  # Cleanup: remove dimension.h file
[1696]763  \rm -f $LIBFGCM/grid/dimensions.h
[1463]764fi
Note: See TracBrowser for help on using the repository browser.