source: LMDZ5/trunk/makelmdz_fcm @ 2246

Last change on this file since 2246 was 2242, checked in by Ehouarn Millour, 10 years ago

Further reorganizing of the physics-dynamics interface.
Things related to dynamics grid and physics grid go in "dynlonlat_phylonlat".
Any physics phy* related stuff (e.g. iniphysiq, ce0l) goes in a phy* subdirectory of dynlonlat_phylonlat.
EM

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