MAKE_DEPEND=yes

#include /opt/SEP/SEP6.4.6/include/SEP.top
################# To run in gomorrah  ####################
#include /usr/local/share/make/SEP.top
##########################################################
include ${SEPINC}/SEP.top

#LATOPTS  = style=html
##LATOPTS = option=web 'style=jfc,makeidx,html,amsmath'
##LATOPTS=class=geophysics
#SIGDIR = /mnt/sepdata/1a/sigsbee_multiple
#OLEVEL=2
##UF90FLAGS =-mp -check bounds -O3
##UF90FLAGS =-parallel -g -openmp -openmp_report2  -O3 -axW -vec_report3 -C #-check bounds 
#UF90FLAGS =-O3 -C 
##UF90FLAGS =-parallel -openmp -openmp_report2  -O3 -axW -vec_report3
##UF90FLAGS =-parallel -openmp -openmp_report2 -axW -vec_report3
#MAINLIBS=-lsep2df90 -lsep3df90 -lsep3d -lsepf90 -lsep -L${LIBDIR}  -lsepgeef90
#UF77LIBS = ${BEILIB}

##WHEREFFTW = /usr/local/FFTW/FFT3_INTEL/lib/libfftw3f.a
##UF90LIBS=${MPILIBS} ${MAINLIBS} -lsepparf90 -lseppar_mpi -lsepgeef90 -lsep2df90 -static-libcxa -lguide -lseppar  -lsuperset -lsupersetf90 -#lsuperset -lsepauxf90 -lsepmathf90 -lsep3df90 -lsep3d -lsepf90 -lsep $(WHEREFFTW)

#WHEREFFTW = /net/koko/linux_local/FFTW/FFTW2/lib/lib
#UF90LIBS=${MPILIBS} ${MAINLIBS} -lsepparf90 -lseppar_mpi -lsepgeef90 -lsep2df90 -static-libcxa -lguide -lseppar  -lsuperset -lsupersetf90 -lsuperset -lsepauxf90 -lsepmathf90 -lsep3df90 -lsep3d -lsepf90 -lsep $(WHEREFFTW)fftw.a $(WHEREFFTW)rfftw.a #-Bstatic
#
# To run in gomorrah
#
##WHEREFFTW = /opt/FFTW/fftw-3.1.2/libbench2/libbench2.a

#COLOR=y

############################################################################


LATOPTS  = style=html
#LATOPTS = option=web 'style=jfc,makeidx,html,amsmath'
#LATOPTS=class=geophysics
SIGDIR = /data/sigsbee_multiple
OLEVEL=2
UF90FLAGS =-openmp -openmp_report2 -check bounds -O3
MAINLIBS=-lsep2df90 -lsep3df90 -lsep3d -lsepf90 -lsep -L${LIBDIR}  -lsepgeef90
UF77LIBS = ${BEILIB}
UF90DEFINES = -DSEP_OMP

#
# 64bit
#
WHEREFFTW = /opt/FFTW/lib/lib
UF90LIBS=${MPILIBS} ${MAINLIBS} -lsepparf90 -lsepgeef90 -lsep2df90 -static-libcxa -lguide -lseppar  -lsuperset -lsupersetf90 -lsuperset -lsepauxf90 -lsepmathf90 -lsep3df90 -lsep3d -lsepf90 -lsep $(WHEREFFTW)fftw3f.a #$(WHEREFFTW)rfftw.a # -lseppar_mpi

F90=/opt/intel/fce/10.0.023/bin/ifort

############################################################################
RESULTSER = geo0 geo45 geo45t
RESULTSNR = sodcig

BIN=./bin
PAR=./par
RESDIR=./fig
FIG=./fig
DATA=./data
SRCDIR=./src

#UF90FLAGS=-O1

##############################
#
# Programs
#
cmpx: complexo.x
	rm -f ${BIN}/complexo.x;rm -f complexo.x;make complexo.x
	mv -f complexo.x ${BIN}/complexo.x

wderiv:wderiv.x
	rm -f ${BIN}/wderiv.x;rm -f wderiv.x;make wderiv.x
	mv -f wderiv.x ${BIN}/wderiv.x

a2b:a2bmeu.x
	rm -f ${BIN}/a2bmeu.x;rm -f a2bmeu.x;make a2bmeu.x
	mv -f a2bmeu.x ${BIN}/a2bmeu.x

sod2adcig:sod2adcig.x
	rm -f ${BIN}/sod2adcig.x;rm -f sod2adcig.x;make sod2adcig.x
	mv -f sod2adcig.x ${BIN}/sod2adcig.x

rtmpw:rtm_SO_pw.x
	rm -f ${BIN}/rtm_SO_pw.x;rm -f rtm_SO_pw.x;make rtm_SO_pw.x
	mv -f rtm_SO_pw.x ${BIN}/rtm_SO_pw.x

rtm: rtm.x
	rm -f ${BIN}/rtm.x;rm -f rtm.x;make rtm.x
	mv -f rtm.x ${BIN}/rtm.x

rtm2: rtm2.x
	rm -f ${BIN}/rtm2.x;rm -f rtm2.x;make rtm2.x
	mv -f rtm2.x ${BIN}/rtm2.x

rtmso: rtm_SO.x
	rm -f ${BIN}/rtm_SO.x;rm -f rtm_SO.x;make rtm_SO.x
	mv -f rtm_SO.x ${BIN}/rtm_SO.x

rtmso1: rtm_SO1.x
	rm -f ${BIN}/rtm_SO1.x;rm -f rtm_SO1.x;make rtm_SO1.x
	mv -f rtm_SO1.x ${BIN}/rtm_SO1.x

rtmsh: rtm_shot.x
	rm -f ${BIN}/rtm_shot.x;rm -f rtm_shot.x;make rtm_shot.x
	mv -f rtm_shot.x ${BIN}/rtm_shot.x

rtmill:
	rm -f ${BIN}/rtm_illu.x;rm -f rtm_illu.x;make rtm_illu.x
	mv -f rtm_illu.x ${BIN}/rtm_illu.x

fdmod:
	rm -f ${BIN}/fdmod2d.x;rm -f fdmod2d.x;make fdmod2d.x
	mv -f fdmod2d.x ${BIN}/fdmod2d.x

mute:
	rm -f ${BIN}/mute.x;rm -f mute.x;make mute.x
	mv -f mute.x ${BIN}/mute.x

mute1:
	rm -f ${BIN}/mute1.x;rm -f mute1.x;make mute1.x
	mv -f mute1.x ${BIN}/mute1.x
##############################
#
# Playing with fft
#
fftest: fftest.x
	rm -f ${BIN}/fftest.x;rm -f fftest.x;make fftest.x
	mv -f fftest.x ${BIN}/fftest.x

