1 | #!/bin/bash |
---|
2 | set -eu # error on command failure, and on unset variables |
---|
3 | export LC_ALL=C # standardize awk format |
---|
4 | |
---|
5 | ########################################################################### |
---|
6 | # Author : Laurent Fairhead et Frédéric Hourdin |
---|
7 | # Usage : install_lmdz.sh -help |
---|
8 | # |
---|
9 | # bash installation script of the LMDZ model on different computer types : |
---|
10 | # Linux PC, "mesocentre" (IPSL-UPMC, IPSL-X), super-computer (IDRIS) |
---|
11 | # |
---|
12 | # The model is downloaded in the following directory tree |
---|
13 | # $MODEL/modipsl/modeles/... |
---|
14 | # using the "modipsl" infrastructure created by the "IPSL" |
---|
15 | # for coupled (atmosphere/ocean/vegetation/chemistry) climate modeling |
---|
16 | # activities. |
---|
17 | # Here we only download atmospheric (LMDZ) and vegetation (ORCHIDEE) |
---|
18 | # components. |
---|
19 | # |
---|
20 | # The sources of the models can be found in the "modeles" directory. |
---|
21 | # In the present case, LMDZ, ORCHIDEE, and IOIPSL or XIOS (handling of |
---|
22 | # input-outputs using the NetCDF library). |
---|
23 | # |
---|
24 | # The script downloads various source files (including a version of NetCDF) |
---|
25 | # and utilities, compiles the model, and runs a test simulation in a |
---|
26 | # minimal configuration. |
---|
27 | # |
---|
28 | # Prerequisites : gfortran, bash or ksh, wget, gunzip, tar, ... |
---|
29 | # |
---|
30 | # Modif 18/11/2011 |
---|
31 | # changes for option real 8. |
---|
32 | # We compile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM |
---|
33 | # but with -r4 for netcdf. Variable real must be set to |
---|
34 | # r4 or r8 at the beginning of the script below. |
---|
35 | # |
---|
36 | ########################################################################### |
---|
37 | |
---|
38 | ### Functions |
---|
39 | |
---|
40 | function myget { |
---|
41 | # Get a file from LMDZ repository, make it executable if .(ba)sh |
---|
42 | local url=$1 |
---|
43 | |
---|
44 | local filename |
---|
45 | filename=$(basename "$url") |
---|
46 | |
---|
47 | wget --no-check-certificate -nv "http://lmdz.lmd.jussieu.fr/pub/$url" |
---|
48 | if [[ $filename =~ .*\.(ba)?sh ]]; then chmod +x "$filename"; fi |
---|
49 | } |
---|
50 | |
---|
51 | function set_default_params { |
---|
52 | # Valeur par défaut des parametres |
---|
53 | svn_lmdz="" |
---|
54 | version="20240508.CM7" |
---|
55 | |
---|
56 | netcdf=1 |
---|
57 | bench=1 |
---|
58 | SCM=0 |
---|
59 | veget="none" |
---|
60 | grid_resolution="32x32x39" |
---|
61 | benchphysiq="" |
---|
62 | compphysiq="lmd" |
---|
63 | |
---|
64 | parallel="none" |
---|
65 | trusting="testing" |
---|
66 | MODEL="" |
---|
67 | |
---|
68 | with_xios=0 |
---|
69 | opt_makelmdz_xios="" |
---|
70 | |
---|
71 | rad="rrtm" |
---|
72 | |
---|
73 | compile_with_fcm=1 |
---|
74 | |
---|
75 | cosp="none" |
---|
76 | aerosols=0 |
---|
77 | inlandsis=0 |
---|
78 | |
---|
79 | make_j=8 |
---|
80 | clean_install=1 |
---|
81 | |
---|
82 | # Check if on a Mac /!\ Probably doesn't work anymore, to fix one day... |
---|
83 | if [[ $(uname) = "Darwin" ]]; then |
---|
84 | export MAKE="make" |
---|
85 | fi |
---|
86 | |
---|
87 | optim_debug="" |
---|
88 | arch="local" |
---|
89 | |
---|
90 | arch="local-gfortran" |
---|
91 | arch_dir="" |
---|
92 | |
---|
93 | jobcmd="" |
---|
94 | } |
---|
95 | |
---|
96 | function read_cmdline_args { |
---|
97 | while (($# > 0)); do |
---|
98 | case $1 in |
---|
99 | "-h") cat <<........fin |
---|
100 | $0 [ -v version ] [ -r svn_release ] |
---|
101 | [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] |
---|
102 | [-name LOCAL_MODEL_NAME] [-rad RADIATIF] |
---|
103 | |
---|
104 | -v "version" like 20150828.trunk, see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk (default <$version>) |
---|
105 | |
---|
106 | -r "svn_release" : either the svn release number or "last" (default <$svn_lmdz>) |
---|
107 | |
---|
108 | -parallel parallel support: mpi, omp, mpi_omp (mpi with openMP) or none (default: <$parallel>) |
---|
109 | |
---|
110 | -d "grid resolution": should be among the available benchs if -bench 1 (valid values: 48x36x19, 48x36x39) (default : <$grid_resolution>) |
---|
111 | |
---|
112 | -bench activating the bench or not (0/1) (default: <$bench>) |
---|
113 | |
---|
114 | -unstable use unstable tar instead of testing |
---|
115 | |
---|
116 | -name name of the folder to install to (default <$MODEL>) |
---|
117 | |
---|
118 | -netcdf 0, 1 or PATH. 0: do not download NetCDF, look for it in standard locations (/usr); 1: download and compile NetCDF; PATH: full path to an existing installed NetCDF library (default: <$netcdf>) |
---|
119 | |
---|
120 | -xios use (download and compile) the XIOS library (will compile the parallel NetCDF4-HDF5 library) (requires to also have -parallel mpi_omp) |
---|
121 | |
---|
122 | -cosp to run with cospv1 or cospv2 [none/v1/v2] (default <$cosp>) |
---|
123 | |
---|
124 | -rad radiative code: oldrad, rrtm or ecrad (default <$rad>) |
---|
125 | |
---|
126 | -nofcm to compile without fcm |
---|
127 | |
---|
128 | -SCM install 1D version automatically |
---|
129 | |
---|
130 | -debug compile everything in debug mode |
---|
131 | |
---|
132 | -benchphysiq to choose which physics.def package to use in the bench (default <$benchphysiq>) |
---|
133 | |
---|
134 | -compilephysiq physics to compile the model with (default <$compphysiq>) |
---|
135 | |
---|
136 | -veget surface/vegetation scheme treatment controlled by the single variable veget which can have the following values: none: bucket scheme (default); CMIP6 | veget2.0: orchidee version used in CMIP exercise, rev 5661; veget2.2: orchidee branch 2.2, rev 8529 (bundled); number: orchidee version number [only orch>2.0] (default $veget) |
---|
137 | |
---|
138 | -spla activate interactive aerosols |
---|
139 | |
---|
140 | -inlandsis activate new snow scheme |
---|
141 | |
---|
142 | -arch name of the arch to use (default <$arch>) |
---|
143 | |
---|
144 | -arch_dir where to find the arch files (default <$arch_dir>) |
---|
145 | |
---|
146 | -make_j number of processes to parallelize installations (default <$make_j>) |
---|
147 | |
---|
148 | -jobcmd command prepended to fcm compile jobs, e.g. "srun" (default <$jobcmd>) |
---|
149 | |
---|
150 | -noclean will only download necessary files (but no thorough check is made on the integrity of existing files), and will recompile everything (very quick if it's already been compiled before) |
---|
151 | |
---|
152 | ........fin |
---|
153 | exit 1;; |
---|
154 | "-v") version=$2; shift; shift;; |
---|
155 | "-r") svn_lmdz=$2; shift; shift;; |
---|
156 | "-d") grid_resolution=$2; shift; shift;; |
---|
157 | "-unstable") trusting="unstable"; shift;; |
---|
158 | "-cosp") cosp=$2 |
---|
159 | case $cosp in |
---|
160 | "none"|"v1"|"v2") cosp=$2; shift; shift;; |
---|
161 | *) echo "Only none v1 v2 for cosp option"; exit 1 |
---|
162 | esac;; |
---|
163 | "-nofcm") compile_with_fcm=0; echo "This option will be reactivated soon (promesse du 8dec2022)"; exit 1; shift;; |
---|
164 | "-SCM") SCM=1; shift;; |
---|
165 | "-rad") rad=$2 |
---|
166 | case $rad in |
---|
167 | "oldrad"|"rrtm"|"ecrad") rad=$2; shift; shift;; |
---|
168 | *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 |
---|
169 | esac;; |
---|
170 | "-parallel") parallel=$2 |
---|
171 | case $parallel in |
---|
172 | "none"|"mpi"|"omp"|"mpi_omp") parallel=$2; shift; shift;; |
---|
173 | *) echo "Only none mpi omp mpi_omp for the parallel option"; exit 1 |
---|
174 | esac;; |
---|
175 | "-bench") bench=$2; shift; shift;; |
---|
176 | "-debug") optim_debug=-debug; shift;; |
---|
177 | "-name") MODEL=$2; shift; shift;; |
---|
178 | "-netcdf") netcdf=$2; shift; shift;; |
---|
179 | "-benchphysiq") benchphysiq=$2; shift; shift;; |
---|
180 | "-compilephysiq") compphysiq=$2; shift; shift;; |
---|
181 | "-xios") with_xios=1; shift;; |
---|
182 | "-arch") arch=$2; shift; shift;; |
---|
183 | "-arch_dir") arch_dir=$2; shift; shift;; |
---|
184 | "-veget") veget=$2; shift; shift;; |
---|
185 | "-spla") aerosols=1; shift;; |
---|
186 | "-inlandsis") inlandsis=1; shift;; |
---|
187 | "-make_j") make_j=$2; shift; shift;; |
---|
188 | "-jobcmd") jobcmd=$2; shift; shift;; |
---|
189 | "-noclean") clean_install=0; shift;; |
---|
190 | *) bash install_lmdz.sh -h; exit 1 |
---|
191 | esac |
---|
192 | done |
---|
193 | |
---|
194 | # Isotopes : Compile and run with isotopes if lmdz_phys="lmdiso" in main.sh |
---|
195 | if [[ $compphysiq = "lmdiso" ]]; then isotopes=1; else isotopes=0; fi |
---|
196 | |
---|
197 | # Option de compilation pour Cosp |
---|
198 | case $cosp in |
---|
199 | v1) opt_cosp="-cosp true";; |
---|
200 | v2) opt_cosp="-cospv2 true";; |
---|
201 | *) opt_cosp="" |
---|
202 | esac |
---|
203 | |
---|
204 | #Define veget-related suffix for gcm name |
---|
205 | if [[ $veget = 'none' ]]; then |
---|
206 | suff_orc='' |
---|
207 | else |
---|
208 | suff_orc='_orch' |
---|
209 | fi |
---|
210 | |
---|
211 | |
---|
212 | if [[ $parallel = "none" ]]; then |
---|
213 | suff_para='_seq' |
---|
214 | else |
---|
215 | suff_para='_para_mem' |
---|
216 | fi |
---|
217 | |
---|
218 | if [[ $with_xios = 1 ]]; then opt_makelmdz_xios="-io xios"; fi |
---|
219 | |
---|
220 | if [[ $aerosols = 1 ]]; then |
---|
221 | opt_aer="-dust true"; suff_aer="_spla" |
---|
222 | else |
---|
223 | opt_aer=""; suff_aer="" |
---|
224 | fi |
---|
225 | |
---|
226 | if [[ $inlandsis = 1 ]]; then |
---|
227 | opt_inlandsis="-inlandsis true" |
---|
228 | else |
---|
229 | opt_inlandsis="" |
---|
230 | fi |
---|
231 | |
---|
232 | if [[ $isotopes = 1 ]]; then |
---|
233 | opt_isotopes="-isotopes true"; suff_iso="_iso" |
---|
234 | else |
---|
235 | opt_isotopes="" ; suff_iso="" |
---|
236 | fi |
---|
237 | |
---|
238 | # set default arch if parallel |
---|
239 | if [[ $arch = "local-gfortran" && $parallel != "none" ]]; then |
---|
240 | arch="local-gfortran-parallel" |
---|
241 | echo "Switching default arch to $arch" |
---|
242 | fi |
---|
243 | |
---|
244 | # Name of the model's folder. The convention taken here is that models that requires different compilation sources should have a different names. |
---|
245 | local xios_name="" |
---|
246 | if [[ $with_xios = 1 ]]; then xios_name="XIOS"; fi |
---|
247 | if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version${svn_lmdz}OR$veget$xios_name"; fi |
---|
248 | |
---|
249 | if [[ $arch_dir = "" ]]; then |
---|
250 | arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"; |
---|
251 | elif ! readlink -fe "$arch_dir"; then |
---|
252 | echo "STOP: no arch dir <$arch_dir>"; exit 1 |
---|
253 | fi |
---|
254 | } |
---|
255 | |
---|
256 | function ensure_correct_option_combinations { |
---|
257 | # Check on veget version |
---|
258 | if [[ $veget != 'none' && $veget != "CMIP6" && $veget != "orch2.0" && $veget != "orch2.2" ]]; then |
---|
259 | re='^[0-9]+$' |
---|
260 | if ! [[ $veget =~ $re ]]; then |
---|
261 | echo 'Valeur de l option veget non valable'; exit 1 |
---|
262 | fi |
---|
263 | fi |
---|
264 | |
---|
265 | ## if also compiling XIOS, parallel must be mpi_omp |
---|
266 | if [[ $with_xios = 1 && $parallel != "mpi_omp" ]]; then |
---|
267 | echo "Error, you must set -parallel mpi_omp if you want XIOS"; exit 1 |
---|
268 | fi |
---|
269 | |
---|
270 | if [[ $cosp = "v2" && $with_xios = 0 ]]; then |
---|
271 | echo "Error, Cospv2 cannot run without Xios"; exit 1 |
---|
272 | fi |
---|
273 | |
---|
274 | # STOP if trying to use both ORCHIDEE and Isotopes : |
---|
275 | if [[ $isotopes = 1 && $veget != "none" ]]; then |
---|
276 | echo "STOP: You cannot run LMDZ with ORCHIDEE and ISOtopes at the same time"; exit 1 |
---|
277 | fi |
---|
278 | |
---|
279 | # STOP if trying to use both SPLA and Isotopes : |
---|
280 | if [[ $isotopes = 1 && $aerosols = 1 ]]; then |
---|
281 | echo "STOP: You cannot run LMDZ with Isotopes and aerosols=spla at the same time"; exit 1 |
---|
282 | fi |
---|
283 | |
---|
284 | # (Temporary) STOP if trying to use Isotopes with XIOS : |
---|
285 | # TODO Amaury: check if still relevant |
---|
286 | if [[ $isotopes = 1 && $with_xios = 1 ]]; then |
---|
287 | echo "STOP: Isotopes cannont yet be run with XIOS"; exit 1 |
---|
288 | fi |
---|
289 | |
---|
290 | if [[ $aerosols = 1 && $rad != "rrtm" ]]; then |
---|
291 | echo "STOP: For the time being, <aerosols=spla> requires <rad=rrtm>"; exit 1 |
---|
292 | fi |
---|
293 | # TODO: vérifier quelles contraintes sont des contraintes lmdzsetup, et lesquelles sont des vraies contraintes |
---|
294 | } |
---|
295 | |
---|
296 | function check_available_software { |
---|
297 | echo "################################################################" |
---|
298 | echo "Check if required software is available" |
---|
299 | echo "################################################################" |
---|
300 | for logiciel in wget tar gzip make gcc cmake m4 c++; do |
---|
301 | if [[ $(which "$logiciel") = "" ]]; then |
---|
302 | echo "You must first install $logiciel on your system"; exit 1 |
---|
303 | fi |
---|
304 | done |
---|
305 | |
---|
306 | cat <<eod > tt.f90 |
---|
307 | print*,'coucou' |
---|
308 | end |
---|
309 | eod |
---|
310 | $compiler tt.f90 || a.out |
---|
311 | ./a.out >| tt |
---|
312 | if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then |
---|
313 | echo "problem installing with compiler $compiler"; exit 1 |
---|
314 | fi |
---|
315 | \rm tt a.out tt.f90 |
---|
316 | } |
---|
317 | |
---|
318 | function download_model { |
---|
319 | if [[ $clean_install = 1 ]]; then rm -rf "$MODEL"; fi |
---|
320 | |
---|
321 | mkdir -p "$MODEL" |
---|
322 | MODEL=$(readlink -e -f "$MODEL"); echo "$MODEL" # absolute path |
---|
323 | if [[ ! -d "$MODEL/modipsl" ]]; then |
---|
324 | echo "##########################################################" |
---|
325 | echo "Download a slightly modified version of LMDZ" |
---|
326 | echo "##########################################################" |
---|
327 | cd "$MODEL" |
---|
328 | getlog="$(pwd)/get.log" |
---|
329 | echo "logfile : $getlog" |
---|
330 | myget "src_archives/$trusting/modipsl.$version.tar.gz" &>> get.log |
---|
331 | echo "install_lmdz.sh wget_OK $(date)" |
---|
332 | gunzip "modipsl.$version.tar.gz" &>> get.log |
---|
333 | tar xf "modipsl.$version.tar" &>> get.log |
---|
334 | \rm "modipsl.$version.tar" |
---|
335 | cd - &> /dev/null |
---|
336 | fi |
---|
337 | } |
---|
338 | |
---|
339 | function init_arch { |
---|
340 | set +e; arch_dir=$(readlink -f "$arch_dir"); set -e # full path. readlink must be called *after* the path is created |
---|
341 | |
---|
342 | # Check where default fcm, path, env are located - by default in $arch_path, instead in $MODEL/modipsl/modeles/LMDZ/arch/ |
---|
343 | local i fcm_path path_path env_path |
---|
344 | for i in "path" "fcm" "env"; do |
---|
345 | local varname=${i}_path |
---|
346 | if [[ -f $arch_dir/arch-$arch.$i ]]; then |
---|
347 | declare $varname="$arch_dir/arch-$arch.$i" |
---|
348 | else |
---|
349 | declare $varname="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.$i" |
---|
350 | if [[ ! -f ${!varname} ]]; then |
---|
351 | echo "STOP: no ${!varname}"; exit 1 |
---|
352 | fi |
---|
353 | fi |
---|
354 | done |
---|
355 | default_fcm_path=$fcm_path |
---|
356 | default_path_path=$path_path |
---|
357 | default_env_path=$env_path |
---|
358 | |
---|
359 | # check compiler |
---|
360 | compiler=$(< "$default_fcm_path" grep "%COMPILER" | sed -e "s/%COMPILER\s*//") |
---|
361 | |
---|
362 | # load env |
---|
363 | # shellcheck disable=SC1090 |
---|
364 | if [[ -f $default_env_path ]]; then source "$default_env_path"; fi |
---|
365 | |
---|
366 | local mpi_file # can't be done before as it depends on sourcing the env |
---|
367 | mpi_file=$(readlink -e -f "$(which mpif90)") |
---|
368 | path_mpi=$(dirname "$mpi_file") |
---|
369 | root_mpi=$(dirname "$path_mpi") |
---|
370 | } |
---|
371 | |
---|
372 | function install_arch { |
---|
373 | local component=$1 |
---|
374 | |
---|
375 | # Use same .env for all components (for module compatibility) |
---|
376 | cp -f "$default_env_path" "$MODEL/modipsl/modeles/$component/arch" &> /dev/null || true # allow failure if we're copying the file to itself |
---|
377 | |
---|
378 | # Use local .path and .fcm is available, otherwise default |
---|
379 | if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.path" ]]; then |
---|
380 | cp -f "$default_path_path" "$MODEL/modipsl/modeles/$component/arch" |
---|
381 | |
---|
382 | if [[ $component = "ORCHIDEE" ]]; then |
---|
383 | if [[ $orcbranch = "/tags/ORCHIDEE_2_0/ORCHIDEE" ]]; then # 2.0 and before have a different fcm convention |
---|
384 | sed -i'' -e "s/-I//" -e "s/-L//" "$MODEL/modipsl/modeles/ORCHIDEE/arch/arch-$arch.path" # /!\ we only replace first occurence on purpose |
---|
385 | fi |
---|
386 | fi |
---|
387 | fi |
---|
388 | if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.fcm" ]]; then |
---|
389 | cp -f "$default_fcm_path" "$MODEL/modipsl/modeles/$component/arch" |
---|
390 | |
---|
391 | if [[ $component = "XIOS" ]]; then |
---|
392 | # Adapt for XIOS, which uses different naming conventions |
---|
393 | sed -i'' -e "s/%COMPILER/%FCOMPILER/" -e "s/%LINK/%LINKER/" -e "s/-fdefault-real-8//" "$MODEL/modipsl/modeles/XIOS/arch/arch-$arch.fcm" |
---|
394 | fi |
---|
395 | fi |
---|
396 | } |
---|
397 | |
---|
398 | function install_netcdf { |
---|
399 | echo "Installing Netcdf" |
---|
400 | local ncdf_compiler="$compiler" |
---|
401 | |
---|
402 | if [[ $netcdf = 0 ]]; then |
---|
403 | ncdfdir=$(nf-config --prefix) |
---|
404 | else |
---|
405 | cd "$MODEL" |
---|
406 | |
---|
407 | # Convert non-basic compiler |
---|
408 | case $compiler in |
---|
409 | mpif90) ncdf_compiler=$($compiler --version | head -n 1 | cut -d " " -f -1) |
---|
410 | esac |
---|
411 | |
---|
412 | case $ncdf_compiler in |
---|
413 | gfortran | GNU) ncdf_compiler="gfortran"; opt1="-compiler gnu"; opt2="-CC gcc -FC gfortran -CXX g++";; |
---|
414 | *) echo "unexpected compiler $ncdf_compiler for netcdf"; exit 1 |
---|
415 | esac |
---|
416 | |
---|
417 | case $with_xios in |
---|
418 | 0) script_install_netcdf="install_netcdf4_hdf5_seq.bash" |
---|
419 | ncdfdir="netcdf4_hdf5_seq" |
---|
420 | opt_="$opt1";; |
---|
421 | 1) script_install_netcdf="install_netcdf4_hdf5.bash" |
---|
422 | ncdfdir="netcdf4_hdf5" |
---|
423 | opt_="$opt2 -MPI $root_mpi";; |
---|
424 | *) echo "with_xios=$with_xios, should be 0 or 1"; exit 1 |
---|
425 | esac |
---|
426 | if [[ $netcdf = 1 ]]; then |
---|
427 | ncdfdir="$MODEL/$ncdfdir" |
---|
428 | else |
---|
429 | mkdir -p "$netcdf"; ncdfdir="$netcdf/$ncdfdir" |
---|
430 | fi |
---|
431 | |
---|
432 | echo "Repertoire netcdf $ncdfdir" |
---|
433 | if [[ ! -d $ncdfdir ]]; then |
---|
434 | netcdflog=$(pwd)/netcdf.log |
---|
435 | echo "----------------------------------------------------------" |
---|
436 | echo "Compiling the Netcdf library" |
---|
437 | echo "----------------------------------------------------------" |
---|
438 | echo "log file : $netcdflog" |
---|
439 | myget script_install/$script_install_netcdf &>> "$netcdflog" |
---|
440 | chmod u=rwx $script_install_netcdf |
---|
441 | # shellcheck disable=SC2086 |
---|
442 | ./$script_install_netcdf -prefix "$ncdfdir" $opt_ &>> "$netcdflog" |
---|
443 | fi |
---|
444 | |
---|
445 | # Add to path |
---|
446 | export PATH="$ncdfdir/bin:$PATH" |
---|
447 | |
---|
448 | #---------------------------------------------------------------------------- |
---|
449 | # LF rajout d'une verrue, pour une raison non encore expliquee, |
---|
450 | # la librairie est parfois rangée dans lib64 et non dans lib |
---|
451 | # par certains compilateurs |
---|
452 | if [[ ! -e lib && -d lib64 ]]; then ln -s lib64 lib; fi |
---|
453 | #---------------------------------------------------------------------------- |
---|
454 | |
---|
455 | echo "install_lmdz.sh netcdf_OK $(date)" |
---|
456 | fi |
---|
457 | |
---|
458 | cat >test_netcdf90.f90 <<EOF |
---|
459 | use netcdf |
---|
460 | print *, "NetCDF library version: ", nf90_inq_libvers() |
---|
461 | end |
---|
462 | EOF |
---|
463 | |
---|
464 | if $ncdf_compiler -I"$ncdfdir"/include test_netcdf90.f90 -L"$ncdfdir"/lib -lnetcdff -lnetcdf -Wl,-rpath="$ncdfdir"/lib && ./a.out; then |
---|
465 | \rm test_netcdf90.f90 a.out |
---|
466 | else |
---|
467 | cat <<EOF |
---|
468 | Failed test program using NetCDF-Fortran. You can: |
---|
469 | - check that you have NetCDF-Fortran installed in your system |
---|
470 | - or specify an installation directory with option -netcdf of install_lmdz.sh |
---|
471 | - or download and compile NetCDF-Fortran with option -netcdf 1 of install_lmdz.sh |
---|
472 | EOF |
---|
473 | exit 1 |
---|
474 | fi |
---|
475 | |
---|
476 | # Compile NetCDF95 |
---|
477 | cd "$MODEL/modipsl/modeles/LMD"* |
---|
478 | echo "Installing NetCDF95" |
---|
479 | cd "$MODEL" |
---|
480 | if [[ ! -d "NetCDF95-0.3" ]]; then |
---|
481 | myget src_archives/netcdf/NetCDF95-0.3.tar.gz |
---|
482 | tar -xf NetCDF95-0.3.tar.gz |
---|
483 | rm NetCDF95-0.3.tar.gz |
---|
484 | cd NetCDF95-0.3 |
---|
485 | mkdir -p build && cd build |
---|
486 | netCDF_INCLUDE_DIR=$(nc-config --includedir) netCDF_LIBRARY=$(nc-config --libdir) cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$ncdfdir" -DCMAKE_INSTALL_PREFIX="$MODEL/modipsl" |
---|
487 | make install |
---|
488 | fi |
---|
489 | } |
---|
490 | |
---|
491 | function install_IOIPSL { |
---|
492 | install_arch "IOIPSL" |
---|
493 | |
---|
494 | cd "$MODEL/modipsl/modeles/IOIPSL" |
---|
495 | ioipsllog="$(pwd)/ioipsl.log" |
---|
496 | echo "Compiling IOIPSL, the interface library with Netcdf $(date) (log: $ioipsllog)" |
---|
497 | |
---|
498 | echo "$jobcmd ./makeioipsl_fcm -j $make_j -arch $arch" > compile.sh |
---|
499 | chmod +x compile.sh |
---|
500 | echo "Compiling IOIPSL using $(\cat compile.sh)" |
---|
501 | if ! ./compile.sh &> "$ioipsllog"; then |
---|
502 | echo "STOP: IOIPSL compile failed, exiting"; exit 1 |
---|
503 | fi |
---|
504 | |
---|
505 | # Link to modipsl/bin |
---|
506 | cp -f bin/* ../../bin |
---|
507 | |
---|
508 | echo "IOIPSL compiled $(date)" |
---|
509 | } |
---|
510 | |
---|
511 | function install_XIOS { |
---|
512 | if [[ $with_xios = 1 ]]; then |
---|
513 | cd "$MODEL/modipsl/modeles" |
---|
514 | xioslog="$(pwd)/XIOS/xios.log" |
---|
515 | echo "##########################################################" |
---|
516 | echo "Compiling XIOS (log $xioslog) $(date)" |
---|
517 | echo "##########################################################" |
---|
518 | |
---|
519 | # Download XIOS |
---|
520 | local xios_http="http://forge.ipsl.fr/ioserver/svn/XIOS2/branches/xios-2.6" |
---|
521 | local xios_rev="2568" |
---|
522 | |
---|
523 | cd "$MODEL/modipsl/modeles" |
---|
524 | set +e; svn co -r $xios_rev $xios_http XIOS; set -e |
---|
525 | |
---|
526 | cd XIOS |
---|
527 | |
---|
528 | install_arch "XIOS" |
---|
529 | |
---|
530 | echo "$jobcmd ./make_xios --job $make_j --arch $arch" > compile.sh |
---|
531 | chmod +x compile.sh |
---|
532 | echo "$(date) Compiling XIOS using $(\cat compile.sh) (log in $xioslog)" |
---|
533 | if ! ./compile.sh &> "$xioslog"; then |
---|
534 | echo "STOP: XIOS compilation failed, exiting"; exit 1 |
---|
535 | fi |
---|
536 | |
---|
537 | echo "Compiled XIOS $(date)" |
---|
538 | fi |
---|
539 | } |
---|
540 | |
---|
541 | function get_orchidee_version { # Set / Check ORCHIDEE version |
---|
542 | local fetch_rev="" |
---|
543 | orcbranch="" |
---|
544 | case $veget in |
---|
545 | "none") fcm_veget_version="false";; |
---|
546 | "orch2.0" | "CMIP6") fcm_veget_version=orchidee2.0; fetch_rev=7906;; # in previous tar we used 6592 but with some modifications to xios_orchidee.f90, which got integrated in 7906 |
---|
547 | "orch2.2") fcm_veget_version=orchidee2.1; orcbranch="/branches/ORCHIDEE_2_2/ORCHIDEE" ;; # the bundled version |
---|
548 | *) fetch_rev=$veget; fcm_veget_version=orchidee2.1;; # /!\ arbitary rev only works for orch>=2.1 |
---|
549 | # /!\ Note: for orch>=4, we should be using fcm_vegt_version="orchideetrunk". Below copied comment by Adriana in LMDZ_Setup docs: |
---|
550 | # Avec orchidee2.1, on va compiler LMDZ avec le cle cpp ORCHIDEE_NOLIC. On ne va donc pas prendre en compte les avancements fait dans le trunk qui permet que les fractions lic soitent traité par ORCHIDEE. Ca marche très bien sans cela puisque dans tout façon c'est en cours de développement et ce n'est pas activé par default. En fait on devrait compiler le trunk avec -v orchideetrunk mais avec landice_opt>2, ce qui ne change rien par rapport à orchidee2.1 |
---|
551 | #Si on voudrait activer landice_opt=2 , il faut compiler avec -v orchideetrunk. |
---|
552 | |
---|
553 | esac |
---|
554 | |
---|
555 | if [[ -n $fetch_rev ]]; then |
---|
556 | local curr_rev |
---|
557 | curr_rev=$(svn info "$MODEL/modipsl/modeles/ORCHIDEE" | grep Revision: | cut -d ":" -f 2 | cut -c 2-) |
---|
558 | orcbranch=$(svn log -v -q svn://forge.ipsl.fr/orchidee/ -r "$fetch_rev" | grep ORCHIDEE | head -1 | sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}') |
---|
559 | if [[ $fetch_rev != "$curr_rev" ]]; then |
---|
560 | echo "Fetching orch $fetch_rev from the repository (curr: $curr_rev)" |
---|
561 | echo "branch is $orcbranch" |
---|
562 | if [[ $fetch_rev -lt 4465 ]]; then echo 'ORCHIDEE version must be >=4465, exiting'; exit 1; fi |
---|
563 | echo "IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr" |
---|
564 | cd "$MODEL/modipsl/modeles" |
---|
565 | rm -rf ORCHIDEE |
---|
566 | svn co -r "$fetch_rev" "svn://forge.ipsl.fr/orchidee/$orcbranch" |
---|
567 | cd - > /dev/null |
---|
568 | fi |
---|
569 | fi |
---|
570 | |
---|
571 | # Check parallel LMDZ+ORCH |
---|
572 | if [[ (! $veget = "none") && $parallel = "none" && ($used_lmdz_rev -lt 4894) ]]; then |
---|
573 | echo "LMDZ revision must be >=4894 for orchidee without parallel support. Upgrade lmdz or use -parallel mpi_omp."; exit 1 |
---|
574 | fi |
---|
575 | } |
---|
576 | |
---|
577 | function compile_orchidee { |
---|
578 | install_arch "ORCHIDEE" |
---|
579 | |
---|
580 | if [[ $veget != "none" ]]; then |
---|
581 | cd "$MODEL/modipsl/modeles/ORCHIDEE" |
---|
582 | |
---|
583 | orchideelog="$(pwd)/orchidee.log" |
---|
584 | echo "Compiling ORCHIDEE, the continental surface model (log $orchideelog) $(date)" |
---|
585 | |
---|
586 | local xios_orchid opt_orc |
---|
587 | if [[ $with_xios = 1 ]]; then |
---|
588 | xios_orchid="-xios"; |
---|
589 | else |
---|
590 | xios_orchid="-noxios" |
---|
591 | fi |
---|
592 | if [[ $optim_debug = "-debug" ]]; then |
---|
593 | opt_orc="-debug"; |
---|
594 | else |
---|
595 | opt_orc="-prod" |
---|
596 | fi |
---|
597 | |
---|
598 | if [[ $parallel != "none" && ! -d src_parallel ]]; then |
---|
599 | echo "STOP: Orchidee version too old for parallel support"; exit 1 |
---|
600 | fi |
---|
601 | echo "$jobcmd ./makeorchidee_fcm -j $make_j $xios_orchid $opt_orc -parallel $parallel -arch $arch" > compile.sh |
---|
602 | chmod +x compile.sh |
---|
603 | echo "Compiling ORCHIDEE using $(\cat compile.sh)" |
---|
604 | if ! ./compile.sh &> "$orchideelog"; then |
---|
605 | echo "STOP: ORCHIDEE compilation failed, exiting"; exit 1 |
---|
606 | fi |
---|
607 | echo "Compiled ORCHIDEE $(date)" |
---|
608 | fi |
---|
609 | } |
---|
610 | |
---|
611 | function get_lmdz_version { |
---|
612 | LMDZPATH=$(readlink -e -f "$MODEL/modipsl/modeles/LMD"*) |
---|
613 | cd "$LMDZPATH" |
---|
614 | lmdzlog="$(pwd)/lmdz.log" |
---|
615 | |
---|
616 | if [[ -n $svn_lmdz ]]; then |
---|
617 | local curr_rev |
---|
618 | curr_rev=$(svn info "$MODEL/modipsl/modeles/LMD"* | grep Revision: | cut -d ":" -f 2 | cut -c 2-) |
---|
619 | if [[ $svn_lmdz != "$curr_rev" ]]; then |
---|
620 | local lmdzbranch |
---|
621 | echo "Fetching LMDZ $svn_lmdz from the repository" |
---|
622 | lmdzbranch=$(svn log -v -q https://svn.lmd.jussieu.fr/LMDZ -r "$svn_lmdz" | grep LMDZ | head -1 | sed -e 's:trunk/.*$:trunk:' | awk '{print $2}') |
---|
623 | cd "$MODEL/modipsl/modeles" |
---|
624 | rm -rf LMD* |
---|
625 | svn co -r "$svn_lmdz" "https://svn.lmd.jussieu.fr/LMDZ$lmdzbranch" LMDZ |
---|
626 | cd - > /dev/null |
---|
627 | fi |
---|
628 | used_lmdz_rev=$svn_lmdz |
---|
629 | else # get svn from info |
---|
630 | set +e; used_lmdz_rev=$(svn info | grep "Last Changed Rev" | cut -c 19-); set -e |
---|
631 | if [[ -z $used_lmdz_rev ]]; then # svn info failed |
---|
632 | used_lmdz_rev=$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null) |
---|
633 | if [[ -z $used_lmdz_rev ]]; then echo "Could not determine lmdz version. This is likely an issue with the .tar itself, please report to LMDZ team."; exit 1; fi |
---|
634 | fi |
---|
635 | fi |
---|
636 | } |
---|
637 | |
---|
638 | function compile_lmdz { |
---|
639 | install_arch "LMDZ" |
---|
640 | cd "$LMDZPATH" |
---|
641 | |
---|
642 | if [[ $used_lmdz_rev -le 4185 ]]; then |
---|
643 | exe_name="bin/gcm_${grid_resolution}_phy${compphysiq}_${suff_para}${suff_orc}${suff_aer}${suff_iso}.e" |
---|
644 | else |
---|
645 | exe_name="bin/gcm_${grid_resolution}_phy${compphysiq}_${rad}${suff_para}${suff_orc}${suff_aer}${suff_iso}.e" |
---|
646 | fi |
---|
647 | |
---|
648 | local opt_rad |
---|
649 | case $rad in |
---|
650 | oldrad) iflag_rrtm=0; NSW=2; opt_rad="";; |
---|
651 | rrtm) iflag_rrtm=1; NSW=6 |
---|
652 | if [[ $used_lmdz_rev -le 4185 ]]; then |
---|
653 | opt_rad="-rrtm true" |
---|
654 | else |
---|
655 | opt_rad="-rad rrtm" |
---|
656 | fi;; |
---|
657 | ecrad) iflag_rrtm=2; NSW=6; opt_rad="-rad ecrad";; |
---|
658 | *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 |
---|
659 | esac |
---|
660 | if [[ $used_lmdz_rev -le 4185 && $rad = "ecrad" ]]; then |
---|
661 | echo "ecrad only available for LMDZ rev starting with 4186 "; exit 1 |
---|
662 | fi |
---|
663 | |
---|
664 | # Compile |
---|
665 | makelmdz="makelmdz_fcm $optim_debug -arch $arch -j $make_j" |
---|
666 | local para_compile_opt="-mem -parallel $parallel"; if [[ $parallel = "none" ]]; then para_compile_opt=""; fi |
---|
667 | echo "$jobcmd ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios $opt_aer $opt_inlandsis $opt_isotopes -p $compphysiq -d ${grid_resolution} -v $fcm_veget_version $para_compile_opt gcm" > compile.sh |
---|
668 | echo "Compiling lmdz using $(\cat compile.sh) (log: $lmdzlog) $(date)" |
---|
669 | chmod +x ./compile.sh |
---|
670 | if ! ./compile.sh &> "$lmdzlog"; then |
---|
671 | echo "STOP: LMDZ compilation failed, exiting"; exit 1 |
---|
672 | fi |
---|
673 | echo "Finished LMDZ compilation $(date)" |
---|
674 | |
---|
675 | # Check executable |
---|
676 | if [[ ! -f $exe_name ]]; then |
---|
677 | echo "STOP: Compilation failed, can't find the executable"; exit 1 |
---|
678 | else |
---|
679 | echo "Compilation successfull, the executable is $exe_name $(date)" |
---|
680 | fi |
---|
681 | } |
---|
682 | |
---|
683 | function run_bench { |
---|
684 | cd "$MODEL/modipsl/modeles/LMDZ"* |
---|
685 | |
---|
686 | if [[ $bench = "tuto" ]]; then |
---|
687 | myget "Training/tutorial.tar"; tar xf tutorial.tar; cd TUTORIAL |
---|
688 | ./init.sh |
---|
689 | elif [[ $bench = 1 ]]; then |
---|
690 | \rm -rf "BENCH${grid_resolution}" |
---|
691 | local bench=bench_lmdz_${grid_resolution} |
---|
692 | myget "3DBenchs/$bench.tar.gz" |
---|
693 | tar xf "$bench.tar.gz" |
---|
694 | |
---|
695 | if [[ $cosp = "v1" || $cosp = "v2" ]]; then |
---|
696 | cd "BENCH${grid_resolution}" |
---|
697 | # copier les fichiers namelist input et output our COSP |
---|
698 | cp ../DefLists/cosp*_input_nl.txt . |
---|
699 | cp ../DefLists/cosp*_output_nl.txt . |
---|
700 | # Activer la cles ok_cosp pour tourner avec COSP |
---|
701 | sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp |
---|
702 | \mv -f tmp config.def |
---|
703 | cd .. |
---|
704 | fi |
---|
705 | |
---|
706 | if [[ -n "$benchphysiq" ]]; then |
---|
707 | cd "BENCH${grid_resolution}" |
---|
708 | if [[ -f "physiq.def_${benchphysiq}" ]]; then |
---|
709 | cp "physiq.def_${benchphysiq}" benchphysiq.def |
---|
710 | echo "using physiq.def_${benchphysiq}" |
---|
711 | else |
---|
712 | echo "using standard physiq.def" |
---|
713 | fi |
---|
714 | cd .. |
---|
715 | else |
---|
716 | echo "using standard physiq.def" |
---|
717 | fi |
---|
718 | |
---|
719 | if [[ $with_xios = 1 ]]; then |
---|
720 | cd "BENCH${grid_resolution}" |
---|
721 | cp ../DefLists/iodef.xml . |
---|
722 | cp ../DefLists/context_lmdz.xml . |
---|
723 | cp ../DefLists/field_def_lmdz.xml . |
---|
724 | # A raffiner par la suite |
---|
725 | echo "A FAIRE : Copier les *xml en fonction de l option cosp" |
---|
726 | cp ../DefLists/field_def_cosp*.xml . |
---|
727 | cp ../DefLists/file_def_hist*xml . |
---|
728 | # adapt iodef.xml to use attached mode |
---|
729 | sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' \ |
---|
730 | iodef.xml > tmp |
---|
731 | \mv -f tmp iodef.xml |
---|
732 | |
---|
733 | # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. |
---|
734 | # except for histday |
---|
735 | for histfile in file_def_hist*xml; do |
---|
736 | if [[ "$histfile" = "file_def_histday_lmdz.xml" ]]; then |
---|
737 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' \ |
---|
738 | "$histfile" > tmp |
---|
739 | \mv -f tmp "$histfile" |
---|
740 | sed -e 's@output_level="_AUTO_"@output_level="5"@' "$histfile" \ |
---|
741 | > tmp |
---|
742 | \mv -f tmp "$histfile" |
---|
743 | sed -e 's@compression_level="2"@compression_level="0"@' \ |
---|
744 | "$histfile" > tmp |
---|
745 | \mv -f tmp "$histfile" |
---|
746 | else |
---|
747 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ |
---|
748 | "$histfile" > tmp |
---|
749 | \mv -f tmp "$histfile" |
---|
750 | fi |
---|
751 | done |
---|
752 | # and add option "ok_all_xml=y" in config.def |
---|
753 | echo "### XIOS outputs" >> config.def |
---|
754 | echo 'ok_all_xml=.true.' >> config.def |
---|
755 | |
---|
756 | #activer les sorties pour Cosp |
---|
757 | if [[ "$cosp" = "v1" ]]; then |
---|
758 | sed -i'' -e 's@enabled=".FALSE."@enabled=".TRUE."@' \ |
---|
759 | -e 's@output_level="_AUTO_"@output_level="5"@' \ |
---|
760 | -e 's@compression_level="2"@compression_level="0"@' \ |
---|
761 | file_def_histdayCOSP_lmdz.xml |
---|
762 | fi |
---|
763 | if [[ "$cosp" = "v2" ]]; then |
---|
764 | sed -i'' -e 's@compression_level="2"@compression_level="0"@' file_def_histdayCOSPv2_lmdz.xml |
---|
765 | for type_ in hf day mth; do |
---|
766 | file=file_def_hist${type_}COSP |
---|
767 | sed -i'' -e 's@src="./'${file}'_lmdz.xml"@src="./'${file}'v2_lmdz.xml"@' context_lmdz.xml |
---|
768 | done |
---|
769 | sed -i'' -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' field_def_lmdz.xml |
---|
770 | fi |
---|
771 | |
---|
772 | cd .. |
---|
773 | fi |
---|
774 | |
---|
775 | # Cas Bench avec ecrad |
---|
776 | if [[ $rad = "ecrad" ]]; then |
---|
777 | cd "BENCH${grid_resolution}" |
---|
778 | cp ../DefLists/namelist_ecrad . |
---|
779 | cp -r ../libf/phylmd/ecrad/data . |
---|
780 | cd .. |
---|
781 | fi |
---|
782 | |
---|
783 | # Adjusting bench physiq.def to radiative code chosen |
---|
784 | cd "BENCH${grid_resolution}" |
---|
785 | sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' \ |
---|
786 | -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef |
---|
787 | \mv tmpdef physiq.def |
---|
788 | cd .. |
---|
789 | |
---|
790 | cp "$exe_name" "BENCH${grid_resolution}/gcm.e" |
---|
791 | cd "BENCH${grid_resolution}" |
---|
792 | |
---|
793 | local bench_cmd="./bench.sh" |
---|
794 | if [[ ${parallel:0:3} = "mpi" ]]; then |
---|
795 | # Lancement avec deux procs mpi et 2 openMP |
---|
796 | echo "export OMP_STACKSIZE=800M" > bench.sh |
---|
797 | if [[ "${parallel:4:3}" = "omp" ]]; then |
---|
798 | echo "export OMP_NUM_THREADS=2" >> bench.sh |
---|
799 | fi |
---|
800 | if [[ $cosp = "v1" || $cosp = "v2" ]]; then |
---|
801 | echo "ulimit -s 200000" >> bench.sh |
---|
802 | else |
---|
803 | echo "ulimit -s unlimited" >> bench.sh |
---|
804 | fi |
---|
805 | if which mpirun &> /dev/null; then |
---|
806 | echo "mpirun -np 2 gcm.e &> listing" >> bench.sh |
---|
807 | elif grep -q "Adastra" /etc/motd; then |
---|
808 | local account |
---|
809 | account=$(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-) |
---|
810 | bench_cmd="srun --nodes=1 --ntasks=1 --cpus-per-task=2 --threads-per-core=2 --time=0:10:00 --constraint=GENOA --account=$account bash bench.sh" |
---|
811 | echo "./gcm.e &> listing" >> bench.sh |
---|
812 | else |
---|
813 | echo "Error: No command found to run parallel bench"; exit 1 |
---|
814 | fi |
---|
815 | if [[ $(hostname | cut -c -6) = "spirit" ]]; then # ulimit unlimited segfaults on Spirit |
---|
816 | sed -i'' "s/ulimit -s unlimited/ulimit -Ss 8000/" bench.sh |
---|
817 | fi |
---|
818 | # Add rebuild, using reb.sh if it is there |
---|
819 | cat <<EOF >> bench.sh |
---|
820 | if [[ -f reb.sh ]]; then |
---|
821 | ./reb.sh histday; ./reb.sh histmth; ./reb.sh histhf; |
---|
822 | ./reb.sh histins; ./reb.sh stomate_history; |
---|
823 | ./reb.sh sechiba_history; ./reb.sh sechiba_out_2 |
---|
824 | fi |
---|
825 | EOF |
---|
826 | else |
---|
827 | echo "./gcm.e &> listing" > bench.sh |
---|
828 | fi |
---|
829 | # Getting orchidee stuff |
---|
830 | if [[ $veget = 'CMIP6' || $veget = "orch2.0" ]]; then # TODO once we have a 2.2 bench, add it here (or in planned separate bench script) |
---|
831 | echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' |
---|
832 | myget 3DBenchs/BENCHCMIP6.tar.gz |
---|
833 | tar xvzf BENCHCMIP6.tar.gz |
---|
834 | sed -e "s:VEGET=n:VEGET=y:" config.def > tmp |
---|
835 | mv -f tmp config.def |
---|
836 | if [[ $with_xios = 1 ]]; then |
---|
837 | cp ../../ORCHIDEE/src_xml/context_orchidee.xml . |
---|
838 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
839 | cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml . |
---|
840 | cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml . |
---|
841 | cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml . |
---|
842 | if [[ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ]]; then |
---|
843 | cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml . |
---|
844 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
845 | fi |
---|
846 | sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp |
---|
847 | mv tmp iodef.xml |
---|
848 | sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' \ |
---|
849 | file_def_orchidee.xml > tmp |
---|
850 | \mv -f tmp file_def_orchidee.xml |
---|
851 | sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ |
---|
852 | file_def_orchidee.xml > tmp |
---|
853 | \mv -f tmp file_def_orchidee.xml |
---|
854 | sed -e 's@output_level="_AUTO_"@output_level="1"@' \ |
---|
855 | file_def_orchidee.xml > tmp |
---|
856 | \mv -f tmp file_def_orchidee.xml |
---|
857 | sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' \ |
---|
858 | file_def_orchidee.xml > tmp |
---|
859 | \mv -f tmp file_def_orchidee.xml |
---|
860 | sed -e 's@compression_level="4"@compression_level="0"@' \ |
---|
861 | file_def_orchidee.xml > tmp |
---|
862 | \mv -f tmp file_def_orchidee.xml |
---|
863 | sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' \ |
---|
864 | orchidee.def > tmp |
---|
865 | \mv -f tmp orchidee.def |
---|
866 | fi |
---|
867 | fi |
---|
868 | |
---|
869 | if [[ -f ../arch.env ]]; then source ../arch.env; fi |
---|
870 | |
---|
871 | echo "EXECUTION DU BENCH" |
---|
872 | date |
---|
873 | if (! $bench_cmd &> out.bench) || ! (tail -n 1 listing | grep "Everything is cool"); then |
---|
874 | tail listing |
---|
875 | echo "Bench FAILED, exiting"; exit 1 |
---|
876 | fi |
---|
877 | date |
---|
878 | tail listing |
---|
879 | fi |
---|
880 | |
---|
881 | # 1D case |
---|
882 | if [[ $SCM = 1 ]]; then |
---|
883 | cd "$MODEL" |
---|
884 | myget 1D/1D.tar.gz |
---|
885 | tar xf 1D.tar.gz |
---|
886 | cd 1D |
---|
887 | for e in "fcm" "env" "path"; do |
---|
888 | cp "$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.$e" "$MODEL/modipsl/modeles/LMDZ/arch/arch-local.$e" |
---|
889 | done |
---|
890 | if [[ $rad = "oldrad" ]]; then |
---|
891 | sed -i'' -e 's/^rad=.*$/rad=oldrad/' run.sh |
---|
892 | sed -i'' -e 's/^rad=.*$/rad=oldrad/' bin/compile |
---|
893 | elif [[ $rad = ecrad ]] ; then |
---|
894 | sed -i'' -e 's/^rad=.*$/rad=ecrad/' run.sh |
---|
895 | sed -i'' -e 's/^rad=.*$/rad=ecrad/' bin/compile |
---|
896 | fi |
---|
897 | echo "Running 1D/run.sh, log in $(pwd)/run1d.log" |
---|
898 | ./run.sh &> "$(pwd)/run1d.log" |
---|
899 | fi |
---|
900 | } |
---|
901 | |
---|
902 | # If sourced: returns, else run setup |
---|
903 | if [[ ! "${BASH_SOURCE[0]}" = "$0" ]]; then return 0; fi |
---|
904 | |
---|
905 | echo "install_lmdz.sh DEBUT $(date)" |
---|
906 | |
---|
907 | set_default_params |
---|
908 | read_cmdline_args "$@" |
---|
909 | ensure_correct_option_combinations |
---|
910 | download_model |
---|
911 | init_arch |
---|
912 | check_available_software |
---|
913 | get_lmdz_version |
---|
914 | get_orchidee_version |
---|
915 | install_netcdf |
---|
916 | install_IOIPSL |
---|
917 | install_XIOS |
---|
918 | compile_orchidee |
---|
919 | compile_lmdz |
---|
920 | run_bench |
---|