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