vspflt.H:
	${BIN}/fftest.x <vsp.H > $@

greenflt.H:
#	<greensinvel.H Transp reshape=2,3 plane=12 > tempgreen.H
	<tempgreen.H ${BIN}/fftest.x > $@

################################
#
# Wderiv
#
tandip.H:
	<j1.H Window3d n3=1 min3=1 | ${BIN}/wderiv.x eps=0 0.00000000000000001 > $@


################################
#
#
#
#sig_shot.H:
teste_sig.H:
#	Vel n1=1250 n2=5000 n3=1 o1=0 o2=0 o3=0 d1=4 d2=4 d3=1 vc=1 xa1=0 z1=0 alfa1=30 vr1=2 za2=0 z2=20 vr2=1 alfa2=30 const1=1 const2=1 > den2.H
#	Vel n1=1250 n2=5000 n3=1 o1=0 o2=0 o3=0 d1=4 d2=4 d3=1 vc=1 xa1=0 z1=2500 vr1=1.1 xa2=0 z2=2520 vr2=1 const1=1 const2=1 > den1.H
#	Math file1=den1.H file2=den2.H exp="file1+file2" > den3.H
#	< den3.H Scale dclip=1 >den.H
#	Vel n1=1250 n2=5000 n3=1 o1=0 o2=0 o3=0 d1=4 d2=4 d3=1 vc=2500 > vel.H
#	Pad <sigsbee2b_strati_pad.H end1=300 extend=1 |Interp type=1 d2out=25 > sigsbee2b_strati_2pad.H
#	Pad < ../2Wpar/data/sigsb2a.stratigraphy.H end1=300 beg2=1000 end2=1000 extend=1 | Interp type=1 d2out=25 maxsize=1000 > \
#	sigsbee2b_strati_2pad.H
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=10975 dxs=300 nxs=1 tmax=8.5 bx=1000 ex=1000 hsfile=temp11.H
	Bandpass flo=5 fhi=50 < temp11.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 > $@

sig1.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=10000 dxs=150 nxs=100 tmax=8.5 bx=1000 ex=1000 hsfile=temp11.H
	Bandpass flo=5 fhi=50 < temp11.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@

sig2.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=25000 dxs=150 nxs=100 tmax=8.5 bx=1000 ex=1000 hsfile=temp12.H
	Bandpass flo=5 fhi=50 < temp12.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@

sig3.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=40000 dxs=150 nxs=100 tmax=8.5 bx=1000 ex=1000 hsfile=temp13.H
	Bandpass flo=5 fhi=50 < temp13.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@

sig4.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=55000 dxs=150 nxs=100 tmax=8.5 bx=1000 ex=1000 hsfile=temp14.H
	Bandpass flo=5 fhi=50 < temp14.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@

sig5.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=55000 dxs=150 nxs=100 tmax=8.5 bx=1000 ex=1000 hsfile=temp15.H
	Bandpass flo=5 fhi=50 < temp15.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@

sig1a.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=23800 dxs=150 nxs=4 tmax=8.5 bx=1000 ex=1000 hsfile=temp11a.H
	Bandpass flo=5 fhi=50 < temp11a.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@ &

sig2a.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=38800 dxs=150 nxs=4 tmax=8.5 bx=1000 ex=1000 hsfile=temp12a.H
	Bandpass flo=5 fhi=50 < temp12a.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@ &

sig3a.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=53800 dxs=300 nxs=4 tmax=8.5 bx=1000 ex=1000 hsfile=temp13a.H
	Bandpass flo=5 fhi=50 < temp13a.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@ &

sig4a.H:
	Fdmod intag=sigsbee2b_strati_2pad.H no_stdout=1 oxs=68800 dxs=300 nxs=4 tmax=8.5 bx=1000 ex=1000 hsfile=temp14a.H
	Bandpass flo=5 fhi=50 < temp14a.H | Mute vmute=4500 tmute=1.4 |Window3d j1=10 j2=6 > $@ &

sigsb_shot.H:
	Window3d <sig3a.H n3=3 f3=1 >z.H
	Cat sig1.H sig1a.H sig2.H sig2a.H sig3.H z.H sig4.H sig4a.H > $@

sig_shot_prep.H:sig_shot.H
	< sig_shot.H Window3d j2=2 | /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=3 f_min1=5 f_max1=32 f_max=40 maxsize=1000 > j2.H
	< j2.H Transp reshape=1,3,5 plane=23 | Pad beg1=200 end1=200 > $@

sig_sou_mig.H:sig_sou.H
	echo o1=-0.12517 >> sig_sou.H; Pad <sig_sou.H beg1=452 end1=452 | /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=3 f_min1=5 f_max1=32 f_max=40 maxsize=1000 > j2.H
	<j2.H Transp plane=35 > $@

sig_velmig.H:
	<vel_pad.H Window3d j2=2 j1=2| Transp reshape=1,3 plane=12 |Transp plane=13 > $@
 
sig_shot_mig.H:
	@date
	/net/koko/homes/sep/alejandro/research/SPWEI_SERIAL/bin/LINUX/ShotMig D=sig_shot_prep.H D_d=sig_sou_mig.H V=sig_velmig.H R=$@  \
	pverb=2 nx_shots=12 ox_shots=0 \
	par=sigmig_go.P taper=y taper_pcent=2 marine=y minx=-56250 maxx=105705 & #restart=y

################################
#
#
#
rot1_shot1.H:
	Vel n1=1250 n2=5000 n3=1 o1=0 o2=0 o3=0 d1=4 d2=4 d3=1 vc=1 xa1=0 z1=0 alfa1=30 vr1=2 za2=0 z2=20 vr2=1 alfa2=30 const1=1 const2=1 > den2.H
	Vel n1=1250 n2=5000 n3=1 o1=0 o2=0 o3=0 d1=4 d2=4 d3=1 vc=1 xa1=0 z1=2500 vr1=1.1 xa2=0 z2=2520 vr2=1 const1=1 const2=1 > den1.H
	Math file1=den1.H file2=den2.H exp="file1+file2" > den3.H
	< den3.H Scale dclip=1 >den.H
	Vel n1=1250 n2=5000 n3=1 o1=0 o2=0 o3=0 d1=4 d2=4 d3=1 vc=2500 > vel.H
	Fdmod intag=vel.H dfile=den.H no_stdout=1 oxs=0 dxs=20 nxs=101 tmax=5 bx=0 ex=2000 hsfile=temp11.H
	Bandpass flo=5 fhi=32 < temp11.H | Mute vmute=2500 tmute=.2 > temp21.H; < temp21.H Window j2=5 j1=10 > $@

