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