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