














































 







































































 


































































































































































 

















































































































































































































































































































































































































































 






































































































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                



















































































subroutine Con2PrimPolyWrapper(handle, dens, sx, sy, sz, tau, rho, &
     velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, &
     uyz, uzz, detg, x, y, z, r, GRHydro_rho_min, GRHydro_reflevel, GRHydro_C2P_failed)

  use Con2Prim_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  REAL*8, INTENT(INOUT) :: dens, sx, sy, sz
  REAL*8, INTENT(OUT) :: tau
  REAL*8, INTENT(INOUT) :: rho
  REAL*8, INTENT(INOUT) :: velx, vely, velz, epsilon, press, w_lorentz
  REAL*8, INTENT(IN) :: uxx, uxy, uxz, uyy, uyz, uzz, detg
  REAL*8, INTENT(IN) :: x, y, z, r, GRHydro_rho_min

  INTEGER*4, INTENT(IN) :: handle, GRHydro_reflevel
  REAL*8, INTENT(OUT) :: GRHydro_C2P_failed

  REAL*8 :: sdetg

  sdetg = sqrt(detg)

  call Con2Prim_ptPolytype(handle, dens, sx, sy, sz, tau, rho, &
     velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, &
     uyz, uzz, sdetg, x, y, z, r, GRHydro_rho_min, GRHydro_reflevel, &
     GRHydro_C2P_failed)

end subroutine

