source: trunk/LMDZ.COMMON/makelmdz_fcm @ 2757

Last change on this file since 2757 was 2645, checked in by emillour, 3 years ago

Common Dynamics:
Minor improvement in makelmdz_fcm: rename internal variable "INCLUDE"
as "INCLUDE_DIR" to avoid collisions with environment variable "INCLUDE"
present on some systems.
EM

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