# common for SEPWAVElib
# We avoid parameter passing by using
# common blocks with definitions for all subroutines
#%
define maxcoef 40
define ntmaxdim 6		#maximum tensor indices (contracted)
define nmaxdim  3		#maximum space dimensions
define nmaxcomp 3               #maximum displacements components
define nmaxsrc  3               #maximum number of simlutanoues sources
define maxorder 20              #maximum order of time update


integer ndim		# number of space dimensions
integer ncomp		# number of displacement components
integer ntcomp		# number of tensor components
integer nstiff          # number of stiffness tensor components
integer nrho		# number of density tensor components
integer nscomp          # number of source components
integer idim(nmaxdim)      # how dow the space dim map into the vector array 
#mf$layout idim(:serial)
integer icomp(nmaxcomp)    # how dow the components map into the vector array 
#mf$layout icomp(:serial)
integer tcomp(ntmaxdim)    # how dow the components map into the tensor array 
#mf$layout tcomp(:serial)
integer trudim(0:nmaxdim)    # inverse of idim 
#mf$layout trudim(:serial)
integer iscomp(ntmaxdim)    # specify in which stress components to add source 
#mf$layout iscomp(:serial)


real    ddx(nmaxdim)       # vector of scales for the derivative
#mf$layout ddx(:serial)
real dt,dtseis
integer idtseis
integer ntsteps,type       # number of timesteps kept and medium type
integer norder             # number of time order 
integer visco,viscorho
integer finite,duffing     # finite displacements or chaotic

common /basics/icomp,ncomp,idim,ndim,tcomp,ntcomp,ddx,dt,dtseis,idtseis,ntsteps,nstiff,trudim,type,nscomp,iscomp,norder,nrho,visco,viscorho,finite,duffing

real    coef(-maxcoef:maxcoef)  # convolutional coefficients
#mf$layout coef(:serial)
real    coef2(-maxcoef:maxcoef)  # convolutional coefficients
#mf$layout coef2(:serial)
real    coefone(-maxcoef:maxcoef)  # convolutional coefficients for oneway
#mf$layout coefone(:serial)
integer nlo             # the lowest  conv coefficient relative to 0
integer nhi             # the highest conv coefficient relative to 0
integer nlo2            # the lowest  conv coefficient relative to 0
integer nhi2            # the highest conv coefficient relative to 0
integer nloone          # the lowest  conv coefficient relative to 0
integer nhione          # the highest conv coefficient relative to 0
common /delcom/nlo,nhi,coef,nlo2,nhi2,coef2,nloone,nhione,coefone

integer    abbin(nmaxcomp,nmaxdim)
#mf$layout abbin(:serial,:serial)
integer    ccin(ntmaxdim,ntmaxdim)
#mf$layout ccin(:serial,:serial)
integer    truin(nmaxcomp,nmaxdim)
#mf$layout truin(:serial,:serial)
integer    rhoin(nmaxcomp,nmaxcomp)
#mf$layout rhoin(:serial,:serial)

common /map/abbin,ccin,truin,rhoin

integer    stagger,staggrid
integer    stagc0(ntmaxdim,nmaxdim),stagc1(ntmaxdim,nmaxdim)
#mf$layout stagc0(:serial,:serial)
#mf$layout stagc1(:serial,:serial)
common /stagger/stagger,staggrid,stagc0,stagc1       # stagger mask (6,3)

integer    deriv(ntmaxdim,nmaxdim), dtype(nmaxdim)
#mf$layout deriv(:serial,:serial)
#mf$layout dtype(:serial)
common /deriv/deriv,dtype      # derivative mask (6,3) and derivative type mask


real       scaling(ntmaxdim,nmaxdim)
#mf$layout scaling(:serial,:serial)
common /tensorscale/scaling	       # scaling mask (6,3)

real       stiffmask(ntmaxdim,ntmaxdim)
#mf$layout stiffmask(:serial,:serial)
common /symmetry/stiffmask     # stiffness symmetry mask (6,6)


integer nbounds(3),nbound1,nbound2,nbound3,ndamp,nabsorb,surf_type,oneway
real damping
#mf$layout nbounds(:serial)
common /boundaries/nbound1,nbound2,nbound3,ndamp,nabsorb,surf_type,oneway,nbounds,damping

integer sloc(nmaxcomp,nmaxsrc),nloc,nts,src_type, nsmooth(3),srcextend 
real srcshift(3,3),srcdamp
#mf$layout srcshift(:serial,:serial)
#mf$layout sloc (:serial,:serial)
#mf$layout nsmooth(:serial)
real wate(-4:4,nmaxdim)
#mf$layout wate(:serial,:serial)
common /sources/nloc,nts,src_type,sloc,nsmooth,wate,srcextend,srcshift,srcdamp
real lsz0,lsx0,lsz1,lsx1,lsm
integer lsn,linesource
common /linesrc/linesource,lsz0,lsx0,lsz1,lsx1,lsm,lsn


integer geo_depth,centered
common /receivers/geo_depth,centered
real lrz0,lrx0,lrz1,lrx1,lrm
integer lrn,linereceiver
common /linerecr/linereceiver,lrz0,lrx0,lrz1,lrx1,lrm,lrn

# actual sizes
integer nx,ny,nz
common /sizes/nx,ny,nz

# wave equation type , eg 2.5D equation
integer eqn
common /eqntype/eqn

# nonlinear parameters
real hold,spring
common /nonlin/hold,spring

# SHASTA FCT parameters if used
real c1,c2
common /flux/c1,c2


integer incore,npadincore,nincore,nblocks,ntincore,nzout,nxout,nyout
common /outcore/incore,npadincore,nincore,nblocks,ntincore,nzout,nxout,nyout

# here we include Object types and layouts
#include "types"
