1 | #!/bin/bash |
---|
2 | # |
---|
3 | # $Id$ |
---|
4 | # |
---|
5 | # |
---|
6 | ######################################################################## |
---|
7 | # for debug, uncomment line below |
---|
8 | #set -xv |
---|
9 | ######################################################################## |
---|
10 | # options par defaut pour la commande make |
---|
11 | ######################################################################## |
---|
12 | dim="96x72x19" |
---|
13 | physique=lmd |
---|
14 | code=gcm |
---|
15 | filtre=filtrez |
---|
16 | grille=reg |
---|
17 | couple=false |
---|
18 | veget=false |
---|
19 | chimie=false |
---|
20 | parallel=none |
---|
21 | paramem="par" |
---|
22 | compil_mod=prod |
---|
23 | io=ioipsl |
---|
24 | LIBPREFIX="" |
---|
25 | fcm_path=none |
---|
26 | cosp=false |
---|
27 | sisvat=false |
---|
28 | rrtm=false |
---|
29 | full="" |
---|
30 | |
---|
31 | # guess a default 'arch' |
---|
32 | arch="local" # start with assuming we're on a local machine with local arch file |
---|
33 | ## try to recognise machine and infer arch from it |
---|
34 | machine=`hostname` |
---|
35 | if [[ "${machine:0:3}" == "ada" ]] |
---|
36 | then |
---|
37 | arch="X64_ADA" |
---|
38 | fi |
---|
39 | if [[ "${machine:0:7}" == "platine" ]] |
---|
40 | then |
---|
41 | arch="IA64_PLATINE" |
---|
42 | fi |
---|
43 | if [[ "${machine:0:6}" == "titane" ]] |
---|
44 | then |
---|
45 | arch="X64_TITANE" |
---|
46 | fi |
---|
47 | if [[ "${machine:0:8}" == "mercure1" ]] |
---|
48 | then |
---|
49 | arch="SX8_MERCURE" |
---|
50 | fi |
---|
51 | if [[ "${machine:0:8}" == "mercure2" ]] |
---|
52 | then |
---|
53 | arch="SX9_MERCURE" |
---|
54 | fi |
---|
55 | |
---|
56 | LMDGCM=`pwd -P` |
---|
57 | LIBFGCM=$LMDGCM/libf |
---|
58 | LIBOGCM=$LMDGCM/libo |
---|
59 | if [[ ! -d $LIBOGCM ]] |
---|
60 | then |
---|
61 | # create the directory |
---|
62 | mkdir $LIBOGCM |
---|
63 | if [[ ! $? ]] |
---|
64 | then |
---|
65 | echo "Failed to create directory $LIBOGCM" |
---|
66 | exit |
---|
67 | fi |
---|
68 | fi |
---|
69 | COSP_PATH=$LMDGCM/.void_dir |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | localdir=`pwd -P` |
---|
74 | ######################################################################## |
---|
75 | # Quelques initialisations de variables du shell. |
---|
76 | ######################################################################## |
---|
77 | |
---|
78 | CPP_KEY="" |
---|
79 | INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. ' |
---|
80 | LIB="" |
---|
81 | adjnt="" |
---|
82 | ##COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
83 | PARA_FFLAGS="" |
---|
84 | PARA_LD="" |
---|
85 | EXT_SRC="" |
---|
86 | #src_dirs: directories containing source files |
---|
87 | src_dirs="grid misc" |
---|
88 | ######################################################################## |
---|
89 | # lecture des options |
---|
90 | ######################################################################## |
---|
91 | |
---|
92 | while (($# > 0)) |
---|
93 | do |
---|
94 | case $1 in |
---|
95 | "-h") cat <<fin |
---|
96 | Usage : |
---|
97 | makelmdz [options] -arch nom_arch exec |
---|
98 | [-h] : brief help |
---|
99 | [-d [[IMx]JMx]LM] : IM, JM, LM are the dimensions in x, y, z (default: $dim) |
---|
100 | [-p PHYS] : set of physical parametrizations (in libf/phyPHYS), (default: lmd) |
---|
101 | [-prod / -dev / -debug] : compilation mode production (default) / developement / debug |
---|
102 | [-c false/MPI1/MPI2] : coupling with ocean model : MPI1/MPI2/false (default: false) |
---|
103 | [-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false) |
---|
104 | false : no vegetation model |
---|
105 | orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version) |
---|
106 | orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6 |
---|
107 | true : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6 |
---|
108 | [-chimie INCA/false] : with INCA chemistry model or without (default: false) |
---|
109 | [-cosp true/false] : compile with/without cosp package (default: false) |
---|
110 | [-sisvat true/false] : compile with/without sisvat package (default: false) |
---|
111 | [-rrtm true/false] : compile with/without rrtm package (default: false) |
---|
112 | [-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp |
---|
113 | [-g GRI] : grid configuration in dyn3d/GRI_xy.h (default: reg, inclues a zoom) |
---|
114 | [-io ioipsl/mix/xios] : Input/Output library (default: ioipsl) |
---|
115 | [-include INCLUDES] : extra include path to add |
---|
116 | [-cpp CPP_KEY] : additional preprocessing definitions |
---|
117 | [-adjnt] : adjoint model, not operational ... |
---|
118 | [-mem] : reduced memory dynamics (if in parallel mode) |
---|
119 | [-filtre NOMFILTRE] : use filtre from libf/NOMFILTRE (default: filtrez) |
---|
120 | [-full] : Full (re)compilation (from scratch) |
---|
121 | [-link LINKS] : additional links with other libraries |
---|
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 nom_arch : target architecture |
---|
125 | exec : executable to build |
---|
126 | fin |
---|
127 | exit;; |
---|
128 | "-d") |
---|
129 | dim=$2 ; shift ; shift ;; |
---|
130 | |
---|
131 | "-p") |
---|
132 | physique="$2" ; shift ; shift ;; |
---|
133 | |
---|
134 | "-g") |
---|
135 | grille="$2" ; shift ; shift ;; |
---|
136 | |
---|
137 | "-c") |
---|
138 | couple="$2" ; shift ; shift ;; |
---|
139 | |
---|
140 | "-prod") |
---|
141 | compil_mod="prod" ; shift ;; |
---|
142 | |
---|
143 | "-dev") |
---|
144 | compil_mod="dev" ; shift ;; |
---|
145 | |
---|
146 | "-debug") |
---|
147 | compil_mod="debug" ; shift ;; |
---|
148 | |
---|
149 | "-io") |
---|
150 | io="$2" ; shift ; shift ;; |
---|
151 | |
---|
152 | "-v") |
---|
153 | veget="$2" ; shift ; shift ;; |
---|
154 | |
---|
155 | "-chimie") |
---|
156 | chimie="$2" ; shift ; shift ;; |
---|
157 | |
---|
158 | "-parallel") |
---|
159 | parallel="$2" ; shift ; shift ;; |
---|
160 | |
---|
161 | "-include") |
---|
162 | INCLUDE="$INCLUDE -I$2" ; shift ; shift ;; |
---|
163 | |
---|
164 | "-cpp") |
---|
165 | CPP_KEY="$CPP_KEY $2" ; shift ; shift ;; |
---|
166 | |
---|
167 | "-cosp") |
---|
168 | cosp="$2" ; shift ; shift ;; |
---|
169 | |
---|
170 | "-sisvat") |
---|
171 | sisvat="$2" ; shift ; shift ;; |
---|
172 | |
---|
173 | "-rrtm") |
---|
174 | rrtm="$2" ; shift ; shift ;; |
---|
175 | |
---|
176 | "-mem") |
---|
177 | paramem="mem" ; shift ;; |
---|
178 | |
---|
179 | "-filtre") |
---|
180 | filtre=$2 ; shift ; shift ;; |
---|
181 | |
---|
182 | "-full") |
---|
183 | full="full" ; shift ;; |
---|
184 | |
---|
185 | "-link") |
---|
186 | LIB="$LIB $2" ; shift ; shift ;; |
---|
187 | |
---|
188 | "-fcm_path") |
---|
189 | fcm_path=$2 ; shift ; shift ;; |
---|
190 | |
---|
191 | "-ext_src") |
---|
192 | EXT_SRC=$2 ; src_dirs="$src_dirs $EXT_SRC" ; shift ; shift ;; |
---|
193 | |
---|
194 | "-arch") |
---|
195 | arch=$2 ; shift ; shift ;; |
---|
196 | |
---|
197 | *) |
---|
198 | code="$1" ; shift ;; |
---|
199 | esac |
---|
200 | done |
---|
201 | |
---|
202 | ############################################################### |
---|
203 | # lecture des chemins propres \`a l'architecture de la machine # |
---|
204 | ############################################################### |
---|
205 | rm -f .void_file |
---|
206 | echo > .void_file |
---|
207 | rm -rf .void_dir |
---|
208 | mkdir .void_dir |
---|
209 | rm -f arch.path |
---|
210 | if [[ -r arch/arch-${arch}.path ]] |
---|
211 | then |
---|
212 | ln -s arch/arch-${arch}.path ./arch.path |
---|
213 | source arch.path |
---|
214 | else |
---|
215 | echo "Error: missing arch/arch-${arch}.path file !" |
---|
216 | exit |
---|
217 | fi |
---|
218 | rm -f arch.fcm |
---|
219 | if [[ -r arch/arch-${arch}.fcm ]] |
---|
220 | then |
---|
221 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
222 | else |
---|
223 | echo "Error: missing arch/arch-${arch}.fcm file !" |
---|
224 | exit |
---|
225 | fi |
---|
226 | ######################################################################## |
---|
227 | # Definition des clefs CPP, des chemins des includes et modules |
---|
228 | # et des libraries |
---|
229 | ######################################################################## |
---|
230 | |
---|
231 | # basic compile flags from arch.fcm file |
---|
232 | archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm ) |
---|
233 | COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} ) |
---|
234 | |
---|
235 | # other compile flags, depending on compilation mode |
---|
236 | if [[ "$compil_mod" == "prod" ]] |
---|
237 | then |
---|
238 | ## read COMPIL_FFLAGS from arch.fcm file |
---|
239 | archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm ) |
---|
240 | archfileopt=$( echo ${archfileline##%PROD_FFLAGS} ) |
---|
241 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
242 | elif [[ "$compil_mod" == "dev" ]] |
---|
243 | then |
---|
244 | ## read %DEV_FFLAGS from arch.fcm file |
---|
245 | archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm ) |
---|
246 | archfileopt=$( echo ${archfileline##%DEV_FFLAGS} ) |
---|
247 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
248 | elif [[ "$compil_mod" == "debug" ]] |
---|
249 | then |
---|
250 | ## read %DEBUG_FFLAGS from arch.fcm file |
---|
251 | archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm ) |
---|
252 | archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} ) |
---|
253 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}" |
---|
254 | fi |
---|
255 | |
---|
256 | # add CPP_KEY defined in arch.fcm file |
---|
257 | archfileline=$( grep -i '^%FPP_DEF' arch.fcm ) |
---|
258 | archfileopt=$( echo ${archfileline##%FPP_DEF} ) |
---|
259 | CPP_KEY="$CPP_KEY ${archfileopt}" |
---|
260 | |
---|
261 | # get compiler name from arch.fcm file |
---|
262 | archfileline=$( grep -i '^%COMPILER' arch.fcm ) |
---|
263 | fcompiler=$( echo ${archfileline##%COMPILER} ) |
---|
264 | |
---|
265 | # get linker name from arch.fcm file |
---|
266 | archfileline=$( grep -i '^%LINK' arch.fcm ) |
---|
267 | linker=$( echo ${archfileline##%LINK} ) |
---|
268 | |
---|
269 | # get ar command from arch.fcm file |
---|
270 | archfileline=$( grep -i '^%AR' arch.fcm ) |
---|
271 | arcommand=$( echo ${archfileline##%AR} ) |
---|
272 | |
---|
273 | # get make utility from arch.fcm file |
---|
274 | archfileline=$( grep -i '^%MAKE' arch.fcm ) |
---|
275 | makecommand=$( echo ${archfileline##%MAKE} ) |
---|
276 | |
---|
277 | # get basic libraries to link with arch.fcm file |
---|
278 | archfileline=$( grep -i '^%BASE_LD' arch.fcm ) |
---|
279 | archfileopt=$( echo ${archfileline##%BASE_LD} ) |
---|
280 | LIB="$LIB ${archfileopt}" |
---|
281 | |
---|
282 | # add Include files defined in arch.fcm file for pre-processing |
---|
283 | archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm ) |
---|
284 | for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done |
---|
285 | |
---|
286 | phys_root=$physique |
---|
287 | if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi |
---|
288 | if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi |
---|
289 | if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi |
---|
290 | if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi |
---|
291 | if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi |
---|
292 | if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi |
---|
293 | if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi |
---|
294 | |
---|
295 | if [[ "$physique" != "nophys" ]] |
---|
296 | then |
---|
297 | #We'll use some physics |
---|
298 | src_dirs="$src_dirs phy_common phy$physique" |
---|
299 | LIBPHY='$(LIBO)/libphy'"$physique"'.a' |
---|
300 | LIBPHY_COMMON='$(LIBO)/libphy_common.a' |
---|
301 | lib_phy='-lphy'"$physique"' -lphy_common' |
---|
302 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
303 | if [[ $phys_root == "lmd" ]] |
---|
304 | then |
---|
305 | #For lmd physics, default planet type is Earth |
---|
306 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
307 | fi |
---|
308 | fi |
---|
309 | |
---|
310 | if [[ "$chimie" == "INCA" ]] |
---|
311 | then |
---|
312 | CPP_KEY="$CPP_KEY INCA" |
---|
313 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
314 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
315 | libchimie=" -L${INCA_LIBDIR} -lchimie" |
---|
316 | fi |
---|
317 | |
---|
318 | if [[ "$couple" != "false" ]] |
---|
319 | then |
---|
320 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
321 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
322 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
323 | fi |
---|
324 | |
---|
325 | if [[ "$parallel" == "none" ]] |
---|
326 | then |
---|
327 | FLAG_PARA='' |
---|
328 | else |
---|
329 | FLAG_PARA="$paramem" |
---|
330 | if [[ $paramem == par ]] |
---|
331 | then |
---|
332 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
333 | echo "You should use option \"-mem\"." |
---|
334 | exit 1 |
---|
335 | fi |
---|
336 | fi |
---|
337 | |
---|
338 | if [[ "$parallel" == "mpi" ]] |
---|
339 | then |
---|
340 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
341 | # MPI additional compilation options |
---|
342 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
343 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
344 | # MPI additional links |
---|
345 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
346 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
347 | elif [[ "$parallel" == "omp" ]] |
---|
348 | then |
---|
349 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
350 | # OMP additional compilation options |
---|
351 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
352 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
353 | # OMP additional links |
---|
354 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
355 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
356 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
357 | then |
---|
358 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
359 | # MPI additional compilation options |
---|
360 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
361 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
362 | # OMP additional compilation options |
---|
363 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
364 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
365 | # MPI additional links |
---|
366 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
367 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
368 | # OMP additional links |
---|
369 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
370 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
371 | fi |
---|
372 | |
---|
373 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
374 | && "$compil_mod" == "debug" ]] |
---|
375 | then |
---|
376 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
377 | echo "We suggest switching to \"-dev\"." |
---|
378 | fi |
---|
379 | |
---|
380 | |
---|
381 | #============================================================================== |
---|
382 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
383 | then |
---|
384 | |
---|
385 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
386 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
387 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
388 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
389 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
390 | fi |
---|
391 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
392 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
393 | else |
---|
394 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
395 | fi |
---|
396 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
397 | for lib in ${orch_libs} ; do |
---|
398 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
399 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
400 | fi |
---|
401 | done |
---|
402 | elif [[ "$veget" != "false" ]] ; then |
---|
403 | echo "Option -v $veget does not exist" |
---|
404 | echo "Use ./makelmdz -h for more information" |
---|
405 | exit |
---|
406 | fi |
---|
407 | |
---|
408 | #=============================================================================== |
---|
409 | if [[ $io == ioipsl ]] |
---|
410 | then |
---|
411 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
412 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
413 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
414 | elif [[ $io == mix ]] |
---|
415 | then |
---|
416 | # For now, xios implies also using ioipsl |
---|
417 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
418 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
419 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
420 | elif [[ $io == xios ]] |
---|
421 | then |
---|
422 | # For now, xios implies also using ioipsl |
---|
423 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
424 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
425 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
426 | fi |
---|
427 | |
---|
428 | if [[ "$cosp" == "true" ]] |
---|
429 | then |
---|
430 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
431 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
432 | src_dirs="$src_dirs cosp" |
---|
433 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
434 | opt_dep="$opt_dep cosp" |
---|
435 | lcosp="-l${LIBPREFIX}cosp" |
---|
436 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
437 | fi |
---|
438 | |
---|
439 | if [[ "$sisvat" == "true" ]] |
---|
440 | then |
---|
441 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
442 | src_dirs="$src_dirs phy${physique}/sisvat" |
---|
443 | fi |
---|
444 | |
---|
445 | if [[ "$rrtm" == "true" ]] |
---|
446 | then |
---|
447 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
448 | src_dirs="$src_dirs phy${physique}/rrtm" |
---|
449 | fi |
---|
450 | |
---|
451 | |
---|
452 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
453 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
454 | |
---|
455 | ######################################################################## |
---|
456 | # calcul du nombre de dimensions |
---|
457 | ######################################################################## |
---|
458 | |
---|
459 | |
---|
460 | dim_full=$dim |
---|
461 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
462 | set $dim |
---|
463 | dimc=$# |
---|
464 | echo calcul de la dimension |
---|
465 | echo dim $dim |
---|
466 | echo dimc $dimc |
---|
467 | |
---|
468 | ######################################################################## |
---|
469 | # Gestion des dimensions du modele. |
---|
470 | # on cree ou remplace le fichier des dimensions |
---|
471 | ######################################################################## |
---|
472 | |
---|
473 | cd $LIBFGCM/grid |
---|
474 | if [[ -f dimensions.h ]] |
---|
475 | then |
---|
476 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
477 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
478 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
479 | echo vous pouvez continuer en repondant oui. |
---|
480 | echo "Voulez-vous vraiment continuer?" |
---|
481 | echo "" |
---|
482 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
483 | echo "Wait until the first compilation is finished before launching this one." |
---|
484 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
485 | echo "yes (or 'oui') to the question below to proceed." |
---|
486 | echo "Do you wish to continue?" |
---|
487 | read reponse |
---|
488 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
489 | then |
---|
490 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
491 | else |
---|
492 | exit |
---|
493 | fi |
---|
494 | fi |
---|
495 | |
---|
496 | cd $LIBFGCM/grid/dimension |
---|
497 | ./makdim $dim |
---|
498 | if (($? != 0)) |
---|
499 | then |
---|
500 | exit 1 |
---|
501 | fi |
---|
502 | |
---|
503 | cat $LIBFGCM/grid/dimensions.h |
---|
504 | cd $LMDGCM |
---|
505 | |
---|
506 | ######################################################################## |
---|
507 | # Differentes dynamiques (3d, 2d, 1d) |
---|
508 | ######################################################################## |
---|
509 | |
---|
510 | if (( $dimc == 3 )) ; then |
---|
511 | src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}" |
---|
512 | if [[ $physique != "nophys" ]] ; then |
---|
513 | src_dirs="$src_dirs dynphy_lonlat dynphy_lonlat/phy${phys_root}" |
---|
514 | libdyn_phy="-ldynphy_lonlat" |
---|
515 | LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a' |
---|
516 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat' |
---|
517 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat/'"phy${phys_root}" |
---|
518 | fi |
---|
519 | cd $LIBFGCM/grid |
---|
520 | \rm fxyprim.h |
---|
521 | cp -p fxy_${grille}.h fxyprim.h |
---|
522 | filtre="FILTRE=$filtre" |
---|
523 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common ' |
---|
524 | elif (( $dimc == 2 )) ; then |
---|
525 | src_dirs="$src_dirs dyn2d" |
---|
526 | filtre="FILTRE= L_FILTRE= " |
---|
527 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
528 | elif (( $dimc == 1 )) ; then |
---|
529 | #src_dirs="$src_dirs dyn3d dyn3d_common filtrez" |
---|
530 | src_dirs="$src_dirs phy${physique}/dyn1d" |
---|
531 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
532 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= " |
---|
533 | #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre |
---|
534 | INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d' |
---|
535 | else |
---|
536 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
537 | fi |
---|
538 | |
---|
539 | cd $LMDGCM |
---|
540 | |
---|
541 | ######################################################################## |
---|
542 | # library directory name: |
---|
543 | ######################################################################## |
---|
544 | |
---|
545 | nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'` |
---|
546 | echo "Path to library: "$nomlib |
---|
547 | |
---|
548 | ######################################################################## |
---|
549 | # Cleanup for a full recompilation, if requested |
---|
550 | ######################################################################## |
---|
551 | |
---|
552 | if [[ $full == "full" ]] |
---|
553 | then |
---|
554 | # remove makefile and librairies |
---|
555 | echo "-full option: recompiling from scratch" |
---|
556 | \rm -f makefile |
---|
557 | \rm -rf "${LIBOGCM}/${nomlib}" |
---|
558 | fi |
---|
559 | |
---|
560 | ######################################################################## |
---|
561 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
562 | ######################################################################## |
---|
563 | ######################################################################## |
---|
564 | # c'est a dire dans 3 cas: |
---|
565 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
566 | # derniere creation du makefile |
---|
567 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
568 | # n'existe pas. |
---|
569 | # 3. Si le makefile n'existe pas. |
---|
570 | ######################################################################## |
---|
571 | cd $LMDGCM |
---|
572 | |
---|
573 | |
---|
574 | if [[ -r .makelmdz ]] |
---|
575 | then |
---|
576 | old_lmdz_configuration=$(cat .makelmdz ) |
---|
577 | else |
---|
578 | old_lmdz_configuration="" |
---|
579 | fi |
---|
580 | lmdz_configuration="$src_dirs" |
---|
581 | if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]] |
---|
582 | then |
---|
583 | configuration_change="true" |
---|
584 | else |
---|
585 | configuration_change="false" |
---|
586 | fi |
---|
587 | |
---|
588 | mkdir -p make_dir |
---|
589 | suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'` |
---|
590 | echo suf_make $suf_make |
---|
591 | |
---|
592 | \rm tmp77 tmp90 |
---|
593 | for dir in $src_dirs ; do |
---|
594 | find libf/$dir -name '*.[Fh]' -print | sort >> tmp77 |
---|
595 | find libf/$dir -name '*.F90' -print | sort >> tmp90 |
---|
596 | done |
---|
597 | |
---|
598 | liste77=make_dir/liste_des_sources_f77_$suf_make |
---|
599 | liste90=make_dir/liste_des_sources_f90_$suf_make |
---|
600 | makefile=make_dir/makefile_$suf_make |
---|
601 | |
---|
602 | if [[ $configuration_change == "true" || ! ( -r $makefile ) || ! ( -r $liste90 ) || ! ( -r $liste77 ) || ` diff tmp77 $liste77 | wc -w ` -ne 0 || ` diff tmp90 $liste90 | wc -w ` -ne 0 ]] |
---|
603 | then |
---|
604 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
605 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
606 | diff $liste77 tmp77 |
---|
607 | diff $liste90 tmp90 |
---|
608 | \cp -f tmp77 $liste77 |
---|
609 | \cp -f tmp90 $liste90 |
---|
610 | echo "Recreating the makefile" |
---|
611 | echo "src_dirs: $src_dirs" |
---|
612 | ./create_make_gcm $src_dirs > tmp |
---|
613 | \mv -f tmp $makefile |
---|
614 | echo "New makefile created" |
---|
615 | fi |
---|
616 | |
---|
617 | ln -sf $makefile makefile |
---|
618 | |
---|
619 | #Create a .makelmdz file containing main compilation option for later comparisons |
---|
620 | echo "$lmdz_configuration" > .makelmdz |
---|
621 | |
---|
622 | ################################################################# |
---|
623 | # Preparation de l'execution de la comande make |
---|
624 | ################################################################# |
---|
625 | |
---|
626 | source_code=${code}.F |
---|
627 | dirmain=dyn${dimc}d${FLAG_PARA} |
---|
628 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
629 | then |
---|
630 | source_code=${code}.F90 |
---|
631 | elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then |
---|
632 | dirmain=phy$physique |
---|
633 | source_code=${code}.F90 |
---|
634 | elif [[ -r $LMDGCM/libf/dynphy_lonlat/phy$phys_root/${code}.F90 ]] ; then |
---|
635 | dirmain="dynphy_lonlat/phy${phys_root}" |
---|
636 | source_code=${code}.F90 |
---|
637 | elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then |
---|
638 | dirmain=phy$physique/dyn1d |
---|
639 | source_code=${code}.F90 |
---|
640 | fi |
---|
641 | |
---|
642 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
643 | then |
---|
644 | mkdir ${LIBOGCM}/${nomlib} |
---|
645 | # check we indeed managed to create the directory |
---|
646 | if [[ ! $? ]] |
---|
647 | then |
---|
648 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
649 | exit |
---|
650 | fi |
---|
651 | fi |
---|
652 | |
---|
653 | # where module files are created |
---|
654 | mod_loc_dir=$localdir |
---|
655 | |
---|
656 | if [[ "$physique" != "nophys" ]] |
---|
657 | then |
---|
658 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
659 | fi |
---|
660 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
661 | |
---|
662 | # ranlib utility (check it exists or else default to ls) |
---|
663 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
664 | then |
---|
665 | ranlib="ranlib" |
---|
666 | else |
---|
667 | ranlib="ls" |
---|
668 | fi |
---|
669 | |
---|
670 | # add CPP keys to COMPIL_FLAGS |
---|
671 | # (but first add -D before all CPP_KEY items) |
---|
672 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
673 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
674 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
675 | then |
---|
676 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
677 | fi |
---|
678 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
679 | |
---|
680 | ################################################################# |
---|
681 | # Execution du make |
---|
682 | ################################################################# |
---|
683 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
684 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
685 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
686 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
687 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
688 | INCLUDE="$INCLUDE" \ |
---|
689 | $filtre \ |
---|
690 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
691 | "PHYS=$physique" \ |
---|
692 | LIBPHY=${LIBPHY} \ |
---|
693 | LIBPHY_COMMON=${LIBPHY_COMMON} \ |
---|
694 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
695 | DIM=$dimc \ |
---|
696 | FLAG_PARA=$FLAG_PARA \ |
---|
697 | L_PHY="$lib_phy" \ |
---|
698 | L_DYN_PHY="$libdyn_phy" \ |
---|
699 | L_ADJNT=$adjnt \ |
---|
700 | L_COSP="$lcosp" \ |
---|
701 | L_CHIMIE="$libchimie" \ |
---|
702 | LOCAL_DIR="$localdir" \ |
---|
703 | F77="$fcompiler" \ |
---|
704 | F90="$fcompiler" \ |
---|
705 | OPLINK="$LIB" \ |
---|
706 | LINK="$linker" \ |
---|
707 | GCM="$LMDGCM" \ |
---|
708 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
709 | MOD_SUFFIX="mod" \ |
---|
710 | AR=$arcommand \ |
---|
711 | DIRMAIN=$dirmain \ |
---|
712 | SOURCE=$source_code \ |
---|
713 | PROG=$code |
---|
714 | |
---|
715 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
716 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
717 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
718 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
719 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
720 | INCLUDE="$INCLUDE" \ |
---|
721 | $filtre \ |
---|
722 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
723 | "PHYS=$physique" \ |
---|
724 | LIBPHY=${LIBPHY} \ |
---|
725 | LIBPHY_COMMON=${LIBPHY_COMMON} \ |
---|
726 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
727 | DIM=$dimc \ |
---|
728 | FLAG_PARA=$FLAG_PARA \ |
---|
729 | L_PHY="$lib_phy" \ |
---|
730 | L_DYN_PHY="$libdyn_phy" \ |
---|
731 | L_ADJNT=$adjnt \ |
---|
732 | L_COSP="$lcosp" \ |
---|
733 | L_CHIMIE="$libchimie" \ |
---|
734 | LOCAL_DIR="$localdir" \ |
---|
735 | F77="$fcompiler" \ |
---|
736 | F90="$fcompiler" \ |
---|
737 | OPLINK="$LIB" \ |
---|
738 | LINK="$linker" \ |
---|
739 | GCM="$LMDGCM" \ |
---|
740 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
741 | MOD_SUFFIX="mod" \ |
---|
742 | AR=$arcommand \ |
---|
743 | DIRMAIN=$dirmain \ |
---|
744 | SOURCE=$source_code \ |
---|
745 | PROG=$code |
---|
746 | |
---|
747 | |
---|
748 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
749 | then |
---|
750 | # Cleanup: remove dimension.h file |
---|
751 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
752 | fi |
---|