1 | #!/bin/bash |
---|
2 | |
---|
3 | ########################################################################### |
---|
4 | # Author : Laurent Fairhead et Frédéric Hourdin |
---|
5 | # Usage : install_lmdz.sh -help |
---|
6 | # |
---|
7 | # bash installation script of the LMDZ model on different computer types : |
---|
8 | # Linux PC, "mesocentre" (IPSL-UPMC, IPSL-X), super-computer (IDRIS) |
---|
9 | # |
---|
10 | # The model is downloaded in the following directory tree |
---|
11 | # $MODEL/modipsl/modeles/... |
---|
12 | # using the "modipsl" infrastructure created by the "IPSL" |
---|
13 | # for coupled (atmosphere/ocean/vegetation/chemistry) climate modeling |
---|
14 | # activities. |
---|
15 | # Here we only download atmospheric (LMDZ) and vegetation (ORCHIDEE) |
---|
16 | # components. |
---|
17 | # |
---|
18 | # The sources of the models can be found in the "modeles" directory. |
---|
19 | # In the present case, LMDZ, ORCHIDEE, and IOIPSL or XIOS (handling of input-outputs |
---|
20 | # using the NetCDF library). |
---|
21 | # |
---|
22 | # The script downloads various source files (including a version of NetCDF) |
---|
23 | # and utilities, compiles the model, and runs a test simulation in a |
---|
24 | # minimal configuration. |
---|
25 | # |
---|
26 | # Prerequisites : pgf90/gfortran, bash or ksh, wget , gunzip, tar, ... |
---|
27 | # |
---|
28 | # Modif 18/11/2011 |
---|
29 | # changes for option real 8. |
---|
30 | # We compile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM |
---|
31 | # but with -r4 for netcdf. Variable real must be set to |
---|
32 | # r4 or r8 at the beginning of the script below. |
---|
33 | # |
---|
34 | ########################################################################### |
---|
35 | |
---|
36 | echo install.sh DEBUT `date` |
---|
37 | |
---|
38 | set -e |
---|
39 | |
---|
40 | ################################################################ |
---|
41 | # Choice of installation options |
---|
42 | ################################################################ |
---|
43 | |
---|
44 | # A function to fetch files either locally or on the internet |
---|
45 | function myget { #1st and only argument should be file name |
---|
46 | # Path on local computer where to look for the datafile |
---|
47 | if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then |
---|
48 | \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 . |
---|
49 | elif [ -f ~/LMDZ/pub/$1 ] ; then |
---|
50 | \cp -f -p ~/LMDZ/pub/$1 . |
---|
51 | else |
---|
52 | wget -nv http://www.lmd.jussieu.fr/~lmdz/pub/$1 |
---|
53 | #dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir |
---|
54 | fi |
---|
55 | } |
---|
56 | |
---|
57 | # 04_2021 : tester si r4 marche encore ! |
---|
58 | #real=r4 |
---|
59 | real=r8 |
---|
60 | |
---|
61 | ######################################################################### |
---|
62 | # Valeur par défaut des parametres |
---|
63 | ######################################################################### |
---|
64 | svn="" |
---|
65 | #version=trunk |
---|
66 | version=20210320.trunk |
---|
67 | getlmdzor=1 |
---|
68 | netcdf=1 # 1 for automatic installation |
---|
69 | # 0 for no installation |
---|
70 | # /.../../netcdf-4.0.1 if wanting to link with an already |
---|
71 | # compiled netcdf library (implies to check option compatibility) |
---|
72 | check_linux=1 |
---|
73 | ioipsl=1 |
---|
74 | bench=1 |
---|
75 | pclinux=1 |
---|
76 | pcmac=0 # default: not on a Mac |
---|
77 | compiler=gfortran |
---|
78 | SCM=0 |
---|
79 | # surface/vegetation scheme treatment |
---|
80 | # controlled by the single variable veget which can have the following values |
---|
81 | # - NONE: bucket scheme (default) |
---|
82 | # - CMIP6: orchidee version used in CMIP exercise, rev 5661 |
---|
83 | # - number: orchidee version number (not yet implemented) |
---|
84 | veget=NONE |
---|
85 | # choose the resolution for the bench runs |
---|
86 | # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) |
---|
87 | # 96x71x19 standard configuration |
---|
88 | grid_resolution=144x142x79 |
---|
89 | grid_resolution=96x95x39 |
---|
90 | grid_resolution=48x36x19 |
---|
91 | grid_resolution=32x32x39 |
---|
92 | # choose the physiq version you want to test |
---|
93 | #physiq=NPv6.0.14splith |
---|
94 | physiq= |
---|
95 | |
---|
96 | ## parallel can take the values none/mpi/omp/mpi_omp |
---|
97 | parallel=mpi_omp |
---|
98 | parallel=none |
---|
99 | idris_acct=lmd |
---|
100 | OPT_GPROF="" |
---|
101 | OPT_MAKELMDZ="" |
---|
102 | MODEL="" |
---|
103 | |
---|
104 | ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no |
---|
105 | with_xios="n" |
---|
106 | opt_makelmdz_xios="" |
---|
107 | |
---|
108 | ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0) |
---|
109 | compile_with_fcm=1 |
---|
110 | cosp=0 ; opt_cosp1="" |
---|
111 | cosp=0 ; opt_cosp2="" |
---|
112 | cosp=0 ; opt_cospv2="" |
---|
113 | opt_cosp="" |
---|
114 | |
---|
115 | # Check if on a Mac |
---|
116 | if [ `uname` = "Darwin" ] |
---|
117 | then |
---|
118 | pcmac=1 |
---|
119 | export MAKE=make |
---|
120 | fi |
---|
121 | #echo "pcmac="$pcmac |
---|
122 | |
---|
123 | env_file="" |
---|
124 | |
---|
125 | ######################################################################### |
---|
126 | # Options interactives |
---|
127 | ######################################################################### |
---|
128 | while (($# > 0)) |
---|
129 | do |
---|
130 | case $1 in |
---|
131 | "-h") cat <<........fin |
---|
132 | $0 [ -v version ] [ -r svn_release ] |
---|
133 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
---|
134 | [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] |
---|
135 | |
---|
136 | -v "version" like 20150828.trunk |
---|
137 | see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk |
---|
138 | |
---|
139 | -r "svn_release" : either the svn release number or "last" |
---|
140 | |
---|
141 | -compiler gfortran|ifort|pgf90 (default: gfortran) |
---|
142 | |
---|
143 | -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential) |
---|
144 | |
---|
145 | -d GRID_RESOLUTION should be among the available benchs if -bench 1 |
---|
146 | among which : 48x36x19, 48x36x39 |
---|
147 | if wanting to run a bench simulation in addition to compilation |
---|
148 | default : 48x36x19 |
---|
149 | |
---|
150 | -bench activating the bench or not (0/1). Default 1 |
---|
151 | |
---|
152 | -name LOCAL_MODEL_NAME : default = LMDZversion.release |
---|
153 | |
---|
154 | -netcdf PATH : full path to an existing installed NetCDF library |
---|
155 | (without -netcdf: also download and install the NetCDF library) |
---|
156 | |
---|
157 | -xios also download and compile the XIOS library |
---|
158 | (requires the NetCDF4-HDF5 library, also installed by default) |
---|
159 | (requires to also have -parallel mpi_omp) |
---|
160 | |
---|
161 | -gprof to compile with -pg to enable profiling with gprof |
---|
162 | |
---|
163 | -cosp to compile with cosp(v1) |
---|
164 | |
---|
165 | -cosp2 to compile with cosp(1v2) |
---|
166 | |
---|
167 | -cospv2 to compile with cosp(v2) |
---|
168 | |
---|
169 | -nofcm to compile without fcm |
---|
170 | |
---|
171 | -SCM install 1D version automatically |
---|
172 | |
---|
173 | -debug compile everything in debug mode |
---|
174 | |
---|
175 | -opt_makelmdz to call makelmdz or makelmdz_fcm with additional options |
---|
176 | |
---|
177 | -physiq to choose which physics package to use |
---|
178 | |
---|
179 | -env_file specify an arch.env file to overwrite the existing one |
---|
180 | |
---|
181 | -veget surface model to run [NONE/CMIP6/xxxx] |
---|
182 | |
---|
183 | ........fin |
---|
184 | exit ;; |
---|
185 | "-v") version=$2 ; shift ; shift ;; |
---|
186 | "-r") svn=$2 ; shift ; shift ;; |
---|
187 | "-compiler") compiler=$2 |
---|
188 | case $compiler in |
---|
189 | "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;; |
---|
190 | *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit |
---|
191 | esac ;; |
---|
192 | "-d") grid_resolution=$2 ; shift ; shift ;; |
---|
193 | "-gprof") OPT_GPROF="-pg" ; shift ;; |
---|
194 | "-cosp") cosp=1 ; opt_cosp1="-cosp true" ; shift ;; |
---|
195 | "-cosp2") cosp2=1 ; opt_cosp2="-cosp2 true" ; shift ;; |
---|
196 | "-cospv2") cospv2=1 ; opt_cospv2="-cospv2 true" ; shift ;; |
---|
197 | "-nofcm") compile_with_fcm=0 ; shift ;; |
---|
198 | "-SCM") SCM=1 ; shift ;; |
---|
199 | "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;; |
---|
200 | "-parallel") parallel=$2 |
---|
201 | case $parallel in |
---|
202 | "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;; |
---|
203 | *) echo Only none mpi omp mpi_omp for the parallel option ; exit |
---|
204 | esac ;; |
---|
205 | "-bench") bench=$2 ; shift ; shift ;; |
---|
206 | "-debug") optim=-debug ; shift ;; |
---|
207 | "-name") MODEL=$2 ; shift ; shift ;; |
---|
208 | "-netcdf") netcdf=$2 ; shift ; shift ;; |
---|
209 | "-physiq") physiq=$2 ; shift ; shift ;; |
---|
210 | "-xios") with_xios="y" ; shift ;; |
---|
211 | "-env_file") env_file=$2 ; shift ; shift ;; |
---|
212 | "-veget") veget=$2 ; shift ; shift ;; |
---|
213 | *) ./install_lmdz.sh -h ; exit |
---|
214 | esac |
---|
215 | done |
---|
216 | |
---|
217 | # Check on veget version |
---|
218 | #if [ "$veget" != 'NONE' -a "$veget" != "CMIP6" -a "$veget" != +([0-9]) ] ; then |
---|
219 | if [ $veget != 'NONE' -a $veget != "CMIP6" ] ; then |
---|
220 | re='^[0-9]+$' |
---|
221 | if ! [[ $veget =~ $re ]] ; then |
---|
222 | echo 'Valeur de l option veget non valable' |
---|
223 | exit |
---|
224 | fi |
---|
225 | fi |
---|
226 | |
---|
227 | #Define veget-related suffix for gcm name |
---|
228 | if [ "$veget" = 'NONE' ] ; then |
---|
229 | suff_orc='' |
---|
230 | #For use with tutorial, orchidee_rev is also defined (will be written in surface_env at the end of the script) |
---|
231 | orchidee_rev='' |
---|
232 | else |
---|
233 | suff_orc='_orch' |
---|
234 | fi |
---|
235 | |
---|
236 | |
---|
237 | if [ $parallel = none ] ; then sequential=1; suff_exe='_seq' ; else sequential=0; suff_exe='_para_mem' ; fi |
---|
238 | |
---|
239 | #Chemin pour placer le modele |
---|
240 | if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn$optim ; fi |
---|
241 | |
---|
242 | |
---|
243 | arch=local |
---|
244 | |
---|
245 | |
---|
246 | if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi |
---|
247 | |
---|
248 | ################################################################ |
---|
249 | # Specificite des machines |
---|
250 | ################################################################ |
---|
251 | |
---|
252 | hostname=`hostname` |
---|
253 | if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi |
---|
254 | |
---|
255 | case ${hostname:0:5} in |
---|
256 | |
---|
257 | jean-) compiler="mpiifort" ; |
---|
258 | par_comp="mpiifort" ; |
---|
259 | o_ins_make="-t jeanzay" ; |
---|
260 | make=gmake ; |
---|
261 | module purge |
---|
262 | module load intel-compilers/19.0.4 ; |
---|
263 | #module load intel-mpi/19.0.4 ; |
---|
264 | #module load intel-mkl/19.0.4 ; |
---|
265 | module load hdf5/1.10.5-mpi ; |
---|
266 | module load netcdf/4.7.2-mpi ; |
---|
267 | module load netcdf-fortran/4.5.2-mpi ; |
---|
268 | module load subversion/1.9.7 ; |
---|
269 | export NETCDF_LIBDIR=./ |
---|
270 | export NETCDFFORTRAN_INCDIR=./ |
---|
271 | export NETCDFFORTRAN_LIBDIR=./ |
---|
272 | arch=X64_JEANZAY ;; |
---|
273 | |
---|
274 | cicla|camel) compiler="gfortran" ; |
---|
275 | if [ $parallel != none ] ; then |
---|
276 | module load openmpi/1.6.5-gfortran ; |
---|
277 | root_mpi=$MPI_HOME ; |
---|
278 | path_mpi=$root_mpi/bin ; |
---|
279 | par_comp=${path_mpi}/mpif90 ; |
---|
280 | mpirun=${path_mpi}/mpirun ; |
---|
281 | fi ; |
---|
282 | arch=local ; |
---|
283 | make=make ; |
---|
284 | o_ins_make="-t g95" ;; |
---|
285 | |
---|
286 | *) if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then |
---|
287 | path_mpi=`which mpif90 | sed -e s:/mpif90::` ; |
---|
288 | if [ -d /usr/lib64/openmpi ] ; then |
---|
289 | root_mpi="/usr/lib64/openmpi" |
---|
290 | else |
---|
291 | root_mpi="/usr" |
---|
292 | fi |
---|
293 | # For Scientifique Linux with gfortran at LMD : |
---|
294 | elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 -a $compiler = "gfortran" ] ; then |
---|
295 | path_mpi=/usr/lib64/openmpi/1.4.5-gfortran/bin ; |
---|
296 | root_mpi=/usr/lib64/openmpi/1.4.5-gfortran ; |
---|
297 | export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH |
---|
298 | # For Scientifique Linux with ifort at LMD : |
---|
299 | elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a $compiler = "ifort" ] ; then |
---|
300 | path_mpi=/usr/lib64/openmpi/1.4.5-ifort/bin ; |
---|
301 | root_mpi=/usr/lib64/openmpi/1.4.5-ifort ; |
---|
302 | export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH |
---|
303 | # For Scientifique Linux with pgf90 at LMD : |
---|
304 | elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a $compiler = "pgf90" ] ; then |
---|
305 | path_mpi=/usr/lib64/openmpi/1.4.5-pgf/bin ; |
---|
306 | root_mpi=/usr/lib64/openmpi/1.4.5-pgf ; |
---|
307 | export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH |
---|
308 | else |
---|
309 | echo "Cannot find mpif90" ; |
---|
310 | if [ $parallel = none ] ; then exit ; fi ; |
---|
311 | fi ; |
---|
312 | par_comp=${path_mpi}/mpif90 ; |
---|
313 | mpirun=${path_mpi}/mpirun ; |
---|
314 | arch=local ; |
---|
315 | make=make ; |
---|
316 | o_ins_make="-t g95" |
---|
317 | esac |
---|
318 | |
---|
319 | # Flags for parallelism: |
---|
320 | if [ $parallel != none ] ; then |
---|
321 | # MPI_LD are the flags needed for linking with MPI |
---|
322 | MPI_LD="-L${root_mpi}/lib -lmpi" |
---|
323 | if [ "$compiler" = "gfortran" ] ; then |
---|
324 | # MPI_FLAGS are the flags needed for compilation with MPI |
---|
325 | MPI_FLAGS="-fcray-pointer" |
---|
326 | # OMP_FLAGS are the flags needed for compilation with OpenMP |
---|
327 | OMP_FLAGS="-fopenmp -fcray-pointer" |
---|
328 | # OMP_LD are the flags needed for linking with OpenMP |
---|
329 | OMP_LD="-fopenmp" |
---|
330 | elif [ "$compiler" = "ifort" ] ; then |
---|
331 | MPI_FLAGS="" |
---|
332 | OMP_FLAGS="-openmp" |
---|
333 | OMP_LD="-openmp" |
---|
334 | else # pgf90 |
---|
335 | MPI_FLAGS="" |
---|
336 | OMP_FLAGS="-mp" |
---|
337 | OMP_LD="-mp" |
---|
338 | fi |
---|
339 | fi |
---|
340 | |
---|
341 | ##################################################################### |
---|
342 | # Test for old gfortran compilers |
---|
343 | # If the compiler is too old (older than 4.3.x) we test if the |
---|
344 | # temporary gfortran44 patch is available on the computer in which |
---|
345 | # case the compiler is changed from gfortran to gfortran44 |
---|
346 | # Must be aware than parallelism can not be activated in this case |
---|
347 | ##################################################################### |
---|
348 | |
---|
349 | if [ "$compiler" = "gfortran" ] ; then |
---|
350 | gfortran=gfortran |
---|
351 | gfortranv=`gfortran --version | \ |
---|
352 | head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` |
---|
353 | if [ $gfortranv -le 43 ] ; then |
---|
354 | echo ERROR : Your gfortran compiler is too old |
---|
355 | echo 'Please choose a new one (ifort) and change the line' |
---|
356 | echo compiler=xxx |
---|
357 | echo in the install.sh script and rerun it |
---|
358 | if [ `which gfortran44 | wc -w` -ne 0 ] ; then |
---|
359 | gfortran=gfortran44 |
---|
360 | else |
---|
361 | echo gfotran trop vieux ; exit |
---|
362 | fi |
---|
363 | fi |
---|
364 | compiler=$gfortran |
---|
365 | fi |
---|
366 | ##################################################################### |
---|
367 | |
---|
368 | ## if also compiling XIOS, parallel must be mpi_omp |
---|
369 | if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then |
---|
370 | echo "Error, you must set -parallel mpi_omp if you want XIOS" |
---|
371 | exit |
---|
372 | fi |
---|
373 | |
---|
374 | ## We can't compile with -cosp and -cosp2 |
---|
375 | if [ "$cosp" = 1 -a "$cosp2" = 1 ] ; then |
---|
376 | echo "Error, you can't run with cosp1 and cosp2" |
---|
377 | exit |
---|
378 | fi |
---|
379 | if [ "$cosp" = 1 ] ; then |
---|
380 | opt_cosp="$opt_cosp1" |
---|
381 | fi |
---|
382 | if [ "$cosp2" = 1 ] ; then |
---|
383 | opt_cosp="$opt_cosp2" |
---|
384 | fi |
---|
385 | if [ "$cospv2" = 1 ] ; then |
---|
386 | opt_cosp="$opt_cospv2" |
---|
387 | fi |
---|
388 | |
---|
389 | ## if also compiling XIOS, cosp must be activate to define axis in *.xml |
---|
390 | if [ "$with_xios" = "y" ] ; then |
---|
391 | if [ "$cosp" = 0 -a "$cosp2" = 0 -a "$cospv2" = 0 ] ; then |
---|
392 | echo "Error, you must use -cosp option when compiling with -xios" |
---|
393 | echo "You need to call Cosp in physical first step to define axis variables" |
---|
394 | exit |
---|
395 | fi |
---|
396 | opt_makelmdz_xios="-io xios" |
---|
397 | fi |
---|
398 | |
---|
399 | if [ "$cospv2" = 1 -a "$with_xios" = "n" ] ; then |
---|
400 | echo "Error, Cospv2 cannot run without Xios" |
---|
401 | exit |
---|
402 | fi |
---|
403 | |
---|
404 | echo '################################################################' |
---|
405 | echo Choix des options de compilation |
---|
406 | echo '################################################################' |
---|
407 | |
---|
408 | export FC=$compiler |
---|
409 | export F90=$compiler |
---|
410 | export F77=$compiler |
---|
411 | export CPPFLAGS= |
---|
412 | OPTIMNC=$OPTIM |
---|
413 | BASE_LD="$OPT_GPROF" |
---|
414 | OPTPREC="$OPT_GPROF" |
---|
415 | ARFLAGS="rs" ; if [ -f /etc/issue ] ; then if [ "`grep -i ubuntu /etc/issue`" != "" ] ; then if [ "`grep -i ubuntu /etc/issue | awk ' { print $2 } ' | cut -d. -f1`" -ge 16 ] ; then ARFLAGS="rU" ; fi ; fi ; fi |
---|
416 | |
---|
417 | |
---|
418 | |
---|
419 | if [ "$compiler" = "$gfortran" ] ; then |
---|
420 | OPTIM='-O3' |
---|
421 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan" |
---|
422 | OPTDEV="-Wall -fbounds-check" |
---|
423 | fmod='I ' |
---|
424 | OPTPREC="$OPTPREC -cpp -ffree-line-length-0" |
---|
425 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi |
---|
426 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
427 | export FFLAGS=" $OPTIMNC" |
---|
428 | export CC=gcc |
---|
429 | export CXX=g++ |
---|
430 | export fpp_flags="-P -C -traditional -ffreestanding" |
---|
431 | |
---|
432 | elif [ $compiler = mpif90 ] ; then |
---|
433 | OPTIM='-O3' |
---|
434 | OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" |
---|
435 | OPTDEV="-Wall -fbounds-check" |
---|
436 | BASE_LD="$BASE_LD -lblas" |
---|
437 | fmod='I ' |
---|
438 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi |
---|
439 | export F90FLAGS=" -ffree-form $OPTIMNC" |
---|
440 | export FFLAGS=" $OPTIMNC" |
---|
441 | export CC=gcc |
---|
442 | export CXX=g++ |
---|
443 | |
---|
444 | elif [ $compiler = pgf90 ] ; then |
---|
445 | OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align' |
---|
446 | OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback' |
---|
447 | OPTDEV='-g -Mbounds -Ktrap=fp -traceback' |
---|
448 | fmod='module ' |
---|
449 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi |
---|
450 | export CPPFLAGS="-DpgiFortran" |
---|
451 | export CC=pgcc |
---|
452 | export CFLAGS="-O2 -Msignextend" |
---|
453 | export CXX=pgCC |
---|
454 | export CXXFLAGS="-O2 -Msignextend" |
---|
455 | export FFLAGS="-O2 $OPTIMNC" |
---|
456 | export F90FLAGS="-O2 $OPTIMNC" |
---|
457 | compile_with_fcm=1 |
---|
458 | |
---|
459 | elif [ $compiler = ifort ] ; then |
---|
460 | OPTIM="-O2 -fp-model strict -ip -align all " |
---|
461 | OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" |
---|
462 | OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" |
---|
463 | fmod='module ' |
---|
464 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi |
---|
465 | export CPP="icc -E" |
---|
466 | export FFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
467 | export FCFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
468 | export CC=icc |
---|
469 | export CFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
470 | export CXX=icpc |
---|
471 | export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" |
---|
472 | export fpp_flags="-P -traditional" |
---|
473 | # Pourquoi forcer la compilation fcm. Marche mieux sans |
---|
474 | #compile_with_fcm=1 |
---|
475 | |
---|
476 | elif [ $compiler = mpiifort ] ; then |
---|
477 | echo on ne fait rien la |
---|
478 | # Pourquoi forcer la compilation fcm. Marche mieux sans |
---|
479 | #compile_with_fcm=1 |
---|
480 | |
---|
481 | else |
---|
482 | echo unexpected compiler $compiler ; exit |
---|
483 | fi |
---|
484 | |
---|
485 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
486 | |
---|
487 | hostname=`hostname` |
---|
488 | |
---|
489 | ########################################################################## |
---|
490 | # If installing on known machines such as Jean-Zay at IDRIS, |
---|
491 | # don't check for available software and don't install netcdf |
---|
492 | if [ ${hostname:0:5} = jean- ] ; then |
---|
493 | netcdf=0 # no need to recompile netcdf, alreday available |
---|
494 | check_linux=0 |
---|
495 | pclinux=0 |
---|
496 | ioipsl=0 # no need to recompile ioipsl, already available |
---|
497 | #netcdf="/smplocal/pub/NetCDF/4.1.3" |
---|
498 | compiler="mpiifort" |
---|
499 | fmod='module ' |
---|
500 | if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi |
---|
501 | OPTIM="-auto -align all -O2 -fp-model strict -xHost " |
---|
502 | OPTIMGCM="$OPTIM $OPTPREC" |
---|
503 | fi |
---|
504 | ########################################################################## |
---|
505 | |
---|
506 | |
---|
507 | mkdir -p $MODEL |
---|
508 | echo $MODEL |
---|
509 | MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary |
---|
510 | |
---|
511 | |
---|
512 | echo '################################################################' |
---|
513 | if [ "$check_linux" = 1 ] ; then |
---|
514 | echo Check if required software is available |
---|
515 | echo '################################################################' |
---|
516 | |
---|
517 | #### Ehouarn: test if the required shell is available |
---|
518 | #### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh |
---|
519 | use_shell="bash" # default |
---|
520 | if [ "`which bash`" = "" ] ; then |
---|
521 | echo "no bash ; we will use ksh" |
---|
522 | use_shell="ksh" |
---|
523 | if [ "`which ksh`" = "" ] ; then |
---|
524 | echo "bash (or ksh) needed!! Install it!" |
---|
525 | exit |
---|
526 | fi |
---|
527 | fi |
---|
528 | |
---|
529 | for logiciel in wget tar gzip make $compiler gcc ; do |
---|
530 | if [ "`which $logiciel`" = "" ] ; then |
---|
531 | echo You must first install $logiciel on your system |
---|
532 | exit |
---|
533 | fi |
---|
534 | done |
---|
535 | |
---|
536 | if [ $pclinux = 1 ] ; then |
---|
537 | cd $MODEL |
---|
538 | cat <<eod > tt.f90 |
---|
539 | print*,'coucou' |
---|
540 | end |
---|
541 | eod |
---|
542 | $compiler tt.f90 -o a.out |
---|
543 | ./a.out >| tt |
---|
544 | if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then |
---|
545 | echo problem installing with compiler $compiler ; exit ; fi |
---|
546 | \rm tt a.out tt.f90 |
---|
547 | fi |
---|
548 | fi |
---|
549 | |
---|
550 | ########################################################################### |
---|
551 | if [ $getlmdzor = 1 ] ; then |
---|
552 | echo '##########################################################' |
---|
553 | echo Download a slightly modified version of LMDZ |
---|
554 | echo '##########################################################' |
---|
555 | cd $MODEL |
---|
556 | myget src/modipsl_orc_cmip6.$version.tar.gz |
---|
557 | echo install.sh wget_OK `date` |
---|
558 | gunzip modipsl_orc_cmip6.$version.tar.gz |
---|
559 | tar xvf modipsl_orc_cmip6.$version.tar |
---|
560 | \rm modipsl_orc_cmip6.$version.tar |
---|
561 | fi |
---|
562 | |
---|
563 | echo OK1 |
---|
564 | |
---|
565 | if [ $netcdf = 1 ] ; then |
---|
566 | cd $MODEL |
---|
567 | netcdflog=`pwd`/netcdf.log |
---|
568 | echo '##########################################################' |
---|
569 | echo Compiling the Netcdf library |
---|
570 | echo '##########################################################' |
---|
571 | echo log file : $netcdflog |
---|
572 | if [ "$with_xios" = "n" ] ; then |
---|
573 | # keep it simple |
---|
574 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz |
---|
575 | myget import/netcdf-4.0.1.tar.gz |
---|
576 | gunzip netcdf-4.0.1.tar.gz |
---|
577 | tar xvf netcdf-4.0.1.tar |
---|
578 | \rm -f netcdf-4.0.1.tar |
---|
579 | |
---|
580 | cd netcdf-4.0.1 |
---|
581 | |
---|
582 | localdir=`pwd -P` |
---|
583 | ./configure --prefix=$localdir --enable-shared --disable-cxx |
---|
584 | #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile |
---|
585 | $make check > $netcdflog 2>&1 |
---|
586 | $make install >> $netcdflog 2>&1 |
---|
587 | #LF rajout d'une verrue, pour une raison non encore expliquee, la librairie est parfois rangée dans lib64 |
---|
588 | # et non dans lib par certains compilateurs |
---|
589 | if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi |
---|
590 | else |
---|
591 | # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script |
---|
592 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash |
---|
593 | myget import/install_netcdf4_hdf5.bash |
---|
594 | chmod u=rwx install_netcdf4_hdf5.bash |
---|
595 | if [ "$compiler" = "gfortran" ] ; then |
---|
596 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi > $netcdflog 2>&1 |
---|
597 | elif [ "$compiler" = "ifort" ] ; then |
---|
598 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi > $netcdflog 2>&1 |
---|
599 | elif [ "$compiler" = "pgf90" ] ; then |
---|
600 | ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi > $netcdflog 2>&1 |
---|
601 | else |
---|
602 | echo "unexpected compiler $compiler" ; exit |
---|
603 | fi |
---|
604 | fi # of if [ "$with_xios" = "n" ] |
---|
605 | echo install.sh netcdf_OK `date` |
---|
606 | fi # of if [ $netcdf = 1 ] |
---|
607 | |
---|
608 | #====================================================================================== |
---|
609 | echo OK2 ioipsl=$ioipsl |
---|
610 | echo '##########################################################' |
---|
611 | echo 'Installing MODIPSL, the installation package manager for the ' |
---|
612 | echo 'IPSL models and tools' |
---|
613 | echo '##########################################################' |
---|
614 | |
---|
615 | if [ $netcdf = 0 -o $netcdf = 1 ] ; then |
---|
616 | if [ "$with_xios" = "y" ] ; then |
---|
617 | ncdfdir=$MODEL/netcdf4_hdf5 |
---|
618 | else |
---|
619 | ncdfdir=$MODEL/netcdf-4.0.1 |
---|
620 | fi |
---|
621 | else |
---|
622 | ncdfdir=$netcdf |
---|
623 | fi |
---|
624 | |
---|
625 | if [ $ioipsl = 1 ] ; then |
---|
626 | cd $MODEL/modipsl |
---|
627 | \rm -rf lib/* |
---|
628 | |
---|
629 | cd util |
---|
630 | |
---|
631 | cp AA_make.gdef AA_make.orig |
---|
632 | F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi |
---|
633 | if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi |
---|
634 | sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp |
---|
635 | sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \ |
---|
636 | -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ |
---|
637 | -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ |
---|
638 | -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \ |
---|
639 | -e 's:g95 L_O =:g95 L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \ |
---|
640 | -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ |
---|
641 | -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ |
---|
642 | tmp >| AA_make.gdef |
---|
643 | |
---|
644 | if [ $pcmac == 1 ] |
---|
645 | then |
---|
646 | cp AA_make.gdef tmp |
---|
647 | sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef |
---|
648 | fi |
---|
649 | |
---|
650 | |
---|
651 | # We use lines for g95 even for the other compilers to run ins_make |
---|
652 | if [ "$use_shell" = "ksh" ] ; then |
---|
653 | ./ins_make $o_ins_make |
---|
654 | else # bash |
---|
655 | sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash |
---|
656 | #if [ "`grep ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar |
---|
657 | # \cp -f ~rdzt401/bin/AA_make.gdef . |
---|
658 | #fi |
---|
659 | if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar |
---|
660 | echo 'Warning jean-zay not in AA_make.gdef' |
---|
661 | echo 'Think about updating' |
---|
662 | exit 1 |
---|
663 | fi |
---|
664 | |
---|
665 | chmod u=rwx ins_make.bash |
---|
666 | ./ins_make.bash $o_ins_make |
---|
667 | fi # of if [ "$use_shell" = "ksh" ] |
---|
668 | |
---|
669 | #======================================================================================= |
---|
670 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
671 | ioipsllog=`pwd`/ioipsl.log |
---|
672 | echo '##########################################################' |
---|
673 | echo 'Compiling IOIPSL, the interface library with Netcdf' |
---|
674 | echo '##########################################################' |
---|
675 | echo log file : $ioipsllog |
---|
676 | |
---|
677 | if [ "$use_shell" = "bash" ] ; then |
---|
678 | cp Makefile Makefile.ksh |
---|
679 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
680 | fi |
---|
681 | # if [ "$pclinux" = 1 ] ; then |
---|
682 | # Build IOIPSL modules and library |
---|
683 | $make clean |
---|
684 | $make > $ioipsllog 2>&1 |
---|
685 | if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib |
---|
686 | cp -f *.mod ../../../lib |
---|
687 | fi |
---|
688 | # Build IOIPSL tools (ie: "rebuild", if present) |
---|
689 | if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then |
---|
690 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
691 | # adapt Makefile & rebuild script if in bash |
---|
692 | if [ "$use_shell" = "bash" ] ; then |
---|
693 | cp Makefile Makefile.ksh |
---|
694 | sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile |
---|
695 | cp rebuild rebuild.ksh |
---|
696 | sed -e 's:/bin/ksh:/bin/bash:g' \ |
---|
697 | -e 's:print -u2:echo:g' \ |
---|
698 | -e 's:print:echo:g' rebuild.ksh > rebuild |
---|
699 | fi |
---|
700 | $make clean |
---|
701 | $make > $ioipsllog 2>&1 |
---|
702 | fi |
---|
703 | # fi # of if [ "$pclinux" = 1 ] |
---|
704 | |
---|
705 | else # of if [ $ioipsl = 1 ] |
---|
706 | if [ ${hostname:0:5} = jean- ] ; then |
---|
707 | cd $MODEL/modipsl |
---|
708 | cd util |
---|
709 | if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then |
---|
710 | echo 'Warning jean-zay not in AA_make.gdef' |
---|
711 | echo 'Think about updating' |
---|
712 | exit 1 |
---|
713 | fi |
---|
714 | ./ins_make $o_ins_make |
---|
715 | # Compile IOIPSL on jean-zay |
---|
716 | cd $MODEL/modipsl/modeles/IOIPSL/src |
---|
717 | gmake > ioipsl.log |
---|
718 | cd $MODEL/modipsl/modeles/IOIPSL/tools |
---|
719 | gmake > ioipsl.log |
---|
720 | |
---|
721 | fi |
---|
722 | echo install.sh ioipsl_OK `date` |
---|
723 | fi # of if [ $ioipsl = 1 ] |
---|
724 | # Saving ioipsl lib for possible parallel compile |
---|
725 | cd $MODEL/modipsl |
---|
726 | tar cf ioipsl.tar lib/ bin/ |
---|
727 | |
---|
728 | #=========================================================================== |
---|
729 | if [ "$with_xios" = "y" ] ; then |
---|
730 | echo '##########################################################' |
---|
731 | echo 'Compiling XIOS' |
---|
732 | echo '##########################################################' |
---|
733 | cd $MODEL/modipsl/modeles |
---|
734 | xioslog=`pwd`/xios.log |
---|
735 | echo "log file: $xioslog" |
---|
736 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash |
---|
737 | myget import/install_xios.bash |
---|
738 | chmod u=rwx install_xios.bash |
---|
739 | if [ ${hostname:0:5} = jean- ] ; then |
---|
740 | # echo 'Need to work on install_xios implementation for jean-zay' |
---|
741 | # exit |
---|
742 | svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 XIOS |
---|
743 | cd XIOS/arch |
---|
744 | svn update |
---|
745 | cd .. |
---|
746 | ./make_xios --prod --arch $arch --job 4 > xios.log 2>&1 |
---|
747 | else |
---|
748 | ./install_xios.bash -prefix $MODEL/modipsl/modeles \ |
---|
749 | -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \ |
---|
750 | -MPI $root_mpi -arch $arch > xios.log 2>&1 |
---|
751 | fi |
---|
752 | if [ -f XIOS/lib/libxios.a ] ; then |
---|
753 | echo "OK, XIOS library successfully generated" |
---|
754 | fi |
---|
755 | fi |
---|
756 | |
---|
757 | #============================================================================ |
---|
758 | veget_version=false |
---|
759 | if [ "$veget" != 'NONE' ] ; then |
---|
760 | cd $MODEL/modipsl/modeles/ORCHIDEE |
---|
761 | set +e ; svn upgrade ; set -e |
---|
762 | if [ "$veget" = "CMIP6" ] ; then |
---|
763 | veget_version=orchidee2.0 |
---|
764 | orchidee_rev=6592 |
---|
765 | else # specific orchidee revision |
---|
766 | set +e |
---|
767 | svn log -r $veget | grep $veget |
---|
768 | if [ $? -gt 0 ] ; then |
---|
769 | echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE' |
---|
770 | exit |
---|
771 | fi |
---|
772 | set -e |
---|
773 | set +e ; svn update -r $veget ; set -e |
---|
774 | fi |
---|
775 | # Correctif suite debug Jean-Zay |
---|
776 | sed -i -e 's/9010 FORMAT(A52,F17.14)/9010 FORMAT(A52,F20.14)/' src_stomate/stomate.f90 |
---|
777 | opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi |
---|
778 | |
---|
779 | orchideelog=`pwd`/orchidee.log |
---|
780 | echo '########################################################' |
---|
781 | echo 'Compiling ORCHIDEE, the continental surfaces model ' |
---|
782 | echo '########################################################' |
---|
783 | echo log file : $orchideelog |
---|
784 | export ORCHPATH=`pwd` |
---|
785 | if [ -d tools ] ; then |
---|
786 | ################################################################### |
---|
787 | # Pour les experts qui voudraient changer de version d'orchidee. |
---|
788 | # Attention : necessite d'avoir le password pour orchidee |
---|
789 | |
---|
790 | # Correctif suite debug Jean-Zay |
---|
791 | if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi |
---|
792 | ################################################################### |
---|
793 | if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi |
---|
794 | cd arch |
---|
795 | sed -e s:"%COMPILER .*.$":"%COMPILER $compiler":1 \ |
---|
796 | -e s:"%LINK .*.$":"%LINK $compiler":1 \ |
---|
797 | -e s:"%FPP_FLAGS .*.$":"%FPP_FLAGS $fpp_flags":1 \ |
---|
798 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
799 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
800 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
801 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
802 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
803 | -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
804 | arch-gfortran.fcm > arch-local.fcm |
---|
805 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
806 | echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path |
---|
807 | echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
808 | echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path |
---|
809 | echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path |
---|
810 | echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path |
---|
811 | cd ../ |
---|
812 | # compiling ORCHIDEE sequential mode |
---|
813 | ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel none -arch $arch > $orchideelog 2>&1 |
---|
814 | echo ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel none -arch $arch |
---|
815 | echo End of the first compilation of orchidee ; pwd |
---|
816 | else |
---|
817 | if [ -d src_parallel ] ; then |
---|
818 | liste_src="parallel parameters global stomate sechiba driver" |
---|
819 | if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi |
---|
820 | fi |
---|
821 | for d in $liste_src ; do src_d=src_$d |
---|
822 | echo src_d $src_d |
---|
823 | echo ls ; ls |
---|
824 | if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi |
---|
825 | cd $src_d ; \rm -f *.mod make ; $make clean |
---|
826 | $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi |
---|
827 | cd .. |
---|
828 | done |
---|
829 | fi |
---|
830 | echo install.sh orchidee_OK `date` |
---|
831 | fi # of if [ "$veget" = 1 ] |
---|
832 | |
---|
833 | |
---|
834 | #============================================================================ |
---|
835 | # Ehouarn: the directory name LMDZ* depends on version/tar file... |
---|
836 | if [ -d $MODEL/modipsl/modeles/LMD* ] ; then |
---|
837 | echo '##########################################################' |
---|
838 | echo 'Compiling LMDZ' |
---|
839 | echo '##########################################################' |
---|
840 | cd $MODEL/modipsl/modeles/LMD* |
---|
841 | LMDZPATH=`pwd` |
---|
842 | else |
---|
843 | echo "ERROR: No LMD* directory !!!" |
---|
844 | exit |
---|
845 | fi |
---|
846 | |
---|
847 | ########################################################### |
---|
848 | # For those who want to use fcm to compile via : |
---|
849 | # makelmdz_fcm -arch local ..... |
---|
850 | ############################################################ |
---|
851 | |
---|
852 | if [ "$pclinux" = "1" ] ; then |
---|
853 | |
---|
854 | # create local 'arch' files (if on Linux PC): |
---|
855 | cd arch |
---|
856 | # arch-local.path file |
---|
857 | echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path |
---|
858 | echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path |
---|
859 | echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
860 | echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
861 | echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path |
---|
862 | echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path |
---|
863 | echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
864 | echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path |
---|
865 | |
---|
866 | if [ $pcmac == 1 ] ; then |
---|
867 | BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib" |
---|
868 | else |
---|
869 | BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib" |
---|
870 | fi |
---|
871 | # Arch-local.fcm file (adapted from arch-linux-32bit.fcm) |
---|
872 | |
---|
873 | if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi |
---|
874 | sed -e s:"%COMPILER .*.$":"%COMPILER $compiler":1 \ |
---|
875 | -e s:"%LINK .*.$":"%LINK $compiler":1 \ |
---|
876 | -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ |
---|
877 | -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ |
---|
878 | -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ |
---|
879 | -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ |
---|
880 | -e s:"%FPP_DEF .*.$":"%FPP_DEF $FPP_DEF":1 \ |
---|
881 | -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ |
---|
882 | -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
883 | arch-linux-32bit.fcm > arch-local.fcm |
---|
884 | |
---|
885 | cd .. |
---|
886 | ### Adapt "bld.cfg" (add the shell): |
---|
887 | whereisthatshell=$(which ${use_shell}) |
---|
888 | echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg |
---|
889 | |
---|
890 | fi # of if [ "$pclinux" = 1 ] |
---|
891 | |
---|
892 | |
---|
893 | cd $MODEL/modipsl/modeles/LMDZ* |
---|
894 | lmdzlog=`pwd`/lmdz.log |
---|
895 | |
---|
896 | ################################################################## |
---|
897 | # Possibly update LMDZ if a specific svn release is requested |
---|
898 | ################################################################## |
---|
899 | |
---|
900 | |
---|
901 | set +e ; svn upgrade ; set -e |
---|
902 | if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi |
---|
903 | if [ "$svn" != "" ] ; then |
---|
904 | svn info | grep -q 'http:' |
---|
905 | if [ $? = 0 ] ; then |
---|
906 | svn switch --relocate http://svn.lmd.jussieu.fr/LMDZ https://svn.lmd.jussieu.fr/LMDZ |
---|
907 | fi |
---|
908 | svn update $svnopt |
---|
909 | fi |
---|
910 | set -e |
---|
911 | |
---|
912 | echo '##################################################################' |
---|
913 | echo Compile LMDZ |
---|
914 | echo '##################################################################' |
---|
915 | echo log file : $lmdzlog |
---|
916 | |
---|
917 | if [ "$env_file" != "" ] ; then mv arch/arch-${arch}.env arch/arch-${arch}.orig ; \cp -f $env_file arch/arch-${arch}.env ; fi |
---|
918 | |
---|
919 | echo install.sh avant_compilation `date` |
---|
920 | if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm $optim -arch $arch -j 8 " ; else makelmdz="makelmdz $optim -arch $arch" ; fi |
---|
921 | |
---|
922 | # sequential compilation and bench |
---|
923 | if [ "$sequential" = 1 ] ; then |
---|
924 | echo "./$makelmdz $optim $OPT_MAKELMDZ $optim -rrtm true $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh |
---|
925 | chmod +x ./compile.sh |
---|
926 | if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi |
---|
927 | echo install.sh apres_compilation `date` |
---|
928 | |
---|
929 | |
---|
930 | fi # fin sequential |
---|
931 | |
---|
932 | |
---|
933 | |
---|
934 | # compiling in parallel mode |
---|
935 | if [ $parallel != "none" ] ; then |
---|
936 | echo '##########################################################' |
---|
937 | echo ' Parallel compile ' |
---|
938 | echo '##########################################################' |
---|
939 | # saving the sequential libs and binaries |
---|
940 | cd $MODEL/modipsl |
---|
941 | tar cf sequential.tar bin/ lib/ |
---|
942 | \rm -rf bin/ lib/ |
---|
943 | tar xf ioipsl.tar |
---|
944 | # |
---|
945 | # Orchidee |
---|
946 | # |
---|
947 | cd $ORCHPATH |
---|
948 | if [ -d src_parallel -a $veget != 'NONE' ] ; then |
---|
949 | cd arch |
---|
950 | sed \ |
---|
951 | -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
952 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
953 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
954 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
955 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
956 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
957 | arch-local.fcm > tmp.fcm |
---|
958 | |
---|
959 | mv tmp.fcm arch-local.fcm |
---|
960 | cd ../ |
---|
961 | echo compiling ORCHIDEE parallel mode |
---|
962 | echo logfile $orchideelog |
---|
963 | ./makeorchidee_fcm -j 8 -clean -noxios $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1 |
---|
964 | ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1 |
---|
965 | echo ./makeorchidee_fcm -j 8 -clean -noxios $opt_orc -parallel $parallel -arch $arch |
---|
966 | echo ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel $parallel -arch $arch |
---|
967 | elif [ $veget != 'NONE' ] ; then |
---|
968 | echo '##########################################################' |
---|
969 | echo ' Orchidee version too old ' |
---|
970 | echo ' Please update to new version ' |
---|
971 | echo '##########################################################' |
---|
972 | exit |
---|
973 | fi # of if [ -d src_parallel ] |
---|
974 | # LMDZ |
---|
975 | cd $LMDZPATH |
---|
976 | if [ $arch = local ] ; then |
---|
977 | cd arch |
---|
978 | sed -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ |
---|
979 | -e s:"%LINK.*.$":"%LINK $par_comp":1 \ |
---|
980 | -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ |
---|
981 | -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ |
---|
982 | -e s:"%ARFLAGS.*.$":"%ARFLAGS $ARFLAGS":1 \ |
---|
983 | -e s@"%BASE_LD.*.$"@"%BASE_LD -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \ |
---|
984 | -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ |
---|
985 | -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ |
---|
986 | arch-local.fcm > tmp.fcm |
---|
987 | mv tmp.fcm arch-local.fcm |
---|
988 | cd ../ |
---|
989 | fi |
---|
990 | rm -f compile.sh |
---|
991 | echo resol=${grid_resolution} >> compile.sh |
---|
992 | if [ ${hostname:0:5} = jean- -a "$cospv2" = 1 ] ; then |
---|
993 | echo ./$makelmdz -dev $optim $OPT_MAKELMDZ -rrtm true $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh |
---|
994 | echo ./$makelmdz -dev $optim $OPT_MAKELMDZ -rrtm true $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm |
---|
995 | else |
---|
996 | echo ./$makelmdz $optim $OPT_MAKELMDZ -rrtm true $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh |
---|
997 | echo ./$makelmdz $optim $OPT_MAKELMDZ -rrtm true $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm |
---|
998 | fi |
---|
999 | chmod +x ./compile.sh |
---|
1000 | if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi |
---|
1001 | |
---|
1002 | echo "Compilation finished" |
---|
1003 | |
---|
1004 | fi # of if [ $parallel != "none" ] |
---|
1005 | |
---|
1006 | |
---|
1007 | ################################################################## |
---|
1008 | # Verification du succes de la compilation |
---|
1009 | ################################################################## |
---|
1010 | |
---|
1011 | # Recherche de l'executable dont le nom a change au fil du temps ... |
---|
1012 | gcm="" |
---|
1013 | #for exe in gcm.e bin/gcm_${grid_resolution}_phylmd_seq_orch.e bin/gcm_${grid_resolution}_phylmd_seq.e bin/gcm_${grid_resolution}_phylmd_para_mem_orch.e bin/gcm_${grid_resolution}_phylmd_para_mem.e ; do |
---|
1014 | for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e ; do if [ -f $exe ] ; then gcm=$exe ; fi |
---|
1015 | done |
---|
1016 | |
---|
1017 | if [ "$gcm" = "" ] ; then |
---|
1018 | if [ $bench != 0 ] ; then |
---|
1019 | echo 'Compilation failed !! Cannot run the benchmark;' |
---|
1020 | exit |
---|
1021 | else |
---|
1022 | echo 'Compilation not done (only done when bench=1)' |
---|
1023 | fi |
---|
1024 | else |
---|
1025 | echo '##########################################################' |
---|
1026 | echo 'Compilation successfull !! ' |
---|
1027 | echo '##########################################################' |
---|
1028 | echo The executable is $gcm |
---|
1029 | fi |
---|
1030 | |
---|
1031 | ################################################################## |
---|
1032 | # Below, we run a benchmark test (if bench=0) |
---|
1033 | ################################################################## |
---|
1034 | |
---|
1035 | if [ $bench != 0 ] ; then |
---|
1036 | |
---|
1037 | echo '##########################################################' |
---|
1038 | echo ' Running a test run ' |
---|
1039 | echo '##########################################################' |
---|
1040 | |
---|
1041 | \rm -rf BENCH${grid_resolution} |
---|
1042 | bench=bench_lmdz_${grid_resolution} |
---|
1043 | echo install.sh before bench download `date` |
---|
1044 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz |
---|
1045 | myget 3DBenchs/$bench.tar.gz |
---|
1046 | echo install.sh after bench download `date` |
---|
1047 | tar xvf $bench.tar.gz |
---|
1048 | |
---|
1049 | if [ "$cosp" = 1 -o "$cosp2" = 1 -o "$cospv2" = 1 ] ; then |
---|
1050 | cd BENCH${grid_resolution} |
---|
1051 | # copier les fichiers namelist input et output our COSP |
---|
1052 | cp ../DefLists/cosp*_input_nl.txt . |
---|
1053 | cp ../DefLists/cosp*_output_nl.txt . |
---|
1054 | # Activer la cles ok_cosp pour tourner avec COSP |
---|
1055 | sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp |
---|
1056 | \mv -f tmp config.def |
---|
1057 | cd .. |
---|
1058 | fi |
---|
1059 | |
---|
1060 | if [ -n "$physiq" ]; then |
---|
1061 | cd BENCH${grid_resolution} |
---|
1062 | if [ -f physiq.def_${physiq} ]; then |
---|
1063 | cp physiq.def_${physiq} physiq.def |
---|
1064 | echo using physiq.def_${physiq} |
---|
1065 | else |
---|
1066 | echo using standard physiq.def |
---|
1067 | fi |
---|
1068 | cd .. |
---|
1069 | else |
---|
1070 | echo using standard physiq.def |
---|
1071 | fi |
---|
1072 | |
---|
1073 | if [ "$with_xios" = "y" ] ; then |
---|
1074 | cd BENCH${grid_resolution} |
---|
1075 | cp ../DefLists/iodef.xml . |
---|
1076 | cp ../DefLists/context_lmdz.xml . |
---|
1077 | cp ../DefLists/field_def_lmdz.xml . |
---|
1078 | cp ../DefLists/field_def_cosp*.xml . |
---|
1079 | cp ../DefLists/file_def_hist*xml . |
---|
1080 | # adapt iodef.xml to use attached mode |
---|
1081 | sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp |
---|
1082 | \mv -f tmp iodef.xml |
---|
1083 | |
---|
1084 | # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. |
---|
1085 | # except for histday |
---|
1086 | for histfile in file_def_hist*xml |
---|
1087 | do |
---|
1088 | if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then |
---|
1089 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1090 | sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1091 | sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1092 | else |
---|
1093 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1094 | fi |
---|
1095 | done |
---|
1096 | # and add option "ok_all_xml=y" in config.def |
---|
1097 | echo "### XIOS outputs" >> config.def |
---|
1098 | echo 'ok_all_xml=.true.' >> config.def |
---|
1099 | |
---|
1100 | #activer les sorties pour Cosp |
---|
1101 | if [ "$cosp" = 1 -o "$cosp2" = 1 ] ; then |
---|
1102 | histfile=file_def_histdayCOSP_lmdz.xml |
---|
1103 | sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1104 | sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1105 | sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1106 | fi |
---|
1107 | if [ "$cospv2" = 1 ] ; then |
---|
1108 | histfile=file_def_histdayCOSPv2_lmdz.xml |
---|
1109 | sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile |
---|
1110 | contextfile=context_lmdz.xml |
---|
1111 | sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile |
---|
1112 | fieldfile=field_def_lmdz.xml |
---|
1113 | sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile |
---|
1114 | fi |
---|
1115 | |
---|
1116 | cd .. |
---|
1117 | fi |
---|
1118 | |
---|
1119 | cp $gcm BENCH${grid_resolution}/gcm.e |
---|
1120 | |
---|
1121 | cd BENCH${grid_resolution} |
---|
1122 | # On cree le fichier bench.sh au besoin |
---|
1123 | # Dans le cas 48x36x39 le bench.sh existe deja en parallele |
---|
1124 | |
---|
1125 | if [ "$grid_resolution" = "48x36x39" ] ; then |
---|
1126 | echo On ne touche pas au bench.sh |
---|
1127 | # But we have to adapt "run_local.sh" for $mpirun |
---|
1128 | sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp |
---|
1129 | mv -f tmp run_local.sh |
---|
1130 | chmod u=rwx run_local.sh |
---|
1131 | elif [ "${parallel:0:3}" = "mpi" ] ; then |
---|
1132 | # Lancement avec deux procs mpi et 2 openMP |
---|
1133 | echo "export OMP_STACKSIZE=800M" > bench.sh |
---|
1134 | if [ "${parallel:4:3}" = "omp" ] ; then |
---|
1135 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
---|
1136 | fi |
---|
1137 | if [ "$cospv2" = 1 -o "$cosp" = 1 -o "$cosp2" = 1 ] ; then |
---|
1138 | if [ ${hostname:0:5} = jean- ] ; then |
---|
1139 | chmod +x ../arch.env |
---|
1140 | ../arch.env |
---|
1141 | echo "ulimit -s 2000000" >> bench.sh |
---|
1142 | else |
---|
1143 | echo "ulimit -s 200000" >> bench.sh |
---|
1144 | fi |
---|
1145 | else |
---|
1146 | echo "ulimit -s unlimited" >> bench.sh |
---|
1147 | fi |
---|
1148 | if [ ${hostname:0:5} = jean- ] ; then |
---|
1149 | . ../arch/arch-${arch}.env |
---|
1150 | echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing 2>&1" >> bench.sh |
---|
1151 | else |
---|
1152 | echo "$mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh |
---|
1153 | fi |
---|
1154 | # Add rebuild, using reb.sh if it is there |
---|
1155 | echo 'if [ -f reb.sh ] ; then' >> bench.sh |
---|
1156 | echo ' ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ./reb.sh histins ; ./reb.sh stomate_history ; ./reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh |
---|
1157 | echo 'fi' >> bench.sh |
---|
1158 | else |
---|
1159 | echo "./gcm.e > listing 2>&1" > bench.sh |
---|
1160 | fi |
---|
1161 | # Getting orchidee stuff |
---|
1162 | if [ $veget == 'CMIP6' ] ; then |
---|
1163 | #echo 'myget 3DBenchs/BENCHorch11.tar.gz' |
---|
1164 | #myget 3DBenchs/BENCHorch11.tar.gz |
---|
1165 | #tar xvzf BENCHorch11.tar.gz |
---|
1166 | echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' |
---|
1167 | myget 3DBenchs/BENCHCMIP6.tar.gz |
---|
1168 | tar xvzf BENCHCMIP6.tar.gz |
---|
1169 | sed -e "s:VEGET=n:VEGET=y:" config.def > tmp |
---|
1170 | mv -f tmp config.def |
---|
1171 | fi |
---|
1172 | echo EXECUTION DU BENCH |
---|
1173 | set +e |
---|
1174 | date ; ./bench.sh > out.bench 2>&1 ; date |
---|
1175 | set -e |
---|
1176 | tail listing |
---|
1177 | |
---|
1178 | |
---|
1179 | echo '##########################################################' |
---|
1180 | echo 'Simulation finished in' `pwd` |
---|
1181 | echo 'You have compiled with:' |
---|
1182 | cat ../compile.sh |
---|
1183 | if [ $parallel = "none" ] ; then |
---|
1184 | echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' |
---|
1185 | echo 'or ./bench.sh' |
---|
1186 | else |
---|
1187 | echo 'You may re-run it with : ' |
---|
1188 | echo 'cd ' `pwd` '; ./bench.sh' |
---|
1189 | # echo 'ulimit -s unlimited' |
---|
1190 | # echo 'export OMP_NUM_THREADS=2' |
---|
1191 | # echo 'export OMP_STACKSIZE=800M' |
---|
1192 | # echo "$mpirun -np 2 gcm.e " |
---|
1193 | fi |
---|
1194 | echo '##########################################################' |
---|
1195 | |
---|
1196 | fi # bench |
---|
1197 | |
---|
1198 | |
---|
1199 | ################################################################# |
---|
1200 | # Installation eventuelle du 1D |
---|
1201 | ################################################################# |
---|
1202 | |
---|
1203 | if [ $SCM = 1 ] ; then |
---|
1204 | cd $MODEL |
---|
1205 | #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz |
---|
1206 | myget 1D/1D.tar.gz |
---|
1207 | tar xvf 1D.tar.gz |
---|
1208 | cd 1D |
---|
1209 | ./run.sh |
---|
1210 | fi |
---|
1211 | set -vx |
---|
1212 | |
---|
1213 | ################################################################# |
---|
1214 | # sauvegarde des options veget pour utilisation eventuelle tutorial_prod |
---|
1215 | ################################################################# |
---|
1216 | cd $MODEL/modipsl/modeles |
---|
1217 | echo surface_env file created in $MODEL |
---|
1218 | echo 'veget='$veget > surface_env |
---|
1219 | #opt_veget="-v $veget_version" |
---|
1220 | #echo 'opt_veget="'$opt_veget\" >> surface_env |
---|
1221 | echo 'opt_veget="'-v $veget_version\" >> surface_env |
---|
1222 | echo 'orchidee_rev='$orchidee_rev >> surface_env |
---|
1223 | echo 'suforch='$suff_orc >> surface_env |
---|
1224 | |
---|
1225 | |
---|
1226 | |
---|
1227 | |
---|