13SUBROUTINE getbsubs (bsubsmn, frho, bsupu, bsupv, mmax, nmax, info)
20 REAL(rprec),
INTENT(out) :: bsubsmn(0:mmax, -nmax:nmax, 0:1)
21 REAL(rprec),
DIMENSION(nzeta, ntheta3),
INTENT(in) :: frho
22 REAL(rprec),
DIMENSION(nzeta, ntheta3),
INTENT(in) :: bsupu
23 REAL(rprec),
DIMENSION(nzeta, ntheta3),
INTENT(in) :: bsupv
24 INTEGER,
INTENT(in) :: mmax
25 INTEGER,
INTENT(in) :: nmax
26 INTEGER,
INTENT(out) :: info
28 REAL(rprec),
PARAMETER :: p5 = 0.5_dp, one = 1
30 INTEGER :: i, j, m, n, nmax1, itotal, ijtot, mntot
31 REAL(rprec) :: ccmn, ssmn, csmn, scmn, dm, dn, termsc, termcs, termcc, termss, amn
32 REAL(rprec),
ALLOCATABLE :: amatrix(:,:), save_matrix(:,:), brhs(:)
49 IF ((mmax+1 .ne.
ntheta2) .or. (nmax .ne.
nzeta/2))
RETURN
53 IF (.not.
lasym) itotal = itotal - 2*nmax1
54 ALLOCATE (amatrix(itotal, itotal), brhs(itotal), save_matrix(itotal, itotal), stat=m)
55 IF (m .ne. 0) stop
'Allocation error in getbsubs'
68 lpior0 = ((i.eq.1 .or. i.eq.
ntheta2) .and. (j.gt.
nzeta/2+1))
69 IF (lpior0 .and. .not.
lasym) cycle
73 brhs(ijtot) = frho(j,i)
78 IF (mntot .ge. itotal)
EXIT
79 IF (m.eq.0 .and. n.eq.0 .and.
lasym) cycle
86 dn = n * bsupv(j,i) *
nfp
87 termsc = dm*ccmn - dn*ssmn
88 termcs =-dm*ssmn + dn*ccmn
89 IF (n.eq.0 .or. n.eq.nmax)
THEN
92 amatrix(ijtot,mntot) = termsc
93 ELSE IF (n .eq. 0)
THEN
95 amatrix(ijtot,mntot) = bsupv(j,i)
98 amatrix(ijtot,mntot) = termcs
100 ELSE IF (m.eq.0 .or. m.eq.mmax)
THEN
102 amatrix(ijtot,mntot) = termcs
104 amatrix(ijtot,mntot) = termsc
106 amatrix(ijtot,mntot) = termcs
110 IF (m.eq.0 .and. (n.eq.0 .or. n.eq.nmax)) cycle
112 IF (mntot .ge. itotal)
EXIT
118 termcc =-dm*scmn - dn*csmn
119 termss = dm*csmn + dn*scmn
121 IF ((n.eq.0 .or. n.eq.nmax) .or. (m.eq.0 .or. m.eq.mmax))
THEN
123 amatrix(ijtot,mntot) = termcc
125 amatrix(ijtot,mntot) = termcc
127 amatrix(ijtot,mntot) = termss
137 save_matrix = amatrix
140 IF (ijtot .ne. itotal .or. mntot .ne. itotal)
THEN
141 print *,
' itotal = ', itotal,
' ijtot = ', ijtot,
' mntot = ', mntot
142 print *,
' ntheta3: ',
ntheta3,
' nzeta: ',
nzeta,
' mnyq: ', mmax,
' nnyq: ', nmax
145 CALL solver (amatrix, brhs, itotal, 1, info)
146 IF (info .ne. 0)
GOTO 200
156 lpior0 = ((i.eq.1 .or. i.eq.
ntheta2) .and. (j.gt.
nzeta/2+1))
157 IF (lpior0 .and. .not.
lasym) cycle
161 amn = sum(save_matrix(ijtot,:)*brhs(:))
163 IF (abs(amn) .lt. 1.e-12_dp) cycle
164 IF (abs(frho(j,i) - amn) .gt. 1.e-8_dp*abs(amn))
THEN
165 print 50,
'In GETbsubs, i = ',i,
' j = ',j,
' Original force = ', frho(j,i),
' Final force = ', amn
169 50
FORMAT(a,i5,a,i5,a,1p,e10.3,a,1p,e10.3)
181 IF (mntot .ge. itotal)
EXIT
182 IF (m.eq.0 .and. n.eq.0 .and.
lasym) cycle
186 IF (n.eq.0 .or. n.eq.nmax)
THEN
188 bsubsmn(m,n,0) = brhs(mntot)
189 ELSE IF (n .eq. 0)
THEN
190 bsubsmn(m,n,0) = brhs(mntot)
192 bsubsmn(m,-n,0) = brhs(mntot)
194 ELSE IF (m.eq.0 .or. m.eq.mmax)
THEN
195 bsubsmn(m,-n,0) = brhs(mntot)
197 bsubsmn(m,n,0) = brhs(mntot)
199 bsubsmn(m,-n,0) = brhs(mntot)
203 IF (m.eq.0 .and. (n.eq.0 .or. n.eq.nmax)) cycle
204 IF (mntot .ge. itotal)
EXIT
208 IF ((n.eq.0 .or. n.eq.nmax) .or. (m.eq.0 .or. m.eq.mmax))
THEN
209 bsubsmn(m,n,1) = brhs(mntot)
211 bsubsmn(m,n,1) = brhs(mntot)
213 bsubsmn(m,-n,1)= brhs(mntot)
220 IF (mntot .ne. ijtot) info = -2
224 DEALLOCATE (amatrix, save_matrix, brhs)