# IT4Innovations 2022
# JK LK

name = 'intel-compilers'
version = '2021.2.0'

homepage = 'https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit.html'
description = "Intel C, C++ & Fortran compilers (classic and oneAPI)"

toolchain = SYSTEM

# see https://software.intel.com/content/www/us/en/develop/articles/oneapi-standalone-components.html
sources = [
    {
        'source_urls': ['https://registrationcenter-download.intel.com/akdlm/irc_nas/17749/'],
        'filename': 'l_dpcpp-cpp-compiler_p_%(version)s.118_offline.sh',
    },
    {
        'source_urls': ['https://registrationcenter-download.intel.com/akdlm/irc_nas/17756/'],
        'filename': 'l_fortran-compiler_p_%(version)s.136_offline.sh',
    },
]
checksums = [
    # l_dpcpp-cpp-compiler_p_2021.2.0.118_offline.sh
    '5d01cbff1a574c3775510cd97ffddd27fdf56d06a6b0c89a826fb23da4336d59',
    'a62e04a80f6d2f05e67cd5acb03fa58857ee22c6bd581ec0651c0ccd5bdec5a1',  # l_fortran-compiler_p_2021.2.0.136_offline.sh
]

local_gccver = '10.3.0'
dependencies = [
    ('GCCcore', local_gccver),
    ('binutils', '2.36.1', '', ('GCCcore', local_gccver)),
]

license_file = '/apps/licenses/intel/license.lic'
accept_eula = True


import os
if os.environ.get("CLUSTERNAME") in ["KAROLINA"]:
   	modextravars = {
		"DEBUGFLAGS": "-O0 -g",
		"CC": "icc",
		"CXX": "icpc",
		"F77": "ifort",
		"F90": "ifort",
		"FC": "ifort",
		"OPTFLAGS": "-O3 -fPIC -march=core-avx2",
		"CXXFLAGS": "-O3 -fPIC -march=core-avx2",
		"CFLAGS": "-O3 -fPIC -march=core-avx2",
		"FCFLAGS": "-O3 -fPIC -march=core-avx2",
		"FFLAGS": "-O3 -fPIC -march=core-avx2",
		"EASYBUILD_OPTARCH": "march=core-avx2",
	}
elif os.environ.get("CLUSTERNAME") in ["BARBORA"]:
	modextravars = {
                "CC": "icc",
                "CXX": "icpc",
                "F77": "ifort",
                "F90": "ifort",
                "FC": "ifort",
		"OPTFLAGS": "-O3 -xHost -ip",
	}
elif os.environ.get("CLUSTERNAME") in ["CS"]:
	if os.environ.get("MFLAGS") in ["avx2"]:
        	modextravars = {
                	"DEBUGFLAGS": "-O0 -g",
                	"CC": "icc",
                	"CXX": "icpc",
                	"F77": "ifort",
                	"F90": "ifort",
                	"FC": "ifort",
                	"OPTFLAGS": "-O3 -fPIC -march=core-avx2",
                	"CXXFLAGS": "-O3 -fPIC -march=core-avx2",
                	"CFLAGS": "-O3 -fPIC -march=core-avx2",
                	"FCFLAGS": "-O3 -fPIC -march=core-avx2",
                	"FFLAGS": "-O3 -fPIC -march=core-avx2",
                	"EASYBUILD_OPTARCH": "march=core-avx2",
	}
	elif os.environ.get("MFLAGS") in ["avx512"]:
		modextravars = {
                	"DEBUGFLAGS": "-O0 -g",
                	"CC": "icc",
                	"CXX": "icpc",
                	"F77": "ifort",
                	"F90": "ifort",
                	"FC": "ifort",
                	"OPTFLAGS": "-O3 -fPIC -march=core-avx512",
                	"CXXFLAGS": "-O3 -fPIC -march=core-avx512",
                	"CFLAGS": "-O3 -fPIC -march=core-avx512",
                	"FCFLAGS": "-O3 -fPIC -march=core-avx512",
                	"FFLAGS": "-O3 -fPIC -march=core-avx512",
                	"EASYBUILD_OPTARCH": "march=core-avx512",
        	}

moduleclass = 'compiler'
