Skip to content

Commit

Permalink
hacks leading up to get dbgout for free-bdy iterations only
Browse files Browse the repository at this point in the history
  • Loading branch information
jons-pf committed Oct 29, 2023
1 parent a41c1e0 commit 40b55e2
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 146 deletions.
3 changes: 2 additions & 1 deletion src/NESTOR/analyt.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/NESTOR/bextern.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SUBROUTINE bextern(plascur, wint)
USE mgrid_mod, ONLY: bvac

use dbgout
use vmec_main, only: num_eqsolve_retries

IMPLICIT NONE

Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/NESTOR/data/vacmod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/NESTOR/fouri.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/NESTOR/fourp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SUBROUTINE fourp (grpmn, grp)
USE vacmod, vm_grpmn => grpmn

use dbgout
use vmec_main, only: num_eqsolve_retries

IMPLICIT NONE

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/NESTOR/precal.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SUBROUTINE precal
USE vacmod

use dbgout
use vmec_main, only: num_eqsolve_retries

IMPLICIT NONE

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

Expand Down
3 changes: 2 additions & 1 deletion src/NESTOR/surface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions src/NESTOR/vacuum.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -255,6 +256,6 @@ SUBROUTINE vacuum(rmnc, rmns, zmns, zmnc, xm, xn, &

ENDIF

icall = icall + 1
!icall = icall + 1

END SUBROUTINE vacuum
Loading

0 comments on commit 40b55e2

Please sign in to comment.