source: LMDZ6/branches/Optimisation_LMDZ/makelmdz_fcm @ 5428

Last change on this file since 5428 was 3704, checked in by adurocher, 5 years ago

Fixed compilation script : return non-zero on error, delete lock file

  • 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: 20.6 KB
RevLine 
[1279]1#!/bin/bash
2# $Id: makelmdz_fcm 3704 2020-06-11 09:09:36Z fhourdin $
3# This is a script in Bash.
4
[2098]5# FH : on ne cr\'ee plus le fichier arch.mk qui est suppos\'e exister par
[783]6# FH : ailleurs.
[2098]7# FH : ulterieurement, ce fichier sera pr\'e-existant pour une s\'erie
8# FH : de configurations en versions optimis\'ees et debug qui seront
9# FH : li\'es (ln -s) avec arch.mk en fonction de l'architecture.
10# FH : Pour le moment, cette version est en test et on peut cr\'eer les
11# FH : arch.mk en lan\c{}cant une premi\`ere fois makegcm.
[783]12#
[1279]13##set -x
[2202]14set -e
[783]15########################################################################
16# options par defaut pour la commande make
17########################################################################
18
[1279]19dim="96x72x19"
20physique=lmd
21filtre=filtrez
22grille=reg
23couple=false
24veget=false
[1865]25sisvat=false
[1990]26rrtm=false
[2631]27dust=false
[2690]28strataer=false
[1279]29chimie=false
30parallel=none
[1680]31paramem="par"
[1279]32compil_mod=prod
33io=ioipsl
34LIBPREFIX=""
35cosp=false
[3358]36cosp2=false
[3491]37cospv2=false
[1802]38job=1
39full=''
[2358]40libphy=false
[783]41
[2743]42arch_defined="FALSE"
43arch_path="arch"
44arch_default_path="arch"
45
[1279]46LMDGCM=`/bin/pwd`
47LIBOGCM=$LMDGCM/libo
48LIBFGCM=$LMDGCM/libf
[2239]49DYN_COMMON_PATH=$LIBFGCM/dyn3d_common
[2084]50# path for optional packages, but default set to ".void_dir"
[2239]51FILTRE_PATH=$LMDGCM/.void_dir
52DYN_PHYS_PATH=$LMDGCM/.void_dir
[2242]53DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
[2326]54PHY_COMMON_PATH=$LMDGCM/.void_dir
[2084]55RRTM_PATH=$LMDGCM/.void_dir
[2631]56DUST_PATH=$LMDGCM/.void_dir
[2690]57STRATAER_PATH=$LMDGCM/.void_dir
[2084]58SISVAT_PATH=$LMDGCM/.void_dir
[1327]59COSP_PATH=$LMDGCM/.void_dir
[1578]60fcm_path=$LMDGCM/tools/fcm/bin
[783]61
62########################################################################
63#  Quelques initialisations de variables du shell.
64########################################################################
65
[1279]66CPP_KEY="" 
67INCLUDE=""
68LIB=""
69adjnt=""
70COMPIL_FFLAGS="%PROD_FFLAGS"
71PARA_FFLAGS=""
72PARA_LD=""
73EXT_SRC=""
[783]74
75########################################################################
76# lecture des options de mymake
77########################################################################
78
[1279]79while (($# > 0))
80  do
81  case $1 in
82      "-h") cat <<fin
[783]83Usage :
[1772]84makelmdz_fcm [options] -arch nom_arch exec
85[-h]                       : brief help
86[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
87[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
88[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug
[1965]89[-c false/MPI1/OMCT]       : coupling with ocean model : MPI1/OMCT/false (default: false)
[1772]90[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
91          false       : no vegetation model
[3435]92          orchidee2.1 : compile using ORCHIDEE 2.1 (or more recent version)
93          orchidee2.0 : compile using ORCHIDEE 2.0
[1772]94          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
95          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
96[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
[2238]97[-cosp true/false]    : compile with/without cosp package (default: false)
[3358]98[-cosp2 true/false]    : compile with/without cosp2 package (default: false)
[3491]99[-cospv2 true/false]    : compile with/without cospv2 package (default: false)
[2238]100[-sisvat true/false]  : compile with/without sisvat package (default: false)
101[-rrtm true/false]    : compile with/without rrtm package (default: false)
[2631]102[-dust true/false]    : compile with/without the dust package by Boucher and co (default: false)
[2690]103[-strataer true/false]    : compile with/without the strat aer package by Boucher and co (default: false)
[1772]104[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
105[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
[2097]106[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
[1772]107[-include INCLUDES]        : extra include path to add
108[-cpp CPP_KEY]             : additional preprocessing definitions
109[-adjnt]                   : adjoint model, not operational ...
110[-mem]                     : reduced memory dynamics (if in parallel mode)
111[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
112[-link LINKS]              : additional links with other libraries
[1802]113[-j n]                     : active parallel compiling on ntask
114[-full]                    : full recompiling
[2358]115[-libphy]                  : only compile physics package (no dynamics or main program)
[1772]116[-fcm_path path]           : path to the fcm tool (default: tools/fcm/bin)
117[-ext_src path]            : path to an additional set of routines to compile with the model
[2743]118[-arch_path path]          : path to architecture files (default: $arch_default_path)
[1772]119 -arch nom_arch            : target architecture
120 exec                      : executable to build
[783]121fin
[1279]122          exit;;
[783]123
[1279]124      "-d")
125          dim=$2 ; shift ; shift ;;
126     
127      "-p")
128          physique="$2" ;  shift ; shift ;;
[783]129
[1279]130      "-g")
131          grille="$2" ; shift ; shift ;;
[783]132
[1279]133      "-c")
134          couple="$2" ; shift ; shift ;;
[783]135
[1279]136      "-prod")
137          compil_mod="prod" ; shift ;;
[1002]138
[1279]139      "-dev")
140          compil_mod="dev" ; shift ;;
[1002]141
[1279]142      "-debug")
143          compil_mod="debug" ; shift ;;
[1002]144
[1279]145      "-io")
146          io="$2" ; shift ; shift ;;
[783]147
[1279]148      "-v")
149          veget="$2" ; shift ; shift ;;
[783]150
[1865]151      "-sisvat")
152          sisvat="$2" ; shift ; shift ;;
153
[1990]154      "-rrtm")
155          rrtm="$2" ; shift ; shift ;;
156
[2631]157      "-dust")
158          dust="$2" ; shift ; shift ;;
159
[2690]160      "-strataer")
161          strataer="$2" ; shift ; shift ;;
162
[1279]163      "-chimie")
164          chimie="$2" ; shift ; shift ;;
[783]165
[1279]166      "-parallel")
167          parallel="$2" ; shift ; shift ;;
168     
169      "-include")
170          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
[783]171
[1279]172      "-cpp")
173          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
[1132]174
[1279]175      "-adjnt")
[1772]176          echo "not operational ... work to be done here ";exit
[1279]177          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
178          optim="$optim -Dadj" ; shift ;;
[783]179
[1279]180      "-cosp")
181          cosp="$2" ; shift ; shift ;;
[3358]182
183      "-cosp2")
184          cosp2="$2" ; shift ; shift ;;
[3491]185
186      "-cospv2")
187          cospv2="$2" ; shift ; shift ;;
[1680]188     
189      "-mem")
190          paramem="mem" ; shift ;;
[783]191
[1279]192      "-filtre")
193          filtre=$2 ; shift ; shift ;;
[783]194
[1279]195      "-link")
196          LIB="$LIB $2" ; shift ; shift ;;
[1136]197
[1279]198      "-fcm_path")
199          fcm_path=$2 ; shift ; shift ;;
[783]200
[1279]201      "-ext_src")
202          EXT_SRC=$2 ; shift ; shift ;;
[2358]203
[1802]204      "-j")
205          job=$2 ; shift ; shift ;;
[2358]206
[1802]207      "-full")
208          full="-full" ; shift ;;
[783]209
[2358]210      "-libphy")
211          libphy="true" ; shift ;;
212
[1279]213      "-arch")
[2743]214          arch=$2 ; arch_defined="TRUE" ; shift ; shift ;;
[783]215
[2743]216      "-arch_path")
217          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
218
[1279]219      *)
220          code="$1" ; shift ;;
221  esac
222done
223
[1136]224###############################################################
[1755]225# path to fcm
[1136]226###############################################################
[1755]227# handle case when provided path to fcm was given as a relative
228# path (from makelmdz_fcm script directory) and not an absolute path
229if [[ ${fcm_path:0:1} != "/" ]] ; then
230  # prepend with makelmdz_fcm location
231  fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path}
232fi
[783]233
[1757]234# add fcm_path to PATH
235export PATH=${fcm_path}:${PATH}
236
[1755]237echo "Path to fcm:"
238echo ${fcm_path}
[1136]239
[783]240###############################################################
[2098]241# lecture des chemins propres \`a l'architecture de la machine #
[783]242###############################################################
[1279]243rm -f .void_file
244echo > .void_file
[1327]245rm -rf .void_dir
246mkdir .void_dir
[783]247
[2743]248if [[ "$arch_defined" == "TRUE" ]]
249then
250  rm -f arch.path
251  rm -f arch.fcm
252  rm -f arch.env
253
254  if test -f $arch_path/arch-${arch}.path
255  then
256    ln -s $arch_path/arch-${arch}.path arch.path
257  elif test -f $arch_default_path/arch-${arch}.path
258  then
259    ln -s $arch_default_path/arch-${arch}.path arch.path
260  fi
261       
262  if test -f $arch_path/arch-${arch}.fcm
263  then
264    ln -s $arch_path/arch-${arch}.fcm arch.fcm
265  elif test -f $arch_default_path/arch-${arch}.fcm
266  then
267    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
268  fi
269
270  if test -f $arch_path/arch-${arch}.env
271  then
272    ln -s $arch_path/arch-${arch}.env arch.env
273  elif test -f $arch_default_path/arch-${arch}.env
274  then
275    ln -s $arch_default_path/arch-${arch}.env arch.env
276  else
277    ln -s .void_file arch.env
278  fi
279  # source architecture PATH and ENV files
280  source arch.env
281  source arch.path
282else
283  echo "You must define a target architecture"
284  exit 1
285fi
286
[783]287########################################################################
288# Definition des clefs CPP, des chemins des includes et modules
289#  et des libraries
290########################################################################
291
[1279]292if [[ "$compil_mod" == "prod" ]]
293then
294  COMPIL_FFLAGS="%PROD_FFLAGS"
295elif [[ "$compil_mod" == "dev" ]]
296then
297  COMPIL_FFLAGS="%DEV_FFLAGS"
298elif [[ "$compil_mod" == "debug" ]]
299then
300  COMPIL_FFLAGS="%DEBUG_FFLAGS"
301fi
[783]302
[2250]303phys_root=$physique
304if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
305if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
306if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
307if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
308if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
309if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi
310if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
311
[1279]312if [[ "$physique" != "nophys" ]]
313then
[1615]314   #We'll use some physics
315   CPP_KEY="$CPP_KEY CPP_PHYS"
[2250]316   if [[ "${phys_root}" == "lmd" ]]
[1615]317   then
318   #For lmd physics, default planet type is Earth
[1279]319   CPP_KEY="$CPP_KEY CPP_EARTH"
[1615]320   fi
[2326]321   # set physics common utilities path
322   PHY_COMMON_PATH="${LIBFGCM}/phy_common"
[2239]323   # set the dyn/phys interface path
[2417]324   DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat"
325   DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}"
[1279]326fi
[783]327
[2239]328if [[ "$filtre" == "filtrez" ]]
329then
330   FILTRE_PATH=${LIBFGCM}/$filtre
331fi
332
[1279]333if [[ "$chimie" == "INCA" ]]
334then
335   CPP_KEY="$CPP_KEY INCA"
336   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
337   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
338fi
[783]339
[1279]340if [[ "$couple" != "false" ]]
341then
[1965]342    if [[ "$couple" == "MPI1" ]]
343    then
344        CPP_KEY="$CPP_KEY CPP_COUPLE"
345        export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
346        export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib
347        INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
348        LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lmpp_io"
349    else
350        CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT"
351        INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
352        LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lscrip -lmct -lmpeu"
353    fi
[1279]354fi
[783]355
[1279]356if [[ "$parallel" == "mpi" ]]
357then
358   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
359   PARA_FFLAGS="%MPI_FFLAGS"
360   PARA_LD="%MPI_LD"
361elif [[ "$parallel" == "omp" ]]
362then
363   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
364   PARA_FFLAGS="%OMP_FFLAGS"
365   PARA_LD="%OMP_LD"
366elif [[ "$parallel" == "mpi_omp" ]]
367then
368   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
369   PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS"
370   PARA_LD="%MPI_LD %OMP_LD"
371fi
[783]372
[1279]373if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
374   && "$compil_mod" == "debug" ]]
375then
376    echo "Usually, parallelization with OpenMP requires some optimization."
377    echo "We suggest switching to \"-dev\"."
378fi
[783]379
[3435]380if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" -o "$veget" = "orchidee2.1" ]
[1279]381then
[1811]382#NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
383#    For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments
384#    option orchidee1.9 : Compile with ORCHIDEE version up to the inclusion of OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
[1279]385   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
[1772]386   CPP_KEY="$CPP_KEY CPP_VEGET"
[1811]387# temporary, for Orchidee versions 1.9.* (before openmp activation)
388   if [[ "$veget" == "orchidee1.9" ]] ; then
389      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
390   fi
391   if [[ "$veget" == "orchidee2.0" ]] ; then
[1854]392      orch_libs="sechiba parameters stomate parallel orglob orchidee"
[3435]393      CPP_KEY="$CPP_KEY ORCHIDEE_NOUNSTRUCT"
394   elif [[ "$veget" == "orchidee2.1" ]] ; then
395      orch_libs="sechiba parameters stomate parallel orglob orchidee"
[1811]396   else
397      orch_libs="sechiba parameters stomate parallel orglob"
398   fi
399   LIB="${LIB} -L${ORCH_LIBDIR}"
400   for lib in ${orch_libs} ; do
401      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
402         LIB="${LIB} -l${LIBPREFIX}$lib "
403      fi
404   done
405elif [[ "$veget" != "false" ]] ; then
[1772]406   echo "Option -v $veget does not exist"
407   echo "Use ./makelmdz_fcm -h for more information"
408   exit 
[1279]409fi
[783]410
[1865]411if [[ "$sisvat" == "true" ]]
412then
413   CPP_KEY="$CPP_KEY CPP_SISVAT"
[2084]414   SISVAT_PATH="$LIBFGCM/%PHYS/sisvat"
[1865]415fi
416
[1990]417if [[ "$rrtm" == "true" ]]
418then
419   CPP_KEY="$CPP_KEY CPP_RRTM"
[2084]420   RRTM_PATH="$LIBFGCM/%PHYS/rrtm"
[1990]421fi
422
[2631]423if [[ "$dust" == "true" ]]
424then
425   CPP_KEY="$CPP_KEY CPP_Dust"
426   DUST_PATH="$LIBFGCM/%PHYS/Dust"
427fi
428
[2690]429if [[ "$strataer" == "true" ]]
430then
431   CPP_KEY="$CPP_KEY CPP_StratAer"
432   STRATAER_PATH="$LIBFGCM/%PHYS/StratAer"
433fi
434
[1279]435if [[ $io == ioipsl ]]
436then
437   CPP_KEY="$CPP_KEY CPP_IOIPSL"
438   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
439   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
[2097]440elif [[ $io == mix ]]
[1897]441then
442   # For now, xios implies also using ioipsl
443   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
444   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
[3075]445   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++"
[2097]446elif [[ $io == xios ]]
447then
448   # For now, xios implies also using ioipsl
449   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
450   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
[3075]451   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++"
[1279]452fi
[1897]453
[1279]454if [[ "$cosp" == "true" ]]
455then
456   CPP_KEY="$CPP_KEY CPP_COSP"
[2239]457   COSP_PATH="$LIBFGCM/phylmd/cosp"
[1279]458#   LIB="${LIB} -l${LIBPREFIX}cosp"
459fi
[783]460
[3358]461if [[ "$cosp2" == "true" ]]
462then
463   CPP_KEY="$CPP_KEY CPP_COSP2"
464   COSP_PATH="$LIBFGCM/phylmd/cosp2"
465#   LIB="${LIB} -l${LIBPREFIX}cosp2"
466fi
467
[3491]468if [[ "$cospv2" == "true" ]]
469then
470   CPP_KEY="$CPP_KEY CPP_COSPV2"
471   COSP_PATH="$LIBFGCM/phylmd/cospv2"
472#   LIB="${LIB} -l${LIBPREFIX}cosp2"
473fi
[3358]474
[3491]475
476
[1551]477INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
478LIB="$LIB ${NETCDF_LIBDIR}"
479
[783]480########################################################################
481# calcul du nombre de dimensions
482########################################################################
483
484
[1279]485dim_full=$dim
486dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
487set $dim
488dimc=$#
[783]489echo calcul de la dimension
490echo dim $dim
491echo dimc $dimc
492
493
494########################################################################
495# Gestion des dimensions du modele.
[1114]496# on cree ou remplace le fichier des dimensions
[783]497########################################################################
498
[1695]499cd $LIBFGCM/grid
500if [[ -f dimensions.h ]]
501then
502  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
503  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
504  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
505  echo  vous pouvez continuer en repondant oui.
506  echo "Voulez-vous vraiment continuer?"
[1755]507  echo ""
508  echo "WARNING: you are probably already compiling the model somewhere else."
509  echo "Wait until the first compilation is finished before launching this one."
510  echo "If you are sure that you are not compiling elsewhere, just answer "
511  echo "yes (or 'oui') to the question below to proceed."
512  echo "Do you wish to continue?"
[1695]513  read reponse
[1755]514  if [[ $reponse == "oui" || $reponse == "yes" ]]
[1695]515  then
[1696]516    \rm -f $LIBFGCM/grid/dimensions.h
[1695]517  else
518    exit
519  fi
520fi
521
522
[783]523cd $LIBFGCM/grid/dimension
[1114]524./makdim $dim
[783]525cat $LIBFGCM/grid/dimensions.h
526cd $LMDGCM
527
528
529########################################################################
530# Differentes dynamiques (3d, 2d, 1d)
531########################################################################
532
[1279]533dimension=`echo $dim | wc -w`
[783]534echo dimension $dimension
535
[1279]536if (( $dimension == 3 ))
537then
[783]538  cd $LIBFGCM/grid
539  \rm fxyprim.h
540  cp -p fxy_${grille}.h fxyprim.h
[2239]541#else
542#  echo "Probleme dans les dimensions de la dynamique !!"
543#  echo "Non reactive pour l'instant !!!"
[1279]544fi
[783]545
[2239]546if (( $dimension == 1 ))
547then
548  CPP_KEY="$CPP_KEY CPP_1D"
549##in 1D, add dyn3d to include path (because main prog is in physics)
550  INCLUDE="$INCLUDE -Ilibf/dyn3d -Ilibf/dyn3d_common"
551## no filtre in 1d:
552  FILTRE_PATH=$LMDGCM/.void_dir
553## no need to compile all routines in dyn3d_common either:
554  DYN_COMMON_PATH=$LMDGCM/.void_dir
555## no need to compile all routines in dynlmdz_phy... ;
556## (because key ones are included in 1D main program)
557  DYN_PHYS_PATH=$LMDGCM/.void_dir
[2242]558  DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
[2239]559fi
560
[783]561######################################################################
562#   Traitement special pour le nouveau rayonnement de Laurent Li.
563#   ---> YM desactive pour le traitemement en parallele
564######################################################################
565
[1279]566#if [[ -f $libf/phy$physique/raddim.h ]]
567#then
568# if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
569#then
[783]570#  \rm -f $libf/phy$physique/raddim.h
571#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
572#  echo $libf/phy$physique/raddim.$dimh.h
573#  cat $libf/phy$physique/raddim.h
574# else
575#  echo On peut diminuer la taille de l executable en creant
576#  echo le fichier $libf/phy$physique/raddim.$dimh.h
577#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
[1279]578# fi
579#fi
[783]580
581######################################################################
582# Gestion du filtre qui n'existe qu'en 3d.
583######################################################################
584
[1279]585if (( `expr $dimc \> 2` == 1 ))
586then
587   filtre="FILTRE=$filtre"
[783]588else
[1279]589   filtre="FILTRE= L_FILTRE= "
590fi
[783]591echo MACRO FILTRE $filtre
592
593echo $dimc
594
595
596
597######################################################################
598# Creation du suffixe de la configuration
599######################################################################
600
601
[1279]602SUFF_NAME=_${dim_full}
603SUFF_NAME=${SUFF_NAME}_phy${physique}
[783]604
[1279]605if [[ "$parallel" != "none" ]]
606then
607  SUFF_NAME=${SUFF_NAME}_para
[1680]608  DYN=dyn${dimc}d${paramem}
609  if [[ "$paramem" == "mem" ]]
610  then
[2202]611      SUFF_NAME=${SUFF_NAME}_${paramem}
612  else
613      echo "The version of the dynamics in dyn3dpar is no longer updated."
614      echo "You should use option \"-mem\"."
615      exit 1
[1680]616  fi
[783]617else
[1279]618  SUFF_NAME=${SUFF_NAME}_seq
[2239]619  if (( $dimension == 1 ))
620  then
621    # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
622    DYN=phy${physique}/dyn1d
623  else
624    DYN=dyn${dimc}d
625  fi
[1279]626fi
[783]627
[1772]628if [[ $veget != "false" ]]
[1279]629then
630  SUFF_NAME=${SUFF_NAME}_orch
631fi
[783]632
[1279]633if [[ $couple != "false" ]]
634then
635  SUFF_NAME=${SUFF_NAME}_couple
636fi
[783]637
[1279]638if [[ $chimie == "INCA" ]]
639then
640  SUFF_NAME=${SUFF_NAME}_inca
641fi
[783]642
[2358]643if [[ $libphy == "true" ]]
644then
645  # special case where we compile only the physics
646  DYN=$LMDGCM/.void_dir
647  DYN_COMMON_PATH=$LMDGCM/.void_dir
648  FILTRE_PATH=$LMDGCM/.void_dir
649  DYN_PHYS_PATH=$LMDGCM/.void_dir
650  DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
651  #and there is no main program to generate
652  code=""
653  SUFF_NAME=""
654else
655  SUFF_NAME=${SUFF_NAME}.e
656fi
657
[783]658cd $LMDGCM
[1279]659config_fcm="config.fcm"
[783]660rm -f $config_fcm
661touch $config_fcm
662rm -f bin/${code}${SUFF_NAME}.e
663rm -f arch.fcm
[1279]664rm -f arch.opt
[783]665
666echo "%ARCH          $arch"          >> $config_fcm
667echo "%INCDIR        $INCLUDE"       >> $config_fcm 
668echo "%LIB           $LIB"           >> $config_fcm
669echo "%ROOT_PATH     $PWD"           >> $config_fcm
670echo "%LIBF          $LIBFGCM"       >> $config_fcm
671echo "%LIBO          $LIBOGCM"       >> $config_fcm
672echo "%DYN           $DYN"           >> $config_fcm
[2239]673echo "%DYN_COMMON    $DYN_COMMON_PATH" >> $config_fcm
[2326]674echo "%PHY_COMMON    $PHY_COMMON_PATH" >> $config_fcm
[2239]675echo "%FILTRE        $FILTRE_PATH"   >> $config_fcm
[783]676echo "%PHYS          phy${physique}" >> $config_fcm
[2239]677echo "%DYN_PHYS      $DYN_PHYS_PATH" >> $config_fcm
[2242]678echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH" >> $config_fcm
[2084]679echo "%RRTM          $RRTM_PATH"     >> $config_fcm
[2631]680echo "%DUST          $DUST_PATH"     >> $config_fcm
[2690]681echo "%STRATAER      $STRATAER_PATH" >> $config_fcm
[2084]682echo "%SISVAT        $SISVAT_PATH"   >> $config_fcm
[1327]683echo "%COSP          $COSP_PATH"     >> $config_fcm
[783]684echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
685echo "%EXEC          $code"          >> $config_fcm
686echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
[1002]687echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
688echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
689echo "%PARA_LD       $PARA_LD"       >> $config_fcm
[1279]690echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
[783]691
[1002]692
693
[1137]694ln -s arch/arch-${arch}.fcm arch.fcm
[1279]695if test -f arch/arch-${arch}.opt &&  [ $compil_mod = "prod" ]
696  then
697  ln -s arch/arch-${arch}.opt arch.opt
698else
699  ln -s .void_file arch.opt
700fi
701
[3704]702set +e
703
[1002]704rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
[1802]705./build_gcm ${fcm_path} -j $job $full
[3704]706build_status=$?
[783]707
[3647]708err=$?
709# Check error message from fcm build
710if [ $err != 0 ] ; then
711  exit 1
712fi
713
[1279]714rm -rf tmp_src
715rm -rf config
[783]716ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
[2358]717ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src
[1695]718
[1869]719
[1696]720if [[ -r $LIBFGCM/grid/dimensions.h ]]
[1695]721then
722  # Cleanup: remove dimension.h file
[1696]723  \rm -f $LIBFGCM/grid/dimensions.h
[1695]724fi
[3704]725
726exit $build_status
Note: See TracBrowser for help on using the repository browser.