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:3}" == "ada" ]] |
---|
38 | then |
---|
39 | arch="X64_ADA" |
---|
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 | elif [[ $io == xios ]] |
---|
396 | then |
---|
397 | # For now, xios implies also using ioipsl |
---|
398 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
399 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
400 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
401 | fi |
---|
402 | |
---|
403 | if [[ "$cosp" == "true" ]] |
---|
404 | then |
---|
405 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
406 | COSP_PATH="$LIBFGCM/cosp" |
---|
407 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
408 | opt_dep="$opt_dep cosp" |
---|
409 | lcosp="-l${LIBPREFIX}cosp" |
---|
410 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
411 | fi |
---|
412 | |
---|
413 | if [[ "$sisvat" == "true" ]] |
---|
414 | then |
---|
415 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
416 | fi |
---|
417 | |
---|
418 | |
---|
419 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
420 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
421 | |
---|
422 | ######################################################################## |
---|
423 | # calcul du nombre de dimensions |
---|
424 | ######################################################################## |
---|
425 | |
---|
426 | |
---|
427 | dim_full=$dim |
---|
428 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
429 | set $dim |
---|
430 | dimc=$# |
---|
431 | echo calcul de la dimension |
---|
432 | echo dim $dim |
---|
433 | echo dimc $dimc |
---|
434 | |
---|
435 | |
---|
436 | ######################################################################## |
---|
437 | # Gestion des dimensions du modele. |
---|
438 | # on cree ou remplace le fichier des dimensions |
---|
439 | ######################################################################## |
---|
440 | |
---|
441 | cd $LIBFGCM/grid |
---|
442 | if [[ -f dimensions.h ]] |
---|
443 | then |
---|
444 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
445 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
446 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
447 | echo vous pouvez continuer en repondant oui. |
---|
448 | echo "Voulez-vous vraiment continuer?" |
---|
449 | echo "" |
---|
450 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
451 | echo "Wait until the first compilation is finished before launching this one." |
---|
452 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
453 | echo "yes (or 'oui') to the question below to proceed." |
---|
454 | echo "Do you wish to continue?" |
---|
455 | read reponse |
---|
456 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
457 | then |
---|
458 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
459 | else |
---|
460 | exit |
---|
461 | fi |
---|
462 | fi |
---|
463 | |
---|
464 | |
---|
465 | cd $LIBFGCM/grid/dimension |
---|
466 | ./makdim $dim |
---|
467 | cat $LIBFGCM/grid/dimensions.h |
---|
468 | cd $LMDGCM |
---|
469 | |
---|
470 | |
---|
471 | ######################################################################## |
---|
472 | # Differentes dynamiques (3d, 2d, 1d) |
---|
473 | ######################################################################## |
---|
474 | |
---|
475 | if (( $dimc == 3 )) ; then |
---|
476 | cd $LIBFGCM/grid |
---|
477 | \rm fxyprim.h |
---|
478 | cp -p fxy_${grille}.h fxyprim.h |
---|
479 | filtre="FILTRE=$filtre" |
---|
480 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} ' |
---|
481 | elif (( $dimc == 2 )) ; then |
---|
482 | filtre="FILTRE= L_FILTRE= " |
---|
483 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
484 | elif (( $dimc == 1 )) ; then |
---|
485 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique " |
---|
486 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d' # Pas tres propre |
---|
487 | else |
---|
488 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
489 | fi |
---|
490 | |
---|
491 | ###################################################################### |
---|
492 | # Creation du suffixe de la configuration |
---|
493 | ###################################################################### |
---|
494 | |
---|
495 | SUFF_NAME=_${dim_full} |
---|
496 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
497 | |
---|
498 | if [[ "$parallel" != "none" ]] |
---|
499 | then |
---|
500 | SUFF_NAME=${SUFF_NAME}_para |
---|
501 | DYN=dyn${dimc}d${paramem} |
---|
502 | if [[ "$paramem" == "mem" ]] |
---|
503 | then |
---|
504 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
505 | fi |
---|
506 | else |
---|
507 | SUFF_NAME=${SUFF_NAME}_seq |
---|
508 | DYN=dyn${dimc}d |
---|
509 | fi |
---|
510 | |
---|
511 | if [[ $veget != "false" ]] |
---|
512 | then |
---|
513 | SUFF_NAME=${SUFF_NAME}_orch |
---|
514 | fi |
---|
515 | |
---|
516 | if [[ $couple != "false" ]] |
---|
517 | then |
---|
518 | SUFF_NAME=${SUFF_NAME}_couple |
---|
519 | fi |
---|
520 | |
---|
521 | if [[ $chimie == "INCA" ]] |
---|
522 | then |
---|
523 | SUFF_NAME=${SUFF_NAME}_inca |
---|
524 | fi |
---|
525 | |
---|
526 | cd $LMDGCM |
---|
527 | |
---|
528 | |
---|
529 | ######################################################################## |
---|
530 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
531 | ######################################################################## |
---|
532 | ######################################################################## |
---|
533 | # c'est a dire dans 3 cas: |
---|
534 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
535 | # derniere creation du makefile |
---|
536 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
537 | # n'existe pas. |
---|
538 | # 3. Si le makefile n'existe pas. |
---|
539 | ######################################################################## |
---|
540 | cd $LMDGCM |
---|
541 | |
---|
542 | find libf -name '*.[Fh]' -print > tmp77 |
---|
543 | find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90 |
---|
544 | find libf -name '*.[Fh90]' -print >> tmp90 |
---|
545 | |
---|
546 | 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 ]] |
---|
547 | then |
---|
548 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
549 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
550 | diff liste_des_sources_f77 tmp77 |
---|
551 | diff liste_des_sources_f90 tmp90 |
---|
552 | \cp -f tmp77 liste_des_sources_f77 |
---|
553 | \cp -f tmp90 liste_des_sources_f90 |
---|
554 | echo "on recree le makefile" |
---|
555 | ./create_make_gcm > tmp |
---|
556 | \mv -f tmp makefile |
---|
557 | echo "Nouveau makefile cree" |
---|
558 | fi |
---|
559 | |
---|
560 | ################################################################# |
---|
561 | # Preparation de l'execution de la comande make |
---|
562 | ################################################################# |
---|
563 | |
---|
564 | source_code=${code}.F |
---|
565 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
566 | then |
---|
567 | source_code=${code}.F90 |
---|
568 | fi |
---|
569 | |
---|
570 | # library directory name: |
---|
571 | 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'` |
---|
572 | echo $nomlib |
---|
573 | |
---|
574 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
575 | then |
---|
576 | mkdir ${LIBOGCM}/${nomlib} |
---|
577 | # check we indeed managed to create the directory |
---|
578 | if [[ ! $? ]] |
---|
579 | then |
---|
580 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
581 | exit |
---|
582 | fi |
---|
583 | fi |
---|
584 | |
---|
585 | # where module files are created |
---|
586 | mod_loc_dir=$localdir |
---|
587 | |
---|
588 | if [[ "$physique" != "nophys" ]] |
---|
589 | then |
---|
590 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
591 | fi |
---|
592 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
593 | |
---|
594 | # ranlib utility (check it exists or else default to ls) |
---|
595 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
596 | then |
---|
597 | ranlib="ranlib" |
---|
598 | else |
---|
599 | ranlib="ls" |
---|
600 | fi |
---|
601 | |
---|
602 | # add CPP keys to COMPIL_FLAGS |
---|
603 | # (but first add -D before all CPP_KEY items) |
---|
604 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
605 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
606 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
607 | then |
---|
608 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
609 | fi |
---|
610 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
611 | |
---|
612 | ################################################################# |
---|
613 | # Execution du make |
---|
614 | ################################################################# |
---|
615 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
616 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
617 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
618 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
619 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
620 | INCLUDE="$INCLUDE" \ |
---|
621 | $filtre \ |
---|
622 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
623 | "PHYS=$physique" \ |
---|
624 | DIM=$dimc \ |
---|
625 | FLAG_PARA=$FLAG_PARA \ |
---|
626 | L_ADJNT=$adjnt \ |
---|
627 | L_COSP="$lcosp" \ |
---|
628 | L_CHIMIE="$libchimie" \ |
---|
629 | LOCAL_DIR="$localdir" \ |
---|
630 | F77="$fcompiler" \ |
---|
631 | F90="$fcompiler" \ |
---|
632 | OPLINK="$LIB" \ |
---|
633 | LINK="$linker" \ |
---|
634 | GCM="$LMDGCM" \ |
---|
635 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
636 | MOD_SUFFIX="mod" \ |
---|
637 | AR=$arcommand \ |
---|
638 | SOURCE=$source_code \ |
---|
639 | PROG=$code |
---|
640 | |
---|
641 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
642 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
643 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
644 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
645 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
646 | INCLUDE="$INCLUDE" \ |
---|
647 | $filtre \ |
---|
648 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
649 | "PHYS=$physique" \ |
---|
650 | DIM=$dimc \ |
---|
651 | FLAG_PARA=$FLAG_PARA \ |
---|
652 | L_ADJNT=$adjnt \ |
---|
653 | L_COSP="$lcosp" \ |
---|
654 | L_CHIMIE="$libchimie" \ |
---|
655 | LOCAL_DIR="$localdir" \ |
---|
656 | F77="$fcompiler" \ |
---|
657 | F90="$fcompiler" \ |
---|
658 | OPLINK="$LIB" \ |
---|
659 | LINK="$linker" \ |
---|
660 | GCM="$LMDGCM" \ |
---|
661 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
662 | MOD_SUFFIX="mod" \ |
---|
663 | AR=$arcommand \ |
---|
664 | SOURCE=$source_code \ |
---|
665 | PROG=$code |
---|
666 | |
---|
667 | |
---|
668 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
669 | then |
---|
670 | # Cleanup: remove dimension.h file |
---|
671 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
672 | fi |
---|