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