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