source: XIOS/dev/branch_openmp/make_xios @ 1620

Last change on this file since 1620 was 1157, checked in by yushan, 3 years ago

branch re-merged with trunk @1156

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