Skip to content

Commit

Permalink
Fixed linux build on travis
Browse files Browse the repository at this point in the history
Fixed linux build on travis

Expanded the travis continuous integration:

"manually build" netcdf-fortran using gfortran-6
this requires building szip, hdf5 and netcdf-c with the same compiler
add expanded scripts for different stages of the compilation
  • Loading branch information
bartnijssen committed Aug 16, 2016
1 parent 7061c7d commit a7e3f14
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 25 deletions.
31 changes: 19 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
sudo: false
sudo: false # use container-based build
language: fortran
compiler:
- gfortran
os:
- linux
notifications:
email: false

compiler: gfortran-6
os: linux
env: TESTID='summa_linux'
addons:
apt:
source:
sources:
- ubuntu-toolchain-r-test
packages:
- libnetcdf-dev
- liblapack-dev
- gfortran
- gfortran-6
before_install:
- source ci/summa_install_utils
- summa_before_install
install:
- summa_install
script:
- sed -i "s/FC =/FC = gfortran/" build/Makefile
- sed -i "s|F_MASTER =|F_MASTER = ${TRAVIS_BUILD_DIR}|" build/Makefile
- make -C build/ -f Makefile
- ${TRAVIS_BUILD_DIR}/bin/summa.exe
- summa_script
after_success:
- summa_after_success
after_failure:
- summa_after_failure
34 changes: 21 additions & 13 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ FC =

# gfortran compiler on OS X tested with 4.8 and higher
# (works on Mac OS X with Macports)
ifeq "$(FC)" "gfortran-mp-4.8"
ifeq "$(FC)" "gfortran-mp-6"
NCDF_PATH = /opt/local
LAPK_PATH = /opt/local
# define the lapack libraries - on OS X you need atlas and
# blas as well
LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -lblas -latlas
endif

# Ubuntu gfortran compiler tested with 4.6 and higher
# Ubuntu gfortran compiler tested with 6.0 and higher
# also used for the travis build
ifeq "$(FC)" "gfortran"
NCDF_PATH = /usr
ifeq "$(FC)" "gfortran-6"
NCDF_PATH = /usr/local
LAPK_PATH = /usr
# define the lapack libraries
LIBLAPACK = -L$(LAPK_PATH)/lib -llapack -lblas
endif

# Intel fortran compiler
ifeq "$(FC)" "ifort"
NCDF_PATH = /opt/netcdf4-intel
LAPK_PATH = /usr
# define the lapack libraries
LIBLAPACK = -L$(LAPK_PATH)/lib -llapack
Expand All @@ -63,15 +71,15 @@ INCNETCDF = -I$(NCDF_PATH)/include
# Define compiler flags. If you use a different compiler,
# you will need to figure out what the equivalent flags are
# and may need to update this section
ifeq "$(FC)" "gfortran-mp-4.8"
ifeq "$(FC)" "gfortran-mp-6"
FLAGS_NOAH = -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -g -fbacktrace -Wno-unused -Wno-unused-dummy-argument
FLAGS_COMM = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
FLAGS_SUMMA = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
endif
ifeq "$(FC)" "gfortran"
FLAGS_NOAH = -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -g -fbacktrace -Wno-unused -Wno-unused-dummy-argument
FLAGS_COMM = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
FLAGS_SUMMA = -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
ifeq "$(FC)" "gfortran-6"
FLAGS_NOAH = -p -g -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
FLAGS_COMM = -p -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
FLAGS_SUMMA = -p -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
endif
ifeq "$(FC)" "ifort"
FLAGS_NOAH = -warn nounused -autodouble -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency
Expand Down Expand Up @@ -107,7 +115,7 @@ ENGINE_DIR = $(F_KORE_DIR)/engine

# utilities
SUMMA_NRUTIL= \
nrtype.f90 \
nrtype.f90 \
nr_utility.f90
NRUTIL = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_NRUTIL))

Expand All @@ -121,7 +129,7 @@ NRPROC = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_NRPROC))

