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