diff --git a/src/NESTOR/analyt.f90 b/src/NESTOR/analyt.f90 index 3809dfe1e..02915ad58 100644 --- a/src/NESTOR/analyt.f90 +++ b/src/NESTOR/analyt.f90 @@ -14,6 +14,7 @@ SUBROUTINE analyt(grpmn, bvec, ivacskip, lasym, m_map, n_map, grpmn_m_map, grpmn_n_map) USE vacmod, vm_grpmn => grpmn use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE INTEGER, INTENT(in) :: ivacskip @@ -164,7 +165,7 @@ SUBROUTINE analyt(grpmn, bvec, ivacskip, lasym, m_map, n_map, grpmn_m_map, grpmn tlpm = tlp + tlm END DO LLOOP - if (open_dbg_context("vac1n_analyt", id=icall)) then + if (open_dbg_context("vac1n_analyt", num_eqsolve_retries)) then call add_real_3d("all_tlp", mf+nf+1, nv, nu3, all_tlp) call add_real_3d("all_tlm", mf+nf+1, nv, nu3, all_tlm) diff --git a/src/NESTOR/bextern.f90 b/src/NESTOR/bextern.f90 index c464a38ef..63573debc 100644 --- a/src/NESTOR/bextern.f90 +++ b/src/NESTOR/bextern.f90 @@ -10,6 +10,7 @@ SUBROUTINE bextern(plascur, wint) USE mgrid_mod, ONLY: bvac use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE @@ -36,7 +37,7 @@ SUBROUTINE bextern(plascur, wint) ! USE BEXU, BEXV, BEXN AS TEMPORARY STORAGE FOR BX, BY, BZ ! --> add to interpolated field from mgrid CALL belicu (plascur, bexu, bexv, bexn, cosuv, sinuv, r1b, z1b) - DO i = 1, nuv2 + DO i = 1, nuv2 brad(i) = brad(i) + bexu(i)*cosuv(i) + bexv(i)*sinuv(i) bphi(i) = bphi(i) - bexu(i)*sinuv(i) + bexv(i)*cosuv(i) bz(i) = bz(i) + bexn(i) @@ -57,7 +58,7 @@ SUBROUTINE bextern(plascur, wint) ! NOTE: BEXN == NP*F = -B0 dot [Xu cross Xv] NP (see PKM, Eq. 2.13) bexni(:nuv2) = wint(:nuv2)*bexn(:nuv2)*pi2*pi2 - if (open_dbg_context("vac1n_bextern", id=icall)) then + if (open_dbg_context("vac1n_bextern", num_eqsolve_retries)) then call add_real_2d("brad", nv, nu3, brad) call add_real_2d("bphi", nv, nu3, bphi) diff --git a/src/NESTOR/data/vacmod.f90 b/src/NESTOR/data/vacmod.f90 index b4fbc26ca..b0a9a0f7f 100644 --- a/src/NESTOR/data/vacmod.f90 +++ b/src/NESTOR/data/vacmod.f90 @@ -8,7 +8,7 @@ MODULE vacmod IMPLICIT NONE - integer, save :: icall = 0 + ! integer, save :: icall = 0 REAL(rprec), PARAMETER :: p5 = cp5 REAL(rprec), PARAMETER :: two = c2p0 diff --git a/src/NESTOR/fouri.f90 b/src/NESTOR/fouri.f90 index fbc10c774..feacca061 100644 --- a/src/NESTOR/fouri.f90 +++ b/src/NESTOR/fouri.f90 @@ -14,6 +14,7 @@ SUBROUTINE fouri(grpmn, gsource, amatrix, amatsq, bvec, wint, lasym) USE vacmod, vm_amatrix => amatrix, vm_grpmn => grpmn use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE @@ -198,7 +199,7 @@ SUBROUTINE fouri(grpmn, gsource, amatrix, amatsq, bvec, wint, lasym) amatsq(1+mnpd:mnpd2,1+mnpd:mnpd2) = amatrix(:,:,4) end if - if (open_dbg_context("vac1n_fouri", id=icall)) then + if (open_dbg_context("vac1n_fouri", num_eqsolve_retries)) then ! TODO: isym for lasym=.TRUE. call add_real_2d("source", nv, nu2, source) diff --git a/src/NESTOR/fourp.f90 b/src/NESTOR/fourp.f90 index 9d5683dcf..e53784a0d 100644 --- a/src/NESTOR/fourp.f90 +++ b/src/NESTOR/fourp.f90 @@ -9,6 +9,7 @@ SUBROUTINE fourp (grpmn, grp) USE vacmod, vm_grpmn => grpmn use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE @@ -93,7 +94,7 @@ SUBROUTINE fourp (grpmn, grp) END DO ! ku - if (open_dbg_context("vac1n_fourp", id=icall)) then + if (open_dbg_context("vac1n_fourp", num_eqsolve_retries)) then ! NOTE: This is the sum of the results from analyt and fourp! call add_real_4d("grpmn", mf1, nf1, nv, nu3, grpmn) diff --git a/src/NESTOR/precal.f90 b/src/NESTOR/precal.f90 index b215216fb..68844dfbd 100644 --- a/src/NESTOR/precal.f90 +++ b/src/NESTOR/precal.f90 @@ -7,6 +7,7 @@ SUBROUTINE precal USE vacmod use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE @@ -233,7 +234,7 @@ SUBROUTINE precal precal_done = .true. - if (open_dbg_context("vac1n_precal", id=icall)) then + if (open_dbg_context("vac1n_precal", num_eqsolve_retries)) then call add_int("nvper", nvper) call add_int("nuv_tan", nuv_tan) diff --git a/src/NESTOR/scalpot.f90 b/src/NESTOR/scalpot.f90 index 86ca46e33..75d20dea3 100644 --- a/src/NESTOR/scalpot.f90 +++ b/src/NESTOR/scalpot.f90 @@ -12,7 +12,10 @@ !> @param n_map SUBROUTINE scalpot(bvec, amatrix, wint, ivacskip, lasym, m_map, n_map) USE vacmod, vm_amatrix => amatrix + use dbgout + use vmec_main, only: num_eqsolve_retries + IMPLICIT NONE INTEGER, INTENT(in) :: ivacskip @@ -64,7 +67,7 @@ SUBROUTINE scalpot(bvec, amatrix, wint, ivacskip, lasym, m_map, n_map) gstore = gstore + bexni(ip)*green(:,ip) END DO - if (open_dbg_context("vac1n_greenf", id=icall)) then + if (open_dbg_context("vac1n_greenf", num_eqsolve_retries)) then call add_real_4d("green", nv, nu, nv, nu3, green) call add_real_4d("greenp", nv, nu, nv, nu3, greenp) @@ -78,11 +81,11 @@ SUBROUTINE scalpot(bvec, amatrix, wint, ivacskip, lasym, m_map, n_map) ! AND STORE IN GRPMN (NOTE THAT GRPMN IS ADDED TO THE ANALYTIC PIECE IN EQ. 2.14, ! - COMPUTED IN ANALYT - WHICH HAS THE APPROPRIATE SIN, COS FACTORS ALREADY) CALL fourp (grpmn, greenp) - + ! COMPUTE FOURIER INTEGRAL OF GRADIENT (GRPMN) OVER PRIMED MESH IN EQ. 2.14 ! AND SOURCE (GSTORE) OVER UNPRIMED MESH IN EQ. 2.16 CALL fouri (grpmn, gstore, amatrix, amatsav, bvec, wint, lasym) - + ! debugging: focus on Fourier transforms in fouri for now ! return diff --git a/src/NESTOR/surface.f90 b/src/NESTOR/surface.f90 index 7f0aa9d73..e32d050c5 100644 --- a/src/NESTOR/surface.f90 +++ b/src/NESTOR/surface.f90 @@ -16,6 +16,7 @@ SUBROUTINE surface(rc, rs, zs, zc, xm, xn, mnmax, lasym, signgs) USE vacmod use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE @@ -121,7 +122,7 @@ SUBROUTINE surface(rc, rs, zs, zc, xm, xn, mnmax, lasym, signgs) rsinuv(i) = r1b(i)*sinuv(i) END DO - if (open_dbg_context("vac1n_surface", id=icall)) then + if (open_dbg_context("vac1n_surface", num_eqsolve_retries)) then call add_real_2d("r1b", nv, nu, r1b) ! nu ! call add_real_2d("rub", nv, nu3, rub) call add_real_2d("rvb", nv, nu3, rvb) diff --git a/src/NESTOR/vacuum.f90 b/src/NESTOR/vacuum.f90 index 5d081faa0..a7d9b3efe 100644 --- a/src/NESTOR/vacuum.f90 +++ b/src/NESTOR/vacuum.f90 @@ -29,6 +29,7 @@ SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, & use vmec_main, only: input_extension use dbgout + use vmec_main, only: num_eqsolve_retries IMPLICIT NONE @@ -83,7 +84,7 @@ SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, & ! potential = SUM potsin*SIN(mu - nv) + potcos*COS(mu - nv) ! write inputs to NESTOR - if (open_dbg_context("vac1n_vacuum", id=icall)) then + if (open_dbg_context("vac1n_vacuum", num_eqsolve_retries)) then call add_real_1d("rmnc", mnmax, rmnc) call add_real_1d("zmns", mnmax, zmns) @@ -129,7 +130,7 @@ SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, & ! stand-alone for debugging: working on scalpot at the moment ! return - vac1n_solver_active = open_dbg_context("vac1n_solver", id=icall) + vac1n_solver_active = open_dbg_context("vac1n_solver", num_eqsolve_retries) if (vac1n_solver_active) then call add_real_2d("amatrix", mnpd2, mnpd2, amatrix) call add_real_1d("potvac_in", mnpd2, potvac) @@ -200,7 +201,7 @@ SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, & bzv(i) = zub(i)*bsupu + zvb(i)*bsupv END DO - if (open_dbg_context("vac1n_bsqvac", id=icall)) then + if (open_dbg_context("vac1n_bsqvac", num_eqsolve_retries)) then call add_real_1d("potsin", mnpd, potsin) if (lasym) then @@ -255,6 +256,6 @@ SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, & ENDIF - icall = icall + 1 + !icall = icall + 1 END SUBROUTINE vacuum diff --git a/src/data/vmec_input.f90 b/src/data/vmec_input.f90 index 93c3e9b83..4a9be29a2 100644 --- a/src/data/vmec_input.f90 +++ b/src/data/vmec_input.f90 @@ -11,6 +11,7 @@ MODULE vmec_input INTEGER, PARAMETER :: ns_default = 31 INTEGER, PARAMETER :: niter_default = 100 REAL(rprec), PARAMETER :: ftol_default = 1.E-10_dp + integer, parameter :: num_iter2_to_dump = 20 INTEGER :: nfp INTEGER :: ncurr @@ -81,49 +82,49 @@ MODULE vmec_input ! debugging output - !> maximum number of iterations for which to dump data - integer :: max_dump = 2 + !> values of iter2 for which to dump data + integer, dimension(num_iter2_to_dump) :: iter2_to_dump !> individual flags to control debug output loosely related to !> similarly-named routines (checkpoints along iterations) - logical :: dump_add_fluxes = .false. - logical :: dump_metric = .false. - logical :: dump_volume = .false. - logical :: dump_bcontrav = .false. - logical :: dump_bcov = .false. - logical :: dump_lambda_forces = .false. - logical :: dump_bcov_full = .false. - logical :: dump_precondn = .false. - logical :: dump_forceNorms_tcon = .false. - logical :: dump_lulv_comb = .false. - logical :: dump_calc_fbal = .false. - logical :: dump_evolve = .false. - logical :: dump_fixaray = .false. - logical :: dump_spectral_constraint = .false. - logical :: dump_forces = .false. - logical :: dump_totzsp_input = .false. - logical :: dump_funct3d_geometry = .false. - logical :: dump_constraint_force = .false. - logical :: dump_guess_axis = .false. - logical :: dump_interp = .false. - logical :: dump_jacobian = .false. - logical :: dump_lamcal = .false. - logical :: dump_profil1d = .false. - logical :: dump_profil3d = .false. - logical :: dump_readin_boundary = .false. - logical :: dump_phys_gc = .false. - logical :: dump_fsq = .false. - logical :: dump_scale_m1 = .false. - logical :: dump_scalfor_out = .false. - logical :: dump_fsq1 = .false. - logical :: dump_scalfor_R = .false. - logical :: dump_scalfor_Z = .false. - logical :: dump_symforce = .false. - logical :: dump_tomnsps = .false. - logical :: dump_tomnspa = .false. - logical :: dump_multigrid_result = .false. - logical :: dump_rbsq = .false. - logical :: dump_printout = .false. + logical :: dump_add_fluxes = .false. + logical :: dump_metric = .false. + logical :: dump_volume = .false. + logical :: dump_bcontrav = .false. + logical :: dump_bcov = .false. + logical :: dump_lambda_forces = .false. + logical :: dump_bcov_full = .false. + logical :: dump_precondn = .false. + logical :: dump_forceNorms_tcon = .false. + logical :: dump_lulv_comb = .false. + logical :: dump_calc_fbal = .false. + logical :: dump_evolve = .false. + logical :: dump_fixaray = .false. + logical :: dump_spectral_constraint = .false. + logical :: dump_forces = .false. + logical :: dump_totzsp_input = .false. + logical :: dump_funct3d_geometry = .false. + logical :: dump_constraint_force = .false. + logical :: dump_guess_axis = .false. + logical :: dump_interp = .false. + logical :: dump_jacobian = .false. + logical :: dump_lamcal = .false. + logical :: dump_profil1d = .false. + logical :: dump_profil3d = .false. + logical :: dump_readin_boundary = .false. + logical :: dump_phys_gc = .false. + logical :: dump_fsq = .false. + logical :: dump_scale_m1 = .false. + logical :: dump_scalfor_out = .false. + logical :: dump_fsq1 = .false. + logical :: dump_scalfor_R = .false. + logical :: dump_scalfor_Z = .false. + logical :: dump_symforce = .false. + logical :: dump_tomnsps = .false. + logical :: dump_tomnspa = .false. + logical :: dump_multigrid_result = .false. + logical :: dump_rbsq = .false. + logical :: dump_printout = .false. ! fileout logical :: dump_bcovar_fileout = .false. @@ -140,29 +141,29 @@ MODULE vmec_input logical :: dump_freeb_data = .false. ! debugging output flags for NESTOR - logical :: dump_vac1n_vacuum = .false. - logical :: dump_vac1n_precal = .false. - logical :: dump_vac1n_surface = .false. - logical :: dump_vac1n_bextern = .false. - logical :: dump_vac1n_analyt = .false. - logical :: dump_vac1n_greenf = .false. - logical :: dump_vac1n_fourp = .false. - logical :: dump_vac1n_fouri = .false. - logical :: dump_vac1n_solver = .false. - logical :: dump_vac1n_bsqvac = .false. - - logical :: dump_vac2_vacuum = .false. - logical :: dump_vac2_precal = .false. - logical :: dump_vac2_surface = .false. - logical :: dump_vac2_bexmat = .false. - logical :: dump_vac2_matrix = .false. - logical :: dump_vac2_foumat_unreg = .false. - logical :: dump_vac2_analin = .false. - logical :: dump_vac2_analyt = .false. - logical :: dump_vac2_foumat = .false. - logical :: dump_vac2_linsys = .false. - logical :: dump_vac2_linslv = .false. - logical :: dump_vac2_bsqvac = .false. + logical :: dump_vac1n_vacuum = .false. + logical :: dump_vac1n_precal = .false. + logical :: dump_vac1n_surface = .false. + logical :: dump_vac1n_bextern = .false. + logical :: dump_vac1n_analyt = .false. + logical :: dump_vac1n_greenf = .false. + logical :: dump_vac1n_fourp = .false. + logical :: dump_vac1n_fouri = .false. + logical :: dump_vac1n_solver = .false. + logical :: dump_vac1n_bsqvac = .false. + + logical :: dump_vac2_vacuum = .false. + logical :: dump_vac2_precal = .false. + logical :: dump_vac2_surface = .false. + logical :: dump_vac2_bexmat = .false. + logical :: dump_vac2_matrix = .false. + logical :: dump_vac2_foumat_unreg = .false. + logical :: dump_vac2_analin = .false. + logical :: dump_vac2_analyt = .false. + logical :: dump_vac2_foumat = .false. + logical :: dump_vac2_linsys = .false. + logical :: dump_vac2_linslv = .false. + logical :: dump_vac2_bsqvac = .false. @@ -215,45 +216,45 @@ MODULE vmec_input lasym, & lbsubs, & vac_1_2, & - max_dump , & ! dbgout - dump_add_fluxes , & - dump_metric , & - dump_volume , & - dump_bcontrav , & - dump_bcov , & - dump_lambda_forces , & - dump_bcov_full , & - dump_precondn , & - dump_forceNorms_tcon , & - dump_lulv_comb , & - dump_calc_fbal , & - dump_evolve , & - dump_fixaray , & - dump_spectral_constraint, & - dump_forces , & - dump_totzsp_input , & - dump_funct3d_geometry , & - dump_constraint_force , & - dump_guess_axis , & - dump_interp , & - dump_jacobian , & - dump_lamcal , & - dump_profil1d , & - dump_profil3d , & - dump_readin_boundary , & - dump_phys_gc , & - dump_fsq , & - dump_scale_m1 , & - dump_scalfor_out , & - dump_fsq1 , & - dump_scalfor_R , & - dump_scalfor_Z , & - dump_symforce , & - dump_tomnsps , & - dump_tomnspa , & - dump_multigrid_result , & - dump_rbsq , & - dump_printout , & + iter2_to_dump , & ! dbgout + dump_add_fluxes , & + dump_metric , & + dump_volume , & + dump_bcontrav , & + dump_bcov , & + dump_lambda_forces , & + dump_bcov_full , & + dump_precondn , & + dump_forceNorms_tcon , & + dump_lulv_comb , & + dump_calc_fbal , & + dump_evolve , & + dump_fixaray , & + dump_spectral_constraint , & + dump_forces , & + dump_totzsp_input , & + dump_funct3d_geometry , & + dump_constraint_force , & + dump_guess_axis , & + dump_interp , & + dump_jacobian , & + dump_lamcal , & + dump_profil1d , & + dump_profil3d , & + dump_readin_boundary , & + dump_phys_gc , & + dump_fsq , & + dump_scale_m1 , & + dump_scalfor_out , & + dump_fsq1 , & + dump_scalfor_R , & + dump_scalfor_Z , & + dump_symforce , & + dump_tomnsps , & + dump_tomnspa , & + dump_multigrid_result , & + dump_rbsq , & + dump_printout , & dump_bcovar_fileout , & ! dbgout from fileout dump_bss , & dump_jxbforce_bsub_lowpass, & @@ -266,27 +267,27 @@ MODULE vmec_input dump_threed1_beta , & dump_threed1_shafrint , & dump_freeb_data , & - dump_vac1n_vacuum , & ! NESTOR vac1 - dump_vac1n_precal , & - dump_vac1n_surface , & - dump_vac1n_bextern , & - dump_vac1n_analyt , & - dump_vac1n_greenf , & - dump_vac1n_fourp , & - dump_vac1n_fouri , & - dump_vac1n_solver , & - dump_vac1n_bsqvac , & - dump_vac2_vacuum , & ! NESTOR vac2 - dump_vac2_precal , & - dump_vac2_surface , & - dump_vac2_bexmat , & - dump_vac2_matrix , & - dump_vac2_foumat_unreg , & - dump_vac2_analin , & - dump_vac2_analyt , & - dump_vac2_foumat , & - dump_vac2_linsys , & - dump_vac2_linslv , & + dump_vac1n_vacuum , & ! NESTOR vac1 + dump_vac1n_precal , & + dump_vac1n_surface , & + dump_vac1n_bextern , & + dump_vac1n_analyt , & + dump_vac1n_greenf , & + dump_vac1n_fourp , & + dump_vac1n_fouri , & + dump_vac1n_solver , & + dump_vac1n_bsqvac , & + dump_vac2_vacuum , & ! NESTOR vac2 + dump_vac2_precal , & + dump_vac2_surface , & + dump_vac2_bexmat , & + dump_vac2_matrix , & + dump_vac2_foumat_unreg , & + dump_vac2_analin , & + dump_vac2_analyt , & + dump_vac2_foumat , & + dump_vac2_linsys , & + dump_vac2_linslv , & dump_vac2_bsqvac @@ -359,6 +360,11 @@ SUBROUTINE read_indata_namelist (iunit, istat) ac_aux_s(:) = -1 ai_aux_s(:) = -1 + ! by default, dump first two iterations + iter2_to_dump(:) = 0 + iter2_to_dump(1) = 1 + iter2_to_dump(2) = 2 + READ (iunit, nml=indata, iostat=istat) if (istat .ne. 0) then diff --git a/src/dbgout.f90 b/src/dbgout.f90 index 8eab55008..da479d667 100644 --- a/src/dbgout.f90 +++ b/src/dbgout.f90 @@ -2,6 +2,8 @@ module dbgout use json implicit none + logical :: skip_dbgout_collison = .false. + contains !> check if any output is desired for the current iteration @@ -25,17 +27,25 @@ function open_dbg_context(context_name, repetition, id) character(len=255) :: dump_filename character(len=255) :: output_folder logical :: should_write, file_exists + integer :: iter_value_to_use, i ! enable semi-pretty-printing JSON data json_pretty_print = .true. - ! check if debug out should be written at all if (present(id)) then - should_write = id.le.max_dump + iter_value_to_use = id else - should_write = iter2.le.max_dump + iter_value_to_use = iter2 end if + ! check if debug out should be written at all + should_write = .false. + do i = 1, num_iter2_to_dump + if (iter_value_to_use .eq. iter2_to_dump(i)) then + should_write = .true. + end if + end do ! num_iter2_to_dump + ! check if requested context is enabled by input flags if (trim(context_name) .eq. "add_fluxes") then open_dbg_context = dump_add_fluxes @@ -239,6 +249,11 @@ function open_dbg_context(context_name, repetition, id) ! check if file already exists (and stop in that case) inquire(file=trim(dump_filename), exist=file_exists) if (file_exists) then + if (skip_dbgout_collison) then + ! Temporary hack to skip overwriting a file + ! without halting the algorithm. + return + end if stop "debug output file already exists: '"//trim(dump_filename)//"'" end if diff --git a/src/eqsolve.f90 b/src/eqsolve.f90 index 906b5bbae..bd31745fc 100644 --- a/src/eqsolve.f90 +++ b/src/eqsolve.f90 @@ -12,6 +12,8 @@ SUBROUTINE eqsolve(ier_flag) USE realspace USE xstuff + use dbgout, only: skip_dbgout_collison + IMPLICIT NONE INTEGER, intent(inout) :: ier_flag @@ -35,6 +37,11 @@ SUBROUTINE eqsolve(ier_flag) ! COMPUTE INITIAL R, Z AND MAGNETIC FLUX PROFILES 20 CONTINUE ! try again + ! !!! THIS must be the ONLY place where this gets incremented !!! + num_eqsolve_retries = num_eqsolve_retries + 1 + + ! print *, "goto 20, num_eqsolve_retries = ", num_eqsolve_retries + ! RECOMPUTE INITIAL PROFILE, BUT WITH IMPROVED AXIS ! OR ! RESTART FROM INITIAL PROFILE, BUT WITH A SMALLER TIME-STEP @@ -60,9 +67,6 @@ SUBROUTINE eqsolve(ier_flag) ! FORCE ITERATION LOOP iter_loop: DO WHILE (liter_flag) - ! !!! THIS must be the ONLY place where this gets incremented !!! - num_eqsolve_retries = num_eqsolve_retries + 1 - ! ADVANCE FOURIER AMPLITUDES OF R, Z, AND LAMBDA CALL evolve (delt0r, ier_flag, liter_flag) @@ -175,6 +179,10 @@ SUBROUTINE eqsolve(ier_flag) ! Retrieve previous good state CALL restart_iter(delt0r) iter1 = iter2 + + ! This breaks the dbgout logic, in that the same iter2 and num_eqsolve_retries combination is touched twice. + ! Hence, allow ONCE to overwrite the output file. + skip_dbgout_collison = .true. ELSE ! Increment time step and printout every nstep iterations ! status report due or @@ -189,6 +197,10 @@ SUBROUTINE eqsolve(ier_flag) ! count iterations iter2 = iter2 + 1 + + ! Disable again the temporary overwrite that was allowed above. + ! Trust on VMEC to reach this branch in the next iteration. + skip_dbgout_collison = .false. ENDIF diff --git a/src/funct3d.f90 b/src/funct3d.f90 index 4b3efb073..476adc945 100644 --- a/src/funct3d.f90 +++ b/src/funct3d.f90 @@ -13,7 +13,7 @@ SUBROUTINE funct3d (ier_flag) USE vmec_main - USE vacmod, ONLY: bsqvac, amatsav, bvecsav, mnpd2, bsubvvac, nestor_icall => icall + USE vacmod, ONLY: bsqvac, amatsav, bvecsav, mnpd2, bsubvvac use nestor_io, only: write_nestor_outputs USE vmec_params, ONLY: bad_jacobian_flag, signgs, ntmax USE realspace @@ -377,7 +377,7 @@ SUBROUTINE funct3d (ier_flag) !print *, "max bsqvac = ", maxval(bsqvac) - if (open_dbg_context("rbsq", id=nestor_icall)) then + if (open_dbg_context("rbsq", num_eqsolve_retries)) then call add_real_2d("rbsq", nzeta, ntheta3, rbsq) call close_dbg_out() end if