#!/bin/bash usage() { echo usage: echo makeitp willem/trunk/2013/2014-1/myxbeach/cyclic intel/gnu mpi/openmpi/serial/mpich2 scalasca1/scalasca/jumpshot/gprof/no static/shared/both debug/opt [-c] [-n] [-jnn] [-v] echo "-c clean" echo "-n skip configure" echo "-jnn run nn-parallel" echo "-v verbose" } ROOT=/home/willem/projecten/parallel #useprofiler=yes if [ "$useprofiler" ]; then module load mygperftools export LDFLAGS="$LDFLAGS -lprofiler" fi dir=surfsara-2014-1 startdir=`pwd` mpi_filter=$startdir/../mpi_filter mpi_filter=cat src="$1" shift compiler="$1" shift mpi="$1" shift trace="$1" shift shst="$1" shift opt="$1" shift echo "rest":$* doconfigure=yes optimize=no ncores=4 if [ -e /proc/cpuinfo ] ; then ncores=`grep bogomips /proc/cpuinfo | wc -l` fi if [ "$src" = trunk ] ; then ncores=1 fi V=0 parmake=-j$ncores while [ "$1" ] ; do case "$1" in -n) doconfigure=no shift ;; -j*) parmake="$1" shift ;; -c) clean=yes shift ;; -v) V=1 shift ;; *) echo "Invalid parameter: $1" exit 1 ;; esac done case "$src" in willem) cd $ROOT/xbeach/branches/willem-2016/wtrunk || exit ;; trunk) cd $ROOT/xbeach/trunk || exit #parmake= ;; 2013|2014-1) cd $ROOT/xbeach/branches/surfsara-$src || exit ;; cyclic) cd $ROOT/xbeach/branches/cyclic-2015 || exit ;; myxbeach) cd $ROOT/myxbeach/trunk || exit #parmake= ;; *) usage exit 1 esac binst=$src/$compiler/$mpi/$trace/$shst/$opt builddir=$ROOT/xbeachbuild/$binst mkdir -p $builddir || exit case $clean in yes) rm -rf "$builddir" || exit 1 mkdir -p "$builddir" || exit 1 echo all done exit 0 ;; esac mpiflag=--with-mpi case "$mpi" in mpich2) module load mpich2 case "$compiler" in gnu) : ;; intel) echo "No Intel support for mpich2" exit 1 ;; *) usage exit 1 ;; esac ;; openmpi) module unload mpi case "$compiler" in gnu) #module load openmpi/gnu ;; intel) module load intel module load openmpi/intel ;; *) usage exit 1 ;; esac ;; mpi) ;; serial) mpiflag=--without-mpi ;; *) usage exit 1 ;; esac case "$shst" in static) shstflag="--disable-shared" ;; shared) shstflag="--disable-static" ;; both) shstflag="" ;; *) usage exit 1 ;; esac case "$opt" in debug) optimize=no ;; opt) optimize=yes ;; *) usage exit 1 ;; esac case "$compiler" in intel) module load intel module load netcdf/intel case "$optimize" in yes) export FCFLAGS="$FCFLAGS -O2 -g -traceback -vec-report0" ;; *) export FCFLAGS="$FCFLAGS -O0 -g -traceback -vec-report0 -check bounds,format,pointers,stack" ;; esac export FC=ifort case "$mpi" in serial) : ;; mpi) export MPIFC=mpiifort ;; openmpi) export MPIFC=mpif90 ;; esac ;; gnu) #module load mynetcdf #module load netcdf/gnu export FCFLAGS="$FCFLAGS -I/usr/include" case "$optimize" in yes) export FCFLAGS="$FCFLAGS -fbacktrace -O2 -g -Wall -Wno-unused-dummy-argument -Wno-unused-function -ffpe-trap=invalid,zero,overflow" ;; *) export FCFLAGS="$FCFLAGS -fbacktrace -fbounds-check -O0 -g -Wall -Wno-unused-dummy-argument -Wno-unused-function -ffpe-trap=invalid,zero,overflow" ;; esac export FC=gfortran export MPIFC=mpif90 makedepsflag=--with-makefdepsn case "$mpi" in serial) ;; mpi) ;; openmpi) ;; esac ;; *) usage exit 1 ;; esac papidir=/opt/bullxde/perftools/papi-bull/5.0.1.0-Bull.2.0/lib64 case "$trace" in scalasca) MPIFC="skin -user $MPIFC" #MPIFC="skin $MPIFC" case "$compiler" in intel) #module load scalasca/impi/intel/2.0 scorep module load scalasca ;; gnu) module load scalasca/xmpi/gnu ;; *) usage exit 1 ;; esac export LDFLAGS="$LDFLAGS -L$papidir" ;; scalasca1) MPIFC="skin -comp=none -mode=MPI $MPIFC" #MPIFC="skin $MPIFC" case "$compiler" in intel) #module load scalasca/impi/intel/2.0 scorep module load scalasca ;; gnu) module load scalasca/xmpi/gnu ;; *) usage exit 1 ;; esac export LDFLAGS="$LDFLAGS -L$papidir" ;; jumpshot) if [ "$mpi" != openmpi ] ; then echo "mpi must be openmpi for jumpshot" exit 1 fi export LDFLAGS="$LDFLAGS -lmpe_f2cmpi -llmpe -lmpe" ;; gprof) FCFLAGS="$FCFLAGS -pg" LDFLAGS="$LDFLAGS -pg" ;; no) ;; *) usage exit 1 ;; esac if [ "$SURFSARA_NETCDF_INCLUDE" ] ; then export NETCDF_CFLAGS=-I$SURFSARA_NETCDF_INCLUDE export NETCDF_LIBS=-L$SURFSARA_NETCDF_LIB fi no_optflag=--with-no_opt makedepsflag=${makedepsflag:-'--with-makedeps'} if [ "$src" = trunk ] ; then makedepsflag="" fi installdir=$ROOT/xbeachbin/$binst echo installdir:$installdir echo builddir:$builddir echo FC:$FC for i in $FC ; do echo -n " "; which $i ; done echo MPIFC:$MPIFC for i in $MPIFC ; do echo -n " "; which $i ; done echo FCFLAGS:$FCFLAGS echo mpiflag:$mpiflag echo LDFLAGS:$LDFLAGS echo doconfigure:$doconfigure echo makedepsflag:$makedepsflag # export FCFLAGS='-ffree-line-length-none -O2 -g -Wall -fcheck=all -finit-real=snan -ffpe-trap=invalid -fno-var-tracking -I/usr/include' pwd="`pwd`" if [ "$doconfigure" = yes ]; then ( cd $builddir || exit 1 "$pwd"/configure --prefix=$installdir \ -enable-option-checking=fatal \ $mpiflag \ --with-netcdf \ $makedepsflag \ $no_optflag \ $shstflag ) || exit 1 fi if [ "$src" != trunk ] ; then cd "$builddir" || exit make dep | exit cd - fi echo parmake:$parmake set -o pipefail cd "$builddir" || exit make V="$V" $parmake install 2>&1 || exit echo "Build directory:" echo "$builddir" echo "Installation directory:" echo "$installdir" echo all done