include ${SEPINC}/SEP.top
LATOPTS = option=web 'style=jfc,makeidx,html,amsmath'
#LATOPTS = 'style=amsmath'
BINDIR = ./Bin/
SRCDIR = ./Src/
RESDIR = ./Fig
PARDIR = ./Par
SIGDIR = /mnt/sepdata/1a/sigsbee_multiple
#COLOR=yes
B=BINDIR
S=SRCDIR
R=RESDIR
P=PARDIR

#RESULTSNR = eigenvalues_const eigenvalues_bill
RESULTSER = compare compare_mig1
RESULTSCR = 
OLEVEL=2
#UF90FLAGS =-mp -check bounds
#UF90FLAGS =-parallel -openmp -openmp_report2  -O3 -axW -vec_report3
MAINLIBS=-lsep2df90 -lsep3df90 -lsep3d -lsepf90 -lsep -L${LIBDIR}  -lsepgeef90
UF90LIBS=${MPILIBS} ${MAINLIBS} -lsepparf90 -lseppar_mpi -lsepgeef90 -lsep2df90 -static-libcxa -lguide#-Bstatic 
UF77LIBS = ${BEILIB}

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


shot3d.H: nfs-splitspread-shots.H
	Create3d < $< >x.H nkeys=2 keyname2=s_x keyname1=offset_x
	Headermath <x.H >xx.H key1=cmp_x eqn1="0.3048*(2*s_x+offset_x)/2" key2=g_x eqn2="0.3048*(offset_x+s_x)" 
	Sort3d < xx.H nkeys=2 key1=offset_x key2=cmp_x ng1=695 og1=-7932.42 dg1=22.86 og2=-636.27 ng2=700 dg2=45.72 max_memory=1000 >xxx.H
	Infill3d <xxx.H >xxxx.H
	Stack <xxxx.H >$@;<shot3d.H Window min2=0 min3=3048 max3=18288 >shot3d.pos.H
	Rm x.H xx.H xxx.H xxxx.H

###########################
#       My stuffs         #
###########################
Prog=/net/koko/brad/bin/LINUX/ShotMig

001cmp.H:
	<splitspread_shots.H Create3d keyname1=offset_x keyname2=s_x >junk1.H 
	<junk1.H Headermath par=./Par/math.P | Headermath key1=cmp_x 'eqn1=0.3048*(2*s_x+offset_x)/2)' key2=aoffset 'eqn2=@ABS(0.3048*offset_x)' >junk2.H
	<junk2.H Sort3d par=./Par/sortcmp.P max_memory=1000 >junk3.H; <junk3.H Infill3d > junk4.H; <junk4.H Stack3d normalize=1 > $@
#	rm -f junk*.H*; rm -f /scr1/claudio/junk*.H*

velan.H:
	<001cmp.H Window f3=200 j3=25 n3=16 | ${B}/Veltran.x

prep-fs.H: ${SIGDIR}/fs-splitspread-shots.H
	Cp  ${SIGDIR}/fs-splitspread-shots.H  fs-splitspread_shots.H
	<fs-splitspread_shots.H /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=2 f_min1=6 f_max1=36 f_max=42  maxsize=1000 > $@

prep_mult.H:
	Math file1=fs-splitspread_shots.H file2=splitspread_shots.H exp="file1-file2" > mult-splitspread_shots.H
	<mult-splitspread_shots.H Window n1=800 n3=1 f3=200 | /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=2 f_min1=6 \
	f_max1=36 f_max=42 maxsize=1000 > $@

source01.H:${SIGDIR}/nfs-splitspread-shots.H
	< ${SIGDIR}/nfs-splitspread-shots.H Window3d min1=4.88 max1=5.12 f3=5 n3=1 f2=673 n2=1 | \
	Pad end1=1470 > j1.H 
	echo o1=-0.112 n4=1 o4=1 d4=1 n5=1 o5=1 d5=1 >> j1.H
	<j1.H /net/koko/bob/SEP_BOB/bin/Transf shotmig=y is2d=y wei=y f_min=2 f_min1=6 f_max1=36 f_max=42  maxsize=1000 > $@

prep_pos.H:
	< prep.H Window3d min1=0 squeeze=n | Pad beg1=347 >$@

prep_neg.H:
	< prep.H Window3d max1=0 squeeze=n | Pad n1=695 >$@

prep_spl.H:
	< prep.H Window3d squeeze=n | Pad beg1=347 end1=347 >$@

prep_spl-fs.H:
	< prep-fs.H Window3d squeeze=n | Pad beg1=347 end1=347 >$@

prep_mult2.H: prep_mult.H
	< prep_mult.H Window3d squeeze=n | Pad beg1=347 end1=347 >$@

vel_pad.H:
	< ${SIGSMULT_DATA}/sigsbee2b_migration_velocity.H Window> j.H
	echo "hff=-1 gff=-1 d1=25 o2=10025 d2=37.5"      >>j.H
	< j.H Window3d n1=1201 j2=2|Pad beg2=2000 n2out=10000 extend=1|Transp> vel_pad.H
	/net/koko/alejandro/plib/pcs2/bin/Wedge.x vel_pad.H axis=2 nn=1 no=0. nd=75. 
	echo  "  label1="x" label2="y" label3="z" " >> vel_pad.H

