source: LMDZ5/trunk/makelmdz_fcm @ 1990

Last change on this file since 1990 was 1990, checked in by Laurent Fairhead, 10 years ago

Corrections à la version r1989 pour permettre la compilation avec RRTM
Inclusion de la licence CeCILL_V2 pour RRTM


Changes to revision r1989 to enable RRTM code compilation
RRTM part put under CeCILL_V2 licence

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