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