3 subroutine eqb( alf0,alf1,alf2, bet0,bet1,bet2, alw0,alw1,alw2,
5 * keyctr,nstep,platok,rax,zax,b0cen,r0cen,psax,igdf,
6 * n_tht, n_psi, epsro, nurs, i_eqdsk,i_bsh,
11 parameter(nursp4=nursp+4,nursp6=nursp4*6)
16 common /combsh/ rm0,zm0,rc0,zc0,asp0,el_up,el_lw,tr_up,tr_lw,nbsh
17 common /comabw/ alf0p,alf1p,alf2p, bet0f,bet1f,bet2f
20 c -----------------------------------------------------------------
23 real*8 alf0,alf1,alf2, bet0,bet1,bet2, alw0,alw1,alw2
24 real time_beg,time_end, time_b,time_e, dtim1,dtim2,dtim3
25 real*8 q_giv(nrp),q_0(nrp)
27 dimension pstab(nursp), qtab(nursp), psian(nrp)
28 real*8 rrk(nursp4),cck(nursp4),wrk(nursp6)
37 c--------------------------------------------------------------------
42 c--------------------------------------------------------------------
48 if(keyctr.ge.100)
return
68 c...input initial
data
84 c--------------------------------------------------------------------
102 c--------------------------------------------------------------------
106 write(fname,
'(a,a)') path(1:kname),
'inpol.dat'
154 if(igdf.eq.2) igrdf=1
157 if(nbsh.eq.0.or.nbsh.eq.1)
then
159 call taburs(0,1.d0,nurs)
160 elseif(nbsh.eq.-1)
then
163 elseif(nbsh.eq.-2)
then
165 call taburs(0,1.d0,nurs)
170 dfdpsi(i)=tabf(psia(i))
173 if(ngav.eq.0) call
presol(i_betp,betplx,betpol)
179 if(nbsh.eq.0.or.nbsh.eq.1)
then
181 elseif(nbsh.eq.-1)
then
184 elseif(nbsh.eq.-2)
then
204 c--------------------------------------------------------------------
216 c------------------------------------------------
217 write(fname,
'(a,a)') path(1:kname),
'tab_q.dat'
222 read(1,*) pstab(i), qtab(i)
225 c------------------------------------------------
228 pstab(i)=pstab(i)/pstab(nutab)
231 call
e01baf(nutab,pstab,qtab,rrk,cck,
232 * nutab+4,wrk,6*nutab+16,ifail)
238 psia05=1.d0-0.5d0*(psia(i)+psia(i+1))
240 call
e02bcf(nutab+4,rrk,cck,psia05,0,cwk,ifail)
242 q_giv(i)=cwk(1)*2.d0*pi
248 q_giv(iplas)=qtab(nutab)*2.d0*pi
265 errpsn=dabs(psian(i)-psia(i))
266 errpsa=dmax1(errpsa,errpsn)
269 if(errpsa.gt.1.d-9) go to 2257
277 dfdpsi(i)=tabf(psia(i))
320 if(iter.gt.4) call
skbetp(betplx,betpol)
353 errod = 0.5d0*erro/(dabs(z(iplas,2)-zm)+dabs(r(iplas,2)-rm))
356 if(errod.lt.epsro) go to 2000
357 if(itin.ge.nimax)
then
358 write(*,*)
'SPIDER: MAX NUMBER OF ITERATIONS IS EXCEEDED'
359 write(*,*)
'ERROD=',errod
360 write(*,*)
'ITER=',itin
384 c--------------------------------------------------------------------
400 if(ngav.gt.0) qax = q_giv0
409 write(* ,*)
'*******************************************'
410 write(* ,*)
'Iterations have been converged for epsro =',epsro
411 write(* ,*)
'Achieved accuracy ................ errod =',errod
412 write(* ,*)
'Number of iterations ............. iter =',iter
413 write(* ,*)
'Magnetic axis coordinates ........ rm =', rm
414 write(* ,*)
' zm =', zm
415 write(* ,*)
'Plasma current ................... tokp =', tokp
416 write(* ,*)
' cnor =', cnor
417 write(* ,*)
'Magnetic axis PSI value .......... psim =', psim
418 write(* ,*)
'Poloidal beta value ............. betpol =', betpol
419 write(* ,*)
'Total beta value ............. bettot =', bettot
420 write(* ,*)
'Plas.boun.poloidal current value... fvac =', fvac
422 write(* ,*)
'*******************************************'
461 parameter(nursp=4000,nursp4=nursp+4,nursp6=nursp4*6)
465 common/comppp/
ppp(nursp),fff(nursp),www(nursp)
466 common/comurs/psit(nursp),purs(nursp),furs(nursp),wurs(nursp),
468 dimension pstab(nursp),pptab(nursp),fptab(nursp)
469 real*8 rrk(nursp4),cck(nursp4),wrk(nursp6)
474 write(*,*)
'retab:recalculation p and ff'
477 pstab(i)=1.d0-psia(i)
480 call
e01baf(iplas,pstab,dfdpsi,rrk,cck,
481 * iplas+4,wrk,6*iplas+16,ifail)
483 if(ifail.ne.0.and.kpr.eq.1)
write(*,*)
'ifail=',ifail
489 call
e02bcf(iplas+4,rrk,cck,zpsi,0,cwk,ifail)
491 if(ifail.ne.0.and.kpr.eq.1)
write(*,*)
'ifail=',ifail
497 furs(1)=dfdpsi(iplas)
501 * iplas+4,wrk,6*iplas+16,ifail)
503 if(ifail.ne.0.and.kpr.eq.1)
write(*,*)
'ifail=',ifail
509 call
e02bcf(iplas+4,rrk,cck,zpsi,0,cwk,ifail)
511 if(ifail.ne.0.and.kpr.eq.1)
write(*,*)
'ifail=',ifail
526 dpsi=1.d0/(nurs-1.d0)
531 ppp(i)=
ppp(i-1) +(purs(i-1)+purs(i))*dpsi*0.5d0
532 fff(i)=fff(i-1) +(furs(i-1)+furs(i))*dpsi*0.5d0
548 common/comppp/
ppp(nursp),fff(nursp),www(nursp)
549 dimension pstab(nursp),pptab(nursp),fptab(nursp)
556 pstab(i)=1.d0-psia(i)
563 if(zpsi.gt.pstab(i) .AND. zpsi.le.pstab(i+1))
then
569 dpsi=pstab(ic+1)-pstab(ic)
570 furs(it)=( dfdpsi(ic)*(pstab(ic+1)-zpsi)+
571 * dfdpsi(ic+1)*(zpsi-pstab(ic)) )/dpsi
573 purs(it)=(
dpdpsi(ic)*(pstab(ic+1)-zpsi)+
574 *
dpdpsi(ic+1)*(zpsi-pstab(ic)) )/dpsi
577 furs(1)=dfdpsi(iplas)
583 dpsi=1.d0/(nurs-1.d0)
588 ppp(i)=
ppp(i-1) +(purs(i-1)+purs(i))*dpsi*0.5d0
589 fff(i)=fff(i-1) +(furs(i-1)+furs(i))*dpsi*0.5d0
604 common/comppp/
ppp(nursp),fff(nursp),www(nursp)
605 dimension pstab(*),pptab(*),fptab(*)
609 write(*,*)
'retab_L:recalculation p and ff'
616 if(zpsi.gt.pstab(i) .AND. zpsi.le.pstab(i+1))
then
622 dpsi=pstab(ic+1)-pstab(ic)
623 furs(it)=( fptab(ic)*(pstab(ic+1)-zpsi)+
624 * fptab(ic+1)*(zpsi-pstab(ic)) )/dpsi
626 purs(it)=( pptab(ic)*(pstab(ic+1)-zpsi)+
627 * pptab(ic+1)*(zpsi-pstab(ic)) )/dpsi
636 dpsi=1.d0/(nurs-1.d0)
641 ppp(i)=
ppp(i-1) +(purs(i-1)+purs(i))*dpsi*0.5d0
642 fff(i)=fff(i-1) +(furs(i-1)+furs(i))*dpsi*0.5d0
656 common/comppp/
ppp(nursp),fff(nursp),www(nursp)
657 dimension pstab(nursp),pptab(nursp),fptab(nursp)
661 write(*,*)
'retab_F:linear recalculation ff table'
664 pstab(i)=1.d0-psia(i)
671 if(zpsi.gt.pstab(i) .AND. zpsi.le.pstab(i+1))
then
677 dpsi=pstab(ic+1)-pstab(ic)
678 furs(it)=( dfdpsi(ic)*(pstab(ic+1)-zpsi)+
679 * dfdpsi(ic+1)*(zpsi-pstab(ic)) )/dpsi
685 furs(1)=dfdpsi(iplas)
691 dpsi=1.d0/(nurs-1.d0)
697 fff(i)=fff(i-1) +(furs(i-1)+furs(i))*dpsi*0.5d0
712 common/comppp/
ppp(nursp),fff(nursp),www(nursp)
713 dimension pstab(nursp),pptab(nursp),fptab(nursp)
717 write(*,*)
'retab_p:linear recalculation p table'
720 pstab(i)=1.d0-psia(i)
727 if(zpsi.gt.pstab(i) .AND. zpsi.le.pstab(i+1))
then
733 dpsi=pstab(ic+1)-pstab(ic)
737 purs(it)=(
dpdpsi(ic)*(pstab(ic+1)-zpsi)+
738 *
dpdpsi(ic+1)*(zpsi-pstab(ic)) )/dpsi
747 dpsi=1.d0/(nurs-1.d0)
752 ppp(i)=
ppp(i-1) +(purs(i-1)+purs(i))*dpsi*0.5d0
770 volcen=volcen+vol(1,j)*0.5d0
785 volk=vol1(i,j)+vol2(i-1,j)+vol3(i-1,j-1)+vol4(i,j-1)
786 pintg=pintg+zpres*volk
794 bettot=2.d0*paverg/(b0ax*b0ax)
795 bettot=bettot*(psim-psip)*cnor
821 c
write(6,*)
'matpla'
828 write(*,*)
'iter=',iter,itin
832 c
write(6,*)
'rightg'
836 if(iter.gt.4) call
skbetp(betplx,betpol)
852 write(*,*)
'presol: errpsi',errpsi
864 errod = 0.5d0*erro/dabs(z(iplas,2)-zm)
866 if(errpsi.lt.1.d-4 .or. iter.ge.50) go to 2000
879 if(psi(i,j).gt.psimax)
then
889 write(*,*)
'presol: '
890 write(*,*)
'number of iterations ',iter
891 write(*,*)
'accuracy ',errpsi
893 c--------------------------------------------------------------------
895 call
prgrid(imax,jmax,erro,1,errpsi)
903 write(*,*)
'rax,zax',rax,zax
904 write(*,*)
'plas.current',platok,cnor
905 write(*,*)
'psax',psax
936 xa=dfloat(i-1)/dfloat(iplas-1)
937 fun=( 1.d0-dtanh(((xa0-xa)/xw)**2) )
975 common/comppp/
ppp(nursp),fff(nursp),www(nursp)
977 roomega=www(nurs)*psim*cnor
978 write(*,*)
'roomega',roomega
subroutine e02bcf(NCAP7, K, C, X, LEFT, S, IFAIL)
subroutine psib_ext(psex_av)
subroutine put_tim(dt, time)
subroutine spider_remesh(erro, errpsi, imov)
subroutine grid_b(igdf, nstep)
subroutine eqb(alf0, alf1, alf2, bet0, bet1, bet2, alw0, alw1, alw2,
real(r8) function dpdpsi(psi_n)
subroutine grid_p1(igdf, nstep)
subroutine get_tim(dt, time)
subroutine e01baf(M, X, Y, K, C, LCK, WRK, LWRK, IFAIL)
subroutine retab_l_ast(pstab, pptab, fptab, ntab)
subroutine grid_b1(igdf, nstep)
subroutine skbetp(betplx, betpol)
subroutine bt_pol(betpol)
subroutine bt_tot(bettot)
subroutine prgrid(imax, jmax, erro, imov, errpsi)
subroutine get_www(roomega)
subroutine grid_p0(igdf, nstep)
subroutine presol(i_betp, betplx, betpol)
subroutine grid_1(igdf, nstep)
subroutine grid_0(igdf, nstep)