source: XIOS/dev/dev_trunk_omp/make_xios @ 1730

Last change on this file since 1730 was 1665, checked in by yushan, 5 years ago

MARK: branch merged with trunk @1660. Add option --omp to enable multithreading.

  • Property svn:executable set to *
File size: 10.3 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"
20use_ep="FALSE"
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] : tracking memory leak - developper only"
45            echo "       [--omp] : enable multithread XIOS using mpi_endpoint (EP) : default no EP"
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         "--omp")   use_ep="true" ; 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
158
159
160# Vérification de la présence d'un mode de compilation.
161
162if [[ "$use_ep" == "true" ]]; then
163
164if [[ "$compil_mode" == "prod" ]]
165   then
166      COMPIL_CFLAGS="%PROD_CFLAGS -D_usingEP -D_intelmpi"
167      COMPIL_FFLAGS="%PROD_FFLAGS -D_usingEP -D_intelmpi"
168elif [[ "$compil_mode" == "dev" ]]
169   then
170      COMPIL_CFLAGS="%DEV_CFLAGS -D_usingEP -D_intelmpi"
171      COMPIL_FFLAGS="%DEV_FFLAGS -D_usingEP -D_intelmpi"
172elif [[ "$compil_mode" == "debug" ]]
173   then
174      COMPIL_CFLAGS="%DEBUG_CFLAGS -D_usingEP -D_intelmpi"
175      COMPIL_FFLAGS="%DEBUG_FFLAGS -D_usingEP -D_intelmpi"
176fi
177
178else
179
180if [[ "$compil_mode" == "prod" ]]
181   then
182      COMPIL_CFLAGS="%PROD_CFLAGS"
183      COMPIL_FFLAGS="%PROD_FFLAGS"
184elif [[ "$compil_mode" == "dev" ]]
185   then
186      COMPIL_CFLAGS="%DEV_CFLAGS"
187      COMPIL_FFLAGS="%DEV_FFLAGS"
188elif [[ "$compil_mode" == "debug" ]]
189   then
190      COMPIL_CFLAGS="%DEBUG_CFLAGS"
191      COMPIL_FFLAGS="%DEBUG_FFLAGS"
192fi
193
194fi
195rm -r $PWD/extern/netcdf4
196
197if [[ "$netcdf_lib" == "netcdf4_par" ]]
198   then
199     ln -s $PWD/.void_dir $PWD/extern/netcdf4
200     XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR"
201elif [[ "$netcdf_lib" == "netcdf4_seq" ]]
202  then
203    ln -s $PWD/.void_dir $PWD/extern/netcdf4
204elif [[ "$netcdf_lib" == "netcdf4_internal" ]]
205  then
206    ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4
207    XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL"
208    export NETCDF_INCDIR="-I${PWD}/extern/netcdf4"
209    export NETCDF_LIBDIR=""
210    export NETCDF_LIB=""
211else
212   echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'"
213   exit
214fi
215
216if [[ "$use_oasis" == "true" ]]
217   then
218    if [[ "$oasis" == "oasis3_mct" ]]
219    then
220        XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT"
221    elif [[ "$oasis" == "oasis3"  ]]
222    then
223        XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS"
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"
232    XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR"
233    XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB"
234fi 
235
236# Setting path for boost
237if [[ "$use_extern_boost" == "true" ]]
238then
239   rm -r $PWD/extern/boost
240   ln -s $PWD/.void_dir $PWD/extern/boost
241else
242   export BOOST_INCDIR="-I${PWD}/extern/boost"
243   export BOOST_LIBDIR=""
244   export BOOST_LIB=""
245fi
246
247# Setting path for blitz
248if [[ "$use_extern_blitz" == "true" ]]
249then
250   rm -r $PWD/extern/blitz
251   ln -s $PWD/.void_dir $PWD/extern/blitz
252else
253   echo "src::blitz $PWD/extern/blitz/src" >> ${PWD}/bld_dir.cfg
254   export BLITZ_INCDIR="-I${PWD}/extern/blitz"
255   export BLITZ_LIBDIR=""
256   export BLITZ_LIB=""
257fi
258
259
260if [[ "$use_memtrack" == "true" ]]
261   then
262   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK"
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
275fi
276
277XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
278XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
279
280XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB"
281
282rm -f ${install_dir}/config.fcm
283echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> ${install_dir}/config.fcm
284echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> ${install_dir}/config.fcm
285echo "%CPP_KEY       $XIOS_CPPKEY"   >> ${install_dir}/config.fcm
286
287echo "%CBASE_INC     $XIOS_CINCDIR" >> ${install_dir}/config.fcm     
288echo "%FBASE_INC     $XIOS_FINCDIR" >> ${install_dir}/config.fcm
289echo "%ARCH_LD       $XIOS_LIB"     >> ${install_dir}/config.fcm
290
291echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !"
292
293# Création de la documentation doxygen.
294if [[ !(-z $doc) ]]
295   then
296      echo -e "- Create Doxygen documentation (disabled)..."
297      #doxygen -s
298fi
299
300make_dir=$PWD
301
302export PATH=$PWD/tools/FCM/bin:$PATH
303
304if [[ "$compil_full" == "true" ]]
305   then
306   fcm build --clean --ignore-lock
307   fcm build -f --ignore-lock -j $job
308else
309  fcm build --ignore-lock -j $job
310fi
311
312build_exit_status=$?
313
314if [[ $build_exit_status == 0 ]]
315  then
316  set nothing
317#    cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK
318#    cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK
319#    make
320fi
321
322exit $build_exit_status
Note: See TracBrowser for help on using the repository browser.