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