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