From 6eda483e6747fd7758584846f470d36e7fc74b4d Mon Sep 17 00:00:00 2001 From: StuartBenjamin Date: Mon, 12 Oct 2026 22:47:22 -0700 Subject: [PATCH 1/2] RDCON - BUGFIX - MRE runs without a Zeff table use a flat Zeff, as before With MRE_flag, a run whose rdcon.in has no psi_N_Zeff stopped ("Provide Zeff profile values"), where develop used the scalar Zeff (default 1.52). One Zeff value, or none, without psi_N_Zeff now gives a flat profile at that value, matching develop (mufrac to 1e-16 with Zeff = 2.0; 1e-9 with the default, which develop held in single precision). The profile spline's "extrap" end condition needs 4 nodes, so shorter tables, which gave NaN, now stop with a message. Co-Authored-By: Claude Opus 5.5 --- rdcon/dcon.f | 17 +++++++++++++++++ rdcon/mercier.f | 12 ++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/rdcon/dcon.f b/rdcon/dcon.f index ee948fbca..77d635e26 100644 --- a/rdcon/dcon.f +++ b/rdcon/dcon.f @@ -222,6 +222,7 @@ SUBROUTINE dcon_run LOGICAL :: cyl_flag=.FALSE.,regrid_flag=.FALSE.,verbose=.TRUE. INTEGER :: mmin,ipsi + REAL(r8) :: zeff0 COMPLEX(r8), DIMENSION(:,:), ALLOCATABLE :: mx0 COMPLEX(r8), DIMENSION(:), ALLOCATABLE :: vx0 @@ -346,6 +347,22 @@ SUBROUTINE dcon_run IF(MRE_flag)THEN CALL read_var_len(Zeff,Zeff_) CALL read_var_len(psi_N_Zeff,psi_N_Zeff_) +c one Zeff value (default 1.52) without psi_N_Zeff: flat profile. + IF(.NOT.ALLOCATED(psi_N_Zeff_))THEN + zeff0=1.52_r8 + IF(ALLOCATED(Zeff_))THEN + IF(SIZE(Zeff_) > 1) + $ CALL program_stop("A Zeff profile needs psi_N_Zeff") + zeff0=Zeff_(1) + DEALLOCATE(Zeff_) + ENDIF + ALLOCATE(Zeff_(4),psi_N_Zeff_(4)) + Zeff_=zeff0 + psi_N_Zeff_=(/0.0_r8,1.0_r8/3,2.0_r8/3,1.0_r8/) + ENDIF + IF(.NOT.ALLOCATED(Zeff_) .OR. SIZE(Zeff_) /= SIZE(psi_N_Zeff_) + $ .OR. SIZE(Zeff_) < 4) + $ CALL program_stop("Zeff, psi_N_Zeff: equal sizes, >= 4") CALL spline_alloc(mreterms,mpsi,30) mreterms%xs=sq%xs mreterms%fs=0 diff --git a/rdcon/mercier.f b/rdcon/mercier.f index b3e03ed23..277894db6 100644 --- a/rdcon/mercier.f +++ b/rdcon/mercier.f @@ -43,14 +43,10 @@ SUBROUTINE mercier_scan c----------------------------------------------------------------------- IF(MRE_flag)THEN CALL spline_alloc(ff,mtheta,22) - IF(ALLOCATED(Zeff_) .AND. ALLOCATED(psi_N_Zeff_))THEN - CALL spline_alloc(Zeff_spline,SIZE(psi_N_Zeff_)-1,1) - Zeff_spline%xs=psi_N_Zeff_ - Zeff_spline%fs(:,1)=Zeff_ - CALL spline_fit(Zeff_spline,"extrap") - ELSE - CALL program_stop("Provide Zeff profile values") - ENDIF + CALL spline_alloc(Zeff_spline,SIZE(psi_N_Zeff_)-1,1) + Zeff_spline%xs=psi_N_Zeff_ + Zeff_spline%fs(:,1)=Zeff_ + CALL spline_fit(Zeff_spline,"extrap") ELSE CALL spline_alloc(ff,mtheta,5) ENDIF From a630b4855228ab369a41ab6c554d49053259f5dc Mon Sep 17 00:00:00 2001 From: Matthew Pharr Date: Thu, 15 Oct 2026 12:25:04 +0200 Subject: [PATCH 2/2] RDCON - BUGFIX - make sure psi_N_Zeff is strictly increasing --- rdcon/dcon.f | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rdcon/dcon.f b/rdcon/dcon.f index 77d635e26..c4c9726bf 100644 --- a/rdcon/dcon.f +++ b/rdcon/dcon.f @@ -363,6 +363,8 @@ SUBROUTINE dcon_run IF(.NOT.ALLOCATED(Zeff_) .OR. SIZE(Zeff_) /= SIZE(psi_N_Zeff_) $ .OR. SIZE(Zeff_) < 4) $ CALL program_stop("Zeff, psi_N_Zeff: equal sizes, >= 4") + IF(ANY(psi_N_Zeff_(2:) <= psi_N_Zeff_(:SIZE(psi_N_Zeff_)-1))) + $ CALL program_stop("psi_N_Zeff must be strictly increasing") CALL spline_alloc(mreterms,mpsi,30) mreterms%xs=sq%xs mreterms%fs=0