source: XIOS/dev/XIOS_DEV_CMIP6/make_xios @ 1458

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

Few corrections related to compilation options --use_extern_boost and --use_extern_blitz.

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