























































































































 


































































































































































 








































































































































































































 




























































 










 








































































































































































































































 










                                
                                

                                
                                

                                
                                

                                


























































































subroutine EOS_Omni_EOS_short(eoskey,keytemp,rf_precision,npoints,&
     rho,eps,temp,ye,press,entropy,cs2,dedt,dpderho,dpdrhoe,munu,&
     keyerr,anyerr)

  use EOS_Omni_Module
  implicit none
  REAL*8 barotropiceos_gammath
  integer, parameter :: cctki_use_barotropiceos_gammath = kind(barotropiceos_gammath)
  REAL*8 gl_gamma
  integer, parameter :: cctki_use_gl_gamma = kind(gl_gamma)
  REAL*8 gl_k
  integer, parameter :: cctki_use_gl_k = kind(gl_k)
  REAL*8 hybrid_gamma (10)
  integer, parameter :: cctki_use_hybrid_gamma = kind(hybrid_gamma)
  REAL*8 hybrid_gamma1
  integer, parameter :: cctki_use_hybrid_gamma1 = kind(hybrid_gamma1)
  REAL*8 hybrid_gamma2
  integer, parameter :: cctki_use_hybrid_gamma2 = kind(hybrid_gamma2)
  REAL*8 hybrid_gamma_th
  integer, parameter :: cctki_use_hybrid_gamma_th = kind(hybrid_gamma_th)
  REAL*8 hybrid_k0
  integer, parameter :: cctki_use_hybrid_k0 = kind(hybrid_k0)
  REAL*8 hybrid_k1
  integer, parameter :: cctki_use_hybrid_k1 = kind(hybrid_k1)
  REAL*8 hybrid_rho (9)
  integer, parameter :: cctki_use_hybrid_rho = kind(hybrid_rho)
  REAL*8 hybrid_rho_nuc
  integer, parameter :: cctki_use_hybrid_rho_nuc = kind(hybrid_rho_nuc)
  REAL*8 poly_gamma
  integer, parameter :: cctki_use_poly_gamma = kind(poly_gamma)
  REAL*8 poly_gamma_initial
  integer, parameter :: cctki_use_poly_gamma_initial = kind(poly_gamma_initial)
  REAL*8 poly_k
  integer, parameter :: cctki_use_poly_k = kind(poly_k)
  integer*8 barotropiceos_table_name
  integer, parameter :: cctki_use_barotropiceos_table_name = kind(barotropiceos_table_name)
  integer*8 coldeos_table_name
  integer, parameter :: cctki_use_coldeos_table_name = kind(coldeos_table_name)
  integer*8 dump_nuceos_table_name
  integer, parameter :: cctki_use_dump_nuceos_table_name = kind(dump_nuceos_table_name)
  integer*8 nuceos_table_name
  integer, parameter :: cctki_use_nuceos_table_name = kind(nuceos_table_name)
  INTEGER*4 barotropiceos_read_table
  integer, parameter :: cctki_use_barotropiceos_read_table = kind(barotropiceos_read_table)
  INTEGER*4 barotropiceos_use_thermal_gamma_law
  integer, parameter :: cctki_use_barotropiceos_use_thermal_gamma_law = kind(barotropiceos_use_thermal_gamma_law)
  INTEGER*4 coldeos_read_table
  integer, parameter :: cctki_use_coldeos_read_table = kind(coldeos_read_table)
  INTEGER*4 coldeos_use_thermal_gamma_law
  integer, parameter :: cctki_use_coldeos_use_thermal_gamma_law = kind(coldeos_use_thermal_gamma_law)
  INTEGER*4 do_energy_shift
  integer, parameter :: cctki_use_do_energy_shift = kind(do_energy_shift)
  INTEGER*4 dump_nuceos_table
  integer, parameter :: cctki_use_dump_nuceos_table = kind(dump_nuceos_table)
  INTEGER*4 n_pieces
  integer, parameter :: cctki_use_n_pieces = kind(n_pieces)
  INTEGER*4 nuceos_read_table
  integer, parameter :: cctki_use_nuceos_read_table = kind(nuceos_read_table)
  INTEGER*4 read_table_on_single_process
  integer, parameter :: cctki_use_read_table_on_single_process = kind(read_table_on_single_process)
  INTEGER*4 reader_process
  integer, parameter :: cctki_use_reader_process = kind(reader_process)
  COMMON /EOS_Omnirest/barotropiceos_gammath, gl_gamma, gl_k, hybrid_gamma, hybrid_gamma1, hybrid_gamma2, hybrid_gamma_th, hybrid_k&
  &0, hybrid_k1, hybrid_rho, hybrid_rho_nuc, poly_gamma, poly_gamma_initial, poly_k, barotropiceos_table_name, coldeos_table_name, &
  &dump_nuceos_table_name, nuceos_table_name, barotropiceos_read_table, barotropiceos_use_thermal_gamma_law, coldeos_read_table, co&
  &ldeos_use_thermal_gamma_law, do_energy_shift, dump_nuceos_table, n_pieces, nuceos_read_table, read_table_on_single_process, read&
  &er_process
  REAL*8 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  REAL*8 CCTKH19
  integer, parameter :: cctki_use_CCTKH19 = kind(CCTKH19)
  REAL*8 CCTKH29
  integer, parameter :: cctki_use_CCTKH29 = kind(CCTKH29)
  REAL*8 CCTKH31
  integer, parameter :: cctki_use_CCTKH31 = kind(CCTKH31)
  REAL*8 CCTKH33
  integer, parameter :: cctki_use_CCTKH33 = kind(CCTKH33)
  REAL*8 CCTKH35
  integer, parameter :: cctki_use_CCTKH35 = kind(CCTKH35)
  REAL*8 CCTKH37
  integer, parameter :: cctki_use_CCTKH37 = kind(CCTKH37)
  REAL*8 CCTKH39
  integer, parameter :: cctki_use_CCTKH39 = kind(CCTKH39)
  REAL*8 CCTKH41
  integer, parameter :: cctki_use_CCTKH41 = kind(CCTKH41)
  REAL*8 CCTKH43
  integer, parameter :: cctki_use_CCTKH43 = kind(CCTKH43)
  REAL*8 CCTKH45
  integer, parameter :: cctki_use_CCTKH45 = kind(CCTKH45)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  integer*8 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  integer*8 CCTKH9
  integer, parameter :: cctki_use_CCTKH9 = kind(CCTKH9)
  integer*8 CCTKH10
  integer, parameter :: cctki_use_CCTKH10 = kind(CCTKH10)
  integer*8 CCTKH11
  integer, parameter :: cctki_use_CCTKH11 = kind(CCTKH11)
  integer*8 CCTKH15
  integer, parameter :: cctki_use_CCTKH15 = kind(CCTKH15)
  integer*8 out_dir
  integer, parameter :: cctki_use_out_dir = kind(out_dir)
  integer*8 CCTKH21
  integer, parameter :: cctki_use_CCTKH21 = kind(CCTKH21)
  integer*8 CCTKH22
  integer, parameter :: cctki_use_CCTKH22 = kind(CCTKH22)
  integer*8 CCTKH23
  integer, parameter :: cctki_use_CCTKH23 = kind(CCTKH23)
  integer*8 CCTKH25
  integer, parameter :: cctki_use_CCTKH25 = kind(CCTKH25)
  integer*8 CCTKH47
  integer, parameter :: cctki_use_CCTKH47 = kind(CCTKH47)
  integer*8 CCTKH49
  integer, parameter :: cctki_use_CCTKH49 = kind(CCTKH49)
  integer*8 CCTKH51
  integer, parameter :: cctki_use_CCTKH51 = kind(CCTKH51)
  integer*8 CCTKH53
  integer, parameter :: cctki_use_CCTKH53 = kind(CCTKH53)
  integer*8 CCTKH54
  integer, parameter :: cctki_use_CCTKH54 = kind(CCTKH54)
  integer*8 CCTKH57
  integer, parameter :: cctki_use_CCTKH57 = kind(CCTKH57)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  INTEGER*4 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  INTEGER*4 CCTKH12
  integer, parameter :: cctki_use_CCTKH12 = kind(CCTKH12)
  INTEGER*4 CCTKH13
  integer, parameter :: cctki_use_CCTKH13 = kind(CCTKH13)
  INTEGER*4 CCTKH14
  integer, parameter :: cctki_use_CCTKH14 = kind(CCTKH14)
  INTEGER*4 CCTKH16
  integer, parameter :: cctki_use_CCTKH16 = kind(CCTKH16)
  INTEGER*4 CCTKH17
  integer, parameter :: cctki_use_CCTKH17 = kind(CCTKH17)
  INTEGER*4 CCTKH18
  integer, parameter :: cctki_use_CCTKH18 = kind(CCTKH18)
  INTEGER*4 CCTKH20
  integer, parameter :: cctki_use_CCTKH20 = kind(CCTKH20)
  INTEGER*4 CCTKH24
  integer, parameter :: cctki_use_CCTKH24 = kind(CCTKH24)
  INTEGER*4 CCTKH26
  integer, parameter :: cctki_use_CCTKH26 = kind(CCTKH26)
  INTEGER*4 CCTKH27
  integer, parameter :: cctki_use_CCTKH27 = kind(CCTKH27)
  INTEGER*4 CCTKH28
  integer, parameter :: cctki_use_CCTKH28 = kind(CCTKH28)
  INTEGER*4 CCTKH30
  integer, parameter :: cctki_use_CCTKH30 = kind(CCTKH30)
  INTEGER*4 CCTKH32
  integer, parameter :: cctki_use_CCTKH32 = kind(CCTKH32)
  INTEGER*4 CCTKH34
  integer, parameter :: cctki_use_CCTKH34 = kind(CCTKH34)
  INTEGER*4 CCTKH36
  integer, parameter :: cctki_use_CCTKH36 = kind(CCTKH36)
  INTEGER*4 CCTKH38
  integer, parameter :: cctki_use_CCTKH38 = kind(CCTKH38)
  INTEGER*4 CCTKH40
  integer, parameter :: cctki_use_CCTKH40 = kind(CCTKH40)
  INTEGER*4 CCTKH42
  integer, parameter :: cctki_use_CCTKH42 = kind(CCTKH42)
  INTEGER*4 CCTKH44
  integer, parameter :: cctki_use_CCTKH44 = kind(CCTKH44)
  INTEGER*4 CCTKH46
  integer, parameter :: cctki_use_CCTKH46 = kind(CCTKH46)
  INTEGER*4 CCTKH48
  integer, parameter :: cctki_use_CCTKH48 = kind(CCTKH48)
  INTEGER*4 CCTKH50
  integer, parameter :: cctki_use_CCTKH50 = kind(CCTKH50)
  INTEGER*4 CCTKH52
  integer, parameter :: cctki_use_CCTKH52 = kind(CCTKH52)
  INTEGER*4 CCTKH55
  integer, parameter :: cctki_use_CCTKH55 = kind(CCTKH55)
  INTEGER*4 CCTKH56
  integer, parameter :: cctki_use_CCTKH56 = kind(CCTKH56)
  COMMON /IOrest/CCTKH5, CCTKH19, CCTKH29, CCTKH31, CCTKH33, CCTKH35, CCTKH37, CCTKH39, CCTKH41, CCTKH43, CCTKH45, CCTKH2, CCTKH3, &
  &CCTKH6, CCTKH9, CCTKH10, CCTKH11, CCTKH15, out_dir, CCTKH21, CCTKH22, CCTKH23, CCTKH25, CCTKH47, CCTKH49, CCTKH51, CCTKH53, CCTK&
  &H54, CCTKH57, CCTKH0, CCTKH1, CCTKH4, CCTKH7, CCTKH8, CCTKH12, CCTKH13, CCTKH14, CCTKH16, CCTKH17, CCTKH18, CCTKH20, CCTKH24, CC&
  &TKH26, CCTKH27, CCTKH28, CCTKH30, CCTKH32, CCTKH34, CCTKH36, CCTKH38, CCTKH40, CCTKH42, CCTKH44, CCTKH46, CCTKH48, CCTKH50, CCTK&
  &H52, CCTKH55, CCTKH56

  INTEGER*4, intent(in)     :: eoskey,keytemp,npoints
  INTEGER*4, intent(out)    :: keyerr(npoints)
  INTEGER*4, intent(out)    :: anyerr
  REAL*8, intent(in)    :: rf_precision
  REAL*8, intent(in)    :: rho(npoints),ye(npoints)
  REAL*8, intent(inout) :: eps(npoints), temp(npoints)
  REAL*8, intent(out)   :: press(npoints)
  REAL*8, intent(inout) :: entropy(npoints)
  REAL*8, intent(out)   :: cs2(npoints)
  REAL*8, intent(out)   :: dedt(npoints)
  REAL*8, intent(out)   :: dpderho(npoints)
  REAL*8, intent(out)   :: dpdrhoe(npoints)
  REAL*8, intent(out)   :: munu(npoints)

  
  character(256)   :: warnstring

  if(eoskey.ne.4) then
     
     
     !$OMP CRITICAL
     write(warnstring,"(A8,i5)") "eoskey: ", eoskey
     call CCTK_Warn(1,43,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
     call CCTK_Error(44,"EOS_Omni_MultiVarCalls.F90","EOS_Omni","EOS_Omni_EOS_short currently does not work for this eoskey")
     !$OMP END CRITICAL
     STOP
  endif

  anyerr    = 0
  keyerr(:) = 0

  if(keytemp.eq.1) then
     call nuc_eos_m_kt1_short(npoints,rho,temp,ye,eps,press,&
          entropy,cs2,dedt,dpderho,dpdrhoe,munu,keyerr,anyerr)
  else if(keytemp.eq.0) then
     call nuc_eos_m_kt0_short(npoints,rho,temp,ye,eps,press,&
          entropy,cs2,dedt,dpderho,dpdrhoe,munu,rf_precision,&
          keyerr,anyerr)
  else if (keytemp.eq.2) then
     call nuc_eos_m_kt2_short(npoints,rho,temp,ye,eps,press,&
          entropy,cs2,dedt,dpderho,dpdrhoe,munu,rf_precision,&
          keyerr,anyerr)
  else
     !$OMP CRITICAL
     call CCTK_Error(65,"EOS_Omni_MultiVarCalls.F90","EOS_Omni","This keytemp is not supported")
     !$OMP END CRITICAL
     STOP
  endif

end subroutine EOS_Omni_EOS_short

subroutine EOS_Omni_EOS_full(eoskey,keytemp,rf_precision,npoints,&
     rho,eps,temp,ye,press,entropy,cs2,dedt,dpderho,dpdrhoe,&
     xa,xh,xn,xp,abar,zbar,mue,mun,mup,muhat,keyerr,anyerr)

  use EOS_Omni_Module
  implicit none
  REAL*8 barotropiceos_gammath
  integer, parameter :: cctki_use_barotropiceos_gammath = kind(barotropiceos_gammath)
  REAL*8 gl_gamma
  integer, parameter :: cctki_use_gl_gamma = kind(gl_gamma)
  REAL*8 gl_k
  integer, parameter :: cctki_use_gl_k = kind(gl_k)
  REAL*8 hybrid_gamma (10)
  integer, parameter :: cctki_use_hybrid_gamma = kind(hybrid_gamma)
  REAL*8 hybrid_gamma1
  integer, parameter :: cctki_use_hybrid_gamma1 = kind(hybrid_gamma1)
  REAL*8 hybrid_gamma2
  integer, parameter :: cctki_use_hybrid_gamma2 = kind(hybrid_gamma2)
  REAL*8 hybrid_gamma_th
  integer, parameter :: cctki_use_hybrid_gamma_th = kind(hybrid_gamma_th)
  REAL*8 hybrid_k0
  integer, parameter :: cctki_use_hybrid_k0 = kind(hybrid_k0)
  REAL*8 hybrid_k1
  integer, parameter :: cctki_use_hybrid_k1 = kind(hybrid_k1)
  REAL*8 hybrid_rho (9)
  integer, parameter :: cctki_use_hybrid_rho = kind(hybrid_rho)
  REAL*8 hybrid_rho_nuc
  integer, parameter :: cctki_use_hybrid_rho_nuc = kind(hybrid_rho_nuc)
  REAL*8 poly_gamma
  integer, parameter :: cctki_use_poly_gamma = kind(poly_gamma)
  REAL*8 poly_gamma_initial
  integer, parameter :: cctki_use_poly_gamma_initial = kind(poly_gamma_initial)
  REAL*8 poly_k
  integer, parameter :: cctki_use_poly_k = kind(poly_k)
  integer*8 barotropiceos_table_name
  integer, parameter :: cctki_use_barotropiceos_table_name = kind(barotropiceos_table_name)
  integer*8 coldeos_table_name
  integer, parameter :: cctki_use_coldeos_table_name = kind(coldeos_table_name)
  integer*8 dump_nuceos_table_name
  integer, parameter :: cctki_use_dump_nuceos_table_name = kind(dump_nuceos_table_name)
  integer*8 nuceos_table_name
  integer, parameter :: cctki_use_nuceos_table_name = kind(nuceos_table_name)
  INTEGER*4 barotropiceos_read_table
  integer, parameter :: cctki_use_barotropiceos_read_table = kind(barotropiceos_read_table)
  INTEGER*4 barotropiceos_use_thermal_gamma_law
  integer, parameter :: cctki_use_barotropiceos_use_thermal_gamma_law = kind(barotropiceos_use_thermal_gamma_law)
  INTEGER*4 coldeos_read_table
  integer, parameter :: cctki_use_coldeos_read_table = kind(coldeos_read_table)
  INTEGER*4 coldeos_use_thermal_gamma_law
  integer, parameter :: cctki_use_coldeos_use_thermal_gamma_law = kind(coldeos_use_thermal_gamma_law)
  INTEGER*4 do_energy_shift
  integer, parameter :: cctki_use_do_energy_shift = kind(do_energy_shift)
  INTEGER*4 dump_nuceos_table
  integer, parameter :: cctki_use_dump_nuceos_table = kind(dump_nuceos_table)
  INTEGER*4 n_pieces
  integer, parameter :: cctki_use_n_pieces = kind(n_pieces)
  INTEGER*4 nuceos_read_table
  integer, parameter :: cctki_use_nuceos_read_table = kind(nuceos_read_table)
  INTEGER*4 read_table_on_single_process
  integer, parameter :: cctki_use_read_table_on_single_process = kind(read_table_on_single_process)
  INTEGER*4 reader_process
  integer, parameter :: cctki_use_reader_process = kind(reader_process)
  COMMON /EOS_Omnirest/barotropiceos_gammath, gl_gamma, gl_k, hybrid_gamma, hybrid_gamma1, hybrid_gamma2, hybrid_gamma_th, hybrid_k&
  &0, hybrid_k1, hybrid_rho, hybrid_rho_nuc, poly_gamma, poly_gamma_initial, poly_k, barotropiceos_table_name, coldeos_table_name, &
  &dump_nuceos_table_name, nuceos_table_name, barotropiceos_read_table, barotropiceos_use_thermal_gamma_law, coldeos_read_table, co&
  &ldeos_use_thermal_gamma_law, do_energy_shift, dump_nuceos_table, n_pieces, nuceos_read_table, read_table_on_single_process, read&
  &er_process
  REAL*8 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  REAL*8 CCTKH19
  integer, parameter :: cctki_use_CCTKH19 = kind(CCTKH19)
  REAL*8 CCTKH29
  integer, parameter :: cctki_use_CCTKH29 = kind(CCTKH29)
  REAL*8 CCTKH31
  integer, parameter :: cctki_use_CCTKH31 = kind(CCTKH31)
  REAL*8 CCTKH33
  integer, parameter :: cctki_use_CCTKH33 = kind(CCTKH33)
  REAL*8 CCTKH35
  integer, parameter :: cctki_use_CCTKH35 = kind(CCTKH35)
  REAL*8 CCTKH37
  integer, parameter :: cctki_use_CCTKH37 = kind(CCTKH37)
  REAL*8 CCTKH39
  integer, parameter :: cctki_use_CCTKH39 = kind(CCTKH39)
  REAL*8 CCTKH41
  integer, parameter :: cctki_use_CCTKH41 = kind(CCTKH41)
  REAL*8 CCTKH43
  integer, parameter :: cctki_use_CCTKH43 = kind(CCTKH43)
  REAL*8 CCTKH45
  integer, parameter :: cctki_use_CCTKH45 = kind(CCTKH45)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  integer*8 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  integer*8 CCTKH9
  integer, parameter :: cctki_use_CCTKH9 = kind(CCTKH9)
  integer*8 CCTKH10
  integer, parameter :: cctki_use_CCTKH10 = kind(CCTKH10)
  integer*8 CCTKH11
  integer, parameter :: cctki_use_CCTKH11 = kind(CCTKH11)
  integer*8 CCTKH15
  integer, parameter :: cctki_use_CCTKH15 = kind(CCTKH15)
  integer*8 out_dir
  integer, parameter :: cctki_use_out_dir = kind(out_dir)
  integer*8 CCTKH21
  integer, parameter :: cctki_use_CCTKH21 = kind(CCTKH21)
  integer*8 CCTKH22
  integer, parameter :: cctki_use_CCTKH22 = kind(CCTKH22)
  integer*8 CCTKH23
  integer, parameter :: cctki_use_CCTKH23 = kind(CCTKH23)
  integer*8 CCTKH25
  integer, parameter :: cctki_use_CCTKH25 = kind(CCTKH25)
  integer*8 CCTKH47
  integer, parameter :: cctki_use_CCTKH47 = kind(CCTKH47)
  integer*8 CCTKH49
  integer, parameter :: cctki_use_CCTKH49 = kind(CCTKH49)
  integer*8 CCTKH51
  integer, parameter :: cctki_use_CCTKH51 = kind(CCTKH51)
  integer*8 CCTKH53
  integer, parameter :: cctki_use_CCTKH53 = kind(CCTKH53)
  integer*8 CCTKH54
  integer, parameter :: cctki_use_CCTKH54 = kind(CCTKH54)
  integer*8 CCTKH57
  integer, parameter :: cctki_use_CCTKH57 = kind(CCTKH57)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  INTEGER*4 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  INTEGER*4 CCTKH12
  integer, parameter :: cctki_use_CCTKH12 = kind(CCTKH12)
  INTEGER*4 CCTKH13
  integer, parameter :: cctki_use_CCTKH13 = kind(CCTKH13)
  INTEGER*4 CCTKH14
  integer, parameter :: cctki_use_CCTKH14 = kind(CCTKH14)
  INTEGER*4 CCTKH16
  integer, parameter :: cctki_use_CCTKH16 = kind(CCTKH16)
  INTEGER*4 CCTKH17
  integer, parameter :: cctki_use_CCTKH17 = kind(CCTKH17)
  INTEGER*4 CCTKH18
  integer, parameter :: cctki_use_CCTKH18 = kind(CCTKH18)
  INTEGER*4 CCTKH20
  integer, parameter :: cctki_use_CCTKH20 = kind(CCTKH20)
  INTEGER*4 CCTKH24
  integer, parameter :: cctki_use_CCTKH24 = kind(CCTKH24)
  INTEGER*4 CCTKH26
  integer, parameter :: cctki_use_CCTKH26 = kind(CCTKH26)
  INTEGER*4 CCTKH27
  integer, parameter :: cctki_use_CCTKH27 = kind(CCTKH27)
  INTEGER*4 CCTKH28
  integer, parameter :: cctki_use_CCTKH28 = kind(CCTKH28)
  INTEGER*4 CCTKH30
  integer, parameter :: cctki_use_CCTKH30 = kind(CCTKH30)
  INTEGER*4 CCTKH32
  integer, parameter :: cctki_use_CCTKH32 = kind(CCTKH32)
  INTEGER*4 CCTKH34
  integer, parameter :: cctki_use_CCTKH34 = kind(CCTKH34)
  INTEGER*4 CCTKH36
  integer, parameter :: cctki_use_CCTKH36 = kind(CCTKH36)
  INTEGER*4 CCTKH38
  integer, parameter :: cctki_use_CCTKH38 = kind(CCTKH38)
  INTEGER*4 CCTKH40
  integer, parameter :: cctki_use_CCTKH40 = kind(CCTKH40)
  INTEGER*4 CCTKH42
  integer, parameter :: cctki_use_CCTKH42 = kind(CCTKH42)
  INTEGER*4 CCTKH44
  integer, parameter :: cctki_use_CCTKH44 = kind(CCTKH44)
  INTEGER*4 CCTKH46
  integer, parameter :: cctki_use_CCTKH46 = kind(CCTKH46)
  INTEGER*4 CCTKH48
  integer, parameter :: cctki_use_CCTKH48 = kind(CCTKH48)
  INTEGER*4 CCTKH50
  integer, parameter :: cctki_use_CCTKH50 = kind(CCTKH50)
  INTEGER*4 CCTKH52
  integer, parameter :: cctki_use_CCTKH52 = kind(CCTKH52)
  INTEGER*4 CCTKH55
  integer, parameter :: cctki_use_CCTKH55 = kind(CCTKH55)
  INTEGER*4 CCTKH56
  integer, parameter :: cctki_use_CCTKH56 = kind(CCTKH56)
  COMMON /IOrest/CCTKH5, CCTKH19, CCTKH29, CCTKH31, CCTKH33, CCTKH35, CCTKH37, CCTKH39, CCTKH41, CCTKH43, CCTKH45, CCTKH2, CCTKH3, &
  &CCTKH6, CCTKH9, CCTKH10, CCTKH11, CCTKH15, out_dir, CCTKH21, CCTKH22, CCTKH23, CCTKH25, CCTKH47, CCTKH49, CCTKH51, CCTKH53, CCTK&
  &H54, CCTKH57, CCTKH0, CCTKH1, CCTKH4, CCTKH7, CCTKH8, CCTKH12, CCTKH13, CCTKH14, CCTKH16, CCTKH17, CCTKH18, CCTKH20, CCTKH24, CC&
  &TKH26, CCTKH27, CCTKH28, CCTKH30, CCTKH32, CCTKH34, CCTKH36, CCTKH38, CCTKH40, CCTKH42, CCTKH44, CCTKH46, CCTKH48, CCTKH50, CCTK&
  &H52, CCTKH55, CCTKH56

  INTEGER*4, intent(in)     :: eoskey,keytemp,npoints
  INTEGER*4, intent(out)    :: keyerr(npoints)
  INTEGER*4, intent(out)    :: anyerr
  REAL*8, intent(in)    :: rf_precision
  REAL*8, intent(in)    :: rho(npoints),ye(npoints)
  REAL*8, intent(inout) :: eps(npoints), temp(npoints)
  REAL*8, intent(out)   :: press(npoints)
  REAL*8, intent(inout) :: entropy(npoints)
  REAL*8, intent(out)   :: cs2(npoints)
  REAL*8, intent(out)   :: dedt(npoints)
  REAL*8, intent(out)   :: dpderho(npoints)
  REAL*8, intent(out)   :: dpdrhoe(npoints)
  REAL*8, intent(out)   :: xa(npoints)
  REAL*8, intent(out)   :: xh(npoints)
  REAL*8, intent(out)   :: xn(npoints)
  REAL*8, intent(out)   :: xp(npoints)
  REAL*8, intent(out)   :: abar(npoints)
  REAL*8, intent(out)   :: zbar(npoints)
  REAL*8, intent(out)   :: mue(npoints)
  REAL*8, intent(out)   :: mun(npoints)
  REAL*8, intent(out)   :: mup(npoints)
  REAL*8, intent(out)   :: muhat(npoints)

  
  character(256)   :: warnstring

  if(eoskey.ne.4) then
     !$OMP CRITICAL
     write(warnstring,"(A8,i5)") "eoskey: ", eoskey
     call CCTK_Warn(1,109,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
     call CCTK_Error(110,"EOS_Omni_MultiVarCalls.F90","EOS_Omni","EOS_Omni_EOS_full currently does not work for this eoskey")
     !$OMP END CRITICAL
     STOP
  endif

  anyerr    = 0
  keyerr(:) = 0

  if(keytemp.eq.1) then
     call nuc_eos_m_kt1_full(npoints,rho,temp,ye,eps,press,&
          entropy,cs2,dedt,dpderho,dpdrhoe,xa,xh,xn,xp,abar,zbar,&
          mue,mun,mup,muhat,keyerr,anyerr)
  else if(keytemp.eq.0) then
     call nuc_eos_m_kt0_full(npoints,rho,temp,ye,eps,press,&
          entropy,cs2,dedt,dpderho,dpdrhoe,xa,xh,xn,xp,abar,zbar,&
          mue,mun,mup,muhat,rf_precision,&
          keyerr,anyerr)
  else
     !$OMP CRITICAL
     call CCTK_Error(129,"EOS_Omni_MultiVarCalls.F90","EOS_Omni","This keytemp is not supported")
     !$OMP END CRITICAL
     STOP
  endif

end subroutine EOS_Omni_EOS_full


subroutine EOS_Omni_EOS_dpderho_dpdrhoe(eoskey,keytemp,rf_precision,npoints,&
     rho,eps,temp,ye,dpderho,dpdrhoe,keyerr,anyerr)

  use EOS_Omni_Module
  implicit none
  REAL*8 barotropiceos_gammath
  integer, parameter :: cctki_use_barotropiceos_gammath = kind(barotropiceos_gammath)
  REAL*8 gl_gamma
  integer, parameter :: cctki_use_gl_gamma = kind(gl_gamma)
  REAL*8 gl_k
  integer, parameter :: cctki_use_gl_k = kind(gl_k)
  REAL*8 hybrid_gamma (10)
  integer, parameter :: cctki_use_hybrid_gamma = kind(hybrid_gamma)
  REAL*8 hybrid_gamma1
  integer, parameter :: cctki_use_hybrid_gamma1 = kind(hybrid_gamma1)
  REAL*8 hybrid_gamma2
  integer, parameter :: cctki_use_hybrid_gamma2 = kind(hybrid_gamma2)
  REAL*8 hybrid_gamma_th
  integer, parameter :: cctki_use_hybrid_gamma_th = kind(hybrid_gamma_th)
  REAL*8 hybrid_k0
  integer, parameter :: cctki_use_hybrid_k0 = kind(hybrid_k0)
  REAL*8 hybrid_k1
  integer, parameter :: cctki_use_hybrid_k1 = kind(hybrid_k1)
  REAL*8 hybrid_rho (9)
  integer, parameter :: cctki_use_hybrid_rho = kind(hybrid_rho)
  REAL*8 hybrid_rho_nuc
  integer, parameter :: cctki_use_hybrid_rho_nuc = kind(hybrid_rho_nuc)
  REAL*8 poly_gamma
  integer, parameter :: cctki_use_poly_gamma = kind(poly_gamma)
  REAL*8 poly_gamma_initial
  integer, parameter :: cctki_use_poly_gamma_initial = kind(poly_gamma_initial)
  REAL*8 poly_k
  integer, parameter :: cctki_use_poly_k = kind(poly_k)
  integer*8 barotropiceos_table_name
  integer, parameter :: cctki_use_barotropiceos_table_name = kind(barotropiceos_table_name)
  integer*8 coldeos_table_name
  integer, parameter :: cctki_use_coldeos_table_name = kind(coldeos_table_name)
  integer*8 dump_nuceos_table_name
  integer, parameter :: cctki_use_dump_nuceos_table_name = kind(dump_nuceos_table_name)
  integer*8 nuceos_table_name
  integer, parameter :: cctki_use_nuceos_table_name = kind(nuceos_table_name)
  INTEGER*4 barotropiceos_read_table
  integer, parameter :: cctki_use_barotropiceos_read_table = kind(barotropiceos_read_table)
  INTEGER*4 barotropiceos_use_thermal_gamma_law
  integer, parameter :: cctki_use_barotropiceos_use_thermal_gamma_law = kind(barotropiceos_use_thermal_gamma_law)
  INTEGER*4 coldeos_read_table
  integer, parameter :: cctki_use_coldeos_read_table = kind(coldeos_read_table)
  INTEGER*4 coldeos_use_thermal_gamma_law
  integer, parameter :: cctki_use_coldeos_use_thermal_gamma_law = kind(coldeos_use_thermal_gamma_law)
  INTEGER*4 do_energy_shift
  integer, parameter :: cctki_use_do_energy_shift = kind(do_energy_shift)
  INTEGER*4 dump_nuceos_table
  integer, parameter :: cctki_use_dump_nuceos_table = kind(dump_nuceos_table)
  INTEGER*4 n_pieces
  integer, parameter :: cctki_use_n_pieces = kind(n_pieces)
  INTEGER*4 nuceos_read_table
  integer, parameter :: cctki_use_nuceos_read_table = kind(nuceos_read_table)
  INTEGER*4 read_table_on_single_process
  integer, parameter :: cctki_use_read_table_on_single_process = kind(read_table_on_single_process)
  INTEGER*4 reader_process
  integer, parameter :: cctki_use_reader_process = kind(reader_process)
  COMMON /EOS_Omnirest/barotropiceos_gammath, gl_gamma, gl_k, hybrid_gamma, hybrid_gamma1, hybrid_gamma2, hybrid_gamma_th, hybrid_k&
  &0, hybrid_k1, hybrid_rho, hybrid_rho_nuc, poly_gamma, poly_gamma_initial, poly_k, barotropiceos_table_name, coldeos_table_name, &
  &dump_nuceos_table_name, nuceos_table_name, barotropiceos_read_table, barotropiceos_use_thermal_gamma_law, coldeos_read_table, co&
  &ldeos_use_thermal_gamma_law, do_energy_shift, dump_nuceos_table, n_pieces, nuceos_read_table, read_table_on_single_process, read&
  &er_process
  REAL*8 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  REAL*8 CCTKH19
  integer, parameter :: cctki_use_CCTKH19 = kind(CCTKH19)
  REAL*8 CCTKH29
  integer, parameter :: cctki_use_CCTKH29 = kind(CCTKH29)
  REAL*8 CCTKH31
  integer, parameter :: cctki_use_CCTKH31 = kind(CCTKH31)
  REAL*8 CCTKH33
  integer, parameter :: cctki_use_CCTKH33 = kind(CCTKH33)
  REAL*8 CCTKH35
  integer, parameter :: cctki_use_CCTKH35 = kind(CCTKH35)
  REAL*8 CCTKH37
  integer, parameter :: cctki_use_CCTKH37 = kind(CCTKH37)
  REAL*8 CCTKH39
  integer, parameter :: cctki_use_CCTKH39 = kind(CCTKH39)
  REAL*8 CCTKH41
  integer, parameter :: cctki_use_CCTKH41 = kind(CCTKH41)
  REAL*8 CCTKH43
  integer, parameter :: cctki_use_CCTKH43 = kind(CCTKH43)
  REAL*8 CCTKH45
  integer, parameter :: cctki_use_CCTKH45 = kind(CCTKH45)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  integer*8 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  integer*8 CCTKH9
  integer, parameter :: cctki_use_CCTKH9 = kind(CCTKH9)
  integer*8 CCTKH10
  integer, parameter :: cctki_use_CCTKH10 = kind(CCTKH10)
  integer*8 CCTKH11
  integer, parameter :: cctki_use_CCTKH11 = kind(CCTKH11)
  integer*8 CCTKH15
  integer, parameter :: cctki_use_CCTKH15 = kind(CCTKH15)
  integer*8 out_dir
  integer, parameter :: cctki_use_out_dir = kind(out_dir)
  integer*8 CCTKH21
  integer, parameter :: cctki_use_CCTKH21 = kind(CCTKH21)
  integer*8 CCTKH22
  integer, parameter :: cctki_use_CCTKH22 = kind(CCTKH22)
  integer*8 CCTKH23
  integer, parameter :: cctki_use_CCTKH23 = kind(CCTKH23)
  integer*8 CCTKH25
  integer, parameter :: cctki_use_CCTKH25 = kind(CCTKH25)
  integer*8 CCTKH47
  integer, parameter :: cctki_use_CCTKH47 = kind(CCTKH47)
  integer*8 CCTKH49
  integer, parameter :: cctki_use_CCTKH49 = kind(CCTKH49)
  integer*8 CCTKH51
  integer, parameter :: cctki_use_CCTKH51 = kind(CCTKH51)
  integer*8 CCTKH53
  integer, parameter :: cctki_use_CCTKH53 = kind(CCTKH53)
  integer*8 CCTKH54
  integer, parameter :: cctki_use_CCTKH54 = kind(CCTKH54)
  integer*8 CCTKH57
  integer, parameter :: cctki_use_CCTKH57 = kind(CCTKH57)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  INTEGER*4 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  INTEGER*4 CCTKH12
  integer, parameter :: cctki_use_CCTKH12 = kind(CCTKH12)
  INTEGER*4 CCTKH13
  integer, parameter :: cctki_use_CCTKH13 = kind(CCTKH13)
  INTEGER*4 CCTKH14
  integer, parameter :: cctki_use_CCTKH14 = kind(CCTKH14)
  INTEGER*4 CCTKH16
  integer, parameter :: cctki_use_CCTKH16 = kind(CCTKH16)
  INTEGER*4 CCTKH17
  integer, parameter :: cctki_use_CCTKH17 = kind(CCTKH17)
  INTEGER*4 CCTKH18
  integer, parameter :: cctki_use_CCTKH18 = kind(CCTKH18)
  INTEGER*4 CCTKH20
  integer, parameter :: cctki_use_CCTKH20 = kind(CCTKH20)
  INTEGER*4 CCTKH24
  integer, parameter :: cctki_use_CCTKH24 = kind(CCTKH24)
  INTEGER*4 CCTKH26
  integer, parameter :: cctki_use_CCTKH26 = kind(CCTKH26)
  INTEGER*4 CCTKH27
  integer, parameter :: cctki_use_CCTKH27 = kind(CCTKH27)
  INTEGER*4 CCTKH28
  integer, parameter :: cctki_use_CCTKH28 = kind(CCTKH28)
  INTEGER*4 CCTKH30
  integer, parameter :: cctki_use_CCTKH30 = kind(CCTKH30)
  INTEGER*4 CCTKH32
  integer, parameter :: cctki_use_CCTKH32 = kind(CCTKH32)
  INTEGER*4 CCTKH34
  integer, parameter :: cctki_use_CCTKH34 = kind(CCTKH34)
  INTEGER*4 CCTKH36
  integer, parameter :: cctki_use_CCTKH36 = kind(CCTKH36)
  INTEGER*4 CCTKH38
  integer, parameter :: cctki_use_CCTKH38 = kind(CCTKH38)
  INTEGER*4 CCTKH40
  integer, parameter :: cctki_use_CCTKH40 = kind(CCTKH40)
  INTEGER*4 CCTKH42
  integer, parameter :: cctki_use_CCTKH42 = kind(CCTKH42)
  INTEGER*4 CCTKH44
  integer, parameter :: cctki_use_CCTKH44 = kind(CCTKH44)
  INTEGER*4 CCTKH46
  integer, parameter :: cctki_use_CCTKH46 = kind(CCTKH46)
  INTEGER*4 CCTKH48
  integer, parameter :: cctki_use_CCTKH48 = kind(CCTKH48)
  INTEGER*4 CCTKH50
  integer, parameter :: cctki_use_CCTKH50 = kind(CCTKH50)
  INTEGER*4 CCTKH52
  integer, parameter :: cctki_use_CCTKH52 = kind(CCTKH52)
  INTEGER*4 CCTKH55
  integer, parameter :: cctki_use_CCTKH55 = kind(CCTKH55)
  INTEGER*4 CCTKH56
  integer, parameter :: cctki_use_CCTKH56 = kind(CCTKH56)
  COMMON /IOrest/CCTKH5, CCTKH19, CCTKH29, CCTKH31, CCTKH33, CCTKH35, CCTKH37, CCTKH39, CCTKH41, CCTKH43, CCTKH45, CCTKH2, CCTKH3, &
  &CCTKH6, CCTKH9, CCTKH10, CCTKH11, CCTKH15, out_dir, CCTKH21, CCTKH22, CCTKH23, CCTKH25, CCTKH47, CCTKH49, CCTKH51, CCTKH53, CCTK&
  &H54, CCTKH57, CCTKH0, CCTKH1, CCTKH4, CCTKH7, CCTKH8, CCTKH12, CCTKH13, CCTKH14, CCTKH16, CCTKH17, CCTKH18, CCTKH20, CCTKH24, CC&
  &TKH26, CCTKH27, CCTKH28, CCTKH30, CCTKH32, CCTKH34, CCTKH36, CCTKH38, CCTKH40, CCTKH42, CCTKH44, CCTKH46, CCTKH48, CCTKH50, CCTK&
  &H52, CCTKH55, CCTKH56

  INTEGER*4, intent(in)     :: eoskey,keytemp,npoints
  INTEGER*4, intent(out)    :: keyerr(npoints)
  INTEGER*4, intent(out)    :: anyerr
  REAL*8, intent(in)    :: rf_precision
  REAL*8, intent(in)    :: rho(npoints),ye(npoints)
  REAL*8, intent(inout) :: eps(npoints), temp(npoints)
  REAL*8, intent(out)   :: dpderho(npoints)
  REAL*8, intent(out)   :: dpdrhoe(npoints)

  
  integer          :: i,p
  character(256)   :: warnstring
  real*8           :: hybrideos_local_gamma
  real*8           :: hybrideos_local_k, hybrideos_local_eps
  real*8           :: hybrideos_dp_poly,hybrideos_dp_th

  anyerr    = 0
  keyerr(:) = 0

  select case(eoskey)
  case (1)
     
        if(keytemp.eq.1) then
           do i=1,npoints
              eps(i) = press_gf * poly_k_cgs * &
                   (rho(i)*inv_rho_gf)**(poly_gamma) / &
                   (poly_gamma - 1.0d0) / rho(i)
           enddo
        endif
        do i=1,npoints
           dpdrhoe(i) = press_gf * poly_k_cgs *  &
                poly_gamma * inv_rho_gf *        &
                (rho(i)*inv_rho_gf) ** (poly_gamma - 1.d0)
           dpderho(i) = 0.0d0
        enddo
  case (2)
     
        if(keytemp.eq.1) then
           do i=1,npoints
              eps(i) = press_gf * gl_k_cgs * &
                   (rho(i)*inv_rho_gf)**(gl_gamma) / &
                   (gl_gamma - 1.0d0) / rho(i)
           enddo
        endif
        do i=1,npoints
           dpdrhoe(i) = (gl_gamma-1.0d0) * &
                eps(i)
           dpderho(i) = (gl_gamma - 1.0d0) * &
                rho(i)
        enddo
  case (3)
     
        do i=1,npoints
           hybrideos_local_gamma = hybrideos_gamma(1)
           hybrideos_local_k = hybrideos_k(1)
           hybrideos_local_eps = hybrideos_eps(1)
           if (n_pieces .gt. 1) then
              do p = 1,n_pieces-1
                 if (rho(i) .gt. hybrideos_rho(p)) then
                    hybrideos_local_gamma = hybrideos_gamma(p+1)
                    hybrideos_local_k = hybrideos_k(p+1)
                    hybrideos_local_eps = hybrideos_eps(p+1)
                 end if
              end do
           end if
           if (keytemp .eq. 1) then
              
              eps(i)=hybrideos_local_k/(hybrideos_local_gamma - 1.0)*rho(i)**(hybrideos_local_gamma - 1.0) + hybrideos_local_eps
           end if
           hybrideos_dp_poly = hybrideos_local_gamma * hybrideos_local_k * rho(i)**(hybrideos_local_gamma - 1.0d0)
           hybrideos_dp_th = (hybrid_gamma_th - 1.0d0) * (eps(i) - &
                hybrideos_dp_poly/(hybrideos_local_gamma - 1.0d0) - &
                hybrideos_local_eps)
           dpdrhoe(i) = hybrideos_dp_poly + max(0.0d0,hybrideos_dp_th)
           dpderho(i) = (hybrid_gamma_th - 1.0d0) * rho(i)
        enddo
    case (4)
       if(keytemp.ne.0) then
          call CCTK_Error(222,"EOS_Omni_MultiVarCalls.F90","EOS_Omni","Keytemp other than 0 not supported for dpdrhoe, dpderho")
          STOP
       else
          call nuc_eos_m_kt0_dpdrhoe_dpderho(npoints,&
               rho,temp,ye,eps,dpdrhoe,dpderho,rf_precision,&
               keyerr,anyerr)
       endif
   case DEFAULT
      write(warnstring,*) "eoskey ",eoskey," not implemented!"
      call CCTK_Error(231,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
      STOP
   end select

 end subroutine EOS_Omni_EOS_dpderho_dpdrhoe


 subroutine EOS_Omni_EOS_DEpsByDRho_DEpsByDPress(eoskey,keytemp,rf_precision,&
      npoints,rho,eps,temp,ye,depsdrho,depsdpress,keyerr,anyerr)

  use EOS_Omni_Module
  implicit none
  REAL*8 barotropiceos_gammath
  integer, parameter :: cctki_use_barotropiceos_gammath = kind(barotropiceos_gammath)
  REAL*8 gl_gamma
  integer, parameter :: cctki_use_gl_gamma = kind(gl_gamma)
  REAL*8 gl_k
  integer, parameter :: cctki_use_gl_k = kind(gl_k)
  REAL*8 hybrid_gamma (10)
  integer, parameter :: cctki_use_hybrid_gamma = kind(hybrid_gamma)
  REAL*8 hybrid_gamma1
  integer, parameter :: cctki_use_hybrid_gamma1 = kind(hybrid_gamma1)
  REAL*8 hybrid_gamma2
  integer, parameter :: cctki_use_hybrid_gamma2 = kind(hybrid_gamma2)
  REAL*8 hybrid_gamma_th
  integer, parameter :: cctki_use_hybrid_gamma_th = kind(hybrid_gamma_th)
  REAL*8 hybrid_k0
  integer, parameter :: cctki_use_hybrid_k0 = kind(hybrid_k0)
  REAL*8 hybrid_k1
  integer, parameter :: cctki_use_hybrid_k1 = kind(hybrid_k1)
  REAL*8 hybrid_rho (9)
  integer, parameter :: cctki_use_hybrid_rho = kind(hybrid_rho)
  REAL*8 hybrid_rho_nuc
  integer, parameter :: cctki_use_hybrid_rho_nuc = kind(hybrid_rho_nuc)
  REAL*8 poly_gamma
  integer, parameter :: cctki_use_poly_gamma = kind(poly_gamma)
  REAL*8 poly_gamma_initial
  integer, parameter :: cctki_use_poly_gamma_initial = kind(poly_gamma_initial)
  REAL*8 poly_k
  integer, parameter :: cctki_use_poly_k = kind(poly_k)
  integer*8 barotropiceos_table_name
  integer, parameter :: cctki_use_barotropiceos_table_name = kind(barotropiceos_table_name)
  integer*8 coldeos_table_name
  integer, parameter :: cctki_use_coldeos_table_name = kind(coldeos_table_name)
  integer*8 dump_nuceos_table_name
  integer, parameter :: cctki_use_dump_nuceos_table_name = kind(dump_nuceos_table_name)
  integer*8 nuceos_table_name
  integer, parameter :: cctki_use_nuceos_table_name = kind(nuceos_table_name)
  INTEGER*4 barotropiceos_read_table
  integer, parameter :: cctki_use_barotropiceos_read_table = kind(barotropiceos_read_table)
  INTEGER*4 barotropiceos_use_thermal_gamma_law
  integer, parameter :: cctki_use_barotropiceos_use_thermal_gamma_law = kind(barotropiceos_use_thermal_gamma_law)
  INTEGER*4 coldeos_read_table
  integer, parameter :: cctki_use_coldeos_read_table = kind(coldeos_read_table)
  INTEGER*4 coldeos_use_thermal_gamma_law
  integer, parameter :: cctki_use_coldeos_use_thermal_gamma_law = kind(coldeos_use_thermal_gamma_law)
  INTEGER*4 do_energy_shift
  integer, parameter :: cctki_use_do_energy_shift = kind(do_energy_shift)
  INTEGER*4 dump_nuceos_table
  integer, parameter :: cctki_use_dump_nuceos_table = kind(dump_nuceos_table)
  INTEGER*4 n_pieces
  integer, parameter :: cctki_use_n_pieces = kind(n_pieces)
  INTEGER*4 nuceos_read_table
  integer, parameter :: cctki_use_nuceos_read_table = kind(nuceos_read_table)
  INTEGER*4 read_table_on_single_process
  integer, parameter :: cctki_use_read_table_on_single_process = kind(read_table_on_single_process)
  INTEGER*4 reader_process
  integer, parameter :: cctki_use_reader_process = kind(reader_process)
  COMMON /EOS_Omnirest/barotropiceos_gammath, gl_gamma, gl_k, hybrid_gamma, hybrid_gamma1, hybrid_gamma2, hybrid_gamma_th, hybrid_k&
  &0, hybrid_k1, hybrid_rho, hybrid_rho_nuc, poly_gamma, poly_gamma_initial, poly_k, barotropiceos_table_name, coldeos_table_name, &
  &dump_nuceos_table_name, nuceos_table_name, barotropiceos_read_table, barotropiceos_use_thermal_gamma_law, coldeos_read_table, co&
  &ldeos_use_thermal_gamma_law, do_energy_shift, dump_nuceos_table, n_pieces, nuceos_read_table, read_table_on_single_process, read&
  &er_process
  REAL*8 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  REAL*8 CCTKH19
  integer, parameter :: cctki_use_CCTKH19 = kind(CCTKH19)
  REAL*8 CCTKH29
  integer, parameter :: cctki_use_CCTKH29 = kind(CCTKH29)
  REAL*8 CCTKH31
  integer, parameter :: cctki_use_CCTKH31 = kind(CCTKH31)
  REAL*8 CCTKH33
  integer, parameter :: cctki_use_CCTKH33 = kind(CCTKH33)
  REAL*8 CCTKH35
  integer, parameter :: cctki_use_CCTKH35 = kind(CCTKH35)
  REAL*8 CCTKH37
  integer, parameter :: cctki_use_CCTKH37 = kind(CCTKH37)
  REAL*8 CCTKH39
  integer, parameter :: cctki_use_CCTKH39 = kind(CCTKH39)
  REAL*8 CCTKH41
  integer, parameter :: cctki_use_CCTKH41 = kind(CCTKH41)
  REAL*8 CCTKH43
  integer, parameter :: cctki_use_CCTKH43 = kind(CCTKH43)
  REAL*8 CCTKH45
  integer, parameter :: cctki_use_CCTKH45 = kind(CCTKH45)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  integer*8 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  integer*8 CCTKH9
  integer, parameter :: cctki_use_CCTKH9 = kind(CCTKH9)
  integer*8 CCTKH10
  integer, parameter :: cctki_use_CCTKH10 = kind(CCTKH10)
  integer*8 CCTKH11
  integer, parameter :: cctki_use_CCTKH11 = kind(CCTKH11)
  integer*8 CCTKH15
  integer, parameter :: cctki_use_CCTKH15 = kind(CCTKH15)
  integer*8 out_dir
  integer, parameter :: cctki_use_out_dir = kind(out_dir)
  integer*8 CCTKH21
  integer, parameter :: cctki_use_CCTKH21 = kind(CCTKH21)
  integer*8 CCTKH22
  integer, parameter :: cctki_use_CCTKH22 = kind(CCTKH22)
  integer*8 CCTKH23
  integer, parameter :: cctki_use_CCTKH23 = kind(CCTKH23)
  integer*8 CCTKH25
  integer, parameter :: cctki_use_CCTKH25 = kind(CCTKH25)
  integer*8 CCTKH47
  integer, parameter :: cctki_use_CCTKH47 = kind(CCTKH47)
  integer*8 CCTKH49
  integer, parameter :: cctki_use_CCTKH49 = kind(CCTKH49)
  integer*8 CCTKH51
  integer, parameter :: cctki_use_CCTKH51 = kind(CCTKH51)
  integer*8 CCTKH53
  integer, parameter :: cctki_use_CCTKH53 = kind(CCTKH53)
  integer*8 CCTKH54
  integer, parameter :: cctki_use_CCTKH54 = kind(CCTKH54)
  integer*8 CCTKH57
  integer, parameter :: cctki_use_CCTKH57 = kind(CCTKH57)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  INTEGER*4 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  INTEGER*4 CCTKH12
  integer, parameter :: cctki_use_CCTKH12 = kind(CCTKH12)
  INTEGER*4 CCTKH13
  integer, parameter :: cctki_use_CCTKH13 = kind(CCTKH13)
  INTEGER*4 CCTKH14
  integer, parameter :: cctki_use_CCTKH14 = kind(CCTKH14)
  INTEGER*4 CCTKH16
  integer, parameter :: cctki_use_CCTKH16 = kind(CCTKH16)
  INTEGER*4 CCTKH17
  integer, parameter :: cctki_use_CCTKH17 = kind(CCTKH17)
  INTEGER*4 CCTKH18
  integer, parameter :: cctki_use_CCTKH18 = kind(CCTKH18)
  INTEGER*4 CCTKH20
  integer, parameter :: cctki_use_CCTKH20 = kind(CCTKH20)
  INTEGER*4 CCTKH24
  integer, parameter :: cctki_use_CCTKH24 = kind(CCTKH24)
  INTEGER*4 CCTKH26
  integer, parameter :: cctki_use_CCTKH26 = kind(CCTKH26)
  INTEGER*4 CCTKH27
  integer, parameter :: cctki_use_CCTKH27 = kind(CCTKH27)
  INTEGER*4 CCTKH28
  integer, parameter :: cctki_use_CCTKH28 = kind(CCTKH28)
  INTEGER*4 CCTKH30
  integer, parameter :: cctki_use_CCTKH30 = kind(CCTKH30)
  INTEGER*4 CCTKH32
  integer, parameter :: cctki_use_CCTKH32 = kind(CCTKH32)
  INTEGER*4 CCTKH34
  integer, parameter :: cctki_use_CCTKH34 = kind(CCTKH34)
  INTEGER*4 CCTKH36
  integer, parameter :: cctki_use_CCTKH36 = kind(CCTKH36)
  INTEGER*4 CCTKH38
  integer, parameter :: cctki_use_CCTKH38 = kind(CCTKH38)
  INTEGER*4 CCTKH40
  integer, parameter :: cctki_use_CCTKH40 = kind(CCTKH40)
  INTEGER*4 CCTKH42
  integer, parameter :: cctki_use_CCTKH42 = kind(CCTKH42)
  INTEGER*4 CCTKH44
  integer, parameter :: cctki_use_CCTKH44 = kind(CCTKH44)
  INTEGER*4 CCTKH46
  integer, parameter :: cctki_use_CCTKH46 = kind(CCTKH46)
  INTEGER*4 CCTKH48
  integer, parameter :: cctki_use_CCTKH48 = kind(CCTKH48)
  INTEGER*4 CCTKH50
  integer, parameter :: cctki_use_CCTKH50 = kind(CCTKH50)
  INTEGER*4 CCTKH52
  integer, parameter :: cctki_use_CCTKH52 = kind(CCTKH52)
  INTEGER*4 CCTKH55
  integer, parameter :: cctki_use_CCTKH55 = kind(CCTKH55)
  INTEGER*4 CCTKH56
  integer, parameter :: cctki_use_CCTKH56 = kind(CCTKH56)
  COMMON /IOrest/CCTKH5, CCTKH19, CCTKH29, CCTKH31, CCTKH33, CCTKH35, CCTKH37, CCTKH39, CCTKH41, CCTKH43, CCTKH45, CCTKH2, CCTKH3, &
  &CCTKH6, CCTKH9, CCTKH10, CCTKH11, CCTKH15, out_dir, CCTKH21, CCTKH22, CCTKH23, CCTKH25, CCTKH47, CCTKH49, CCTKH51, CCTKH53, CCTK&
  &H54, CCTKH57, CCTKH0, CCTKH1, CCTKH4, CCTKH7, CCTKH8, CCTKH12, CCTKH13, CCTKH14, CCTKH16, CCTKH17, CCTKH18, CCTKH20, CCTKH24, CC&
  &TKH26, CCTKH27, CCTKH28, CCTKH30, CCTKH32, CCTKH34, CCTKH36, CCTKH38, CCTKH40, CCTKH42, CCTKH44, CCTKH46, CCTKH48, CCTKH50, CCTK&
  &H52, CCTKH55, CCTKH56

  INTEGER*4, intent(in)     :: eoskey,keytemp,npoints
  INTEGER*4, intent(out)    :: keyerr(npoints)
  INTEGER*4, intent(out)    :: anyerr
  REAL*8, intent(in)    :: rf_precision
  REAL*8, intent(in)    :: rho(npoints),ye(npoints)
  REAL*8, intent(inout) :: eps(npoints), temp(npoints)
  REAL*8, intent(out)   :: depsdrho(npoints)
  REAL*8, intent(out)   :: depsdpress(npoints)

  
  integer          :: i,p
  character(256)   :: warnstring
  real*8           :: hybrideos_local_gamma
  real*8           :: hybrideos_local_k, hybrideos_local_eps
  real*8           :: hybrideos_dp_poly,hybrideos_dp_th
  
  real*8           :: xdpderho,xdpdrhoe


  anyerr    = 0
  keyerr(:) = 0

  select case (eoskey)
  case (1)
     
        if(keytemp.eq.1) then
           do i=1,npoints
              eps(i) = press_gf * poly_k_cgs * &
                   (rho(i)*inv_rho_gf)**(poly_gamma) / &
                   (poly_gamma - 1.0d0) / rho(i)
           enddo
        endif
        do i=1,npoints
           depsdpress(i) = 1.0d0/(poly_gamma - 1.0d0)/rho(i)
           depsdrho(i) = depsdpress(i) * press_gf * poly_k_cgs *  &
                poly_gamma * inv_rho_gf *        &
                (rho(i)*inv_rho_gf) ** (poly_gamma - 1.d0)
        enddo
  case (2)
     
        if(keytemp.eq.1) then
           do i=1,npoints
              eps(i) = press_gf * gl_k_cgs * &
                   (rho(i)*inv_rho_gf)**(gl_gamma) / &
                   (gl_gamma - 1.0d0) / rho(i)
           enddo
        endif
        do i=1,npoints
           depsdpress(i) = 1.0/( (gl_gamma - 1.0d0) * &
                rho(i))
           depsdrho(i) = -eps(i)/rho(i)
       enddo
  case (3)
     
        do i=1,npoints
           hybrideos_local_gamma = hybrideos_gamma(1)
           hybrideos_local_k = hybrideos_k(1)
           hybrideos_local_eps = hybrideos_eps(1)
           if (n_pieces .gt. 1) then
              do p = 1,n_pieces-1
                 if (rho(i) .gt. hybrideos_rho(p)) then
                    hybrideos_local_gamma = hybrideos_gamma(p+1)
                    hybrideos_local_k = hybrideos_k(p+1)
                    hybrideos_local_eps = hybrideos_eps(p+1)
                 end if
              end do
           end if
           if (keytemp .eq. 1) then
              
              eps(i)=hybrideos_local_k/(hybrideos_local_gamma - 1.0)*rho(i)**(hybrideos_local_gamma - 1.0) + hybrideos_local_eps
           end if
           hybrideos_dp_poly = hybrideos_local_gamma * hybrideos_local_k * rho(i)**(hybrideos_local_gamma - 1.0d0)
           hybrideos_dp_th = (hybrid_gamma_th - 1.0d0) * (eps(i) - &
                hybrideos_dp_poly/(hybrideos_local_gamma - 1.0d0) - &
                hybrideos_local_eps)


           xdpdrhoe = hybrideos_dp_poly + max(0.0d0,hybrideos_dp_th)
           xdpderho = (hybrid_gamma_th - 1.0d0) * rho(i)
           depsdpress(i) = 1.0 / xdpderho
           depsdrho(i) = - xdpdrhoe * depsdpress(i)
        enddo
    case (4)
      write(warnstring,*) "depsdrho and depsdpress not implemented yet for hot nuclear EOS"
      call CCTK_Error(329,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
      STOP
   case DEFAULT
      write(warnstring,*) "eoskey ",eoskey," not implemented!"
      call CCTK_Error(333,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
      STOP
   end select

 end subroutine EOS_Omni_EOS_DEpsByDRho_DEpsByDPress


subroutine EOS_Omni_EOS_Press_cs2(eoskey,keytemp,rf_precision,npoints,&
                              rho,eps,temp,ye,press,cs2,keyerr,anyerr)

  use EOS_Omni_Module
  implicit none
  REAL*8 barotropiceos_gammath
  integer, parameter :: cctki_use_barotropiceos_gammath = kind(barotropiceos_gammath)
  REAL*8 gl_gamma
  integer, parameter :: cctki_use_gl_gamma = kind(gl_gamma)
  REAL*8 gl_k
  integer, parameter :: cctki_use_gl_k = kind(gl_k)
  REAL*8 hybrid_gamma (10)
  integer, parameter :: cctki_use_hybrid_gamma = kind(hybrid_gamma)
  REAL*8 hybrid_gamma1
  integer, parameter :: cctki_use_hybrid_gamma1 = kind(hybrid_gamma1)
  REAL*8 hybrid_gamma2
  integer, parameter :: cctki_use_hybrid_gamma2 = kind(hybrid_gamma2)
  REAL*8 hybrid_gamma_th
  integer, parameter :: cctki_use_hybrid_gamma_th = kind(hybrid_gamma_th)
  REAL*8 hybrid_k0
  integer, parameter :: cctki_use_hybrid_k0 = kind(hybrid_k0)
  REAL*8 hybrid_k1
  integer, parameter :: cctki_use_hybrid_k1 = kind(hybrid_k1)
  REAL*8 hybrid_rho (9)
  integer, parameter :: cctki_use_hybrid_rho = kind(hybrid_rho)
  REAL*8 hybrid_rho_nuc
  integer, parameter :: cctki_use_hybrid_rho_nuc = kind(hybrid_rho_nuc)
  REAL*8 poly_gamma
  integer, parameter :: cctki_use_poly_gamma = kind(poly_gamma)
  REAL*8 poly_gamma_initial
  integer, parameter :: cctki_use_poly_gamma_initial = kind(poly_gamma_initial)
  REAL*8 poly_k
  integer, parameter :: cctki_use_poly_k = kind(poly_k)
  integer*8 barotropiceos_table_name
  integer, parameter :: cctki_use_barotropiceos_table_name = kind(barotropiceos_table_name)
  integer*8 coldeos_table_name
  integer, parameter :: cctki_use_coldeos_table_name = kind(coldeos_table_name)
  integer*8 dump_nuceos_table_name
  integer, parameter :: cctki_use_dump_nuceos_table_name = kind(dump_nuceos_table_name)
  integer*8 nuceos_table_name
  integer, parameter :: cctki_use_nuceos_table_name = kind(nuceos_table_name)
  INTEGER*4 barotropiceos_read_table
  integer, parameter :: cctki_use_barotropiceos_read_table = kind(barotropiceos_read_table)
  INTEGER*4 barotropiceos_use_thermal_gamma_law
  integer, parameter :: cctki_use_barotropiceos_use_thermal_gamma_law = kind(barotropiceos_use_thermal_gamma_law)
  INTEGER*4 coldeos_read_table
  integer, parameter :: cctki_use_coldeos_read_table = kind(coldeos_read_table)
  INTEGER*4 coldeos_use_thermal_gamma_law
  integer, parameter :: cctki_use_coldeos_use_thermal_gamma_law = kind(coldeos_use_thermal_gamma_law)
  INTEGER*4 do_energy_shift
  integer, parameter :: cctki_use_do_energy_shift = kind(do_energy_shift)
  INTEGER*4 dump_nuceos_table
  integer, parameter :: cctki_use_dump_nuceos_table = kind(dump_nuceos_table)
  INTEGER*4 n_pieces
  integer, parameter :: cctki_use_n_pieces = kind(n_pieces)
  INTEGER*4 nuceos_read_table
  integer, parameter :: cctki_use_nuceos_read_table = kind(nuceos_read_table)
  INTEGER*4 read_table_on_single_process
  integer, parameter :: cctki_use_read_table_on_single_process = kind(read_table_on_single_process)
  INTEGER*4 reader_process
  integer, parameter :: cctki_use_reader_process = kind(reader_process)
  COMMON /EOS_Omnirest/barotropiceos_gammath, gl_gamma, gl_k, hybrid_gamma, hybrid_gamma1, hybrid_gamma2, hybrid_gamma_th, hybrid_k&
  &0, hybrid_k1, hybrid_rho, hybrid_rho_nuc, poly_gamma, poly_gamma_initial, poly_k, barotropiceos_table_name, coldeos_table_name, &
  &dump_nuceos_table_name, nuceos_table_name, barotropiceos_read_table, barotropiceos_use_thermal_gamma_law, coldeos_read_table, co&
  &ldeos_use_thermal_gamma_law, do_energy_shift, dump_nuceos_table, n_pieces, nuceos_read_table, read_table_on_single_process, read&
  &er_process
  REAL*8 CCTKH5
  integer, parameter :: cctki_use_CCTKH5 = kind(CCTKH5)
  REAL*8 CCTKH19
  integer, parameter :: cctki_use_CCTKH19 = kind(CCTKH19)
  REAL*8 CCTKH29
  integer, parameter :: cctki_use_CCTKH29 = kind(CCTKH29)
  REAL*8 CCTKH31
  integer, parameter :: cctki_use_CCTKH31 = kind(CCTKH31)
  REAL*8 CCTKH33
  integer, parameter :: cctki_use_CCTKH33 = kind(CCTKH33)
  REAL*8 CCTKH35
  integer, parameter :: cctki_use_CCTKH35 = kind(CCTKH35)
  REAL*8 CCTKH37
  integer, parameter :: cctki_use_CCTKH37 = kind(CCTKH37)
  REAL*8 CCTKH39
  integer, parameter :: cctki_use_CCTKH39 = kind(CCTKH39)
  REAL*8 CCTKH41
  integer, parameter :: cctki_use_CCTKH41 = kind(CCTKH41)
  REAL*8 CCTKH43
  integer, parameter :: cctki_use_CCTKH43 = kind(CCTKH43)
  REAL*8 CCTKH45
  integer, parameter :: cctki_use_CCTKH45 = kind(CCTKH45)
  integer*8 CCTKH2
  integer, parameter :: cctki_use_CCTKH2 = kind(CCTKH2)
  integer*8 CCTKH3
  integer, parameter :: cctki_use_CCTKH3 = kind(CCTKH3)
  integer*8 CCTKH6
  integer, parameter :: cctki_use_CCTKH6 = kind(CCTKH6)
  integer*8 CCTKH9
  integer, parameter :: cctki_use_CCTKH9 = kind(CCTKH9)
  integer*8 CCTKH10
  integer, parameter :: cctki_use_CCTKH10 = kind(CCTKH10)
  integer*8 CCTKH11
  integer, parameter :: cctki_use_CCTKH11 = kind(CCTKH11)
  integer*8 CCTKH15
  integer, parameter :: cctki_use_CCTKH15 = kind(CCTKH15)
  integer*8 out_dir
  integer, parameter :: cctki_use_out_dir = kind(out_dir)
  integer*8 CCTKH21
  integer, parameter :: cctki_use_CCTKH21 = kind(CCTKH21)
  integer*8 CCTKH22
  integer, parameter :: cctki_use_CCTKH22 = kind(CCTKH22)
  integer*8 CCTKH23
  integer, parameter :: cctki_use_CCTKH23 = kind(CCTKH23)
  integer*8 CCTKH25
  integer, parameter :: cctki_use_CCTKH25 = kind(CCTKH25)
  integer*8 CCTKH47
  integer, parameter :: cctki_use_CCTKH47 = kind(CCTKH47)
  integer*8 CCTKH49
  integer, parameter :: cctki_use_CCTKH49 = kind(CCTKH49)
  integer*8 CCTKH51
  integer, parameter :: cctki_use_CCTKH51 = kind(CCTKH51)
  integer*8 CCTKH53
  integer, parameter :: cctki_use_CCTKH53 = kind(CCTKH53)
  integer*8 CCTKH54
  integer, parameter :: cctki_use_CCTKH54 = kind(CCTKH54)
  integer*8 CCTKH57
  integer, parameter :: cctki_use_CCTKH57 = kind(CCTKH57)
  INTEGER*4 CCTKH0
  integer, parameter :: cctki_use_CCTKH0 = kind(CCTKH0)
  INTEGER*4 CCTKH1
  integer, parameter :: cctki_use_CCTKH1 = kind(CCTKH1)
  INTEGER*4 CCTKH4
  integer, parameter :: cctki_use_CCTKH4 = kind(CCTKH4)
  INTEGER*4 CCTKH7
  integer, parameter :: cctki_use_CCTKH7 = kind(CCTKH7)
  INTEGER*4 CCTKH8
  integer, parameter :: cctki_use_CCTKH8 = kind(CCTKH8)
  INTEGER*4 CCTKH12
  integer, parameter :: cctki_use_CCTKH12 = kind(CCTKH12)
  INTEGER*4 CCTKH13
  integer, parameter :: cctki_use_CCTKH13 = kind(CCTKH13)
  INTEGER*4 CCTKH14
  integer, parameter :: cctki_use_CCTKH14 = kind(CCTKH14)
  INTEGER*4 CCTKH16
  integer, parameter :: cctki_use_CCTKH16 = kind(CCTKH16)
  INTEGER*4 CCTKH17
  integer, parameter :: cctki_use_CCTKH17 = kind(CCTKH17)
  INTEGER*4 CCTKH18
  integer, parameter :: cctki_use_CCTKH18 = kind(CCTKH18)
  INTEGER*4 CCTKH20
  integer, parameter :: cctki_use_CCTKH20 = kind(CCTKH20)
  INTEGER*4 CCTKH24
  integer, parameter :: cctki_use_CCTKH24 = kind(CCTKH24)
  INTEGER*4 CCTKH26
  integer, parameter :: cctki_use_CCTKH26 = kind(CCTKH26)
  INTEGER*4 CCTKH27
  integer, parameter :: cctki_use_CCTKH27 = kind(CCTKH27)
  INTEGER*4 CCTKH28
  integer, parameter :: cctki_use_CCTKH28 = kind(CCTKH28)
  INTEGER*4 CCTKH30
  integer, parameter :: cctki_use_CCTKH30 = kind(CCTKH30)
  INTEGER*4 CCTKH32
  integer, parameter :: cctki_use_CCTKH32 = kind(CCTKH32)
  INTEGER*4 CCTKH34
  integer, parameter :: cctki_use_CCTKH34 = kind(CCTKH34)
  INTEGER*4 CCTKH36
  integer, parameter :: cctki_use_CCTKH36 = kind(CCTKH36)
  INTEGER*4 CCTKH38
  integer, parameter :: cctki_use_CCTKH38 = kind(CCTKH38)
  INTEGER*4 CCTKH40
  integer, parameter :: cctki_use_CCTKH40 = kind(CCTKH40)
  INTEGER*4 CCTKH42
  integer, parameter :: cctki_use_CCTKH42 = kind(CCTKH42)
  INTEGER*4 CCTKH44
  integer, parameter :: cctki_use_CCTKH44 = kind(CCTKH44)
  INTEGER*4 CCTKH46
  integer, parameter :: cctki_use_CCTKH46 = kind(CCTKH46)
  INTEGER*4 CCTKH48
  integer, parameter :: cctki_use_CCTKH48 = kind(CCTKH48)
  INTEGER*4 CCTKH50
  integer, parameter :: cctki_use_CCTKH50 = kind(CCTKH50)
  INTEGER*4 CCTKH52
  integer, parameter :: cctki_use_CCTKH52 = kind(CCTKH52)
  INTEGER*4 CCTKH55
  integer, parameter :: cctki_use_CCTKH55 = kind(CCTKH55)
  INTEGER*4 CCTKH56
  integer, parameter :: cctki_use_CCTKH56 = kind(CCTKH56)
  COMMON /IOrest/CCTKH5, CCTKH19, CCTKH29, CCTKH31, CCTKH33, CCTKH35, CCTKH37, CCTKH39, CCTKH41, CCTKH43, CCTKH45, CCTKH2, CCTKH3, &
  &CCTKH6, CCTKH9, CCTKH10, CCTKH11, CCTKH15, out_dir, CCTKH21, CCTKH22, CCTKH23, CCTKH25, CCTKH47, CCTKH49, CCTKH51, CCTKH53, CCTK&
  &H54, CCTKH57, CCTKH0, CCTKH1, CCTKH4, CCTKH7, CCTKH8, CCTKH12, CCTKH13, CCTKH14, CCTKH16, CCTKH17, CCTKH18, CCTKH20, CCTKH24, CC&
  &TKH26, CCTKH27, CCTKH28, CCTKH30, CCTKH32, CCTKH34, CCTKH36, CCTKH38, CCTKH40, CCTKH42, CCTKH44, CCTKH46, CCTKH48, CCTKH50, CCTK&
  &H52, CCTKH55, CCTKH56

  INTEGER*4, intent(in)     :: eoskey,keytemp,npoints
  INTEGER*4, intent(out)    :: keyerr(npoints)
  INTEGER*4, intent(out)    :: anyerr
  REAL*8, intent(in)    :: rf_precision
  REAL*8, intent(in)    :: rho(npoints),ye(npoints)
  REAL*8, intent(inout) :: eps(npoints), temp(npoints)
  REAL*8, intent(out)   :: press(npoints)
  REAL*8, intent(out)   :: cs2(npoints)

  
  integer          :: i,p
  character(256)   :: warnstring
  real*8           :: hybrideos_local_gamma, hybrideos_local_k, hybrideos_local_eps,&
                      hybrideos_p_poly, hybrideos_p_th
  real*8,parameter :: zero = 0.0d0
  
  real*8           :: xrho
  real*8           :: xdpderho,xdpdrhoe
  
  integer :: ir
  real*8 :: press_cold, press_th
  real*8 :: eps_cold, eps_th
  real*8 :: gamma, cs2_cold, cs2_th, h, h_cold

  anyerr    = 0
  keyerr(:) = 0

  select case (eoskey)
     case (1)
        
        if(keytemp.eq.1) then
           do i=1,npoints
              eps(i) = press_gf * poly_k_cgs * &
                   (rho(i)*inv_rho_gf)**(poly_gamma) / &
                   (poly_gamma - 1.0d0) / rho(i)
           enddo
        endif
        do i=1,npoints
           press(i) = press_gf * poly_k_cgs * &
                (rho(i)*inv_rho_gf)**poly_gamma
           cs2(i) = poly_gamma * press(i) / rho(i) / &
                (1 + eps(i) + press(i)/rho(i))
           
        enddo
     case (2)
        
        if(keytemp.eq.1) then
           do i=1,npoints
              eps(i) = press_gf * gl_k_cgs * &
                   (rho(i)*inv_rho_gf)**(gl_gamma) / &
                   (gl_gamma - 1.0d0) / rho(i)
           enddo
        endif
        do i=1,npoints
           press(i) = (gl_gamma - 1.0d0) * rho(i) * eps(i)
           xdpdrhoe = (gl_gamma-1.0d0)*eps(i)
           xdpderho = (gl_gamma-1.0d0)*rho(i)
           cs2(i) = (xdpdrhoe + press(i) * xdpderho / (rho(i)**2)) / &
                (1.0d0 + eps(i) + press(i)/rho(i))
           
        enddo

     case (3)
        
        do i=1,npoints
           
           hybrideos_local_gamma = hybrideos_gamma(1)
           hybrideos_local_k = hybrideos_k(1)
           hybrideos_local_eps = hybrideos_eps(1)
           if (n_pieces .gt. 1) then
              do p = 1,n_pieces-1
                 if (rho(i) .gt. hybrideos_rho(p)) then
                    hybrideos_local_gamma = hybrideos_gamma(p+1)
                    hybrideos_local_k = hybrideos_k(p+1)
                    hybrideos_local_eps = hybrideos_eps(p+1)
                 end if
              end do
           end if
           if (keytemp .eq. 1) then
              
              eps(i)=hybrideos_local_k/(hybrideos_local_gamma - 1.0)*rho(i)**(hybrideos_local_gamma - 1.0) + hybrideos_local_eps
           end if
           hybrideos_p_poly = hybrideos_local_k * (rho(i))**hybrideos_local_gamma
           hybrideos_p_th = (hybrid_gamma_th-1)* (rho(i)*eps(i) - &
                hybrideos_p_poly/(hybrideos_local_gamma-1) - &
                hybrideos_local_eps * rho(i))
           hybrideos_p_th = max(zero, hybrideos_p_th)
           press(i) = hybrideos_p_poly + hybrideos_p_th
           cs2(i) = (hybrideos_local_gamma * hybrideos_p_poly + hybrid_gamma_th * hybrideos_p_th) / &
                rho(i) / (1.0d0 + eps(i) + press(i)/rho(i))
           
        enddo

     case (4)
        
        if(keytemp.eq.1) then
           call nuc_eos_m_kt1_press_eps_cs2(npoints,rho,temp,ye,&
                eps,press,cs2,keyerr,anyerr)
        else if(keytemp.eq.0) then
           call nuc_eos_m_kt0_press_cs2(npoints,rho,temp,ye,eps,press,&
                cs2,rf_precision,keyerr,anyerr)
        else
           call CCTK_Error(449,"EOS_Omni_MultiVarCalls.F90","EOS_Omni","This keytemp is not suppported!")
           STOP
        endif
     case (5)
        
        
        
        do i=1,npoints
           if(rho(i).lt.coldeos_rhomin) then
              press(i) = coldeos_low_kappa * rho(i)**coldeos_low_gamma
              eps(i) = press(i) / (coldeos_low_gamma - 1.0) / rho(i) 
              cs2(i) = coldeos_low_kappa * coldeos_low_gamma * &
                   rho(i)**(coldeos_low_gamma-1.0d0) / &
                   (1.0d0 + eps(i) + press(i))
              cycle
           else if(rho(i).gt.coldeos_rhomax) then
              keyerr(i) = 103
              anyerr = 1
           else
              xrho = log10(rho(i))
              ir = 2 + INT( (xrho - coldeos_logrho(1) - 1.0d-10) * coldeos_dlrhoi )
           endif
           ir = max(2, min(ir,coldeos_nrho))

           gamma = (coldeos_gamma(ir) - coldeos_gamma(ir-1)) / &
                (coldeos_logrho(ir) - coldeos_logrho(ir-1)) * &
                (xrho - coldeos_logrho(ir-1)) + coldeos_gamma(ir-1)

           
           cs2_cold = (coldeos_cs2(ir) - coldeos_cs2(ir-1)) / &
                (coldeos_cs2(ir) - coldeos_cs2(ir-1)) * &
                (xrho - coldeos_logrho(ir-1)) + coldeos_cs2(ir-1)

           eps_cold = (coldeos_eps(ir) - coldeos_eps(ir-1)) / &
                    (coldeos_logrho(ir) - coldeos_logrho(ir-1)) * &
                    (xrho - coldeos_logrho(ir-1)) + coldeos_eps(ir-1)

           if(keytemp.eq.0) then
              eps_th = max(0.0d0,eps(i) - eps_cold)
           else if (keytemp.eq.1) then
              eps_th = 0.0d0
              eps(i) = eps_cold
           endif

           press_cold = coldeos_kappa * rho(i)**gamma
           press_th = coldeos_thfac*(coldeos_gammath - 1.0d0)*rho(i)*eps_th
           press(i) = press_cold + press_th

           xdpdrhoe = coldeos_thfac*(coldeos_gammath - 1.0d0)*eps_th
           xdpderho = coldeos_thfac*(coldeos_gammath - 1.0d0)*rho(i)
           cs2_th = (xdpdrhoe + press_th * xdpderho / (rho(i)**2))
           
           h = 1.0d0 + eps(i) + (press_cold+press_th) / rho(i)
           h_cold = 1.0d0 + eps_cold + press_cold / rho(i)
           
           cs2(i) = (cs2_cold * h_cold + cs2_th) / h

        enddo

     case (6)
        
        write(warnstring,*) "eoskey ",eoskey," for barotropic EOS not implemented!"
        call CCTK_Error(511,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
        STOP
     case DEFAULT
        write(warnstring,*) "eoskey ",eoskey," not implemented!"
        call CCTK_Error(515,"EOS_Omni_MultiVarCalls.F90","EOS_Omni",warnstring)
        STOP
     end select

end subroutine EOS_Omni_EOS_Press_cs2

