source: XIOS/trunk/make_xios @ 1452

Last change on this file since 1452 was 1452, checked in by oabramkina, 3 years ago

Trunk: adding a compilation option '--use_extern_blitz' to allow usage of external blitz.

  • Property svn:executable set to *
File size: 7.9 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        gunzip -f "$tarname"
67        tar -xf ${tarname%.gz}
68    done
69fi
70
71# Vérification de la présence d'un identifiant d'architecture.
72
73###############################################################
74# lecture des chemins propres a l'architecture de la machine #
75#           et configuration de l'environnement              #
76###############################################################
77
78rm -f .void_file
79echo > .void_file
80rm -rf .void_dir
81mkdir .void_dir
82
83if [[ "$arch_defined" == "TRUE" ]]
84then
85  rm -f arch.path
86  rm -f arch.fcm
87  rm -f arch.env
88
89  if test -f $arch_path/arch-${arch}.path
90  then
91    ln -s $arch_path/arch-${arch}.path arch.path
92  elif test -f $arch_default_path/arch-${arch}.path
93  then
94    ln -s $arch_default_path/arch-${arch}.path arch.path
95  fi
96       
97  if test -f $arch_path/arch-${arch}.fcm
98  then
99    ln -s $arch_path/arch-${arch}.fcm arch.fcm
100  elif test -f $arch_default_path/arch-${arch}.fcm
101  then
102    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
103  fi
104
105  if test -f $arch_path/arch-${arch}.env
106  then
107    ln -s $arch_path/arch-${arch}.env arch.env
108  elif test -f $arch_default_path/arch-${arch}.env
109  then
110    ln -s $arch_default_path/arch-${arch}.env arch.env
111  else
112    ln -s .void_file arch.env
113  fi
114  source arch.env
115  source arch.path
116else
117      echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!"
118      exit 1
119fi
120
121# Vérification de la présence d'un mode de compilation.
122
123if [[ "$compil_mode" == "prod" ]]
124   then
125      COMPIL_CFLAGS="%PROD_CFLAGS"
126      COMPIL_FFLAGS="%PROD_FFLAGS"
127elif [[ "$compil_mode" == "dev" ]]
128   then
129      COMPIL_CFLAGS="%DEV_CFLAGS"
130      COMPIL_FFLAGS="%DEV_FFLAGS"
131elif [[ "$compil_mode" == "debug" ]]
132   then
133      COMPIL_CFLAGS="%DEBUG_CFLAGS"
134      COMPIL_FFLAGS="%DEBUG_FFLAGS"
135fi
136
137rm -r $PWD/extern/netcdf4
138
139if [[ "$netcdf_lib" == "netcdf4_par" ]]
140   then
141     ln -s $PWD/.void_dir $PWD/extern/netcdf4
142     XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR"
143elif [[ "$netcdf_lib" == "netcdf4_seq" ]]
144  then
145    ln -s $PWD/.void_dir $PWD/extern/netcdf4
146elif [[ "$netcdf_lib" == "netcdf4_internal" ]]
147  then
148    ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4
149    XIOS_CPPKEY="$XIOS_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL"
150    export NETCDF_INCDIR="-I${PWD}/extern/netcdf4"
151    export NETCDF_LIBDIR=""
152    export NETCDF_LIB=""
153else
154   echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'"
155   exit
156fi
157
158if [[ "$use_oasis" == "true" ]]
159   then
160    if [[ "$oasis" == "oasis3_mct" ]]
161    then
162        XIOS_CPPKEY="$XIOS_CPPKEY USE_OMCT"
163    elif [[ "$oasis" == "oasis3"  ]]
164    then
165        XIOS_CPPKEY="$XIOS_CPPKEY USE_OASIS"
166        OASIS_INCDIR="-I$PWD/../../prism/X64/build/lib/psmile.MPI1"
167        OASIS_LIBDIR="-L$PWD/../../prism/X64/lib"
168        OASIS_LIB="-lpsmile.MPI1 -lmpp_io"
169    else
170        echo "Bad choice for --use_oasis argument : choose between 'oasis3','oasis3_mct'"
171        exit
172    fi
173    NETCDF_LIB="-lnetcdff -lnetcdf"
174    XIOS_FINCDIR="$OASIS_INCDIR $XIOS_FINCDIR"
175    XIOS_LIB="$OASIS_LIBDIR $OASIS_LIB $XIOS_LIB"
176fi 
177
178# Setting path for boost
179if [[ "$use_extern_boost" == "true" ]]
180then
181   ln -s $PWD/.void_dir $PWD/extern/boost
182else
183   export BOOST_INCDIR="-I${PWD}/extern/boost"
184   export BOOST_LIBDIR=""
185   export BOOST_LIB=""
186fi
187
188# Setting path for blitz
189if [[ "$use_extern_blitz" == "true" ]]
190then
191   ln -s $PWD/.void_dir $PWD/extern/blitz
192else
193   export BLITZ_INCDIR="-I${PWD}/extern/blitz"
194   export BLITZ_LIBDIR=""
195   export BLITZ_LIB=""
196fi
197
198
199if [[ "$use_memtrack" == "true" ]]
200   then
201   XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK"
202
203    if [[ "$memtrack" == "light" ]]
204    then
205        XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_LIGHT"
206    elif [[ "$memtrack" == "FULL"  ]]
207    then
208      XIOS_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XIOS_LIB"
209      XIOS_CPPKEY="$XIOS_CPPKEY XIOS_MEMTRACK_FULL"
210    else
211        echo "Bad choice for --memtrack argument : choose between 'light','full'"
212        exit
213    fi
214fi
215
216XIOS_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
217XIOS_FINCDIR="$NETCDF_INCDIR $XIOS_FINCDIR $MPI_INCDIR $BOOST_INCDIR $BLITZ_INCDIR"
218
219XIOS_LIB="$XIOS_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB"
220
221rm -f config.fcm
222echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> config.fcm
223echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
224echo "%CPP_KEY       $XIOS_CPPKEY"   >> config.fcm
225
226echo "%CBASE_INC     $XIOS_CINCDIR" >> config.fcm     
227echo "%FBASE_INC     $XIOS_FINCDIR" >> config.fcm
228echo "%ARCH_LD       $XIOS_LIB"     >> config.fcm
229
230echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !"
231
232# Création de la documentation doxygen.
233if [[ !(-z $doc) ]]
234   then
235      echo -e "- Create Doxygen documentation (disabled)..."
236      #doxygen -s
237fi
238
239make_dir=$PWD
240
241export PATH=$PWD/tools/FCM/bin:$PATH
242
243if [[ "$compil_full" == "true" ]]
244   then
245   fcm build --clean --ignore-lock
246   fcm build -f --ignore-lock -j $job
247else
248  fcm build --ignore-lock -j $job
249fi
250
251build_exit_status=$?
252
253if [[ $build_exit_status == 0 ]]
254  then
255  set nothing
256#    cd $WORKDIR/XIOS_NEMO_COUPLE/modeles/NEMO/WORK
257#    cd $WORKDIR/XIOS_NEMO/modeles/NEMO/WORK
258#    make
259fi
260
261exit $build_exit_status
Note: See TracBrowser for help on using the repository browser.