ARCH = LINUX
SEP_ARCH = LINUX
SEPINC = /opt/SEP/SEP7.0/include

include ${SEPINC}/SEP.top

BINDIR = ./Bin
RESDIR = ./Fig
SRCDIR = ./Src
TXTDIR = ./Txt

FFTWLIB = -L/opt/FFTW/lib -lfftw3f

###################################
# PUT your SEPLib path here
###################################
#SEPLIBDIR = /net/server/tang/Research/SEP6.4.6/SEP6.4.6_INTEL/lib
SEPLIBDIR = /opt/SEP/SEP7.0/lib

###################################
# OLD links
###################################
#UF90LIBS  = -lsupersetf90 -lsepgeef90 -lsuperset -lsepauxf90 -lsepmathf90 -lsep2df90 -lsep3df90 -lsep3d -lsepf90 -lsep -openmp -lsvml ${FFTWLIB}

###################################
# NEW one, manually supply sepwindow.o
###################################
UF90LIBS = sepwindow.o -lsupersetf90 -lsepgeef90 -lsuperset -lsepauxf90 -lsepmathf90 -lsep2df90 -lsep3df90 -lsep -openmp -lsvml ${FFTWLIB}

# for pompei
UF90FLAGS = -O3 -axP -openmp -static-libcxa -Bstatic


MIG_PARA = pdip=45 offset=n ntpx=25 nws=106 oper="foufd" nxpad_beg=50 nxpad_end=50 #image_xmin=-2000 image_xmax=2000

MigPar2 = pdip=45 offset=n ntpx=25 nws=106 oper="foufd" nxpad_beg=50 nxpad_end=50 #image_xmin=-2000 image_xmax=2000

OFF_PARA = nhx=33 ohx=-160
OFF_PARA2 = nhx=81 ohx=-400
#OFF_PARA2 = nhx=61 ohx=-300

BSC_PARA = typbsc=2 nopbsc=3

twin.vmod.H: ${BINDIR}/lens_twin.x
	${BINDIR}/lens_twin.x ox=-5000 dx=10 nx=1001 oz=0 dz=10 nz=201 x11=-800. x13=800. x21=800. x23=800. > $@ refl=junk1.H nref=1 zref=1500. fm=0.02 bvel=twin.bvel.H
	echo n4=1 n5=1 n6=1 d4=1. d5=1. d6=1. o4=0. o5=0. o6=0. >> junk1.H
	Transp < junk1.H reshape=3,5,6 plane=12 > twin.refl.H

Z = ~/Research/beamWET/tomo
Zb = ~/Research/beamWET/bin
strip = ~yang/Research/codelib/bin/StripOutDummyAxis.x
tool = ~yang/Research/codelib/bin
 

bslw.H: c0.vmod.H 
	Math file1=$< exp="1./file1" > $@

#change axis from (z,x) to (x,y,z)
#for c1,c2.a1,a2
#$Z/vel%.H
%.vmod.H: $Z/vel%.H
	<$< Window min1=0 > junk1.H
	echo  n4=1 n5=1 n6=1 d4=1. d5=1. d6=1. o4=0. o5=0. o6=0. >> junk1.H
	Transp < junk1.H reshape=1,3 plane=12 > $@
	echo label1=x label2=z >> $@
	Rm junk1.H

%.slow.H: twin.vmod.H
	Math file1=$< exp="1./file1" > $@
%.dslw.H: %.vmod.H bslw.H
	Math file1=$< file2=bslw.H exp="1/file1-file2" > $@


#Transform from (z,x,hx) to (hx,hy,x,y,z)
refl.H: $Z/ref.H
	<$< Window min1=0 > junk1.H
	echo  n3=1 o3=0 d3=100 n4=1 n5=1 n6=1 d4=1. d5=1. d6=1. o4=0. o5=0. o6=0. >> junk1.H
	Transp < junk1.H reshape=1,3,5,6 plane=13 > $@
	echo label3=x label5=z >> $@
	Rm junk1.H

