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
Line 
1#!/bin/bash
2install_dir=$PWD
3compil_full="false"
4use_oasis="false"
5oasis="oasis3_mct"
6build_path="./"
7build_dir="./"
8build_suffixed="false"
9use_extern_blitz="false"
10use_memtrack="false"
11job="1"
12netcdf_lib="netcdf4_par"
13compil_mode="prod"
14arch_path=$PWD/"arch"
15arch_default_path=$PWD/"arch"
16arch_defined="FALSE"
17arch_path_defined="FALSE"
18fcm_version=new
19
20# Traitement de la ligne de commande
21while (($# > 0))
22   do
23      case $1 in
24         "-h"|"--help"|"-help")
25            echo "make_xios - installs XIOS on your architecture"
26            echo "make_xios [options]"
27            echo "options :"
28            echo "       [--prod] : compilation in production mode (default)"
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"
34            echo "       [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler"
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"
39            echo "       [--doc] : to generate Doxygen documentation (not available yet)"
40            echo "       [--job ntasks] : to use parallel compilation with ntasks"
41            echo "       [--netcdf_lib 'netcdf4_par'/'netcdf4_seq'/'netcdf4_internal' : default netcdf4_par] : choice of netcdf library"
42            echo "       [--memtrack full/light] : tracking memory leak - developper only"
43            echo "       [--fcm] : fcm version compatibility : 'new'/'old'"
44            echo "Example : ./make_xios --prod --arch PW6_VARGAS"
45            echo "Example : ./make_xios --avail"
46            exit;;
47         "--prod")  compil_mode="prod"  ; shift ;;
48         "--dev")   compil_mode="dev"   ; shift ;;
49         "--debug") compil_mode="debug" ; shift ;;
50         "--arch")  arch=$2     ; arch_defined="TRUE"; shift ; shift ;;
51         "--arch_path")  arch_path=$2     ; arch_path_defined="TRUE"; shift ; shift ;;
52         "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;;
53         "--full")  compil_full="true"  ; shift ;;
54         "--use_oasis")  use_oasis="true" oasis=$2 ; shift ; shift  ;;
55         "--build_path")  build_path=$2     ; shift ; shift ;;
56         "--build_dir")  build_dir=$2     ; shift ; shift ;;
57         "--build_suffixed")  build_suffixed="true" ; shift  ;;
58         "--use_extern_blitz")  use_extern_blitz="true" ; shift  ;;
59         "--doc")   doc="true"          ; shift ;;
60         "--job")   job=$2              ; shift ; shift ;;
61         "--netcdf_lib")   netcdf_lib=$2 ; shift ; shift ;;
62         "--memtrack")  use_memtrack="true" memtrack=$2  ; shift ; shift ;;
63         "--fcm")       fcm_version=$2  ; shift ; shift ;;
64         *)         code="$1"           ; shift ;;
65      esac
66   done
67
68# Installation des sources
69nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l`
70if [ ${nb_files_gz} -ne 0 ]               
71then
72    echo -e "- uncompress archives ..."         
73    for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do
74        if  ( [[ ${tarname} == "${install_dir}/tools/archive/blitz.tar.gz" ]] && [[ "$use_extern_blitz" == "true" ]] )
75        then
76                continue
77        fi
78        gunzip -f "$tarname"
79        tar -xf ${tarname%.gz}
80    done
81fi
82
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
91if [[ "$build_suffixed" == "true" ]]; then
92    install_dir="${install_dir}/config_${arch}_${compil_mode}"
93else
94    install_dir="${install_dir}/${build_dir}"
95fi
96
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
104# Vérification de la présence d'un identifiant d'architecture.
105
106###############################################################
107# lecture des chemins propres a l'architecture de la machine #
108#           et configuration de l'environnement              #
109###############################################################
110
111rm -f .void_file
112echo > .void_file
113rm -rf .void_dir
114mkdir .void_dir
115
116if [[ "$arch_defined" == "TRUE" ]]
117then
118  rm -f ${install_dir}/arch.path
119  rm -f ${install_dir}/arch.fcm
120  rm -f ${install_dir}/arch.env
121
122  if test -f $arch_path/arch-${arch}.path
123  then
124    ln -s $arch_path/arch-${arch}.path ${install_dir}/arch.path
125  elif test -f $arch_default_path/arch-${arch}.path
126  then
127    ln -s $arch_default_path/arch-${arch}.path ${install_dir}/arch.path
128  fi
129       
130  if test -f $arch_path/arch-${arch}.fcm
131  then
132    ln -s $arch_path/arch-${arch}.fcm ${install_dir}/arch.fcm
133  elif test -f $arch_default_path/arch-${arch}.fcm
134  then
135    ln -s $arch_default_path/arch-${arch}.fcm ${install_dir}/arch.fcm
136  fi
137
138  if test -f $arch_path/arch-${arch}.env
139  then
140    ln -s $arch_path/arch-${arch}.env ${install_dir}/arch.env
141  elif test -f $arch_default_path/arch-${arch}.env
142  then
143    ln -s $arch_default_path/arch-${arch}.env ${install_dir}/arch.env
144  else
145    ln -s .void_file ${install_dir}/arch.env
146  fi
147  source ${install_dir}/arch.env
148  source ${install_dir}/arch.path
149else
150      echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!"
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
170rm -r $PWD/extern/netcdf4
171
172if [[ "$netcdf_lib" == "netcdf4_par" ]]
173   then
174     ln -s $PWD/.void_dir $PWD/extern/netcdf4
175     XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR"
176elif [[ "$netcdf_lib" == "netcdf4_seq" ]]
177  then
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
182    XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL"
183    export NETCDF_INCDIR="-I${PWD}/extern/netcdf4"
184    export NETCDF_LIBDIR=""
185    export NETCDF_LIB=""
186else
187   echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'"
188   exit
189fi
190
191if [[ "$use_oasis" == "true" ]]
192   then
193    if [[ "$oasis" == "oasis3_mct" ]]
194    then
195        XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT"
196    elif [[ "$oasis" == "oasis3"  ]]
197    then
198        XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS"
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"
207    XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR"
208    XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB"
209fi 
210
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
256    if [[ ! -z $hdf5_settings_file ]]
257    then
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
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
280# Setting path for boost
281export BOOST_INCDIR="-I${PWD}/extern/boost_extraction/include"
282
283# Setting path for blitz
284if [[ "$use_extern_blitz" == "true" ]]
285then
286   rm -r $PWD/extern/blitz
287   ln -s $PWD/.void_dir $PWD/extern/blitz
288else
289   echo "src::blitz $PWD/extern/blitz/src" >> ${PWD}/bld_dir.cfg
290   export BLITZ_INCDIR="-I${PWD}/extern/blitz"
291   export BLITZ_LIBDIR=""
292   export BLITZ_LIB=""
293fi
294
295
296if [[ "$use_memtrack" == "true" ]]
297   then
298   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK"
299
300    if [[ "$memtrack" == "light" ]]
301    then
302        XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_LIGHT"
303    elif [[ "$memtrack" == "full"  ]]
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
310fi
311
312XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
313XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
314
315XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB"
316
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
321
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
325
326echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !"
327
328# Création de la documentation doxygen.
329if [[ !(-z $doc) ]]
330   then
331      echo -e "- Create Doxygen documentation (disabled)..."
332      #doxygen -s
333fi
334
335make_dir=$PWD
336
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 
347if [[ "$compil_full" == "true" ]]
348   then
349   fcm build --clean --ignore-lock
350   fcm build -f --ignore-lock -j $job
351else
352  fcm build --ignore-lock -j $job
353fi
354
355build_exit_status=$?
356
357if [[ $build_exit_status == 0 ]]
358  then
359  set nothing
360#    cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK
361#    cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK
362#    make
363fi
364
365exit $build_exit_status
Note: See TracBrowser for help on using the repository browser.