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