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