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