name: hdf4 dev ctest script runs

# Triggers the workflow on a call from another workflow
on:
  workflow_call:
    inputs:
      snap_name:
        description: 'The name in the source tarballs'
        type: string
        required: false
        default: hdfsrc
      file_base:
        description: "The common base name of the source tarballs"
        required: true
        type: string
      use_environ:
        description: 'Environment to locate files'
        type: string
        required: true
        default: snapshots

permissions:
  contents: read

jobs:
  build_and_test_win:
  # Windows w/ MSVC + CMake
  #
    name: "Windows MSVC CTest"
    runs-on: windows-latest
    steps:
      - name: Install Dependencies (Windows)
        run: choco install ninja

      - name: Install Dependencies
        uses: ssciwr/doxygen-install@v1
        with:
          version: "1.10.0"

      - name: Enable Developer Command Prompt
        uses: ilammy/msvc-dev-cmd@v1.13.0

      - name: Set file base name (Windows)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT
        shell: bash

      # Get files created by release script
      - name: Get zip-tarball (Windows)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
              name: zip-tarball
              path: ${{ github.workspace }}

      - name: using powershell
        shell: pwsh
        run: Get-Location

      - name: List files for the space (Windows)
        run: |
              Get-ChildItem -Path ${{ github.workspace }}
              Get-ChildItem -Path ${{ runner.workspace }}
        shell: pwsh

      - name: Uncompress source (Windows)
        working-directory: ${{ github.workspace }}
        run: 7z x ${{ steps.set-file-base.outputs.FILE_BASE }}.zip
        shell: bash

      - name: Copy script files for the space (Windows)
        run: |
          Copy-Item -Path ${{ runner.workspace }}/hdf4/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake -Destination ${{ runner.workspace }}/hdf4/
          Copy-Item -Path ${{ runner.workspace }}/hdf4/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake -Destination ${{ runner.workspace }}/hdf4/
        shell: pwsh

      - name: List files for the hdf4 (Windows)
        run: |
          Get-ChildItem -Path ${{ runner.workspace }}/hdf4
        shell: pwsh

      - name: Create options file (Windows)
        uses: "DamianReeves/write-file-action@master"
        with:
            path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
            write-mode: overwrite
            contents: |
              set (CTEST_DROP_SITE_INIT "my.cdash.org")
              # Change following line to submit to your CDash dashboard to a different CDash project
              #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
              set (MODEL "GHDaily")
              set (GROUP "GHDaily")
              set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest script (Windows)
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }},LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=VS202264,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: bash
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (Windows_intel)
        uses: actions/upload-artifact@v4
        with:
          name: cl-win-log
          path: ${{ runner.workspace }}/hdf4/hdf4.log
          if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

  build_and_test_linux:
  # Linux (Ubuntu) w/ gcc + CMake
  #
    name: "Ubuntu gcc CMake"
    runs-on: ubuntu-latest
    steps:
      - name: Install CMake Dependencies (Linux)
        run: |
          sudo apt-get update
          sudo apt-get install ninja-build graphviz curl

      - name: Install Dependencies
        uses: ssciwr/doxygen-install@v1
        with:
          version: "1.10.0"

      - name: Set file base name (Linux)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT

      # Get files created by release script
      - name: Get tgz-tarball (Linux)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
              name: tgz-tarball
              path: ${{ github.workspace }}

      - name: List files for the space (Linux)
        run: |
            ls -l ${{ github.workspace }}
            ls ${{ runner.workspace }}

      - name: Uncompress source (Linux)
        run: tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz

      - name: Copy script files for the space (Linux)
        run: |
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake ${{ runner.workspace }}/hdf4
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake ${{ runner.workspace }}/hdf4

      - name: List files for the hdf4 (Linux)
        run: |
            ls ${{ runner.workspace }}/hdf4

      - name: Create options file (Linux)
        uses: "DamianReeves/write-file-action@master"
        with:
          path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
          write-mode: overwrite
          contents: |
            set (CTEST_DROP_SITE_INIT "my.cdash.org")
            # Change following line to submit to your CDash dashboard to a different CDash project
            #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
            set (MODEL "GHDaily")
            set (GROUP "GHDaily")
            set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest (Linux)
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }}-GCC,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=Unix,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: bash
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (Linux)
        uses: actions/upload-artifact@v4
        with:
            name: gcc-ubuntu-log
            path: ${{ runner.workspace }}/hdf4/hdf4.log
            if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

  build_and_test_mac_latest:
  # MacOS w/ Clang + CMake
  #
    name: "MacOS Clang CMake"
    runs-on: macos-latest
    steps:
      - name: Install Dependencies (MacOS_latest)
        run: brew install ninja curl

      - name: Install Dependencies
        uses: ssciwr/doxygen-install@v1
        with:
          version: "1.10.0"

      - name: check clang version
        shell: bash
        run: |
          which clang
          clang -v

      - name: Set up JDK 19
        uses: actions/setup-java@v4
        with:
          java-version: '19'
          distribution: 'temurin'

      - name: Set file base name (MacOS_latest)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT

      # Get files created by release script
      - name: Get tgz-tarball (MacOS_latest)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
              name: tgz-tarball
              path: ${{ github.workspace }}

      - name: List files for the space (MacOS_latest)
        run: |
              ls ${{ github.workspace }}
              ls ${{ runner.workspace }}

      - name: Uncompress source (MacOS_latest)
        run: tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz

      - name: Copy script files for the space (MacOS_latest)
        run: |
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake ${{ runner.workspace }}/hdf4
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake ${{ runner.workspace }}/hdf4

      # symlinks the compiler executables to a common location 
      - name: Setup GNU Fortran
        uses: fortran-lang/setup-fortran@v1
        id: setup-fortran
        with:
          compiler: gcc
          version: 14

      - name: List files for the hdf4 (MacOS_latest)
        run: |
              ls ${{ runner.workspace }}/hdf4

      - name: Create options file (MacOS_latest)
        uses: "DamianReeves/write-file-action@master"
        with:
          path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
          write-mode: overwrite
          contents: |
            set (CTEST_DROP_SITE_INIT "my.cdash.org")
            # Change following line to submit to your CDash dashboard to a different CDash project
            #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
            set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
            set (NO_MAC_FORTRAN "ON")
            set (MODEL "GHDaily")
            set (GROUP "GHDaily")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest (MacOS_latest)
        id: run-ctest
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }}-Clang,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=Unix,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: bash
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (MacOS_latest)
        uses: actions/upload-artifact@v4
        with:
          name: macos-log
          path: ${{ runner.workspace }}/hdf4/hdf4.log
          if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

