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