[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 |
---|
[4471] | 15 | # Atmospheric resolution, for LMDZ/ORCHIDEE in regular mode |
---|
| 16 | resol_atm=144x142x79 |
---|
| 17 | # Oceanic resolution, for NEMO (ORCA2/ORCA1/ORCA025) |
---|
| 18 | resol_oce=ORCA1 |
---|
| 19 | # Version of ice model lim2/lim3 |
---|
| 20 | version_lim=lim3 |
---|
| 21 | # Version ESM CO2: CO2 interactif ocean/atmosphere (y/n) |
---|
| 22 | esmco2=n |
---|
| 23 | |
---|
[4268] | 24 | # Optimization mode |
---|
| 25 | # optmode=prod/dev/debug |
---|
| 26 | optmode=prod |
---|
| 27 | # fcm_arch |
---|
| 28 | fcm_arch=default |
---|
| 29 | # Default values to be overritten |
---|
[4339] | 30 | parallel=mpi_omp |
---|
[4268] | 31 | export fcm_arch parallel xios |
---|
| 32 | full_flag="" |
---|
[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 |
---|
[4471] | 37 | outfile=$submitdir/out_compile_ipslcm6 |
---|
[4408] | 38 | rm -f $outfile; echo > $outfile |
---|
[4471] | 39 | echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo |
---|
[4408] | 40 | |
---|
[4278] | 41 | #### Read arguments |
---|
[4268] | 42 | # Loop over all arguments to modify default set up |
---|
| 43 | while (($# > 0)) ; do |
---|
[4278] | 44 | case $1 in |
---|
| 45 | "-h") cat <<fin |
---|
[4268] | 46 | |
---|
| 47 | ######################################################################## |
---|
[4471] | 48 | # Usage of the script compile_ipslcm6.sh |
---|
[4268] | 49 | # |
---|
| 50 | ######################################################################## |
---|
| 51 | |
---|
[4471] | 52 | ./compile_ipslcm6.sh [Options] |
---|
[4268] | 53 | |
---|
| 54 | |
---|
[4471] | 55 | Options: [LR / VLR / MR025] Model resolution, choose only one. Default: LR. |
---|
| 56 | [ESMCO2] Compile IPSLCM6 for CO2 interactif ocean/atmosphere. |
---|
| 57 | [-full] Full recompilation of all components. This option can be added to all other options. |
---|
| 58 | [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod. |
---|
[4268] | 59 | |
---|
[4407] | 60 | |
---|
[4471] | 61 | Example 1: Default compilation of IPSLCM6 for resoltion LR |
---|
| 62 | (Resolution atmos: 144x142x79, ocean: ORCA1) |
---|
| 63 | ./compile_ipslcm6.sh |
---|
[4268] | 64 | |
---|
[4471] | 65 | Example 2: Compilation of IPSLCM6 for resolution MR025 |
---|
| 66 | (atmos: 256x256x79, ocean: ORCA025, NOPISCES) |
---|
| 67 | ./compile_ipslcm6.sh MR025 |
---|
[4268] | 68 | |
---|
[4471] | 69 | Example 3: Compilation of IPSLCM6 for ESM CO2 |
---|
| 70 | ./compile_ipslcm6.sh ESMCO2 |
---|
| 71 | |
---|
| 72 | Example 4: Default resoltuion (LR) compiled in debug mode |
---|
| 73 | ./compile_ipslcm6.sh -debug |
---|
| 74 | |
---|
| 75 | Example 5: Default compilation with full recompilation of all components. No clean is needed. |
---|
| 76 | ./compile_ipslcm6.sh -full |
---|
| 77 | |
---|
| 78 | Example 6: Full recompilation of resolution MR05 in debug mode |
---|
| 79 | ./compile_ipslcm6.sh MR025 -debug -full |
---|
| 80 | |
---|
[4278] | 81 | fin |
---|
| 82 | exit;; |
---|
[4268] | 83 | |
---|
[4471] | 84 | "VLR") |
---|
| 85 | resol_atm=96x95x39; resol_oce=ORCA1 ; version_lim=lim2; shift ;; |
---|
| 86 | |
---|
| 87 | "LR") |
---|
| 88 | resol_atm=144x142x79; resol_oce=ORCA1 ; version_lim=lim3; shift ;; |
---|
| 89 | |
---|
| 90 | "MR025") |
---|
| 91 | resol_atm=256x256x79; resol_oce=ORCA025 ; version_lim=lim3; shift ;; |
---|
| 92 | |
---|
| 93 | "ESMCO2") |
---|
| 94 | esmco2=y; shift ;; |
---|
| 95 | |
---|
[4278] | 96 | "-parallel") |
---|
| 97 | parallel=$2 ; shift ; shift ;; |
---|
| 98 | |
---|
| 99 | "-arch") |
---|
| 100 | fcm_arch="$2" ; shift ; shift ;; |
---|
| 101 | |
---|
[4407] | 102 | "-debug") |
---|
| 103 | optmode=debug ; shift ;; |
---|
| 104 | |
---|
| 105 | "-dev") |
---|
| 106 | optmode=dev ; shift ;; |
---|
| 107 | |
---|
| 108 | "-prod") |
---|
| 109 | optmode=prod ; shift ;; |
---|
| 110 | |
---|
[4278] | 111 | "-full") |
---|
| 112 | full_flag="-full"; shift ;; |
---|
| 113 | |
---|
[4391] | 114 | "-netcdf_lib_seq") |
---|
| 115 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
| 116 | |
---|
[4278] | 117 | *) |
---|
| 118 | echo "unknown option "$2" , exiting..." |
---|
| 119 | exit |
---|
| 120 | esac |
---|
| 121 | done |
---|
[4268] | 122 | |
---|
[4471] | 123 | echo "Following options are set in current compiling:" >> $outfile |
---|
| 124 | echo " resol_atm=${resol_atm}, resol_oce=${resol_oce}, $version_lim=${version_lim}" >> $outfile |
---|
| 125 | echo " esmco2=${esmco2}" >> $outfile |
---|
| 126 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag" >> $outfile |
---|
[4408] | 127 | echo >> $outfile |
---|
[4268] | 128 | |
---|
[4278] | 129 | ### Read host dependent default values |
---|
| 130 | ### These variables will not be changed if they were set as argument |
---|
[4268] | 131 | ###./host.sh $host |
---|
| 132 | # Later : Following lines should be set in host.sh file |
---|
| 133 | # begin host.sh |
---|
| 134 | if [ $fcm_arch == default ] ; then |
---|
[4278] | 135 | # Find out current host and source specific paths and commands for the host |
---|
| 136 | case $( hostname -s ) in |
---|
| 137 | ada*) |
---|
| 138 | fcm_arch=X64_ADA;; |
---|
| 139 | irene*) |
---|
[4391] | 140 | fcm_arch=X64_IRENE;; |
---|
[4278] | 141 | asterix*|obelix*) |
---|
| 142 | fcm_arch=ifort_LSCE;; |
---|
[4391] | 143 | ciclad*|climserv*) |
---|
| 144 | fcm_arch=ifort_CICLAD;; |
---|
[4278] | 145 | *) |
---|
[4391] | 146 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
[4278] | 147 | echo Exit now. |
---|
| 148 | exit |
---|
| 149 | esac |
---|
[4268] | 150 | fi |
---|
| 151 | |
---|
[4452] | 152 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
[4391] | 153 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 154 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
[4408] | 155 | echo >> $outfile |
---|
[4470] | 156 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components" |
---|
| 157 | echo "Note that this new environement might be kept after compilation." |
---|
| 158 | echo "If this is the case, source again your personal environment after compilation. " |
---|
| 159 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 160 | module list >> $outfile 2>&1 |
---|
| 161 | |
---|
| 162 | # Make a link to this file, to be used also in config.card |
---|
[4391] | 163 | rm -f ARCH/arch.env |
---|
| 164 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
[4470] | 165 | |
---|
| 166 | # Source the file |
---|
| 167 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 168 | echo >> $outfile |
---|
| 169 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 170 | module list >> $outfile 2>&1 |
---|
[4391] | 171 | fi |
---|
| 172 | |
---|
[4268] | 173 | #### 2 Do the compilation |
---|
| 174 | ## 2.1 Compile ioipsl |
---|
| 175 | cd $modipsl/modeles/IOIPSL |
---|
[4278] | 176 | echo; echo "NOW COMPILE IOIPSL" |
---|
[4408] | 177 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 178 | |
---|
[4411] | 179 | # Check if compilation with fcm is included in IOIPSL |
---|
| 180 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 181 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 182 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 183 | exit |
---|
| 184 | fi |
---|
| 185 | |
---|
[4408] | 186 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 187 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
[4268] | 188 | # Test if compiling succeded |
---|
| 189 | if [[ $? != 0 ]] ; then |
---|
[4278] | 190 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 191 | exit |
---|
[4268] | 192 | fi |
---|
| 193 | |
---|
| 194 | ## 2.2 Compile xios |
---|
| 195 | cd $modipsl/modeles/XIOS |
---|
[4278] | 196 | echo; echo "NOW COMPILE XIOS" |
---|
[4408] | 197 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
| 198 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
| 199 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
[4268] | 200 | # Test if compiling succeded |
---|
| 201 | if [[ $? != 0 ]] ; then |
---|
[4278] | 202 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 203 | exit |
---|
[4268] | 204 | fi |
---|
[4391] | 205 | # Move executables to modipsl/bin |
---|
[4457] | 206 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 207 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
[4391] | 208 | else |
---|
| 209 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 210 | exit |
---|
| 211 | fi |
---|
[4268] | 212 | |
---|
[4391] | 213 | |
---|
[4268] | 214 | ## 2.3 Compile orchidee |
---|
| 215 | cd $modipsl/modeles/ORCHIDEE |
---|
[4278] | 216 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
[4408] | 217 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 218 | |
---|
[4452] | 219 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
| 220 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
[4268] | 221 | # Test if compiling finished |
---|
| 222 | if [[ $? != 0 ]] ; then |
---|
| 223 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 224 | exit |
---|
| 225 | fi |
---|
| 226 | |
---|
[4408] | 227 | |
---|
[4411] | 228 | ## 2.4 Compile LMDZ for regular latlon configuration |
---|
[4469] | 229 | cd $modipsl/modeles/LMDZ |
---|
| 230 | # Compile LMDZ regular lat-lon exectuable |
---|
| 231 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" |
---|
| 232 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" >> $outfile |
---|
[4268] | 233 | |
---|
[4469] | 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 gcm >> $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 gcm >> $outfile 2>&1 |
---|
| 236 | # Test if compiling finished |
---|
| 237 | if [[ $? != 0 ]] ; then |
---|
| 238 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 239 | exit |
---|
| 240 | fi |
---|
[4408] | 241 | |
---|
[4469] | 242 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 243 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" |
---|
| 244 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" >> $outfile |
---|
| 245 | |
---|
| 246 | 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 |
---|
| 247 | ./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 |
---|
| 248 | # Test if compiling finished |
---|
| 249 | if [[ $? != 0 ]] ; then |
---|
| 250 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 251 | exit |
---|
| 252 | fi |
---|
[4278] | 253 | |
---|
[4469] | 254 | # Find executable suffix |
---|
| 255 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
| 256 | suffix=_${resol_atm}_phylmd_seq_orch |
---|
| 257 | else |
---|
| 258 | suffix=_${resol_atm}_phylmd_para_mem_orch |
---|
| 259 | fi |
---|
| 260 | echo suffix = $suffix |
---|
[4408] | 261 | |
---|
[4469] | 262 | # Move executables to modipsl/bin folder |
---|
| 263 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
| 264 | 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 |
---|
| 265 | 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] | 266 | |
---|
[4268] | 267 | fi |
---|
| 268 | |
---|
[4278] | 269 | |
---|
[4408] | 270 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
| 271 | echo; echo "ALL COMPILING FINISHED" |
---|
[4278] | 272 | |
---|
[4409] | 273 | date |
---|
[4268] | 274 | exit |
---|
| 275 | |
---|
| 276 | |
---|