rot1_shot2.H:
	Fdmod intag=vel.H dfile=den.H no_stdout=1 oxs=2020 dxs=20 nxs=100 tmax=5 bx=0 ex=2000 hsfile=temp12.H
	Bandpass flo=5 fhi=32 < temp12.H | Mute vmute=2500 tmute=.2 > temp22.H; < temp22.H Window j2=5 j1=10 > $@

rot1_shot3.H:
	Fdmod intag=vel.H dfile=den.H no_stdout=1 oxs=4020 dxs=20 nxs=100 tmax=5 bx=0 ex=2000 hsfile=temp13.H
	Bandpass flo=5 fhi=32 < temp13.H | Mute vmute=2500 tmute=.2 > temp23.H; < temp23.H Window j2=5 j1=10 > $@

# mv shot_rot1.H rot1_shot.H 

rot1_vel.H:
	Window3d <vel.H j1=3 j2=5 | Pad beg2=500 end2=0 extend=1 > j1.H
	Transp reshape=1,3 plane=12 < j1.H > $@

rot1_vello.H:
	Math file1=vel.H exp="file1*0.+2375." >j1.H
	Window3d <j1.H j1=3 j2=5 | Pad beg2=500 end2=0 extend=1 > j2.H
	Transp reshape=1,3 plane=12 < j2.H > $@

rot1_velhi.H:
	Math file1=vel.H exp="file1*0.+2625." >j1.H
	Window3d <j1.H j1=3 j2=5 | Pad beg2=500 end2=0 extend=1 > j2.H
	Transp reshape=1,3 plane=12 < j2.H > $@

rot1_prep.H:rot1_shot.H
#	< rot1_shot.H /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=3 f_min1=5 f_max1=32 f_max=40 maxsize=1000 > j2.H
	< rot1_shot_noOD.H Pad n1out=2001| /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=3 f_min1=5 f_max1=32 f_max=40 maxsize=1000 > j2.H
	< j2.H Transp reshape=1,3,5 plane=23 | Pad beg1=250 end1=250 > $@

rot1_sou.H:
	Window3d < temp12.H n3=1 min3=4000 n2=1 min2=1000 max1=1 | Bandpass flo=5 fhi=32 nplo=3 nphi=3 | Pad n1out=6211 | Window j2=5 j1=10 | Pad n1out=2001 > j1.H ; echo o1=-.392 >> j1.H
	< j1.H /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=3 f_min1=5 f_max1=32 f_max=40 maxsize=1000 > j2.H 
	< j2.H Transp reshape=1,3,5 plane=23 > $@

#rot1_mig.H: rot1_prep.H
#	@date
#	nohup Parallel command=/net/koko/homes/sep/alejandro/research/SPWEI_SERIAL/bin/LINUX/ShotMig files="rot1_prep.H,rot1_sou.H,rot1_vello.H,$@" \
#	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=201 axis=4,4,4,6 pverb=2  \
#	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
#	nx_shots=201 ox_shots=0 \
#	par=rot1_go_sis.P taper=y taper_pcent=2 marine=y minx=-2500 maxx=12000 & #restart=y

#	nohup Parallel command=/net/koko/homes/sep/alejandro/research/SPWEI_SERIAL/bin/LINUX/ShotMig files="rot1_prep.H,rot1_sou.H,rot1_vello.H,$@" \

rot1_prep2.H:
	Window3d squeeze=n max1=13000 min1=-5000 <rot1_prep.H >$@

rot1_miglo.H:
	@date
	nohup Parallel command=/net/koko/claudio/Research/Off2ang/ShotMigNew files="rot1_prep2.H,rot1_sou.H,rot1_vello.H,$@" \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=301 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=301 ox_shots=0 \
	par=rot1_go_sis.P taper=y taper_pcent=2 marine=y minx=-2500 maxx=19500 #restart=y

rot1_mighi.H:
	@date
	nohup Parallel command=/net/koko/claudio/Research/Off2ang/ShotMigNew files="rot1_prep2.H,rot1_sou.H,rot1_velhi.H,$@" \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=301 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=301 ox_shots=0 \
	par=rot1_go_sis.P taper=y taper_pcent=2 marine=y minx=-2500 maxx=19500 #restart=y

#rot1_miglo.H:
#	@date
#	/net/koko/homes/sep/alejandro/research/SPWEI_SERIAL/bin/LINUX/ShotMig D=rot1_prep.H D_d=rot1_sou.H V=rot1_vello.H R=$@  \
#	pverb=2 nx_shots=301 ox_shots=0 \
#	par=rot1_go_sis.P taper=y taper_pcent=2 marine=y minx=-2500 maxx=16000 & #restart=y

rot1_mig.H:
	@date
	/net/koko/homes/sep/alejandro/research/SPWEI_SERIAL/bin/LINUX/ShotMig D=rot1_prep.H D_d=rot1_sou.H V=rot1_vel.H R=$@  \
	pverb=2 nx_shots=301 ox_shots=0 \
	par=rot1_go_sis.P taper=y taper_pcent=2 marine=y minx=-2500 maxx=16000 & #restart=y

####################
#
# GaussVel
#
shgauss.H:
	Interp type=1 d1out=5 d2out=5 <velgauss.H >velgauss_interp5x5.H
	Fdmod intag=velgauss_interp5x5.H no_stdout=1 oxs=3000 dxs=5 nxs=1 tmax=2 bx=600 ex=600 hsfile=tgauss.H
#	Bandpass flo=5 fhi=32 < tgauss.H < temp21.H Window j2=5 j1=10 > $@


################################
#
# CIG Rotation
#
sogrot: sodcig_rot.x
	rm -f ${BIN}/sodcig_rot.x;rm -f sodcig_rot.x;make sodcig_rot.x
	mv -f sodcig_rot.x ${BIN}/sodcig_rot.x

teste: teste_main.x
	rm -f ${BIN}/teste_main.x;rm -f teste_main.x;make teste_main.x
	mv -f teste_main.x ${BIN}/teste_main.x

sogrot4: sodcig4_rot.x
	rm -f ${BIN}/sodcig4_rot.x;rm -f sodcig4_rot.x;make sodcig4_rot.x
	mv -f sodcig4_rot.x ${BIN}/sodcig4_rot.x

sogor: sodcig_rot_orig.x
	rm -f ${BIN}/sodcig_rot_orig.x;rm -f sodcig_rot_orig.x;make sodcig_rot_orig.x
	mv -f sodcig_rot_orig.x ${BIN}/sodcig_rot_orig.x

