VMEC_EvalSplMode Function

public function VMEC_EvalSplMode(mn_in, rderiv, rho_in, xx_Spl)

Uses

  • proc~~vmec_evalsplmode~~UsesGraph proc~vmec_evalsplmode VMEC_EvalSplMode MODgvec_VMEC_Readin MODgvec_VMEC_Readin proc~vmec_evalsplmode->MODgvec_VMEC_Readin module~modgvec_vmec_vars MODgvec_VMEC_Vars proc~vmec_evalsplmode->module~modgvec_vmec_vars module~modgvec_cubic_spline MODgvec_cubic_spline module~modgvec_vmec_vars->module~modgvec_cubic_spline module~modgvec_globals MODgvec_Globals module~modgvec_vmec_vars->module~modgvec_globals module~modgvec_rprofile_base MODgvec_rProfile_base module~modgvec_vmec_vars->module~modgvec_rprofile_base module~modgvec_cubic_spline->module~modgvec_globals module~sll_m_bsplines sll_m_bsplines module~modgvec_cubic_spline->module~sll_m_bsplines iso_fortran_env iso_fortran_env module~modgvec_globals->iso_fortran_env module~modgvec_rprofile_base->module~modgvec_globals module~sll_m_bsplines_base sll_m_bsplines_base module~sll_m_bsplines->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform sll_m_bsplines_non_uniform module~sll_m_bsplines->module~sll_m_bsplines_non_uniform module~sll_m_bsplines_uniform sll_m_bsplines_uniform module~sll_m_bsplines->module~sll_m_bsplines_uniform module~sll_m_working_precision sll_m_working_precision module~sll_m_bsplines->module~sll_m_working_precision module~sll_m_bsplines_base->module~sll_m_working_precision module~sll_m_bsplines_non_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_non_uniform->module~sll_m_working_precision module~sll_m_bsplines_uniform->module~sll_m_bsplines_base module~sll_m_bsplines_uniform->module~sll_m_working_precision

evaluate spline for specific mode at position s

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: mn_in(:)
integer, intent(in) :: rderiv
real(kind=wp), intent(in) :: rho_in(:)

position to evaluate rho=[0,1], rho=sqrt(phi_norm)

type(t_cubspl), intent(in) :: xx_Spl(:)

Return Value real(kind=wp), (SIZE(rho_in))


Calls

proc~~vmec_evalsplmode~~CallsGraph proc~vmec_evalsplmode VMEC_EvalSplMode proc~cubspl_eval t_cubspl%cubspl_eval proc~vmec_evalsplmode->proc~cubspl_eval xm xm proc~vmec_evalsplmode->xm xn xn proc~vmec_evalsplmode->xn eval_basis eval_basis proc~cubspl_eval->eval_basis eval_basis_and_n_derivs eval_basis_and_n_derivs proc~cubspl_eval->eval_basis_and_n_derivs

Source Code

FUNCTION VMEC_EvalSplMode(mn_in,rderiv,rho_in,xx_Spl)
  ! MODULES
  USE MODgvec_VMEC_Readin
  USE MODgvec_VMEC_Vars
  IMPLICIT NONE
  !-----------------------------------------------------------------------------------------------------------------------------------
  ! INPUT VARIABLES
    INTEGER,INTENT(IN)         :: mn_in(:) !of size 1: =jmode, of size 2: find jmode to mn
    INTEGER,INTENT(IN)         :: rderiv !0: eval spl, 1: eval spl deriv
    REAL(wp),INTENT(IN)        :: rho_in(:) !! position to evaluate rho=[0,1], rho=sqrt(phi_norm)
    TYPE(t_cubspl),INTENT(IN)  :: xx_Spl(:)
  !-----------------------------------------------------------------------------------------------------------------------------------
  ! OUTPUT VARIABLES
    REAL(wp)                   :: VMEC_EvalSplMode(SIZE(rho_in))
  !-----------------------------------------------------------------------------------------------------------------------------------
  ! LOCAL VARIABLES
    INTEGER                    :: jMode,modefound
    REAL(wp),DIMENSION(SIZE(rho_in))  :: rhom,drhom,xx_eval !for weighted spline interpolation
  !===================================================================================================================================
    IF(.NOT.MPIroot) CALL abort(__STAMP__, &
                          'EvalSpl called from non-MPIroot process, but VMEC data only on root!')
    IF(size(mn_in,1).EQ.2)THEN
      modefound=0
      DO jMode=1,mn_mode
        IF((NINT(xm(jMode)).EQ.mn_in(1)).AND.(NINT(xn(jMode)).EQ.mn_in(2)))THEN
          modefound=jMode
          EXIT
        END IF
      END DO
      IF(modefound.NE.0) THEN
        jMode=modefound
      ELSE
        WRITE(*,*)'Remark: mode m= ',mn_in(1),' n= ',mn_in(2),'not found in VMEC solution, setting to zero!'
        VMEC_EvalSplMode=0.0_wp
        RETURN
      END IF
    ELSEIF(size(mn_in,1).EQ.1)THEN
      jMode=mn_in(1)
    ELSE
      CALL abort(__STAMP__, &
       'mn_in should have size 1 or 2')
    END IF

    SELECT CASE(xmabs(jMode))
    CASE(0)
      rhom=1.0_wp
      drhom=0.0_wp
    CASE(1)
      rhom=rho_in
      drhom=1.0_wp
    CASE(2)
      rhom=rho_in*rho_in
      drhom=2.0_wp*rho_in
    CASE DEFAULT
      rhom=rho_in**xmabs(jMode)
      drhom=REAL(xmabs(jMode),wp)*rho_in**(xmabs(jMode)-1)
    END SELECT
    xx_eval=xx_Spl(jMode)%eval(rho_in,0)  ! includes weight 1/rhom
    IF(rderiv.EQ.0) THEN
      VMEC_EvalSplMode=rhom*xx_eval
    ELSEIF(rderiv.EQ.1) THEN
      VMEC_EvalSplMode=rhom*xx_Spl(jMode)%eval(rho_in,1) + drhom*xx_eval
    ELSE
      CALL abort(__STAMP__, &
       'rderiv should be 0 or 1')
    END IF
  END FUNCTION VMEC_EvalSplMode