source: trunk/LMDZ.COMMON/makelmdz_fcm @ 3537

Last change on this file since 3537 was 3499, checked in by afalco, 6 weeks ago

libphy compilation: fixed a few pathes for compilation with dynamico & others.
Removing lock when fail.
Allows for user to re-run compilation without the warning "ATTENTION... you might be already compiling"
AF

File size: 23.6 KB
Line 
1#!/bin/bash
2# $Id: makelmdz_fcm 1615 2012-02-10 15:42:26Z emillour $
3# This is a script in Bash to compile the GCM and related tools
4#
5##set -x
6set -e
7########################################################################
8# options par defaut pour la commande make
9########################################################################
10
11dim="96x72x19"
12physique=lmd
13filtre=filtrez
14grille=reg
15couple=false
16veget=false
17sisvat=false
18rrtm=false
19dust=false
20strataer=false
21chimie=false
22chemistry=false
23parallel=none
24paramem="par"
25compil_mod=prod
26io=ioipsl
27LIBPREFIX=""
28cosp=false
29bands=""
30scatterers=""
31job=1
32full=''
33libphy=false
34
35arch_defined="FALSE"
36arch_path="arch"
37arch_default_path="arch"
38
39LMDGCM=`/bin/pwd`
40LIBOGCM=$LMDGCM/libo
41LIBFGCM=$LMDGCM/libf
42DYN_COMMON_PATH=$LIBFGCM/dyn3d_common
43# path for optional packages, but default set to ".void_dir"
44FILTRE_PATH=$LMDGCM/.void_dir
45DYN_PHYS_PATH=$LMDGCM/.void_dir
46DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
47PHY_COMMON_PATH=$LMDGCM/.void_dir
48RRTM_PATH=$LMDGCM/.void_dir
49DUST_PATH=$LMDGCM/.void_dir
50STRATAER_PATH=$LMDGCM/.void_dir
51SISVAT_PATH=$LMDGCM/.void_dir
52COSP_PATH=$LMDGCM/.void_dir
53CHEM_PATH=$LMDGCM/.void_dir
54CLOUD_PATH=$LMDGCM/.void_dir
55MUPHY_PATH=$LMDGCM/.void_dir
56AERONO_PATH=$LMDGCM/.void_dir
57EVOLUTION_PATH=$LMDGCM/.void_dir
58# Path to fcm utility:
59##fcm_path=$LMDGCM/tools/fcm/bin
60##fcm_path=/planeto/mturbet/planeto2-mturbet/FCM_V1.2/bin
61fcm_path=$(dirname $(which fcm))
62
63########################################################################
64#  Quelques initialisations de variables du shell.
65########################################################################
66
67CPP_KEY=""
68INCLUDE_DIR=""
69LIB=""
70adjnt=""
71COMPIL_FFLAGS="%PROD_FFLAGS"
72PARA_FFLAGS=""
73PARA_LD=""
74EXT_SRC=""
75
76########################################################################
77# lecture des options de mymake
78########################################################################
79
80while (($# > 0))
81  do
82  case $1 in
83      "-h") cat <<fin
84Usage :
85makelmdz_fcm [options] -arch arch_name exec
86[-h]                       : brief help
87[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
88[-s nscat]                 : (Generic) Number of radiatively active scatterers
89[-b IRxVIS]                : (Generic) Number of infrared (IR) and visible (VIS) bands for radiative transfer
90[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
91[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug .
92[-c false/MPI1/OMCT]       : (Earth) coupling with ocean model : MPI1/OMCT/false (default: false)
93[-v false/orchidee2.0/orchidee1.9/true] : (Earth) version of the vegetation model to include (default: false)
94          false       : no vegetation model
95          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
96          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
97          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
98[-chimie INCA/false]       : (Earth) with INCA chemistry model or without (default: false)
99[-cosp true/false]         : (Earth) add the cosp model (default: false)
100[-sisvat true/false]  : (Earth) compile with/without sisvat package (default: false)
101[-rrtm true/false]    : (Earth) compile with/without rrtm package (default: false)
102[-dust true/false]    : (Earth) compile with/without the dust package by Boucher and co (default: false)
103[-strataer true/false]    : (Earth) compile with/without the strat aer package by Boucher and co (default: false)
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)
106[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
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
113[-j n]                     : active parallel compiling on ntask
114[-full]                    : full (re-)compilation (from scratch)
115[-libphy]                  : only compile physics package (no dynamics or main program)
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
118[-arch_path path]          : path to architecture files (default: $arch_default_path)
119 -arch arch                : target architecture
120 exec                      : executable to build
121fin
122          exit;;
123
124      "-d")
125          dim=$2 ; shift ; shift ;;
126
127      "-p")
128          physique="$2" ;  shift ; shift ;;
129
130      "-s")
131          scatterers=$2 ; shift ; shift ;;
132
133      "-b")
134          bands=$2 ; shift ; shift ;;
135
136      "-g")
137          grille="$2" ; shift ; shift ;;
138
139      "-c")
140          couple="$2" ; shift ; shift ;;
141
142      "-prod")
143          compil_mod="prod" ; shift ;;
144
145      "-dev")
146          compil_mod="dev" ; shift ;;
147
148      "-debug")
149          compil_mod="debug" ; shift ;;
150
151      "-io")
152          io="$2" ; shift ; shift ;;
153
154      "-v")
155          veget="$2" ; shift ; shift ;;
156
157      "-sisvat")
158          sisvat="$2" ; shift ; shift ;;
159
160      "-rrtm")
161          rrtm="$2" ; shift ; shift ;;
162
163      "-dust")
164          dust="$2" ; shift ; shift ;;
165
166      "-strataer")
167          strataer="$2" ; shift ; shift ;;
168
169      "-chimie")
170          chimie="$2" ; shift ; shift ;;
171
172      "-parallel")
173          parallel="$2" ; shift ; shift ;;
174
175      "-include")
176          INCLUDE_DIR="$INCLUDE_DIR -I$2" ; shift ; shift ;;
177
178      "-cpp")
179          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
180
181      "-adjnt")
182          echo "not operational ... work to be done here ";exit 1
183          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
184          optim="$optim -Dadj" ; shift ;;
185
186      "-cosp")
187          cosp="$2" ; shift ; shift ;;
188
189      "-mem")
190          paramem="mem" ; shift ;;
191
192      "-filtre")
193          filtre=$2 ; shift ; shift ;;
194
195      "-link")
196          LIB="$LIB $2" ; shift ; shift ;;
197
198      "-fcm_path")
199          fcm_path=$2 ; shift ; shift ;;
200
201      "-ext_src")
202          EXT_SRC=$2 ; shift ; shift ;;
203
204      "-j")
205          job=$2 ; shift ; shift ;;
206
207      "-full")
208          full="-full" ; shift ;;
209
210      "-libphy")
211          libphy="true" ; shift ;;
212
213      "-arch")
214          arch=$2 ; arch_defined="TRUE" ; shift ; shift ;;
215
216      "-arch_path")
217          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
218
219      *)
220          code="$1" ; shift ;;
221  esac
222done
223
224###############################################################
225# path to fcm
226###############################################################
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
233
234# add fcm_path to PATH
235export PATH=${fcm_path}:${PATH}
236
237echo "Path to fcm:"
238echo ${fcm_path}
239
240#################################
241# setup arch.env and arch.path  #
242#################################
243rm -f .void_file
244echo > .void_file
245rm -rf .void_dir
246mkdir .void_dir
247
248if [[ "$arch_defined" == "TRUE" ]]
249then
250  rm -f arch.path
251  rm -f arch.env
252
253  if test -f $arch_path/arch-${arch}.path
254  then
255    ln -s $arch_path/arch-${arch}.path arch.path
256  elif test -f $arch_default_path/arch-${arch}.path
257  then
258    ln -s $arch_default_path/arch-${arch}.path arch.path
259  fi
260
261  if test -f $arch_path/arch-${arch}.env
262  then
263    ln -s $arch_path/arch-${arch}.env arch.env
264  elif test -f $arch_default_path/arch-${arch}.env
265  then
266    ln -s $arch_default_path/arch-${arch}.env arch.env
267  else
268    ln -s .void_file arch.env
269  fi
270  # source architecture PATH and ENV files
271  source arch.env
272  source arch.path
273else
274  echo "You must define a target architecture"
275  exit 1
276fi
277
278########################################################################
279# Definition des clefs CPP, des chemins des includes et modules
280#  et des libraries
281########################################################################
282
283if [[ "$compil_mod" == "prod" ]]
284then
285  COMPIL_FFLAGS="%PROD_FFLAGS"
286elif [[ "$compil_mod" == "dev" ]]
287then
288  COMPIL_FFLAGS="%DEV_FFLAGS"
289elif [[ "$compil_mod" == "debug" ]]
290then
291  COMPIL_FFLAGS="%DEBUG_FFLAGS"
292fi
293
294phys_root=$physique
295if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
296if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi
297if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
298if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
299if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
300if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
301if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
302
303if [[ "$physique" != "nophys" ]]
304then
305   #We'll use some physics
306   CPP_KEY="$CPP_KEY CPP_PHYS"
307   if [[ "${phys_root}" == "lmd" ]]
308   then
309   #For lmd physics, default planet type is Earth
310   CPP_KEY="$CPP_KEY CPP_EARTH"
311   fi
312   # set physics common utilities path
313   PHY_COMMON_PATH="${LIBFGCM}/phy_common"
314   # set the dyn/phys interface path
315   DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat"
316   DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}"
317fi
318
319if [[ "$filtre" == "filtrez" ]]
320then
321   FILTRE_PATH=${LIBFGCM}/$filtre
322fi
323
324if [[ "$chimie" == "INCA" ]]
325then
326   CPP_KEY="$CPP_KEY INCA"
327   INCLUDE_DIR="$INCLUDE_DIR -I${INCA_INCDIR}"
328   LIB="$LIB -L${INCA_LIBDIR} ${INCA_LIB}"
329fi
330
331if [[ "$couple" != "false" ]]
332then
333    if [[ "$couple" == "MPI1" ]]
334    then
335        CPP_KEY="$CPP_KEY CPP_COUPLE"
336        export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1
337        export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib
338        INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}"
339        LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
340    else
341        CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT"
342        INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}"
343        LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
344    fi
345fi
346
347if [[ "$parallel" != "none" && \
348     ( "$code" == "newstart" || "$code" == "start2archive" ) ]]
349then
350    echo "newstart or start2archive utilities should be run in serial!"
351    echo " Compile without -parallel [mpi|omp|mpi_omp] option!"
352    exit 1
353fi
354
355if [[ "$parallel" == "mpi" ]]
356then
357   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
358   PARA_FFLAGS="%MPI_FFLAGS"
359   PARA_LD="%MPI_LD"
360elif [[ "$parallel" == "omp" ]]
361then
362   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
363   PARA_FFLAGS="%OMP_FFLAGS"
364   PARA_LD="%OMP_LD"
365elif [[ "$parallel" == "mpi_omp" ]]
366then
367   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
368   PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS"
369   PARA_LD="%MPI_LD %OMP_LD"
370fi
371
372if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
373   && "$compil_mod" == "debug" ]]
374then
375    echo "Usually, parallelization with OpenMP requires some optimization."
376    echo "We suggest switching to \"-dev\"."
377fi
378
379if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
380then
381#NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
382#    For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments
383#    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
384   INCLUDE_DIR="${INCLUDE_DIR} ${ORCHIDEE_INCDIR}"
385   CPP_KEY="$CPP_KEY CPP_VEGET"
386# temporary, for Orchidee versions 1.9.* (before openmp activation)
387   if [[ "$veget" == "orchidee1.9" ]] ; then
388      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
389   fi
390   if [[ "$veget" == "orchidee2.0" ]] ; then
391      orch_libs="sechiba parameters stomate parallel orglob orchidee"
392   else
393      orch_libs="sechiba parameters stomate parallel orglob"
394   fi
395   LIB="${LIB} -L${ORCHIDEE_LIBDIR} ${ORCHIDEE_LIB}"
396elif [[ "$veget" != "false" ]] ; then
397   echo "Option -v $veget does not exist"
398   echo "Use ./makelmdz_fcm -h for more information"
399   exit 1
400fi
401
402if [[ "$sisvat" == "true" ]]
403then
404   CPP_KEY="$CPP_KEY CPP_SISVAT"
405   SISVAT_PATH="$LIBFGCM/%PHYS/sisvat"
406fi
407
408if [[ "$rrtm" == "true" ]]
409then
410   CPP_KEY="$CPP_KEY CPP_RRTM"
411   RRTM_PATH="$LIBFGCM/%PHYS/rrtm"
412fi
413
414if [[ "$dust" == "true" ]]
415then
416   CPP_KEY="$CPP_KEY CPP_Dust"
417   DUST_PATH="$LIBFGCM/%PHYS/Dust"
418fi
419
420if [[ "$strataer" == "true" ]]
421then
422   CPP_KEY="$CPP_KEY CPP_StratAer"
423   STRATAER_PATH="$LIBFGCM/%PHYS/StratAer"
424fi
425
426if [[ $io == ioipsl ]]
427then
428   CPP_KEY="$CPP_KEY CPP_IOIPSL"
429   INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR}"
430   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}"
431elif [[ $io == mix ]]
432then
433   # For now, xios implies also using ioipsl
434   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
435   INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
436   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
437elif [[ $io == xios ]]
438then
439   # For now, xios implies also using ioipsl
440   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
441   INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
442   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
443fi
444
445if [[ "$cosp" == "true" ]]
446then
447   CPP_KEY="$CPP_KEY CPP_COSP"
448   COSP_PATH="$LIBFGCM/cosp"
449#   LIB="${LIB} -l${LIBPREFIX}cosp"
450fi
451
452# for Titan (but could be used by others as well), there is also "chimtitan"
453if [[ -d ${LIBFGCM}/chim${physique} ]]
454then
455   CHEM_PATH="${LIBFGCM}/chim${physique}"
456   INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/chim${physique}"
457fi
458
459# for Titan add microphysics dependencies
460if [[ -d ${LIBFGCM}/muphy${physique} ]] ; then
461  if ! [ `echo $CPP_KEY | grep -c "OLD_COMPILO"` -gt 0 ] ; then
462    # add muphy{physique} to the list of files to compile.
463    MUPHY_PATH="${LIBFGCM}/muphy${physique}"
464    # For Titan as we embbed some libraries with CPP keys, we define them:
465    #   -DPREC={32|64|80} real kind precision (32: simple, 64: double, 80: extended double)
466    #   -DHAVE_NC_FTN=1 (mandatory: for support of NetCDF in lintnd).
467    CPP_KEY="$CPP_KEY PREC=64 HAVE_NC_FTN=1"
468    if [[ "${physique}" == "titan" ]] ; then
469      echo "Yaahh you're about to use YAMMS in a GCM..."
470    fi
471  fi
472fi
473
474# for Venus (but could be used by others as well), there is also "phyvenus/cloudvenus"
475if [[ -d ${LIBFGCM}/phy${physique}/cloud${physique} ]]
476then
477   CLOUD_PATH="${LIBFGCM}/phy${physique}/cloud${physique}"
478   INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/phy${physique}/cloud${physique}"
479fi
480
481# for Mars (but could be used by others as well), there is also "aeronomars"
482if [[ -d ${LIBFGCM}/aerono${physique} ]]
483then
484   AERONO_PATH="${LIBFGCM}/aerono${physique}"
485   INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/aerono${physique}"
486fi
487
488if [[ -d ${LIBFGCM}/evolution &&  "$code" == "pem" ]]
489then
490if [[ "$physique" == "std" ]]
491then
492   CPP_KEY="$CPP_KEY CPP_STD"
493fi
494   EVOLUTION_PATH="${LIBFGCM}/evolution"
495   INCLUDE="$INCLUDE -I${LIBFGCM}/evolution"
496fi
497
498if [[ -d ${LIBFGCM}/evolution &&  "$code" == "reshape_XIOS_output" ]]
499then
500if [[ "$physique" == "std" ]]
501then
502   CPP_KEY="$CPP_KEY CPP_STD"
503fi
504   EVOLUTION_PATH="${LIBFGCM}/evolution"
505   INCLUDE="$INCLUDE -I${LIBFGCM}/evolution"
506fi
507
508
509# NETCDF library include/library paths
510INCLUDE_DIR="$INCLUDE_DIR ${NETCDF_INCDIR}"
511LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}"
512
513########################################################################
514# calcul du nombre de dimensions
515########################################################################
516
517
518dim_full=$dim
519dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
520set $dim
521dimc=$#
522echo calcul de la dimension
523echo dim $dim
524echo dimc $dimc
525
526
527########################################################################
528# Gestion des dimensions du modele.
529# on cree ou remplace le fichier des dimensions
530########################################################################
531
532cd $LIBFGCM/grid
533if [[ -f dimensions.h ]]
534then
535  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
536  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
537  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
538  echo  vous pouvez continuer en repondant oui.
539  echo "Voulez-vous vraiment continuer?"
540  echo ""
541  echo "WARNING: you are probably already compiling the model somewhere else."
542  echo "Wait until the first compilation is finished before launching this one."
543  echo "If you are sure that you are not compiling elsewhere, just answer "
544  echo "yes (or 'oui') to the question below to proceed."
545  echo "Do you wish to continue?"
546  read reponse
547  if [[ $reponse == "oui" || $reponse == "yes" ]]
548  then
549    \rm -f $LIBFGCM/grid/dimensions.h
550  else
551    exit 1
552  fi
553fi
554
555
556cd $LIBFGCM/grid/dimension
557./makdim $dim
558if (($? != 0))
559then
560    exit 1
561fi
562
563cat $LIBFGCM/grid/dimensions.h
564cd $LMDGCM
565
566if [[ "$bands" != "" ]]
567then
568  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
569  makbandsarg=$(echo $bands | sed -e 's/[^0-9]/ /g')
570  cd $LIBFGCM/phy$physique/bands
571  ./makbands $makbandsarg
572  cat $LIBFGCM/phy$physique/bands.h
573  cd $LMDGCM
574fi
575
576if [[ "$scatterers" != "" ]]
577then
578  if [[ -f $LIBFGCM/phy$physique/scatterers/make_scatterers ]]
579  then
580    # Generic model, recreate scatterers.h
581    cd $LIBFGCM/phy$physique/scatterers
582    ./make_scatterers $scatterers
583    cat $LIBFGCM/phy$physique/scatterers.h
584    cd $LMDGCM
585  else
586    echo "Error: you should not use the -s # option with -p $physique"
587    exit 1
588  fi
589fi
590
591
592########################################################################
593# Differentes dynamiques (3d, 2d, 1d)
594########################################################################
595
596dimension=`echo $dim | wc -w`
597echo dimension $dimension
598
599if (( $dimension == 3 ))
600then
601  cd $LIBFGCM/grid
602  \rm fxyprim.h
603  cp -p fxy_${grille}.h fxyprim.h
604#else
605#  echo "Probleme dans les dimensions de la dynamique !!"
606#  echo "Non reactive pour l'instant !!!"
607fi
608
609if (( $dimension == 1 ))
610then
611## Sanity check: 1D models should be used in serial
612## unless compiled with xios and then it should be in mpi only
613  if [[ $io == xios ]]
614  then
615   echo "OK io xios"
616   if [[ $parallel != "mpi" ]]
617   then
618    echo "Error: a 1D model compiled with xios should also be compiled with "
619    echo "       -parallel mpi option!"
620    exit 1
621   fi
622  else
623  # no xios, check that it is in serial only
624   if [[ $parallel != "none" ]]
625   then
626    echo "Error: a 1D model should not be compiled with "
627    echo "       -parallel [mpi|omp|mpi_omp] option!"
628    exit 1
629   fi
630  fi # of if [[ $io == "xios" ]]
631  CPP_KEY="$CPP_KEY CPP_1D"
632##in 1D, add dyn3d to include path (because main prog is in physics)
633  INCLUDE_DIR="$INCLUDE_DIR -Ilibf/dyn3d -Ilibf/dyn3d_common"
634## no filtre in 1d:
635  FILTRE_PATH=$LMDGCM/.void_dir
636## no need to compile all routines in dyn3d_common either:
637  DYN_COMMON_PATH=$LMDGCM/.void_dir
638## no need to compile all routines in dynlmdz_phy... ;
639## (because key ones are included in 1D main program)
640  DYN_PHYS_PATH=$LMDGCM/.void_dir
641  DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
642fi
643
644######################################################################
645#   Traitement special pour le nouveau rayonnement de Laurent Li.
646#   ---> YM desactive pour le traitemement en parallele
647######################################################################
648
649#if [[ -f $libf/phy$physique/raddim.h ]]
650#then
651# if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
652#then
653#  \rm -f $libf/phy$physique/raddim.h
654#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
655#  echo $libf/phy$physique/raddim.$dimh.h
656#  cat $libf/phy$physique/raddim.h
657# else
658#  echo On peut diminuer la taille de l executable en creant
659#  echo le fichier $libf/phy$physique/raddim.$dimh.h
660#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
661# fi
662#fi
663
664######################################################################
665# Gestion du filtre qui n'existe qu'en 3d.
666######################################################################
667
668if (( `expr $dimc \> 2` == 1 ))
669then
670   filtre="FILTRE=$filtre"
671else
672   filtre="FILTRE= L_FILTRE= "
673fi
674echo MACRO FILTRE $filtre
675
676echo $dimc
677
678
679
680######################################################################
681# Creation du suffixe de la configuration
682######################################################################
683
684if [[ $libphy != "true" ]];then
685  SUFF_NAME=_${dim_full}
686fi
687SUFF_NAME=${SUFF_NAME}_phy${physique}
688
689if [[ "$bands" != "" ]]
690then
691  #if bands option -b VISxIR is used, add "_bVISxIR" to executable name
692  SUFF_NAME=${SUFF_NAME}_b$bands
693fi
694
695if [[ "$parallel" != "none" ]]
696then
697  SUFF_NAME=${SUFF_NAME}_para
698  if (( $dimension == 1 ))
699  then
700    # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
701    DYN=phy${physique}/dyn1d
702  else
703    DYN=dyn${dimc}d${paramem}
704  fi
705  if [[ "$paramem" == "mem" ]]
706  then
707   SUFF_NAME=${SUFF_NAME}_${paramem}
708  fi
709else
710  SUFF_NAME=${SUFF_NAME}_seq
711  if (( $dimension == 1 ))
712  then
713    # dynamics-related routines in"dyn1d" subdirectory of phy${physique}
714    DYN=phy${physique}/dyn1d
715  else
716    DYN=dyn${dimc}d
717  fi
718fi
719
720if [[ $veget != "false" ]]
721then
722  SUFF_NAME=${SUFF_NAME}_orch
723fi
724
725if [[ $couple != "false" ]]
726then
727  SUFF_NAME=${SUFF_NAME}_couple
728fi
729
730if [[ $chimie == "INCA" ]]
731then
732  SUFF_NAME=${SUFF_NAME}_inca
733fi
734SUFF_DEBUG=
735if [[ "$compil_mod" == "debug" ]]
736then
737  SUFF_DEBUG=_debug
738fi
739SUFF_DIR=${SUFF_NAME}${SUFF_DEBUG}
740
741if [[ $libphy == "true" ]]
742then
743  # special case where we compile only the physics
744  DYN=$LMDGCM/.void_dir
745  DYN_COMMON_PATH=$LMDGCM/.void_dir
746  FILTRE_PATH=$LMDGCM/.void_dir
747  DYN_PHYS_PATH=$LMDGCM/.void_dir
748  DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir
749  #and there is no main program to generate
750  code=""
751  SUFF_NAME=""
752  # SUFF_DIR=
753else
754  SUFF_NAME=${SUFF_NAME}.e
755fi
756
757cd $LMDGCM
758config_fcm="config.fcm"
759rm -f $config_fcm
760touch $config_fcm
761
762echo "%ARCH          $arch"          >> $config_fcm
763echo "%INCDIR        $INCLUDE_DIR"       >> $config_fcm
764echo "%LIB           $LIB"           >> $config_fcm
765echo "%ROOT_PATH     $PWD"           >> $config_fcm
766echo "%LIBF          $LIBFGCM"       >> $config_fcm
767echo "%LIBO          $LIBOGCM"       >> $config_fcm
768echo "%DYN           $DYN"           >> $config_fcm
769echo "%DYN_COMMON    $DYN_COMMON_PATH" >> $config_fcm
770echo "%PHY_COMMON    $PHY_COMMON_PATH" >> $config_fcm
771echo "%FILTRE        $FILTRE_PATH"   >> $config_fcm
772echo "%PHYS          phy${physique}" >> $config_fcm
773echo "%DYN_PHYS      $DYN_PHYS_PATH" >> $config_fcm
774echo "%DYN_PHYS_SUB  $DYN_PHYS_SUB_PATH" >> $config_fcm
775echo "%RRTM          $RRTM_PATH"     >> $config_fcm
776echo "%DUST          $DUST_PATH"     >> $config_fcm
777echo "%STRATAER      $STRATAER_PATH" >> $config_fcm
778echo "%SISVAT        $SISVAT_PATH"   >> $config_fcm
779echo "%COSP          $COSP_PATH"     >> $config_fcm
780echo "%CHEM          $CHEM_PATH"     >> $config_fcm
781echo "%CLOUD         $CLOUD_PATH"    >> $config_fcm
782echo "%MUPHY         $MUPHY_PATH"    >> $config_fcm
783echo "%AERONO        $AERONO_PATH"   >> $config_fcm
784echo "%EVOLUTION     $EVOLUTION_PATH"  >> $config_fcm
785echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
786echo "%EXEC          $code"          >> $config_fcm
787echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
788echo "%SUFF_DIR      $SUFF_DIR"      >> $config_fcm
789echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
790echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
791echo "%PARA_LD       $PARA_LD"       >> $config_fcm
792echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
793
794# setup arch.fcm and arch.opt
795rm -f arch.fcm
796rm -f arch.opt
797ln -s arch/arch-${arch}.fcm arch.fcm
798if test -f arch/arch-${arch}.opt &&  [ $compil_mod = "prod" ]
799  then
800  ln -s arch/arch-${arch}.opt arch.opt
801else
802  ln -s .void_file arch.opt
803fi
804
805# cleanup before compiling
806if [[ $libphy != "true" ]]; then
807  rm -f bin/${code}${SUFF_NAME}
808fi
809rm -f $LIBOGCM/${arch}${SUFF_DIR}/.config/fcm.bld.lock
810
811function delete_dim_h {
812  if [[ -r $LIBFGCM/grid/dimensions.h ]];then
813    echo "Removing dimensions.h"
814    \rm -f $LIBFGCM/grid/dimensions.h
815  fi
816}
817
818./build_gcm ${fcm_path} -j $job $full || (echo "Build gcm failed."; delete_dim_h; exit 1)
819
820rm -rf tmp_src
821rm -rf config
822ln -s $LIBOGCM/${arch}${SUFF_DIR}/.config config
823ln -s $LIBOGCM/${arch}${SUFF_DIR}/.config/ppsrc tmp_src
824
825delete_dim_h
Note: See TracBrowser for help on using the repository browser.