source: LMDZ5/trunk/makelmdz_fcm @ 1867

Last change on this file since 1867 was 1865, checked in by Laurent Fairhead, 11 years ago

Inclusion de la bibliothèque SISVAT/MAR à LMDZ pour le traitement des surfaces
"land ice"

  1. Menegoz

Integration of the SISVAT/MAR library to LMDZ to model the land ice surfaces

  1. Menegoz
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 13.9 KB
Line 
1#!/bin/bash
2# $Id: makelmdz_fcm 1865 2013-09-13 08:26:46Z fairhead $
3# This is a script in Bash.
4
5# FH : on ne crée plus le fichier arch.mk qui est supposé exister par
6# FH : ailleurs.
7# FH : ulterieurement, ce fichier sera pré-existant pour une série
8# FH : de configurations en versions optimisées et debug qui seront
9# FH : liés (ln -s) avec arch.mk en fonction de l'architecture.
10# FH : Pour le moment, cette version est en test et on peut créer les
11# FH : arch.mk en lançant une première fois makegcm.
12#
13##set -x
14########################################################################
15# options par defaut pour la commande make
16########################################################################
17
18dim="96x72x19"
19physique=lmd
20filtre=filtrez
21grille=reg
22couple=false
23veget=false
24sisvat=false
25chimie=false
26parallel=none
27paramem="par"
28compil_mod=prod
29io=ioipsl
30LIBPREFIX=""
31cosp=false
32job=1
33full=''
34
35LMDGCM=`/bin/pwd`
36LIBOGCM=$LMDGCM/libo
37LIBFGCM=$LMDGCM/libf
38COSP_PATH=$LMDGCM/.void_dir
39fcm_path=$LMDGCM/tools/fcm/bin
40
41########################################################################
42#  Quelques initialisations de variables du shell.
43########################################################################
44
45CPP_KEY="" 
46INCLUDE=""
47LIB=""
48adjnt=""
49COMPIL_FFLAGS="%PROD_FFLAGS"
50PARA_FFLAGS=""
51PARA_LD=""
52EXT_SRC=""
53
54########################################################################
55# lecture des options de mymake
56########################################################################
57
58while (($# > 0))
59  do
60  case $1 in
61      "-h") cat <<fin
62Usage :
63makelmdz_fcm [options] -arch nom_arch exec
64[-h]                       : brief help
65[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
66[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
67[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug
68[-c false/MPI1/MPI2]       : coupling with ocean model : MPI1/MPI2/false (default: false)
69[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
70          false       : no vegetation model
71          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
72          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
73          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
74[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
75[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
76[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
77[-io IO]                   : Input/Output library (default: ioipsl)
78[-include INCLUDES]        : extra include path to add
79[-cpp CPP_KEY]             : additional preprocessing definitions
80[-adjnt]                   : adjoint model, not operational ...
81[-mem]                     : reduced memory dynamics (if in parallel mode)
82[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
83[-link LINKS]              : additional links with other libraries
84[-j n]                     : active parallel compiling on ntask
85[-full]                    : full recompiling
86[-fcm_path path]           : path to the fcm tool (default: tools/fcm/bin)
87[-ext_src path]            : path to an additional set of routines to compile with the model
88 -arch nom_arch            : target architecture
89 exec                      : executable to build
90fin
91          exit;;
92
93      "-d")
94          dim=$2 ; shift ; shift ;;
95     
96      "-p")
97          physique="$2" ;  shift ; shift ;;
98
99      "-g")
100          grille="$2" ; shift ; shift ;;
101
102      "-c")
103          couple="$2" ; shift ; shift ;;
104
105      "-prod")
106          compil_mod="prod" ; shift ;;
107
108      "-dev")
109          compil_mod="dev" ; shift ;;
110
111      "-debug")
112          compil_mod="debug" ; shift ;;
113
114      "-io")
115          io="$2" ; shift ; shift ;;
116
117      "-v")
118          veget="$2" ; shift ; shift ;;
119
120      "-sisvat")
121          sisvat="$2" ; shift ; shift ;;
122
123      "-chimie")
124          chimie="$2" ; shift ; shift ;;
125
126      "-parallel")
127          parallel="$2" ; shift ; shift ;;
128     
129      "-include")
130          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
131
132      "-cpp")
133          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
134
135      "-adjnt")
136          echo "not operational ... work to be done here ";exit
137          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
138          optim="$optim -Dadj" ; shift ;;
139
140      "-cosp")
141          cosp="$2" ; shift ; shift ;;
142     
143      "-mem")
144          paramem="mem" ; shift ;;
145
146      "-filtre")
147          filtre=$2 ; shift ; shift ;;
148
149      "-link")
150          LIB="$LIB $2" ; shift ; shift ;;
151
152      "-fcm_path")
153          fcm_path=$2 ; shift ; shift ;;
154
155      "-ext_src")
156          EXT_SRC=$2 ; shift ; shift ;;
157      "-j")
158          job=$2 ; shift ; shift ;;
159      "-full")
160          full="-full" ; shift ;;
161
162      "-arch")
163          arch=$2 ; shift ; shift ;;
164
165      *)
166          code="$1" ; shift ;;
167  esac
168done
169
170###############################################################
171# path to fcm
172###############################################################
173# handle case when provided path to fcm was given as a relative
174# path (from makelmdz_fcm script directory) and not an absolute path
175if [[ ${fcm_path:0:1} != "/" ]] ; then
176  # prepend with makelmdz_fcm location
177  fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path}
178fi
179
180# add fcm_path to PATH
181export PATH=${fcm_path}:${PATH}
182
183echo "Path to fcm:"
184echo ${fcm_path}
185
186###############################################################
187# lecture des chemins propres à l'architecture de la machine #
188###############################################################
189rm -f .void_file
190echo > .void_file
191rm -rf .void_dir
192mkdir .void_dir
193rm -f arch.path
194ln -s arch/arch-${arch}.path ./arch.path
195source arch.path
196
197########################################################################
198# Definition des clefs CPP, des chemins des includes et modules
199#  et des libraries
200########################################################################
201
202if [[ "$compil_mod" == "prod" ]]
203then
204  COMPIL_FFLAGS="%PROD_FFLAGS"
205elif [[ "$compil_mod" == "dev" ]]
206then
207  COMPIL_FFLAGS="%DEV_FFLAGS"
208elif [[ "$compil_mod" == "debug" ]]
209then
210  COMPIL_FFLAGS="%DEBUG_FFLAGS"
211fi
212
213if [[ "$physique" != "nophys" ]]
214then
215   #We'll use some physics
216   CPP_KEY="$CPP_KEY CPP_PHYS"
217   if [[ "${physique:0:3}" == "lmd" ]]
218   then
219   #For lmd physics, default planet type is Earth
220   CPP_KEY="$CPP_KEY CPP_EARTH"
221   fi
222fi
223
224if [[ "$chimie" == "INCA" ]]
225then
226   CPP_KEY="$CPP_KEY INCA"
227   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
228   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
229fi
230
231if [[ "$couple" != "false" ]]
232then
233   CPP_KEY="$CPP_KEY CPP_COUPLE"
234   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
235   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
236fi
237
238if [[ "$parallel" == "mpi" ]]
239then
240   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
241   PARA_FFLAGS="%MPI_FFLAGS"
242   PARA_LD="%MPI_LD"
243elif [[ "$parallel" == "omp" ]]
244then
245   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
246   PARA_FFLAGS="%OMP_FFLAGS"
247   PARA_LD="%OMP_LD"
248elif [[ "$parallel" == "mpi_omp" ]]
249then
250   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
251   PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS"
252   PARA_LD="%MPI_LD %OMP_LD"
253fi
254
255if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
256   && "$compil_mod" == "debug" ]]
257then
258    echo "Usually, parallelization with OpenMP requires some optimization."
259    echo "We suggest switching to \"-dev\"."
260fi
261
262if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
263then
264#NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
265#    For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments
266#    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
267   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
268   CPP_KEY="$CPP_KEY CPP_VEGET"
269# temporary, for Orchidee versions 1.9.* (before openmp activation)
270   if [[ "$veget" == "orchidee1.9" ]] ; then
271      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
272   fi
273   if [[ "$veget" == "orchidee2.0" ]] ; then
274      orch_libs="sechiba parameters stomate parallel orglob orchidee"
275   else
276      orch_libs="sechiba parameters stomate parallel orglob"
277   fi
278   LIB="${LIB} -L${ORCH_LIBDIR}"
279   for lib in ${orch_libs} ; do
280      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
281         LIB="${LIB} -l${LIBPREFIX}$lib "
282      fi
283   done
284elif [[ "$veget" != "false" ]] ; then
285   echo "Option -v $veget does not exist"
286   echo "Use ./makelmdz_fcm -h for more information"
287   exit 
288fi
289
290if [[ "$sisvat" == "true" ]]
291then
292   CPP_KEY="$CPP_KEY CPP_SISVAT"
293fi
294
295if [[ $io == ioipsl ]]
296then
297   CPP_KEY="$CPP_KEY CPP_IOIPSL"
298   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
299   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
300fi
301if [[ "$cosp" == "true" ]]
302then
303   CPP_KEY="$CPP_KEY CPP_COSP"
304   COSP_PATH="$LIBFGCM/cosp"
305#   LIB="${LIB} -l${LIBPREFIX}cosp"
306fi
307
308INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
309LIB="$LIB ${NETCDF_LIBDIR}"
310
311########################################################################
312# calcul du nombre de dimensions
313########################################################################
314
315
316dim_full=$dim
317dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
318set $dim
319dimc=$#
320echo calcul de la dimension
321echo dim $dim
322echo dimc $dimc
323
324
325########################################################################
326# Gestion des dimensions du modele.
327# on cree ou remplace le fichier des dimensions
328########################################################################
329
330cd $LIBFGCM/grid
331if [[ -f dimensions.h ]]
332then
333  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
334  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
335  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
336  echo  vous pouvez continuer en repondant oui.
337  echo "Voulez-vous vraiment continuer?"
338  echo ""
339  echo "WARNING: you are probably already compiling the model somewhere else."
340  echo "Wait until the first compilation is finished before launching this one."
341  echo "If you are sure that you are not compiling elsewhere, just answer "
342  echo "yes (or 'oui') to the question below to proceed."
343  echo "Do you wish to continue?"
344  read reponse
345  if [[ $reponse == "oui" || $reponse == "yes" ]]
346  then
347    \rm -f $LIBFGCM/grid/dimensions.h
348  else
349    exit
350  fi
351fi
352
353
354cd $LIBFGCM/grid/dimension
355./makdim $dim
356cat $LIBFGCM/grid/dimensions.h
357cd $LMDGCM
358
359
360########################################################################
361# Differentes dynamiques (3d, 2d, 1d)
362########################################################################
363
364dimension=`echo $dim | wc -w`
365echo dimension $dimension
366
367if (( $dimension == 3 ))
368then
369  cd $LIBFGCM/grid
370  \rm fxyprim.h
371  cp -p fxy_${grille}.h fxyprim.h
372else
373  echo "Probleme dans les dimensions de la dynamique !!"
374  echo "Non reactive pour l'instant !!!"
375fi
376
377######################################################################
378#   Traitement special pour le nouveau rayonnement de Laurent Li.
379#   ---> YM desactive pour le traitemement en parallele
380######################################################################
381
382#if [[ -f $libf/phy$physique/raddim.h ]]
383#then
384# if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
385#then
386#  \rm -f $libf/phy$physique/raddim.h
387#  cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h
388#  echo $libf/phy$physique/raddim.$dimh.h
389#  cat $libf/phy$physique/raddim.h
390# else
391#  echo On peut diminuer la taille de l executable en creant
392#  echo le fichier $libf/phy$physique/raddim.$dimh.h
393#  \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h
394# fi
395#fi
396
397######################################################################
398# Gestion du filtre qui n'existe qu'en 3d.
399######################################################################
400
401if (( `expr $dimc \> 2` == 1 ))
402then
403   filtre="FILTRE=$filtre"
404else
405   filtre="FILTRE= L_FILTRE= "
406fi
407echo MACRO FILTRE $filtre
408
409echo $dimc
410
411
412
413######################################################################
414# Creation du suffixe de la configuration
415######################################################################
416
417
418SUFF_NAME=_${dim_full}
419SUFF_NAME=${SUFF_NAME}_phy${physique}
420
421if [[ "$parallel" != "none" ]]
422then
423  SUFF_NAME=${SUFF_NAME}_para
424  DYN=dyn${dimc}d${paramem}
425  if [[ "$paramem" == "mem" ]]
426  then
427   SUFF_NAME=${SUFF_NAME}_${paramem}
428  fi
429else
430  SUFF_NAME=${SUFF_NAME}_seq
431  DYN=dyn${dimc}d
432fi
433
434if [[ $veget != "false" ]]
435then
436  SUFF_NAME=${SUFF_NAME}_orch
437fi
438
439if [[ $couple != "false" ]]
440then
441  SUFF_NAME=${SUFF_NAME}_couple
442fi
443
444if [[ $chimie == "INCA" ]]
445then
446  SUFF_NAME=${SUFF_NAME}_inca
447fi
448
449cd $LMDGCM
450config_fcm="config.fcm"
451rm -f $config_fcm
452touch $config_fcm
453rm -f bin/${code}${SUFF_NAME}.e
454rm -f arch.fcm
455rm -f arch.opt
456
457echo "%ARCH          $arch"          >> $config_fcm
458echo "%INCDIR        $INCLUDE"       >> $config_fcm 
459echo "%LIB           $LIB"           >> $config_fcm
460echo "%ROOT_PATH     $PWD"           >> $config_fcm
461echo "%LIBF          $LIBFGCM"       >> $config_fcm
462echo "%LIBO          $LIBOGCM"       >> $config_fcm
463echo "%DYN           $DYN"           >> $config_fcm
464echo "%PHYS          phy${physique}" >> $config_fcm
465echo "%COSP          $COSP_PATH"     >> $config_fcm
466echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
467echo "%EXEC          $code"          >> $config_fcm
468echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
469echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
470echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
471echo "%PARA_LD       $PARA_LD"       >> $config_fcm
472echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
473
474
475
476ln -s arch/arch-${arch}.fcm arch.fcm
477if test -f arch/arch-${arch}.opt &&  [ $compil_mod = "prod" ]
478  then
479  ln -s arch/arch-${arch}.opt arch.opt
480else
481  ln -s .void_file arch.opt
482fi
483
484
485rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
486./build_gcm ${fcm_path} -j $job $full
487
488rm -rf tmp_src
489rm -rf config
490ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
491ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/tmp tmp_src
492
493if [[ -r $LIBFGCM/grid/dimensions.h ]]
494then
495  # Cleanup: remove dimension.h file
496  \rm -f $LIBFGCM/grid/dimensions.h
497fi
Note: See TracBrowser for help on using the repository browser.