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