Changeset 5361
- Timestamp:
- Dec 2, 2024, 5:21:37 PM (27 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BOL/script_install/install_lmdz.sh
r5021 r5361 1 1 #!/bin/bash 2 3 #set -vx 2 set -eu # error on command failure, and on unset variables 3 export LC_ALL=C # standardize awk format 4 4 5 5 ########################################################################### … … 26 26 # minimal configuration. 27 27 # 28 # Prerequisites : pgf90/gfortran, bash or ksh, wget, gunzip, tar, ...28 # Prerequisites : gfortran, bash or ksh, wget, gunzip, tar, ... 29 29 # 30 30 # Modif 18/11/2011 … … 36 36 ########################################################################### 37 37 38 echo install_lmdz.sh DEBUT `date` 39 set -e 40 41 ################################################################ 42 # Choice of installation options 43 ################################################################ 44 45 ################################################################ 46 # A function to fetch files either locally or on the internet 47 ################################################################ 48 function myget { #1st and only argument should be file name 49 # Path on local computer where to look for the datafile 50 if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then 51 \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 . 52 elif [ -f ~/LMDZ/pub/$1 ] ; then 53 \cp -f -p ~/LMDZ/pub/$1 . 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 do_compile_sh { 52 local component=$1 53 local command=$2 54 local log 55 56 log="$(pwd)/$component.log" 57 echo "$command" > compile.sh 58 echo "Compiling $component using $(\cat compile.sh) (log: $log) $(date)" 59 chmod +x ./compile.sh 60 if ! ./compile.sh &> "$log"; then 61 echo "STOP: $component compilation failed, exiting"; exit 1 62 fi 63 echo "Finished $component compilation $(date)" 64 } 65 66 function get_svn_branch { 67 local url=$1 68 local rev=$2 69 local res 70 71 res=$(svn log -v -q "$url" -r "$rev" -l 1 | cut -d "/" -f -4) 72 if echo "$res" | grep -q "/trunk/"; then 73 res=$(echo "$res" | grep "/trunk/" | head -1 | cut -d "/" -f 2-3) 74 elif echo "$res" | grep -q "/branches/"; then 75 res=$(echo "$res" | grep "/branches/" | head -1 | cut -d "/" -f 2-4) 76 else 77 echo "Could not determine svn branch for $url, r=$rev" 78 fi 79 echo "$res" 80 } 81 82 function set_default_params { 83 # Valeur par défaut des parametres 84 svn_lmdz="" 85 version="20241018.trunk" 86 87 netcdf=1 88 bench=1 89 SCM=0 90 veget="none" 91 grid_resolution="32x32x39" 92 benchphysiq="" 93 compphysiq="lmd" 94 is_1D="n" 95 fortran_file="gcm" 96 97 parallel="none" 98 trusting="testing" 99 MODEL="" 100 101 with_xios=0 102 opt_makelmdz_xios="" 103 104 icolmdz=0 105 dynamico_commit="11001689" 106 107 rad="rrtm" 108 109 compile_with_fcm=1 110 111 cosp="none" 112 aerosols=0 113 strataer=0 114 inlandsis=0 115 116 make_j=8 117 clean_install=1 118 local="$(pwd)" 119 120 # Check if on a Mac /!\ Probably doesn't work anymore, to fix one day... 121 if [[ $(uname) = "Darwin" ]]; then 122 export MAKE="make" 123 fi 124 125 optim_flag="-prod" 126 arch="local" 127 128 arch="local-gfortran" 129 arch_dir="" 130 131 jobcmd="" 132 } 133 134 function read_cmdline_args { 135 while (($# > 0)); do 136 case $1 in 137 "-h") cat <<........fin 138 $0 [ -v version ] [ -r svn_release ] 139 [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] 140 [-name LOCAL_MODEL_NAME] [-rad RADIATIF] 141 142 -v "version" like 20150828.trunk, see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk (default <$version>) 143 144 -r "svn_release" : either the svn release number or "last" (default <$svn_lmdz>) 145 146 -parallel parallel support: mpi, omp, mpi_omp (mpi with openMP) or none (default: <$parallel>) 147 148 -d "grid resolution": should be among the available benchs if -bench 1 (valid values: 48x36x19, 48x36x39) (default : <$grid_resolution>) 149 150 -bench activating the bench or not (0/1) (default: <$bench>) 151 152 -unstable use unstable tar instead of testing 153 154 -name name of the folder to install to (default <$MODEL>) 155 156 -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>) 157 158 -xios use (download and compile) the XIOS library (will compile the parallel NetCDF4-HDF5 library) (requires to also have -parallel mpi_omp) 159 160 -cosp to run with cospv1 or cospv2 [none/v1/v2] (default <$cosp>) 161 162 -rad radiative code: oldrad, rrtm or ecrad (default <$rad>) 163 164 -nofcm to compile without fcm 165 166 -SCM install 1D version automatically 167 168 -debug compile everything in debug mode 169 170 -benchphysiq to choose which physics.def package to use in the bench (default <$benchphysiq>) 171 172 -compilephysiq physics to compile the model with (default <$compphysiq>) 173 174 -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) 175 176 -spla activate interactive aerosols 177 178 -inlandsis activate new snow scheme 179 180 -arch name of the arch to use (default <$arch>) 181 182 -arch_dir where to find the arch files (default <$arch_dir>) 183 184 -make_j number of processes to parallelize installations (default <$make_j>) 185 186 -jobcmd command prepended to fcm compile jobs, e.g. "srun" (default <$jobcmd>) 187 188 -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) 189 190 -icolmdz to compile the icolmdz executable as well as the lonlat one 191 192 ........fin 193 exit 1;; 194 "-v") version=$2; shift; shift;; 195 "-r") svn_lmdz=$2; shift; shift;; 196 "-d") grid_resolution=$2; shift; shift;; 197 "-unstable") trusting="unstable"; shift;; 198 "-cosp") cosp=$2 199 case $cosp in 200 "none"|"v1"|"v2") cosp=$2; shift; shift;; 201 *) echo "Only none v1 v2 for cosp option"; exit 1 202 esac;; 203 "-nofcm") compile_with_fcm=0; echo "This option will be reactivated soon (promesse du 8dec2022)"; exit 1; shift;; 204 "-SCM") SCM=1; shift;; 205 "-rad") rad=$2 206 case $rad in 207 "oldrad"|"rrtm"|"ecrad") rad=$2; shift; shift;; 208 *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 209 esac;; 210 "-parallel") parallel=$2 211 case $parallel in 212 "none"|"mpi"|"omp"|"mpi_omp") parallel=$2; shift; shift;; 213 *) echo "Only none mpi omp mpi_omp for the parallel option"; exit 1 214 esac;; 215 "-bench") bench=$2; shift; shift;; 216 "-debug") optim_flag="-debug"; shift;; 217 "-name") MODEL=$2; shift; shift;; 218 "-netcdf") netcdf=$2; shift; shift;; 219 "-benchphysiq") benchphysiq=$2; shift; shift;; 220 "-compilephysiq") compphysiq=$2; shift; shift;; 221 "-xios") with_xios=1; shift;; 222 "-arch") arch=$2; shift; shift;; 223 "-arch_dir") arch_dir=$2; shift; shift;; 224 "-veget") veget=$2; shift; shift;; 225 "-spla") aerosols=1; shift;; 226 "-strataer") strataer=1; shift;; 227 "-inlandsis") inlandsis=1; shift;; 228 "-make_j") make_j=$2; shift; shift;; 229 "-jobcmd") jobcmd=$2; shift; shift;; 230 "-noclean") clean_install=0; shift;; 231 "-icolmdz") icolmdz=1; shift;; 232 *) bash install_lmdz.sh -h; exit 1 233 esac 234 done 235 236 # Isotopes : Compile and run with isotopes if lmdz_phys="lmdiso" in main.sh 237 if [[ $compphysiq = "lmdiso" ]]; then isotopes=1; else isotopes=0; fi 238 239 # Option de compilation pour Cosp 240 case $cosp in 241 v1) opt_cosp="-cosp true";; 242 v2) opt_cosp="-cospv2 true";; 243 *) opt_cosp="" 244 esac 245 246 #Define veget-related suffix for gcm name 247 if [[ $veget = 'none' ]]; then 248 suff_orc='' 54 249 else 55 wget --no-check-certificate -nv http://lmdz.lmd.jussieu.fr/pub/$1 56 save_pub_locally=0 57 if [ $save_pub_locally = 1 ] ; then # saving wget files on ~/LMDZ/pub 58 dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir 59 cp -r `basename $1` $dir 60 fi 61 fi 62 } 63 64 # 04_2021 : tester si r4 marche encore ! 65 #real=r4 66 real=r8 67 68 69 ######################################################################### 70 # Valeur par défaut des parametres 71 ######################################################################### 72 svn="" 73 #version=trunk 74 version=20231022.trunk 75 76 getlmdzor=1 77 netcdf=1 # 1: for automatic installation; 78 # or 0: do not install NetCDF and look for it in standard locations; 79 # or absolute path: look for NetCDF there 80 check_linux=1 81 ioipsl=1 82 bench=1 83 pclinux=1 84 pcmac=0 # default: not on a Mac 85 compiler=gfortran 86 if [ `gfortran -dumpversion | cut -d. -f1` -ge 10 ] ; then allow_arg_mismatch="-fallow-argument-mismatch" ; fi 87 SCM=0 88 # surface/vegetation scheme treatment 89 # controlled by the single variable veget which can have the following values 90 # - NONE: bucket scheme (default) 91 # - CMIP6: orchidee version used in CMIP exercise, rev 5661 92 # - number: orchidee version number 93 veget=NONE 94 # choose the resolution for the bench runs 95 # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE) 96 # 96x71x19 standard configuration 97 grid_resolution=144x142x79 98 grid_resolution=96x95x39 99 grid_resolution=48x36x19 100 grid_resolution=32x32x39 101 # choose the physiq version you want to test 102 #physiq=NPv6.0.14splith 103 physiq= 104 105 ## parallel can take the values none/mpi/omp/mpi_omp 106 parallel=mpi_omp 107 parallel=none 108 idris_acct=lmd 109 trusting=testing 110 OPT_GPROF="" 111 OPT_MAKELMDZ="" 112 MODEL="" 113 114 ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no 115 with_xios="n" 116 opt_makelmdz_xios="" 117 118 ## compile with oldrad/rrtm/ecrad radiatif code (Default=rrtm) 119 rad=rrtm 120 121 ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0) 122 compile_with_fcm=1 123 124 #Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE) 125 cosp=NONE 126 opt_cosp="" 127 128 # Check if on a Mac 129 if [ `uname` = "Darwin" ] 130 then 131 pcmac=1 132 export MAKE=make 133 fi 134 #echo "pcmac="$pcmac 135 136 env_file="" 137 138 ######################################################################### 139 # Options interactives 140 ######################################################################### 141 while (($# > 0)) 142 do 143 case $1 in 144 "-h") cat <<........fin 145 $0 [ -v version ] [ -r svn_release ] 146 [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ] 147 [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF] 148 149 -v "version" like 20150828.trunk 150 see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk 151 152 -r "svn_release" : either the svn release number or "last" 153 154 -compiler gfortran|ifort|pgf90 (default: gfortran) 155 156 -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential) 157 158 -d GRID_RESOLUTION should be among the available benchs if -bench 1 159 among which : 48x36x19, 48x36x39 160 if wanting to run a bench simulation in addition to compilation 161 default : 48x36x19 162 163 -bench activating the bench or not (0/1). Default 1 164 165 -testing/unstable 166 167 -name LOCAL_MODEL_NAME : default = LMDZversion.release 168 169 -netcdf 0, 1 or PATH 170 0: do not download NetCDF, look for it in standard locations 171 1: download and compile NetCDF 172 PATH: full path to an existing installed NetCDF library 173 174 -xios also download and compile the XIOS library 175 (requires the NetCDF4-HDF5 library, also installed by default) 176 (requires to also have -parallel mpi_omp) 177 178 -gprof to compile with -pg to enable profiling with gprof 179 180 -cosp to run without our with cospv1 or cospv2 [none/v1/v2] 181 182 -rad RADIATIF can be oldrad, rrtm or ecrad radiatif code 183 184 -nofcm to compile without fcm 185 186 -SCM install 1D version automatically 187 188 -debug compile everything in debug mode 189 190 -opt_makelmdz to call makelmdz or makelmdz_fcm with additional options 191 192 -physiq to choose which physics package to use 193 194 -env_file specify an arch.env file to overwrite the existing one 195 196 -veget surface model to run [NONE/CMIP6/xxxx] 197 198 ........fin 199 exit ;; 200 "-v") version=$2 ; shift ; shift ;; 201 "-r") svn=$2 ; shift ; shift ;; 202 "-compiler") compiler=$2 203 case $compiler in 204 "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift 205 shift ;; 206 *) echo "Only gfortran , ifort or pgf90 for the " \ 207 "compiler option" 208 exit 209 esac ;; 210 "-d") grid_resolution=$2 ; shift ; shift ;; 211 "-gprof") OPT_GPROF="-pg" ; shift ;; 212 "-unstable"|"-testing") trusting=`echo $1 | cut -c2-` ; shift ;; 213 "-cosp") cosp=$2 214 case $cosp in 215 "none"|"v1"|"v2") cosp=$2 ; shift ; shift ;; 216 *) echo Only none v1 v2 for cosp option ; exit 217 esac ;; 218 "-nofcm") compile_with_fcm=0 ; echo This option will be reactivated soon '(promesse du 8dec2022)' ; exit 1 ; shift ;; 219 "-SCM") SCM=1 ; shift ;; 220 "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;; 221 "-rrtm") rrtm="$2" 222 if [ "$2" = "false" ] ; then 223 rad="oldrad" 224 else 225 rad="rrtm" 226 fi 227 shift ; shift ;; 228 "-rad") rad=$2 229 case $rad in 230 "oldrad"|"rrtm"|"ecrad") rad=$2 ; shift ; shift ;; 231 *) echo Only oldrad rrtm ecrad for rad option ; exit 232 esac ;; 233 "-parallel") parallel=$2 234 case $parallel in 235 "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift 236 shift ;; 237 *) echo Only none mpi omp mpi_omp for the parallel \ 238 option 239 exit 240 esac ;; 241 "-bench") bench=$2 ; shift ; shift ;; 242 "-debug") optim=-debug ; shift ;; 243 "-name") MODEL=$2 ; shift ; shift ;; 244 "-netcdf") netcdf=$2 ; shift ; shift ;; 245 "-physiq") physiq=$2 ; shift ; shift ;; 246 "-xios") with_xios="y" ; shift ;; 247 "-env_file") env_file=$2 ; shift ; shift ;; 248 "-veget") veget=$2 ; shift ; shift ;; 249 *) bash install_lmdz.sh -h ; exit 250 esac 251 done 252 253 # Option de compilation du rayonnement : depend de $mysvn ><= r4185, 254 # sera donc definie plus bas 255 256 #opt_rad="" 257 #case $rad in 258 # rrtm) opt_rad="-rad rrtm" ;; 259 # ecrad) opt_rad="-rad ecrad" ;; 260 #esac 261 262 263 # Option de compilation pour Cosp 264 opt_cosp="" 265 case $cosp in 266 v1) opt_cosp="-cosp true" ;; 267 v2) opt_cosp="-cospv2 true" ;; 268 esac 269 270 # Check on veget version 271 #if [ "$veget" != 'NONE' -a "$veget" != "CMIP6" -a "$veget" != +([0-9]) ] ; then 272 if [ $veget != 'NONE' -a $veget != "CMIP6" ] ; then 273 re='^[0-9]+$' 274 if ! [[ $veget =~ $re ]] ; then 275 echo 'Valeur de l option veget non valable' 276 exit 277 fi 278 fi 279 280 #Define veget-related suffix for gcm name 281 if [ "$veget" = 'NONE' ] ; then 282 suff_orc='' 283 #For use with tutorial, orchidee_rev is also defined (will be 284 #written in surface_env at the end of the script) 285 orchidee_rev='' 286 else 287 suff_orc='_orch' 288 fi 289 290 291 if [ $parallel = none ] ; then 292 sequential=1; suff_exe='_seq' 293 else 294 sequential=0; suff_exe='_para_mem' 295 fi 296 297 #Chemin pour placer le modele 298 if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn$optim ; fi 299 300 301 arch=local 302 303 304 if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi 305 306 ################################################################ 307 # Specificite des machines 308 ################################################################ 309 310 hostname=`hostname` 311 if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi 312 313 case ${hostname:0:5} in 314 315 jean-) compiler="mpiifort" ; 316 par_comp="mpiifort" ; 317 o_ins_make="-t jeanzay" ; 318 make=gmake ; 319 module purge 320 module load gcc/6.5.0 321 module load intel-compilers/19.0.4 ; 322 #module load intel-mpi/19.0.4 ; 323 #module load intel-mkl/19.0.4 ; 324 module load hdf5/1.10.5-mpi ; 325 module load netcdf/4.7.2-mpi ; 326 module load netcdf-fortran/4.5.2-mpi ; 327 module load subversion/1.9.7 ; 328 module load cmake 329 export NETCDF_LIBDIR=./ 330 export NETCDFFORTRAN_INCDIR=./ 331 export NETCDFFORTRAN_LIBDIR=./ 332 arch=X64_JEANZAY ;; 333 334 cicla|camel) compiler="gfortran" ; 335 module purge 336 module load gnu/10.2.0 337 module load openmpi/4.0.5 338 module load hdf5/1.10.7-mpi 339 module load netcdf-c/4.7.4-mpi 340 module load netcdf-fortran/4.5.3-mpi 341 netcdf=/net/nfs/tools/PrgEnv/linux-scientific6-x86_64/gcc-10.2.0/netcdf-fortran-4.5.3-k3drgfqok3lip62hnm3tsyof4cjen5sk 342 module load svn/1.14.0 343 344 if [ $parallel != none ] ; then 345 root_mpi=/net/nfs/tools/meso-sl6/openmpi/4.0.5-gcc-10.2.0 346 path_mpi=$root_mpi/bin ; 347 par_comp=${path_mpi}/mpif90 ; 348 mpirun=${path_mpi}/mpirun ; 349 fi ; 350 arch=local ; 351 make=make ; 352 o_ins_make="-t g95" ;; 353 354 *) if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then 355 path_mpi=`which mpif90 | sed -e s:/mpif90::` ; 356 if [ -d /usr/lib64/openmpi ] ; then 357 root_mpi="/usr/lib64/openmpi" 358 else 359 root_mpi="/usr" 360 fi 361 else 362 echo "Cannot find mpif90" ; 363 if [ $parallel = none ] ; then exit ; fi ; 364 fi ; 365 if [ $parallel != none ] ; then 366 root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::) 367 path_mpi=$(which mpif90 | sed -e s:/mpif90::) 368 export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH 369 fi 370 par_comp=${path_mpi}/mpif90 ; 371 mpirun=${path_mpi}/mpirun ; 372 arch=local ; 373 make=make ; 374 o_ins_make="-t g95" 375 esac 376 377 # Flags for parallelism: 378 if [ $parallel != none ] ; then 379 # MPI_LD are the flags needed for linking with MPI 380 MPI_LD="-L${root_mpi}/lib -lmpi" 381 if [ "$compiler" = "gfortran" ] ; then 382 # MPI_FLAGS are the flags needed for compilation with MPI 383 MPI_FLAGS="-fcray-pointer" 384 # OMP_FLAGS are the flags needed for compilation with OpenMP 385 OMP_FLAGS="-fopenmp -fcray-pointer" 386 # OMP_LD are the flags needed for linking with OpenMP 387 OMP_LD="-fopenmp" 388 elif [ "$compiler" = "ifort" ] ; then 389 MPI_FLAGS="" 390 OMP_FLAGS="-openmp" 391 OMP_LD="-openmp" 392 else # pgf90 393 MPI_FLAGS="" 394 OMP_FLAGS="-mp" 395 OMP_LD="-mp" 396 fi 397 fi 398 399 ##################################################################### 400 # Test for old gfortran compilers 401 # If the compiler is too old (older than 4.3.x) we test if the 402 # temporary gfortran44 patch is available on the computer in which 403 # case the compiler is changed from gfortran to gfortran44 404 # Must be aware than parallelism can not be activated in this case 405 ##################################################################### 406 407 if [ "$compiler" = "gfortran" ] ; then 408 gfortran=gfortran 409 gfortranv=`gfortran --version | \ 410 head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '` 411 if [ $gfortranv -le 43 ] ; then 412 echo ERROR : Your gfortran compiler is too old 413 echo 'Please choose a new one (ifort) and change the line' 414 echo compiler=xxx 415 echo in the install_lmdz.sh script and rerun it 416 if [ `which gfortran44 | wc -w` -ne 0 ] ; then 417 gfortran=gfortran44 418 else 419 echo gfotran trop vieux ; exit 420 fi 421 fi 422 compiler=$gfortran 423 fi 424 ##################################################################### 425 426 ## if also compiling XIOS, parallel must be mpi_omp 427 if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then 428 echo "Error, you must set -parallel mpi_omp if you want XIOS" 429 exit 430 fi 431 432 if [ "$with_xios" = "y" ] ; then 433 opt_makelmdz_xios="-io xios" 434 fi 435 436 if [ "$cosp" = "v2" -a "$with_xios" = "n" ] ; then 437 echo "Error, Cospv2 cannot run without Xios" 438 exit 439 fi 440 441 echo '################################################################' 442 echo Choix des options de compilation 443 echo '################################################################' 444 445 export FC=$compiler 446 export F90=$compiler 447 export F77=$compiler 448 export CPPFLAGS= 449 OPTIMNC=$OPTIM 450 BASE_LD="$OPT_GPROF" 451 OPTPREC="$OPT_GPROF" 452 ARFLAGS="rs" 453 if [ "`lsb_release -i -s`" = "Ubuntu" ] ; then 454 if [ "`lsb_release -r -s | cut -d. -f1`" -ge 16 ] ; then 455 ARFLAGS="rU" 456 fi 457 fi 458 459 if [ "$compiler" = "$gfortran" ] ; then 460 OPTIM="-O3 $allow_arg_mismatch" 461 OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan $allow_arg_mismatch" 462 OPTDEV="-Wall -fbounds-check $allow_arg_mismatch" 463 fmod='I ' 464 OPTPREC="$OPTPREC -cpp -ffree-line-length-0" 465 if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi 466 export F90FLAGS=" -ffree-form $OPTIMNC" 467 export FFLAGS=" $OPTIMNC" 468 export CC=gcc 469 export CXX=g++ 470 export fpp_flags="-P -C -traditional -ffreestanding" 471 472 elif [ $compiler = mpif90 ] ; then 473 OPTIM='-O3' 474 OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all" 475 OPTDEV="-Wall -fbounds-check" 476 BASE_LD="$BASE_LD -lblas" 477 fmod='I ' 478 if [ $real = r8 ] ; then 479 OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" 480 fi 481 export F90FLAGS=" -ffree-form $OPTIMNC" 482 export FFLAGS=" $OPTIMNC" 483 export CC=gcc 484 export CXX=g++ 485 486 elif [ $compiler = pgf90 ] ; then 487 OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align' 488 OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback' 489 OPTDEV='-g -Mbounds -Ktrap=fp -traceback' 490 fmod='module ' 491 if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi 492 export CPPFLAGS="-DpgiFortran" 493 export CC=pgcc 494 export CFLAGS="-O2 -Msignextend" 495 export CXX=pgCC 496 export CXXFLAGS="-O2 -Msignextend" 497 export FFLAGS="-O2 $OPTIMNC" 498 export F90FLAGS="-O2 $OPTIMNC" 499 compile_with_fcm=1 500 501 elif [[ $compiler = ifort || $compiler = mpiifort ]] ; then 502 OPTIM="-O2 -fp-model strict -ip -align all " 503 OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check" 504 OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check" 505 fmod='module ' 506 if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi 507 export CPP="icc -E" 508 export FFLAGS="-O2 -ip -fpic -mcmodel=large" 509 export FCFLAGS="-O2 -ip -fpic -mcmodel=large" 510 export CC=icc 511 export CFLAGS="-O2 -ip -fpic -mcmodel=large" 512 export CXX=icpc 513 export CXXFLAGS="-O2 -ip -fpic -mcmodel=large" 514 export fpp_flags="-P -traditional" 515 # Pourquoi forcer la compilation fcm. Marche mieux sans 516 #compile_with_fcm=1 517 else 518 echo unexpected compiler $compiler ; exit 519 fi 520 521 OPTIMGCM="$OPTIM $OPTPREC" 522 523 hostname=`hostname` 524 525 ########################################################################## 526 # If installing on known machines such as Jean-Zay at IDRIS, 527 # don't check for available software and don't install netcdf 528 if [ ${hostname:0:5} = jean- ] ; then 529 netcdf=0 # no need to recompile netcdf, alreday available 530 check_linux=0 531 pclinux=0 532 ioipsl=0 # no need to recompile ioipsl, already available 533 #netcdf="/smplocal/pub/NetCDF/4.1.3" 534 compiler="mpiifort" 535 fmod='module ' 536 if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi 537 OPTIM="-auto -align all -O2 -fp-model strict -xHost " 538 OPTIMGCM="$OPTIM $OPTPREC" 539 fi 540 ########################################################################## 541 542 543 mkdir -p $MODEL 544 echo $MODEL 545 MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary 546 547 548 if [ "$check_linux" = 1 ] ; then 549 echo '################################################################' 550 echo Check if required software is available 551 echo '################################################################' 552 553 #### Ehouarn: test if the required shell is available 554 #### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh 555 use_shell="bash" # default 556 if [ "`which bash`" = "" ] ; then 557 echo "no bash ; we will use ksh" 558 use_shell="ksh" 559 if [ "`which ksh`" = "" ] ; then 560 echo "bash (or ksh) needed!! Install it!" 561 exit 562 fi 563 fi 564 565 for logiciel in wget tar gzip make $compiler gcc cmake m4 c++ ; do 566 if [ "`which $logiciel`" = "" ] ; then 567 echo You must first install $logiciel on your system 568 exit 250 suff_orc='_orch' 251 fi 252 253 254 if [[ $parallel = "none" ]]; then 255 suff_para='_seq' 256 else 257 suff_para='_para_mem' 258 fi 259 260 if [[ $with_xios = 1 ]]; then opt_makelmdz_xios="-io xios"; fi 261 262 if [[ $aerosols = 1 ]]; then 263 opt_aer="-dust true"; suff_aer="_spla" 264 else 265 opt_aer=""; suff_aer="" 266 fi 267 268 if [[ $strataer = 1 ]]; then 269 opt_strataer="-strataer true" 270 else 271 opt_strataer="" 272 fi 273 274 if [[ $inlandsis = 1 ]]; then 275 opt_inlandsis="-inlandsis true" 276 else 277 opt_inlandsis="" 278 fi 279 280 if [[ $isotopes = 1 ]]; then 281 opt_isotopes="-isotopes true"; suff_iso="_iso" 282 else 283 opt_isotopes="" ; suff_iso="" 284 fi 285 286 # set default arch if parallel 287 if [[ $arch = "local-gfortran" && $parallel != "none" ]]; then 288 arch="local-gfortran-parallel" 289 echo "Switching default arch to $arch" 290 fi 291 292 # Name of the model's folder. The convention taken here is that models that requires different compilation sources should have a different names. 293 local xios_name="" 294 if [[ $with_xios = 1 ]]; then xios_name="XIOS"; fi 295 if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version${svn_lmdz}OR$veget$xios_name"; fi 296 297 if [[ $arch_dir = "" ]]; then 298 arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"; 299 elif ! readlink -fe "$arch_dir" >/dev/null; then 300 echo "STOP: no arch dir <$arch_dir>"; exit 1 301 fi 302 303 if ! (echo "$grid_resolution" | grep -q "x"); then 304 is_1D="y" 305 fortran_file="lmdz1d" 306 fi 307 } 308 309 function ensure_correct_option_combinations { 310 # Check on veget version 311 if [[ $veget != 'none' && $veget != "CMIP6" && $veget != "orch2.0" && $veget != "orch2.2" ]]; then 312 re='^[0-9]+$' 313 if ! [[ $veget =~ $re ]]; then 314 echo 'Valeur de l option veget non valable'; exit 1 315 fi 316 fi 317 318 ## if compiling icolmdz, XIOS must be set 319 if [[ $icolmdz = 1 && $with_xios = 0 ]]; then 320 echo "Error, you must set -xios to compile the icolmdz executable"; exit 1 321 fi 322 ## if also compiling XIOS, parallel must be mpi_omp 323 if [[ $with_xios = 1 && $parallel != "mpi_omp" ]]; then 324 echo "Error, you must set -parallel mpi_omp if you want XIOS"; exit 1 325 fi 326 327 if [[ $cosp = "v2" && $with_xios = 0 ]]; then 328 echo "Error, Cospv2 cannot run without Xios"; exit 1 329 fi 330 331 # STOP if trying to use both ORCHIDEE and Isotopes : 332 if [[ $isotopes = 1 && $veget != "none" ]]; then 333 echo "STOP: You cannot run LMDZ with ORCHIDEE and ISOtopes at the same time"; exit 1 334 fi 335 336 # STOP if trying to use both SPLA and Isotopes : 337 if [[ $isotopes = 1 && $aerosols = 1 ]]; then 338 echo "STOP: You cannot run LMDZ with Isotopes and aerosols=spla at the same time"; exit 1 339 fi 340 341 # (Temporary) STOP if trying to use Isotopes with XIOS : 342 if [[ $isotopes = 1 && $with_xios = 1 ]]; then 343 echo "STOP: Isotopes cannont yet be run with XIOS"; exit 1 344 fi 345 346 if [[ $aerosols = 1 && $rad != "rrtm" ]]; then 347 echo "STOP: For the time being, <aerosols=spla> requires <rad=rrtm>"; exit 1 348 fi 349 } 350 351 function check_available_software { 352 local required_soft=("wget" "tar" "gzip" "make" "gcc" "cmake" "m4" "c++") 353 echo "Checking if required software is available (${required_soft[*]})" 354 for logiciel in "${required_soft[@]}"; do 355 if [[ $(which "$logiciel") = "" ]]; then 356 echo "You must first install $logiciel on your system"; exit 1 569 357 fi 570 358 done 571 359 572 if [ $pclinux = 1 ] ; then 573 cd $MODEL 574 cat <<eod > tt.f90 360 cat <<eod > tt.f90 575 361 print*,'coucou' 576 362 end 577 363 eod 578 $compiler tt.f90 -o a.out 579 ./a.out >| tt 580 if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then 581 echo problem installing with compiler $compiler ; exit ; fi 582 \rm tt a.out tt.f90 583 fi 584 fi 585 586 ########################################################################### 587 if [ $getlmdzor = 1 -a ! -d $MODEL/modipsl ] ; then 588 ########################################################################### 589 echo '##########################################################' 590 echo Download a slightly modified version of LMDZ 591 echo '##########################################################' 592 cd $MODEL 593 getlog=`pwd`/get.log 594 echo logfile : $getlog 595 myget src_archives/$trusting/modipsl.$version.tar.gz >> get.log 2>&1 596 echo install_lmdz.sh wget_OK `date` 597 gunzip modipsl.$version.tar.gz >> get.log 2>&1 598 tar xf modipsl.$version.tar >> get.log 2>&1 599 \rm modipsl.$version.tar 600 fi 601 602 ########################################################################### 603 echo Installing Netcdf 604 ########################################################################### 605 606 if [ $netcdf = 0 ] ; then 607 ncdfdir=/usr 608 609 else 610 cd $MODEL 611 612 case $compiler in 613 gfortran) opt1="-compiler gnu" ; opt2="-CC gcc -FC gfortran -CXX g++" ;; 614 ifort) opt1="-compiler intel" ; opt2="-CC icc -FC ifort -CXX icpc" ;; 615 pgf90) opt1="-compiler pgf90" ; opt2="-CC pgcc -FC pgf90 -CXX pgCC" ;; 616 *) echo "unexpected compiler $compiler" for netcdf ; exit 1 364 $compiler tt.f90 || a.out 365 ./a.out >| tt 366 if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then 367 echo "problem installing with compiler $compiler"; exit 1 368 fi 369 rm tt a.out tt.f90 370 } 371 372 function download_modipsl_tar { 373 if [[ $clean_install = 1 ]]; then rm -rf "$MODEL"; fi 374 375 mkdir -p "$MODEL" 376 MODEL=$(readlink -e -f "$MODEL"); echo "MODEL: $MODEL" # absolute path 377 if [[ ! -d "$MODEL/modipsl" ]]; then 378 echo "Downloading a slightly modified version of modipsl+LMDZ" 379 cd "$MODEL" 380 getlog="$(pwd)/get.log" 381 echo "logfile : $getlog" 382 myget "src_archives/$trusting/modipsl.$version.tar.gz" &>> get.log 383 echo "install_lmdz.sh wget_OK $(date)" 384 385 gunzip "modipsl.$version.tar.gz" &>> get.log 386 tar xf "modipsl.$version.tar" &>> get.log 387 rm "modipsl.$version.tar" 388 fi 389 } 390 391 function init_arch { 392 cd "$local" 393 set +e; arch_dir=$(readlink -f "$arch_dir"); set -e # full path. readlink must be called *after* the path is created 394 395 # Check where default fcm, path, env are located - by default in $arch_path, instead in $MODEL/modipsl/modeles/LMDZ/arch/ 396 local i fcm_path path_path env_path 397 for i in "path" "fcm" "env"; do 398 local varname=${i}_path 399 if [[ -f $arch_dir/arch-$arch.$i ]]; then 400 declare $varname="$arch_dir/arch-$arch.$i" 401 else 402 declare $varname="$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.$i" 403 if [[ ! -f ${!varname} ]]; then 404 echo "STOP: no ${!varname}"; exit 1 405 fi 406 fi 407 done 408 default_fcm_path=$fcm_path 409 default_path_path=$path_path 410 default_env_path=$env_path 411 412 # check compiler 413 compiler=$(< "$default_fcm_path" grep "%COMPILER" | sed -e "s/%COMPILER\s*//") 414 415 # load env 416 # shellcheck disable=SC1090 417 if [[ -f $default_env_path ]]; then source "$default_env_path"; fi 418 419 local mpi_file # can't be done before as it depends on sourcing the env 420 mpi_file=$(readlink -e -f "$(which mpif90)") 421 path_mpi=$(dirname "$mpi_file") 422 root_mpi=$(dirname "$path_mpi") 423 } 424 425 function install_arch { 426 local component=$1 427 428 # Use same .env for all components (for module compatibility) 429 cp -f "$default_env_path" "$MODEL/modipsl/modeles/$component/arch" &> /dev/null || true # allow failure if we're copying the file to itself 430 431 # Use local .path and .fcm if available, otherwise default 432 if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.path" ]]; then 433 cp -f "$default_path_path" "$MODEL/modipsl/modeles/$component/arch" 434 435 if [[ $component = "ORCHIDEE" ]]; then 436 if [[ $orcbranch = "/tags/ORCHIDEE_2_0/ORCHIDEE" ]]; then # 2.0 and before have a different fcm convention 437 sed -i'' -e "s/-I//" -e "s/-L//" "$MODEL/modipsl/modeles/ORCHIDEE/arch/arch-$arch.path" # /!\ we only replace first occurence on purpose 438 fi 439 fi 440 fi 441 if [[ ! -f "$MODEL/modipsl/modeles/$component/arch/arch-$arch.fcm" ]]; then 442 cp -f "$default_fcm_path" "$MODEL/modipsl/modeles/$component/arch" 443 444 if [[ $component = "XIOS" ]]; then 445 # Adapt for XIOS, which uses different naming conventions 446 sed -i'' -e "s/%COMPILER/%FCOMPILER/" -e "s/%LINK/%LINKER/" -e "s/-fdefault-real-8//" "$MODEL/modipsl/modeles/XIOS/arch/arch-$arch.fcm" 447 fi 448 fi 449 } 450 451 function install_netcdf { 452 echo "Installing Netcdf" 453 local ncdf_compiler="$compiler" 454 455 if [[ $netcdf = 0 ]]; then 456 ncdfdir=$(nf-config --prefix) 457 else 458 cd "$MODEL" 459 460 # Convert non-basic compiler 461 case $compiler in 462 mpif90) ncdf_compiler=$($compiler --version | head -n 1 | cut -d " " -f -1) 463 esac 464 465 case $ncdf_compiler in 466 gfortran | GNU) ncdf_compiler="gfortran"; opt1="-compiler gnu"; opt2="-CC gcc -FC gfortran -CXX g++";; 467 *) echo "unexpected compiler $ncdf_compiler for netcdf"; exit 1 468 esac 469 470 case $with_xios in 471 0) script_install_netcdf="install_netcdf4_hdf5_seq.bash" 472 ncdfdir="netcdf4_hdf5_seq" 473 opt_="$opt1";; 474 1) script_install_netcdf="install_netcdf4_hdf5.bash" 475 ncdfdir="netcdf4_hdf5" 476 opt_="$opt2 -MPI $root_mpi";; 477 *) echo "with_xios=$with_xios, should be 0 or 1"; exit 1 478 esac 479 if [[ $netcdf = 1 ]]; then 480 ncdfdir="$MODEL/$ncdfdir" 481 else 482 mkdir -p "$netcdf"; ncdfdir="$netcdf/$ncdfdir" 483 fi 484 485 echo "Repertoire netcdf $ncdfdir" 486 if [[ ! -d $ncdfdir ]]; then 487 netcdflog=$(pwd)/netcdf.log 488 echo "----------------------------------------------------------" 489 echo "Compiling the Netcdf library" 490 echo "----------------------------------------------------------" 491 echo "log file : $netcdflog" 492 myget script_install/$script_install_netcdf &>> "$netcdflog" 493 chmod u=rwx $script_install_netcdf 494 # shellcheck disable=SC2086 495 ./$script_install_netcdf -prefix "$ncdfdir" $opt_ &>> "$netcdflog" 496 fi 497 498 # Add to path 499 export PATH="$ncdfdir/bin:$PATH" 500 echo "Bin PATH" $PATH 501 502 #---------------------------------------------------------------------------- 503 # LF rajout d'une verrue, pour une raison non encore expliquee, 504 # la librairie est parfois rangée dans lib64 et non dans lib 505 # par certains compilateurs 506 if [[ ! -e lib && -d lib64 ]]; then ln -s lib64 lib; fi 507 #---------------------------------------------------------------------------- 508 509 echo "install_lmdz.sh netcdf_OK $(date)" 510 fi 511 512 cat >test_netcdf90.f90 <<EOF 513 use netcdf 514 print *, "NetCDF library version: ", nf90_inq_libvers() 515 end 516 EOF 517 518 if $ncdf_compiler -I"$ncdfdir"/include test_netcdf90.f90 -L"$ncdfdir"/lib -lnetcdff -lnetcdf -Wl,-rpath="$ncdfdir"/lib && ./a.out; then 519 rm test_netcdf90.f90 a.out 520 else 521 cat <<EOF 522 Failed test program using NetCDF-Fortran. You can: 523 - check that you have NetCDF-Fortran installed in your system 524 - or specify an installation directory with option -netcdf of install_lmdz.sh 525 - or download and compile NetCDF-Fortran with option -netcdf 1 of install_lmdz.sh 526 EOF 527 exit 1 528 fi 529 530 # Compile NetCDF95 531 cd "$MODEL/modipsl/modeles/LMD"* 532 echo "Installing NetCDF95" 533 cd "$MODEL" 534 if [[ ! -d "NetCDF95-0.3" ]]; then 535 myget src_archives/netcdf/NetCDF95-0.3.tar.gz 536 tar -xf NetCDF95-0.3.tar.gz 537 rm NetCDF95-0.3.tar.gz 538 cd NetCDF95-0.3 539 mkdir -p build && cd build 540 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" 541 make install 542 fi 543 } 544 545 function install_IOIPSL { 546 install_arch "IOIPSL" 547 548 cd "$MODEL/modipsl/modeles/IOIPSL" 549 ioipsllog="$(pwd)/ioipsl.log" 550 echo "Compiling IOIPSL, the interface library with Netcdf $(date) (log: $ioipsllog)" 551 # in case ksh is not installed on the pc 552 if [[ ! -x /bin/ksh ]]; then 553 sed -i'' -e 's/ksh/bash/' ins_m_prec 554 fi 555 echo "$jobcmd ./makeioipsl_fcm -j $make_j -arch $arch $optim_flag" > compile.sh 556 chmod +x compile.sh 557 echo "Compiling IOIPSL using $(\cat compile.sh)" 558 if ! ./compile.sh &> "$ioipsllog"; then 559 echo "STOP: IOIPSL compile failed, exiting"; exit 1 560 fi 561 562 # Link to modipsl/bin 563 cp -f bin/* ../../bin 564 565 echo "IOIPSL compiled $(date)" 566 } 567 568 function install_XIOS { 569 if [[ $with_xios = 1 ]]; then 570 cd "$MODEL/modipsl/modeles" 571 xioslog="$(pwd)/XIOS/xios.log" 572 echo "##########################################################" 573 echo "Compiling XIOS (log $xioslog) $(date)" 574 echo "##########################################################" 575 576 # Download XIOS 577 local xios_http="http://forge.ipsl.fr/ioserver/svn/XIOS2/branches/xios-2.6" 578 local xios_rev="2568" 579 580 cd "$MODEL/modipsl/modeles" 581 set +e; svn co -r $xios_rev $xios_http XIOS; set -e 582 583 cd XIOS 584 585 install_arch "XIOS" 586 do_compile_sh "XIOS" "$jobcmd ./make_xios --job $make_j --arch $arch" 587 fi 588 } 589 590 function get_orchidee_version { # Set / Check ORCHIDEE version 591 echo "Checking Orchidee source version" 592 local fetch_rev="" 593 orcbranch="" 594 case $veget in 595 "none") fcm_veget_version="false";; 596 "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 597 "orch2.2") fcm_veget_version=orchidee2.1; orcbranch="/branches/ORCHIDEE_2_2/ORCHIDEE" ;; # the bundled version 598 *) fetch_rev=$veget; fcm_veget_version=orchidee2.1;; # /!\ arbitary rev only works for orch>=2.1 599 # /!\ Note: for orch>=4, we should be using fcm_vegt_version="orchideetrunk". Below copied comment by Adriana in LMDZ_Setup docs: 600 # 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 601 #Si on voudrait activer landice_opt=2 , il faut compiler avec -v orchideetrunk. 602 617 603 esac 618 604 619 case $with_xios in 620 n) script_install_netcdf=install_netcdf4_hdf5_seq.bash 621 ncdfdir=netcdf4_hdf5_seq 622 opt_=$opt1 ;; 623 y) script_install_netcdf=install_netcdf4_hdf5.bash 624 ncdfdir=netcdf4_hdf5 625 opt_="$opt2 -MPI $root_mpi" ;; 626 *) echo with_xios=$with_xios, should be n or y ; exit 1 627 esac 628 if [ $netcdf = 1 ] ; then 629 ncdfdir=$MODEL/$ncdfdir 605 if [[ -n $fetch_rev ]]; then 606 echo "IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr" 607 local curr_rev 608 curr_rev=$(svn info "$MODEL/modipsl/modeles/ORCHIDEE" | grep Revision: | cut -d ":" -f 2 | cut -c 2-) 609 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}') 610 if [[ $fetch_rev != "$curr_rev" ]]; then 611 echo "Fetching orch $fetch_rev from the repository (curr: $curr_rev)" 612 echo "branch is $orcbranch" 613 if [[ $fetch_rev -lt 4465 ]]; then echo 'ORCHIDEE version must be >=4465, exiting'; exit 1; fi 614 cd "$MODEL/modipsl/modeles" 615 rm -rf ORCHIDEE 616 svn co -r "$fetch_rev" "svn://forge.ipsl.fr/orchidee/$orcbranch" 617 cd - > /dev/null 618 fi 619 fi 620 621 # Check parallel LMDZ+ORCH 622 if [[ (! $veget = "none") && $parallel = "none" && ($used_lmdz_rev -lt 4894) ]]; then 623 echo "LMDZ revision must be >=4894 for orchidee without parallel support. Upgrade lmdz or use -parallel mpi_omp."; exit 1 624 fi 625 } 626 627 function compile_orchidee { 628 install_arch "ORCHIDEE" 629 630 if [[ $veget != "none" ]]; then 631 cd "$MODEL/modipsl/modeles/ORCHIDEE" 632 633 local xios_orchid 634 if [[ $with_xios = 1 ]]; then 635 xios_orchid="-xios"; 636 else 637 xios_orchid="-noxios" 638 fi 639 640 if [[ $parallel != "none" && ! -d src_parallel ]]; then 641 echo "STOP: Orchidee version too old for parallel support"; exit 1 642 fi 643 do_compile_sh "ORCHIDEE" "$jobcmd ./makeorchidee_fcm -j $make_j $xios_orchid $optim_flag -parallel $parallel -arch $arch" 644 fi 645 } 646 647 function get_lmdz_version { 648 echo "Checking LMDZ source version" 649 LMDZPATH=$(readlink -e -f "$MODEL/modipsl/modeles/LMD"*) 650 cd "$LMDZPATH" 651 652 if [[ -n $svn_lmdz ]]; then 653 local curr_rev 654 curr_rev=$(svn info "$MODEL/modipsl/modeles/LMD"* | grep Revision: | cut -d ":" -f 2 | cut -c 2-) 655 if [[ $svn_lmdz != "$curr_rev" ]]; then 656 local lmdzbranch 657 echo "Fetching LMDZ $svn_lmdz from the repository" 658 lmdzbranch=$(get_svn_branch "https://svn.lmd.jussieu.fr/LMDZ" "$svn_lmdz") 659 echo "branch is $lmdzbranch" 660 cd "$MODEL/modipsl/modeles" 661 rm -rf LMD* 662 svn co -r "$svn_lmdz" "https://svn.lmd.jussieu.fr/LMDZ/$lmdzbranch" LMDZ 663 cd - > /dev/null 664 fi 665 used_lmdz_rev=$svn_lmdz 666 else # get svn from info 667 set +e; used_lmdz_rev=$(svn info | grep "Last Changed Rev" | cut -c 19-); set -e 668 if [[ -z $used_lmdz_rev ]]; then # svn info failed 669 used_lmdz_rev=$(grep 'Revision: [0-9]' "$MODEL"/Read*.md | awk ' { print $2 } ' 2>/dev/null) 670 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 671 fi 672 fi 673 } 674 675 function compile_lmdz { 676 install_arch "LMDZ" 677 cd "$LMDZPATH" 678 679 if [[ $used_lmdz_rev -le 4185 ]]; then 680 exe_name="bin/${fortran_file}_${grid_resolution}_phy${compphysiq}_${suff_para}${suff_orc}${suff_aer}${suff_iso}.e" 630 681 else 631 mkdir -p $netcdf ; ncdfdir=$netcdf/$ncdfdir 632 fi 633 634 echo Repertoire netcdf $ncdfdir 635 if [ ! -d $ncdfdir ] ; then 636 netcdflog=`pwd`/netcdf.log 637 echo '----------------------------------------------------------' 638 echo Compiling the Netcdf library 639 echo '----------------------------------------------------------' 640 echo log file : $netcdflog 641 myget script_install/$script_install_netcdf >> $netcdflog 2>&1 642 chmod u=rwx $script_install_netcdf 643 ./$script_install_netcdf -prefix $ncdfdir $opt_ >> $netcdflog 2>&1 644 fi 645 646 #---------------------------------------------------------------------------- 647 # LF rajout d'une verrue, pour une raison non encore expliquee, 648 # la librairie est parfois rangée dans lib64 et non dans lib 649 # par certains compilateurs 650 if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi 651 #---------------------------------------------------------------------------- 652 653 echo install_lmdz.sh netcdf_OK `date` 654 655 fi 656 657 cat >test_netcdf90.f90 <<EOF 658 use netcdf 659 print *, "NetCDF library version: ", nf90_inq_libvers() 660 end 661 EOF 662 663 $compiler -I$ncdfdir/include test_netcdf90.f90 -L$ncdfdir/lib -lnetcdff \ 664 -lnetcdf -Wl,-rpath=$ncdfdir/lib && ./a.out 665 666 if (($? == 0)) 667 then 668 rm test_netcdf90.f90 a.out 669 else 670 echo "Failed test program using NetCDF-Fortran." 671 echo "You can:" 672 echo "- check that you have NetCDF-Fortran installed in your system" 673 echo "- or specify an installation directory with option -netcdf of" \ 674 "install_lmdz.sh" 675 echo "- or download and compile NetCDF-Fortran with option -netcdf 1 of" \ 676 "install_lmdz.sh" 677 exit 1 678 fi 679 680 #========================================================================= 681 if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]] 682 then 683 if [ $ioipsl = 1 ] ; then 684 #===================================================================== 685 echo OK ioipsl=$ioipsl 686 echo '##########################################################' 687 echo 'Installing MODIPSL, the installation package manager for the ' 688 echo 'IPSL models and tools' 689 echo '##########################################################' 690 echo `date` 691 692 cd $MODEL/modipsl 693 \rm -rf lib/* 694 cd util 695 cp AA_make.gdef AA_make.orig 696 F_C="$compiler -c " 697 if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] 698 then 699 F_C="$compiler -c -cpp " 700 fi 701 if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi 702 sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp 703 sed -e "s:F_L = g95:F_L = $compiler:" \ 704 -e "s:F_C = g95 -c -cpp:F_C = $F_C": \ 705 -e 's/g95.*.w_w.*.(F_D)/g95 w_w = '"$OPTIMGCM"'/' \ 706 -e 's:g95.*.NCDF_INC.*.$:g95 NCDF_INC= '"$ncdfdir"'/include:' \ 707 -e 's:g95.*.NCDF_LIB.*.$:g95 NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \ 708 -e 's:g95 L_O =:g95 L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \ 709 -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \ 710 -e 's:#-Q- g95 M_K = gmake:#-Q- g95 M_K = make:' \ 711 tmp >| AA_make.gdef 712 713 if [ $pcmac == 1 ] 714 then 715 cp AA_make.gdef tmp 716 sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef 717 fi 718 719 720 # We use lines for g95 even for the other compilers to run ins_make 721 if [ "$use_shell" = "ksh" ] ; then 722 ./ins_make $o_ins_make 723 else # bash 724 sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash 725 if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then 726 # Bidouille pour compiler sur ada des vieux modipsl.tar 727 echo 'Warning jean-zay not in AA_make.gdef' 728 echo 'Think about updating' 729 exit 1 730 fi 731 732 chmod u=rwx ins_make.bash 733 ./ins_make.bash $o_ins_make 734 fi # of if [ "$use_shell" = "ksh" ] 735 736 echo install_lmdz.sh MODIPSL_OK `date` 737 738 cd $MODEL/modipsl/modeles/IOIPSL/src 739 ioipsllog=`pwd`/ioipsl.log 740 echo '##########################################################' 741 echo 'Compiling IOIPSL, the interface library with Netcdf' 742 echo '##########################################################' 743 echo `date` 744 echo log file : $ioipsllog 745 746 if [ "$use_shell" = "bash" ] ; then 747 cp Makefile Makefile.ksh 748 sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile 749 fi 750 ### if [ "$pclinux" = 1 ] ; then 751 # Build IOIPSL modules and library 752 $make clean 753 $make > $ioipsllog 2>&1 754 if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then 755 # copy module files to lib 756 cp -f *.mod ../../../lib 757 fi 758 # Build IOIPSL tools (ie: "rebuild", if present) 759 # For IOIPSLv_2_2_2, "rebuild" files are in IOIPSL/tools 760 rebuild_dir="" 761 if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then 762 rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/tools 763 elif [ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ] ; then 764 rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/rebuild 765 fi 766 if [ $rebuild_dir != "" ] ; then 767 cd $rebuild_dir 768 # adapt Makefile & rebuild script if in bash 769 if [ "$use_shell" = "bash" ] ; then 770 cp Makefile Makefile.ksh 771 sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile 772 cp rebuild rebuild.ksh 773 sed -e 's:/bin/ksh:/bin/bash:g' \ 774 -e 's:print -u2:echo:g' \ 775 -e 's:print:echo:g' rebuild.ksh > rebuild 776 fi 777 $make clean 778 $make > $ioipsllog 2>&1 779 fi 780 ### fi # of if [ "$pclinux" = 1 ] which is commented out 781 782 else # of if [ $ioipsl = 1 ] 783 if [ ${hostname:0:5} = jean- ] ; then 784 cd $MODEL/modipsl 785 cd util 786 if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then 787 echo 'Warning jean-zay not in AA_make.gdef' 788 echo 'Think about updating' 789 exit 1 790 fi 791 ./ins_make $o_ins_make 792 # Compile IOIPSL on jean-zay 793 cd $MODEL/modipsl/modeles/IOIPSL/src 794 gmake > ioipsl.log 795 # For IOIPSLv_2_2_2, "rebuild" files are in IOIPSL/tools, so "gmake" in IOIPSL/tools is enough 796 # For IOIPSLv_2_2_5, "rebuild" files are in a separate IOIPSL/rebuild folder , while "tools" only contains "FCM" 797 if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/Makefile ] ; then 798 cd $MODEL/modipsl/modeles/IOIPSL/tools 799 gmake > ioipsl.log 800 fi 801 if [ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ] ; then 802 cd $MODEL/modipsl/modeles/IOIPSL/rebuild 803 gmake > ioipsl.log 804 fi 805 806 fi 807 echo install_lmdz.sh ioipsl_OK `date` 808 fi # of if [ $ioipsl = 1 ] 809 fi # of if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]] 810 811 #========================================================================= 812 if [ "$with_xios" = "y" ] ; then 813 echo '##########################################################' 814 echo 'Compiling XIOS' 815 echo '##########################################################' 816 cd $MODEL/modipsl/modeles 817 xioslog=`pwd`/XIOS/xios.log 818 #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash 819 myget script_install/install_xios.bash 820 chmod u=rwx install_xios.bash 821 # following will be recalculated later on once LMDZ is updated 822 # mysvn=`svnversion LMDZ | egrep -o "[0-9]+" 2>/dev/null` 823 mysvn=`grep 'Revision: [0-9]' $MODEL/Read*.md | awk ' { print $2 } ' 2>/dev/null` 824 if [ "$svn" != "" ] ; then mysvn=$svn ; fi 825 echo mysvn $mysvn 826 827 if [ ${hostname:0:5} = jean- ] ; then 828 if [ $mysvn -ge 4619 ] ; then 829 svn co http://forge.ipsl.fr/ioserver/svn/XIOS2/branches/xios-2.6 \ 830 XIOS 831 else 832 svn co http://forge.ipsl.fr/ioserver/svn/XIOS2/branches/xios-2.5 \ 833 XIOS 834 fi 835 cd XIOS/arch 836 svn update 837 cd .. 838 echo "Compiling XIOS, start" `date` \ 839 echo "log file: $xioslog" 840 #./make_xios --prod --arch $arch --job 4 > xios.log 2>&1 841 cat > compile_xios.sh <<EOD 842 ./make_xios --prod --arch X64_JEANZAY --full --job 4 > xios.log 2>&1 843 EOD 844 srun --pty --ntasks=1 --cpus-per-task=20 --hint=nomultithread -t 00:30:00 \ 845 --account=gzi@cpu --qos=qos_cpu-dev bash ./compile_xios.sh 846 847 else 848 ./install_xios.bash -prefix $MODEL/modipsl/modeles \ 849 -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \ 850 -MPI $root_mpi -arch $arch > xios.log 2>&1 851 fi # of case Jean-Zay 852 if [ -f XIOS/lib/libxios.a ] ; then 853 echo "XIOS library successfully generated" 854 echo install_lmdz.sh XIOS_OK `date` 855 fi 856 fi 857 858 #============================================================================ 859 veget_version=false 860 if [ "$veget" != 'NONE' ] ; then 861 cd $MODEL/modipsl/modeles/ORCHIDEE 862 set +e ; svn upgrade ; set -e 863 if [ "$veget" = "CMIP6" ] ; then 864 veget_version=orchidee2.0 865 orchidee_rev=6592 866 else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches 867 veget_version=orchidee2.1 868 orchidee_rev=$veget 869 if [ $veget -lt 4465 ] ; then 870 echo 'Stopping, ORCHIDEE version too old, script needs work on ' \ 871 'the CPP flags to pass to makelmdz' 872 exit 1 873 fi 874 set +e 875 # which branch is my version on? 876 orcbranch=`svn log -v -q svn://forge.ipsl.fr/orchidee/ -r $veget |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}'` 877 # switch to that branch 878 echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at \ 879 orchidee-help@listes.ipsl.fr 880 svn switch -r $veget --accept theirs-full \ 881 svn://forge.ipsl.fr/orchidee/$orcbranch 882 svn log -r $veget | grep $veget 883 if [ $? -gt 0 ] ; then 884 echo 'Cannot update ORCHIDEE as not on the right branch for ' \ 885 'ORCHIDEE' 886 exit 887 fi 888 set -e 889 set +e ; svn update -r $veget ; set -e 890 fi 891 # Correctif suite debug Jean-Zay 892 sed -i -e 's/9010 FORMAT(A52,F17.14)/9010 FORMAT(A52,F20.14)/' \ 893 src_stomate/stomate.f90 894 opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi 895 896 orchideelog=`pwd`/orchidee.log 897 echo '########################################################' 898 echo 'Compiling ORCHIDEE, the continental surface model ' 899 echo '########################################################' 900 echo Start of the first compilation of orchidee, in sequential mode: `date` 901 echo log file : $orchideelog 902 903 export ORCHPATH=`pwd` 904 xios_orchid="-noxios" 905 if [ "$with_xios" = "y" ] ; then 906 xios_orchid="-xios" 907 fi 908 if [ -d tools ] ; then 909 ################################################################### 910 # Pour les experts qui voudraient changer de version d'orchidee. 911 # Attention : necessite d'avoir le password pour orchidee 912 913 # Correctif suite debug Jean-Zay 914 if [ -f src_global/time.f90 ] ; then 915 sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 916 fi 917 ################################################################### 918 if [ "$veget_version" == "false" ] ; then 919 veget_version=orchidee2.0 920 fi 921 cd arch 922 sed -e s:"%COMPILER .*.$":"%COMPILER $compiler":1 \ 923 -e s:"%LINK .*.$":"%LINK $compiler":1 \ 924 -e s:"%FPP_FLAGS .*.$":"%FPP_FLAGS $fpp_flags":1 \ 925 -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ 926 -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ 927 -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ 928 -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ 929 -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ 930 -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ 931 arch-gfortran.fcm > arch-local.fcm 932 echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" \ 933 > arch-local.path 934 echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path 935 echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path 936 echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path 937 echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path 938 echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path 939 cd ../ 940 941 echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none \ 942 -arch $arch 943 ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none \ 944 -arch $arch > $orchideelog 2>&1 945 pwd 946 else # of "if [ -d tools ]" 947 if [ -d src_parallel ] ; then 948 liste_src="parallel parameters global stomate sechiba driver" 949 if [ "$veget_version" == "false" ] ; then 950 veget_version=orchidee2.0 951 fi 952 fi 953 for d in $liste_src ; do 954 src_d=src_$d 955 echo src_d $src_d 956 echo ls ; ls 957 if [ ! -d $src_d ] ; then 958 echo Problem orchidee : no $src_d ; exit 959 fi 960 cd $src_d ; \rm -f *.mod make ; $make clean 961 $make > $orchideelog 2>&1 962 if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then 963 cp -f *.mod ../../../lib 964 fi 965 cd .. 966 done 967 fi # of "if [ -d tools ]" 968 echo install_lmdz.sh orchidee_compil_seq_OK `date` 969 fi # of if [ "$veget" != 'NONE' ] 970 971 972 #============================================================================ 973 # Ehouarn: the directory name LMDZ* depends on version/tar file... 974 if [ -d $MODEL/modipsl/modeles/LMD* ] ; then 975 echo '###############################################################' 976 echo 'Preparing LMDZ compilation : arch file, svn switch if needed...' 977 echo '###############################################################' 978 cd $MODEL/modipsl/modeles/LMD* 979 LMDZPATH=`pwd` 980 else 981 echo "ERROR: No LMD* directory !!!" 982 exit 983 fi 984 985 ########################################################### 986 # For those who want to use fcm to compile via : 987 # makelmdz_fcm -arch local ..... 988 ############################################################ 989 990 991 992 cd $MODEL/modipsl/modeles/LMDZ* 993 lmdzlog=`pwd`/lmdz.log 994 995 ################################################################## 996 # Possibly update LMDZ if a specific svn release is requested 997 ################################################################## 998 999 set +e ; svn upgrade ; set -e 1000 1001 if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi 1002 if [ "$svn" != "" ] ; then 1003 set +e ; svn info | grep -q 'https:' 1004 if [ $? = 0 ] ; then 1005 svn switch --relocate https://svn.lmd.jussieu.fr/LMDZ \ 1006 http://svn.lmd.jussieu.fr/LMDZ 1007 fi 1008 svn update $svnopt 1009 set -e 1010 fi 1011 1012 #--------------------------------------------------------------------- 1013 # Retrieve the final svn release number, and adjust compilation 1014 # options accordingly 1015 # If svn not available, will use the svn writen in $MODEL/Readm*md 1016 # For old version it assumes that it is before 4185 (the version 1017 # for which the test was introduced 1018 #--------------------------------------------------------------------- 1019 1020 set +e ; mysvn=`svnversion . | egrep -o "[0-9]+" 2>/dev/null` ; set -e 1021 if [ "$mysvn" = "" ] ; then mysvn=`grep 'Revision: [0-9]' $MODEL/Read*.md | awk ' { print $2 } ' 2>/dev/null` ; fi 1022 if [ "$mysvn" = "" ] ; then mysvn=4190 ; fi 1023 1024 if [[ "$pclinux" = "1" && ! -f arch/arch-local.path ]] ; then 1025 1026 # create local 'arch' files (if on Linux PC): 1027 cd arch 1028 # arch-local.path file 1029 # test for version as arch.pth file changed format with rev 4426 1030 if [ "$mysvn" -gt 4425 ] ; then 1031 echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib \"" > arch-local.path 1032 echo "NETCDF_LIB=\"-lnetcdff -lnetcdf\"" >> arch-local.path 1033 echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path 1034 echo 'NETCDF95_INCDIR=-I$LMDGCM/../../include' >> arch-local.path 1035 echo 'NETCDF95_LIBDIR=-L$LMDGCM/../../lib' >> arch-local.path 1036 echo 'NETCDF95_LIB=-lnetcdf95' >> arch-local.path 1037 echo 'IOIPSL_INCDIR=-I$LMDGCM/../../lib' >> arch-local.path 1038 echo 'IOIPSL_LIBDIR=-L$LMDGCM/../../lib' >> arch-local.path 1039 echo 'IOIPSL_LIB=-lioipsl' >> arch-local.path 1040 echo 'XIOS_INCDIR=-I$LMDGCM/../XIOS/inc' >> arch-local.path 1041 echo 'XIOS_LIBDIR=-L$LMDGCM/../XIOS/lib' >> arch-local.path 1042 echo "XIOS_LIB=\"-lxios -lstdc++\"" >> arch-local.path 1043 echo 'ORCH_INCDIR=-I$LMDGCM/../../lib' >> arch-local.path 1044 echo 'ORCH_LIBDIR=-L$LMDGCM/../../lib' >> arch-local.path 1045 else 1046 echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" \ 1047 > arch-local.path 1048 echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path 1049 echo 'NETCDF95_INCDIR=$LMDGCM/../../include' >> arch-local.path 1050 echo 'NETCDF95_LIBDIR=$LMDGCM/../../lib' >> arch-local.path 1051 echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path 1052 echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path 1053 echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path 1054 echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path 1055 echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path 1056 echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path 1057 fi 1058 1059 if [ $pcmac == 1 ] ; then 1060 BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib" 1061 else 1062 BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib" 1063 fi 1064 # Arch-local.fcm file (adapted from arch-linux-32bit.fcm) 1065 1066 if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi 1067 sed -e s:"%COMPILER .*.$":"%COMPILER $compiler":1 \ 1068 -e s:"%LINK .*.$":"%LINK $compiler":1 \ 1069 -e s:"%PROD_FFLAGS .*.$":"%PROD_FFLAGS $OPTIM":1 \ 1070 -e s:"%DEV_FFLAGS .*.$":"%DEV_FFLAGS $OPTDEV":1 \ 1071 -e s:"%DEBUG_FFLAGS .*.$":"%DEBUG_FFLAGS $OPTDEB":1 \ 1072 -e s:"%BASE_FFLAGS .*.$":"%BASE_FFLAGS $OPTPREC":1 \ 1073 -e s:"%FPP_DEF .*.$":"%FPP_DEF $FPP_DEF":1 \ 1074 -e s:"%BASE_LD .*.$":"%BASE_LD $BASE_LD":1 \ 1075 -e s:"%ARFLAGS .*.$":"%ARFLAGS $ARFLAGS":1 \ 1076 arch-linux-32bit.fcm > arch-local.fcm 1077 1078 cd .. 1079 ### Adapt "bld.cfg" (add the shell): 1080 #whereisthatshell=$(which ${use_shell}) 1081 #echo "bld::tool::SHELL $whereisthatshell" >> bld.cfg 1082 1083 fi # of if [ "$pclinux" = 1 ] 1084 #--------------------------------------------------------------------- 1085 # Option de compilation du rayonnement : depend de $mysvn ><= r4185 1086 #--------------------------------------------------------------------- 1087 opt_rad="" 1088 1089 case $rad in 1090 oldrad) iflag_rrtm=0 ; NSW=2 ; opt_rad="" ;; 1091 rrtm) iflag_rrtm=1 ; NSW=6 1092 if [ $mysvn -le 4185 ] ; then 682 exe_name="bin/${fortran_file}_${grid_resolution}_phy${compphysiq}_${rad}${suff_para}${suff_orc}${suff_aer}${suff_iso}.e" 683 fi 684 685 local opt_rad 686 case $rad in 687 oldrad) iflag_rrtm=0; NSW=2; opt_rad="";; 688 rrtm) iflag_rrtm=1; NSW=6 689 if [[ $used_lmdz_rev -le 4185 ]]; then 1093 690 opt_rad="-rrtm true" 1094 691 else 1095 692 opt_rad="-rad rrtm" 1096 fi ;; 1097 ecrad) iflag_rrtm=2 ; NSW=6 ; opt_rad="-rad ecrad" ;; 1098 *) echo Only oldrad rrtm ecrad for rad option ; exit 1099 esac 1100 1101 if [ $mysvn -le 4185 -a $rad = "ecrad" ] ; then 1102 echo "ecrad only available for LMDZ rev starting with 4186 " ; exit 693 fi;; 694 ecrad) iflag_rrtm=2; NSW=6; opt_rad="-rad ecrad";; 695 *) echo "Only oldrad rrtm ecrad for rad option"; exit 1 696 esac 697 if [[ $used_lmdz_rev -le 4185 && $rad = "ecrad" ]]; then 698 echo "ecrad only available for LMDZ rev starting with 4186 "; exit 1 699 fi 700 701 # Compile 702 local makelmdz="makelmdz_fcm $optim_flag -arch $arch -j $make_j" 703 local para_compile_opt="-mem -parallel $parallel"; if [[ $parallel = "none" ]]; then para_compile_opt=""; fi 704 do_compile_sh "LMDZ" "$jobcmd ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios $opt_aer $opt_inlandsis $opt_strataer $opt_isotopes -p $compphysiq -d ${grid_resolution} -v $fcm_veget_version $para_compile_opt $fortran_file" 705 706 # Check executable 707 if [[ ! -f $exe_name ]]; then 708 echo "STOP: Compilation failed, can't find the executable"; exit 1 709 else 710 echo "Compilation successful, the executable is $exe_name $(date)" 711 fi 712 } 713 714 function get_dynamico_icosa_version { 715 if [[ $icolmdz = 1 ]]; then 716 echo "Checking DYNAMICO source version" 717 cd "$MODEL/modipsl/modeles" 718 if [[ ! -d DYNAMICO ]]; then 719 git clone https://gitlab.in2p3.fr/ipsl/projets/dynamico/dynamico.git DYNAMICO 720 fi 721 cd DYNAMICO 722 git checkout master && git checkout $dynamico_commit 723 cd - > /dev/null 724 725 echo "Checking ICOSA_LMDZ source version" 726 if [[ ! -d ICOSA_LMDZ ]]; then 727 svn checkout http://svn.lmd.jussieu.fr/LMDZ/ICOSA_LMDZ 728 fi 729 cd ICOSA_LMDZ 730 svn up -r 5320 731 fi 732 } 733 734 function compile_icolmdzor { 735 if [[ $icolmdz = 1 ]]; then 736 install_arch "ICOSA_LMDZ" 737 local para_compile_opt="-parallel $parallel"; if [[ $parallel = "none" ]]; then para_compile_opt=""; fi 738 739 # LMDZ physics package library already available in LMDZ/config/lib directory 740 741 # Compile DYNAMICO 742 cd "$MODEL/modipsl/modeles/DYNAMICO" 743 744 # Need to get rather than install the archs as DYNAMICO uses FCMv2 that does not understand the makefile syntax ($shell) 745 cd arch 746 wget "http://lmdz.lmd.jussieu.fr/pub/src_archives/misc/arch/DYNAMICO/arch-$arch.env" 747 wget "http://lmdz.lmd.jussieu.fr/pub/src_archives/misc/arch/DYNAMICO/arch-$arch.fcm" 748 wget "http://lmdz.lmd.jussieu.fr/pub/src_archives/misc/arch/DYNAMICO/arch-$arch.path" 749 cd .. 750 751 do_compile_sh "DYNAMICO" "$jobcmd ./make_icosa $optim_flag -arch $arch -job $make_j $para_compile_opt -external_ioipsl -with_xios" 752 753 # Compile icosa_lmdz 754 echo "Bin PATH before icosalmdz" "$PATH" 755 cd "$MODEL/modipsl/modeles/ICOSA_LMDZ" 756 do_compile_sh "ICOSA_LMDZ" "$jobcmd ./make_icosa_lmdz -arch $arch -j $make_j -nodeps -p lmd $optim_flag $para_compile_opt -with_orchidee" 757 echo "# Running environment for icosa_lmdz" > icosalmdz.env 758 echo "# " >> icosalmdz.env 759 if [[ -v LD_LIBRARY_PATH ]]; then 760 echo "export LD_LIBRARY_PATH=$ncdfdir/lib:$LD_LIBRARY_PATH" >> icosalmdz.env 761 else 762 echo "export LD_LIBRARY_PATH=$ncdfdir/lib" >> icosalmdz.env 763 fi 764 fi 765 } 766 767 function run_bench { 768 local bench_cmd="./bench.sh" 769 770 cd "$MODEL/modipsl/modeles/LMDZ"* 771 772 if [[ $bench = "tuto" ]]; then 773 myget "Training/tutorial.tar"; tar xf tutorial.tar; cd TUTORIAL 774 ./init.sh 775 elif [[ $bench = 1 ]]; then 776 rm -rf "BENCH${grid_resolution}" 777 local bench=bench_lmdz_${grid_resolution} 778 if [[ $compphysiq = "lmdiso" ]]; then bench=bench_lmdz_iso_${grid_resolution}; fi 779 780 if [[ $is_1D = "y" ]] ; then # 1D 781 myget "1D/1D.tar.gz" 782 mkdir -p "BENCH${grid_resolution}" 783 tar xf "1D.tar.gz" -C "BENCH${grid_resolution}" --strip-components=1 784 cd "BENCH${grid_resolution}" 785 # Below: ugly, but until we rewrite the 1D case... 786 sed -i'' -e "s:^listecas=.*$:listecas=ARMCU/REF:" -e "s:cd \$local/bin ; ./compile -L \$L:#cd \$local/bin ; ./compile -L \$L:" \ 787 -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:" \ 788 run.sh 789 cp "../$exe_name" bin/ 790 bench_cmd="./run.sh -rad $rad" # suppress ferret commands that launch after bench is "over" 791 else 792 myget "3DBenchs/$bench.tar.gz" 793 mkdir "BENCH${grid_resolution}" 794 tar xf "$bench.tar.gz" -C "BENCH${grid_resolution}" --strip-components=1 795 796 if [[ $cosp = "v1" || $cosp = "v2" ]]; then 797 cd "BENCH${grid_resolution}" 798 # copier les fichiers namelist input et output our COSP 799 cp ../DefLists/cosp*_input_nl.txt . 800 cp ../DefLists/cosp*_output_nl.txt . 801 # Activer la cles ok_cosp pour tourner avec COSP 802 sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp 803 \mv -f tmp config.def 804 cd .. 805 fi 806 807 if [[ -n "$benchphysiq" ]]; then 808 cd "BENCH${grid_resolution}" 809 if [[ -f "physiq.def_${benchphysiq}" ]]; then 810 cp "physiq.def_${benchphysiq}" benchphysiq.def 811 echo "using physiq.def_${benchphysiq}" 812 else 813 echo "using standard physiq.def" 814 fi 815 cd .. 816 else 817 echo "using standard physiq.def" 818 fi 819 820 if [[ $with_xios = 1 ]]; then 821 cd "BENCH${grid_resolution}" 822 cp ../DefLists/iodef.xml . 823 cp ../DefLists/context_lmdz.xml . 824 cp ../DefLists/field_def_lmdz.xml . 825 # A raffiner par la suite 826 echo "A FAIRE : Copier les *xml en fonction de l option cosp" 827 cp ../DefLists/field_def_cosp*.xml . 828 cp ../DefLists/file_def_hist*xml . 829 # adapt iodef.xml to use attached mode 830 sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' \ 831 iodef.xml > tmp 832 \mv -f tmp iodef.xml 833 834 # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. 835 # except for histday 836 for histfile in file_def_hist*xml; do 837 if [[ "$histfile" = "file_def_histday_lmdz.xml" ]]; then 838 sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' \ 839 "$histfile" > tmp 840 \mv -f tmp "$histfile" 841 sed -e 's@output_level="_AUTO_"@output_level="5"@' "$histfile" \ 842 > tmp 843 \mv -f tmp "$histfile" 844 sed -e 's@compression_level="2"@compression_level="0"@' \ 845 "$histfile" > tmp 846 \mv -f tmp "$histfile" 847 else 848 sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ 849 "$histfile" > tmp 850 \mv -f tmp "$histfile" 851 fi 852 done 853 # and add option "ok_all_xml=y" in config.def 854 echo "### XIOS outputs" >> config.def 855 echo 'ok_all_xml=.true.' >> config.def 856 857 #activer les sorties pour Cosp 858 if [[ "$cosp" = "v1" ]]; then 859 sed -i'' -e 's@enabled=".FALSE."@enabled=".TRUE."@' \ 860 -e 's@output_level="_AUTO_"@output_level="5"@' \ 861 -e 's@compression_level="2"@compression_level="0"@' \ 862 file_def_histdayCOSP_lmdz.xml 863 fi 864 if [[ "$cosp" = "v2" ]]; then 865 sed -i'' -e 's@compression_level="2"@compression_level="0"@' file_def_histdayCOSPv2_lmdz.xml 866 for type_ in hf day mth; do 867 file=file_def_hist${type_}COSP 868 sed -i'' -e 's@src="./'${file}'_lmdz.xml"@src="./'${file}'v2_lmdz.xml"@' context_lmdz.xml 869 done 870 sed -i'' -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' field_def_lmdz.xml 871 fi 872 873 cd .. 874 fi 875 876 # Cas Bench avec ecrad 877 if [[ $rad = "ecrad" ]]; then 878 cd "BENCH${grid_resolution}" 879 cp ../DefLists/namelist_ecrad . 880 cp -r ../libf/phylmd/ecrad/data . 881 cd .. 882 fi 883 884 # Adjusting bench physiq.def to radiative code chosen 885 cd "BENCH${grid_resolution}" 886 sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' \ 887 -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef 888 \mv tmpdef physiq.def 889 cd .. 890 891 cp "$exe_name" "BENCH${grid_resolution}/gcm.e" 892 cd "BENCH${grid_resolution}" 893 894 if [[ ${parallel:0:3} = "mpi" ]]; then 895 # Lancement avec deux procs mpi et 2 openMP 896 echo "export OMP_STACKSIZE=800M" > bench.sh 897 if [[ "${parallel:4:3}" = "omp" ]]; then 898 echo "export OMP_NUM_THREADS=2" >> bench.sh 899 fi 900 if [[ $cosp = "v1" || $cosp = "v2" ]]; then 901 echo "ulimit -s 200000" >> bench.sh 902 else 903 echo "ulimit -s unlimited" >> bench.sh 904 fi 905 if which mpirun &> /dev/null; then 906 echo "mpirun -np 2 gcm.e &> listing" >> bench.sh 907 elif grep -q "Adastra" /etc/motd; then 908 local account 909 account=$(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-) 910 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" 911 echo "./gcm.e &> listing" >> bench.sh 912 else 913 echo "Error: No command found to run parallel bench"; exit 1 914 fi 915 if [[ $(hostname | cut -c -6) = "spirit" ]]; then # ulimit unlimited segfaults on Spirit 916 sed -i'' "s/ulimit -s unlimited/ulimit -Ss 8000/" bench.sh 917 fi 918 # Add rebuild, using reb.sh if it is there 919 cat <<EOF >> bench.sh 920 if [[ -f reb.sh ]]; then 921 ./reb.sh histday; ./reb.sh histmth; ./reb.sh histhf; 922 ./reb.sh histins; ./reb.sh stomate_history; 923 ./reb.sh sechiba_history; ./reb.sh sechiba_out_2 1103 924 fi 1104 1105 ################################################################## 1106 1107 1108 if [[ ! -f libf/misc/netcdf95.F90 && ! -d $MODEL/NetCDF95-0.3 ]] 1109 then 1110 cd $MODEL 1111 myget src_archives/netcdf/NetCDF95-0.3.tar.gz 1112 tar -xf NetCDF95-0.3.tar.gz 1113 rm NetCDF95-0.3.tar.gz 1114 cd NetCDF95-0.3 1115 mkdir build 1116 cd build 1117 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$ncdfdir \ 1118 -DCMAKE_INSTALL_PREFIX=$MODEL/modipsl 1119 make install 1120 cd $MODEL/modipsl/modeles/LMDZ* 1121 fi 1122 1123 echo '##################################################################' 1124 echo "Preparing script compile.sh for LMDZ compilation" 1125 echo "It will only be run automatically if bench=1/tuto" 1126 echo Here bench=$bench 1127 echo '##################################################################' 1128 1129 if [ "$env_file" != "" ] ; then 1130 mv arch/arch-${arch}.env arch/arch-${arch}.orig 1131 \cp -f $env_file arch/arch-${arch}.env 1132 fi 1133 1134 if [ $compile_with_fcm = 1 ] ; then 1135 makelmdz="makelmdz_fcm $optim -arch $arch -j 8 " 1136 else 1137 makelmdz="makelmdz $optim -arch $arch" 1138 fi 1139 1140 # sequential compilation 1141 if [ "$sequential" = 1 ] ; then 1142 echo Sequential compilation command, saved in compile.sh: 1143 echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp " \ 1144 "-d ${grid_resolution} -v $veget_version gcm " 1145 echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp " \ 1146 "-d ${grid_resolution} -v $veget_version gcm " > compile.sh 1147 chmod +x ./compile.sh 1148 if [ $bench = 1 ] ; then 1149 echo install_lmdz.sh start_lmdz_seq_compilation `date` 1150 echo log file: $lmdzlog 1151 ./compile.sh > $lmdzlog 2>&1 1152 echo install_lmdz.sh end_lmdz_seq_compilation `date` 1153 fi 1154 fi # fin sequential 1155 1156 # compiling in parallel mode 1157 if [ $parallel != "none" ] ; then 1158 echo '##########################################################' 1159 echo ' Parallel compile ' 1160 echo '##########################################################' 1161 echo "(after saving the sequential libs and binaries)" 1162 cd $MODEL/modipsl 1163 tar cf sequential.tar bin/ lib/ 1164 # 1165 # Orchidee 1166 # 1167 cd $ORCHPATH 1168 if [ -d src_parallel -a $veget != 'NONE' ] ; then 1169 cd arch 1170 sed \ 1171 -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ 1172 -e s:"%LINK.*.$":"%LINK $par_comp":1 \ 1173 -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ 1174 -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ 1175 -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ 1176 -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ 1177 arch-local.fcm > tmp.fcm 1178 1179 mv tmp.fcm arch-local.fcm 1180 cd ../ 1181 echo Compiling ORCHIDEE in parallel mode `date` 1182 echo logfile $orchideelog 1183 echo "NOTE : to recompile it when necessary, use ./compile_orc.sh " \ 1184 "in modipsl/modeles/ORCHIDEE" 1185 echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc \ 1186 -parallel $parallel -arch $arch > compile_orc.sh 1187 echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc \ 1188 -parallel $parallel -arch $arch >> compile_orc.sh 1189 echo echo Now you must also recompile LMDZ, by running ./compile.sh \ 1190 in modeles/LMDZ >> compile_orc.sh 1191 chmod u+x compile_orc.sh 1192 ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc \ 1193 -parallel $parallel -arch $arch > $orchideelog 2>&1 1194 ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel \ 1195 -arch $arch >> $orchideelog 2>&1 1196 echo End of ORCHIDEE compilation in parallel mode `date` 1197 elif [ $veget != 'NONE' ] ; then 1198 echo '##########################################################' 1199 echo ' Orchidee version too old ' 1200 echo ' Please update to new version ' 1201 echo '##########################################################' 1202 exit 1203 fi # of [ -d src_parallel -a $veget != 'NONE' ] 1204 1205 # LMDZ 1206 cd $LMDZPATH 1207 if [ $arch = local ] ; then 1208 cd arch 1209 sed -e s:"%COMPILER.*.$":"%COMPILER $par_comp":1 \ 1210 -e s:"%LINK.*.$":"%LINK $par_comp":1 \ 1211 -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS $MPI_FLAGS":1 \ 1212 -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS $OMP_FLAGS":1 \ 1213 -e s:"%ARFLAGS.*.$":"%ARFLAGS $ARFLAGS":1 \ 1214 -e s@"%BASE_LD.*.$"@"%BASE_LD -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \ 1215 -e s:"%MPI_LD.*.$":"%MPI_LD $MPI_LD":1 \ 1216 -e s:"%OMP_LD.*.$":"%OMP_LD $OMP_LD":1 \ 1217 arch-local.fcm > tmp.fcm 1218 mv tmp.fcm arch-local.fcm 1219 cd ../ 1220 fi 1221 rm -f compile.sh 1222 echo resol=${grid_resolution} >> compile.sh 1223 if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then 1224 1225 echo LMDZ compilation command in parallel mode, saved in compile.sh, \ 1226 is : 1227 echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod " \ 1228 "n est pas corrige ! )" 1229 # ATTENTION le probleme de cospv2 sur jean-zay en mode prod n 1230 # est pas corrige 1231 echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \ 1232 $opt_makelmdz_xios -d \$resol -v $veget_version -mem \ 1233 -parallel $parallel gcm >> compile.sh 1234 echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \ 1235 $opt_makelmdz_xios -d \$resol -v $veget_version -mem \ 1236 -parallel $parallel gcm 1237 else 1238 echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \ 1239 $opt_makelmdz_xios -d \$resol -v $veget_version -mem \ 1240 -parallel $parallel gcm >> compile.sh 1241 echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \ 1242 $opt_makelmdz_xios -d \$resol -v $veget_version -mem \ 1243 -parallel $parallel gcm 1244 fi 1245 chmod +x ./compile.sh 1246 1247 if [ $bench = 1 ] ; then 1248 echo Compiling LMDZ in parallel mode `date`, LMDZ log file: $lmdzlog 1249 ./compile.sh > $lmdzlog 2>&1 1250 fi 1251 1252 fi # of if [ $parallel != "none" ] 1253 1254 1255 ################################################################## 1256 # Verification du succes de la compilation 1257 ################################################################## 1258 1259 # Recherche de l'executable dont le nom a change au fil du temps ... 1260 # suffix contains radiative option starting with revision 4186 1261 if [ $mysvn -ge 4186 ] ; then suff_exe=_${rad}${suff_exe} ; fi 1262 gcm="" 1263 1264 for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e 1265 do 1266 if [ -f $exe ] ; then gcm=$exe ; fi 1267 done 1268 1269 if [ "$gcm" = "" ] ; then 1270 if [ $bench = 1 ] ; then 1271 echo 'Compilation failed !! Cannot run the benchmark;' 1272 exit 1273 else 1274 echo 'Compilation not done (only done when bench=1)' 1275 fi 1276 else 1277 echo '##########################################################' 1278 echo 'Compilation successfull !! ' `date` 1279 echo '##########################################################' 1280 echo The executable is $gcm 1281 fi 1282 1283 ################################################################## 1284 # Below, we run a benchmark if bench=1 or tuto 1285 ################################################################## 1286 1287 if [ $bench = tuto ] ; then 1288 myget Training/tutorial.tar ; tar xf tutorial.tar ; cd TUTORIAL 1289 ./init.sh 1290 1291 elif [[ $bench = 1 && ! -d BENCH${grid_resolution} ]] ; then 1292 # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE 1293 # OU DES BENCHS PAR MOTS CLES COMME tuto 1294 1295 echo '##########################################################' 1296 echo ' Running a test run ' 1297 echo '##########################################################' 1298 1299 \rm -rf BENCH${grid_resolution} 1300 bench=bench_lmdz_${grid_resolution} 1301 echo install_lmdz.sh before bench download `date` 1302 #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz 1303 myget 3DBenchs/$bench.tar.gz 1304 echo install_lmdz.sh after bench download `date` 1305 tar xf $bench.tar.gz 1306 1307 if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then 1308 cd BENCH${grid_resolution} 1309 # copier les fichiers namelist input et output our COSP 1310 cp ../DefLists/cosp*_input_nl.txt . 1311 cp ../DefLists/cosp*_output_nl.txt . 1312 # Activer la cles ok_cosp pour tourner avec COSP 1313 sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp 1314 \mv -f tmp config.def 1315 cd .. 1316 fi 1317 1318 if [ -n "$physiq" ]; then 1319 cd BENCH${grid_resolution} 1320 if [ -f physiq.def_${physiq} ]; then 1321 cp physiq.def_${physiq} physiq.def 1322 echo using physiq.def_${physiq} 925 EOF 1323 926 else 1324 echo using standard physiq.def 1325 fi 1326 cd .. 1327 else 1328 echo using standard physiq.def 1329 fi 1330 1331 if [ "$with_xios" = "y" ] ; then 1332 cd BENCH${grid_resolution} 1333 cp ../DefLists/iodef.xml . 1334 cp ../DefLists/context_lmdz.xml . 1335 cp ../DefLists/field_def_lmdz.xml . 1336 # A raffiner par la suite 1337 echo A FAIRE : Copier les *xml en fonction de l option cosp 1338 cp ../DefLists/field_def_cosp*.xml . 1339 cp ../DefLists/file_def_hist*xml . 1340 # adapt iodef.xml to use attached mode 1341 sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' \ 1342 iodef.xml > tmp 1343 \mv -f tmp iodef.xml 1344 1345 # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE. 1346 # except for histday 1347 for histfile in file_def_hist*xml 1348 do 1349 if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then 1350 sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' \ 1351 $histfile > tmp 1352 \mv -f tmp $histfile 1353 sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile \ 1354 > tmp 1355 \mv -f tmp $histfile 1356 sed -e 's@compression_level="2"@compression_level="0"@' \ 1357 $histfile > tmp 1358 \mv -f tmp $histfile 1359 else 927 echo "./gcm.e &> listing" > bench.sh 928 fi 929 chmod +x bench.sh 930 # Getting orchidee stuff 931 if [[ $veget = 'CMIP6' || $veget = "orch2.0" ]]; then # TODO once we have a 2.2 bench, add it here (or in planned separate bench script) 932 echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' 933 myget 3DBenchs/BENCHCMIP6.tar.gz 934 tar xvzf BENCHCMIP6.tar.gz 935 sed -e "s:VEGET=n:VEGET=y:" config.def > tmp 936 mv -f tmp config.def 937 if [[ $with_xios = 1 ]]; then 938 cp ../../ORCHIDEE/src_xml/context_orchidee.xml . 939 echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp 940 cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml . 941 cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml . 942 cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml . 943 if [[ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ]]; then 944 cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml . 945 echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp 946 fi 947 sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp 948 mv tmp iodef.xml 949 sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' \ 950 file_def_orchidee.xml > tmp 951 \mv -f tmp file_def_orchidee.xml 1360 952 sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ 1361 $histfile > tmp 1362 \mv -f tmp $histfile 953 file_def_orchidee.xml > tmp 954 \mv -f tmp file_def_orchidee.xml 955 sed -e 's@output_level="_AUTO_"@output_level="1"@' \ 956 file_def_orchidee.xml > tmp 957 \mv -f tmp file_def_orchidee.xml 958 sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' \ 959 file_def_orchidee.xml > tmp 960 \mv -f tmp file_def_orchidee.xml 961 sed -e 's@compression_level="4"@compression_level="0"@' \ 962 file_def_orchidee.xml > tmp 963 \mv -f tmp file_def_orchidee.xml 964 sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' \ 965 orchidee.def > tmp 966 \mv -f tmp orchidee.def 1363 967 fi 968 fi 969 970 fi 971 972 if [[ -f ../arch.env ]]; then source ../arch.env; fi 973 974 echo "STARTING BENCH" 975 date 976 if (! $bench_cmd &> out.bench) || ! (tail -n 1 listing | grep "Everything is cool"); then 977 tail listing 978 echo "Bench FAILED, exiting"; exit 1 979 fi 980 date 981 tail listing 982 fi 983 984 # 1D case 985 if [[ $SCM = 1 ]]; then 986 cd "$MODEL" 987 myget 1D/1D.tar.gz 988 tar xf 1D.tar.gz 989 cd 1D 990 for e in "fcm" "env" "path"; do 991 cp "$MODEL/modipsl/modeles/LMDZ/arch/arch-$arch.$e" "$MODEL/modipsl/modeles/LMDZ/arch/arch-local.$e" 1364 992 done 1365 # and add option "ok_all_xml=y" in config.def 1366 echo "### XIOS outputs" >> config.def 1367 echo 'ok_all_xml=.true.' >> config.def 1368 1369 #activer les sorties pour Cosp 1370 if [ "$cosp" = "v1" ] ; then 1371 sed -i'' -e 's@enabled=".FALSE."@enabled=".TRUE."@' \ 1372 -e 's@output_level="_AUTO_"@output_level="5"@' \ 1373 -e 's@compression_level="2"@compression_level="0"@' \ 1374 file_def_histdayCOSP_lmdz.xml 1375 fi 1376 if [ "$cosp" = "v2" ] ; then 1377 sed -e 's@compression_level="2"@compression_level="0"@' file_def_histdayCOSPv2_lmdz.xml 1378 for type_ in hf day mth ; do 1379 file=file_def_hist${type_}COSP 1380 sed -i'' -e 's@src="./'${file}'_lmdz.xml"@src="./'${file}'v2_lmdz.xml"@' context_lmdz.xml 1381 done 1382 sed -i '' -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' field_def_lmdz.xml 1383 fi 1384 1385 cd .. 1386 fi 1387 1388 # Cas Bensh avec ecrad 1389 if [ "$rad" = "ecrad" ] ; then 1390 cd BENCH${grid_resolution} 1391 cp ../DefLists/namelist_ecrad . 1392 cp -r ../libf/phylmd/ecrad/data . 1393 cd .. 1394 fi 1395 1396 # Adjusting bench physiq.def to radiative code chosen 1397 cd BENCH${grid_resolution} 1398 sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' \ 1399 -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef 1400 \mv tmpdef physiq.def 1401 cd .. 1402 1403 cp $gcm BENCH${grid_resolution}/gcm.e 1404 1405 cd BENCH${grid_resolution} 1406 # On cree le fichier bench.sh au besoin 1407 # Dans le cas 48x36x39 le bench.sh existe deja en parallele 1408 1409 if [ "$grid_resolution" = "48x36x39" ] ; then 1410 echo On ne touche pas au bench.sh 1411 # But we have to adapt "run_local.sh" for $mpirun 1412 sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp 1413 mv -f tmp run_local.sh 1414 chmod u=rwx run_local.sh 1415 elif [ "${parallel:0:3}" = "mpi" ] ; then 1416 # Lancement avec deux procs mpi et 2 openMP 1417 echo "export OMP_STACKSIZE=800M" > bench.sh 1418 if [ "${parallel:4:3}" = "omp" ] ; then 1419 echo "export OMP_NUM_THREADS=2" >> bench.sh 1420 fi 1421 if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then 1422 if [ ${hostname:0:5} = jean- ] ; then 1423 chmod +x ../arch.env 1424 ../arch.env 1425 echo "ulimit -s 2000000" >> bench.sh 1426 else 1427 echo "ulimit -s 200000" >> bench.sh 1428 fi 1429 else 1430 echo "ulimit -s unlimited" >> bench.sh 1431 fi 1432 if [ ${hostname:0:5} = jean- ] ; then 1433 . ../arch/arch-${arch}.env 1434 echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing 2>&1" \ 1435 >> bench.sh 1436 else 1437 echo "$mpirun -np 2 gcm.e > listing 2>&1" >> bench.sh 1438 fi 1439 # Add rebuild, using reb.sh if it is there 1440 echo 'if [ -f reb.sh ] ; then' >> bench.sh 1441 echo ' ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ' \ 1442 './reb.sh histins ; ./reb.sh stomate_history ; ' \ 1443 './reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh 1444 echo 'fi' >> bench.sh 1445 else 1446 echo "./gcm.e > listing 2>&1" > bench.sh 1447 fi 1448 # Getting orchidee stuff 1449 if [ $veget == 'CMIP6' ] ; then 1450 #echo 'myget 3DBenchs/BENCHorch11.tar.gz' 1451 #myget 3DBenchs/BENCHorch11.tar.gz 1452 #tar xvzf BENCHorch11.tar.gz 1453 echo 'myget 3DBenchs/BENCHCMIP6.tar.gz' 1454 myget 3DBenchs/BENCHCMIP6.tar.gz 1455 tar xvzf BENCHCMIP6.tar.gz 1456 sed -e "s:VEGET=n:VEGET=y:" config.def > tmp 1457 mv -f tmp config.def 1458 if [ "$with_xios" = "y" ] ; then 1459 cp ../../ORCHIDEE/src_xml/context_orchidee.xml . 1460 echo '<context id="orchidee" src="./context_orchidee.xml"/>' \ 1461 > add.tmp 1462 cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml . 1463 cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml . 1464 cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml . 1465 if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then 1466 cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml . 1467 echo '<context id="orchidee" ' \ 1468 'src="./context_input_orchidee.xml"/>' >> add.tmp 1469 fi 1470 sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp 1471 mv tmp iodef.xml 1472 sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' \ 1473 file_def_orchidee.xml > tmp 1474 \mv -f tmp file_def_orchidee.xml 1475 sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \ 1476 file_def_orchidee.xml > tmp 1477 \mv -f tmp file_def_orchidee.xml 1478 sed -e 's@output_level="_AUTO_"@output_level="1"@' \ 1479 file_def_orchidee.xml > tmp 1480 \mv -f tmp file_def_orchidee.xml 1481 sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' \ 1482 file_def_orchidee.xml > tmp 1483 \mv -f tmp file_def_orchidee.xml 1484 sed -e 's@compression_level="4"@compression_level="0"@' \ 1485 file_def_orchidee.xml > tmp 1486 \mv -f tmp file_def_orchidee.xml 1487 sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' \ 1488 orchidee.def > tmp 1489 \mv -f tmp orchidee.def 1490 fi 1491 fi 1492 1493 if [[ -f ../arch.env ]] 1494 then 1495 source ../arch.env 1496 fi 1497 1498 echo EXECUTION DU BENCH 1499 set +e 1500 date ; ./bench.sh > out.bench 2>&1 ; date 1501 set -e 1502 tail listing 1503 1504 1505 echo '##########################################################' 1506 echo 'Simulation finished in' `pwd` 1507 echo 'You have compiled with:' 1508 cat ../compile.sh 1509 if [ $parallel = "none" ] ; then 1510 echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e' 1511 echo 'or ./bench.sh' 1512 else 1513 echo 'You may re-run it with : ' 1514 echo 'cd ' `pwd` '; ./bench.sh' 1515 # echo 'ulimit -s unlimited' 1516 # echo 'export OMP_NUM_THREADS=2' 1517 # echo 'export OMP_STACKSIZE=800M' 1518 # echo "$mpirun -np 2 gcm.e " 1519 fi 1520 echo '##########################################################' 1521 1522 fi # bench 1523 1524 1525 ################################################################# 1526 # Installation eventuelle du 1D 1527 ################################################################# 1528 1529 if [ $SCM = 1 ] ; then 1530 cd $MODEL 1531 myget 1D/1D.tar.gz 1532 tar xf 1D.tar.gz 1533 cd 1D 1534 if [ $rad = oldrad ] ; then 1535 sed -i'' -e 's/^rad=.*$/rad=oldrad/' run.sh 1536 sed -i'' -e 's/^rad=.*$/rad=oldrad/' bin/compile 1537 fi 1538 if [ $rad = ecrad ] ; then 1539 sed -i'' -e 's/^rad=.*$/rad=ecrad/' run.sh 1540 sed -i'' -e 's/^rad=.*$/rad=ecrad/' bin/compile 1541 fi 1542 echo Running 1D/run.sh, log in `pwd`/run1d.log 1543 ./run.sh > `pwd`/run1d.log 2>&1 1544 fi 1545 1546 1547 ################################################################# 1548 # sauvegarde des options veget pour utilisation eventuelle tutorial_prod 1549 ################################################################# 1550 cd $MODEL/modipsl/modeles 1551 #echo surface_env file created in $MODEL 1552 echo 'veget='$veget > surface_env 1553 #opt_veget="-v $veget_version" 1554 #echo 'opt_veget="'$opt_veget\" >> surface_env 1555 echo 'opt_veget="'-v $veget_version\" >> surface_env 1556 echo 'orchidee_rev='$orchidee_rev >> surface_env 1557 echo 'suforch='$suff_orc >> surface_env 993 if [[ $rad = "oldrad" ]]; then 994 sed -i'' -e 's/^rad=.*$/rad=oldrad/' run.sh 995 sed -i'' -e 's/^rad=.*$/rad=oldrad/' bin/compile 996 elif [[ $rad = ecrad ]] ; then 997 sed -i'' -e 's/^rad=.*$/rad=ecrad/' run.sh 998 sed -i'' -e 's/^rad=.*$/rad=ecrad/' bin/compile 999 fi 1000 echo "Running 1D/run.sh, log in $(pwd)/run1d.log" 1001 ./run.sh &> "$(pwd)/run1d.log" 1002 fi 1003 } 1004 1005 function run_bench_icosa { 1006 local bench_cmd="./bench.sh" 1007 1008 if [[ $icolmdz = 1 ]]; then 1009 cd "$MODEL/modipsl/modeles/ICOSA_LMDZ" 1010 if [[ $bench = 1 ]]; then 1011 namebench="bench_icolmdz_nbp10_79" 1012 rm -rf $namebench 1013 myget "3DBenchs/$namebench.tar.gz" 1014 mkdir -p $namebench 1015 tar xf "$namebench.tar.gz" -C "$namebench" --strip-components=1 1016 cd $namebench 1017 # copy executables 1018 if [[ ! -x ../bin/icosa_lmdz.exe ]]; then 1019 echo "STOP in icosa_lmdz bench, icosa_lmdz.exe executable not present"; exit 1 1020 fi 1021 cp ../bin/icosa_lmdz.exe . 1022 if [[ ! -x ../../XIOS/bin/xios_server.exe ]]; then 1023 echo "STOP in icosa_lmdz bench, XIOS executable not present"; exit 1 1024 fi 1025 cp ../../XIOS/bin/xios_server.exe . 1026 echo "STARTING ICOSA_LMDZ BENCH" 1027 date 1028 if (! $bench_cmd &> out.bench) || ! ( grep "Time elapsed" listing); then 1029 tail listing 1030 echo "ICOSA_LMDZ bench FAILED, exiting"; exit 1 1031 fi 1032 date 1033 echo "ICOSA_LMDZ bench finished" 1034 fi 1035 fi 1036 1037 } 1038 # If sourced: returns, else run setup 1039 if [[ ! "${BASH_SOURCE[0]}" = "$0" ]]; then return 0; fi 1040 1041 echo "install_lmdz.sh DEBUT $(date)" 1042 1043 set_default_params 1044 read_cmdline_args "$@" 1045 ensure_correct_option_combinations 1046 download_modipsl_tar 1047 init_arch 1048 check_available_software 1049 get_lmdz_version 1050 get_dynamico_icosa_version 1051 get_orchidee_version 1052 install_netcdf 1053 install_IOIPSL 1054 install_XIOS 1055 compile_orchidee 1056 compile_lmdz 1057 compile_icolmdzor 1058 run_bench 1059 run_bench_icosa
Note: See TracChangeset
for help on using the changeset viewer.