571f98e047de92e8f94c5820e1c8109a5f3e3af4
[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 login0'*|'Linux compute'*)
87                 export     ARCH=${ARCH:-LXifort}
88                 export  VER_MPI=${VER_MPI:-MPIAUTO}
89                 export OPTLEVEL=${OPTLEVEL:-O3}
90                 export MVWORK=${MVWORK:-NO}
91                 export VER_CDF=${VER_CDF:-CDFBULL}
92                 export MNHENV=${MNHENV:-"
93 module rm intel    ; module load intel/13.0.1.117 ;
94 module rm intelmpi ; module load intelmpi/4.1.0 ;
95 module rm intel-itac ; module load intel-itac/8.0.3
96 "}
97               ;;
98 'Linux brodie'*|'Linux mercure'*)
99                 export     ARCH=${ARCH:-SX8}
100                 export  VER_MPI=${VER_MPI:-MPIAUTO}
101                 export OPTLEVEL=${OPTLEVEL:-O4}
102                 export MVWORK=${MVWORK:-YES}
103                 export VER_CDF=${VER_CDF:-CDFSX}
104                 export MNHENV=${MNHENV:-"
105 module rm sxf90  ; module load sxf90/400 ;
106 module rm sxmpi  ; module load sxmpi/8.0.10 ;
107 module rm netcdf ; module load netcdf/3.6.3
108 "}
109               ;;
110 'Linux babel'*)
111                 export     ARCH=${ARCH:-BGQ}
112                 export  VER_MPI=${VER_MPI:-MPIAUTO}
113                 export OPTLEVEL=${OPTLEVEL:-O2}
114                 export MVWORK=${MVWORK:-YES}
115                 export MNHENV=${MNHENV:-"
116 module load netcdf/3.6.3
117 "}
118                ;;
119 'Linux turing'*)
120                 export     ARCH=${ARCH:-BGQ}
121                 export  VER_MPI=${VER_MPI:-MPIAUTO}
122                 export OPTLEVEL=${OPTLEVEL:-O2NAN}
123                 export MVWORK=${MVWORK:-YES}
124                 export VER_CDF=${VER_CDF:-CDFBGQ}
125                 export MNHENV=${MNHENV:-"
126 source /bglocal/fe/pub/Modules/default/init/bash
127 export MODULEPATH=/bghome/rech/mnh/rmnh007/my_modules:\$MODULEPATH
128 module purge
129 module load ibmcmp/V1R2M2/14.01.0000.0011/gcc.legacy
130 export VER_GA=ga-mpi-5-0-3-v1r2m2-gcc-legacy
131 module load ga/\${VER_GA}
132 "}
133               ;;
134 'Linux ada'*)
135                 export     ARCH=${ARCH:-LXifort}
136                 export  VER_MPI=${VER_MPI:-MPIINTEL}
137                 export OPTLEVEL=${OPTLEVEL:-O2}
138                 export MVWORK=${MVWORK:-YES}
139                 export MNHENV=${MNHENV:-"
140 #export OBJDIR_PATH=$WORKDIR/DIR_OBJ_ADA
141 export MP_MPILIB=pempi
142 module load netcdf/seq/4.1.3
143 "}
144               ;;
145 AIX*)
146                 export MNH_ARCH=`echo $ARCH | grep AIX`
147                 export     ARCH=${MNH_ARCH:-AIX64}
148                 export  VER_MPI=${VER_MPI:-MPIAUTO}
149                 export OPTLEVEL=${OPTLEVEL:-O2}
150                 export MVWORK=${MVWORK:-NO}
151                 export VER_CDF=${VER_CDF:-CDFAIX}
152                 case "$(hostname)" in
153                       vargas*)
154                       export MNHENV=${MNHENV:-"
155 module rm fortran ; module load fortran/13.1.0.7
156 module rm netcdf  ; module load netcdf/3.6.3
157 "}
158                       ;;
159                       c1a*)
160                       export VERSION_GRIBAPI="1.9.9"
161                       export MNHENV=${MNHENV:-"
162 . /usr/local/apps/module/init/sh.in
163 module rm fortran ; module load fortran/xlf/13.1.0.7
164 module rm netcdf  ; module load netcdf/3.6.3
165 export CDF_PATH=/usr/local/apps/netcdf/3.6.3/LP64
166 export GRIBAPI_PATH=/usr/local/lib/metaps/lib/grib_api/${VERSION_GRIBAPI}
167 export LIB_GRIBAPI='${GRIB_API_LIB}'
168 "}
169                       ;;
170                       c2a*)
171                       export VERSION_GRIBAPI="2.0.0"
172                       export MNHENV=${MNHENV:-"
173 . /usr/local/apps/module/init/sh.in
174 module rm fortran ; module load fortran/xlf/13.1.0.9
175 module rm netcdf  ; module load netcdf/3.6.3
176 export CDF_PATH=/usr/local/apps/netcdf/3.6.3/LP64
177 export GRIBAPI_PATH=/usr/local/lib/metaps/lib/grib_api/${VERSION_GRIBAPI}
178 export LIB_GRIBAPI='${GRIB_API_LIB}'
179 "}
180                       ;;
181                  esac
182               ;;
183 'Linux cc'*) # ECMWF Cray plateforme
184                 export MNH_ARCH=`echo $ARCH | grep LX`
185                 export     ARCH=${MNH_ARCH:-LXcray}
186                 export  VER_MPI=${VER_MPI:-MPICRAY}
187                 export OPTLEVEL=${OPTLEVEL:-O2}
188                 export MVWORK=${MVWORK:-NO}
189                 export VER_CDF=${VER_CDF:-CDFAUTO}
190                 if [ "${ARCH}" == "LXcray" ] 
191                 then
192                 export MNHENV=${MNHENV:-"
193 . /opt/modules/default/init/bash
194 module rm grib_api
195 "}
196                 else
197                 if [ "${ARCH}" == "LXifort" ]
198                 then
199                 export MNHENV=${MNHENV:-"
200 . /opt/modules/default/init/bash
201 module switch PrgEnv-cray PrgEnv-intel
202 module rm grib_api
203 "}
204                 fi
205                 fi
206 ;;
207 'Linux sxmnh1') #CNRM ifort sur sxmnh1 (diff mandriva)
208                 export    OMPI_FC=ifort
209                 export       ARCH=${ARCH:-LXifort}
210                 export    VER_MPI=${VER_MPI:-MPIAUTO}
211                 export   OPTLEVEL=${OPTLEVEL:-DEBUG}
212                 export     MVWORK=${MVWORK:-NO}
213                 export    VER_CDF=${VER_CDF:-CDFCTI}
214                 export NEED_NCARG=${NEED_NCARG:-NO}
215                 export NEED_TOOLS=NO
216               ;;
217 'Linux lx'*|'Linux sx'*|'Linux px'*) #CNRM
218                 export MNH_ARCH=`echo $ARCH | grep LX`
219                 export     ARCH=${MNH_ARCH:-LXgfortran}
220                 export  VER_MPI=${VER_MPI:-MPIAUTO}
221                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
222                 export MVWORK=${MVWORK:-NO}
223                 export VER_CDF=${VER_CDF:-CDFCTI}
224                 export NEED_NCARG=${NEED_NCARG:-NO}
225                 export NEED_TOOLS=NO
226               ;;
227 'Linux nuwa'*)
228                 export     ARCH=${ARCH:-LXifort}
229                 export  VER_MPI=${VER_MPI:-MPIAUTO}
230                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
231                 export MVWORK=${MVWORK:-NO}
232                 export VER_CDF=${VER_CDF:-CDFAUTO}
233                 export NEED_NCARG=${NEED_NCARG:-YES}
234                       export MNHENV=${MNHENV:-"
235 . /opt/intel/fce/10.1.021/bin/ifortvars.sh
236 export MPI_ROOT=/usr/local/OpenMPI/1.6.3/ifort10.1.021
237 export PATH=\$MPI_ROOT/bin:\$PATH
238 export LD_LIBRARY_PATH=\$MPI_ROOT/lib64:\$LD_LIBRARY_PATH
239 export MANPATH=\$MPI_ROOT/share/man:\$MANPATH
240 "}
241               ;;
242 'Linux eos'*)
243                 export     ARCH=${ARCH:-LXifort}
244                 export  VER_MPI=${VER_MPI:-MPIINTEL}
245                 export OPTLEVEL=${OPTLEVEL:-O2}
246                 export VER_CDF=${VER_CDF:-CDFAUTO}
247                 export   MNHENV=${MNHENV:-"
248 "}
249               ;;
250
251 'Linux occigen'*)
252                 export     ARCH=${ARCH:-LXifort}
253                 export  VER_MPI=${VER_MPI:-MPIINTEL}
254                 export OPTLEVEL=${OPTLEVEL:-O2}
255                 export VER_CDF=${VER_CDF:-CDFAUTO}
256                 export   MNHENV=${MNHENV:-"
257 ulimit -s unlimited
258 module load intel/15.0.3.187
259 module load intelmpi/5.0.1.035
260 export SLURM_CPU_BIND=none
261 export I_MPI_PIN_PROCESSOR_LIST=all:map=spread
262 "}
263               ;;
264
265 Linux*)
266                 export     ARCH=${ARCH:-LXgfortran}
267                 export  VER_MPI=${VER_MPI:-MPIVIDE}
268                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
269                 export MVWORK=${MVWORK:-NO}
270                 #export VER_CDF=${VER_CDF:-CDFGFOR}
271                 export VER_CDF=${VER_CDF:-CDFAUTO}
272                 export NEED_NCARG=${NEED_NCARG:-YES}
273               ;;
274 *)
275                 echo "WARNING ; system not yet tested "
276                 echo "WARNING ; edit profile_mesonh & set correct variables ARCH , VER_MPI & OPTLEVEL "
277
278                 export     ARCH=${ARCH}
279                 export  VER_MPI=${VER_MPI:-MPIVIDE}
280                 export OPTLEVEL=${OPTLEVEL:-DEBUG}
281               ;;
282 esac
283 ##
284 ## Environnement for scandollar
285 ##
286
287 if [ "x${CONF_DOLLAR}" = "x" ] ; then
288 # set default value for CONF_DOLLAR file
289 case "$(hostname)" in
290   tori*|yuki*)
291         export POSTCONF=confdollar_dsinec_default
292         ;;
293
294   lx*|px*|sx*)
295         export POSTCONF=confdollar_cnrmpc_default
296         ;;
297
298   aeropc*)
299         export POSTCONF=confdollar_aeropc_default
300
301         ;;
302
303   brodie*)
304         export POSTCONF=confdollar_brodie_default
305
306         ;;
307
308   vargas*)
309         export POSTCONF=confdollar_vargas_default
310         ;;
311
312   c1a*)
313         export POSTCONF=confdollar_c1a_default
314         ;;
315
316   service*)
317         export POSTCONF=confdollar_jade_default
318         ;;
319
320   babel*)
321         export POSTCONF=confdollar_babel_default
322         ;;
323   turing*)
324         export POSTCONF=confdollar_turing_default
325         ;;
326  titane*|curie*)
327         export POSTCONF=confdollar_titane_default
328         ;;
329
330   eos*)
331         export POSTCONF=confdollar_eos_default
332         ;;
333
334   occigen*)
335         export POSTCONF=confdollar_occigen_default
336         ;;
337
338   *)
339         export POSTCONF=confdollar_aeropc_default
340         ;;
341 esac
342
343 export CONF_DOLLAR=${LOCAL}/conf/post/${POSTCONF}
344
345 fi
346
347 #
348 #  Install 32/64 mesonh tools
349 #
350 if [ "x${NEED_TOOLS}" == "xYES" ] ; then
351   case "$(uname -m)" in
352   'x86_64')
353           export BIN_TOOLS=${BIN_TOOLS:-X86_64}
354            ;;
355   'x86'|'i'*'86')
356           export BIN_TOOLS=${BIN_TOOLS:-X86}
357            ;;
358   esac
359 fi
360
361 #
362 # Generate profile_mesonh
363 #
364 ${LOCAL}/bin/eval_dollar  profile_mesonh.ihm > profile_mesonh
365 chmod +x profile_mesonh
366 XYZ=${ARCH}${MNH_REAL}I${MNH_INT}-${VERSION_XYZ}${VER_USER:+-${VER_USER}}-${VER_MPI}-${OPTLEVEL}
367 cp profile_mesonh profile_mesonh-${XYZ}
368 #
369 #  Do some post-install stuff
370 #
371 if [ "x${MVWORK}" == "xYES" ] ; then
372    if [ "x${WORKDIR}" == "x" ] ; then
373      echo "ATTENTION :: configure !!!!!"
374      echo
375      echo '  ---> vous n avez pas initialiser la variable $WORKDIR '
376      echo '  ---> ou seront stoké les binaires et cas tests '
377      echo '  ---> initialisez la et relance "./configure"'
378      exit 1
379    fi
380    if [ -d $WORKDIR ] && [ ${LOCAL} == ${LOCAL##/work} ] ; then
381 #  if we are not allready in the workdir --> move stuff
382       WORK=$WORKDIR/${RACINE}_WORKDIR
383       mkdir -p ${WORK}
384       for dir in MY_RUN exe pub
385       do
386          [ -d $LOCAL/${dir} ] && [ ! -L $LOCAL/${dir} ] \
387           && mv $LOCAL/${dir} ${WORK}/. \
388           && ln -s ${WORK}/${dir} $LOCAL/.
389       done
390    fi
391 fi
392 if [ "x${NEED_NCARG}" != "xNO" ] ; then
393 ( cd $LOCAL/pub ; [ ! -d ncl_ncarg-5.2.1.Linux_x86_64 ] && tar xvfz ncl_ncarg-5.2.1.Linux_x86_64.tar.gz )
394 fi
395
396 #
397 #  Install CDF if VER_CDF=CDFAUTO
398 #
399 if [ "x${VER_CDF}" == "xCDFAUTO" ] ;then
400 ( cd $LOCAL/src/LIB ; [ ! -d netcdf-${VERSION_CDF} ] && tar xvfz netcdf-${VERSION_CDF}.tar.gz )
401 ( cd $LOCAL/src/LIB ; [ ! -d hdf5-${VERSION_HDF} ] && tar xvfz hdf5-${VERSION_HDF}.tar.gz )
402 fi
403 #
404 #  Install GRIBAPI
405 #
406 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 -
407 ##########################################################
408 #                                                        #
409 #      RESUME                                            #
410 #                                                        #
411 ##########################################################
412
413 echo  ARCH=${ARCH}
414 echo  VER_MPI=${VER_MPI}
415 echo  VER_USER=${VER_USER-" pas de version user ..."}
416 echo  OPTLEVEL=${OPTLEVEL}
417 echo  CONF_DOLLAR=${CONF_DOLLAR}
418 echo  VER_CDF=${VER_CDF}
419 echo  BIN_TOOLS=${BIN_TOOLS}
420 echo
421 echo  "---> XYZ=${XYZ}"
422 echo
423 echo "création du fichier -->  ../conf/profile_mesonh-${XYZ}"
424 echo
425 ##########################################################
426 #                                                        #
427 # ENVIRONEMENT MESONH ALLREADY SET                       #
428 #                                                        #
429 ##########################################################
430 else
431 clear
432 echo
433 echo "ATTENTION :: configure !!!!!"
434 echo
435 echo '  ---> vous avez déjà initialisé votre environnement MESONH sur cette version'
436 echo '  ---> $XYZ="'$XYZ'"'
437 echo
438 echo "Vérifiez votre fichier '.profile'" ou "'.bashrc'"  !!!
439 echo
440 echo "  ---> mettez en commentaire la ligne '. ../profile_mesonh...' "
441 echo "  ---> relogger vous sur une autre session et relancer ./configure "
442 echo
443 echo "Fichier 'profile_mesonh' non modifié !!! "
444 echo
445 exit 1
446 fi