source: XIOS/dev/XIOS_DEV_CMIP6/make_xios @ 1450

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

Adding back light memory tracking to trunk and adding it to dev_cmip6.

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