#for c1,c2,a1,a2
%.crec.H: %.vmod.H ${BINDIR}/wem3d.x twin.csou.H 
	${BINDIR}/wem3d.x csou=twin.csou.H vmod=$< imag=refl.H crec=$@ report=n \
        adj=n ngx=601 ogx=-3000 dgx=10 nsx=151 offset=n dsx=40 osx=-3000 ${MigPar2}

%.imag.H: %.vmod.H ${BINDIR}/wem3d.x twin.csou.H %.crec.H
	${BINDIR}/wem3d.x csou=twin.csou.H vmod=$< crec=$*.crec.H imag=$@ \
        adj=y ${MigPar2} ${OFF_PARA2} report=n

%.imag.bvel.H: %.vmod.H ${BINDIR}/wem3d.x twin.csou.H %.crec.H
	${BINDIR}/wem3d.x csou=twin.csou.H vmod=c0.vmod.H crec=$*.crec.H imag=$@ \
        adj=y ${MigPar2} ${OFF_PARA2}


%.dimg.forward.H: ${BINDIR}/wemva3d_baspix.x twin.csou.H %.crec.H %.dslw.H bslw.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=$*.crec.H bslw=bslw.H \
                                   dslw=$*.dslw.H dimg=$@ adj=n add=n \
                                   comsou=n ${MigPar2} ${BSC_PARA} ${OFF_PARA2}

%.dslw.adjoint.H: ${BINDIR}/wemva3d_baspix.x bslw.H twin.csou.H %.crec.H %.dimg.forward.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=$*.crec.H bslw=bslw.H \
                                   dslw=$@ dimg=$*.dimg.forward.H adj=y add=n \
                                   comsou=n ${MigPar2} ${BSC_PARA} ${OFF_PARA2}

%.dimg.offdso.H: %.imag.bvel.H ${BINDIR}/offdso.x
	${BINDIR}/offdso.x modl=$@ data=$< adj=y add=n hcut=0. hord=2.

%.dslw.offdso.H: %.dimg.offdso.H ${BINDIR}/wemva3d_baspix.x bslw.H twin.csou.H %.crec.H 	
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=$*.crec.H bslw=bslw.H \
                                   dslw=$@ dimg=$< adj=y add=n \
                                   comsou=n ${MigPar2} ${BSC_PARA} ${OFF_PARA2} 

#Call beamfocus program to generate the perturbed image,
#Tranpose the axis from z,x,hx --> hx,hy,x,y,z
%.dimg.bf.H : $Z/dImgY.%.bf.H
	<$< Window f1=40 n1=100 | Transp reshape=2,3 plane=12 >tmp.H
	<tmp.H Transp plane=25 > $@
%.dimg.angdso.H : $Z/dImgY.%.angdso.H
	<$< Window f1=40 n1=100 | Transp reshape=2,3 plane=12 >tmp.H
	<tmp.H Transp plane=25 > $@
	
%.dslw.bf.H: %.dimg.bf.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=$*.crec.H bslw=bslw.H \
                                   dslw=$@ dimg=$< adj=y add=n \
                                   comsou=n ${MigPar2} ${BSC_PARA} ${OFF_PARA2}
%.dslw.angdso.H: %.dimg.angdso.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=$*.crec.H bslw=bslw.H \
                                   dslw=$@ dimg=$< adj=y add=n \
                                   comsou=n ${MigPar2} ${BSC_PARA} ${OFF_PARA2}

job:
	make c1.dslw.bf.H
	make c2.dslw.bf.H
	make a1.dslw.bf.H
	make a2.dslw.bf.H

######## Twin velocity model case
twin.slow.H: twin.vmod.H
	Math file1=$< exp="1./file1" > $@
twin.bslw.H: twin.vmod.H
	Math file1=twin.bvel.H exp="1./file1" > $@

twin.dslw.H: twin.slow.H twin.bslw.H
	Math file1=twin.slow.H file2=twin.bslw.H exp="file1-file2" > $@

twin.tsou.H:
	Wavelet n1=1500 o1=0 d1=0.002 domain=time tdelay=0.12 fund=15 wavelet=ricker2 | Add scale=-1 > $@
	#Wavelet n1=1500 o1=0 d1=0.002 domain=time fund=15 wavelet=ricker2 | Add scale=-1 > $@