####### intel builds
  build_and_test_win_intel:
  # Windows w/ OneAPI + CMake
  #
    name: "Windows Intel CTest"
    runs-on: windows-latest
    steps:
      - name: Install Dependencies (Windows_intel)
        run: choco install ninja

      - name: add oneAPI to env
        uses: fortran-lang/setup-fortran@v1
        id: setup-fortran
        with:
          compiler: intel
          version: '2024.1'

      - name: Set file base name (Windows_intel)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT
        shell: bash

      # Get files created by release script
      - name: Get zip-tarball (Windows_intel)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
              name: zip-tarball
              path: ${{ github.workspace }}

      - name: using powershell
        shell: pwsh
        run: Get-Location

      - name: List files for the space (Windows_intel)
        run: |
              Get-ChildItem -Path ${{ github.workspace }}
              Get-ChildItem -Path ${{ runner.workspace }}
        shell: pwsh

      - name: Uncompress source (Windows_intel)
        working-directory: ${{ github.workspace }}
        run: 7z x ${{ steps.set-file-base.outputs.FILE_BASE }}.zip
        shell: bash

      - name: Copy script files for the space (Windows_intel)
        run: |
          Copy-Item -Path ${{ runner.workspace }}/hdf4/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake -Destination ${{ runner.workspace }}/hdf4/
          Copy-Item -Path ${{ runner.workspace }}/hdf4/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake -Destination ${{ runner.workspace }}/hdf4/
        shell: pwsh

      - name: List files for the hdf4 (Windows_intel)
        run: |
              Get-ChildItem -Path ${{ runner.workspace }}/hdf4
        shell: pwsh

      - name: Create options file (Windows_intel)
        uses: "DamianReeves/write-file-action@master"
        with:
          path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
          write-mode: overwrite
          contents: |
            set (CTEST_DROP_SITE_INIT "my.cdash.org")
            # Change following line to submit to your CDash dashboard to a different CDash project
            #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
            #set (CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler 2024,fortran=ifx")
            set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
            set (MODEL "GHDaily")
            set (GROUP "GHDaily")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
            #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/intel.cmake")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest (Windows_intel) with oneapi
        env:
          FC: ${{ steps.setup-fortran.outputs.fc }}
          CC: ${{ steps.setup-fortran.outputs.cc }}
          CXX: ${{ steps.setup-fortran.outputs.cxx }}
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }}-Intel,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=VS202264,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: pwsh
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (Windows_intel)
        uses: actions/upload-artifact@v4
        with:
          name: intel-win-log
          path: ${{ runner.workspace }}/hdf4/hdf4.log
          if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

  build_and_test_linux_intel:
  # Linux (Ubuntu) w/ OneAPI + CMake
  #
    name: "Ubuntu Intel CMake"
    runs-on: ubuntu-latest
    steps:
      - name: Install CMake Dependencies (Linux_intel)
        run: |
          sudo apt-get update
          sudo apt-get install ninja-build doxygen graphviz curl

      - name: add oneAPI to env
        uses: fortran-lang/setup-fortran@v1
        id: setup-fortran
        with:
          compiler: intel
          version: '2024.1'

      - name: Set file base name (Linux_intel)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT

      # Get files created by release script
      - name: Get tgz-tarball (Linux_intel)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
              name: tgz-tarball
              path: ${{ github.workspace }}

      - name: List files for the space (Linux_intel)
        run: |
              ls -l ${{ github.workspace }}
              ls ${{ runner.workspace }}

      - name: Uncompress source (Linux_intel)
        run: tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz

      - name: Copy script files for the space (Linux_intel)
        run: |
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake ${{ runner.workspace }}/hdf4
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake ${{ runner.workspace }}/hdf4

      - name: List files for the hdf4 (Linux_Linux)
        run: |
          ls ${{ runner.workspace }}/hdf4

      - name: Create options file (Linux_intel)
        uses: "DamianReeves/write-file-action@master"
        with:
          path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
          write-mode: overwrite
          contents: |
            set (CTEST_DROP_SITE_INIT "my.cdash.org")
            # Change following line to submit to your CDash dashboard to a different CDash project
            #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
            set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
            set (MODEL "GHDaily")
            set (GROUP "GHDaily")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
            set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest (Linux_intel)
        env:
          FC: ${{ steps.setup-fortran.outputs.fc }}
          CC: ${{ steps.setup-fortran.outputs.cc }}
          CXX: ${{ steps.setup-fortran.outputs.cxx }}
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }}-Intel,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=Unix,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: bash
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (Linux_intel)
        uses: actions/upload-artifact@v4
        with:
          name: intel-ubuntu-log
          path: ${{ runner.workspace }}/hdf4/hdf4.log
          if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

