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