twin.csou.H: ${BINDIR}/wei_transf.x twin.tsou.H
	echo d2=1 d3=1 d4=1 d5=1 o2=0 o3=0 o4=0 o5=0 n2=1 n3=1 n4=1 n5=1 >> twin.tsou.H
	${BINDIR}/wei_transf.x < twin.tsou.H adj=y ${FREQ} > junk1.H
	Transp plane=13 < junk1.H > $@
	Rm junk1.H

twin.crec.H: ${BINDIR}/wem3d.x twin.csou.H twin.vmod.H
	${BINDIR}/wem3d.x csou=twin.csou.H vmod=twin.vmod.H imag=twin.refl.H crec=$@ \
        adj=n ngx=801 ogx=-4000 dgx=10 nsx=401 offset=n dsx=20 osx=-4000 ${MIG_PARA}

twin.imag.H: ${BINDIR}/wem3d.x twin.csou.H twin.vmod.H twin.crec.H
	${BINDIR}/wem3d.x csou=twin.csou.H vmod=twin.vmod.H crec=twin.crec.H imag=$@ \
        adj=y ${MIG_PARA} ${OFF_PARA}

twin.imag.bvel.H: ${BINDIR}/wem3d.x twin.csou.H twin.vmod.H twin.crec.H
	${BINDIR}/wem3d.x csou=twin.csou.H vmod=twin.bvel.H crec=twin.crec.H imag=$@ \
        adj=y ${MIG_PARA} ${OFF_PARA}


twin.dimg.forward.H: ${BINDIR}/wemva3d_baspix.x twin.bslw.H twin.csou.H twin.crec.H twin.dslw.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=twin.crec.H bslw=twin.bslw.H \
                                   dslw=twin.dslw.H dimg=$@ adj=n add=n\
                                   comsou=n ${MIG_PARA} ${BSC_PARA} ${OFF_PARA}

twin.dslw.adjoint.H: ${BINDIR}/wemva3d_baspix.x twin.bslw.H twin.csou.H twin.crec.H twin.dimg.forward.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=twin.crec.H bslw=twin.bslw.H \
                                   dslw=$@ dimg=twin.dimg.forward.H adj=y add=n\
                                   comsou=n ${MIG_PARA} ${BSC_PARA} ${OFF_PARA}

twin.dimg.offdso.H: ${BINDIR}/offdso.x twin.imag.bvel.H
	${BINDIR}/offdso.x modl=$@ data=twin.imag.bvel.H adj=y add=n hcut=0. hord=2.


twinZ.dimg.offdso.H: twin.dimg.offdso.H
	<$< ${strip} result=tmp.H 
	Transp < tmp.H plane=13 > tmp2.H 
#	$Z/DimgWEMVA.x <tmp2.H >tmp3.H 

twin.dslw.offdso.H: ${BINDIR}/wemva3d_baspix.x twin.bslw.H twin.csou.H twin.crec.H twin.dimg.offdso.H
	${BINDIR}/wemva3d_baspix.x csou=twin.csou.H crec=twin.crec.H bslw=twin.bslw.H \
                                   dslw=$@ dimg=twin.dimg.offdso.H adj=y add=n\
                                   comsou=n ${MIG_PARA} ${BSC_PARA} ${OFF_PARA}



# plane-waves

twin.plane.all.csou.H: ${BINDIR}/plane_source.x twin.csou.H twin.crec.H
	${BINDIR}/plane_source.x soufnc=twin.csou.H data=twin.crec.H sx0=0 npsx=61 psx_min=-0.000453153 psx_max=0.000453153 offset=n \
                                 plane_sou=$@ plane_rec=twin.plane.all.crec.H

twin.plane.all.imag.H: ${BINDIR}/wem3d.x twin.plane.all.csou.H twin.vmod.H
	${BINDIR}/wem3d.x crec=twin.plane.all.crec.H csou=twin.plane.all.csou.H vmod=twin.vmod.H imag=$@ \
        comsou=y adj=y ${MIG_PARA} ${OFF_PARA}

