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 | |
---|
12 | dim="96x72x19" |
---|
13 | physique=lmd |
---|
14 | filtre=filtrez |
---|
15 | grille=reg |
---|
16 | couple=false |
---|
17 | veget=false |
---|
18 | sisvat=false |
---|
19 | rrtm=false |
---|
20 | dust=false |
---|
21 | strataer=false |
---|
22 | chimie=false |
---|
23 | chemistry=false |
---|
24 | parallel=none |
---|
25 | paramem="par" |
---|
26 | compil_mod=prod |
---|
27 | io=ioipsl |
---|
28 | LIBPREFIX="" |
---|
29 | cosp=false |
---|
30 | bands="" |
---|
31 | scatterers="" |
---|
32 | job=1 |
---|
33 | full='' |
---|
34 | libphy=false |
---|
35 | clean=false |
---|
36 | |
---|
37 | arch_defined="FALSE" |
---|
38 | arch_path="arch" |
---|
39 | arch_default_path="arch" |
---|
40 | |
---|
41 | LMDGCM=`/bin/pwd` |
---|
42 | LIBOGCM=$LMDGCM/libo |
---|
43 | LIBFGCM=$LMDGCM/libf |
---|
44 | DYN_COMMON_PATH=$LIBFGCM/dyn3d_common |
---|
45 | # path for optional packages, but default set to ".void_dir" |
---|
46 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
47 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
48 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
49 | PHY_COMMON_PATH=$LMDGCM/.void_dir |
---|
50 | RRTM_PATH=$LMDGCM/.void_dir |
---|
51 | DUST_PATH=$LMDGCM/.void_dir |
---|
52 | STRATAER_PATH=$LMDGCM/.void_dir |
---|
53 | SISVAT_PATH=$LMDGCM/.void_dir |
---|
54 | COSP_PATH=$LMDGCM/.void_dir |
---|
55 | CHEM_PATH=$LMDGCM/.void_dir |
---|
56 | CLOUD_PATH=$LMDGCM/.void_dir |
---|
57 | MUPHY_PATH=$LMDGCM/.void_dir |
---|
58 | AERONO_PATH=$LMDGCM/.void_dir |
---|
59 | EVOLUTION_PATH=$LMDGCM/.void_dir |
---|
60 | # Path to fcm utility: |
---|
61 | ##fcm_path=$LMDGCM/tools/fcm/bin |
---|
62 | ##fcm_path=/planeto/mturbet/planeto2-mturbet/FCM_V1.2/bin |
---|
63 | fcm_path=$(dirname $(which fcm)) |
---|
64 | |
---|
65 | ######################################################################## |
---|
66 | # Quelques initialisations de variables du shell. |
---|
67 | ######################################################################## |
---|
68 | |
---|
69 | CPP_KEY="" |
---|
70 | INCLUDE_DIR="" |
---|
71 | LIB="" |
---|
72 | adjnt="" |
---|
73 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
74 | PARA_FFLAGS="" |
---|
75 | PARA_LD="" |
---|
76 | EXT_SRC="" |
---|
77 | |
---|
78 | ######################################################################## |
---|
79 | # lecture des options de mymake |
---|
80 | ######################################################################## |
---|
81 | |
---|
82 | # Get the compilation command |
---|
83 | compilation_command="$(basename $0) $@" |
---|
84 | |
---|
85 | # Parse arguments and capture options |
---|
86 | while (($# > 0)) |
---|
87 | do |
---|
88 | case $1 in |
---|
89 | "-h") cat <<fin |
---|
90 | Usage : |
---|
91 | makelmdz_fcm [options] -arch arch_name 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 true/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 | [-libphy] : only compile physics package (no dynamics or main program) |
---|
122 | [-fcm_path path] : path to the fcm tool (default: tools/fcm/bin) |
---|
123 | [-ext_src path] : path to an additional set of routines to compile with the model |
---|
124 | [-arch_path path] : path to architecture files (default: $arch_default_path) |
---|
125 | -arch arch : target architecture |
---|
126 | exec : executable to build |
---|
127 | fin |
---|
128 | exit;; |
---|
129 | |
---|
130 | "-d") |
---|
131 | dim=$2 ; shift ; shift ;; |
---|
132 | |
---|
133 | "-p") |
---|
134 | physique="$2" ; shift ; shift ;; |
---|
135 | |
---|
136 | "-s") |
---|
137 | scatterers=$2 ; shift ; shift ;; |
---|
138 | |
---|
139 | "-b") |
---|
140 | bands=$2 ; shift ; shift ;; |
---|
141 | |
---|
142 | "-g") |
---|
143 | grille="$2" ; shift ; shift ;; |
---|
144 | |
---|
145 | "-c") |
---|
146 | couple="$2" ; shift ; shift ;; |
---|
147 | |
---|
148 | "-prod") |
---|
149 | compil_mod="prod" ; shift ;; |
---|
150 | |
---|
151 | "-dev") |
---|
152 | compil_mod="dev" ; shift ;; |
---|
153 | |
---|
154 | "-debug") |
---|
155 | compil_mod="debug" ; shift ;; |
---|
156 | |
---|
157 | "-io") |
---|
158 | io="$2" ; shift ; shift ;; |
---|
159 | |
---|
160 | "-v") |
---|
161 | veget="$2" ; shift ; shift ;; |
---|
162 | |
---|
163 | "-sisvat") |
---|
164 | sisvat="$2" ; shift ; shift ;; |
---|
165 | |
---|
166 | "-rrtm") |
---|
167 | rrtm="$2" ; shift ; shift ;; |
---|
168 | |
---|
169 | "-dust") |
---|
170 | dust="$2" ; shift ; shift ;; |
---|
171 | |
---|
172 | "-strataer") |
---|
173 | strataer="$2" ; shift ; shift ;; |
---|
174 | |
---|
175 | "-chimie") |
---|
176 | chimie="$2" ; shift ; shift ;; |
---|
177 | |
---|
178 | "-parallel") |
---|
179 | parallel="$2" ; shift ; shift ;; |
---|
180 | |
---|
181 | "-include") |
---|
182 | INCLUDE_DIR="$INCLUDE_DIR -I$2" ; shift ; shift ;; |
---|
183 | |
---|
184 | "-cpp") |
---|
185 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
186 | |
---|
187 | "-adjnt") |
---|
188 | echo "not operational ... work to be done here ";exit 1 |
---|
189 | opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d " |
---|
190 | optim="$optim -Dadj" ; shift ;; |
---|
191 | |
---|
192 | "-cosp") |
---|
193 | cosp="$2" ; shift ; shift ;; |
---|
194 | |
---|
195 | "-mem") |
---|
196 | paramem="mem" ; shift ;; |
---|
197 | |
---|
198 | "-filtre") |
---|
199 | filtre=$2 ; shift ; shift ;; |
---|
200 | |
---|
201 | "-link") |
---|
202 | LIB="$LIB $2" ; shift ; shift ;; |
---|
203 | |
---|
204 | "-fcm_path") |
---|
205 | fcm_path=$2 ; shift ; shift ;; |
---|
206 | |
---|
207 | "-ext_src") |
---|
208 | EXT_SRC=$2 ; shift ; shift ;; |
---|
209 | |
---|
210 | "-j") |
---|
211 | job=$2 ; shift ; shift ;; |
---|
212 | |
---|
213 | "-full") |
---|
214 | full="-full" ; shift ;; |
---|
215 | |
---|
216 | "-libphy") |
---|
217 | libphy="true" ; shift ;; |
---|
218 | |
---|
219 | "-clean") |
---|
220 | clean="true" ; shift ;; |
---|
221 | |
---|
222 | "-arch") |
---|
223 | arch=$2 ; arch_defined="TRUE" ; shift ; shift ;; |
---|
224 | |
---|
225 | "-arch_path") |
---|
226 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
227 | |
---|
228 | *) |
---|
229 | code="$1" ; shift ;; |
---|
230 | esac |
---|
231 | done |
---|
232 | |
---|
233 | ############################################################### |
---|
234 | # path to fcm |
---|
235 | ############################################################### |
---|
236 | # handle case when provided path to fcm was given as a relative |
---|
237 | # path (from makelmdz_fcm script directory) and not an absolute path |
---|
238 | if [[ ${fcm_path:0:1} != "/" ]] ; then |
---|
239 | # prepend with makelmdz_fcm location |
---|
240 | fcm_path=$(cd $(dirname $0) ; pwd)"/"${fcm_path} |
---|
241 | fi |
---|
242 | |
---|
243 | # add fcm_path to PATH |
---|
244 | export PATH=${fcm_path}:${PATH} |
---|
245 | |
---|
246 | echo "Path to fcm:" |
---|
247 | echo ${fcm_path} |
---|
248 | |
---|
249 | ################################# |
---|
250 | # setup arch.env and arch.path # |
---|
251 | ################################# |
---|
252 | rm -f .void_file |
---|
253 | echo > .void_file |
---|
254 | rm -rf .void_dir |
---|
255 | mkdir .void_dir |
---|
256 | |
---|
257 | if [[ "$arch_defined" == "TRUE" ]] |
---|
258 | then |
---|
259 | rm -f arch.path |
---|
260 | rm -f arch.env |
---|
261 | |
---|
262 | if test -f $arch_path/arch-${arch}.path |
---|
263 | then |
---|
264 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
265 | elif test -f $arch_default_path/arch-${arch}.path |
---|
266 | then |
---|
267 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
268 | fi |
---|
269 | |
---|
270 | if test -f $arch_path/arch-${arch}.env |
---|
271 | then |
---|
272 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
273 | elif test -f $arch_default_path/arch-${arch}.env |
---|
274 | then |
---|
275 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
276 | else |
---|
277 | ln -s .void_file arch.env |
---|
278 | fi |
---|
279 | # source architecture PATH and ENV files |
---|
280 | source arch.env |
---|
281 | source arch.path |
---|
282 | else |
---|
283 | echo "You must define a target architecture" |
---|
284 | exit 1 |
---|
285 | fi |
---|
286 | |
---|
287 | ######################################################################## |
---|
288 | # Definition des clefs CPP, des chemins des includes et modules |
---|
289 | # et des libraries |
---|
290 | ######################################################################## |
---|
291 | |
---|
292 | if [[ "$compil_mod" == "prod" ]] |
---|
293 | then |
---|
294 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
295 | elif [[ "$compil_mod" == "dev" ]] |
---|
296 | then |
---|
297 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
298 | elif [[ "$compil_mod" == "debug" ]] |
---|
299 | then |
---|
300 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
301 | fi |
---|
302 | |
---|
303 | phys_root=$physique |
---|
304 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
305 | if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi |
---|
306 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
307 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
308 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
309 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
310 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
311 | |
---|
312 | if [[ "$physique" != "nophys" ]] |
---|
313 | then |
---|
314 | #We'll use some physics |
---|
315 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
316 | if [[ "${phys_root}" == "lmd" ]] |
---|
317 | then |
---|
318 | #For lmd physics, default planet type is Earth |
---|
319 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
320 | fi |
---|
321 | # set physics common utilities path |
---|
322 | PHY_COMMON_PATH="${LIBFGCM}/phy_common" |
---|
323 | # set the dyn/phys interface path |
---|
324 | DYN_PHYS_PATH="${LIBFGCM}/dynphy_lonlat" |
---|
325 | DYN_PHYS_SUB_PATH="${LIBFGCM}/dynphy_lonlat/phy${phys_root}" |
---|
326 | fi |
---|
327 | |
---|
328 | if [[ "$filtre" == "filtrez" ]] |
---|
329 | then |
---|
330 | FILTRE_PATH=${LIBFGCM}/$filtre |
---|
331 | fi |
---|
332 | |
---|
333 | if [[ "$chimie" == "INCA" ]] |
---|
334 | then |
---|
335 | CPP_KEY="$CPP_KEY INCA" |
---|
336 | INCLUDE_DIR="$INCLUDE_DIR -I${INCA_INCDIR}" |
---|
337 | LIB="$LIB -L${INCA_LIBDIR} ${INCA_LIB}" |
---|
338 | fi |
---|
339 | |
---|
340 | if [[ "$couple" != "false" ]] |
---|
341 | then |
---|
342 | if [[ "$couple" == "MPI1" ]] |
---|
343 | then |
---|
344 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
345 | export OASIS_INCDIR=$LMDGCM/../../prism/X64/build/lib/psmile.MPI1 |
---|
346 | export OASIS_LIBDIR=$LMDGCM/../../prism/X64/lib |
---|
347 | INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}" |
---|
348 | LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" |
---|
349 | else |
---|
350 | CPP_KEY="$CPP_KEY CPP_COUPLE CPP_OMCT" |
---|
351 | INCLUDE_DIR="$INCLUDE_DIR -I${OASIS_INCDIR}" |
---|
352 | LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}" |
---|
353 | fi |
---|
354 | fi |
---|
355 | |
---|
356 | if [[ "$parallel" != "none" && \ |
---|
357 | ( "$code" == "newstart" || "$code" == "start2archive" ) ]] |
---|
358 | then |
---|
359 | echo "newstart or start2archive utilities should be run in serial!" |
---|
360 | echo " Compile without -parallel [mpi|omp|mpi_omp] option!" |
---|
361 | exit 1 |
---|
362 | fi |
---|
363 | |
---|
364 | if [[ "$parallel" == "mpi" ]] |
---|
365 | then |
---|
366 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
367 | PARA_FFLAGS="%MPI_FFLAGS" |
---|
368 | PARA_LD="%MPI_LD" |
---|
369 | elif [[ "$parallel" == "omp" ]] |
---|
370 | then |
---|
371 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
372 | PARA_FFLAGS="%OMP_FFLAGS" |
---|
373 | PARA_LD="%OMP_LD" |
---|
374 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
375 | then |
---|
376 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
377 | PARA_FFLAGS="%MPI_FFLAGS %OMP_FFLAGS" |
---|
378 | PARA_LD="%MPI_LD %OMP_LD" |
---|
379 | fi |
---|
380 | |
---|
381 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
382 | && "$compil_mod" == "debug" ]] |
---|
383 | then |
---|
384 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
385 | echo "We suggest switching to \"-dev\"." |
---|
386 | fi |
---|
387 | |
---|
388 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
389 | then |
---|
390 | #NB: option 'true': for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6 |
---|
391 | # For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments |
---|
392 | # 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 |
---|
393 | INCLUDE_DIR="${INCLUDE_DIR} ${ORCHIDEE_INCDIR}" |
---|
394 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
395 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
396 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
397 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
398 | fi |
---|
399 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
400 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
401 | else |
---|
402 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
403 | fi |
---|
404 | LIB="${LIB} -L${ORCHIDEE_LIBDIR} ${ORCHIDEE_LIB}" |
---|
405 | elif [[ "$veget" != "false" ]] ; then |
---|
406 | echo "Option -v $veget does not exist" |
---|
407 | echo "Use ./makelmdz_fcm -h for more information" |
---|
408 | exit 1 |
---|
409 | fi |
---|
410 | |
---|
411 | if [[ "$sisvat" == "true" ]] |
---|
412 | then |
---|
413 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
414 | SISVAT_PATH="$LIBFGCM/%PHYS/sisvat" |
---|
415 | fi |
---|
416 | |
---|
417 | if [[ "$rrtm" == "true" ]] |
---|
418 | then |
---|
419 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
420 | RRTM_PATH="$LIBFGCM/%PHYS/rrtm" |
---|
421 | fi |
---|
422 | |
---|
423 | if [[ "$dust" == "true" ]] |
---|
424 | then |
---|
425 | CPP_KEY="$CPP_KEY CPP_Dust" |
---|
426 | DUST_PATH="$LIBFGCM/%PHYS/Dust" |
---|
427 | fi |
---|
428 | |
---|
429 | if [[ "$strataer" == "true" ]] |
---|
430 | then |
---|
431 | CPP_KEY="$CPP_KEY CPP_StratAer" |
---|
432 | STRATAER_PATH="$LIBFGCM/%PHYS/StratAer" |
---|
433 | fi |
---|
434 | |
---|
435 | if [[ $io == ioipsl ]] |
---|
436 | then |
---|
437 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
438 | INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR}" |
---|
439 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB}" |
---|
440 | elif [[ $io == mix ]] |
---|
441 | then |
---|
442 | # For now, xios implies also using ioipsl |
---|
443 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
444 | INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
445 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
446 | elif [[ $io == xios ]] |
---|
447 | then |
---|
448 | # For now, xios implies also using ioipsl |
---|
449 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
450 | INCLUDE_DIR="$INCLUDE_DIR ${IOIPSL_INCDIR} ${XIOS_INCDIR}" |
---|
451 | LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}" |
---|
452 | fi |
---|
453 | |
---|
454 | if [[ "$cosp" == "true" ]] |
---|
455 | then |
---|
456 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
457 | COSP_PATH="$LIBFGCM/cosp" |
---|
458 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
459 | fi |
---|
460 | |
---|
461 | # for Titan (but could be used by others as well), there is also "chimtitan" |
---|
462 | if [[ -d ${LIBFGCM}/chim${physique} ]] |
---|
463 | then |
---|
464 | CHEM_PATH="${LIBFGCM}/chim${physique}" |
---|
465 | INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/chim${physique}" |
---|
466 | fi |
---|
467 | |
---|
468 | # for Titan add microphysics dependencies |
---|
469 | if [[ -d ${LIBFGCM}/muphy${physique} ]] ; then |
---|
470 | if ! [ `echo $CPP_KEY | grep -c "OLD_COMPILO"` -gt 0 ] ; then |
---|
471 | # add muphy{physique} to the list of files to compile. |
---|
472 | MUPHY_PATH="${LIBFGCM}/muphy${physique}" |
---|
473 | # For Titan as we embbed some libraries with CPP keys, we define them: |
---|
474 | # -DPREC={32|64|80} real kind precision (32: simple, 64: double, 80: extended double) |
---|
475 | # -DHAVE_NC_FTN=1 (mandatory: for support of NetCDF in lintnd). |
---|
476 | CPP_KEY="$CPP_KEY PREC=64 HAVE_NC_FTN=1" |
---|
477 | if [[ "${physique}" == "titan" ]] ; then |
---|
478 | echo "Yaahh you're about to use YAMMS in a GCM..." |
---|
479 | fi |
---|
480 | fi |
---|
481 | fi |
---|
482 | |
---|
483 | # for Venus (but could be used by others as well), there is also "phyvenus/cloudvenus" |
---|
484 | if [[ -d ${LIBFGCM}/phy${physique}/cloud${physique} ]] |
---|
485 | then |
---|
486 | CLOUD_PATH="${LIBFGCM}/phy${physique}/cloud${physique}" |
---|
487 | INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/phy${physique}/cloud${physique}" |
---|
488 | fi |
---|
489 | |
---|
490 | # for Mars (but could be used by others as well), there is also "aeronomars" |
---|
491 | if [[ -d ${LIBFGCM}/aerono${physique} ]] |
---|
492 | then |
---|
493 | AERONO_PATH="${LIBFGCM}/aerono${physique}" |
---|
494 | INCLUDE_DIR="$INCLUDE_DIR -I${LIBFGCM}/aerono${physique}" |
---|
495 | fi |
---|
496 | |
---|
497 | if [[ -d ${LIBFGCM}/evolution && "$code" == "pem" ]] |
---|
498 | then |
---|
499 | if [[ "$physique" == "std" ]] |
---|
500 | then |
---|
501 | CPP_KEY="$CPP_KEY CPP_STD" |
---|
502 | fi |
---|
503 | EVOLUTION_PATH="${LIBFGCM}/evolution" |
---|
504 | INCLUDE="$INCLUDE -I${LIBFGCM}/evolution" |
---|
505 | fi |
---|
506 | |
---|
507 | if [[ -d ${LIBFGCM}/evolution && "$code" == "reshape_XIOS_output" ]] |
---|
508 | then |
---|
509 | if [[ "$physique" == "std" ]] |
---|
510 | then |
---|
511 | CPP_KEY="$CPP_KEY CPP_STD" |
---|
512 | fi |
---|
513 | EVOLUTION_PATH="${LIBFGCM}/evolution" |
---|
514 | INCLUDE="$INCLUDE -I${LIBFGCM}/evolution" |
---|
515 | fi |
---|
516 | |
---|
517 | |
---|
518 | # NETCDF library include/library paths |
---|
519 | INCLUDE_DIR="$INCLUDE_DIR ${NETCDF_INCDIR}" |
---|
520 | LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}" |
---|
521 | |
---|
522 | ######################################################################## |
---|
523 | # calcul du nombre de dimensions |
---|
524 | ######################################################################## |
---|
525 | |
---|
526 | |
---|
527 | dim_full=$dim |
---|
528 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
529 | set $dim |
---|
530 | dimc=$# |
---|
531 | echo calcul de la dimension |
---|
532 | echo dim $dim |
---|
533 | echo dimc $dimc |
---|
534 | |
---|
535 | |
---|
536 | ######################################################################## |
---|
537 | # Gestion des dimensions du modele. |
---|
538 | # on cree ou remplace le fichier des dimensions |
---|
539 | ######################################################################## |
---|
540 | |
---|
541 | cd $LIBFGCM/grid |
---|
542 | if [[ -f dimensions.h ]] |
---|
543 | then |
---|
544 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
545 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
546 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
547 | echo vous pouvez continuer en repondant oui. |
---|
548 | echo "Voulez-vous vraiment continuer?" |
---|
549 | echo "" |
---|
550 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
551 | echo "Wait until the first compilation is finished before launching this one." |
---|
552 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
553 | echo "yes (or 'oui') to the question below to proceed." |
---|
554 | echo "Do you wish to continue?" |
---|
555 | read reponse |
---|
556 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
557 | then |
---|
558 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
559 | else |
---|
560 | exit 1 |
---|
561 | fi |
---|
562 | fi |
---|
563 | |
---|
564 | |
---|
565 | cd $LIBFGCM/grid/dimension |
---|
566 | ./makdim $dim |
---|
567 | if (($? != 0)) |
---|
568 | then |
---|
569 | exit 1 |
---|
570 | fi |
---|
571 | |
---|
572 | cat $LIBFGCM/grid/dimensions.h |
---|
573 | cd $LMDGCM |
---|
574 | |
---|
575 | if [[ "$bands" != "" ]] |
---|
576 | then |
---|
577 | # Generic model, recreate bands.h (IR & VIS bands for radiative transfer) |
---|
578 | makbandsarg=$(echo $bands | sed -e 's/[^0-9]/ /g') |
---|
579 | cd $LIBFGCM/phy$physique/bands |
---|
580 | ./makbands $makbandsarg |
---|
581 | cat $LIBFGCM/phy$physique/bands.h |
---|
582 | cd $LMDGCM |
---|
583 | fi |
---|
584 | |
---|
585 | if [[ "$scatterers" != "" ]] |
---|
586 | then |
---|
587 | if [[ -f $LIBFGCM/phy$physique/scatterers/make_scatterers ]] |
---|
588 | then |
---|
589 | # Generic model, recreate scatterers.h |
---|
590 | cd $LIBFGCM/phy$physique/scatterers |
---|
591 | ./make_scatterers $scatterers |
---|
592 | cat $LIBFGCM/phy$physique/scatterers.h |
---|
593 | cd $LMDGCM |
---|
594 | else |
---|
595 | echo "Error: you should not use the -s # option with -p $physique" |
---|
596 | exit 1 |
---|
597 | fi |
---|
598 | fi |
---|
599 | |
---|
600 | |
---|
601 | ######################################################################## |
---|
602 | # Generation of a Fortran subroutine to track compilation and version |
---|
603 | # details through the executable file |
---|
604 | ######################################################################## |
---|
605 | |
---|
606 | # Path to the root directory where we want to check version control system |
---|
607 | root_dir="$LMDGCM/.." |
---|
608 | |
---|
609 | # Path and name of the generated file |
---|
610 | version_F90file="$LIBFGCM/misc/pgrm_version.F90" |
---|
611 | |
---|
612 | # Path and name of the file containing the compilation and version details |
---|
613 | default_out_file="pgrm_version_details.txt" |
---|
614 | |
---|
615 | # Get the current date |
---|
616 | current_date=$(date) |
---|
617 | |
---|
618 | # Function to process problematic characters |
---|
619 | # - Convert input to UTF-8 and ignore invalid characters |
---|
620 | # - Remove carriage return characters to prevent formatting issues |
---|
621 | # - Escape backslashes and single quotes |
---|
622 | clean_output() { |
---|
623 | iconv -f "$(locale charmap)" -t UTF-8//IGNORE \ |
---|
624 | | tr -d '\r' \ |
---|
625 | | sed 's/\\/\\\\/g; s/'\''/'\'\''/g' |
---|
626 | } |
---|
627 | |
---|
628 | vcs_info="" |
---|
629 | vcs_diff="" |
---|
630 | vcs_stat="" |
---|
631 | # Check if there is a Git repository at the root |
---|
632 | if command -v git > /dev/null 2>&1 && git -C "$root_dir" rev-parse --is-inside-work-tree > /dev/null 2>&1; then |
---|
633 | dir_name="$(basename "$root_dir")" |
---|
634 | vcs_info+="-> Git Information for \"$dir_name\"\n$(git -C "$root_dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s" | clean_output)\n" |
---|
635 | vcs_stat+="-> Git Status for \"$dir_name\"\n$(git -C "$root_dir" status --short | clean_output)\n" |
---|
636 | vcs_diff+="-> Git Diff for \"$dir_name\"\n$(git -C "$root_dir" diff | clean_output)\n" |
---|
637 | else # No so we iterate through each subdirectory to determine version control system |
---|
638 | for dir in "$root_dir"/*; do |
---|
639 | # Skip if it is not a directory or the name contains "git" or "svn" |
---|
640 | [ -d "$dir" ] || continue |
---|
641 | [[ "$dir" == *git* || "$dir" == *svn* ]] && continue |
---|
642 | |
---|
643 | # Determine the version control system for each subdirectory |
---|
644 | dir_name="$(basename "$dir")" |
---|
645 | if command -v svn > /dev/null 2>&1 && svn info "$dir" > /dev/null 2>&1; then # SVN |
---|
646 | vcs_info+="\n-> SVN Information for \"$dir_name\"\n$(svn info "$dir" | clean_output)\n" |
---|
647 | vcs_diff+="\n-> SVN Diff for \"$dir_name\"\n$(svn diff "$dir" | clean_output)\n" |
---|
648 | vcs_stat+="\n-> SVN Status for \"$dir_name\"\n$(svn status "$dir" | clean_output)\n" |
---|
649 | elif command -v git > /dev/null 2>&1 && git -C "$dir" rev-parse --is-inside-work-tree > /dev/null 2>&1; then # Git |
---|
650 | vcs_info+="-> Git Information for \"$dir_name\"\n$(git -C "$dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s" | clean_output)\n" |
---|
651 | vcs_diff+="\n-> Git Diff for \"$dir_name\"\n$(git -C "$dir" diff | clean_output)\n" |
---|
652 | vcs_stat+="\n-> Git Status for \"$dir_name\"\n$(git -C "$dir" status --short | clean_output)\n" |
---|
653 | else # None |
---|
654 | vcs_info+="\n-> No version control system for \"$dir_name\"\n" |
---|
655 | fi |
---|
656 | done |
---|
657 | fi |
---|
658 | |
---|
659 | # Generate the Fortran subroutine |
---|
660 | cat << EOF > "$version_F90file" |
---|
661 | MODULE pgrm_version_mod |
---|
662 | |
---|
663 | !*********************************************************************** |
---|
664 | ! File generated automatically at compilation |
---|
665 | ! |
---|
666 | ! DESCRIPTION: |
---|
667 | ! The subroutine 'print_pgrm_version' prints compilation details, the version |
---|
668 | ! control information (SVN or Git), the status and the diff result if applicable. |
---|
669 | ! |
---|
670 | ! PARAMETERS: |
---|
671 | ! None. |
---|
672 | ! |
---|
673 | ! USAGE: |
---|
674 | ! Use the command-line option "--version [file]" when running your program: |
---|
675 | ! ./myprogram --version [file] |
---|
676 | ! This will write compilation and version details into the specified [file]. |
---|
677 | ! If [file] is omitted, the default name "pgrm_version_details.txt" will be used. |
---|
678 | ! This feature helps track code builds and their exact compilation context |
---|
679 | ! directly from the executable. |
---|
680 | !*********************************************************************** |
---|
681 | |
---|
682 | implicit none |
---|
683 | |
---|
684 | character(*), parameter :: default_out_file = "${default_out_file}" |
---|
685 | |
---|
686 | !======================================================================= |
---|
687 | contains |
---|
688 | !======================================================================= |
---|
689 | |
---|
690 | SUBROUTINE print_pgrm_version(user_out_file) |
---|
691 | |
---|
692 | !---- Arguments |
---|
693 | character(*), optional, intent(in) :: user_out_file |
---|
694 | |
---|
695 | !---- Variables |
---|
696 | integer, parameter :: io_unit = 10 |
---|
697 | character(:), allocatable :: out_file |
---|
698 | |
---|
699 | !---- Code |
---|
700 | if (present(user_out_file)) then |
---|
701 | out_file = trim(adjustl(user_out_file)) |
---|
702 | else |
---|
703 | out_file = trim(adjustl(default_out_file)) |
---|
704 | endif |
---|
705 | |
---|
706 | open(io_unit,file = out_file,status = 'replace',action = 'write') |
---|
707 | |
---|
708 | write(*,*) |
---|
709 | write(*,'(a)') '-> Writing compilation details to the file "'//out_file//'".' |
---|
710 | write(io_unit,'(a)') '========================= COMPILATION DETAILS ==========================' |
---|
711 | write(io_unit,'(a)') '-> Date : ${current_date}' |
---|
712 | write(io_unit,'(a)') '-> Command: ${compilation_command}' |
---|
713 | write(io_unit,*) |
---|
714 | EOF |
---|
715 | |
---|
716 | if [ -n "$vcs_info" ]; then |
---|
717 | echo "write(*,'(a)') '-> Writing information result to the file \"'//out_file//'\".'" >> "$version_F90file" |
---|
718 | echo "write(io_unit,'(a)') '===================== VERSION CONTROL INFORMATION ======================'" >> "$version_F90file" |
---|
719 | while IFS= read -r line; do |
---|
720 | echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file" |
---|
721 | done <<< "$(echo -e "$vcs_info")" |
---|
722 | else |
---|
723 | echo "write(io_unit,'(a)') '====================== NO VERSION CONTROL SYSTEM ======================='" >> "$version_F90file" |
---|
724 | fi |
---|
725 | |
---|
726 | if [ -n "$vcs_stat" ]; then |
---|
727 | echo "write(*,'(a)') '-> Writing status result to the file \"'//out_file//'\".'" >> "$version_F90file" |
---|
728 | echo "write(io_unit,*)" >> "$version_F90file" |
---|
729 | echo "write(io_unit,'(a)') '======================== VERSION CONTROL STATUS ========================'" >> "$version_F90file" |
---|
730 | while IFS= read -r line; do |
---|
731 | echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file" |
---|
732 | done <<< "$(echo -e "$vcs_stat")" |
---|
733 | fi |
---|
734 | |
---|
735 | if [ -n "$vcs_diff" ]; then |
---|
736 | echo "write(*,'(a)') '-> Writing diff result to the file \"'//out_file//'\".'" >> "$version_F90file" |
---|
737 | echo "write(io_unit,*)" >> "$version_F90file" |
---|
738 | echo "write(io_unit,'(a)') '========================= VERSION CONTROL DIFF ========================='" >> "$version_F90file" |
---|
739 | while IFS= read -r line; do |
---|
740 | echo "write(io_unit,'(a)') '${line}'" >> "$version_F90file" |
---|
741 | done <<< "$(echo -e "$vcs_diff")" |
---|
742 | fi |
---|
743 | |
---|
744 | cat << EOF >> "$version_F90file" |
---|
745 | write(io_unit,'(a)') '========================================================================' |
---|
746 | write(*,*) |
---|
747 | |
---|
748 | close(io_unit) |
---|
749 | |
---|
750 | END SUBROUTINE print_pgrm_version |
---|
751 | |
---|
752 | END MODULE pgrm_version_mod |
---|
753 | EOF |
---|
754 | |
---|
755 | # Termination message |
---|
756 | echo "'$version_F90file' has been generated successfully." |
---|
757 | |
---|
758 | |
---|
759 | ######################################################################## |
---|
760 | # Differentes dynamiques (3d, 2d, 1d) |
---|
761 | ######################################################################## |
---|
762 | |
---|
763 | dimension=`echo $dim | wc -w` |
---|
764 | echo dimension $dimension |
---|
765 | |
---|
766 | if (( $dimension == 3 )) |
---|
767 | then |
---|
768 | cd $LIBFGCM/grid |
---|
769 | \rm fxyprim.h |
---|
770 | cp -p fxy_${grille}.h fxyprim.h |
---|
771 | #else |
---|
772 | # echo "Probleme dans les dimensions de la dynamique !!" |
---|
773 | # echo "Non reactive pour l'instant !!!" |
---|
774 | fi |
---|
775 | |
---|
776 | if (( $dimension == 1 )) |
---|
777 | then |
---|
778 | ## Sanity check: 1D models should be used in serial |
---|
779 | ## unless compiled with xios and then it should be in mpi only |
---|
780 | if [[ $io == xios ]] |
---|
781 | then |
---|
782 | echo "OK io xios" |
---|
783 | if [[ $parallel != "mpi" ]] |
---|
784 | then |
---|
785 | echo "Error: a 1D model compiled with xios should also be compiled with " |
---|
786 | echo " -parallel mpi option!" |
---|
787 | exit 1 |
---|
788 | fi |
---|
789 | else |
---|
790 | # no xios, check that it is in serial only |
---|
791 | if [[ $parallel != "none" ]] |
---|
792 | then |
---|
793 | echo "Error: a 1D model should not be compiled with " |
---|
794 | echo " -parallel [mpi|omp|mpi_omp] option!" |
---|
795 | exit 1 |
---|
796 | fi |
---|
797 | fi # of if [[ $io == "xios" ]] |
---|
798 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
799 | ##in 1D, add dyn3d to include path (because main prog is in physics) |
---|
800 | INCLUDE_DIR="$INCLUDE_DIR -Ilibf/dyn3d -Ilibf/dyn3d_common" |
---|
801 | ## no filtre in 1d: |
---|
802 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
803 | ## no need to compile all routines in dyn3d_common either: |
---|
804 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
805 | ## no need to compile all routines in dynlmdz_phy... ; |
---|
806 | ## (because key ones are included in 1D main program) |
---|
807 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
808 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
809 | fi |
---|
810 | |
---|
811 | ###################################################################### |
---|
812 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
813 | # ---> YM desactive pour le traitemement en parallele |
---|
814 | ###################################################################### |
---|
815 | |
---|
816 | #if [[ -f $libf/phy$physique/raddim.h ]] |
---|
817 | #then |
---|
818 | # if [[ -f $libf/phy$physique/raddim.$dimh.h ]] |
---|
819 | #then |
---|
820 | # \rm -f $libf/phy$physique/raddim.h |
---|
821 | # cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
822 | # echo $libf/phy$physique/raddim.$dimh.h |
---|
823 | # cat $libf/phy$physique/raddim.h |
---|
824 | # else |
---|
825 | # echo On peut diminuer la taille de l executable en creant |
---|
826 | # echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
827 | # \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
828 | # fi |
---|
829 | #fi |
---|
830 | |
---|
831 | ###################################################################### |
---|
832 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
833 | ###################################################################### |
---|
834 | |
---|
835 | if (( `expr $dimc \> 2` == 1 )) |
---|
836 | then |
---|
837 | filtre="FILTRE=$filtre" |
---|
838 | else |
---|
839 | filtre="FILTRE= L_FILTRE= " |
---|
840 | fi |
---|
841 | echo MACRO FILTRE $filtre |
---|
842 | |
---|
843 | echo $dimc |
---|
844 | |
---|
845 | |
---|
846 | |
---|
847 | ###################################################################### |
---|
848 | # Creation du suffixe de la configuration |
---|
849 | ###################################################################### |
---|
850 | |
---|
851 | if [[ $libphy != "true" ]];then |
---|
852 | SUFF_NAME=_${dim_full} |
---|
853 | fi |
---|
854 | SUFF_NAME=${SUFF_NAME}_phy${physique} |
---|
855 | |
---|
856 | if [[ "$bands" != "" ]] |
---|
857 | then |
---|
858 | #if bands option -b VISxIR is used, add "_bVISxIR" to executable name |
---|
859 | SUFF_NAME=${SUFF_NAME}_b$bands |
---|
860 | fi |
---|
861 | |
---|
862 | if [[ "$parallel" != "none" ]] |
---|
863 | then |
---|
864 | SUFF_NAME=${SUFF_NAME}_para |
---|
865 | if (( $dimension == 1 )) |
---|
866 | then |
---|
867 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
868 | DYN=phy${physique}/dyn1d |
---|
869 | else |
---|
870 | DYN=dyn${dimc}d${paramem} |
---|
871 | fi |
---|
872 | if [[ "$paramem" == "mem" ]] |
---|
873 | then |
---|
874 | SUFF_NAME=${SUFF_NAME}_${paramem} |
---|
875 | fi |
---|
876 | else |
---|
877 | SUFF_NAME=${SUFF_NAME}_seq |
---|
878 | if (( $dimension == 1 )) |
---|
879 | then |
---|
880 | # dynamics-related routines in"dyn1d" subdirectory of phy${physique} |
---|
881 | DYN=phy${physique}/dyn1d |
---|
882 | else |
---|
883 | DYN=dyn${dimc}d |
---|
884 | fi |
---|
885 | fi |
---|
886 | |
---|
887 | if [[ $veget != "false" ]] |
---|
888 | then |
---|
889 | SUFF_NAME=${SUFF_NAME}_orch |
---|
890 | fi |
---|
891 | |
---|
892 | if [[ $couple != "false" ]] |
---|
893 | then |
---|
894 | SUFF_NAME=${SUFF_NAME}_couple |
---|
895 | fi |
---|
896 | |
---|
897 | if [[ $chimie == "INCA" ]] |
---|
898 | then |
---|
899 | SUFF_NAME=${SUFF_NAME}_inca |
---|
900 | fi |
---|
901 | SUFF_DEBUG= |
---|
902 | if [[ "$compil_mod" == "debug" ]] |
---|
903 | then |
---|
904 | SUFF_DEBUG=_debug |
---|
905 | fi |
---|
906 | SUFF_DIR=${SUFF_NAME}${SUFF_DEBUG} |
---|
907 | |
---|
908 | if [[ $libphy == "true" ]] |
---|
909 | then |
---|
910 | # special case where we compile only the physics |
---|
911 | DYN=$LMDGCM/.void_dir |
---|
912 | DYN_COMMON_PATH=$LMDGCM/.void_dir |
---|
913 | FILTRE_PATH=$LMDGCM/.void_dir |
---|
914 | DYN_PHYS_PATH=$LMDGCM/.void_dir |
---|
915 | DYN_PHYS_SUB_PATH=$LMDGCM/.void_dir |
---|
916 | #and there is no main program to generate |
---|
917 | code="" |
---|
918 | SUFF_NAME="" |
---|
919 | # SUFF_DIR= |
---|
920 | else |
---|
921 | SUFF_NAME=${SUFF_NAME}.e |
---|
922 | fi |
---|
923 | |
---|
924 | cd $LMDGCM |
---|
925 | config_fcm="config.fcm" |
---|
926 | rm -f $config_fcm |
---|
927 | touch $config_fcm |
---|
928 | |
---|
929 | echo "%ARCH $arch" >> $config_fcm |
---|
930 | echo "%INCDIR $INCLUDE_DIR" >> $config_fcm |
---|
931 | echo "%LIB $LIB" >> $config_fcm |
---|
932 | echo "%ROOT_PATH $PWD" >> $config_fcm |
---|
933 | echo "%LIBF $LIBFGCM" >> $config_fcm |
---|
934 | echo "%LIBO $LIBOGCM" >> $config_fcm |
---|
935 | echo "%DYN $DYN" >> $config_fcm |
---|
936 | echo "%DYN_COMMON $DYN_COMMON_PATH" >> $config_fcm |
---|
937 | echo "%PHY_COMMON $PHY_COMMON_PATH" >> $config_fcm |
---|
938 | echo "%FILTRE $FILTRE_PATH" >> $config_fcm |
---|
939 | echo "%PHYS phy${physique}" >> $config_fcm |
---|
940 | echo "%DYN_PHYS $DYN_PHYS_PATH" >> $config_fcm |
---|
941 | echo "%DYN_PHYS_SUB $DYN_PHYS_SUB_PATH" >> $config_fcm |
---|
942 | echo "%RRTM $RRTM_PATH" >> $config_fcm |
---|
943 | echo "%DUST $DUST_PATH" >> $config_fcm |
---|
944 | echo "%STRATAER $STRATAER_PATH" >> $config_fcm |
---|
945 | echo "%SISVAT $SISVAT_PATH" >> $config_fcm |
---|
946 | echo "%COSP $COSP_PATH" >> $config_fcm |
---|
947 | echo "%CHEM $CHEM_PATH" >> $config_fcm |
---|
948 | echo "%CLOUD $CLOUD_PATH" >> $config_fcm |
---|
949 | echo "%MUPHY $MUPHY_PATH" >> $config_fcm |
---|
950 | echo "%AERONO $AERONO_PATH" >> $config_fcm |
---|
951 | echo "%EVOLUTION $EVOLUTION_PATH" >> $config_fcm |
---|
952 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
953 | echo "%EXEC $code" >> $config_fcm |
---|
954 | echo "%SUFF_NAME $SUFF_NAME" >> $config_fcm |
---|
955 | echo "%SUFF_DIR $SUFF_DIR" >> $config_fcm |
---|
956 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> $config_fcm |
---|
957 | echo "%PARA_FFLAGS $PARA_FFLAGS" >> $config_fcm |
---|
958 | echo "%PARA_LD $PARA_LD" >> $config_fcm |
---|
959 | echo "%EXT_SRC $EXT_SRC" >> $config_fcm |
---|
960 | |
---|
961 | # setup arch.fcm and arch.opt |
---|
962 | rm -f arch.fcm |
---|
963 | rm -f arch.opt |
---|
964 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
965 | if test -f arch/arch-${arch}.opt && [ $compil_mod = "prod" ] |
---|
966 | then |
---|
967 | ln -s arch/arch-${arch}.opt arch.opt |
---|
968 | else |
---|
969 | ln -s .void_file arch.opt |
---|
970 | fi |
---|
971 | |
---|
972 | # cleanup before compiling |
---|
973 | if [[ $libphy != "true" ]]; then |
---|
974 | rm -f bin/${code}${SUFF_NAME} |
---|
975 | fi |
---|
976 | rm -f $LIBOGCM/${arch}${SUFF_DIR}/.config/fcm.bld.lock |
---|
977 | |
---|
978 | function delete_dim_h { |
---|
979 | if [[ -r $LIBFGCM/grid/dimensions.h ]];then |
---|
980 | echo "Removing dimensions.h" |
---|
981 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
982 | fi |
---|
983 | } |
---|
984 | |
---|
985 | if [[ $clean == "true" ]];then |
---|
986 | echo "-- Cleaning up folder $LIBOGCM/${arch}${SUFF_DIR} --" |
---|
987 | delete_dim_h |
---|
988 | rm -rf tmp_src |
---|
989 | rm -rf config |
---|
990 | rm -rf $LIBOGCM/${arch}${SUFF_DIR} |
---|
991 | exit 0 |
---|
992 | fi |
---|
993 | |
---|
994 | ./build_gcm ${fcm_path} -j $job $full || (echo "Build gcm failed."; delete_dim_h; exit 1) |
---|
995 | |
---|
996 | rm -rf tmp_src |
---|
997 | rm -rf config |
---|
998 | ln -s $LIBOGCM/${arch}${SUFF_DIR}/.config config |
---|
999 | ln -s $LIBOGCM/${arch}${SUFF_DIR}/.config/ppsrc tmp_src |
---|
1000 | |
---|
1001 | delete_dim_h |
---|