[5036] | 1 | #!/bin/bash |
---|
[4268] | 2 | #set -vx |
---|
| 3 | # Default options |
---|
| 4 | # |
---|
| 5 | # |
---|
| 6 | # |
---|
[4409] | 7 | date |
---|
[4268] | 8 | #### 1 Set up the compiling options |
---|
| 9 | #### Define some directories |
---|
| 10 | submitdir=$( pwd ) |
---|
| 11 | modipsl=$submitdir/../.. |
---|
[4275] | 12 | arch_path=$submitdir/ARCH |
---|
[4268] | 13 | |
---|
[4278] | 14 | #### Set default options |
---|
[4268] | 15 | # Optimization mode |
---|
| 16 | # optmode=prod/dev/debug |
---|
| 17 | optmode=prod |
---|
[4411] | 18 | # Resolution of LMDZ in regular mode |
---|
[4469] | 19 | resol_atm=144x142x79 |
---|
[4643] | 20 | # Also compile ce0l subprogram to LMDZ (y/n) |
---|
| 21 | ce0l=y |
---|
[4411] | 22 | |
---|
[4268] | 23 | # fcm_arch |
---|
| 24 | fcm_arch=default |
---|
| 25 | # Default values to be overritten |
---|
[4339] | 26 | parallel=mpi_omp |
---|
[6112] | 27 | # Compilation with rrtm or ecrad radiative code (default rad=rrtm) |
---|
| 28 | rad=rrtm |
---|
[6241] | 29 | opt_rad="" |
---|
[6112] | 30 | # Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE) |
---|
| 31 | cosp=NONE |
---|
| 32 | |
---|
[4268] | 33 | export fcm_arch parallel xios |
---|
| 34 | full_flag="" |
---|
[4643] | 35 | full_xios="" |
---|
| 36 | full_lmdz="" |
---|
| 37 | full_orch="" |
---|
| 38 | |
---|
[4391] | 39 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
| 40 | netcdf_lib="" |
---|
[4268] | 41 | |
---|
[4408] | 42 | # Output text file for compilation of each component |
---|
[4622] | 43 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
| 44 | outfile=$submitdir/out_compile_lmdzor.$datestr |
---|
| 45 | echo > $outfile |
---|
[4643] | 46 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo |
---|
[4408] | 47 | |
---|
[4278] | 48 | #### Read arguments |
---|
[4268] | 49 | # Loop over all arguments to modify default set up |
---|
| 50 | while (($# > 0)) ; do |
---|
[4278] | 51 | case $1 in |
---|
[4643] | 52 | "-h") cat <<end_help |
---|
[4268] | 53 | ######################################################################## |
---|
[4411] | 54 | # Usage of the script compile_lmdzor.sh |
---|
[4268] | 55 | # |
---|
| 56 | ######################################################################## |
---|
| 57 | |
---|
| 58 | ./compile_config [Options] |
---|
| 59 | |
---|
[4469] | 60 | Options: -full, -resol_atm, -debug, -dev, -prod(default) |
---|
[4268] | 61 | |
---|
[4411] | 62 | Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL |
---|
| 63 | ./compile_lmdzor.sh |
---|
[4268] | 64 | |
---|
[4407] | 65 | Example 2: Compile in debug mode |
---|
[4411] | 66 | ./compile_lmdzor.sh -debug |
---|
[4407] | 67 | |
---|
| 68 | Example 3: Default compilation with full recompilation of all components |
---|
[4411] | 69 | ./compile_lmdzor.sh -full |
---|
[4268] | 70 | |
---|
[4411] | 71 | Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79) |
---|
| 72 | The dimension can be changed to any other 3d dimension. |
---|
[4469] | 73 | ./compile_lmdzor.sh -resol_atm 96x95x79 |
---|
[4268] | 74 | |
---|
[4643] | 75 | end_help |
---|
| 76 | exit;; |
---|
| 77 | "-parallel") parallel=$2 ; shift ; shift ;; |
---|
[6112] | 78 | "-rad") rad=$2 ; shift ; shift ;; |
---|
| 79 | "-cosp") cosp=$2 ; shift ; shift ;; |
---|
[4643] | 80 | "-arch") fcm_arch="$2" ; shift ; shift ;; |
---|
| 81 | "-xios") xios="$2" ; shift ; shift ;; |
---|
| 82 | "-debug") optmode=debug ; shift ;; |
---|
| 83 | "-dev") optmode=dev ; shift ;; |
---|
| 84 | "-prod") optmode=prod ; shift ;; |
---|
| 85 | "-resol_atm") resol_atm=$2 ; shift ; shift ;; |
---|
| 86 | "CE0L") ce0l=y ; shift ;; |
---|
| 87 | "-full") full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;; |
---|
| 88 | "-full_xios") full_xios="--full" ; shift ;; # Note only full_xios is using double dash: --full |
---|
| 89 | "-full_lmdz") full_lmdz="-full" ; shift ;; |
---|
| 90 | "-full_orch") full_orch="-full" ; shift ;; |
---|
| 91 | "-netcdf_lib_seq") netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
[4644] | 92 | *) echo "unknown option "$1" , exiting..." ; exit |
---|
[4278] | 93 | esac |
---|
| 94 | done |
---|
[4268] | 95 | |
---|
[4643] | 96 | echo "Following options are set in current compiling:" >> $outfile |
---|
| 97 | echo " resol_atm=${resol_atm}" >> $outfile |
---|
| 98 | echo " ce0l=${ce0l}" >> $outfile |
---|
| 99 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile |
---|
| 100 | echo " full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch" >> $outfile |
---|
[4408] | 101 | echo >> $outfile |
---|
[4268] | 102 | |
---|
[6112] | 103 | if [ $cosp = v1 ] ; then |
---|
| 104 | opt_cosp="-cosp true" |
---|
| 105 | elif [ $cosp = v2 ] ; then |
---|
| 106 | opt_cosp="-cospv2 true" |
---|
| 107 | else |
---|
| 108 | opt_cosp="" |
---|
| 109 | fi |
---|
[4278] | 110 | ### Read host dependent default values |
---|
| 111 | ### These variables will not be changed if they were set as argument |
---|
[4268] | 112 | ###./host.sh $host |
---|
| 113 | # Later : Following lines should be set in host.sh file |
---|
| 114 | # begin host.sh |
---|
| 115 | if [ $fcm_arch == default ] ; then |
---|
[4278] | 116 | # Find out current host and source specific paths and commands for the host |
---|
| 117 | case $( hostname -s ) in |
---|
[4744] | 118 | jean-zay*) |
---|
| 119 | fcm_arch=X64_JEANZAY;; |
---|
[5030] | 120 | irene170|irene171|irene190|irene191|irene192|irene193) |
---|
| 121 | fcm_arch=X64_IRENE;; |
---|
| 122 | irene172|irene173|irene194|irene195) |
---|
| 123 | fcm_arch=X64_IRENE-AMD;; |
---|
[4278] | 124 | asterix*|obelix*) |
---|
[4975] | 125 | fcm_arch=ifort_LSCE |
---|
| 126 | if [ "${parallel}" == "mpi_omp" ] ; then |
---|
| 127 | echo "Warning!! Currently at Obelix hybrid mode is not possible." |
---|
| 128 | echo " Option -parallel mpi_omp is now changed to -parallel mpi" |
---|
| 129 | echo "" |
---|
| 130 | parallel=mpi |
---|
| 131 | else |
---|
| 132 | echo "You used -parallel" $parallel |
---|
| 133 | fi ;; |
---|
[6261] | 134 | spirit*) |
---|
| 135 | fcm_arch=ifort_MESOIPSL;; |
---|
[4975] | 136 | ciclad*|climserv*|loholt*|camelot*) |
---|
[4391] | 137 | fcm_arch=ifort_CICLAD;; |
---|
[4278] | 138 | *) |
---|
[4391] | 139 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
[4278] | 140 | echo Exit now. |
---|
| 141 | exit |
---|
| 142 | esac |
---|
[4268] | 143 | fi |
---|
| 144 | |
---|
[4452] | 145 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
[4391] | 146 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 147 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
[4408] | 148 | echo >> $outfile |
---|
[4932] | 149 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components." |
---|
[4470] | 150 | echo "Note that this new environement might be kept after compilation." |
---|
| 151 | echo "If this is the case, source again your personal environment after compilation. " |
---|
| 152 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 153 | module list >> $outfile 2>&1 |
---|
| 154 | |
---|
| 155 | # Make a link to this file, to be used also in config.card |
---|
[4391] | 156 | rm -f ARCH/arch.env |
---|
| 157 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
[4470] | 158 | |
---|
| 159 | # Source the file |
---|
| 160 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 161 | echo >> $outfile |
---|
| 162 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 163 | module list >> $outfile 2>&1 |
---|
[4391] | 164 | fi |
---|
| 165 | |
---|
[4268] | 166 | #### 2 Do the compilation |
---|
| 167 | ## 2.1 Compile ioipsl |
---|
| 168 | cd $modipsl/modeles/IOIPSL |
---|
[4278] | 169 | echo; echo "NOW COMPILE IOIPSL" |
---|
[4408] | 170 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 171 | |
---|
[4411] | 172 | # Check if compilation with fcm is included in IOIPSL |
---|
| 173 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 174 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 175 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 176 | exit |
---|
| 177 | fi |
---|
| 178 | |
---|
[4972] | 179 | echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 180 | ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
[4268] | 181 | # Test if compiling succeded |
---|
| 182 | if [[ $? != 0 ]] ; then |
---|
[4278] | 183 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 184 | exit |
---|
[4268] | 185 | fi |
---|
| 186 | |
---|
| 187 | ## 2.2 Compile xios |
---|
| 188 | cd $modipsl/modeles/XIOS |
---|
[4278] | 189 | echo; echo "NOW COMPILE XIOS" |
---|
[4408] | 190 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
[4643] | 191 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios >> $outfile |
---|
| 192 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios >> $outfile 2>&1 |
---|
[4268] | 193 | # Test if compiling succeded |
---|
| 194 | if [[ $? != 0 ]] ; then |
---|
[4278] | 195 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 196 | exit |
---|
[4268] | 197 | fi |
---|
[4391] | 198 | # Move executables to modipsl/bin |
---|
[4457] | 199 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 200 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
[4391] | 201 | else |
---|
| 202 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 203 | exit |
---|
| 204 | fi |
---|
[4268] | 205 | |
---|
[4391] | 206 | |
---|
[4268] | 207 | ## 2.3 Compile orchidee |
---|
| 208 | cd $modipsl/modeles/ORCHIDEE |
---|
[4278] | 209 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
[4408] | 210 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 211 | |
---|
[4975] | 212 | |
---|
| 213 | # Check if the compilation of ORCHIDEE was previsouly interupted prematured. |
---|
| 214 | # In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm |
---|
| 215 | # to ask question and wait for interactivly answer from the user. |
---|
| 216 | if [ -f build/fcm.bld.lock ] ; then |
---|
| 217 | echo >> $outfile |
---|
| 218 | echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. " >> $outfile |
---|
| 219 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
| 220 | echo " The file will now be removed. " >> $outfile |
---|
| 221 | echo >> $outfile |
---|
| 222 | rm -f build/fcm.bld.lock |
---|
| 223 | fi |
---|
| 224 | |
---|
[4643] | 225 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver >> $outfile |
---|
| 226 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver >> $outfile 2>&1 |
---|
[4268] | 227 | # Test if compiling finished |
---|
| 228 | if [[ $? != 0 ]] ; then |
---|
| 229 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 230 | exit |
---|
| 231 | fi |
---|
| 232 | |
---|
[4643] | 233 | # Rename executables to contain $optmode |
---|
| 234 | if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol $modipsl/bin/orchidee_ol_${optmode} ; fi |
---|
| 235 | if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver $modipsl/bin/orchideedriver_${optmode} ; fi |
---|
[4408] | 236 | |
---|
[4643] | 237 | |
---|
[4411] | 238 | ## 2.4 Compile LMDZ for regular latlon configuration |
---|
[4469] | 239 | cd $modipsl/modeles/LMDZ |
---|
[4932] | 240 | # Compile LMDZ regular lat-lon executable |
---|
[4469] | 241 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" |
---|
| 242 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" >> $outfile |
---|
[6241] | 243 | # Retrieve the final svn release number, needed for radiative code suffix of executable |
---|
| 244 | lmdzsvn=`svnversion . | egrep -o "[0-9]+" | awk 'NR==1'` |
---|
[4268] | 245 | |
---|
[4622] | 246 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
| 247 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
| 248 | # to ask question and wait for interactivly answer from the user. |
---|
| 249 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
| 250 | echo >> $outfile |
---|
| 251 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
| 252 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
| 253 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
| 254 | echo >> $outfile |
---|
| 255 | rm -f libf/grid/dimensions.h |
---|
| 256 | rm -f .lock |
---|
| 257 | fi |
---|
| 258 | |
---|
[6241] | 259 | # Need to define the proper option for radiative code compilation. By default, we use rrtm |
---|
| 260 | case $rad in |
---|
| 261 | oldrad) opt_rad="" ;; |
---|
| 262 | rrtm) if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;; |
---|
| 263 | ecrad) opt_rad="-rad ecrad" ;; |
---|
| 264 | *) echo Only oldrad rrtm ecrad for rad option ; exit |
---|
| 265 | esac |
---|
| 266 | |
---|
| 267 | if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | echo ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad $opt_cosp -$optmode -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm >> $outfile |
---|
| 271 | ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm >> $outfile 2>&1 |
---|
[4469] | 272 | # Test if compiling finished |
---|
| 273 | if [[ $? != 0 ]] ; then |
---|
| 274 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 275 | exit |
---|
| 276 | fi |
---|
[4408] | 277 | |
---|
[4643] | 278 | # Move executables to modipsl/bin folder |
---|
| 279 | echo >> $outfile |
---|
| 280 | echo "Move gcm.e executable to modipsl/bin" >> $outfile |
---|
| 281 | echo ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 282 | ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 283 | echo >> $outfile |
---|
[4278] | 284 | |
---|
[6241] | 285 | suffix=${resol_atm}_phylmd |
---|
| 286 | if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi |
---|
[4469] | 287 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
[6241] | 288 | suffix=_${suffix}_seq_orch.e |
---|
[4469] | 289 | else |
---|
[6241] | 290 | suffix=_${suffix}_para_mem_orch.e |
---|
[4469] | 291 | fi |
---|
[4643] | 292 | echo gcm suffix = $suffix |
---|
[4408] | 293 | |
---|
[4643] | 294 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ; then |
---|
| 295 | mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e |
---|
| 296 | else |
---|
| 297 | echo "ERROR gcm${suffix} executable does not exist." |
---|
| 298 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 299 | exit |
---|
| 300 | fi |
---|
[4278] | 301 | |
---|
[4268] | 302 | |
---|
[4643] | 303 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 304 | if [ $ce0l == y ] ; then |
---|
| 305 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" |
---|
| 306 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" >> $outfile |
---|
| 307 | |
---|
[6241] | 308 | echo ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l >> $outfile |
---|
| 309 | ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l >> $outfile 2>&1 |
---|
[4643] | 310 | # Test if compiling finished |
---|
| 311 | if [[ $? != 0 ]] ; then |
---|
| 312 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 313 | exit |
---|
| 314 | fi |
---|
| 315 | |
---|
| 316 | |
---|
| 317 | # Move executables to modipsl/bin folder |
---|
| 318 | echo >> $outfile |
---|
| 319 | echo "Move ce0l.e executable to modipsl/bin" >> $outfile |
---|
| 320 | echo ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 321 | ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 322 | echo >> $outfile |
---|
[5122] | 323 | suffix=_${resol_atm}_phylmd_seq.e |
---|
[6241] | 324 | if [ $lmdzsvn -ge 4186 ] ; then suffix=_${resol_atm}_phylmd_${rad}_seq.e ; fi |
---|
[4643] | 325 | echo ce0l suffix = $suffix |
---|
| 326 | |
---|
| 327 | if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ; then |
---|
| 328 | mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e |
---|
| 329 | else |
---|
| 330 | echo "ERROR ce0l${suffix} executable does not exist." |
---|
| 331 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 332 | exit |
---|
| 333 | fi |
---|
| 334 | fi |
---|
| 335 | |
---|
| 336 | |
---|
[4408] | 337 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
[4643] | 338 | echo ls -lrt modipsl/bin >> $outfile |
---|
| 339 | ls -lrt $modipsl/bin >> $outfile |
---|
[4278] | 340 | |
---|
[4643] | 341 | echo; echo "ALL COMPILING FINISHED" ; echo |
---|
| 342 | echo "Executables are found in modipsl/bin" |
---|
| 343 | echo "Check that executable names correspond with the name set in config.card before launching the job" |
---|
| 344 | echo ls -lrt modipsl/bin |
---|
| 345 | ls -lrt $modipsl/bin |
---|
| 346 | |
---|
[4409] | 347 | date |
---|
[4643] | 348 | |
---|
[4268] | 349 | exit |
---|