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