Module comm
Implicit None

Real(Kind=8), Parameter :: Pi=3.1415926535897932384626433832795d0
Real(Kind=8), Parameter :: mu_0 = 1.2566370614359172953850573533118d-6
Real(Kind=8), Parameter :: eps_0 = 8.85418781762038985053656d-12
Real(Kind=8), Parameter :: elec_charge = 1.602176565d-19
Real(Kind=8), Parameter :: Boltzmann = 1.3806504d-23
Real(Kind=8), Parameter :: gas_constant = 8.314472d0
Real(Kind=8), Parameter :: gamma=2d-13
Real(Kind=8), Parameter :: rn=2.5d25
Integer, Parameter :: nv=4

Real(Kind=8) :: gams
Real(Kind=8) :: ydim, zdim
Real(Kind=8) :: yl1, yl2, zl1, zl2, zh1, zh2
Integer :: ny, nz, mmax, nn,nnn
Integer :: nyl11, nyl12, nyl21, nyl22, nzl11, nzl12, nzl21, nzl22 , nzh11, nzh12 , nzh21, nzh22
Real(Kind=8) :: res, rel
Real(Kind=8), Allocatable, Dimension(:,:,:) :: res_calc
Integer :: error
Logical :: ifread
Real(Kind=8), Allocatable :: y(:), z(:)
Real(Kind=8), Allocatable ::dy(:), dz(:)
Real(Kind=8), Allocatable :: vol(:,:)
Real(Kind=8), Allocatable :: yold(:), zold(:)
Integer :: nyo, nzo
Real(Kind=8), Allocatable :: arn(:,:),art(:)
Real(Kind=8), Allocatable :: g(:),h(:)
Real(Kind=8), Allocatable :: ap(:,:),af(:),temp_sol(:)
Integer, Allocatable :: connect(:,:),ijk(:,:)
Real(Kind=8), Allocatable :: sig(:,:)
Real(Kind=8), Allocatable :: sigy(:,:)
Real(Kind=8), Allocatable :: sigz(:,:)
Real(Kind=8), Allocatable :: emob(:,:)
Real(Kind=8), Allocatable :: emoby(:,:)
Real(Kind=8), Allocatable :: emobz(:,:)
Real(Kind=8), Allocatable :: epsy(:,:)
Real(Kind=8), Allocatable :: epsz(:,:)
Real(Kind=8), Allocatable :: pmoby(:,:)
Real(Kind=8), Allocatable :: pmobz(:,:)
Real(Kind=8), Allocatable :: nmoby(:,:)
Real(Kind=8), Allocatable :: nmobz(:,:)
Real(Kind=8), Allocatable :: phi(:,:)
Real(Kind=8), Allocatable :: cdy(:,:)
Real(Kind=8), Allocatable :: cdz(:,:)
Real(Kind=8), Allocatable :: ey(:,:)
Real(Kind=8), Allocatable :: ez(:,:)
Real(Kind=8), Allocatable :: rnn(:,:)
Real(Kind=8), Allocatable :: rnp(:,:)
Real(Kind=8), Allocatable :: rne(:,:)
Real(Kind=8), Allocatable :: ornn(:,:,:)
Real(Kind=8), Allocatable :: ornp(:,:,:)
Real(Kind=8), Allocatable :: orne(:,:,:)
Real(Kind=8), Allocatable :: eta(:,:)
Real(Kind=8), Allocatable :: alpha(:,:)
Real(Kind=8), Allocatable :: rnny(:,:)
Real(Kind=8), Allocatable :: rnpy(:,:)
Real(Kind=8), Allocatable :: rney(:,:)
Real(Kind=8), Allocatable :: rnnz(:,:)
Real(Kind=8), Allocatable :: rnpz(:,:)
Real(Kind=8), Allocatable :: rnez(:,:)
Real(Kind=8), Allocatable :: dalphay(:,:)
Real(Kind=8), Allocatable :: dalphaz(:,:)
Real(Kind=8), Allocatable :: detay(:,:)
Real(Kind=8), Allocatable :: detaz(:,:)
Real(Kind=8), Allocatable :: enth(:,:),enth0(:,:)
Real(Kind=8), Allocatable :: timekeep(:)
Integer, Allocatable :: ian(:,:)
Integer, Allocatable :: neycase(:,:),npycase(:,:),nnycase(:,:)
Integer, Allocatable :: nezcase(:,:),npzcase(:,:),nnzcase(:,:)
Integer(Kind=8) :: bigstor_length
Logical, Dimension(6) :: convegence_check
Integer :: total_cell
Character(Len=256) :: input_file, output_name,grid_name,grid_name2
Integer(Kind=8) :: irecl
Logical :: debug_run, custom_grid, high_charge_dens, directCGS
Real(Kind=8) :: resmax_old, rlxmod
Real(Kind=8) :: solve_rel
Real(Kind=8) :: sig_air, sig_ins, sig_cond
Real(Kind=8) :: emob_cond, emob_ins, emob_air, nmob, pmob
Real(Kind=8) :: eps_cond, eps_ins, eps_air
Real(Kind=8) :: t,tstep, tstep_max,total_vol,total_gas_vol,rise_time
Integer :: maxtit, modrec,max_threads
Integer :: mm,innerloop,rx,ry,rwcount
Integer :: phi_boundary_mode
Real(Kind=8) :: sig_threshold, initial_charge, cp_ion,cp_ion2, sheath, electron_temperature,pc
Integer :: convection_mode, surface_mode,metastable_mode
Real(Kind=8) :: meta_alpha,meta_eta,meta_time0,meta_time1,sig_time

Namelist /inputs/ ydim, zdim, sheath, yl1, yl2, zl1, zl2, zh1, zh2, &
                  ny, nz, emob_cond, emob_ins, emob_air, nmob, pmob,  &
                  sig_air, sig_ins, sig_cond, nyo, nzo, output_name,maxtit,modrec,tstep_max, &
                  custom_grid,grid_name,grid_name2,rise_time,eps_cond, eps_ins, eps_air, mm,rx,ry, &
                  phi_boundary_mode,sig_threshold, initial_charge,convection_mode, surface_mode, &
                  high_charge_dens, directCGS,electron_temperature,rwcount,t,metastable_mode, &
                  meta_alpha,meta_eta,meta_time0,meta_time1,sig_time,ifread

End Module comm
