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