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