Skip to content

Commit f5ab95b

Browse files
authored
Fix periodically failing CI tests (OpenFUSIONToolkit#326)
- Introduce surface resampling for LCFS in `gs_get_qprof` to improve repeatability of dl calculation * Mirrors `gq_save_eqdsk`, but with higher resolution of 1,000 points (hardcoded for now) * Add simple forward Euler tracer class to `tracing_2d` - Add `--installed` flag to homebrew prefix searches in `build_libs.py` - Explicitly check PMIx version for compatibility if available via homebrew - Add code review action to avoid failures due to long setup time in full agent environment
1 parent 5128ac1 commit f5ab95b

6 files changed

Lines changed: 166 additions & 155 deletions

File tree

.github/workflows/ci_build.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
concurrency:
1212
group: ci-${{ github.ref }}
1313
cancel-in-progress: ${{ contains(github.ref, 'pull/')}}
14-
14+
1515
jobs:
1616
build:
1717
if: github.repository == 'OpenFUSIONToolkit/OpenFUSIONToolkit'
@@ -23,7 +23,7 @@ jobs:
2323
FC: ${{ matrix.config.fc }}
2424
OMP_NUM_THREADS: 2
2525
OMPI_MCA_pmix_tool_remote_connections: 0 # Fix occasional OpenMPI error
26-
26+
2727
strategy:
2828
fail-fast: false
2929
matrix:
@@ -136,16 +136,15 @@ jobs:
136136
echo "source ${{ github.workspace }}/oft_venv/bin/activate" > ${{ github.workspace }}/setup_env.sh
137137
source ${{ github.workspace }}/setup_env.sh
138138
python -m pip install pytest numpy scipy h5py netcdf4 matplotlib jupyter nbconvert pyvista
139-
139+
140140
- name: Install prerequisites (macOS)
141141
if: startsWith(matrix.config.os, 'macos')
142142
run: |
143-
brew install pmix
144143
${{ matrix.config.python }} -m venv ${{ github.workspace }}/oft_venv
145144
echo "source ${{ github.workspace }}/oft_venv/bin/activate" > ${{ github.workspace }}/setup_env.sh
146145
source ${{ github.workspace }}/setup_env.sh
147146
python -m pip install pytest numpy scipy h5py netcdf4 matplotlib jupyter nbconvert
148-
147+
149148
- name: Install Intel oneAPI
150149
if: ${{ matrix.config.cc == 'icx' }}
151150
run: |
@@ -157,7 +156,7 @@ jobs:
157156
echo "source /opt/intel/oneapi/compiler/latest/env/vars.sh" >> ${{ github.workspace }}/setup_env.sh
158157
echo "source /opt/intel/oneapi/mkl/latest/env/vars.sh" >> ${{ github.workspace }}/setup_env.sh
159158
echo "ulimit -s unlimited" >> ${{ github.workspace }}/setup_env.sh
160-
159+
161160
- name: Check compilers
162161
run: |
163162
source ${{ github.workspace }}/setup_env.sh
@@ -190,7 +189,7 @@ jobs:
190189
run: |
191190
source ${{ github.workspace }}/setup_env.sh
192191
python ../src/utilities/build_libs.py ${{ matrix.config.build_flags }} --no_dl_progress --build_arpack=1 --oft_build_tests=1
193-
192+
194193
- name: Build external (MPICH+OpenMP)
195194
if: startsWith(matrix.parallel, 'mpich')
196195
shell: bash
@@ -229,7 +228,7 @@ jobs:
229228
run: |
230229
source ${{ github.workspace }}/setup_env.sh
231230
make
232-
231+
233232
- name: Install OFT
234233
shell: bash
235234
working-directory: builds/build_release
@@ -261,7 +260,7 @@ jobs:
261260
run: |
262261
rm -rf build
263262
rm -rf petsc*
264-
263+
265264
- name: Upload test results to Codecov
266265
if: ${{ !cancelled() && (matrix.config.os == 'ubuntu-24.04') }}
267266
uses: codecov/codecov-action@v6
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Copilot Code Review Environment
2+
3+
# Setup steps for GitHub Copilot code review agents
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
paths:
9+
- .github/workflows/copilot-code-review.yml
10+
- src/utilities/build_libs.py
11+
12+
jobs:
13+
copilot-code-review:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v5

src/physics/grad_shaf.F90

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
!------------------------------------------------------------------------------
1414
MODULE oft_gs
1515
USE oft_base
16+
USE spline_mod
1617
USE oft_sort, ONLY: sort_matrix, sort_array
1718
USE oft_io, ONLY: hdf5_field_exist, hdf5_read, hdf5_write, &
1819
xdmf_plot_file, hdf5_create_file, hdf5_create_group
@@ -4113,7 +4114,6 @@ SUBROUTINE psi2pt_error(m,n,cofs,err,iflag)
41134114
real(8), intent(out) :: err(m)
41144115
integer(4), intent(inout) :: iflag
41154116
real(8) :: f(3),goptmp(3,3),psitmp(1),pt(2)
4116-
real(8), parameter :: tol=1.d-10
41174117
!---
41184118
pt=cofs(1)*active_targets%vec + active_targets%pt
41194119
call bmesh_findcell(active_targets%psi_eval%mesh,active_targets%cell,pt,f)
@@ -4346,8 +4346,10 @@ subroutine gs_get_qprof(gseq,nr,psi_q,prof,dl,rbounds,zbounds,ravgs)
43464346
real(8), pointer :: ptout(:,:)
43474347
real(8), parameter :: tol=1.d-10
43484348
integer(4) :: i,j,cell
4349+
integer(4), parameter :: nlcfs=1000
43494350
logical :: lcfs_all,lcfs_any
43504351
type(gsinv_interp), pointer :: field
4352+
TYPE(spline_type) :: lcfs_rz
43514353
CHARACTER(LEN=OFT_ERROR_SLEN) :: error_str
43524354
lcfs_any = PRESENT(dl).OR.PRESENT(rbounds).OR.PRESENT(zbounds)
43534355
lcfs_all = PRESENT(dl).AND.PRESENT(rbounds).AND.PRESENT(zbounds)
@@ -4412,7 +4414,6 @@ subroutine gs_get_qprof(gseq,nr,psi_q,prof,dl,rbounds,zbounds,ravgs)
44124414
active_tracer%raxis=raxis
44134415
active_tracer%zaxis=zaxis
44144416
active_tracer%inv=.TRUE.
4415-
IF(PRESENT(dl))ALLOCATE(ptout(3,active_tracer%maxsteps+1))
44164417
!$omp do schedule(dynamic,1)
44174418
do j=1,nr
44184419
!------------------------------------------------------------------------------
@@ -4433,6 +4434,7 @@ subroutine gs_get_qprof(gseq,nr,psi_q,prof,dl,rbounds,zbounds,ravgs)
44334434
!!$omp end critical
44344435
pt_last=pt
44354436
IF(j==1.AND.PRESENT(dl))THEN
4437+
ALLOCATE(ptout(3,active_tracer%maxsteps+1))
44364438
CALL tracinginv_fs(gseq%device%fe_rep%mesh,pt(1:2),ptout)
44374439
ELSE
44384440
CALL tracinginv_fs(gseq%device%fe_rep%mesh,pt(1:2))
@@ -4444,6 +4446,27 @@ subroutine gs_get_qprof(gseq,nr,psi_q,prof,dl,rbounds,zbounds,ravgs)
44444446
CYCLE
44454447
end if
44464448
IF((j==1).AND.PRESENT(dl))THEN
4449+
!------------------------------------------------------------------------------
4450+
! Reinterpolate LCFS to get uniform spacing and compute geometric parameters
4451+
!------------------------------------------------------------------------------
4452+
IF(active_tracer%nsteps>nlcfs)THEN
4453+
!---Allocate and fit spline
4454+
CALL spline_alloc(lcfs_rz,active_tracer%nsteps,2)
4455+
lcfs_rz%xs(0:active_tracer%nsteps) = ptout(1,1:active_tracer%nsteps+1)/ptout(1,active_tracer%nsteps+1)
4456+
lcfs_rz%fs(0:active_tracer%nsteps,1) = ptout(2,1:active_tracer%nsteps+1)
4457+
lcfs_rz%fs(0:active_tracer%nsteps,2) = ptout(3,1:active_tracer%nsteps+1)
4458+
CALL spline_fit(lcfs_rz,"periodic")
4459+
!---Resample trace
4460+
DO i=0,nlcfs-1
4461+
CALL spline_eval(lcfs_rz,i/REAL(nlcfs-1,8),0)
4462+
ptout(1,i+1)=i*ptout(1,active_tracer%nsteps+1)/REAL(nlcfs-1,8)
4463+
ptout(2,i+1)=lcfs_rz%f(1)
4464+
ptout(3,i+1)=lcfs_rz%f(2)
4465+
END DO
4466+
!---Destroy Spline
4467+
CALL spline_dealloc(lcfs_rz)
4468+
active_tracer%nsteps=nlcfs
4469+
END IF
44474470
!---Extrapolate to real LCFS
44484471
IF(psi_q(1)<0.05d0)THEN
44494472
DO i=1,active_tracer%nsteps
@@ -4472,6 +4495,7 @@ subroutine gs_get_qprof(gseq,nr,psi_q,prof,dl,rbounds,zbounds,ravgs)
44724495
END IF
44734496
END DO
44744497
IF(active_tracer%status/=1)dl=-1.d0
4498+
DEALLOCATE(ptout)
44754499
END IF
44764500
!---Get flux variables
44774501
IF(gseq%mode==0)THEN
@@ -4490,7 +4514,6 @@ subroutine gs_get_qprof(gseq,nr,psi_q,prof,dl,rbounds,zbounds,ravgs)
44904514
END IF
44914515
end do
44924516
CALL active_tracer%delete
4493-
IF(PRESENT(dl))DEALLOCATE(ptout)
44944517
CALL field%delete()
44954518
DEALLOCATE(field)
44964519
!$omp end parallel

0 commit comments

Comments
 (0)