Skip to content

Instantly share code, notes, and snippets.

@codedeep79
Created October 4, 2025 03:09
Show Gist options
  • Select an option

  • Save codedeep79/eff8c07906daaac196a5a93c7acef648 to your computer and use it in GitHub Desktop.

Select an option

Save codedeep79/eff8c07906daaac196a5a93c7acef648 to your computer and use it in GitHub Desktop.
script cài đặt Intel Fortran Compiler (ifort / ifx trong Intel oneAPI HPC Toolkit) cho hầu hết các distro Linux phổ biến (Ubuntu/Debian, CentOS/RHEL/Fedora, Arch).
#!/usr/bin/env bash
# Script cài đặt Intel Fortran Compiler (ifort/ifx) trên Linux
# Hỗ trợ: Ubuntu/Debian, CentOS/RHEL/Fedora, Arch (AUR)
set -e
echo "🔎 Phát hiện hệ điều hành..."
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
else
echo "❌ Không nhận diện được distro"
exit 1
fi
echo "👉 Distro: $DISTRO"
case "$DISTRO" in
ubuntu|debian)
echo "📦 Cài đặt Intel oneAPI HPC Toolkit trên Ubuntu/Debian..."
wget -qO- https://apt.repos.intel.com/intel-gpg-keys/Intel_GPG_Keys.pub | sudo apt-key add -
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" -y
sudo apt update
sudo apt install intel-hpckit -y
;;
centos|rhel)
echo "📦 Cài đặt Intel oneAPI HPC Toolkit trên CentOS/RHEL..."
wget https://yum.repos.intel.com/oneapi/Intel-OneAPI.repo
sudo mv Intel-OneAPI.repo /etc/yum.repos.d/
sudo yum install intel-hpckit -y
;;
fedora)
echo "📦 Cài đặt Intel oneAPI HPC Toolkit trên Fedora..."
wget https://yum.repos.intel.com/oneapi/Intel-OneAPI.repo
sudo mv Intel-OneAPI.repo /etc/yum.repos.d/
sudo dnf install intel-hpckit -y
;;
arch|manjaro)
echo "📦 Cài đặt Intel oneAPI HPC Toolkit trên Arch/Manjaro (AUR)..."
if ! command -v yay &> /dev/null; then
echo "⚠️ Chưa có yay (AUR helper). Hãy cài đặt yay trước:"
echo " git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si"
exit 1
fi
yay -S intel-oneapi-basekit intel-oneapi-hpckit --noconfirm
;;
*)
echo "❌ Distro $DISTRO chưa được hỗ trợ trực tiếp."
echo "👉 Vui lòng cài thủ công từ: https://www.intel.com/content/www/us/en/developer/tools/oneapi/toolkits.html"
exit 1
;;
esac
# Load môi trường oneAPI
if [ -f /opt/intel/oneapi/setvars.sh ]; then
echo "✅ Cài đặt xong. Kích hoạt Intel oneAPI environment..."
echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bashrc
source /opt/intel/oneapi/setvars.sh
else
echo "⚠️ Không tìm thấy /opt/intel/oneapi/setvars.sh"
fi
# Kiểm tra compiler
echo "⚡ Kiểm tra trình biên dịch Fortran..."
if command -v ifort &> /dev/null; then
ifort --version
elif command -v ifx &> /dev/null; then
ifx --version
else
echo "❌ Không tìm thấy ifort/ifx, vui lòng kiểm tra lại cài đặt."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment