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 | cosp2=false |
---|
28 | cospv2=false |
---|
29 | sisvat=false |
---|
30 | inlandsis=false |
---|
31 | rrtm=false |
---|
32 | rrtm=false |
---|
33 | ecrad=false |
---|
34 | dust=false |
---|
35 | strataer=false |
---|
36 | full="" |
---|
37 | |
---|
38 | arch_defined="FALSE" |
---|
39 | arch_path="arch" |
---|
40 | arch_default_path="arch" |
---|
41 | |
---|
42 | # guess a default 'arch' |
---|
43 | arch="local" # start with assuming we're on a local machine with local arch file |
---|
44 | arch_defined="TRUE" # and thus also set arch_defined to true |
---|
45 | ## try to recognise machine and infer arch from it |
---|
46 | machine=`hostname` |
---|
47 | if [[ "${machine:0:4}" == "jean" ]] |
---|
48 | then |
---|
49 | arch="X64_JEANZAY" |
---|
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)/misc -I$(LIBF)/filtrez -I. ' |
---|
92 | LIB="" |
---|
93 | adjnt="" |
---|
94 | ##COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
95 | PARA_FFLAGS="" |
---|
96 | PARA_LD="" |
---|
97 | EXT_SRC="" |
---|
98 | #src_dirs: directories containing source files |
---|
99 | src_dirs="grid misc" |
---|
100 | ######################################################################## |
---|
101 | # lecture des options |
---|
102 | ######################################################################## |
---|
103 | |
---|
104 | while (($# > 0)) |
---|
105 | do |
---|
106 | case $1 in |
---|
107 | "-h") cat <<fin |
---|
108 | Usage : |
---|
109 | makelmdz [options] -arch nom_arch exec |
---|
110 | [-h] : brief help |
---|
111 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
112 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
113 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
114 | [-c false/MPI1/MPI2] : coupling with ocean model : MPI1/MPI2/false (default: false) |
---|
115 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
116 | false : no vegetation model |
---|
117 | orchidee2.1 : compile using ORCHIDEE 2.1 (or more recent version) |
---|
118 | orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version) |
---|
119 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
120 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
121 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
122 | [-cosp true/false] : compile with/without cosp package (default: false) |
---|
123 | [-cosp2 true/false] : compile with/without cosp2 package (default: false) |
---|
124 | [-cospv2 true/false] : compile with/without cospv2 package (default: false) |
---|
125 | [-sisvat true/false] : compile with/without sisvat package (default: false) |
---|
126 | [-inlandsis true/false] : compile with/without inlandsis package (default: false) |
---|
127 | [-rrtm true/false] : compile with/without rrtm package (default: false) |
---|
128 | [-ecrad true/false] : compile with/without ecrad package (default: false) |
---|
129 | [-dust true/false] : compile with/without the dust package from Boucher et al. (default: false) |
---|
130 | [-strataer true/false] : compile with/without the strat aer package from Boucher et al. (default: false) |
---|
131 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
132 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
133 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
134 | [-include INCLUDES] : extra include path to add |
---|
135 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
136 | [-adjnt] : adjoint model, not operational ... |
---|
137 | [-mem] : reduced memory dynamics (if in parallel mode) |
---|
138 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
139 | [-full] : Full (re)compilation (from scratch) |
---|
140 | [-link LINKS] : additional links with other libraries |
---|
141 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
142 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
143 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
144 | -arch nom_arch : target architecture |
---|
145 | exec : executable to build |
---|
146 | fin |
---|
147 | exit;; |
---|
148 | "-d") |
---|
149 | dim=$2 ; shift ; shift ;; |
---|
150 | |
---|
151 | "-p") |
---|
152 | physique="$2" ; shift ; shift ;; |
---|
153 | |
---|
154 | "-g") |
---|
155 | grille="$2" ; shift ; shift ;; |
---|
156 | |
---|
157 | "-c") |
---|
158 | couple="$2" ; shift ; shift ;; |
---|
159 | |
---|
160 | "-prod") |
---|
161 | compil_mod="prod" ; shift ;; |
---|
162 | |
---|
163 | "-dev") |
---|
164 | compil_mod="dev" ; shift ;; |
---|
165 | |
---|
166 | "-debug") |
---|
167 | compil_mod="debug" ; shift ;; |
---|
168 | |
---|
169 | "-io") |
---|
170 | io="$2" ; shift ; shift ;; |
---|
171 | |
---|
172 | "-v") |
---|
173 | veget="$2" ; shift ; shift ;; |
---|
174 | |
---|
175 | "-chimie") |
---|
176 | chimie="$2" ; shift ; shift ;; |
---|
177 | |
---|
178 | "-parallel") |
---|
179 | parallel="$2" ; shift ; shift ;; |
---|
180 | |
---|
181 | "-include") |
---|
182 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
183 | |
---|
184 | "-cpp") |
---|
185 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
186 | |
---|
187 | "-cosp") |
---|
188 | cosp="$2" ; shift ; shift ;; |
---|
189 | |
---|
190 | "-cosp2") |
---|
191 | cosp2="$2" ; shift ; shift ;; |
---|
192 | |
---|
193 | "-cosp2") |
---|
194 | cospv2="$2" ; shift ; shift ;; |
---|
195 | |
---|
196 | "-sisvat") |
---|
197 | sisvat="$2" ; shift ; shift ;; |
---|
198 | |
---|
199 | "-inlandsis") |
---|
200 | inlandsis="$2" ; shift ; shift ;; |
---|
201 | |
---|
202 | "-rrtm") |
---|
203 | rrtm="$2" ; shift ; shift ;; |
---|
204 | |
---|
205 | "-ecrad") |
---|
206 | ecrad="$2" ; shift ; shift ;; |
---|
207 | |
---|
208 | "-dust") |
---|
209 | dust="$2" ; shift ; shift ;; |
---|
210 | |
---|
211 | "-strataer") |
---|
212 | strataer="$2" ; shift ; shift ;; |
---|
213 | |
---|
214 | "-mem") |
---|
215 | paramem="mem" ; shift ;; |
---|
216 | |
---|
217 | "-filtre") |
---|
218 | filtre=$2 ; shift ; shift ;; |
---|
219 | |
---|
220 | "-full") |
---|
221 | full="full" ; shift ;; |
---|
222 | |
---|
223 | "-link") |
---|
224 | LIB="$LIB $2" ; shift ; shift ;; |
---|
225 | |
---|
226 | "-fcm_path") |
---|
227 | fcm_path=$2 ; shift ; shift ;; |
---|
228 | |
---|
229 | "-ext_src") |
---|
230 | EXT_SRC=$2 ; src_dirs="$src_dirs $EXT_SRC" ; shift ; shift ;; |
---|
231 | |
---|
232 | "-arch") |
---|
233 | arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; |
---|
234 | |
---|
235 | "-arch_path") |
---|
236 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
237 | |
---|
238 | *) |
---|
239 | code="$1" ; shift ;; |
---|
240 | esac |
---|
241 | done |
---|
242 | |
---|
243 | ############################################################### |
---|
244 | # lecture des chemins propres \`a l'architecture de la machine # |
---|
245 | ############################################################### |
---|
246 | rm -f .void_file |
---|
247 | echo > .void_file |
---|
248 | rm -rf .void_dir |
---|
249 | mkdir .void_dir |
---|
250 | |
---|
251 | if [[ "$arch_defined" == "TRUE" ]] |
---|
252 | then |
---|
253 | rm -f arch.path |
---|
254 | rm -f arch.fcm |
---|
255 | rm -f arch.env |
---|
256 | |
---|
257 | if test -f $arch_path/arch-${arch}.path |
---|
258 | then |
---|
259 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
260 | elif test -f $arch_default_path/arch-${arch}.path |
---|
261 | then |
---|
262 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
263 | fi |
---|
264 | |
---|
265 | if test -f $arch_path/arch-${arch}.fcm |
---|
266 | then |
---|
267 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
268 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
269 | then |
---|
270 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
271 | fi |
---|
272 | |
---|
273 | if test -f $arch_path/arch-${arch}.env |
---|
274 | then |
---|
275 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
276 | elif test -f $arch_default_path/arch-${arch}.env |
---|
277 | then |
---|
278 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
279 | else |
---|
280 | ln -s .void_file arch.env |
---|
281 | fi |
---|
282 | # source architecture PATH and ENV files |
---|
283 | source arch.env |
---|
284 | source arch.path |
---|
285 | else |
---|
286 | echo "You must define a target architecture" |
---|
287 | exit 1 |
---|
288 | fi |
---|
289 | |
---|
290 | ######################################################################## |
---|
291 | # Definition des clefs CPP, des chemins des includes et modules |
---|
292 | # et des libraries |
---|
293 | ######################################################################## |
---|
294 | |
---|
295 | # basic compile flags from arch.fcm file |
---|
296 | archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm ) |
---|
297 | COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} ) |
---|
298 | |
---|
299 | # other compile flags, depending on compilation mode |
---|
300 | if [[ "$compil_mod" == "prod" ]] |
---|
301 | then |
---|
302 | ## read COMPIL_FFLAGS from arch.fcm file |
---|
303 | archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm ) |
---|
304 | archfileopt=$( echo ${archfileline##%PROD_FFLAGS} ) |
---|
305 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
306 | elif [[ "$compil_mod" == "dev" ]] |
---|
307 | then |
---|
308 | ## read %DEV_FFLAGS from arch.fcm file |
---|
309 | archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm ) |
---|
310 | archfileopt=$( echo ${archfileline##%DEV_FFLAGS} ) |
---|
311 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
312 | elif [[ "$compil_mod" == "debug" ]] |
---|
313 | then |
---|
314 | ## read %DEBUG_FFLAGS from arch.fcm file |
---|
315 | archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm ) |
---|
316 | archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} ) |
---|
317 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
318 | fi |
---|
319 | |
---|
320 | # add CPP_KEY defined in arch.fcm file |
---|
321 | archfileline=$( grep -i '^%FPP_DEF' arch.fcm ) |
---|
322 | archfileopt=$( echo ${archfileline##%FPP_DEF} ) |
---|
323 | CPP_KEY="$CPP_KEY ${archfileopt}" |
---|
324 | |
---|
325 | # get compiler name from arch.fcm file |
---|
326 | archfileline=$( grep -i '^%COMPILER' arch.fcm ) |
---|
327 | fcompiler=$( echo ${archfileline##%COMPILER} ) |
---|
328 | |
---|
329 | # get linker name from arch.fcm file |
---|
330 | archfileline=$( grep -i '^%LINK' arch.fcm ) |
---|
331 | linker=$( echo ${archfileline##%LINK} ) |
---|
332 | |
---|
333 | # get ar command from arch.fcm file |
---|
334 | archfileline=$( grep -i '^%AR ' arch.fcm ) |
---|
335 | arcommand=$( echo ${archfileline##%AR} ) |
---|
336 | |
---|
337 | # get ar command options from arch.fcm file |
---|
338 | archfileline=$( grep -i '^%ARFLAGS' arch.fcm ) |
---|
339 | arflags=$( echo ${archfileline##%ARFLAGS} ) |
---|
340 | |
---|
341 | # get make utility from arch.fcm file |
---|
342 | archfileline=$( grep -i '^%MAKE' arch.fcm ) |
---|
343 | makecommand=$( echo ${archfileline##%MAKE} ) |
---|
344 | |
---|
345 | # get basic libraries to link with arch.fcm file |
---|
346 | archfileline=$( grep -i '^%BASE_LD' arch.fcm ) |
---|
347 | archfileopt=$( echo ${archfileline##%BASE_LD} ) |
---|
348 | LIB="$LIB ${archfileopt}" |
---|
349 | |
---|
350 | # add Include files defined in arch.fcm file for pre-processing |
---|
351 | archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm ) |
---|
352 | for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done |
---|
353 | |
---|
354 | phys_root=$physique |
---|
355 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
356 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
357 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
358 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
359 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
360 | if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi |
---|
361 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
362 | |
---|
363 | if [[ "$physique" != "nophys" ]] |
---|
364 | then |
---|
365 | #We'll use some physics |
---|
366 | src_dirs="$src_dirs phy_common phy$physique" |
---|
367 | LIBPHY='$(LIBO)/libphy'"$physique"'.a' |
---|
368 | LIBPHY_COMMON='$(LIBO)/libphy_common.a' |
---|
369 | lib_phy='-lphy'"$physique"' -lphy_common' |
---|
370 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
371 | if [[ $phys_root == "lmd" ]] |
---|
372 | then |
---|
373 | #For lmd physics, default planet type is Earth |
---|
374 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
375 | fi |
---|
376 | fi |
---|
377 | |
---|
378 | if [[ "$chimie" == "INCA" ]] |
---|
379 | then |
---|
380 | CPP_KEY="$CPP_KEY INCA" |
---|
381 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
382 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
383 | libchimie=" -L${INCA_LIBDIR} -lchimie" |
---|
384 | fi |
---|
385 | |
---|
386 | if [[ "$couple" != "false" ]] |
---|
387 | then |
---|
388 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
389 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
390 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
391 | fi |
---|
392 | |
---|
393 | if [[ "$parallel" == "none" ]] |
---|
394 | then |
---|
395 | FLAG_PARA='' |
---|
396 | else |
---|
397 | FLAG_PARA="$paramem" |
---|
398 | if [[ $paramem == par ]] |
---|
399 | then |
---|
400 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
401 | echo "You should use option \"-mem\"." |
---|
402 | exit 1 |
---|
403 | fi |
---|
404 | fi |
---|
405 | |
---|
406 | if [[ "$parallel" == "mpi" ]] |
---|
407 | then |
---|
408 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
409 | # MPI additional compilation options |
---|
410 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
411 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
412 | # MPI additional links |
---|
413 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
414 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
415 | elif [[ "$parallel" == "omp" ]] |
---|
416 | then |
---|
417 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
418 | # OMP additional compilation options |
---|
419 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
420 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
421 | # OMP additional links |
---|
422 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
423 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
424 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
425 | then |
---|
426 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
427 | # MPI additional compilation options |
---|
428 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
429 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
430 | # OMP additional compilation options |
---|
431 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
432 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
433 | # MPI additional links |
---|
434 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
435 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
436 | # OMP additional links |
---|
437 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
438 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
439 | fi |
---|
440 | |
---|
441 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
442 | && "$compil_mod" == "debug" ]] |
---|
443 | then |
---|
444 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
445 | echo "We suggest switching to \"-dev\"." |
---|
446 | fi |
---|
447 | |
---|
448 | |
---|
449 | #============================================================================== |
---|
450 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" -o "$veget" = "orchidee2.1" ] |
---|
451 | then |
---|
452 | |
---|
453 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
454 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
455 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
456 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
457 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
458 | fi |
---|
459 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
460 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
461 | CPP_KEY="$CPP_KEY ORCHIDEE_NOUNSTRUCT" |
---|
462 | elif [[ "$veget" == "orchidee2.1" ]] ; then |
---|
463 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
464 | else |
---|
465 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
466 | fi |
---|
467 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
468 | for lib in ${orch_libs} ; do |
---|
469 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
470 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
471 | fi |
---|
472 | done |
---|
473 | elif [[ "$veget" != "false" ]] ; then |
---|
474 | echo "Option -v $veget does not exist" |
---|
475 | echo "Use ./makelmdz -h for more information" |
---|
476 | exit |
---|
477 | fi |
---|
478 | |
---|
479 | #=============================================================================== |
---|
480 | if [[ $io == ioipsl ]] |
---|
481 | then |
---|
482 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
483 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
484 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
485 | elif [[ $io == mix ]] |
---|
486 | then |
---|
487 | # For now, xios implies also using ioipsl |
---|
488 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
489 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
490 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++" |
---|
491 | elif [[ $io == xios ]] |
---|
492 | then |
---|
493 | # For now, xios implies also using ioipsl |
---|
494 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
495 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
496 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++" |
---|
497 | fi |
---|
498 | |
---|
499 | if [[ "$cosp" == "true" ]] |
---|
500 | then |
---|
501 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
502 | # COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
503 | src_dirs="$src_dirs phy${physique}/cosp" |
---|
504 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
505 | # opt_dep="$opt_dep cosp" |
---|
506 | # lcosp="-l${LIBPREFIX}cosp" |
---|
507 | INCLUDE="$INCLUDE"' -I$(LIBF)/'phy${physique}'/cosp' |
---|
508 | fi |
---|
509 | |
---|
510 | if [[ "$cosp2" == "true" ]] |
---|
511 | then |
---|
512 | CPP_KEY="$CPP_KEY CPP_COSP2" |
---|
513 | src_dirs="$src_dirs phy${physique}/cosp2" |
---|
514 | INCLUDE="$INCLUDE"' -I$(LIBF)/'phy${physique}'/cosp2' |
---|
515 | fi |
---|
516 | |
---|
517 | if [[ "$cospv2" == "true" ]] |
---|
518 | then |
---|
519 | CPP_KEY="$CPP_KEY CPP_COSPV2" |
---|
520 | src_dirs="$src_dirs phy${physique}/cospv2" |
---|
521 | INCLUDE="$INCLUDE"' -I$(LIBF)/'phy${physique}'/cospv2' |
---|
522 | fi |
---|
523 | |
---|
524 | |
---|
525 | if [[ "$sisvat" == "true" ]] |
---|
526 | then |
---|
527 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
528 | src_dirs="$src_dirs phy${physique}/sisvat" |
---|
529 | fi |
---|
530 | |
---|
531 | |
---|
532 | if [[ "$inlandsis" == "true" ]] |
---|
533 | then |
---|
534 | CPP_KEY="$CPP_KEY CPP_INLANDSIS" |
---|
535 | src_dirs="$src_dirs phy${physique}/inlandsis" |
---|
536 | fi |
---|
537 | |
---|
538 | |
---|
539 | if [[ "$rrtm" == "true" ]] |
---|
540 | then |
---|
541 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
542 | src_dirs="$src_dirs phy${physique}/rrtm" |
---|
543 | fi |
---|
544 | |
---|
545 | if [[ "$ecrad" == "true" ]] |
---|
546 | then |
---|
547 | CPP_KEY="$CPP_KEY CPP_ECRAD" |
---|
548 | src_dirs="$src_dirs phy${physique}/ecrad" |
---|
549 | fi |
---|
550 | |
---|
551 | |
---|
552 | if [[ "$dust" == "true" ]] |
---|
553 | then |
---|
554 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
555 | src_dirs="$src_dirs phy${physique}/Dust" |
---|
556 | fi |
---|
557 | |
---|
558 | if [[ "$strataer" == "true" ]] |
---|
559 | then |
---|
560 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
561 | src_dirs="$src_dirs phy${physique}/StratAer" |
---|
562 | fi |
---|
563 | |
---|
564 | |
---|
565 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
566 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
567 | |
---|
568 | ######################################################################## |
---|
569 | # calcul du nombre de dimensions |
---|
570 | ######################################################################## |
---|
571 | |
---|
572 | |
---|
573 | dim_full=$dim |
---|
574 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
575 | set $dim |
---|
576 | dimc=$# |
---|
577 | echo calcul de la dimension |
---|
578 | echo dim $dim |
---|
579 | echo dimc $dimc |
---|
580 | |
---|
581 | ######################################################################## |
---|
582 | # Gestion des dimensions du modele. |
---|
583 | # on cree ou remplace le fichier des dimensions |
---|
584 | ######################################################################## |
---|
585 | |
---|
586 | cd $LIBFGCM/grid |
---|
587 | if [[ -f dimensions.h ]] |
---|
588 | then |
---|
589 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
590 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
591 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
592 | echo vous pouvez continuer en repondant oui. |
---|
593 | echo "Voulez-vous vraiment continuer?" |
---|
594 | echo "" |
---|
595 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
596 | echo "Wait until the first compilation is finished before launching this one." |
---|
597 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
598 | echo "yes (or 'oui') to the question below to proceed." |
---|
599 | echo "Do you wish to continue?" |
---|
600 | read reponse |
---|
601 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
602 | then |
---|
603 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
604 | else |
---|
605 | exit |
---|
606 | fi |
---|
607 | fi |
---|
608 | |
---|
609 | cd $LIBFGCM/grid/dimension |
---|
610 | ./makdim $dim |
---|
611 | if (($? != 0)) |
---|
612 | then |
---|
613 | exit 1 |
---|
614 | fi |
---|
615 | |
---|
616 | cat $LIBFGCM/grid/dimensions.h |
---|
617 | cd $LMDGCM |
---|
618 | |
---|
619 | ######################################################################## |
---|
620 | # Differentes dynamiques (3d, 2d, 1d) |
---|
621 | ######################################################################## |
---|
622 | |
---|
623 | if (( $dimc == 3 )) ; then |
---|
624 | src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}" |
---|
625 | if [[ $physique != "nophys" ]] ; then |
---|
626 | src_dirs="$src_dirs dynphy_lonlat dynphy_lonlat/phy${phys_root}" |
---|
627 | libdyn_phy="-ldynphy_lonlat" |
---|
628 | LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a' |
---|
629 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat' |
---|
630 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat/'"phy${phys_root}" |
---|
631 | fi |
---|
632 | cd $LIBFGCM/grid |
---|
633 | \rm fxyprim.h |
---|
634 | cp -p fxy_${grille}.h fxyprim.h |
---|
635 | filtre="FILTRE=$filtre" |
---|
636 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common ' |
---|
637 | elif (( $dimc == 2 )) ; then |
---|
638 | src_dirs="$src_dirs dyn2d" |
---|
639 | filtre="FILTRE= L_FILTRE= " |
---|
640 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
641 | elif (( $dimc == 1 )) ; then |
---|
642 | #src_dirs="$src_dirs dyn3d dyn3d_common filtrez" |
---|
643 | src_dirs="$src_dirs phy${physique}/dyn1d" |
---|
644 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
645 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= " |
---|
646 | #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre |
---|
647 | INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d' |
---|
648 | else |
---|
649 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
650 | fi |
---|
651 | |
---|
652 | cd $LMDGCM |
---|
653 | |
---|
654 | ######################################################################## |
---|
655 | # library directory name: |
---|
656 | ######################################################################## |
---|
657 | |
---|
658 | 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'` |
---|
659 | echo "Path to library: "$nomlib |
---|
660 | |
---|
661 | ######################################################################## |
---|
662 | # Cleanup for a full recompilation, if requested |
---|
663 | ######################################################################## |
---|
664 | |
---|
665 | if [[ $full == "full" ]] |
---|
666 | then |
---|
667 | # remove makefile and librairies |
---|
668 | echo "-full option: recompiling from scratch" |
---|
669 | \rm -f makefile |
---|
670 | \rm -rf "${LIBOGCM}/${nomlib}" |
---|
671 | fi |
---|
672 | |
---|
673 | ######################################################################## |
---|
674 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
675 | ######################################################################## |
---|
676 | ######################################################################## |
---|
677 | # c'est a dire dans 3 cas: |
---|
678 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
679 | # derniere creation du makefile |
---|
680 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
681 | # n'existe pas. |
---|
682 | # 3. Si le makefile n'existe pas. |
---|
683 | ######################################################################## |
---|
684 | cd $LMDGCM |
---|
685 | |
---|
686 | |
---|
687 | if [[ -r .makelmdz ]] |
---|
688 | then |
---|
689 | old_lmdz_configuration=$(cat .makelmdz ) |
---|
690 | else |
---|
691 | old_lmdz_configuration="" |
---|
692 | fi |
---|
693 | lmdz_configuration="$src_dirs" |
---|
694 | if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]] |
---|
695 | then |
---|
696 | configuration_change="true" |
---|
697 | else |
---|
698 | configuration_change="false" |
---|
699 | fi |
---|
700 | |
---|
701 | mkdir -p make_dir |
---|
702 | suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'` |
---|
703 | echo suf_make $suf_make |
---|
704 | |
---|
705 | \rm tmp77 tmp90 |
---|
706 | for dir in $src_dirs ; do |
---|
707 | find libf/$dir -name '*.[Fh]' -print | sort >> tmp77 |
---|
708 | find libf/$dir -name '*.F90' -print | sort >> tmp90 |
---|
709 | done |
---|
710 | |
---|
711 | liste77=make_dir/liste_des_sources_f77_$suf_make |
---|
712 | liste90=make_dir/liste_des_sources_f90_$suf_make |
---|
713 | makefile=make_dir/makefile_$suf_make |
---|
714 | |
---|
715 | if [[ $configuration_change == "true" || ! ( -r $makefile ) || ! ( -r $liste90 ) || ! ( -r $liste77 ) || ` diff tmp77 $liste77 | wc -w ` -ne 0 || ` diff tmp90 $liste90 | wc -w ` -ne 0 ]] |
---|
716 | then |
---|
717 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
718 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
719 | diff $liste77 tmp77 |
---|
720 | diff $liste90 tmp90 |
---|
721 | \cp -f tmp77 $liste77 |
---|
722 | \cp -f tmp90 $liste90 |
---|
723 | echo "Recreating the makefile" |
---|
724 | echo "src_dirs: $src_dirs" |
---|
725 | ./create_make_gcm $src_dirs > tmp |
---|
726 | \mv -f tmp $makefile |
---|
727 | echo "New makefile created" |
---|
728 | fi |
---|
729 | |
---|
730 | ln -sf $makefile makefile |
---|
731 | |
---|
732 | #Create a .makelmdz file containing main compilation option for later comparisons |
---|
733 | echo "$lmdz_configuration" > .makelmdz |
---|
734 | |
---|
735 | ################################################################# |
---|
736 | # Preparation de l'execution de la comande make |
---|
737 | ################################################################# |
---|
738 | |
---|
739 | source_code=${code}.F |
---|
740 | dirmain=dyn${dimc}d${FLAG_PARA} |
---|
741 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
742 | then |
---|
743 | source_code=${code}.F90 |
---|
744 | elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then |
---|
745 | dirmain=phy$physique |
---|
746 | source_code=${code}.F90 |
---|
747 | elif [[ -r $LMDGCM/libf/dynphy_lonlat/phy$phys_root/${code}.F90 ]] ; then |
---|
748 | dirmain="dynphy_lonlat/phy${phys_root}" |
---|
749 | source_code=${code}.F90 |
---|
750 | elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then |
---|
751 | dirmain=phy$physique/dyn1d |
---|
752 | source_code=${code}.F90 |
---|
753 | fi |
---|
754 | |
---|
755 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
756 | then |
---|
757 | mkdir ${LIBOGCM}/${nomlib} |
---|
758 | # check we indeed managed to create the directory |
---|
759 | if [[ ! $? ]] |
---|
760 | then |
---|
761 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
762 | exit |
---|
763 | fi |
---|
764 | fi |
---|
765 | |
---|
766 | # where module files are created |
---|
767 | mod_loc_dir=$localdir |
---|
768 | |
---|
769 | if [[ "$physique" != "nophys" ]] |
---|
770 | then |
---|
771 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
772 | fi |
---|
773 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
774 | |
---|
775 | # ranlib utility (check it exists or else default to ls) |
---|
776 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
777 | then |
---|
778 | ranlib="ranlib" |
---|
779 | else |
---|
780 | ranlib="ls" |
---|
781 | fi |
---|
782 | |
---|
783 | # add CPP keys to COMPIL_FLAGS |
---|
784 | # (but first add -D before all CPP_KEY items) |
---|
785 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
786 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
787 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
788 | then |
---|
789 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
790 | fi |
---|
791 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
792 | |
---|
793 | ################################################################# |
---|
794 | # Execution du make |
---|
795 | ################################################################# |
---|
796 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
797 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
798 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
799 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
800 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
801 | INCLUDE="$INCLUDE" \ |
---|
802 | $filtre \ |
---|
803 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
804 | "PHYS=$physique" \ |
---|
805 | LIBPHY=${LIBPHY} \ |
---|
806 | LIBPHY_COMMON=${LIBPHY_COMMON} \ |
---|
807 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
808 | DIM=$dimc \ |
---|
809 | FLAG_PARA=$FLAG_PARA \ |
---|
810 | L_PHY="$lib_phy" \ |
---|
811 | L_DYN_PHY="$libdyn_phy" \ |
---|
812 | L_ADJNT=$adjnt \ |
---|
813 | L_COSP="$lcosp" \ |
---|
814 | L_COSP2="$lcosp2" \ |
---|
815 | L_COSPV2="$lcospv2" \ |
---|
816 | L_CHIMIE="$libchimie" \ |
---|
817 | LOCAL_DIR="$localdir" \ |
---|
818 | F77="$fcompiler" \ |
---|
819 | F90="$fcompiler" \ |
---|
820 | OPLINK="$LIB" \ |
---|
821 | LINK="$linker" \ |
---|
822 | GCM="$LMDGCM" \ |
---|
823 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
824 | MOD_SUFFIX="mod" \ |
---|
825 | AR=$arcommand \ |
---|
826 | ARFLAGS="$arflags" \ |
---|
827 | DIRMAIN=$dirmain \ |
---|
828 | SOURCE=$source_code \ |
---|
829 | PROG=$code |
---|
830 | |
---|
831 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
832 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
833 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
834 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
835 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
836 | INCLUDE="$INCLUDE" \ |
---|
837 | $filtre \ |
---|
838 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
839 | "PHYS=$physique" \ |
---|
840 | LIBPHY=${LIBPHY} \ |
---|
841 | LIBPHY_COMMON=${LIBPHY_COMMON} \ |
---|
842 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
843 | DIM=$dimc \ |
---|
844 | FLAG_PARA=$FLAG_PARA \ |
---|
845 | L_PHY="$lib_phy" \ |
---|
846 | L_DYN_PHY="$libdyn_phy" \ |
---|
847 | L_ADJNT=$adjnt \ |
---|
848 | L_COSP="$lcosp" \ |
---|
849 | L_COSP2="$lcosp2" \ |
---|
850 | L_COSPV2="$lcospv2" \ |
---|
851 | L_CHIMIE="$libchimie" \ |
---|
852 | LOCAL_DIR="$localdir" \ |
---|
853 | F77="$fcompiler" \ |
---|
854 | F90="$fcompiler" \ |
---|
855 | OPLINK="$LIB" \ |
---|
856 | LINK="$linker" \ |
---|
857 | GCM="$LMDGCM" \ |
---|
858 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
859 | MOD_SUFFIX="mod" \ |
---|
860 | AR=$arcommand \ |
---|
861 | ARFLAGS="$arflags" \ |
---|
862 | DIRMAIN=$dirmain \ |
---|
863 | SOURCE=$source_code \ |
---|
864 | PROG=$code |
---|
865 | |
---|
866 | |
---|
867 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
868 | then |
---|
869 | # Cleanup: remove dimension.h file |
---|
870 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
871 | fi |
---|