[4625] | 1 | #!/bin/bash |
---|
| 2 | #set -vx |
---|
| 3 | # Default options |
---|
| 4 | # |
---|
| 5 | # |
---|
| 6 | # |
---|
| 7 | date |
---|
| 8 | #### 1 Set up the compiling options |
---|
| 9 | #### Define some directories |
---|
| 10 | submitdir=$( pwd ) |
---|
| 11 | modipsl=$submitdir/../.. |
---|
| 12 | arch_path=$submitdir/ARCH |
---|
| 13 | |
---|
| 14 | #### Set default options |
---|
| 15 | # Optimization mode |
---|
| 16 | # optmode=prod/dev/debug |
---|
| 17 | optmode=prod |
---|
| 18 | # Resolution of LMDZ in regular mode |
---|
| 19 | regular_latlon=yes |
---|
[6218] | 20 | resol_atm_3d=144x142x79 |
---|
| 21 | # Also compile ce0l subprogram to LMDZ (y/n) |
---|
| 22 | ce0l=n |
---|
| 23 | |
---|
[4625] | 24 | optchimie=NMHC_AER_S |
---|
[4697] | 25 | #recompilation de inca seul ou de tous les modeles |
---|
| 26 | clean_inca="" |
---|
| 27 | full_flag="" |
---|
[4625] | 28 | |
---|
[6213] | 29 | # choose radiative code compilation option |
---|
| 30 | rad=rrtm |
---|
| 31 | opt_rad="" |
---|
| 32 | |
---|
| 33 | |
---|
[4625] | 34 | # fcm_arch |
---|
| 35 | fcm_arch=default |
---|
| 36 | # Default values to be overritten |
---|
| 37 | parallel=mpi_omp |
---|
| 38 | export fcm_arch parallel xios |
---|
[4697] | 39 | |
---|
[4625] | 40 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
| 41 | netcdf_lib="" |
---|
| 42 | |
---|
| 43 | # Output text file for compilation of each component |
---|
[5698] | 44 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
| 45 | outfile=$submitdir/out_compile_lmdzorinca.$datestr |
---|
| 46 | echo > $outfile |
---|
[6218] | 47 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzorinca.$datestr"; echo |
---|
[4625] | 48 | |
---|
| 49 | #### Read arguments |
---|
| 50 | # Loop over all arguments to modify default set up |
---|
| 51 | while (($# > 0)) ; do |
---|
| 52 | case $1 in |
---|
| 53 | "-h") cat <<fin |
---|
| 54 | |
---|
| 55 | ######################################################################## |
---|
[4706] | 56 | # Usage of the script compile_lmdzorinca.sh |
---|
[4625] | 57 | # |
---|
| 58 | ######################################################################## |
---|
| 59 | |
---|
| 60 | ./compile_config [Options] |
---|
| 61 | |
---|
[4706] | 62 | Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default) |
---|
[4625] | 63 | |
---|
[4706] | 64 | Example 1: Default compilation of LMDZ-ORCHIDEE-INCA with XIOS and IOIPSL - NMHC_AER_S / 96x95x39 |
---|
[4697] | 65 | ./compile_lmdzorinca.sh |
---|
[4625] | 66 | |
---|
[4706] | 67 | Example 2: Compilation with a chosen chemistry, for example DUSS (default: NMHC_AER_S) |
---|
| 68 | ./compile_lmdzorinca.sh -chimie DUSS |
---|
| 69 | |
---|
| 70 | Example 3: Compile in debug mode - in this case you need to modify Optmode in config.card |
---|
[4697] | 71 | ./compile_lmdzorinca.sh -debug |
---|
[4625] | 72 | |
---|
[4706] | 73 | Example 4: Default compilation with full recompilation of all components |
---|
[4697] | 74 | ./compile_lmdzorinca.sh -full |
---|
[4625] | 75 | |
---|
[4706] | 76 | Example 5: Default compilation with recompilation of inca model only |
---|
| 77 | ./compile_lmdzorinca.sh -clean_inca |
---|
| 78 | |
---|
| 79 | Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39) |
---|
[4625] | 80 | The dimension can be changed to any other 3d dimension. |
---|
[4706] | 81 | ./compile_lmdzorinca.sh -regular_latlon 144x142x79 |
---|
[4625] | 82 | |
---|
[6213] | 83 | Example 7: choose radiative schema for LMDZ (oldrad/rrtm/ecrad). Default is rrtm |
---|
| 84 | ./compile_lmdzorinca.sh -rad ecrad |
---|
| 85 | |
---|
| 86 | |
---|
[4625] | 87 | fin |
---|
| 88 | exit;; |
---|
| 89 | |
---|
| 90 | "-parallel") |
---|
| 91 | parallel=$2 ; shift ; shift ;; |
---|
| 92 | |
---|
| 93 | "-arch") |
---|
| 94 | fcm_arch="$2" ; shift ; shift ;; |
---|
| 95 | |
---|
| 96 | "-xios") |
---|
| 97 | xios="$2" ; shift ; shift ;; |
---|
| 98 | |
---|
| 99 | "-optmode") |
---|
| 100 | optmode=$2 ; shift ; shift ;; |
---|
| 101 | |
---|
| 102 | "-debug") |
---|
| 103 | optmode=debug ; shift ;; |
---|
| 104 | |
---|
| 105 | "-dev") |
---|
| 106 | optmode=dev ; shift ;; |
---|
| 107 | |
---|
| 108 | "-prod") |
---|
| 109 | optmode=prod ; shift ;; |
---|
| 110 | |
---|
[6218] | 111 | "-ce0l") |
---|
| 112 | ce0l=y ; shift ;; |
---|
| 113 | |
---|
[6213] | 114 | "-rad") |
---|
| 115 | rad=$2; shift ; shift;; |
---|
| 116 | |
---|
[4625] | 117 | "-regular_latlon") |
---|
| 118 | regular_latlon=yes ; |
---|
| 119 | resol_atm_3d=$2 ; shift ; shift ;; |
---|
| 120 | |
---|
| 121 | "-full") |
---|
| 122 | full_flag="-full"; shift ;; |
---|
[4697] | 123 | |
---|
| 124 | "-clean_inca") |
---|
| 125 | clean_inca="-clean"; shift ;; |
---|
[4625] | 126 | |
---|
| 127 | "-netcdf_lib_seq") |
---|
| 128 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
| 129 | |
---|
| 130 | "-chimie") |
---|
| 131 | echo $2; |
---|
| 132 | optchimie=$2; shift ; shift;; |
---|
| 133 | |
---|
| 134 | *) |
---|
| 135 | echo "unknown option "$2" , exiting..." |
---|
| 136 | exit |
---|
| 137 | esac |
---|
| 138 | done |
---|
| 139 | |
---|
| 140 | echo "Following arguments are set in current compiling:" >> $outfile |
---|
| 141 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile |
---|
[6218] | 142 | echo " ce0l=${ce0l}" >> $outfile |
---|
[5110] | 143 | echo " chimie = $optchimie, clean_inca = ${clean_inca}" |
---|
[4625] | 144 | echo >> $outfile |
---|
| 145 | |
---|
| 146 | ### Read host dependent default values |
---|
| 147 | ### These variables will not be changed if they were set as argument |
---|
| 148 | ###./host.sh $host |
---|
| 149 | # Later : Following lines should be set in host.sh file |
---|
| 150 | # begin host.sh |
---|
| 151 | if [ $fcm_arch == default ] ; then |
---|
| 152 | # Find out current host and source specific paths and commands for the host |
---|
| 153 | case $( hostname -s ) in |
---|
[5111] | 154 | jean-zay*) |
---|
| 155 | fcm_arch=X64_JEANZAY;; |
---|
| 156 | irene170|irene171|irene190|irene191|irene192|irene193) |
---|
| 157 | fcm_arch=X64_IRENE;; |
---|
| 158 | irene172|irene173|irene194|irene195) |
---|
| 159 | fcm_arch=X64_IRENE-AMD;; |
---|
[4625] | 160 | asterix*|obelix*) |
---|
| 161 | fcm_arch=ifort_LSCE;; |
---|
| 162 | ciclad*|climserv*) |
---|
| 163 | fcm_arch=ifort_CICLAD;; |
---|
| 164 | *) |
---|
| 165 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
| 166 | echo Exit now. |
---|
| 167 | exit |
---|
| 168 | esac |
---|
| 169 | fi |
---|
| 170 | |
---|
| 171 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
| 172 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 173 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
| 174 | echo >> $outfile |
---|
[6307] | 175 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components." |
---|
| 176 | echo "Note that this new environement might be kept after compilation." |
---|
| 177 | echo "If this is the case, source again your personal environment after compilation. " |
---|
| 178 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 179 | module list >> $outfile 2>&1 |
---|
| 180 | |
---|
| 181 | # Make a link to this file, to be used also in config.card |
---|
[4625] | 182 | rm -f ARCH/arch.env |
---|
| 183 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
[6307] | 184 | |
---|
| 185 | # Source the file |
---|
| 186 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 187 | |
---|
| 188 | echo >> $outfile |
---|
| 189 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 190 | module list >> $outfile 2>&1 |
---|
[4625] | 191 | fi |
---|
| 192 | |
---|
| 193 | #### 2 Do the compilation |
---|
| 194 | ## 2.1 Compile ioipsl |
---|
| 195 | cd $modipsl/modeles/IOIPSL |
---|
| 196 | echo; echo "NOW COMPILE IOIPSL" |
---|
| 197 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 198 | |
---|
| 199 | # Check if compilation with fcm is included in IOIPSL |
---|
| 200 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 201 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 202 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 203 | exit |
---|
| 204 | fi |
---|
| 205 | |
---|
| 206 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 207 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
| 208 | # Test if compiling succeded |
---|
| 209 | if [[ $? != 0 ]] ; then |
---|
| 210 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 211 | exit |
---|
| 212 | fi |
---|
| 213 | |
---|
| 214 | ## 2.2 Compile xios |
---|
| 215 | cd $modipsl/modeles/XIOS |
---|
| 216 | echo; echo "NOW COMPILE XIOS" |
---|
| 217 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
| 218 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
| 219 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
| 220 | # Test if compiling succeded |
---|
| 221 | if [[ $? != 0 ]] ; then |
---|
| 222 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 223 | exit |
---|
| 224 | fi |
---|
| 225 | # Move executables to modipsl/bin |
---|
| 226 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 227 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
| 228 | else |
---|
| 229 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 230 | exit |
---|
| 231 | fi |
---|
| 232 | |
---|
| 233 | |
---|
| 234 | ## 2.3 Compile orchidee |
---|
| 235 | cd $modipsl/modeles/ORCHIDEE |
---|
| 236 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
| 237 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 238 | |
---|
| 239 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
| 240 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
| 241 | # Test if compiling finished |
---|
| 242 | if [[ $? != 0 ]] ; then |
---|
| 243 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 244 | exit |
---|
| 245 | fi |
---|
| 246 | |
---|
| 247 | |
---|
[4697] | 248 | ## 2.4 Compile LMDZ and INCA for regular latlon configuration |
---|
[4625] | 249 | if [ $regular_latlon = yes ] ; then |
---|
| 250 | |
---|
| 251 | cd $modipsl/modeles/INCA |
---|
| 252 | #compile INCA regulat lat_lon chimie librairy |
---|
| 253 | echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}" |
---|
[6219] | 254 | echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile |
---|
| 255 | ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile 2>&1 |
---|
[4625] | 256 | |
---|
| 257 | # Test if compiling finished |
---|
| 258 | if [[ $? != 0 ]] ; then |
---|
| 259 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
| 260 | exit |
---|
| 261 | fi |
---|
| 262 | |
---|
| 263 | echo "Move inca.dat modipsl/bin" |
---|
| 264 | if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ; then |
---|
[6428] | 265 | mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${optchimie}.dat ; |
---|
[4625] | 266 | else |
---|
| 267 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
| 268 | exit |
---|
| 269 | fi |
---|
| 270 | |
---|
| 271 | |
---|
[6428] | 272 | echo "Move tracer.def to modipsl/bin" |
---|
| 273 | if [[ -f $modipsl/modeles/INCA/tracer.def ]] ; then |
---|
| 274 | mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ; |
---|
| 275 | fi |
---|
| 276 | |
---|
| 277 | |
---|
| 278 | |
---|
[4625] | 279 | cd $modipsl/modeles/LMDZ |
---|
| 280 | # Compile LMDZ regular lat-lon exectuable |
---|
| 281 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" |
---|
| 282 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 283 | |
---|
[5041] | 284 | |
---|
| 285 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
| 286 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
| 287 | # to ask question and wait for interactivly answer from the user. |
---|
| 288 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
| 289 | echo >> $outfile |
---|
| 290 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
| 291 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
| 292 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
| 293 | echo >> $outfile |
---|
| 294 | rm -f libf/grid/dimensions.h |
---|
| 295 | rm -f .lock |
---|
| 296 | fi |
---|
| 297 | |
---|
[6213] | 298 | # Need to define the proper option for radiative code compilation. By default, we use rrtm |
---|
| 299 | case $rad in |
---|
| 300 | oldrad) opt_rad="" ;; |
---|
[6427] | 301 | rrtm) opt_rad="-rad rrtm" ;; |
---|
[6213] | 302 | ecrad) opt_rad="-rad ecrad" ;; |
---|
| 303 | *) echo Only oldrad rrtm ecrad for rad option ; exit |
---|
| 304 | esac |
---|
[5041] | 305 | |
---|
| 306 | |
---|
[6213] | 307 | echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile |
---|
| 308 | ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile 2>&1 |
---|
[4625] | 309 | # Test if compiling finished |
---|
| 310 | if [[ $? != 0 ]] ; then |
---|
| 311 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 312 | exit |
---|
| 313 | fi |
---|
| 314 | |
---|
[6213] | 315 | |
---|
| 316 | suffix=_${resol_atm_3d}_phylmd |
---|
[6427] | 317 | suffix=${suffix}_${rad} |
---|
[6213] | 318 | |
---|
[4625] | 319 | # Find executable suffix |
---|
| 320 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
[6213] | 321 | suffix=${suffix}_seq_orch_inca |
---|
[4625] | 322 | else |
---|
[6213] | 323 | suffix=${suffix}_para_mem_orch_inca |
---|
[4625] | 324 | fi |
---|
| 325 | echo suffix = $suffix |
---|
| 326 | |
---|
| 327 | # Move executables to modipsl/bin folder |
---|
| 328 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
[5478] | 329 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then |
---|
| 330 | mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ; |
---|
| 331 | |
---|
| 332 | else |
---|
| 333 | echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP" |
---|
| 334 | exit |
---|
[4625] | 335 | |
---|
[5478] | 336 | fi |
---|
| 337 | |
---|
[6218] | 338 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 339 | if [ $ce0l == y ] ; then |
---|
| 340 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" |
---|
| 341 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" >> $outfile |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode -arch $fcm_arch -chimie INCA -arch_path $arch_path -j 8 $full_lmdz ce0l >> $outfile |
---|
| 345 | ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode -arch $fcm_arch -chimie INCA -arch_path $arch_path -j 8 $full_lmdz ce0l >> $outfile 2>&1 |
---|
| 346 | # Test if compiling finished |
---|
| 347 | if [[ $? != 0 ]] ; then |
---|
| 348 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 349 | exit |
---|
| 350 | fi |
---|
| 351 | |
---|
| 352 | |
---|
| 353 | # Move executables to modipsl/bin folder |
---|
| 354 | echo >> $outfile |
---|
| 355 | echo "Move ce0l.e executable to modipsl/bin" >> $outfile |
---|
| 356 | echo ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 357 | ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 358 | echo >> $outfile |
---|
| 359 | suffix=_${resol_atm_3d}_phylmd_seq.e |
---|
| 360 | echo ce0l suffix = $suffix |
---|
| 361 | |
---|
| 362 | if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ; then |
---|
| 363 | mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}_${optchimie}.e |
---|
| 364 | else |
---|
| 365 | echo "ERROR ce0l${suffix} executable does not exist." |
---|
| 366 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 367 | exit |
---|
| 368 | fi |
---|
[4625] | 369 | fi |
---|
| 370 | |
---|
| 371 | |
---|
[6218] | 372 | |
---|
| 373 | fi |
---|
| 374 | |
---|
| 375 | |
---|
[4625] | 376 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
| 377 | echo; echo "ALL COMPILING FINISHED" |
---|
| 378 | |
---|
[5110] | 379 | if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then |
---|
| 380 | echo; echo "====================================================" |
---|
| 381 | echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" |
---|
| 382 | echo; echo "Optmode="$optmode |
---|
| 383 | echo; echo "====================================================" |
---|
| 384 | fi |
---|
| 385 | |
---|
[4625] | 386 | date |
---|
| 387 | exit |
---|
| 388 | |
---|
| 389 | |
---|