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 | |
---|
21 | # fcm_arch |
---|
22 | fcm_arch=default |
---|
23 | # Default values to be overritten |
---|
24 | parallel=mpi_omp |
---|
25 | export fcm_arch parallel xios |
---|
26 | full_flag="" |
---|
27 | # Default netcdf_lib is used for XIOS but can be change by argument |
---|
28 | netcdf_lib="" |
---|
29 | |
---|
30 | # Output text file for compilation of each component |
---|
31 | datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` |
---|
32 | outfile=$submitdir/out_compile_lmdzor.$datestr |
---|
33 | echo > $outfile |
---|
34 | echo; echo "Text output from compilation will be stored in file out_compile_lmdzor"; echo |
---|
35 | |
---|
36 | #### Read arguments |
---|
37 | # Loop over all arguments to modify default set up |
---|
38 | while (($# > 0)) ; do |
---|
39 | case $1 in |
---|
40 | "-h") cat <<fin |
---|
41 | |
---|
42 | ######################################################################## |
---|
43 | # Usage of the script compile_lmdzor.sh |
---|
44 | # |
---|
45 | ######################################################################## |
---|
46 | |
---|
47 | ./compile_config [Options] |
---|
48 | |
---|
49 | Options: -full, -resol_atm, -debug, -dev, -prod(default) |
---|
50 | |
---|
51 | Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL |
---|
52 | ./compile_lmdzor.sh |
---|
53 | |
---|
54 | Example 2: Compile in debug mode |
---|
55 | ./compile_lmdzor.sh -debug |
---|
56 | |
---|
57 | Example 3: Default compilation with full recompilation of all components |
---|
58 | ./compile_lmdzor.sh -full |
---|
59 | |
---|
60 | Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79) |
---|
61 | The dimension can be changed to any other 3d dimension. |
---|
62 | ./compile_lmdzor.sh -resol_atm 96x95x79 |
---|
63 | |
---|
64 | fin |
---|
65 | exit;; |
---|
66 | |
---|
67 | "-parallel") |
---|
68 | parallel=$2 ; shift ; shift ;; |
---|
69 | |
---|
70 | "-arch") |
---|
71 | fcm_arch="$2" ; shift ; shift ;; |
---|
72 | |
---|
73 | "-xios") |
---|
74 | xios="$2" ; shift ; shift ;; |
---|
75 | |
---|
76 | "-debug") |
---|
77 | optmode=debug ; shift ;; |
---|
78 | |
---|
79 | "-dev") |
---|
80 | optmode=dev ; shift ;; |
---|
81 | |
---|
82 | "-prod") |
---|
83 | optmode=prod ; shift ;; |
---|
84 | |
---|
85 | "-resol_atm") |
---|
86 | resol_atm=$2 ; shift ; shift ;; |
---|
87 | |
---|
88 | "-full") |
---|
89 | full_flag="-full"; shift ;; |
---|
90 | |
---|
91 | "-netcdf_lib_seq") |
---|
92 | netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;; |
---|
93 | |
---|
94 | *) |
---|
95 | echo "unknown option "$2" , exiting..." |
---|
96 | exit |
---|
97 | esac |
---|
98 | done |
---|
99 | |
---|
100 | echo "Following arguments are set in current compiling:" >> $outfile |
---|
101 | echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag resol_atm=${resol_atm}" >> $outfile |
---|
102 | echo >> $outfile |
---|
103 | |
---|
104 | ### Read host dependent default values |
---|
105 | ### These variables will not be changed if they were set as argument |
---|
106 | ###./host.sh $host |
---|
107 | # Later : Following lines should be set in host.sh file |
---|
108 | # begin host.sh |
---|
109 | if [ $fcm_arch == default ] ; then |
---|
110 | # Find out current host and source specific paths and commands for the host |
---|
111 | case $( hostname -s ) in |
---|
112 | ada*) |
---|
113 | fcm_arch=X64_ADA;; |
---|
114 | irene*) |
---|
115 | fcm_arch=X64_IRENE;; |
---|
116 | asterix*|obelix*) |
---|
117 | fcm_arch=ifort_LSCE;; |
---|
118 | ciclad*|climserv*) |
---|
119 | fcm_arch=ifort_CICLAD;; |
---|
120 | *) |
---|
121 | echo Current host is not known. You must use option -arch to specify which architecuture files to use. |
---|
122 | echo Exit now. |
---|
123 | exit |
---|
124 | esac |
---|
125 | fi |
---|
126 | |
---|
127 | # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. |
---|
128 | # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. |
---|
129 | if [ -f ARCH/arch-${fcm_arch}.env ] ; then |
---|
130 | echo >> $outfile |
---|
131 | echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components" |
---|
132 | echo "Note that this new environement might be kept after compilation." |
---|
133 | echo "If this is the case, source again your personal environment after compilation. " |
---|
134 | echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile |
---|
135 | module list >> $outfile 2>&1 |
---|
136 | |
---|
137 | # Make a link to this file, to be used also in config.card |
---|
138 | rm -f ARCH/arch.env |
---|
139 | ln -s arch-${fcm_arch}.env ARCH/arch.env |
---|
140 | |
---|
141 | # Source the file |
---|
142 | source ARCH/arch.env >> $outfile 2>&1 |
---|
143 | echo >> $outfile |
---|
144 | echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile |
---|
145 | module list >> $outfile 2>&1 |
---|
146 | fi |
---|
147 | |
---|
148 | #### 2 Do the compilation |
---|
149 | ## 2.1 Compile ioipsl |
---|
150 | cd $modipsl/modeles/IOIPSL |
---|
151 | echo; echo "NOW COMPILE IOIPSL" |
---|
152 | echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile |
---|
153 | |
---|
154 | # Check if compilation with fcm is included in IOIPSL |
---|
155 | if [ ! -f makeioipsl_fcm ] ; then |
---|
156 | echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." |
---|
157 | echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." |
---|
158 | exit |
---|
159 | fi |
---|
160 | |
---|
161 | echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile |
---|
162 | ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 |
---|
163 | # Test if compiling succeded |
---|
164 | if [[ $? != 0 ]] ; then |
---|
165 | echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" |
---|
166 | exit |
---|
167 | fi |
---|
168 | |
---|
169 | ## 2.2 Compile xios |
---|
170 | cd $modipsl/modeles/XIOS |
---|
171 | echo; echo "NOW COMPILE XIOS" |
---|
172 | echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile |
---|
173 | echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile |
---|
174 | ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $outfile 2>&1 |
---|
175 | # Test if compiling succeded |
---|
176 | if [[ $? != 0 ]] ; then |
---|
177 | echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" |
---|
178 | exit |
---|
179 | fi |
---|
180 | # Move executables to modipsl/bin |
---|
181 | if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then |
---|
182 | mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe |
---|
183 | else |
---|
184 | echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" |
---|
185 | exit |
---|
186 | fi |
---|
187 | |
---|
188 | |
---|
189 | ## 2.3 Compile orchidee |
---|
190 | cd $modipsl/modeles/ORCHIDEE |
---|
191 | echo; echo "NOW COMPILE ORCHIDEE" |
---|
192 | echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile |
---|
193 | |
---|
194 | echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile |
---|
195 | ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 |
---|
196 | # Test if compiling finished |
---|
197 | if [[ $? != 0 ]] ; then |
---|
198 | echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" |
---|
199 | exit |
---|
200 | fi |
---|
201 | |
---|
202 | |
---|
203 | ## 2.4 Compile LMDZ for regular latlon configuration |
---|
204 | cd $modipsl/modeles/LMDZ |
---|
205 | # Compile LMDZ regular lat-lon exectuable |
---|
206 | echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" |
---|
207 | echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" >> $outfile |
---|
208 | |
---|
209 | # Check if the compilation of LMDZ was previsouly interupted prematured. |
---|
210 | # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm |
---|
211 | # to ask question and wait for interactivly answer from the user. |
---|
212 | if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then |
---|
213 | echo >> $outfile |
---|
214 | echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. " >> $outfile |
---|
215 | echo " This means that the compilation is either currently on going in another terminal was previous interupted before the end." >> $outfile |
---|
216 | echo " The files dimension.h and .lock will now be removed. " >> $outfile |
---|
217 | echo >> $outfile |
---|
218 | rm -f libf/grid/dimensions.h |
---|
219 | rm -f .lock |
---|
220 | fi |
---|
221 | |
---|
222 | 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 |
---|
223 | ./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 |
---|
224 | # Test if compiling finished |
---|
225 | if [[ $? != 0 ]] ; then |
---|
226 | echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" |
---|
227 | exit |
---|
228 | fi |
---|
229 | |
---|
230 | # Compile ce0l initialization program for LMDZ regular lat-lon exectuable |
---|
231 | echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" |
---|
232 | echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. 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 ce0l >> $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 ce0l >> $outfile 2>&1 |
---|
236 | # Test if compiling finished |
---|
237 | if [[ $? != 0 ]] ; then |
---|
238 | echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" |
---|
239 | exit |
---|
240 | fi |
---|
241 | |
---|
242 | # Find executable suffix |
---|
243 | if [ $parallel == seq ] || [ $parallel == none ] ; then |
---|
244 | suffix=_${resol_atm}_phylmd_seq_orch |
---|
245 | else |
---|
246 | suffix=_${resol_atm}_phylmd_para_mem_orch |
---|
247 | fi |
---|
248 | echo suffix = $suffix |
---|
249 | |
---|
250 | # Move executables to modipsl/bin folder |
---|
251 | echo "Move gcm.e and ce0l executable to modipsl/bin" |
---|
252 | 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 |
---|
253 | 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 |
---|
254 | |
---|
255 | |
---|
256 | echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile |
---|
257 | echo; echo "ALL COMPILING FINISHED" |
---|
258 | |
---|
259 | date |
---|
260 | exit |
---|
261 | |
---|
262 | |
---|