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