subroutine analytical_fields_GC_p(pchunk,F,Y_R,Y_PHI, &
Y_Z,B_R,B_PHI,B_Z,E_R,E_PHI,E_Z,curlb_R,curlb_PHI,curlb_Z,gradB_R, &
gradB_PHI,gradB_Z,PSIp)
INTEGER, INTENT(IN) :: pchunk
TYPE(FIELDS), INTENT(IN) :: F
REAL(rp),DIMENSION(pchunk),INTENT(IN) :: Y_R,Y_PHI,Y_Z
REAL(rp),DIMENSION(pchunk),INTENT(OUT) :: B_R,B_PHI,B_Z
REAL(rp),DIMENSION(pchunk),INTENT(OUT) :: gradB_R,gradB_PHI,gradB_Z
REAL(rp),DIMENSION(pchunk),INTENT(OUT) :: curlB_R,curlB_PHI,curlB_Z
REAL(rp),DIMENSION(pchunk),INTENT(OUT) :: E_R,E_PHI,E_Z
REAL(rp),DIMENSION(pchunk),INTENT(OUT) :: PSIp
REAL(rp),DIMENSION(pchunk) :: dRBR,dRBPHI,dRBZ,dZBR,dZBPHI,dZBZ,Bmag,dRbhatPHI
REAL(rp),DIMENSION(pchunk) :: dRbhatZ,dZbhatR,dZbhatPHI,qprof,rm,theta
REAL(rp) :: B0,E0,lam,R0,q0
integer(ip) :: cc
B0=F%Bo
E0=F%Eo
lam=F%AB%lambda
R0=F%AB%Ro
q0=F%AB%qo
!$OMP SIMD
! !$OMP& aligned(Y_R,Y_PHI,Y_Z,B_R,B_PHI,B_Z,gradB_R,gradB_PHI,gradB_Z, &
! !$OMP& curlB_R,curlB_PHI,curlB_Z,E_R,E_PHI,E_Z,PSIp)
do cc=1_idef,pchunk
rm(cc)=sqrt((Y_R(cc)-R0)*(Y_R(cc)-R0)+Y_Z(cc)*Y_Z(cc))
theta(cc)=atan2(Y_Z(cc),(Y_R(cc)-R0))
qprof(cc) = 1.0_rp + (rm(cc)*rm(cc)/(lam*lam))
PSIp(cc)=Y_R(cc)*lam**2*B0/ &
(2*q0*(R0+rm(cc)*cos(theta(cc))))* &
log(1+(rm(cc)/lam)**2)
B_R(cc)=B0*Y_Z(cc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