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 | mysrc_path=$submitdir/SOURCES |
---|
15 | sources_RH8_path=$submitdir/SOURCES/REDHAT8 |
---|
16 | |
---|
17 | #### Set default options |
---|
18 | # Optimization mode |
---|
19 | # optmode=prod/dev/debug |
---|
20 | optmode=prod |
---|
21 | # Resolution of LMDZ in regular mode |
---|
22 | regular_latlon=yes |
---|
23 | resol_atm_3d=96x95x39 |
---|
24 | optchimie=NMHC_AER_S |
---|
25 | #recompilation de inca seul ou de tous les modeles |
---|
26 | clean_inca="" |
---|
27 | full_flag="" |
---|
28 | |
---|
29 | # fcm_arch |
---|
30 | fcm_arch=default |
---|
31 | # Default values to be overritten |
---|
32 | parallel=mpi_omp |
---|
33 | export fcm_arch parallel xios |
---|
34 | |
---|
35 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
36 | netcdf_lib="" |
---|
37 | |
---|
38 | # Output text file for compilation of each component |
---|
39 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
40 | outfile=$submitdir/out_compile_lmdzorinca.$datestr |
---|
41 | echo > $outfile |
---|
42 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo |
---|
43 | |
---|
44 | #### Read arguments |
---|
45 | # Loop over all arguments to modify default set up |
---|
46 | while (($# > 0)) ; do |
---|
47 | case $1 in |
---|
48 | "-h") cat <<fin |
---|
49 | |
---|
50 | ######################################################################## |
---|
51 | # Usage of the script compile_lmdzorinca.sh |
---|
52 | # |
---|
53 | ######################################################################## |
---|
54 | |
---|
55 | ./compile_config [Options] |
---|
56 | |
---|
57 | Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default) |
---|
58 | |
---|
59 | Example 1: Default compilation of LMDZ-ORCHIDEE-INCA with XIOS and IOIPSL - NMHC_AER_S / 96x95x39 |
---|
60 | ./compile_lmdzorinca.sh |
---|
61 | |
---|
62 | Example 2: Compilation with a chosen chemistry, for example DUSS (default: NMHC_AER_S) |
---|
63 | ./compile_lmdzorinca.sh -chimie DUSS |
---|
64 | |
---|
65 | Example 3: Compile in debug mode - in this case you need to modify Optmode in config.card |
---|
66 | ./compile_lmdzorinca.sh -debug |
---|
67 | |
---|
68 | Example 4: Default compilation with full recompilation of all components |
---|
69 | ./compile_lmdzorinca.sh -full |
---|
70 | |
---|
71 | Example 5: Default compilation with recompilation of inca model only |
---|
72 | ./compile_lmdzorinca.sh -clean_inca |
---|
73 | |
---|
74 | Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39) |
---|
75 | The dimension can be changed to any other 3d dimension. |
---|
76 | ./compile_lmdzorinca.sh -regular_latlon 144x142x79 |
---|
77 | |
---|
78 | fin |
---|
79 | exit;; |
---|
80 | |
---|
81 | "-parallel") |
---|
82 | parallel=$2 ; shift ; shift ;; |
---|
83 | |
---|
84 | "-arch") |
---|
85 | fcm_arch="$2" ; shift ; shift ;; |
---|
86 | |
---|
87 | "-xios") |
---|
88 | xios="$2" ; shift ; shift ;; |
---|
89 | |
---|
90 | "-optmode") |
---|
91 | optmode=$2 ; shift ; shift ;; |
---|
92 | |
---|
93 | "-debug") |
---|
94 | optmode=debug ; shift ;; |
---|
95 | |
---|
96 | "-dev") |
---|
97 | optmode=dev ; shift ;; |
---|
98 | |
---|
99 | "-prod") |
---|
100 | optmode=prod ; shift ;; |
---|
101 | |
---|
102 | "-regular_latlon") |
---|
103 | regular_latlon=yes ; |
---|
104 | resol_atm_3d=$2 ; shift ; shift ;; |
---|
105 | |
---|
106 | "-full") |
---|
107 | full_flag="-full"; shift ;; |
---|
108 | |
---|
109 | "-clean_inca") |
---|
110 | clean_inca="-clean"; shift ;; |
---|
111 | |
---|
112 | "-netcdf_lib_seq") |
---|
113 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
114 | |
---|
115 | "-chimie") |
---|
116 | echo $2; |
---|
117 | optchimie=$2; shift ; shift;; |
---|
118 | |
---|
119 | *) |
---|
120 | echo "unknown option "$2" , exiting..." |
---|
121 | exit |
---|
122 | esac |
---|
123 | done |
---|
124 | echo; echo "********************* WARNING **********************" |
---|
125 | echo; echo "********************* WARNING **********************" |
---|
126 | echo; echo " if you are working with an lmdz version before rev 3563 (check it with command svn info) " |
---|
127 | echo "you need to modify phylmd/physiq_mod.F90 file " |
---|
128 | echo "add ! to comment lines if/endif before and after the call to AEROSOL_METEO_CALC" |
---|
129 | echo; echo "********************* WARNING **********************" |
---|
130 | echo; echo "********************* WARNING **********************" |
---|
131 | |
---|
132 | echo "Following arguments are set in current compiling:" >> $outfile |
---|
133 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile |
---|
134 | echo " chimie = $optchimie, clean_inca = ${clean_inca}" |
---|
135 | echo >> $outfile |
---|
136 | |
---|
137 | ### Read host dependent default values |
---|
138 | ### These variables will not be changed if they were set as argument |
---|
139 | ###./host.sh $host |
---|
140 | # Later : Following lines should be set in host.sh file |
---|
141 | # begin host.sh |
---|
142 | if [ $fcm_arch == default ] ; then |
---|
143 | # Find out current host and source specific paths and commands for the host |
---|
144 | case $( hostname -s ) in |
---|
145 | jean-zay*) |
---|
146 | fcm_arch=X64_JEANZAY;; |
---|
147 | irene170|irene171|irene190|irene191|irene192|irene193) |
---|
148 | fcm_arch=X64_IRENE;; |
---|
149 | irene172|irene173|irene194|irene195) |
---|
150 | fcm_arch=X64_IRENE-AMD;; |
---|
151 | asterix*|obelix*) |
---|
152 | fcm_arch=ifort_LSCE;; |
---|
153 | ciclad*|climserv*) |
---|
154 | fcm_arch=ifort_CICLAD;; |
---|
155 | *) |
---|
156 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
157 | echo Exit now. |
---|
158 | exit |
---|
159 | esac |
---|
160 | fi |
---|
161 | |
---|
162 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
163 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
164 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
165 | echo >> $outfile |
---|
166 | echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component" |
---|
167 | rm -f ARCH/arch.env |
---|
168 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
169 | fi |
---|
170 | |
---|
171 | #### 2 Do the compilation |
---|
172 | ## 2.1 Compile ioipsl |
---|
173 | cd $modipsl/modeles/IOIPSL |
---|
174 | echo; echo "NOW COMPILE IOIPSL" |
---|
175 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
176 | |
---|
177 | # Check if compilation with fcm is included in IOIPSL |
---|
178 | if [ ! -f makeioipsl_fcm ] ; then |
---|
179 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
180 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
181 | exit |
---|
182 | fi |
---|
183 | |
---|
184 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
185 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
186 | # Test if compiling succeded |
---|
187 | if [[ $? != 0 ]] ; then |
---|
188 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
189 | exit |
---|
190 | fi |
---|
191 | |
---|
192 | ## 2.2 Compile xios |
---|
193 | cd $modipsl/modeles/XIOS |
---|
194 | echo; echo "NOW COMPILE XIOS" |
---|
195 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
196 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
197 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
198 | # Test if compiling succeded |
---|
199 | if [[ $? != 0 ]] ; then |
---|
200 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
201 | exit |
---|
202 | fi |
---|
203 | # Move executables to modipsl/bin |
---|
204 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
205 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
206 | else |
---|
207 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
208 | exit |
---|
209 | fi |
---|
210 | |
---|
211 | |
---|
212 | ## 2.3 Compile orchidee |
---|
213 | cd $modipsl/modeles/ORCHIDEE |
---|
214 | |
---|
215 | |
---|
216 | cp ${sources_RH8_path}/ORCHIDEE/* src_parallel/. |
---|
217 | |
---|
218 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
219 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
220 | |
---|
221 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
222 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
223 | # Test if compiling finished |
---|
224 | if [[ $? != 0 ]] ; then |
---|
225 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
226 | exit |
---|
227 | fi |
---|
228 | |
---|
229 | |
---|
230 | ## 2.4 Compile LMDZ and INCA for regular latlon configuration |
---|
231 | if [ $regular_latlon = yes ] ; then |
---|
232 | |
---|
233 | cd $modipsl/modeles/INCA |
---|
234 | #compile INCA regulat lat_lon chimie librairy |
---|
235 | echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}" |
---|
236 | echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile |
---|
237 | ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_flag $clean_inca >> $outfile 2>&1 |
---|
238 | |
---|
239 | # Test if compiling finished |
---|
240 | if [[ $? != 0 ]] ; then |
---|
241 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
242 | exit |
---|
243 | fi |
---|
244 | |
---|
245 | echo "Move inca.dat modipsl/bin" |
---|
246 | if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ; then |
---|
247 | mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ; |
---|
248 | # cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat; |
---|
249 | else |
---|
250 | echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP" |
---|
251 | exit |
---|
252 | fi |
---|
253 | |
---|
254 | |
---|
255 | cd $modipsl/modeles/LMDZ |
---|
256 | |
---|
257 | cp ${sources_RH8_path}/LMDZ/* arch/. |
---|
258 | |
---|
259 | # Compile LMDZ regular lat-lon exectuable |
---|
260 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" |
---|
261 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}" >> $outfile |
---|
262 | |
---|
263 | |
---|
264 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
265 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
266 | # to ask question and wait for interactivly answer from the user. |
---|
267 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
268 | echo >> $outfile |
---|
269 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
270 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
271 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
272 | echo >> $outfile |
---|
273 | rm -f libf/grid/dimensions.h |
---|
274 | rm -f .lock |
---|
275 | fi |
---|
276 | |
---|
277 | |
---|
278 | |
---|
279 | |
---|
280 | |
---|
281 | echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile |
---|
282 | ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile 2>&1 |
---|
283 | # Test if compiling finished |
---|
284 | if [[ $? != 0 ]] ; then |
---|
285 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
286 | exit |
---|
287 | fi |
---|
288 | |
---|
289 | # # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
290 | # echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" |
---|
291 | # echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}" >> $outfile |
---|
292 | # |
---|
293 | # echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l >> $outfile |
---|
294 | # ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l >> $outfile 2>&1 |
---|
295 | # # Test if compiling finished |
---|
296 | # if [[ $? != 0 ]] ; then |
---|
297 | # echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
298 | # exit |
---|
299 | # fi |
---|
300 | # |
---|
301 | # Find executable suffix |
---|
302 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
303 | suffix=_${resol_atm_3d}_phylmd_seq_orch_inca |
---|
304 | else |
---|
305 | suffix=_${resol_atm_3d}_phylmd_para_mem_orch_inca |
---|
306 | fi |
---|
307 | echo suffix = $suffix |
---|
308 | |
---|
309 | # Move executables to modipsl/bin folder |
---|
310 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
311 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then |
---|
312 | mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ; |
---|
313 | |
---|
314 | else |
---|
315 | echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP" |
---|
316 | exit |
---|
317 | |
---|
318 | fi |
---|
319 | # if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm_3d}_${optmode}_${optchimie}.e ; fi |
---|
320 | |
---|
321 | fi |
---|
322 | |
---|
323 | |
---|
324 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
325 | echo; echo "ALL COMPILING FINISHED" |
---|
326 | |
---|
327 | if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then |
---|
328 | echo; echo "====================================================" |
---|
329 | echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" |
---|
330 | echo; echo "Optmode="$optmode |
---|
331 | echo; echo "====================================================" |
---|
332 | fi |
---|
333 | |
---|
334 | date |
---|
335 | exit |
---|
336 | |
---|
337 | |
---|