Compute
    (integral_0^psi d psi q/g)/(integral_0^psimax d psi q/g)
    This is the radial coordinate used in PEST1 according to
    Manickam.
integer, intent(in) :: ns
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: s(ns)
integer, intent(out) :: ier
    Compute (R0/2*pi) * the volume integral dV/X**2 and return result
    in 'res'.
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the plasma surface and return result in 'res'.
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the plasma volume and return result in 'res'.
    ier error flag (ok if =0)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the enclosed volume V(psi) and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: ns
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res(ns)
integer, intent(out) :: ier
    Compute d/dpsi of enclosed volume V and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: ns
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res(ns)
integer, intent(out) :: ier
    compute <p>, the volume average pressure and return the result
    in 'res'. ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    compute <B^2>, the volume average of the square of the magnetic field
    and return the result in 'res'. ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute (the volume averaged) beta and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the (volume averaged) 2 sqrt(<p^2>)/B0^2
    and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute beta-toroidal and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the approximate beta-poroidal and return the result in 'res'. The
    formula used is loosely based on Eq(4.32) in Ideal Magnetohydrodynamics
    by J P Freidberg, since there appears to be an error in Eq(4.29) therein.
    Call i2mex_getBetaPoloidal for a more accurate estimate of beta-poloidal.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute beta-toroidal and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the normalized beta (beta_N) and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the plasma boundary frame; ie the abscissae xin and xout
    where the plasma boundary intersects the mid plane, and the ordinates
    zbot and ztop where the plasma boundary intersects the vertical plane
    passing through the magnetic axis.
real(i2mex_r8), intent(out) :: xin     mid plane intersect inside
real(i2mex_r8), intent(out) :: xout     mid plane intersect outside
real(i2mex_r8), intent(out) :: zbot     bottom intersect below magnetic axis
real(i2mex_r8), intent(out) :: ztop     top intersect above magnetic axis
integer, intent(out) :: ier
    Compute the minor radius, and return the result in 'res'. The
    minor radius is defined as the half distance between Xout and Xin,
    where Xin and Xout are the plasma boundary points intersecting the
    mid plane.
   
    ier error flag (ok if =0)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the major radius, and return the result in 'res'. The
    major radius is defined as the average of Xout and Xin, where
    Xin and Xout are the plasma boundary points intersecting the
    mid plane.
   
    ier error flag (ok if =0)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the magnetic radius position, and return the result in 'res'.
    ier error flag (ok if =0)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the magnetic Z position, and return the result in 'res'.
    ier error flag (ok if =0)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute the vacuum magnetic field at the major radius position,
    and return the result in 'res'.
    ier error flag (ok if =0)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute <J.B>/<B^2> and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res(ns)
integer, intent(out) :: ier
    Compute <1/R^2> = integral d theta J /X^2 / integral d theta J
    and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res(ns)
integer, intent(out) :: ier
    Compute <B^2> = integral d theta J B^2 / integral d theta J
    and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res(ns)
integer, intent(out) :: ier
    Compute Ip, the plasma current, and return the result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier
    Compute li, the internal plasma inductance, and return the
    result in 'res'.
    ier error flag (ok if =0)
integer, intent(in) :: nt1, ns
real(i2mex_r8), intent(in) :: the(nt1)
real(i2mex_r8), intent(in) :: psi(ns)
real(i2mex_r8), intent(out) :: res
integer, intent(out) :: ier