[4268] | 1 | #!/bin/bash |
---|
| 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 |
---|
[4268] | 27 | export fcm_arch parallel xios |
---|
| 28 | full_flag="" |
---|
[4643] | 29 | full_xios="" |
---|
| 30 | full_lmdz="" |
---|
| 31 | full_orch="" |
---|
| 32 | |
---|
[4391] | 33 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
| 34 | netcdf_lib="" |
---|
[4268] | 35 | |
---|
[4408] | 36 | # Output text file for compilation of each component |
---|
[4622] | 37 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
| 38 | outfile=$submitdir/out_compile_lmdzor.$datestr |
---|
| 39 | echo > $outfile |
---|
[4643] | 40 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo |
---|
[4408] | 41 | |
---|
[4278] | 42 | #### Read arguments |
---|
[4268] | 43 | # Loop over all arguments to modify default set up |
---|
| 44 | while (($# > 0)) ; do |
---|
[4278] | 45 | case $1 in |
---|
[4643] | 46 | "-h") cat <<end_help |
---|
[4268] | 47 | ######################################################################## |
---|
[4411] | 48 | # Usage of the script compile_lmdzor.sh |
---|
[4268] | 49 | # |
---|
| 50 | ######################################################################## |
---|
| 51 | |
---|
| 52 | ./compile_config [Options] |
---|
| 53 | |
---|
[4469] | 54 | Options: -full, -resol_atm, -debug, -dev, -prod(default) |
---|
[4268] | 55 | |
---|
[4411] | 56 | Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL |
---|
| 57 | ./compile_lmdzor.sh |
---|
[4268] | 58 | |
---|
[4407] | 59 | Example 2: Compile in debug mode |
---|
[4411] | 60 | ./compile_lmdzor.sh -debug |
---|
[4407] | 61 | |
---|
| 62 | Example 3: Default compilation with full recompilation of all components |
---|
[4411] | 63 | ./compile_lmdzor.sh -full |
---|
[4268] | 64 | |
---|
[4411] | 65 | Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79) |
---|
| 66 | The dimension can be changed to any other 3d dimension. |
---|
[4469] | 67 | ./compile_lmdzor.sh -resol_atm 96x95x79 |
---|
[4268] | 68 | |
---|
[4643] | 69 | end_help |
---|
| 70 | exit;; |
---|
| 71 | "-parallel") parallel=$2 ; shift ; shift ;; |
---|
| 72 | "-arch") fcm_arch="$2" ; shift ; shift ;; |
---|
| 73 | "-xios") xios="$2" ; shift ; shift ;; |
---|
| 74 | "-debug") optmode=debug ; shift ;; |
---|
| 75 | "-dev") optmode=dev ; shift ;; |
---|
| 76 | "-prod") optmode=prod ; shift ;; |
---|
| 77 | "-resol_atm") resol_atm=$2 ; shift ; shift ;; |
---|
| 78 | "CE0L") ce0l=y ; shift ;; |
---|
| 79 | "-full") full_flag="-full"; shift ;; |
---|
| 80 | "-full") full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;; |
---|
| 81 | "-full_xios") full_xios="--full" ; shift ;; # Note only full_xios is using double dash: --full |
---|
| 82 | "-full_lmdz") full_lmdz="-full" ; shift ;; |
---|
| 83 | "-full_orch") full_orch="-full" ; shift ;; |
---|
| 84 | "-netcdf_lib_seq") netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
[4644] | 85 | *) echo "unknown option "$1" , exiting..." ; exit |
---|
[4278] | 86 | esac |
---|
| 87 | done |
---|
[4268] | 88 | |
---|
[4643] | 89 | echo "Following options are set in current compiling:" >> $outfile |
---|
| 90 | echo " resol_atm=${resol_atm}" >> $outfile |
---|
| 91 | echo " ce0l=${ce0l}" >> $outfile |
---|
| 92 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile |
---|
| 93 | echo " full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch" >> $outfile |
---|
| 94 | echo " parallel = $parallel, fcm_arch = $fcm_arch" >> $outfile |
---|
[4408] | 95 | echo >> $outfile |
---|
[4268] | 96 | |
---|
[4278] | 97 | ### Read host dependent default values |
---|
| 98 | ### These variables will not be changed if they were set as argument |
---|
[4268] | 99 | ###./host.sh $host |
---|
| 100 | # Later : Following lines should be set in host.sh file |
---|
| 101 | # begin host.sh |
---|
| 102 | if [ $fcm_arch == default ] ; then |
---|
[4278] | 103 | # Find out current host and source specific paths and commands for the host |
---|
| 104 | case $( hostname -s ) in |
---|
[4744] | 105 | jean-zay*) |
---|
| 106 | fcm_arch=X64_JEANZAY;; |
---|
[4278] | 107 | irene*) |
---|
[4391] | 108 | fcm_arch=X64_IRENE;; |
---|
[4278] | 109 | asterix*|obelix*) |
---|
| 110 | fcm_arch=ifort_LSCE;; |
---|
[4391] | 111 | ciclad*|climserv*) |
---|
| 112 | fcm_arch=ifort_CICLAD;; |
---|
[4278] | 113 | *) |
---|
[4391] | 114 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
[4278] | 115 | echo Exit now. |
---|
| 116 | exit |
---|
| 117 | esac |
---|
[4268] | 118 | fi |
---|
| 119 | |
---|
[4452] | 120 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
[4391] | 121 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 122 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
[4408] | 123 | echo >> $outfile |
---|
[4470] | 124 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components" |
---|
| 125 | echo "Note that this new environement might be kept after compilation." |
---|
| 126 | echo "If this is the case, source again your personal environment after compilation. " |
---|
| 127 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 128 | module list >> $outfile 2>&1 |
---|
| 129 | |
---|
| 130 | # Make a link to this file, to be used also in config.card |
---|
[4391] | 131 | rm -f ARCH/arch.env |
---|
| 132 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
[4470] | 133 | |
---|
| 134 | # Source the file |
---|
| 135 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 136 | echo >> $outfile |
---|
| 137 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 138 | module list >> $outfile 2>&1 |
---|
[4391] | 139 | fi |
---|
| 140 | |
---|
[4268] | 141 | #### 2 Do the compilation |
---|
| 142 | ## 2.1 Compile ioipsl |
---|
| 143 | cd $modipsl/modeles/IOIPSL |
---|
[4278] | 144 | echo; echo "NOW COMPILE IOIPSL" |
---|
[4408] | 145 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 146 | |
---|
[4411] | 147 | # Check if compilation with fcm is included in IOIPSL |
---|
| 148 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 149 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 150 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 151 | exit |
---|
| 152 | fi |
---|
| 153 | |
---|
[4408] | 154 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 155 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
[4268] | 156 | # Test if compiling succeded |
---|
| 157 | if [[ $? != 0 ]] ; then |
---|
[4278] | 158 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 159 | exit |
---|
[4268] | 160 | fi |
---|
| 161 | |
---|
| 162 | ## 2.2 Compile xios |
---|
| 163 | cd $modipsl/modeles/XIOS |
---|
[4278] | 164 | echo; echo "NOW COMPILE XIOS" |
---|
[4408] | 165 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
[4643] | 166 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios >> $outfile |
---|
| 167 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios >> $outfile 2>&1 |
---|
[4268] | 168 | # Test if compiling succeded |
---|
| 169 | if [[ $? != 0 ]] ; then |
---|
[4278] | 170 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 171 | exit |
---|
[4268] | 172 | fi |
---|
[4391] | 173 | # Move executables to modipsl/bin |
---|
[4457] | 174 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 175 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
[4391] | 176 | else |
---|
| 177 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 178 | exit |
---|
| 179 | fi |
---|
[4268] | 180 | |
---|
[4391] | 181 | |
---|
[4268] | 182 | ## 2.3 Compile orchidee |
---|
| 183 | cd $modipsl/modeles/ORCHIDEE |
---|
[4278] | 184 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
[4408] | 185 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 186 | |
---|
[4643] | 187 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver >> $outfile |
---|
| 188 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver >> $outfile 2>&1 |
---|
[4268] | 189 | # Test if compiling finished |
---|
| 190 | if [[ $? != 0 ]] ; then |
---|
| 191 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 192 | exit |
---|
| 193 | fi |
---|
| 194 | |
---|
[4643] | 195 | # Rename executables to contain $optmode |
---|
| 196 | if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol $modipsl/bin/orchidee_ol_${optmode} ; fi |
---|
| 197 | if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver $modipsl/bin/orchideedriver_${optmode} ; fi |
---|
[4408] | 198 | |
---|
[4643] | 199 | |
---|
[4411] | 200 | ## 2.4 Compile LMDZ for regular latlon configuration |
---|
[4469] | 201 | cd $modipsl/modeles/LMDZ |
---|
| 202 | # Compile LMDZ regular lat-lon exectuable |
---|
| 203 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" |
---|
| 204 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" >> $outfile |
---|
[4268] | 205 | |
---|
[4622] | 206 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
| 207 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
| 208 | # to ask question and wait for interactivly answer from the user. |
---|
| 209 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
| 210 | echo >> $outfile |
---|
| 211 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
| 212 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
| 213 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
| 214 | echo >> $outfile |
---|
| 215 | rm -f libf/grid/dimensions.h |
---|
| 216 | rm -f .lock |
---|
| 217 | fi |
---|
| 218 | |
---|
[4643] | 219 | echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm >> $outfile |
---|
| 220 | ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm >> $outfile 2>&1 |
---|
[4469] | 221 | # Test if compiling finished |
---|
| 222 | if [[ $? != 0 ]] ; then |
---|
| 223 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 224 | exit |
---|
| 225 | fi |
---|
[4408] | 226 | |
---|
[4643] | 227 | # Move executables to modipsl/bin folder |
---|
| 228 | echo >> $outfile |
---|
| 229 | echo "Move gcm.e executable to modipsl/bin" >> $outfile |
---|
| 230 | echo ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 231 | ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 232 | echo >> $outfile |
---|
[4278] | 233 | |
---|
[4469] | 234 | # Find executable suffix |
---|
| 235 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
[4643] | 236 | suffix=_${resol_atm}_phylmd_seq_orch.e |
---|
[4469] | 237 | else |
---|
[4643] | 238 | suffix=_${resol_atm}_phylmd_para_mem_orch.e |
---|
[4469] | 239 | fi |
---|
[4643] | 240 | echo gcm suffix = $suffix |
---|
[4408] | 241 | |
---|
[4643] | 242 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ; then |
---|
| 243 | mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e |
---|
| 244 | else |
---|
| 245 | echo "ERROR gcm${suffix} executable does not exist." |
---|
| 246 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 247 | exit |
---|
| 248 | fi |
---|
[4278] | 249 | |
---|
[4268] | 250 | |
---|
[4643] | 251 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 252 | if [ $ce0l == y ] ; then |
---|
| 253 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" |
---|
| 254 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" >> $outfile |
---|
| 255 | |
---|
| 256 | echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l >> $outfile |
---|
| 257 | ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l >> $outfile 2>&1 |
---|
| 258 | # Test if compiling finished |
---|
| 259 | if [[ $? != 0 ]] ; then |
---|
| 260 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 261 | exit |
---|
| 262 | fi |
---|
| 263 | |
---|
| 264 | |
---|
| 265 | # Move executables to modipsl/bin folder |
---|
| 266 | echo >> $outfile |
---|
| 267 | echo "Move ce0l.e executable to modipsl/bin" >> $outfile |
---|
| 268 | echo ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 269 | ls -lrt $modipsl/modeles/LMDZ/bin >> $outfile |
---|
| 270 | echo >> $outfile |
---|
| 271 | echo ce0l suffix = $suffix |
---|
| 272 | |
---|
| 273 | if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ; then |
---|
| 274 | mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e |
---|
| 275 | else |
---|
| 276 | echo "ERROR ce0l${suffix} executable does not exist." |
---|
| 277 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 278 | exit |
---|
| 279 | fi |
---|
| 280 | fi |
---|
| 281 | |
---|
| 282 | |
---|
[4408] | 283 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
[4643] | 284 | echo ls -lrt modipsl/bin >> $outfile |
---|
| 285 | ls -lrt $modipsl/bin >> $outfile |
---|
[4278] | 286 | |
---|
[4643] | 287 | echo; echo "ALL COMPILING FINISHED" ; echo |
---|
| 288 | echo "Executables are found in modipsl/bin" |
---|
| 289 | echo "Check that executable names correspond with the name set in config.card before launching the job" |
---|
| 290 | echo ls -lrt modipsl/bin |
---|
| 291 | ls -lrt $modipsl/bin |
---|
| 292 | |
---|
[4409] | 293 | date |
---|
[4643] | 294 | |
---|
[4268] | 295 | exit |
---|