[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 |
---|
| 20 | resol_atm_3d=96x95x39 |
---|
| 21 | optchimie=NMHC_AER_S |
---|
[4697] | 22 | #recompilation de inca seul ou de tous les modeles |
---|
| 23 | clean_inca="" |
---|
| 24 | full_flag="" |
---|
[4625] | 25 | |
---|
[6213] | 26 | # choose radiative code compilation option |
---|
| 27 | rad=rrtm |
---|
| 28 | opt_rad="" |
---|
| 29 | |
---|
| 30 | |
---|
[4625] | 31 | # fcm_arch |
---|
| 32 | fcm_arch=default |
---|
| 33 | # Default values to be overritten |
---|
| 34 | parallel=mpi_omp |
---|
| 35 | export fcm_arch parallel xios |
---|
[4697] | 36 | |
---|
[4625] | 37 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
| 38 | netcdf_lib="" |
---|
| 39 | |
---|
| 40 | # Output text file for compilation of each component |
---|
[5698] | 41 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
| 42 | outfile=$submitdir/out_compile_lmdzorinca.$datestr |
---|
| 43 | echo > $outfile |
---|
| 44 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo |
---|
[4625] | 45 | |
---|
| 46 | #### Read arguments |
---|
| 47 | # Loop over all arguments to modify default set up |
---|
| 48 | while (($# > 0)) ; do |
---|
| 49 | case $1 in |
---|
| 50 | "-h") cat <<fin |
---|
| 51 | |
---|
| 52 | ######################################################################## |
---|
[4706] | 53 | # Usage of the script compile_lmdzorinca.sh |
---|
[4625] | 54 | # |
---|
| 55 | ######################################################################## |
---|
| 56 | |
---|
| 57 | ./compile_config [Options] |
---|
| 58 | |
---|
[4706] | 59 | Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default) |
---|
[4625] | 60 | |
---|
[4706] | 61 | Example 1: Default compilation of LMDZ-ORCHIDEE-INCA with XIOS and IOIPSL - NMHC_AER_S / 96x95x39 |
---|
[4697] | 62 | ./compile_lmdzorinca.sh |
---|
[4625] | 63 | |
---|
[4706] | 64 | Example 2: Compilation with a chosen chemistry, for example DUSS (default: NMHC_AER_S) |
---|
| 65 | ./compile_lmdzorinca.sh -chimie DUSS |
---|
| 66 | |
---|
| 67 | Example 3: Compile in debug mode - in this case you need to modify Optmode in config.card |
---|
[4697] | 68 | ./compile_lmdzorinca.sh -debug |
---|
[4625] | 69 | |
---|
[4706] | 70 | Example 4: Default compilation with full recompilation of all components |
---|
[4697] | 71 | ./compile_lmdzorinca.sh -full |
---|
[4625] | 72 | |
---|
[4706] | 73 | Example 5: Default compilation with recompilation of inca model only |
---|
| 74 | ./compile_lmdzorinca.sh -clean_inca |
---|
| 75 | |
---|
| 76 | Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39) |
---|
[4625] | 77 | The dimension can be changed to any other 3d dimension. |
---|
[4706] | 78 | ./compile_lmdzorinca.sh -regular_latlon 144x142x79 |
---|
[4625] | 79 | |
---|
[6213] | 80 | Example 7: choose radiative schema for LMDZ (oldrad/rrtm/ecrad). Default is rrtm |
---|
| 81 | ./compile_lmdzorinca.sh -rad ecrad |
---|
| 82 | |
---|
| 83 | |
---|
[4625] | 84 | fin |
---|
| 85 | exit;; |
---|
| 86 | |
---|
| 87 | "-parallel") |
---|
| 88 | parallel=$2 ; shift ; shift ;; |
---|
| 89 | |
---|
| 90 | "-arch") |
---|
| 91 | fcm_arch="$2" ; shift ; shift ;; |
---|
| 92 | |
---|
| 93 | "-xios") |
---|
| 94 | xios="$2" ; shift ; shift ;; |
---|
| 95 | |
---|
| 96 | "-optmode") |
---|
| 97 | optmode=$2 ; shift ; shift ;; |
---|
| 98 | |
---|
| 99 | "-debug") |
---|
| 100 | optmode=debug ; shift ;; |
---|
| 101 | |
---|
| 102 | "-dev") |
---|
| 103 | optmode=dev ; shift ;; |
---|
| 104 | |
---|
| 105 | "-prod") |
---|
| 106 | optmode=prod ; shift ;; |
---|
| 107 | |
---|
[6213] | 108 | "-rad") |
---|
| 109 | rad=$2; shift ; shift;; |
---|
| 110 | |
---|
[4625] | 111 | "-regular_latlon") |
---|
| 112 | regular_latlon=yes ; |
---|
| 113 | resol_atm_3d=$2 ; shift ; shift ;; |
---|
| 114 | |
---|
| 115 | "-full") |
---|
| 116 | full_flag="-full"; shift ;; |
---|
[4697] | 117 | |
---|
| 118 | "-clean_inca") |
---|
| 119 | clean_inca="-clean"; shift ;; |
---|
[4625] | 120 | |
---|
| 121 | "-netcdf_lib_seq") |
---|
| 122 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
| 123 | |
---|
| 124 | "-chimie") |
---|
| 125 | echo $2; |
---|
| 126 | optchimie=$2; shift ; shift;; |
---|
| 127 | |
---|
| 128 | *) |
---|
| 129 | echo "unknown option "$2" , exiting..." |
---|
| 130 | exit |
---|
| 131 | esac |
---|
| 132 | done |
---|
[4698] | 133 | echo; echo "********************* WARNING **********************" |
---|
| 134 | echo; echo "********************* WARNING **********************" |
---|
| 135 | echo; echo " if you are working with an lmdz version before rev 3563 (check it with command svn info) " |
---|
| 136 | echo "you need to modify phylmd/physiq_mod.F90 file " |
---|
| 137 | echo "add ! to comment lines if/endif before and after the call to AEROSOL_METEO_CALC" |
---|
| 138 | echo; echo "********************* WARNING **********************" |
---|
| 139 | echo; echo "********************* WARNING **********************" |
---|
[4625] | 140 | |
---|
| 141 | echo "Following arguments are set in current compiling:" >> $outfile |
---|
| 142 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $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 |
---|
| 175 | echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component" |
---|
| 176 | rm -f ARCH/arch.env |
---|
| 177 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
| 178 | fi |
---|
| 179 | |
---|
| 180 | #### 2 Do the compilation |
---|
| 181 | ## 2.1 Compile ioipsl |
---|
| 182 | cd $modipsl/modeles/IOIPSL |
---|
| 183 | echo; echo "NOW COMPILE IOIPSL" |
---|
| 184 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 185 | |
---|
| 186 | # Check if compilation with fcm is included in IOIPSL |
---|
| 187 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 188 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 189 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 190 | exit |
---|
| 191 | fi |
---|
| 192 | |
---|
| 193 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 194 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
| 195 | # Test if compiling succeded |
---|
| 196 | if [[ $? != 0 ]] ; then |
---|
| 197 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 198 | exit |
---|
| 199 | fi |
---|
| 200 | |
---|
| 201 | ## 2.2 Compile xios |
---|
| 202 | cd $modipsl/modeles/XIOS |
---|
| 203 | echo; echo "NOW COMPILE XIOS" |
---|
| 204 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
| 205 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
| 206 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
| 207 | # Test if compiling succeded |
---|
| 208 | if [[ $? != 0 ]] ; then |
---|
| 209 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 210 | exit |
---|
| 211 | fi |
---|
| 212 | # Move executables to modipsl/bin |
---|
| 213 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 214 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
| 215 | else |
---|
| 216 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 217 | exit |
---|
| 218 | fi |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | ## 2.3 Compile orchidee |
---|
| 222 | cd $modipsl/modeles/ORCHIDEE |
---|
| 223 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
| 224 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 225 | |
---|
| 226 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
| 227 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
| 228 | # Test if compiling finished |
---|
| 229 | if [[ $? != 0 ]] ; then |
---|
| 230 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 231 | exit |
---|
| 232 | fi |
---|
| 233 | |
---|
| 234 | |
---|
[4697] | 235 | ## 2.4 Compile LMDZ and INCA for regular latlon configuration |
---|
[4625] | 236 | if [ $regular_latlon = yes ] ; then |
---|
| 237 | |
---|
| 238 | cd $modipsl/modeles/INCA |
---|
| 239 | #compile INCA regulat lat_lon chimie librairy |
---|
| 240 | echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}" |
---|
[4697] | 241 | echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile |
---|
| 242 | ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile 2>&1 |
---|
[4625] | 243 | |
---|
| 244 | # Test if compiling finished |
---|
| 245 | if [[ $? != 0 ]] ; then |
---|
| 246 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
| 247 | exit |
---|
| 248 | fi |
---|
| 249 | |
---|
| 250 | echo "Move inca.dat modipsl/bin" |
---|
| 251 | if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ; then |
---|
| 252 | mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ; |
---|
| 253 | # cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat; |
---|
| 254 | else |
---|
| 255 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
| 256 | exit |
---|
| 257 | fi |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | cd $modipsl/modeles/LMDZ |
---|
| 261 | # Compile LMDZ regular lat-lon exectuable |
---|
| 262 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" |
---|
| 263 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 264 | |
---|
[6213] | 265 | # Retrieve the final svn release number, needed for radiative code suffix of executable |
---|
| 266 | lmdzsvn=`svnversion . | egrep -o "[0-9]+" | awk 'NR==1'` |
---|
[5041] | 267 | |
---|
[6213] | 268 | |
---|
[5041] | 269 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
| 270 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
| 271 | # to ask question and wait for interactivly answer from the user. |
---|
| 272 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
| 273 | echo >> $outfile |
---|
| 274 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
| 275 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
| 276 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
| 277 | echo >> $outfile |
---|
| 278 | rm -f libf/grid/dimensions.h |
---|
| 279 | rm -f .lock |
---|
| 280 | fi |
---|
| 281 | |
---|
[6213] | 282 | # Need to define the proper option for radiative code compilation. By default, we use rrtm |
---|
| 283 | case $rad in |
---|
| 284 | oldrad) opt_rad="" ;; |
---|
| 285 | rrtm) if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;; |
---|
| 286 | ecrad) opt_rad="-rad ecrad" ;; |
---|
| 287 | *) echo Only oldrad rrtm ecrad for rad option ; exit |
---|
| 288 | esac |
---|
[5041] | 289 | |
---|
[6213] | 290 | if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi |
---|
[5041] | 291 | |
---|
| 292 | |
---|
| 293 | |
---|
[6213] | 294 | |
---|
| 295 | 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 |
---|
| 296 | ./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] | 297 | # Test if compiling finished |
---|
| 298 | if [[ $? != 0 ]] ; then |
---|
| 299 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 300 | exit |
---|
| 301 | fi |
---|
| 302 | |
---|
| 303 | # # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 304 | # echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" |
---|
| 305 | # echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 306 | # |
---|
| 307 | # echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l >> $outfile |
---|
| 308 | # ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l >> $outfile 2>&1 |
---|
| 309 | # # Test if compiling finished |
---|
| 310 | # if [[ $? != 0 ]] ; then |
---|
| 311 | # echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 312 | # exit |
---|
| 313 | # fi |
---|
| 314 | # |
---|
[6213] | 315 | |
---|
| 316 | |
---|
| 317 | |
---|
| 318 | |
---|
| 319 | suffix=_${resol_atm_3d}_phylmd |
---|
| 320 | if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi |
---|
| 321 | |
---|
[4625] | 322 | # Find executable suffix |
---|
| 323 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
[6213] | 324 | suffix=${suffix}_seq_orch_inca |
---|
[4625] | 325 | else |
---|
[6213] | 326 | suffix=${suffix}_para_mem_orch_inca |
---|
[4625] | 327 | fi |
---|
| 328 | echo suffix = $suffix |
---|
| 329 | |
---|
| 330 | # Move executables to modipsl/bin folder |
---|
| 331 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
[5478] | 332 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then |
---|
| 333 | mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ; |
---|
| 334 | |
---|
| 335 | else |
---|
| 336 | echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP" |
---|
| 337 | exit |
---|
[4625] | 338 | |
---|
[5478] | 339 | fi |
---|
| 340 | # if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm_3d}_${optmode}_${optchimie}.e ; fi |
---|
| 341 | |
---|
[4625] | 342 | fi |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
| 346 | echo; echo "ALL COMPILING FINISHED" |
---|
| 347 | |
---|
[5110] | 348 | if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then |
---|
| 349 | echo; echo "====================================================" |
---|
| 350 | echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" |
---|
| 351 | echo; echo "Optmode="$optmode |
---|
| 352 | echo; echo "====================================================" |
---|
| 353 | fi |
---|
| 354 | |
---|
[4625] | 355 | date |
---|
| 356 | exit |
---|
| 357 | |
---|
| 358 | |
---|