Skip to content

Commit

Permalink
fix(par): PETSc Fortran API has changed in v3.22.0 (MODFLOW-USGS#2030)
Browse files Browse the repository at this point in the history
* - 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 <wbonelli@ucar.edu>
  • Loading branch information
mjr-deltares and wpbonelli authored Oct 9, 2024
1 parent 0c46781 commit e2d9eaa
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
13 changes: 10 additions & 3 deletions .github/actions/test-extended/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion .github/actions/test-par/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
9 changes: 6 additions & 3 deletions src/Utilities/Matrix/PetscMatrix.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit e2d9eaa

Please sign in to comment.