From e2d9eaa4d31a88fa70be342b6cb28262ca2418c8 Mon Sep 17 00:00:00 2001 From: mjr-deltares <45555666+mjr-deltares@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:38:12 +0200 Subject: [PATCH] fix(par): PETSc Fortran API has changed in v3.22.0 (#2030) * - changes in PETSc API v3.22.0 * - need value array instead * - add tmate * - revert this * - explicit declarations for arrays * - pin petsc for macOS to v3.21 * - same for extended * - bump up to macos-14 * - set petsc back to release * - try brew * - move parallel and extended to macos-13 - restore local build for petsc on macos * - add ldflags workaround for parallel macos * don't reinstall brew or gcc 13 * add ldflags workaround for extended macos * - now try again with petsc release for mac * - petsc set to 3.21 for macos - deactivate petsc debug builds on linux --------- Co-authored-by: wpbonelli --- .github/actions/test-extended/action.yml | 13 ++++++++++--- .github/actions/test-par/action.yml | 11 ++++++++++- .github/workflows/ci.yml | 22 ++++++++++++++++++++-- src/Utilities/Matrix/PetscMatrix.F90 | 9 ++++++--- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/.github/actions/test-extended/action.yml b/.github/actions/test-extended/action.yml index 49d2cc67da5..953df09622c 100644 --- a/.github/actions/test-extended/action.yml +++ b/.github/actions/test-extended/action.yml @@ -11,11 +11,20 @@ runs: version: 13 - name: Checkout PETSc + if: runner.os == 'Linux' uses: actions/checkout@v4 with: repository: petsc/petsc path: petsc ref: release + + - name: Checkout PETSc + if: runner.os == 'macOS' + uses: actions/checkout@v4 + with: + repository: petsc/petsc + path: petsc + ref: release-3.21 - name: Configure environment if: runner.os == 'Linux' @@ -37,7 +46,7 @@ runs: working-directory: petsc run: | sudo wget -P $GITHUB_WORKSPACE/petsc https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.2.tar.gz - sudo ./configure PETSC_ARCH=linux-gnu --download-fblaslapack --download-openmpi=$GITHUB_WORKSPACE/petsc/openmpi-5.0.2.tar.gz + sudo ./configure PETSC_ARCH=linux-gnu --download-fblaslapack --download-openmpi=$GITHUB_WORKSPACE/petsc/openmpi-5.0.2.tar.gz --with-debugging=0 sudo make all - name: Configure PETSc @@ -64,9 +73,7 @@ runs: if: runner.os == 'macOS' shell: bash run: | - bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install netcdf-fortran - brew install gcc@13 nc-config --all nf-config diff --git a/.github/actions/test-par/action.yml b/.github/actions/test-par/action.yml index 5b96a2835a6..7b390758473 100644 --- a/.github/actions/test-par/action.yml +++ b/.github/actions/test-par/action.yml @@ -11,11 +11,20 @@ runs: version: 13 - name: Checkout PETSc + if: runner.os != 'macOS' uses: actions/checkout@v4 with: repository: petsc/petsc path: petsc ref: release + + - name: Checkout PETSc + if: runner.os == 'macOS' + uses: actions/checkout@v4 + with: + repository: petsc/petsc + path: petsc + ref: release-3.21 - name: Configure environment if: runner.os == 'Linux' @@ -37,7 +46,7 @@ runs: working-directory: petsc run: | sudo wget -P $GITHUB_WORKSPACE/petsc https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.2.tar.gz - sudo ./configure PETSC_ARCH=linux-gnu --download-fblaslapack --download-openmpi=$GITHUB_WORKSPACE/petsc/openmpi-5.0.2.tar.gz + sudo ./configure PETSC_ARCH=linux-gnu --download-fblaslapack --download-openmpi=$GITHUB_WORKSPACE/petsc/openmpi-5.0.2.tar.gz --with-debugging=0 sudo make all - name: Configure PETSc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 012b22c1f4d..42ba0f583ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -502,7 +502,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, macos-12, windows-2022 ] + os: [ ubuntu-22.04, macos-13, windows-2022 ] defaults: run: shell: bash @@ -530,6 +530,15 @@ jobs: working-directory: modflow6 run: pixi run install + - name: Set LDFLAGS (macOS) + if: matrix.os == 'macos-13' + run: | + os_ver=$(sw_vers -productVersion | cut -d'.' -f1) + if (( "$os_ver" > 12 )); then + ldflags="$LDFLAGS -Wl,-ld_classic" + echo "LDFLAGS=$ldflags" >> $GITHUB_ENV + fi + - name: Test parallel MF6 if: runner.os != 'Windows' uses: ./modflow6/.github/actions/test-par @@ -555,7 +564,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, macos-12 ] + os: [ ubuntu-22.04, macos-13 ] defaults: run: shell: bash @@ -581,6 +590,15 @@ jobs: working-directory: modflow6 run: pixi run pip install xugrid xarray netcdf4 + - name: Set LDFLAGS (macOS) + if: matrix.os == 'macos-13' + run: | + os_ver=$(sw_vers -productVersion | cut -d'.' -f1) + if (( "$os_ver" > 12 )); then + ldflags="$LDFLAGS -Wl,-ld_classic" + echo "LDFLAGS=$ldflags" >> $GITHUB_ENV + fi + - name: Test extended MF6 uses: ./modflow6/.github/actions/test-extended diff --git a/src/Utilities/Matrix/PetscMatrix.F90 b/src/Utilities/Matrix/PetscMatrix.F90 index 440e9b71f96..c2ee2bde546 100644 --- a/src/Utilities/Matrix/PetscMatrix.F90 +++ b/src/Utilities/Matrix/PetscMatrix.F90 @@ -396,7 +396,8 @@ subroutine pm_get_aij_local(this, ia, ja, amat) ! local PetscErrorCode :: ierr integer(I4B) :: irow, icol, ipos - real(DP) :: val + integer(I4B), dimension(1) :: irow_idxs, icol_idxs + real(DP), dimension(1) :: values Mat :: local_mat call MatGetDiagonalBlock(this%mat, local_mat, ierr) @@ -405,9 +406,11 @@ subroutine pm_get_aij_local(this, ia, ja, amat) do irow = 1, this%nrow do ipos = this%ia_local(irow), this%ia_local(irow + 1) - 1 icol = this%ja_local(ipos) - call MatGetValues(local_mat, 1, irow - 1, 1, icol - 1, val, ierr) + irow_idxs(1) = irow - 1 + icol_idxs(1) = icol - 1 + call MatGetValues(local_mat, 1, irow_idxs, 1, icol_idxs, values, ierr) CHKERRQ(ierr) - this%amat_local(ipos) = val + this%amat_local(ipos) = values(1) end do end do