1 | #!/bin/bash |
---|
2 | |
---|
3 | install_dir=$PWD |
---|
4 | compil_full="false" |
---|
5 | use_oasis="false" |
---|
6 | oasis="oasis3_mct" |
---|
7 | build_path="./" |
---|
8 | build_dir="./" |
---|
9 | build_suffixed="false" |
---|
10 | use_extern_boost="false" |
---|
11 | use_extern_blitz="false" |
---|
12 | use_memtrack="false" |
---|
13 | job="1" |
---|
14 | netcdf_lib="netcdf4_par" |
---|
15 | compil_mode="prod" |
---|
16 | arch_path=$PWD/"arch" |
---|
17 | arch_default_path=$PWD/"arch" |
---|
18 | arch_defined="FALSE" |
---|
19 | arch_path_defined="FALSE" |
---|
20 | fcm_version=old |
---|
21 | |
---|
22 | # Traitement de la ligne de commande |
---|
23 | while (($# > 0)) |
---|
24 | do |
---|
25 | case $1 in |
---|
26 | "-h"|"--help"|"-help") |
---|
27 | echo "make_xios - installs XIOS on your architecture" |
---|
28 | echo "make_xios [options]" |
---|
29 | echo "options :" |
---|
30 | echo " [--prod] : compilation in production mode (default)" |
---|
31 | echo " [--dev] : compilation in development mode" |
---|
32 | echo " [--debug] : compilation in debug mode" |
---|
33 | echo " --arch arch : to choose target architecture" |
---|
34 | echo " [--avail] : to know available target architectures " |
---|
35 | echo " [--full] : to generate dependencies and recompile from scratch" |
---|
36 | echo " [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler" |
---|
37 | echo " [--build_path : absolute path to the build directory" |
---|
38 | echo " [--build_dir : name of the build directory" |
---|
39 | echo " [--build_suffixed : generate automatically suffixed name of the build directory (e.g. config_X64_CURIE_prod)" |
---|
40 | echo " [--use_extern_boost : to use external boost library" |
---|
41 | echo " [--use_extern_blitz : to use external blitz library" |
---|
42 | echo " [--doc] : to generate Doxygen documentation (not available yet)" |
---|
43 | echo " [--job ntasks] : to use parallel compilation with ntasks" |
---|
44 | echo " [--netcdf_lib 'netcdf4_par'/'netcdf4_seq'/'netcdf4_internal' : default netcdf4_par] : choice of netcdf library" |
---|
45 | echo " [--memtrack] : tracking memory leak - developper only" |
---|
46 | echo " [--fcm] : fcm version compatibility : 'new'/'old'" |
---|
47 | echo "Example : ./make_xios --prod --arch PW6_VARGAS" |
---|
48 | echo "Example : ./make_xios --avail" |
---|
49 | exit;; |
---|
50 | "--prod") compil_mode="prod" ; shift ;; |
---|
51 | "--dev") compil_mode="dev" ; shift ;; |
---|
52 | "--debug") compil_mode="debug" ; shift ;; |
---|
53 | "--arch") arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
54 | "--arch_path") arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
55 | "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;; |
---|
56 | "--full") compil_full="true" ; shift ;; |
---|
57 | "--use_oasis") use_oasis="true" oasis=$2 ; shift ; shift ;; |
---|
58 | "--build_path") build_path=$2 ; shift ; shift ;; |
---|
59 | "--build_dir") build_dir=$2 ; shift ; shift ;; |
---|
60 | "--build_suffixed") build_suffixed="true" ; shift ;; |
---|
61 | "--use_extern_boost") use_extern_boost="true" ; shift ;; |
---|
62 | "--use_extern_blitz") use_extern_blitz="true" ; shift ;; |
---|
63 | "--doc") doc="true" ; shift ;; |
---|
64 | "--job") job=$2 ; shift ; shift ;; |
---|
65 | "--netcdf_lib") netcdf_lib=$2 ; shift ; shift ;; |
---|
66 | "--memtrack") use_memtrack="true" memtrack=$2 ; shift ; shift ;; |
---|
67 | "--fcm") fcm_version=$2 ; shift ; shift ;; |
---|
68 | *) code="$1" ; shift ;; |
---|
69 | esac |
---|
70 | done |
---|
71 | |
---|
72 | # Installation des sources |
---|
73 | nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l` |
---|
74 | if [ ${nb_files_gz} -ne 0 ] |
---|
75 | then |
---|
76 | echo -e "- uncompress archives ..." |
---|
77 | for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do |
---|
78 | if ( [[ ${tarname} == "${install_dir}/tools/archive/boost.tar.gz" ]] && [[ "$use_extern_boost" == "true" ]] ) || ( [[ ${tarname} == "${install_dir}/tools/archive/blitz.tar.gz" ]] && [[ "$use_extern_blitz" == "true" ]] ) |
---|
79 | then |
---|
80 | continue |
---|
81 | fi |
---|
82 | gunzip -f "$tarname" |
---|
83 | tar -xf ${tarname%.gz} |
---|
84 | done |
---|
85 | fi |
---|
86 | |
---|
87 | # Definition of the root directory of the build |
---|
88 | |
---|
89 | if [[ "$build_path" == "./" ]]; then |
---|
90 | install_dir=$PWD |
---|
91 | else |
---|
92 | install_dir=${build_path} |
---|
93 | fi |
---|
94 | |
---|
95 | if [[ "$build_suffixed" == "true" ]]; then |
---|
96 | install_dir="${install_dir}/config_${arch}_${compil_mode}" |
---|
97 | else |
---|
98 | install_dir="${install_dir}/${build_dir}" |
---|
99 | fi |
---|
100 | |
---|
101 | mkdir -p $install_dir |
---|
102 | |
---|
103 | rm -f ${PWD}/bld_dir.cfg |
---|
104 | echo "inc ${install_dir}/arch.fcm" >> ${PWD}/bld_dir.cfg |
---|
105 | echo "inc ${install_dir}/config.fcm" >> ${PWD}/bld_dir.cfg |
---|
106 | echo "dir::root ${install_dir}" >> ${PWD}/bld_dir.cfg |
---|
107 | |
---|
108 | # Vérification de la présence d'un identifiant d'architecture. |
---|
109 | |
---|
110 | ############################################################### |
---|
111 | # lecture des chemins propres a l'architecture de la machine # |
---|
112 | # et configuration de l'environnement # |
---|
113 | ############################################################### |
---|
114 | |
---|
115 | rm -f .void_file |
---|
116 | echo > .void_file |
---|
117 | rm -rf .void_dir |
---|
118 | mkdir .void_dir |
---|
119 | |
---|
120 | if [[ "$arch_defined" == "TRUE" ]] |
---|
121 | then |
---|
122 | rm -f ${install_dir}/arch.path |
---|
123 | rm -f ${install_dir}/arch.fcm |
---|
124 | rm -f ${install_dir}/arch.env |
---|
125 | |
---|
126 | if test -f $arch_path/arch-${arch}.path |
---|
127 | then |
---|
128 | ln -s $arch_path/arch-${arch}.path ${install_dir}/arch.path |
---|
129 | elif test -f $arch_default_path/arch-${arch}.path |
---|
130 | then |
---|
131 | ln -s $arch_default_path/arch-${arch}.path ${install_dir}/arch.path |
---|
132 | fi |
---|
133 | |
---|
134 | if test -f $arch_path/arch-${arch}.fcm |
---|
135 | then |
---|
136 | ln -s $arch_path/arch-${arch}.fcm ${install_dir}/arch.fcm |
---|
137 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
138 | then |
---|
139 | ln -s $arch_default_path/arch-${arch}.fcm ${install_dir}/arch.fcm |
---|
140 | fi |
---|
141 | |
---|
142 | if test -f $arch_path/arch-${arch}.env |
---|
143 | then |
---|
144 | ln -s $arch_path/arch-${arch}.env ${install_dir}/arch.env |
---|
145 | elif test -f $arch_default_path/arch-${arch}.env |
---|
146 | then |
---|
147 | ln -s $arch_default_path/arch-${arch}.env ${install_dir}/arch.env |
---|
148 | else |
---|
149 | ln -s .void_file ${install_dir}/arch.env |
---|
150 | fi |
---|
151 | source ${install_dir}/arch.env |
---|
152 | source ${install_dir}/arch.path |
---|
153 | else |
---|
154 | echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!" |
---|
155 | exit 1 |
---|
156 | fi |
---|
157 | |
---|
158 | # Vérification de la présence d'un mode de compilation. |
---|
159 | |
---|
160 | if [[ "$compil_mode" == "prod" ]] |
---|
161 | then |
---|
162 | COMPIL_CFLAGS="%PROD_CFLAGS" |
---|
163 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
164 | elif [[ "$compil_mode" == "dev" ]] |
---|
165 | then |
---|
166 | COMPIL_CFLAGS="%DEV_CFLAGS" |
---|
167 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
168 | elif [[ "$compil_mode" == "debug" ]] |
---|
169 | then |
---|
170 | COMPIL_CFLAGS="%DEBUG_CFLAGS" |
---|
171 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
172 | fi |
---|
173 | |
---|
174 | rm -r $PWD/extern/netcdf4 |
---|
175 | |
---|
176 | if [[ "$netcdf_lib" == "netcdf4_par" ]] |
---|
177 | then |
---|
178 | ln -s $PWD/.void_dir $PWD/extern/netcdf4 |
---|
179 | XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR" |
---|
180 | elif [[ "$netcdf_lib" == "netcdf4_seq" ]] |
---|
181 | then |
---|
182 | ln -s $PWD/.void_dir $PWD/extern/netcdf4 |
---|
183 | elif [[ "$netcdf_lib" == "netcdf4_internal" ]] |
---|
184 | then |
---|
185 | ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4 |
---|
186 | XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL" |
---|
187 | export NETCDF_INCDIR="-I${PWD}/extern/netcdf4" |
---|
188 | export NETCDF_LIBDIR="" |
---|
189 | export NETCDF_LIB="" |
---|
190 | else |
---|
191 | echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'" |
---|
192 | exit |
---|
193 | fi |
---|
194 | |
---|
195 | if [[ "$use_oasis" == "true" ]] |
---|
196 | then |
---|
197 | if [[ "$oasis" == "oasis3_mct" ]] |
---|
198 | then |
---|
199 | XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT" |
---|
200 | elif [[ "$oasis" == "oasis3" ]] |
---|
201 | then |
---|
202 | XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS" |
---|
203 | OASIS_INCDIR="-I$PWD/../../prism/X64/build/lib/psmile.MPI1" |
---|
204 | OASIS_LIBDIR="-L$PWD/../../prism/X64/lib" |
---|
205 | OASIS_LIB="-lpsmile.MPI1 -lmpp_io" |
---|
206 | else |
---|
207 | echo "Bad choice for --use_oasis argument : choose between 'oasis3','oasis3_mct'" |
---|
208 | exit |
---|
209 | fi |
---|
210 | NETCDF_LIB="-lnetcdff -lnetcdf" |
---|
211 | XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR" |
---|
212 | XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB" |
---|
213 | fi |
---|
214 | |
---|
215 | # Setting path for boost |
---|
216 | if [[ "$use_extern_boost" == "true" ]] |
---|
217 | then |
---|
218 | rm -r $PWD/extern/boost |
---|
219 | ln -s $PWD/.void_dir $PWD/extern/boost |
---|
220 | else |
---|
221 | export BOOST_INCDIR="-I${PWD}/extern/boost" |
---|
222 | export BOOST_LIBDIR="" |
---|
223 | export BOOST_LIB="" |
---|
224 | fi |
---|
225 | |
---|
226 | # Setting path for blitz |
---|
227 | if [[ "$use_extern_blitz" == "true" ]] |
---|
228 | then |
---|
229 | rm -r $PWD/extern/blitz |
---|
230 | ln -s $PWD/.void_dir $PWD/extern/blitz |
---|
231 | else |
---|
232 | echo "src::blitz $PWD/extern/blitz/src" >> ${PWD}/bld_dir.cfg |
---|
233 | export BLITZ_INCDIR="-I${PWD}/extern/blitz" |
---|
234 | export BLITZ_LIBDIR="" |
---|
235 | export BLITZ_LIB="" |
---|
236 | fi |
---|
237 | |
---|
238 | |
---|
239 | if [[ "$use_memtrack" == "true" ]] |
---|
240 | then |
---|
241 | XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK" |
---|
242 | |
---|
243 | if [[ "$memtrack" == "light" ]] |
---|
244 | then |
---|
245 | XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_LIGHT" |
---|
246 | elif [[ "$memtrack" == "FULL" ]] |
---|
247 | then |
---|
248 | XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB" |
---|
249 | XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_FULL" |
---|
250 | else |
---|
251 | echo "Bad choice for --memtrack argument : choose between 'light','full'" |
---|
252 | exit |
---|
253 | fi |
---|
254 | fi |
---|
255 | |
---|
256 | XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR" |
---|
257 | XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR" |
---|
258 | |
---|
259 | XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB" |
---|
260 | |
---|
261 | rm -f ${install_dir}/config.fcm |
---|
262 | echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> ${install_dir}/config.fcm |
---|
263 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> ${install_dir}/config.fcm |
---|
264 | echo "%CPP_KEY $XIOS_CPPKEY" >> ${install_dir}/config.fcm |
---|
265 | |
---|
266 | echo "%CBASE_INC $XIOS_CINCDIR" >> ${install_dir}/config.fcm |
---|
267 | echo "%FBASE_INC $XIOS_FINCDIR" >> ${install_dir}/config.fcm |
---|
268 | echo "%ARCH_LD $XIOS_LIB" >> ${install_dir}/config.fcm |
---|
269 | |
---|
270 | echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !" |
---|
271 | |
---|
272 | # Création de la documentation doxygen. |
---|
273 | if [[ !(-z $doc) ]] |
---|
274 | then |
---|
275 | echo -e "- Create Doxygen documentation (disabled)..." |
---|
276 | #doxygen -s |
---|
277 | fi |
---|
278 | |
---|
279 | make_dir=$PWD |
---|
280 | |
---|
281 | if [[ "$fcm_version" == "new" ]] |
---|
282 | then |
---|
283 | export PATH=$PWD/tools/FCM_NEW/bin:$PATH |
---|
284 | elif [[ "$fcm_version" == "old" ]] |
---|
285 | then |
---|
286 | export PATH=$PWD/tools/FCM_OLD/bin:$PATH |
---|
287 | else |
---|
288 | echo "=> Bad option for --fcm flag : "$fcm_version" , only 'new' or 'old' permitted" |
---|
289 | fi |
---|
290 | |
---|
291 | if [[ "$compil_full" == "true" ]] |
---|
292 | then |
---|
293 | fcm build --clean --ignore-lock |
---|
294 | fcm build -f --ignore-lock -j $job |
---|
295 | else |
---|
296 | fcm build --ignore-lock -j $job |
---|
297 | fi |
---|
298 | |
---|
299 | build_exit_status=$? |
---|
300 | |
---|
301 | if [[ $build_exit_status == 0 ]] |
---|
302 | then |
---|
303 | set nothing |
---|
304 | # cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK |
---|
305 | # cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK |
---|
306 | # make |
---|
307 | fi |
---|
308 | |
---|
309 | exit $build_exit_status |
---|