MAKE_DEPEND=yes
RESDIR=.
include ${SEPINC}/SEP.top
FFTWLIBS=-L/opt/FFTW/lib -lfftw3f

MAIN_LIBS=-lsupersetf90 -lsuperset -lsepparf90 -lseppar -lsep2df90 -lsep3df90 -lsep3d -lsepf90 -lsep 
VEC= -L/opt/intel/mkl/9.1/lib/em64t -lmkl -lvml
UF90LIBS=-lsep2df90 -lsepparf90 -lseppar -lsupersetf90 -lsuperset ${FFTWLIBS} ${MAIN_LIBS} -openmp # ${VEC} -lpthread 
UF90FLAGS=-fast -O3 

#UF90DEFINES=-DFFTW=1  #-DSEP_OMP -DOMP# -DDEBUG# -DAMD -DDEBUG
UF90DEFINES= -DLINUX -DUSE_FFTW 

OBJS= wei_cam.o   wei_file.o              wei_step.o       wei_wem.o \
wei_damp.o  wei_fk_fx_wavefield.o  wei_kmap.o   wei_table.o      wei_wem_ssf.o \
wei_dsr.o   wei_fk_type.o          wei_ssf.o    wei_wavespace.o \
wei_fft.o  wei_fft_fftw.o  wei_fft_mkl.o  wei_sg_basic_image.o

all: ${OBJS}

compile: S_G_wem.x S_G_cam.x

SRCDIR=.

#VEC= -L/opt/intel/mkl72/lib/em64t -lmkl -lvml
#VEC= -L/usr/local/ACML/pathscale64/lib -lacml_mv -lacml
#UF90LIBS=-L. -lsepauxf90 -lsepaux ${FFTWLIBS}  ${MAIN_LIBS} ${VEC} -lsepgeef90 -lsep2df90   -lpthread

#WHERE TO PUT THE BINARIES
BINDIR=./

clean: #bclean
	rm -f *.o *stb
	rm -f *mod
	rm -f *.x




sref.H: marmvel.H
	Window3d < marmvel.H j1=3 |Transp plane=12 |Transp plane=23 >vel.H
	Lloyd_vel < marmvel.H  >$@ nref=6

gmage.%.H:  fmage.%.H
	Transp < fmage.$*.H  reshape=2,4,5 plane=13 >m.H
	<m.H Reverse which=2 >x.H core=1
	< x.H OFF2ANG >$@
nmage.%.H:  mmage.%.H
	Transp < mmage.$*.H  reshape=2,4,5 plane=13 >m.H
	<m.H Reverse which=2 >x.H core=1
	< x.H OFF2ANG >$@
gtot.H:  image_tot.H
	Transp < image_tot.H  reshape=2,4,5 plane=13 >m.H
	<m.H Reverse which=2 >x.H core=1
	< x.H OFF2ANG >$@


LAB3=label1="Depth(m)" label2="X Position(m)" label3="Angle(degrees)" title=" "
angle.v3 angle.v: gmage.8.H gtot.H gmage.32.H gmage.127.H
	Window3d < gmage.8.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >a1.V ${LAB3}
	Window3d < gmage.8.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.42 |Cubeplot center=1 frame3=2  >a2.V  ${LAB3}
	< b1.H Grey eout=1 gainpanel=a clip=.042 |Cubeplot center=1 frame3=2  >a3.V ${LAB3}
	Window3d < gmage.32.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >b1.V ${LAB3}
	Window3d < gmage.32.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.42 |Cubeplot center=1 frame3=2  >b2.V  ${LAB3}
	< b1.H Grey eout=1 gainpanel=a clip=.042 |Cubeplot center=1 frame3=2  >b3.V ${LAB3}
	Window3d < gmage.128.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >c1.V ${LAB3}
	Window3d < gmage.128.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.42 |Cubeplot center=1 frame3=2  >c2.V  ${LAB3}
	< b1.H Grey eout=1 gainpanel=a clip=.042 |Cubeplot center=1 frame3=2  >c3.V ${LAB3}
	Vppen gridnum a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V out=angle.v3  >c.V vpstyle=n
	Vppen gridnum a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V out=angle.v gridnum=3,3  >c.V vpstyle=n 

