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$physique" |
---|
299 | LIBPHY='$(LIBO)/libphy'"$physique"'.a' |
---|
300 | lib_phy='-lphy'"$physique" |
---|
301 | CPP_KEY="$CPP_KEY CPP_PHYS" |
---|
302 | if [[ $phys_root == "lmd" ]] |
---|
303 | then |
---|
304 | #For lmd physics, default planet type is Earth |
---|
305 | CPP_KEY="$CPP_KEY CPP_EARTH" |
---|
306 | fi |
---|
307 | fi |
---|
308 | |
---|
309 | if [[ "$chimie" == "INCA" ]] |
---|
310 | then |
---|
311 | CPP_KEY="$CPP_KEY INCA" |
---|
312 | INCLUDE="$INCLUDE -I${INCA_INCDIR}" |
---|
313 | LIB="$LIB -L${INCA_LIBDIR} -lchimie" |
---|
314 | libchimie=" -L${INCA_LIBDIR} -lchimie" |
---|
315 | fi |
---|
316 | |
---|
317 | if [[ "$couple" != "false" ]] |
---|
318 | then |
---|
319 | CPP_KEY="$CPP_KEY CPP_COUPLE" |
---|
320 | INCLUDE="$INCLUDE -I${OASIS_INCDIR}" |
---|
321 | LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io" |
---|
322 | fi |
---|
323 | |
---|
324 | if [[ "$parallel" == "none" ]] |
---|
325 | then |
---|
326 | FLAG_PARA='' |
---|
327 | else |
---|
328 | FLAG_PARA="$paramem" |
---|
329 | if [[ $paramem == par ]] |
---|
330 | then |
---|
331 | echo "The version of the dynamics in dyn3dpar is no longer updated." |
---|
332 | echo "You should use option \"-mem\"." |
---|
333 | exit 1 |
---|
334 | fi |
---|
335 | fi |
---|
336 | |
---|
337 | if [[ "$parallel" == "mpi" ]] |
---|
338 | then |
---|
339 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI" |
---|
340 | # MPI additional compilation options |
---|
341 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
342 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
343 | # MPI additional links |
---|
344 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
345 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
346 | elif [[ "$parallel" == "omp" ]] |
---|
347 | then |
---|
348 | CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP" |
---|
349 | # OMP additional compilation options |
---|
350 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
351 | PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} ) |
---|
352 | # OMP additional links |
---|
353 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
354 | PARA_LD=$( echo ${archfileline##%OMP_LD} ) |
---|
355 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
356 | then |
---|
357 | CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP" |
---|
358 | # MPI additional compilation options |
---|
359 | archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm ) |
---|
360 | PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} ) |
---|
361 | # OMP additional compilation options |
---|
362 | archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm ) |
---|
363 | PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} ) |
---|
364 | # MPI additional links |
---|
365 | archfileline=$( grep -i '^%MPI_LD' arch.fcm ) |
---|
366 | PARA_LD=$( echo ${archfileline##%MPI_LD} ) |
---|
367 | # OMP additional links |
---|
368 | archfileline=$( grep -i '^%OMP_LD' arch.fcm ) |
---|
369 | PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} ) |
---|
370 | fi |
---|
371 | |
---|
372 | if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \ |
---|
373 | && "$compil_mod" == "debug" ]] |
---|
374 | then |
---|
375 | echo "Usually, parallelization with OpenMP requires some optimization." |
---|
376 | echo "We suggest switching to \"-dev\"." |
---|
377 | fi |
---|
378 | |
---|
379 | |
---|
380 | #============================================================================== |
---|
381 | if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ] |
---|
382 | then |
---|
383 | |
---|
384 | INCLUDE="${INCLUDE} -I${ORCH_INCDIR}" |
---|
385 | CPP_KEY="$CPP_KEY CPP_VEGET" |
---|
386 | # temporary, for Orchidee versions 1.9.* (before openmp activation) |
---|
387 | if [[ "$veget" == "orchidee1.9" ]] ; then |
---|
388 | CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP" |
---|
389 | fi |
---|
390 | if [[ "$veget" == "orchidee2.0" ]] ; then |
---|
391 | orch_libs="sechiba parameters stomate parallel orglob orchidee" |
---|
392 | else |
---|
393 | orch_libs="sechiba parameters stomate parallel orglob" |
---|
394 | fi |
---|
395 | LIB="${LIB} -L${ORCH_LIBDIR}" |
---|
396 | for lib in ${orch_libs} ; do |
---|
397 | if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then |
---|
398 | LIB="${LIB} -l${LIBPREFIX}$lib " |
---|
399 | fi |
---|
400 | done |
---|
401 | elif [[ "$veget" != "false" ]] ; then |
---|
402 | echo "Option -v $veget does not exist" |
---|
403 | echo "Use ./makelmdz -h for more information" |
---|
404 | exit |
---|
405 | fi |
---|
406 | |
---|
407 | #=============================================================================== |
---|
408 | if [[ $io == ioipsl ]] |
---|
409 | then |
---|
410 | CPP_KEY="$CPP_KEY CPP_IOIPSL" |
---|
411 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}" |
---|
412 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl" |
---|
413 | elif [[ $io == mix ]] |
---|
414 | then |
---|
415 | # For now, xios implies also using ioipsl |
---|
416 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS" |
---|
417 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
418 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
419 | elif [[ $io == xios ]] |
---|
420 | then |
---|
421 | # For now, xios implies also using ioipsl |
---|
422 | CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT" |
---|
423 | INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}" |
---|
424 | LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios" |
---|
425 | fi |
---|
426 | |
---|
427 | if [[ "$cosp" == "true" ]] |
---|
428 | then |
---|
429 | CPP_KEY="$CPP_KEY CPP_COSP" |
---|
430 | COSP_PATH="$LIBFGCM/phylmd/cosp" |
---|
431 | src_dirs="$src_dirs cosp" |
---|
432 | # LIB="${LIB} -l${LIBPREFIX}cosp" |
---|
433 | opt_dep="$opt_dep cosp" |
---|
434 | lcosp="-l${LIBPREFIX}cosp" |
---|
435 | INCLUDE="$INCLUDE"' -I$(LIBF)/cosp' |
---|
436 | fi |
---|
437 | |
---|
438 | if [[ "$sisvat" == "true" ]] |
---|
439 | then |
---|
440 | CPP_KEY="$CPP_KEY CPP_SISVAT" |
---|
441 | src_dirs="$src_dirs phy${physique}/sisvat" |
---|
442 | fi |
---|
443 | |
---|
444 | if [[ "$rrtm" == "true" ]] |
---|
445 | then |
---|
446 | CPP_KEY="$CPP_KEY CPP_RRTM" |
---|
447 | src_dirs="$src_dirs phy${physique}/rrtm" |
---|
448 | fi |
---|
449 | |
---|
450 | |
---|
451 | INCLUDE="$INCLUDE ${NETCDF_INCDIR}" |
---|
452 | LIB="$LIB ${NETCDF_LIBDIR}" |
---|
453 | |
---|
454 | ######################################################################## |
---|
455 | # calcul du nombre de dimensions |
---|
456 | ######################################################################## |
---|
457 | |
---|
458 | |
---|
459 | dim_full=$dim |
---|
460 | dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
461 | set $dim |
---|
462 | dimc=$# |
---|
463 | echo calcul de la dimension |
---|
464 | echo dim $dim |
---|
465 | echo dimc $dimc |
---|
466 | |
---|
467 | ######################################################################## |
---|
468 | # Gestion des dimensions du modele. |
---|
469 | # on cree ou remplace le fichier des dimensions |
---|
470 | ######################################################################## |
---|
471 | |
---|
472 | cd $LIBFGCM/grid |
---|
473 | if [[ -f dimensions.h ]] |
---|
474 | then |
---|
475 | echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs' |
---|
476 | echo "Attendez que la premiere compilation soit terminee pour relancer la suivante." |
---|
477 | echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs," |
---|
478 | echo vous pouvez continuer en repondant oui. |
---|
479 | echo "Voulez-vous vraiment continuer?" |
---|
480 | echo "" |
---|
481 | echo "WARNING: you are probably already compiling the model somewhere else." |
---|
482 | echo "Wait until the first compilation is finished before launching this one." |
---|
483 | echo "If you are sure that you are not compiling elsewhere, just answer " |
---|
484 | echo "yes (or 'oui') to the question below to proceed." |
---|
485 | echo "Do you wish to continue?" |
---|
486 | read reponse |
---|
487 | if [[ $reponse == "oui" || $reponse == "yes" ]] |
---|
488 | then |
---|
489 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
490 | else |
---|
491 | exit |
---|
492 | fi |
---|
493 | fi |
---|
494 | |
---|
495 | cd $LIBFGCM/grid/dimension |
---|
496 | ./makdim $dim |
---|
497 | if (($? != 0)) |
---|
498 | then |
---|
499 | exit 1 |
---|
500 | fi |
---|
501 | |
---|
502 | cat $LIBFGCM/grid/dimensions.h |
---|
503 | cd $LMDGCM |
---|
504 | |
---|
505 | ######################################################################## |
---|
506 | # Differentes dynamiques (3d, 2d, 1d) |
---|
507 | ######################################################################## |
---|
508 | |
---|
509 | if (( $dimc == 3 )) ; then |
---|
510 | src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}" |
---|
511 | if [[ $physique != "nophys" ]] ; then |
---|
512 | src_dirs="$src_dirs dynlonlat_phylonlat dynlonlat_phylonlat/phy${phys_root}" |
---|
513 | libdyn_phy="-ldynlonlat_phylonlat" |
---|
514 | LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a' |
---|
515 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat' |
---|
516 | INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat/'"phy${phys_root}" |
---|
517 | fi |
---|
518 | cd $LIBFGCM/grid |
---|
519 | \rm fxyprim.h |
---|
520 | cp -p fxy_${grille}.h fxyprim.h |
---|
521 | filtre="FILTRE=$filtre" |
---|
522 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common ' |
---|
523 | elif (( $dimc == 2 )) ; then |
---|
524 | src_dirs="$src_dirs dyn2d" |
---|
525 | filtre="FILTRE= L_FILTRE= " |
---|
526 | INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d' |
---|
527 | elif (( $dimc == 1 )) ; then |
---|
528 | #src_dirs="$src_dirs dyn3d dyn3d_common filtrez" |
---|
529 | src_dirs="$src_dirs phy${physique}/dyn1d" |
---|
530 | CPP_KEY="$CPP_KEY CPP_1D" |
---|
531 | filtre="L_DYN= DYN= FILTRE= L_FILTRE= " |
---|
532 | #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre |
---|
533 | INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d' |
---|
534 | else |
---|
535 | echo Dimension dimc=$dimc pas prevu ; exit |
---|
536 | fi |
---|
537 | |
---|
538 | cd $LMDGCM |
---|
539 | |
---|
540 | ######################################################################## |
---|
541 | # library directory name: |
---|
542 | ######################################################################## |
---|
543 | |
---|
544 | 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'` |
---|
545 | echo "Path to library: "$nomlib |
---|
546 | |
---|
547 | ######################################################################## |
---|
548 | # Cleanup for a full recompilation, if requested |
---|
549 | ######################################################################## |
---|
550 | |
---|
551 | if [[ $full == "full" ]] |
---|
552 | then |
---|
553 | # remove makefile and librairies |
---|
554 | echo "-full option: recompiling from scratch" |
---|
555 | \rm -f makefile |
---|
556 | \rm -rf "${LIBOGCM}/${nomlib}" |
---|
557 | fi |
---|
558 | |
---|
559 | ######################################################################## |
---|
560 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
561 | ######################################################################## |
---|
562 | ######################################################################## |
---|
563 | # c'est a dire dans 3 cas: |
---|
564 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
565 | # derniere creation du makefile |
---|
566 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
567 | # n'existe pas. |
---|
568 | # 3. Si le makefile n'existe pas. |
---|
569 | ######################################################################## |
---|
570 | cd $LMDGCM |
---|
571 | |
---|
572 | |
---|
573 | if [[ -r .makelmdz ]] |
---|
574 | then |
---|
575 | old_lmdz_configuration=$(cat .makelmdz ) |
---|
576 | else |
---|
577 | old_lmdz_configuration="" |
---|
578 | fi |
---|
579 | lmdz_configuration="$src_dirs" |
---|
580 | if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]] |
---|
581 | then |
---|
582 | configuration_change="true" |
---|
583 | else |
---|
584 | configuration_change="false" |
---|
585 | fi |
---|
586 | |
---|
587 | mkdir -p make_dir |
---|
588 | suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'` |
---|
589 | echo suf_make $suf_make |
---|
590 | |
---|
591 | \rm tmp77 tmp90 |
---|
592 | for dir in $src_dirs ; do |
---|
593 | find libf/$dir -name '*.[Fh]' -print | sort >> tmp77 |
---|
594 | find libf/$dir -name '*.F90' -print | sort >> tmp90 |
---|
595 | done |
---|
596 | |
---|
597 | liste77=make_dir/liste_des_sources_f77_$suf_make |
---|
598 | liste90=make_dir/liste_des_sources_f90_$suf_make |
---|
599 | makefile=make_dir/makefile_$suf_make |
---|
600 | |
---|
601 | if [[ $configuration_change == "true" || ! ( -r $makefile ) || ! ( -r $liste_90 ) || ! ( -r $liste_77 ) || ` diff tmp77 $liste_77 | wc -w ` -ne 0 || ` diff tmp90 $liste_90 | wc -w ` -ne 0 ]] |
---|
602 | then |
---|
603 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
604 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
605 | diff $liste77 tmp77 |
---|
606 | diff $liste90 tmp90 |
---|
607 | \cp -f tmp77 $liste77 |
---|
608 | \cp -f tmp90 $liste90 |
---|
609 | echo "Recreating the makefile" |
---|
610 | echo "src_dirs: $src_dirs" |
---|
611 | ./create_make_gcm $src_dirs > tmp |
---|
612 | \mv -f tmp $makefile |
---|
613 | echo "New makefile created" |
---|
614 | fi |
---|
615 | |
---|
616 | ln -sf $makefile makefile |
---|
617 | |
---|
618 | #Create a .makelmdz file containing main compilation option for later comparisons |
---|
619 | echo "$lmdz_configuration" > .makelmdz |
---|
620 | |
---|
621 | ################################################################# |
---|
622 | # Preparation de l'execution de la comande make |
---|
623 | ################################################################# |
---|
624 | |
---|
625 | source_code=${code}.F |
---|
626 | dirmain=dyn${dimc}d${FLAG_PARA} |
---|
627 | if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]] |
---|
628 | then |
---|
629 | source_code=${code}.F90 |
---|
630 | elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then |
---|
631 | dirmain=phy$physique |
---|
632 | source_code=${code}.F90 |
---|
633 | elif [[ -r $LMDGCM/libf/dynlonlat_phylonlat/phy$phys_root/${code}.F90 ]] ; then |
---|
634 | dirmain="dynlonlat_phylonlat/phy${phys_root}" |
---|
635 | source_code=${code}.F90 |
---|
636 | elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then |
---|
637 | dirmain=phy$physique/dyn1d |
---|
638 | source_code=${code}.F90 |
---|
639 | fi |
---|
640 | |
---|
641 | if [[ ! -d "${LIBOGCM}/${nomlib}" ]] |
---|
642 | then |
---|
643 | mkdir ${LIBOGCM}/${nomlib} |
---|
644 | # check we indeed managed to create the directory |
---|
645 | if [[ ! $? ]] |
---|
646 | then |
---|
647 | echo "Error: could not create directory ${LIBOGCM}/${nomlib}" |
---|
648 | exit |
---|
649 | fi |
---|
650 | fi |
---|
651 | |
---|
652 | # where module files are created |
---|
653 | mod_loc_dir=$localdir |
---|
654 | |
---|
655 | if [[ "$physique" != "nophys" ]] |
---|
656 | then |
---|
657 | INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique" |
---|
658 | fi |
---|
659 | INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib} |
---|
660 | |
---|
661 | # ranlib utility (check it exists or else default to ls) |
---|
662 | if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]] |
---|
663 | then |
---|
664 | ranlib="ranlib" |
---|
665 | else |
---|
666 | ranlib="ls" |
---|
667 | fi |
---|
668 | |
---|
669 | # add CPP keys to COMPIL_FLAGS |
---|
670 | # (but first add -D before all CPP_KEY items) |
---|
671 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'` |
---|
672 | # (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas |
---|
673 | if [[ "${fcompiler:0:3}" == "xlf" ]] |
---|
674 | then |
---|
675 | cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'` |
---|
676 | fi |
---|
677 | COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}" |
---|
678 | |
---|
679 | ################################################################# |
---|
680 | # Execution du make |
---|
681 | ################################################################# |
---|
682 | echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
683 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
684 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
685 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
686 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
687 | INCLUDE="$INCLUDE" \ |
---|
688 | $filtre \ |
---|
689 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
690 | "PHYS=$physique" \ |
---|
691 | LIBPHY=${LIBPHY} \ |
---|
692 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
693 | DIM=$dimc \ |
---|
694 | FLAG_PARA=$FLAG_PARA \ |
---|
695 | L_PHY="$lib_phy" \ |
---|
696 | L_DYN_PHY="$libdyn_phy" \ |
---|
697 | L_ADJNT=$adjnt \ |
---|
698 | L_COSP="$lcosp" \ |
---|
699 | L_CHIMIE="$libchimie" \ |
---|
700 | LOCAL_DIR="$localdir" \ |
---|
701 | F77="$fcompiler" \ |
---|
702 | F90="$fcompiler" \ |
---|
703 | OPLINK="$LIB" \ |
---|
704 | LINK="$linker" \ |
---|
705 | GCM="$LMDGCM" \ |
---|
706 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
707 | MOD_SUFFIX="mod" \ |
---|
708 | AR=$arcommand \ |
---|
709 | DIRMAIN=$dirmain \ |
---|
710 | SOURCE=$source_code \ |
---|
711 | PROG=$code |
---|
712 | |
---|
713 | $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \ |
---|
714 | OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \ |
---|
715 | OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
716 | OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
717 | OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \ |
---|
718 | INCLUDE="$INCLUDE" \ |
---|
719 | $filtre \ |
---|
720 | LIBO=${LIBOGCM}/${nomlib} \ |
---|
721 | "PHYS=$physique" \ |
---|
722 | LIBPHY=${LIBPHY} \ |
---|
723 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
724 | DIM=$dimc \ |
---|
725 | FLAG_PARA=$FLAG_PARA \ |
---|
726 | L_PHY="$lib_phy" \ |
---|
727 | L_DYN_PHY="$libdyn_phy" \ |
---|
728 | L_ADJNT=$adjnt \ |
---|
729 | L_COSP="$lcosp" \ |
---|
730 | L_CHIMIE="$libchimie" \ |
---|
731 | LOCAL_DIR="$localdir" \ |
---|
732 | F77="$fcompiler" \ |
---|
733 | F90="$fcompiler" \ |
---|
734 | OPLINK="$LIB" \ |
---|
735 | LINK="$linker" \ |
---|
736 | GCM="$LMDGCM" \ |
---|
737 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
738 | MOD_SUFFIX="mod" \ |
---|
739 | AR=$arcommand \ |
---|
740 | DIRMAIN=$dirmain \ |
---|
741 | SOURCE=$source_code \ |
---|
742 | PROG=$code |
---|
743 | |
---|
744 | |
---|
745 | if [[ -r $LIBFGCM/grid/dimensions.h ]] |
---|
746 | then |
---|
747 | # Cleanup: remove dimension.h file |
---|
748 | \rm -f $LIBFGCM/grid/dimensions.h |
---|
749 | fi |
---|