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 | rrtm=false |
---|
29 | full="" |
---|
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:0:3}" == "ada" ]] |
---|
36 | then |
---|
37 | arch="X64_ADA" |
---|
38 | fi |
---|
39 | if [[ "${machine:0:7}" == "platine" ]] |
---|
40 | then |
---|
41 | arch="IA64_PLATINE" |
---|
42 | fi |
---|
43 | if [[ "${machine:0:6}" == "titane" ]] |
---|
44 | then |
---|
45 | arch="X64_TITANE" |
---|
46 | fi |
---|
47 | if [[ "${machine:0:8}" == "mercure1" ]] |
---|
48 | then |
---|
49 | arch="SX8_MERCURE" |
---|
50 | fi |
---|
51 | if [[ "${machine:0:8}" == "mercure2" ]] |
---|
52 | then |
---|
53 | arch="SX9_MERCURE" |
---|
54 | fi |
---|
55 | |
---|
56 | LMDGCM=`pwd -P` |
---|
57 | LIBFGCM=$LMDGCM/libf |
---|
58 | LIBOGCM=$LMDGCM/libo |
---|
59 | if [[ ! -d $LIBOGCM ]] |
---|
60 | then |
---|
61 | # create the directory |
---|
62 | mkdir $LIBOGCM |
---|
63 | if [[ ! $? ]] |
---|
64 | then |
---|
65 | echo "Failed to create directory $LIBOGCM" |
---|
66 | exit |
---|
67 | fi |
---|
68 | fi |
---|
69 | COSP_PATH=$LMDGCM/.void_dir |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | localdir=`pwd -P` |
---|
74 | ######################################################################## |
---|
75 | # Quelques initialisations de variables du shell. |
---|
76 | ######################################################################## |
---|
77 | |
---|
78 | CPP_KEY="" |
---|
79 | INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. ' |
---|
80 | LIB="" |
---|
81 | adjnt="" |
---|
82 | ##COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
83 | PARA_FFLAGS="" |
---|
84 | PARA_LD="" |
---|
85 | EXT_SRC="" |
---|
86 | #src_dirs: directories containing source files |
---|
87 | src_dirs="grid misc" |
---|
88 | ######################################################################## |
---|
89 | # lecture des options |
---|
90 | ######################################################################## |
---|
91 | |
---|
92 | while (($# > 0)) |
---|
93 | do |
---|
94 | case $1 in |
---|
95 | "-h") cat <<fin |
---|
96 | Usage : |
---|
97 | makelmdz [options] -arch nom_arch exec |
---|
98 | [-h] : brief help |
---|
99 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
100 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
101 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
102 | [-c false/MPI1/MPI2] : coupling with ocean model : MPI1/MPI2/false (default: false) |
---|
103 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
104 | false : no vegetation model |
---|
105 | orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version) |
---|
106 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
107 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
108 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
109 | [-cosp true/false] : compile with/without cosp package (default: false) |
---|
110 | [-sisvat true/false] : compile with/without sisvat package (default: false) |
---|
111 | [-rrtm true/false] : compile with/without rrtm package (default: false) |
---|
112 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
113 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
114 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
115 | [-include INCLUDES] : extra include path to add |
---|
116 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
117 | [-adjnt] : adjoint model, not operational ... |
---|
118 | [-mem] : reduced memory dynamics (if in parallel mode) |
---|
119 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
120 | [-full] : Full (re)compilation (from scratch) |
---|
121 | [-link LINKS] : additional links with other libraries |
---|
122 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
123 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
124 | -arch nom_arch : target architecture |
---|
125 | exec : executable to build |
---|
126 | fin |
---|
127 | exit;; |
---|
128 | "-d") |
---|
129 | dim=$2 ; shift ; shift ;; |
---|
130 | |
---|
131 | "-p") |
---|
132 | physique="$2" ; shift ; shift ;; |
---|
133 | |
---|
134 | "-g") |
---|
135 | grille="$2" ; shift ; shift ;; |
---|
136 | |
---|
137 | "-c") |
---|
138 | couple="$2" ; shift ; shift ;; |
---|
139 | |
---|
140 | "-prod") |
---|
141 | compil_mod="prod" ; shift ;; |
---|
142 | |
---|
143 | "-dev") |
---|
144 | compil_mod="dev" ; shift ;; |
---|
145 | |
---|
146 | "-debug") |
---|
147 | compil_mod="debug" ; shift ;; |
---|
148 | |
---|
149 | "-io") |
---|
150 | io="$2" ; shift ; shift ;; |
---|
151 | |
---|
152 | "-v") |
---|
153 | veget="$2" ; shift ; shift ;; |
---|
154 | |
---|
155 | "-chimie") |
---|
156 | chimie="$2" ; shift ; shift ;; |
---|
157 | |
---|
158 | "-parallel") |
---|
159 | parallel="$2" ; shift ; shift ;; |
---|
160 | |
---|
161 | "-include") |
---|
162 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
163 | |
---|
164 | "-cpp") |
---|
165 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
166 | |
---|
167 | "-cosp") |
---|
168 | cosp="$2" ; shift ; shift ;; |
---|
169 | |
---|
170 | "-sisvat") |
---|
171 | sisvat="$2" ; shift ; shift ;; |
---|
172 | |
---|
173 | "-rrtm") |
---|
174 | rrtm="$2" ; shift ; shift ;; |
---|
175 | |
---|
176 | "-mem") |
---|
177 | paramem="mem" ; shift ;; |
---|
178 | |
---|
179 | "-filtre") |
---|
180 | filtre=$2 ; shift ; shift ;; |
---|
181 | |
---|
182 | "-full") |
---|
183 | full="full" ; 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 ; src_dirs="$src_dirs $EXT_SRC" ; 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 \`a 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 | src_dirs="$src_dirs phy$physique" |
---|
290 | LIBPHY='$(LIBO)/libphy'"$physique"'.a' |
---|
291 | lib_phy='-lphy'"$physique" |
---|
292 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
293 | if [[ "${physique:0:3}" == "lmd" ]] |
---|
294 | then |
---|
295 | #For lmd physics, default planet type is Earth |
---|
296 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
297 | fi |
---|
298 | fi |
---|
299 | |
---|
300 | if [[ "$chimie" == "INCA" ]] |
---|
301 | then |
---|
302 | CPP_KEY="$CPP_KEY INCA" |
---|
303 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
304 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
305 | libchimie=" -L${INCA_LIBDIR} -lchimie" |
---|
306 | fi |
---|
307 | |
---|
308 | if [[ "$couple" != "false" ]] |
---|
309 | then |
---|
310 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
311 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
312 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
313 | fi |
---|
314 | |
---|
315 | if [[ "$parallel" == "none" ]] |
---|
316 | then |
---|
317 | FLAG_PARA='' |
---|
318 | else |
---|
319 | FLAG_PARA="$paramem" |
---|
320 | if [[ $paramem == par ]] |
---|
321 | then |
---|
322 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
323 | echo "You should use option \"-mem\"." |
---|
324 | exit 1 |
---|
325 | fi |
---|
326 | fi |
---|
327 | |
---|
328 | if [[ "$parallel" == "mpi" ]] |
---|
329 | then |
---|
330 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
331 | # MPI additional compilation options |
---|
332 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
333 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
334 | # MPI additional links |
---|
335 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
336 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
337 | elif [[ "$parallel" == "omp" ]] |
---|
338 | then |
---|
339 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
340 | # OMP additional compilation options |
---|
341 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
342 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
343 | # OMP additional links |
---|
344 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
345 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
346 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
347 | then |
---|
348 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
349 | # MPI additional compilation options |
---|
350 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
351 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
352 | # OMP additional compilation options |
---|
353 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
354 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
355 | # MPI additional links |
---|
356 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
357 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
358 | # OMP additional links |
---|
359 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
360 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
361 | fi |
---|
362 | |
---|
363 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
364 | && "$compil_mod" == "debug" ]] |
---|
365 | then |
---|
366 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
367 | echo "We suggest switching to \"-dev\"." |
---|
368 | fi |
---|
369 | |
---|
370 | |
---|
371 | #============================================================================== |
---|
372 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
373 | then |
---|
374 | |
---|
375 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
376 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
377 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
378 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
379 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
380 | fi |
---|
381 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
382 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
383 | else |
---|
384 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
385 | fi |
---|
386 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
387 | for lib in ${orch_libs} ; do |
---|
388 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
389 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
390 | fi |
---|
391 | done |
---|
392 | elif [[ "$veget" != "false" ]] ; then |
---|
393 | echo "Option -v $veget does not exist" |
---|
394 | echo "Use ./makelmdz -h for more information" |
---|
395 | exit |
---|
396 | fi |
---|
397 | |
---|
398 | #=============================================================================== |
---|
399 | if [[ $io == ioipsl ]] |
---|
400 | then |
---|
401 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
402 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
403 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
404 | elif [[ $io == mix ]] |
---|
405 | then |
---|
406 | # For now, xios implies also using ioipsl |
---|
407 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
408 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
409 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
410 | elif [[ $io == xios ]] |
---|
411 | then |
---|
412 | # For now, xios implies also using ioipsl |
---|
413 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
414 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
415 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
416 | fi |
---|
417 | |
---|
418 | if [[ "$cosp" == "true" ]] |
---|
419 | then |
---|
420 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
421 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
422 | src_dirs="$src_dirs cosp" |
---|
423 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
424 | opt_dep="$opt_dep cosp" |
---|
425 | lcosp="-l${LIBPREFIX}cosp" |
---|
426 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
427 | fi |
---|
428 | |
---|
429 | if [[ "$sisvat" == "true" ]] |
---|
430 | then |
---|
431 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
432 | src_dirs="$src_dirs phy${physique}/sisvat" |
---|
433 | fi |
---|
434 | |
---|
435 | if [[ "$rrtm" == "true" ]] |
---|
436 | then |
---|
437 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
438 | src_dirs="$src_dirs phy${physique}/rrtm" |
---|
439 | fi |
---|
440 | |
---|
441 | |
---|
442 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
443 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
444 | |
---|
445 | ######################################################################## |
---|
446 | # calcul du nombre de dimensions |
---|
447 | ######################################################################## |
---|
448 | |
---|
449 | |
---|
450 | dim_full=$dim |
---|
451 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
452 | set $dim |
---|
453 | dimc=$# |
---|
454 | echo calcul de la dimension |
---|
455 | echo dim $dim |
---|
456 | echo dimc $dimc |
---|
457 | |
---|
458 | ######################################################################## |
---|
459 | # Gestion des dimensions du modele. |
---|
460 | # on cree ou remplace le fichier des dimensions |
---|
461 | ######################################################################## |
---|
462 | |
---|
463 | cd $LIBFGCM/grid |
---|
464 | if [[ -f dimensions.h ]] |
---|
465 | then |
---|
466 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
467 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
468 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
469 | echo vous pouvez continuer en repondant oui. |
---|
470 | echo "Voulez-vous vraiment continuer?" |
---|
471 | echo "" |
---|
472 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
473 | echo "Wait until the first compilation is finished before launching this one." |
---|
474 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
475 | echo "yes (or 'oui') to the question below to proceed." |
---|
476 | echo "Do you wish to continue?" |
---|
477 | read reponse |
---|
478 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
479 | then |
---|
480 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
481 | else |
---|
482 | exit |
---|
483 | fi |
---|
484 | fi |
---|
485 | |
---|
486 | cd $LIBFGCM/grid/dimension |
---|
487 | ./makdim $dim |
---|
488 | if (($? != 0)) |
---|
489 | then |
---|
490 | exit 1 |
---|
491 | fi |
---|
492 | |
---|
493 | cat $LIBFGCM/grid/dimensions.h |
---|
494 | cd $LMDGCM |
---|
495 | |
---|
496 | ######################################################################## |
---|
497 | # Differentes dynamiques (3d, 2d, 1d) |
---|
498 | ######################################################################## |
---|
499 | |
---|
500 | if (( $dimc == 3 )) ; then |
---|
501 | src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}" |
---|
502 | if [[ $physique != "nophys" ]] ; then |
---|
503 | src_dirs="$src_dirs dynlonlat_phylonlat dynlonlat_phylonlat/phy${physique}" |
---|
504 | libdyn_phy="-ldynlonlat_phylonlat" |
---|
505 | LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a' |
---|
506 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat' |
---|
507 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat_'"${physique}" |
---|
508 | fi |
---|
509 | cd $LIBFGCM/grid |
---|
510 | \rm fxyprim.h |
---|
511 | cp -p fxy_${grille}.h fxyprim.h |
---|
512 | filtre="FILTRE=$filtre" |
---|
513 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common ' |
---|
514 | elif (( $dimc == 2 )) ; then |
---|
515 | src_dirs="$src_dirs dyn2d" |
---|
516 | filtre="FILTRE= L_FILTRE= " |
---|
517 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
518 | elif (( $dimc == 1 )) ; then |
---|
519 | #src_dirs="$src_dirs dyn3d dyn3d_common filtrez" |
---|
520 | src_dirs="$src_dirs phy${physique}/dyn1d" |
---|
521 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
522 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= " |
---|
523 | #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre |
---|
524 | INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d' |
---|
525 | else |
---|
526 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
527 | fi |
---|
528 | |
---|
529 | cd $LMDGCM |
---|
530 | |
---|
531 | ######################################################################## |
---|
532 | # library directory name: |
---|
533 | ######################################################################## |
---|
534 | |
---|
535 | 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'` |
---|
536 | echo "Path to library: "$nomlib |
---|
537 | |
---|
538 | ######################################################################## |
---|
539 | # Cleanup for a full recompilation, if requested |
---|
540 | ######################################################################## |
---|
541 | |
---|
542 | if [[ $full == "full" ]] |
---|
543 | then |
---|
544 | # remove makefile and librairies |
---|
545 | echo "-full option: recompiling from scratch" |
---|
546 | \rm -f makefile |
---|
547 | \rm -rf "${LIBOGCM}/${nomlib}" |
---|
548 | fi |
---|
549 | |
---|
550 | ######################################################################## |
---|
551 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
552 | ######################################################################## |
---|
553 | ######################################################################## |
---|
554 | # c'est a dire dans 3 cas: |
---|
555 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
556 | # derniere creation du makefile |
---|
557 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
558 | # n'existe pas. |
---|
559 | # 3. Si le makefile n'existe pas. |
---|
560 | ######################################################################## |
---|
561 | cd $LMDGCM |
---|
562 | |
---|
563 | find libf -name '*.[Fh]' -print | sort > tmp77 |
---|
564 | #find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90 |
---|
565 | find libf -name '*.F90' -print | sort > tmp90 |
---|
566 | |
---|
567 | if [[ -r .makelmdz ]] |
---|
568 | then |
---|
569 | old_lmdz_configuration=$(cat .makelmdz ) |
---|
570 | else |
---|
571 | old_lmdz_configuration="" |
---|
572 | fi |
---|
573 | lmdz_configuration="$src_dirs" |
---|
574 | if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]] |
---|
575 | then |
---|
576 | configuration_change="true" |
---|
577 | else |
---|
578 | configuration_change="false" |
---|
579 | fi |
---|
580 | |
---|
581 | if [[ $configuration_change == "true" || ! ( -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 ]] |
---|
582 | then |
---|
583 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
584 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
585 | diff liste_des_sources_f77 tmp77 |
---|
586 | diff liste_des_sources_f90 tmp90 |
---|
587 | \cp -f tmp77 liste_des_sources_f77 |
---|
588 | \cp -f tmp90 liste_des_sources_f90 |
---|
589 | echo "Recreating the makefile" |
---|
590 | echo "src_dirs: $src_dirs" |
---|
591 | ./create_make_gcm $src_dirs > tmp |
---|
592 | \mv -f tmp makefile |
---|
593 | echo "New makefile created" |
---|
594 | fi |
---|
595 | |
---|
596 | #Create a .makelmdz file containing main compilation option for later comparisons |
---|
597 | echo "$lmdz_configuration" > .makelmdz |
---|
598 | |
---|
599 | ################################################################# |
---|
600 | # Preparation de l'execution de la comande make |
---|
601 | ################################################################# |
---|
602 | |
---|
603 | source_code=${code}.F |
---|
604 | dirmain=dyn${dimc}d${FLAG_PARA} |
---|
605 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
606 | then |
---|
607 | source_code=${code}.F90 |
---|
608 | elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then |
---|
609 | dirmain=phy$physique |
---|
610 | source_code=${code}.F90 |
---|
611 | elif [[ -r $LMDGCM/libf/dynlonlat_phylonlat/phy$physique/${code}.F90 ]] ; then |
---|
612 | dirmain="dynlonlat_phylonlat/phy${physique}" |
---|
613 | source_code=${code}.F90 |
---|
614 | elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then |
---|
615 | dirmain=phy$physique/dyn1d |
---|
616 | source_code=${code}.F90 |
---|
617 | fi |
---|
618 | |
---|
619 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
620 | then |
---|
621 | mkdir ${LIBOGCM}/${nomlib} |
---|
622 | # check we indeed managed to create the directory |
---|
623 | if [[ ! $? ]] |
---|
624 | then |
---|
625 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
626 | exit |
---|
627 | fi |
---|
628 | fi |
---|
629 | |
---|
630 | # where module files are created |
---|
631 | mod_loc_dir=$localdir |
---|
632 | |
---|
633 | if [[ "$physique" != "nophys" ]] |
---|
634 | then |
---|
635 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
636 | fi |
---|
637 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
638 | |
---|
639 | # ranlib utility (check it exists or else default to ls) |
---|
640 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
641 | then |
---|
642 | ranlib="ranlib" |
---|
643 | else |
---|
644 | ranlib="ls" |
---|
645 | fi |
---|
646 | |
---|
647 | # add CPP keys to COMPIL_FLAGS |
---|
648 | # (but first add -D before all CPP_KEY items) |
---|
649 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
650 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
651 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
652 | then |
---|
653 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
654 | fi |
---|
655 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
656 | |
---|
657 | ################################################################# |
---|
658 | # Execution du make |
---|
659 | ################################################################# |
---|
660 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
661 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
662 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
663 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
664 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
665 | INCLUDE="$INCLUDE" \ |
---|
666 | $filtre \ |
---|
667 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
668 | "PHYS=$physique" \ |
---|
669 | LIBPHY=${LIBPHY} \ |
---|
670 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
671 | DIM=$dimc \ |
---|
672 | FLAG_PARA=$FLAG_PARA \ |
---|
673 | L_PHY="$lib_phy" \ |
---|
674 | L_DYN_PHY="$libdyn_phy" \ |
---|
675 | L_ADJNT=$adjnt \ |
---|
676 | L_COSP="$lcosp" \ |
---|
677 | L_CHIMIE="$libchimie" \ |
---|
678 | LOCAL_DIR="$localdir" \ |
---|
679 | F77="$fcompiler" \ |
---|
680 | F90="$fcompiler" \ |
---|
681 | OPLINK="$LIB" \ |
---|
682 | LINK="$linker" \ |
---|
683 | GCM="$LMDGCM" \ |
---|
684 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
685 | MOD_SUFFIX="mod" \ |
---|
686 | AR=$arcommand \ |
---|
687 | DIRMAIN=$dirmain \ |
---|
688 | SOURCE=$source_code \ |
---|
689 | PROG=$code |
---|
690 | |
---|
691 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
692 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
693 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
694 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
695 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
696 | INCLUDE="$INCLUDE" \ |
---|
697 | $filtre \ |
---|
698 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
699 | "PHYS=$physique" \ |
---|
700 | LIBPHY=${LIBPHY} \ |
---|
701 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
702 | DIM=$dimc \ |
---|
703 | FLAG_PARA=$FLAG_PARA \ |
---|
704 | L_PHY="$lib_phy" \ |
---|
705 | L_DYN_PHY="$libdyn_phy" \ |
---|
706 | L_ADJNT=$adjnt \ |
---|
707 | L_COSP="$lcosp" \ |
---|
708 | L_CHIMIE="$libchimie" \ |
---|
709 | LOCAL_DIR="$localdir" \ |
---|
710 | F77="$fcompiler" \ |
---|
711 | F90="$fcompiler" \ |
---|
712 | OPLINK="$LIB" \ |
---|
713 | LINK="$linker" \ |
---|
714 | GCM="$LMDGCM" \ |
---|
715 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
716 | MOD_SUFFIX="mod" \ |
---|
717 | AR=$arcommand \ |
---|
718 | DIRMAIN=$dirmain \ |
---|
719 | SOURCE=$source_code \ |
---|
720 | PROG=$code |
---|
721 | |
---|
722 | |
---|
723 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
724 | then |
---|
725 | # Cleanup: remove dimension.h file |
---|
726 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
727 | fi |
---|