ang.v3 ang.v: nmage.256.H gtot.H nmage.1024.H nmage.2048.H
	Window3d < nmage.256.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >a1.V ${LAB3}
	Window3d < nmage.256.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.42 |Cubeplot center=1 frame3=2  >a2.V  ${LAB3}
	< b1.H Grey eout=1 gainpanel=a clip=.042 |Cubeplot center=1 frame3=2  >a3.V ${LAB3}
	Window3d < nmage.1024.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >b1.V ${LAB3}
	Window3d < nmage.1024.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.42 |Cubeplot center=1 frame3=2  >b2.V  ${LAB3}
	< b1.H Grey eout=1 gainpanel=a clip=.042 |Cubeplot center=1 frame3=2  >b3.V ${LAB3}
	Window3d < nmage.2048.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >c1.V ${LAB3}
	Window3d < nmage.2048.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.42 |Cubeplot center=1 frame3=2  >c2.V  ${LAB3}
	< b1.H Grey eout=1 gainpanel=a clip=.042 |Cubeplot center=1 frame3=2  >c3.V ${LAB3}
	Vppen gridnum a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V out=ang.v3  >c.V vpstyle=n
	Vppen gridnum a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V out=ang.v gridnum=3,3  >c.V vpstyle=n 




gmage.%.v3 gmage.%.v: gmage.%.H gtot.H
	Window3d < gmage.$*.H |Transp plane=23 |Grey eout=1 gainpanel=a |Cubeplot center=1 frame3=2  >a1.V
	Window3d < gmage.$*.H |Transp plane=23|Scale >a1.H
	Window3d < gtot.H |Transp plane=23|Scale >a2.H
	Add scale=1,-1 a1.H a2.H >b1.H
	< b1.H Grey eout=1 gainpanel=a clip=.38 |Cubeplot center=1 frame3=2  >a2.V
	< b1.H Grey eout=1 gainpanel=a clip=.038 |Cubeplot center=1 frame3=2  >a3.V
	Vppen gridnum a1.V a2.V a3.V out=gmage.$*.v3  >c.V vpstyle=n
	Vppen gridnum a1.V a2.V a3.V out=gmage.$*.v gridnum=3,1  >c.V vpstyle=n
	

image_tot.H: marm.bfreq.H  ${BINDIR}/S_G_wem.x sref.H scale.x
	${BINDIR}/S_G_wem.x Data=marm.bfreq.H S=marmvel.H ref_slow=sref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=$@    nzb=1 npad_x=0 maxang=60. npad_mx=12 az__n=251 npad_hx=10

try.H:  input_cam_test.H S_G_wem.x new_vel.H
	Window3d < new_vel.H >vel.H j3=5 j2=4 j1=4 n3=200
	Lloyd_vel < vel.H >sref.H
#	${BINDIR}/S_G_wem.x Data=input_cam_test.H S=vel.H ref_slow=sref.H az__o=0 az__d=25 az__n=200 verb=y nw_tot=104 nzb=1 R=a1.H  npad_x=0 maxang=60. npad_mx=12  npad_hx=10 nzb=20
	${BINDIR}/S_G_wem.x Data=input_cam_test.H S=vel.H ref_slow=sref.H az__o=0 az__d=25 az__n=200 verb=y nw_tot=104 nzb=1 R=a2.H  npad_x=0 maxang=60. npad_mx=12  npad_hx=10 nzb=20 wem_type=CAM


	

mmage.%.H:  marm.bfreq.H ${BINDIR}/S_G_wem_scale.x sref.H scale.x
	${BINDIR}/scale.x < marm.bfreq.H >a.H mx=$*
	${BINDIR}/S_G_wem_scale.x Data=a.H S=marmvel.H ref_slow=sref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=$@    nzb=1 npad_x=0 maxang=60. npad_mx=12 az__n=251 npad_hx=10 sfact=1.

