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