easyblock = 'ConfigureMake'

name = 'CDO'
version = '1.8.1'

homepage = 'https://code.zmaw.de/projects/cdo'
description = """CDO is a collection of command line Operators to manipulate and analyse Climate and NWP model Data."""

toolchain = {'name': 'intel', 'version': '2017.02'}
toolchainopts = {'pic': True, 'usempi': True}

sources = [SOURCELOWER_TAR_GZ]
source_urls = ['https://code.zmaw.de/attachments/download/14271/']
checksums = ['54498438de788f245d47499efad7966c']

dependencies = [
    ('HDF5', '1.8.18'),
    ('netCDF', '4.4.1.1'),
    ('YAXT', '0.5.1'),
]

configopts = "--with-hdf5=$EBROOTHDF5 --with-netcdf=$EBROOTNETCDF"
# fix for linking issues with HDF5 libraries for libcdi, should link with both -lnetcdf and -lhdf5_hl -lhdf5
prebuildopts = "find libcdi -name Makefile | xargs sed -i 's/-lnetcdf -lnetcdf/-lnetcdf -lhdf5_hl -lhdf5/g' && "

sanity_check_paths = {
    'files': ['bin/cdo'],
    'dirs': [],
}

moduleclass = 'data'
