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 | manuel complet sur http://... |
---|
101 | Usage : |
---|
102 | makegcm [options] exec |
---|
103 | [-h] : manuel abrege |
---|
104 | [-d [[IMx]JMx]LM] : IM, JM, LM sont les dims en x, y, z (def: $dim) |
---|
105 | [-p PHYS] : compilation avec la physique libf/phyPHYS, (def: lmd) |
---|
106 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
---|
107 | [-c false/MPI1/MPI2] : couple ocean : MPI1/MPI2/false (def: false) |
---|
108 | [-v false/true] : avec ou sans vegetation (def: false) |
---|
109 | [-chimie INCA/false] : avec ou sans model de chimie INCA (def: false) |
---|
110 | [-parallel none/mpi/omp/mpi_omp] : parallelisation (default: none) : mpi, openmp ou mixte mpi_openmp |
---|
111 | [-g GRI] : conf. grille dans dyn3d/GRI_xy.h (def: reg inclue un zoom) |
---|
112 | [-io IO] : choix d une librairie I/O, experts (def: ioipsl) |
---|
113 | [-include INCLUDES] : variables supplementaires pour include |
---|
114 | [-cpp CPP_KEY] : cle cpp supplementaires |
---|
115 | [-adjnt] : adjoint, a remettre en route ... |
---|
116 | [-mem] : version memoire reduite (si en mode parallele) |
---|
117 | [-filtre NOMFILTRE] : prend le filtre dans libf/NOMFILTRE (def: filtrez) |
---|
118 | [-link LINKS] : liens optionels avec d autres librairies |
---|
119 | [-ext_src path] : chemin d un repertoire source avec des sources externe a compiler avec le modele |
---|
120 | [-arch nom_arch] : nom de l architecture cible |
---|
121 | exec : executable genere |
---|
122 | fin |
---|
123 | exit;; |
---|
124 | "-d") |
---|
125 | dim=$2 ; shift ; shift ;; |
---|
126 | |
---|
127 | "-O") |
---|
128 | echo "option obsolete dans ce makegcm" |
---|
129 | exit;; |
---|
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 "option a reactiver ";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" == "true" ]] |
---|
354 | then |
---|
355 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
356 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
357 | LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob" |
---|
358 | fi |
---|
359 | |
---|
360 | if [[ $io == ioipsl ]] |
---|
361 | then |
---|
362 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
363 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
364 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
365 | fi |
---|
366 | |
---|
367 | if [[ "$cosp" == "true" ]] |
---|
368 | then |
---|
369 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
370 | COSP_PATH="$LIBFGCM/cosp" |
---|
371 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
372 | opt_dep="$opt_dep cosp" |
---|
373 | lcosp="-l${LIBPREFIX}cosp" |
---|
374 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
375 | fi |
---|
376 | |
---|
377 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
378 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
379 | |
---|
380 | ######################################################################## |
---|
381 | # calcul du nombre de dimensions |
---|
382 | ######################################################################## |
---|
383 | |
---|
384 | |
---|
385 | dim_full=$dim |
---|
386 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
387 | set $dim |
---|
388 | dimc=$# |
---|
389 | echo calcul de la dimension |
---|
390 | echo dim $dim |
---|
391 | echo dimc $dimc |
---|
392 | |
---|
393 | |
---|
394 | ######################################################################## |
---|
395 | # Gestion des dimensions du modele. |
---|
396 | # on cree ou remplace le fichier des dimensions |
---|
397 | ######################################################################## |
---|
398 | |
---|
399 | cd $LIBFGCM/grid |
---|
400 | if [[ -f dimensions.h ]] |
---|
401 | then |
---|
402 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
403 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
404 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
405 | echo vous pouvez continuer en repondant oui. |
---|
406 | echo "Voulez-vous vraiment continuer?" |
---|
407 | read reponse |
---|
408 | if [[ $reponse == "oui" ]] |
---|
409 | then |
---|
410 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
411 | else |
---|
412 | exit |
---|
413 | fi |
---|
414 | fi |
---|
415 | |
---|
416 | |
---|
417 | cd $LIBFGCM/grid/dimension |
---|
418 | ./makdim $dim |
---|
419 | cat $LIBFGCM/grid/dimensions.h |
---|
420 | cd $LMDGCM |
---|
421 | |
---|
422 | |
---|
423 | ######################################################################## |
---|
424 | # Differentes dynamiques (3d, 2d, 1d) |
---|
425 | ######################################################################## |
---|
426 | |
---|
427 | dimension=`echo $dim | wc -w` |
---|
428 | echo dimension $dimension |
---|
429 | |
---|
430 | if (( $dimension == 3 )) |
---|
431 | then |
---|
432 | cd $LIBFGCM/grid |
---|
433 | \rm fxyprim.h |
---|
434 | cp -p fxy_${grille}.h fxyprim.h |
---|
435 | else |
---|
436 | echo "Probleme dans les dimensions de la dynamique !!" |
---|
437 | echo "Non reactive pour l'instant !!!" |
---|
438 | fi |
---|
439 | |
---|
440 | ###################################################################### |
---|
441 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
442 | ###################################################################### |
---|
443 | |
---|
444 | if (( `expr $dimc \> 2` == 1 )) |
---|
445 | then |
---|
446 | filtre="FILTRE=$filtre" |
---|
447 | else |
---|
448 | filtre="FILTRE= L_FILTRE= " |
---|
449 | fi |
---|
450 | echo MACRO FILTRE $filtre |
---|
451 | |
---|
452 | echo $dimc |
---|
453 | |
---|
454 | ###################################################################### |
---|
455 | # Creation du suffixe de la configuration |
---|
456 | ###################################################################### |
---|
457 | |
---|
458 | |
---|
459 | SUFF_NAME=_${dim_full} |
---|
460 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
461 | |
---|
462 | if [[ "$parallel" != "none" ]] |
---|
463 | then |
---|
464 | SUFF_NAME=${SUFF_NAME}_para |
---|
465 | DYN=dyn${dimc}d${paramem} |
---|
466 | if [[ "$paramem" == "mem" ]] |
---|
467 | then |
---|
468 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
469 | fi |
---|
470 | else |
---|
471 | SUFF_NAME=${SUFF_NAME}_seq |
---|
472 | DYN=dyn${dimc}d |
---|
473 | fi |
---|
474 | |
---|
475 | if [[ $veget == "true" ]] |
---|
476 | then |
---|
477 | SUFF_NAME=${SUFF_NAME}_orch |
---|
478 | fi |
---|
479 | |
---|
480 | if [[ $couple != "false" ]] |
---|
481 | then |
---|
482 | SUFF_NAME=${SUFF_NAME}_couple |
---|
483 | fi |
---|
484 | |
---|
485 | if [[ $chimie == "INCA" ]] |
---|
486 | then |
---|
487 | SUFF_NAME=${SUFF_NAME}_inca |
---|
488 | fi |
---|
489 | |
---|
490 | cd $LMDGCM |
---|
491 | |
---|
492 | |
---|
493 | ######################################################################## |
---|
494 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
495 | ######################################################################## |
---|
496 | ######################################################################## |
---|
497 | # c'est a dire dans 3 cas: |
---|
498 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
499 | # derniere creation du makefile |
---|
500 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
501 | # n'existe pas. |
---|
502 | # 3. Si le makefile n'existe pas. |
---|
503 | ######################################################################## |
---|
504 | cd $LMDGCM |
---|
505 | find libf -name '*.[Fh]' -print > tmp77 |
---|
506 | find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90 |
---|
507 | find libf -name '*.[Fh90]' -print >> tmp90 |
---|
508 | |
---|
509 | 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 ]] |
---|
510 | then |
---|
511 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
512 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
513 | diff liste_des_sources_f77 tmp77 |
---|
514 | diff liste_des_sources_f90 tmp90 |
---|
515 | \cp -f tmp77 liste_des_sources_f77 |
---|
516 | \cp -f tmp90 liste_des_sources_f90 |
---|
517 | echo "on recree le makefile" |
---|
518 | ./create_make_gcm > tmp |
---|
519 | \mv -f tmp makefile |
---|
520 | echo "Nouveau makefile cree" |
---|
521 | fi |
---|
522 | |
---|
523 | ################################################################# |
---|
524 | # Preparation de l'execution de la comande make |
---|
525 | ################################################################# |
---|
526 | |
---|
527 | source_code=${code}.F |
---|
528 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
529 | then |
---|
530 | source_code=${code}.F90 |
---|
531 | fi |
---|
532 | |
---|
533 | # library directory name: |
---|
534 | if [[ "$parallel" == "none" ]] |
---|
535 | then |
---|
536 | nomlib=${arch}_${physique}_${dim_full}_${grille}_${compil_mod} |
---|
537 | else |
---|
538 | nomlib=${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_${FLAG_PARA} |
---|
539 | fi |
---|
540 | |
---|
541 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
542 | then |
---|
543 | mkdir ${LIBOGCM}/${nomlib} |
---|
544 | # check we indeed managed to create the directory |
---|
545 | if [[ ! $? ]] |
---|
546 | then |
---|
547 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
548 | exit |
---|
549 | fi |
---|
550 | fi |
---|
551 | |
---|
552 | # where module files are created |
---|
553 | mod_loc_dir=$localdir |
---|
554 | |
---|
555 | if [[ "$physique" != "nophys" ]] |
---|
556 | then |
---|
557 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
558 | fi |
---|
559 | INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib} |
---|
560 | |
---|
561 | # ranlib utility (check it exists or else default to ls) |
---|
562 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
563 | then |
---|
564 | ranlib="ranlib" |
---|
565 | else |
---|
566 | ranlib="ls" |
---|
567 | fi |
---|
568 | |
---|
569 | # add CPP keys to COMPIL_FLAGS |
---|
570 | # (but first add -D before all CPP_KEY items) |
---|
571 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
572 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
573 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
574 | then |
---|
575 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
576 | fi |
---|
577 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
578 | |
---|
579 | ################################################################# |
---|
580 | # Execution du make |
---|
581 | ################################################################# |
---|
582 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
583 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
584 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
585 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
586 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
587 | INCLUDE="$INCLUDE" \ |
---|
588 | $filtre \ |
---|
589 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
590 | "PHYS=$physique" \ |
---|
591 | DIM=$dimc \ |
---|
592 | FLAG_PARA=$FLAG_PARA \ |
---|
593 | L_ADJNT=$adjnt \ |
---|
594 | L_COSP="$lcosp" \ |
---|
595 | L_CHIMIE="$libchimie" \ |
---|
596 | LOCAL_DIR="$localdir" \ |
---|
597 | F77="$fcompiler" \ |
---|
598 | F90="$fcompiler" \ |
---|
599 | OPLINK="$LIB" \ |
---|
600 | LINK="$linker" \ |
---|
601 | GCM="$LMDGCM" \ |
---|
602 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
603 | MOD_SUFFIX="mod" \ |
---|
604 | AR=$arcommand \ |
---|
605 | SOURCE=$source_code \ |
---|
606 | PROG=$code |
---|
607 | |
---|
608 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
609 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
610 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
611 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
612 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
613 | INCLUDE="$INCLUDE" \ |
---|
614 | $filtre \ |
---|
615 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
616 | "PHYS=$physique" \ |
---|
617 | DIM=$dimc \ |
---|
618 | FLAG_PARA=$FLAG_PARA \ |
---|
619 | L_ADJNT="$adjnt" \ |
---|
620 | L_COSP="$lcosp" \ |
---|
621 | L_CHIMIE="$libchimie" \ |
---|
622 | LOCAL_DIR="$localdir" \ |
---|
623 | F77="$fcompiler" \ |
---|
624 | F90="$fcompiler" \ |
---|
625 | OPLINK="$LIB" \ |
---|
626 | LINK="$linker" \ |
---|
627 | GCM="$LMDGCM" \ |
---|
628 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
629 | MOD_SUFFIX="mod" \ |
---|
630 | AR=$arcommand \ |
---|
631 | SOURCE=$source_code \ |
---|
632 | PROG=$code |
---|
633 | |
---|
634 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
635 | then |
---|
636 | # Cleanup: remove dimension.h file |
---|
637 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
638 | fi |
---|