Subroutine zero
      
Use comm
Implicit None
nn=ny*nz
nnn=nn*nv
Write(*,*) "zero: nn, nnn = ", nn, nnn

Allocate(y(0:ny+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to y", error
  Stop
End If
y=0d0

Allocate(dy(0:ny+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to dy", error
  Stop
End If
dy=0d0

Allocate(g(0:ny+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to g", error
  Stop
End If
g=0d0

Allocate(z(0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to z", error
  Stop
End If
z=0d0

Allocate(dz(0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to dz", error
  Stop
End If
dz=0d0

Allocate(h(0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to h", error
  Stop
End If
h=0d0

Allocate(art(0:ny+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to art", error
  Stop
End If
art=0d0

Allocate(arn(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to arn", error
  Stop
End If
arn=0d0

Allocate(vol(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to vol", error
  Stop
End If
vol=0d0

Allocate(ap(nnn,5*nv),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to ap", error
  Stop
End If
ap=0d0

Allocate(af(nnn),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to af", error
  Stop
End If
af=0d0

Allocate(temp_sol(nnn),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to temp_sol", error
  Stop
End If
temp_sol=0d0

Allocate(connect(nnn,5*nv),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to connect", error
  Stop
End If
connect=0

Allocate(ijk(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to ijk", error
  Stop
End If
ijk=0

Allocate(res_calc(ny,nz,nv),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to res_calc", error
  Stop
End If
res_calc=0d0

Allocate(sig(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to sig", error
  Stop
End If
sig=0d0

Allocate(sigy(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to sigy", error
  Stop
End If
sigy=0d0

Allocate(sigz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to sigz", error
  Stop
End If
sigz=0d0

Allocate(emob(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to emob", error
  Stop
End If
emob=0d0

Allocate(emoby(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to emoby", error
  Stop
End If
emoby=0d0

Allocate(emobz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to emobz", error
  Stop
End If
emobz=0d0

Allocate(nmoby(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to nmoby", error
  Stop
End If
nmoby=0d0

Allocate(nmobz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to nmobz", error
  Stop
End If
nmobz=0d0

Allocate(pmoby(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to pmoby", error
  Stop
End If
pmoby=0d0

Allocate(pmobz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to pmobz", error
  Stop
End If
pmobz=0d0

Allocate(epsy(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to epsy", error
  Stop
End If
epsy=0d0

Allocate(epsz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to epsz", error
  Stop
End If
epsz=0d0


Allocate(ian(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to ian", error
  Stop
End If

Allocate(neycase(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to neycase", error
  Stop
End If

Allocate(npycase(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to npycase", error
  Stop
End If

Allocate(nnycase(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to nnycase", error
  Stop
End If

Allocate(nezcase(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to nezcase", error
  Stop
End If

Allocate(npzcase(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to npzcase", error
  Stop
End If

Allocate(nnzcase(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to nnzcase", error
  Stop
End If

Allocate(phi(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to phi", error,  ny, nz
  Stop
End If
phi=0d0

Allocate(cdy(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to cdy", error,  ny, nz
  Stop
End If
cdy=0d0

Allocate(cdz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to cdz", error,  ny, nz
  Stop
End If
cdz=0d0

Allocate(ey(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to ey", error,  ny, nz
  Stop
End If
ey=0d0

Allocate(ez(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to ez", error,  ny, nz
  Stop
End If
ez=0d0

Allocate(rnn(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnn", error,  ny, nz
  Stop
End If
rnn=0d0

Allocate(rnp(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnp", error,  ny, nz
  Stop
End If
rnp=0d0

Allocate(rne(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rne", error,  ny, nz
  Stop
End If
rne=0d0

Allocate(rnny(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnny", error,  ny, nz
  Stop
End If
rnny=0d0

Allocate(rnpy(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnpy", error,  ny, nz
  Stop
End If
rnpy=0d0

Allocate(rney(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rney", error,  ny, nz
  Stop
End If
rney=0d0

Allocate(rnnz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnnz", error,  ny, nz
  Stop
End If
rnnz=0d0

Allocate(rnpz(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnpz", error,  ny, nz
  Stop
End If
rnpz=0d0

Allocate(rnez(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to rnez", error,  ny, nz
  Stop
End If
rnez=0d0

Allocate(ornn(ny,nz,2),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to ornn", error,  ny, nz
  Stop
End If
ornn=0d0

Allocate(ornp(ny,nz,2),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to ornp", error,  ny, nz
  Stop
End If
ornp=0d0

Allocate(orne(ny,nz,2),Stat=error)
If (error/=0) Then
  Print *,"ALLOCATE: Error allocating memory to orne", error,  ny, nz
  Stop
End If
orne=0d0

Allocate(alpha(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to alpha", error
  Stop
End If
alpha=0d0

Allocate(eta(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to eta", error
  Stop
End If
eta=0d0

Allocate(dalphay(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to dalphay", error
  Stop
End If
dalphay=0d0

Allocate(dalphaz(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to dalphaz", error
  Stop
End If
dalphaz=0d0

Allocate(detay(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to detay", error
  Stop
End If
detay=0d0

Allocate(detaz(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to detaz", error
  Stop
End If
detaz=0d0

Allocate(enth(0:ny+1,0:nz+1),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to enth", error
  Stop
End If
enth=0d0

Allocate(enth0(ny,nz),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to enth0", error
  Stop
End If
enth0=0d0

Allocate(timekeep(maxtit),Stat=error)
If (error/=0) Then
  Print *,"ZERO: Error allocating memory to timekeep", error
  Stop
End If
timekeep=0d0

End Subroutine zero
