1 | #!/bin/csh -f |
---|
2 | # $Header: /users/lmdz/cvsroot/LMDZ.3.3/makegcm,v 1.21 2001/07/04 08:41:44 lmdz Exp $ |
---|
3 | #set verbose echo |
---|
4 | ######################################################################## |
---|
5 | # options par defaut pour la commande make |
---|
6 | ######################################################################## |
---|
7 | set dim="64x48x32" |
---|
8 | set physique=mars |
---|
9 | set phys="PHYS=$physique" |
---|
10 | set include='-I$(LIBF)/grid -I$(LIBF)/misc -I. -I$(LIBF)/dynlonlat_phylonlat' |
---|
11 | set ntrac = 1 |
---|
12 | set filtre=filtrez |
---|
13 | set grille=reg |
---|
14 | set dyntype="dyn" |
---|
15 | set full="" |
---|
16 | #src_dirs: directories containing source files |
---|
17 | set src_dirs="grid misc" |
---|
18 | |
---|
19 | ######################################################################## |
---|
20 | # path a changer contenant les sources et les objets du modele |
---|
21 | ######################################################################## |
---|
22 | |
---|
23 | #### If you want you can set environment variables here (instead of |
---|
24 | #### relying on the C-shell environment variables) |
---|
25 | # default LMDGCM to where makegcm script is located: |
---|
26 | set scriptdir=`dirname $0` |
---|
27 | setenv LMDGCM `readlink -f $scriptdir` |
---|
28 | # You may set LIBOGCM to something else; otherwise we default to: |
---|
29 | setenv LIBOGCM $LMDGCM/libo |
---|
30 | |
---|
31 | ### NetCDF librairies. some presets for LMD people. |
---|
32 | hostname | grep 'lmd.jussieu.fr' > /dev/null |
---|
33 | if ( $? == 0 ) then |
---|
34 | echo "*** NETCDF preset *** LMD machines" |
---|
35 | setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_ifort/lib |
---|
36 | setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_ifort/include |
---|
37 | endif |
---|
38 | hostname | grep 'n201' > /dev/null |
---|
39 | if ( $? == 0 ) then |
---|
40 | echo "*** NETCDF preset *** GNOME cluster" |
---|
41 | setenv NCDFLIB /usr/local/lib |
---|
42 | setenv NCDFINC /usr/local/include |
---|
43 | endif |
---|
44 | hostname | grep 'ciclad' > /dev/null |
---|
45 | if ( $? == 0 ) then |
---|
46 | echo "*** NETCDF preset *** CICLAD cluster" |
---|
47 | setenv NCDFLIB /opt/netcdf3/ifort/lib |
---|
48 | setenv NCDFINC /opt/netcdf3/ifort/include |
---|
49 | endif |
---|
50 | hostname | grep 'ada' > /dev/null |
---|
51 | if ( $? == 0 ) then |
---|
52 | echo "*** NETCDF preset *** CICLAD cluster" |
---|
53 | setenv NCDFLIB /smplocal/pub/NetCDF/4.1.3/seq/lib |
---|
54 | setenv NCDFINC /smplocal/pub/NetCDF/4.1.3/seq/include |
---|
55 | endif |
---|
56 | ### end NetCDF presets |
---|
57 | |
---|
58 | setenv localdir "`pwd`" |
---|
59 | set MODIPSL=0 |
---|
60 | echo $localdir | grep modipsl >& /dev/null |
---|
61 | if ( ! $status ) then |
---|
62 | set MODIPSL=1 |
---|
63 | setenv LMDGCM $localdir |
---|
64 | cd ../.. |
---|
65 | setenv LIBOGCM "`pwd`/lib" |
---|
66 | cd $localdir |
---|
67 | if ( `hostname` == rhodes ) then |
---|
68 | set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` |
---|
69 | set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` |
---|
70 | else |
---|
71 | if ( `hostname` == nymphea0 ) then |
---|
72 | set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"` |
---|
73 | set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'` |
---|
74 | else |
---|
75 | echo 'Probleme de definition des variables NCDFINC et NCDFLIB' |
---|
76 | endif |
---|
77 | endif |
---|
78 | else |
---|
79 | if ( ! $?LMDGCM ) then |
---|
80 | echo You must initialize the variable LMDGCM in your environnement |
---|
81 | echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc |
---|
82 | exit |
---|
83 | endif |
---|
84 | if ( ! $?LIBOGCM ) then |
---|
85 | set LIBOGCM=$LMDGCM/libo |
---|
86 | endif |
---|
87 | if ( ! $?NCDFLIB ) then |
---|
88 | echo You must initialize the variable NCDFLIB in your environnement |
---|
89 | echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc |
---|
90 | exit |
---|
91 | endif |
---|
92 | if ( ! $?NCDFINC ) then |
---|
93 | echo You must initialize the variable NCDFINC in your environnement |
---|
94 | echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc |
---|
95 | exit |
---|
96 | endif |
---|
97 | endif |
---|
98 | set model=$LMDGCM |
---|
99 | set libo=$LIBOGCM |
---|
100 | |
---|
101 | ######################################################################## |
---|
102 | # Les differentes platformes reconnues |
---|
103 | ######################################################################## |
---|
104 | |
---|
105 | set HP=0 |
---|
106 | set IBM=0 |
---|
107 | set SUN=0 |
---|
108 | set VPP=0 |
---|
109 | set CRAY=0 |
---|
110 | set DEC=0 |
---|
111 | set LINUX=0 |
---|
112 | set NEC=0 |
---|
113 | set XNEC=0 |
---|
114 | if ( `uname` == HP-UX ) then |
---|
115 | set machine=HP |
---|
116 | set HP=1 |
---|
117 | else if (`uname` == UNIX_System_V ) then |
---|
118 | set machine=VPP |
---|
119 | set VPP=1 |
---|
120 | else if (`uname` == SunOS ) then |
---|
121 | set machine=SUN |
---|
122 | set SUN=1 |
---|
123 | else if ( `uname` == AIX ) then |
---|
124 | set machine=IBM |
---|
125 | set IBM=1 |
---|
126 | else if ( `uname` == OSF1 ) then |
---|
127 | set machine=ALPHA |
---|
128 | set DEC=1 |
---|
129 | else if ( `uname` == Linux ) then |
---|
130 | set machine=LINUX |
---|
131 | set LINUX=1 |
---|
132 | else if ( `hostname` == atlas || `hostname` == axis || `hostname` == etoile ) then |
---|
133 | set machine=CRAY |
---|
134 | set CRAY=1 |
---|
135 | else if ( `uname` == SUPER-UX ) then |
---|
136 | set machine=NEC |
---|
137 | set NEC=1 |
---|
138 | else if ( `hostname` == rhodes) then |
---|
139 | set machine=XNEC |
---|
140 | set XNEC=1 |
---|
141 | else |
---|
142 | echo Vous travaillez sur une machine non prevue par le reglement |
---|
143 | exit |
---|
144 | endif |
---|
145 | |
---|
146 | # create $libo directory if it doesn't exist |
---|
147 | if ( ! -d $libo ) then |
---|
148 | mkdir $libo |
---|
149 | endif |
---|
150 | |
---|
151 | if $VPP then |
---|
152 | set netcdf=netcdf_v |
---|
153 | else |
---|
154 | set netcdf=netcdf |
---|
155 | endif |
---|
156 | ######################################################################## |
---|
157 | # Quelques initialisations de variables du shell. |
---|
158 | ######################################################################## |
---|
159 | |
---|
160 | set dyn= |
---|
161 | set opt_link="" |
---|
162 | set adjnt="" |
---|
163 | set opt_dep="" |
---|
164 | |
---|
165 | set optim90="" |
---|
166 | set oplink="" |
---|
167 | |
---|
168 | ######################################################################## |
---|
169 | # Optimisations par defaut suivant les machines |
---|
170 | ######################################################################## |
---|
171 | |
---|
172 | echo "Optimisations par defaut suivant les machines" |
---|
173 | set libf=$model/libf |
---|
174 | #setenv localdir "LOCAL_DIR=`pwd`" |
---|
175 | #setenv localdir "`pwd`" |
---|
176 | cd $model |
---|
177 | if $CRAY then |
---|
178 | set optim90="-Wp'-P' -DCRAY "'-p$(LIBO) -eiv ' |
---|
179 | set oplink="-Wl'-DSTACK=128 -f indef' -L$NCDFLIB -lnetcdf " |
---|
180 | set mod_loc_dir=" " |
---|
181 | set mod_suffix=" " |
---|
182 | else if $SUN then |
---|
183 | set optim90=" -fast" |
---|
184 | set optimtru90=" -fast -free" |
---|
185 | set opt_link="-L$NCDFLIB -lnetcdf" |
---|
186 | set mod_loc_dir=$localdir |
---|
187 | set mod_suffix=mod |
---|
188 | else if $HP then |
---|
189 | else if $IBM then |
---|
190 | else if $VPP then |
---|
191 | set optim90="$optim -X9 -w" |
---|
192 | if $COUPLE then |
---|
193 | set opt_link="-Wg,-c $IOIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl" |
---|
194 | set oplink="-Wl,-t,-P,-dy " |
---|
195 | else |
---|
196 | set opt_link="-Wg,-c /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl" |
---|
197 | set oplink="-Wl,-t,-dy " |
---|
198 | endif |
---|
199 | set mod_loc_dir=$IOIPSLDIR |
---|
200 | set mod_suffix=mod |
---|
201 | else if $DEC then |
---|
202 | else if $LINUX then |
---|
203 | # Ehouarn 'ifort' compiler |
---|
204 | #NB: on gnome -O3 ==> NaNs ... |
---|
205 | set optim="-auto -O2 -fp-model precise -ip -mkl=sequential -align all " |
---|
206 | set optim90="-auto -O2 -fp-model precise -ip -mkl=sequential -align all " |
---|
207 | set optimtru90="-auto -O2 -fp-model precise -ip -mkl=sequential -align all " |
---|
208 | # set opt_link=" -Mfree -lpgf90 -lpgftnrtl -lpghpf -lpghpf2 -L$NCDFLIB -lnetcdf -Bstatic " |
---|
209 | # set mod_loc_dir=$LIBOGCM |
---|
210 | # ifort puts mod files in local directory |
---|
211 | set mod_loc_dir="." |
---|
212 | set mod_suffix=mod |
---|
213 | else if $NEC then |
---|
214 | set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "' |
---|
215 | set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "' |
---|
216 | ### set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lioipsl -L/u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v " |
---|
217 | set opt_link=" -C hopt -float0 -ew -P static -L/SX/usr/local/lib -lnetcdf_i8r8 " |
---|
218 | set mod_loc_dir="." |
---|
219 | set mod_suffix="mod" |
---|
220 | else if $XNEC then |
---|
221 | set optim90=' -clear -R5 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' |
---|
222 | set optimtru90=' -clear -R5 -f4 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "' |
---|
223 | if $MODIPSL then |
---|
224 | if $COUPLE then |
---|
225 | set opt_link="-L$IOIPSLDIR -lsxioipsl -loasis2.4_mpi2 -float0 -ew -P static -I$NCDFINC $NCDFLIB " |
---|
226 | else |
---|
227 | set opt_link="-L$IOIPSLDIR -lsxioipsl -float0 -ew -P static -I$NCDFINC $NCDFLIB " |
---|
228 | endif |
---|
229 | set mod_loc_dir="./" |
---|
230 | else |
---|
231 | #### set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lsxioipsl -L /u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8" |
---|
232 | set opt_link=" -C hopt -float0 -ew -P static -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8" |
---|
233 | set mod_loc_dir="." |
---|
234 | endif |
---|
235 | set mod_suffix="mod" |
---|
236 | |
---|
237 | endif |
---|
238 | |
---|
239 | # Ehouarn: add 'g9fortran' string to pathname |
---|
240 | set nomlib=${machine} |
---|
241 | |
---|
242 | # Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64) |
---|
243 | if (`uname` == Linux && `uname -m` == "x86_64") then |
---|
244 | set nomlib=${machine}64 |
---|
245 | endif |
---|
246 | |
---|
247 | ######################################################################## |
---|
248 | # lecture des options de mymake |
---|
249 | ######################################################################## |
---|
250 | |
---|
251 | top: |
---|
252 | if ($#argv > 0) then |
---|
253 | switch ($1:q) |
---|
254 | |
---|
255 | case -h: |
---|
256 | |
---|
257 | ######################################################################## |
---|
258 | # Manuel en ligne |
---|
259 | ######################################################################## |
---|
260 | more <<eod |
---|
261 | |
---|
262 | |
---|
263 | makegcm [Options] prog |
---|
264 | |
---|
265 | |
---|
266 | The makegcm script: |
---|
267 | ------------------- |
---|
268 | |
---|
269 | 1. compiles a series of subroutines located in the $LMDGCM/libf |
---|
270 | sub-directories. |
---|
271 | The objects are then stored in the libraries in $LIBOGCM. |
---|
272 | |
---|
273 | 2. then, makegcm compiles program prog.f located by default in |
---|
274 | $LMDGCM/libf/dyn3d and makes the link with the libraries. |
---|
275 | |
---|
276 | Environment Variables '$LMDGCM' and '$LIBOGCM' |
---|
277 | must be set as environment variables or directly |
---|
278 | in the makegcm file. |
---|
279 | |
---|
280 | The makegcm command is used to control the different versions of the model |
---|
281 | in parallel, compiled using the compilation options |
---|
282 | and the various dimensions, without having to recompile the whole model. |
---|
283 | |
---|
284 | The FORTRAN libraries are stored in directory $LIBOGCM. |
---|
285 | |
---|
286 | |
---|
287 | OPTIONS: |
---|
288 | -------- |
---|
289 | |
---|
290 | The following options can either be defined by default by editing the |
---|
291 | makegcm "script", or in interactive mode: |
---|
292 | |
---|
293 | -d imxjmxlm where im, jm, and lm are the number of longitudes, |
---|
294 | latitudes and vertical layers respectively. |
---|
295 | |
---|
296 | -t ntrac Selects the number of tracers present in the model |
---|
297 | |
---|
298 | Options -d and -t overwrite file |
---|
299 | $LMDGCM/libf/grid/dimensions.h |
---|
300 | which contains the 3 dimensions of the |
---|
301 | horizontal grid |
---|
302 | im, jm, lm plus the number of tracers passively advected |
---|
303 | by the dynamics ntrac, |
---|
304 | in 4 PARAMETER FORTRAN format |
---|
305 | with a new file: |
---|
306 | $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac |
---|
307 | If the file does not exist already |
---|
308 | it is created by the script |
---|
309 | $LMDGCM/libf/grid/dimension/makdim |
---|
310 | |
---|
311 | -p PHYS Selects the set of physical parameterizations |
---|
312 | you want to compile the model with. |
---|
313 | The model is then compiled using the physical |
---|
314 | parameterization sources in directory: |
---|
315 | $LMDGCM/libf/phyPHYS |
---|
316 | |
---|
317 | -g grille Selects the grid type. |
---|
318 | This option overwrites file |
---|
319 | $LMDGCM/libf/grid/fxyprim.h |
---|
320 | with file |
---|
321 | $LMDGCM/libf/grid/fxy_grille.h |
---|
322 | the grid can take the following values: |
---|
323 | 1. reg - the regular grid |
---|
324 | 2. sin - to obtain equidistant points in terms of sin(latitude) |
---|
325 | 3. new - to zoom into a part of the globe |
---|
326 | |
---|
327 | -O "compilation options" set of fortran compilation options to use |
---|
328 | |
---|
329 | -include path |
---|
330 | Used if the subroutines contain #include files (ccp) that |
---|
331 | are located in directories that are not referenced by default. |
---|
332 | |
---|
333 | -adjnt Compiles the adjoint model to the dynamical code. |
---|
334 | |
---|
335 | -olddyn To compile GCM with "old dynamics" |
---|
336 | |
---|
337 | -filtre filter |
---|
338 | To select the longitudinal filter in the polar regions. |
---|
339 | "filter" corresponds to the name of a directory located in |
---|
340 | $LMDGCM/libf. The standard filter for the model is "filtrez" |
---|
341 | which can be used for a regular grid and for a |
---|
342 | grid with longitudinal zoom. |
---|
343 | |
---|
344 | -link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..." |
---|
345 | Adds a link to FORTRAN libraries |
---|
346 | libfile1.a, libfile2.a ... |
---|
347 | located in directories dir1, dir2 ...respectively |
---|
348 | If dirn is a directory with an automatic path |
---|
349 | (/usr/lib ... for example) |
---|
350 | there is no need to specify -Ldirn. |
---|
351 | |
---|
352 | -full Full (re)compilation (from scratch) |
---|
353 | |
---|
354 | eod |
---|
355 | exit |
---|
356 | |
---|
357 | ######################################################################## |
---|
358 | # Lecture des differentes options |
---|
359 | ######################################################################## |
---|
360 | |
---|
361 | case -d: |
---|
362 | set dim=$2 ; shift ; shift ; goto top |
---|
363 | |
---|
364 | case -O: |
---|
365 | set optim="$2" ; set optim90="$2" ; set optimtru90="$2" ; shift ; shift ; goto top |
---|
366 | |
---|
367 | case -p |
---|
368 | set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top |
---|
369 | |
---|
370 | case -g |
---|
371 | set grille="$2" ; shift ; shift ; goto top |
---|
372 | |
---|
373 | case -t |
---|
374 | set ntrac=$2 ; shift ; shift ; goto top |
---|
375 | |
---|
376 | case -include |
---|
377 | set include="$include -I$2" ; shift ; shift ; goto top |
---|
378 | |
---|
379 | case -adjnt |
---|
380 | set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d " |
---|
381 | |
---|
382 | case -olddyn |
---|
383 | set dyntype="olddyn" ; shift; goto top |
---|
384 | |
---|
385 | case -full |
---|
386 | set full="full" ; shift ; goto top |
---|
387 | |
---|
388 | case -filtre |
---|
389 | set filtre=$2 ; shift ; shift ; goto top |
---|
390 | |
---|
391 | case -link |
---|
392 | set opt_link="$opt_link $2" ; shift ; shift ; goto top |
---|
393 | |
---|
394 | case -debug |
---|
395 | if $HP then |
---|
396 | set optim90=" -g " |
---|
397 | else if $SUN then |
---|
398 | setenv PARALLEL 4 |
---|
399 | set optim90=" -g -C " |
---|
400 | set optimtru90=" -g -C " |
---|
401 | else if $CRAY then |
---|
402 | set optim90="$optim90"" -G1 " |
---|
403 | else if $LINUX then |
---|
404 | ## for ifort |
---|
405 | set optim=" -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug" |
---|
406 | set optim90=" -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug" |
---|
407 | set optimtru90=" -g -O0 -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug" |
---|
408 | else |
---|
409 | echo "pas d option debug predefinie pour cette machine" |
---|
410 | exit |
---|
411 | endif |
---|
412 | shift ; goto top |
---|
413 | |
---|
414 | default |
---|
415 | set code="$1" ; shift ; goto top |
---|
416 | |
---|
417 | endsw |
---|
418 | endif |
---|
419 | |
---|
420 | echo "apres les opts dim $dim" |
---|
421 | |
---|
422 | ######################################################################## |
---|
423 | # cas special sans physique |
---|
424 | ######################################################################## |
---|
425 | if ( "$physique" == 'nophys' ) then |
---|
426 | set phys="L_PHY= LIBPHY=" |
---|
427 | else |
---|
428 | set src_dirs="$src_dirs aerono$physique phy$physique" |
---|
429 | set include="$include "'-I$(LIBF)/aerono'"$physique"' -I$(LIBF)/phy'"$physique" |
---|
430 | endif |
---|
431 | set libdyn_phy="" |
---|
432 | set LIBDYN_PHYS="" |
---|
433 | ######################################################################## |
---|
434 | # choix du nombre de traceur par defaut si il n'a pas ete choisi, |
---|
435 | # suivant la physique |
---|
436 | ######################################################################## |
---|
437 | |
---|
438 | if ( $ntrac == 0 ) then |
---|
439 | if ( "$physique" == 'nophys' ) then |
---|
440 | set ntrac=1 |
---|
441 | else if ( "$physique" == 'lmd' ) then |
---|
442 | set ntrac=2 |
---|
443 | else if ( "$physique" == 'lmd_test_li' ) then |
---|
444 | set ntrac=2 |
---|
445 | else if ( "$physique" == 'ec' ) then |
---|
446 | set ntrac=1 |
---|
447 | else |
---|
448 | set ntrac = 1 |
---|
449 | endif |
---|
450 | endif |
---|
451 | |
---|
452 | ######################################################################## |
---|
453 | #subtilites sur le nom de la librairie |
---|
454 | ######################################################################## |
---|
455 | |
---|
456 | \rm tmp ; touch tmp |
---|
457 | \rm tmp90 ; touch tmp90 |
---|
458 | foreach i ( $optim90 ) |
---|
459 | echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g' -e 's/://g' -e 's/=//g' -e 's/%//g' >> tmp |
---|
460 | end |
---|
461 | set suf= |
---|
462 | foreach i ( `sort tmp | uniq ` ) |
---|
463 | set suf=$suf$i |
---|
464 | end |
---|
465 | if ( ! $IBM ) then |
---|
466 | set nomlib="$nomlib$suf" |
---|
467 | endif |
---|
468 | if ( $DEC ) then |
---|
469 | set nomlib=DEC |
---|
470 | endif |
---|
471 | |
---|
472 | # dimension |
---|
473 | |
---|
474 | echo "dimension avant sed $dim" |
---|
475 | if ( $IBM ) then |
---|
476 | set dim=`echo $dim | sed -en 's/[^0-9]/ /g'` |
---|
477 | set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'` |
---|
478 | else if ( $SUN || $XNEC ) then |
---|
479 | set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
480 | set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'` |
---|
481 | else |
---|
482 | # set dim=`echo $dim | sed -n -e 's/[^0-9]/ /gp'` |
---|
483 | # set dim_=`echo $dim | sed -n -e 's/[^0-9]/_/gp'` |
---|
484 | set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` |
---|
485 | set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'` |
---|
486 | endif |
---|
487 | |
---|
488 | # build final name of libraries directory: |
---|
489 | if ( "$dyntype" == "olddyn" ) then |
---|
490 | set nomlib=${nomlib}_${dim_}_t${ntrac}_${grille}_olddyn |
---|
491 | else |
---|
492 | set nomlib=${nomlib}_${dim_}_t${ntrac}_${grille} |
---|
493 | endif |
---|
494 | |
---|
495 | # Append 'physique' type, if it is not mars, to nomlib |
---|
496 | if ( "$physique" != "mars" ) then |
---|
497 | set nomlib=${nomlib}_${physique} |
---|
498 | endif |
---|
499 | |
---|
500 | ## M-A-F nomlib trop long sur CRAY pour ar |
---|
501 | if ( $CRAY ) then |
---|
502 | set nomlib=F90_${dim_}_t${ntrac} |
---|
503 | endif |
---|
504 | if ( $NEC || $XNEC ) then |
---|
505 | set nomlib=F90_${dim_}_t${ntrac} |
---|
506 | endif |
---|
507 | |
---|
508 | echo "calcul de la dimension" |
---|
509 | set dimc=`echo $dim | wc -w` |
---|
510 | |
---|
511 | if ( "$dimc" == "2" ) then |
---|
512 | set include="$include "'-I$(LIBF)/dyn2d ' |
---|
513 | set dimh=$dim |
---|
514 | endif |
---|
515 | if ( "$dimc" == "3" ) then |
---|
516 | if ( "$dyntype" == "olddyn" ) then |
---|
517 | set include="$include "'-I$(LIBF)/olddyn3d ' |
---|
518 | set src_dirs="$src_dirs olddyn3d dynlonlat_phylonlat dynlonlat_phylonlat/phy$physique" |
---|
519 | else |
---|
520 | set include="$include "'-I$(LIBF)/dyn3d ' |
---|
521 | set src_dirs="$src_dirs dyn3d dynlonlat_phylonlat dynlonlat_phylonlat/phy$physique" |
---|
522 | endif |
---|
523 | set libdyn_phy="-ldynlonlat_phylonlat" |
---|
524 | set LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a' |
---|
525 | set dimh=`echo $dim | awk ' { print $1 "." $2 } '` |
---|
526 | endif |
---|
527 | echo "dimc is $dimc" |
---|
528 | |
---|
529 | ######################################################################## |
---|
530 | # path pour les #include |
---|
531 | ######################################################################## |
---|
532 | |
---|
533 | set include="$include -I$NCDFINC " |
---|
534 | echo $include |
---|
535 | |
---|
536 | ######################################################################## |
---|
537 | # Gestion des dimensions du modele. |
---|
538 | # on cree ou remplace le fichier des dimensions/nombre de traceur |
---|
539 | ######################################################################## |
---|
540 | |
---|
541 | cd $libf/grid |
---|
542 | if ( -f dimensions.h ) then |
---|
543 | echo "WARNING: you are probably already compiling the model (perhaps" |
---|
544 | echo " elsewhere). Wait until the first compilation ends before " |
---|
545 | echo " compiling a different configuration." |
---|
546 | echo "If you are sure that you are not already compiling, then you" |
---|
547 | echo " may continue this compilation by answering yes." |
---|
548 | echo "Do you want to continue?" |
---|
549 | if ( $< == "yes" ) then |
---|
550 | #remove old dimensions.h file |
---|
551 | \rm -f $libf/grid/dimensions.h |
---|
552 | else |
---|
553 | exit |
---|
554 | endif |
---|
555 | endif |
---|
556 | |
---|
557 | # Build the appropriate 'dimensions.h' file |
---|
558 | cd dimension |
---|
559 | ./makdim $dim |
---|
560 | # echo contents of dimensions.h to standard output |
---|
561 | cat $libf/grid/dimensions.h |
---|
562 | |
---|
563 | cd $LMDGCM |
---|
564 | # set path to objects directory |
---|
565 | set libo=$libo/$nomlib |
---|
566 | # create objects directory, if it doesn't exist |
---|
567 | if ( ! -d $libo ) then |
---|
568 | mkdir $libo |
---|
569 | cd $model |
---|
570 | endif |
---|
571 | |
---|
572 | ######################################################################## |
---|
573 | # Differentes dynamiques (3d, 2d, 1d) |
---|
574 | ######################################################################## |
---|
575 | |
---|
576 | set dimension=`echo $dim | wc -w` |
---|
577 | echo dimension $dimension dim $dim |
---|
578 | if ( $dimension == 1 ) then |
---|
579 | echo "No dynamics" |
---|
580 | ## set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique " |
---|
581 | ## NB: we still need to have L_DYN=libdyn3d to reach routines and module |
---|
582 | ## objects which are located in dyn3d |
---|
583 | set dyntype="" |
---|
584 | set filtre="L_DYN= DYN= FILTRE= L_FILTRE= " |
---|
585 | set dyn="L_DYN= DYN= L_FILTRE= " |
---|
586 | set dirmain="phy$physique/dyn1d" |
---|
587 | set src_dirs="$src_dirs phy$physique/dyn1d " |
---|
588 | set include="$include "' -I$(LIBF)/phy'"$physique"'/dyn1d' |
---|
589 | endif |
---|
590 | endif |
---|
591 | |
---|
592 | cd $model |
---|
593 | if ( $dimension == 3 ) then |
---|
594 | cd libf/grid |
---|
595 | \rm fxyprim.h |
---|
596 | cp -p fxy_${grille}.h fxyprim.h |
---|
597 | endif |
---|
598 | |
---|
599 | ###################################################################### |
---|
600 | # Traitement special pour le nouveau rayonnement de Laurent Li. |
---|
601 | ###################################################################### |
---|
602 | |
---|
603 | if ( -f $libf/phy$physique/raddim.h ) then |
---|
604 | if ( -f $libf/phy$physique/raddim.$dimh.h ) then |
---|
605 | \rm $libf/phy$physique/raddim.h |
---|
606 | cp -p $libf/phy$physique/raddim.$dimh.h $libf/phy$physique/raddim.h |
---|
607 | echo $libf/phy$physique/raddim.$dimh.h |
---|
608 | cat $libf/phy$physique/raddim.$dimh.h |
---|
609 | cat $libf/phy$physique/raddim.h |
---|
610 | else |
---|
611 | echo On peut diminuer la taille de l executable en creant |
---|
612 | echo le fichier $libf/phy$physique/raddim.$dimh.h |
---|
613 | \cp -p $libf/phy$physique/raddim.defaut.h $libf/phy$physique/raddim.h |
---|
614 | endif |
---|
615 | endif |
---|
616 | |
---|
617 | ###################################################################### |
---|
618 | # Gestion du filtre qui n'existe qu'en 3d. |
---|
619 | ###################################################################### |
---|
620 | |
---|
621 | # set filtre to 'oldfiltrez' if using -olddyn option |
---|
622 | if ( "$dyntype" == "olddyn" ) then |
---|
623 | set filtre="oldfiltrez" |
---|
624 | endif |
---|
625 | |
---|
626 | if ( `expr $dimc \> 2` == 1 ) then |
---|
627 | set filtre="FILTRE=$filtre" |
---|
628 | if ( "$dyntype" == "olddyn" ) then |
---|
629 | set src_dirs="$src_dirs oldfiltrez" |
---|
630 | else |
---|
631 | set src_dirs="$src_dirs filtrez" |
---|
632 | endif |
---|
633 | else |
---|
634 | set filtre="FILTRE= L_FILTRE= L_DYN= " |
---|
635 | endif |
---|
636 | echo "MACRO FILTRE $filtre" |
---|
637 | |
---|
638 | echo "dimc $dimc" |
---|
639 | |
---|
640 | #cleanup for a full recompilation, if requested |
---|
641 | if ("$full" == "full") then |
---|
642 | # remove makefile and $libo |
---|
643 | cd $model |
---|
644 | \rm -f makefile |
---|
645 | \rm -rf $libo/* |
---|
646 | endif |
---|
647 | |
---|
648 | ######################################################################## |
---|
649 | # Avant de lancer le make, on recree le makefile si necessaire |
---|
650 | ######################################################################## |
---|
651 | # c'est a dire dans 3 cas: |
---|
652 | # 1. si la liste des fichiers .F et .h a ete modifiee depuis la |
---|
653 | # derniere creation du makefile |
---|
654 | # 2. si le fichier contenant cette liste "liste_des_sources" |
---|
655 | # n'existe pas. |
---|
656 | # 3. Si le makefile n'existe pas. |
---|
657 | ######################################################################## |
---|
658 | |
---|
659 | cd $model |
---|
660 | find libf -name '*.[Fh]' -print | sort >! tmp77 |
---|
661 | #find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90 |
---|
662 | find libf -name '*.[Fh]90' -print | sort >> tmp90 |
---|
663 | |
---|
664 | if ( `diff tmp77 liste_des_sources_f77 | wc -w` \ |
---|
665 | || `diff tmp90 liste_des_sources_f90 | wc -w` \ |
---|
666 | || ! -f makefile \ |
---|
667 | || ! -f liste_des_sources_f90 \ |
---|
668 | || ! -f liste_des_sources_f77 ) then |
---|
669 | echo "les fichiers suivants ont ete crees ou detruits" |
---|
670 | echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90" |
---|
671 | diff liste_des_sources_f77 tmp77 |
---|
672 | diff liste_des_sources_f90 tmp90 |
---|
673 | \cp tmp77 liste_des_sources_f77 |
---|
674 | \cp tmp90 liste_des_sources_f90 |
---|
675 | echo "On recree le makefile" |
---|
676 | echo "src_dirs: $src_dirs" |
---|
677 | ./create_make_gcm $src_dirs >! tmp |
---|
678 | \mv tmp makefile |
---|
679 | echo "Nouveau makefile cree." |
---|
680 | endif |
---|
681 | |
---|
682 | ######################################################################## |
---|
683 | # Execution de la comande make |
---|
684 | ######################################################################## |
---|
685 | |
---|
686 | echo PHYSIQUE $phys |
---|
687 | echo dynamique $dyn $dimension |
---|
688 | echo OPTIM90="$optim90" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code |
---|
689 | echo PATH pour les fichiers INCLUDE $include |
---|
690 | echo OPLINK="$oplink" |
---|
691 | |
---|
692 | if $HP then |
---|
693 | set f77='fort77 +OP' |
---|
694 | set f90='jensaisrien' |
---|
695 | set opt_link="$opt_link -lm" |
---|
696 | else if $VPP then |
---|
697 | set f77=frt |
---|
698 | set f90=$f77 |
---|
699 | else if $CRAY then |
---|
700 | set f77=f90 |
---|
701 | set f90=f90 |
---|
702 | else if $LINUX then |
---|
703 | set f77=ifort |
---|
704 | set f90=ifort |
---|
705 | set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdf " |
---|
706 | else if $SUN then |
---|
707 | set f77=f90 |
---|
708 | set f90=f90 |
---|
709 | else if $NEC then |
---|
710 | set f77=f90 |
---|
711 | set f90=f90 |
---|
712 | else if $XNEC then |
---|
713 | set f77=sxmpif90 |
---|
714 | set f90=sxmpif90 |
---|
715 | else |
---|
716 | set f77=f77 |
---|
717 | set f90=f90 |
---|
718 | endif |
---|
719 | |
---|
720 | cd $model |
---|
721 | |
---|
722 | if $VPP then |
---|
723 | set make="gmake RANLIB=ls" |
---|
724 | else if $CRAY then |
---|
725 | set make="make RANLIB=ls" |
---|
726 | else if $NEC then |
---|
727 | set make="make RANLIB=ls" |
---|
728 | else if $LINUX then |
---|
729 | set make="make -k RANLIB=ranlib" |
---|
730 | else if $XNEC then |
---|
731 | set make="/usr/local/bin/gmake RANLIB=ls" |
---|
732 | set make="/usr/freeware/bin/gmake RANLIB=ls" |
---|
733 | else |
---|
734 | set make="make RANLIB=ranlib" |
---|
735 | endif |
---|
736 | |
---|
737 | set include="$include"" -I$libf/phy$physique" |
---|
738 | |
---|
739 | |
---|
740 | ################################################################# |
---|
741 | # Execution de la comande make... ENFIN! |
---|
742 | ################################################################# |
---|
743 | |
---|
744 | if $VPP then |
---|
745 | set optim90=" $optim90 -Am -M$libo" |
---|
746 | set optimtru90="$optim90" |
---|
747 | else if $SUN then |
---|
748 | set optim90=" $optim90 -M$libo" |
---|
749 | set optimtru90=" $optimtru90 " |
---|
750 | else if $NEC then |
---|
751 | set optim90=" $optim90 -I$libo " |
---|
752 | else if $XNEC then |
---|
753 | set optim90=" $optim90 -I$libo " |
---|
754 | set optimtru90=" $optimtru90 -I$libo " |
---|
755 | else if $LINUX then |
---|
756 | # Ehouarn : adapt to gfortran |
---|
757 | set optim="$optim -I${libo}" |
---|
758 | set optim90="$optim90 -I${libo}" |
---|
759 | set optimtru90="$optimtru90 -I${libo}" |
---|
760 | # Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above) |
---|
761 | # set mod_loc_dir=$libo |
---|
762 | endif |
---|
763 | |
---|
764 | set link="$f90 $optim90" |
---|
765 | |
---|
766 | set ar=ar |
---|
767 | |
---|
768 | if $XNEC then |
---|
769 | set link="sxld $opt_link" |
---|
770 | set link="$f90 " |
---|
771 | # set ar=sxar |
---|
772 | endif |
---|
773 | |
---|
774 | |
---|
775 | cd $localdir |
---|
776 | |
---|
777 | ## locate main program (could be in dyn3d or dynlonlat_phylonlat/phy$physique |
---|
778 | ## or phy$physique/dyn1d and could be .F or .F90) |
---|
779 | set source_code=${code}.F |
---|
780 | set dirmain=dyn${dimc}d |
---|
781 | if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then |
---|
782 | set source_code=${code}.F90 |
---|
783 | endif |
---|
784 | if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F ) then |
---|
785 | set dirmain=phy${physique}/dyn1d |
---|
786 | set source_code=${code}.F |
---|
787 | endif |
---|
788 | if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F90 ) then |
---|
789 | set dirmain=phy${physique}/dyn1d |
---|
790 | set source_code=${code}.F90 |
---|
791 | endif |
---|
792 | if ( -f $LMDGCM/libf/dynlonlat_phylonlat/phy${physique}/${code}.F ) then |
---|
793 | set dirmain=dynlonlat_phylonlat/phy${physique} |
---|
794 | set source_code=${code}.F |
---|
795 | endif |
---|
796 | if ( -f $LMDGCM/libf/dynlonlat_phylonlat/phy${physique}/${code}.F90 ) then |
---|
797 | set dirmain=dynlonlat_phylonlat/phy${physique} |
---|
798 | set source_code=${code}.F90 |
---|
799 | endif |
---|
800 | |
---|
801 | echo $make -f $LMDGCM/makefile \ |
---|
802 | OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ |
---|
803 | OPTIM="$optim" \ |
---|
804 | OPTIM90="$optim90" \ |
---|
805 | OPTIMTRU90="$optimtru90" \ |
---|
806 | INCLUDE="$include" \ |
---|
807 | $filtre \ |
---|
808 | LIBO=$libo \ |
---|
809 | $phys \ |
---|
810 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
811 | DIM=$dimc \ |
---|
812 | DYNTYPE="$dyntype" \ |
---|
813 | L_DYN_PHY="$libdyn_phy" \ |
---|
814 | L_ADJNT="$adjnt" \ |
---|
815 | LOCAL_DIR="$localdir" \ |
---|
816 | F77="$f77" \ |
---|
817 | F90="$f90" \ |
---|
818 | OPLINK="$oplink" \ |
---|
819 | LINK="$link" \ |
---|
820 | GCM="$LMDGCM" \ |
---|
821 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
822 | MOD_SUFFIX=$mod_suffix \ |
---|
823 | AR=$ar \ |
---|
824 | DIRMAIN=$dirmain \ |
---|
825 | SOURCE=$source_code \ |
---|
826 | PROG=$code |
---|
827 | |
---|
828 | |
---|
829 | $make -f $LMDGCM/makefile \ |
---|
830 | OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \ |
---|
831 | OPTIM="$optim" \ |
---|
832 | OPTIM90="$optim90" \ |
---|
833 | OPTIMTRU90="$optimtru90" \ |
---|
834 | INCLUDE="$include" \ |
---|
835 | $filtre \ |
---|
836 | LIBO=$libo \ |
---|
837 | $phys \ |
---|
838 | LIBDYN_PHYS=${LIBDYN_PHYS} \ |
---|
839 | DIM=$dimc \ |
---|
840 | DYNTYPE="$dyntype" \ |
---|
841 | L_DYN_PHY="$libdyn_phy" \ |
---|
842 | L_ADJNT="$adjnt" \ |
---|
843 | LOCAL_DIR="$localdir" \ |
---|
844 | F77="$f77" \ |
---|
845 | F90="$f90" \ |
---|
846 | OPLINK="$oplink" \ |
---|
847 | LINK="$link" \ |
---|
848 | GCM="$LMDGCM" \ |
---|
849 | MOD_LOC_DIR=$mod_loc_dir \ |
---|
850 | MOD_SUFFIX=$mod_suffix \ |
---|
851 | AR=$ar \ |
---|
852 | DIRMAIN=$dirmain \ |
---|
853 | SOURCE=$source_code \ |
---|
854 | PROG=$code |
---|
855 | |
---|
856 | # cleanup, remove dimensions.h |
---|
857 | \rm -f $libf/grid/dimensions.h |
---|