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