1 | #!/bin/bash |
---|
2 | # |
---|
3 | # $Id$ |
---|
4 | # |
---|
5 | # |
---|
6 | ######################################################################## |
---|
7 | # for debug, uncomment line below |
---|
8 | #set -xv |
---|
9 | ######################################################################## |
---|
10 | # options par defaut pour la commande make |
---|
11 | ######################################################################## |
---|
12 | dim="96x72x19" |
---|
13 | physique=lmd |
---|
14 | code=gcm |
---|
15 | filtre=filtrez |
---|
16 | grille=reg |
---|
17 | couple=false |
---|
18 | veget=false |
---|
19 | chimie=false |
---|
20 | parallel=none |
---|
21 | paramem="par" |
---|
22 | compil_mod=prod |
---|
23 | io=ioipsl |
---|
24 | LIBPREFIX="" |
---|
25 | fcm_path=none |
---|
26 | cosp=false |
---|
27 | sisvat=false |
---|
28 | |
---|
29 | # guess a default 'arch' |
---|
30 | arch="local" # start with assuming we're on a local machine with local arch file |
---|
31 | ## try to recognise machine and infer arch from it |
---|
32 | machine=`hostname` |
---|
33 | if [[ "$machine" == "brodie" ]] |
---|
34 | then |
---|
35 | arch="SX8_BRODIE" |
---|
36 | fi |
---|
37 | if [[ "${machine:0:6}" == "vargas" ]] |
---|
38 | then |
---|
39 | arch="PW6_VARGAS" |
---|
40 | fi |
---|
41 | if [[ "${machine:0:6}" == "ciclad" ]] |
---|
42 | then |
---|
43 | arch="AMD64_CICLAD" |
---|
44 | fi |
---|
45 | if [[ "${machine:0:7}" == "platine" ]] |
---|
46 | then |
---|
47 | arch="IA64_PLATINE" |
---|
48 | fi |
---|
49 | if [[ "${machine:0:6}" == "titane" ]] |
---|
50 | then |
---|
51 | arch="X64_TITANE" |
---|
52 | fi |
---|
53 | if [[ "${machine:0:8}" == "mercure1" ]] |
---|
54 | then |
---|
55 | arch="SX8_MERCURE" |
---|
56 | fi |
---|
57 | if [[ "${machine:0:8}" == "mercure2" ]] |
---|
58 | then |
---|
59 | arch="SX9_MERCURE" |
---|
60 | fi |
---|
61 | |
---|
62 | LMDGCM=`pwd -P` |
---|
63 | LIBFGCM=$LMDGCM/libf |
---|
64 | LIBOGCM=$LMDGCM/libo |
---|
65 | if [[ ! -d $LIBOGCM ]] |
---|
66 | then |
---|
67 | # create the directory |
---|
68 | mkdir $LIBOGCM |
---|
69 | if [[ ! $? ]] |
---|
70 | then |
---|
71 | echo "Failed to create directory $LIBOGCM" |
---|
72 | exit |
---|
73 | fi |
---|
74 | fi |
---|
75 | COSP_PATH=$LMDGCM/.void_dir |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | localdir=`pwd -P` |
---|
80 | ######################################################################## |
---|
81 | # Quelques initialisations de variables du shell. |
---|
82 | ######################################################################## |
---|
83 | |
---|
84 | CPP_KEY="" |
---|
85 | INCLUDE='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/filtrez -I. ' |
---|
86 | LIB="" |
---|
87 | adjnt="" |
---|
88 | ##COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
89 | PARA_FFLAGS="" |
---|
90 | PARA_LD="" |
---|
91 | EXT_SRC="" |
---|
92 | |
---|
93 | ######################################################################## |
---|
94 | # lecture des options |
---|
95 | ######################################################################## |
---|
96 | |
---|
97 | while (($# > 0)) |
---|
98 | do |
---|
99 | case $1 in |
---|
100 | "-h") cat <<fin |
---|
101 | Usage : |
---|
102 | makelmdz [options] -arch nom_arch exec |
---|
103 | [-h] : brief help |
---|
104 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
105 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
106 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
107 | [-c false/MPI1/MPI2] : coupling with ocean model : MPI1/MPI2/false (default: false) |
---|
108 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
109 | false : no vegetation model |
---|
110 | orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version) |
---|
111 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
112 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
113 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
114 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
115 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
116 | [-io IO] : Input/Output library (default: ioipsl) |
---|
117 | [-include INCLUDES] : extra include path to add |
---|
118 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
119 | [-adjnt] : adjoint model, not operational ... |
---|
120 | [-mem] : reduced memory dynamics (if in parallel mode) |
---|
121 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
122 | [-link LINKS] : additional links with other libraries |
---|
123 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
124 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
125 | -arch nom_arch : target architecture |
---|
126 | exec : executable to build |
---|
127 | fin |
---|
128 | exit;; |
---|
129 | "-d") |
---|
130 | dim=$2 ; shift ; shift ;; |
---|
131 | |
---|
132 | "-p") |
---|
133 | physique="$2" ; shift ; shift ;; |
---|
134 | |
---|
135 | "-g") |
---|
136 | grille="$2" ; shift ; shift ;; |
---|
137 | |
---|
138 | "-c") |
---|
139 | couple="$2" ; shift ; shift ;; |
---|
140 | |
---|
141 | "-prod") |
---|
142 | compil_mod="prod" ; shift ;; |
---|
143 | |
---|
144 | "-dev") |
---|
145 | compil_mod="dev" ; shift ;; |
---|
146 | |
---|
147 | "-debug") |
---|
148 | compil_mod="debug" ; shift ;; |
---|
149 | |
---|
150 | "-io") |
---|
151 | io="$2" ; shift ; shift ;; |
---|
152 | |
---|
153 | "-v") |
---|
154 | veget="$2" ; shift ; shift ;; |
---|
155 | |
---|
156 | "-chimie") |
---|
157 | chimie="$2" ; shift ; shift ;; |
---|
158 | |
---|
159 | "-parallel") |
---|
160 | parallel="$2" ; shift ; shift ;; |
---|
161 | |
---|
162 | "-include") |
---|
163 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
164 | |
---|
165 | "-cpp") |
---|
166 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
167 | |
---|
168 | "-adjnt") |
---|
169 | echo "not operational ... work to be done here ";exit |
---|
170 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
171 | optim="$optim -Dadj" ; shift ;; |
---|
172 | |
---|
173 | "-cosp") |
---|
174 | cosp="$2" ; shift ; shift ;; |
---|
175 | |
---|
176 | "-sisvat") |
---|
177 | sisvat="$2" ; shift ; shift ;; |
---|
178 | |
---|
179 | "-mem") |
---|
180 | paramem="mem" ; shift ;; |
---|
181 | |
---|
182 | "-filtre") |
---|
183 | filtre=$2 ; shift ; shift ;; |
---|
184 | |
---|
185 | "-link") |
---|
186 | LIB="$LIB $2" ; shift ; shift ;; |
---|
187 | |
---|
188 | "-fcm_path") |
---|
189 | fcm_path=$2 ; shift ; shift ;; |
---|
190 | |
---|
191 | "-ext_src") |
---|
192 | EXT_SRC=$2 ; shift ; shift ;; |
---|
193 | |
---|
194 | "-arch") |
---|
195 | arch=$2 ; shift ; shift ;; |
---|
196 | |
---|
197 | *) |
---|
198 | code="$1" ; shift ;; |
---|
199 | esac |
---|
200 | done |
---|
201 | |
---|
202 | ############################################################### |
---|
203 | # lecture des chemins propres à l'architecture de la machine # |
---|
204 | ############################################################### |
---|
205 | rm -f .void_file |
---|
206 | echo > .void_file |
---|
207 | rm -rf .void_dir |
---|
208 | mkdir .void_dir |
---|
209 | rm -f arch.path |
---|
210 | if [[ -r arch/arch-${arch}.path ]] |
---|
211 | then |
---|
212 | ln -s arch/arch-${arch}.path ./arch.path |
---|
213 | source arch.path |
---|
214 | else |
---|
215 | echo "Error: missing arch/arch-${arch}.path file !" |
---|
216 | exit |
---|
217 | fi |
---|
218 | rm -f arch.fcm |
---|
219 | if [[ -r arch/arch-${arch}.fcm ]] |
---|
220 | then |
---|
221 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
222 | else |
---|
223 | echo "Error: missing arch/arch-${arch}.fcm file !" |
---|
224 | exit |
---|
225 | fi |
---|
226 | ######################################################################## |
---|
227 | # Definition des clefs CPP, des chemins des includes et modules |
---|
228 | # et des libraries |
---|
229 | ######################################################################## |
---|
230 | |
---|
231 | # basic compile flags from arch.fcm file |
---|
232 | archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm ) |
---|
233 | COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} ) |
---|
234 | |
---|
235 | # other compile flags, depending on compilation mode |
---|
236 | if [[ "$compil_mod" == "prod" ]] |
---|
237 | then |
---|
238 | ## read COMPIL_FFLAGS from arch.fcm file |
---|
239 | archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm ) |
---|
240 | archfileopt=$( echo ${archfileline##%PROD_FFLAGS} ) |
---|
241 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
242 | elif [[ "$compil_mod" == "dev" ]] |
---|
243 | then |
---|
244 | ## read %DEV_FFLAGS from arch.fcm file |
---|
245 | archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm ) |
---|
246 | archfileopt=$( echo ${archfileline##%DEV_FFLAGS} ) |
---|
247 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
248 | elif [[ "$compil_mod" == "debug" ]] |
---|
249 | then |
---|
250 | ## read %DEBUG_FFLAGS from arch.fcm file |
---|
251 | archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm ) |
---|
252 | archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} ) |
---|
253 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
254 | fi |
---|
255 | |
---|
256 | # add CPP_KEY defined in arch.fcm file |
---|
257 | archfileline=$( grep -i '^%FPP_DEF' arch.fcm ) |
---|
258 | archfileopt=$( echo ${archfileline##%FPP_DEF} ) |
---|
259 | CPP_KEY="$CPP_KEY ${archfileopt}" |
---|
260 | |
---|
261 | # get compiler name from arch.fcm file |
---|
262 | archfileline=$( grep -i '^%COMPILER' arch.fcm ) |
---|
263 | fcompiler=$( echo ${archfileline##%COMPILER} ) |
---|
264 | |
---|
265 | # get linker name from arch.fcm file |
---|
266 | archfileline=$( grep -i '^%LINK' arch.fcm ) |
---|
267 | linker=$( echo ${archfileline##%LINK} ) |
---|
268 | |
---|
269 | # get ar command from arch.fcm file |
---|
270 | archfileline=$( grep -i '^%AR' arch.fcm ) |
---|
271 | arcommand=$( echo ${archfileline##%AR} ) |
---|
272 | |
---|
273 | # get make utility from arch.fcm file |
---|
274 | archfileline=$( grep -i '^%MAKE' arch.fcm ) |
---|
275 | makecommand=$( echo ${archfileline##%MAKE} ) |
---|
276 | |
---|
277 | # get basic libraries to link with arch.fcm file |
---|
278 | archfileline=$( grep -i '^%BASE_LD' arch.fcm ) |
---|
279 | archfileopt=$( echo ${archfileline##%BASE_LD} ) |
---|
280 | LIB="$LIB ${archfileopt}" |
---|
281 | |
---|
282 | # add Include files defined in arch.fcm file for pre-processing |
---|
283 | archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm ) |
---|
284 | for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done |
---|
285 | |
---|
286 | if [[ "$physique" != "nophys" ]] |
---|
287 | then |
---|
288 | #We'll use some physics |
---|
289 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
290 | if [[ "${physique:0:3}" == "lmd" ]] |
---|
291 | then |
---|
292 | #For lmd physics, default planet type is Earth |
---|
293 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
294 | fi |
---|
295 | fi |
---|
296 | |
---|
297 | if [[ "$chimie" == "INCA" ]] |
---|
298 | then |
---|
299 | CPP_KEY="$CPP_KEY INCA" |
---|
300 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
301 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
302 | libchimie=" -L${INCA_LIBDIR} -lchimie" |
---|
303 | fi |
---|
304 | |
---|
305 | if [[ "$couple" != "false" ]] |
---|
306 | then |
---|
307 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
308 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
309 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
310 | fi |
---|
311 | |
---|
312 | if [[ "$parallel" == "none" ]] |
---|
313 | then |
---|
314 | FLAG_PARA='' |
---|
315 | else |
---|
316 | FLAG_PARA="$paramem" |
---|
317 | fi |
---|
318 | |
---|
319 | if [[ "$parallel" == "mpi" ]] |
---|
320 | then |
---|
321 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
322 | # MPI additional compilation options |
---|
323 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
324 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
325 | # MPI additional links |
---|
326 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
327 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
328 | elif [[ "$parallel" == "omp" ]] |
---|
329 | then |
---|
330 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
331 | # OMP additional compilation options |
---|
332 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
333 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
334 | # OMP additional links |
---|
335 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
336 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
337 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
338 | then |
---|
339 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
340 | # MPI additional compilation options |
---|
341 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
342 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
343 | # OMP additional compilation options |
---|
344 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
345 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
346 | # MPI additional links |
---|
347 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
348 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
349 | # OMP additional links |
---|
350 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
351 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
352 | fi |
---|
353 | |
---|
354 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
355 | && "$compil_mod" == "debug" ]] |
---|
356 | then |
---|
357 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
358 | echo "We suggest switching to \"-dev\"." |
---|
359 | fi |
---|
360 | |
---|
361 | |
---|
362 | #============================================================================== |
---|
363 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
364 | then |
---|
365 | |
---|
366 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
367 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
368 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
369 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
370 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
371 | fi |
---|
372 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
373 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
374 | else |
---|
375 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
376 | fi |
---|
377 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
378 | for lib in ${orch_libs} ; do |
---|
379 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
380 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
381 | fi |
---|
382 | done |
---|
383 | elif [[ "$veget" != "false" ]] ; then |
---|
384 | echo "Option -v $veget does not exist" |
---|
385 | echo "Use ./makelmdz -h for more information" |
---|
386 | exit |
---|
387 | fi |
---|
388 | |
---|
389 | #=============================================================================== |
---|
390 | if [[ $io == ioipsl ]] |
---|
391 | then |
---|
392 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
393 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
394 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
395 | fi |
---|
396 | |
---|
397 | if [[ "$cosp" == "true" ]] |
---|
398 | then |
---|
399 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
400 | COSP_PATH="$LIBFGCM/cosp" |
---|
401 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
402 | opt_dep="$opt_dep cosp" |
---|
403 | lcosp="-l${LIBPREFIX}cosp" |
---|
404 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
405 | fi |
---|
406 | |
---|
407 | if [[ "$sisvat" == "true" ]] |
---|
408 | then |
---|
409 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
410 | fi |
---|
411 | |
---|
412 | |
---|
413 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
414 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
415 | |
---|
416 | ######################################################################## |
---|
417 | # calcul du nombre de dimensions |
---|
418 | ######################################################################## |
---|
419 | |
---|
420 | |
---|
421 | dim_full=$dim |
---|
422 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
423 | set $dim |
---|
424 | dimc=$# |
---|
425 | echo calcul de la dimension |
---|
426 | echo dim $dim |
---|
427 | echo dimc $dimc |
---|
428 | |
---|
429 | |
---|
430 | ######################################################################## |
---|
431 | # Gestion des dimensions du modele. |
---|
432 | # on cree ou remplace le fichier des dimensions |
---|
433 | ######################################################################## |
---|
434 | |
---|
435 | cd $LIBFGCM/grid |
---|
436 | if [[ -f dimensions.h ]] |
---|
437 | then |
---|
438 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
439 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
440 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
441 | echo vous pouvez continuer en repondant oui. |
---|
442 | echo "Voulez-vous vraiment continuer?" |
---|
443 | echo "" |
---|
444 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
445 | echo "Wait until the first compilation is finished before launching this one." |
---|
446 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
447 | echo "yes (or 'oui') to the question below to proceed." |
---|
448 | echo "Do you wish to continue?" |
---|
449 | read reponse |
---|
450 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
451 | then |
---|
452 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
453 | else |
---|
454 | exit |
---|
455 | fi |
---|
456 | fi |
---|
457 | |
---|
458 | |
---|
459 | cd $LIBFGCM/grid/dimension |
---|
460 | ./makdim $dim |
---|
461 | cat $LIBFGCM/grid/dimensions.h |
---|
462 | cd $LMDGCM |
---|
463 | |
---|
464 | |
---|
465 | ######################################################################## |
---|
466 | # Differentes dynamiques (3d, 2d, 1d) |
---|
467 | ######################################################################## |
---|
468 | |
---|
469 | if (( $dimc == 3 )) ; then |
---|
470 | cd $LIBFGCM/grid |
---|
471 | \rm fxyprim.h |
---|
472 | cp -p fxy_${grille}.h fxyprim.h |
---|
473 | filtre="FILTRE=$filtre" |
---|
474 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} ' |
---|
475 | elif (( $dimc == 2 )) ; then |
---|
476 | filtre="FILTRE= L_FILTRE= " |
---|
477 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
478 | elif (( $dimc == 1 )) ; then |
---|
479 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique " |
---|
480 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d' # Pas tres propre |
---|
481 | else |
---|
482 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
483 | fi |
---|
484 | |
---|
485 | ###################################################################### |
---|
486 | # Creation du suffixe de la configuration |
---|
487 | ###################################################################### |
---|
488 | |
---|
489 | SUFF_NAME=_${dim_full} |
---|
490 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
491 | |
---|
492 | if [[ "$parallel" != "none" ]] |
---|
493 | then |
---|
494 | SUFF_NAME=${SUFF_NAME}_para |
---|
495 | DYN=dyn${dimc}d${paramem} |
---|
496 | if [[ "$paramem" == "mem" ]] |
---|
497 | then |
---|
498 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
499 | fi |
---|
500 | else |
---|
501 | SUFF_NAME=${SUFF_NAME}_seq |
---|
502 | DYN=dyn${dimc}d |
---|
503 | fi |
---|
504 | |
---|
505 | if [[ $veget != "false" ]] |
---|
506 | then |
---|
507 | SUFF_NAME=${SUFF_NAME}_orch |
---|
508 | fi |
---|
509 | |
---|
510 | if [[ $couple != "false" ]] |
---|
511 | then |
---|
512 | SUFF_NAME=${SUFF_NAME}_couple |
---|
513 | fi |
---|
514 | |
---|
515 | if [[ $chimie == "INCA" ]] |
---|
516 | then |
---|
517 | SUFF_NAME=${SUFF_NAME}_inca |
---|
518 | fi |
---|
519 | |
---|
520 | cd $LMDGCM |
---|
521 | |
---|
522 | |
---|
523 | ######################################################################## |
---|
524 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
525 | ######################################################################## |
---|
526 | ######################################################################## |
---|
527 | # c'est a dire dans 3 cas: |
---|
528 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
529 | # derniere creation du makefile |
---|
530 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
531 | # n'existe pas. |
---|
532 | # 3. Si le makefile n'existe pas. |
---|
533 | ######################################################################## |
---|
534 | cd $LMDGCM |
---|
535 | |
---|
536 | find libf -name '*.[Fh]' -print > tmp77 |
---|
537 | find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90 |
---|
538 | find libf -name '*.[Fh90]' -print >> tmp90 |
---|
539 | |
---|
540 | if [[ ! ( -r makefile ) || ! ( -r liste_des_sources_f90 ) || ! ( -r liste_des_sources_f77 ) || ` diff tmp77 liste_des_sources_f77 | wc -w ` -ne 0 || ` diff tmp90 liste_des_sources_f90 | wc -w ` -ne 0 ]] |
---|
541 | then |
---|
542 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
543 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
544 | diff liste_des_sources_f77 tmp77 |
---|
545 | diff liste_des_sources_f90 tmp90 |
---|
546 | \cp -f tmp77 liste_des_sources_f77 |
---|
547 | \cp -f tmp90 liste_des_sources_f90 |
---|
548 | echo "on recree le makefile" |
---|
549 | ./create_make_gcm > tmp |
---|
550 | \mv -f tmp makefile |
---|
551 | echo "Nouveau makefile cree" |
---|
552 | fi |
---|
553 | |
---|
554 | ################################################################# |
---|
555 | # Preparation de l'execution de la comande make |
---|
556 | ################################################################# |
---|
557 | |
---|
558 | source_code=${code}.F |
---|
559 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
560 | then |
---|
561 | source_code=${code}.F90 |
---|
562 | fi |
---|
563 | |
---|
564 | # library directory name: |
---|
565 | nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'` |
---|
566 | echo $nomlib |
---|
567 | |
---|
568 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
569 | then |
---|
570 | mkdir ${LIBOGCM}/${nomlib} |
---|
571 | # check we indeed managed to create the directory |
---|
572 | if [[ ! $? ]] |
---|
573 | then |
---|
574 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
575 | exit |
---|
576 | fi |
---|
577 | fi |
---|
578 | |
---|
579 | # where module files are created |
---|
580 | mod_loc_dir=$localdir |
---|
581 | |
---|
582 | if [[ "$physique" != "nophys" ]] |
---|
583 | then |
---|
584 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
585 | fi |
---|
586 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
587 | |
---|
588 | # ranlib utility (check it exists or else default to ls) |
---|
589 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
590 | then |
---|
591 | ranlib="ranlib" |
---|
592 | else |
---|
593 | ranlib="ls" |
---|
594 | fi |
---|
595 | |
---|
596 | # add CPP keys to COMPIL_FLAGS |
---|
597 | # (but first add -D before all CPP_KEY items) |
---|
598 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
599 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
600 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
601 | then |
---|
602 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
603 | fi |
---|
604 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
605 | |
---|
606 | ################################################################# |
---|
607 | # Execution du make |
---|
608 | ################################################################# |
---|
609 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
610 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
611 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
612 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
613 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
614 | INCLUDE="$INCLUDE" \ |
---|
615 | $filtre \ |
---|
616 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
617 | "PHYS=$physique" \ |
---|
618 | DIM=$dimc \ |
---|
619 | FLAG_PARA=$FLAG_PARA \ |
---|
620 | L_ADJNT=$adjnt \ |
---|
621 | L_COSP="$lcosp" \ |
---|
622 | L_CHIMIE="$libchimie" \ |
---|
623 | LOCAL_DIR="$localdir" \ |
---|
624 | F77="$fcompiler" \ |
---|
625 | F90="$fcompiler" \ |
---|
626 | OPLINK="$LIB" \ |
---|
627 | LINK="$linker" \ |
---|
628 | GCM="$LMDGCM" \ |
---|
629 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
630 | MOD_SUFFIX="mod" \ |
---|
631 | AR=$arcommand \ |
---|
632 | SOURCE=$source_code \ |
---|
633 | PROG=$code |
---|
634 | |
---|
635 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
636 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
637 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
638 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
639 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
640 | INCLUDE="$INCLUDE" \ |
---|
641 | $filtre \ |
---|
642 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
643 | "PHYS=$physique" \ |
---|
644 | DIM=$dimc \ |
---|
645 | FLAG_PARA=$FLAG_PARA \ |
---|
646 | L_ADJNT=$adjnt \ |
---|
647 | L_COSP="$lcosp" \ |
---|
648 | L_CHIMIE="$libchimie" \ |
---|
649 | LOCAL_DIR="$localdir" \ |
---|
650 | F77="$fcompiler" \ |
---|
651 | F90="$fcompiler" \ |
---|
652 | OPLINK="$LIB" \ |
---|
653 | LINK="$linker" \ |
---|
654 | GCM="$LMDGCM" \ |
---|
655 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
656 | MOD_SUFFIX="mod" \ |
---|
657 | AR=$arcommand \ |
---|
658 | SOURCE=$source_code \ |
---|
659 | PROG=$code |
---|
660 | |
---|
661 | |
---|
662 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
663 | then |
---|
664 | # Cleanup: remove dimension.h file |
---|
665 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
666 | fi |
---|