pmage.%.H:  marm.bfreq.H ${BINDIR}/S_G_wem_scale.x sref.H scale.x
	${BINDIR}/scale.x < marm.bfreq.H >a.H mx=$*
	${BINDIR}/S_G_wem_scale.x Data=a.H S=marmvel.H ref_slow=sref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=$@    nzb=1 npad_x=0 maxang=60. npad_mx=12 az__n=251 npad_hx=10 sfact=10.

fmage.%.H:  marm.bfreq.H ${BINDIR}/S_G_wem_scale.x sref.H scale.x
	${BINDIR}/scale.x < marm.bfreq.H >a.H mx=$*
	${BINDIR}/S_G_wem_scale.x Data=a.H S=marmvel.H ref_slow=sref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=$@    nzb=1 npad_x=0 maxang=60. npad_mx=12 az__n=251 npad_hx=10

mzero.%.H: mmage.%.H
	Window3d < mmage.$*.H  min3=0 |Transp>$@

pzero.%.H: pmage.%.H
	Window3d < pmage.$*.H  min3=0 |Transp>$@

fzero.%.H: fmage.%.H
	Window3d < fmage.$*.H  min3=0 |Transp>$@

cor.H: image_tot.H
	Window3d < image_tot.H min3=0 n3=1 |Transp >$@

LABS=label1="Depth(m)" label2="X Position(m)" title=" "
fzero.%.v3 fzero.%.v: fzero.%.H cor.H
	Grey < fzero.$*.H  >a1.V ${LABS}
	Scale < fzero.$*.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a3.V clip=.038
	Vppen gridnum=3,1 a1.V a2.V a3.V out=fzero.$*.v vpstyle=n
	Vppen  a1.V a2.V a3.V out=fzero.$*.v3 vpstyle=n

bitinput.v bitinput.v3: fzero.4.H fzero.16.H fzero.64.H cor.H
	Grey < fzero.4.H  >a1.V ${LABS}
	Scale < fzero.4.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a3.V clip=.038
	Grey < fzero.16.H  >b1.V ${LABS}
	Scale < fzero.16.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >b2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >b3.V clip=.038
	Grey < fzero.64.H  >c1.V ${LABS}
	Scale < fzero.64.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >c2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >c3.V clip=.038
	Vppen gridnum=3,3 a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V out=bitinput.v vpstyle=n
	Vppen  a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V out=bitinput.v3 vpstyle=n


pzero.%.v3 pzero.%.v: pzero.%.H cor.H
	Grey < pzero.$*.H  >a1.V ${LABS}
	Scale < pzero.$*.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a3.V clip=.038
	Vppen gridnum=3,1 a1.V a2.V a3.V out=pzero.$*.v vpstyle=n
	Vppen  a1.V a2.V a3.V out=pzero.$*.v3 vpstyle=n

mzero.%.v3 mzero.%.v: mzero.%.H cor.H
	Grey < mzero.$*.H  >a1.V ${LABS}
	Scale < mzero.$*.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a3.V clip=.038
	Vppen gridnum=3,1 a1.V a2.V a3.V out=mzero.$*.v vpstyle=n yscale=3
	Vppen  a1.V a2.V a3.V out=mzero.$*.v3 vpstyle=n

ints.v3 ints.v: mzero.32.H cor.H mzero.128.H mzero.256.H
	Grey < mzero.32.H  >a1.V ${LABS}
	Scale < mzero.32.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >a3.V clip=.038
	Grey < mzero.128.H  >b1.V ${LABS}
	Scale < mzero.128.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >b2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >b3.V clip=.038
	Grey < mzero.256.H  >c1.V ${LABS}
	Scale < mzero.256.H >a2.H
	Scale < cor.H >a3.H
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >c2.V clip=.38
	Add scale=1,-1 a2.H a3.H |Grey ${LABS} >c3.V clip=.038
	Vppen gridnum=3,3 a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V >a.V out=ints.v vpstyle=n 
	Vppen  a1.V a2.V a3.V b1.V b2.V b3.V c1.V c2.V c3.V >a.V out=ints.v3 vpstyle=n 




