source: LMDZ5/branches/LMDZ5-DOFOCO/makelmdz_fcm @ 2955

Last change on this file since 2955 was 2071, checked in by jghattas, 10 years ago

Updated all compile envrionement with r2064 from the trunk.

  • 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
RevLine 
[1279]1#!/bin/bash
2# $Id: makelmdz_fcm 2071 2014-06-23 08:35:34Z musat $
3# This is a script in Bash.
4
[1140]5# FH : on ne crée plus le fichier arch.mk qui est supposé exister par
[783]6# FH : ailleurs.
[1140]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.
[783]12#
[1279]13##set -x
[783]14########################################################################
15# options par defaut pour la commande make
16########################################################################
17
[1279]18dim="96x72x19"
19physique=lmd
20filtre=filtrez
21grille=reg
22couple=false
23veget=false
[2071]24sisvat=false
25rrtm=false
[1279]26chimie=false
27parallel=none
[1680]28paramem="par"
[1279]29compil_mod=prod
30io=ioipsl
31LIBPREFIX=""
32cosp=false
[2071]33job=1
34full=''
[783]35
[1279]36LMDGCM=`/bin/pwd`
37LIBOGCM=$LMDGCM/libo
38LIBFGCM=$LMDGCM/libf
[1327]39COSP_PATH=$LMDGCM/.void_dir
[1578]40fcm_path=$LMDGCM/tools/fcm/bin
[783]41
42########################################################################
43#  Quelques initialisations de variables du shell.
44########################################################################
45
[1279]46CPP_KEY="" 
47INCLUDE=""
48LIB=""
49adjnt=""
50COMPIL_FFLAGS="%PROD_FFLAGS"
51PARA_FFLAGS=""
52PARA_LD=""
53EXT_SRC=""
[783]54
55########################################################################
56# lecture des options de mymake
57########################################################################
58
[1279]59while (($# > 0))
60  do
61  case $1 in
62      "-h") cat <<fin
[783]63Usage :
[1772]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
[2071]69[-c false/MPI1/OMCT]       : coupling with ocean model : MPI1/OMCT/false (default: false)
[1772]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
[2071]85[-j n]                     : active parallel compiling on ntask
86[-full]                    : full recompiling
[1772]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
[783]91fin
[1279]92          exit;;
[783]93
[1279]94      "-d")
95          dim=$2 ; shift ; shift ;;
96     
97      "-p")
98          physique="$2" ;  shift ; shift ;;
[783]99
[1279]100      "-g")
101          grille="$2" ; shift ; shift ;;
[783]102
[1279]103      "-c")
104          couple="$2" ; shift ; shift ;;
[783]105
[1279]106      "-prod")
107          compil_mod="prod" ; shift ;;
[1002]108
[1279]109      "-dev")
110          compil_mod="dev" ; shift ;;
[1002]111
[1279]112      "-debug")
113          compil_mod="debug" ; shift ;;
[1002]114
[1279]115      "-io")
116          io="$2" ; shift ; shift ;;
[783]117
[1279]118      "-v")
119          veget="$2" ; shift ; shift ;;
[783]120
[2071]121      "-sisvat")
122          sisvat="$2" ; shift ; shift ;;
123
124      "-rrtm")
125          rrtm="$2" ; shift ; shift ;;
126
[1279]127      "-chimie")
128          chimie="$2" ; shift ; shift ;;
[783]129
[1279]130      "-parallel")
131          parallel="$2" ; shift ; shift ;;
132     
133      "-include")
134          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
[783]135
[1279]136      "-cpp")
137          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
[1132]138
[1279]139      "-adjnt")
[1772]140          echo "not operational ... work to be done here ";exit
[1279]141          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
142          optim="$optim -Dadj" ; shift ;;
[783]143
[1279]144      "-cosp")
145          cosp="$2" ; shift ; shift ;;
[1680]146     
147      "-mem")
148          paramem="mem" ; shift ;;
[783]149
[1279]150      "-filtre")
151          filtre=$2 ; shift ; shift ;;
[783]152
[1279]153      "-link")
154          LIB="$LIB $2" ; shift ; shift ;;
[1136]155
[1279]156      "-fcm_path")
157          fcm_path=$2 ; shift ; shift ;;
[783]158
[1279]159      "-ext_src")
160          EXT_SRC=$2 ; shift ; shift ;;
[2071]161      "-j")
162          job=$2 ; shift ; shift ;;
163      "-full")
164          full="-full" ; shift ;;
[783]165
[1279]166      "-arch")
167          arch=$2 ; shift ; shift ;;
[783]168
[1279]169      *)
170          code="$1" ; shift ;;
171  esac
172done
173
[1136]174###############################################################
[1755]175# path to fcm
[1136]176###############################################################
[1755]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
[783]183
[1757]184# add fcm_path to PATH
185export PATH=${fcm_path}:${PATH}
186
[1755]187echo "Path to fcm:"
188echo ${fcm_path}
[1136]189
[783]190###############################################################
[1140]191# lecture des chemins propres à l'architecture de la machine #
[783]192###############################################################
[1279]193rm -f .void_file
194echo > .void_file
[1327]195rm -rf .void_dir
196mkdir .void_dir
[1279]197rm -f arch.path
198ln -s arch/arch-${arch}.path ./arch.path
[783]199source arch.path
200
201########################################################################
202# Definition des clefs CPP, des chemins des includes et modules
203#  et des libraries
204########################################################################
205
[1279]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
[783]216
[1279]217if [[ "$physique" != "nophys" ]]
218then
[1615]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
[1279]224   CPP_KEY="$CPP_KEY CPP_EARTH"
[1615]225   fi
[1279]226fi
[783]227
[1279]228if [[ "$chimie" == "INCA" ]]
229then
230   CPP_KEY="$CPP_KEY INCA"
231   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
232   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
233fi
[783]234
[1279]235if [[ "$couple" != "false" ]]
236then
[2071]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
[1279]249fi
[783]250
[1279]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
[783]267
[1279]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
[783]274
[2071]275if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
[1279]276then
[2071]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
[1279]280   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
[1772]281   CPP_KEY="$CPP_KEY CPP_VEGET"
[2071]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
[1772]298   echo "Option -v $veget does not exist"
299   echo "Use ./makelmdz_fcm -h for more information"
300   exit 
[1279]301fi
[783]302
[2071]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
[1279]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"
[2071]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"
[1279]328fi
[2071]329
[1279]330if [[ "$cosp" == "true" ]]
331then
332   CPP_KEY="$CPP_KEY CPP_COSP"
[1327]333   COSP_PATH="$LIBFGCM/cosp"
[1279]334#   LIB="${LIB} -l${LIBPREFIX}cosp"
335fi
[783]336
[1551]337INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
338LIB="$LIB ${NETCDF_LIBDIR}"
339
[783]340########################################################################
341# calcul du nombre de dimensions
342########################################################################
343
344
[1279]345dim_full=$dim
346dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
347set $dim
348dimc=$#
[783]349echo calcul de la dimension
350echo dim $dim
351echo dimc $dimc
352
353
354########################################################################
355# Gestion des dimensions du modele.
[1114]356# on cree ou remplace le fichier des dimensions
[783]357########################################################################
358
[1695]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?"
[1755]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?"
[1695]373  read reponse
[1755]374  if [[ $reponse == "oui" || $reponse == "yes" ]]
[1695]375  then
[1696]376    \rm -f $LIBFGCM/grid/dimensions.h
[1695]377  else
378    exit
379  fi
380fi
381
382
[783]383cd $LIBFGCM/grid/dimension
[1114]384./makdim $dim
[783]385cat $LIBFGCM/grid/dimensions.h
386cd $LMDGCM
387
388
389########################################################################
390# Differentes dynamiques (3d, 2d, 1d)
391########################################################################
392
[1279]393dimension=`echo $dim | wc -w`
[783]394echo dimension $dimension
395
[1279]396if (( $dimension == 3 ))
397then
[783]398  cd $LIBFGCM/grid
399  \rm fxyprim.h
400  cp -p fxy_${grille}.h fxyprim.h
[1279]401else
402  echo "Probleme dans les dimensions de la dynamique !!"
403  echo "Non reactive pour l'instant !!!"
404fi
[783]405
406######################################################################
407#   Traitement special pour le nouveau rayonnement de Laurent Li.
408#   ---> YM desactive pour le traitemement en parallele
409######################################################################
410
[1279]411#if [[ -f $libf/phy$physique/raddim.h ]]
412#then
413# if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
414#then
[783]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
[1279]423# fi
424#fi
[783]425
426######################################################################
427# Gestion du filtre qui n'existe qu'en 3d.
428######################################################################
429
[1279]430if (( `expr $dimc \> 2` == 1 ))
431then
432   filtre="FILTRE=$filtre"
[783]433else
[1279]434   filtre="FILTRE= L_FILTRE= "
435fi
[783]436echo MACRO FILTRE $filtre
437
438echo $dimc
439
440
441
442######################################################################
443# Creation du suffixe de la configuration
444######################################################################
445
446
[1279]447SUFF_NAME=_${dim_full}
448SUFF_NAME=${SUFF_NAME}_phy${physique}
[783]449
[1279]450if [[ "$parallel" != "none" ]]
451then
452  SUFF_NAME=${SUFF_NAME}_para
[1680]453  DYN=dyn${dimc}d${paramem}
454  if [[ "$paramem" == "mem" ]]
455  then
456   SUFF_NAME=${SUFF_NAME}_${paramem}
457  fi
[783]458else
[1279]459  SUFF_NAME=${SUFF_NAME}_seq
460  DYN=dyn${dimc}d
461fi
[783]462
[1772]463if [[ $veget != "false" ]]
[1279]464then
465  SUFF_NAME=${SUFF_NAME}_orch
466fi
[783]467
[1279]468if [[ $couple != "false" ]]
469then
470  SUFF_NAME=${SUFF_NAME}_couple
471fi
[783]472
[1279]473if [[ $chimie == "INCA" ]]
474then
475  SUFF_NAME=${SUFF_NAME}_inca
476fi
[783]477
478cd $LMDGCM
[1279]479config_fcm="config.fcm"
[783]480rm -f $config_fcm
481touch $config_fcm
482rm -f bin/${code}${SUFF_NAME}.e
483rm -f arch.fcm
[1279]484rm -f arch.opt
[783]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
[1327]494echo "%COSP          $COSP_PATH"     >> $config_fcm
[783]495echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
496echo "%EXEC          $code"          >> $config_fcm
497echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
[1002]498echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
499echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
500echo "%PARA_LD       $PARA_LD"       >> $config_fcm
[1279]501echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
[783]502
[1002]503
504
[1137]505ln -s arch/arch-${arch}.fcm arch.fcm
[1279]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
[1002]514rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
[2071]515./build_gcm ${fcm_path} -j $job $full
[783]516
[1279]517rm -rf tmp_src
518rm -rf config
[783]519ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
520ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/tmp tmp_src
[1695]521
[2071]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
[1696]531if [[ -r $LIBFGCM/grid/dimensions.h ]]
[1695]532then
533  # Cleanup: remove dimension.h file
[1696]534  \rm -f $LIBFGCM/grid/dimensions.h
[1695]535fi
Note: See TracBrowser for help on using the repository browser.