twin.plane.all.imag.bvel.H: ${BINDIR}/wem3d.x twin.plane.all.csou.H twin.bvel.H
	${BINDIR}/wem3d.x crec=twin.plane.all.crec.H csou=twin.plane.all.csou.H vmod=twin.bvel.H imag=$@ \
        comsou=y adj=y ${MIG_PARA} ${OFF_PARA}

twin.plane.all.dimg.forward.H: ${BINDIR}/wemva3d_baspix.x twin.plane.all.csou.H twin.dslw.H twin.bslw.H
	${BINDIR}/wemva3d_baspix.x csou=twin.plane.all.csou.H crec=twin.plane.all.crec.H bslw=twin.bslw.H dslw=twin.dslw.H dimg=$@ \
        comsou=y adj=n ${MIG_PARA} ${OFF_PARA} ${BSC_PARA}

twin.plane.all.dslw.adjoint.H: ${BINDIR}/wemva3d_baspix.x twin.plane.all.csou.H twin.bslw.H twin.plane.all.dimg.forward.H
	${BINDIR}/wemva3d_baspix.x csou=twin.plane.all.csou.H crec=twin.plane.all.crec.H bslw=twin.bslw.H dslw=$@ dimg=twin.plane.all.dimg.forward.H \
        comsou=y adj=y ${MIG_PARA} ${OFF_PARA} ${BSC_PARA}

twin.plane.all.dimg.offdso.H: ${BINDIR}/offdso.x twin.plane.all.imag.bvel.H
	${BINDIR}/offdso.x modl=$@ data=twin.plane.all.imag.bvel.H adj=y add=n hcut=0. hord=2.

twin.plane.all.dslw.offdso.H: ${BINDIR}/wemva3d_baspix.x twin.plane.all.csou.H twin.bslw.H twin.plane.all.dimg.offdso.H
	${BINDIR}/wemva3d_baspix.x csou=twin.plane.all.csou.H crec=twin.plane.all.crec.H bslw=twin.bslw.H dslw=$@ dimg=twin.plane.all.dimg.offdso.H \
        comsou=y adj=y ${MIG_PARA} ${OFF_PARA} ${BSC_PARA}




# image-space phase encoding
PERM_CSOU = /net/koko/claudio/Research/report/sep136/tang1/0001twin_sou_encw_bvel_tr1.H
PERM_CREC = /net/koko/claudio/Research/report/sep136/tang1/0001twin_rec_encw_bvel_tr1.H
PERM_CSOU2 = /net/koko/claudio/Research/report/sep136/tang1/1111twin_sou_encw_bvel_tr.H
PERM_CREC2 = /net/koko/claudio/Research/report/sep136/tang1/1111twin_rec_encw_bvel_tr.H

PERM_RESIZE = n1=801 min1=-4000

twin.perm.csou.H: ${PERM_CSOU2}
	Window3d < $< squeeze=n ${PERM_RESIZE} > $@

twin.perm.crec.H: ${PERM_CREC2}
	Window3d < $< squeeze=n ${PERM_RESIZE} > $@

twin.perm.imag.H: ${BINDIR}/wem3d.x twin.perm.csou.H twin.perm.crec.H twin.vmod.H
	${BINDIR}/wem3d.x crec=twin.perm.crec.H csou=twin.perm.csou.H vmod=twin.vmod.H imag=$@ \
        comsou=y adj=y radian=n ${MIG_PARA} ${OFF_PARA}

twin.perm.imag.bvel.H: ${BINDIR}/wem3d.x twin.perm.csou.H twin.perm.crec.H twin.vmod.H
	${BINDIR}/wem3d.x crec=twin.perm.crec.H csou=twin.perm.csou.H vmod=twin.bvel.H imag=$@ \
        comsou=y adj=y radian=n ${MIG_PARA} ${OFF_PARA}

twin.perm.dimg.forward.H: ${BINDIR}/wemva3d_baspix.x twin.perm.csou.H twin.perm.crec.H twin.dslw.H twin.bslw.H
	${BINDIR}/wemva3d_baspix.x csou=twin.perm.csou.H crec=twin.perm.crec.H bslw=twin.bslw.H dslw=twin.dslw.H dimg=$@ \
        comsou=y adj=n radian=n ${MIG_PARA} ${BSC_PARA} ${OFF_PARA}

