source: LMDZ5/branches/testing/makelmdz_fcm @ 1856

Last change on this file since 1856 was 1795, checked in by Ehouarn Millour, 11 years ago

Version testing basee sur la r1794


Testing release based on r1794

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