source: XIOS3/trunk/make_xios

Last change on this file was 2629, checked in by jderouillat, 2 months ago

Delete boost dependencies, the few features used are replaced by functions stored in extern/boost_extraction

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