source: XIOS/trunk/make_xios @ 1448

Last change on this file since 1448 was 1448, checked in by oabramkina, 6 years ago

Trunk: adding a compilation option '--use_extern_boost' to allow usage of external boost.

  • Property svn:executable set to *
File size: 6.7 KB
Line 
1#!/bin/bash
2
3install_dir=$PWD
4compil_full="false"
5use_oasis="false"
6oasis="oasis3_mct"
7use_extern_boost="false"
8use_memtrack="false"
9job="1"
10netcdf_lib="netcdf4_par"
11compil_mode="prod"
12
13
14# Traitement de la ligne de commande
15while (($# > 0))
16   do
17      case $1 in
18         "-h"|"--help"|"-help")
19            echo "make_xios - installs XIOS on your architecture"
20            echo "make_xios [options]"
21            echo "options :"
22            echo "       [--prod] : compilation in production mode (default)"
23            echo "       [--dev] : compilation in development mode"
24            echo "       [--debug] : compilation in debug mode"
25            echo "       --arch arch : to choose target architecture"
26            echo "       [--avail] : to know available target architectures "
27            echo "       [--full] : to generate dependencies and recompile from scratch"
28            echo "       [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler"
29        echo "       [--use_extern_boost : to use external boost library"
30            echo "       [--doc] : to generate Doxygen documentation (not available yet)"
31            echo "       [--job ntasks] : to use parallel compilation with ntasks"
32            echo "       [--netcdf_lib 'netcdf4_par'/'netcdf4_seq'/'netcdf4_internal' : default netcdf4_par] : choice of netcdf library"
33            echo "       [--memtrack] : tracking memory leak - developper only"
34            echo "Example : ./make_xios --prod --arch PW6_VARGAS"
35            echo "Example : ./make_xios --avail"
36            exit;;
37         "--prod")  compil_mode="prod"  ; shift ;;
38         "--dev")   compil_mode="dev"   ; shift ;;
39         "--debug") compil_mode="debug" ; shift ;;
40         "--arch")  arch=$2     ; shift ; shift ;;
41         "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;;
42         "--full")  compil_full="true"  ; shift ;;
43         "--use_oasis")  use_oasis="true" oasis=$2 ; shift ; shift  ;;
44         "--use_extern_boost")  use_extern_boost="true" ; shift  ;;
45         "--doc")   doc="true"          ; shift ;;
46         "--job")   job=$2              ; shift ; shift ;;
47         "--netcdf_lib")   netcdf_lib=$2 ; shift ; shift ;;
48         "--memtrack")   use_memtrack="true" ; shift ;;
49         *)         code="$1"           ; shift ;;
50      esac
51   done
52
53# Installation des sources
54nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l`
55if [ ${nb_files_gz} -ne 0 ]               
56then
57    echo -e "- uncompress archives ..."         
58    for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do
59        gunzip -f "$tarname"
60        tar -xf ${tarname%.gz}
61    done
62fi
63
64# Vérification de la présence d'un identifiant d'architecture.
65
66###############################################################
67# lecture des chemins propres a l'architecture de la machine #
68#           et configuration de l'environnement              #
69###############################################################
70
71rm -f .void_file
72echo > .void_file
73rm -rf .void_dir
74mkdir .void_dir
75
76if [[ !(-z $arch) ]]
77   then
78      rm -f  $install_dir/arch.path
79      rm -f  $install_dir/arch.fcm
80      rm -f  $install_dir/arch.env
81      ln -s  $install_dir/arch/arch-${arch}.path $install_dir/arch.path
82      ln -s  $install_dir/arch/arch-${arch}.fcm  $install_dir/arch.fcm
83
84      if test -f $install_dir/arch/arch-${arch}.env
85      then
86        ln -s $install_dir/arch/arch-${arch}.env arch.env
87      else
88        ln -s $install_dir/.void_file arch.env
89      fi
90
91      source $install_dir/arch.env
92      source $install_dir/arch.path
93  else
94      echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!"
95      exit 1
96fi
97
98# Vérification de la présence d'un mode de compilation.
99
100if [[ "$compil_mode" == "prod" ]]
101   then
102      COMPIL_CFLAGS="%PROD_CFLAGS"
103      COMPIL_FFLAGS="%PROD_FFLAGS"
104elif [[ "$compil_mode" == "dev" ]]
105   then
106      COMPIL_CFLAGS="%DEV_CFLAGS"
107      COMPIL_FFLAGS="%DEV_FFLAGS"
108elif [[ "$compil_mode" == "debug" ]]
109   then
110      COMPIL_CFLAGS="%DEBUG_CFLAGS"
111      COMPIL_FFLAGS="%DEBUG_FFLAGS"
112fi
113
114rm -r $PWD/extern/netcdf4
115
116if [[ "$netcdf_lib" == "netcdf4_par" ]]
117   then
118     ln -s $PWD/.void_dir $PWD/extern/netcdf4
119     XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR"
120elif [[ "$netcdf_lib" == "netcdf4_seq" ]]
121  then
122    ln -s $PWD/.void_dir $PWD/extern/netcdf4
123elif [[ "$netcdf_lib" == "netcdf4_internal" ]]
124  then
125    ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4
126    XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL"
127    export NETCDF_INCDIR="-I${PWD}/extern/netcdf4"
128    export NETCDF_LIBDIR=""
129    export NETCDF_LIB=""
130else
131   echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'"
132   exit
133fi
134
135if [[ "$use_oasis" == "true" ]]
136   then
137    if [[ "$oasis" == "oasis3_mct" ]]
138    then
139        XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT"
140    elif [[ "$oasis" == "oasis3"  ]]
141    then
142        XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS"
143        OASIS_INCDIR="-I$PWD/../../prism/X64/build/lib/psmile.MPI1"
144        OASIS_LIBDIR="-L$PWD/../../prism/X64/lib"
145        OASIS_LIB="-lpsmile.MPI1 -lmpp_io"
146    else
147        echo "Bad choice for --use_oasis argument : choose between 'oasis3','oasis3_mct'"
148        exit
149    fi
150    NETCDF_LIB="-lnetcdff -lnetcdf"
151    XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR"
152    XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB"
153fi
154
155# Setting path for boost
156if [[ "$use_extern_boost" == "true" ]]
157then
158   ln -s $PWD/.void_dir $PWD/extern/boost
159else
160   ln -s $PWD/extern/boost $PWD/extern/boost
161   export BOOST_INCDIR="-I${PWD}/extern/boost"
162   export BOOST_LIBDIR=""
163   export BOOST_LIB=""
164fi
165
166
167if [[ "$use_memtrack" == "true" ]]
168   then
169   XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB"
170   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK"
171fi
172
173XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR $BOOST_INCDIR"
174XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR $BOOST_INCDIR"
175
176XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB"
177
178rm -f config.fcm
179echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> config.fcm
180echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
181echo "%CPP_KEY       $XIOS_CPPKEY"   >> config.fcm
182
183echo "%CBASE_INC     $XIOS_CINCDIR" >> config.fcm     
184echo "%FBASE_INC     $XIOS_FINCDIR" >> config.fcm
185echo "%ARCH_LD       $XIOS_LIB"     >> config.fcm
186
187echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !"
188
189# Création de la documentation doxygen.
190if [[ !(-z $doc) ]]
191   then
192      echo -e "- Create Doxygen documentation (disabled)..."
193      #doxygen -s
194fi
195
196make_dir=$PWD
197
198export PATH=$PWD/tools/FCM/bin:$PATH
199
200if [[ "$compil_full" == "true" ]]
201   then
202   fcm build --clean --ignore-lock
203   fcm build -f --ignore-lock -j $job
204else
205  fcm build --ignore-lock -j $job
206fi
207
208build_exit_status=$?
209
210if [[ $build_exit_status == 0 ]]
211  then
212  set nothing
213#    cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK
214#    cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK
215#    make
216fi
217
218exit $build_exit_status
Note: See TracBrowser for help on using the repository browser.