Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ runs:
COMPILER: ${{ inputs.compiler }}
VERSION: ${{ inputs.version }}
run: |
cd $(echo '/${{ github.action_path }}' | sed -e 's/\\/\//g' -e 's/://')
cd $(echo "$GITHUB_ACTION_PATH" | sed -e 's/\\/\//g' -e 's/://')
source ./main.sh

if [[ "${{ inputs.update-environment }}" == "true" ]]; then
Expand Down
45 changes: 27 additions & 18 deletions setup-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

set -ex

if command -v sudo > /dev/null 2>&1; then
SUDO=sudo
else
if [[ $EUID -ne 0 ]]; then
echo "This script requires 'sudo' to install packages. Please install 'sudo' or run as root."
exit 1
fi
fi

require_fetch()
{
if command -v curl > /dev/null 2>&1; then
Expand All @@ -18,7 +27,7 @@ require_fetch()
# https://github.com/cea-hpc/modules
install_environment_modules_apt() {
echo "Installing environment-modules package..."
sudo apt-get install -y environment-modules
$SUDO apt-get install -y environment-modules
echo "Environment-modules installed."
echo "Sourcing modules.sh script to set up environment modules..."
source /etc/profile.d/modules.sh
Expand Down Expand Up @@ -53,8 +62,8 @@ install_gcc_brew()
install_gcc_apt()
{
if [ "$version" == "latest" ]; then
sudo apt-get update
sudo apt-get install -y gcc gfortran g++
$SUDO apt-get update
$SUDO apt-get install -y gcc gfortran g++
else
# Check whether the system gcc version is the version we are after.
cur=$(apt show gcc | grep "Version" | cut -d':' -f3 | cut -d'-' -f1)
Expand All @@ -68,15 +77,15 @@ install_gcc_apt()
fi
else
# Install the PPA for installing other versions of gcc.
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo apt-get update
$SUDO add-apt-repository --yes ppa:ubuntu-toolchain-r/test
$SUDO apt-get update
fi

if [ "${needs_install}" == "1" ]; then
sudo apt-get install -y gcc-${version} gfortran-${version} g++-${version}
$SUDO apt-get install -y gcc-${version} gfortran-${version} g++-${version}
fi

sudo update-alternatives \
$SUDO update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${version} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${version} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${version} \
Expand Down Expand Up @@ -367,25 +376,25 @@ install_intel_apt()
require_fetch
local _KEY="GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB"
$fetch https://apt.repos.intel.com/intel-gpg-keys/$_KEY > $_KEY
sudo apt-key add $_KEY
$SUDO apt-key add $_KEY
rm $_KEY
echo "deb https://apt.repos.intel.com/oneapi all main" \
| sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
| $SUDO tee /etc/apt/sources.list.d/oneAPI.list
$SUDO apt-get update

if [ "$version" == "latest" ]; then
sudo apt-get install -y \
$SUDO apt-get install -y \
intel-oneapi-compiler-fortran \
intel-oneapi-compiler-dpcpp-cpp
else
# c/cpp compiler package names changed with 2024+
case $version in
2024* | 2025*)
sudo apt-get install -y \
$SUDO apt-get install -y \
intel-oneapi-compiler-{fortran,dpcpp-cpp}-$version
;;
*)
sudo apt-get install -y \
$SUDO apt-get install -y \
intel-oneapi-compiler-{fortran,dpcpp-cpp-and-cpp-classic}-$version
;;
esac
Expand Down Expand Up @@ -453,7 +462,7 @@ install_intel_dmg()
require_fetch
$fetch $MACOS_HPCKIT_URL > m_HPCKit.dmg
hdiutil attach m_HPCKit.dmg
sudo /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \
$SUDO /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \
--action install \
--eula=accept \
--continue-with-optional-error=yes \
Expand Down Expand Up @@ -589,10 +598,10 @@ install_nvidiahpc_apt()

# install NVIDIA HPC SDK
echo "Installing NVIDIA HPC SDK $version..."
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
sudo apt-get update -y
sudo apt-get install -y nvhpc-$cversion
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | $SUDO gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | $SUDO tee /etc/apt/sources.list.d/nvhpc.list
$SUDO apt-get update -y
$SUDO apt-get install -y nvhpc-$cversion
echo "NVIDIA HPC SDK $version installed."

# load NVIDIA HPC SDK module
Expand Down
Loading