twin.perm.dslw.adjoint.H: ${BINDIR}/wemva3d_baspix.x twin.perm.csou.H twin.perm.crec.H twin.bslw.H twin.perm.dimg.forward.H
	${BINDIR}/wemva3d_baspix.x csou=twin.perm.csou.H crec=twin.perm.crec.H bslw=twin.bslw.H dslw=$@ dimg=twin.perm.dimg.forward.H \
        comsou=y adj=y radian=n ${MIG_PARA} ${BSC_PARA} ${OFF_PARA}


twin.perm.dimg.offdso.H: ${BINDIR}/offdso.x twin.perm.imag.bvel.H
	${BINDIR}/offdso.x modl=$@ data=twin.perm.imag.bvel.H adj=y add=n hcut=0. hord=2.

twin.perm.dslw.offdso.H: ${BINDIR}/wemva3d_baspix.x twin.perm.csou.H twin.perm.crec.H twin.bslw.H twin.perm.dimg.offdso.H
	${BINDIR}/wemva3d_baspix.x csou=twin.perm.csou.H crec=twin.perm.crec.H bslw=twin.bslw.H dslw=$@ dimg=twin.perm.dimg.offdso.H \
        comsou=y adj=y radian=n ${MIG_PARA} ${OFF_PARA} ${BSC_PARA}



# Figures
LABEL_PARA = label1="z[m]" label2="x[m]" title=" " labelfat=1 titlefat=1 labelsz=11 titlesz=12
PCLIP_PARA = newclip=1
COLOR_PARA = color= j 
SCALE_PARA = wantscalebar=n barlabel=" "
RSIZE_SLOW_PARA = min1=-4000 max1=4010
RSIZE_IMAG_PARA = min3=-4000 max3=4010 min5=1000
LABEL_IMAG_PARA = label1="z[m]" label2="x[m]" label3="hx[m]" title=" " labelfat=1 titlefat=1 labelsz=8 point1=0.8 point2=0.85 wantcoordlabel=-1
${RESDIR}/twin-slow.v: twin.slow.H
	Window3d < $< ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} labelsz= > /dev/null

${RESDIR}/twin-bslw.v: twin.bslw.H
	Window3d < $< ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA}> /dev/null

${RESDIR}/twin-dslw.v: twin.dslw.H
	Window3d < $< ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(a)"> /dev/null

# shot-profile domain
${RESDIR}/twin-imag-bvel.v: twin.imag.bvel.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_a > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-dimg-forward.v: twin.dimg.forward.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_a > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-dimg-offdso.v: twin.dimg.offdso.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_a > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-dslw-adjoint.v: twin.dslw.adjoint.H
	Window3d < $< ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(b)"> /dev/null

${RESDIR}/twin-dslw-offdso.v: twin.dslw.offdso.H
	Math file1=$< exp="-1*file1" > junk1.H
	Window3d < junk1.H ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(b)"> /dev/null
	Rm junk1.H

# plane-wave domain
${RESDIR}/twin-plane-all-imag-bvel.v: twin.plane.all.imag.bvel.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA} > /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_b > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-plane-all-dimg-forward.v: twin.plane.all.dimg.forward.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_b > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-plane-all-dimg-offdso.v: twin.plane.all.dimg.offdso.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_b > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-plane-all-dslw-adjoint.v: twin.plane.all.dslw.adjoint.H
	Window3d < $< ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(c)"> /dev/null

${RESDIR}/twin-plane-all-dslw-offdso.v: twin.plane.all.dslw.offdso.H
	Math file1=$< exp="-1*file1" > junk1.H
	Window3d < junk1.H ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(c)"> /dev/null
	Rm junk1.H

