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