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