rotsog: rot_sog.x
	rm -f ${BIN}/rot_sog.x;rm -f rot_sog.x;make rot_sog.x
	mv -f rot_sog.x ${BIN}/rot_sog.x
#####
#
# Diagnostics
#
sogfft: sodcig_rot_fft.x
	rm -f ${BIN}/sodcig_rot_fft.x;rm -f sodcig_rot_fft.x;make sodcig_rot_fft.x
	mv -f sodcig_rot_fft.x ${BIN}/sodcig_rot_fft.x

xxx:
	< sism2.H Pad beg2=140 end2=141 beg3=80 end3=81 end1=101 > jjj.H; echo o3=-800 >> jjj.H
#	< jjj.H ${BIN}/sodcig_rot_fft.x Rot_s_cig=Rot_s_cig1.H npadz=00 npadh=00 npadx=00 test_fft=1 > /dev/null
	< jjj.H ${BIN}/sodcig_rot_fft.x Rot_s_cig=Rot_s_cig2.H npadz=00 npadh=00 npadx=00 test_fft=2 > /dev/null
#	< jjj.H ${BIN}/sodcig_rot_fft.x Rot_s_cig=Rot_s_cig3.H npadz=00 npadh=00 npadx=00 test_fft=3 > /dev/null

xxx1:
	< sism2.H Pad beg2=121 end2=120 beg3=50 end3=51 end1=101 |${BIN}/sodcig_rot_fft.x Rot_s_cig=Rot_s_cig1.H npadz=0 npadh=0 npadx=0 test_fft=1 > /dev/null
	< sism2.H Pad beg2=121 end2=120 beg3=50 end3=51 end1=101 |${BIN}/sodcig_rot_fft.x Rot_s_cig=Rot_s_cig2.H npadz=0 npadh=0 npadx=0 test_fft=2 > /dev/null
	< sism2.H Pad beg2=121 end2=120 beg3=50 end3=51 end1=101 |${BIN}/sodcig_rot_fft.x Rot_s_cig=Rot_s_cig3.H npadz=0 npadh=0 npadx=0 test_fft=3 > /dev/null

kwrite: kwrite.x
	rm -f ${BIN}/kwrite.x;rm -f kwrite.x;make kwrite.x
	mv -f kwrite.x ${BIN}/kwrite.x

sism.H:
	${BIN}/kwrite.x 1 > jjj.H; < jjj.H Bandpass flo=.001 fhi=.005 > $@
#	${BIN}/kwrite.x 1 > $@

sism1.H:
	${BIN}/kwrite.x 1 > jjj.H; < jjj.H Bandpass flo=.001 fhi=.005 > $@
#	${BIN}/kwrite.x 1 > $@

sism2.H:
	${BIN}/kwrite.x 1 > jjj.H; < jjj.H Bandpass flo=.001 fhi=.005 > $@
#	${BIN}/kwrite.x 1 > $@

sism3.H:
	${BIN}/kwrite.x 1 > jjj.H; < jjj.H Bandpass flo=.001 fhi=.005 > $@

sism4.H:
	${BIN}/kwrite.x 1 > jjj.H; < jjj.H Bandpass flo=.001 fhi=.005 > $@

sism1_ang.H:
	< sism1.H ../../Off2ang/Yaxun/Bin/LINUX/off2ang_sd.x style=1 > $@

test01:
#	Window3d max1=3000 max2=210 <sism.H >sisma.H
#	< sisma.H ${BIN}/sodcig_rot.x >$@
	< /homes/sep/claudio/Research/Ill_ADCIG/001-ODCIG.H ${BIN}/sodcig_rot.x Rot_s_cig=test_01_Rot.H test_fft=y npadz=100 npadh=100 npadx=100 > /dev/null

yyy:
	< sism1.H ${BIN}/sodcig_rot_orig.x Rot_s_cig=Rot_s_cig.H Rot_g_cig=Rot_g_cig.H npadz=100 npadh=100 npadx=100 test_fft= y > /dev/null

ttt:
#	< sism4.H Pad beg2=0 end2=121 beg3=0 end3=241 > jjj.H
#	< sism4.H Pad beg2=121 end2=0 beg3=0 end3=241 > jjj.H
#	< xxx.H Pad beg2=40 end2=41 beg3=40 end3=40 end1= 101 > jjj.H
#	< sism2.H Transp plane=23 | Window3d squeeze=n n2=1 min2=0 | Pad beg2=60 end2=61 beg3=50 end3=51 end1=51 > jjj.H; echo o2=-600 o3=-900 >> #jjj.H
	< sism4.H ${BIN}/sodcig_rot.x Ccig=Ccig.H Rot_s_cig=Rot_s_cig.H Rot_g_cig=Rot_g_cig.H npadz=0 100 npadh=0 100 npadx=0 100 > /dev/null

ttt1:
#	<  sism2.H Pad end1=101 end2=101 end3=101 | ${BIN}/sodcig_rot.x Ccig=Ccig.H Rot_s_cig=Rot_s_temp.H Rot_g_cig=Rot_g_temp.H npadz=0 npadh=0 npadx=0 > /dev/null 
#	<  sism2.H Pad end1=1 end2=1 end3=1 | ${BIN}/sodcig_rot.x Ccig=Ccig.H Rot_s_cig=Rot_s_temp.H Rot_g_cig=Rot_g_temp.H npadz=0 npadh=0 npadx=0 !> /dev/null
#	< Rot_s_temp.H Window3d n2=81 n3=181 > Rot_s_cig0.H;< Rot_g_temp.H Window3d n2=81 n3=181 > Rot_g_cig0.H
#	<  sism2.H Pad end1=21 beg2=20 end2=21 beg3=20 end3=21 | Transp plane=23 > jjj.H; echo o2=-1100 >> jjj.H 
	<  sism2.H Pad end1=1 end2=1 end3=1 | Transp plane=23 > jjj.H; echo o2=-900 >> jjj.H 
	<jjj.H ${BIN}/sodcig_rot.x Ccig=Ccig.H Rot_s_cig=Rot_s_temp.H Rot_g_cig=Rot_g_temp.H npadz=0 npadh=0 npadx=0 > /dev/null
#	< sism2.H Transp plane=23 > jjj1.H;echo o2=-900 >> jjj1.H
#	< jjj1.H ${BIN}/sodcig_rot.x Ccig=Ccig.H Rot_s_cig=Rot_s_temp.H Rot_g_cig=Rot_g_temp.H npadz=0 npadh=0 npadx=0 > /dev/null
#	< Rot_s_temp.H Window3d n2=181 n3=81 > Rot_s_cig1.H;< Rot_g_temp.H Window3d n2=181 n3=81 > Rot_g_cig1.H

