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