# image-space encoding
${RESDIR}/twin-perm-imag-bvel.v: twin.perm.imag.bvel.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA} > /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_c > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-perm-dimg-forward.v: twin.perm.dimg.forward.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_c > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-perm-dimg-offdso.v: twin.perm.dimg.offdso.H
	Window3d < $< ${RSIZE_IMAG_PARA}| Transp plane=13 | Grey eout=1 gainpanel=a > junk1.T
	Cubeplot < junk1.T flat=1 frame1=50 frame2=400 frame3=16 out=junk1.v ${LABEL_IMAG_PARA}> /dev/null
	vp_annotate < junk1.v batch=y text=${TXTDIR}/text_filt_c > $@
	Rm junk1.T
	rm -f junk1.v

${RESDIR}/twin-perm-dslw-adjoint.v: twin.perm.dslw.adjoint.H
	Window3d < $< ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(d)"> /dev/null

${RESDIR}/twin-perm-dslw-offdso.v: twin.perm.dslw.offdso.H
	Math file1=$< exp="-1*file1" > junk1.H
	Window3d < junk1.H ${RSIZE_SLOW_PARA}| Transp | Grey color=j out=$@ ${PCLIP_PARA} ${LABEL_PARA} ${COLOR_PARA} ${SCALE_PARA} title="(d)"> /dev/null
	Rm junk1.H

# 
${RESDIR}/twin-bimg-all.v: ${RESDIR}/twin-imag-bvel.v ${RESDIR}/twin-plane-all-imag-bvel.v ${RESDIR}/twin-perm-imag-bvel.v
	vp_OverUnderAniso ${RESDIR}/twin-imag-bvel.v ${RESDIR}/twin-plane-all-imag-bvel.v ${RESDIR}/twin-perm-imag-bvel.v > $@

${RESDIR}/twin-dimg-all.v: ${RESDIR}/twin-dimg-forward.v ${RESDIR}/twin-plane-all-dimg-forward.v ${RESDIR}/twin-perm-dimg-forward.v
	vp_OverUnderAniso ${RESDIR}/twin-dimg-forward.v ${RESDIR}/twin-plane-all-dimg-forward.v ${RESDIR}/twin-perm-dimg-forward.v > $@

${RESDIR}/twin-dslw-all.v: ${RESDIR}/twin-dslw.v ${RESDIR}/twin-dslw-adjoint.v ${RESDIR}/twin-plane-all-dslw-adjoint.v ${RESDIR}/twin-perm-dslw-adjoint.v
	vp_OverUnderAniso ${RESDIR}/twin-dslw.v ${RESDIR}/twin-dslw-adjoint.v ${RESDIR}/twin-plane-all-dslw-adjoint.v ${RESDIR}/twin-perm-dslw-adjoint.v > $@

${RESDIR}/twin-dimg-offdso-all.v: ${RESDIR}/twin-dimg-offdso.v ${RESDIR}/twin-plane-all-dimg-offdso.v ${RESDIR}/twin-perm-dimg-offdso.v
	vp_OverUnderAniso ${RESDIR}/twin-dimg-offdso.v ${RESDIR}/twin-plane-all-dimg-offdso.v ${RESDIR}/twin-perm-dimg-offdso.v > $@

${RESDIR}/twin-dslw-offdso-all.v: ${RESDIR}/twin-dslw.v ${RESDIR}/twin-dslw-offdso.v ${RESDIR}/twin-plane-all-dslw-offdso.v ${RESDIR}/twin-perm-dslw-offdso.v
	vp_OverUnderAniso ${RESDIR}/twin-dslw.v ${RESDIR}/twin-dslw-offdso.v ${RESDIR}/twin-plane-all-dslw-offdso.v ${RESDIR}/twin-perm-dslw-offdso.v > $@



${RESDIR}/%.pdf:${RESDIR}/%.v
	pstexpen $< ${RESDIR}/$*.ps color=y fat=1 fatmult=1.5 invras=n force=  invras=y
	epstopdf ${RESDIR}/$*.ps --outfile=$@


sepwindow.o:
	icc ${SRCDIR}/sepwindow/sepwindow.c -c -o $@

clean:
	rm -f *.mod *.o .make.dependencies.* ${BINDIR}/*.x

clean-data:
	rm -f *.H

include ${SEPINC}/SEP.bottom
