From 76385ee0c4c035c8b47fb7c55d4f407efb003705 Mon Sep 17 00:00:00 2001 From: zaikunzhang Date: Thu, 25 Apr 2024 18:17:13 +0800 Subject: [PATCH] add scripts --- .github/scripts/LICENCE.txt | 165 ++++++++++++++++++ .github/scripts/README.md | 3 + .github/scripts/check_success_timeout | 64 +++++++ .../scripts/check_success_timeout_big_test | 64 +++++++ .github/scripts/install_aocc | 36 ++++ .github/scripts/install_epstopdf | 11 ++ .github/scripts/install_flang | 54 ++++++ .github/scripts/install_g95 | 30 ++++ .github/scripts/install_ghostscript | 52 ++++++ .github/scripts/install_nvfortran | 22 +++ .github/scripts/install_oneapi_linux.sh | 43 +++++ .github/scripts/install_oneapi_macos.sh | 57 ++++++ .github/scripts/install_oneapi_windows.bat | 56 ++++++ .github/scripts/install_pycutest | 55 ++++++ .github/scripts/install_sunf95 | 24 +++ .github/scripts/link_gfortran | 32 ++++ .github/scripts/misc_app | 30 ++++ .github/scripts/misc_env | 42 +++++ .github/scripts/misc_setup | 11 ++ 19 files changed, 851 insertions(+) create mode 100644 .github/scripts/LICENCE.txt create mode 100644 .github/scripts/README.md create mode 100755 .github/scripts/check_success_timeout create mode 100755 .github/scripts/check_success_timeout_big_test create mode 100755 .github/scripts/install_aocc create mode 100755 .github/scripts/install_epstopdf create mode 100755 .github/scripts/install_flang create mode 100755 .github/scripts/install_g95 create mode 100755 .github/scripts/install_ghostscript create mode 100755 .github/scripts/install_nvfortran create mode 100755 .github/scripts/install_oneapi_linux.sh create mode 100755 .github/scripts/install_oneapi_macos.sh create mode 100755 .github/scripts/install_oneapi_windows.bat create mode 100644 .github/scripts/install_pycutest create mode 100755 .github/scripts/install_sunf95 create mode 100755 .github/scripts/link_gfortran create mode 100755 .github/scripts/misc_app create mode 100755 .github/scripts/misc_env create mode 100755 .github/scripts/misc_setup diff --git a/.github/scripts/LICENCE.txt b/.github/scripts/LICENCE.txt new file mode 100644 index 0000000..153d416 --- /dev/null +++ b/.github/scripts/LICENCE.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. \ No newline at end of file diff --git a/.github/scripts/README.md b/.github/scripts/README.md new file mode 100644 index 0000000..0695ab4 --- /dev/null +++ b/.github/scripts/README.md @@ -0,0 +1,3 @@ +# What + +This repository contains some scripts that can be used in [GitHub Actions](https://docs.github.com/en/actions). diff --git a/.github/scripts/check_success_timeout b/.github/scripts/check_success_timeout new file mode 100755 index 0000000..6c1b640 --- /dev/null +++ b/.github/scripts/check_success_timeout @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Set maximum running time of the tests +MAX_RUNTIME_SECONDS=$((330*60)) +#MAX_RUNTIME_SECONDS=$((50)) + +# Install jq +sudo apt update && sudo apt install -y jq + +# Fetch the jobs for the current workflow run using the GitHub API +# $1 = ${{ secrets.GITHUB_TOKEN }} +# $2 = ${{ github.repository }} +# $3 = ${{ github.run_id }} +response=$(curl -s -H "Authorization: token $1" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$2/actions/runs/$3/jobs?per_page=100") + +echo "Response:" +echo "$response" +echo "Jobs length:" "$(echo "$response" | jq ' .jobs | length')" + +# Loop through all the test jobs +all_success_or_timeout=true +jobs_length=$(echo "$response" | jq ' .jobs | length') +for ((i=0; i> "$GITHUB_ENV" + +# Show the result of the installation. +echo "The AOCC flang installed is:" +aflang --version +echo "The path to AOCC flang is:" +command -v aflang diff --git a/.github/scripts/install_epstopdf b/.github/scripts/install_epstopdf new file mode 100755 index 0000000..1b74068 --- /dev/null +++ b/.github/scripts/install_epstopdf @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Usage: bash install_epstopdf + +sudo apt update && sudo apt install -y texlive wget +URL="https://tug.org/svn/texlive/trunk/Build/extra/epstopdf/epstopdf.pl?view=co" +sudo wget "$URL" -O /usr/bin/epstopdf +sudo chmod +x /usr/bin/epstopdf +which epstopdf +epstopdf --version +which kpsewhich +kpsewhich --version diff --git a/.github/scripts/install_flang b/.github/scripts/install_flang new file mode 100755 index 0000000..40473d5 --- /dev/null +++ b/.github/scripts/install_flang @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Usage: bash install_flang + +REPO_NAME="flang" +TMP_DIR="$(mktemp -d)" + +FLANG_DFT="$HOME/local/flang" + +if [[ ! -d /home/runner/work/ ]] ; then + printf "\nThe runner is not hosted by GitHub. Skip installation of p7zip and ncurses.\n" + if [[ -d $FLANG_DFT && -f $FLANG_DFT/bin/flang && -f $FLANG_DFT/bin/flang ]] ;then + echo "PATH=$PATH:$FLANG_DFT/bin" >> "$GITHUB_ENV" + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$FLANG_DFT/lib" >> "$GITHUB_ENV" + printf "\nflang is already installed. Skip installation.\n" + exit 0 + fi +else + if [[ "$RUNNER_OS" == "Linux" ]] ; then + sudo apt update && sudo apt install p7zip-full libncurses* # libncurses* needed for libtinfo.so + elif [[ "$RUNNER_OS" == "macOS" ]] ; then + brew install p7zip ncurses + fi +fi + +PI_MODEL_FILE="/sys/firmware/devicetree/base/model" +if [[ -f "$PI_MODEL_FILE" ]] && grep -qi 'Raspberry Pi' < "$PI_MODEL_FILE" ; then # Raspberry Pi + ARCH=aarch64 +elif [[ $(uname -s) == 'Darwin' ]] ; then # macOS + ARCH=macos_86 +else # Linux + ARCH=x86_64 +fi + +cd "$TMP_DIR" || exit 42 +git clone https://github.com/zaikunzhang/"$REPO_NAME".git + +cd "$REPO_NAME/$ARCH" || exit 42 +FLANG_7Z="flang.7z.001" +7za x "$FLANG_7Z" -aoa # -aoa: overwrite all existing files without prompt +rm -f flang.7z* + +# Set environment variable for subsequent steps +# N.B.: The following lines will not work if this script is invoked with sudo. +# Put flang/bin to the beginning of PATH, in case there is another flang in PATH, e.g., from AOCC. +echo "PATH=$TMP_DIR/$REPO_NAME/$ARCH/flang/bin:$PATH" >> "$GITHUB_ENV" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TMP_DIR/$REPO_NAME/$ARCH/flang/lib" >> "$GITHUB_ENV" + +# Show the result of the installation. +export PATH=$TMP_DIR/$REPO_NAME/$ARCH/flang/bin:$PATH +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TMP_DIR/$REPO_NAME/$ARCH/flang/lib +echo "The flang installed is:" +flang --version +echo "The path to flang is:" +command -v flang diff --git a/.github/scripts/install_g95 b/.github/scripts/install_g95 new file mode 100755 index 0000000..a2f0221 --- /dev/null +++ b/.github/scripts/install_g95 @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Usage: bash install_g95 + +REPO_NAME="g95" +TMP_DIR="$(mktemp -d)" +G95DIR="$TMP_DIR/$REPO_NAME/g95/" + +cd "$TMP_DIR" || exit 42 +git clone https://github.com/zaikunzhang/"$REPO_NAME" +cd "$REPO_NAME" || exit 42 +unzip g95.zip +rm -f g95.zip + +# Make some links +CRT1="$(find /usr/ -type f -name "crt1.o*" -print -quit)" +CRTI="$(find /usr/ -type f -name "crti.o*" -print -quit)" +CRTN="$(find /usr/ -type f -name "crtn.o*" -print -quit)" +ln -s "$CRT1" "$G95DIR/lib/gcc-lib/x86_64-unknown-linux-gnu/4.0.3/" +ln -s "$CRTI" "$G95DIR/lib/gcc-lib/x86_64-unknown-linux-gnu/4.0.3/" +ln -s "$CRTN" "$G95DIR/lib/gcc-lib/x86_64-unknown-linux-gnu/4.0.3/" + +# Set environment variable for subsequent steps +echo "PATH=$PATH:$G95DIR/bin:$G95DIR/lib/gcc-lib/x86_64-unknown-linux-gnu/4.0.3" >> "$GITHUB_ENV" + +# Show the result of the installation. +export PATH=$PATH:$G95DIR/bin:$G95DIR/lib/gcc-lib/x86_64-unknown-linux-gnu/4.0.3 +echo "The g95 installed is:" +g95 --version +echo "The path to g95 is:" +command -v g95 diff --git a/.github/scripts/install_ghostscript b/.github/scripts/install_ghostscript new file mode 100755 index 0000000..f2368b0 --- /dev/null +++ b/.github/scripts/install_ghostscript @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Usage: bash install_ghostscript + +# Default version. This is the latest version as of 20220926. This should not matter if the "Find +# out the latest version" part works properly. +VER_DFT=10.0.0 + +# The working directory. +DIR=$(mktemp -d) +cd "$DIR" || exit 42 + +# Find out the latest version. +RELEASE="https://www.ghostscript.com/releases/index.html" +WEBPG=index.html +wget "$RELEASE" -O "$WEBPG" +VER=$(grep "latest release" "$WEBPG" | grep -oE "([0-9]{1,}\.)+[0-9]{1,}") +if [[ -z "$VER" ]] ; then + printf "\n\n******Fail to find the latest version.******\n******Will install the default version: %s******\n\n" "$VER_DFT" + VER=$VER_DFT +fi +printf "\n\n******Version to install: %s******\n\n" "$VER" +VER_NO_DOT=${VER//\./} +VER_DFT_NO_DOT=${VER_DFT//\./} + +# Download URL +URL=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs"$VER_NO_DOT"/ghostscript-"$VER"-linux-x86_64.tgz +URL_DFT=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs"$VER_DFT_NO_DOT"/ghostscript-"$VER_DFT"-linux-x86_64.tgz + +TGZ=gs.tgz + +if wget "$URL" -O "$TGZ" > /dev/null 2>&1 ; then + NEWGS="ghostscript-$VER-linux-x86_64/gs-$VER_NO_DOT-linux-x86_64" +else + printf "******Failed to download the latest version.******\n******Will install the default version: %s******\n\n" "$VER_DFT" + wget "$URL_DFT" -O "$TGZ" + NEWGS="ghostscript-$VER_DFT-linux-x86_64/gs-$VER_DFT_NO_DOT-linux-x86_64" +fi + +GS="$(command -v gs)" +if [[ -z "$GS" ]] ; then + GS=/usr/bin/gs +fi + +tar zxvf "$TGZ" +if [[ -f "$GS" ]] ; then + sudo mv "$GS" "$GS".bak +fi +sudo cp "$NEWGS" "$GS" +rm -r "$DIR" + +gs -v +command -v gs diff --git a/.github/scripts/install_nvfortran b/.github/scripts/install_nvfortran new file mode 100755 index 0000000..636c7c2 --- /dev/null +++ b/.github/scripts/install_nvfortran @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Usage: bash install_nvfortran + +# ARCH is the architecture of the current system. +if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "aarch" ]] ; then + ARCH=arm64 +else + ARCH=amd64 +fi + +echo "deb [trusted=yes] https://developer.download.nvidia.com/hpc-sdk/ubuntu/$ARCH /" | sudo tee /etc/apt/sources.list.d/nvhpc.list +sudo apt update && sudo apt install -y nvhpc && sudo apt clean # clean is to remove the downloaded .deb files + +NVFORTRAN="$(find /opt/*nvidia* -type f -executable -name nvfortran -print | tail -1)" + +sudo ln -s "$NVFORTRAN" /usr/bin + +# Show the result of the installation. +echo "The nvfortran installed is:" +nvfortran --version +echo "The path to nvfortran is:" +command -v nvfortran diff --git a/.github/scripts/install_oneapi_linux.sh b/.github/scripts/install_oneapi_linux.sh new file mode 100755 index 0000000..c1e2e7a --- /dev/null +++ b/.github/scripts/install_oneapi_linux.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# This script installs the Fortran compilers provided in Intel OneAPI. +# Usage: bash install_oneapi_linux.sh + +# do the job in the temporary directory of the system +cd /tmp || exit 42 + +# download the key to system keyring +wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null + +# add signed entry to apt sources and configure the APT client to use Intel repository: +echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ + | sudo tee /etc/apt/sources.list.d/oneAPI.list + +# installation +sudo apt update +#sudo apt install intel-basekit intel-hpckit # Instead of this line, the following line seems to suffice +sudo apt install -y intel-oneapi-common-vars intel-oneapi-compiler-fortran +installer_exit_code=$? +sudo apt clean # Remove the .deb + +# Run the script that sets the necessary environment variables and then damp them to $GITHUB_ENV +# so that they are available in subsequent steps. +if [[ -f /opt/intel/oneapi/setvars.sh ]] ; then + source /opt/intel/oneapi/setvars.sh + env | grep -i 'intel\|oneapi' >> "$GITHUB_ENV" +else + exit 1 +fi + +# Show the result of the installation. +echo "The ifort installed is:" +ifort --version +echo "The path to ifort is:" +command -v ifort +echo "The ifx installed is:" +ifx --version +echo "The path to ifx is:" +command -v ifx + +# Exit with the installer exit code. +exit $installer_exit_code diff --git a/.github/scripts/install_oneapi_macos.sh b/.github/scripts/install_oneapi_macos.sh new file mode 100755 index 0000000..aecfb44 --- /dev/null +++ b/.github/scripts/install_oneapi_macos.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# This script installs the Fortran compilers provided in Intel OneAPI. +# See https://github.com/oneapi-src/oneapi-ci +# https://github.com/oneapi-src/oneapi-ci/blob/master/scripts/install_macos.sh +# +# Usage: bash install_oneapi_macos.sh +# +# Zaikun Zhang (www.zhangzk.net), January 9, 2023 + +# URL for the offline installer of Intel OneAPI Fortran compiler. To get the latest URL, search for +# "Intel Fortran Compiler Classic for macOS" at +# https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html +# and take the URL for the "Offline" installer. +# Default version: 2023.2.0 (updated on 20231015) +URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2fbce033-15f4-4e13-8d14-f5a2016541ce/m_fortran-compiler-classic_p_2023.2.0.49001_offline.dmg" +if [[ $# -ge 1 ]] ; then + if [[ $1 = "2022" ]] ; then + URL="https://registrationcenter-download.intel.com/akdlm/irc_nas/18977/m_HPCKit_p_2022.3.1.15344_offline.dmg" + fi + if [[ $1 = "2021" ]] ; then + URL="https://registrationcenter-download.intel.com/akdlm/irc_nas/18242/m_HPCKit_p_2021.4.0.3389_offline.dmg" + fi +fi + +# Component to install. +COMPONENTS=intel.oneapi.mac.ifort-compiler + +# Download the installer. curl is included by default in macOS. +cd "$TMPDIR" || exit 42 +curl --output webimage.dmg --url "$URL" --retry 5 --retry-delay 5 +hdiutil attach webimage.dmg + +# Install the compiler. +sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=. +installer_exit_code=$? + +# Run the script that sets the necessary environment variables and then damp them to $GITHUB_ENV +# so that they are available in subsequent steps. +if [[ -f /opt/intel/oneapi/setvars.sh ]] ; then + source /opt/intel/oneapi/setvars.sh + env | grep -i 'intel\|oneapi' >> "$GITHUB_ENV" +else + exit 1 +fi + +# Show the result of the installation. +echo "The ifort installed is:" +ifort --version +echo "The path to ifort is:" +command -v ifort + +# Remove the installer +rm webimage.dmg +hdiutil detach /Volumes/"$(basename "$URL" .dmg)" -quiet + +# Exit with the installer exit code. +exit $installer_exit_code diff --git a/.github/scripts/install_oneapi_windows.bat b/.github/scripts/install_oneapi_windows.bat new file mode 100755 index 0000000..ae768b5 --- /dev/null +++ b/.github/scripts/install_oneapi_windows.bat @@ -0,0 +1,56 @@ +:: This script installs the Fortran compilers provided in Intel OneAPI. +:: See https://github.com/oneapi-src/oneapi-ci +:: https://github.com/oneapi-src/oneapi-ci/blob/master/scripts/install_windows.bat +:: +:: Usage: cmd.exe "/K" '"install_oneapi_windows.bat"' +:: N.B.: This is a cmd script, which may not work in PowerShell. +:: +:: Zaikun Zhang (www.zhangzk.net), January 9, 2023 + +:: URL for the offline installer of Intel OneAPI Fortran compiler. To get the latest URL, search for +:: "Intel Fortran Compiler Classic and Intel Fortran Compiler for Windows" at +:: https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html +:: and take the URL for the "Offline" installer. +:: Default version: 2024.0.1 (updated on 20231219) +set URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/2e7500af-3097-4424-bd07-5d86c7791ec5/w_fortran-compiler_p_2024.0.1.30_offline.exe +if "%1"=="2023" ( + set URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/1720594b-b12c-4aca-b7fb-a7d317bac5cb/w_fortran-compiler_p_2023.2.1.7_offline.exe +) +if "%1"=="2022" ( + set URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18976/w_HPCKit_p_2022.3.1.19755_offline.exe +) +if "%1"=="2021" ( + set URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18247/w_HPCKit_p_2021.4.0.3340_offline.exe +) + +:: Component to install. +set COMPONENTS=intel.oneapi.win.ifort-compiler + +:: Download the installer. curl is included by default in Windows since Windows 10, version 1803. +::cd %Temp% :: CD does not work if %Temp% is on a different drive. +curl.exe --output webimage.exe --url %URL% --retry 5 --retry-delay 5 +start /b /wait webimage.exe -s -x -f webimage_extracted --log extract.log + +:: Install the compiler. +webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=. +set installer_exit_code=%ERRORLEVEL% + +:: Run the script that sets the necessary environment variables and then damp them to $GITHUB_ENV +:: so that they are available in subsequent steps. +:: N.B.: `grep 'intel\|oneapi'` does not work on Windows. +call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" +set | grep -i "intel" >> %GITHUB_ENV% +set | grep -i "oneapi" >> %GITHUB_ENV% + +:: Show the result of the installation. +echo The path to ifort is: +where ifort.exe +echo The path to ifx is: +where ifx.exe + +:: Remove the installer. +del webimage.exe +rd /s/q "webimage_extracted" + +:: Exit with the installer exit code. +exit /b %installer_exit_code% diff --git a/.github/scripts/install_pycutest b/.github/scripts/install_pycutest new file mode 100644 index 0000000..ff6c701 --- /dev/null +++ b/.github/scripts/install_pycutest @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# Usage: bash install_pycutest +# Requirements: having Python installed via actions/setup-python. + +set -e +set -x + +if [[ "$RUNNER_OS" == "Windows" ]]; then + echo "PyCUTEst is not available on $RUNNER_OS" 1>&2 + exit 1 +elif [[ "$RUNNER_OS" == "Linux" ]]; then + # Download CUTEst and its dependencies + mkdir "$GITHUB_WORKSPACE/cutest" + git clone --depth 1 --branch v2.1.24 https://github.com/ralna/ARCHDefs.git "$GITHUB_WORKSPACE/cutest/archdefs" + git clone --depth 1 --branch v2.0.6 https://github.com/ralna/SIFDecode.git "$GITHUB_WORKSPACE/cutest/sifdecode" + git clone --depth 1 --branch v2.0.17 https://github.com/ralna/CUTEst.git "$GITHUB_WORKSPACE/cutest/cutest" + git clone --depth 1 --branch v0.5 https://bitbucket.org/optrove/sif.git "$GITHUB_WORKSPACE/cutest/mastsif" + + # Set the environment variables + export ARCHDEFS="$GITHUB_WORKSPACE/cutest/archdefs" + export SIFDECODE="$GITHUB_WORKSPACE/cutest/sifdecode" + export CUTEST="$GITHUB_WORKSPACE/cutest/cutest" + export MASTSIF="$GITHUB_WORKSPACE/cutest/mastsif" + export MYARCH=pc64.lnx.gfo + { + echo "ARCHDEFS=$ARCHDEFS" + echo "SIFDECODE=$SIFDECODE" + echo "CUTEST=$CUTEST" + echo "MASTSIF=$MASTSIF" + echo "MYARCH=$MYARCH" + } >> "$GITHUB_ENV" + + # Build and install CUTEst + /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/jfowkes/pycutest/master/.install_cutest.sh)" +elif [[ "$RUNNER_OS" == "macOS" ]]; then + # Install gfortran + sudo ln -fs /usr/local/bin/gfortran-12 /usr/local/bin/gfortran + sudo ln -fs /usr/local/Cellar/gcc@12/*/lib/gcc/12/*.dylib /usr/local/lib/ + + # Install CUTEst + brew tap optimizers/cutest + brew install cutest --without-single + brew install mastsif + + # Set the environment variables + for f in "archdefs" "sifdecode" "cutest" "mastsif"; do + while IFS= read -r line; do + echo "${line#export }" >> "$GITHUB_ENV" + done <<< "$(cat "$(brew --prefix $f)/$f.bashrc")" + done +fi + +# Install PyCUTEst +echo "PYCUTEST_CACHE=$GITHUB_WORKSPACE" >> "$GITHUB_ENV" +python -m pip install --progress-bar=off pycutest diff --git a/.github/scripts/install_sunf95 b/.github/scripts/install_sunf95 new file mode 100755 index 0000000..e7a1716 --- /dev/null +++ b/.github/scripts/install_sunf95 @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# Usage: bash install_sunf95 + +REPO_NAME=OracleDevStd +TMP_DIR="$(mktemp -d)" +cd "$TMP_DIR" || exit 42 +git clone https://github.com/zaikunzhang/"$REPO_NAME".git + +cd "$REPO_NAME" || exit 42 +ORACLE_7Z="OracleDevStd.7z.001" +7za x "$ORACLE_7Z" -aoa # -aoa: overwrite all existing files without prompt +rm -f OracleDevStd.7z* + +# Set environment variable for subsequent steps +echo "PATH=$PATH:$TMP_DIR/$REPO_NAME/OracleDevStd/bin" >> "$GITHUB_ENV" +echo "LD_LIBRARY_PATH=$TMP_DIR/$REPO_NAME/OracleDevStd/lib/compilers/sys/amd64:$TMP_DIR/$REPO_NAME/OracleDevStd/lib/compilers/sys/:$LD_LIBRARY_PATH" >> "$GITHUB_ENV" + +# Show the result of the installation. +export PATH=$PATH:$TMP_DIR/$REPO_NAME/OracleDevStd/bin +export LD_LIBRARY_PATH=$TMP_DIR/$REPO_NAME/OracleDevStd/lib/compilers/sys/amd64:$TMP_DIR/$REPO_NAME/OracleDevStd/lib/compilers/sys/:$LD_LIBRARY_PATH +echo "The sunf95 installed is:" +sunf95 --version +echo "The path to sunf95 is:" +command -v sunf95 diff --git a/.github/scripts/link_gfortran b/.github/scripts/link_gfortran new file mode 100755 index 0000000..74692ce --- /dev/null +++ b/.github/scripts/link_gfortran @@ -0,0 +1,32 @@ +#!/usr/usr/bin/env bash +# This script installs the requested version of gfortran and links it to /usr/bin/gfortran +# +# Usage: bash link_gfortran + +if [[ $# -lt 1 ]]; then + printf "\nPlease provide the version of gfortran to link.\n\n" + exit 42 +fi + +REQUESTED_GFORTRAN_VERSION="$1" + +GFORTRAN_PATH="/usr/bin/gfortran" + +REQUESTED_GFORTRAN="gfortran-""$REQUESTED_GFORTRAN_VERSION" + +sudo apt update && sudo apt install "$REQUESTED_GFORTRAN" + +REQUESTED_GFORTRAN_PATH="$(realpath "$(command -v "$REQUESTED_GFORTRAN")")" + +if [[ -f "$GFORTRAN_PATH" ]] ; then + sudo mv "$GFORTRAN_PATH" "$GFORTRAN_PATH".bak +fi + +sudo ln -s "$REQUESTED_GFORTRAN_PATH" "$GFORTRAN_PATH" + +echo "gfortran is linked to" +realpath "$(command -v gfortran)" +echo "The version of gfortran is" +gfortran --version + +exit 0 diff --git a/.github/scripts/misc_app b/.github/scripts/misc_app new file mode 100755 index 0000000..4f68480 --- /dev/null +++ b/.github/scripts/misc_app @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# This script installs miscellaneous applications for GitHub Actions on ***hosted runners***. +# Usage: bash mist_setup + +# Exist if the runner is not hosted. Is there a better way to decide the runner type? +if [[ ("$RUNNER_OS" == "Linux" && ! -d /home/runner/work/) || ("$RUNNER_OS" == "macOS" && ! -d /Users/runner/work/) ]] ; then + printf "\nThe runner is not hosted by GitHub.\n" + exit 0 +fi + +if [[ "$RUNNER_OS" == "Linux" ]] ; then + sudo apt update + sudo apt install gdb make cmake ninja-build + gdb --version + make --version + cmake --version + ninja --version +elif [[ "$RUNNER_OS" == "macOS" ]] ; then + brew install coreutils make cmake ninja + make --version + cmake --version + ninja --version + # gdb cannot be installed by brew on macOS 14 with Apple Silicon chips as of 20240219 + (brew install gdb &> /dev/null && gbd --version) || echo "!!! WARNING: gdb cannot be installed !!!" +elif [[ "$RUNNER_OS" == "Windows" ]] ; then + choco install wget make cmake ninja --no-progress # gdb cannot be installed by choco + make --version + cmake --version + ninja --version +fi diff --git a/.github/scripts/misc_env b/.github/scripts/misc_env new file mode 100755 index 0000000..ccf8545 --- /dev/null +++ b/.github/scripts/misc_env @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# This script sets the following environment variables for GitHub Actions: +# ROOT_DIR: the root directory of the current repo +# TEST_DIR: a random directory under /tmp for testing +# SEDI: sed -i "" (mocOS) or sed -i (Linux/Windows) +# +# Usage: bash misc_env + +# Set ROOT_DIR to the root directory of the current repo. +ROOT_DIR="$(pwd -P)" # `realpath` is unavailable on macOS; -P is needed +echo "$ROOT_DIR" +echo "ROOT_DIR=$ROOT_DIR" >> "$GITHUB_ENV" + +# Set TEST_DIR to a random directory. It is needed in the Makefiles for the Fortran tests of PRIM. +TEST_DIR=/tmp/gittest_$(date +%s)_"$((RANDOM*RANDOM))" +echo "$TEST_DIR" +echo "TEST_DIR=$TEST_DIR" >> "$GITHUB_ENV" + +# Set SEDI to either 'sed -i ""' (macOS) or 'sed -i' (Linux/Windows). +# When calling "sed -i" on macOS, it is obligatory to specify a string (e.g., .bak) after -i as the +# extension for saving a backup. If the string is "", then no backup will be saved. If no string is +# specified, then an error will be raised, saying "invalid command code". +if [[ "$RUNNER_OS" = "macOS" ]] ; then + SEDI='sed -i ""' +else + SEDI='sed -i' +fi +echo "$SEDI" +echo "SEDI=$SEDI" >> "$GITHUB_ENV" + +# Set GFORTRAN_VERSION to the version of gfortran used when mexifying and linting Fortran code. +GFORTRAN_VERSION=13 +echo "$GFORTRAN_VERSION" +echo "GFORTRAN_VERSION=$GFORTRAN_VERSION" >> "$GITHUB_ENV" + +# The following does not work. Why? +# Make tools such as grep, make, and git available on Windows. +#if [[ "$RUNNER_OS" = "Windows" ]] ; then +# PATH="$PATH"":/c/Program Files/Git/usr/bin:/c/Program Files/Git/bin:/c/ProgramData/Chocolatey/bin" +# echo "$PATH" +# echo "PATH=$PATH" >> "$GITHUB_ENV" +#fi diff --git a/.github/scripts/misc_setup b/.github/scripts/misc_setup new file mode 100755 index 0000000..7841644 --- /dev/null +++ b/.github/scripts/misc_setup @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# This script sets the miscellanies environment variables and installs miscellaneous applications +# for GitHub Actions: +# +# Usage: bash misc_setup + +# The directory where this scrip resides +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +bash "$SCRIPT_DIR"/misc_env +bash "$SCRIPT_DIR"/misc_app