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