[5684] | 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 | mysrc_path=$submitdir/SOURCES |
---|
| 14 | |
---|
| 15 | #### Set default options |
---|
| 16 | # Coupled with ocean biogeochemistry (y/n) |
---|
| 17 | cpltop=WithTOP |
---|
| 18 | # Coupled with ocean biogeochemistry (y/n) |
---|
| 19 | cplmode=online |
---|
| 20 | |
---|
| 21 | # Optimization mode |
---|
| 22 | # optmode=prod/dev/debug |
---|
| 23 | optmode=prod |
---|
| 24 | # fcm_arch |
---|
| 25 | fcm_arch=default |
---|
| 26 | export fcm_arch xios |
---|
| 27 | full_nemo=n |
---|
| 28 | full_xios="" |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | # Output text file for compilation of each component |
---|
| 32 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
| 33 | outfile=$submitdir/out_compile_nemo.$datestr |
---|
| 34 | echo > $outfile |
---|
| 35 | echo; echo "Text output from compilation will be stored in file out_compile_nemo.$datestr"; echo |
---|
| 36 | |
---|
| 37 | #### Read arguments |
---|
| 38 | # Loop over all arguments to modify default set up |
---|
| 39 | while (($# > 0)) ; do |
---|
| 40 | case $1 in |
---|
| 41 | "-h") cat <<end_help |
---|
| 42 | ######################################################################## |
---|
| 43 | # Usage of the script compile_nemo.sh |
---|
| 44 | # |
---|
| 45 | ######################################################################## |
---|
| 46 | |
---|
| 47 | ./compile_nemo.sh [Options] |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | Options: [ORCA1 / ORCA2 / ORCA025 ] Model resolution, choose only one. Default: ORCA2 |
---|
| 51 | [OFFLINE] Compile Coupled NEMO-TOP in offline mode |
---|
| 52 | [-full] Full recompilation of all components. This option can be added to all other options. |
---|
| 53 | [-cleannemo] Full recompilation of NEMO component only. |
---|
| 54 | [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod. |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | Example 1: Default compilation of ORCA_ICE_TOP |
---|
| 58 | ./compile_nemo.sh |
---|
| 59 | |
---|
| 60 | Example 2: Compilation of TOP offline |
---|
| 61 | ./compile_nemo.sh OFFLINE |
---|
| 62 | |
---|
| 63 | Example 3: Compilation of ORCA_ICE without passive tracers |
---|
| 64 | ./compile_nemo.sh NOTOP -cleannemo |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | Example 4: Default resoltuion (LR) compiled in debug mode |
---|
| 68 | ./compile_nemo.sh -debug |
---|
| 69 | |
---|
| 70 | Example 5: Default compilation with full recompilation of NEMO and XIOS. No clean is needed. |
---|
| 71 | ./compile_nemo.sh -full |
---|
| 72 | |
---|
| 73 | Example 6: Full recompilation in debug mode |
---|
| 74 | ./compile_nemo.sh OFFLINE -debug -full |
---|
| 75 | |
---|
| 76 | end_help |
---|
| 77 | exit;; |
---|
| 78 | "NOTOP") cpltop=WithoutTOP; shift ;; |
---|
| 79 | "OFFLINE") cplmode=offline; shift ;; |
---|
| 80 | "-arch") fcm_arch="$2" ; shift ; shift ;; |
---|
| 81 | "-debug") optmode=debug ; shift ;; |
---|
| 82 | "-dev") optmode=dev ; shift ;; |
---|
| 83 | "-prod") optmode=prod ; shift ;; |
---|
| 84 | "-full") full_nemo=y ; full_xios="--full" ; shift ;; |
---|
| 85 | "-full_xios") full_xios="--full" ; shift ;; # Note only full_xios is using double dash: --full |
---|
| 86 | "-full_nemo") full_nemo=y ; shift ;; |
---|
| 87 | "-cleannemo") full_nemo=y ; shift ;; |
---|
| 88 | *) echo "unknown option "$1" , exiting..." ; exit |
---|
| 89 | esac |
---|
| 90 | done |
---|
| 91 | |
---|
| 92 | echo "Following options are set in current compiling:" >> $outfile |
---|
| 93 | echo " WithTracer=${cpltop}, coupled_mode=${cplmode}" >> $outfile |
---|
| 94 | echo " optmode = $optmode, fcm_arch = $fcm_arch " >> $outfile |
---|
| 95 | echo " full_xios=$full_xios, full_nemo=$full_nemo," >> $outfile |
---|
| 96 | echo >> $outfile |
---|
| 97 | |
---|
| 98 | ### Read host dependent default values |
---|
| 99 | ### These variables will not be changed if they were set as argument |
---|
| 100 | ###./host.sh $host |
---|
| 101 | # Later : Following lines should be set in host.sh file |
---|
| 102 | # begin host.sh |
---|
| 103 | if [ $fcm_arch == default ] ; then |
---|
| 104 | # Find out current host and source specific paths and commands for the host |
---|
| 105 | case $( hostname -s ) in |
---|
| 106 | jean-zay*) |
---|
| 107 | fcm_arch=X64_JEANZAY;; |
---|
| 108 | irene170|irene171|irene190|irene191|irene192|irene193) |
---|
| 109 | fcm_arch=X64_IRENE;; |
---|
| 110 | irene172|irene173|irene194|irene195) |
---|
| 111 | fcm_arch=X64_IRENE-AMD;; |
---|
| 112 | ciclad*|climserv*) |
---|
| 113 | fcm_arch=ifort_CICLAD;; |
---|
| 114 | *) |
---|
| 115 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
| 116 | echo Exit now. |
---|
| 117 | exit |
---|
| 118 | esac |
---|
| 119 | fi |
---|
| 120 | |
---|
| 121 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
| 122 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
| 123 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
| 124 | echo >> $outfile |
---|
| 125 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components" |
---|
| 126 | echo "Note that this new environement might be kept after compilation." |
---|
| 127 | echo "If this is the case, source again your personal environment after compilation. " |
---|
| 128 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 129 | module list >> $outfile 2>&1 |
---|
| 130 | |
---|
| 131 | # Make a link to this file, to be used also in config.card |
---|
| 132 | rm -f ARCH/arch.env |
---|
| 133 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
| 134 | |
---|
| 135 | # Source the file |
---|
| 136 | source ARCH/arch.env >> $outfile 2>&1 |
---|
| 137 | echo >> $outfile |
---|
| 138 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
| 139 | module list >> $outfile 2>&1 |
---|
| 140 | fi |
---|
| 141 | |
---|
| 142 | #### 2 Do the compilation |
---|
| 143 | |
---|
| 144 | ## 2.3 Compile xios |
---|
| 145 | cd $modipsl/modeles/XIOS |
---|
| 146 | echo; echo "NOW COMPILE XIOS" |
---|
| 147 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
| 148 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path --job 2 $full_xios >> $outfile |
---|
| 149 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path --job 2 $full_xios >> $outfile 2>&1 |
---|
| 150 | # Test if compiling succeded |
---|
| 151 | if [[ $? != 0 ]] ; then |
---|
| 152 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
| 153 | exit |
---|
| 154 | fi |
---|
| 155 | # Move executables to modipsl/bin |
---|
| 156 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
| 157 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
| 158 | else |
---|
| 159 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
| 160 | exit |
---|
| 161 | fi |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | ## 2.5 Compile NEMO |
---|
| 165 | nemo_root=$modipsl/modeles/NEMO |
---|
| 166 | cfg_ref=ORCA2_ICE_PISCES |
---|
| 167 | cfg_wrk=ORCA_ICE_TRC |
---|
| 168 | addkeys="key_top key_si3" |
---|
| 169 | delkeys="key_qco" |
---|
| 170 | |
---|
| 171 | if [ ${cplmode} == offline ] ; then |
---|
| 172 | cfg_ref=ORCA2_OFF_TRC |
---|
| 173 | cfg_wrk=ORCA_OFF_TRC |
---|
| 174 | delkeys="key_si3" |
---|
| 175 | fi |
---|
| 176 | if [ ${cpltop} == WithoutTOP ] ; then |
---|
| 177 | cfg_wrk=ORCA_ICE |
---|
| 178 | delkeys="key_top key_qco" |
---|
| 179 | fi |
---|
| 180 | |
---|
| 181 | echo >> $outfile ; echo cd $nemo_root >> $outfile |
---|
| 182 | echo >> $outfile ; echo cp $mysrc_path/arch-${fcm_arch}.fcm arch/CNRS/. >> $outfile |
---|
| 183 | echo >> $outfile |
---|
| 184 | |
---|
| 185 | cd $nemo_root ; cp $mysrc_path/arch-${fcm_arch}.fcm arch/CNRS/. |
---|
| 186 | |
---|
| 187 | echo >> $outfile |
---|
| 188 | # creation of config |
---|
| 189 | echo >> $outfile ; echo cd $nemo_root >> $outfile |
---|
| 190 | echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys" del_key "$delkeys" >> $outfile |
---|
| 191 | echo >> $outfile |
---|
| 192 | cd $nemo_root |
---|
| 193 | ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys" del_key "$delkeys" >> $outfile 2>&1 |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | # Copy of specfic source files |
---|
| 197 | echo >> $outfile ; echo cp $mysrc_path/*.*90 $nemo_root/cfgs/$cfg_wrk/MY_SRC/. >> $outfile |
---|
| 198 | echo >> $outfile |
---|
| 199 | cp $mysrc_path/*.*90 $nemo_root/cfgs/$cfg_wrk/MY_SRC/. |
---|
| 200 | |
---|
| 201 | if [ $full_nemo == y ] ; then |
---|
| 202 | # To make a full compilation, first make a clean to remove all files produced during previous compilation |
---|
| 203 | echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean >> $outfile |
---|
| 204 | echo >> $outfile |
---|
| 205 | ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean >> $outfile 2>&1 |
---|
| 206 | fi |
---|
| 207 | echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8 >> $outfile |
---|
| 208 | echo >> $outfile |
---|
| 209 | ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8 >> $outfile 2>&1 |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | # Test if compiling finished |
---|
| 213 | if [[ $? != 0 ]] ; then |
---|
| 214 | echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP" |
---|
| 215 | exit |
---|
| 216 | fi |
---|
| 217 | |
---|
| 218 | echo >> $outfile |
---|
| 219 | echo "Move nemo executable to modipsl/bin" >> $outfile |
---|
| 220 | echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin >> $outfile |
---|
| 221 | ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin >> $outfile |
---|
| 222 | echo >> $outfile |
---|
| 223 | |
---|
| 224 | if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then |
---|
| 225 | mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${cplmode}_${optmode}.exe |
---|
| 226 | else |
---|
| 227 | echo "ERROR gcm${suffix} executable does not exist." |
---|
| 228 | echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP" |
---|
| 229 | exit |
---|
| 230 | fi |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
| 234 | echo ls -lrt modipsl/bin >> $outfile |
---|
| 235 | ls -lrt $modipsl/bin >> $outfile |
---|
| 236 | |
---|
| 237 | echo; echo "ALL COMPILING FINISHED" ; echo |
---|
| 238 | echo "Executables are found in modipsl/bin" |
---|
| 239 | echo "Check that executable names correspond with the name set in config.card before launching the job" |
---|
| 240 | echo ls -lrt modipsl/bin |
---|
| 241 | ls -lrt $modipsl/bin |
---|
| 242 | |
---|
| 243 | date |
---|
| 244 | |
---|
| 245 | exit |
---|
| 246 | |
---|
| 247 | |
---|