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