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