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