source: LMDZ5/branches/testing/makelmdz_fcm @ 1795

Last change on this file since 1795 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
Line 
1#!/bin/bash
2# $Id: makelmdz_fcm 1795 2013-07-18 08:20:28Z emillour $
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
24chimie=false
25parallel=none
26paramem="par"
27compil_mod=prod
28io=ioipsl
29LIBPREFIX=""
30cosp=false
31
32LMDGCM=`/bin/pwd`
33LIBOGCM=$LMDGCM/libo
34LIBFGCM=$LMDGCM/libf
35COSP_PATH=$LMDGCM/.void_dir
36fcm_path=$LMDGCM/tools/fcm/bin
37
38########################################################################
39#  Quelques initialisations de variables du shell.
40########################################################################
41
42CPP_KEY="" 
43INCLUDE=""
44LIB=""
45adjnt=""
46COMPIL_FFLAGS="%PROD_FFLAGS"
47PARA_FFLAGS=""
48PARA_LD=""
49EXT_SRC=""
50
51########################################################################
52# lecture des options de mymake
53########################################################################
54
55while (($# > 0))
56  do
57  case $1 in
58      "-h") cat <<fin
59Usage :
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
85fin
86          exit;;
87
88      "-d")
89          dim=$2 ; shift ; shift ;;
90     
91      "-p")
92          physique="$2" ;  shift ; shift ;;
93
94      "-g")
95          grille="$2" ; shift ; shift ;;
96
97      "-c")
98          couple="$2" ; shift ; shift ;;
99
100      "-prod")
101          compil_mod="prod" ; shift ;;
102
103      "-dev")
104          compil_mod="dev" ; shift ;;
105
106      "-debug")
107          compil_mod="debug" ; shift ;;
108
109      "-io")
110          io="$2" ; shift ; shift ;;
111
112      "-v")
113          veget="$2" ; shift ; shift ;;
114
115      "-chimie")
116          chimie="$2" ; shift ; shift ;;
117
118      "-parallel")
119          parallel="$2" ; shift ; shift ;;
120     
121      "-include")
122          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
123
124      "-cpp")
125          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
126
127      "-adjnt")
128          echo "not operational ... work to be done here ";exit
129          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
130          optim="$optim -Dadj" ; shift ;;
131
132      "-cosp")
133          cosp="$2" ; shift ; shift ;;
134     
135      "-mem")
136          paramem="mem" ; shift ;;
137
138      "-filtre")
139          filtre=$2 ; shift ; shift ;;
140
141      "-link")
142          LIB="$LIB $2" ; shift ; shift ;;
143
144      "-fcm_path")
145          fcm_path=$2 ; shift ; shift ;;
146
147      "-ext_src")
148          EXT_SRC=$2 ; shift ; shift ;;
149
150      "-arch")
151          arch=$2 ; shift ; shift ;;
152
153      *)
154          code="$1" ; shift ;;
155  esac
156done
157
158###############################################################
159# path to fcm
160###############################################################
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
167
168# add fcm_path to PATH
169export PATH=${fcm_path}:${PATH}
170
171echo "Path to fcm:"
172echo ${fcm_path}
173
174###############################################################
175# lecture des chemins propres à l'architecture de la machine #
176###############################################################
177rm -f .void_file
178echo > .void_file
179rm -rf .void_dir
180mkdir .void_dir
181rm -f arch.path
182ln -s arch/arch-${arch}.path ./arch.path
183source arch.path
184
185########################################################################
186# Definition des clefs CPP, des chemins des includes et modules
187#  et des libraries
188########################################################################
189
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
200
201if [[ "$physique" != "nophys" ]]
202then
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
208   CPP_KEY="$CPP_KEY CPP_EARTH"
209   fi
210fi
211
212if [[ "$chimie" == "INCA" ]]
213then
214   CPP_KEY="$CPP_KEY INCA"
215   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
216   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
217fi
218
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
225
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
242
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
249
250if [[ "$veget" == "orchidee2.0" ]]
251then
252# orchidee2.0 :
253# Compile with ORCHIDEE 2.0 (or more recent)
254   CPP_KEY="$CPP_KEY CPP_VEGET"
255   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
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}"
263   LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob"
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 
277fi
278
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"
288   COSP_PATH="$LIBFGCM/cosp"
289#   LIB="${LIB} -l${LIBPREFIX}cosp"
290fi
291
292INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
293LIB="$LIB ${NETCDF_LIBDIR}"
294
295########################################################################
296# calcul du nombre de dimensions
297########################################################################
298
299
300dim_full=$dim
301dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
302set $dim
303dimc=$#
304echo calcul de la dimension
305echo dim $dim
306echo dimc $dimc
307
308
309########################################################################
310# Gestion des dimensions du modele.
311# on cree ou remplace le fichier des dimensions
312########################################################################
313
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?"
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?"
328  read reponse
329  if [[ $reponse == "oui" || $reponse == "yes" ]]
330  then
331    \rm -f $LIBFGCM/grid/dimensions.h
332  else
333    exit
334  fi
335fi
336
337
338cd $LIBFGCM/grid/dimension
339./makdim $dim
340cat $LIBFGCM/grid/dimensions.h
341cd $LMDGCM
342
343
344########################################################################
345# Differentes dynamiques (3d, 2d, 1d)
346########################################################################
347
348dimension=`echo $dim | wc -w`
349echo dimension $dimension
350
351if (( $dimension == 3 ))
352then
353  cd $LIBFGCM/grid
354  \rm fxyprim.h
355  cp -p fxy_${grille}.h fxyprim.h
356else
357  echo "Probleme dans les dimensions de la dynamique !!"
358  echo "Non reactive pour l'instant !!!"
359fi
360
361######################################################################
362#   Traitement special pour le nouveau rayonnement de Laurent Li.
363#   ---> YM desactive pour le traitemement en parallele
364######################################################################
365
366#if [[ -f $libf/phy$physique/raddim.h ]]
367#then
368# if [[ -f $libf/phy$physique/raddim.$dimh.h ]]
369#then
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
378# fi
379#fi
380
381######################################################################
382# Gestion du filtre qui n'existe qu'en 3d.
383######################################################################
384
385if (( `expr $dimc \> 2` == 1 ))
386then
387   filtre="FILTRE=$filtre"
388else
389   filtre="FILTRE= L_FILTRE= "
390fi
391echo MACRO FILTRE $filtre
392
393echo $dimc
394
395
396
397######################################################################
398# Creation du suffixe de la configuration
399######################################################################
400
401
402SUFF_NAME=_${dim_full}
403SUFF_NAME=${SUFF_NAME}_phy${physique}
404
405if [[ "$parallel" != "none" ]]
406then
407  SUFF_NAME=${SUFF_NAME}_para
408  DYN=dyn${dimc}d${paramem}
409  if [[ "$paramem" == "mem" ]]
410  then
411   SUFF_NAME=${SUFF_NAME}_${paramem}
412  fi
413else
414  SUFF_NAME=${SUFF_NAME}_seq
415  DYN=dyn${dimc}d
416fi
417
418if [[ $veget != "false" ]]
419then
420  SUFF_NAME=${SUFF_NAME}_orch
421fi
422
423if [[ $couple != "false" ]]
424then
425  SUFF_NAME=${SUFF_NAME}_couple
426fi
427
428if [[ $chimie == "INCA" ]]
429then
430  SUFF_NAME=${SUFF_NAME}_inca
431fi
432
433cd $LMDGCM
434config_fcm="config.fcm"
435rm -f $config_fcm
436touch $config_fcm
437rm -f bin/${code}${SUFF_NAME}.e
438rm -f arch.fcm
439rm -f arch.opt
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
449echo "%COSP          $COSP_PATH"     >> $config_fcm
450echo "%CPP_KEY       $CPP_KEY"       >> $config_fcm
451echo "%EXEC          $code"          >> $config_fcm
452echo "%SUFF_NAME     $SUFF_NAME"     >> $config_fcm
453echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm
454echo "%PARA_FFLAGS   $PARA_FFLAGS"   >> $config_fcm
455echo "%PARA_LD       $PARA_LD"       >> $config_fcm
456echo "%EXT_SRC       $EXT_SRC"       >> $config_fcm
457
458
459
460ln -s arch/arch-${arch}.fcm arch.fcm
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
469rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock
470./build_gcm ${fcm_path}
471
472rm -rf tmp_src
473rm -rf config
474ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config
475ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/tmp tmp_src
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.