ttt2:
	< sism2.H Transp plane=23 |Pad beg2=60 end2=61 beg3=50 end3=51 end1=101 > jjj.H; echo o2=-1500. o3=-900 >> jjj.H 
	<jjj.H ${BIN}/sodcig4_rot.x Ccig= Ccig.H Rot_s_cig=Rot_s_cig.H Rot_g_cig=Rot_g_cig.H npadz=0 npadh=0 npadx=0 > /dev/null

ttt3:
	< sism2.H Pad beg2=40 end2=41 beg3=50 end3=51 end1=101 > jjj.H; o3=-500 o2=-800>> jjj.H 
	<jjj.H ${BIN}/sodcig4_rot.x Ccig= Ccig.H Rot_s_cig=Rot_s_cig.H Rot_g_cig=Rot_g_cig.H npadz=0 100 npadh=0 100 npadx=0 100 > /dev/null
#	< sism3.H Transp plane=23 |Pad beg2=60 end2=61 beg3=50 end3=51 end1=101 > jjj.H; echo o2=-1500. o3=-900 >> jjj.H
#	< sism2.H Pad beg2=0 end2=121 beg3=0 end3=321 end1=1 > jjj.H
##	|Pad beg2=0 end2=121 beg3=0 end3=241 > jjj.H;echo o2=-900 >> jjj.H

ttt4:
	<  sism2.H Pad end1=1 end2=1 end3=1 | Transp plane=23 | ${BIN}/teste_main.x Rot_s_cig=Rot_s_temp.H Rot_g_cig=Rot_g_temp.H > /dev/null

vvv:
#	< sism2.H Window3d n3=100 n1=250 min2=-200 max2=200 | Transp plane=23 > jjj.H; echo o2=-900. >> jjj.H 
	< sism2.H Window3d n3=100 n1=250 min2=-200 max2=200 > jjj.H
	<jjj.H ${BIN}/sodcig_rot.x Ccig=Ccig.H Rot_s_cig=Rot_s_cig.H Rot_g_cig=Rot_g_cig.H npadz=0 npadh=0 npadx=0 > /dev/null

uuu:
	<sism2.H ../../Off2ang/Yaxun/Bin/LINUX/off2ang_sd.x style=0 mode=2 niter=10 > sism2_gamma.H
	<sism2.H Transp plane=23 | ../../Off2ang/Yaxun/Bin/LINUX/off2ang_sd.x style=1 > sism2_alpha.H

Rotscig.H:
#	< sism2.H Window3d min2=-400. n2=41 n3=31 n1=300 | Transp plane=23 > jjj.H ;echo o2=-150 >>jjj.H
	< sism2.H Window3d min2=-200. n2=41 n3=41 n1=300 > jjj.H
	<jjj.H ${BIN}/rot_sog.x > $@


################################################
#
# CIGROT figs
# The data were produced in Matlab and converted
# to Seplib format using Nick's' toolbox
#
rot1.v:
	Window3d <rot1.H n3=1 |Grey pclip=100 \
	title='a' label1='Depth(m)' label2='half-offset(m)' \
	screenratio=2 screenht=5 screenwd=2.5 \
	labelsz=1.5 labelfat=n titlesz=2 wantaxis1=y wantaxis2=y \
	o2num=-200 d2num=100.\
	o1num=0 d1num=250.\
	> /dev/null out=junk1.v
	vppen < junk1.v xcenter=-0.5 ycenter=-.5 vpstyle=n > fig/$@


got1.v:
	Window3d <got1.H n3=1 |Grey pclip=100 \
	title='b' label1='Depth(m)' label2='half-offset(m)' \
	screenratio=2 screenht=5 screenwd=2.5 \
	labelsz=1.5 labelfat=n titlesz=2 wantaxis1=n wantaxis2=y \
	o2num=-200 d2num=100.\
	> /dev/null out=junk1.v
	vppen < junk1.v xcenter=-2.5 ycenter=-.5 vpstyle=n > fig/$@

geo0.v:
	vp_Overlay fig/rot1.v fig/got1.v > fig/$@

rot.v:
	Window3d <rot.H n3=1 |Grey pclip=100 \
	title='a' label1='Depth(m)' label2='half-offset(m)' \
	screenratio=2 screenht=5 screenwd=2.5 \
	labelsz=2 labelfat=n titlesz=2 wantaxis1=y wantaxis2=y \
	o2num=-600 d2num=200.\
	o1num=0 d1num=250.\
	> /dev/null out=junk1.v
	vppen < junk1.v xcenter=-0.5 ycenter=-.5 vpstyle=n > fig/$@


got.v:
	Window3d <got.H n3=1 |Grey pclip=100 \
	title='b' label1='Depth(m)' label2='half-offset(m)' \
	screenratio=2 screenht=5 screenwd=2.5 \
	labelsz=2 labelfat=n titlesz=2 wantaxis1=n wantaxis2=y \
	o2num=-600 d2num=200.\
	> /dev/null out=junk1.v
	vppen < junk1.v xcenter=-2.5 ycenter=-.5 vpstyle=n > fig/$@

geo45.v:
	vp_Overlay fig/rot.v fig/got.v > fig/$@

rott.v:
	Window3d <rot.H n3=1 f3=61|Grey pclip=100 \
	title='a' label1='Depth(m)' label2='half-offset(m)' \
	screenratio=2 screenht=5 screenwd=2.5 \
	labelsz=2 labelfat=n titlesz=2 wantaxis1=y wantaxis2=y \
	o2num=-600 d2num=200.\
	o1num=0 d1num=250.\
	> /dev/null out=junk1.v
	vppen < junk1.v xcenter=-0.5 ycenter=-.5 vpstyle=n > fig/$@


gott.v:
	Window3d <got.H n3=1 f3=61|Grey pclip=100 \
	title='b' label1='Depth(m)' label2='half-offset(m)' \
	screenratio=2 screenht=5 screenwd=2.5 \
	labelsz=2 labelfat=n titlesz=2 wantaxis1=n wantaxis2=y \
	o2num=-600 d2num=200.\
	> /dev/null out=junk1.v
	vppen < junk1.v xcenter=-2.5 ycenter=-.5 vpstyle=n > fig/$@

geo45t.v:
	vp_Overlay fig/rott.v fig/gott.v > fig/$@
################################
#
# Adcig
#
mmm:
	<sism2.H  Pad beg2=121 end2=120 beg3=50 end3=51 end1=51 | ${BIN}/sod2adcig.x npadz=0 npadh=0 npadx=0 > /dev/null