subroutine Con2PrimGenWrapper(handle, dens, sx, sy, sz, tau, rho, velx, vely, &
                              velz, epsilon, pressure, w_lorentz, uxx, uxy, &
                              uxz, uyy, uyz, uzz, det, x, y, z, r, epsnegative, &
                              GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, &
                              retval)

  use Con2Prim_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle
  REAL*8, INTENT(INOUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(INOUT) :: rho, velx, vely, velz, epsilon, pressure
  REAL*8, INTENT(INOUT) :: w_lorentz
  REAL*8, INTENT(IN) :: uxx, uxy, uxz, uyy, uyz, uzz, det
  REAL*8, INTENT(IN) :: x, y, z, r
  INTEGER*4, INTENT(OUT) :: epsnegative
  REAL*8, INTENT(IN) :: GRHydro_rho_min, pmin, epsmin
  INTEGER*4, INTENT(IN) :: GRHydro_reflevel
  REAL*8, INTENT(OUT) :: retval

  REAL*8 :: sdetg
  INTEGER*4, parameter :: cctk_iteration = -1, ii = -1, jj = -1, kk = -1
  logical :: log_epsnegative

  sdetg = sqrt(det)

  call Con2Prim_pt(cctK_iteration, ii, jj, kk, &
                   handle, dens, sx, sy, sz, tau, rho, velx, vely, &
                   velz, epsilon, pressure, w_lorentz, uxx, uxy, &
                   uxz, uyy, uyz, uzz, sdetg, x, y, z, r, log_epsnegative, &
                   GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, &
                   retval)
  if(log_epsnegative) then
    epsnegative = 1
  else
    epsnegative = 0
  end if

end subroutine

subroutine Con2PrimGenMWrapper(handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, &
                               tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, &
                               vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, &
                               Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, &
                               uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)

  use Con2PrimM_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle, keytemp
  REAL*8, INTENT(IN) :: prec, gamma_eos
  REAL*8, INTENT(INOUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(IN) :: Bconsx, Bconsy, Bconsz
  REAL*8, INTENT(INOUT) :: y_e,  temp
  REAL*8, INTENT(INOUT) :: rho, velx, vely, velz, epsilon, pressure
  REAL*8, INTENT(OUT) :: Bvecx, Bvecy, Bvecz, Bvecsq
  REAL*8, INTENT(INOUT) :: w_lorentz
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: uxx, uxy, uxz, uyy, uyz, uzz
  REAL*8, INTENT(IN) :: det
  INTEGER*4, INTENT(OUT) :: epsnegative
  REAL*8, INTENT(OUT) :: retval

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  if(handle.eq.1 .or. handle.eq.2) then
    call GRHydro_Con2PrimM_ptold(handle, gamma_eos, dens, sx, sy, sz, &
                                 tau, Bconsx, Bconsy, Bconsz, rho, velx, &
                                 vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, &
                                 Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, &
                                 uxy, uxz, uyy, uyz, uzz, sdetg, epsnegative, retval)
  else
    call GRHydro_Con2PrimM_pt2(handle, keytemp, prec, prec, gamma_eos, dens, sx, sy, sz, &
                               tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, &
                               vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, &
                               Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, &
                               uxy, uxz, uyy, uyz, uzz, sdetg, epsnegative, retval)
  end if

end subroutine

subroutine Con2PrimPolyMWrapper(handle, gamma_eos, dens, sx, sy, sz, sc,&
                                Bconsx, Bconsy, Bconsz, rho, velx, vely, velz,&
                                epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq,&
                                w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx,&
                                uxy, uxz, uyy, uyz, uzz, det, epsnegative,&
                                retval)

  use Con2PrimM_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle
  REAL*8, INTENT(IN) :: gamma_eos
  REAL*8, INTENT(INOUT) :: dens, sx, sy, sz, sc
  REAL*8, INTENT(INOUT) :: Bconsx, Bconsy, Bconsz
  REAL*8, INTENT(INOUT) :: rho, velx, vely, velz, epsilon, pressure
  REAL*8, INTENT(OUT) :: Bvecx, Bvecy, Bvecz
  REAL*8, INTENT(OUT) :: Bvecsq
  REAL*8, INTENT(INOUT) :: w_lorentz
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: uxx, uxy, uxz, uyy, uyz, uzz
  REAL*8, INTENT(IN) :: det
  INTEGER*4, INTENT(OUT) :: epsnegative
  REAL*8, INTENT(OUT) :: retval

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call GRHydro_Con2PrimM_Polytype_pt(handle, gamma_eos, dens, sx, sy, sz, sc, &
                                     Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, &
                                     epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, &
                                     w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, &
                                     uxy, uxz, uyy, uyz, uzz, sdetg, epsnegative, &
                                     retval)
end subroutine

subroutine Prim2ConGenWrapper(handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens,&
                              sx, sy, sz, tau, rho, velx, vely, velz, epsilon,&
                              press, w_lorentz)

  use Con2Prim_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: det
  REAL*8, INTENT(OUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(IN) :: rho, velx, vely, velz, epsilon
  REAL*8, INTENT(OUT) :: press, w_lorentz

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call prim2con(handle, gxx, gxy, gxz, gyy, gyz, gzz, sdetg, dens,&
                sx, sy, sz, tau, rho, velx, vely, velz, epsilon,&
                press, w_lorentz)
end subroutine

subroutine Prim2ConPolyWrapper(handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens,&
                               sx, sy, sz, tau, rho, velx, vely, velz, epsilon,&
                               press, w_lorentz)

  use Con2Prim_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: det
  REAL*8, INTENT(OUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(IN) :: rho, velx, vely, velz
  REAL*8, INTENT(OUT) :: epsilon, press, w_lorentz

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call prim2conpolytype(handle, gxx, gxy, gxz, gyy, gyz, gzz, sdetg, dens,&
                        sx, sy, sz, tau, rho, velx, vely, velz, epsilon,&
                        press, w_lorentz)
end subroutine

subroutine Prim2ConGenMWrapper(handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens,&
                               sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho,&
                               velx, vely, velz, epsilon, press, Bvecx, Bvecy,&
                               Bvecz, w_lorentz)

  use Con2PrimM_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: det
  REAL*8, INTENT(OUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(OUT) :: Bconsx, Bconsy, Bconsz
  REAL*8, INTENT(IN) :: rho, velx, vely, velz, epsilon
  REAL*8, INTENT(OUT) :: press
  REAL*8, INTENT(IN) :: Bvecx, Bvecy, Bvecz
  REAL*8, INTENT(OUT) :: w_lorentz

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call prim2conM(handle, gxx, gxy, gxz, gyy, gyz, gzz, sdetg, dens,&
                 sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho,&
                 velx, vely, velz, epsilon, press, Bvecx, Bvecy,&
                 Bvecz, w_lorentz)
end subroutine

subroutine Prim2ConGenM_hotWrapper(handle, GRHydro_reflevel, i, j, k, x, y, z,&
                                   gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx,&
                                   sy, sz, tau, Bconsx, Bconsy, Bconsz, rho,&
                                   velx, vely, velz, epsilon, press, Bvecx,&
                                   Bvecy, Bvecz, w_lorentz, temperature, Y_e)

  use Con2PrimM_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle, GRHydro_reflevel
  INTEGER*4, INTENT(IN) :: i, j, k
  REAL*8, INTENT(IN) :: x, y, z
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: det
  REAL*8, INTENT(OUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(OUT) :: Bconsx, Bconsy, Bconsz
  REAL*8, INTENT(IN) :: rho, velx, vely, velz, epsilon
  REAL*8, INTENT(OUT) :: press
  REAL*8, INTENT(IN) :: Bvecx, Bvecy, Bvecz
  REAL*8, INTENT(OUT) :: w_lorentz
  REAL*8, INTENT(INOUT) :: temperature
  REAL*8, INTENT(IN) :: Y_e

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call prim2conM_hot(handle, GRHydro_reflevel, i, j, k, x, y, z, gxx,&
                     gxy, gxz, gyy, gyz, gzz, sdetg, dens, sx, sy, sz,&
                     tau, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz,&
                     epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz,&
                     temperature, Y_e)
end subroutine

subroutine Prim2ConPolyMWrapper(handle, gxx, gxy, gxz, gyy, gyz, gzz, det,&
                                dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz,&
                                rho, velx, vely, velz, epsilon, press, Bvecx,&
                                Bvecy, Bvecz, w_lorentz)

  use Con2PrimM_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: det
  REAL*8, INTENT(OUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(OUT) :: Bconsx, Bconsy, Bconsz
  REAL*8, INTENT(IN) :: rho, velx, vely, velz
  REAL*8, INTENT(OUT) :: epsilon
  REAL*8, INTENT(OUT) :: press
  REAL*8, INTENT(IN) :: Bvecx, Bvecy, Bvecz
  REAL*8, INTENT(OUT) :: w_lorentz

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call prim2conpolytypeM(handle, gxx, gxy, gxz, gyy, gyz, gzz, sdetg,&
                         dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz,&
                         rho, velx, vely, velz, epsilon, press, Bvecx,&
                         Bvecy, Bvecz, w_lorentz)
end subroutine

subroutine Con2PrimGenMeeWrapper(handle, keytemp, prec, gamma_eos, dens, sx, sy,&
                                 sz, tau, Bconsx, Bconsy, Bconsz, entropycons,&
                                 y_e, temp, rho, velx, vely, velz, epsilon,&
                                 pressure, Bvecx, Bvecy, Bvecz, Bvecsq,&
                                 w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx,&
                                 uxy, uxz, uyy, uyz, uzz, det, epsnegative,&
                                 retval)

  use Con2Prim_fortran_interfaces

  implicit none

  interface
  integer*8 function CCTK_PointerTo (var)
  implicit none
  type(*),dimension(..),TARGET :: var
  end function CCTK_PointerTo
  end interface
  interface
  integer function CCTK_Equals (arg1, arg2)
  implicit none
  integer*8 arg1
  character(*) arg2
  end function CCTK_Equals
  integer function CCTK_MyProc (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_MyProc
  integer function CCTK_nProcs (cctkGH)
  implicit none
  integer*8 cctkGH
  end function CCTK_nProcs
  integer function CCTK_IsThornActive (name)
  implicit none
  character(*) name
  end function CCTK_IsThornActive
  integer*8 function CCTK_NullPointer ()
  implicit none
  end function CCTK_NullPointer
  end interface
  interface
  INTEGER*4 function Boundary_SelectGroupForBC (GH, faces, boundary_width, table_handle, group_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) group_name
  character(*) bc_name
  end function Boundary_SelectGroupForBC
  end interface
  interface
  INTEGER*4 function Boundary_SelectVarForBC (GH, faces, boundary_width, table_handle, var_name, bc_name)
  implicit none
  integer*8 GH
  INTEGER*4 faces
  INTEGER*4 boundary_width
  INTEGER*4 table_handle
  character(*) var_name
  character(*) bc_name
  end function Boundary_SelectVarForBC
  end interface
  interface
  subroutine Con2PrimGen (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, pressure, w_lorentz, uxx, uxy, uxz, uyy, u&
  &yz, uzz, det, x, y, z, r, epsnegative, GRHydro_rho_min, pmin, epsmin, GRHydro_reflevel, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  INTEGER*4 epsnegative
  REAL*8 GRHydro_rho_min
  REAL*8 pmin
  REAL*8 epsmin
  INTEGER*4 GRHydro_reflevel
  REAL*8 retval
  end subroutine Con2PrimGen
  end interface
  interface
  subroutine Con2PrimGenM (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, y_e, temp, rho, velx, v&
  &ely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz&
  &, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenM
  end interface
  interface
  subroutine Con2PrimGenMee (handle, keytemp, prec, gamma_eos, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, tem&
  &p, rho, velx, vely, velz, epsilon, pressure, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz&
  &, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  INTEGER*4 keytemp
  REAL*8 prec
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 entropycons
  REAL*8 y_e
  REAL*8 temp
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimGenMee
  end interface
  interface
  subroutine Con2PrimPoly (handle, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, w_lorentz, uxx, uxy, uxz, uyy, uyz&
  &, uzz, det, x, y, z, r, rho_min, GRHydro_reflevel, GRHydro_C2P_failed)
  implicit none
  INTEGER*4 handle
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 r
  REAL*8 rho_min
  INTEGER*4 GRHydro_reflevel
  REAL*8 GRHydro_C2P_failed
  end subroutine Con2PrimPoly
  end interface
  interface
  subroutine Con2PrimPolyM (handle, gamma_eos, dens, sx, sy, sz, sc, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, pressu&
  &re, Bvecx, Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy, gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, det, epsnegative, retval)
  implicit none
  INTEGER*4 handle
  REAL*8 gamma_eos
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 sc
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 pressure
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 Bvecsq
  REAL*8 w_lorentz
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  INTEGER*4 epsnegative
  REAL*8 retval
  end subroutine Con2PrimPolyM
  end interface
  interface
  subroutine EOS_Omni_DPressByDEps (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdepsrho, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdepsrho(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDEps
  end interface
  interface
  subroutine EOS_Omni_DPressByDRho (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpdrhoeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpdrhoeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_DPressByDRho
  end interface
  interface
  subroutine EOS_Omni_EpsFromPress (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, xeps, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 xeps(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_EpsFromPress
  end interface
  interface
  INTEGER*4 function EOS_Omni_GetHandle (name)
  implicit none
  character(*) name
  end function EOS_Omni_GetHandle
  end interface
  interface
  subroutine EOS_Omni_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_cs2
  end interface
  interface
  subroutine EOS_Omni_dpderho_dpdrhoe (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, dpderho, dpdrhoe, keyerr, anyer&
  &r)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 dpderho(*)
  REAL*8 dpdrhoe(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_dpderho_dpdrhoe
  end interface
  interface
  subroutine EOS_Omni_press (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press
  end interface
  interface
  subroutine EOS_Omni_pressOMP (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_pressOMP
  end interface
  interface
  subroutine EOS_Omni_press_cs2 (eoskey, havetemp, rf_precision, npoints, rho, eps, temp, ye, press, cs2, keyerr, anyerr)
  implicit none
  INTEGER*4 eoskey
  INTEGER*4 havetemp
  REAL*8 rf_precision
  INTEGER*4 npoints
  REAL*8 rho(*)
  REAL*8 eps(*)
  REAL*8 temp(*)
  REAL*8 ye(*)
  REAL*8 press(*)
  REAL*8 cs2(*)
  INTEGER*4 keyerr(*)
  INTEGER*4 anyerr
  end subroutine EOS_Omni_press_cs2
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrained (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrained
  end interface
  interface
  INTEGER*4 function MoLRegisterConstrainedGroup (ConstrainedIndex)
  implicit none
  INTEGER*4 ConstrainedIndex
  end function MoLRegisterConstrainedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolved (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolved
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroup (EvolvedIndex, RHSIndex)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndex
  end function MoLRegisterEvolvedGroup
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedGroupSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedGroupSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterEvolvedSlow (EvolvedIndex, RHSIndexSlow)
  implicit none
  INTEGER*4 EvolvedIndex
  INTEGER*4 RHSIndexSlow
  end function MoLRegisterEvolvedSlow
  end interface
  interface
  INTEGER*4 function MoLRegisterSaveAndRestoreGroup (SandRIndex)
  implicit none
  INTEGER*4 SandRIndex
  end function MoLRegisterSaveAndRestoreGroup
  end interface
  interface
  subroutine Prim2ConGen (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press, &
  &w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConGen
  end interface
  interface
  subroutine Prim2ConGenM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, vel&
  &y, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConGenM
  end interface
  interface
  subroutine Prim2ConGenM_hot (handle, GRHydro_reflevel, i, j, k, x, y, z, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau&
  &, Bconsx, Bconsy, Bconsz, rho, velx, vely, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz, temperature, Y_e)
  implicit none
  INTEGER*4 handle
  INTEGER*4 GRHydro_reflevel
  INTEGER*4 i
  INTEGER*4 j
  INTEGER*4 k
  REAL*8 x
  REAL*8 y
  REAL*8 z
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  REAL*8 temperature
  REAL*8 Y_e
  end subroutine Prim2ConGenM_hot
  end interface
  interface
  subroutine Prim2ConPoly (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, rho, velx, vely, velz, epsilon, press,&
  & w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 w_lorentz
  end subroutine Prim2ConPoly
  end interface
  interface
  subroutine Prim2ConPolyM (handle, gxx, gxy, gxz, gyy, gyz, gzz, det, dens, sx, sy, sz, tau, Bconsx, Bconsy, Bconsz, rho, velx, ve&
  &ly, velz, epsilon, press, Bvecx, Bvecy, Bvecz, w_lorentz)
  implicit none
  INTEGER*4 handle
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  REAL*8 dens
  REAL*8 sx
  REAL*8 sy
  REAL*8 sz
  REAL*8 tau
  REAL*8 Bconsx
  REAL*8 Bconsy
  REAL*8 Bconsz
  REAL*8 rho
  REAL*8 velx
  REAL*8 vely
  REAL*8 velz
  REAL*8 epsilon
  REAL*8 press
  REAL*8 Bvecx
  REAL*8 Bvecy
  REAL*8 Bvecz
  REAL*8 w_lorentz
  end subroutine Prim2ConPolyM
  end interface
  interface
  subroutine SetDriftCorrectPosition (GH_Pointer, x, y, z)
  implicit none
  integer*8 GH_Pointer
  REAL*8 x
  REAL*8 y
  REAL*8 z
  end subroutine SetDriftCorrectPosition
  end interface
  interface
  subroutine SpatialDet (gxx, gxy, gxz, gyy, gyz, gzz, det)
  implicit none
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  REAL*8 det
  end subroutine SpatialDet
  end interface
  interface
  subroutine UpperMet (uxx, uxy, uxz, uyy, uyz, uzz, det, gxx, gxy, gxz, gyy, gyz, gzz)
  implicit none
  REAL*8 uxx
  REAL*8 uxy
  REAL*8 uxz
  REAL*8 uyy
  REAL*8 uyz
  REAL*8 uzz
  REAL*8 det
  REAL*8 gxx
  REAL*8 gxy
  REAL*8 gxz
  REAL*8 gyy
  REAL*8 gyz
  REAL*8 gzz
  end subroutine UpperMet
  end interface

  INTEGER*4, INTENT(IN) :: handle, keytemp
  REAL*8, INTENT(IN) :: prec, gamma_eos
  REAL*8, INTENT(INOUT) :: dens, sx, sy, sz, tau
  REAL*8, INTENT(IN) :: Bconsx, Bconsy, Bconsz
  REAL*8, INTENT(INOUT) :: entropycons, y_e, temp
  REAL*8, INTENT(INOUT) :: rho, velx, vely, velz, epsilon, pressure
  REAL*8, INTENT(OUT) :: Bvecx, Bvecy, Bvecz
  REAL*8, INTENT(OUT) :: Bvecsq
  REAL*8, INTENT(INOUT) :: w_lorentz
  REAL*8, INTENT(IN) :: gxx, gxy, gxz, gyy, gyz, gzz
  REAL*8, INTENT(IN) :: uxx, uxy, uxz, uyy, uyz, uzz
  REAL*8, INTENT(IN) :: det
  INTEGER*4, INTENT(OUT) :: epsnegative
  REAL*8, INTENT(OUT) :: retval

  REAL*8 :: sdetg

  sdetg = sqrt(det)

  call GRHydro_Con2PrimM_ptee(handle, keytemp, prec, gamma_eos, dens, sx, sy, sz,&
                              tau, Bconsx, Bconsy, Bconsz, entropycons, y_e, temp,&
                              rho, velx, vely, velz, epsilon, pressure, Bvecx,&
                              Bvecy, Bvecz, Bvecsq, w_lorentz, gxx, gxy, gxz, gyy,&
                              gyz, gzz, uxx, uxy, uxz, uyy, uyz, uzz, sdetg,&
                              epsnegative, retval)
end subroutine
