subroutine get_fio_FOmagnetic_fields_p(params,F,Y_R,Y_PHI,Y_Z, &
B_X,B_Y,B_Z,flag,hint)
TYPE(FIELDS), INTENT(IN) :: F
TYPE(KORC_PARAMS), INTENT(IN) :: params
REAL(rp), DIMENSION(params%pchunk), INTENT(IN) :: Y_R,Y_PHI,Y_Z
REAL(rp), DIMENSION(params%pchunk), INTENT(INOUT) :: B_X,B_Y,B_Z
INTEGER(is), DIMENSION(params%pchunk), INTENT(INOUT) :: flag
TYPE(C_PTR), DIMENSION(params%pchunk), INTENT(INOUT) :: hint
INTEGER (C_INT) :: status
INTEGER :: pp,pchunk
REAL(rp), DIMENSION(3) :: x
REAL(rp), DIMENSION(3) :: Btmp
pchunk=params%pchunk
do pp = 1,pchunk
if (flag(pp) .EQ. 1_is) then
x(1) = Y_R(pp)*params%cpp%length
x(2) = Y_PHI(pp)
x(3) = Y_Z(pp)*params%cpp%length
! prtcls%hint(pp)=c_null_ptr
status = fio_eval_field(F%FIO_B, x(1), &
Btmp(1),hint(pp))
if (status .eq. FIO_SUCCESS) then
B_X(pp)=(Btmp(1)*cos(x(2))-Btmp(2)*sin(x(2)))/ &
params%cpp%Bo
B_Y(pp)=(Btmp(1)*sin(x(2))+Btmp(2)*cos(x(2)))/ &
params%cpp%Bo
B_Z(pp)=Btmp(3)/params%cpp%Bo
else if (status .eq. FIO_NO_DATA) then
flag(pp) = 0_is
else if (status .ne. FIO_SUCCESS) then
flag(pp) = 0_is
end if
end if
end do
end subroutine get_fio_FOmagnetic_fields_p