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