1 | #!/bin/bash |
---|
2 | # $Id: makelmdz_fcm 3880 2021-04-28 14:55:57Z dcugnet $ |
---|
3 | # This is a script in Bash. |
---|
4 | |
---|
5 | # FH : on ne cr\'ee plus le fichier arch.mk qui est suppos\'e exister par |
---|
6 | # FH : ailleurs. |
---|
7 | # FH : ulterieurement, ce fichier sera pr\'e-existant pour une s\'erie |
---|
8 | # FH : de configurations en versions optimis\'ees et debug qui seront |
---|
9 | # FH : li\'es (ln -s) avec arch.mk en fonction de l'architecture. |
---|
10 | # FH : Pour le moment, cette version est en test et on peut cr\'eer les |
---|
11 | # FH : arch.mk en lan\c{}cant une premi\`ere fois makegcm. |
---|
12 | # |
---|
13 | ##set -x |
---|
14 | set -e |
---|
15 | ######################################################################## |
---|
16 | # options par defaut pour la commande make |
---|
17 | ######################################################################## |
---|
18 | |
---|
19 | dim="96x72x19" |
---|
20 | physique=lmd |
---|
21 | filtre=filtrez |
---|
22 | grille=reg |
---|
23 | couple=false |
---|
24 | veget=false |
---|
25 | sisvat=false |
---|
26 | inlandsis=false |
---|
27 | rrtm=false |
---|
28 | ecrad=false |
---|
29 | dust=false |
---|
30 | strataer=false |
---|
31 | chimie=false |
---|
32 | parallel=none |
---|
33 | paramem="par" |
---|
34 | compil_mod=prod |
---|
35 | io=ioipsl |
---|
36 | LIBPREFIX="" |
---|
37 | cosp=false |
---|
38 | cosp2=false |
---|
39 | cospv2=false |
---|
40 | job=1 |
---|
41 | full='' |
---|
42 | libphy=false |
---|
43 | |
---|
44 | arch_defined="FALSE" |
---|
45 | arch_path="arch" |
---|
46 | arch_default_path="arch" |
---|
47 | |
---|
48 | LMDGCM=`/bin/pwd` |
---|
49 | LIBOGCM=$LMDGCM/libo |
---|
50 | LIBFGCM=$LMDGCM/libf |
---|
51 | DYN_COMMON_PATH=$LIBFGCM/dyn3d_common |
---|
52 | # path for optional packages, but default set to ".void_dir" |
---|
53 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
54 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
55 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
56 | PHY_COMMON_PATH=$LMDGCM/.void_dir |
---|
57 | RRTM_PATH=$LMDGCM/.void_dir |
---|
58 | ECRAD_PATH=$LMDGCM/.void_dir |
---|
59 | DUST_PATH=$LMDGCM/.void_dir |
---|
60 | STRATAER_PATH=$LMDGCM/.void_dir |
---|
61 | SISVAT_PATH=$LMDGCM/.void_dir |
---|
62 | COSP_PATH=$LMDGCM/.void_dir |
---|
63 | fcm_path=$LMDGCM/tools/fcm/bin |
---|
64 | |
---|
65 | ######################################################################## |
---|
66 | # Quelques initialisations de variables du shell. |
---|
67 | ######################################################################## |
---|
68 | |
---|
69 | CPP_KEY="" |
---|
70 | INCLUDE="" |
---|
71 | LIB="" |
---|
72 | adjnt="" |
---|
73 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
74 | PARA_FFLAGS="" |
---|
75 | PARA_LD="" |
---|
76 | EXT_SRC="" |
---|
77 | |
---|
78 | ######################################################################## |
---|
79 | # lecture des options de mymake |
---|
80 | ######################################################################## |
---|
81 | |
---|
82 | while (($# > 0)) |
---|
83 | do |
---|
84 | case $1 in |
---|
85 | "-h") cat <<fin |
---|
86 | Usage : |
---|
87 | makelmdz_fcm [options] -arch nom_arch exec |
---|
88 | [-h] : brief help |
---|
89 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
90 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
91 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
92 | [-c false/MPI1/OMCT] : coupling with ocean model : MPI1/OMCT/false (default: false) |
---|
93 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
94 | false : no vegetation model |
---|
95 | orchidee2.1 : compile using ORCHIDEE 2.1 (or more recent version) |
---|
96 | orchidee2.0 : compile using ORCHIDEE 2.0 |
---|
97 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
98 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
99 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
100 | [-cosp true/false] : compile with/without cosp package (default: false) |
---|
101 | [-cosp2 true/false] : compile with/without cosp2 package (default: false) |
---|
102 | [-cospv2 true/false] : compile with/without cospv2 package (default: false) |
---|
103 | [-sisvat true/false] : compile with/without sisvat package (default: false) |
---|
104 | [-inlandsis true/false] : compile with/without inlandsis package (default: false) |
---|
105 | [-rrtm true/false] : compile with/without rrtm package (default: false) |
---|
106 | [-ecrad true/false] : compile with/without ecrad package (default: false) |
---|
107 | [-dust true/false] : compile with/without the dust package by Boucher and co (default: false) |
---|
108 | [-strataer true/false] : compile with/without the strat aer package by Boucher and co (default: false) |
---|
109 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
110 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
111 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
112 | [-include INCLUDES] : extra include path to add |
---|
113 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
114 | [-adjnt] : adjoint model, not operational ... |
---|
115 | [-mem] : reduced memory dynamics (if in parallel mode) |
---|
116 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
117 | [-link LINKS] : additional links with other libraries |
---|
118 | [-j n] : active parallel compiling on ntask |
---|
119 | [-full] : full recompiling |
---|
120 | [-libphy] : only compile physics package (no dynamics or main program) |
---|
121 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
122 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
123 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
124 | -arch nom_arch : target architecture |
---|
125 | exec : executable to build |
---|
126 | fin |
---|
127 | exit;; |
---|
128 | |
---|
129 | "-d") |
---|
130 | dim=$2 ; shift ; shift ;; |
---|
131 | |
---|
132 | "-p") |
---|
133 | physique="$2" ; shift ; shift ;; |
---|
134 | |
---|
135 | "-g") |
---|
136 | grille="$2" ; shift ; shift ;; |
---|
137 | |
---|
138 | "-c") |
---|
139 | couple="$2" ; shift ; shift ;; |
---|
140 | |
---|
141 | "-prod") |
---|
142 | compil_mod="prod" ; shift ;; |
---|
143 | |
---|
144 | "-dev") |
---|
145 | compil_mod="dev" ; shift ;; |
---|
146 | |
---|
147 | "-debug") |
---|
148 | compil_mod="debug" ; shift ;; |
---|
149 | |
---|
150 | "-io") |
---|
151 | io="$2" ; shift ; shift ;; |
---|
152 | |
---|
153 | "-v") |
---|
154 | veget="$2" ; shift ; shift ;; |
---|
155 | |
---|
156 | "-sisvat") |
---|
157 | sisvat="$2" ; shift ; shift ;; |
---|
158 | |
---|
159 | "-inlandsis") |
---|
160 | inlandsis="$2" ; shift ; shift ;; |
---|
161 | |
---|
162 | "-rrtm") |
---|
163 | rrtm="$2" ; shift ; shift ;; |
---|
164 | |
---|
165 | "-ecrad") |
---|
166 | ecrad="$2" ; shift ; shift ;; |
---|
167 | |
---|
168 | "-dust") |
---|
169 | dust="$2" ; shift ; shift ;; |
---|
170 | |
---|
171 | "-strataer") |
---|
172 | strataer="$2" ; shift ; shift ;; |
---|
173 | |
---|
174 | "-chimie") |
---|
175 | chimie="$2" ; shift ; shift ;; |
---|
176 | |
---|
177 | "-parallel") |
---|
178 | parallel="$2" ; shift ; shift ;; |
---|
179 | |
---|
180 | "-include") |
---|
181 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
182 | |
---|
183 | "-cpp") |
---|
184 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
185 | |
---|
186 | "-adjnt") |
---|
187 | echo "not operational ... work to be done here ";exit |
---|
188 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
189 | optim="$optim -Dadj" ; shift ;; |
---|
190 | |
---|
191 | "-cosp") |
---|
192 | cosp="$2" ; shift ; shift ;; |
---|
193 | |
---|
194 | "-cosp2") |
---|
195 | cosp2="$2" ; shift ; shift ;; |
---|
196 | |
---|
197 | "-cospv2") |
---|
198 | cospv2="$2" ; shift ; shift ;; |
---|
199 | |
---|
200 | "-mem") |
---|
201 | paramem="mem" ; shift ;; |
---|
202 | |
---|
203 | "-filtre") |
---|
204 | filtre=$2 ; shift ; shift ;; |
---|
205 | |
---|
206 | "-link") |
---|
207 | LIB="$LIB $2" ; shift ; shift ;; |
---|
208 | |
---|
209 | "-fcm_path") |
---|
210 | fcm_path=$2 ; shift ; shift ;; |
---|
211 | |
---|
212 | "-ext_src") |
---|
213 | EXT_SRC=$2 ; shift ; shift ;; |
---|
214 | |
---|
215 | "-j") |
---|
216 | job=$2 ; shift ; shift ;; |
---|
217 | |
---|
218 | "-full") |
---|
219 | full="-full" ; shift ;; |
---|
220 | |
---|
221 | "-libphy") |
---|
222 | libphy="true" ; shift ;; |
---|
223 | |
---|
224 | "-arch") |
---|
225 | arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; |
---|
226 | |
---|
227 | "-arch_path") |
---|
228 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
229 | |
---|
230 | *) |
---|
231 | code="$1" ; shift ;; |
---|
232 | esac |
---|
233 | done |
---|
234 | |
---|
235 | ############################################################### |
---|
236 | # path to fcm |
---|
237 | ############################################################### |
---|
238 | # handle case when provided path to fcm was given as a relative |
---|
239 | # path (from makelmdz_fcm script directory) and not an absolute path |
---|
240 | if [[ ${fcm_path:0:1} != "/" ]] ; then |
---|
241 | # prepend with makelmdz_fcm location |
---|
242 | fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path} |
---|
243 | fi |
---|
244 | |
---|
245 | # add fcm_path to PATH |
---|
246 | export PATH=${fcm_path}:${PATH} |
---|
247 | |
---|
248 | echo "Path to fcm:" |
---|
249 | echo ${fcm_path} |
---|
250 | |
---|
251 | ############################################################### |
---|
252 | # lecture des chemins propres \`a l'architecture de la machine # |
---|
253 | ############################################################### |
---|
254 | rm -f .void_file |
---|
255 | echo > .void_file |
---|
256 | rm -rf .void_dir |
---|
257 | mkdir .void_dir |
---|
258 | |
---|
259 | if [[ "$arch_defined" == "TRUE" ]] |
---|
260 | then |
---|
261 | rm -f arch.path |
---|
262 | rm -f arch.fcm |
---|
263 | rm -f arch.env |
---|
264 | |
---|
265 | if test -f $arch_path/arch-${arch}.path |
---|
266 | then |
---|
267 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
268 | elif test -f $arch_default_path/arch-${arch}.path |
---|
269 | then |
---|
270 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
271 | fi |
---|
272 | |
---|
273 | if test -f $arch_path/arch-${arch}.fcm |
---|
274 | then |
---|
275 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
276 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
277 | then |
---|
278 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
279 | fi |
---|
280 | |
---|
281 | if test -f $arch_path/arch-${arch}.env |
---|
282 | then |
---|
283 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
284 | elif test -f $arch_default_path/arch-${arch}.env |
---|
285 | then |
---|
286 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
287 | else |
---|
288 | ln -s .void_file arch.env |
---|
289 | fi |
---|
290 | # source architecture PATH and ENV files |
---|
291 | source arch.env |
---|
292 | source arch.path |
---|
293 | else |
---|
294 | echo "You must define a target architecture" |
---|
295 | exit 1 |
---|
296 | fi |
---|
297 | |
---|
298 | ######################################################################## |
---|
299 | # Definition des clefs CPP, des chemins des includes et modules |
---|
300 | # et des libraries |
---|
301 | ######################################################################## |
---|
302 | |
---|
303 | if [[ "$compil_mod" == "prod" ]] |
---|
304 | then |
---|
305 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
306 | elif [[ "$compil_mod" == "dev" ]] |
---|
307 | then |
---|
308 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
309 | elif [[ "$compil_mod" == "debug" ]] |
---|
310 | then |
---|
311 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
312 | fi |
---|
313 | |
---|
314 | phys_root=$physique |
---|
315 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
316 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
317 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
318 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
319 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
320 | if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi |
---|
321 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
322 | |
---|
323 | if [[ "$physique" != "nophys" ]] |
---|
324 | then |
---|
325 | #We'll use some physics |
---|
326 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
327 | if [[ "${phys_root}" == "lmd" ]] |
---|
328 | then |
---|
329 | #For lmd physics, default planet type is Earth |
---|
330 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
331 | fi |
---|
332 | # set physics common utilities path |
---|
333 | PHY_COMMON_PATH="${LIBFGCM}/phy_common" |
---|
334 | # set the dyn/phys interface path |
---|
335 | DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat" |
---|
336 | DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}" |
---|
337 | fi |
---|
338 | |
---|
339 | if [[ "$filtre" == "filtrez" ]] |
---|
340 | then |
---|
341 | FILTRE_PATH=${LIBFGCM}/$filtre |
---|
342 | fi |
---|
343 | |
---|
344 | if [[ "$chimie" == "INCA" ]] |
---|
345 | then |
---|
346 | CPP_KEY="$CPP_KEY INCA" |
---|
347 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
348 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
349 | fi |
---|
350 | |
---|
351 | if [[ "$couple" != "false" ]] |
---|
352 | then |
---|
353 | if [[ "$couple" == "MPI1" ]] |
---|
354 | then |
---|
355 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
356 | export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 |
---|
357 | export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib |
---|
358 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
359 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lmpp_io" |
---|
360 | else |
---|
361 | CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" |
---|
362 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
363 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.MPI1 -lscrip -lmct -lmpeu" |
---|
364 | fi |
---|
365 | fi |
---|
366 | |
---|
367 | if [[ "$parallel" == "mpi" ]] |
---|
368 | then |
---|
369 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
370 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
371 | PARA_LD="%MPI_LD" |
---|
372 | elif [[ "$parallel" == "omp" ]] |
---|
373 | then |
---|
374 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
375 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
376 | PARA_LD="%OMP_LD" |
---|
377 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
378 | then |
---|
379 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
380 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
381 | PARA_LD="%MPI_LD %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 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" -o "$veget" = "orchidee2.1" ] |
---|
392 | then |
---|
393 | #NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6 |
---|
394 | # For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments |
---|
395 | # option orchidee1.9 : Compile with ORCHIDEE version up to the inclusion of OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
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 | CPP_KEY="$CPP_KEY ORCHIDEE_NOUNSTRUCT" |
---|
405 | elif [[ "$veget" == "orchidee2.1" ]] ; then |
---|
406 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
407 | else |
---|
408 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
409 | fi |
---|
410 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
411 | for lib in ${orch_libs} ; do |
---|
412 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
413 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
414 | fi |
---|
415 | done |
---|
416 | elif [[ "$veget" != "false" ]] ; then |
---|
417 | echo "Option -v $veget does not exist" |
---|
418 | echo "Use ./makelmdz_fcm -h for more information" |
---|
419 | exit |
---|
420 | fi |
---|
421 | |
---|
422 | if [[ "$sisvat" == "true" ]] |
---|
423 | then |
---|
424 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
425 | SISVAT_PATH="$LIBFGCM/%PHYS/sisvat" |
---|
426 | fi |
---|
427 | |
---|
428 | if [[ "$inlandsis" == "true" ]] |
---|
429 | then |
---|
430 | CPP_KEY="$CPP_KEY CPP_INLANDSIS" |
---|
431 | INLANDSIS_PATH="$LIBFGCM/%PHYS/inlandsis" |
---|
432 | fi |
---|
433 | |
---|
434 | |
---|
435 | if [[ "$rrtm" == "true" ]] |
---|
436 | then |
---|
437 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
438 | RRTM_PATH="$LIBFGCM/%PHYS/rrtm" |
---|
439 | fi |
---|
440 | |
---|
441 | if [[ "$ecrad" == "true" ]] |
---|
442 | then |
---|
443 | CPP_KEY="$CPP_KEY CPP_ECRAD" |
---|
444 | ECRAD_PATH="$LIBFGCM/%PHYS/ecrad" |
---|
445 | fi |
---|
446 | |
---|
447 | |
---|
448 | if [[ "$dust" == "true" ]] |
---|
449 | then |
---|
450 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
451 | DUST_PATH="$LIBFGCM/%PHYS/Dust" |
---|
452 | fi |
---|
453 | |
---|
454 | if [[ "$strataer" == "true" ]] |
---|
455 | then |
---|
456 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
457 | STRATAER_PATH="$LIBFGCM/%PHYS/StratAer" |
---|
458 | fi |
---|
459 | |
---|
460 | if [[ $io == ioipsl ]] |
---|
461 | then |
---|
462 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
463 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
464 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
465 | elif [[ $io == mix ]] |
---|
466 | then |
---|
467 | # For now, xios implies also using ioipsl |
---|
468 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
469 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
470 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++" |
---|
471 | elif [[ $io == xios ]] |
---|
472 | then |
---|
473 | # For now, xios implies also using ioipsl |
---|
474 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
475 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
476 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios -l${LIBPREFIX}stdc++" |
---|
477 | fi |
---|
478 | |
---|
479 | if [[ "$cosp" == "true" ]] |
---|
480 | then |
---|
481 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
482 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
483 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
484 | fi |
---|
485 | |
---|
486 | if [[ "$cosp2" == "true" ]] |
---|
487 | then |
---|
488 | CPP_KEY="$CPP_KEY CPP_COSP2" |
---|
489 | COSP_PATH="$LIBFGCM/phylmd/cosp2" |
---|
490 | # LIB="${LIB} -l${LIBPREFIX}cosp2" |
---|
491 | fi |
---|
492 | |
---|
493 | if [[ "$cospv2" == "true" ]] |
---|
494 | then |
---|
495 | CPP_KEY="$CPP_KEY CPP_COSPV2" |
---|
496 | COSP_PATH="$LIBFGCM/phylmd/cospv2" |
---|
497 | # LIB="${LIB} -l${LIBPREFIX}cosp2" |
---|
498 | fi |
---|
499 | |
---|
500 | |
---|
501 | |
---|
502 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
503 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
504 | |
---|
505 | ######################################################################## |
---|
506 | # calcul du nombre de dimensions |
---|
507 | ######################################################################## |
---|
508 | |
---|
509 | |
---|
510 | dim_full=$dim |
---|
511 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
512 | set $dim |
---|
513 | dimc=$# |
---|
514 | echo calcul de la dimension |
---|
515 | echo dim $dim |
---|
516 | echo dimc $dimc |
---|
517 | |
---|
518 | |
---|
519 | ######################################################################## |
---|
520 | # Gestion des dimensions du modele. |
---|
521 | # on cree ou remplace le fichier des dimensions |
---|
522 | ######################################################################## |
---|
523 | |
---|
524 | cd $LIBFGCM/grid |
---|
525 | if [[ -f dimensions.h ]] |
---|
526 | then |
---|
527 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
528 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
529 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
530 | echo vous pouvez continuer en repondant oui. |
---|
531 | echo "Voulez-vous vraiment continuer?" |
---|
532 | echo "" |
---|
533 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
534 | echo "Wait until the first compilation is finished before launching this one." |
---|
535 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
536 | echo "yes (or 'oui') to the question below to proceed." |
---|
537 | echo "Do you wish to continue?" |
---|
538 | read reponse |
---|
539 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
540 | then |
---|
541 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
542 | else |
---|
543 | exit |
---|
544 | fi |
---|
545 | fi |
---|
546 | |
---|
547 | |
---|
548 | cd $LIBFGCM/grid/dimension |
---|
549 | ./makdim $dim |
---|
550 | cat $LIBFGCM/grid/dimensions.h |
---|
551 | cd $LMDGCM |
---|
552 | |
---|
553 | |
---|
554 | ######################################################################## |
---|
555 | # Differentes dynamiques (3d, 2d, 1d) |
---|
556 | ######################################################################## |
---|
557 | |
---|
558 | dimension=`echo $dim | wc -w` |
---|
559 | echo dimension $dimension |
---|
560 | |
---|
561 | if (( $dimension == 3 )) |
---|
562 | then |
---|
563 | cd $LIBFGCM/grid |
---|
564 | \rm fxyprim.h |
---|
565 | cp -p fxy_${grille}.h fxyprim.h |
---|
566 | #else |
---|
567 | # echo "Probleme dans les dimensions de la dynamique !!" |
---|
568 | # echo "Non reactive pour l'instant !!!" |
---|
569 | fi |
---|
570 | |
---|
571 | if (( $dimension == 1 )) |
---|
572 | then |
---|
573 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
574 | ##in 1D, add dyn3d to include path (because main prog is in physics) |
---|
575 | INCLUDE="$INCLUDE -Ilibf/dyn3d -Ilibf/dyn3d_common" |
---|
576 | ## no filtre in 1d: |
---|
577 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
578 | ## no need to compile all routines in dyn3d_common either: |
---|
579 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
580 | ## no need to compile all routines in dynlmdz_phy... ; |
---|
581 | ## (because key ones are included in 1D main program) |
---|
582 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
583 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
584 | fi |
---|
585 | |
---|
586 | ###################################################################### |
---|
587 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
588 | # ---> YM desactive pour le traitemement en parallele |
---|
589 | ###################################################################### |
---|
590 | |
---|
591 | #if [[ -f $libf/phy$physique/raddim.h ]] |
---|
592 | #then |
---|
593 | # if [[ -f $libf/phy$physique/raddim.$dimh.h ]] |
---|
594 | #then |
---|
595 | # \rm -f $libf/phy$physique/raddim.h |
---|
596 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
597 | # echo $libf/phy$physique/raddim.$dimh.h |
---|
598 | # cat $libf/phy$physique/raddim.h |
---|
599 | # else |
---|
600 | # echo On peut diminuer la taille de l executable en creant |
---|
601 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
602 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
603 | # fi |
---|
604 | #fi |
---|
605 | |
---|
606 | ###################################################################### |
---|
607 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
608 | ###################################################################### |
---|
609 | |
---|
610 | if (( `expr $dimc \> 2` == 1 )) |
---|
611 | then |
---|
612 | filtre="FILTRE=$filtre" |
---|
613 | else |
---|
614 | filtre="FILTRE= L_FILTRE= " |
---|
615 | fi |
---|
616 | echo MACRO FILTRE $filtre |
---|
617 | |
---|
618 | echo $dimc |
---|
619 | |
---|
620 | |
---|
621 | |
---|
622 | ###################################################################### |
---|
623 | # Creation du suffixe de la configuration |
---|
624 | ###################################################################### |
---|
625 | |
---|
626 | |
---|
627 | SUFF_NAME=_${dim_full} |
---|
628 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
629 | |
---|
630 | if [[ "$parallel" != "none" ]] |
---|
631 | then |
---|
632 | SUFF_NAME=${SUFF_NAME}_para |
---|
633 | DYN=dyn${dimc}d${paramem} |
---|
634 | if [[ "$paramem" == "mem" ]] |
---|
635 | then |
---|
636 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
637 | else |
---|
638 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
639 | echo "You should use option \"-mem\"." |
---|
640 | exit 1 |
---|
641 | fi |
---|
642 | else |
---|
643 | SUFF_NAME=${SUFF_NAME}_seq |
---|
644 | if (( $dimension == 1 )) |
---|
645 | then |
---|
646 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
647 | DYN=phy${physique}/dyn1d |
---|
648 | else |
---|
649 | DYN=dyn${dimc}d |
---|
650 | fi |
---|
651 | fi |
---|
652 | |
---|
653 | if [[ $veget != "false" ]] |
---|
654 | then |
---|
655 | SUFF_NAME=${SUFF_NAME}_orch |
---|
656 | fi |
---|
657 | |
---|
658 | if [[ $dust == "true" ]] |
---|
659 | then |
---|
660 | SUFF_NAME=${SUFF_NAME}_spla |
---|
661 | fi |
---|
662 | |
---|
663 | if [[ $couple != "false" ]] |
---|
664 | then |
---|
665 | SUFF_NAME=${SUFF_NAME}_couple |
---|
666 | fi |
---|
667 | |
---|
668 | if [[ $chimie == "INCA" ]] |
---|
669 | then |
---|
670 | SUFF_NAME=${SUFF_NAME}_inca |
---|
671 | fi |
---|
672 | |
---|
673 | if [[ $libphy == "true" ]] |
---|
674 | then |
---|
675 | # special case where we compile only the physics |
---|
676 | DYN=$LMDGCM/.void_dir |
---|
677 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
678 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
679 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
680 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
681 | #and there is no main program to generate |
---|
682 | code="" |
---|
683 | SUFF_NAME="" |
---|
684 | else |
---|
685 | SUFF_NAME=${SUFF_NAME}.e |
---|
686 | fi |
---|
687 | |
---|
688 | cd $LMDGCM |
---|
689 | config_fcm="config.fcm" |
---|
690 | rm -f $config_fcm |
---|
691 | touch $config_fcm |
---|
692 | rm -f bin/${code}${SUFF_NAME}.e |
---|
693 | rm -f arch.fcm |
---|
694 | rm -f arch.opt |
---|
695 | |
---|
696 | echo "%ARCH $arch" >> $config_fcm |
---|
697 | echo "%INCDIR $INCLUDE" >> $config_fcm |
---|
698 | echo "%LIB $LIB" >> $config_fcm |
---|
699 | echo "%ROOT_PATH $PWD" >> $config_fcm |
---|
700 | echo "%LIBF $LIBFGCM" >> $config_fcm |
---|
701 | echo "%LIBO $LIBOGCM" >> $config_fcm |
---|
702 | echo "%DYN $DYN" >> $config_fcm |
---|
703 | echo "%DYN_COMMON $DYN_COMMON_PATH" >> $config_fcm |
---|
704 | echo "%PHY_COMMON $PHY_COMMON_PATH" >> $config_fcm |
---|
705 | echo "%FILTRE $FILTRE_PATH" >> $config_fcm |
---|
706 | echo "%PHYS phy${physique}" >> $config_fcm |
---|
707 | echo "%DYN_PHYS $DYN_PHYS_PATH" >> $config_fcm |
---|
708 | echo "%DYN_PHYS_SUB $DYN_PHYS_SUB_PATH" >> $config_fcm |
---|
709 | echo "%RRTM $RRTM_PATH" >> $config_fcm |
---|
710 | echo "%ECRAD $ECRAD_PATH" >> $config_fcm |
---|
711 | echo "%DUST $DUST_PATH" >> $config_fcm |
---|
712 | echo "%STRATAER $STRATAER_PATH" >> $config_fcm |
---|
713 | echo "%SISVAT $SISVAT_PATH" >> $config_fcm |
---|
714 | echo "%INLANDSIS $INLANDSIS_PATH" >> $config_fcm |
---|
715 | echo "%COSP $COSP_PATH" >> $config_fcm |
---|
716 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
717 | echo "%EXEC $code" >> $config_fcm |
---|
718 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
---|
719 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
---|
720 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
---|
721 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
---|
722 | echo "%EXT_SRC $EXT_SRC" >> $config_fcm |
---|
723 | |
---|
724 | |
---|
725 | |
---|
726 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
727 | if test -f arch/arch-${arch}.opt && [ $compil_mod = "prod" ] |
---|
728 | then |
---|
729 | ln -s arch/arch-${arch}.opt arch.opt |
---|
730 | else |
---|
731 | ln -s .void_file arch.opt |
---|
732 | fi |
---|
733 | |
---|
734 | rm -f $LIBOGCM/${arch}${SUFF_NAME}/.config/fcm.bld.lock |
---|
735 | ./build_gcm ${fcm_path} -j $job $full |
---|
736 | |
---|
737 | err=$? |
---|
738 | # Check error message from fcm build |
---|
739 | if [ $err != 0 ] ; then |
---|
740 | exit 1 |
---|
741 | fi |
---|
742 | |
---|
743 | rm -rf tmp_src |
---|
744 | rm -rf config |
---|
745 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config config |
---|
746 | ln -s $LIBOGCM/${arch}${SUFF_NAME}/.config/ppsrc tmp_src |
---|
747 | |
---|
748 | |
---|
749 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
750 | then |
---|
751 | # Cleanup: remove dimension.h file |
---|
752 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
753 | fi |
---|