mig_Sis_Parallel_16000.H:  data_f.H wave.H vel_pad.H ${PARDIR}/go_sis.P 
	@date
	nohup Parallel command=/net/koko/brad/bin/LINUX/ShotMig files="data_f.H,wave.H,vel_pad.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=60 axis=4,4,5,5 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY"  mach_mfile=machinefile_all nx_shots=327 ox_shots=10925. \
	par=${PARDIR}/go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=6000 #restart=y

mig_Sis_Parallel_pad.H:  data_f.H wave.H vel_pad.H ${PARDIR}/go_sis.P 
	@date
	nohup Parallel command=./ShotMigNew files="data_f_pad.H,wave.H,vel_pad.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=37 axis=4,4,5,5 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY"  mach_mfile=machinefile_half nx_shots=327 ox_shots=10925. \
	par=${PARDIR}/go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=6000 minx=10925 maxx=60000   #restart=y

Mig_pos.H: prep_pos.H source01.H vel_pad.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_pos.H,source01.H,vel_pad.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000   #restart=y

Mig_pos_paral.H: prep_pos.H source01.H vel_pad.H go_sis.P
	Window3d < prep_pos.H squeeze=n j4=50 n3=200> prep_pos_tmp.H
	Window3d < source01.H squeeze=n n3=200> source01_tmp.H
	Window3d < vel_pad.H squeeze=n n3=400 > vel_pad_tmp.H
	@date
	nohup Parallel command=./ShotMigNew files="prep_pos_tmp.H,source01_tmp.H,vel_pad_tmp.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=10 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	nref=2 taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000   #restart=y

Mig_pos_serial.H: prep_pos.H source01.H vel_pad.H go_sis.P
	@date
	Window3d < prep_pos.H squeeze=n j4=50 n3=200> prep_pos_tmp.H
	Window3d < source01.H squeeze=n n3=200> source01_tmp.H	
	Window3d < vel_pad.H squeeze=n n3=400 > vel_pad_tmp.H
	./ShotMigNew D=prep_pos_tmp.H D_d=source01_tmp.H V=vel_pad_tmp.H R=$@  \
	nref=2 taper=y  taper_pcent=2 marine=y watercolumn=5400  minx=12000 maxx=70000  

Mig_neg.H: prep_neg.H source01.H vel_pad.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_neg.H,source01.H,vel_pad.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 restart=y

Mig_spl.H: prep_spl.H source01.H vel_pad.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_spl.H,source01.H,vel_pad.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 #restart=y

Mig_spl-fs.H: prep_spl-fs.H source01.H vel_pad.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_spl-fs.H,source01.H,vel_pad.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 #restart=y

Mig_mult.H: prep-mult.H source01.H vel_pad.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep-mult.H,source01.H,vel_pad.H,$@"  \
        tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
        file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
        nx_shots=496 ox_shots=10925 \
        par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 #restart=y

Mig_mult2.H: prep_mult2.H source01.H vel_pad.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_mult2.H,source01.H,vel_pad.H,$@"  \
        tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=200 axis=4,4,4,6 pverb=2  \
        file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
        jhx=2 nx_shots=200 ox_shots=10925 \
        par=go_sismult.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 #restart=y

Mig_spl_hi.H: prep_spl.H source01.H vel_pad_hi.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_spl.H,source01.H,vel_pad_hi.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 #restart=y

Mig_spl_lo.H: prep_spl.H source01.H vel_pad_lo.H go_sis.P
	@date
	nohup Parallel command=./ShotMigNew files="prep_spl.H,source01.H,vel_pad_lo.H,$@"  \
	tags="D,D_d,V,R" usage="INPUT,INPUT,INPUT,OUTPUT" nblock=496 axis=4,4,4,6 pverb=2  \
	file_type="DISTRIBUTE,COPY,COPY,COPY" mach_mfile=machinefile_200 \
	nx_shots=496 ox_shots=10925 \
	par=go_sis.P  taper=y  taper_pcent=2 marine=y watercolumn=5400 minx=12000 maxx=70000 #restart=y

ADCIG_spl-fs.H:Mig_spl-fs.H
	< Mig_spl-fs.H Transp reshape=2,4,5 plane=13 | Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y eps=1 maxmem=1000 >$@

ADCIG_spl.H:Mig_spl.H
	< Mig_spl.H Transp reshape=2,4,5 plane=13 | Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y eps=1 maxmem=1000 >$@

ADCIG_spl_lo.H:Mig_spl_lo.H
	< Mig_spl_lo.H Transp reshape=2,4,5 plane=13 | Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y eps=1 maxmem=1000 >$@

ADCIG_spl_hi.H:Mig_spl_hi.H
	< Mig_spl_hi.H Transp reshape=2,4,5 plane=13 | Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y eps=1 maxmem=1000 >$@

ADCIG_pos.H:Mig_pos.H
	< Mig_pos.H Transp reshape=2,4,5 plane=13 | Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y eps=1 maxmem=1000 >$@

ADCIG_neg.H:Mig_neg.H
	< Mig_neg.H Transp reshape=2,4,5 plane=13 | Pad beg2=43 end2=44 | /net/koko/bob/SEP_BOB/bin/OFF2ANG verb=y eps=1 maxmem=1000 >$@

Vo_pos:
	< Mig_pos.H Window3d | Transp plane=13 | Transp plane=23 | Grey eout=1 gainpanel=a pclip=95 | Ricksep &

Va_pos:
	Window3d < ang_pos.H | Transp plane=23 | Grey eout=1 gainpanel=a pclip=95 | Ricksep &
include ${SEPINC}/SEP.bottom

