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