subroutine TFCoord_IcGrid3D_helper_new( &
  & cptr, cptr_icgrid3D, cptr_Zs, Z_T&
  & ) bind(C, name='TFCoord_IcGrid3D_helper_new')

  use, intrinsic :: iso_c_binding

  use dc_types, only: DP

  use TFCoord_IcGrid3D_helper, only: &
    & TFCoord_IcGrid3D, TFCoord_IcGrid3D_Init

  use IcGrid3D_FVM_Manager, only: &
    & IcGrid3D_FVM

  use Field_IcGrid2D_Manager, only: &
    & Field_IcGrid2D

  implicit none

  type(c_ptr), intent(out) :: cptr
  type(c_ptr), value :: cptr_icgrid3D
  type(c_ptr), value :: cptr_Zs
  real(DP), value :: Z_T

  type(TFCoord_IcGrid3D), pointer :: ptr
  type(IcGrid3D_FVM), pointer :: ptr_icgrid3D
  type(Field_IcGrid2D), pointer :: ptr_Zs

  allocate(ptr)
  call c_f_pointer(cptr_icgrid3D, ptr_icgrid3D)
  call c_f_pointer(cptr_Zs, ptr_Zs)

  call TFCoord_IcGrid3D_Init(ptr, ptr_icgrid3D, ptr_Zs, Z_T)

  cptr = c_loc(ptr)

end subroutine TFCoord_IcGrid3D_helper_new

subroutine TFCoord_IcGrid3D_helper_del( &
  & cptr &
  & )  bind(C, name='TFCoord_IcGrid3D_helper_del')

  use, intrinsic :: iso_c_binding

  use TFCoord_IcGrid3D_helper, only: &
    & TFCoord_IcGrid3D, TFCoord_IcGrid3D_Final

  implicit none
  type(c_ptr), intent(inout) :: cptr

  type(TFCoord_IcGrid3D), pointer :: ptr

  call c_f_pointer(cptr, ptr)
  call TFCoord_IcGrid3D_Final(ptr)
  deallocate(ptr)

  cptr = c_null_ptr

end subroutine TFCoord_IcGrid3D_helper_del

subroutine TFCoord_IcGrid3D_helper_get_TFMetric_G_1div2( &
  & cptr, cptr_G1div2 &
  & ) bind(C, name='TFCoord_IcGrid3D_helper_get_TFMetric_G_1div2')

  use, intrinsic :: iso_c_binding

  use Field_IcGrid2D_Manager, only: &
    & Field_IcGrid2D

  use TFCoord_IcGrid3D_helper, only: &
    & TFCoord_IcGrid3D, get_TFMetric_G_1div2

  implicit none
  type(c_ptr), value :: cptr
  type(c_ptr), intent(out) :: cptr_G1div2

  type(TFCoord_IcGrid3D), pointer :: ptr
  type(Field_IcGrid2D), pointer :: ptr_G1div2

  call c_f_pointer(cptr, ptr)
  ptr_G1div2 => get_TFMetric_G_1div2(ptr)

  cptr_G1div2 = c_loc(ptr_G1div2)

end subroutine TFCoord_IcGrid3D_helper_get_TFMetric_G_1div2

subroutine TFCoord_IcGrid3D_helper_calc_metric_G_1div2( &
  & cptr &
  & ) bind(C, name='TFCoord_IcGrid3D_helper_calc_metric_G_1div2')

  use, intrinsic :: iso_c_binding

  use TFCoord_IcGrid3D_helper, only: &
    & TFCoord_IcGrid3D, calc_metric_G_1div2

  implicit none
  type(c_ptr), value :: cptr

  type(TFCoord_IcGrid3D), pointer :: ptr

  call c_f_pointer(cptr, ptr)
  call calc_metric_G_1div2(ptr)

end subroutine TFCoord_IcGrid3D_helper_calc_metric_G_1div2


subroutine TFCoord_IcGrid3D_helper_calc_metric_G_Z( &
  & cptr, cptr_derivate &
  & )  bind(C, name='TFCoord_IcGrid3D_helper_calc_metric_G_Z')

  use, intrinsic :: iso_c_binding

  use TFCoord_IcGrid3D_helper, only: &
    & TFCoord_IcGrid3D, calc_metric_G_Z

  use Derivate_Field_IcGrid2D_Manager, only: &
    & Derivate_Field_IcGrid2D

  implicit none
  type(c_ptr), value :: cptr
  type(c_ptr), value :: cptr_derivate

  type(TFCoord_IcGrid3D), pointer :: ptr
  type(Derivate_Field_IcGrid2D), pointer :: ptr_derivate

  call c_f_pointer(cptr, ptr)
  call c_f_pointer(cptr_derivate, ptr_derivate)

  call calc_metric_G_Z(ptr, ptr_derivate)

end subroutine TFCoord_IcGrid3D_helper_calc_metric_G_Z