mmm1:
	< sism2.H Transp plane=23 |Pad beg2=60 end2=61 beg3=50 end3=51 end1=101 > jjj.H; echo o2=-1500. o3=-900 >> jjj.H ;
	< jjj.H  ${BIN}/sod2adcig.x npadz=0 npadh=0 npadx=0 adcig=adcig.H nang=141 > /dev/null

#########################################
################################
#
# KxKh filter
#
kxkh: kxkh_flt.x
	rm -f ${BIN}/kxkh_flt.x;rm -f kxkh_flt.x;make kxkh_flt.x
	mv -f kxkh_flt.x ${BIN}/kxkh_flt.x

kfilt: kfilt.x
	rm -f ${BIN}/kfilt.x;rm -f kfilt.x;make kfilt.x
	mv -f kfilt.x ${BIN}/kfilt.x

kxkh2: kxkh_flt2.x
	rm -f ${BIN}/kxkh_flt2.x;rm -f kxkh_flt2.x;make kxkh_flt2.x
	mv -f kxkh_flt2.x ${BIN}/kxkh_flt2.x

zzz:
	< /homes/sep/claudio/Research/Ill_ADCIG/001-ODCIG.H ${BIN}/kxkh_flt.x Rot_s_cig=sig_01_flt.H apply=n npadz=100 npadh=100 npadx=100 khflt1=-0.05 kxflt1=-0.05 khflt2=-0.01 kxflt2=-0.005 khflt3=0.01 kxflt3=-0.005 khflt4=0.05 kxflt4=-0.05 fatkx=1 > /dev/null
#khflt1=-0.05 kxflt1=-0.002 khflt2=-0.05 kxflt2=-0.01 fatkx=1 > /dev/null

www:
	< /homes/sep/claudio/Research/Ill_ADCIG/001-ODCIG.H ${BIN}/kxkh_flt.x Rot_s_cig=sig_01_flt.H apply=y npadz=100 npadh=100 npadx=100 khflt1=-0.05 kxflt1=-0.05 khflt2=-0.01 kxflt2=-0.005 khflt3=0.01 kxflt3=-0.005 khflt4=0.05 kxflt4=-0.05 fatkx=1 > /dev/null
#khflt1=-0.05 kxflt1=-0.002 khflt2=-0.05 kxflt2=-0.01 fatkx=1 > /dev/null

sss:
	< /homes/sep/claudio/Research/Ill_ADCIG/001-ODCIG.H ${BIN}/kxkh_flt2.x Rot_s_cig=sig_02_flt.H apply=y npadz=100 npadh=100 npadx=100 khflt5= -0.00 kxflt5=0.05 khflt6=-0.004 kxflt6=0.00 khflt7=0.01 kxflt7=0.005 khflt8=0.4 kxflt8=0.05 khflt4=0.00 kxflt4=-0.05 khflt3=0.00 kxflt3=-0.005 khflt2=-0.01 kxflt2=-0.005 khflt1=-0.4 kxflt1=-0.05 fatkx=1 > /dev/null

kzkx1:
	< mig_Sis_pad_800_strati_sort.H Pad beg3=250 end3=250 end1=201| ${BIN}/kfilt.x Rot_s_cig=sig_02_kzkx.H apply=n domain=kzkx npadz=0 400 npadh=0 100 npadx=0 100 khflt5= -0.00 kxflt5= 0.05 khflt6= -0.004 kxflt6= 0.00 khflt7= 0.01 kxflt7= 0.005 khflt8= 0.4 kxflt8= 0.05 khflt4= 0.00 kxflt4= -0.05 khflt3= 0.00 kxflt3= -0.005 khflt2= -0.01 kxflt2= -0.005 khflt1= -0.4 kxflt1= -0.05 > /dev/null

kzkx2:
	< mig_Sis_pad_800_strati_sort.H Pad beg3=50 end3=50 end1=201| ${BIN}/kfilt.x Rot_s_cig=sig_02_kzkx.H apply=y domain=kzkx npadz=0 npadh=0 npadx=0 kzflt5=0.15 kxflt5=0.0 kzflt6=0.02 kxflt6=0.00 kzflt7=0.03 kxflt7=0.003 kzflt8=0.15 kxflt8=0.01 kzflt4=-0.15 kxflt4=-0.0 kzflt3=-0.02 kxflt3=-0.00 kzflt2=-0.03 kxflt2=-0.003 kzflt1=-0.15 kxflt1=-0.01 > /dev/null


kzkh1:
	< mig_Sis_pad_800_strati_sort.H ${BIN}/kfilt.x zzz=zzz.H Rot_s_cig=sig_02_flt.H apply=y domain=kzkh npadz=100 npadh=100 npadx=100 khflt5=-0.005 kzflt5=-0.15 khflt6=-0.01 kzflt6=-0.02 khflt7=0.005 kzflt7=-0.02 khflt8=0.01 kzflt8=-0.15 khflt4=0.005 kzflt4=0.15 khflt3=0.01 kzflt3=0.02 khflt2=-0.005 kzflt2=0.02 khflt1=-0.01 kzflt1=0.15 zmerge1=13000. zmerge2=16000. zramp=500. xmerge1=35000. xmerge2=40000. xramp=500. > /dev/null

khkx1:
	< /homes/sep/claudio/Research/Ill_ADCIG/001-ODCIG.H ${BIN}/kfilt.x Rot_s_cig=sig_02_flt.H apply=y domain=kxkh npadz=100 npadh=100 npadx=100 khflt5= -0.00 kxflt5= 0.05 khflt6= -0.004 kxflt6= 0.00 khflt7= 0.01 kxflt7= 0.005 khflt8= 0.4 kxflt8= 0.05 khflt4= 0.00 kxflt4= -0.05 khflt3= 0.00 kxflt3= -0.005 khflt2= -0.01 kxflt2= -0.005 khflt1= -0.4 kxflt1= -0.05 > /dev/null
###################Best Parameters##################################
#
# sig_flt_new.H
#
khkx0:
	< mig_Sis_pad_800_strati_sort.H Pad beg2=50 end2=51 beg3=50 end3=50 | ${BIN}/kfilt.x Rot_s_cig=filtered.H apply=y domain=kxkh npadz=00 npadh=00 npadx=00 khflt1=-0.06 kxflt1=-0.05 khflt2=-0.001 kxflt2=-0.005 khflt3=0.001 kxflt3=-0.005 khflt4=0.06 kxflt4=-0.05 khflt5=0.06 kxflt5=0.05 khflt6=0.001 kxflt6=0.005 khflt7=-0.001 kxflt7=0.005 khflt8=-0.06 kxflt8=0.05 > /dev/null

