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