image.%.H:  marm.freq.H ${BINDIR}/S_G_wem.x sref.H scale.x
	${BINDIR}/scale.x < marm.freq.H >a.H mx=$*
	${BINDIR}/S_G_wem.x Data=a.H S=marmvel.H ref_slow=sref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=$@    nzb=1 npad_x=0 maxang=60 npad_x=12

image.H:  marm.freq.H ${BINDIR}/S_G_wem.x sref.H
	${BINDIR}/S_G_wem.x Data=marm.freq.H S=marmvel.H ref_slow=sref.H az__o=0 az__d=12 az__n=25 verb=y nw_tot=35 nzb=50 R=$@    nzb=1  az__n=251
#	${BINDIR}/S_G_wem.x Data=a.H S=vel.H ref_slow=sref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=image.small.H    nzb=1 npad_x=0 maxang=60 npad_x=12

img.H:   ${BINDIR}/S_G_wem.x
	Spike n2=512 o2=2500 d2=12.5  o1=0 d1=.008 n1=512 >t.H k1=300 k2=256
	Transf < t.H is2d=y >freq.H f_min=3 f_max=25
	Spike n1=700 o1=0 d1=12.5 d3=12 o3=0 n3=251 mag=2000 >v.H
	Lloyd_vel < v.H >ref.H
	${BINDIR}/S_G_wem.x Data=freq.H S=v.H ref_slow=ref.H az__o=0 az__d=12 az__n=251 verb=y nw_tot=35 nzb=50 R=i.H    nzb=1 npad_x=16
	Window3d < i.H |Transp >$@

sref.datum.H: vel_datum_10.H
	Cp vel_datum_10.H vel.datum.H
	Lloyd_vel < vel.datum.H >$@

input.H:
	Transf <input_infill_cmps_sub4_zoffs_w.H >a.H wei=y
	Transf < a.H >$@ f_min=3 f_max=55
	Cp input_infill_cmps_sub4_zoffs_w.H $@
	



datum.H:  marm.freq.H ${BINDIR}/S_G_datum.x sref.datum.H input.H
#	${BINDIR}/S_G_datum.x Data=input_cmps_zoffs_w.H S=vel.datum.H ref_slow=sref.datum.H az__o=0 az__d=50 az__n=10 verb=y nw_tot=35 nzb=50 Ddown=$@    nzb=1 
	${BINDIR}/S_G_datum.x Data=input.H S=vel.datum.H ref_slow=sref.datum.H az__o=0 az__d=50 az__n=10 verb=y nw_tot=35 nzb=50 Ddown=$@    nzb=1  npad_x=12

sref.3d.H: elfvel.H
	Window3d < elfvel.H  >vel.3d.H
	Lloyd_vel < vel.3d.H  >$@ nref=5

image.3d.H:  elf.freq.H ${BINDIR}/S_G_wem.x sref.3d.H
	${BINDIR}/S_G_wem.x Data=elf.freq.H S=vel.3d.H ref_slow=sref.3d.H az__o=0 az__d=30 az__n=2 verb=y nw_tot=35 nzb=1 R=$@   npad_x=16

image2.H:  marm.freq.H /net/koko/homes/sep/bob/Src/old_wei/wei_sg/Phase.x sref.H
	/net/koko/homes/sep/bob/Src/old_wei/wei_sg/Phase.x D=marm.freq.H S=vel.H schoice=sref.H az__o=0 az__d=30 az__n=10 verb=y nw_tot=35 R=$@ adj=y \
amx_n=512        amx_o=2100       amx_d=12.5        label1=\
amy_n=1          amy_o=0          amy_d=1           label2=\
ahx_n=1         ahx_o=0       ahx_d=1.          label3=\
ahy_n=1          ahy_o=0          ahy_d=1           label4=\
aw__n=73         aw__o=1.72414    aw__d=0.344828    label5=Frequency\
velocity=y



include ${SEPINC}/SEP.bottom
