diff --git a/.github/common/build_executables.py b/.github/common/build_executables.py index df9861d..c181833 100755 --- a/.github/common/build_executables.py +++ b/.github/common/build_executables.py @@ -1,8 +1,7 @@ -import os import sys -import pymake import subprocess -import pathlib as pl + +RETRIES = 3 def get_ostag() -> str: @@ -27,15 +26,31 @@ def get_cctag() -> str: raise ValueError(f"platform {sys.platform!r} not supported") +def mfpymake_run_command(args) -> bool: + success = False + for idx in range(RETRIES): + p = subprocess.run(args) + if p.returncode == 0: + success = True + break + print(f"{args[0]} run {idx + 1}/{RETRIES} failed...rerunning") + return success + + if __name__ == "__main__": - path = (pl.Path(os.path.dirname(pymake.__file__)) / "../").resolve() - print(f"path to pymake: {path}") + cmd = [ + "make-code-json", + "-f", + f"{get_ostag()}/code.json", + "--verbose", + ] - file_path = pl.Path(".github/common/buildall.py") + if not mfpymake_run_command(cmd): + raise RuntimeError(f"could not run {cmd[0]}") - cmds = [ - "python", - file_path, + cmd = [ + "make-program", + ":", f"--appdir={get_ostag()}", "-fc=ifort", f"-cc={get_cctag()}", @@ -43,14 +58,6 @@ def get_cctag() -> str: "--keep", ] - retries = 3 - success = False - for idx in range(retries): - p = subprocess.run(cmds) - if p.returncode == 0: - success = True - break - print(f"run {idx + 1}/{retries} failed...rerunning") + if not mfpymake_run_command(cmd): + raise RuntimeError("could not build the executables") - if not success: - raise RuntimeError("could not build the executables") \ No newline at end of file diff --git a/.github/common/buildall.py b/.github/common/buildall.py deleted file mode 100644 index 86e4fba..0000000 --- a/.github/common/buildall.py +++ /dev/null @@ -1,20 +0,0 @@ -# Build the executables that are used in the flopy autotests - -try: - import pymake -except: - print("pymake is not installed...will not build executables") - pymake = None - - -def build_all(): - if pymake is not None: - # build code json - pymake.usgs_program_data.export_json(current=True, write_markdown=True) - - # build all of the applications - pymake.build_apps(release_precision=False, verbose=True) - - -if __name__ == "__main__": - build_all() diff --git a/.github/intel-scripts/README.md b/.github/intel-scripts/README.md deleted file mode 100755 index 87b994e..0000000 --- a/.github/intel-scripts/README.md +++ /dev/null @@ -1,17 +0,0 @@ -These scripts install the ifort compiler on the CI machines. - -The content has been directly copied from the Intel OneAPI-CI examples, found -here: - -https://github.com/oneapi-src/oneapi-ci - -Note that on Linux and macOS, shell scripts must be marked as executable: not -doing so for these scripts will result in a permission error during the GitHub -Action. Windows does not have such a permission system, but you can mark a -script nonetheless with git: - -```sh -git update-index --chmod=+x {name_of_script} -``` - -Then commit and push. diff --git a/.github/intel-scripts/cache_exclude_linux.sh b/.github/intel-scripts/cache_exclude_linux.sh deleted file mode 100755 index 0e835d2..0000000 --- a/.github/intel-scripts/cache_exclude_linux.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020 Intel Corporation -# -# SPDX-License-Identifier: MIT - -#shellcheck disable=SC2010 -LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1) - -sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/compiler/lib/ia32_lin -sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/bin/ia32 -sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/emu -sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/oclfpga \ No newline at end of file diff --git a/.github/intel-scripts/cache_exclude_windows.sh b/.github/intel-scripts/cache_exclude_windows.sh deleted file mode 100755 index f396a94..0000000 --- a/.github/intel-scripts/cache_exclude_windows.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020 Intel Corporation -# -# SPDX-License-Identifier: MIT - -#shellcheck disable=SC2010 -LATEST_VERSION=$(ls -1 "C:\Program Files (x86)\Intel\oneAPI\compiler" | grep -v latest | sort | tail -1) - -rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\compiler\lib\ia32_win" -rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\bin\intel64_ia32" -rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\emu" -rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\oclfpga" -rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\ocloc" -rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\x86" \ No newline at end of file diff --git a/.github/intel-scripts/ifortvars_linux.sh b/.github/intel-scripts/ifortvars_linux.sh deleted file mode 100755 index 35943c4..0000000 --- a/.github/intel-scripts/ifortvars_linux.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020 Intel Corporation -# -# SPDX-License-Identifier: MIT - -#shellcheck disable=SC2010 -LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1) -# shellcheck source=/dev/null -source /opt/intel/oneapi/compiler/"$LATEST_VERSION"/env/vars.sh - -# print intel compiler versions -ifort --version -icc --version - -# build executables -python .github/common/build_executables.py - diff --git a/.github/intel-scripts/ifortvars_macos.sh b/.github/intel-scripts/ifortvars_macos.sh deleted file mode 100755 index 1232334..0000000 --- a/.github/intel-scripts/ifortvars_macos.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020 Intel Corporation -# -# SPDX-License-Identifier: MIT - -source /opt/intel/oneapi/setvars.sh - -# print intel compiler versions -ifort --version -icc --version - -# build executables -python .github/common/build_executables.py - diff --git a/.github/intel-scripts/ifortvars_windows.bat b/.github/intel-scripts/ifortvars_windows.bat deleted file mode 100755 index 8deb1f8..0000000 --- a/.github/intel-scripts/ifortvars_windows.bat +++ /dev/null @@ -1,16 +0,0 @@ -REM SPDX-FileCopyrightText: 2020 Intel Corporation -REM -REM SPDX-License-Identifier: MIT - -set LANGUAGE=%1 -set VS_VER=%2 - -IF "%VS_VER%"=="2017_build_tools" ( -@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" -) - -IF "%VS_VER%"=="2019_build_tools" ( -@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" -) -for /f "tokens=* usebackq" %%f in (`dir /b "C:\Program Files (x86)\Intel\oneAPI\compiler\" ^| findstr /V latest ^| sort`) do @set "LATEST_VERSION=%%f" -@call "C:\Program Files (x86)\Intel\oneAPI\compiler\%LATEST_VERSION%\env\vars.bat" diff --git a/.github/intel-scripts/install_linux.sh b/.github/intel-scripts/install_linux.sh deleted file mode 100755 index 5279447..0000000 --- a/.github/intel-scripts/install_linux.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020 Intel Corporation -# -# SPDX-License-Identifier: MIT - -URL=$1 -COMPONENTS=$2 - -curl --output webimage.sh --url "$URL" --retry 5 --retry-delay 5 -chmod +x webimage.sh -./webimage.sh -x -f webimage_extracted --log extract.log -rm -rf webimage.sh -WEBIMAGE_NAME=$(ls -1 webimage_extracted/) -if [ -z "$COMPONENTS" ]; then - sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --eula=accept --log-dir=. - installer_exit_code=$? -else - sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=. - installer_exit_code=$? -fi -rm -rf webimage_extracted -exit $installer_exit_code \ No newline at end of file diff --git a/.github/intel-scripts/install_macos.sh b/.github/intel-scripts/install_macos.sh deleted file mode 100755 index ac758cc..0000000 --- a/.github/intel-scripts/install_macos.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2020 Intel Corporation -# -# SPDX-License-Identifier: MIT - -URL=$1 -COMPONENTS=$2 - -curl --output webimage.dmg --url "$URL" --retry 5 --retry-delay 5 -hdiutil attach webimage.dmg -if [ -z "$COMPONENTS" ]; then - sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=. - installer_exit_code=$? -else - sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --continue-with-optional-error=yes --log-dir=. - installer_exit_code=$? -fi -hdiutil detach /Volumes/"$(basename "$URL" .dmg)" -quiet -exit $installer_exit_code \ No newline at end of file diff --git a/.github/intel-scripts/install_windows.bat b/.github/intel-scripts/install_windows.bat deleted file mode 100755 index 64769b0..0000000 --- a/.github/intel-scripts/install_windows.bat +++ /dev/null @@ -1,15 +0,0 @@ -REM SPDX-FileCopyrightText: 2020 Intel Corporation -REM -REM SPDX-License-Identifier: MIT - -set URL=%1 -set COMPONENTS=%2 - -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 -del webimage.exe -if "%COMPONENTS%"=="" ( - webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 --log-dir=. -) else ( - webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 --log-dir=. -) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 6ed729c..a03f618 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -13,44 +13,26 @@ jobs: strategy: fail-fast: false matrix: - include: - - os: ubuntu-20.04 - os_script: ifortvars_linux.sh - artifact_name: linux.zip - - os: macos-latest - os_script: ifortvars_macos.sh - artifact_name: mac.zip - - os: windows-2019 - os_script: ifortvars_windows.bat - artifact_name: win64.zip + os: [ubuntu-20.04, macos-latest, windows-2019] defaults: run: shell: bash - env: - WINDOWS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/18976/w_HPCKit_p_2022.3.1.19755_offline.exe - LINUX_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/18975/l_HPCKit_p_2022.3.1.16997_offline.sh - MACOS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/18977/m_HPCKit_p_2022.3.1.15344_offline.dmg - WINDOWS_FORTRAN_COMPONENTS: intel.oneapi.win.ifort-compiler - LINUX_FORTRAN_COMPONENTS_WEB: intel.oneapi.lin.ifort-compiler - MACOS_FORTRAN_COMPONENTS: intel.oneapi.mac.ifort-compiler - WINDOWS_CPP_COMPONENTS: intel.oneapi.win.cpp-compiler - LINUX_CPP_COMPONENTS_WEB: intel.oneapi.lin.dpcpp-cpp-compiler-pro - MACOS_CPP_COMPONENTS: intel.oneapi.mac.cpp-compiler - FC: ifort - -# if: -# github.event_name == 'push' + steps: - name: Checkout repo uses: actions/checkout@v3 + - name: Setup Intel OneAPI Compilers + uses: modflowpy/install-intelfortran-action@v1 + - uses: oprypin/find-latest-tag@v1 with: repository: MODFLOW-USGS/executables # The repository to scan. releases-only: true # We know that all relevant tags have a GitHub release for them. id: executables # The step ID to refer to later. - - run: | + - name: Setup persistent environment variables + run: | echo "MODFLOW-USGS/executables is at version ${{ steps.executables.outputs.tag }}" echo "RELEASE_VERSION=${{ steps.executables.outputs.tag }}" >> $GITHUB_ENV @@ -69,60 +51,15 @@ jobs: run: | pip list - - name: cache install intel compilers on linux - if: runner.os == 'Linux' - id: cache-install-linux - uses: actions/cache@v3.0.11 - with: - path: | - /opt/intel/oneapi/compiler - key: install-${{ env.LINUX_HPCKIT_URL }}-${{ env.LINUX_CPP_COMPONENTS_WEB }}-${{ env.LINUX_FORTRAN_COMPONENTS_WEB }}-compiler-${{ hashFiles('**/.github/intel-scripts/cache_exclude_linux.sh') }} - - - name: install intel compilers on linux - if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true' - run: | - .github/intel-scripts/install_linux.sh $LINUX_HPCKIT_URL $LINUX_CPP_COMPONENTS_WEB:$LINUX_FORTRAN_COMPONENTS_WEB - - - name: cache install intel compilers on macos - if: runner.os == 'macOS' - id: cache-install-macos - uses: actions/cache@v3.0.11 - with: - path: /opt/intel/oneapi - key: install-${{ env.MACOS_HPCKIT_URL }}--${{ env.MACOS_CPP_COMPONENTS }}-${{ env.MACOS_FORTRAN_COMPONENTS }} - - - name: install intel compilers on macos - if: runner.os == 'macOS' && steps.cache-install-macos.outputs.cache-hit != 'true' - run: | - .github/intel-scripts/install_macos.sh $MACOS_HPCKIT_URL $MACOS_CPP_COMPONENTS:$MACOS_FORTRAN_COMPONENTS - - - name: cache install intel compilers on windows - if: runner.os == 'Windows' - id: cache-install-windows - uses: actions/cache@v3.0.11 - with: - path: C:\Program Files (x86)\Intel\oneAPI\compiler - key: install-${{ env.WINDOWS_HPCKIT_URL }}-${{ env.WINDOWS_CPP_COMPONENTS }}-${{ env.WINDOWS_FORTRAN_COMPONENTS }}-compiler-${{ hashFiles('**/.github/intel-scripts/cache_exclude_windows.sh') }} - - - name: install intel compilers on windows - if: runner.os == 'Windows' && steps.cache-install-windows.outputs.cache-hit != 'true' - run: | - .github/intel-scripts/install_windows.bat $WINDOWS_HPCKIT_URL $WINDOWS_CPP_COMPONENTS:$WINDOWS_FORTRAN_COMPONENTS - - - name: activate intel compilers and build executables on linux and macOS - if: runner.os == 'Linux' || runner.os == 'macOS' - env: - CC: icc + - name: build executables on Linux and macOS + if: runner.os != 'Windows' run: | - .github/intel-scripts/${{ matrix.os_script }} + python .github/common/build_executables.py - - name: activate intel compilers and build executables on Windows + - name: build executables on Windows if: runner.os == 'Windows' - env: - CC: icl shell: cmd run: | - call ".github/intel-scripts/ifortvars_windows.bat" python .github/common/build_executables.py - name: Upload a Build Artifact @@ -130,7 +67,7 @@ jobs: with: name: release_build path: | - ./${{ matrix.artifact_name }} + ./*.zip - name: Upload additional Build Artifacts if: runner.os == 'Linux' @@ -141,16 +78,6 @@ jobs: ./code.json ./code.md - - name: exclude unused files from cache on windows - if: runner.os == 'Windows' && steps.cache-install-windows.outputs.cache-hit != 'true' - run: | - .github/intel-scripts/cache_exclude_windows.sh - - - name: exclude unused files from cache on linux - if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true' - run: | - .github/intel-scripts/cache_exclude_linux.sh - # make the release if previous job was successful release: @@ -161,8 +88,6 @@ jobs: run: shell: bash -# if: -# github.event_name == 'push' steps: - name: Setup Python uses: actions/setup-python@v4 @@ -230,16 +155,6 @@ jobs: allowUpdates: true token: ${{ secrets.GITHUB_TOKEN }} -# - name: Upload compiled executables to the latest GitHub release -# if: github.event_name == 'push' -# uses: svenstaro/upload-release-action@2.3.0 -# with: -# repo_token: ${{ secrets.GITHUB_TOKEN }} -# file: ./release_build/* -# tag: $NEXT_VERSION -# overwrite: true -# file_glob: true -# # - name: Delete Artifact # uses: GeekyEggo/delete-artifact@v1.0.0 # with: diff --git a/README.md b/README.md index 5aa6653..f07c1d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # MODFLOW EXECUTABLES -The purpose of this repository is to distribute binary executable programs for MODFLOW and related programs that will run on Windows, Mac, and Linux operating systems. Executables for these different operating systems can be found under the [release](https://github.com/MODFLOW-USGS/executables/releases) tab above and are named: +The purpose of this repository is to distribute binary executable programs for MODFLOW and related programs that will run on Windows, Mac, and Linux operating systems. These programs are compiled using [pymake](https://github.com/modflowpy/pymake) and the Intel OneAPI compilers. The release also includes a json file ([code.json](https://github.com/MODFLOW-USGS/executables/releases/latest/download/code.json)) that includes the current version number and the url address that can be used to download the source files used to build these programs. + +Executables for these different operating systems can be found under the [release](https://github.com/MODFLOW-USGS/executables/releases) tab above and are named: * [win64.zip](https://github.com/MODFLOW-USGS/executables/releases/latest/download/win64.zip) * [mac.zip](https://github.com/MODFLOW-USGS/executables/releases/latest/download/mac.zip) @@ -10,28 +12,23 @@ The programs, version numbers, and the date stamp on the downloaded file used to | Program | Version | UTC Date | | ------- | ------- | ---- | -| mf6 | 6.4.0 | 12/01/2022 | -| zbud6 | 6.4.0 | 12/01/2022 | -| libmf6 | 6.4.0 | 12/01/2022 | -| mp7 | 7.2.001 | 10/23/2018 | -| mt3dms | 5.3.0 | 02/21/2010 | -| mt3dusgs | 1.1.0 | 07/12/2019 | -| vs2dt | 3.3 | 04/02/2018 | -| triangle | 1.6 | 07/29/2005 | -| gridgen | 1.0.02 | 10/24/2018 | | crt | 1.3.1 | 04/11/2017 | -| sutra | 3.0 | 08/20/2019 | +| gridgen | 1.0.02 | 10/24/2018 | +| libmf6 | 6.4.1 | 12/09/2022 | | mf2000 | 1.19.01 | 03/30/2010 | | mf2005 | 1.12.00 | 12/07/2021 | +| mf6 | 6.4.1 | 12/09/2022 | +| mflgr | 2.0.0 | 09/20/2013 | +| mfnwt | 1.3.0 | 09/07/2022 | | mfusg | 1.5 | 02/27/2019 | -| zonbudusg | 1.5 | 02/27/2019 | -| swtv4 | 4.00.05 | 10/24/2018 | | mp6 | 6.0.1 | 10/23/2018 | -| mflgr | 2.0.0 | 09/20/2013 | +| mp7 | 7.2.001 | 10/23/2018 | +| mt3dms | 5.3.0 | 02/21/2010 | +| mt3dusgs | 1.1.0 | 07/12/2019 | +| sutra | 3.0 | 08/20/2019 | +| swtv4 | 4.00.05 | 10/24/2018 | +| triangle | 1.6 | 07/29/2005 | +| vs2dt | 3.3 | 04/02/2018 | +| zbud6 | 6.4.1 | 12/09/2022 | | zonbud3 | 3.01 | 10/25/2018 | -| mfnwt | 1.3.0 | 09/07/2022 | - - - -These programs are compiled using [pymake](https://github.com/modflowpy/pymake) and the Intel OneAPI compilers. The release also includes a json file ([code.json](https://github.com/MODFLOW-USGS/executables/releases/latest/download/code.json)) that includes the current version number and the url address that can be used to download the source files used to build these programs. - +| zonbudusg | 1.5 | 02/27/2019 | diff --git a/update_readme.py b/update_readme.py new file mode 100644 index 0000000..f80766a --- /dev/null +++ b/update_readme.py @@ -0,0 +1,46 @@ +import subprocess +import pathlib as pl + +target_file = pl.Path("code.md") +TAG = "| Program | Version | UTC Date |" +FILES = ("code.json", "code.md") + + +def _create_code_json() -> None: + subprocess.run( + [ + "make-code-json", + "-f", + f"code.json", + "--verbose", + ] + ) + + if not target_file.is_file(): + raise FileNotFoundError(f"{target_file} does not exist") + + +def _update_readme() -> None: + with open("README.md", "r") as f: + readme_md = f.read().splitlines() + with open("code.md", "r") as f: + code_md = f.read().splitlines() + with open("README.md", "w") as f: + for line in readme_md: + if TAG not in line: + f.write(f"{line}\n") + else: + for code_line in code_md: + f.write(f"{code_line}\n") + break + + +def _clean_files() -> None: + for file in FILES: + pl.Path(file).unlink() + + +if __name__ == "__main__": + _create_code_json() + _update_readme() + _clean_files()