Gaelle 2/5/2016 upgrade to MNH-521
[MNH-git_open_source-lfs.git] / src / configure
1 #!/bin/bash
2 #MNH_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
3 #MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
4 #MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt  
5 #MNH_LIC for details. version 1.
6 #set -x
7 #set -e
8 if [ "x$XYZ" = "x" ]
9 then
10
11 export VERSION_MASTER=${VERSION_MASTER:-MNH-V5-2}
12 export VERSION_BUG=${VERSION_BUG:-1}
13 export VERSION_XYZ=${VERSION_XYZ:-${VERSION_MASTER}-${VERSION_BUG}}
14 export VERSION_DATE=${VERSION_DATE:-"04/02/2016"}
15 export VERSION_CDF=${VERSION_CDF:-"4.1.3"}
16 export VERSION_HDF=${VERSION_HDF:-"1.8.9"}
17 export VERSION_GRIBAPI=${VERSION_GRIBAPI:-"1.13.1"}
18 export MNH_INT=${MNH_INT:-"4"}
19 export LFI_INT=${LFI_INT:-8}
20 export MNH_IOCDF4=${MNH_IOCDF4:-1}
21 #
22 export NEED_TOOLS=YES
23 #
24 export LOCAL=${PWD%/src}
25 RACINE=$(basename $LOCAL )
26 #
27 cd ${LOCAL}/conf
28 #
29 TARG=$(uname -s -n)
30 #
31 case "$TARG" in
32 'Linux service'*)
33                 export     ARCH=${ARCH:-LXifort}
34                 export  VER_MPI=${VER_MPI:-MPIICE}
35                 export NEED_NCARG=${NEED_NCARG:-YES}
36                 export MVWORK=${MVWORK:-NO}
37                 domain=$(grep .fr /etc/hosts | head -1 )
38                 case "${domain}" in
39 *cines*) # jade
40                 export OPTLEVEL=${OPTLEVEL:-O2}
41                 export MVWORK=${MVWORK:-NO}
42                 export VER_CDF=${VER_CDF:-CDFICE}
43                 export NEED_NCARG=${NEED_NCARG:-YES}
44                 export MNHENV=${MNHENV:-"
45 module rm netcdf ; module load netcdf/4.0
46 module rm MPT    ; module load MPT/2.02
47 module rm intel  ; module load intel/12.0.13
48 export MPI_DSM_CPULIST=0-7:allhosts
49 "}
50 ;;
51 *cict*)  # hyperion
52                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
53                 export VER_CDF=${VER_CDF:-CDFAUTO}
54                 export MNHENV=${MNHENV:-"
55 . /usr/share/modules/init/bash
56 module purge
57 module load intel-fc-10/10.1.017
58 module load sgi-mpt/1.26
59 export MPI_DSM_CPULIST=0-7:allhosts
60 "}
61               ;;
62                 esac
63               ;;
64 'Linux platine'*|'Linux titane'*|'Linux curie'*)
65                 export     ARCH=${ARCH:-LXifort}
66                 export  VER_MPI=${VER_MPI:-MPIAUTO}
67                 export OPTLEVEL=${OPTLEVEL:-O2}
68                 export MVWORK=${MVWORK:-NO}
69                 export VER_CDF=${VER_CDF:-CDFAUTO}
70               ;;
71 'Linux beaufix'*|'Linux compute'*)
72                 export     ARCH=${ARCH:-LXifort}
73                 export  VER_MPI=${VER_MPI:-MPIINTEL}
74                 export OPTLEVEL=${OPTLEVEL:-O3}
75                 export MVWORK=${MVWORK:-NO}
76                 export VER_CDF=${VER_CDF:-CDFBFIX}
77                 export NEED_TOOLS=NO
78                 export MNHENV=${MNHENV:-"
79 module rm intel    ; module load intel/13.1.4.183 ;
80 module rm intelmpi ; module load intelmpi/4.1.1.036 ;
81 module rm netcdf ; module load netcdf/4.3.0 ;
82 module rm grib_api ; module load grib_api/1.13.0_netcdf ;
83 export GRIBAPI_PATH=/opt/softs/libraries/ICC13.1.4.183/grib_api-1.13.0_netcdf
84 "}
85               ;;
86 'Linux prolix'*)
87                 export     ARCH=${ARCH:-LXifort}
88                 export  VER_MPI=${VER_MPI:-MPIINTEL}
89                 export OPTLEVEL=${OPTLEVEL:-O3}
90                 export MVWORK=${MVWORK:-NO}
91                 export VER_CDF=${VER_CDF:-CDFBFIX}
92                 export MNHENV=${MNHENV:-"
93 module rm intel    ; module load intel/13.1.4.183 ;
94 module rm intelmpi ; module load intelmpi/5.1.2.150 ;
95 module rm netcdf ; module load netcdf/4.3.0 ;
96 module rm grib_api ; module load grib_api/1.13.0_netcdf ;
97 export GRIBAPI_PATH=/opt/softs/libraries/ICC13.1.4.183/grib_api-1.13.0_netcdf
98 "}
99               ;;
100 'Linux login0'*|'Linux compute'*)
101                 export     ARCH=${ARCH:-LXifort}
102                 export  VER_MPI=${VER_MPI:-MPIAUTO}
103                 export OPTLEVEL=${OPTLEVEL:-O3}
104                 export MVWORK=${MVWORK:-NO}
105                 export VER_CDF=${VER_CDF:-CDFBULL}
106                 export MNHENV=${MNHENV:-"
107 module rm intel    ; module load intel/13.0.1.117 ;
108 module rm intelmpi ; module load intelmpi/4.1.0 ;
109 module rm intel-itac ; module load intel-itac/8.0.3
110 "}
111               ;;
112 'Linux brodie'*|'Linux mercure'*)
113                 export     ARCH=${ARCH:-SX8}
114                 export  VER_MPI=${VER_MPI:-MPIAUTO}
115                 export OPTLEVEL=${OPTLEVEL:-O4}
116                 export MVWORK=${MVWORK:-YES}
117                 export VER_CDF=${VER_CDF:-CDFSX}
118                 export MNHENV=${MNHENV:-"
119 module rm sxf90  ; module load sxf90/400 ;
120 module rm sxmpi  ; module load sxmpi/8.0.10 ;
121 module rm netcdf ; module load netcdf/3.6.3
122 "}
123               ;;
124 'Linux babel'*)
125                 export     ARCH=${ARCH:-BGQ}
126                 export  VER_MPI=${VER_MPI:-MPIAUTO}
127                 export OPTLEVEL=${OPTLEVEL:-O2}
128                 export MVWORK=${MVWORK:-YES}
129                 export MNHENV=${MNHENV:-"
130 module load netcdf/3.6.3
131 "}
132                ;;
133 'Linux turing'*)
134                 export     ARCH=${ARCH:-BGQ}
135                 export  VER_MPI=${VER_MPI:-MPIAUTO}
136                 export OPTLEVEL=${OPTLEVEL:-O2NAN}
137                 export MVWORK=${MVWORK:-YES}
138                 export VER_CDF=${VER_CDF:-CDFBGQ}
139                 export MNHENV=${MNHENV:-"
140 source /bglocal/fe/pub/Modules/default/init/bash
141 export MODULEPATH=/bghome/rech/mnh/rmnh007/my_modules:\$MODULEPATH
142 module purge
143 module load ibmcmp/V1R2M2/14.01.0000.0011/gcc.legacy
144 export VER_GA=ga-mpi-5-0-3-v1r2m2-gcc-legacy
145 module load ga/\${VER_GA}
146 "}
147               ;;
148 'Linux ada'*)
149                 export     ARCH=${ARCH:-LXifort}
150                 export  VER_MPI=${VER_MPI:-MPIINTEL}
151                 export OPTLEVEL=${OPTLEVEL:-O2}
152                 export MVWORK=${MVWORK:-YES}
153                 export MNHENV=${MNHENV:-"
154 #export OBJDIR_PATH=$WORKDIR/DIR_OBJ_ADA
155 export MP_MPILIB=pempi
156 module load netcdf/seq/4.1.3
157 "}
158               ;;
159 AIX*)
160                 export MNH_ARCH=`echo $ARCH | grep AIX`
161                 export     ARCH=${MNH_ARCH:-AIX64}
162                 export  VER_MPI=${VER_MPI:-MPIAUTO}
163                 export OPTLEVEL=${OPTLEVEL:-O2}
164                 export MVWORK=${MVWORK:-NO}
165                 export VER_CDF=${VER_CDF:-CDFAIX}
166                 case "$(hostname)" in
167                       vargas*)
168                       export MNHENV=${MNHENV:-"
169 module rm fortran ; module load fortran/13.1.0.7
170 module rm netcdf  ; module load netcdf/3.6.3
171 "}
172                       ;;
173                       c1a*)
174                       export VERSION_GRIBAPI="1.9.9"
175                       export MNHENV=${MNHENV:-"
176 . /usr/local/apps/module/init/sh.in
177 module rm fortran ; module load fortran/xlf/13.1.0.7
178 module rm netcdf  ; module load netcdf/3.6.3
179 export CDF_PATH=/usr/local/apps/netcdf/3.6.3/LP64
180 export GRIBAPI_PATH=/usr/local/lib/metaps/lib/grib_api/${VERSION_GRIBAPI}
181 export LIB_GRIBAPI='${GRIB_API_LIB}'
182 "}
183                       ;;
184                       c2a*)
185                       export VERSION_GRIBAPI="2.0.0"
186                       export MNHENV=${MNHENV:-"
187 . /usr/local/apps/module/init/sh.in
188 module rm fortran ; module load fortran/xlf/13.1.0.9
189 module rm netcdf  ; module load netcdf/3.6.3
190 export CDF_PATH=/usr/local/apps/netcdf/3.6.3/LP64
191 export GRIBAPI_PATH=/usr/local/lib/metaps/lib/grib_api/${VERSION_GRIBAPI}
192 export LIB_GRIBAPI='${GRIB_API_LIB}'
193 "}
194                       ;;
195                  esac
196               ;;
197 'Linux cc'*) # ECMWF Cray plateforme
198                 export MNH_ARCH=`echo $ARCH | grep LX`
199                 export     ARCH=${MNH_ARCH:-LXcray}
200                 export  VER_MPI=${VER_MPI:-MPICRAY}
201                 export OPTLEVEL=${OPTLEVEL:-O2}
202                 export MVWORK=${MVWORK:-NO}
203                 export VER_CDF=${VER_CDF:-CDFAUTO}
204                 if [ "${ARCH}" == "LXcray" ] 
205                 then
206                 export MNHENV=${MNHENV:-"
207 . /opt/modules/default/init/bash
208 module rm grib_api
209 "}
210                 else
211                 if [ "${ARCH}" == "LXifort" ]
212                 then
213                 export MNHENV=${MNHENV:-"
214 . /opt/modules/default/init/bash
215 module switch PrgEnv-cray PrgEnv-intel
216 module rm grib_api
217 "}
218                 fi
219                 fi
220 ;;
221 'Linux sxmnh1') #CNRM ifort sur sxmnh1 (diff mandriva)
222                 export    OMPI_FC=ifort
223                 export       ARCH=${ARCH:-LXifort}
224                 export    VER_MPI=${VER_MPI:-MPIAUTO}
225                 export   OPTLEVEL=${OPTLEVEL:-DEBUG}
226                 export     MVWORK=${MVWORK:-NO}
227                 export    VER_CDF=${VER_CDF:-CDFCTI}
228                 export NEED_NCARG=${NEED_NCARG:-NO}
229                 export NEED_TOOLS=NO
230               ;;
231 'Linux lx'*|'Linux sx'*|'Linux px'*) #CNRM
232                 export MNH_ARCH=`echo $ARCH | grep LX`
233                 export     ARCH=${MNH_ARCH:-LXgfortran}
234                 export  VER_MPI=${VER_MPI:-MPIAUTO}
235                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
236                 export MVWORK=${MVWORK:-NO}
237                 export VER_CDF=${VER_CDF:-CDFCTI}
238                 export NEED_NCARG=${NEED_NCARG:-NO}
239                 export NEED_TOOLS=NO
240               ;;
241 'Linux nuwa'*)
242                 export     ARCH=${ARCH:-LXifort}
243                 export  VER_MPI=${VER_MPI:-MPIAUTO}
244                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
245                 export MVWORK=${MVWORK:-NO}
246                 export VER_CDF=${VER_CDF:-CDFAUTO}
247                 export NEED_NCARG=${NEED_NCARG:-YES}
248                       export MNHENV=${MNHENV:-"
249 . /opt/intel/fce/10.1.021/bin/ifortvars.sh
250 export MPI_ROOT=/usr/local/OpenMPI/1.6.3/ifort10.1.021
251 export PATH=\$MPI_ROOT/bin:\$PATH
252 export LD_LIBRARY_PATH=\$MPI_ROOT/lib64:\$LD_LIBRARY_PATH
253 export MANPATH=\$MPI_ROOT/share/man:\$MANPATH
254 "}
255               ;;
256 'Linux eos'*)
257                 export     ARCH=${ARCH:-LXifort}
258                 export  VER_MPI=${VER_MPI:-MPIINTEL}
259                 export OPTLEVEL=${OPTLEVEL:-O2}
260                 export VER_CDF=${VER_CDF:-CDFAUTO}
261                 export   MNHENV=${MNHENV:-"
262 "}
263               ;;
264
265 'Linux occigen'*)
266                 export     ARCH=${ARCH:-LXifort}
267                 export  VER_MPI=${VER_MPI:-MPIINTEL}
268                 export OPTLEVEL=${OPTLEVEL:-O2}
269                 export VER_CDF=${VER_CDF:-CDFAUTO}
270                 export   MNHENV=${MNHENV:-"
271 ulimit -s unlimited
272 module load intel/15.0.3.187
273 module load intelmpi/5.0.1.035
274 export SLURM_CPU_BIND=none
275 export I_MPI_PIN_PROCESSOR_LIST=all:map=spread
276 "}
277               ;;
278
279 Linux*)
280                 export     ARCH=${ARCH:-LXgfortran}
281                 export  VER_MPI=${VER_MPI:-MPIVIDE}
282                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
283                 export MVWORK=${MVWORK:-NO}
284                 #export VER_CDF=${VER_CDF:-CDFGFOR}
285                 export VER_CDF=${VER_CDF:-CDFAUTO}
286                 export NEED_NCARG=${NEED_NCARG:-YES}
287               ;;
288 *)
289                 echo "WARNING ; system not yet tested "
290                 echo "WARNING ; edit profile_mesonh & set correct variables ARCH , VER_MPI & OPTLEVEL "
291
292                 export     ARCH=${ARCH}
293                 export  VER_MPI=${VER_MPI:-MPIVIDE}
294                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
295               ;;
296 esac
297 ##
298 ## Environnement for scandollar
299 ##
300
301 if [ "x${CONF_DOLLAR}" = "x" ] ; then
302 # set default value for CONF_DOLLAR file
303 case "$(hostname)" in
304   tori*|yuki*)
305         export POSTCONF=confdollar_dsinec_default
306         ;;
307
308   lx*|px*|sx*)
309         export POSTCONF=confdollar_cnrmpc_default
310         ;;
311
312   aeropc*)
313         export POSTCONF=confdollar_aeropc_default
314
315         ;;
316
317   brodie*)
318         export POSTCONF=confdollar_brodie_default
319
320         ;;
321
322   vargas*)
323         export POSTCONF=confdollar_vargas_default
324         ;;
325
326   c1a*)
327         export POSTCONF=confdollar_c1a_default
328         ;;
329
330   service*)
331         export POSTCONF=confdollar_jade_default
332         ;;
333
334   babel*)
335         export POSTCONF=confdollar_babel_default
336         ;;
337   turing*)
338         export POSTCONF=confdollar_turing_default
339         ;;
340  titane*|curie*)
341         export POSTCONF=confdollar_titane_default
342         ;;
343
344   eos*)
345         export POSTCONF=confdollar_eos_default
346         ;;
347
348   occigen*)
349         export POSTCONF=confdollar_occigen_default
350         ;;
351
352   *)
353         export POSTCONF=confdollar_aeropc_default
354         ;;
355 esac
356
357 export CONF_DOLLAR=${LOCAL}/conf/post/${POSTCONF}
358
359 fi
360
361 #
362 #  Install 32/64 mesonh tools
363 #
364 if [ "x${NEED_TOOLS}" == "xYES" ] ; then
365   case "$(uname -m)" in
366   'x86_64')
367           export BIN_TOOLS=${BIN_TOOLS:-X86_64}
368            ;;
369   'x86'|'i'*'86')
370           export BIN_TOOLS=${BIN_TOOLS:-X86}
371            ;;
372   esac
373 fi
374
375 #
376 # Generate profile_mesonh
377 #
378 ${LOCAL}/bin/eval_dollar  profile_mesonh.ihm > profile_mesonh
379 chmod +x profile_mesonh
380 XYZ=${ARCH}${MNH_REAL}I${MNH_INT}-${VERSION_XYZ}${VER_USER:+-${VER_USER}}-${VER_MPI}-${OPTLEVEL}
381 cp profile_mesonh profile_mesonh-${XYZ}
382 #
383 #  Do some post-install stuff
384 #
385 if [ "x${MVWORK}" == "xYES" ] ; then
386    if [ "x${WORKDIR}" == "x" ] ; then
387      echo "ATTENTION :: configure !!!!!"
388      echo
389      echo '  ---> vous n avez pas initialiser la variable $WORKDIR '
390      echo '  ---> ou seront stoké les binaires et cas tests '
391      echo '  ---> initialisez la et relance "./configure"'
392      exit 1
393    fi
394    if [ -d $WORKDIR ] && [ ${LOCAL} == ${LOCAL##/work} ] ; then
395 #  if we are not allready in the workdir --> move stuff
396       WORK=$WORKDIR/${RACINE}_WORKDIR
397       mkdir -p ${WORK}
398       for dir in MY_RUN exe pub
399       do
400          [ -d $LOCAL/${dir} ] && [ ! -L $LOCAL/${dir} ] \
401           && mv $LOCAL/${dir} ${WORK}/. \
402           && ln -s ${WORK}/${dir} $LOCAL/.
403       done
404    fi
405 fi
406 if [ "x${NEED_NCARG}" != "xNO" ] ; then
407 ( cd $LOCAL/pub ; [ ! -d ncl_ncarg-5.2.1.Linux_x86_64 ] && tar xvfz ncl_ncarg-5.2.1.Linux_x86_64.tar.gz )
408 fi
409
410 #
411 #  Install CDF if VER_CDF=CDFAUTO
412 #
413 if [ "x${VER_CDF}" == "xCDFAUTO" ] ;then
414 ( cd $LOCAL/src/LIB ; [ ! -d netcdf-${VERSION_CDF} ] && tar xvfz netcdf-${VERSION_CDF}.tar.gz )
415 ( cd $LOCAL/src/LIB ; [ ! -d hdf5-${VERSION_HDF} ] && tar xvfz hdf5-${VERSION_HDF}.tar.gz )
416 fi
417 #
418 #  Install GRIBAPI
419 #
420 cd $LOCAL/src/LIB ; [ ! -d grib_api-${VERSION_GRIBAPI} ] && [ -f grib_api-${VERSION_GRIBAPI}.tar.gz ] && gunzip -c grib_api-${VERSION_GRIBAPI}.tar.gz |tar -xvf -
421 ##########################################################
422 #                                                        #
423 #      RESUME                                            #
424 #                                                        #
425 ##########################################################
426
427 echo  ARCH=${ARCH}
428 echo  VER_MPI=${VER_MPI}
429 echo  VER_USER=${VER_USER-" pas de version user ..."}
430 echo  OPTLEVEL=${OPTLEVEL}
431 echo  CONF_DOLLAR=${CONF_DOLLAR}
432 echo  VER_CDF=${VER_CDF}
433 echo  BIN_TOOLS=${BIN_TOOLS}
434 echo
435 echo  "---> XYZ=${XYZ}"
436 echo
437 echo "création du fichier -->  ../conf/profile_mesonh-${XYZ}"
438 echo
439 ##########################################################
440 #                                                        #
441 # ENVIRONEMENT MESONH ALLREADY SET                       #
442 #                                                        #
443 ##########################################################
444 else
445 clear
446 echo
447 echo "ATTENTION :: configure !!!!!"
448 echo
449 echo '  ---> vous avez déjà initialisé votre environnement MESONH sur cette version'
450 echo '  ---> $XYZ="'$XYZ'"'
451 echo
452 echo "Vérifiez votre fichier '.profile'" ou "'.bashrc'"  !!!
453 echo
454 echo "  ---> mettez en commentaire la ligne '. ../profile_mesonh...' "
455 echo "  ---> relogger vous sur une autre session et relancer ./configure "
456 echo
457 echo "Fichier 'profile_mesonh' non modifié !!! "
458 echo
459 exit 1
460 fi