# Hook-up modules (set files and directory paths)
SUMMA_HOOKUP= \
summaFileManager.f90
summaFileManager.f90
HOOKUP = $(patsubst %, $(HOOKUP_DIR)/%, $(SUMMA_HOOKUP))

# Data modules
Expand All @@ -139,7 +147,7 @@ UTILMS = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_UTILMS))

# Model guts
SUMMA_MODGUT= \
MODGUT = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_MODGUT))
MODGUT = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_MODGUT))

# Solver
SUMMA_SOLVER= \
Expand Down Expand Up @@ -218,7 +226,7 @@ SUMMA_ALL = $(PRELIM) $(MODRUN) $(SOLVER) $(NETCDF)

# Define the driver routine
SUMMA_DRIVER= \
multi_driver.f90
multi_driver.f90
DRIVER = $(patsubst %, $(DRIVER_DIR)/%, $(SUMMA_DRIVER))

# Define the executable
Expand Down
100 changes: 100 additions & 0 deletions ci/summa_install_utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env bash

set -e

export CC=/usr/bin/gcc-6
export FC=/usr/bin/gfortran-6

if [ -z "$WORKDIR" ]; then
export WORKDIR=$HOME/workdir
mkdir -p $WORKDIR
fi

if [ -z "$INSTALLDIR" ]; then
export INSTALLDIR=$HOME/installdir
mkdir -p $INSTALLDIR
fi

function install_szip {
echo install_szip
cd $WORKDIR
wget --no-check-certificate -q http://www.hdfgroup.org/ftp/lib-external/szip/2.1/src/szip-2.1.tar.gz
tar -xzf szip-2.1.tar.gz
cd szip-2.1
./configure --prefix=$INSTALLDIR &> config.log
make &> make.log
make install
export CPPFLAGS="$CPPFLAGS -I${INSTALLDIR}/include"
export LDFLAGS="$LDFLAGS -L${INSTALLDIR}/lib"
}

function install_hdf5 {
echo install_hdf5
cd $WORKDIR
wget --no-check-certificate -q http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.17.tar.gz
tar -xzf hdf5-1.8.17.tar.gz
cd hdf5-1.8.17
./configure --prefix=$INSTALLDIR &> config.log
make &> make.log
make install
export LIBDIR=${INSTALLDIR}/lib
}

function install_netcdf_c {
echo install_netcdf_c
cd $WORKDIR
wget --no-check-certificate -q ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.tar.gz
tar -xzf netcdf-4.4.1.tar.gz
cd netcdf-4.4.1
./configure --prefix=$INSTALLDIR &> config.log
make &> make.log
make install
export LD_LIBRARY_PATH=${INSTALLDIR}/lib
}

function install_netcdf_fortran {
echo install_netcdf_fortran
cd $WORKDIR
wget --no-check-certificate -q ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.4.tar.gz
tar -xzf netcdf-fortran-4.4.4.tar.gz
cd netcdf-fortran-4.4.4
./configure --prefix=$INSTALLDIR &> config.log
make &> make.log
make install
}

function summa_before_install {
echo summa_before_install
# Install szip (used by hdf5)
install_szip
# Install HDF5
install_hdf5
# Install NetCDF-C
install_netcdf_c
# Install NetCDF fortran
install_netcdf_fortran
}

function summa_install {
echo summa_install
cd ${TRAVIS_BUILD_DIR}
sed -i "s/FC =.*/FC = gfortran-6/" build/Makefile
sed -i "s|F_MASTER =.*|F_MASTER = ${TRAVIS_BUILD_DIR}|" build/Makefile
sed -i "s|NCDF_PATH =.*|NCDF_PATH = ${INSTALLDIR}|" build/Makefile
make -C build/ -f Makefile &> make.log
}

function summa_script {
echo summa_script
${TRAVIS_BUILD_DIR}/bin/summa.exe
}

function summa_after_success {
echo summa_after_success
echo "SUMMA build succeeded"
}

function summa_after_failure {
echo summa_after_failure
echo "SUMMA build failed"
}

0 comments on commit a7e3f14

Please sign in to comment.