source: XIOS/dev/XIOS_DEV_CMIP6/make_xios @ 1497

Last change on this file since 1497 was 1497, checked in by oabramkina, 4 years ago

Adding the following compilation options in order to separate the build and the source directories:

--build_path : path to the build directory
--build_dir : name of the build directory
--build_suffixed : generate automatically suffixed name of the build directory.

By default the root directory of the build and the source is the same.
If both options, build_dir and build_suffixed, are specified, the suffixed name will be used.

For example, if XIOS is compiled with the following command:
./make_xios --arch GCC_LINUX --prod --build_path ~/toto --build_indexed

the build directory will be:

~/toto/config_GCC_LINUX_prod

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