####### clang builds
  build_and_test_win_clang:
  # Windows w/ clang + CMake
  #
    name: "Windows ClangCL CTest"
    runs-on: windows-latest
    steps:
      - name: Install Dependencies (Windows_clang)
        run: choco install ninja

      - name: add clang to env
        uses: KyleMayes/install-llvm-action@v2.0.6
        id: setup-clang
        with:
          env: true
          version: '18'

      - name: Set file base name (Windows_clang)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT
        shell: bash

      # Get files created by release script
      - name: Get zip-tarball (Windows_clang)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
          name: zip-tarball
          path: ${{ github.workspace }}

      - name: using powershell
        shell: pwsh
        run: Get-Location

      - name: List files for the space (Windows_clang)
        run: |
          Get-ChildItem -Path ${{ github.workspace }}
          Get-ChildItem -Path ${{ runner.workspace }}
        shell: pwsh

      - name: Uncompress source (Windows_clang)
        working-directory: ${{ github.workspace }}
        run: 7z x ${{ steps.set-file-base.outputs.FILE_BASE }}.zip
        shell: bash

      - name: Copy script files for the space (Windows_clang)
        run: |
          Copy-Item -Path ${{ runner.workspace }}/hdf4/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake -Destination ${{ runner.workspace }}/hdf4/
          Copy-Item -Path ${{ runner.workspace }}/hdf4/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake -Destination ${{ runner.workspace }}/hdf4/
        shell: pwsh

      - name: List files for the hdf4 (Windows_clang)
        run: |
          Get-ChildItem -Path ${{ runner.workspace }}/hdf4
        shell: pwsh

      - name: Create options file (Windows_clang)
        uses: "DamianReeves/write-file-action@master"
        with:
          path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
          write-mode: overwrite
          contents: |
              set (CTEST_DROP_SITE_INIT "my.cdash.org")
              # Change following line to submit to your CDash dashboard to a different CDash project
              #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
              set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
              #set (CMAKE_GENERATOR_TOOLSET "ClangCL")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
              #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/clang.cmake")
              set (MODEL "GHDaily")
              set (GROUP "GHDaily")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest (Windows_clang) with clang
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }}-Clang,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=VS202264,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: pwsh
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (Windows_clang)
        uses: actions/upload-artifact@v4
        with:
          name: clang-win-log
          path: ${{ runner.workspace }}/hdf4/hdf4.log
          if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`

  build_and_test_linux_clang:
  # Linux (Ubuntu) w/ clang + CMake
  #
    name: "Ubuntu Clang CMake"
    runs-on: ubuntu-22.04
    steps:
      - name: Install CMake Dependencies (Linux_clang)
        run: |
          sudo apt-get update
          sudo apt-get install ninja-build doxygen graphviz curl libtinfo5

      - name: add clang to env
        uses: KyleMayes/install-llvm-action@v2.0.6
        id: setup-clang
        with:
          env: true
          version: '18.1'

      - name: check clang version
        shell: bash
        run: |
          which clang
          clang -v

      - name: Set file base name (Linux_clang)
        id: set-file-base
        run: |
          FILE_NAME_BASE=$(echo "${{ inputs.file_base }}")
          echo "FILE_BASE=$FILE_NAME_BASE" >> $GITHUB_OUTPUT
          if [[ '${{ inputs.use_environ }}' == 'release' ]]
          then
            SOURCE_NAME_BASE=$(echo "${{ inputs.snap_name }}")
          else
            SOURCE_NAME_BASE=$(echo "hdfsrc")
          fi
          echo "SOURCE_BASE=$SOURCE_NAME_BASE" >> $GITHUB_OUTPUT

      # Get files created by release script
      - name: Get tgz-tarball (Linux_clang)
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
        with:
          name: tgz-tarball
          path: ${{ github.workspace }}

      - name: List files for the space (Linux_clang)
        run: |
          ls -l ${{ github.workspace }}
          ls ${{ runner.workspace }}

      - name: Uncompress source (Linux_clang)
        run: tar -zxvf ${{ github.workspace }}/${{ steps.set-file-base.outputs.FILE_BASE }}.tar.gz

      - name: Copy script files for the space (Linux_clang)
        run: |
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/CTestScript.cmake ${{ runner.workspace }}/hdf4
          cp ${{ github.workspace }}/${{ steps.set-file-base.outputs.SOURCE_BASE }}/config/cmake/scripts/HDF4config.cmake ${{ runner.workspace }}/hdf4

      - name: List files for the hdf4 (Linux_clang)
        run: |
          ls ${{ runner.workspace }}/hdf4

      - name: Create options file (Linux_clang)
        uses: "DamianReeves/write-file-action@master"
        with:
          path: ${{ runner.workspace }}/hdf4/HDF4options.cmake
          write-mode: overwrite
          contents: |
              set (CTEST_DROP_SITE_INIT "my.cdash.org")
              # Change following line to submit to your CDash dashboard to a different CDash project
              set (SITE_BUILDNAME_SUFFIX "${{ steps.set-file-base.outputs.FILE_BASE }}")
              #set (CTEST_DROP_LOCATION_INIT "/submit.php?project=HDF4")
              set (MODEL "GHDaily")
              set (GROUP "GHDaily")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} --log-level=VERBOSE")
              #set (CMAKE_GENERATOR_TOOLSET "clang")
              #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/clang.cmake")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_SUPPORT:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_ENABLE_SZIP_ENCODING:BOOL=ON")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DJPEG_USE_LOCALCONTENT:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
              set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")

      - name: Run ctest (Linux_clang)
        run: |
          cd "${{ runner.workspace }}/hdf4"
          ctest -S HDF4config.cmake,CTEST_SITE_EXT=GH-${{ github.event.repository.full_name }}-Clang,LOCAL_SUBMIT=ON,NINJA=TRUE,BUILD_GENERATOR=Unix,CTEST_SOURCE_NAME=${{ steps.set-file-base.outputs.SOURCE_BASE }} -C Release -VV -O hdf4.log
        shell: bash
        continue-on-error: true

      # Save log files created by ctest script
      - name: Save log (Linux_clang)
        uses: actions/upload-artifact@v4
        with:
          name: clang-ubuntu-log
          path: ${{ runner.workspace }}/hdf4/hdf4.log
          if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
