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