khkx_n0:
	< mig_Sis_pad_800_strati_sort.H Pad beg2=50 end2=51 beg3=50 end3=50 | ${BIN}/kfilt.x Rot_s_cig=not_filtered.H apply=n domain=kxkh npadz=00 npadh=00 npadx=00 khflt1=-0.06 kxflt1=-0.05 khflt2=-0.001 kxflt2=-0.005 khflt3=0.001 kxflt3=-0.005 khflt4=0.06 kxflt4=-0.05 khflt5=0.06 kxflt5=0.05 khflt6=0.001 kxflt6=0.005 khflt7=-0.001 kxflt7=0.005 khflt8=-0.06 kxflt8=0.05 > /dev/null

khkx_filt:
	< mig_Sis_pad_800_strati_sort.H Pad beg2=50 end2=51 beg3=50 end3=50 | ${BIN}/kfilt.x Rot_s_cig=flt_new.H apply=n domain=kxkh npadz=00 npadh=00 npadx=00 khflt1=-0.06 kxflt1=-0.05 khflt2=-0.001 kxflt2=-0.005 khflt3=0.001 kxflt3=-0.005 khflt4=0.06 kxflt4=-0.05 khflt5=0.06 kxflt5=0.05 khflt6=0.001 kxflt6=0.005 khflt7=-0.001 kxflt7=0.005 khflt8=-0.06 kxflt8=0.05 > /dev/null

khkxdiff:
	< xdiff.H Pad beg2=50 end2=51 beg3=50 end3=50 | ${BIN}/kfilt.x Rot_s_cig=xdiff_flt.H apply=n domain=kxkh npadz=00 npadh=00 npadx=00 khflt1= -0.03 kxflt1= -0.05 khflt2= -0.000 kxflt2= -0.005 khflt3= 0.000 kxflt3= -0.005 khflt4= 0.03 kxflt4= -0.05 khflt5= 0.03 kxflt5= 0.05 khflt6= 0.000 kxflt6= 0.005 khflt7= -0.000 kxflt7= 0.005 khflt8= -0.03 kxflt8= 0.05 > /dev/null

multiple_model.H:
	Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt.H exp="file1-file2" >xdiff.H
	Window3d min1=10150 max3=34700 < xdiff.H | Pad beg1=166 end3=137 > xdiff_cut_pad.H
	Math file1=xdiff_cut_pad.H file2=sig_02_flt_cut.H exp="file1+file2" > sig_02_flt_cutbk.H
	Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_02_flt_cutbk.H exp="file1-file2" > $@

multiple_model_new.H:
	Window3d n3=200 min3=29975 n2=33 min2=-1200 < sig_flt_new.H > sig_flt_cut_new.H
	Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt_cut_new.H exp="file1-file2" >xdiff_new.H
	Window3d min1=10150 max3=34700 < xdiff_new.H | Pad beg1=166 end3=137 > xdiff_cut_pad_new.H
	Math file1=xdiff_cut_pad_new.H file2=sig_flt_cut_new.H exp="file1+file2" > sig_flt_cutbk_new.H
	Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt_cutbk_new.H exp="file1-file2" > $@

# do adaptive subtraction of the primaries to get the multiples
# 
multiple_model1.H:
	< multiple_model.H ${BIN}/mute.x > $@

mult_est_01.H:
	Transp plane=23 <mig_Sis_pad_800_strati_sort.H >junk1.H
	Transp plane=23 <multiple_model.H >junk2.H
	Transp plane=23 <weight.H | Smooth rect1=5 rect2=5 rect3=1 tridiag=1 >junk3.H
	Math file1=junk3.H file2=junk2.H exp="file1*file2" >junk4.H
	time ~claudio/Research/ResMult/Bin/Ultimatch-new-all.x < junk1.H \
		primaries_in=  multiples_in=junk4.H mu=0.001 \
		primaries_out=prim_est_01.H \
		mode=2 nsmode=2 wmode=1 nfilt=5,5 npatch=101,101 \
		op=1 niter=10 2D=1 eps=120. > $@

prim_01_subt.H:
	Math file1=junk1.H file2=mult_est_01.H exp="file1-file2" > $@

mult_est_01_cmp.H:
	time ~claudio/Research/ResMult/Bin/Ultimatch-new-all.x < mig_Sis_pad_800_strati_sort.H \
		primaries_in=  multiples_in=multiple_model1.H mu=0.001 \
		primaries_out=prim_est_01.H weight=weight.H \
		mode=2 nsmode=2 wmode=1 nfilt=7,21 npatch=33,31 \
		op=1 niter=10 2D=1 eps=0.1 > $@

mult_est_02.H:
	time ~claudio/Research/ResMult/Bin/Ultimatch-new-all.x < junk1.H \
		primaries_in=prim_01_subt.H multiples_in=junk2.H mu=0.001 \
		primaries_out=prim_est_02.H \
		mode=2 nsmode=2 wmode=1 nfilt=5,5 npatch=101,101 \
		op=2 niter=20 2D=1 eps=120. > $@


#########################################################################################################
# Window3d n3=200 min3=29975 n2=33 min2=-1200 < sig_flt_new.H > sig_flt_cut_new.H
# Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt_cut_new.H exp="file1-file2" >xdiff_new.H
# Window3d min1=10150 max3=34700 < xdiff_new.H | Pad beg1=166 end3=137 > xdiff_cut_pad_new.H
# Math file1=xdiff_cut_pad_new.H file2=sig_flt_cut_new.H exp="file1+file2" > sig_flt_cutbk_new.H
# Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt_cutbk_new.H exp="file1-file2"  >multiple_model_new.H

# do adaptive subtraction of the primaries to get the multiples
# 

vel_sigsbee_pad.H:
	<vel_pad.H Window3d min1=29975 n1=200 min2=6000 n2=461 |Transp >$@
########################################################################################################
# These are the rules for the sep134 multiple !!!!!
#########################################################################################################################
###################Best Parameters##################################
khkx10:
	< mig_Sis_pad_800_strati_sort.H Pad beg2=50 end2=51 beg3=50 end3=50 | ${BIN}/kfilt.x Rot_s_cig=9999filt.H apply=y domain=kxkh npadz=00 npadh=00 npadx=00 khflt1=-0.06 kxflt1=-0.05 khflt2=-0.001 kxflt2=-0.005 khflt3=0.001 kxflt3=-0.005 khflt4=0.06 kxflt4=-0.05 khflt5=0.06 kxflt5=0.05 khflt6=0.001 kxflt6=0.005 khflt7=-0.001 kxflt7=0.005 khflt8=-0.06 kxflt8=0.05 > /dev/null

weight.H:
	${BIN}/mute1.x cig=mig_Sis_pad_800_strati_sort.H vel=vel_sigsbee_pad.H | Smooth rect3=5 rect1=5 > $@

