[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 |
---|
| 19 | regular_latlon=yes |
---|
| 20 | resol_atm_3d=144x142x79 |
---|
| 21 | |
---|
[4268] | 22 | # fcm_arch |
---|
| 23 | fcm_arch=default |
---|
| 24 | # Default values to be overritten |
---|
[4339] | 25 | parallel=mpi_omp |
---|
[4268] | 26 | export fcm_arch parallel xios |
---|
| 27 | full_flag="" |
---|
[4391] | 28 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
| 29 | netcdf_lib="" |
---|
[4268] | 30 | |
---|
[4408] | 31 | # Output text file for compilation of each component |
---|
[4411] | 32 | outfile=$submitdir/out_compile_lmdzor |
---|
[4408] | 33 | rm -f $outfile; 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 | |
---|
[4407] | 49 | Options: -full, -regular_latlon, -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. |
---|
| 62 | ./compile_lmdzor.sh -regular_latlon 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 | |
---|
| 76 | "-optmode") |
---|
| 77 | optmode=$2 ; shift ; shift ;; |
---|
[4407] | 78 | |
---|
| 79 | "-debug") |
---|
| 80 | optmode=debug ; shift ;; |
---|
| 81 | |
---|
| 82 | "-dev") |
---|
| 83 | optmode=dev ; shift ;; |
---|
| 84 | |
---|
| 85 | "-prod") |
---|
| 86 | optmode=prod ; shift ;; |
---|
| 87 | |
---|
[4278] | 88 | "-regular_latlon") |
---|
| 89 | regular_latlon=yes ; |
---|
| 90 | resol_atm_3d=$2 ; shift ; shift ;; |
---|
| 91 | |
---|
| 92 | "-full") |
---|
| 93 | full_flag="-full"; shift ;; |
---|
| 94 | |
---|
[4391] | 95 | "-netcdf_lib_seq") |
---|
| 96 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
| 97 | |
---|
[4278] | 98 | *) |
---|
| 99 | echo "unknown option "$2" , exiting..." |
---|
| 100 | exit |
---|
| 101 | esac |
---|
| 102 | done |
---|
[4268] | 103 | |
---|
[4408] | 104 | echo "Following arguments are set in current compiling:" >> $outfile |
---|
| 105 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile |
---|
| 106 | echo >> $outfile |
---|
[4268] | 107 | |
---|
[4278] | 108 | ### Read host dependent default values |
---|
| 109 | ### These variables will not be changed if they were set as argument |
---|
[4268] | 110 | ###./host.sh $host |
---|
| 111 | # Later : Following lines should be set in host.sh file |
---|
| 112 | # begin host.sh |
---|
| 113 | if [ $fcm_arch == default ] ; then |
---|
[4278] | 114 | # Find out current host and source specific paths and commands for the host |
---|
| 115 | case $( hostname -s ) in |
---|
| 116 | ada*) |
---|
| 117 | fcm_arch=X64_ADA;; |
---|
| 118 | irene*) |
---|
[4391] | 119 | fcm_arch=X64_IRENE;; |
---|
[4278] | 120 | asterix*|obelix*) |
---|
| 121 | fcm_arch=ifort_LSCE;; |
---|
[4391] | 122 | ciclad*|climserv*) |
---|
| 123 | fcm_arch=ifort_CICLAD;; |
---|
[4278] | 124 | *) |
---|
[4391] | 125 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
[4278] | 126 | echo Exit now. |
---|
| 127 | exit |
---|
| 128 | esac |
---|
[4268] | 129 | fi |
---|
| 130 | |
---|
[4391] | 131 | # Set a link to arch.env and source the file if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
| 132 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 133 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
[4408] | 134 | echo >> $outfile |
---|
| 135 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation." |
---|
| 136 | echo "Note that this new environement will be kept after compilation." |
---|
| 137 | echo "You might want to source again your personal environment after compilation. This must be done manually or by reconnection." |
---|
| 138 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 139 | module list >> $outfile 2>&1 |
---|
| 140 | |
---|
[4391] | 141 | rm -f ARCH/arch.env |
---|
| 142 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
[4408] | 143 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 144 | |
---|
| 145 | echo >> $outfile |
---|
| 146 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 147 | module list >> $outfile 2>&1 |
---|
[4391] | 148 | fi |
---|
| 149 | |
---|
[4268] | 150 | #### 2 Do the compilation |
---|
| 151 | ## 2.1 Compile ioipsl |
---|
| 152 | cd $modipsl/modeles/IOIPSL |
---|
[4278] | 153 | echo; echo "NOW COMPILE IOIPSL" |
---|
[4408] | 154 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
| 155 | |
---|
[4411] | 156 | # Check if compilation with fcm is included in IOIPSL |
---|
| 157 | if [ ! -f makeioipsl_fcm ] ; then |
---|
| 158 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
| 159 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
| 160 | exit |
---|
| 161 | fi |
---|
| 162 | |
---|
[4408] | 163 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
| 164 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
[4268] | 165 | # Test if compiling succeded |
---|
| 166 | if [[ $? != 0 ]] ; then |
---|
[4278] | 167 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
| 168 | exit |
---|
[4268] | 169 | fi |
---|
| 170 | |
---|
| 171 | ## 2.2 Compile xios |
---|
| 172 | cd $modipsl/modeles/XIOS |
---|
[4278] | 173 | echo; echo "NOW COMPILE XIOS" |
---|
[4408] | 174 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
| 175 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
| 176 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
[4268] | 177 | # Test if compiling succeded |
---|
| 178 | if [[ $? != 0 ]] ; then |
---|
[4278] | 179 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 180 | exit |
---|
[4268] | 181 | fi |
---|
[4391] | 182 | # Move executables to modipsl/bin |
---|
| 183 | if [ $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 184 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/. |
---|
| 185 | else |
---|
| 186 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 187 | exit |
---|
| 188 | fi |
---|
[4268] | 189 | |
---|
[4391] | 190 | |
---|
[4268] | 191 | ## 2.3 Compile orchidee |
---|
| 192 | cd $modipsl/modeles/ORCHIDEE |
---|
[4278] | 193 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
[4408] | 194 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
| 195 | |
---|
| 196 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} $full_flag >> $outfile |
---|
| 197 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} $full_flag >> $outfile 2>&1 |
---|
[4268] | 198 | # Test if compiling finished |
---|
| 199 | if [[ $? != 0 ]] ; then |
---|
| 200 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
| 201 | exit |
---|
| 202 | fi |
---|
| 203 | |
---|
[4408] | 204 | |
---|
[4411] | 205 | ## 2.4 Compile LMDZ for regular latlon configuration |
---|
[4278] | 206 | if [ $regular_latlon = yes ] ; then |
---|
[4268] | 207 | |
---|
[4278] | 208 | cd $modipsl/modeles/LMDZ |
---|
| 209 | # Compile LMDZ regular lat-lon exectuable |
---|
| 210 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" |
---|
[4408] | 211 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 212 | |
---|
| 213 | echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag gcm >> $outfile |
---|
| 214 | ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag gcm >> $outfile 2>&1 |
---|
[4278] | 215 | # Test if compiling finished |
---|
| 216 | if [[ $? != 0 ]] ; then |
---|
| 217 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
| 218 | exit |
---|
| 219 | fi |
---|
| 220 | |
---|
| 221 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
| 222 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" |
---|
[4408] | 223 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" >> $outfile |
---|
| 224 | |
---|
| 225 | echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag ce0l >> $outfile |
---|
| 226 | ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag ce0l >> $outfile 2>&1 |
---|
[4278] | 227 | # Test if compiling finished |
---|
| 228 | if [[ $? != 0 ]] ; then |
---|
| 229 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
| 230 | exit |
---|
| 231 | fi |
---|
| 232 | |
---|
| 233 | # Find executable suffix |
---|
| 234 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
| 235 | suffix=_${resol_atm_3d}_phylmd_seq_orch |
---|
| 236 | else |
---|
| 237 | suffix=_${resol_atm_3d}_phylmd_para_mem_orch |
---|
| 238 | fi |
---|
| 239 | echo suffix = $suffix |
---|
[4268] | 240 | |
---|
[4278] | 241 | # Move executables to modipsl/bin folder |
---|
| 242 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
| 243 | if [ $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}.e ; fi |
---|
| 244 | if [ $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm_3d}.e ; fi |
---|
[4268] | 245 | |
---|
| 246 | # Write .resol file |
---|
| 247 | cd $submitdir |
---|
[4278] | 248 | resol2D=$( echo ${resol_atm_3d} | awk '-Fx' '{print $1}' )$( echo ${resol_atm_3d} | awk '-Fx' '{print $2}' ) |
---|
[4268] | 249 | echo "noORCAxLMD$resol2D" >.resol |
---|
[4278] | 250 | echo "RESOL_ATM_3D=${resol_atm_3d}" >>.resol |
---|
[4268] | 251 | fi |
---|
| 252 | |
---|
[4278] | 253 | |
---|
[4408] | 254 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
| 255 | echo; echo "ALL COMPILING FINISHED" |
---|
[4278] | 256 | |
---|
[4409] | 257 | date |
---|
[4268] | 258 | exit |
---|
| 259 | |
---|
| 260 | |
---|