[5975] | 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 | |
---|
| 14 | #### Set default options |
---|
| 15 | # Optimization mode |
---|
| 16 | # optmode=prod/dev/debug |
---|
| 17 | optmode=prod |
---|
| 18 | # Resolution of LMDZ in regular mode |
---|
| 19 | regular_latlon=yes |
---|
| 20 | resol_atm_3d=144x142x79 |
---|
| 21 | optchimie=NMHC_AER_S |
---|
| 22 | #recompilation de inca seul ou de tous les modeles |
---|
| 23 | clean_inca="" |
---|
| 24 | full_flag="" |
---|
| 25 | |
---|
| 26 | # fcm_arch |
---|
| 27 | fcm_arch=default |
---|
| 28 | # Default values to be overritten |
---|
| 29 | parallel=mpi_omp |
---|
| 30 | export fcm_arch parallel xios |
---|
| 31 | |
---|
| 32 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
| 33 | netcdf_lib="" |
---|
| 34 | |
---|
| 35 | # Output text file for compilation of each component |
---|
| 36 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
| 37 | outfile=$submitdir/out_compile_lmdzorinca.$datestr |
---|
| 38 | echo > $outfile |
---|
| 39 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzorinca.$datestr"; echo |
---|
| 40 | |
---|
| 41 | #### Read arguments |
---|
| 42 | # Loop over all arguments to modify default set up |
---|
| 43 | while (($# > 0)) ; do |
---|
| 44 | case $1 in |
---|
| 45 | "-h") cat <<fin |
---|
| 46 | |
---|
| 47 | ######################################################################## |
---|
| 48 | # Usage of the script compile_lmdzorinca.sh |
---|
| 49 | # |
---|
| 50 | ######################################################################## |
---|
| 51 | |
---|
| 52 | ./compile_config [Options] |
---|
| 53 | |
---|
| 54 | Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default) |
---|
| 55 | |
---|
| 56 | Example 1: Default compilation of LMDZ-ORCHIDEE-INCA with XIOS and IOIPSL - NMHC_AER_S / 144x142x79 |
---|
| 57 | ./compile_lmdzorinca.sh |
---|
| 58 | |
---|
| 59 | Example 2: Compilation with a chosen chemistry, for example DUSS (default: NMHC_AER_S) |
---|
| 60 | ./compile_lmdzorinca.sh -chimie DUSS |
---|
| 61 | |
---|
| 62 | Example 3: Compile in debug mode - in this case you need to modify Optmode in config.card |
---|
| 63 | ./compile_lmdzorinca.sh -debug |
---|
| 64 | |
---|
| 65 | Example 4: Default compilation with full recompilation of all components |
---|
| 66 | ./compile_lmdzorinca.sh -full |
---|
| 67 | |
---|
| 68 | Example 5: Default compilation with recompilation of inca model only |
---|
| 69 | ./compile_lmdzorinca.sh -clean_inca |
---|
| 70 | |
---|
| 71 | Example 6: 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_lmdzorinca.sh -regular_latlon 96x95x39 |
---|
| 74 | |
---|
| 75 | fin |
---|
| 76 | exit;; |
---|
| 77 | |
---|
| 78 | "-parallel") |
---|
| 79 | parallel=$2 ; shift ; shift ;; |
---|
| 80 | |
---|
| 81 | "-arch") |
---|
| 82 | fcm_arch="$2" ; shift ; shift ;; |
---|
| 83 | |
---|
| 84 | "-xios") |
---|
| 85 | xios="$2" ; shift ; shift ;; |
---|
| 86 | |
---|
| 87 | "-optmode") |
---|
| 88 | optmode=$2 ; shift ; shift ;; |
---|
| 89 | |
---|
| 90 | "-debug") |
---|
| 91 | optmode=debug ; shift ;; |
---|
| 92 | |
---|
| 93 | "-dev") |
---|
| 94 | optmode=dev ; shift ;; |
---|
| 95 | |
---|
| 96 | "-prod") |
---|
| 97 | optmode=prod ; shift ;; |
---|
| 98 | |
---|
| 99 | "-regular_latlon") |
---|
| 100 | regular_latlon=yes ; |
---|
| 101 | resol_atm_3d=$2 ; shift ; shift ;; |
---|
| 102 | |
---|
| 103 | "-full") |
---|
| 104 | full_flag="-full"; shift ;; |
---|
| 105 | |
---|
| 106 | "-clean_inca") |
---|
| 107 | clean_inca="-clean"; shift ;; |
---|
| 108 | |
---|
| 109 | "-netcdf_lib_seq") |
---|
| 110 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
| 111 | |
---|
| 112 | "-chimie") |
---|
| 113 | echo $2; |
---|
| 114 | optchimie=$2; shift ; shift;; |
---|
| 115 | |
---|
| 116 | *) |
---|
| 117 | echo "unknown option "$2" , exiting..." |
---|
| 118 | exit |
---|
| 119 | esac |
---|
| 120 | done |
---|
| 121 | echo; echo "********************* WARNING **********************" |
---|
| 122 | echo; echo "********************* WARNING **********************" |
---|
| 123 | echo; echo " if you are working with an lmdz version before rev 3563 (check it with command svn info) " |
---|
| 124 | echo "you need to modify phylmd/physiq_mod.F90 file " |
---|
| 125 | echo "add ! to comment lines if/endif before and after the call to AEROSOL_METEO_CALC" |
---|
| 126 | echo; echo "********************* WARNING **********************" |
---|
| 127 | echo; echo "********************* WARNING **********************" |
---|
| 128 | |
---|
| 129 | echo "Following arguments are set in current compiling:" >> $outfile |
---|
| 130 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile |
---|
| 131 | echo " chimie = $optchimie, clean_inca = ${clean_inca}" |
---|
| 132 | echo >> $outfile |
---|
| 133 | |
---|
| 134 | ### Read host dependent default values |
---|
| 135 | ### These variables will not be changed if they were set as argument |
---|
| 136 | ###./host.sh $host |
---|
| 137 | # Later : Following lines should be set in host.sh file |
---|
| 138 | # begin host.sh |
---|
| 139 | if [ $fcm_arch == default ] ; then |
---|
| 140 | # Find out current host and source specific paths and commands for the host |
---|
| 141 | case $( hostname -s ) in |
---|
| 142 | jean-zay*) |
---|
| 143 | fcm_arch=X64_JEANZAY;; |
---|
| 144 | irene170|irene171|irene190|irene191|irene192|irene193) |
---|
| 145 | fcm_arch=X64_IRENE;; |
---|
| 146 | irene172|irene173|irene194|irene195) |
---|
| 147 | fcm_arch=X64_IRENE-AMD;; |
---|
| 148 | asterix*|obelix*) |
---|
| 149 | fcm_arch=ifort_LSCE;; |
---|
| 150 | ciclad*|climserv*) |
---|
| 151 | fcm_arch=ifort_CICLAD;; |
---|
| 152 | *) |
---|
| 153 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
| 154 | echo Exit now. |
---|
| 155 | exit |
---|
| 156 | esac |
---|
| 157 | fi |
---|
| 158 | |
---|
| 159 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
| 160 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 161 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
| 162 | echo >> $outfile |
---|
[6307] | 163 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components." |
---|
| 164 | echo "Note that this new environement might be kept after compilation." |
---|
| 165 | echo "If this is the case, source again your personal environment after compilation. " |
---|
| 166 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 167 | module list >> $outfile 2>&1 |
---|
| 168 | # Get initial svn version |
---|
| 169 | svn_version=$(module list -t | grep subversion) |
---|
| 170 | |
---|
| 171 | # Make a link to this file, to be used also in config.card |
---|
[5975] | 172 | rm -f ARCH/arch.env |
---|
| 173 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
[6307] | 174 | |
---|
| 175 | # Source the file |
---|
| 176 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 177 | if [ X$svn_version != X ] ; then |
---|
| 178 | # Put back initial version of svn |
---|
| 179 | module load ${svn_version} |
---|
| 180 | fi |
---|
| 181 | |
---|
| 182 | echo >> $outfile |
---|
| 183 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 184 | module list >> $outfile 2>&1 |
---|
[5975] | 185 | fi |
---|
| 186 | |
---|
| 187 | #### 2 Do the compilation |
---|
| 188 | ## 2.1 Compile ioipsl |
---|
| 189 | cd $modipsl/modeles/IOIPSL |
---|
| 190 | echo; echo "NOW COMPILE IOIPSL" |
---|
| 191 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 192 | |
---|
| 193 | # Check if compilation with fcm is included in IOIPSL |
---|
| 194 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 195 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 196 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 197 | exit |
---|
| 198 | fi |
---|
| 199 | |
---|
| 200 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 201 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
| 202 | # Test if compiling succeded |
---|
| 203 | if [[ $? != 0 ]] ; then |
---|
| 204 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 205 | exit |
---|
| 206 | fi |
---|
| 207 | |
---|
| 208 | ## 2.2 Compile xios |
---|
| 209 | cd $modipsl/modeles/XIOS |
---|
| 210 | echo; echo "NOW COMPILE XIOS" |
---|
| 211 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
| 212 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
| 213 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
| 214 | # Test if compiling succeded |
---|
| 215 | if [[ $? != 0 ]] ; then |
---|
| 216 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 217 | exit |
---|
| 218 | fi |
---|
| 219 | # Move executables to modipsl/bin |
---|
| 220 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 221 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
| 222 | else |
---|
| 223 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 224 | exit |
---|
| 225 | fi |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | ## 2.3 Compile orchidee |
---|
| 229 | cd $modipsl/modeles/ORCHIDEE |
---|
| 230 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
| 231 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 232 | |
---|
| 233 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
| 234 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
| 235 | # Test if compiling finished |
---|
| 236 | if [[ $? != 0 ]] ; then |
---|
| 237 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 238 | exit |
---|
| 239 | fi |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | ## 2.4 Compile LMDZ and INCA for regular latlon configuration |
---|
| 243 | if [ $regular_latlon = yes ] ; then |
---|
| 244 | |
---|
| 245 | cd $modipsl/modeles/INCA |
---|
| 246 | #compile INCA regulat lat_lon chimie librairy |
---|
| 247 | echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}" |
---|
| 248 | echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile |
---|
| 249 | ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile 2>&1 |
---|
| 250 | |
---|
| 251 | # Test if compiling finished |
---|
| 252 | if [[ $? != 0 ]] ; then |
---|
| 253 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
| 254 | exit |
---|
| 255 | fi |
---|
| 256 | |
---|
| 257 | echo "Move inca.dat modipsl/bin" |
---|
| 258 | if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ; then |
---|
| 259 | mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ; |
---|
| 260 | # cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat; |
---|
| 261 | else |
---|
| 262 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
| 263 | exit |
---|
| 264 | fi |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | cd $modipsl/modeles/LMDZ |
---|
| 268 | # Compile LMDZ regular lat-lon exectuable |
---|
| 269 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" |
---|
| 270 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 271 | |
---|
| 272 | |
---|
| 273 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
| 274 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
| 275 | # to ask question and wait for interactivly answer from the user. |
---|
| 276 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
| 277 | echo >> $outfile |
---|
| 278 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
| 279 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
| 280 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
| 281 | echo >> $outfile |
---|
| 282 | rm -f libf/grid/dimensions.h |
---|
| 283 | rm -f .lock |
---|
| 284 | fi |
---|
| 285 | |
---|
| 286 | |
---|
| 287 | |
---|
| 288 | |
---|
| 289 | |
---|
| 290 | echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile |
---|
| 291 | ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile 2>&1 |
---|
| 292 | # Test if compiling finished |
---|
| 293 | if [[ $? != 0 ]] ; then |
---|
| 294 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 295 | exit |
---|
| 296 | fi |
---|
| 297 | |
---|
| 298 | # # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 299 | # echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" |
---|
| 300 | # echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 301 | # |
---|
| 302 | # echo ./makelmdz_fcm -d ${resol_atm_3d} -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 |
---|
| 303 | # ./makelmdz_fcm -d ${resol_atm_3d} -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 |
---|
| 304 | # # Test if compiling finished |
---|
| 305 | # if [[ $? != 0 ]] ; then |
---|
| 306 | # echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 307 | # exit |
---|
| 308 | # fi |
---|
| 309 | # |
---|
| 310 | # Find executable suffix |
---|
| 311 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
| 312 | suffix=_${resol_atm_3d}_phylmd_seq_orch_inca |
---|
| 313 | else |
---|
| 314 | suffix=_${resol_atm_3d}_phylmd_para_mem_orch_inca |
---|
| 315 | fi |
---|
| 316 | echo suffix = $suffix |
---|
| 317 | |
---|
| 318 | # Move executables to modipsl/bin folder |
---|
| 319 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
| 320 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then |
---|
| 321 | mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ; |
---|
| 322 | |
---|
| 323 | else |
---|
| 324 | echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP" |
---|
| 325 | exit |
---|
| 326 | |
---|
| 327 | fi |
---|
| 328 | # if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm_3d}_${optmode}_${optchimie}.e ; fi |
---|
| 329 | |
---|
| 330 | fi |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
| 334 | echo; echo "ALL COMPILING FINISHED" |
---|
| 335 | |
---|
| 336 | if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then |
---|
| 337 | echo; echo "====================================================" |
---|
| 338 | echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" |
---|
| 339 | echo; echo "Optmode="$optmode |
---|
| 340 | echo; echo "====================================================" |
---|
| 341 | fi |
---|
| 342 | |
---|
| 343 | date |
---|
| 344 | exit |
---|
| 345 | |
---|
| 346 | |
---|