multiple_model1_new.H:
	Window3d n3=200 min3=29975 n2=33 min2=-1200 < sig_flt_new.H > sig_flt_cut_new.H
	Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt_cut_new.H exp="file1-file2" >xdiff_new.H
	Window3d min1=10150 max3=34700 < xdiff_new.H | Pad beg1=166 end3=137 > xdiff_cut_pad_new.H
	Math file1=xdiff_cut_pad_new.H file2=sig_flt_cut_new.H exp="file1+file2" > sig_flt_cutbk_new.H
	Math file1=mig_Sis_pad_800_strati_sort.H file2=sig_flt_cutbk_new.H exp="file1-file2"  >multiple_model_new.H
	< multiple_model_new.H ${BIN}/mute.x > $@

mult_est_01_new.H:
	Transp plane=23 <mig_Sis_pad_800_strati_sort.H >junk1_new.H
	Transp plane=23 <multiple_model.H >junk2_new.H
	Transp plane=23 <weight.H | Smooth rect1=5 rect2=5 rect3=1 tridiag=1 >junk3_new.H
	Math file1=junk3_new.H file2=junk2_new.H exp="file1*file2" >junk4_new.H
	time ~claudio/Research/ResMult/Bin/Ultimatch-new-all.x < junk1_new.H \
		primaries_in=  multiples_in=junk4_new.H mu=0.001 \
		primaries_out=prim_est_01_new.H \
		mode=2 nsmode=2 wmode=1 nfilt=5,5 npatch=101,101 \
		op=1 niter=10 2D=1 eps=120. > $@

prim_01_subt_new.H:
	Math file1=junk1_new.H file2=mult_est_01_new.H exp="file1-file2" > $@

mult_est_01_newa.H:
	Transp plane=23 <mig_Sis_pad_800_strati_sort.H >junk1_new.H
	Transp plane=23 <multiple_model1_new.H >junk2_new.H
	Transp plane=23 <weight.H | Smooth rect1=5 rect2=5 rect3=1 tridiag=1 >junk3_new.H
	Math file1=junk3_new.H file2=junk2_new.H exp="file1*file2" >junk4_new.H
	time ~claudio/research.ln/ResMult/Bin/Ultimatch-new-all.x < junk1_new.H \
		primaries_in=  multiples_in=junk4_new.H mu=0.001 \
		primaries_out=prim_est_01_new.H \
		mode=2 nsmode=2 wmode=1 nfilt=5,5 npatch=101,101 \
		op=1 niter=20 2D=1 eps=120. > $@

prim_01_subt_newa.H:
	Math file1=junk1_new.H file2=mult_est_01_newa.H exp="file1-file2" > $@
####################################################################################################
#
#
khkx11:
	< mig_Sis_pad_800_strati_sort.H Pad beg2=50 end2=51 beg3=50 end3=50 | ${BIN}/kfilt.x Rot_s_cig=9999filt.H apply=y domain=kxkh npadz=00 npadh=00 npadx=00 khflt1=-0.06 kxflt1=-0.05 khflt2=-0.001 kxflt2=-0.005 khflt3=0.001 kxflt3=-0.005 khflt4=0.06 kxflt4=-0.05 khflt5=0.06 kxflt5=0.05 khflt6=0.001 kxflt6=0.005 khflt7=-0.001 kxflt7=0.005 khflt8=-0.06 kxflt8=0.05 > /dev/null

9999multiple_model_newa.H:
	Math file1=mig_Sis_pad_800_sort.H file2=sig_flt_cut_new.H exp="file1-file2" > 9999xdiff_new.H
	Window3d min1=10150 max3=34700 < 9999xdiff_new.H | Pad beg1=166 end3=137 > 9999xdiff_cut_pad_new.H
	Math file1=9999xdiff_cut_pad_new.H file2=sig_flt_cut_new.H exp="file1+file2" > 9999sig_flt_cutbk_new.H
	Math file1=mig_Sis_pad_800_sort.H file2=9999sig_flt_cutbk_new.H exp="file1-file2"  >9999multiple_model_new.H
	< 9999multiple_model_new.H ${BIN}/mute.x > $@

9999mult_est_01_newa.H:
	Transp plane=23 <mig_Sis_pad_800_sort.H >junk1_new.H
	Transp plane=23 <multiple_model1_new.H >junk2_new.H
	Transp plane=23 <weight.H | Smooth rect1=5 rect2=5 rect3=1 tridiag=1 >junk3_new.H
	Math file1=junk3_new.H file2=junk2_new.H exp="file1*file2" >junk4_new.H
	time ~claudio/research.ln/ResMult/Bin/Ultimatch-new-all.x < junk1_new.H \
		primaries_in=  multiples_in=junk4_new.H mu=0.001 \
		primaries_out=prim_est_01_new.H \
		mode=2 nsmode=2 wmode=1 nfilt=5,5 npatch=101,101 \
		op=1 niter=20 2D=1 eps=120. > $@

9999prim_01_subt_newa.H:
	Math file1=junk1_new.H file2=9999mult_est_01_newa.H exp="file1-file2" > $@
#
#

inv_gbomult.H:
	Math file1=2.H exp="file1*10000" >2a.H
	~claudio/research.ln/ResMult/Bin/Ultimatch-new-all.x < 3.H \
	primaries_in=  multiples_in=2a.H mu=0.001 \
	primaries_out=prim_gbomult.H \
	mode=2 nsmode=2 wmode=1 nfilt=21,21 npatch=51,51 \
	op=1 niter=50 2D=1 eps=5. > $@


#######################################################################################################

mig_ang.H:
	< mig_Sis_pad_800_strati.H Window3d n1=200 min1=29975 squeeze=n | Transp reshape=2,4,5 plane=13 > temp.H
	< temp.H Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y amax=40 eps=10 maxmem=1000 > $@

flt_anga.H:
	< prim_01_subt_newa.H Transp plane=23 reshape=1,2,4,5,6 > temp.H
	< temp.H Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y amax=40 eps=10 maxmem=1000 > $@

flt_ang.H:
	< prim_01_subt_new.H Transp plane=23 reshape=1,2,4,5,6 > temp.H
	< temp.H Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y amax=40 eps=10 maxmem=1000 > $@

##########################################

regclean_%:
	@-touch $*; Rm $*; touch $*; \rm $*

clean : texclean 
	@-touch j.o j.mod j.x *.fix.f90; \rm *.o *.mod *.x *.fix.f90

#include /opt/SEP/SEP6.4.6/include/SEP.bottom
#include /usr/local/share/make/SEP.bottom
include ${SEPINC}/SEP.bottom
