source: XIOS3/branches/xios-3.0-beta/make_xios @ 2524

Last change on this file since 2524 was 2213, checked in by ymipsl, 3 years ago

Memory tracking

  • no private (and unofficial) extra library no longer needed
  • change option for better coherence

--memtrack FULL
by
-- memtrack full

YM

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