source: LMDZ6/trunk/makelmdz @ 3756

Last change on this file since 3756 was 3574, checked in by fhourdin, 5 years ago

makelmdz ada->jean-zay

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