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 | # Atmospheric resolution, for LMDZ/ORCHIDEE in regular mode |
---|
16 | resol_atm=144x142x79 |
---|
17 | # Oceanic resolution, for NEMO (ORCA2/ORCA1/ORCA025) |
---|
18 | resol_oce=ORCA1 |
---|
19 | # Version of ice model lim2/lim3 |
---|
20 | version_lim=lim3 |
---|
21 | # Version ESM CO2: CO2 interactif ocean/atmosphere (y/n) |
---|
22 | esmco2=n |
---|
23 | |
---|
24 | # Optimization mode |
---|
25 | # optmode=prod/dev/debug |
---|
26 | optmode=prod |
---|
27 | # fcm_arch |
---|
28 | fcm_arch=default |
---|
29 | # Default values to be overritten |
---|
30 | parallel=mpi_omp |
---|
31 | export fcm_arch parallel xios |
---|
32 | full_flag="" |
---|
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 | outfile=$submitdir/out_compile_ipslcm6 |
---|
38 | rm -f $outfile; echo > $outfile |
---|
39 | echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo |
---|
40 | |
---|
41 | #### Read arguments |
---|
42 | # Loop over all arguments to modify default set up |
---|
43 | while (($# > 0)) ; do |
---|
44 | case $1 in |
---|
45 | "-h") cat <<fin |
---|
46 | |
---|
47 | ######################################################################## |
---|
48 | # Usage of the script compile_ipslcm6.sh |
---|
49 | # |
---|
50 | ######################################################################## |
---|
51 | |
---|
52 | ./compile_ipslcm6.sh [Options] |
---|
53 | |
---|
54 | |
---|
55 | Options: [LR / VLR / MR025] Model resolution, choose only one. Default: LR. |
---|
56 | [ESMCO2] Compile IPSLCM6 for CO2 interactif ocean/atmosphere. |
---|
57 | [-full] Full recompilation of all components. This option can be added to all other options. |
---|
58 | [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod. |
---|
59 | |
---|
60 | |
---|
61 | Example 1: Default compilation of IPSLCM6 for resoltion LR |
---|
62 | (Resolution atmos: 144x142x79, ocean: ORCA1) |
---|
63 | ./compile_ipslcm6.sh |
---|
64 | |
---|
65 | Example 2: Compilation of IPSLCM6 for resolution MR025 |
---|
66 | (atmos: 256x256x79, ocean: ORCA025, NOPISCES) |
---|
67 | ./compile_ipslcm6.sh MR025 |
---|
68 | |
---|
69 | Example 3: Compilation of IPSLCM6 for ESM CO2 |
---|
70 | ./compile_ipslcm6.sh ESMCO2 |
---|
71 | |
---|
72 | Example 4: Default resoltuion (LR) compiled in debug mode |
---|
73 | ./compile_ipslcm6.sh -debug |
---|
74 | |
---|
75 | Example 5: Default compilation with full recompilation of all components. No clean is needed. |
---|
76 | ./compile_ipslcm6.sh -full |
---|
77 | |
---|
78 | Example 6: Full recompilation of resolution MR05 in debug mode |
---|
79 | ./compile_ipslcm6.sh MR025 -debug -full |
---|
80 | |
---|
81 | fin |
---|
82 | exit;; |
---|
83 | |
---|
84 | "VLR") |
---|
85 | resol_atm=96x95x39; resol_oce=ORCA1 ; version_lim=lim2; shift ;; |
---|
86 | |
---|
87 | "LR") |
---|
88 | resol_atm=144x142x79; resol_oce=ORCA1 ; version_lim=lim3; shift ;; |
---|
89 | |
---|
90 | "MR025") |
---|
91 | resol_atm=256x256x79; resol_oce=ORCA025 ; version_lim=lim3; shift ;; |
---|
92 | |
---|
93 | "ESMCO2") |
---|
94 | esmco2=y; shift ;; |
---|
95 | |
---|
96 | "-parallel") |
---|
97 | parallel=$2 ; shift ; shift ;; |
---|
98 | |
---|
99 | "-arch") |
---|
100 | fcm_arch="$2" ; shift ; shift ;; |
---|
101 | |
---|
102 | "-debug") |
---|
103 | optmode=debug ; shift ;; |
---|
104 | |
---|
105 | "-dev") |
---|
106 | optmode=dev ; shift ;; |
---|
107 | |
---|
108 | "-prod") |
---|
109 | optmode=prod ; shift ;; |
---|
110 | |
---|
111 | "-full") |
---|
112 | full_flag="-full"; shift ;; |
---|
113 | |
---|
114 | "-netcdf_lib_seq") |
---|
115 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
116 | |
---|
117 | *) |
---|
118 | echo "unknown option "$2" , exiting..." |
---|
119 | exit |
---|
120 | esac |
---|
121 | done |
---|
122 | |
---|
123 | echo "Following options are set in current compiling:" >> $outfile |
---|
124 | echo " resol_atm=${resol_atm}, resol_oce=${resol_oce}, $version_lim=${version_lim}" >> $outfile |
---|
125 | echo " esmco2=${esmco2}" >> $outfile |
---|
126 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag" >> $outfile |
---|
127 | echo >> $outfile |
---|
128 | |
---|
129 | ### Read host dependent default values |
---|
130 | ### These variables will not be changed if they were set as argument |
---|
131 | ###./host.sh $host |
---|
132 | # Later : Following lines should be set in host.sh file |
---|
133 | # begin host.sh |
---|
134 | if [ $fcm_arch == default ] ; then |
---|
135 | # Find out current host and source specific paths and commands for the host |
---|
136 | case $( hostname -s ) in |
---|
137 | ada*) |
---|
138 | fcm_arch=X64_ADA;; |
---|
139 | irene*) |
---|
140 | fcm_arch=X64_IRENE;; |
---|
141 | asterix*|obelix*) |
---|
142 | fcm_arch=ifort_LSCE;; |
---|
143 | ciclad*|climserv*) |
---|
144 | fcm_arch=ifort_CICLAD;; |
---|
145 | *) |
---|
146 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
147 | echo Exit now. |
---|
148 | exit |
---|
149 | esac |
---|
150 | fi |
---|
151 | |
---|
152 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
153 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
154 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
155 | echo >> $outfile |
---|
156 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components" |
---|
157 | echo "Note that this new environement might be kept after compilation." |
---|
158 | echo "If this is the case, source again your personal environment after compilation. " |
---|
159 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
160 | module list >> $outfile 2>&1 |
---|
161 | |
---|
162 | # Make a link to this file, to be used also in config.card |
---|
163 | rm -f ARCH/arch.env |
---|
164 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
165 | |
---|
166 | # Source the file |
---|
167 | source ARCH/arch.env >> $outfile 2>&1 |
---|
168 | echo >> $outfile |
---|
169 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
170 | module list >> $outfile 2>&1 |
---|
171 | fi |
---|
172 | |
---|
173 | #### 2 Do the compilation |
---|
174 | ## 2.1 Compile ioipsl |
---|
175 | cd $modipsl/modeles/IOIPSL |
---|
176 | echo; echo "NOW COMPILE IOIPSL" |
---|
177 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
178 | |
---|
179 | # Check if compilation with fcm is included in IOIPSL |
---|
180 | if [ ! -f makeioipsl_fcm ] ; then |
---|
181 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
182 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
183 | exit |
---|
184 | fi |
---|
185 | |
---|
186 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
187 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
188 | # Test if compiling succeded |
---|
189 | if [[ $? != 0 ]] ; then |
---|
190 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
191 | exit |
---|
192 | fi |
---|
193 | |
---|
194 | ## 2.2 Compile xios |
---|
195 | cd $modipsl/modeles/XIOS |
---|
196 | echo; echo "NOW COMPILE XIOS" |
---|
197 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
198 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
199 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
200 | # Test if compiling succeded |
---|
201 | if [[ $? != 0 ]] ; then |
---|
202 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
203 | exit |
---|
204 | fi |
---|
205 | # Move executables to modipsl/bin |
---|
206 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
207 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
208 | else |
---|
209 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
210 | exit |
---|
211 | fi |
---|
212 | |
---|
213 | |
---|
214 | ## 2.3 Compile orchidee |
---|
215 | cd $modipsl/modeles/ORCHIDEE |
---|
216 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
217 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
218 | |
---|
219 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
220 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
221 | # Test if compiling finished |
---|
222 | if [[ $? != 0 ]] ; then |
---|
223 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
224 | exit |
---|
225 | fi |
---|
226 | |
---|
227 | |
---|
228 | ## 2.4 Compile LMDZ for regular latlon configuration |
---|
229 | cd $modipsl/modeles/LMDZ |
---|
230 | # Compile LMDZ regular lat-lon exectuable |
---|
231 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" |
---|
232 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" >> $outfile |
---|
233 | |
---|
234 | 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_flag gcm >> $outfile |
---|
235 | ./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_flag gcm >> $outfile 2>&1 |
---|
236 | # Test if compiling finished |
---|
237 | if [[ $? != 0 ]] ; then |
---|
238 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
239 | exit |
---|
240 | fi |
---|
241 | |
---|
242 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
243 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" |
---|
244 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" >> $outfile |
---|
245 | |
---|
246 | 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_flag ce0l >> $outfile |
---|
247 | ./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_flag ce0l >> $outfile 2>&1 |
---|
248 | # Test if compiling finished |
---|
249 | if [[ $? != 0 ]] ; then |
---|
250 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
251 | exit |
---|
252 | fi |
---|
253 | |
---|
254 | # Find executable suffix |
---|
255 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
256 | suffix=_${resol_atm}_phylmd_seq_orch |
---|
257 | else |
---|
258 | suffix=_${resol_atm}_phylmd_para_mem_orch |
---|
259 | fi |
---|
260 | echo suffix = $suffix |
---|
261 | |
---|
262 | # Move executables to modipsl/bin folder |
---|
263 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
264 | if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm}_${optmode}.e ; fi |
---|
265 | if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm}_${optmode}.e ; fi |
---|
266 | |
---|
267 | fi |
---|
268 | |
---|
269 | |
---|
270 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
271 | echo; echo "ALL COMPILING FINISHED" |
---|
272 | |
---|
273 | date |
---|
274 | exit |
---|
275 | |
---|
276 | |
---|